diff --git a/src/ConexAgp.cpp b/src/ConexAgp.cpp index cb1d2613ee2052dfa96a62f758bea009d7deb8ea..2fe582e19f43907bda1c34274da397fe942195a2 100644 --- a/src/ConexAgp.cpp +++ b/src/ConexAgp.cpp @@ -310,6 +310,7 @@ void ConexAgp::get_device_property() dev_prop.push_back(Tango::DbDatum("DeviceName")); dev_prop.push_back(Tango::DbDatum("ControllerAddr")); dev_prop.push_back(Tango::DbDatum("LegacySerial")); + dev_prop.push_back(Tango::DbDatum("HasVelocityAcceleration")); // is there at least one property to be read ? if (dev_prop.size()>0) @@ -357,6 +358,17 @@ void ConexAgp::get_device_property() // And try to extract LegacySerial value from database if (dev_prop[i].is_empty()==false) dev_prop[i] >> legacySerial; + // Try to initialize HasVelocityAcceleration from class property + cl_prop = ds_class->get_class_property(dev_prop[++i].name); + if (cl_prop.is_empty()==false) cl_prop >> hasVelocityAcceleration; + else { + // Try to initialize HasVelocityAcceleration from default device value + def_prop = ds_class->get_default_device_property(dev_prop[i].name); + if (def_prop.is_empty()==false) def_prop >> hasVelocityAcceleration; + } + // And try to extract HasVelocityAcceleration value from database + if (dev_prop[i].is_empty()==false) dev_prop[i] >> hasVelocityAcceleration; + } /*----- PROTECTED REGION ID(ConexAgp::get_device_property_after) ENABLED START -----*/ @@ -485,6 +497,11 @@ void ConexAgp::read_Acceleration(Tango::Attribute &attr) { DEBUG_STREAM << "ConexAgp::read_Acceleration(Tango::Attribute &attr) entering... " << endl; /*----- PROTECTED REGION ID(ConexAgp::read_Acceleration) ENABLED START -----*/ + if(!hasVelocityAcceleration) + Tango::Except::throw_exception( + (const char *) "NotSupported", + (const char *) "Not supported", + (const char *) __func__, Tango::ERR); // Set the attribute value attr.set_value(attr_Acceleration_read); @@ -506,6 +523,11 @@ void ConexAgp::write_Acceleration(Tango::WAttribute &attr) Tango::DevDouble w_val; attr.get_write_value(w_val); /*----- PROTECTED REGION ID(ConexAgp::write_Acceleration) ENABLED START -----*/ + if(!hasVelocityAcceleration) + Tango::Except::throw_exception( + (const char *) "NotSupported", + (const char *) "Not supported", + (const char *) __func__, Tango::ERR); string resp("NO"); stringstream cmd; cmd << SET_ACCELERATION << w_val; @@ -527,6 +549,11 @@ void ConexAgp::read_Speed(Tango::Attribute &attr) DEBUG_STREAM << "ConexAgp::read_Speed(Tango::Attribute &attr) entering... " << endl; /*----- PROTECTED REGION ID(ConexAgp::read_Speed) ENABLED START -----*/ // Set the attribute value + if(!hasVelocityAcceleration) + Tango::Except::throw_exception( + (const char *) "NotSupported", + (const char *) "Not supported", + (const char *) __func__, Tango::ERR); attr.set_value(attr_Speed_read); /*----- PROTECTED REGION END -----*/ // ConexAgp::read_Speed @@ -547,6 +574,11 @@ void ConexAgp::write_Speed(Tango::WAttribute &attr) Tango::DevDouble w_val; attr.get_write_value(w_val); /*----- PROTECTED REGION ID(ConexAgp::write_Speed) ENABLED START -----*/ + if(!hasVelocityAcceleration) + Tango::Except::throw_exception( + (const char *) "NotSupported", + (const char *) "Not supported", + (const char *) __func__, Tango::ERR); string resp("NO"); stringstream cmd; cmd << SET_SPEED << w_val; diff --git a/src/ConexAgp.h b/src/ConexAgp.h index b72418e8c02ff8494ee92603dfae1b9743a8cf2c..4bb7c366253fccef2c22c18755880f1da18f4a10 100644 --- a/src/ConexAgp.h +++ b/src/ConexAgp.h @@ -110,6 +110,8 @@ public: Tango::DevLong controllerAddr; // LegacySerial: Use legacy serial-srv Tango::DevBoolean legacySerial; + // HasVelocityAcceleration: VA and AC command supported + Tango::DevBoolean hasVelocityAcceleration; // Attribute data members public: diff --git a/src/ConexAgpClass.cpp b/src/ConexAgpClass.cpp index a947aab281d98f3850f18fdca72d2dd3224d408a..18565d516b518c5ae6aebe43fbdc90cdcd49bfa2 100644 --- a/src/ConexAgpClass.cpp +++ b/src/ConexAgpClass.cpp @@ -413,6 +413,19 @@ void ConexAgpClass::set_default_property() } else add_wiz_dev_prop(prop_name, prop_desc); + prop_name = "HasVelocityAcceleration"; + prop_desc = "VA and AC command supported"; + prop_def = "true"; + vect_data.clear(); + if (prop_def.length()>0) + { + Tango::DbDatum data(prop_name); + data << vect_data ; + dev_def_prop.push_back(data); + add_wiz_dev_prop(prop_name, prop_desc, prop_def); + } + else + add_wiz_dev_prop(prop_name, prop_desc); } //-------------------------------------------------------- diff --git a/src/readthread.cpp b/src/readthread.cpp index 4045ed2954bdc5ac9ff4522f13ccd30037c7ef8f..da6038b57083020188c71ff50a62d92426b2b68b 100644 --- a/src/readthread.cpp +++ b/src/readthread.cpp @@ -144,15 +144,18 @@ void readthread::run(void *) *(_device->attr_TargetPosition_read) = postx; INFO_STREAM << __func__<<": " << posx << " -> "<<*(_device->attr_TargetPosition_read); usleep(10000); - double posa; - _device->SendReceive(string(GET_ACCELERATION), posa); - *(_device->attr_Acceleration_read) = posa; - INFO_STREAM << __func__<<": " << posx << " -> "<<*(_device->attr_Acceleration_read); - usleep(10000); - double posv; - _device->SendReceive(string(GET_SPEED), posv); - *(_device->attr_Speed_read) = posv; - INFO_STREAM << __func__<<": " << posx << " -> "<<*(_device->attr_Speed_read); + if(_device->hasVelocityAcceleration) + { + double posa; + _device->SendReceive(string(GET_ACCELERATION), posa); + *(_device->attr_Acceleration_read) = posa; + INFO_STREAM << __func__<<": " << posx << " -> "<<*(_device->attr_Acceleration_read); + usleep(10000); + double posv; + _device->SendReceive(string(GET_SPEED), posv); + *(_device->attr_Speed_read) = posv; + INFO_STREAM << __func__<<": " << posx << " -> "<<*(_device->attr_Speed_read); + } abort_sleep(1); }