op_stat_scalar_write_symbol()
Abstract
Writes a symbolic value to a scalar statistic.
Syntax
op_stat_scalar_write_symbol (stat_name, str_value, value)
| Argument | Type | Description |
|---|---|---|
stat_name |
const char * |
name of the scalar statistic-of-interest |
str_value |
const char * |
symbolic value to write |
value |
double |
associated numeric value to write (optional; if none, set to OPC_NA_DBL_UNSPEC) |
Return Type
void
No return value.
Example
/* At end of simulation, scalar performance statistics */
/* and input parameters are written out. */
/* Only one station needs to do this */
if (!fddi_sink_scalar_write)
{
/* set the scalar write flag */
fddi_sink_scalar_write = 1;
ete_delay = fddi_sink_accum_delay / fddi_sink_total_pkts;
if (ete_delay >= 10)
op_stat_scalar_write_symbol ("Mean End-to-End Delay", “Critical”, 3.0);
else if (ete_delay >= 5)
op_stat_scalar_write_symbol ("Mean End-to-End Delay", “Marginal”, 2.0);
else
op_stat_scalar_write_symbol ("Mean End-to-End Delay", “Acceptable”, 1.0);
op_stat_scalar_write ("Throughput (bits/sec)",
fddi_sink_total_bits / op_sim_time ());
op_stat_scalar_write ("Peak End-to-End Delay (sec.)", fddi_sink_peak_delay);
op_stat_scalar_write ("TTRT (sec.)", Fddi_T_Opr);
}
Details
Scalar statistics can be written anytime during simulation. Multiple invocations of this KP create multiple values for the same scalar statistic; when these types of statistics are plotted, they produce plots with multiple ordinate values for a common abscissa value.
Scalar statistic values are recorded in the output vector file specified by the ov_file preference of a simulation. Unlike vector data, scalar data is not written unless a vector output file name is specified. In other words, the default behavior of a simulation is to not record any scalar data, even if calls to op_stat_scalar_write_symbol() are executed.
Purpose
Provides a mechanism to write a user-defined symbolic value (and, optionally, an associated numeric value) as the specified scalar statistic. The written value is stored in the vector output file of the simulation. Scalar statistics are used to capture time-independent, summary values, such as average values, final values, or maximum values of time-varying state quantities.
Errors
- Program Abort: Segmentation violation. (due to an invalid scalar statistic name string)
- Recoverable Error: Allocation of memory failed.
Reference
- Use the KP op_stat_local_read() to read the current value of an input statistic
- Use the KP op_stat_scalar_write() to write a numeric value to a scalar statistic
- Use the KP op_stat_write() to write a value to an output statistic that is tagged with the current simulation time
- Use the KP op_stat_write_t() to write a value to an output statistic that is tagged with a specified simulation time