Commit 77073326 authored by Nicolas Tappret's avatar Nicolas Tappret

improve the beaviour of setpoint for read/write attribute. remove update attribute command

parent 675c2776
......@@ -59,7 +59,6 @@
// State | dev_state
// Status | Inherited (no method)
// ResetError | reset_error
// UpdateSetpoint | update_setpoint
// EnableDevice | enable_device
// DisableDevice | disable_device
// Indice2Devicename | indice2_devicename
......@@ -677,26 +676,6 @@ void AttributeCombiner::reset_error()
/*----- PROTECTED REGION END -----*/ // AttributeCombiner::reset_error
}
//--------------------------------------------------------
/**
* Command UpdateSetpoint related method
* Description: Update local setpoints from device setpoints
*
*/
//--------------------------------------------------------
void AttributeCombiner::update_setpoint()
{
DEBUG_STREAM << "AttributeCombiner::UpdateSetpoint() - " << device_name << endl;
/*----- PROTECTED REGION ID(AttributeCombiner::update_setpoint) ENABLED START -----*/
// Force update of setpoints at the next reading
for (int i = 0; i < (int) attMap.size(); i++) {
ATTITEM *item = attMap.get(i);
item->setInit = false;
}
/*----- PROTECTED REGION END -----*/ // AttributeCombiner::update_setpoint
}
//--------------------------------------------------------
/**
* Command EnableDevice related method
* Description: Enable device
......@@ -948,17 +927,21 @@ void AttributeCombiner::add_dynamic_commands()
bool firstValue = true;
int nbAtt = (int) item->attNames.size();
int nbDev = (int) deviceGroup->get_size();
inType setPoint;
for (int i = 0; i < nbDev; i++) {
for (int j = 0; j < nbAtt; j++) {
if (!arl[j][i].has_failed() && arl[j][i].group_element_enabled()) {
inType val;
vector<inType> val;
arl[j][i] >> val;
if (firstValue) {
value = val;
value = val[0];
if(item->rwType == Tango::READ_WRITE){
setPoint = val[1];
}
firstValue = false;
} else {
allEqual = allEqual && (val == value);
allEqual = allEqual && (val[0] == value);
}
} else {
if (arl[j][i].group_element_enabled()) {
......@@ -977,11 +960,9 @@ void AttributeCombiner::add_dynamic_commands()
if (!allEqual && item->manageAlarm)
attr.set_quality(Tango::ATTR_ALARM);
if (!item->setInit &&
item->rwType == Tango::READ_WRITE) {
if (item->rwType == Tango::READ_WRITE) {
Tango::WAttribute &att = getAtt(attName);
att.set_write_value(value);
item->setInit = true;
att.set_write_value(setPoint);
}
}
......@@ -1142,32 +1123,46 @@ void AttributeCombiner::add_dynamic_commands()
int size = nbDev * nbAtt;
// Read scalar attribute and combime them to spectrum
outType *result = new outType[size];
outType *readVal = new outType[size];
outType *readSetPoint = new outType[size];
for (int i = 0; i < nbDev; i++) {
for (int j = 0; j < nbAtt; j++) {
if (arl[j][i].has_failed()) {
result[i * nbAtt + j] = invalid;
readVal[i * nbAtt + j] = invalid;
readSetPoint[i * nbAtt + j] = invalid;
addError(i, arl[j][i]);
} else {
if (arl[j][i].group_element_enabled()) {
inType v;
vector<inType> v;
arl[j][i] >> v;
result[i * nbAtt + j] = (outType) v;
readVal[i * nbAtt + j] = (outType) v[0];
if(item->rwType){
readSetPoint[i * nbAtt + j] = (outType) v[1];
}
} else {
result[i * nbAtt + j] = disableValue;
readVal[i * nbAtt + j] = disableValue;
readSetPoint[i * nbAtt + j] = disableValue;
}
}
}
}
if (!item->setInit &&
item->rwType == Tango::READ_WRITE) {
if (item->rwType == Tango::READ_WRITE) {
Tango::WAttribute &att = getAtt(attName);
att.set_write_value(result, size);
item->setInit = true;
att.set_write_value(readSetPoint, size);
if (size != item->cacheSize && item->cacheReadPointData != nullptr) {
SAFE_FREE(item->cacheData);
}
if (item->cacheReadPointData == nullptr) {
item->cacheReadPointData = (void *) malloc(size * sizeof (outType));
}
memcpy(item->cacheReadPointData, readSetPoint, size * sizeof (outType));
}
//Update cache
......@@ -1182,9 +1177,9 @@ void AttributeCombiner::add_dynamic_commands()
item->cacheSize = size;
}
memcpy(item->cacheData, result, size * sizeof (outType));
memcpy(item->cacheData, readVal, size * sizeof (outType));
attr.set_value(result, size, 0, true);
attr.set_value(readVal, size, 0, true);
}
......@@ -1697,6 +1692,10 @@ void AttributeCombiner::add_dynamic_commands()
attr.set_value((Tango::DevState *)item->cacheData, item->cacheSize);
}else{
attr.set_value((Tango::DevDouble *)item->cacheData, item->cacheSize);
if(item->rwType == Tango::READ_WRITE){
Tango::WAttribute &att = getAtt(item->attName);
att.set_write_value((Tango::DevDouble *)item->cacheReadPointData, item->cacheSize);
}
}
}
......
......@@ -254,13 +254,6 @@ public:
*/
virtual void reset_error();
virtual bool is_ResetError_allowed(const CORBA::Any &any);
/**
* Command UpdateSetpoint related method
* Description: Update local setpoints from device setpoints
*
*/
virtual void update_setpoint();
virtual bool is_UpdateSetpoint_allowed(const CORBA::Any &any);
/**
* Command EnableDevice related method
* Description: Enable device
......
......@@ -58,15 +58,6 @@
</argout>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
</commands>
<commands name="UpdateSetpoint" description="Update local setpoints from device setpoints" execMethod="update_setpoint" displayLevel="OPERATOR" polledPeriod="0" isDynamic="false">
<argin description="">
<type xsi:type="pogoDsl:VoidType"/>
</argin>
<argout description="">
<type xsi:type="pogoDsl:VoidType"/>
</argout>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
</commands>
<commands name="EnableDevice" description="Enable device" execMethod="enable_device" displayLevel="OPERATOR" polledPeriod="0" isDynamic="false">
<argin description="Enable device #i">
<type xsi:type="pogoDsl:ShortType"/>
......
......@@ -170,24 +170,6 @@ CORBA::Any *ResetErrorClass::execute(Tango::DeviceImpl *device, TANGO_UNUSED(con
return new CORBA::Any();
}
//--------------------------------------------------------
/**
* method : UpdateSetpointClass::execute()
* description : method to trigger the execution of the command.
*
* @param device The device on which the command must be executed
* @param in_any The command input data
*
* returns The command output data (packed in the Any object)
*/
//--------------------------------------------------------
CORBA::Any *UpdateSetpointClass::execute(Tango::DeviceImpl *device, TANGO_UNUSED(const CORBA::Any &in_any))
{
cout2 << "UpdateSetpointClass::execute(): arrived" << endl;
((static_cast<AttributeCombiner *>(device))->update_setpoint());
return new CORBA::Any();
}
//--------------------------------------------------------
/**
* method : EnableDeviceClass::execute()
......@@ -686,15 +668,6 @@ void AttributeCombinerClass::command_factory()
Tango::OPERATOR);
command_list.push_back(pResetErrorCmd);
// Command UpdateSetpoint
UpdateSetpointClass *pUpdateSetpointCmd =
new UpdateSetpointClass("UpdateSetpoint",
Tango::DEV_VOID, Tango::DEV_VOID,
"",
"",
Tango::OPERATOR);
command_list.push_back(pUpdateSetpointCmd);
// Command EnableDevice
EnableDeviceClass *pEnableDeviceCmd =
new EnableDeviceClass("EnableDevice",
......
......@@ -222,29 +222,6 @@ public:
{return (static_cast<AttributeCombiner *>(dev))->is_ResetError_allowed(any);}
};
// Command UpdateSetpoint class definition
class UpdateSetpointClass : public Tango::Command
{
public:
UpdateSetpointClass(const char *name,
Tango::CmdArgType in,
Tango::CmdArgType out,
const char *in_desc,
const char *out_desc,
Tango::DispLevel level)
:Command(name,in,out,in_desc,out_desc, level) {};
UpdateSetpointClass(const char *name,
Tango::CmdArgType in,
Tango::CmdArgType out)
:Command(name,in,out) {};
~UpdateSetpointClass() {};
virtual CORBA::Any *execute (Tango::DeviceImpl *dev, const CORBA::Any &any);
virtual bool is_allowed (Tango::DeviceImpl *dev, const CORBA::Any &any)
{return (static_cast<AttributeCombiner *>(dev))->is_UpdateSetpoint_allowed(any);}
};
// Command EnableDevice class definition
class EnableDeviceClass : public Tango::Command
{
......
......@@ -100,21 +100,6 @@ bool AttributeCombiner::is_ResetError_allowed(TANGO_UNUSED(const CORBA::Any &any
return true;
}
//--------------------------------------------------------
/**
* Method : AttributeCombiner::is_UpdateSetpoint_allowed()
* Description : Execution allowed for UpdateSetpoint attribute
*/
//--------------------------------------------------------
bool AttributeCombiner::is_UpdateSetpoint_allowed(TANGO_UNUSED(const CORBA::Any &any))
{
// Not any excluded states for UpdateSetpoint command.
/*----- PROTECTED REGION ID(AttributeCombiner::UpdateSetpointStateAllowed) ENABLED START -----*/
/*----- PROTECTED REGION END -----*/ // AttributeCombiner::UpdateSetpointStateAllowed
return true;
}
//--------------------------------------------------------
/**
* Method : AttributeCombiner::is_EnableDevice_allowed()
......
......@@ -55,6 +55,9 @@ namespace AttributeCombiner_ns {
SAFE_FREE(map[i]->refData);
if (map[i]->cacheData != nullptr && map[i]->cacheSize > 0) {
SAFE_FREE(map[i]->cacheData);
if(map[i]->rwType == Tango::READ_WRITE){
SAFE_FREE(map[i]->cacheReadPointData);
}
}
MY_SAFE_DELETE(map[i]);
}
......@@ -71,13 +74,13 @@ namespace AttributeCombiner_ns {
newItem->attNames.clear();
newItem->type = Tango::DEV_DOUBLE;
newItem->rwType = Tango::READ_WRITE;
newItem->setInit = false;
newItem->isSpectrum = true;
newItem->lengthAttName = "";
newItem->isRef = true;
newItem->isDiff = false;
newItem->refData = nullptr;
newItem->cacheData = nullptr;
newItem->cacheReadPointData = nullptr;
newItem->cacheSize = 0;
newItem->refSize = 0;
newItem->refItem = nullptr;
......@@ -112,13 +115,13 @@ namespace AttributeCombiner_ns {
newItem->attNames.clear();
newItem->type = Tango::DEV_DOUBLE;
newItem->rwType = Tango::READ;
newItem->setInit = false;
newItem->isSpectrum = true;
newItem->lengthAttName = "";
newItem->isRef = false;
newItem->isDiff = true;
newItem->refData = nullptr;
newItem->cacheData = nullptr;
newItem->cacheReadPointData = nullptr;
newItem->cacheSize = 0;
newItem->refSize = 0;
newItem->refItem = refItem;
......@@ -152,7 +155,6 @@ namespace AttributeCombiner_ns {
newItem->attNames = attNames;
newItem->type = type;
newItem->rwType = rwType;
newItem->setInit = false;
newItem->isSpectrum = isSpectrum;
newItem->lengthAttName = lgthAttName;
newItem->isRef = false;
......
......@@ -44,7 +44,6 @@ struct ATTITEM {
bool grouped; // Map all attribute to a single one when true
int type; // Tango type
int rwType; // Read write
bool setInit; // true if setpoint has been initialized
std::string lengthAttName; // Name of the length attribute for multiple spectrum
bool isSpectrum; // Is a multiple spectrum attribute
bool manageAlarm; // true if the attribute should switch ot alarm when values are not equal
......@@ -71,6 +70,7 @@ struct ATTITEM {
Tango::DevDouble *refData;
int cacheSize;
void *cacheData;
void *cacheReadPointData;
};
......
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