• Skip to main content
  • Skip to header right navigation
  • Skip to site footer
CDP Studio logo

CDP Studio

The no-code and full-code software development tool for distributed control systems and HMI

  • Doc
  • Why CDP
    • Software developers
    • Automation engineers
    • Managers
  • Products
    • Automation Designer
    • HMI Designer
    • Maritime HMIs
  • Services
  • Use cases
  • Pricing
  • Try CDP

CDP Studio Documentation

  • Framework - Data Logging
  • LogWriter
  • 5.0.0

ValueLogReader LogServer

LogWriter

Introduction

A Sequencer block for logging data with a message-based API. Compatible with the same Datastores as CDPLogger.

Glossary

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.

Usage

To set up a LogWriter, add it to a component. Next, select and add a Datastore (e.g. CDPCompactDatastore) into the LogWriter.

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 following is a block diagram of the typical usage of the LogWriter block. See below for instructions on how to replicate the example.

Tips

  • 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.

Configuration

See below for a list of configuration options specific to this block.

Datastore

Datastore is the backend used by LogWriter, usually some database. The default is CDPCompactDatastore.

For more information about datastores, see the Choosing a Datastore page.

Message Events

NameTypeDescription
InitInputReinitializes the LogWriter block. Flushes any internal buffers and recreates the datastore connection. Will emit Inited when done.
InitedOutputWill be emitted after Init is done.
WriteValueInputA 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.

WriteValueDoneOutputWill be emitted after WriteValue is done.
WriteValueDefinitionInputWrites 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.
WriteValueDefDoneOutputWill be emitted after WriteValueDefinition is done.
WriteEventInputA 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.

WriteEventDoneOutputWill be emitted after WriteEvent is done.
WriteEventDefinitionInputWrites 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.

WriteEventDefDoneOutputWill be emitted after WriteEventDefinition is done.
FlushInputFlushes internal buffers and commits data to the datastore. Will emit FlushDone or Error when done.
FlushDoneOutputWill be emitted after Flush is done.
ErrorOutputFailure when writing data described by ErrorMsg.

Writing Tags

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.

NameTypeDescription
TriggerAutoFlushInputCalled automatically after AutoFlushTimeout to flush internal buffers and commit data to datastore. Will emit AutoFlushDone or Error when done.
AutoFlushDoneOutputWill be emitted after TriggerAutoFlush is done.

Arguments

NameTypeDescription
TimestampInputUnix timestamp of a value change or CDP event. The unit is specified by the TimeUnit attribute.
ValueInputThe value change of a single node.
ValueTypeInputThe 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".
PathInputThe path (full Routing) to a node that emitted the value change or generated the CDP event.
TagsInputSemicolon-separated tagname=value list of all tags associated with a Path.
TagSourcesInputRelated 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.
IdInputSystem unique eventId (CDP eventId + application handle). Note: for CDP events it is unique only until the application restarts.
CodeInputCDP event code flags. See below for details.
StatusInputNew status of the object that caused the CDP event after the CDP event occurred. For alarms see the Alarm Status Defines in CDPAlarm documentation.
TextInputOptional text sent with the CDP event.
LevelInputOptional level data (for example sent with CDP alarm events).
DescInputOptional description sent with the CDP event. Describes the node that emitted the CDP event.
EventDataInputSemicolon-separated Name=Value pairs containing other optional data sent with the CDP event.
ErrorMsgOutputThe 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):

NameCodeDescription
AlarmSet0x1The alarm's Set flag/state was set. The alarm changed state to "Unack-Set" (The Unack flag was set if not already set).
AlarmClr0x2The alarm's Set flag was cleared. The Unack state is unchanged.
AlarmAck0x4The alarm changed state from "Unacknowledged" to "Acknowledged". The Set state is unchanged.
AlarmReprise0x40A repetition/update of an event that has been reported before. Courtesy of late subscribers.
SourceObjectUnavailable0x100The provider of the event has become unavailable (disconnected or similar).
NodeBoot0x40000000The provider reports that the CDPEventNode has just booted.

Properties

NameDescription
AutoFlushTimeoutWhen non-zero, after a specified number of seconds has passed from the last write, flushes any internal buffers and commits data to the datastore.
DebugThe debug level. Increase it to see more printouts.
LogFrequencyHintUsed by some datastores to optimize storage format. Should be set equal to the average sampling frequency of logged values.
DatastoreSizeCurrent Datastore size in GB.
TimeUnitUnit 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.

Examples

Here are some examples of using the LogWriter.

Logging CDPEventListener Events

Here is a minimal example using the LogWriter. The example uses a CDPEventListener and writes every CDP event it emits to a CSV file.

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.

Other Examples

See also some other examples containing the LogWriter:

  • ValueLogReader and LogWriter - extract logged values from a CDP Logger datastore and write them to a new datastore.
  • EventLogReader and LogWriter - extract logged events from a CDP Logger datastore and write them to a new datastore.

ValueLogReader LogServer

The content of this document is confidential information not to be published without the consent of CDP Technologies AS.

CDP Technologies AS, www.cdpstudio.com

Get started with CDP Studio today

Let us help you take your great ideas and turn them into the products your customer will love.

Try CDP Studio for free
Why CDP Studio?

CDP Technologies AS
Hundsværgata 8,
P.O. Box 144
6001 Ålesund, Norway

Tel: +47 990 80 900
E-mail: info@cdptech.com

Company

About CDP

Contact us

Services

Partners

Blog

Developers

Get started

User manuals

Support

Document download

Release notes

My account

Follow CDP

  • LinkedIn
  • YouTube
  • GitHub

© Copyright 2025 CDP Technologies. Privacy and cookie policy.

Return to top