Integration of FESA and Cosylab Alarm System
Building the C++ Interface
The C++ API to the alarm system can be found in the SVN repository at
https:/www-acc/gsi.de/svn/bel/cosylab/AlarmSystem. The interface library source is under trunk/src/cpp-api/alarm-generator. The build tool is Maven/SCons generating the static library archive libalarmsource.a under alarm-generator/target/install/lib.
The alarm system interface must be built against the version of Boost used by the FESA class. If the system default Boost version differs from the FESA Boost version edit the Scons configuration:
src/SConscript: env.AppendUnique(CPPPATH="/opt/gsi/3rdparty/boost/1.54.0/include") ...
A single header file "alarmapi.hpp" is required. The Maven build places it at alarm-generator/target/install/include. (EXTRA_HEADERS in Makefile.specific)
Libraries
The FESA deploy unit must link the alarm system and some support libraries
Example
DeployUnit Makefile.specific:
ALARM_LIB=../AlarmSystem/trunk/src/cpp-api/alarm-generator/target/install/lib
ALARM_INCLUDE=../AlarmSystem/trunk/src/cpp-api/alarm-generator/target/build/cpp/include
COMPILER_FLAGS += -I$(ALARM_INCLUDE)
LINKER_FLAGS += -L$(ALARM_LIB) -lalarmsource -lprotobuf -llog4cxx -lboost_system-mt EXTRA_HEADERS += alarmapi.hpp
Example Usage
#include "alarmapi.hpp"
using namespace de::gsi::cs::co::alarm;
Initialisation
Note that the endpoints for the C++ interface use different ports than the Java interface
getAlarmSourceFactoryInstance().init();
alarmSourceFactoryConfig.setRemoteSyncEndpoint("tcp://asl730.acc.gsi.de:10555");
alarmSourceFactoryConfig.setRemoteEventSubscriptionEndpoint("tcp://asl730.acc.gsi.de:10444");
Create Alarm Source
To create an alarm source (or find an existing source) with given Type, Nomenclature:
boost::shared_ptr<AlarmSource> alarmSource = getAlarmSourceFactoryInstance().createAlarmSource("Type", "Nomen");
Add some Resource Locators:
std::vector<std::string> resourceLocators;
resourceLocators.push_back("LocatorA");
resourceLocators.push_back("LocatorB");
alarmSource->registerResourceLocators(resourceLocators);
Work with Alarms
Get an alarm from the alarm source by its resource locator:
boost::shared_ptr<Alarm> alarm = alarmSource->getAlarm("LocatorA");
Raise alarm:
alarm->raiseAlarm(kEnumAlarmState::ACTIVE,"Alarm Event Description");
Stop alarm:
alarm->raiseAlarm(kEnumAlarmState::INACTIVE,"Alarm Event Description");