CDPAlarm Class
The Alarm class is used to generate alarm-events based on signals or component state. More...
Header: | #include <CDPAlarm/CDPAlarm.h> |
Inherits: | CDPObject |
Public Functions
CDPAlarm() | |
~CDPAlarm() override | |
virtual void | Acknowledge() |
virtual void | Clear(bool checkTimeout = true) |
CDPTime | DateTimeLastModified() |
virtual void | Disable() |
virtual void | Enable() |
virtual CDPProperty<std::string> & | GetAlarmText() |
virtual CDPProperty<std::string> & | Group() |
virtual bool | IsSet() const |
virtual bool | IsUnacknowledged() const |
unsigned int | Level() const |
virtual void | Reset() |
virtual void | Set(bool checkTimeout = true) |
virtual void | SetAlarmGroup(const std::string &newAlarmGroup) |
virtual void | SetAlarmText(const std::string &newAlarmText) |
virtual void | SetLevel(unsigned int newLevel) |
virtual int | Update(unsigned int &blockedStates, int currentState) |
Reimplemented Public Functions
virtual void | Configure(const char *xml) override |
virtual void | Configure(XMLElementEx *pAlarmElement) override |
virtual void | Create(const char *name, CDPComponent *pParent = NULL) override |
virtual void | Destroy() override |
virtual void | FillNodeChildren(CDP::StudioAPI::NodeStream &serializer) const override |
virtual std::string | GetProperty(std::string propertyName) override |
virtual int | ReceiveMessage(void *message) override |
virtual void | SetProperty(std::string propertyName, std::string propertyValue) override |
virtual void | SetPropertyHandler(CDPPropertyBase *pProp) override |
virtual unsigned int | Status() const override |
virtual bool | ValidatePropertyHandler(CDP::StudioAPI::CDPVariantValue &newValue, CDPPropertyBase *property) override |
- 37 public functions inherited from CDPObject
- 46 public functions inherited from CDPBaseObject
- 26 public functions inherited from CDP::StudioAPI::CDPNode
- 22 public functions inherited from CDP::StudioAPI::ICDPNode
Protected Functions
void | CheckInputAgainstConfiguredLevelValue(const e_AnalogueLevels levelType, const double currentInput, bool &setNow, unsigned int &newLevel) |
void | LogEvent(unsigned int nEventType) |
void | Notify(int _handle) |
void | PossiblyEnableOrDisable_inputTimer() |
void | UpdateLoggingEnabled(CDPPropertyBase *pProp) |
Reimplemented Protected Functions
virtual void | CreateModel() override |
- 13 protected functions inherited from CDPObject
- 1 protected function inherited from CDP::StudioAPI::CDPNode
Additional Inherited Members
- 6 static public members inherited from CDPObject
- 1 static public member inherited from CDPBaseObject
- 7 protected variables inherited from CDPObject
- 9 protected variables inherited from CDPBaseObject
- 1 static protected member inherited from CDPObject
Detailed Description
The Alarm class is used to generate alarm-events based on signals or component state.
Alarm Usage
Alarms can be used without adding specific code to handle them:
- Add an alarm to a component in the Configure mode.
- Set the alarm configuration in the component configuration by selecting the alarm and setting the alarm properties to desired values.
All CDPAlarms are run as part of the state-machine, and will be automatically processed depending on how they are set up. Depending on how the CDPAlarm is configured with inputs, levels and outputs, it is possible to use CDPAlarm-objects without any coding.
It is also possible to use alarms from code. For instance, add a CDPAlarm for Emergency-stop, e.g. EMStop to the model. The EMStop can now be used in code; Some scenarios are outlined below:
Check if the Emergency-stop alarm is set:
if (EMStop.IsSet()) HandleEMStop();
Check if the Emergency-stop alarm is Acknowledged:
if (!EMStop.IsUnacknowledged() ) EquipmentOperatorAcknowledgedEMStop();
To Set or Clear an alarm:
if (alarmShouldBeSet()) alarm.Set(); else if (alarmShouldBeCleared()) alarm.Clear();
Alternatively, use the StatusDefines to check alarm status:
if (EMStop.Status()&STATUS_OK) RequestOKState(); else if (EMStop.Status()&STATUS_SET) PerformEmergencyMeasures();
See below for more information about the different attributes and properties that a CDPAlarm contains.
Alarm status levels
The alarm level signifies the importance of the alarm. The following levels are available:
Level | Description | Example |
---|---|---|
Notify | For information type of events. | "System is not ready to be started yet" |
Warning | For faults that signify that some measure must be taken | "Engine temperature is above normal" |
Error | For faults that are critical and require immediate action, such as stopping machines. | "Engine temperature is too high to function correctly" |
The alarm Status reflects the set/unset, acknowledged/unacknowledged state of the alarm. The status of the parent CDPComponent will be the or'ed status of all it's alarms (and also the or'ed status of all it's subcomponents).
Properties:
Name | Description |
---|---|
Name | The alarm unique name. |
Trig | If set to '1', trig mode is enabled. The alarm will then remain Set until acknowledged, even if the Set condition disappears, and it will be automatically cleared when acknowledged. |
Set | If set to '1', the alarm will be initially set. |
Unacknowledged | If set to '1', the alarm wil be initially set to unacknowledged state. |
SourceValueRouting | Routing to local/remote value which may set or clear the alarm. |
Inhibit | If true, the alarm will be inhibited/blocked. May be set by routed value from InhibitRouting. |
InhibitRouting | Routing to local/remote value which will set the value of Inhibit property. |
Text | Alarm text. If not set, it will be set equal to the Description attribute. The alarm text can include CDPTag names formatted as '%name%'. These will be substituted with the corresponding tag value, searching from the alarm's own tags and moving up the hierarchy until the application level. |
Description | More detailed alarm description text. If not set, it will be set equal to the Text attribute. |
Level | Set alarm level to 'Notify', 'Warning', 'Error'. |
Enabled | Must be set to '1' to be able to set the alarm. If this property is set to 0 to disable the alarm during runtime, the alarm is also acknowledged and cleared. |
WarningLowLevelText | Text to set if warning low level alarm is set. If not specified, displays the text 'Low signal level' The text can include CDPTag names formatted as '%name%'. These will be substituted with the corresponding tag value, searching from the alarm's own tags and moving up the hierarchy until the application level. |
WarningHighLevelText | Text to set if warning high level alarm is set. If not specified, displays the text 'High signal level' The text can include CDPTag names formatted as '%name%'. These will be substituted with the corresponding tag value, searching from the alarm's own tags and moving up the hierarchy until the application level. |
ErrorLowLevelText | Text to set if error low level alarm is set. If not specified, displays the text 'Very low signal level' The text can include CDPTag names formatted as '%name%'. These will be substituted with the corresponding tag value, searching from the alarm's own tags and moving up the hierarchy until the application level. |
ErrorHighLevelText | Text to set if error high level alarm is set. If not specified, displays the text 'Very high signal level' The text can include CDPTag names formatted as '%name%'. These will be substituted with the corresponding tag value, searching from the alarm's own tags and moving up the hierarchy until the application level. |
LoggingEnabled | Set to '0' to disable logging, or to '1' to enable. Default is logging enabled. |
Group | Optional alarm group name(s), used for display filtering. If blank, the top-level parent component name is used as group name. Several can be specified separated by ';'. |
Timeout | Alarm activation timeout (Delay). Decimal value in seconds, for instance Timeout='0.3' |
LevelLowError | When SourceValue is less or equal to this value, the alarm will be set. Overrides Level setting. Can be combined with Timeout. The Alarm text is automatically changed to the corresponding ErrorLowLevelText until the set condition disappears. |
LevelHighError | When SourceValue is greater or equal to this value, the alarm will be set. Overrides Level setting. Can be combined with Timeout. The Alarm text is automatically changed to the corresponding ErrorHighLevelText until the set condition disappears. |
LevelLowWarning | When SourceValue is less or equal to this value, the alarm will be set. Overrides Level setting. Can be combined with Timeout. The Alarm text is automatically changed to the corresponding WarningLowLevelText until the set condition disappears. |
LevelHighWarning | When SourceValue is greater or equal to this value, the alarm will be set. Overrides Level setting. Can be combined with Timeout. The Alarm text is automatically changed to the corresponding WarningHighLevelText until the set condition disappears. |
Inverted | If true, the alarm will be activated when SourceValue is 0. Not valid for level alarms. |
IIR_b0 | For level alarms: IIR filter constant b0 for simple 1st order analogue SourceValue filtering. Filter is disabled if b0 not specified. Recommended to use values 0.4..0.004. Filter is dependent on owner component frequency. |
BlockState | Owning component will not transition into a blocked state when an alarm with BlockState is Set. If the component already is in a blocked state when such an alarm becomes Set, it will remain in current state and transition to another state as normal (but not into other blocked states). One or more of the 32 first states can be specified in a ; separated list. |
EnabledState | Owner component state to enable alarm. If not specified, the alarm will be enabled for all states. Up to 32 states can be specified. |
MessageCommand | Text Message command to send when Set. |
MessageDestination | Destination component for message to send when Set. |
Mask | Mask SourceValue with this mask before checking if != 0. Will use raw SourceValue (unscaled, unmasked). Typically used to check alarm bit in raw value from i/o module. Mask=0 disables masking. |
Messages:
The following messages can be sent to the alarm object through CDP Studio, or through a Connector attached to the Alarm:
CM_ALARMSET | Set the alarm |
CM_ALARMCLEAR | Clear the alarm |
CM_ALARMACKNOWLEDGE | Acknowledge the alarm |
CM_ALARMRESET | Reset the alarm |
Alarm Status Defines
#define STATUS_OK 0x00000000 /** There is a NOTIFY alarm present.*/ #define STATUS_NOTIFY 0x00000001 /** There is a WARNING alarm present.*/ #define STATUS_WARNING 0x00000010 /** There is a LOW LEVEL alarm present.*/ #define STATUS_LEVEL_L 0x00000020 /** There is a HIGH LEVEL alarm present.*/ #define STATUS_LEVEL_H 0x00000040 /** There is an ERROR alarm present.*/ #define STATUS_ERROR 0x00000100 /** There is a LOW-LOW LEVEL alarm present. */ #define STATUS_LEVEL_LL 0x00000200 /** There is a HIGH-HIGH LEVEL alarm present. */ #define STATUS_LEVEL_HH 0x00000400 /** There is an EMERGENCY alarm present. */ #define STATUS_EMERGENCY 0x00000800 /** The signal value is forced (overridden). */ #define STATUS_VALUE_FORCED 0x00001000 /** The alarm is blocked due to too many repeats.*/ #define STATUS_REPEATBLOCKED 0x00002000 /** The alarm is blocked by the software. */ #define STATUS_PROCESSBLOCKED 0x00004000 /** The alarm is blocked by the user. */ #define STATUS_OPERATORBLOCKED 0x00008000 /** There is an Unacknowledged NOTIFY alarm present. */ #define STATUS_UNACKNOTIFY 0x00010000 /** There is an Unacknowledged WARNING alarm present. */ #define STATUS_UNACKWARNING 0x00100000 /** There is an Unacknowledged ERROR alarm present. */ #define STATUS_UNACKERROR 0x01000000 /** There is an Unacknowledged EMERGENCY alarm present. */ #define STATUS_UNACKEMERGENCY 0x08000000 /** The alarm is disabled. */ #define STATUS_DISABLED 0x20000000 /** The signal has a fault condition present.*/ #define STATUS_SIGNAL_FAULT 0x40000000 /** The component is suspended. */ #define STATUS_COMPONENT_SUSPENDED 0x80000000 /** There is an Unacknowledged alarm present of any level. */ #define STATUS_UNACK_MASK (STATUS_UNACKNOTIFY|STATUS_UNACKWARNING|STATUS_UNACKERROR|STATUS_UNACKEMERGENCY) /** There is an Unacknowledged alarm present of any level. */ #define STATUS_UNACK STATUS_UNACK_MASK /** There is an LOW-LOW ERROR alarm present. */ #define STATUS_ERROR_LL (STATUS_ERROR | STATUS_LEVEL_LL) /** There is an HIGH-HIGH ERROR alarm present. */ #define STATUS_ERROR_HH (STATUS_ERROR | STATUS_LEVEL_HH) /** There is an LOW WARNING alarm present. */ #define STATUS_WARNING_L (STATUS_WARNING | STATUS_LEVEL_L) /** There is an HIGH WARNING alarm present. */ #define STATUS_WARNING_H (STATUS_WARNING | STATUS_LEVEL_H) /** There is an alarm present that is SET. */ #define STATUS_SET (STATUS_EMERGENCY|STATUS_ERROR|STATUS_LEVEL_HH|STATUS_LEVEL_LL|STATUS_WARNING|STATUS_LEVEL_L|STATUS_LEVEL_H|STATUS_NOTIFY) /** There is an EMERGENCY alarm present. */ #define STATUS_LEVEL_EMERGENCY STATUS_EMERGENCY /** There is an ERROR alarm present. */ #define STATUS_LEVEL_ERROR STATUS_ERROR /** There is an WARNING alarm present. */ #define STATUS_LEVEL_WARNING STATUS_WARNING /** There is a NOTIFY alarm present. */ #define STATUS_LEVEL_NOTIFY STATUS_NOTIFY /** There is an Unacknowledged NOTIFY alarm present. */ #define STATUS_LEVEL_UNACKNOTIFY STATUS_UNACKNOTIFY /** There is an Unacknowledged WARNING alarm present. */ #define STATUS_LEVEL_UNACKWARNING STATUS_UNACKWARNING /** There is an Unacknowledged ERROR alarm present. */ #define STATUS_LEVEL_UNACKERROR STATUS_UNACKERROR
Member Function Documentation
CDPAlarm::CDPAlarm()
Default constructs an instance of CDPAlarm.
CDPAlarm::~CDPAlarm()
Alarm object destructor
[virtual]
void CDPAlarm::Acknowledge()
Acknowledge alarm if set. If a change is detected, loggingEnabled==true, and an EventLogger instance is found, ReportSimpleEvent with EVENT_ALARMACK is invoked.
[protected]
void CDPAlarm::CheckInputAgainstConfiguredLevelValue(const e_AnalogueLevels levelType, const double currentInput, bool &setNow, unsigned int &newLevel)
If (errorLowEnabled || errorHighEnabled || warningLowEnabled || warningHighEnabled), this function is called to check if currentInput is above/below configured level. setNow becomes true if alarm should be Set, and then newLevel will be updated also. Clear() may be called.
[virtual]
void CDPAlarm::Clear(bool checkTimeout = true)
Clear alarm. If a change is detected, loggingEnabled==true, and an EventLogger instance is found, ReportSimpleEvent with EVENT_ALARMCLEAR is invoked. If inputTimer is used, the timer will be stopped (inputTimer.Reset()) checkTimeout is unused.
[override virtual]
void CDPAlarm::Configure(const char *xml)
Reimplemented from CDPObject::Configure().
Reads alarm configuration from .xml buffer. Called from owner (parent) Configure(...).
[override virtual]
void CDPAlarm::Configure(XMLElementEx *pAlarmElement)
Reimplemented from CDPObject::Configure().
Reads alarm configuration from .xml buffer. Called from owner (parent) Configure(...).
[override virtual]
void CDPAlarm::Create(const char *name, CDPComponent *pParent = NULL)
Reimplemented from CDPObject::Create().
Create alarm and clear status.
[override virtual protected]
void CDPAlarm::CreateModel()
Reimplemented from CDPBaseObject::CreateModel().
Create the model and register messages.
CDPTime CDPAlarm::DateTimeLastModified()
Date and Time object was last modified
[override virtual]
void CDPAlarm::Destroy()
Reimplemented from CDPBaseObject::Destroy().
Do pre-destructor stuff, like signalling to other objects that the component is about to die. This method should reverse what was done in Create().
[virtual]
void CDPAlarm::Disable()
Disable the alarm. Will not even check alarm status.
[virtual]
void CDPAlarm::Enable()
Enable the alarm.
[override virtual]
void CDPAlarm::FillNodeChildren(CDP::StudioAPI::NodeStream &serializer) const
[virtual]
CDPProperty<std::string> &CDPAlarm::GetAlarmText()
Return the alarm text string
[override virtual]
std::string CDPAlarm::GetProperty(std::string propertyName)
Reimplemented from CDPBaseObject::GetProperty().
Get the value of a property in this object.
Text | The alarm text is returned as a string. |
Group | The alarm groups that this alarm belongs to is returned in an string. Each group separated by ';'. |
Level | For Level, the hexadecimal code for the alarm status is returned as a std::string. For instance, STATUS_NOTIFY will be '0x00000001'. See AlarmStatusDefines.h |
[virtual]
CDPProperty<std::string> &CDPAlarm::Group()
Return the alarm group
[virtual]
bool CDPAlarm::IsSet() const
Returns true if alarm is set.
[virtual]
bool CDPAlarm::IsUnacknowledged() const
Returns true if alarm is not acknowledged.
unsigned int CDPAlarm::Level() const
Return the alarm level
See also Alarm Status Defines.
[protected]
void CDPAlarm::LogEvent(unsigned int nEventType)
Helper function to log event
[protected]
void CDPAlarm::Notify(int _handle)
[protected]
void CDPAlarm::PossiblyEnableOrDisable_inputTimer()
This function will either set up timers for "LevelHighError", "LevelLowError", "LevelHighWarning" and "LevelLowWarning" (if configured), or for the inputTimer. The value from "Timeout" will be used when setting up the timers, but the timers are not started.
[override virtual]
int CDPAlarm::ReceiveMessage(void *message)
Reimplemented from CDPBaseObject::ReceiveMessage().
Message processing.
[virtual]
void CDPAlarm::Reset()
Clear status: Calls Acknowledge() and Clear().
[virtual]
void CDPAlarm::Set(bool checkTimeout = true)
Set alarm if enabled. If a change is detected, loggingEnabled==true, and an EventLogger instance is found, ReportSimpleEvent with EVENT_ALARMSET is invoked. If checkTimeout is true and inputTimer is used: if timer is not running, timer is restarted. If timer has not timed out, function will return without alarm being Set. If checkTimeout is false: no checks on inputTimer will be done.
[virtual]
void CDPAlarm::SetAlarmGroup(const std::string &newAlarmGroup)
Set the alarm group to the new string. If change detected, loggingEnabled, and an EventLogger is enabled and found, ReportExtendedEvent will be invoked with an EVENT_TEXT_CHANGE "Group" along with the group.
[virtual]
void CDPAlarm::SetAlarmText(const std::string &newAlarmText)
Set the alarm text to the new string. If loggingEnabled, and an EventLogger is enabled and found, ReportExtendedEvent will be invoked with an EVENT_TEXT_CHANGE "Text" along with the text.
Note: to preserve the new alarm text across application reboots, call instead SetProperty("Text", newAlarmText);
[virtual]
void CDPAlarm::SetLevel(unsigned int newLevel)
Set level to STATUS_NOTIFY, STATUS_WARNING, STATUS_ERROR. If loggingEnabled==true, and an EventLogger instance is found, ReportExtendedEvent with EVENT_PROPERTY_CHANGE "Level" and the new level (string integer) is invoked.
See also Alarm Status Defines.
[override virtual]
void CDPAlarm::SetProperty(std::string propertyName, std::string propertyValue)
Reimplemented from CDPBaseObject::SetProperty().
Set a property in the object. Called by MessageSetProperty after property name and value has been figured out.
[override virtual]
void CDPAlarm::SetPropertyHandler(CDPPropertyBase *pProp)
Reimplemented from CDPObject::SetPropertyHandler().
Do special handling for properties after they are set.
[override virtual]
unsigned int CDPAlarm::Status() const
Reimplemented from CDPBaseObject::Status().
Returns alarm status. Compare with STATUS_xxx to determine what it means.
See also Alarm Status Defines.
[virtual]
int CDPAlarm::Update(unsigned int &blockedStates, int currentState)
Called from owner CDPComponent::Process() to update alarm periodically. Updates blockedStates parameter if alarm is Set. Also handles re-reporting of events. Returns status.
See also Alarm Status Defines.
[protected]
void CDPAlarm::UpdateLoggingEnabled(CDPPropertyBase *pProp)
Update LoggingEnabled on all properties in this object when LoggingEnabled property changes.
[override virtual]
bool CDPAlarm::ValidatePropertyHandler(CDP::StudioAPI::CDPVariantValue &newValue, CDPPropertyBase *property)
Reimplemented from CDPObject::ValidatePropertyHandler().
Do special validation/changing of properties before they are set.
Get started with CDP Studio today
Let us help you take your great ideas and turn them into the products your customer will love.