Commit f246583a authored by Graziano Scalamera's avatar Graziano Scalamera
Browse files

Fix is_new in ERROR alarms

parent 46109c47
......@@ -367,7 +367,6 @@ void AlarmHandler::init_device()
internallock = new(ReadersWritersLock);
dslock = new(ReadersWritersLock);
alarms.set_dev(this);
alarms.set_err_delay(errorDelay);
/*----- PROTECTED REGION END -----*/ // AlarmHandler::init_device_before
......@@ -400,6 +399,7 @@ void AlarmHandler::init_device()
alarmSummary_read[i].resize(MAX_ATTR_SUMMARY);
}*/
// Initialize device
alarms.set_err_delay(errorDelay);
thread->period = subscribeRetryPeriod;
#ifdef _USE_ELETTRA_DB_RW
......@@ -3057,6 +3057,8 @@ void AlarmHandler::load_alarm(string alarm_string, alarm_t &alm, vector<string>
alm.ex_desc=string("One or more events not subscribed");
alm.ex_origin.clear();
alm.error = false;
alm.ts_err_delay = gettime();
alm.ts_err_delay.tv_sec -= errorDelay;
alm.err_counter = 0;
alm.formula.clear();
alm.msg.clear();
......@@ -3458,6 +3460,7 @@ void AlarmHandler::do_alarm(bei_t& e)
}
if(found_ev != events->v_event.end())
{
Tango::TimeVal ts = gettime();
found_ev->err_counter++;
if(e.type == TYPE_TANGO_ERR)
found_ev->ex_reason = string("Event_ERROR");
......@@ -3489,11 +3492,17 @@ void AlarmHandler::do_alarm(bei_t& e)
it->second.ex_origin = found_ev->ex_origin;
if(errorDelay > 0)
{
if((it->second.ts.tv_sec - errorDelay) > it->second.ts_err_delay.tv_sec) //error is present and err delay has passed
if((ts.tv_sec - errorDelay) > it->second.ts_err_delay.tv_sec) //error is present and err delay has passed
{
if(!it->second.error)
it->second.is_new = 1;
it->second.error = true;
}
}
else
{
{
if(!it->second.error)
it->second.is_new = 1;
it->second.error = true;
}
alarm_t alm = it->second;
......
......@@ -339,7 +339,7 @@ void alarm_table::stored(vector<alarm_t>& a)
bool alarm_table::update(const string& alm_name, Tango::TimeVal ts, formula_res_t res, string &attr_values, string grp, string msg, string formula)
{
bool ret_changed=false;
//Tango::TimeVal now = gettime();
Tango::TimeVal now = gettime();
TangoSys_MemStream out_stream;
vlock->readerIn();
alarm_container_t::iterator found = v_alarm.find(alm_name);
......@@ -365,7 +365,7 @@ bool alarm_table::update(const string& alm_name, Tango::TimeVal ts, formula_res_
}
bool status_err_delay;
if(err_delay > 0)
status_err_delay = (!res.ex_reason.empty() || !res.ex_desc.empty() || !res.ex_origin.empty()) && (found->second.err_counter >= 1) && ((ts.tv_sec - err_delay) > found->second.ts_err_delay.tv_sec); //error is present and err delay has passed
status_err_delay = (!res.ex_reason.empty() || !res.ex_desc.empty() || !res.ex_origin.empty()) && (found->second.err_counter >= 1) && ((now.tv_sec - err_delay) > found->second.ts_err_delay.tv_sec); //error is present and err delay has passed
else
status_err_delay = (!res.ex_reason.empty() || !res.ex_desc.empty() || !res.ex_origin.empty());
found->second.quality = res.quality;
......@@ -504,7 +504,11 @@ bool alarm_table::update(const string& alm_name, Tango::TimeVal ts, formula_res_
ret_changed=true;
}
if(status_err_delay)
{
if(!found->second.error)
found->second.is_new = 1;
found->second.error = true;
}
if((bool)(res.value != 0)) {
found->second.on_counter++;
......@@ -558,7 +562,7 @@ bool alarm_table::timer_update()
bool status_err_delay=false;
if(err_delay > 0) //if enabled off delay
status_err_delay = (i->second.err_counter >= 1) && ((ts.tv_sec - err_delay) > i->second.ts_err_delay.tv_sec); //waiting for err delay has passed
if(i->second.on_delay == 0 && i->second.off_delay == 0 && err_delay == 0 && !i->second.shelved && i->second.silenced <=0)
continue; //if not enabled on or off delay or not shelved, nothing to do in timer
if(i->second.on_delay > 0) //if enabled on delay
......@@ -609,6 +613,8 @@ bool alarm_table::timer_update()
ret_changed = true;
if(status_err_delay)
{
if(!i->second.error)
i->second.is_new = 1;
i->second.error = true;
}
......
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