op_ev_src_id()
Abstract
Obtains the object ID of the node, link, or module that was the source of the specified event.
Syntax
op_ev_src_id (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()—and others such as op_intrpt_schedule_self().]. |
Return Type
Objid
Object ID of the module that is the source of the specified event.
This value may be the object ID of a node, link, processor, queue, transmitter, or receiver; for events that do not have objects as sources, or if an error occurs, the constant OPC_OBJID_INVALID is returned.
Example
/* Count the remote interrupts this module scheduled */
/* by looping through all of events and verifying if */
/* each is remote and from this module. */
ri_count = 0;
num_events = op_ev_count ();
next_event = op_ev_current ();
for (i = 0; i<num_events; i++)
{
if ((op_ev_type (next_event) == OPC_INTRPT_REMOTE) &&
(op_ev_src_id (next_event) == my_id))
{
ri_count++;
}
next_event = op_ev_next (next_event);
}
Details
This KP returns IDs for actual objects when invoked for most events. However, for the following interrupt types, it returns the constant OPC_OBJID_KERNEL:
- begin simulation interrupt
- end simulation interrupt
- regular interrupt
Interrupts that are caused by a module source include:
- statistic interrupt
- stream interrupt
- self interrupt
- remote interrupt
- access interrupt
- procedure interrupt
- multicast interrupt
Failure and recovery interrupts are caused by network-domain source objects (links or node object IDs are returned).
Purpose
Provides a mechanism for determining the source object of an event. From this object ID more detailed information can be obtained, such as the object’s type and attribute values. A typical use might be for a process that multiplexes packets from multiple sources to learn which source is connected via which input stream; i.e., whenever a packet is received over an input stream, the process can determine the object ID of the stream source by calling op_ev_src_id().
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.
Reference
- Use the KP op_ev_valid() to determine if the Evhandle is valid
- Use the KP op_ev_dst_id() to determine the destination object ID of the event
- Use the KP op_ev_type() to determine the type of the event
- Use the KP op_ev_time() to determine the scheduled time of the event