op_stat_write()

Abstract

Writes a (time,value) pair to the specified statistic. The value is specified as an argument to this KP and the time is the current simulation time.

Syntax

op_stat_write (stat_handle, value)
Argument Type Description
stat_handle Stathandle Statistic handle identifying the global or local statistic to receive an updated value [A statistic handle can be obtained via the KP op_stat_reg().]
value double Value to write to the specified statistic.

Return Type

void

No return value.

Example

/* obtain the arriving packet */
pkptr = op_pk_get (INPUT_STRM);

/* determine the bulk size of the packet */
bulk_size = op_pk_bulk_size_get (pkptr);

/* If the statistic handle for received packet size has not yet */
/* been initialized, do so now. */
if (pk_size_init == OPC_FALSE)
	{
	pk_size_shandle = op_stat_reg ("Packet Size (bits)", OPC_STAT_INDEX_NONE,
		OPC_STAT_GLOBAL);
	pk_size_init = OPC_TRUE;
	}

/* write out the bulk size of the packet as a global statistic */
op_stat_write (pk_size_shandle, (double) bulk_size);

/* destroy the now useless packet */
op_pk_destroy (pkptr);

Details

This KP appends a new (time, value) pair to an output vector for the specified statistic. Statistics can only be referenced by variables of the type Stathandle that have been initialized by calling the KP op_stat_reg(). Calling this KP with an improperly initialized handle can result in a recoverable simulation error.

Different processes throughout a simulation model can write values to the same output vector through this KP if they use the same statistic handle. The KP op_stat_reg() uses the statistic name that is passed to it to “rendezvous” with other sources of the same statistic; this enables multiplexing of data into a single output vector.

Multiple calls to op_stat_write() at the same simulation time are recorded in sequence; they do not overwrite each other.

To generate data in an output vector file, statistics must be probed using a probe object that was defined in the Probe Editor or selected through the Select statistics operation in the Project Editor. The name of the probe file that contains the probe is specified by the probe attribute of a simulation. To record all global statistics, set the record_gstats attribute of a simulation.

If the capture mode is one that divides by time and the statistic is valid over a specified time period, you must indicate to the system when the period ends. You do this by writing a zero to the statistic with op_stat_write() at the end of this period.

Purpose

Contributes a new value to an output vector, tagged with the current simulation time.

If the Stathandle refers to a local statistic with a statistic wire connected and the triggering conditions of the wire are met, an interrupt is scheduled for the destination module of the statistic wire.

Errors

  • Program Abort: Segmentation violation. (due to an invalid statistic handle)
  • Recoverable Error: Attempting use of unregistered statistic handle.

Reference

本站文档由 北京智网畅联科技有限公司 整理、翻译并提供 · Documentation compiled and provided by Beijing ZNetLink Technology Co., Ltd.

交流群 · QQ Group:OPNET/智网妙算网络仿真交流群(群号 486383494)

原文档 © 2017 Riverbed Technology · 本站为公益翻译,由 AI 辅助完成,请仔细甄别

Original documentation © 2017 Riverbed Technology. Community translation, AI-assisted. Contact: jiazequn@znetlink.com