Commit d12b1dde authored by Jean-Luc Pons's avatar Jean-Luc Pons

Correction

parent 43980075
......@@ -1129,83 +1129,85 @@ void AttributeCombiner::add_dynamic_commands()
template <typename inType, typename outType>
void AttributeCombiner::READSCALAR(Tango::Attribute &attr, ATTITEM *item, Tango::GroupAttrReplyList arl[], outType invalid, outType disableValue) {
string& attName = attr.get_name();
int nbAtt = (int) item->attNames.size();
int nbDev = deviceGroup->get_size();
int size = nbDev * nbAtt;
string &attName = attr.get_name();
int nbAtt = (int) item->attNames.size();
int nbDev = deviceGroup->get_size();
int size = nbDev * nbAtt;
// Read scalar attribute and combime them to spectrum
outType *readVal = new outType[size];
outType *readSetPoint = nullptr;
// Read scalar attribute and combime them to spectrum
outType *readVal = new outType[size];
outType *readSetPoint = nullptr;
if( item->rwType == Tango::READ_WRITE ) {
// Allocate memory for setpoint
readSetPoint = new outType[size];
}
bool isRW = item->rwType == Tango::READ_WRITE;
for (int i = 0; i < nbDev; i++) {
if (isRW) {
// Allocate memory for setpoint
readSetPoint = new outType[size];
}
for (int j = 0; j < nbAtt; j++) {
if (arl[j][i].has_failed()) {
readVal[i * nbAtt + j] = invalid;
readSetPoint[i * nbAtt + j] = invalid;
addError(i, arl[j][i]);
} else {
if (arl[j][i].group_element_enabled()) {
if(item->type != Tango::DEV_STATE && item->rwType == Tango::READ_WRITE){
vector<inType> v;
arl[j][i] >> v;
readVal[i * nbAtt + j] = (outType) v[0];
readSetPoint[i * nbAtt + j] = (outType) v[1];
}else{
inType v;
arl[j][i] >> v;
readVal[i * nbAtt + j] = (outType) v;
}
} else {
readVal[i * nbAtt + j] = disableValue;
readSetPoint[i * nbAtt + j] = disableValue;
}
}
}
for (int i = 0; i < nbDev; i++) {
for (int j = 0; j < nbAtt; j++) {
if (arl[j][i].has_failed()) {
readVal[i * nbAtt + j] = invalid;
if (isRW) readSetPoint[i * nbAtt + j] = invalid;
addError(i, arl[j][i]);
} else {
if (arl[j][i].group_element_enabled()) {
if (item->type != Tango::DEV_STATE && isRW) {
vector<inType> v;
arl[j][i] >> v;
readVal[i * nbAtt + j] = (outType) v[0];
readSetPoint[i * nbAtt + j] = (outType) v[1];
} else {
inType v;
arl[j][i] >> v;
readVal[i * nbAtt + j] = (outType) v;
}
} else {
readVal[i * nbAtt + j] = disableValue;
if (isRW) readSetPoint[i * nbAtt + j] = disableValue;
}
}
}
// Update setpoint value
if (item->rwType == Tango::READ_WRITE) {
}
Tango::WAttribute &att = getAtt(attName);
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 setpoint value
if (isRW) {
delete readSetPoint;
Tango::WAttribute &att = getAtt(attName);
att.set_write_value(readSetPoint, size);
if (size != item->cacheSize && item->cacheReadPointData != nullptr) {
SAFE_FREE(item->cacheData);
}
//Update cache
item->lastUpdate = timeMS();
if (size != item->cacheSize && item->cacheData != nullptr) {
SAFE_FREE(item->cacheData);
if (item->cacheReadPointData == nullptr) {
item->cacheReadPointData = (void *) malloc(size * sizeof(outType));
}
if (item->cacheData == nullptr) {
item->cacheData = (void *) malloc(size * sizeof (outType));
item->cacheSize = size;
}
memcpy(item->cacheReadPointData, readSetPoint, size * sizeof(outType));
delete readSetPoint;
}
//Update cache
item->lastUpdate = timeMS();
if (size != item->cacheSize && item->cacheData != nullptr) {
SAFE_FREE(item->cacheData);
}
if (item->cacheData == nullptr) {
item->cacheData = (void *) malloc(size * sizeof(outType));
item->cacheSize = size;
}
memcpy(item->cacheData, readVal, size * sizeof (outType));
memcpy(item->cacheData, readVal, size * sizeof(outType));
attr.set_value(readVal, size, 0, true);
attr.set_value(readVal, size, 0, true);
}
......
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