SIMulation Workbench Documentation SIMulation Workbench Documentation

Asynchronous RTDB access API
[SimWB RT functions]

Collaboration diagram for Asynchronous RTDB access API:

Functions

int ccurAsynQ_asyncInputQueueMap (int init)
int ccurAsynQ_asyncInputQPut (AsyncQElement *e, int nElements, void *str, int length)
void ccurAsynQ_freeBuf (AsyncQElement *e)
int ccurAsynQ_asyncInputQGet (AsyncQElement *e, int *nElements, void *str, int *len)
int ccurAsynQ_getQNumberOfEntries (void)
int ccurAsynQ_setRTDBItemValue (RTDBItem *pItem, double value, unsigned char rtFlags, unsigned long long stamp)

Detailed Description

This API is used by asynchronous processes to update the value of RTDB items. Asynchronous processes should not update the RTDB directly via calls to ccurRTDB_setCVTValue or ccurRTDB_setAlternateValue because it will violate the principle of RTDB coherence. I.e. a model that uses the value of an RTDB item might see 2 different values if the value is updated directly outside of the synchronous frame run while the model is running.
The queue is processed by the scheduling process in parallel with the execution of the first synchronous sub-cycle (input processes).
The queue is processed for a finite amount of time defined in micro seconds when starting the session. The default processing time is 20 micro seconds which can be changed at test startup time.


Function Documentation

int ccurAsynQ_asyncInputQueueMap ( int  init  ) 

Map the asynchronous update queue within the calling process.
This routine must be called by processes that want to use ccurAsynQ_asyncInputQPut.

Parameters:
init Integer set to != 0 when the queue is to be initialized.
Only the scheduler calls this routine with init != 0.
Returns:
0 If the call is successful.
Return values:
-1 Any of the system calls (shm_open, mmap) failed.
int ccurAsynQ_asyncInputQPut ( AsyncQElement *  e,
int  nElements,
void *  str,
int  length 
)

Put an AsyncQElement element in the queue. The element must be initialized correctly with the item hash index which is used by the asynchronous update routine to update the correct item.

Parameters:
e Pointer to an array of AsyncQElement containing the values to put in the queue.
nElements The number of elements in the array.
str Pointer to the string value when the item to be updated is a string item. Pass NULL for non string item.
length Integer with the length in bytes of the string variable
Return values:
0 If the call is successful.
< 0 RTDB_ASYNCQFULL if the queue is full.
void ccurAsynQ_freeBuf ( AsyncQElement *  e  ) 

Free a buffer entry allocated by the QPut call This routine is only used by the SimWB scheduler and must not be used in user programs.

int ccurAsynQ_asyncInputQGet ( AsyncQElement *  e,
int *  nElements,
void *  str,
int *  len 
)

Get the oldest AsyncQElement element cwfrom the asynchronous queue.
Only the asynchronous queue processing routine uses this routine.

Return values:
0 The queue is empty.
1 The element is a normal scalar element.
2 If the element is a string variable.
int ccurAsynQ_getQNumberOfEntries ( void   ) 

Returns the number of elements still to be processed in the asynchronous IO queue.

Return values:
The number of elements pending in the queue.
int ccurAsynQ_setRTDBItemValue ( RTDBItem pItem,
double  value,
unsigned char  rtFlags,
unsigned long long  stamp 
)

Set the value of the RTDB item via the asynchronous queue.
Asynchronous processes should use this call to update the RTDB. This call will map the queue into the user process via ccurAsynQ_asyncInputQueueMap if it has not been mapped yet.

Parameters:
pItem Pointer to the RTDBItem which is to be updated.
value double with the value for the item.
rtFlags unsigned char with the run time flags corresponding to the item. Only RTDBFL_OUTOFEURANGE and RTDBFL_OUTOFHARDWARERANGE can be updated via this call.
stamp unsigned long long with TSC time stamp corresponding to when the data value was acquired. Pass 0 into this value for the call to use its stamp at the time of this call
Return values:
0 The call is successful.
< 0 RTDB_POINTNOTFOUND if pItem is NULL.
< 0 RTDB_ASYNCQFULL if the queue is full.