diff --git a/src/ConexAgp.cpp b/src/ConexAgp.cpp index be39d1bfcc1480a2ae22ece85ea87274cbb83d02..cb1d2613ee2052dfa96a62f758bea009d7deb8ea 100644 --- a/src/ConexAgp.cpp +++ b/src/ConexAgp.cpp @@ -89,6 +89,8 @@ static const char *ver = (const char *)&version_string; //================================================================ // Position | Tango::DevDouble Scalar // TargetPosition | Tango::DevDouble Scalar +// Acceleration | Tango::DevDouble Scalar +// Speed | Tango::DevDouble Scalar //================================================================ namespace ConexAgp_ns @@ -156,6 +158,8 @@ void ConexAgp::delete_device() /*----- PROTECTED REGION END -----*/ // ConexAgp::delete_device delete[] attr_Position_read; delete[] attr_TargetPosition_read; + delete[] attr_Acceleration_read; + delete[] attr_Speed_read; } //-------------------------------------------------------- @@ -197,6 +201,8 @@ void ConexAgp::init_device() attr_Position_read = new Tango::DevDouble[1]; attr_TargetPosition_read = new Tango::DevDouble[1]; + attr_Acceleration_read = new Tango::DevDouble[1]; + attr_Speed_read = new Tango::DevDouble[1]; /*----- PROTECTED REGION ID(ConexAgp::init_device) ENABLED START -----*/ // Initialize device @@ -466,6 +472,88 @@ void ConexAgp::read_TargetPosition(Tango::Attribute &attr) /*----- PROTECTED REGION END -----*/ // ConexAgp::read_TargetPosition } +//-------------------------------------------------------- +/** + * Read attribute Acceleration related method + * Description: + * + * Data type: Tango::DevDouble + * Attr type: Scalar + */ +//-------------------------------------------------------- +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 -----*/ + // Set the attribute value + attr.set_value(attr_Acceleration_read); + + /*----- PROTECTED REGION END -----*/ // ConexAgp::read_Acceleration +} +//-------------------------------------------------------- +/** + * Write attribute Acceleration related method + * Description: + * + * Data type: Tango::DevDouble + * Attr type: Scalar + */ +//-------------------------------------------------------- +void ConexAgp::write_Acceleration(Tango::WAttribute &attr) +{ + DEBUG_STREAM << "ConexAgp::write_Acceleration(Tango::WAttribute &attr) entering... " << endl; + // Retrieve write value + Tango::DevDouble w_val; + attr.get_write_value(w_val); + /*----- PROTECTED REGION ID(ConexAgp::write_Acceleration) ENABLED START -----*/ + string resp("NO"); + stringstream cmd; + cmd << SET_ACCELERATION << w_val; + SendReceive(cmd.str(), resp); + + /*----- PROTECTED REGION END -----*/ // ConexAgp::write_Acceleration +} +//-------------------------------------------------------- +/** + * Read attribute Speed related method + * Description: + * + * Data type: Tango::DevDouble + * Attr type: Scalar + */ +//-------------------------------------------------------- +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 + attr.set_value(attr_Speed_read); + + /*----- PROTECTED REGION END -----*/ // ConexAgp::read_Speed +} +//-------------------------------------------------------- +/** + * Write attribute Speed related method + * Description: + * + * Data type: Tango::DevDouble + * Attr type: Scalar + */ +//-------------------------------------------------------- +void ConexAgp::write_Speed(Tango::WAttribute &attr) +{ + DEBUG_STREAM << "ConexAgp::write_Speed(Tango::WAttribute &attr) entering... " << endl; + // Retrieve write value + Tango::DevDouble w_val; + attr.get_write_value(w_val); + /*----- PROTECTED REGION ID(ConexAgp::write_Speed) ENABLED START -----*/ + string resp("NO"); + stringstream cmd; + cmd << SET_SPEED << w_val; + SendReceive(cmd.str(), resp); + + /*----- PROTECTED REGION END -----*/ // ConexAgp::write_Speed +} //-------------------------------------------------------- /** diff --git a/src/ConexAgp.h b/src/ConexAgp.h index 38f452ceb24fdf3b70754c60552c08de82ad3ea5..b72418e8c02ff8494ee92603dfae1b9743a8cf2c 100644 --- a/src/ConexAgp.h +++ b/src/ConexAgp.h @@ -45,6 +45,8 @@ #define GET_STATE "TS" #define GET_POSITION "TP" #define GET_TARGET_POSITION "TH" +#define GET_ACCELERATION "AC?" +#define GET_SPEED "VA?" #define MOVE_ABSOLUTE "PA" #define MOVE_RELATIVE "PR" @@ -56,6 +58,8 @@ #define RESET_CONTROLLER "RS" #define RESET_CONTROLLER_1 "RS##" #define ENABLE "MM" +#define SET_ACCELERATION "AC" +#define SET_SPEED "VA" /*----- PROTECTED REGION END -----*/ // ConexAgp.h @@ -111,6 +115,8 @@ public: public: Tango::DevDouble *attr_Position_read; Tango::DevDouble *attr_TargetPosition_read; + Tango::DevDouble *attr_Acceleration_read; + Tango::DevDouble *attr_Speed_read; // Constructors and destructors public: @@ -198,6 +204,26 @@ public: */ virtual void read_TargetPosition(Tango::Attribute &attr); virtual bool is_TargetPosition_allowed(Tango::AttReqType type); +/** + * Attribute Acceleration related methods + * Description: + * + * Data type: Tango::DevDouble + * Attr type: Scalar + */ + virtual void read_Acceleration(Tango::Attribute &attr); + virtual void write_Acceleration(Tango::WAttribute &attr); + virtual bool is_Acceleration_allowed(Tango::AttReqType type); +/** + * Attribute Speed related methods + * Description: + * + * Data type: Tango::DevDouble + * Attr type: Scalar + */ + virtual void read_Speed(Tango::Attribute &attr); + virtual void write_Speed(Tango::WAttribute &attr); + virtual bool is_Speed_allowed(Tango::AttReqType type); //-------------------------------------------------------- diff --git a/src/ConexAgpClass.cpp b/src/ConexAgpClass.cpp index 215ac730e7cf7ff0c91ff6439982e173e925e2ca..a947aab281d98f3850f18fdca72d2dd3224d408a 100644 --- a/src/ConexAgpClass.cpp +++ b/src/ConexAgpClass.cpp @@ -569,6 +569,58 @@ void ConexAgpClass::attribute_factory(vector<Tango::Attr *> &att_list) // Not Memorized att_list.push_back(targetposition); + // Attribute : Acceleration + AccelerationAttrib *Acceleration = new AccelerationAttrib(); + Tango::UserDefaultAttrProp Acceleration_prop; + // description not set for Acceleration + // label not set for Acceleration + // unit not set for Acceleration + // standard_unit not set for Acceleration + // display_unit not set for Acceleration + // format not set for Acceleration + // max_value not set for Acceleration + // min_value not set for Acceleration + // max_alarm not set for Acceleration + // min_alarm not set for Acceleration + // max_warning not set for Acceleration + // min_warning not set for Acceleration + // delta_t not set for Acceleration + // delta_val not set for Acceleration + + Acceleration->set_default_properties(Acceleration_prop); + // Not Polled + Acceleration->set_disp_level(Tango::OPERATOR); + // Not Memorized + Acceleration->set_change_event(true, true); + Acceleration->set_archive_event(true, true); + att_list.push_back(Acceleration); + + // Attribute : Speed + SpeedAttrib *Speed = new SpeedAttrib(); + Tango::UserDefaultAttrProp Speed_prop; + // description not set for Speed + // label not set for Speed + // unit not set for Speed + // standard_unit not set for Speed + // display_unit not set for Speed + // format not set for Speed + // max_value not set for Speed + // min_value not set for Speed + // max_alarm not set for Speed + // min_alarm not set for Speed + // max_warning not set for Speed + // min_warning not set for Speed + // delta_t not set for Speed + // delta_val not set for Speed + + Speed->set_default_properties(Speed_prop); + // Not Polled + Speed->set_disp_level(Tango::OPERATOR); + // Not Memorized + Speed->set_change_event(true, true); + Speed->set_archive_event(true, true); + att_list.push_back(Speed); + // Create a list of static attributes create_static_attribute_list(get_class_attr()->get_attr_list()); diff --git a/src/ConexAgpClass.h b/src/ConexAgpClass.h index 5944454654c632ff8f202f7d310230a7872f49aa..f0671e7b5c68ac1a66cfda5f2e9920bdbc7f2cb2 100644 --- a/src/ConexAgpClass.h +++ b/src/ConexAgpClass.h @@ -59,6 +59,36 @@ namespace ConexAgp_ns //========================================= // Define classes for attributes //========================================= +// Attribute Speed class definition +class SpeedAttrib: public Tango::Attr +{ +public: + SpeedAttrib():Attr("Speed", + Tango::DEV_DOUBLE, Tango::READ_WRITE) {}; + ~SpeedAttrib() {}; + virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att) + {(static_cast<ConexAgp *>(dev))->read_Speed(att);} + virtual void write(Tango::DeviceImpl *dev,Tango::WAttribute &att) + {(static_cast<ConexAgp *>(dev))->write_Speed(att);} + virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty) + {return (static_cast<ConexAgp *>(dev))->is_Speed_allowed(ty);} +}; + +// Attribute Acceleration class definition +class AccelerationAttrib: public Tango::Attr +{ +public: + AccelerationAttrib():Attr("Acceleration", + Tango::DEV_DOUBLE, Tango::READ_WRITE) {}; + ~AccelerationAttrib() {}; + virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att) + {(static_cast<ConexAgp *>(dev))->read_Acceleration(att);} + virtual void write(Tango::DeviceImpl *dev,Tango::WAttribute &att) + {(static_cast<ConexAgp *>(dev))->write_Acceleration(att);} + virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty) + {return (static_cast<ConexAgp *>(dev))->is_Acceleration_allowed(ty);} +}; + // Attribute Position class definition class PositionAttrib: public Tango::Attr { diff --git a/src/ConexAgpStateMachine.cpp b/src/ConexAgpStateMachine.cpp index 0990a270137a5ec7375f6dc61fe8fca9876aa106..5c4d9b19be6ed1098c6fd5c0a3362f3b488c1943 100644 --- a/src/ConexAgpStateMachine.cpp +++ b/src/ConexAgpStateMachine.cpp @@ -86,6 +86,46 @@ bool ConexAgp::is_TargetPosition_allowed(TANGO_UNUSED(Tango::AttReqType type)) return true; } +//-------------------------------------------------------- +/** + * Method : ConexAgp::is_Acceleration_allowed() + * Description : Execution allowed for Acceleration attribute + */ +//-------------------------------------------------------- +bool ConexAgp::is_Acceleration_allowed(TANGO_UNUSED(Tango::AttReqType type)) +{ + // Not any excluded states for Acceleration attribute in Write access. + /*----- PROTECTED REGION ID(ConexAgp::AccelerationStateAllowed_WRITE) ENABLED START -----*/ + + /*----- PROTECTED REGION END -----*/ // ConexAgp::AccelerationStateAllowed_WRITE + + // Not any excluded states for Acceleration attribute in read access. + /*----- PROTECTED REGION ID(ConexAgp::AccelerationStateAllowed_READ) ENABLED START -----*/ + + /*----- PROTECTED REGION END -----*/ // ConexAgp::AccelerationStateAllowed_READ + return true; +} + +//-------------------------------------------------------- +/** + * Method : ConexAgp::is_Speed_allowed() + * Description : Execution allowed for Speed attribute + */ +//-------------------------------------------------------- +bool ConexAgp::is_Speed_allowed(TANGO_UNUSED(Tango::AttReqType type)) +{ + // Not any excluded states for Speed attribute in Write access. + /*----- PROTECTED REGION ID(ConexAgp::SpeedStateAllowed_WRITE) ENABLED START -----*/ + + /*----- PROTECTED REGION END -----*/ // ConexAgp::SpeedStateAllowed_WRITE + + // Not any excluded states for Speed attribute in read access. + /*----- PROTECTED REGION ID(ConexAgp::SpeedStateAllowed_READ) ENABLED START -----*/ + + /*----- PROTECTED REGION END -----*/ // ConexAgp::SpeedStateAllowed_READ + return true; +} + //================================================= // Commands Allowed Methods diff --git a/src/readthread.cpp b/src/readthread.cpp index 14670eb13923de2885f92dc66aa6f88f1cabf2e2..4045ed2954bdc5ac9ff4522f13ccd30037c7ef8f 100644 --- a/src/readthread.cpp +++ b/src/readthread.cpp @@ -142,8 +142,17 @@ void readthread::run(void *) double postx; _device->SendReceive(string(GET_TARGET_POSITION), postx); *(_device->attr_TargetPosition_read) = postx; + INFO_STREAM << __func__<<": " << posx << " -> "<<*(_device->attr_TargetPosition_read); usleep(10000); - INFO_STREAM << __func__<<": " << posx << " -> "<<*(_device->attr_Position_read); + 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); }