Commit a447aa8f authored by Nicolas Tappret's avatar Nicolas Tappret

fix cache return if you have other type than DevDouble

parent 3557c81b
......@@ -576,6 +576,12 @@ void AttributeCombiner::add_dynamic_attributes()
ATTITEM * refItem = attMap.get(name);
ATTITEM * liveItem = attMap.get(attrLiveName);
if(liveItem->type == Tango::DEV_STATE){
cerr << "ERROR: Wrong Type of Live attribute " << fields[1] << endl;
cerr << "ERROR: The Type DevState is not supported for difference" << endl;
exit(0);
}
//add pointer to ref attribute for save attribute
liveItem->refItem = refItem;
refItem->liveItem = liveItem;
......@@ -1242,54 +1248,8 @@ void AttributeCombiner::add_dynamic_commands()
item->cacheSize = diffLength;
}
Tango::DevDouble * liveCacheData = new Tango::DevDouble[diffLength];
ATTITEM * itemLive = item->liveItem;
switch (item->type) {
case Tango::DEV_BOOLEAN:
convertTypePtrToDoublePtr((Tango::DevBoolean *)itemLive->cacheData, liveCacheData, diffLength);
break;
case Tango::DEV_ENUM:
convertTypePtrToDoublePtr((Tango::DevEnum *)itemLive->cacheData, liveCacheData, diffLength);
break;
case Tango::DEV_USHORT:
convertTypePtrToDoublePtr((Tango::DevUShort *)itemLive->cacheData, liveCacheData, diffLength);
break;
case Tango::DEV_SHORT:
convertTypePtrToDoublePtr((Tango::DevShort *)itemLive->cacheData, liveCacheData, diffLength);
break;
case Tango::DEV_LONG:
convertTypePtrToDoublePtr((Tango::DevLong *)itemLive->cacheData, liveCacheData, diffLength);
break;
case Tango::DEV_ULONG:
convertTypePtrToDoublePtr((Tango::DevULong *)itemLive->cacheData, liveCacheData, diffLength);
break;
case Tango::DEV_LONG64:
convertTypePtrToDoublePtr((Tango::DevLong64 *)itemLive->cacheData, liveCacheData, diffLength);
break;
case Tango::DEV_ULONG64:
convertTypePtrToDoublePtr((Tango::DevLong64 *)itemLive->cacheData, liveCacheData, diffLength);
break;
case Tango::DEV_STATE:
convertTypePtrToDoublePtr((Tango::DevState *)itemLive->cacheData, liveCacheData, diffLength);
break;
case Tango::DEV_DOUBLE:
liveCacheData = (Tango::DevDouble *)itemLive->cacheData;
break;
}
Tango::DevDouble * liveCacheData = (Tango::DevDouble *)item->liveItem->cacheData;
Tango::DevDouble * cacheDataPtr = (Tango::DevDouble *)item->cacheData;
for (int i = 0; i < diffLength; i++) {
cacheDataPtr[i] = liveCacheData[i] - item->refItem->refData[i];
......@@ -1685,52 +1645,11 @@ void AttributeCombiner::add_dynamic_commands()
return tp.tv_sec * 1000 + tp.tv_usec / 1000;
}
template <typename inType>
void AttributeCombiner::convertTypePtrToDoublePtr(inType * cacheData, Tango::DevDouble * cacheConverted, int nbToCopy) {
for (int i = 0; i < nbToCopy; i++) {
cacheConverted[i] = (double) cacheData[i];
}
}
void AttributeCombiner::setValueGoodCacheType(Tango::Attribute &attr, ATTITEM *item) {
switch (item->type) {
case Tango::DEV_BOOLEAN:
attr.set_value((Tango::DevBoolean *)item->cacheData, item->cacheSize);
break;
case Tango::DEV_USHORT:
attr.set_value((Tango::DevUShort *)item->cacheData, item->cacheSize);
break;
case Tango::DEV_SHORT:
attr.set_value((Tango::DevShort *)item->cacheData, item->cacheSize);
break;
case Tango::DEV_LONG:
attr.set_value((Tango::DevLong *)item->cacheData, item->cacheSize);
break;
case Tango::DEV_ULONG:
attr.set_value((Tango::DevULong *)item->cacheData, item->cacheSize);
break;
case Tango::DEV_LONG64:
attr.set_value((Tango::DevLong64 *)item->cacheData, item->cacheSize);
break;
case Tango::DEV_ULONG64:
attr.set_value((Tango::DevULong64 *)item->cacheData, item->cacheSize);
break;
case Tango::DEV_STATE:
attr.set_value((Tango::DevState *)item->cacheData, item->cacheSize);
break;
case Tango::DEV_DOUBLE:
attr.set_value((Tango::DevDouble *)item->cacheData, item->cacheSize);
break;
if(item->type == Tango::DEV_STATE){
attr.set_value((Tango::DevState *)item->cacheData, item->cacheSize);
}else{
attr.set_value((Tango::DevDouble *)item->cacheData, item->cacheSize);
}
}
......
......@@ -325,10 +325,6 @@ public:
// Additional Method prototypes
static time_t timeMS();
// Return the cacheData variable cast to DevDouble
template <typename inType>
void convertTypePtrToDoublePtr(inType * cacheData,Tango::DevDouble * cacheConverted, int nbToCopy);
void setValueGoodCacheType(Tango::Attribute &attr, ATTITEM *item);
void writeAttributeProperty(const string& attrName,const string& propertyName, const string& contents);
......
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