Newer
Older
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
//=============================================================================
string Alarm::remove_domain(string str)
{
string::size_type end1 = str.find(".");
if (end1 == string::npos)
{
return str;
}
else
{
string::size_type start = str.find("tango://");
if (start == string::npos)
{
start = 0;
}
else
{
start = 8; //tango:// len
}
string::size_type end2 = str.find(":", start);
if(end1 > end2) //'.' not in the tango host part
return str;
string th = str.substr(0, end1);
th += str.substr(end2, str.size()-end2);
return th;
}
}
//=============================================================================
//=============================================================================
bool Alarm::compare_without_domain(string str1, string str2)
{
string str1_nd = remove_domain(str1);
string str2_nd = remove_domain(str2);
return (str1_nd==str2_nd);
}
//=============================================================================
//=============================================================================
void Alarm::put_signal_property()
{
vector<string> prop;
#ifndef _RW_LOCK
alarms.lock();
#else
alarms.vlock->readerIn();
#endif
alarm_container_t::iterator it;
for(it = alarms.v_alarm.begin(); it != alarms.v_alarm.end(); it++)
{
prop.push_back(it->first);
}
#ifndef _RW_LOCK
alarms.unlock();
#else
alarms.vlock->readerOut();
#endif
Tango::DbData data;
data.push_back(Tango::DbDatum("AlarmList"));
data[0] << prop;
#ifndef _USE_ELETTRA_DB_RW
Tango::Database *db = new Tango::Database();
#else
//save properties using host_rw e port_rw to connect to database
Tango::Database *db;
if(host_rw != "")
db = new Tango::Database(host_rw,port_rw);
else
db = new Tango::Database();
DEBUG_STREAM << __func__<<": connecting to db "<<host_rw<<":"<<port_rw;
#endif
try
{
DECLARE_TIME_VAR t0, t1;
GET_TIME(t0);
db->set_timeout_millis(10000);
db->put_device_property(get_name(), data);
GET_TIME(t1);
DEBUG_STREAM << __func__ << ": saving properties size="<<prop.size()<<" -> " << ELAPSED(t0, t1) << " ms" << endl;
}
catch(Tango::DevFailed &e)
{
stringstream o;
o << " Error saving properties='" << e.errors[0].desc << "'";
WARN_STREAM << __FUNCTION__<< o.str();
}
delete db;
}

Graziano Scalamera
committed
/*----- PROTECTED REGION END -----*/ // Alarm::namespace_ending
} // namespace