diff --git a/specifics/Lambda/Lambda.cpp b/specifics/Lambda/Lambda.cpp index dcece7c..1adcd72 100755 --- a/specifics/Lambda/Lambda.cpp +++ b/specifics/Lambda/Lambda.cpp @@ -84,6 +84,9 @@ namespace Lambda_ns // chargeSumming | Tango::DevBoolean Scalar // lowerThreshold | Tango::DevDouble Scalar // upperThreshold | Tango::DevDouble Scalar +// hwAcquisitionMode | Tango::DevEnum Scalar +// hwAccumulation | Tango::DevBoolean Scalar +// exposureAccuTime | Tango::DevDouble Scalar //================================================================ namespace Lambda_ns @@ -154,6 +157,7 @@ void Lambda::delete_device() m_is_device_initialized = false; /*----- PROTECTED REGION END -----*/ // Lambda::delete_device + delete[] attr_hwAcquisitionMode_read; } //-------------------------------------------------------- @@ -175,6 +179,7 @@ void Lambda::init_device() // Get the device properties from database get_device_property(); + attr_hwAcquisitionMode_read = new hwAcquisitionModeEnum[1]; /*----- PROTECTED REGION ID(Lambda::init_device) ENABLED START -----*/ // Initialize device CREATE_SCALAR_ATTRIBUTE(attr_distortionCorrection_read); @@ -366,6 +371,7 @@ void Lambda::get_device_property() //-------------------------------------------------------- void Lambda::always_executed_hook() { + DEBUG_STREAM << "Lambda::always_executed_hook() " << device_name << endl; /*----- PROTECTED REGION ID(Lambda::always_executed_hook) ENABLED START -----*/ // code always executed before all requests @@ -419,6 +425,7 @@ void Lambda::always_executed_hook() //-------------------------------------------------------- void Lambda::read_attr_hardware(TANGO_UNUSED(vector &attr_list)) { + DEBUG_STREAM << "Lambda::read_attr_hardware(vector &attr_list) entering... " << endl; /*----- PROTECTED REGION ID(Lambda::read_attr_hardware) ENABLED START -----*/ // Add your own code @@ -433,6 +440,7 @@ void Lambda::read_attr_hardware(TANGO_UNUSED(vector &attr_list)) //-------------------------------------------------------- void Lambda::write_attr_hardware(TANGO_UNUSED(vector &attr_list)) { + DEBUG_STREAM << "Lambda::write_attr_hardware(vector &attr_list) entering... " << endl; /*----- PROTECTED REGION ID(Lambda::write_attr_hardware) ENABLED START -----*/ // Add your own code @@ -655,7 +663,7 @@ void Lambda::read_linearityCorrection(Tango::Attribute &attr) //-------------------------------------------------------- void Lambda::write_linearityCorrection(Tango::WAttribute &attr) { - INFO_STREAM << "Lambda::write_linearityCorrection(Tango::WAttribute &attr) entering... " << endl; + DEBUG_STREAM << "Lambda::write_linearityCorrection(Tango::WAttribute &attr) entering... " << endl; // Retrieve write value Tango::DevBoolean w_val; attr.get_write_value(w_val); @@ -720,7 +728,7 @@ void Lambda::read_saturationFlag(Tango::Attribute &attr) //-------------------------------------------------------- void Lambda::write_saturationFlag(Tango::WAttribute &attr) { - INFO_STREAM << "Lambda::write_saturationFlag(Tango::WAttribute &attr) entering... " << endl; + DEBUG_STREAM << "Lambda::write_saturationFlag(Tango::WAttribute &attr) entering... " << endl; // Retrieve write value Tango::DevBoolean w_val; attr.get_write_value(w_val); @@ -785,7 +793,7 @@ void Lambda::read_saturationThreshold(Tango::Attribute &attr) //-------------------------------------------------------- void Lambda::write_saturationThreshold(Tango::WAttribute &attr) { - INFO_STREAM << "Lambda::write_saturationThreshold(Tango::WAttribute &attr) entering... " << endl; + DEBUG_STREAM << "Lambda::write_saturationThreshold(Tango::WAttribute &attr) entering... " << endl; // Retrieve write value Tango::DevLong w_val; attr.get_write_value(w_val); @@ -870,7 +878,7 @@ void Lambda::read_lowerThreshold(Tango::Attribute &attr) //-------------------------------------------------------- void Lambda::write_lowerThreshold(Tango::WAttribute &attr) { - INFO_STREAM << "Lambda::write_lowerThreshold(Tango::WAttribute &attr) entering... " << endl; + DEBUG_STREAM << "Lambda::write_lowerThreshold(Tango::WAttribute &attr) entering... " << endl; // Retrieve write value Tango::DevDouble w_val; attr.get_write_value(w_val); @@ -938,7 +946,7 @@ void Lambda::read_upperThreshold(Tango::Attribute &attr) //-------------------------------------------------------- void Lambda::write_upperThreshold(Tango::WAttribute &attr) { - INFO_STREAM << "Lambda::write_upperThreshold(Tango::WAttribute &attr) entering... " << endl; + DEBUG_STREAM << "Lambda::write_upperThreshold(Tango::WAttribute &attr) entering... " << endl; // Retrieve write value Tango::DevDouble w_val; attr.get_write_value(w_val); @@ -960,6 +968,138 @@ void Lambda::write_upperThreshold(Tango::WAttribute &attr) /*----- PROTECTED REGION END -----*/ // Lambda::write_upperThreshold } +//-------------------------------------------------------- +/** + * Read attribute hwAcquisitionMode related method + * Description: + * + * Data type: Tango::DevEnum (hwAcquisitionModeEnum) + * Attr type: Scalar + */ +//-------------------------------------------------------- +void Lambda::read_hwAcquisitionMode(Tango::Attribute &attr) +{ + DEBUG_STREAM << "Lambda::read_hwAcquisitionMode(Tango::Attribute &attr) entering... " << endl; + /*----- PROTECTED REGION ID(Lambda::read_hwAcquisitionMode) ENABLED START -----*/ + // Set the attribute value + int acqMode = -1; + m_camera->getAcquisitionMode(acqMode); + switch(acqMode) { + case 1: *attr_hwAcquisitionMode_read = Lambda_ns::_1_BIT; break; + case 6: *attr_hwAcquisitionMode_read = Lambda_ns::_6_BITS; break; + case 12: *attr_hwAcquisitionMode_read = Lambda_ns::_12_BITS; break; + case 24: *attr_hwAcquisitionMode_read = Lambda_ns::_24_BITS; break; + default: break; + } + attr.set_value(attr_hwAcquisitionMode_read); + + /*----- PROTECTED REGION END -----*/ // Lambda::read_hwAcquisitionMode +} +//-------------------------------------------------------- +/** + * Write attribute hwAcquisitionMode related method + * Description: + * + * Data type: Tango::DevEnum (hwAcquisitionModeEnum) + * Attr type: Scalar + */ +//-------------------------------------------------------- +void Lambda::write_hwAcquisitionMode(Tango::WAttribute &attr) +{ + DEBUG_STREAM << "Lambda::write_hwAcquisitionMode(Tango::WAttribute &attr) entering... " << endl; + // Retrieve write value + hwAcquisitionModeEnum w_val; + attr.get_write_value(w_val); + /*----- PROTECTED REGION ID(Lambda::write_hwAcquisitionMode) ENABLED START -----*/ + try + { + int acqMode = 24; + switch(w_val) { + case Lambda_ns::_1_BIT: acqMode = 1; break; + case Lambda_ns::_6_BITS: acqMode = 6; break; + case Lambda_ns::_12_BITS: acqMode = 12; break; + case Lambda_ns::_24_BITS: acqMode = 24; break; + default: break; + } + m_camera->setAcquisitionMode(acqMode); + //- Memorize the write value + yat4tango::PropertyHelper::set_memorized_attribute(this, "hwAcquisitionMode", w_val); + } + catch (Tango::DevFailed& df) + { + manage_devfailed_exception(df, "write_hwAcquisitionMode"); + } + catch (lima::Exception& le) + { + manage_lima_exception(le, "write_hwAcquisitionMode"); + } + + /*----- PROTECTED REGION END -----*/ // Lambda::write_hwAcquisitionMode +} +//-------------------------------------------------------- +/** + * Write attribute hwAccumulation related method + * Description: + * + * Data type: Tango::DevBoolean + * Attr type: Scalar + */ +//-------------------------------------------------------- +void Lambda::write_hwAccumulation(Tango::WAttribute &attr) +{ + DEBUG_STREAM << "Lambda::write_hwAccumulation(Tango::WAttribute &attr) entering... " << endl; + // Retrieve write value + Tango::DevBoolean w_val; + attr.get_write_value(w_val); + /*----- PROTECTED REGION ID(Lambda::write_hwAccumulation) ENABLED START -----*/ + try + { + m_camera->setAccumulationMode(w_val); + //- Memorize the write value + yat4tango::PropertyHelper::set_memorized_attribute(this, "hwAccumulation", w_val); + } + catch(Tango::DevFailed& df) + { + manage_devfailed_exception(df, "Lambda::write_hwAccumulation"); + } + catch(Exception& e) + { + manage_lima_exception(e, "Lambda::write_hwAccumulation"); + } + /*----- PROTECTED REGION END -----*/ // Lambda::write_hwAccumulation +} +//-------------------------------------------------------- +/** + * Write attribute exposureAccuTime related method + * Description: + * + * Data type: Tango::DevDouble + * Attr type: Scalar + */ +//-------------------------------------------------------- +void Lambda::write_exposureAccuTime(Tango::WAttribute &attr) +{ + DEBUG_STREAM << "Lambda::write_exposureAccuTime(Tango::WAttribute &attr) entering... " << endl; + // Retrieve write value + Tango::DevDouble w_val; + attr.get_write_value(w_val); + /*----- PROTECTED REGION ID(Lambda::write_exposureAccuTime) ENABLED START -----*/ + try + { + m_camera->setExposureAccuTime(w_val); + //- Memorize the write value + yat4tango::PropertyHelper::set_memorized_attribute(this, "exposureAccuTime", w_val); + } + catch(Tango::DevFailed& df) + { + manage_devfailed_exception(df, "Lambda::write_exposureAccuTime"); + } + catch(Exception& e) + { + manage_lima_exception(e, "Lambda::write_exposureAccuTime"); + } + /*----- PROTECTED REGION END -----*/ // Lambda::write_exposureAccuTime +} //-------------------------------------------------------- /** diff --git a/specifics/Lambda/Lambda.h b/specifics/Lambda/Lambda.h index 68ea898..f5c8182 100755 --- a/specifics/Lambda/Lambda.h +++ b/specifics/Lambda/Lambda.h @@ -64,6 +64,14 @@ namespace Lambda_ns { +enum _hwAcquisitionModeEnum { + _24_BITS, + _12_BITS, + _6_BITS, + _1_BIT, +} ; +typedef _hwAcquisitionModeEnum hwAcquisitionModeEnum; + /*----- PROTECTED REGION ID(Lambda::Additional Class Declarations) ENABLED START -----*/ // Additional Class Declarations @@ -106,6 +114,7 @@ class Lambda : public TANGO_BASE_CLASS Tango::DevBoolean *attr_chargeSumming_read; Tango::DevDouble *attr_lowerThreshold_read; Tango::DevDouble *attr_upperThreshold_read; + hwAcquisitionModeEnum *attr_hwAcquisitionMode_read; // Constructors and destructors public: @@ -298,7 +307,35 @@ class Lambda : public TANGO_BASE_CLASS virtual void read_upperThreshold(Tango::Attribute &attr); virtual void write_upperThreshold(Tango::WAttribute &attr); virtual bool is_upperThreshold_allowed(Tango::AttReqType type); +/** + * Attribute hwAcquisitionMode related methods + * Description: + * + * Data type: Tango::DevEnum + * Attr type: Scalar + */ + virtual void read_hwAcquisitionMode(Tango::Attribute &attr); + virtual void write_hwAcquisitionMode(Tango::WAttribute &attr); + virtual bool is_hwAcquisitionMode_allowed(Tango::AttReqType type); +/** + * Attribute hwAccumulation related methods + * Description: + * + * Data type: Tango::DevBoolean + * Attr type: Scalar + */ + virtual void write_hwAccumulation(Tango::WAttribute &attr); + virtual bool is_hwAccumulation_allowed(Tango::AttReqType type); +/** + * Attribute exposureAccuTime related methods + * Description: + * + * Data type: Tango::DevDouble + * Attr type: Scalar + */ + virtual void write_exposureAccuTime(Tango::WAttribute &attr); + virtual bool is_exposureAccuTime_allowed(Tango::AttReqType type); //-------------------------------------------------------- /** diff --git a/specifics/Lambda/Lambda.xmi b/specifics/Lambda/Lambda.xmi index 4117d5f..f160e37 100755 --- a/specifics/Lambda/Lambda.xmi +++ b/specifics/Lambda/Lambda.xmi @@ -1,7 +1,7 @@ - + @@ -167,6 +167,42 @@ FAULT RUNNING + + + + + + + + FAULT + RUNNING + FAULT + RUNNING + + + + + + + + + FAULT + RUNNING + FAULT + RUNNING + + + + + + + + + 24 Bits + 12 Bits + 6 Bits + 1 Bit + @@ -176,6 +212,6 @@ - + diff --git a/specifics/Lambda/LambdaClass.cpp b/specifics/Lambda/LambdaClass.cpp index d144652..73bfadc 100755 --- a/specifics/Lambda/LambdaClass.cpp +++ b/specifics/Lambda/LambdaClass.cpp @@ -663,6 +663,89 @@ void LambdaClass::attribute_factory(vector &att_list) // Not Memorized att_list.push_back(upperthreshold); + // Attribute : hwAccumulation + hwAccumulationAttrib *hwaccumulation = new hwAccumulationAttrib(); + Tango::UserDefaultAttrProp hwaccumulation_prop; + // description not set for hwAccumulation + // label not set for hwAccumulation + // unit not set for hwAccumulation + // standard_unit not set for hwAccumulation + // display_unit not set for hwAccumulation + // format not set for hwAccumulation + // max_value not set for hwAccumulation + // min_value not set for hwAccumulation + // max_alarm not set for hwAccumulation + // min_alarm not set for hwAccumulation + // max_warning not set for hwAccumulation + // min_warning not set for hwAccumulation + // delta_t not set for hwAccumulation + // delta_val not set for hwAccumulation + + hwaccumulation->set_default_properties(hwaccumulation_prop); + // Not Polled + hwaccumulation->set_disp_level(Tango::OPERATOR); + hwaccumulation->set_memorized(); + hwaccumulation->set_memorized_init(true); + att_list.push_back(hwaccumulation); + + // Attribute : exposureAccuTime + exposureAccuTimeAttrib *exposureaccutime = new exposureAccuTimeAttrib(); + Tango::UserDefaultAttrProp exposureaccutime_prop; + // description not set for exposureAccuTime + // label not set for exposureAccuTime + // unit not set for exposureAccuTime + // standard_unit not set for exposureAccuTime + // display_unit not set for exposureAccuTime + // format not set for exposureAccuTime + // max_value not set for exposureAccuTime + // min_value not set for exposureAccuTime + // max_alarm not set for exposureAccuTime + // min_alarm not set for exposureAccuTime + // max_warning not set for exposureAccuTime + // min_warning not set for exposureAccuTime + // delta_t not set for exposureAccuTime + // delta_val not set for exposureAccuTime + + exposureaccutime->set_default_properties(exposureaccutime_prop); + // Not Polled + exposureaccutime->set_disp_level(Tango::OPERATOR); + exposureaccutime->set_memorized(); + exposureaccutime->set_memorized_init(true); + att_list.push_back(exposureaccutime); + + // Attribute : hwAcquisitionMode + hwAcquisitionModeAttrib *hwacquisitionmode = new hwAcquisitionModeAttrib(); + Tango::UserDefaultAttrProp hwacquisitionmode_prop; + // description not set for hwAcquisitionMode + // label not set for hwAcquisitionMode + // unit not set for hwAcquisitionMode + // standard_unit not set for hwAcquisitionMode + // display_unit not set for hwAcquisitionMode + // format not set for hwAcquisitionMode + // max_value not set for hwAcquisitionMode + // min_value not set for hwAcquisitionMode + // max_alarm not set for hwAcquisitionMode + // min_alarm not set for hwAcquisitionMode + // max_warning not set for hwAcquisitionMode + // min_warning not set for hwAcquisitionMode + // delta_t not set for hwAcquisitionMode + // delta_val not set for hwAcquisitionMode + + { + vector labels; + labels.push_back("24 Bits"); + labels.push_back("12 Bits"); + labels.push_back("6 Bits"); + labels.push_back("1 Bit"); + hwacquisitionmode_prop.set_enum_labels(labels); + } + hwacquisitionmode->set_default_properties(hwacquisitionmode_prop); + // Not Polled + hwacquisitionmode->set_disp_level(Tango::OPERATOR); + hwacquisitionmode->set_memorized(); + hwacquisitionmode->set_memorized_init(true); + att_list.push_back(hwacquisitionmode); + // Create a list of static attributes create_static_attribute_list(get_class_attr()->get_attr_list()); diff --git a/specifics/Lambda/LambdaClass.h b/specifics/Lambda/LambdaClass.h index c22578c..4db4691 100755 --- a/specifics/Lambda/LambdaClass.h +++ b/specifics/Lambda/LambdaClass.h @@ -225,7 +225,49 @@ class upperThresholdAttrib: public Tango::Attr {return (static_cast(dev))->is_upperThreshold_allowed(ty);} }; +// Attribute hwAccumulation class definition +class hwAccumulationAttrib: public Tango::Attr +{ +public: + hwAccumulationAttrib():Attr("hwAccumulation", + Tango::DEV_BOOLEAN, Tango::WRITE) {}; + ~hwAccumulationAttrib() {}; + virtual void write(Tango::DeviceImpl *dev,Tango::WAttribute &att) + {(static_cast(dev))->write_hwAccumulation(att);} + virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty) + {return (static_cast(dev))->is_hwAccumulation_allowed(ty);} +}; +// Attribute exposureAccuTime class definition +class exposureAccuTimeAttrib: public Tango::Attr +{ +public: + exposureAccuTimeAttrib():Attr("exposureAccuTime", + Tango::DEV_DOUBLE, Tango::WRITE) {}; + ~exposureAccuTimeAttrib() {}; + virtual void write(Tango::DeviceImpl *dev,Tango::WAttribute &att) + {(static_cast(dev))->write_exposureAccuTime(att);} + virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty) + {return (static_cast(dev))->is_exposureAccuTime_allowed(ty);} +}; + +// Attribute hwAcquisitionMode class definition +class hwAcquisitionModeAttrib: public Tango::Attr +{ +public: + hwAcquisitionModeAttrib():Attr("hwAcquisitionMode", + Tango::DEV_ENUM, Tango::READ_WRITE) {}; + ~hwAcquisitionModeAttrib() {}; + virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att) + {(static_cast(dev))->read_hwAcquisitionMode(att);} + virtual void write(Tango::DeviceImpl *dev,Tango::WAttribute &att) + {(static_cast(dev))->write_hwAcquisitionMode(att);} + virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty) + {return (static_cast(dev))->is_hwAcquisitionMode_allowed(ty);} + virtual bool same_type(const type_info &in_type) {return typeid(hwAcquisitionModeEnum) == in_type;} + virtual string get_enum_type() {return string("hwAcquisitionModeEnum");} +}; + /** * The LambdaClass singleton definition */ diff --git a/specifics/Lambda/LambdaStateMachine.cpp b/specifics/Lambda/LambdaStateMachine.cpp index 2215e57..8f98e43 100755 --- a/specifics/Lambda/LambdaStateMachine.cpp +++ b/specifics/Lambda/LambdaStateMachine.cpp @@ -60,7 +60,7 @@ bool Lambda::is_configFile_allowed(TANGO_UNUSED(Tango::AttReqType type)) if ( type==Tango::READ_REQ ) { // Compare device state with not allowed states for READ - if (get_state()==Tango::FAULT && !is_device_initialized()) + if (get_state()==Tango::FAULT) { /*----- PROTECTED REGION ID(Lambda::configFileStateAllowed_READ) ENABLED START -----*/ @@ -85,7 +85,7 @@ bool Lambda::is_distortionCorrection_allowed(TANGO_UNUSED(Tango::AttReqType type if ( type==Tango::READ_REQ ) { // Compare device state with not allowed states for READ - if (get_state()==Tango::FAULT && !is_device_initialized()) + if (get_state()==Tango::FAULT) { /*----- PROTECTED REGION ID(Lambda::distortionCorrectionStateAllowed_READ) ENABLED START -----*/ @@ -110,7 +110,7 @@ bool Lambda::is_libraryVersion_allowed(TANGO_UNUSED(Tango::AttReqType type)) if ( type==Tango::READ_REQ ) { // Compare device state with not allowed states for READ - if (get_state()==Tango::FAULT && !is_device_initialized()) + if (get_state()==Tango::FAULT) { /*----- PROTECTED REGION ID(Lambda::libraryVersionStateAllowed_READ) ENABLED START -----*/ @@ -135,7 +135,7 @@ bool Lambda::is_highVoltage_allowed(TANGO_UNUSED(Tango::AttReqType type)) if ( type==Tango::READ_REQ ) { // Compare device state with not allowed states for READ - if ((get_state()==Tango::FAULT && !is_device_initialized())|| + if (get_state()==Tango::FAULT || get_state()==Tango::RUNNING) { /*----- PROTECTED REGION ID(Lambda::highVoltageStateAllowed_READ) ENABLED START -----*/ @@ -161,7 +161,7 @@ bool Lambda::is_humidity_allowed(TANGO_UNUSED(Tango::AttReqType type)) if ( type==Tango::READ_REQ ) { // Compare device state with not allowed states for READ - if ((get_state()==Tango::FAULT && !is_device_initialized())|| + if (get_state()==Tango::FAULT || get_state()==Tango::RUNNING) { /*----- PROTECTED REGION ID(Lambda::humidityStateAllowed_READ) ENABLED START -----*/ @@ -187,7 +187,7 @@ bool Lambda::is_temperature_allowed(TANGO_UNUSED(Tango::AttReqType type)) if ( type==Tango::READ_REQ ) { // Compare device state with not allowed states for READ - if ((get_state()==Tango::FAULT && !is_device_initialized())|| + if (get_state()==Tango::FAULT || get_state()==Tango::RUNNING) { /*----- PROTECTED REGION ID(Lambda::temperatureStateAllowed_READ) ENABLED START -----*/ @@ -212,7 +212,7 @@ bool Lambda::is_linearityCorrection_allowed(TANGO_UNUSED(Tango::AttReqType type) if ( type!=Tango::READ_REQ ) { // Compare device state with not allowed states for WRITE - if ((get_state()==Tango::FAULT && !is_device_initialized())|| + if (get_state()==Tango::FAULT || get_state()==Tango::RUNNING) { /*----- PROTECTED REGION ID(Lambda::linearityCorrectionStateAllowed_WRITE) ENABLED START -----*/ @@ -228,7 +228,7 @@ bool Lambda::is_linearityCorrection_allowed(TANGO_UNUSED(Tango::AttReqType type) if ( type==Tango::READ_REQ ) { // Compare device state with not allowed states for READ - if ((get_state()==Tango::FAULT && !is_device_initialized())|| + if (get_state()==Tango::FAULT || get_state()==Tango::RUNNING) { /*----- PROTECTED REGION ID(Lambda::linearityCorrectionStateAllowed_READ) ENABLED START -----*/ @@ -253,7 +253,7 @@ bool Lambda::is_saturationFlag_allowed(TANGO_UNUSED(Tango::AttReqType type)) if ( type!=Tango::READ_REQ ) { // Compare device state with not allowed states for WRITE - if ((get_state()==Tango::FAULT && !is_device_initialized())|| + if (get_state()==Tango::FAULT || get_state()==Tango::RUNNING) { /*----- PROTECTED REGION ID(Lambda::saturationFlagStateAllowed_WRITE) ENABLED START -----*/ @@ -269,7 +269,7 @@ bool Lambda::is_saturationFlag_allowed(TANGO_UNUSED(Tango::AttReqType type)) if ( type==Tango::READ_REQ ) { // Compare device state with not allowed states for READ - if ((get_state()==Tango::FAULT && !is_device_initialized())|| + if (get_state()==Tango::FAULT || get_state()==Tango::RUNNING) { /*----- PROTECTED REGION ID(Lambda::saturationFlagStateAllowed_READ) ENABLED START -----*/ @@ -294,7 +294,7 @@ bool Lambda::is_saturationThreshold_allowed(TANGO_UNUSED(Tango::AttReqType type) if ( type!=Tango::READ_REQ ) { // Compare device state with not allowed states for WRITE - if ((get_state()==Tango::FAULT && !is_device_initialized())|| + if (get_state()==Tango::FAULT || get_state()==Tango::RUNNING) { /*----- PROTECTED REGION ID(Lambda::saturationThresholdStateAllowed_WRITE) ENABLED START -----*/ @@ -310,7 +310,7 @@ bool Lambda::is_saturationThreshold_allowed(TANGO_UNUSED(Tango::AttReqType type) if ( type==Tango::READ_REQ ) { // Compare device state with not allowed states for READ - if ((get_state()==Tango::FAULT && !is_device_initialized())|| + if (get_state()==Tango::FAULT || get_state()==Tango::RUNNING) { /*----- PROTECTED REGION ID(Lambda::saturationThresholdStateAllowed_READ) ENABLED START -----*/ @@ -336,7 +336,7 @@ bool Lambda::is_chargeSumming_allowed(TANGO_UNUSED(Tango::AttReqType type)) if ( type==Tango::READ_REQ ) { // Compare device state with not allowed states for READ - if (get_state()==Tango::FAULT && !is_device_initialized()) + if (get_state()==Tango::FAULT) { /*----- PROTECTED REGION ID(Lambda::chargeSummingStateAllowed_READ) ENABLED START -----*/ @@ -360,7 +360,7 @@ bool Lambda::is_lowerThreshold_allowed(TANGO_UNUSED(Tango::AttReqType type)) if ( type!=Tango::READ_REQ ) { // Compare device state with not allowed states for WRITE - if ((get_state()==Tango::FAULT && !is_device_initialized()) || + if (get_state()==Tango::FAULT || get_state()==Tango::RUNNING) { /*----- PROTECTED REGION ID(Lambda::lowerThresholdStateAllowed_WRITE) ENABLED START -----*/ @@ -376,7 +376,7 @@ bool Lambda::is_lowerThreshold_allowed(TANGO_UNUSED(Tango::AttReqType type)) if ( type==Tango::READ_REQ ) { // Compare device state with not allowed states for READ - if ((get_state()==Tango::FAULT && !is_device_initialized()) || + if (get_state()==Tango::FAULT || get_state()==Tango::RUNNING) { /*----- PROTECTED REGION ID(Lambda::lowerThresholdStateAllowed_READ) ENABLED START -----*/ @@ -401,7 +401,7 @@ bool Lambda::is_upperThreshold_allowed(TANGO_UNUSED(Tango::AttReqType type)) if ( type!=Tango::READ_REQ ) { // Compare device state with not allowed states for WRITE - if ((get_state()==Tango::FAULT && !is_device_initialized()) || + if (get_state()==Tango::FAULT || get_state()==Tango::RUNNING) { /*----- PROTECTED REGION ID(Lambda::upperThresholdStateAllowed_WRITE) ENABLED START -----*/ @@ -417,7 +417,7 @@ bool Lambda::is_upperThreshold_allowed(TANGO_UNUSED(Tango::AttReqType type)) if ( type==Tango::READ_REQ ) { // Compare device state with not allowed states for READ - if ((get_state()==Tango::FAULT && !is_device_initialized()) || + if (get_state()==Tango::FAULT || get_state()==Tango::RUNNING) { /*----- PROTECTED REGION ID(Lambda::upperThresholdStateAllowed_READ) ENABLED START -----*/ @@ -430,7 +430,76 @@ bool Lambda::is_upperThreshold_allowed(TANGO_UNUSED(Tango::AttReqType type)) return true; } +//-------------------------------------------------------- +/** + * Method : Lambda::is_hwAccumulation_allowed() + * Description : Execution allowed for hwAccumulation attribute + */ +//-------------------------------------------------------- +bool Lambda::is_hwAccumulation_allowed(TANGO_UNUSED(Tango::AttReqType type)) +{ + // Check access type. + if ( type!=Tango::READ_REQ ) + { + // Compare device state with not allowed states for WRITE + if (get_state()==Tango::FAULT || + get_state()==Tango::RUNNING) + { + /*----- PROTECTED REGION ID(Lambda::hwAccumulationStateAllowed_WRITE) ENABLED START -----*/ + + /*----- PROTECTED REGION END -----*/ // Lambda::hwAccumulationStateAllowed_WRITE + return false; + } + return true; + } + + return true; +} +//-------------------------------------------------------- +/** + * Method : Lambda::is_exposureAccuTime_allowed() + * Description : Execution allowed for exposureAccuTime attribute + */ +//-------------------------------------------------------- +bool Lambda::is_exposureAccuTime_allowed(TANGO_UNUSED(Tango::AttReqType type)) +{ + // Check access type. + if ( type!=Tango::READ_REQ ) + { + // Compare device state with not allowed states for WRITE + if (get_state()==Tango::FAULT || + get_state()==Tango::RUNNING) + { + /*----- PROTECTED REGION ID(Lambda::exposureAccuTimeStateAllowed_WRITE) ENABLED START -----*/ + + /*----- PROTECTED REGION END -----*/ // Lambda::exposureAccuTimeStateAllowed_WRITE + return false; + } + return true; + } + return true; +} + +//-------------------------------------------------------- +/** + * Method : Lambda::is_hwAcquisitionMode_allowed() + * Description : Execution allowed for hwAcquisitionMode attribute + */ +//-------------------------------------------------------- +bool Lambda::is_hwAcquisitionMode_allowed(TANGO_UNUSED(Tango::AttReqType type)) +{ + // Not any excluded states for hwAcquisitionMode attribute in Write access. + /*----- PROTECTED REGION ID(Lambda::hwAcquisitionModeStateAllowed_WRITE) ENABLED START -----*/ + + /*----- PROTECTED REGION END -----*/ // Lambda::hwAcquisitionModeStateAllowed_WRITE + + // Not any excluded states for hwAcquisitionMode attribute in read access. + /*----- PROTECTED REGION ID(Lambda::hwAcquisitionModeStateAllowed_READ) ENABLED START -----*/ + + /*----- PROTECTED REGION END -----*/ // Lambda::hwAcquisitionModeStateAllowed_READ +} + //================================================= // Commands Allowed Methods //================================================= diff --git a/specifics/TeledynePI/TangoClassID.txt b/specifics/TeledynePI/TangoClassID.txt new file mode 100644 index 0000000..3bed9b1 --- /dev/null +++ b/specifics/TeledynePI/TangoClassID.txt @@ -0,0 +1,11 @@ +/** + * Device Class Identification: + * + * Class Name : TeledynePI + * Contact : edgard.mfoumoune@synchrotron-soleil.fr + * Class Family : AbstractClasses + * Platform : All Platforms + * Bus : Not Applicable + * Manufacturer : none + * Reference : + */ diff --git a/specifics/TeledynePI/TeledynePI.cpp b/specifics/TeledynePI/TeledynePI.cpp new file mode 100644 index 0000000..f7c68b8 --- /dev/null +++ b/specifics/TeledynePI/TeledynePI.cpp @@ -0,0 +1,936 @@ +/*----- PROTECTED REGION ID(TeledynePI.cpp) ENABLED START -----*/ +//============================================================================= +// +// file : TeledynePI.cpp +// +// description : C++ source for the TeledynePI class and its commands. +// The class is derived from Device. It represents the +// CORBA servant object which will be accessed from the +// network. All commands which can be executed on the +// TeledynePI are implemented in this file. +// +// project : +// +// This file is part of Tango device class. +// +// Tango is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Tango is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Tango. If not, see . +// +// +// +//============================================================================= +// This file is generated by POGO +// (Program Obviously used to Generate tango Object) +//============================================================================= + +#include +#include + +#include +#include + +/*----- PROTECTED REGION END -----*/ // TeledynePI.cpp + +/** + * TeledynePI class description: + * + */ + +//================================================================ +// The following table gives the correspondence +// between command and method names. +// +// Command name | Method name +//================================================================ +// State | dev_state +// Status | Inherited (no method) +//================================================================ + +//================================================================ +// Attributes managed are: +//================================================================ +// temperature | Tango::DevDouble Scalar +// temperatureTarget | Tango::DevDouble Scalar +// gain | Tango::DevEnum Scalar +// adcRate | Tango::DevDouble Scalar +// adcQuality | Tango::DevUShort Scalar +// adcPIxelBitDepth | Tango::DevShort Scalar +//================================================================ + +namespace TeledynePI_ns +{ +/*----- PROTECTED REGION ID(TeledynePI::namespace_starting) ENABLED START -----*/ + +// static initializations + +/*----- PROTECTED REGION END -----*/ // TeledynePI::namespace_starting + +//-------------------------------------------------------- +/** + * Method : TeledynePI::TeledynePI() + * Description : Constructors for a Tango device + * implementing the classTeledynePI + */ +//-------------------------------------------------------- +TeledynePI::TeledynePI(Tango::DeviceClass *cl, string &s) + : TANGO_BASE_CLASS(cl, s.c_str()) +{ + /*----- PROTECTED REGION ID(TeledynePI::constructor_1) ENABLED START -----*/ + init_device(); + + /*----- PROTECTED REGION END -----*/ // TeledynePI::constructor_1 +} +//-------------------------------------------------------- +TeledynePI::TeledynePI(Tango::DeviceClass *cl, const char *s) + : TANGO_BASE_CLASS(cl, s) +{ + /*----- PROTECTED REGION ID(TeledynePI::constructor_2) ENABLED START -----*/ + init_device(); + + /*----- PROTECTED REGION END -----*/ // TeledynePI::constructor_2 +} +//-------------------------------------------------------- +TeledynePI::TeledynePI(Tango::DeviceClass *cl, const char *s, const char *d) + : TANGO_BASE_CLASS(cl, s, d) +{ + /*----- PROTECTED REGION ID(TeledynePI::constructor_3) ENABLED START -----*/ + init_device(); + + /*----- PROTECTED REGION END -----*/ // TeledynePI::constructor_3 +} + +//-------------------------------------------------------- +/** + * Method : TeledynePI::delete_device() + * Description : will be called at device destruction or at init command + */ +//-------------------------------------------------------- +void TeledynePI::delete_device() +{ + INFO_STREAM << "TeledynePI::delete_device() " << device_name << endl; + /*----- PROTECTED REGION ID(TeledynePI::delete_device) ENABLED START -----*/ + + DELETE_SCALAR_ATTRIBUTE(attr_temperature_read); + DELETE_SCALAR_ATTRIBUTE(attr_temperatureTarget_read); + DELETE_SCALAR_ATTRIBUTE(attr_gain_read); + DELETE_SCALAR_ATTRIBUTE(attr_adcRate_read); + + DELETE_SCALAR_ATTRIBUTE(attr_adcQuality_read); + DELETE_SCALAR_ATTRIBUTE(attr_adcPixelBitDepth_read); + + // Delete device allocated objects + INFO_STREAM << "Remove the inner-appender." << endl; + yat4tango::InnerAppender::release(this); + + /*----- PROTECTED REGION END -----*/ // TeledynePI::delete_device +} + +//-------------------------------------------------------- +/** + * Method : TeledynePI::init_device() + * Description : will be called at device initialization. + */ +//-------------------------------------------------------- +void TeledynePI::init_device() +{ + INFO_STREAM << "TeledynePI::init_device() create device " << device_name << endl; + /*----- PROTECTED REGION ID(TeledynePI::init_device_before) ENABLED START -----*/ + + // Initialization before get_device_property() call + CREATE_SCALAR_ATTRIBUTE(attr_temperature_read, 0.0); + CREATE_SCALAR_ATTRIBUTE(attr_temperatureTarget_read, 0.0); + CREATE_SCALAR_ATTRIBUTE(attr_gain_read, (gainEnum)GainMode::LOW); + CREATE_SCALAR_ATTRIBUTE(attr_adcRate_read, 0.0); + + CREATE_SCALAR_ATTRIBUTE(attr_adcQuality_read, (Tango::DevUShort)1); + CREATE_SCALAR_ATTRIBUTE(attr_adcPixelBitDepth_read, (Tango::DevShort)16); + + /*----- PROTECTED REGION END -----*/ // TeledynePI::init_device_before + + + // Get the device properties from database + get_device_property(); + + /*----- PROTECTED REGION ID(TeledynePI::init_device) ENABLED START -----*/ + Tango::Attribute &gain_attribute = get_device_attr()->get_attr_by_name("gain"); + Tango::MultiAttrProp multi_prop_gain_attribute; + gain_attribute.get_properties(multi_prop_gain_attribute); + + multi_prop_gain_attribute.enum_labels = {"LOW", "MEDIUM", "HIGH"}; + gain_attribute.set_properties(multi_prop_gain_attribute); + + // Initialize device + m_is_device_initialized = false; + set_state(Tango::INIT); + m_status_message.str(""); + + INFO_STREAM << "Create the inner-appender in order to manage logs." << endl; + yat4tango::InnerAppender::initialize(this, 512); + + try + { + //- get the main object used to pilot the lima framework + //- in fact LimaDetector is create the singleton control objet + //so this call, will only return existing object, no need to give it the ip !! + m_ct = ControlFactory::instance().get_control("TeledynePI"); + + //- get interface to specific camera + m_hw = dynamic_cast(m_ct->hwInterface()); + } + catch(lima::Exception& e) + { + INFO_STREAM<<"Initialization Failed : "<get_w_attr_by_name("temperatureTarget"); + *attr_temperatureTarget_read = temperatureTargetAtInit; + temperatureTarget.set_write_value(*attr_temperatureTarget_read); + write_temperatureTarget(temperatureTarget); + + INFO_STREAM << "Write tango hardware at Init - gain." << endl; + Tango::WAttribute &gain = dev_attr->get_w_attr_by_name("gain"); + *attr_gain_read = (gainEnum)yat4tango::PropertyHelper::get_memorized_attribute(this, "gain", 0); + gain.set_write_value(*attr_gain_read); + write_gain(gain); + + INFO_STREAM << "Write tango hardware at Init - adcRate." << endl; + Tango::WAttribute &adcRate = dev_attr->get_w_attr_by_name("adcRate"); + *attr_adcRate_read = yat4tango::PropertyHelper::get_memorized_attribute(this, "adcRate", 0.0); + adcRate.set_write_value(*attr_adcRate_read); + write_adcRate(adcRate); + + INFO_STREAM << "Write tango hardware at Init - adcQuality." << endl; + Tango::WAttribute &adcQuality = dev_attr->get_w_attr_by_name("adcQuality"); + *attr_adcQuality_read = yat4tango::PropertyHelper::get_memorized_attribute(this, "adcQuality", 1); + adcQuality.set_write_value(*attr_adcQuality_read); + write_adcQuality(adcQuality); + + INFO_STREAM << "Write tango hardware at Init - adcPixelBitDepth." << endl; + Tango::WAttribute &adcPixelBitDepth = dev_attr->get_w_attr_by_name("adcPixelBitDepth"); + *attr_adcPixelBitDepth_read = yat4tango::PropertyHelper::get_memorized_attribute(this, "adcPixelBitDepth", 16); + adcPixelBitDepth.set_write_value(*attr_adcPixelBitDepth_read); + write_adcPixelBitDepth(adcPixelBitDepth); + } + catch(Tango::DevFailed& df) + { + ERROR_STREAM << df << endl; + m_status_message << "Initialization Failed : "; + for(unsigned i = 0;i < df.errors.length();i++) + { + m_status_message << df.errors[i].desc << endl; + } + m_is_device_initialized = false; + set_state(Tango::FAULT); + return; + } + catch(lima::Exception& e) + { + ERROR_STREAM << "Initialization Failed : " << e.getErrMsg() << endl; + m_status_message << "Initialization Failed : " << e.getErrMsg() << endl; + m_is_device_initialized = false; + set_state(Tango::FAULT); + return; + } + catch(...) + { + m_status_message << "Initialization Failed : Unknown error" << endl; + ERROR_STREAM << m_status_message.str() << endl; + m_is_device_initialized = false; + set_state(Tango::FAULT); + return; + } + + m_is_device_initialized = true; + set_state(Tango::STANDBY); + dev_state(); + /*----- PROTECTED REGION END -----*/ // TeledynePI::init_device +} + +//-------------------------------------------------------- +/** + * Method : TeledynePI::get_device_property() + * Description : Read database to initialize property data members. + */ +//-------------------------------------------------------- +void TeledynePI::get_device_property() +{ + /*----- PROTECTED REGION ID(TeledynePI::get_device_property_before) ENABLED START -----*/ + + // Initialize property data members + + /*----- PROTECTED REGION END -----*/ // TeledynePI::get_device_property_before + + + // Read device properties from database. + Tango::DbData dev_prop; + dev_prop.push_back(Tango::DbDatum("TemperatureTargetAtInit")); + + // is there at least one property to be read ? + if (dev_prop.size()>0) + { + // Call database and extract values + if (Tango::Util::instance()->_UseDb==true) + get_db_device()->get_property(dev_prop); + + // get instance on TeledynePIClass to get class property + Tango::DbDatum def_prop, cl_prop; + TeledynePIClass *ds_class = + (static_cast(get_device_class())); + int i = -1; + + // Try to initialize TemperatureTargetAtInit from class property + cl_prop = ds_class->get_class_property(dev_prop[++i].name); + if (cl_prop.is_empty()==false) cl_prop >> temperatureTargetAtInit; + else { + // Try to initialize TemperatureTargetAtInit from default device value + def_prop = ds_class->get_default_device_property(dev_prop[i].name); + if (def_prop.is_empty()==false) def_prop >> temperatureTargetAtInit; + } + // And try to extract TemperatureTargetAtInit value from database + if (dev_prop[i].is_empty()==false) dev_prop[i] >> temperatureTargetAtInit; + + } + + /*----- PROTECTED REGION ID(TeledynePI::get_device_property_after) ENABLED START -----*/ + yat4tango::PropertyHelper::create_property_if_empty(this, dev_prop,"-60","TemperatureTargetAtInit"); + + // Check device property data members init + + /*----- PROTECTED REGION END -----*/ // TeledynePI::get_device_property_after +} + +//-------------------------------------------------------- +/** + * Method : TeledynePI::always_executed_hook() + * Description : method always executed before any command is executed + */ +//-------------------------------------------------------- +void TeledynePI::always_executed_hook() +{ + /*----- PROTECTED REGION ID(TeledynePI::always_executed_hook) ENABLED START -----*/ + + // code always executed before all requests + try + { + yat::AutoMutex<> _lock(ControlFactory::instance().get_global_mutex()); + if(m_is_device_initialized) + { + m_status_message.str(""); + } + //- get the singleton control objet used to pilot the lima framework + m_ct = ControlFactory::instance().get_control("TeledynePI"); + + //- get interface to specific camera + m_hw = dynamic_cast (m_ct->hwInterface()); + + dev_state(); + } + catch (lima::Exception& e) + { + ERROR_STREAM << e.getErrMsg() << endl; + m_status_message << "Initialization Failed : " << e.getErrMsg() << endl; + //- throw exception + set_state(Tango::FAULT); + m_is_device_initialized = false; + return; + } + catch (Tango::DevFailed& df) + { + ERROR_STREAM << df << endl; + m_status_message << "Initialization Failed : " << string(df.errors[0].desc) << endl; + m_is_device_initialized = false; + set_state(Tango::FAULT); + return; + } + catch (...) + { + ERROR_STREAM << "always_executed_hook Failed : UNKNOWN" << endl; + m_status_message << "always_executed_hook Failed : UNKNOWN" << endl; + m_is_device_initialized = false; + set_state(Tango::FAULT); + return; + } + /*----- PROTECTED REGION END -----*/ // TeledynePI::always_executed_hook +} + +//-------------------------------------------------------- +/** + * Method : TeledynePI::read_attr_hardware() + * Description : Hardware acquisition for attributes + */ +//-------------------------------------------------------- +void TeledynePI::read_attr_hardware(TANGO_UNUSED(vector &attr_list)) +{ + /*----- PROTECTED REGION ID(TeledynePI::read_attr_hardware) ENABLED START -----*/ + + // Add your own code + + /*----- PROTECTED REGION END -----*/ // TeledynePI::read_attr_hardware +} +//-------------------------------------------------------- +/** + * Method : TeledynePI::write_attr_hardware() + * Description : Hardware writing for attributes + */ +//-------------------------------------------------------- +void TeledynePI::write_attr_hardware(TANGO_UNUSED(vector &attr_list)) +{ + /*----- PROTECTED REGION ID(TeledynePI::write_attr_hardware) ENABLED START -----*/ + + // Add your own code + + /*----- PROTECTED REGION END -----*/ // TeledynePI::write_attr_hardware +} + +//-------------------------------------------------------- +/** + * Read attribute temperature related method + * Description: The current temperature (Degree Celsius) + * + * Data type: Tango::DevDouble + * Attr type: Scalar + */ +//-------------------------------------------------------- +void TeledynePI::read_temperature(Tango::Attribute &attr) +{ + DEBUG_STREAM << "TeledynePI::read_temperature(Tango::Attribute &attr) entering... " << endl; + /*----- PROTECTED REGION ID(TeledynePI::read_temperature) ENABLED START -----*/ + try + { + *attr_temperature_read = m_hw->getSensorTemperature(); + attr.set_value(attr_temperature_read); + } + catch(Tango::DevFailed& df) + { + ERROR_STREAM << df << endl; + //- rethrow exception + Tango::Except::re_throw_exception(df, + "TANGO_DEVICE_ERROR", + std::string(df.errors[0].desc).c_str(), + "TeledynePI::read_temperature"); + } + catch(lima::Exception& e) + { + ERROR_STREAM << e.getErrMsg() << endl; + //- throw exception + Tango::Except::throw_exception("TANGO_DEVICE_ERROR", + e.getErrMsg().c_str(), + "TeledynePI::read_temperature"); + } + + /*----- PROTECTED REGION END -----*/ // TeledynePI::read_temperature +} +//-------------------------------------------------------- +/** + * Read attribute temperatureTarget related method + * Description: Define the Temperature target of the detector (in deg Celsius) + * + * Data type: Tango::DevDouble + * Attr type: Scalar + */ +//-------------------------------------------------------- +void TeledynePI::read_temperatureTarget(Tango::Attribute &attr) +{ + DEBUG_STREAM << "TeledynePI::read_temperatureTarget(Tango::Attribute &attr) entering... " << endl; + /*----- PROTECTED REGION ID(TeledynePI::read_temperatureTarget) ENABLED START -----*/ + // Set the attribute value + try + { + *attr_temperatureTarget_read = m_hw->getSensorTemperatureSetpoint(); + attr.set_value(attr_temperatureTarget_read); + } + catch(Tango::DevFailed& df) + { + ERROR_STREAM << df << endl; + //- rethrow exception + Tango::Except::re_throw_exception(df, + "TANGO_DEVICE_ERROR", + std::string(df.errors[0].desc).c_str(), + "TeledynePI::read_temperatureTarget"); + } + catch(lima::Exception& e) + { + ERROR_STREAM << e.getErrMsg() << endl; + //- throw exception + Tango::Except::throw_exception("TANGO_DEVICE_ERROR", + e.getErrMsg().c_str(), + "TeledynePI::read_temperatureTarget"); + } + + /*----- PROTECTED REGION END -----*/ // TeledynePI::read_temperatureTarget +} +//-------------------------------------------------------- +/** + * Write attribute temperatureTarget related method + * Description: Define the Temperature target of the detector (in deg Celsius) + * + * Data type: Tango::DevDouble + * Attr type: Scalar + */ +//-------------------------------------------------------- +void TeledynePI::write_temperatureTarget(Tango::WAttribute &attr) +{ + INFO_STREAM << "TeledynePI::write_temperatureTarget(Tango::WAttribute &attr) entering... " << endl; + // Retrieve write value + Tango::DevDouble w_val; + attr.get_write_value(w_val); + /*----- PROTECTED REGION ID(TeledynePI::write_temperatureTarget) ENABLED START -----*/ + try + { + attr.get_write_value(attr_temperatureTarget_write); + m_hw->setSensorTemperatureSetpoint(attr_temperatureTarget_write); + } + catch(Tango::DevFailed& df) + { + ERROR_STREAM << df << endl; + Tango::Except::re_throw_exception(df, + "TANGO_DEVICE_ERROR", + string(df.errors[0].desc).c_str(), + "TeledynePI::write_temperatureTarget"); + } + catch(lima::Exception& e) + { + ERROR_STREAM << e.getErrMsg() << endl; + Tango::Except::throw_exception("TANGO_DEVICE_ERROR", + e.getErrMsg().c_str(), + "TeledynePI::write_temperatureTarget"); + } + + /*----- PROTECTED REGION END -----*/ // TeledynePI::write_temperatureTarget +} +//-------------------------------------------------------- +/** + * Read attribute gain related method + * Description: Define the gain of the detector [LOW, MEDIUM, HIGH] + * + * Data type: Tango::DevEnum (gainEnum) + * Attr type: Scalar + */ +//-------------------------------------------------------- +void TeledynePI::read_gain(Tango::Attribute &attr) +{ + DEBUG_STREAM << "TeledynePI::read_gain(Tango::Attribute &attr) entering... " << endl; + /*----- PROTECTED REGION ID(TeledynePI::read_gain) ENABLED START -----*/ + // Set the attribute value + + try + { + Tango::DevShort* devShortValue = (Tango::DevShort *)GainMode::LOW; + lima::Princeton::Interface::GainType gain = m_hw->getAdcAnalogGain(); + switch (gain) + { + case lima::Princeton::Interface::GainType::Gain_Low: + devShortValue = (Tango::DevShort *)GainMode::LOW; + break; + + case lima::Princeton::Interface::GainType::Gain_Medium: + devShortValue = (Tango::DevShort *)GainMode::MEDIUM; + break; + + case lima::Princeton::Interface::GainType::Gain_High: + devShortValue = (Tango::DevShort *)GainMode::HIGH; + break; + } + + attr.set_value((Tango::DevShort*) &devShortValue); + } + catch(Tango::DevFailed & df) + { + ERROR_STREAM << df << endl; + Tango::Except::re_throw_exception(df, + "TANGO_DEVICE_ERROR", + string(df.errors[0].desc).c_str(), + "TeledynePI::read_gain"); + } + catch(lima::Exception & e) + { + ERROR_STREAM << e.getErrMsg() << endl; + Tango::Except::throw_exception("TANGO_DEVICE_ERROR", + e.getErrMsg().c_str(), + "TeledynePI::read_gain"); + } + + /*----- PROTECTED REGION END -----*/ // TeledynePI::read_gain +} +//-------------------------------------------------------- +/** + * Write attribute gain related method + * Description: Define the gain of the detector [LOW, MEDIUM, HIGH] + * + * Data type: Tango::DevEnum (gainEnum) + * Attr type: Scalar + */ +//-------------------------------------------------------- +void TeledynePI::write_gain(Tango::WAttribute &attr) +{ + INFO_STREAM << "TeledynePI::write_gain(Tango::WAttribute &attr) entering... " << endl; + // Retrieve write value + gainEnum w_val; + attr.get_write_value(w_val); + /*----- PROTECTED REGION ID(TeledynePI::write_gain) ENABLED START -----*/ + try + { + attr_gain_write = w_val; + lima::Princeton::Interface::GainType enum_gain_value; + switch (attr_gain_write) + { + case GainMode::LOW: + enum_gain_value = lima::Princeton::Interface::GainType::Gain_Low; + break; + + case GainMode::MEDIUM: + enum_gain_value = lima::Princeton::Interface::GainType::Gain_Medium; + break; + + case GainMode::HIGH: + enum_gain_value = lima::Princeton::Interface::GainType::Gain_High; + break; + } + m_hw->setAdcAnalogGain(enum_gain_value); + yat4tango::PropertyHelper::set_memorized_attribute(this, "gain", w_val); + } + + catch (Tango::DevFailed &df) + { + ERROR_STREAM << df << endl; + Tango::Except::re_throw_exception(df, + "TANGO_DEVICE_ERROR", + string(df.errors[0].desc).c_str(), + "TeledynePI::write_gain"); + } + catch (lima::Exception &e) + { + ERROR_STREAM << e.getErrMsg() << endl; + Tango::Except::throw_exception("TANGO_DEVICE_ERROR", + e.getErrMsg().c_str(), + "TeledynePI::write_gain"); + } + /*----- PROTECTED REGION END -----*/ // TeledynePI::write_gain +} +//-------------------------------------------------------- +/** + * Read attribute adcRate related method + * Description: Define the speed at which pixels are digitized (MHz) + * + * Data type: Tango::DevDouble + * Attr type: Scalar + */ +//-------------------------------------------------------- +void TeledynePI::read_adcRate(Tango::Attribute &attr) +{ + DEBUG_STREAM << "TeledynePI::read_adcRate(Tango::Attribute &attr) entering... " << endl; + /*----- PROTECTED REGION ID(TeledynePI::read_adcRate) ENABLED START -----*/ + // Set the attribute value + try + { + *attr_adcRate_read = m_hw->getAdcSpeed(); + } + catch(Tango::DevFailed& df) + { + ERROR_STREAM << df << endl; + Tango::Except::re_throw_exception(df, + "TANGO_DEVICE_ERROR", + std::string(df.errors[0].desc).c_str(), + "TeledynePI::read_adcRate"); + } + catch(lima::Exception& e) + { + ERROR_STREAM << e.getErrMsg() << endl; + Tango::Except::throw_exception("TANGO_DEVICE_ERROR", + e.getErrMsg().c_str(), + "TeledynePI::read_adcRate"); + } + /*----- PROTECTED REGION END -----*/ // TeledynePI::read_adcRate +} +//-------------------------------------------------------- +/** + * Write attribute adcRate related method + * Description: Define the speed at which pixels are digitized (MHz) + * + * Data type: Tango::DevDouble + * Attr type: Scalar + */ +//-------------------------------------------------------- +void TeledynePI::write_adcRate(Tango::WAttribute &attr) +{ + INFO_STREAM << "TeledynePI::write_adcRate(Tango::WAttribute &attr) entering... " << endl; + // Retrieve write value + Tango::DevDouble w_val; + attr.get_write_value(w_val); + /*----- PROTECTED REGION ID(TeledynePI::write_adcRate) ENABLED START -----*/ + try + { + attr.get_write_value(attr_adcRate_write); + m_hw->setAdcSpeed(attr_adcRate_write); + } + catch(Tango::DevFailed& df) + { + ERROR_STREAM << df << endl; + Tango::Except::re_throw_exception(df, + "TANGO_DEVICE_ERROR", + string(df.errors[0].desc).c_str(), + "TeledynePI::write_adcRate"); + } + catch(lima::Exception& e) + { + ERROR_STREAM << e.getErrMsg() << endl; + Tango::Except::throw_exception("TANGO_DEVICE_ERROR", + e.getErrMsg().c_str(), + "TeledynePI::write_adcRate"); + } + + /*----- PROTECTED REGION END -----*/ // TeledynePI::write_adcRate +} + + +//-------------------------------------------------------- +/** + * Read attribute adcQuality related method + * Description: Define the speed at which pixels are digitized (MHz) + * + * Data type: Tango::DevUShort + * Attr type: Scalar + */ +//-------------------------------------------------------- +void TeledynePI::read_adcQuality(Tango::Attribute &attr) +{ + DEBUG_STREAM << "TeledynePI::read_adcQuality(Tango::Attribute &attr) entering... " << endl; + /*----- PROTECTED REGION ID(TeledynePI::read_adcQuality) ENABLED START -----*/ + // Set the attribute value + try + { + *attr_adcQuality_read = (Tango::DevUShort)m_hw->getAdcQuality(); + } + catch(Tango::DevFailed& df) + { + ERROR_STREAM << df << endl; + Tango::Except::re_throw_exception(df, + "TANGO_DEVICE_ERROR", + std::string(df.errors[0].desc).c_str(), + "TeledynePI::read_adcQuality"); + } + catch(lima::Exception& e) + { + ERROR_STREAM << e.getErrMsg() << endl; + Tango::Except::throw_exception("TANGO_DEVICE_ERROR", + e.getErrMsg().c_str(), + "TeledynePI::read_adcQuality"); + } + /*----- PROTECTED REGION END -----*/ // TeledynePI::read_adcQuality +} +//-------------------------------------------------------- +/** + * Write attribute adcQuality related method + * Description: Define the speed at which pixels are digitized (MHz) + * + * Data type: Tango::DevUShort + * Attr type: Scalar + */ +//-------------------------------------------------------- +void TeledynePI::write_adcQuality(Tango::WAttribute &attr) +{ + INFO_STREAM << "TeledynePI::write_adcQuality(Tango::WAttribute &attr) entering... " << endl; + // Retrieve write value + Tango::DevUShort w_val; + attr.get_write_value(w_val); + /*----- PROTECTED REGION ID(TeledynePI::write_adcQuality) ENABLED START -----*/ + try + { + attr.get_write_value(attr_adcQuality_write); + m_hw->setAdcQuality(attr_adcQuality_write); + } + catch(Tango::DevFailed& df) + { + ERROR_STREAM << df << endl; + Tango::Except::re_throw_exception(df, + "TANGO_DEVICE_ERROR", + string(df.errors[0].desc).c_str(), + "TeledynePI::write_adcQuality"); + } + catch(lima::Exception& e) + { + ERROR_STREAM << e.getErrMsg() << endl; + Tango::Except::throw_exception("TANGO_DEVICE_ERROR", + e.getErrMsg().c_str(), + "TeledynePI::write_adcQuality"); + } + + /*----- PROTECTED REGION END -----*/ // TeledynePI::write_adcQuality +} + + +//-------------------------------------------------------- +/** + * Read attribute adcPixelBitDepth related method + * Description: Define the speed at which pixels are digitized (MHz) + * + * Data type: Tango::DevUShort + * Attr type: Scalar + */ +//-------------------------------------------------------- +void TeledynePI::read_adcPixelBitDepth(Tango::Attribute &attr) +{ + DEBUG_STREAM << "TeledynePI::read_adcPixelBitDepth(Tango::Attribute &attr) entering... " << endl; + /*----- PROTECTED REGION ID(TeledynePI::read_adcPixelBitDepth) ENABLED START -----*/ + // Set the attribute value + try + { + *attr_adcPixelBitDepth_read = (Tango::DevShort)m_hw->getAdcPixelBitDepth(); + } + catch(Tango::DevFailed& df) + { + ERROR_STREAM << df << endl; + Tango::Except::re_throw_exception(df, + "TANGO_DEVICE_ERROR", + std::string(df.errors[0].desc).c_str(), + "TeledynePI::read_adcPixelBitDepth"); + } + catch(lima::Exception& e) + { + ERROR_STREAM << e.getErrMsg() << endl; + Tango::Except::throw_exception("TANGO_DEVICE_ERROR", + e.getErrMsg().c_str(), + "TeledynePI::read_adcPixelBitDepth"); + } + /*----- PROTECTED REGION END -----*/ // TeledynePI::read_adcPixelBitDepth +} +//-------------------------------------------------------- +/** + * Write attribute adcPixelBitDepth related method + * Description: Define the pixel bit depth + * + * Data type: Tango::DevShort + * Attr type: Scalar + */ +//-------------------------------------------------------- +void TeledynePI::write_adcPixelBitDepth(Tango::WAttribute &attr) +{ + INFO_STREAM << "TeledynePI::write_adcPixelBitDepth(Tango::WAttribute &attr) entering... " << endl; + // Retrieve write value + Tango::DevShort w_val; + attr.get_write_value(w_val); + /*----- PROTECTED REGION ID(TeledynePI::write_adcPixelBitDepth) ENABLED START -----*/ + try + { + attr.get_write_value(attr_adcPixelBitDepth_write); + m_hw->setAdcPixelBitDepth(attr_adcPixelBitDepth_write); + } + catch(Tango::DevFailed& df) + { + ERROR_STREAM << df << endl; + Tango::Except::re_throw_exception(df, + "TANGO_DEVICE_ERROR", + string(df.errors[0].desc).c_str(), + "TeledynePI::write_adcPixelBitDepth"); + } + catch(lima::Exception& e) + { + ERROR_STREAM << e.getErrMsg() << endl; + Tango::Except::throw_exception("TANGO_DEVICE_ERROR", + e.getErrMsg().c_str(), + "TeledynePI::write_adcPixelBitDepth"); + } + + /*----- PROTECTED REGION END -----*/ // TeledynePI::write_adcPixelBitDepth +} + +//-------------------------------------------------------- +/** + * Method : TeledynePI::add_dynamic_attributes() + * Description : Create the dynamic attributes if any + * for specified device. + */ +//-------------------------------------------------------- +void TeledynePI::add_dynamic_attributes() +{ + /*----- PROTECTED REGION ID(TeledynePI::add_dynamic_attributes) ENABLED START -----*/ + + // Add your own code to create and add dynamic attributes if any + + /*----- PROTECTED REGION END -----*/ // TeledynePI::add_dynamic_attributes +} + +//-------------------------------------------------------- +/** + * Command State related method + * Description: This command gets the device state (stored in its device_state data member) and returns it to the caller. + * + * @returns Device state + */ +//-------------------------------------------------------- +Tango::DevState TeledynePI::dev_state() +{ + DEBUG_STREAM << "TeledynePI::State() - " << device_name << endl; + /*----- PROTECTED REGION ID(TeledynePI::dev_state) ENABLED START -----*/ + + Tango::DevState argout = DeviceImpl::dev_state(); + stringstream DeviceStatus; + DeviceStatus << ""; + Tango::DevState DeviceState = Tango::STANDBY; + + if(!m_is_device_initialized ) + { + DeviceState = Tango::FAULT; + DeviceStatus << m_status_message.str(); + } + else + { + // state & status are retrieved from Factory, Factory is updated by Generic device + DeviceState = ControlFactory::instance().get_state(); + DeviceStatus << ControlFactory::instance().get_status(); + } + + set_state(DeviceState); + set_status(DeviceStatus.str()); + + argout = DeviceState; + return argout; + + /*----- PROTECTED REGION END -----*/ // TeledynePI::dev_state +} +//-------------------------------------------------------- +/** + * Method : TeledynePI::add_dynamic_commands() + * Description : Create the dynamic commands if any + * for specified device. + */ +//-------------------------------------------------------- +void TeledynePI::add_dynamic_commands() +{ + /*----- PROTECTED REGION ID(TeledynePI::add_dynamic_commands) ENABLED START -----*/ + + // Add your own code to create and add dynamic commands if any + + /*----- PROTECTED REGION END -----*/ // TeledynePI::add_dynamic_commands +} + +/*----- PROTECTED REGION ID(TeledynePI::namespace_ending) ENABLED START -----*/ + +/*----- PROTECTED REGION END -----*/ // TeledynePI::namespace_ending +} // namespace diff --git a/specifics/TeledynePI/TeledynePI.h b/specifics/TeledynePI/TeledynePI.h new file mode 100644 index 0000000..1c4fcb8 --- /dev/null +++ b/specifics/TeledynePI/TeledynePI.h @@ -0,0 +1,295 @@ +/*----- PROTECTED REGION ID(TeledynePI.h) ENABLED START -----*/ +//============================================================================= +// +// file : TeledynePI.h +// +// description : Include file for the TeledynePI class +// +// project : +// +// This file is part of Tango device class. +// +// Tango is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Tango is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Tango. If not, see . +// +// +// +//============================================================================= +// This file is generated by POGO +// (Program Obviously used to Generate tango Object) +//============================================================================= + + +#ifndef TeledynePI_H +#define TeledynePI_H + +#include +#include "Factory.h" + +//- YAT/YAT4TANGO +#include +#include + +#include "lima/HwInterface.h" +#include "lima/CtControl.h" +#include "lima/CtAcquisition.h" +#include "lima/CtImage.h" +#include + +#define MAX_ATTRIBUTE_STRING_LENGTH 256 + +/*----- PROTECTED REGION END -----*/ // TeledynePI.h + +/** + * TeledynePI class description: + * + */ + +namespace TeledynePI_ns +{ +enum _gainEnum : short{ +} ; +typedef _gainEnum gainEnum; + +/*----- PROTECTED REGION ID(TeledynePI::Additional Class Declarations) ENABLED START -----*/ + +// Additional Class Declarations + +/*----- PROTECTED REGION END -----*/ // TeledynePI::Additional Class Declarations + +class TeledynePI : public TANGO_BASE_CLASS +{ + +/*----- PROTECTED REGION ID(TeledynePI::Data Members) ENABLED START -----*/ + +public : + // Add your own data members here + //----------------------------------------- + Tango::DevUShort attr_gain_cache; + Tango::DevDouble attr_temperatureTarget_cache; + + // Here is the Start of the automatic code generation part + //------------------------------------------------------------- + Tango::DevDouble attr_temperatureTarget_write; + gainEnum attr_gain_write; + Tango::DevDouble attr_adcRate_write; + Tango::DevUShort attr_adcQuality_write; + Tango::DevShort attr_adcPixelBitDepth_write; + +/*----- PROTECTED REGION END -----*/ // TeledynePI::Data Members + +// Device property data members +public: + // TemperatureTargetAtInit: Define the target temperature to be used at device initialization + Tango::DevDouble temperatureTargetAtInit; + +// Attribute data members +public: + Tango::DevDouble *attr_temperature_read; + Tango::DevDouble *attr_temperatureTarget_read; + gainEnum *attr_gain_read; + Tango::DevDouble *attr_adcRate_read; + Tango::DevUShort *attr_adcQuality_read; + Tango::DevShort *attr_adcPixelBitDepth_read; + +// Constructors and destructors +public: + /** + * Constructs a newly device object. + * + * @param cl Class. + * @param s Device Name + */ + TeledynePI(Tango::DeviceClass *cl,string &s); + /** + * Constructs a newly device object. + * + * @param cl Class. + * @param s Device Name + */ + TeledynePI(Tango::DeviceClass *cl,const char *s); + /** + * Constructs a newly device object. + * + * @param cl Class. + * @param s Device name + * @param d Device description. + */ + TeledynePI(Tango::DeviceClass *cl,const char *s,const char *d); + /** + * The device object destructor. + */ + ~TeledynePI() {delete_device();}; + + +// Miscellaneous methods +public: + /* + * will be called at device destruction or at init command. + */ + void delete_device(); + /* + * Initialize the device + */ + virtual void init_device(); + /* + * Read the device properties from database + */ + void get_device_property(); + /* + * Always executed method before execution command method. + */ + virtual void always_executed_hook(); + + +// Attribute methods +public: + //-------------------------------------------------------- + /* + * Method : TeledynePI::read_attr_hardware() + * Description : Hardware acquisition for attributes. + */ + //-------------------------------------------------------- + virtual void read_attr_hardware(vector &attr_list); + //-------------------------------------------------------- + /* + * Method : TeledynePI::write_attr_hardware() + * Description : Hardware writing for attributes. + */ + //-------------------------------------------------------- + virtual void write_attr_hardware(vector &attr_list); + +/** + * Attribute temperature related methods + * Description: The current temperature (Degree Celsius) + * + * Data type: Tango::DevDouble + * Attr type: Scalar + */ + virtual void read_temperature(Tango::Attribute &attr); + virtual bool is_temperature_allowed(Tango::AttReqType type); +/** + * Attribute temperatureTarget related methods + * Description: Define the Temperature target of the detector (in deg Celsius) + * + * Data type: Tango::DevDouble + * Attr type: Scalar + */ + virtual void read_temperatureTarget(Tango::Attribute &attr); + virtual void write_temperatureTarget(Tango::WAttribute &attr); + virtual bool is_temperatureTarget_allowed(Tango::AttReqType type); +/** + * Attribute gain related methods + * Description: Define the gain of the detector [LOW, MEDIUM, HIGH] + * + * Data type: Tango::DevEnum + * Attr type: Scalar + */ + virtual void read_gain(Tango::Attribute &attr); + virtual void write_gain(Tango::WAttribute &attr); + virtual bool is_gain_allowed(Tango::AttReqType type); +/** + * Attribute adcRate related methods + * Description: Define the speed at which pixels are digitized (MHz) + * + * Data type: Tango::DevDouble + * Attr type: Scalar + */ + virtual void read_adcRate(Tango::Attribute &attr); + virtual void write_adcRate(Tango::WAttribute &attr); + virtual bool is_adcRate_allowed(Tango::AttReqType type); + +/** + * Attribute adcQuality related methods + * Description: Define the quality + * + * Data type: Tango::DevDouble + * Attr type: Scalar + */ + virtual void read_adcQuality(Tango::Attribute &attr); + virtual void write_adcQuality(Tango::WAttribute &attr); + virtual bool is_adcQuality_allowed(Tango::AttReqType type); + +/** + * Attribute adcPixelBitDepth related methods + * Description: Define the speed at which pixels are digitized (MHz) + * + * Data type: Tango::DevDouble + * Attr type: Scalar + */ + virtual void read_adcPixelBitDepth(Tango::Attribute &attr); + virtual void write_adcPixelBitDepth(Tango::WAttribute &attr); + virtual bool is_adcPixelBitDepth_allowed(Tango::AttReqType type); + + //-------------------------------------------------------- + /** + * Method : TeledynePI::add_dynamic_attributes() + * Description : Add dynamic attributes if any. + */ + //-------------------------------------------------------- + void add_dynamic_attributes(); + + + + +// Command related methods +public: + /** + * Command State related method + * Description: This command gets the device state (stored in its device_state data member) and returns it to the caller. + * + * @returns Device state + */ + virtual Tango::DevState dev_state(); + + + //-------------------------------------------------------- + /** + * Method : TeledynePI::add_dynamic_commands() + * Description : Add dynamic commands if any. + */ + //-------------------------------------------------------- + void add_dynamic_commands(); + +/*----- PROTECTED REGION ID(TeledynePI::Additional Method prototypes) ENABLED START -----*/ + bool is_device_initialized(){return m_is_device_initialized;}; +// Additional Method prototypes +protected : + // Add your own data members here + //----------------------------------------- + + //state & status stuff + bool m_is_device_initialized ; + stringstream m_status_message; + + //lima OBJECTS + lima::Princeton::Interface* m_hw; + lima::CtControl* m_ct; +/*----- PROTECTED REGION END -----*/ // TeledynePI::Additional Method prototypes +}; + +/*----- PROTECTED REGION ID(TeledynePI::Additional Classes Definitions) ENABLED START -----*/ + +// Additional Classes Definitions +enum class GainMode : short +{ + LOW, + MEDIUM, + HIGH +}; + +/*----- PROTECTED REGION END -----*/ // TeledynePI::Additional Classes Definitions + +} // End of namespace + +#endif // TeledynePI_H diff --git a/specifics/TeledynePI/TeledynePI.xmi b/specifics/TeledynePI/TeledynePI.xmi new file mode 100644 index 0000000..37a27c4 --- /dev/null +++ b/specifics/TeledynePI/TeledynePI.xmi @@ -0,0 +1,120 @@ + + + + + + + + + + + -60 + + + + + + + + + + + + + + + + + + + + + + + + + + + FAULT + INIT + + + + + + + + + FAULT + INIT + FAULT + INIT + RUNNING + + + + + + + + + FAULT + INIT + FAULT + INIT + RUNNING + + + + + + + + + FAULT + INIT + FAULT + INIT + RUNNING + + + + + + + + + FAULT + INIT + FAULT + INIT + RUNNING + + + + + + + + + FAULT + INIT + FAULT + INIT + RUNNING + + + + + + + + + + + + + + + + diff --git a/specifics/TeledynePI/TeledynePIClass.cpp b/specifics/TeledynePI/TeledynePIClass.cpp new file mode 100644 index 0000000..d04b9ee --- /dev/null +++ b/specifics/TeledynePI/TeledynePIClass.cpp @@ -0,0 +1,628 @@ +/*----- PROTECTED REGION ID(TeledynePIClass.cpp) ENABLED START -----*/ +//============================================================================= +// +// file : TeledynePIClass.cpp +// +// description : C++ source for the TeledynePIClass. +// A singleton class derived from DeviceClass. +// It implements the command and attribute list +// and all properties and methods required +// by the TeledynePI once per process. +// +// project : +// +// This file is part of Tango device class. +// +// Tango is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Tango is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Tango. If not, see . +// +// +// +//============================================================================= +// This file is generated by POGO +// (Program Obviously used to Generate tango Object) +//============================================================================= + + +#include + +/*----- PROTECTED REGION END -----*/ // TeledynePIClass.cpp + +//------------------------------------------------------------------- +/** + * Create TeledynePIClass singleton and + * return it in a C function for Python usage + */ +//------------------------------------------------------------------- +extern "C" { +#ifdef _TG_WINDOWS_ + +__declspec(dllexport) + +#endif + + Tango::DeviceClass *_create_TeledynePI_class(const char *name) { + return TeledynePI_ns::TeledynePIClass::init(name); + } +} + +namespace TeledynePI_ns +{ +//=================================================================== +// Initialize pointer for singleton pattern +//=================================================================== +TeledynePIClass *TeledynePIClass::_instance = NULL; + +//-------------------------------------------------------- +/** + * method : TeledynePIClass::TeledynePIClass(string &s) + * description : constructor for the TeledynePIClass + * + * @param s The class name + */ +//-------------------------------------------------------- +TeledynePIClass::TeledynePIClass(string &s):Tango::DeviceClass(s) +{ + cout2 << "Entering TeledynePIClass constructor" << endl; + set_default_property(); + write_class_property(); + + /*----- PROTECTED REGION ID(TeledynePIClass::constructor) ENABLED START -----*/ + + /*----- PROTECTED REGION END -----*/ // TeledynePIClass::constructor + + cout2 << "Leaving TeledynePIClass constructor" << endl; +} + +//-------------------------------------------------------- +/** + * method : TeledynePIClass::~TeledynePIClass() + * description : destructor for the TeledynePIClass + */ +//-------------------------------------------------------- +TeledynePIClass::~TeledynePIClass() +{ + /*----- PROTECTED REGION ID(TeledynePIClass::destructor) ENABLED START -----*/ + + /*----- PROTECTED REGION END -----*/ // TeledynePIClass::destructor + + _instance = NULL; +} + + +//-------------------------------------------------------- +/** + * method : TeledynePIClass::init + * description : Create the object if not already done. + * Otherwise, just return a pointer to the object + * + * @param name The class name + */ +//-------------------------------------------------------- +TeledynePIClass *TeledynePIClass::init(const char *name) +{ + if (_instance == NULL) + { + try + { + string s(name); + _instance = new TeledynePIClass(s); + } + catch (bad_alloc &) + { + throw; + } + } + return _instance; +} + +//-------------------------------------------------------- +/** + * method : TeledynePIClass::instance + * description : Check if object already created, + * and return a pointer to the object + */ +//-------------------------------------------------------- +TeledynePIClass *TeledynePIClass::instance() +{ + if (_instance == NULL) + { + cerr << "Class is not initialised !!" << endl; + exit(-1); + } + return _instance; +} + + + +//=================================================================== +// Command execution method calls +//=================================================================== + +//=================================================================== +// Properties management +//=================================================================== +//-------------------------------------------------------- +/** + * Method : TeledynePIClass::get_class_property() + * Description : Get the class property for specified name. + */ +//-------------------------------------------------------- +Tango::DbDatum TeledynePIClass::get_class_property(string &prop_name) +{ + for (unsigned int i=0 ; i vect_data; + + // Set Default Class Properties + + // Set Default device Properties + prop_name = "TemperatureTargetAtInit"; + prop_desc = "Define the target temperature to be used at device initialization"; + prop_def = "-60"; + vect_data.clear(); + vect_data.push_back("-60"); + 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); +} + +//-------------------------------------------------------- +/** + * Method : TeledynePIClass::write_class_property() + * Description : Set class description fields as property in database + */ +//-------------------------------------------------------- +void TeledynePIClass::write_class_property() +{ + // First time, check if database used + if (Tango::Util::_UseDb == false) + return; + + Tango::DbData data; + string classname = get_name(); + string header; + string::size_type start, end; + + // Put title + Tango::DbDatum title("ProjectTitle"); + string str_title(""); + title << str_title; + data.push_back(title); + + // Put Description + Tango::DbDatum description("Description"); + vector str_desc; + str_desc.push_back(""); + description << str_desc; + data.push_back(description); + + // Put inheritance + Tango::DbDatum inher_datum("InheritedFrom"); + vector inheritance; + inheritance.push_back("TANGO_BASE_CLASS"); + inher_datum << inheritance; + data.push_back(inher_datum); + + // Call database and and values + get_db_class()->put_property(data); +} + +//=================================================================== +// Factory methods +//=================================================================== + +//-------------------------------------------------------- +/** + * Method : TeledynePIClass::device_factory() + * Description : Create the device object(s) + * and store them in the device list + */ +//-------------------------------------------------------- +void TeledynePIClass::device_factory(const Tango::DevVarStringArray *devlist_ptr) +{ + /*----- PROTECTED REGION ID(TeledynePIClass::device_factory_before) ENABLED START -----*/ + + // Add your own code + + /*----- PROTECTED REGION END -----*/ // TeledynePIClass::device_factory_before + + // Create devices and add it into the device list + for (unsigned long i=0 ; ilength() ; i++) + { + cout4 << "Device name : " << (*devlist_ptr)[i].in() << endl; + device_list.push_back(new TeledynePI(this, (*devlist_ptr)[i])); + } + + // Manage dynamic attributes if any + erase_dynamic_attributes(devlist_ptr, get_class_attr()->get_attr_list()); + + // Export devices to the outside world + for (unsigned long i=1 ; i<=devlist_ptr->length() ; i++) + { + // Add dynamic attributes if any + TeledynePI *dev = static_cast(device_list[device_list.size()-i]); + dev->add_dynamic_attributes(); + + // Check before if database used. + if ((Tango::Util::_UseDb == true) && (Tango::Util::_FileDb == false)) + export_device(dev); + else + export_device(dev, dev->get_name().c_str()); + } + + /*----- PROTECTED REGION ID(TeledynePIClass::device_factory_after) ENABLED START -----*/ + + // Add your own code + + /*----- PROTECTED REGION END -----*/ // TeledynePIClass::device_factory_after +} +//-------------------------------------------------------- +/** + * Method : TeledynePIClass::attribute_factory() + * Description : Create the attribute object(s) + * and store them in the attribute list + */ +//-------------------------------------------------------- +void TeledynePIClass::attribute_factory(vector &att_list) +{ + /*----- PROTECTED REGION ID(TeledynePIClass::attribute_factory_before) ENABLED START -----*/ + + // Add your own code + + /*----- PROTECTED REGION END -----*/ // TeledynePIClass::attribute_factory_before + // Attribute : temperature + temperatureAttrib *temperature = new temperatureAttrib(); + Tango::UserDefaultAttrProp temperature_prop; + temperature_prop.set_description("The current temperature (Degree Celsius)"); + // label not set for temperature + temperature_prop.set_unit("deg C"); + // standard_unit not set for temperature + // display_unit not set for temperature + temperature_prop.set_format("%6.2f"); + // max_value not set for temperature + // min_value not set for temperature + // max_alarm not set for temperature + // min_alarm not set for temperature + // max_warning not set for temperature + // min_warning not set for temperature + // delta_t not set for temperature + // delta_val not set for temperature + + temperature->set_default_properties(temperature_prop); + // Not Polled + temperature->set_disp_level(Tango::OPERATOR); + // Not Memorized + att_list.push_back(temperature); + + // Attribute : temperatureTarget + temperatureTargetAttrib *temperaturetarget = new temperatureTargetAttrib(); + Tango::UserDefaultAttrProp temperaturetarget_prop; + temperaturetarget_prop.set_description("Define the Temperature target of the detector (in deg Celsius)"); + // label not set for temperatureTarget + temperaturetarget_prop.set_unit("deg C"); + // standard_unit not set for temperatureTarget + // display_unit not set for temperatureTarget + temperaturetarget_prop.set_format("%6.2f"); + // max_value not set for temperatureTarget + // min_value not set for temperatureTarget + // max_alarm not set for temperatureTarget + // min_alarm not set for temperatureTarget + // max_warning not set for temperatureTarget + // min_warning not set for temperatureTarget + // delta_t not set for temperatureTarget + // delta_val not set for temperatureTarget + + temperaturetarget->set_default_properties(temperaturetarget_prop); + // Not Polled + temperaturetarget->set_disp_level(Tango::OPERATOR); + // Not Memorized + att_list.push_back(temperaturetarget); + + // Attribute : gain + gainAttrib *gain = new gainAttrib(); + Tango::UserDefaultAttrProp gain_prop; + gain_prop.set_description("Define the gain of the detector [LOW, MEDIUM, HIGH]"); + // label not set for gain + // unit not set for gain + // standard_unit not set for gain + // display_unit not set for gain + // format not set for gain + // max_value not set for gain + // min_value not set for gain + // max_alarm not set for gain + // min_alarm not set for gain + // max_warning not set for gain + // min_warning not set for gain + // delta_t not set for gain + // delta_val not set for gain + + gain->set_default_properties(gain_prop); + // Not Polled + gain->set_disp_level(Tango::OPERATOR); + // Not Memorized + att_list.push_back(gain); + + // Attribute : adcRate + adcRateAttrib *adcrate = new adcRateAttrib(); + Tango::UserDefaultAttrProp adcrate_prop; + adcrate_prop.set_description("Define the speed at which pixels are digitized (MHz)"); + // label not set for adcRate + // unit not set for adcRate + // standard_unit not set for adcRate + adcrate_prop.set_display_unit("MHz"); + // format not set for adcRate + // max_value not set for adcRate + // min_value not set for adcRate + // max_alarm not set for adcRate + // min_alarm not set for adcRate + // max_warning not set for adcRate + // min_warning not set for adcRate + // delta_t not set for adcRate + // delta_val not set for adcRate + + adcrate->set_default_properties(adcrate_prop); + // Not Polled + adcrate->set_disp_level(Tango::OPERATOR); + // Not Memorized + att_list.push_back(adcrate); + + + // Attribute : adcQuality + adcQualityAttrib *adcquality = new adcQualityAttrib(); + Tango::UserDefaultAttrProp adcquality_prop; + adcquality_prop.set_description("Define the quality [LowNoise, HighCapacity, HighSpeed, ElectronMultiplied]"); + // label not set for adcquality + // unit not set for adcquality + // standard_unit not set for adcquality + //adcquality_prop.set_display_unit(""); + //adcquality_prop.set_min_value(1); + //adcquality_prop.set_max_value(4); + // format not set for adcquality + // max_value not set for adcquality + // min_value not set for adcquality + // max_alarm not set for adcquality + // min_alarm not set for adcquality + // max_warning not set for adcquality + // min_warning not set for adcquality + // delta_t not set for adcquality + // delta_val not set for adcquality + + adcquality->set_default_properties(adcquality_prop); + // Not Polled + adcquality->set_disp_level(Tango::OPERATOR); + // Not Memorized + att_list.push_back(adcquality); + + + // Attribute : adcPixelBitDepth + adcPixelBitDepthAttrib *adcPixelBitDepth = new adcPixelBitDepthAttrib(); + Tango::UserDefaultAttrProp adcPixelBitDepth_prop; + adcquality_prop.set_description("Define the pixel bit depth"); + // label not set for adcPixelBitDepth + // unit not set for adcPixelBitDepth + // standard_unit not set for adcPixelBitDepth + //adcPixelBitDepth_prop.set_display_unit(""); + // format not set for adcPixelBitDepth + // max_value not set for adcPixelBitDepth + // min_value not set for adcPixelBitDepth + // max_alarm not set for adcPixelBitDepth + // min_alarm not set for adcPixelBitDepth + // max_warning not set for adcPixelBitDepth + // min_warning not set for adcPixelBitDepth + // delta_t not set for adcPixelBitDepth + // delta_val not set for adcPixelBitDepth + + adcPixelBitDepth->set_default_properties(adcPixelBitDepth_prop); + // Not Polled + adcPixelBitDepth->set_disp_level(Tango::OPERATOR); + // Not Memorized + att_list.push_back(adcPixelBitDepth); + + // Create a list of static attributes + create_static_attribute_list(get_class_attr()->get_attr_list()); + /*----- PROTECTED REGION ID(TeledynePIClass::attribute_factory_after) ENABLED START -----*/ + + // Add your own code + + /*----- PROTECTED REGION END -----*/ // TeledynePIClass::attribute_factory_after +} +//-------------------------------------------------------- +/** + * Method : TeledynePIClass::pipe_factory() + * Description : Create the pipe object(s) + * and store them in the pipe list + */ +//-------------------------------------------------------- +void TeledynePIClass::pipe_factory() +{ + /*----- PROTECTED REGION ID(TeledynePIClass::pipe_factory_before) ENABLED START -----*/ + + // Add your own code + + /*----- PROTECTED REGION END -----*/ // TeledynePIClass::pipe_factory_before + /*----- PROTECTED REGION ID(TeledynePIClass::pipe_factory_after) ENABLED START -----*/ + + // Add your own code + + /*----- PROTECTED REGION END -----*/ // TeledynePIClass::pipe_factory_after +} +//-------------------------------------------------------- +/** + * Method : TeledynePIClass::command_factory() + * Description : Create the command object(s) + * and store them in the command list + */ +//-------------------------------------------------------- +void TeledynePIClass::command_factory() +{ + /*----- PROTECTED REGION ID(TeledynePIClass::command_factory_before) ENABLED START -----*/ + + // Add your own code + + /*----- PROTECTED REGION END -----*/ // TeledynePIClass::command_factory_before + + + /*----- PROTECTED REGION ID(TeledynePIClass::command_factory_after) ENABLED START -----*/ + + // Add your own code + + /*----- PROTECTED REGION END -----*/ // TeledynePIClass::command_factory_after +} + +//=================================================================== +// Dynamic attributes related methods +//=================================================================== + +//-------------------------------------------------------- +/** + * method : TeledynePIClass::create_static_attribute_list + * description : Create the a list of static attributes + * + * @param att_list the ceated attribute list + */ +//-------------------------------------------------------- +void TeledynePIClass::create_static_attribute_list(vector &att_list) +{ + for (unsigned long i=0 ; iget_name()); + transform(att_name.begin(), att_name.end(), att_name.begin(), ::tolower); + defaultAttList.push_back(att_name); + } + + cout2 << defaultAttList.size() << " attributes in default list" << endl; + + /*----- PROTECTED REGION ID(TeledynePIClass::create_static_att_list) ENABLED START -----*/ + + /*----- PROTECTED REGION END -----*/ // TeledynePIClass::create_static_att_list +} + + +//-------------------------------------------------------- +/** + * method : TeledynePIClass::erase_dynamic_attributes + * description : delete the dynamic attributes if any. + * + * @param devlist_ptr the device list pointer + * @param list of all attributes + */ +//-------------------------------------------------------- +void TeledynePIClass::erase_dynamic_attributes(const Tango::DevVarStringArray *devlist_ptr, vector &att_list) +{ + Tango::Util *tg = Tango::Util::instance(); + + for (unsigned long i=0 ; ilength() ; i++) + { + Tango::DeviceImpl *dev_impl = tg->get_device_by_name(((string)(*devlist_ptr)[i]).c_str()); + TeledynePI *dev = static_cast (dev_impl); + + vector &dev_att_list = dev->get_device_attr()->get_attribute_list(); + vector::iterator ite_att; + for (ite_att=dev_att_list.begin() ; ite_att != dev_att_list.end() ; ++ite_att) + { + string att_name((*ite_att)->get_name_lower()); + if ((att_name == "state") || (att_name == "status")) + continue; + vector::iterator ite_str = find(defaultAttList.begin(), defaultAttList.end(), att_name); + if (ite_str == defaultAttList.end()) + { + cout2 << att_name << " is a UNWANTED dynamic attribute for device " << (*devlist_ptr)[i] << endl; + Tango::Attribute &att = dev->get_device_attr()->get_attr_by_name(att_name.c_str()); + dev->remove_attribute(att_list[att.get_attr_idx()], true, false); + --ite_att; + } + } + } + /*----- PROTECTED REGION ID(TeledynePIClass::erase_dynamic_attributes) ENABLED START -----*/ + + /*----- PROTECTED REGION END -----*/ // TeledynePIClass::erase_dynamic_attributes +} + +//-------------------------------------------------------- +/** + * Method : TeledynePIClass::get_attr_object_by_name() + * Description : returns Tango::Attr * object found by name + */ +//-------------------------------------------------------- +Tango::Attr *TeledynePIClass::get_attr_object_by_name(vector &att_list, string attname) +{ + vector::iterator it; + for (it=att_list.begin() ; itget_name()==attname) + return (*it); + // Attr does not exist + return NULL; +} + + +/*----- PROTECTED REGION ID(TeledynePIClass::Additional Methods) ENABLED START -----*/ + +/*----- PROTECTED REGION END -----*/ // TeledynePIClass::Additional Methods +} // namespace diff --git a/specifics/TeledynePI/TeledynePIClass.h b/specifics/TeledynePI/TeledynePIClass.h new file mode 100644 index 0000000..181ccd6 --- /dev/null +++ b/specifics/TeledynePI/TeledynePIClass.h @@ -0,0 +1,198 @@ +/*----- PROTECTED REGION ID(TeledynePIClass.h) ENABLED START -----*/ +//============================================================================= +// +// file : TeledynePIClass.h +// +// description : Include for the TeledynePI root class. +// This class is the singleton class for +// the TeledynePI device class. +// It contains all properties and methods which the +// TeledynePI requires only once e.g. the commands. +// +// project : +// +// This file is part of Tango device class. +// +// Tango is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Tango is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Tango. If not, see . +// +// +// +//============================================================================= +// This file is generated by POGO +// (Program Obviously used to Generate tango Object) +//============================================================================= + + +#ifndef TeledynePIClass_H +#define TeledynePIClass_H + +#include +#include + + +/*----- PROTECTED REGION END -----*/ // TeledynePIClass.h + + +namespace TeledynePI_ns +{ +/*----- PROTECTED REGION ID(TeledynePIClass::classes for dynamic creation) ENABLED START -----*/ + + +/*----- PROTECTED REGION END -----*/ // TeledynePIClass::classes for dynamic creation + +//========================================= +// Define classes for attributes +//========================================= +// Attribute temperature class definition +class temperatureAttrib: public Tango::Attr +{ +public: + temperatureAttrib():Attr("temperature", + Tango::DEV_DOUBLE, Tango::READ) {}; + ~temperatureAttrib() {}; + virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att) + {(static_cast(dev))->read_temperature(att);} + virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty) + {return (static_cast(dev))->is_temperature_allowed(ty);} +}; + +// Attribute temperatureTarget class definition +class temperatureTargetAttrib: public Tango::Attr +{ +public: + temperatureTargetAttrib():Attr("temperatureTarget", + Tango::DEV_DOUBLE, Tango::READ_WRITE) {}; + ~temperatureTargetAttrib() {}; + virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att) + {(static_cast(dev))->read_temperatureTarget(att);} + virtual void write(Tango::DeviceImpl *dev,Tango::WAttribute &att) + {(static_cast(dev))->write_temperatureTarget(att);} + virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty) + {return (static_cast(dev))->is_temperatureTarget_allowed(ty);} +}; + +// Attribute gain class definition +class gainAttrib: public Tango::Attr +{ +public: + gainAttrib():Attr("gain", + Tango::DEV_ENUM, Tango::READ_WRITE) {}; + ~gainAttrib() {}; + virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att) + {(static_cast(dev))->read_gain(att);} + virtual void write(Tango::DeviceImpl *dev,Tango::WAttribute &att) + {(static_cast(dev))->write_gain(att);} + virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty) + {return (static_cast(dev))->is_gain_allowed(ty);} + virtual bool same_type(const type_info &in_type) {return typeid(gainEnum) == in_type;} + virtual string get_enum_type() {return string("gainEnum");} +}; + +// Attribute adcRate class definition +class adcRateAttrib: public Tango::Attr +{ +public: + adcRateAttrib():Attr("adcRate", + Tango::DEV_DOUBLE, Tango::READ_WRITE) {}; + ~adcRateAttrib() {}; + virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att) + {(static_cast(dev))->read_adcRate(att);} + virtual void write(Tango::DeviceImpl *dev,Tango::WAttribute &att) + {(static_cast(dev))->write_adcRate(att);} + virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty) + {return (static_cast(dev))->is_adcRate_allowed(ty);} +}; + +// Attribute adcQuality class definition +class adcQualityAttrib: public Tango::Attr +{ +public: + adcQualityAttrib():Attr("adcQuality", + Tango::DEV_ENUM, Tango::READ_WRITE) {}; + ~adcQualityAttrib() {}; + virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att) + {(static_cast(dev))->read_adcQuality(att);} + virtual void write(Tango::DeviceImpl *dev,Tango::WAttribute &att) + {(static_cast(dev))->write_adcQuality(att);} + virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty) + {return (static_cast(dev))->is_adcQuality_allowed(ty);} +}; + +// Attribute adcPixelBitDepth class definition +class adcPixelBitDepthAttrib: public Tango::Attr +{ +public: + adcPixelBitDepthAttrib():Attr("adcPixelBitDepth", + Tango::DEV_INT, Tango::READ_WRITE) {}; + ~adcPixelBitDepthAttrib() {}; + virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att) + {(static_cast(dev))->read_adcPixelBitDepth(att);} + virtual void write(Tango::DeviceImpl *dev,Tango::WAttribute &att) + {(static_cast(dev))->write_adcPixelBitDepth(att);} + virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty) + {return (static_cast(dev))->is_adcPixelBitDepth_allowed(ty);} +}; + +/** + * The TeledynePIClass singleton definition + */ + +#ifdef _TG_WINDOWS_ +class __declspec(dllexport) TeledynePIClass : public Tango::DeviceClass +#else +class TeledynePIClass : public Tango::DeviceClass +#endif +{ + /*----- PROTECTED REGION ID(TeledynePIClass::Additionnal DServer data members) ENABLED START -----*/ + + + /*----- PROTECTED REGION END -----*/ // TeledynePIClass::Additionnal DServer data members + + public: + // write class properties data members + Tango::DbData cl_prop; + Tango::DbData cl_def_prop; + Tango::DbData dev_def_prop; + + // Method prototypes + static TeledynePIClass *init(const char *); + static TeledynePIClass *instance(); + ~TeledynePIClass(); + Tango::DbDatum get_class_property(string &); + Tango::DbDatum get_default_device_property(string &); + Tango::DbDatum get_default_class_property(string &); + + protected: + TeledynePIClass(string &); + static TeledynePIClass *_instance; + void command_factory(); + void attribute_factory(vector &); + void pipe_factory(); + void write_class_property(); + void set_default_property(); + void get_class_property(); + string get_cvstag(); + string get_cvsroot(); + + private: + void device_factory(const Tango::DevVarStringArray *); + void create_static_attribute_list(vector &); + void erase_dynamic_attributes(const Tango::DevVarStringArray *,vector &); + vector defaultAttList; + Tango::Attr *get_attr_object_by_name(vector &att_list, string attname); +}; + +} // End of namespace + +#endif // TeledynePI_H diff --git a/specifics/TeledynePI/TeledynePIStateMachine.cpp b/specifics/TeledynePI/TeledynePIStateMachine.cpp new file mode 100644 index 0000000..5df2973 --- /dev/null +++ b/specifics/TeledynePI/TeledynePIStateMachine.cpp @@ -0,0 +1,331 @@ +/*----- PROTECTED REGION ID(TeledynePIStateMachine.cpp) ENABLED START -----*/ +//============================================================================= +// +// file : TeledynePIStateMachine.cpp +// +// description : State machine file for the TeledynePI class +// +// project : +// +// This file is part of Tango device class. +// +// Tango is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Tango is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Tango. If not, see . +// +// +// +//============================================================================= +// This file is generated by POGO +// (Program Obviously used to Generate tango Object) +//============================================================================= + +#include + +/*----- PROTECTED REGION END -----*/ // TeledynePI::TeledynePIStateMachine.cpp + +//================================================================ +// States | Description +//================================================================ +// FAULT | +// INIT | +// RUNNING | +// STANDBY | + + +namespace TeledynePI_ns +{ +//================================================= +// Attributes Allowed Methods +//================================================= + +//-------------------------------------------------------- +/** + * Method : TeledynePI::is_temperature_allowed() + * Description : Execution allowed for temperature attribute + */ +//-------------------------------------------------------- +bool TeledynePI::is_temperature_allowed(TANGO_UNUSED(Tango::AttReqType type)) +{ + + // Check access type. + if ( type==Tango::READ_REQ ) + { + // Compare device state with not allowed states for READ + if (get_state()==Tango::FAULT || + get_state()==Tango::INIT) + { + /*----- PROTECTED REGION ID(TeledynePI::temperatureStateAllowed_READ) ENABLED START -----*/ + if ( get_state()==Tango::FAULT && is_device_initialized() ) + { + return true; + } + /*----- PROTECTED REGION END -----*/ // TeledynePI::temperatureStateAllowed_READ + return false; + } + return true; + } + return true; +} + +//-------------------------------------------------------- +/** + * Method : TeledynePI::is_temperatureTarget_allowed() + * Description : Execution allowed for temperatureTarget attribute + */ +//-------------------------------------------------------- +bool TeledynePI::is_temperatureTarget_allowed(TANGO_UNUSED(Tango::AttReqType type)) +{ + // Check access type. + if ( type!=Tango::READ_REQ ) + { + // Compare device state with not allowed states for WRITE + if (get_state()==Tango::FAULT || + get_state()==Tango::INIT || + get_state()==Tango::RUNNING) + { + /*----- PROTECTED REGION ID(TeledynePI::temperatureTargetStateAllowed_WRITE) ENABLED START -----*/ + if (get_state() == Tango::FAULT && is_device_initialized()) + { + return true; + } + /*----- PROTECTED REGION END -----*/ // TeledynePI::temperatureTargetStateAllowed_WRITE + return false; + } + return true; + } + else + + // Check access type. + if ( type==Tango::READ_REQ ) + { + // Compare device state with not allowed states for READ + if (get_state()==Tango::FAULT || + get_state()==Tango::INIT) + { + /*----- PROTECTED REGION ID(TeledynePI::temperatureTargetStateAllowed_READ) ENABLED START -----*/ + if (get_state() == Tango::FAULT && is_device_initialized()) + { + return true; + } + /*----- PROTECTED REGION END -----*/ // TeledynePI::temperatureTargetStateAllowed_READ + return false; + } + return true; + } + return true; +} + +//-------------------------------------------------------- +/** + * Method : TeledynePI::is_gain_allowed() + * Description : Execution allowed for gain attribute + */ +//-------------------------------------------------------- +bool TeledynePI::is_gain_allowed(TANGO_UNUSED(Tango::AttReqType type)) +{ + // Check access type. + if ( type!=Tango::READ_REQ ) + { + // Compare device state with not allowed states for WRITE + if (get_state()==Tango::FAULT || + get_state()==Tango::INIT || + get_state()==Tango::RUNNING) + { + /*----- PROTECTED REGION ID(TeledynePI::gainStateAllowed_WRITE) ENABLED START -----*/ + if (get_state() == Tango::FAULT && is_device_initialized()) + { + return true; + } + /*----- PROTECTED REGION END -----*/ // TeledynePI::gainStateAllowed_WRITE + return false; + } + return true; + } + else + + // Check access type. + if ( type==Tango::READ_REQ ) + { + // Compare device state with not allowed states for READ + if (get_state()==Tango::FAULT || + get_state()==Tango::INIT) + { + /*----- PROTECTED REGION ID(TeledynePI::gainStateAllowed_READ) ENABLED START -----*/ + if (get_state() == Tango::FAULT && is_device_initialized()) + { + return true; + } + /*----- PROTECTED REGION END -----*/ // TeledynePI::gainStateAllowed_READ + return false; + } + return true; + } + return true; +} + +//-------------------------------------------------------- +/** + * Method : TeledynePI::is_adcRate_allowed() + * Description : Execution allowed for adcRate attribute + */ +//-------------------------------------------------------- +bool TeledynePI::is_adcRate_allowed(TANGO_UNUSED(Tango::AttReqType type)) +{ + // Check access type. + if ( type!=Tango::READ_REQ ) + { + // Compare device state with not allowed states for WRITE + if (get_state()==Tango::FAULT || + get_state()==Tango::INIT || + get_state()==Tango::RUNNING) + { + /*----- PROTECTED REGION ID(TeledynePI::adcRateStateAllowed_WRITE) ENABLED START -----*/ + if (get_state() == Tango::FAULT && is_device_initialized()) + { + return true; + } + /*----- PROTECTED REGION END -----*/ // TeledynePI::adcRateStateAllowed_WRITE + return false; + } + return true; + } + else + + // Check access type. + if ( type==Tango::READ_REQ ) + { + // Compare device state with not allowed states for READ + if (get_state()==Tango::FAULT || + get_state()==Tango::INIT) + { + /*----- PROTECTED REGION ID(TeledynePI::adcRateStateAllowed_READ) ENABLED START -----*/ + if (get_state() == Tango::FAULT && is_device_initialized()) + { + return true; + } + /*----- PROTECTED REGION END -----*/ // TeledynePI::adcRateStateAllowed_READ + return false; + } + return true; + } + return true; +} + +//-------------------------------------------------------- +/** + * Method : TeledynePI::is_adcQuality_allowed() + * Description : Execution allowed for adcQuality attribute + */ +//-------------------------------------------------------- +bool TeledynePI::is_adcQuality_allowed(TANGO_UNUSED(Tango::AttReqType type)) +{ + // Check access type. + if ( type!=Tango::READ_REQ ) + { + // Compare device state with not allowed states for WRITE + if (get_state()==Tango::FAULT || + get_state()==Tango::INIT || + get_state()==Tango::RUNNING) + { + /*----- PROTECTED REGION ID(TeledynePI::adcQualityStateAllowed_WRITE) ENABLED START -----*/ + if (get_state() == Tango::FAULT && is_device_initialized()) + { + return true; + } + /*----- PROTECTED REGION END -----*/ // TeledynePI::adcQualityStateAllowed_WRITE + return false; + } + return true; + } + else + + // Check access type. + if ( type==Tango::READ_REQ ) + { + // Compare device state with not allowed states for READ + if (get_state()==Tango::FAULT || + get_state()==Tango::INIT) + { + /*----- PROTECTED REGION ID(TeledynePI::adcQualityStateAllowed_READ) ENABLED START -----*/ + if (get_state() == Tango::FAULT && is_device_initialized()) + { + return true; + } + /*----- PROTECTED REGION END -----*/ // TeledynePI::adcQualityStateAllowed_READ + return false; + } + return true; + } + return true; +} + +//-------------------------------------------------------- +/** + * Method : TeledynePI::is_adcPixelBitDepth_allowed() + * Description : Execution allowed for adcQuality attribute + */ +//-------------------------------------------------------- +bool TeledynePI::is_adcPixelBitDepth_allowed(TANGO_UNUSED(Tango::AttReqType type)) +{ + // Check access type. + if ( type!=Tango::READ_REQ ) + { + // Compare device state with not allowed states for WRITE + if (get_state()==Tango::FAULT || + get_state()==Tango::INIT || + get_state()==Tango::RUNNING) + { + /*----- PROTECTED REGION ID(TeledynePI::adcPixelBitDepthStateAllowed_WRITE) ENABLED START -----*/ + if (get_state() == Tango::FAULT && is_device_initialized()) + { + return true; + } + /*----- PROTECTED REGION END -----*/ // TeledynePI::adcPixelBitDepthStateAllowed_WRITE + return false; + } + return true; + } + else + + // Check access type. + if ( type==Tango::READ_REQ ) + { + // Compare device state with not allowed states for READ + if (get_state()==Tango::FAULT || + get_state()==Tango::INIT) + { + /*----- PROTECTED REGION ID(TeledynePI::adcPixelBitDepthStateAllowed_READ) ENABLED START -----*/ + if (get_state() == Tango::FAULT && is_device_initialized()) + { + return true; + } + /*----- PROTECTED REGION END -----*/ // TeledynePI::adcPixelBitDepthStateAllowed_READ + return false; + } + return true; + } + return true; +} + +//================================================= +// Commands Allowed Methods +//================================================= + + +/*----- PROTECTED REGION ID(TeledynePI::TeledynePIStateAllowed.AdditionalMethods) ENABLED START -----*/ + +// Additional Methods + +/*----- PROTECTED REGION END -----*/ // TeledynePI::TeledynePIStateAllowed.AdditionalMethods + +} // End of namespace diff --git a/src/LimaDetector.cpp b/src/LimaDetector.cpp index 201eae9..d6aa25b 100755 --- a/src/LimaDetector.cpp +++ b/src/LimaDetector.cpp @@ -4350,14 +4350,22 @@ void LimaDetector::configure_image_type(void) { HwDetInfoCtrlObj *hw_det_info; m_hw->getHwCtrlObj(hw_det_info); - if(detectorPixelDepth == "2") + if(detectorPixelDepth == "1") + { + hw_det_info->setCurrImageType(Bpp1); + } + else if(detectorPixelDepth == "2") { hw_det_info->setCurrImageType(Bpp2); } else if(detectorPixelDepth == "4") { hw_det_info->setCurrImageType(Bpp4); - } + } + else if(detectorPixelDepth == "6") + { + hw_det_info->setCurrImageType(Bpp6); + } else if(detectorPixelDepth == "8") { hw_det_info->setCurrImageType(Bpp8); @@ -4818,7 +4826,11 @@ void LimaDetector::add_image_dynamic_attribute(const std::string& attr_name) dai.tai.max_dim_x = 100000; //- arbitrary big value dai.tai.max_dim_y = 100000; //- arbitrary big value - if(detectorPixelDepth == "8" || detectorPixelDepth == "4" || detectorPixelDepth == "2") + if(detectorPixelDepth == "1" || detectorPixelDepth == "6") + { + dai.tai.data_type = Tango::DEV_UCHAR; + } + else if(detectorPixelDepth == "8" || detectorPixelDepth == "4" || detectorPixelDepth == "2") { dai.tai.data_type = Tango::DEV_UCHAR; }