Commit bbf51d30 authored by Nicolas Tappret's avatar Nicolas Tappret

add default behavior for state and status

parent 17f375ae
......@@ -56,7 +56,7 @@
//
// Command name | Method name
//================================================================
// State | Inherited (no method)
// State | dev_state
// Status | Inherited (no method)
// ResetError | reset_error
// UpdateSetpoint | update_setpoint
......@@ -612,6 +612,39 @@ void AttributeCombiner::add_dynamic_attributes()
/*----- PROTECTED REGION END -----*/ // AttributeCombiner::add_dynamic_attributes
}
//--------------------------------------------------------
/**
* Command State related method
* Description: This command gets the device state (stored in its device_state data member) and returns it to the caller.
*
* @returns Device state
*/
//--------------------------------------------------------
Tango::DevState AttributeCombiner::dev_state()
{
DEBUG_STREAM << "AttributeCombiner::State() - " << device_name << endl;
/*----- PROTECTED REGION ID(AttributeCombiner::dev_state) ENABLED START -----*/
vector<Tango::DevState> states;
Tango::DeviceAttribute da = self->read_attribute("states");
da >> states;
Tango::DevState argout = states[0];
unsigned int size = states.size();
string status = "";
for( unsigned int i = 0 ; i < size ; i++){
status += deviceList[i] + ":" + Tango::DevStateName[states[i]] + "\n";
argout = getWorst(argout,states[i]);
}
set_status(status);
/*----- PROTECTED REGION END -----*/ // AttributeCombiner::dev_state
set_state(argout); // Give the state to Tango.
if (argout!=Tango::ALARM)
Tango::DeviceImpl::dev_state();
return get_state(); // Return it after Tango management.
}
//--------------------------------------------------------
/**
* Command ResetError related method
......@@ -1344,7 +1377,6 @@ 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);
}
......@@ -1721,22 +1753,7 @@ 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;
......
......@@ -240,6 +240,13 @@ public:
// Command related methods
public:
/**
* Command State related method
* Description: This command gets the device state (stored in its device_state data member) and returns it to the caller.
*
* @returns Device state
*/
virtual Tango::DevState dev_state();
/**
* Command ResetError related method
* Description: Reset Error stack
......@@ -332,7 +339,6 @@ public:
template <typename T>
void saveAttribute(ATTITEM * attrToSave);
void comupteGobalState(Tango::Attribute &attr);
Tango::DevState getWorst(Tango::DevState &s1, Tango::DevState &s2);
......
<?xml version="1.0" encoding="ASCII"?>
<pogoDsl:PogoSystem xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:pogoDsl="http://www.esrf.fr/tango/pogo/PogoDsl">
<classes name="AttributeCombiner" pogoRevision="9.6">
<description description="A class to combine attributes coming from several devices" title="AttributeCombiner" sourcePath="/mntdirect/_segfs/tango/cppserver/calculation/AttributeCombiner.working" language="Cpp" filestogenerate="XMI file,Code files,Protected Regions" license="GPL" copyright="Copyright (C): 2018&#xA; European Synchrotron Radiation Facility&#xA; BP 220, Grenoble 38043&#xA; France" hasMandatoryProperty="false" hasConcreteProperty="true" hasAbstractCommand="false" hasAbstractAttribute="false">
<description description="A class to combine attributes coming from several devices" title="AttributeCombiner" sourcePath="/mntdirect/_segfs/tango/cppserver/calculation/AttributeCombiner" language="Cpp" filestogenerate="XMI file,Code files,Protected Regions" license="GPL" copyright="Copyright (C): 2018&#xA; European Synchrotron Radiation Facility&#xA; BP 220, Grenoble 38043&#xA; France" hasMandatoryProperty="false" hasConcreteProperty="true" hasAbstractCommand="false" hasAbstractAttribute="false">
<inheritances classname="Device_Impl" sourcePath=""/>
<identification contact="at esrf.fr - pons" author="pons" emailDomain="esrf.fr" classFamily="Calculation" siteSpecific="" platform="All Platforms" bus="Not Applicable" manufacturer="none" reference=""/>
</description>
......@@ -31,14 +31,14 @@
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
<DefaultPropValue>1000</DefaultPropValue>
</deviceProperties>
<commands name="State" description="This command gets the device state (stored in its device_state data member) and returns it to the caller." execMethod="dev_state" displayLevel="OPERATOR" polledPeriod="0">
<commands name="State" description="This command gets the device state (stored in its device_state data member) and returns it to the caller." execMethod="dev_state" displayLevel="OPERATOR" polledPeriod="0" isDynamic="false">
<argin description="none">
<type xsi:type="pogoDsl:VoidType"/>
</argin>
<argout description="Device state">
<type xsi:type="pogoDsl:StateType"/>
</argout>
<status abstract="true" inherited="true" concrete="true"/>
<status abstract="true" inherited="true" concrete="true" concreteHere="true"/>
</commands>
<commands name="Status" description="This command gets the device status (stored in its device_status data member) and returns it to the caller." execMethod="dev_status" displayLevel="OPERATOR" polledPeriod="0">
<argin description="none">
......
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