Commit 17f375ae authored by Nicolas Tappret's avatar Nicolas Tappret

add default behavior for state and status

parent a447aa8f
......@@ -1344,6 +1344,7 @@ void AttributeCombiner::add_dynamic_commands()
else {
if (attName == "States") {
READSCALAR<Tango::DevState, Tango::DevState>(attr, item, arl, Tango::UNKNOWN, Tango::DISABLE);
comupteGobalState(attr);
} else {
READSCALAR<Tango::DevState, Tango::DevState>(attr, item, arl, Tango::UNKNOWN, Tango::UNKNOWN);
}
......@@ -1720,6 +1721,49 @@ void AttributeCombiner::add_dynamic_commands()
Tango::DeviceAttribute daWrite(attrToSave->refItem->attName.c_str(),dataForRef);
self->write_attribute(daWrite);
}
void AttributeCombiner::comupteGobalState(Tango::Attribute &attr){
Tango::DevVarStateArray * states = attr.get_state_value();
Tango::DevState globalState = (*states)[0];
long size = attr.get_data_size();
string status = "";
for(long i = 0 ; i < size ; i++){
status += deviceList[i] + ":" + Tango::DevStateName[(*states)[i]] + "\n";
globalState = getWorst(globalState,(*states)[i]);
}
set_state(globalState);
set_status(status);
}
Tango::DevState AttributeCombiner::getWorst(Tango::DevState &s1, Tango::DevState &s2) {
if (s1 == Tango::FAULT || s2 == Tango::FAULT) {
return Tango::FAULT;
}
if (s1 == Tango::UNKNOWN || s2 == Tango::UNKNOWN) {
return Tango::UNKNOWN;
}
if (s1 == Tango::ALARM || s2 == Tango::ALARM) {
return Tango::ALARM;
}
if (s1 == Tango::MOVING || s2 == Tango::MOVING) {
return Tango::MOVING;
}
if (s1 == Tango::STANDBY || s2 == Tango::STANDBY) {
return Tango::STANDBY;
}
if (s1 == Tango::ON && s2 == Tango::ON) {
return Tango::ON;
}else if (s1 == Tango::OFF && s2 == Tango::OFF) {
return Tango::OFF;
}else if (s1 == Tango::OPEN && s2 == Tango::OPEN) {
return Tango::OPEN;
}else if (s1 == Tango::CLOSE && s2 == Tango::CLOSE) {
return Tango::CLOSE;
}
return Tango::ALARM;
}
// //--------------------------------------------------------
// /**
// * Command saveReference related method
......
......@@ -332,6 +332,9 @@ public:
template <typename T>
void saveAttribute(ATTITEM * attrToSave);
void comupteGobalState(Tango::Attribute &attr);
Tango::DevState getWorst(Tango::DevState &s1, Tango::DevState &s2);
/*----- PROTECTED REGION END -----*/ // AttributeCombiner::Additional Method prototypes
};
......
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