op_ev_state_install()
Abstract
Installs an event state to be associated with all events created in the same thread.
Syntax
op_ev_state_install (client_state_ptr, state_print_proc)
| Argument | Type | Description |
|---|---|---|
client_state_ptr |
void* |
Event state data structure to be installed. Use OPC_NIL to remove a previously installed event state. |
state_print_proc |
SimT_Ev_State_Print_Meth |
Callback used to print the event state, or OPC_NIL if none. (Used only when ODB is enabled.) |
Return Type
void *
Previously installed state, or OPC_NIL if none.
Example
void
my_data_print (const void * ev_state_ptr, PrgT_List * dest_lptr)
{
const My_Model_Data * data_ptr = (const My_Model_Data *)ev_state_ptr;
/* Generate text strings based on value of state pointer */
/* and append to 'dest_lptr' */
}
. . .
My_Model_Data * data_ptr;
data_ptr = allocate_and_set_model_data ();
/* Associate model data with the packet arrival interrupt */
op_ev_state_install (data_ptr, my_data_print);
op_pk_send (pk_ptr, 0);
op_ev_state_install (OPC_NIL, OPC_NIL);
Details
After the event state is installed, it will be associated with all events created thereafter. To stop associating the event state with events, call the function again with a null pointer.
Because the Simulation Kernel knows nothing about the content of an event state, you must be sure that client_state_ptr has the appropriate data type.
The state_print_proc is called when the event state is printed using evprint in ODB. This callback must have the following prototype:
typedef void
(*SimT_Ev_State_Print_Meth) (void *state_ptr, PrgT_List *dump_lptr);
The state_print_proc must add new entries to *dump_lptr. The state information is passed in *state_ptr. Use prg_mem_alloc() to allocate strings for addition to the list. The Simulation Kernel automatically deallocates all memory.
Purpose
This function installs event state information to be associated with events. Event state information provides a faster way of passing custom information with events than ICIs. For details, see “Communicating with Event States“ on page 355 of the Modeling Concepts manual.
Errors
- None.
Reference
- Use the KP op_ev_state() to get the event state associated with an event