op_ev_strm()
Abstract
Obtains the stream index associated with the specified event.
Syntax
op_ev_strm (evhandle)
| Argument | Type | Description |
|---|---|---|
evhandle |
Evhandle |
event handle that identifies the event [An event handle can be obtained from several KPs in this package, such as op_ev_current(), op_ev_seek_time(), and op_ev_next().]. |
Return Type
int
Stream index associated with the specified event.
This value is set by the Simulation Kernel when a packet arrives at an input stream due to transmission via one of the op_pk_deliver… or op_pk_send… KPs. OPC_STRM_INVALID is returned when a recoverable error occurs.
Example
/* Obtain the currently executing event */
this_event = op_ev_current ();
/* If it is a packet arrival, get the packet and store it for later forwarding. */
/* If it is a self interrupt, send the packet on. */
if (op_ev_type (this_event) == OPC_INTRPT_STRM)
{
pkptr = op_pk_get (op_ev_strm (this_event));
op_intrpt_schedule_self (op_sim_time () + forwarding_delay, 0);
}
else if (op_ev_type (this_event) == OPC_INTRPT_SELF)
op_pk_send (pkptr, 0);
Details
This KP will only produce a valid result when applied to an event that is associated with a stream. The two types of events that are associated with streams are stream interrupts and access interrupts. In the former case, the stream associated with the event will be an input stream on which a packet has arrived. In the latter case, the stream associated with the event will be an output stream that is being accessed by the module to which it is connected. Note that op_ev_strm (op_ev_current ()) is equivalent to op_intrpt_strm().
Purpose
For stream interrupts, this KP provides the important service of determining which input stream a packet is arriving on (this information is needed to identify the stream to extract a packet via op_pk_get()). For access interrupts, this KP determines which output stream is being accessed by a connected processor or queue.
Errors
- Program Abort: Segmentation violation. (due to a malformed event handle)
- Recoverable Error: Event handle refers to an event that is either invalid or not currently scheduled.
- Recoverable Error: Event is not packet-stream related.
Reference
- Use the KP op_ev_valid() to determine if the Evhandle is valid
- Use the KP op_ev_type() to determine the type of the event
- Use the KP op_ev_code() to determine the code of a self, remote, or multicast interrupt
- Use the KP op_ev_stat() to determine the input statistic index associated with a statistic interrupt
- Use the KP op_ev_time() to determine the scheduled time of the event
- Use the KP op_ev_ici() to obtain the ICI associated with the event