2.6 EVENT SYSTEM
2.6.1 Purpose
The Event system of CCS provides the facility to register for notification of event to an attribute of a database point. This enables a process to be informed when a database value is written to the registered attribute.
Event notification is done via a specific message type sent to the process that registered the event.
A specialized message parsing function has to be used to retrieve the different parts of the notification message.
2.6.2 Basic Concepts
The CCS Event system is based upon the database event notification of RTAP, fully emulated under CCS_LITE and LCC.
An event can be attached to a database attribute of type: SCALAR, VECTOR or TABLE. On attributes of type SCALAR the occurrence of event's can be filtered in order to trigger only on specific values e.g. rising (evtGREATER) or falling (evtLESS) values. Filtering does not apply to attributes of type: VECTOR and TABLE.
On WS whre the concept of database attribute quality exists, a new type of event has been introduced with the JAN2006 release: it is now also possible to request event notification on a change of quality.
Upon successful event attachment an Id is returned that is used as a reference to event related calls.
When a new database value is written a CCS message of type msgTYPE_EVENT is sent to the process that attached an event to that attribute, whenever the filter is matched.
The message received upon occurrence of a database event contains the following information:
A function is provided to parse and strip of the necessary event information.
The attribute information on SCALAR attribute includes the value as well as the quality before and after the write. On attributes of type VECTOR and TABLE the range of elements written is returned, so that only that specific part of the vector or the table can be read.
Notification of events can be disabled and re-enabled, which can be used for temporary stop of event notification. For a permanent stop of event notification the event must be detached. After an event attach the event is automatically enabled.
Attachment of attributes in a remote environment database is possible. The following configurations are supported:
Attachment from FULL CCS to events occurring in remote environments of type FULL CCS & LCU
Attachment from CCS_LITE to events occuring in remote environments of type FULL CCS, CCS_LITE, LCU
The same process can attach the same attribute several times (up to 64 times) but this implies that several event notification messages will be received.
An extended event attach function, available only on Workstations, allows the user to specify some additional information to be appended to the event notification message and to indicate a process different from the caller as destination for the notification message.
2.6.3 Examples
void main (int argc, char ** argv)
vltUINT8 oldQuality,newQuality;
if (ccsInit(argv[0],0,NULL,NULL,&error) != SUCCESS)
strcpy(dbAttribute,":MYBRANCH:MYPOINT.myattribute");
if ( evtAttach(dbAttribute,evtANY_WRITE,&eventId,&error) == FAILURE)
* After this point a message arrives when there is written
* to ":MYBRANCH:MYPOINT.myattribute".
if (msgSetFilter(NULL, NULL, msgANY_MESSAGE, 0,
"", &msgFilter, &error) == FAILURE)
if (msgRecvMsg(&msgFilter,msgNO_TIMEOUT, &message, &error) != SUCCESS)
if (message->msgType == msgTYPE_EVENT)
if (evtParseMsg( message, &event, &trigger, &triggerProc,
dbAttribute, &attrType, &eventInfo,NULL,
case dbSCALAR: /* Get information on a scalar attribute */
dataType = eventInfo.scalar.dataType;
oldQuality = eventInfo.scalar.oldQuality;
newQuality = eventInfo.scalar.newQuality;
dbMemCpy((char *)&oldValue,eventInfo.scalar.oldValue,dbINT16);
dbMemCpy((char *)&newValue,eventInfo.scalar.newValue,dbINT16);
case dbVECTOR: /* Get information on a vector attribute */
startElem = eventInfo.vector.startElem;
endElem = eventInfo.vector.endElem;
case dbTABLE: /* Get information on a table attribute */
startElem = eventInfo.table.startElem;
endElem = eventInfo.table.endElem;
startField = eventInfo.table.startField;
endField = eventInfo.table.endField;
2.6.4 Reference
Quadralay Corporation http://www.webworks.com Voice: (512) 719-3399 Fax: (512) 719-3606 sales@webworks.com |