#include <AlarmSource.h>
Public Member Functions | |
virtual | ~AlarmSource () |
virtual void | raiseAlarm (std::string faultFamily, std::string faultMember, int faultCode)=0 |
virtual void | raiseAlarm (std::string faultFamily, std::string faultMember, int faultCode, Properties properties)=0 |
virtual void | clearAlarm (std::string faultFamily, std::string faultMember, int faultCode)=0 |
virtual void | setAlarm (std::string faultFamily, std::string faultMember, int faultCode, Properties alarmProps, bool active)=0 |
virtual void | setAlarm (std::string faultFamily, std::string faultMember, int faultCode, bool active)=0 |
virtual void | terminateAllAlarms ()=0 |
virtual void | queueAlarms (ACS::TimeInterval time)=0 |
virtual void | queueAlarms ()=0 |
virtual void | flushAlarms ()=0 |
virtual void | disableAlarms ()=0 |
virtual void | enableAlarms ()=0 |
virtual void | start ()=0 |
virtual void | tearDown ()=0 |
virtual void | update (ACS::Time now) |
The AlarmSource interface offers a set of useful methods to handle alarms from a source.
This class, on one side, allows the sending of alarms with a shorter syntax compared to the original API and, on the other side, offers some common functionalities useful while sending alarms in ACS.
This class implements a guard in the sense that a active (terminated) alarm is not sent to the alarm service if it has been already activated (terminated).
AlarmSource allows to queue the alarms instead of sending them immediately by calling queueAlarms(...)
. To stop queuing the alarms and send them to the alarm service the method flushAlarms()
must be executed. The queuing of the alarms has the advantage that if an alarm is activated and then deactivated during the queuing time, it is not sent to the alarm service. This functionalities can be useful for example when starting up a piece of software connected to an hardware device. In that case it is quite common that before initialization some of the values returned by the device are wrong and can trigger the sending of alarms that will be cleared only when the device is fully operative. With the queuing the operator does not receive this kind of (false) alarms. It is left to developer the responsibility to enable/disable the queuing at the right moment.
If queueAlarms(ACS::TimeInterval) is called twice, the new time interval is used to flush the queue and the old one is discarded. Note that the time when the alarms are flushed after being queued with queueAlarms(ACS::TimeInterval) is not precise but a best-effort approximation.
Alarm sending can be inhibited by calling disableAlarms(): all the alarm events submitted after calling this method are discarded. To revert just call enableAlarms(). The inhibition of the alarms does not interfere with the queuing: alarms queued before inhibit alarms remain queued and will be sent when flushing.
Life cycle: start() must be called before using methods of this class. tearDown() must be called when finished using this class.
The AlarmSource interface provides the update() method to update the state of the object, if needed as in the default implementation update() body is empty and the final implementation of this method depends on the concrete class. Typically, update is invoked at regular time intervals by an external thread, AlarmSourceThread.
virtual acsalarm::AlarmSource::~AlarmSource | ( | ) | [inline, virtual] |
Destructor
virtual void acsalarm::AlarmSource::clearAlarm | ( | std::string | faultFamily, | |
std::string | faultMember, | |||
int | faultCode | |||
) | [pure virtual] |
Clear the alarm with the passed triplet.
If the alarm is already terminated, it is not sent again to the alarm service.
faultFamily | The FaultFamily | |
faultMember | The FaultMember | |
faultCode | The FaultCode |
Implemented in acsalarm::AlarmSourceImpl.
virtual void acsalarm::AlarmSource::disableAlarms | ( | ) | [pure virtual] |
Disable the sending of alarms.
When the alarms are disabled, all the alarms submitted with raise, clear and set are discarded. This means that those alarms are immediately discarded. They are not queued, and will never arrive at the alarm service.
Implemented in acsalarm::AlarmSourceImpl.
virtual void acsalarm::AlarmSource::enableAlarms | ( | ) | [pure virtual] |
Enable the sending of alarms.
Better just "This method reverts the effect of a previous call to disableAlarms(), so that alarms will get processed again.
Alarms are enabled by default.
Implemented in acsalarm::AlarmSourceImpl.
virtual void acsalarm::AlarmSource::flushAlarms | ( | ) | [pure virtual] |
Flush the alarms queued and stop queuing.
Implemented in acsalarm::AlarmSourceImpl.
virtual void acsalarm::AlarmSource::queueAlarms | ( | ) | [pure virtual] |
Start queuing the alarms.
The alarms are queued until flushAlarms()
is executed.
The purpose of the queuing is to avoid alarms flickering for example during the initialization phase of a device where spurious states could trigger the event of false alarms.
Implemented in acsalarm::AlarmSourceImpl.
virtual void acsalarm::AlarmSource::queueAlarms | ( | ACS::TimeInterval | time | ) | [pure virtual] |
Start queuing the alarms.
The alarms are flushed when the passed delay expires or flushAlarms() gets called.
The purpose of the queuing is to avoid alarms flickering for example during the initialization phase of a device where spurious states could trigger the event of false alarms
time | The time to queue alarms in msec |
Implemented in acsalarm::AlarmSourceImpl.
virtual void acsalarm::AlarmSource::raiseAlarm | ( | std::string | faultFamily, | |
std::string | faultMember, | |||
int | faultCode, | |||
Properties | properties | |||
) | [pure virtual] |
Raise an alarm with the given triplet and a set of properties.
If the alarm is already active, it is not sent again to the alarm service.
faultFamily | The FaultFamily | |
faultMember | The FaultMember | |
faultCode | The FaultCode | |
properties | The user properties. It can be null or empty. |
Implemented in acsalarm::AlarmSourceImpl.
virtual void acsalarm::AlarmSource::raiseAlarm | ( | std::string | faultFamily, | |
std::string | faultMember, | |||
int | faultCode | |||
) | [pure virtual] |
Raise an alarm with the given triplet.
If the alarm is already active, it is not sent again to the alarm service.
faultFamily | The FaultFamily | |
faultMember | The FaultMember | |
faultCode | The FaultCode |
Implemented in acsalarm::AlarmSourceImpl.
virtual void acsalarm::AlarmSource::setAlarm | ( | std::string | faultFamily, | |
std::string | faultMember, | |||
int | faultCode, | |||
Properties | alarmProps, | |||
bool | active | |||
) | [pure virtual] |
Send the alarm with the passed triplet and properties to the alarm service. The state activate/terminate of the alarm depends on the passed boolean.
This method is the most complete way to send an alarm.
If the alarm is already active, it is not sent again to the alarm service. If the alarm is already terminated, it is not sent again to the alarm service.
faultFamily | The FaultFamily | |
faultMember | The FaultMember | |
faultCode | The FaultCode | |
alarmProps | The user properties. It can be null or empty. | |
active | if true the alarm is activated otherwise it is terminated. |
Implemented in acsalarm::AlarmSourceImpl.
virtual void acsalarm::AlarmSource::setAlarm | ( | std::string | faultFamily, | |
std::string | faultMember, | |||
int | faultCode, | |||
bool | active | |||
) | [pure virtual] |
Send the alarm with the passed triplet to the alarm service. The state activate/terminate of the alarm depends on the passed boolean.
This method is the most complete way to send an alarm.
If the alarm is already active, it is not sent again to the alarm service. If the alarm is already terminated, it is not sent again to the alarm service.
faultFamily | The FaultFamily | |
faultMember | The FaultMember | |
faultCode | The FaultCode | |
active | if true the alarm is activated otherwise it is terminated. |
Implemented in acsalarm::AlarmSourceImpl.
virtual void acsalarm::AlarmSource::start | ( | ) | [pure virtual] |
Life-cycle: this method must be called before using this class.
Implemented in acsalarm::AlarmSourceImpl.
Referenced by maci::MACIContainerServices::getAlarmSource().
virtual void acsalarm::AlarmSource::tearDown | ( | ) | [pure virtual] |
Life-cycle: tearDown must be called when terminated using this class
Implemented in acsalarm::AlarmSourceImpl.
virtual void acsalarm::AlarmSource::terminateAllAlarms | ( | ) | [pure virtual] |
Terminate all the active alarms.
Implemented in acsalarm::AlarmSourceImpl.
virtual void acsalarm::AlarmSource::update | ( | ACS::Time | now | ) | [inline, virtual] |
update is invoked at regular time intervals by the AlarmSourceThread to update its internal data structures. It must be overloaded by the class extending this interface if needed.
For this method to be invoked by the AlarmSourceTherad, the object must be registered by calling AlarmSourceThread::registerForUpdating(AlarmSource* src) and unregistered before deletion (or when updating is not need anymore) by calling AlarmSourceThread::unregisterFromUpdating(AlarmSource* src).
now | The actual time in msec |
Reimplemented in acsalarm::AlarmSourceImpl.