• 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

  • CDPEventManager Introduction
  • Framework - CDPEventManager

Framework - CDPEventManager

CDPEventManager Introduction

The CDPEventManager library, an internal part of the CDP Core Framework, provides a system for collecting and distributing events. It can be configured to collect and forward events to subscribing CDP applications.

Most CDP Applications are already pre-configured with 2 CDPEventManager components: CDPEventNode and CDPEventSubscriber. The CDPEventNode will log events from it's local application, and send them to subscribers. An application's CDPEventSubscriber is by default subscribing for events from it's local CDPEventNode, but can be configured to subscribe for events from other CDP Applications as well, see Receiving Events In Native GUI Applications. In GUI applications, you may use the Event List, which is a configurable widget for showing events from CDP applications. In Design mode you will find the Event List widget under 'Other'. CDPEventNode and CDPEventSubscriber are not visible in CDP Studio unless Hide Internal Items is unchecked in the filtering in upper right corner. CDPEventNode and CDPEventSubscriber are found in the application's 'CDP' component.

Another possibility to monitor active alarms, is to use an ActiveAlarmCounter together with a CDPEventListener. Using ActiveAlarmCounter, you can get counter-values of active alarms (for different levels/status/groups), and a sequencer Event is emitted when counter-values change. See ActiveAlarmCounter for more info.

Key features for CDPEventManager:

  • CDPEventNode can log events from any custom objects that reports events (e.g. alarms), and distributes events to subscribers.
  • Any custom objects can report events by implementing the IEventLogger interface.
  • CDPEventSubscriber can subscribe events from CDPEventNodes in applications within the system.
  • All reported events are guarantied to be received by the subscriber. (As long as circular event buffer is not overloaded. If overrun occurs it is detected by the protocol and alarm is triggered.).
  • In case the event-messages do not reach their destination, the event-message protocol takes care of resending.

Generating Events

CDPAlarm event triggered

CDPAlarm is an alarm object in CDP. See the CDP Code Documentation for documentation on how to use the CDPAlarm object. The CDPAlarm triggers events in the following situations:

CDPAlarm eventEvent typeEventCodeEventCode valueDescription
SetSimpleEventEVENT_ALARMSET0x00000001The alarm is set/triggered
AcknowledgeSimpleEventEVENT_ALARMACK0x00000004A set alarm is acknowledged by someone (but still remains set)
ClearSimpleEventEVENT_ALARMCLEAR0x00000002A set alarm is cleared

Other Events

Event typeEventCodeEventCode valueDescription
SimpleEventEVENT_REPRISE | x (x = last event reported on the alarm)0x00000040 | xA set or unacknowledged alarm will reinsert the last event reported at customisable intervals
ExtendedEventEVENT_PROPERTY_CHANGE0x00000008Some property was changed
SimpleEventEVENT_SOURCE_OBJECT_UNAVAILABLE0x00000100The provider of the event has become unavailable (disconnected or similar)
SimpleEvent and ExtendedEventEVENT_NODE_BOOT0x40000000The provider reports that the CDPEventNode just have booted
SimpleEventEVENT_EXTENDED_INFO_AVAILABLE0x80000000Indicates that this event also have sent extended event, and that the extended event info is available as extended event

For each alarm that is in Set or Unacknowledged state, the last event performed on the alarm will be reinserted if no new events have been performed on it within a set (configurable) amount of time. This guaranties Set and/or Unacknowledged alarms to reach all subscribers, even if 'last-message' of a event transfer is lost in the network. This event is reported as a simple event in the CDPEventManager system. The value of timestamp and state is not changed, but a new event id will be created and the old id will be retained in the originalEventId property. The interval is set by the parameter "ReReportAlarmInterval" (currently 15s).

How To Generate Own Events

Report events through the IEventLogger interface. Typically from a CDPObject to a CDPEventNode. Users can implement event reporting from any custom made object using CDPObject as its base. Code example of generating a simple event:

#include <CDPSystem/EventLogger/IEventLogger.h>
....
if (IEventLogger::GetInstance( Handle() ) != NULL)
{
  char szTimeStamp[22];   //The time stamp for the alarm and the reported event.
  szTimeStamp[0] = 0;

  unsigned int newEventId = IEventLogger::GetInstance( Handle() )->ReportSimpleEvent(Handle(), status, eventCode, szTimeStamp);

Code example of generating an extended event (ReportExtendedEvent() will also call ReportSimpleEvent() with EVENT_EXTENDED_INFO_AVAILABLE bit set):

#include <CDPSystem/EventLogger/IEventLogger.h>
....
if (IEventLogger::GetInstance( Handle() ) != NULL)
{
  unsigned int newEventId = IEventLogger::GetInstance( Handle() )->ReportExtendedEvent(Handle(),0,EVENT_PROPERTY_CHANGE,"Clock",timeprint.length()+1,timeprint.c_str());

Receiving Events

The most easy way to receive events is to use the Event List widget in GUI applications.

Another way is to use the IEventManager interface. The purpose of IEventManager interface is to enable interfacing the CDPEventManager without creating a dependency to the CDPEventManager library. The functions in this interface will typically be implemented by IEventSubscriber, or another class implementing the IEventSubscriber interface.

Another way is use the IEventSubscriber interface. You could make your own CDPComponent called e.g. MyComponent, which inherits IEventSubscriber, and override wanted functions like this:

#include <CDPEventLogger/IEventSubscriber.h>

class MyComponent : public IEventSubscriber, public CDPComponent

virtual bool EventCallback(Event& event);
virtual bool ExtendedEventCallback(ExtendedEvent& extEvent);

Event Info

The Event object stores information about the event that occurs. The events are classified in two main types of events: SimpleEvents and ExtendedEvents. The SimpleEvent is the actual event. This is where the time stamp is set, and this is where the status of the signaling object is stored. If there is more information available for an event (EVENT_EXTENDED_INFO_AVAILABLE is set in the SimpleEvent), this information is distributed as an ExtendedEvent. In the extended event, there are 932 bytes available for a textual name + data. For both event types, the event code gives a description of the event that happened. Both simple events and extended events contain information about which object generated the event (handle), and also have an event id. The event id is unique for the provider for some period of time, typically at least for some minutes. The event id is used to request extended information regarding the event, and to ensure that all events are transferred to the subscribers (the event id is automatically generated by CDP in the IEventLogger interface.)

Simple Events

Member variables for a Simple Event:

Data typeMember variable nameDescription
unsigned inteventIdEventID - Unique identifier (for this event node)
unsigned intoriginalEventIdSet for reprise events
unsigned inthandleCDP Handle of object that generated the event
intstatusNew status of object after the event
inteventCodeCode describing the event
char[22]timestampTime stamp when event was reported (local time in reporting node)
charpadding_00'padding_nn' not used, needed to be compatible with 4bytes Struct Member Alignment used in old CDP
charpadding_01'padding_nn' not used, needed to be compatible with 4bytes Struct Member Alignment used in old CDP

The eventCode bitmask in the event object denotes which type of event it is. If more information is available, the eventCode also indicates this by having the EVENT_EXTENDED_INFO_AVAILABLE flag set. If the information in the SimpleEvent is sufficient, just do the necessary processing upon the event. Typically this is when only the state has changed in the reporting object. Status, typically the object state, of the object that generated the event is inserted in 'status' when applicable. If the SimpleEvent indicates that there is extended data, for instance a property change, then extended event information will be requested by the IEventSubscriber interface.

Extended Events

Member variables for a Extended Event:

Data typeMember variable nameDescription
intsizeSize of this event info object (16+length(eventNameAndData))
unsigned inthandleCDP Handle of object that generated the event
unsigned inteventIdEventID - Unique identifier (for this event node)
inteventCodeCode describing the alarm event
char[932]eventNameAndDataThis will be a up to 932 bytes of data. eventName (name identifying the event type) is found in start of eventNameAndData, and must always be null-terminated. Then comes eventData: Note that this is not necessarily ascii data

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