TagEventQueue
Opens the tag update event queue. The I/O server writes events into this queue as they are processed. These events include tag updates from drivers that support time-stamped data.
To read events from this queue, use the QueRead() or QuePeek() functions. The data put into the queue contains the following fields:
To use this function, you need to enable the tag update event queue with the [IOServer]EnableEventQueue parameter. This parameter will tell the I/O Server to start placing events into the queue. The function TagEventFormat() returns a handle to the format of the data placed into the string field.
Enabling this formatting feature can increase CPU loading and reduce performance of the I/O Server as every tag update event is formatted and placed in the queue. You should reconsider using this feature if a decrease in performance is noticeable.
The maximum length of each queue is controlled by the [Code]Queue parameter. You may need to adjust this parameter so as not to miss alarm events. When the queue is full, the I/O Server will discard events.
Syntax
TagEventQueue()
Parameters - None
Return Value
The queue handle of the Tag Update Event queue.
Related Functions
QuePeek, QueRead, TagEventFormat
Example
FUNCTION
ReadEvents()
INT status;
INT queue;
INT format;
INT eventId;
STRING event;
INT sec;
INT ms;
TIMESTAMP time;
queue = TagEventQueue();
format = TagEventFormat();
IF (queue <> -1 AND format <> -1) THEN
WHILE (true) DO
status = QueRead(queue, eventId, event, 1);
IF status = 0 THEN
ErrLog("eventId: " + IntToStr(eventId));
StrToFmt(format, event);
ErrLog(" driver: " + FmtGetField(format, "Driver"));
ErrLog(" port: " + FmtGetField(format, "Port"));
ErrLog(" unit: " + FmtGetField(format, "Unit"));
ErrLog(" tag: " + FmtGetField(format, "Tag"));
sec = FmtGetField(format, "Seconds");
ms = FmtGetField(format, "Milliseconds");
time = TimeIntToTimestamp(sec, ms, 1);
ErrLog(" time: " + TimestampToStr(time,14));
ErrLog(" value: " + FmtGetField(format, "Value"));
ErrLog(" quality: " + FmtGetField(format, "Quality"));
END
END
END
END
See Also