A Sequencer block for logging data with a message-based API. Compatible with the same Datastores as CDPLogger.
This documentation refers to two kinds of events:
- CDP events - CDPEventManager events. For example, CDPAlarm Set, Clear and Acknowledge events. These are the events that are logged by CDP Logger, LogWriter and read by EventLogReader.
- Message events - the event inputs and outputs of sequencer blocks as defined by the IEC 61499 standard. In this document, also referred as event messages or just messages.
To write values, first send the WriteValueDefinition message to write the tags associated with the node providing values. Then send the WriteValue message to write the values. The WriteValue message event can be called multiple times for the same node. Finally, call the Flush message event to flush any internal buffers and commit the data to the datastore or wait until the AutoFlush triggers.
CDP events can be written in a similar way. First, call the WriteEventDefinition message to write the tags associated with the node emitting the CDP events. Then call the WriteEvent message to write an CDP event. As with values, either call Flush manually to make sure the data is committed to the datastore or wait until the AutoFlushTimeout triggers.
- The LogWriter value inputs match the ValueLogReader outputs. This means that the LogWriter can be connected directly to the ValueLogReader and be used to extract either all or a subset of the logged data to a new datastore.
- Similarly, the LogWriter CDP event inputs match the EventLogReader outputs, so it can be used to extract CDP event data to a new datastore.
- The LogWriter CDP event inputs also match the CDPEventListener outputs. This can be used to log CDP events from a CDPEventListener to a datastore.
See below for a list of configuration options specific to this block.
For more information about datastores, see the Choosing a Datastore page.
|Reinitializes the LogWriter block. Flushes any internal buffers and recreates the datastore connection. Will emit Inited when done.
|Will be emitted after Init is done.
|A single value change. The arguments must include Timestamp, Value, ValueType and Path. Optionally Tags and TagSources can be included to describe the tags associated with the value - in that case it is not necessary to call WriteValueDefinition before this message event. Will emit WriteValueDone or Error when done.
Note: The WriteValue message event only writes tags and tag sources when encountering a Path for the first time. If the same Path is encountered again, the Tags and TagSources are not updated to prevent unintentional clearing of existing metadata. Use the WriteValueDefinition message event to replace existing tags and tag sources for a Path.
|Will be emitted after WriteValue is done.
|Writes logged node path and any associated tags. The arguments must include Path and Tags. Optionally TagSources can be included to describe the path where the tag information was fetched from. This message event should be called before WriteValue because some Datastores use the tags to optimize storage format. Will emit WriteValueDefDone or Error when done. If this message event is called multiple times for the same Path, the existing tags and tag sources are replaced.
|Will be emitted after WriteValueDefinition is done.
|A single CDP event. The arguments must include Timestamp and Path, optionally also other CDP event data: Id, Code, Status, Text, Level, Desc and EventData. In addition, Tags and TagSources can be included to describe the tags associated with the CDP event sender - in that case, it is not necessary to call WriteEventDefinition before calling this. Will emit WriteEventDone or Error when done.
Note: The WriteEvent message event only writes tags and tag sources when encountering a Path for the first time. If the same Path is encountered again, the Tags and TagSources are not updated to prevent unintentional clearing of existing metadata. Use the WriteEventDefinition message event to replace existing tags and tag sources for a Path.
|Will be emitted after WriteEvent is done.
|Writes the tags associated with the CDP event sender. The arguments must include Path and Tags. Optionally TagSources can be included to describe the path where the tag information was fetched from. This message event should be called before WriteEvent because some Datastores use the tags to optimize storage format. Will emit WriteEventDefDone or Error when done.
If this message event is called multiple times for the same Path, the existing tags and tag sources are replaced.
|Will be emitted after WriteEventDefinition is done.
|Flushes internal buffers and commits data to the datastore. Will emit FlushDone or Error when done.
|Will be emitted after Flush is done.
|Failure when writing data described by ErrorMsg.
The tags associated with a node can be written in two ways:
- Semicolon-separated tagname=value list in the Tags argument.
- Add each tag as a separate input argument with the tag name as the argument name and the tag value as the argument value. Note each user-added argument must be listed in the Data property of the message event.
This affects the WriteValue, WriteValueDefinition, WriteEvent and WriteEventDefinition message events.
Internal Message Events
When disabling the Hide Internal Items filter, some additional message events become visible. It is normally not necessary to access them.
|Called automatically after AutoFlushTimeout to flush internal buffers and commit data to datastore. Will emit AutoFlushDone or Error when done.
|Will be emitted after TriggerAutoFlush is done.
|Unix timestamp of a value change or CDP event. The unit is specified by the TimeUnit attribute.
|The value change of a single node.
|The value type of a value change. Valid values are "undefined", "double", "uint64_t", "int64_t", "float", "unsigned int", "int", "unsigned short", "short", "unsigned char", "char", "bool" and "string".
|The path (full Routing) to a node that emitted the value change or generated the CDP event.
|Semicolon-separated tagname=value list of all tags associated with a Path.
|Related to the Tags argument. Allows to optionally describe the path where the tag information was fetched from. The format is a semicolon-separated tagname=source list.
|System unique eventId (CDP eventId + application handle). Note: for CDP events it is unique only until the application restarts.
|CDP event code flags. See below for details.
|New status of the object that caused the CDP event after the CDP event occurred. For alarms see the Alarm Status Defines in CDPAlarm documentation.
|Optional text sent with the CDP event.
|Optional level data (for example sent with CDP alarm events).
|Optional description sent with the CDP event. Describes the node that emitted the CDP event.
|Semicolon-separated Name=Value pairs containing other optional data sent with the CDP event.
|The error message emitted when a request fails.
CDP Event Code Flags
Common event codes used in the CDP framework (note multiple flags can be set at the same time)): Common event codes used in the CDP framework (note that multiple flags can be set at the same time):
|The alarm's Set flag/state was set. The alarm changed state to "Unack-Set" (The Unack flag was set if not already set).
|The alarm's Set flag was cleared. The Unack state is unchanged.
|The alarm changed state from "Unacknowledged" to "Acknowledged". The Set state is unchanged.
|A repetition/update of an event that has been reported before. Courtesy of late subscribers.
|The provider of the event has become unavailable (disconnected or similar).
|The provider reports that the CDPEventNode has just booted.
|When non-zero, after a specified number of seconds has passed from the last write, flushes any internal buffers and commits data to the datastore.
|The debug level. Increase it to see more printouts.
|Used by some datastores to optimize storage format. Should be set equal to the average sampling frequency of logged values.
|Current Datastore size in GB.
|Unit of the Timestamp argument. Can be set to Second, Millisecond, Microsecond or Nanosecond since epoch (Unix timestamp).
Accessing the Data
The data is written to the selected Datastore. Depending on the Datastore, the data can be accessed in different ways. For example, the CSVDatastore writes the data to a CSV file, which can be opened in a spreadsheet application. To access the written data with CDP tools, add a LogServer component and copy the Datastore configuration from the LogWriter. The LogServer component will then serve the data in the same way as the built-in server of CDP Logger.
There are several options to view logged data through the log server:
- Using CDP Studio Analyze mode Historic Data functionality which will detect a running CDP Logger or LogServer and connect to it. The Analyze mode can also be used to export the logged data to CSV format.
- Making your own GUI application that includes Database Graph Widget.
- Python code can query values from a running CDP Logger or LogServer using the PythonCDPLoggerClient.
- The ValueLogReader and EventLogReader sequencer blocks can be used to extract and process logged data.
The selected Datastore might provide other custom ways to view logged data. See the manual for the selected datastore to get specific information on that.
Note: CDP does not currently provide any widgets for browsing logged event data (e.g. CDPAlarm Set, Clear and Acknowledge events). Datastore-specific third-party tools must be used. If necessary, use the EventLogReader sequencer block and connect it to a LogWriter block to export event data to a different datastore, for example to CSV - see the example here.
Here are some examples of using the LogWriter.
Logging CDPEventListener Events
To run the example, just start the application. The extracted values will be written to a
"log-events.csv" file in the application's working directory.
Here is how to replicate the example:
- Create a system.
- From the Resource tree, add
- Sequencer.CDPEventListener - a block that listens to all CDP events in the system and emits an event message for each CDP event. In this minimal example, we have not set any filters, so the block will emit all CDP events.
- CDPLogger.LogWriter - writes the received event messages to a new Datastore (CSVDatastore in this example).
- Add a CDPLogger.CSVDatastore into the LogWriter block to store extracted CDP events in a CSV file.
- Connect the blocks as shown in the image above.
See also some other examples containing the LogWriter: