1 // ANNA - Anna is Not Nothingness Anymore //
3 // (c) Copyright 2005-2015 Eduardo Ramos Testillano & Francisco Ruiz Rayo //
5 // See project site at http://redmine.teslayout.com/projects/anna-suite //
6 // See accompanying file LICENSE or copy at http://www.teslayout.com/projects/public/anna.LICENSE //
9 #include <anna/core/tracing/Logger.hpp>
10 #include <anna/core/tracing/TraceWriter.hpp>
11 #include <anna/core/functions.hpp>
12 #include <anna/xml/Node.hpp>
15 #include <anna/core/oam/Configuration.hpp>
18 //******************************************************************************
19 //---------------------------------------------------------------- Configuration
20 //******************************************************************************
23 //------------------------------------------------------------------------------
24 //----------------------------------------------- Configuration::Configuration()
25 //------------------------------------------------------------------------------
26 anna::oam::Configuration::Configuration() {
27 //a_alarm_text_preffix_components.clear();
28 //a_alarm_text_suffix_components.clear();
29 a_alarms_preffix_enabled = true;
30 a_alarms_suffix_enabled = true;
31 // Alarm Text Delimiters:
32 a_alarm_text_delimiter_zS = ' ';
33 a_alarm_text_delimiter_psL = "[ ";
34 a_alarm_text_delimiter_psS = " | ";
35 a_alarm_text_delimiter_psR = " ]";
39 //------------------------------------------------------------------------------
40 //-------------------------------------- Configuration::setAlarmTextDelimiters()
41 //------------------------------------------------------------------------------
42 void anna::oam::Configuration::setAlarmTextDelimiters(const char zS, const std::string & psL, const std::string & psS, const std::string & psR) throw() {
43 a_alarm_text_delimiter_zS = zS;
44 a_alarm_text_delimiter_psL = psL;
45 a_alarm_text_delimiter_psS = psS;
46 a_alarm_text_delimiter_psR = psR;
50 //------------------------------------------------------------------------------
51 //-------------------------------------- Configuration::getAlarmTextDelimiters()
52 //------------------------------------------------------------------------------
53 void anna::oam::Configuration::getAlarmTextDelimiters(char & zS, std::string & psL, std::string & psS, std::string & psR) const throw() {
54 zS = a_alarm_text_delimiter_zS;
55 psL = a_alarm_text_delimiter_psL;
56 psS = a_alarm_text_delimiter_psS;
57 psR = a_alarm_text_delimiter_psR;
61 //------------------------------------------------------------------------------
62 //----------------------------------------- Configuration::enableAlarmsPreffix()
63 //------------------------------------------------------------------------------
64 void anna::oam::Configuration::enableAlarmsPreffix(void) throw() {
65 a_alarms_preffix_enabled = true;
66 LOGDEBUG(anna::Logger::debug("Alarm preffix global components SHOWN", ANNA_FILE_LOCATION));
70 //------------------------------------------------------------------------------
71 //------------------------------------------ Configuration::enableAlarmsSuffix()
72 //------------------------------------------------------------------------------
73 void anna::oam::Configuration::enableAlarmsSuffix(void) throw() {
74 a_alarms_suffix_enabled = true;
75 LOGDEBUG(anna::Logger::debug("Alarm suffix global components SHOWN", ANNA_FILE_LOCATION));
79 //------------------------------------------------------------------------------
80 //---------------------------------------- Configuration::disableAlarmsPreffix()
81 //------------------------------------------------------------------------------
82 void anna::oam::Configuration::disableAlarmsPreffix(void) throw() {
83 a_alarms_preffix_enabled = false;
84 LOGDEBUG(anna::Logger::debug("Alarm preffix global components HIDDEN", ANNA_FILE_LOCATION));
88 //------------------------------------------------------------------------------
89 //----------------------------------------- Configuration::disableAlarmsSuffix()
90 //------------------------------------------------------------------------------
91 void anna::oam::Configuration::disableAlarmsSuffix(void) throw() {
92 a_alarms_suffix_enabled = false;
93 LOGDEBUG(anna::Logger::debug("Alarm suffix global components HIDDEN", ANNA_FILE_LOCATION));
97 //------------------------------------------------------------------------------
98 //------------------------------------------------------- Configuration::asXML()
99 //------------------------------------------------------------------------------
100 anna::xml::Node* anna::oam::Configuration::asXML(anna::xml::Node* parent) const throw() {
101 anna::xml::Node* result = parent->createChild("anna.oam.Configuration");
102 std::vector<std::string>::const_iterator it, it_min, it_max;
103 result->createAttribute("AlarmsPreffix", a_alarms_preffix_enabled ? "Enabled" : "Disabled");
104 it_min = a_alarm_text_preffix_components.begin();
105 it_max = a_alarm_text_preffix_components.end();
107 if(a_alarm_text_preffix_components.size() != 0) {
108 anna::xml::Node* pc = result->createChild("AlarmsPreffixComponents");
110 for(it = it_min; it != it_max; it++)
111 pc->createAttribute(anna::functions::asString("Text%d", (int)(it - it_min) + 1).c_str(), *it);
114 result->createAttribute("AlarmsSuffix", a_alarms_suffix_enabled ? "Enabled" : "Disabled");
115 it_min = a_alarm_text_suffix_components.begin();
116 it_max = a_alarm_text_suffix_components.end();
118 if(a_alarm_text_suffix_components.size() != 0) {
119 anna::xml::Node* pc = result->createChild("AlarmsSuffixComponents");
121 for(it = it_min; it != it_max; it++)
122 pc->createAttribute(anna::functions::asString("Text%d", (int)(it - it_min) + 1).c_str(), *it);
125 char zoneDelimiterCharacter[2];
126 sprintf(zoneDelimiterCharacter, "%c", a_alarm_text_delimiter_zS);
127 result->createAttribute("AlarmTextZoneDelimiter", zoneDelimiterCharacter);
128 result->createAttribute("AlarmPreffixSuffixLeftDelimiter", a_alarm_text_delimiter_psL);
129 result->createAttribute("AlarmPreffixSuffixSeparatorDelimiter", a_alarm_text_delimiter_psS);
130 result->createAttribute("AlarmPreffixSuffixRightDelimiter", a_alarm_text_delimiter_psR);