Commit 639b6527 authored by Graziano Scalamera's avatar Graziano Scalamera
Browse files

Add url alarm property

parent 1575e2d0
......@@ -1521,7 +1521,7 @@ void AlarmHandler::load(Tango::DevString argin)
}
#endif
alarms.save_alarm_conf_db(alm.attr_name, alm.name, "", "", alm.enabled, //add new alarm on log before subscribe event
alm.formula, alm.on_delay, alm.off_delay, alm.grp2str(), alm.lev, alm.msg, alm.cmd_name_a, alm.cmd_name_n, alm.silent_time); //but if it fails remove it from table
alm.formula, alm.on_delay, alm.off_delay, alm.grp2str(), alm.lev, alm.msg, alm.url, alm.cmd_name_a, alm.cmd_name_n, alm.silent_time); //but if it fails remove it from table
string conf_str;
alm.confstr(conf_str);
saved_alarms.insert(make_pair(alm.attr_name,conf_str));
......@@ -1842,7 +1842,7 @@ Tango::DevVarStringArray *AlarmHandler::search_alarm(Tango::DevString argin)
ostringstream os;
os.clear();
os << ai->second.ts.tv_sec << SEP << KEY(NAME_KEY) << ai->second.name << SEP << KEY(FORMULA_KEY) << ai->second.formula << SEP << KEY(ONDELAY_KEY) << ai->second.on_delay << SEP << KEY(OFFDELAY_KEY) << ai->second.off_delay <<
SEP << KEY(LEVEL_KEY) << ai->second.lev << SEP << KEY(SILENT_TIME_KEY) << ai->second.silent_time << SEP << KEY(GROUP_KEY) << ai->second.grp2str() << SEP << KEY(MESSAGE_KEY) << ai->second.msg <<
SEP << KEY(LEVEL_KEY) << ai->second.lev << SEP << KEY(SILENT_TIME_KEY) << ai->second.silent_time << SEP << KEY(GROUP_KEY) << ai->second.grp2str() << SEP << KEY(MESSAGE_KEY) << ai->second.msg << SEP << KEY(URL_KEY) << ai->second.url <<
SEP << KEY(ON_COMMAND_KEY) << ai->second.cmd_name_a << SEP << KEY(OFF_COMMAND_KEY) << ai->second.cmd_name_n << SEP << KEY(ENABLED_KEY) << (ai->second.enabled ? "1" : "0");
alarm_filtered.push_back(os.str());
}
......@@ -2113,6 +2113,7 @@ void AlarmHandler::modify(Tango::DevString argin)
i->second.done = false;
i->second.msg = alm.msg;
i->second.url = alm.url;
i->second.lev = alm.lev;
i->second.grp = alm.grp;
//i->second.to_be_evaluated = alm.to_be_evaluated;
......@@ -2948,6 +2949,8 @@ Tango::DevVarStringArray *AlarmHandler::get_alarm_info(const Tango::DevVarString
tmp << "\"" << it->second.msg << "\"";
info.insert(make_pair(MESSAGE_KEY,tmp.str()));
complete.push_back(KEY(MESSAGE_KEY)+tmp.str());
info.insert(make_pair(URL_KEY,it->second.url));
complete.push_back(KEY(URL_KEY)+it->second.url);
info.insert(make_pair(ON_COMMAND_KEY,it->second.cmd_name_a));
complete.push_back(KEY(ON_COMMAND_KEY)+it->second.cmd_name_a);
info.insert(make_pair(OFF_COMMAND_KEY,it->second.cmd_name_n));
......@@ -3063,6 +3066,7 @@ void AlarmHandler::load_alarm(string alarm_string, alarm_t &alm, vector<string>
alm.err_counter = 0;
alm.formula.clear();
alm.msg.clear();
alm.url.clear();
alm.lev.clear();
alm.grp=0;
alm.to_be_evaluated = false;
......@@ -3164,6 +3168,7 @@ void AlarmHandler::load_alarm(string alarm_string, alarm_t &alm, vector<string>
DEBUG_STREAM << " on_delay = '" << alm.on_delay << "'" << endl;
DEBUG_STREAM << " off_delay = '" << alm.off_delay << "'" << endl;
DEBUG_STREAM << " msg = '" << alm.msg << "'" << endl;
DEBUG_STREAM << " url = '" << alm.url << "'" << endl;
DEBUG_STREAM << " grp = '" << showbase << hex << alm.grp << "'=" << alm.grp2str() << endl;
DEBUG_STREAM << " silent_time = '" << alm.silent_time << "'" << endl;
DEBUG_STREAM << " silenced = '" << alm.silenced << "'" << endl;
......@@ -5045,6 +5050,7 @@ void AlarmHandler::prepare_alarm_attr()
alm_summary << KEY(ALARM_TIME_KEY) << time_buf << "." << ai->second.ts.tv_usec << SEP;
alm_summary << KEY(FORMULA_KEY) << ai->second.formula << SEP;
alm_summary << KEY(MESSAGE_KEY) << ai->second.msg; //TODO: escape ';'
//alm_summary << KEY(URL_KEY) << ai->second.url; //TODO: escape ';' TODO: add to alarmSummary?
#else
alm_summary += string(KEY(VALUE_KEY)) + almstate + SEP; //TODO: string or enum value?
alm_summary += KEY(LEVEL_KEY) + ai->second.lev + SEP;
......@@ -5053,6 +5059,7 @@ void AlarmHandler::prepare_alarm_attr()
alm_summary += KEY(ALARM_TIME_KEY) + sval.str() + SEP;
alm_summary += KEY(FORMULA_KEY) + ai->second.formula + SEP;
alm_summary += KEY(MESSAGE_KEY) + ai->second.msg; //TODO: escape ';'
//alm_summary += KEY(URL_KEY) + ai->second.url; //TODO: escape ';' TODO: add to alarmSummary?
#endif
......@@ -5138,6 +5145,7 @@ void AlarmHandler::prepare_alarm_attr()
aid->ack = NOT_ACK;
aid->ts = ai->second.ts;
aid->msg = ai->second.msg;
aid->url = ai->second.url;
}
aid->grp = ai->second.grp;
aid->lev = ai->second.lev;
......@@ -5181,6 +5189,7 @@ void AlarmHandler::prepare_alarm_attr()
aid->ack = NOT_ACK;
aid->ts = ai->second.ts;
aid->msg = ai->second.msg;
aid->url = ai->second.url;
}
aid->grp = ai->second.grp;
aid->lev = ai->second.lev;
......@@ -5220,6 +5229,7 @@ void AlarmHandler::prepare_alarm_attr()
aid->ts = ai->second.ts;
//aid->msg = " "; /* no message again */
aid->msg =ai->second.msg;
aid->url = ai->second.url;
aid->grp = ai->second.grp;
aid->lev = ai->second.lev;
aid->on_counter = ai->second.on_counter;
......@@ -5397,7 +5407,7 @@ void AlarmHandler::put_signal_property()
{
DEBUG_STREAM << __func__<<": SAVING " << it->first << endl;
alarms.save_alarm_conf_db(it->second.attr_name, it->second.name, it->second.stat, it->second.ack, it->second.enabled,
it->second.formula, it->second.on_delay, it->second.off_delay, it->second.grp2str(), it->second.lev, it->second.msg, it->second.cmd_name_a, it->second.cmd_name_n, it->second.silent_time);
it->second.formula, it->second.on_delay, it->second.off_delay, it->second.grp2str(), it->second.lev, it->second.msg, it->second.url, it->second.cmd_name_a, it->second.cmd_name_n, it->second.silent_time);
saved_alarms.insert(make_pair(it->first,conf_str));
}
......@@ -5410,7 +5420,7 @@ void AlarmHandler::put_signal_property()
{
DEBUG_STREAM << __func__<<": UPDATING " << it->first << endl;
alarms.save_alarm_conf_db(it->second.attr_name, it->second.name, it->second.stat, it->second.ack, it->second.enabled,
it->second.formula, it->second.on_delay, it->second.off_delay, it->second.grp2str(), it->second.lev, it->second.msg, it->second.cmd_name_a, it->second.cmd_name_n, it->second.silent_time);
it->second.formula, it->second.on_delay, it->second.off_delay, it->second.grp2str(), it->second.lev, it->second.msg, it->second.url, it->second.cmd_name_a, it->second.cmd_name_n, it->second.silent_time);
itmap->second = conf_string;
}
}
......@@ -5509,6 +5519,7 @@ void AlarmHandler::parse_alarm(string &alarm_string, alarm_t &alm)
alm.ex_origin.clear();
alm.formula.clear();
alm.msg.clear();
alm.url.clear();
alm.lev.clear();
alm.grp=0;
alm.to_be_evaluated = false;
......
......@@ -75,6 +75,7 @@
#define SILENT_TIME_KEY "shlvd_time"
#define GROUP_KEY "group"
#define MESSAGE_KEY "message"
#define URL_KEY "url"
#define ON_COMMAND_KEY "on_command"
#define OFF_COMMAND_KEY "off_command"
#define ENABLED_KEY "enabled"
......@@ -222,6 +223,7 @@ struct alarm_parse : public grammar<alarm_parse>
no_node_d[separator] >> no_node_d[silent_time] |
no_node_d[separator] >> no_node_d[group] |
no_node_d[separator] >> no_node_d[msg] |
no_node_d[separator] >> no_node_d[url] |
no_node_d[separator] >> no_node_d[on_command] |
no_node_d[separator] >> no_node_d[off_command] |
no_node_d[separator] >> no_node_d[enabled]
......@@ -270,12 +272,22 @@ struct alarm_parse : public grammar<alarm_parse>
msg
= discard_node_d[str_p(KEY(MESSAGE_KEY))]
//>> ch_p('"')
>> (+(anychar_p - ';')) //one ore more char except ';'
>> (+(anychar_p - ';')) //one ore more char except ';' TODO: handle escaped "\;"
[
assign_a(self.m_alarm.msg)
]
//>> '"'
;
//------------------------------URL--------------------------------------
url
= discard_node_d[str_p(KEY(URL_KEY))]
//>> ch_p('"')
>> (*(anychar_p - ';')) //zero ore more char except ';' TODO: handle escaped "\;"
[
assign_a(self.m_alarm.url)
]
//>> '"'
;
//---------------------------ON DELAY----------------------------------------
on_delay
= discard_node_d[str_p(KEY(ONDELAY_KEY))] >>
......@@ -346,7 +358,7 @@ struct alarm_parse : public grammar<alarm_parse>
rule_t expression, event, option;
rule<typename lexeme_scanner<ScannerT>::type> symbol; //needed to use lexeme_d in rule name
rule<typename lexeme_scanner<ScannerT>::type> symbol_attr_name; //needed to use lexeme_d in rule name
rule_t name, name_alm, val, token, oper, msg, group, level, on_delay, off_delay, silent_time, on_command, off_command, enabled, separator;
rule_t name, name_alm, val, token, oper, msg, url, group, level, on_delay, off_delay, silent_time, on_command, off_command, enabled, separator;
formula_grammar formula;
rule_t const&
......
......@@ -188,6 +188,7 @@ void alarm_t::confstr(string &s)
KEY(SILENT_TIME_KEY)<<silent_time << SEP <<
KEY(GROUP_KEY)<< grp2str() << SEP <<
KEY(MESSAGE_KEY)<< msg << SEP <<
KEY(URL_KEY)<< msg << SEP <<
KEY(ON_COMMAND_KEY)<< cmd_name_a << SEP <<
KEY(OFF_COMMAND_KEY)<< cmd_name_n << SEP <<
KEY(ENABLED_KEY)<< (enabled ? "1" : "0");
......@@ -838,8 +839,8 @@ void alarm_table::stop_cmdthread()
cmdloop->list.push_back(arg);
}
void alarm_table::save_alarm_conf_db(string att_name, string name, string status, string ack, bool enabled,
string formula, unsigned int on_delay, unsigned int off_delay, string grp, string lev, string msg, string cmd_a, string cmd_n, int silent_time, vector<string> alm_list)
void alarm_table::save_alarm_conf_db(const string &att_name, const string &name, const string &status, const string &ack, bool enabled,
const string &formula, unsigned int on_delay, unsigned int off_delay, const string &grp, const string &lev, const string &msg, const string &url, const string &cmd_a, const string &cmd_n, int silent_time)
{
// We want to put properties for attribute "att_name"
Tango::DbDatum dbd_att_name(att_name);
......@@ -851,22 +852,24 @@ void alarm_table::save_alarm_conf_db(string att_name, string name, string status
Tango::DbDatum dbd_silence_time(SILENT_TIME_KEY); //TODO: silent_time
Tango::DbDatum dbd_group(GROUP_KEY);
Tango::DbDatum dbd_message(MESSAGE_KEY);
Tango::DbDatum dbd_url(URL_KEY);
Tango::DbDatum dbd_oncommand(ON_COMMAND_KEY);
Tango::DbDatum dbd_offcommand(OFF_COMMAND_KEY);
Tango::DbDatum dbd_enabled(ENABLED_KEY);
Tango::DbData db_data;
dbd_att_name << (short int)11; // Eleven properties for attribute "att_name"
dbd_name << name;
dbd_formula << formula;
dbd_att_name << (short int)12; // Twelve properties for attribute "att_name"
dbd_name << name.c_str();
dbd_formula << formula.c_str();
dbd_on_delay << (Tango::DevLong)on_delay;
dbd_off_delay << (Tango::DevLong)off_delay;
dbd_level << lev;
dbd_level << lev.c_str();
dbd_silence_time << (Tango::DevLong)silent_time;
dbd_group << grp;
dbd_message << msg;
dbd_oncommand << cmd_a;
dbd_offcommand << cmd_n;
dbd_group << grp.c_str();
dbd_message << msg.c_str();
dbd_url << url.c_str();
dbd_oncommand << cmd_a.c_str();
dbd_offcommand << cmd_n.c_str();
dbd_enabled << (enabled ? (short int)1 : (short int)0);
db_data.push_back(dbd_att_name);
......@@ -878,6 +881,7 @@ void alarm_table::save_alarm_conf_db(string att_name, string name, string status
db_data.push_back(dbd_silence_time);
db_data.push_back(dbd_group);
db_data.push_back(dbd_message);
db_data.push_back(dbd_url);
db_data.push_back(dbd_oncommand);
db_data.push_back(dbd_offcommand);
db_data.push_back(dbd_enabled);
......@@ -907,6 +911,7 @@ void alarm_table::delete_alarm_conf_db(string att_name)
Tango::DbDatum dbd_silence_time(SILENT_TIME_KEY); //TODO: silent_time
Tango::DbDatum dbd_group(GROUP_KEY);
Tango::DbDatum dbd_message(MESSAGE_KEY);
Tango::DbDatum dbd_url(URL_KEY);
Tango::DbDatum dbd_oncommand(ON_COMMAND_KEY);
Tango::DbDatum dbd_offcommand(OFF_COMMAND_KEY);
Tango::DbDatum dbd_enabled(ENABLED_KEY);
......@@ -922,6 +927,7 @@ void alarm_table::delete_alarm_conf_db(string att_name)
db_data.push_back(dbd_silence_time);
db_data.push_back(dbd_group);
db_data.push_back(dbd_message);
db_data.push_back(dbd_url);
db_data.push_back(dbd_oncommand);
db_data.push_back(dbd_offcommand);
db_data.push_back(dbd_enabled);
......@@ -976,6 +982,7 @@ void alarm_table::get_alarm_list_db(vector<string> &al_list, map<string, string>
string alm_silence_time("-1");
string alm_group;
string alm_message;
string alm_url;
string alm_on_command("");
string alm_off_command("");
string alm_enabled("1");
......@@ -999,6 +1006,8 @@ void alarm_table::get_alarm_list_db(vector<string> &al_list, map<string, string>
db_data[i] >> alm_group;
else if (prop_name == MESSAGE_KEY)
db_data[i] >> alm_message;
else if (prop_name == URL_KEY)
db_data[i] >> alm_url;
else if (prop_name == ON_COMMAND_KEY)
db_data[i] >> alm_on_command;
else if (prop_name == OFF_COMMAND_KEY)
......@@ -1022,6 +1031,7 @@ void alarm_table::get_alarm_list_db(vector<string> &al_list, map<string, string>
KEY(SILENT_TIME_KEY)<<alm_silence_time << SEP <<
KEY(GROUP_KEY)<< alm_group << SEP <<
KEY(MESSAGE_KEY)<< alm_message << SEP <<
KEY(URL_KEY)<< alm_url << SEP <<
KEY(ON_COMMAND_KEY)<< alm_on_command << SEP <<
KEY(OFF_COMMAND_KEY)<< alm_off_command << SEP <<
KEY(ENABLED_KEY)<< alm_enabled;
......
......@@ -291,6 +291,7 @@ class alarm_t {
bool done;
bool to_be_evaluated;
string msg;
string url;
unsigned int grp;
string lev;
set<string> s_event;
......@@ -363,8 +364,8 @@ class alarm_table {
void new_rwlock();
void del_rwlock();
void save_alarm_conf_db(string att_name, string name, string status, string ack, bool enabled,
string formula, unsigned int on_delay, unsigned int off_delay, string grp, string lev, string msg, string cmd_a, string cmd_n, int silent_time, vector<string> alm_list=vector<string>());
void save_alarm_conf_db(const string &att_name, const string &name, const string &status, const string &ack, bool enabled,
const string &formula, unsigned int on_delay, unsigned int off_delay, const string &grp, const string &url, const string &lev, const string &msg, const string &cmd_a, const string &cmd_n, int silent_time);
void delete_alarm_conf_db(string att_name);
void get_alarm_list_db(vector<string> &al_list, map<string, string> &saved_alarms);
void init_cmdthread();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment