op_stat_local_read()
Abstract
Reads the current value from an input statistic of the surrounding processor or queue.
Syntax
op_stat_local_read (instat_index)
| Argument | Type | Description |
|---|---|---|
instat_index |
int |
numeric index of the input statistic-of-interest [Input statistic indices are restricted to the range 0 to 99.] |
Return Type
double
Current value of the specified input statistic. The constant OPC_DBL_INVALID is returned if a recoverable error occurs.
Example
Excerpt from: example model (models/std/eth_net); process model (eth_mac); header block.
/*** mnemonic macros for transitions and executives ***/
#define DEFERENCE_ON (op_stat_local_read (DEFERENCE_INSTAT) == 1.0)
#define DEFERENCE_OFF (op_stat_local_read (DEFERENCE_INSTAT) == 0.0)
#define DEFERENCE_LOW (op_intrpt_type () == OPC_INTRPT_STAT && \
op_intrpt_stat () == DEFERENCE_INSTAT && \
DEFERENCE_OFF)
#define COLL_DET_HIGH (op_intrpt_type () == OPC_INTRPT_STAT && \
op_intrpt_stat () == TRANSMITTING_INSTAT && \
op_stat_local_read (TRANSMITTING_INSTAT) == 0.0)
Details
This KP can read an input statistic anytime; it returns the last value that was written to a connected statistic wire. If no statistic wire is connected to the specified input statistic or if the input statistic index is out-of-range, an error occurs and the constant OPC_DBL_INVALID is returned.
Purpose
Provides a mechanism to obtain the value of an input statistic, which is the value of another module’s output statistic, conveyed through a connecting statistic wire. This KP can be used in two modes:
- The surrounding module is interrupted due to a statistic wire interrupt that indicates a relevant change on the wire, and the process reads the input statistic to determine the updated value.
- The surrounding module independently determines that it needs to sample the value of a statistic wire, so as to use the value in a computation.
Errors
- Program Abort: KP requires process context.
- Recoverable Error: Local statistic index (
<stat_index>) is out-of-range. - Recoverable Error: Module has no connected statistic inputs.
- Recoverable Error: Input statistic index (
<stat_index>) is unoccupied.
Reference
- Use the KP op_stat_write() to write a value to an output statistic, tagged with the current simulation time
- Use the KP op_stat_write_t() to write a value to an output statistic, tagged with a specified simulation time
- Use the KP op_stat_scalar_write() to write a value to a scalar statistic