Skip to content
Snippets Groups Projects
Commit fe6284ee authored by Alessio Igor Bogani's avatar Alessio Igor Bogani
Browse files

Use StatMaskX only as fallback for StateX/StatusX

parent 810bb350
No related branches found
No related tags found
No related merge requests found
......@@ -166,6 +166,7 @@ void Ionpump::init_device()
attr_Current_read = new Tango::DevDouble;
*attr_Current_read = 0;
attrs.clear();
/*----- PROTECTED REGION END -----*/ // Ionpump::init_device_before
// No device property to be read from database
......@@ -173,11 +174,14 @@ void Ionpump::init_device()
/*----- PROTECTED REGION ID(Ionpump::init_device) ENABLED START -----*/
// Initialize device
char attr[20];
try {
get_ps_name();
}
catch(Tango::DevFailed &e) {
sprintf(attr,"State%d",channel);
attrs.push_back(attr);
sprintf(attr,"Status%d",channel);
attrs.push_back(attr);
} catch(Tango::DevFailed &e) {
cout << "Can't get dual name" << endl;
exit(1);
}
......@@ -198,46 +202,20 @@ void Ionpump::always_executed_hook()
/*----- PROTECTED REGION ID(Ionpump::always_executed_hook) ENABLED START -----*/
// code always executed before all requests
/*
* bit 0 = off(0) --- on(1)
* bit 1 = loc(0) --- rem(1)
* bit 2 = noerr(0) --- err(1)
* bit 3 = fix(0) --- step(1)
* bit 4 = start(0) --- protect(1)
* bit 5 = panel interlock (1 = active)
* bit 6 = remote interlock (1 = active)
* bit 7 = cable interlock (1 = active)
*/
char mask[14];
std::stringstream s;
sprintf(mask,"StatMask%d",channel);
string stat_attr(mask);
Tango::DevLong statmask = 0;
try {
devps->read_attribute(stat_attr) >> statmask;
if ((statmask & 0x4) || (statmask & 0xE0)) {
set_state(Tango::FAULT);
s << "Ion pump ERROR" << endl;
} else {
if (statmask & 0x1) {
set_state(Tango::ON);
s << "Ion pump is ON" << endl;
} else {
set_state(Tango::OFF);
s << "Ion pump is OFF" << endl;
}
}
vector<Tango::DeviceAttribute> *devattrs = NULL;
Tango::DevState state;
string status;
try {
devattrs = devps->read_attributes(attrs);
(*devattrs)[0] >> state;
(*devattrs)[1] >> status;
set_state(state);
set_status(status);
} catch(Tango::DevFailed &e) {
set_state(Tango::FAULT);
s << "Error reading PS status" << endl;
}
// Fallback to StatMaskX
get_statmask();
}
set_status(s.str());
/*----- PROTECTED REGION END -----*/ // Ionpump::always_executed_hook
}
......@@ -521,6 +499,51 @@ void Ionpump::get_ps_name()
}
void Ionpump::get_statmask()
{
DEBUG_STREAM << "Dual::get_statmask(): entering... !" << endl;
/*
* bit 0 = off(0) --- on(1)
* bit 1 = loc(0) --- rem(1)
* bit 2 = noerr(0) --- err(1)
* bit 3 = fix(0) --- step(1)
* bit 4 = start(0) --- protect(1)
* bit 5 = panel interlock (1 = active)
* bit 6 = remote interlock (1 = active)
* bit 7 = cable interlock (1 = active)
*/
char mask[14];
std::stringstream s;
sprintf(mask,"StatMask%d",channel);
string stat_attr(mask);
Tango::DevLong statmask = 0;
try {
devps->read_attribute(stat_attr) >> statmask;
if ((statmask & 0x4) || (statmask & 0xE0)) {
set_state(Tango::FAULT);
s << "Ion pump ERROR" << endl;
} else {
if (statmask & 0x1) {
set_state(Tango::ON);
s << "Ion pump is ON" << endl;
} else {
set_state(Tango::OFF);
s << "Ion pump is OFF" << endl;
}
}
} catch(Tango::DevFailed &e) {
set_state(Tango::FAULT);
s << "Error reading PS status" << endl;
}
set_status(s.str());
}
/*----- PROTECTED REGION END -----*/ // Ionpump::namespace_ending
} // namespace
......@@ -69,8 +69,7 @@ class Ionpump : public TANGO_BASE_CLASS
// Add your own data members
public:
vector<string> attrs;
/*----- PROTECTED REGION END -----*/ // Ionpump::Data Members
......@@ -202,6 +201,7 @@ protected :
* Get sip names from database
*/
void get_ps_name(void);
void get_statmask(void);
/*----- PROTECTED REGION END -----*/ // Ionpump::Additional Method prototypes
};
......
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