diff --git a/specifics/Pco/Pco.cpp b/specifics/Pco/Pco.cpp index ef3fc875..f7615205 100755 --- a/specifics/Pco/Pco.cpp +++ b/specifics/Pco/Pco.cpp @@ -1,1542 +1,1700 @@ -static const char *RcsId = "$Id: $"; -//+============================================================================= -// -// file : Pco.cpp -// -// description : C++ source for the Pco 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 -// Pco are implemented in this file. -// -// project : TANGO Device Server -// -// $Author: $ -// -// $Revision: $ -// -// $Revision: $ -// $Date: $ -// -// SVN only: -// $HeadURL: $ -// -// CVS only: -// $Source: $ -// $Log: $ -// -// copyleft : Synchrotron SOLEIL -// L'Orme des merisiers - Saint Aubin -// BP48 - 91192 Gif sur Yvette -// FRANCE -// -//-============================================================================= -// -// This file is generated by POGO -// (Program Obviously used to Generate tango Object) -// -// (c) - Software Engineering Group - ESRF -//============================================================================= - - - -//=================================================================== -// -// The following table gives the correspondence -// between commands and method name. -// -// Command name| Method name -// ---------------------------------------- -// State | dev_state() -// Status | dev_status() -// Talk | talk() -// GetCamInfo | get_cam_info() -// -//=================================================================== -#include -#include - -#include "Pco.h" -#include - - -namespace Pco_ns -{ - -//+---------------------------------------------------------------------------- -// -// method : Pco::Pco(string &s) -// -// description : constructor for simulated Pco -// -// in : - cl : Pointer to the DeviceClass object -// - s : Device name -// -//----------------------------------------------------------------------------- -Pco::Pco(Tango::DeviceClass *cl, string &s) - :Tango::Device_4Impl(cl, s.c_str()), m_dim(this) -{ - init_device(); -} -Pco::Pco(Tango::DeviceClass *cl, const char *s) - : Tango::Device_4Impl(cl, s), m_dim(this) -{ - init_device(); -} -Pco::Pco(Tango::DeviceClass *cl, const char *s, const char *d) - : Tango::Device_4Impl(cl, s, d), m_dim(this) -{ - init_device(); -} -//+---------------------------------------------------------------------------- -// -// method : Pco::delete_device() -// -// description : will be called at device destruction or at init command. -// -//----------------------------------------------------------------------------- -void Pco::delete_device() -{ - INFO_STREAM << "Pco::Pco() delete device " << device_name << endl; - // Delete device allocated objects - - DELETE_DEVSTRING_ATTRIBUTE(attr_pixelRate_read); - DELETE_SCALAR_ATTRIBUTE(attr_currentRecordedFrame_read); - DELETE_DEVSTRING_ATTRIBUTE(attr_cameraModel_read); - DELETE_DEVSTRING_ATTRIBUTE(attr_dllVersion_read); - DELETE_SCALAR_ATTRIBUTE(attr_sensorTemperature_read); - - //- For dyn attr - DELETE_SCALAR_ATTRIBUTE(attr_maxNbImage_read); - DELETE_SCALAR_ATTRIBUTE(attr_cdiMode_read); - DELETE_SCALAR_ATTRIBUTE(attr_frameRate_read); - DELETE_SCALAR_ATTRIBUTE(attr_coolingSetPoint_read); - DELETE_SCALAR_ATTRIBUTE(attr_adcOperation_read); - DELETE_DEVSTRING_ATTRIBUTE(attr_shutterMode_read); - DELETE_SCALAR_ATTRIBUTE(attr_doubleImage_read); - DELETE_SCALAR_ATTRIBUTE(attr_forcedFIFOMode_read); - - INFO_STREAM << "Remove the inner-appender." << endl; - yat4tango::InnerAppender::release(this); - - //!!!! ONLY LimaDetector device can do this !!!! - //if(m_ct!=0) - //{ - // ControlFactory::instance().reset("Pco"); - // m_ct = 0; - //} - - //remove attributes from dam - INFO_STREAM << "Remove dynamic attributes." << endl; - m_dim.remove(); -} - -//+---------------------------------------------------------------------------- -// -// method : Pco::init_device() -// -// description : will be called at device initialization. -// -//----------------------------------------------------------------------------- -void Pco::init_device() -{ - INFO_STREAM << "Pco::Pco() create device " << device_name << endl; - - // Initialise variables to default values - //-------------------------------------------- - get_device_property(); - - CREATE_DEVSTRING_ATTRIBUTE(attr_pixelRate_read, MAX_ATTRIBUTE_STRING_LENGTH); - CREATE_SCALAR_ATTRIBUTE(attr_currentRecordedFrame_read); - CREATE_DEVSTRING_ATTRIBUTE(attr_cameraModel_read, MAX_ATTRIBUTE_STRING_LENGTH); - CREATE_DEVSTRING_ATTRIBUTE(attr_dllVersion_read, MAX_ATTRIBUTE_STRING_LENGTH); - CREATE_SCALAR_ATTRIBUTE(attr_sensorTemperature_read); - - //- For dyn attr - CREATE_SCALAR_ATTRIBUTE(attr_maxNbImage_read); - CREATE_SCALAR_ATTRIBUTE(attr_cdiMode_read); - CREATE_SCALAR_ATTRIBUTE(attr_frameRate_read); - CREATE_SCALAR_ATTRIBUTE(attr_coolingSetPoint_read); - CREATE_DEVSTRING_ATTRIBUTE(attr_adcOperation_read, MAX_ATTRIBUTE_STRING_LENGTH); - CREATE_DEVSTRING_ATTRIBUTE(attr_shutterMode_read, MAX_ATTRIBUTE_STRING_LENGTH); - CREATE_SCALAR_ATTRIBUTE(attr_doubleImage_read); - CREATE_SCALAR_ATTRIBUTE(attr_forcedFIFOMode_read); - - m_is_device_initialized = false; - strcpy(*attr_pixelRate_read, "Not Initialised"); - m_camera_model = "Not Initialised"; - m_dll_version = "Not Initialised"; - 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 - { - //- initialize Lima camera - //- get the main object used to pilot the lima framework - m_ct = ControlFactory::instance().get_control("Pco"); - - //- get interface to specific camera - m_hw = dynamic_cast(m_ct->hwInterface()); - - //- get camera to specific detector - m_camera = (m_hw->getCamera()); - - //- - m_camera->getCameraNameBase(m_camera_model); - INFO_STREAM << "Camera model : " << m_camera_model << endl; - //- - m_camera->getSdkRelease(m_dll_version); - INFO_STREAM << "DLL version : " << m_dll_version << endl; - - //- Create dynamic interface - create_dynamic_interface(); - - INFO_STREAM << "Write tango hardware at Init - pixelRate." << endl; - Tango::WAttribute &pixelRate = dev_attr->get_w_attr_by_name("pixelRate"); - try - { - std::string pixel_rate_str = yat4tango::PropertyHelper::get_memorized_attribute(this, "pixelRate"); - attr_pixelRate_write = const_cast(pixel_rate_str.c_str()); - pixelRate.set_write_value(attr_pixelRate_write); - write_pixelRate(pixelRate); - } - catch(Tango::DevFailed&) - { - ERROR_STREAM << "Failed to write memorized attribute - pixelRate." << endl; - } - - } - catch(lima::Exception& e) - { - m_status_message << "Initialization Failed : " << e.getErrMsg() << endl; - ERROR_STREAM << m_status_message.str() << endl; - return; - } - catch (yat::Exception& ex) - { - m_status_message << "Initialization Failed : " << ex.errors[0].desc << endl; - ERROR_STREAM << m_status_message.str() << endl; - return; - } - catch (Tango::DevFailed& df) - { - m_status_message << "Initialization Failed : " << df.errors[0].desc << endl; - ERROR_STREAM << m_status_message.str() << endl; - return; - } - catch(...) - { - m_status_message << "Initialization Failed : Unknown error" << endl; - ERROR_STREAM << m_status_message.str() << endl; - return; - } - - m_is_device_initialized = true; - dev_state(); -} - -//+---------------------------------------------------------------------------- -// -// method : Pco::get_device_property() -// -// description : Read the device properties from database. -// -//----------------------------------------------------------------------------- -void Pco::get_device_property() -{ - // Initialize your default values here (if not done with POGO). - //------------------------------------------------------------------ - - // Read device properties from database.(Automatic code generation) - //------------------------------------------------------------------ - Tango::DbData dev_prop; - dev_prop.push_back(Tango::DbDatum("SerialNumber")); - - // Call database and extract values - //-------------------------------------------- - if (Tango::Util::instance()->_UseDb==true) - get_db_device()->get_property(dev_prop); - Tango::DbDatum def_prop, cl_prop; - PcoClass *ds_class = - (static_cast(get_device_class())); - int i = -1; - - // Try to initialize SerialNumber from class property - cl_prop = ds_class->get_class_property(dev_prop[++i].name); - if (cl_prop.is_empty()==false) cl_prop >> serialNumber; - else { - // Try to initialize SerialNumber from default device value - def_prop = ds_class->get_default_device_property(dev_prop[i].name); - if (def_prop.is_empty()==false) def_prop >> serialNumber; - } - // And try to extract SerialNumber value from database - if (dev_prop[i].is_empty()==false) dev_prop[i] >> serialNumber; - - - - // End of Automatic code generation - //------------------------------------------------------------------ - - yat4tango::PropertyHelper::create_property_if_empty(this, dev_prop, "0", "SerialNumber"); - -} - -/*------------------------------------------------------------------------- -// Pco::create_dynamic_interface -/-------------------------------------------------------------------------*/ -void Pco::create_dynamic_interface() -{ - DEBUG_STREAM << "Pco::create_dynamic_interface(): entering... !" << endl; - try - { - if (m_camera_model.find("pco.edge") != string::npos) - { - create_pco_edge_dynamic_interface(); - } - else //- Not EDGE - { - // ie: either dimax or XX00 - create_pco_with_ram_dynamic_interface(); - - if (m_camera_model.find("pco.dimax") != string::npos) - { - create_pco_dimax_dynamic_interface(); - } - else if ((m_camera_model.find("pco.4000") != string::npos) || - (m_camera_model.find("pco.2000") != string::npos) || - (m_camera_model.find("pco.1600") != string::npos)) - { - create_pco_xx00_dynamic_interface(); - } - } - } - catch (yat::Exception& ex) - { - THROW_YAT_TO_TANGO_EXCEPTION(ex); - } - catch (Tango::DevFailed& df) - { - ERROR_STREAM << df << endl; - - //- rethrow exception - Tango::Except::re_throw_exception(df, - "TANGO_DEVICE_ERROR", - string(df.errors[0].desc).c_str(), - "Pco::create_dynamic_interface()"); - } -} - -/*------------------------------------------------------------------------- -// Pco::create_pco_edge_dynamic_interface -/-------------------------------------------------------------------------*/ -void Pco::create_pco_edge_dynamic_interface() -{ - Tango::DbData dev_prop; - - //create frameRate dyn attribute - create_attribute("frameRate", - Tango::DEV_DOUBLE, - Tango::SCALAR, - Tango::READ, - Tango::OPERATOR, - "fps", - "%d", - "The frame rate", - "Frame Rate", - /*NOT_MEMORIZED, - NOT_WRITE_MEMORIZED_AT_INIT,*/ - &Pco::read_frameRate_callback, - &Pco::write_callback_null); - - //create coolingSetPoint dyn attribute - create_attribute("coolingSetPoint", - Tango::DEV_SHORT, - Tango::SCALAR, - Tango::READ_WRITE, - Tango::OPERATOR, - "deg C", - "%d", - "set / get the cooling set point", - "Cooling Set Point", - /*MEMORIZED, - WRITE_MEMORIZED_AT_INIT,*/ - &Pco::read_coolingSetPoint_callback, - &Pco::write_coolingSetPoint_callback); - - INFO_STREAM << "Write tango hardware at Init - coolingSetPoint." << endl; - Tango::WAttribute &coolingSetPoint = dev_attr->get_w_attr_by_name("coolingSetPoint"); - dev_prop.push_back(Tango::DbDatum("__MemorizedCoolingSetPoint")); - get_db_device()->get_property(dev_prop); - if (!dev_prop[0].is_empty()) - { - attr_coolingSetPoint_write = yat4tango::PropertyHelper::get_property(this, "__MemorizedCoolingSetPoint"); - coolingSetPoint.set_write_value(attr_coolingSetPoint_write); - yat4tango::DynamicAttributeWriteCallbackData cbd_coolingSetPoint; - cbd_coolingSetPoint.tga = &coolingSetPoint; - write_coolingSetPoint_callback(cbd_coolingSetPoint); - } - dev_prop.clear(); - - //create shutterMode dyn attribute - create_attribute("shutterMode", - Tango::DEV_STRING, - Tango::SCALAR, - Tango::READ_WRITE, - Tango::OPERATOR, - " ", - " ", - "get / set the shutterMode operation: \nROLLING_SHUTTER\nGLOBAL_SHUTTER\nGLOBAL_RESET", - "Shutter Mode", - /*MEMORIZED, - WRITE_MEMORIZED_AT_INIT,*/ - &Pco::read_shutterMode_callback, - &Pco::write_shutterMode_callback); - - INFO_STREAM << "Write tango hardware at Init - shutterMode." << endl; - Tango::WAttribute &shutterMode = dev_attr->get_w_attr_by_name("shutterMode"); - dev_prop.push_back(Tango::DbDatum("__MemorizedShutterMode")); - get_db_device()->get_property(dev_prop); - if (!dev_prop[0].is_empty()) - { - std::string shutter_mode_str = yat4tango::PropertyHelper::get_property(this, "__MemorizedShutterMode"); - attr_shutterMode_write = const_cast(shutter_mode_str.c_str()); - shutterMode.set_write_value(attr_shutterMode_write); - yat4tango::DynamicAttributeWriteCallbackData cbd_shutterMode; - cbd_shutterMode.tga = &shutterMode; - write_shutterMode_callback(cbd_shutterMode); - } - dev_prop.clear(); -} - -/*------------------------------------------------------------------------- -// Pco::create_pco_with_ram_dynamic_interface -/-------------------------------------------------------------------------*/ -void Pco::create_pco_with_ram_dynamic_interface() -{ - Tango::DbData dev_prop; - - //create doubleImage dyn attribute - create_attribute("doubleImage", - Tango::DEV_BOOLEAN, - Tango::SCALAR, - Tango::READ_WRITE, - Tango::OPERATOR, - " ", - " ", - "Set / Get the double image mode", - "Double Image", - /*MEMORIZED, - WRITE_MEMORIZED_AT_INIT,*/ - &Pco::read_doubleImage_callback, - &Pco::write_doubleImage_callback); - - INFO_STREAM << "Write tango hardware at Init - doubleImage." << endl; - Tango::WAttribute &doubleImage = dev_attr->get_w_attr_by_name("doubleImage"); - dev_prop.push_back(Tango::DbDatum("__MemorizedDoubleImage")); - get_db_device()->get_property(dev_prop); - if (!dev_prop[0].is_empty()) - { - attr_doubleImage_write = yat4tango::PropertyHelper::get_property(this, "__MemorizedDoubleImage"); - doubleImage.set_write_value(attr_doubleImage_write); - yat4tango::DynamicAttributeWriteCallbackData cbd_doubleImage; - cbd_doubleImage.tga = &doubleImage; - write_doubleImage_callback(cbd_doubleImage); - } - dev_prop.clear(); - - - //create currentRecordedFrame dyn attribute - create_attribute("currentRecordedFrame", - Tango::DEV_ULONG, - Tango::SCALAR, - Tango::READ, - Tango::OPERATOR, - " ", - "%d", - "current recorded frame : frames recorded in the Camera RAM", - "Current Recorded Frame", - /*NOT_MEMORIZED, - NOT_WRITE_MEMORIZED_AT_INIT,*/ - &Pco::read_currentRecordedFrame_callback, - &Pco::write_callback_null); - - //create forcedFIFOMode dyn attribute - create_attribute("forcedFIFOMode", - Tango::DEV_BOOLEAN, - Tango::SCALAR, - Tango::READ_WRITE, - Tango::OPERATOR, - " ", - " ", - "Forced FIFO mode", - "Forced FIFO mode", - /*MEMORIZED, - WRITE_MEMORIZED_AT_INIT,*/ - &Pco::read_forcedFIFOMode_callback, - &Pco::write_forcedFIFOMode_callback); - - INFO_STREAM << "Write tango hardware at Init - forcedFIFOMode." << endl; - Tango::WAttribute &forcedFIFOMode = dev_attr->get_w_attr_by_name("forcedFIFOMode"); - dev_prop.push_back(Tango::DbDatum("__MemorizedforcedFIFOMode")); - get_db_device()->get_property(dev_prop); - if (!dev_prop[0].is_empty()) - { - attr_forcedFIFOMode_write = yat4tango::PropertyHelper::get_property(this, "__MemorizedforcedFIFOMode"); - forcedFIFOMode.set_write_value(attr_forcedFIFOMode_write); - yat4tango::DynamicAttributeWriteCallbackData cbd_forcedFIFOMode; - cbd_forcedFIFOMode.tga = &forcedFIFOMode; - write_forcedFIFOMode_callback(cbd_forcedFIFOMode); - } - dev_prop.clear(); -} - -/*------------------------------------------------------------------------- -// Pco::create_pco_dimax_dynamic_interface -/-------------------------------------------------------------------------*/ -void Pco::create_pco_dimax_dynamic_interface() -{ - Tango::DbData dev_prop; - - //create maxNbImage dyn attribute - create_attribute("maxNbImage", - Tango::DEV_ULONG, - Tango::SCALAR, - Tango::READ, - Tango::OPERATOR, - " ", - "%d", - "get the max number of images available in the Camera RAM", - "Max Nb Image", - /*NOT_MEMORIZED, - NOT_WRITE_MEMORIZED_AT_INIT,*/ - &Pco::read_maxNbImage_callback, - &Pco::write_callback_null); - - //create cdiMode dyn attribute - create_attribute("cdiMode", - Tango::DEV_BOOLEAN, - Tango::SCALAR, - Tango::READ_WRITE, - Tango::OPERATOR, - " ", - "%1d", - "enable / disable the cdi mode", - "CDI mode", - /*MEMORIZED, - WRITE_MEMORIZED_AT_INIT,*/ - &Pco::read_cdiMode_callback, - &Pco::write_cdiMode_callback); - - INFO_STREAM << "Write tango hardware at Init - cdiMode." << endl; - Tango::WAttribute &cdiMode = dev_attr->get_w_attr_by_name("cdiMode"); - dev_prop.push_back(Tango::DbDatum("__MemorizedCdiMode")); - get_db_device()->get_property(dev_prop); - if (!dev_prop[0].is_empty()) - { - attr_cdiMode_write = yat4tango::PropertyHelper::get_property(this, "__MemorizedCdiMode"); - cdiMode.set_write_value(attr_cdiMode_write); - yat4tango::DynamicAttributeWriteCallbackData cbd_cdiMode; - cbd_cdiMode.tga = &cdiMode; - write_cdiMode_callback(cbd_cdiMode); - } - dev_prop.clear(); - - //create frameRate dyn attribute - create_attribute("frameRate", - Tango::DEV_DOUBLE, - Tango::SCALAR, - Tango::READ, - Tango::OPERATOR, - "fps", - "%d", - "get the frame rate", - "Frame Rate", - /*NOT_MEMORIZED, - NOT_WRITE_MEMORIZED_AT_INIT,*/ - &Pco::read_frameRate_callback, - &Pco::write_callback_null); -} - -/*------------------------------------------------------------------------- -// Pco::create_pco_xx00_dynamic_interface -/-------------------------------------------------------------------------*/ -void Pco::create_pco_xx00_dynamic_interface() -{ - Tango::DbData dev_prop; - - //create maxNbImage dyn attribute - create_attribute("maxNbImage", - Tango::DEV_ULONG, - Tango::SCALAR, - Tango::READ, - Tango::OPERATOR, - " ", - "%d", - "get the max number of images available in the Camera RAM", - "Max Nb Image", - /*NOT_MEMORIZED, - NOT_WRITE_MEMORIZED_AT_INIT,*/ - &Pco::read_maxNbImage_callback, - &Pco::write_callback_null); - - //create adcOperation dyn attribute - create_attribute("adcOperation", - Tango::DEV_STRING, - Tango::SCALAR, - Tango::READ_WRITE, - Tango::OPERATOR, - " ", - "%1d", - "get / set the adc operation: \nSINGLE\nDUAL", - "ADC Operation", - /*MEMORIZED, - WRITE_MEMORIZED_AT_INIT,*/ - &Pco::read_adcOperation_callback, - &Pco::write_adcOperation_callback); - - INFO_STREAM << "Write tango hardware at Init - adcOperation." << endl; - Tango::WAttribute &adcOperation = dev_attr->get_w_attr_by_name("adcOperation"); - dev_prop.push_back(Tango::DbDatum("__MemorizedAdcOperation")); - get_db_device()->get_property(dev_prop); - if (!dev_prop[0].is_empty()) - { - std::string adc_op_str = yat4tango::PropertyHelper::get_property(this, "__MemorizedAdcOperation"); - attr_adcOperation_write = const_cast(adc_op_str.c_str()); - adcOperation.set_write_value(attr_adcOperation_write); - yat4tango::DynamicAttributeWriteCallbackData cbd_adcOperation; - cbd_adcOperation.tga = &adcOperation; - write_adcOperation_callback(cbd_adcOperation); - } - dev_prop.clear(); - - //create coolingSetPoint dyn attribute - create_attribute("coolingSetPoint", - Tango::DEV_SHORT, - Tango::SCALAR, - Tango::READ_WRITE, - Tango::OPERATOR, - "deg C", - "%d", - "get / set the cooling set point", - "Cooling Set Point", - /*MEMORIZED, - WRITE_MEMORIZED_AT_INIT,*/ - &Pco::read_coolingSetPoint_callback, - &Pco::write_coolingSetPoint_callback); - - INFO_STREAM << "Write tango hardware at Init - coolingSetPoint." << endl; - Tango::WAttribute &coolingSetPoint = dev_attr->get_w_attr_by_name("coolingSetPoint"); - dev_prop.push_back(Tango::DbDatum("__MemorizedCoolingSetPoint")); - get_db_device()->get_property(dev_prop); - if (!dev_prop[0].is_empty()) - { - attr_coolingSetPoint_write = yat4tango::PropertyHelper::get_property(this, "__MemorizedCoolingSetPoint"); - coolingSetPoint.set_write_value(attr_coolingSetPoint_write); - yat4tango::DynamicAttributeWriteCallbackData cbd_coolingSetPoint; - cbd_coolingSetPoint.tga = &coolingSetPoint; - write_coolingSetPoint_callback(cbd_coolingSetPoint); - } - dev_prop.clear(); -} - -//+---------------------------------------------------------------------------- -// -// method : Pco::always_executed_hook() -// -// description : method always executed before any command is executed -// -//----------------------------------------------------------------------------- -void Pco::always_executed_hook() -{ - DEBUG_STREAM << "Pco::always_executed_hook() entering... "<< endl; - - //- update state - dev_state(); -} -//+---------------------------------------------------------------------------- -// -// method : Pco::read_attr_hardware -// -// description : Hardware acquisition for attributes. -// -//----------------------------------------------------------------------------- -void Pco::read_attr_hardware(vector &attr_list) -{ - DEBUG_STREAM << "Pco::read_attr_hardware(vector &attr_list) entering... "<< endl; - // Add your own code here -} - -//+---------------------------------------------------------------------------- -// -// method : Pco::read_sensorTemperature -// -// description : Extract real attribute values for sensorTemperature acquisition result. -// -//----------------------------------------------------------------------------- -void Pco::read_sensorTemperature(Tango::Attribute &attr) -{ - DEBUG_STREAM << "Pco::read_sensorTemperature(Tango::Attribute &attr) entering... "<< endl; - - try - { - std::string temp_temperature_info,temp_temperature; - m_camera->getTemperatureInfo(temp_temperature_info); - yat::StringUtil::extract_token(&temp_temperature_info, '[', ']', &temp_temperature); - *attr_sensorTemperature_read = yat::StringUtil::to_num(temp_temperature); - attr.set_value(attr_sensorTemperature_read); - } - catch (lima::Exception& e) - { - ERROR_STREAM << e.getErrMsg() << endl; - //- throw exception - Tango::Except::throw_exception( - "LIMA_ERROR", - e.getErrMsg().c_str(), - "Pco::read_sensorTemperature"); - } -} - -//+---------------------------------------------------------------------------- -// -// method : Pco::read_maxNbImage_callback() -// -// description : Extract real attribute values for maxNbImage -// -//----------------------------------------------------------------------------- -void Pco::read_maxNbImage_callback(yat4tango::DynamicAttributeReadCallbackData& cbd) -{ - DEBUG_STREAM << "Pco::read_maxNbImage_callback()" << endl; // << cbd.dya->get_name() << endl; - - try - { - m_camera->getMaxNbImages(*attr_maxNbImage_read); - cbd.tga->set_value(attr_maxNbImage_read); - } - catch (lima::Exception& e) - { - ERROR_STREAM << e.getErrMsg() << endl; - //- throw exception - Tango::Except::throw_exception( - "LIMA_ERROR", - e.getErrMsg().c_str(), - "Pco::read_maxNbImage_callback"); - } -} - -//+---------------------------------------------------------------------------- -// -// method : Pco::read_cdiMode_callback() -// -// description : Extract real attribute values for cdi -// -//----------------------------------------------------------------------------- -void Pco::read_cdiMode_callback(yat4tango::DynamicAttributeReadCallbackData& cbd) -{ - DEBUG_STREAM << "Pco::read_cdiMode_callback()" << endl; // << cbd.dya->get_name() << endl; - - try - { - int cdi_mode_temp = -1; - m_camera->getCDIMode(cdi_mode_temp); - *attr_cdiMode_read = cdi_mode_temp; - cbd.tga->set_value(attr_cdiMode_read); - } - catch (lima::Exception& e) - { - ERROR_STREAM << e.getErrMsg() << endl; - //- throw exception - Tango::Except::throw_exception( - "LIMA_ERROR", - e.getErrMsg().c_str(), - "Pco::read_cdiMode_callback"); - } -} - - -//+---------------------------------------------------------------------------- -// -// method : Pco::write_cdiMode_callback() -// -// description : Extract real attribute values for cdi -// -//----------------------------------------------------------------------------- -void Pco::write_cdiMode_callback(yat4tango::DynamicAttributeWriteCallbackData& cbd) -{ - INFO_STREAM << "Pco::write_cdiMode_callback()" << endl; // << cbd.dya->get_name() << endl; - - try - { - cbd.tga->get_write_value(attr_cdiMode_write); - m_camera->setCDIMode(attr_cdiMode_write); - } - catch (lima::Exception& e) - { - ERROR_STREAM << e.getErrMsg() << endl; - //- throw exception - Tango::Except::throw_exception( - "LIMA_ERROR", - e.getErrMsg().c_str(), - "Pco::write_cdiMode_callback"); - } -} - -//+---------------------------------------------------------------------------- -// -// method : Pco::read_frameRate_callback() -// -// description : Extract real attribute values for frameRate -// -//----------------------------------------------------------------------------- -void Pco::read_frameRate_callback(yat4tango::DynamicAttributeReadCallbackData& cbd) -{ - DEBUG_STREAM << "Pco::read_frameRate_callback()" << endl; // << cbd.dya->get_name() << endl; - - try - { - //- "manual" state machine as this is a dynamic attribute - if (get_state() == Tango::DISABLE || get_state() == Tango::FAULT) - return; - - m_camera->getFrameRate(*attr_frameRate_read); - - cbd.tga->set_value(attr_frameRate_read); - } - catch (lima::Exception& e) - { - ERROR_STREAM << e.getErrMsg() << endl; - //- throw exception - Tango::Except::throw_exception( - "LIMA_ERROR", - e.getErrMsg().c_str(), - "Pco::read_frameRate_callback"); - } -} - -//+---------------------------------------------------------------------------- -// -// method : Pco::read_coolingSetPoint_callback() -// -// description : Extract real attribute values for coolingSetPoint -// -//----------------------------------------------------------------------------- -void Pco::read_coolingSetPoint_callback(yat4tango::DynamicAttributeReadCallbackData& cbd) -{ - DEBUG_STREAM << "Pco::read_coolingSetPoint_callback()" << endl; // << cbd.dya->get_name() << endl; - - try - { - //- "manual" state machine as this is a dynamic attribute - if (get_state() == Tango::DISABLE || get_state() == Tango::FAULT) - return; - - int temp_cooling_set_point = -1; - m_camera->getCoolingTemperature(temp_cooling_set_point); - *attr_coolingSetPoint_read = temp_cooling_set_point; - - cbd.tga->set_value(attr_coolingSetPoint_read); - } - catch (lima::Exception& e) - { - ERROR_STREAM << e.getErrMsg() << endl; - //- throw exception - Tango::Except::throw_exception( - "LIMA_ERROR", - e.getErrMsg().c_str(), - "Pco::read_coolingSetPoint_callback"); - } -} - -//+---------------------------------------------------------------------------- -// -// method : Pco::write_coolingSetPoint_callback() -// -// description : Extract real attribute values for coolingSetPoint -// -//----------------------------------------------------------------------------- -void Pco::write_coolingSetPoint_callback(yat4tango::DynamicAttributeWriteCallbackData& cbd) -{ - INFO_STREAM << "Pco::write_coolingSetPoint_callback()" << endl; // << cbd.dya->get_name() << endl; - - if (get_state() == Tango::FAULT || - get_state() == Tango::RUNNING || - get_state() == Tango::DISABLE) - { - std::string reason = "It's currently not allowed to write attribute coolingSetPoint. The device state is " + std::string(Tango::DevStateName[get_state()]); - Tango::Except::throw_exception( "TANGO_DEVICE_ERROR", - reason.c_str(), - "Pco::write_coolingSetPoint_callback()"); - } - - try - { - cbd.tga->get_write_value(attr_coolingSetPoint_write); - m_camera->setCoolingTemperature(attr_coolingSetPoint_write); - - //- Memorize the value - yat4tango::PropertyHelper::set_property(this, "__MemorizedCoolingSetPoint", attr_coolingSetPoint_write); - } - catch (lima::Exception& e) - { - ERROR_STREAM << e.getErrMsg() << endl; - //- throw exception - Tango::Except::throw_exception( - "LIMA_ERROR", - e.getErrMsg().c_str(), - "Pco::write_coolingSetPoint_callback"); - } -} - -//+---------------------------------------------------------------------------- -// -// method : Pco::read_adcOperation_callback() -// -// description : Extract real attribute values for adcOperation -// -//----------------------------------------------------------------------------- -void Pco::read_adcOperation_callback(yat4tango::DynamicAttributeReadCallbackData& cbd) -{ - DEBUG_STREAM << "Pco::read_adcOperation_callback()" << endl; // << cbd.dya->get_name() << endl; - - try - { - int adc_temp = -1; - m_camera->getAdc(adc_temp); - switch (adc_temp) - { - case 1: - strcpy(*attr_adcOperation_read, "SINGLE"); - break; - case 2: - strcpy(*attr_adcOperation_read, "DUAL"); - break; - default: - strcpy(*attr_adcOperation_read, "UNKNOWN"); - break; - } - - cbd.tga->set_value(attr_adcOperation_read); - } - catch (lima::Exception& e) - { - ERROR_STREAM << e.getErrMsg() << endl; - //- throw exception - Tango::Except::throw_exception( - "LIMA_ERROR", - e.getErrMsg().c_str(), - "Pco::read_adcOperation_callback"); - } -} - -//+---------------------------------------------------------------------------- -// -// method : Pco::write_adcOperation_callback() -// -// description : Extract real attribute values for adcOperation -// -//----------------------------------------------------------------------------- -void Pco::write_adcOperation_callback(yat4tango::DynamicAttributeWriteCallbackData& cbd) -{ - INFO_STREAM << "Pco::write_adcOperation_callback()" << endl; // << cbd.dya->get_name() << endl; - - if (get_state() == Tango::FAULT || get_state() == Tango::RUNNING) - { - std::string reason = "It's currently not allowed to write attribute adcOperation. The device state is " + std::string(Tango::DevStateName[get_state()]); - Tango::Except::throw_exception( "TANGO_DEVICE_ERROR", - reason.c_str(), - "Pco::write_adcOperation_callback()"); - } - - try - { - std::string previous = *attr_adcOperation_read; - cbd.tga->get_write_value(attr_adcOperation_write); - std::string current = attr_adcOperation_write; - - int value_to_write; - - if(current == "SINGLE") - value_to_write = 1; - else if(current == "DUAL") - value_to_write = 2; - else - Tango::Except::throw_exception("CONFIGURATION_ERROR", - "Available ADC values are: \n- SINGLE\n- DUAL" , - "Pco::write_adcOperation_callback"); - - m_camera->setAdc(value_to_write); - //- Memorize the value - yat4tango::PropertyHelper::set_property(this, "__MemorizedAdcOperation", static_cast(attr_adcOperation_write)); - } - catch (lima::Exception& e) - { - ERROR_STREAM << e.getErrMsg() << endl; - //- throw exception - Tango::Except::throw_exception( - "LIMA_ERROR", - e.getErrMsg().c_str(), - "Pco::write_adcOperation_callback"); - } -} - -//+---------------------------------------------------------------------------- -// -// method : Pco::read_shutterMode_callback -// -// description : Extract real attribute values for shutterMode acquisition result. -// -//----------------------------------------------------------------------------- -void Pco::read_shutterMode_callback(yat4tango::DynamicAttributeReadCallbackData& cbd) -{ - DEBUG_STREAM << "Pco::read_shutterMode_callback(Tango::Attribute &attr) entering... "<< endl; - - try - { - //- "manual" state machine as this is a dynamic attribute - if (get_state() == Tango::DISABLE || get_state() == Tango::FAULT) - return; - - int shutter_temp = -1; - m_camera->getRollingShutter(shutter_temp); - switch (shutter_temp) - { - case 1: - strcpy(*attr_shutterMode_read, "ROLLING_SHUTTER"); - break; - case 2: - strcpy(*attr_shutterMode_read, "GLOBAL_SHUTTER"); - break; - case 4: - strcpy(*attr_shutterMode_read, "GLOBAL_RESET"); - break; - default: - strcpy(*attr_shutterMode_read, "UNKNOWN"); - break; - } - - cbd.tga->set_value(attr_shutterMode_read); - } - catch (lima::Exception& e) - { - ERROR_STREAM << e.getErrMsg() << endl; - //- throw exception - Tango::Except::throw_exception( - "LIMA_ERROR", - e.getErrMsg().c_str(), - "Pco::read_shutterMode_callback"); - } -} - -//+---------------------------------------------------------------------------- -// -// method : Pco::write_shutterMode_callback -// -// description : Write shutterMode attribute values to hardware. -// -//----------------------------------------------------------------------------- -void Pco::write_shutterMode_callback(yat4tango::DynamicAttributeWriteCallbackData& cbd) -{ - INFO_STREAM << "Pco::write_shutterMode_callback(Tango::WAttribute &attr) entering... "<< endl; - - if (get_state() == Tango::FAULT || - get_state() == Tango::RUNNING || - get_state() == Tango::DISABLE) - { - std::string reason = "It's currently not allowed to write attribute shutterMode. The device state is " + std::string(Tango::DevStateName[get_state()]); - Tango::Except::throw_exception( "TANGO_DEVICE_ERROR", - reason.c_str(), - "Pco::write_adcOperation_callback()"); - } - - try - { - - std::string previous = *attr_shutterMode_read; - cbd.tga->get_write_value(attr_shutterMode_write); - std::string current = attr_shutterMode_write; - - int value_to_write; - - if (current == "ROLLING_SHUTTER") - value_to_write = 1; - else if (current == "GLOBAL_SHUTTER") - value_to_write = 2; - else if (current == "GLOBAL_RESET") - value_to_write = 4; - else - Tango::Except::throw_exception( "CONFIGURATION_ERROR", - "Available Shutter values are: \n- ROLLING_SHUTTER\n- GLOBAL_SHUTTER\n- GLOBAL_RESET", - "Pco::write_shutterMode_callback"); - - m_camera->setRollingShutter(value_to_write); - - //- Memorize the value - yat4tango::PropertyHelper::set_property(this, "__MemorizedShutterMode", static_cast(attr_shutterMode_write)); - } - catch (lima::Exception& e) - { - ERROR_STREAM << e.getErrMsg() << endl; - //- throw exception - Tango::Except::throw_exception( - "LIMA_ERROR", - e.getErrMsg().c_str(), - "Pco::write_shutterMode_callback"); - } -} - -//+---------------------------------------------------------------------------- -// -// method : Pco::read_pixelRate -// -// description : Extract real attribute values for pixelRate acquisition result. -// -//----------------------------------------------------------------------------- -void Pco::read_pixelRate(Tango::Attribute &attr) -{ - DEBUG_STREAM << "Pco::read_pixelRate(Tango::Attribute &attr) entering... "<< endl; - - try - { - const char * pixel_rate_str = talk("pixelRate"); - strcpy(*attr_pixelRate_read, pixel_rate_str); - attr.set_value(attr_pixelRate_read); - } - catch (yat::Exception& ex) - { - THROW_YAT_TO_TANGO_EXCEPTION(ex); - } - catch (lima::Exception& e) - { - ERROR_STREAM << e.getErrMsg() << endl; - //- throw exception - Tango::Except::throw_exception("LIMA_ERROR", - e.getErrMsg().c_str(), - "Pco::read_pixelRate"); - } -} - -//+---------------------------------------------------------------------------- -// -// method : Pco::write_pixelRate -// -// description : Write pixelRate attribute values to hardware. -// -//----------------------------------------------------------------------------- -void Pco::write_pixelRate(Tango::WAttribute &attr) -{ - INFO_STREAM << "Pco::write_pixelRate(Tango::WAttribute &attr) entering... "<< endl; - - try - { - std::string previous = *attr_pixelRate_read; - attr.get_write_value(attr_pixelRate_write); - std::string current = attr_pixelRate_write; - - std::string pixel_rate_valid_values; - m_camera->getPixelRateValidValues(pixel_rate_valid_values); - if (pixel_rate_valid_values.find(current) == std::string::npos) - { - Tango::Except::throw_exception( "CONFIGURATION_ERROR", - "Available pixelRate values are:\n" + pixel_rate_valid_values, - "Pco::write_shutterMode_callback"); - } - - int value_to_write = yat::StringUtil::to_num(std::string(attr_pixelRate_write)); - m_camera->setPixelRate(value_to_write); - } - catch (yat::Exception& ex) - { - THROW_YAT_TO_TANGO_EXCEPTION(ex); - } - catch (lima::Exception& e) - { - ERROR_STREAM << e.getErrMsg() << endl; - //- throw exception - Tango::Except::throw_exception("LIMA_ERROR", - e.getErrMsg().c_str(), - "Pco::write_pixelScanRate"); - } -} - -//+---------------------------------------------------------------------------- -// -// method : Pco::read_cameraModel -// -// description : Extract real attribute values for cameraModel acquisition result. -// -//----------------------------------------------------------------------------- -void Pco::read_cameraModel(Tango::Attribute &attr) -{ - DEBUG_STREAM << "Pco::read_cameraModel(Tango::Attribute &attr) entering... "<< endl; - - try - { - strcpy(*attr_cameraModel_read, m_camera_model.c_str()); - attr.set_value(attr_cameraModel_read); - } - catch (yat::Exception& ex) - { - THROW_YAT_TO_TANGO_EXCEPTION(ex); - } - catch (lima::Exception& e) - { - ERROR_STREAM << e.getErrMsg() << endl; - //- throw exception - Tango::Except::throw_exception( - "LIMA_ERROR", - e.getErrMsg().c_str(), - "Pco::read_cameraModel"); - } -} - -//+---------------------------------------------------------------------------- -// -// method : Pco::read_dllVersion -// -// description : Extract real attribute values for dllVersion acquisition result. -// -//----------------------------------------------------------------------------- -void Pco::read_dllVersion(Tango::Attribute &attr) -{ - DEBUG_STREAM << "Pco::read_dllVersion(Tango::Attribute &attr) entering... "<< endl; - - try - { - strcpy(*attr_dllVersion_read, m_dll_version.c_str()); - attr.set_value(attr_dllVersion_read); - } - catch (yat::Exception& ex) - { - THROW_YAT_TO_TANGO_EXCEPTION(ex); - } - catch (lima::Exception& e) - { - ERROR_STREAM << e.getErrMsg() << endl; - //- throw exception - Tango::Except::throw_exception( - "LIMA_ERROR", - e.getErrMsg().c_str(), - "Pco::read_dllVersion"); - } -} - -//+---------------------------------------------------------------------------- -// -// method : Pco::read_doubleImage_callback() -// -// description : Extract real attribute values for cdi -// -//----------------------------------------------------------------------------- -void Pco::read_doubleImage_callback(yat4tango::DynamicAttributeReadCallbackData& cbd) -{ - DEBUG_STREAM << "Pco::read_doubleImage_callback()" << endl; - - try - { - WORD wDoubleImage = 0; - int dummy_err = -10; - m_camera->_pco_GetDoubleImageMode(wDoubleImage, dummy_err); - *attr_doubleImage_read = (Tango::DevBoolean)wDoubleImage; - cbd.tga->set_value(attr_doubleImage_read); - } - catch (lima::Exception& e) - { - ERROR_STREAM << e.getErrMsg() << endl; - //- throw exception - Tango::Except::throw_exception( "LIMA_ERROR", - e.getErrMsg().c_str(), - "Pco::read_doubleImage_callback"); - } -} - -//+---------------------------------------------------------------------------- -// -// method : Pco::write_doubleImage_callback() -// -// description : Extract real attribute values for cdi -// -//----------------------------------------------------------------------------- -void Pco::write_doubleImage_callback(yat4tango::DynamicAttributeWriteCallbackData& cbd) -{ - INFO_STREAM << "Pco::write_doubleImage_callback()" << endl; - - if (get_state() == Tango::FAULT || - get_state() == Tango::RUNNING || - get_state() == Tango::DISABLE) - { - std::string reason = "It's currently not allowed to write attribute doubleImage. The device state is " + std::string(Tango::DevStateName[get_state()]); - Tango::Except::throw_exception( "TANGO_DEVICE_ERROR", - reason.c_str(), - "Pco::write_doubleImage_callback()"); - } - - try - { - cbd.tga->get_write_value(attr_doubleImage_write); - m_camera->setDoubleImageMode(attr_doubleImage_write); - - //- Memorize the value - yat4tango::PropertyHelper::set_property(this, "__MemorizedDoubleImage", attr_doubleImage_write); - } - catch (lima::Exception& e) - { - ERROR_STREAM << e.getErrMsg() << endl; - //- throw exception - Tango::Except::throw_exception( "LIMA_ERROR", - e.getErrMsg().c_str(), - "Pco::write_doubleImage_callback"); - } -} - -//+---------------------------------------------------------------------------- -// -// method : Pco::read_forcedFIFOMode_callback() -// -// description : Extract real attribute values for forcedFIFOMod -// -//----------------------------------------------------------------------------- -void Pco::read_forcedFIFOMode_callback(yat4tango::DynamicAttributeReadCallbackData& cbd) -{ - DEBUG_STREAM << "Pco::read_forcedFIFOMode_callback()" << endl; - - try - { - int temp_fifo = -1; - m_camera->getRecorderForcedFifo(temp_fifo); - *attr_forcedFIFOMode_read = (Tango::DevBoolean) temp_fifo; - cbd.tga->set_value(attr_forcedFIFOMode_read); - } - catch (lima::Exception& e) - { - ERROR_STREAM << e.getErrMsg() << endl; - //- throw exception - Tango::Except::throw_exception( "LIMA_ERROR", - e.getErrMsg().c_str(), - "Pco::read_forcedFIFOMode_callback"); - } -} - -//+---------------------------------------------------------------------------- -// -// method : Pco::write_forcedFIFOMode_callback() -// -// description : Extract real attribute values for forcedFIFOMode -// -//----------------------------------------------------------------------------- -void Pco::write_forcedFIFOMode_callback(yat4tango::DynamicAttributeWriteCallbackData& cbd) -{ - INFO_STREAM << "Pco::write_forcedFIFOMode_callback()" << endl; - - if (get_state() == Tango::FAULT || - get_state() == Tango::RUNNING || - get_state() == Tango::DISABLE) - { - std::string reason = "It's currently not allowed to write attribute forcedFIFOMode. The device state is " + std::string(Tango::DevStateName[get_state()]); - Tango::Except::throw_exception( "TANGO_DEVICE_ERROR", - reason.c_str(), - "Pco::write_forcedFIFOMode_callback()"); - } - - try - { - cbd.tga->get_write_value(attr_forcedFIFOMode_write); - m_camera->setRecorderForcedFifo((int)attr_forcedFIFOMode_write); - - //- Memorize the value - yat4tango::PropertyHelper::set_property(this, "__MemorizedForcedFIFOMode", attr_forcedFIFOMode_write); - } - catch (lima::Exception& e) - { - ERROR_STREAM << e.getErrMsg() << endl; - //- throw exception - Tango::Except::throw_exception( "LIMA_ERROR", - e.getErrMsg().c_str(), - "Pco::write_forcedFIFOMode_callback"); - } -} - -//+---------------------------------------------------------------------------- -// -// method : Pco::read_currentRecordedFrame_callback() -// -// description : Extract real attribute values for maxNbImage -// -//----------------------------------------------------------------------------- -void Pco::read_currentRecordedFrame_callback(yat4tango::DynamicAttributeReadCallbackData& cbd) -{ - DEBUG_STREAM << "Pco::read_currentRecordedFrame_callback()" << endl; // << cbd.dya->get_name() << endl; - - try - { - if (get_state() == Tango::RUNNING || get_state() == Tango::STANDBY) - { - m_camera->getLastImgRecorded(*attr_currentRecordedFrame_read); - } - cbd.tga->set_value(attr_currentRecordedFrame_read); - } - catch (lima::Exception& e) - { - ERROR_STREAM << e.getErrMsg() << endl; - //- throw exception - Tango::Except::throw_exception( - "LIMA_ERROR", - e.getErrMsg().c_str(), - "Pco::read_currentRecordedFrame_callback"); - } -} - -//+------------------------------------------------------------------ -/** - * method: Pco::talk - * - * description: method to execute "Talk" - * Availables values are:
- * lasterror
- * camInfo
- * camType
- * clTransferParam
- * cocRunTime
- * frameRate
- * maxNbImages
- * timestamp
- * " "
- * - * @param argin str argin - * @return str argout - * - */ -//+------------------------------------------------------------------ -Tango::DevString Pco::talk(Tango::DevString argin) -{ - // POGO has generated a method core with argout allocation. - // If you would like to use a static reference without copying, - // See "TANGO Device Server Programmer's Manual" - // (chapter : Writing a TANGO DS / Exchanging data) - //------------------------------------------------------------ - DEBUG_STREAM << "Pco::talk(): entering... !" << endl; - - // Add your own code to control device here - Tango::DevString argout; - try - { - string result(""); - result = m_camera->talk(std::string(argin)); - - argout = new char[result.size() + 1]; - if (result.size() > 0) - { - result.copy(argout, result.size()); - } - argout[result.size()] = 0; - return argout; - } - catch(lima::Exception& e) - { - ERROR_STREAM << e.getErrMsg() << endl; - //- throw exception - Tango::Except::throw_exception("LIMA_ERROR", - e.getErrMsg().c_str(), - "Pco::talk"); - } -} - -//+------------------------------------------------------------------ -/** - * method: Pco::get_cam_info - * - * description: method to execute "GetCamInfo" - * Get Camera Infos - * - * @return cam infos - * - */ -//+------------------------------------------------------------------ -Tango::DevString Pco::get_cam_info() -{ - // POGO has generated a method core with argout allocation. - // If you would like to use a static reference without copying, - // See "TANGO Device Server Programmer's Manual" - // (chapter : Writing a TANGO DS / Exchanging data) - //------------------------------------------------------------ - INFO_STREAM << "Pco::get_cam_info(): entering... !" << endl; - - // Add your own code to control device here - Tango::DevString argout; - try - { - string result(""); - result = m_camera->talk(std::string("camInfo")); - - argout = new char[result.size() + 1]; - if (result.size() > 0) - { - result.copy(argout, result.size()); - } - argout[result.size()] = 0; - return argout; - } - catch(lima::Exception& e) - { - ERROR_STREAM << e.getErrMsg() << endl; - //- throw exception - Tango::Except::throw_exception("LIMA_ERROR", - e.getErrMsg().c_str(), - "Pco::get_cam_info"); - } -} - -//+------------------------------------------------------------------ -/** - * method: Pco::dev_state - * - * description: method to execute "State" - * This command gets the device state (stored in its device_state data member) and returns it to the caller. - * - * @return State Code - * - */ -//+------------------------------------------------------------------ -Tango::DevState Pco::dev_state() -{ - Tango::DevState argout = DeviceImpl::dev_state(); - DEBUG_STREAM << "Pco::dev_state(): entering... !" << endl; - - // Add your own code to control device here - - stringstream DeviceStatus; - DeviceStatus.str(""); - Tango::DevState DeviceState = Tango::STANDBY; - - //if error during init_device - if(!m_is_device_initialized) - { - DeviceState = Tango::FAULT; - DeviceStatus << m_status_message.str(); - DeviceStatus << endl; - } - else - { - // let's take a look at the status of control & the status of the plugin - DeviceState = ControlFactory::instance().get_state(); - DeviceStatus << ControlFactory::instance().get_status(); - } - - set_state(DeviceState); - set_status(DeviceStatus.str()); - - argout = DeviceState; - return argout; -} - - - - - - - - - - -} // namespace +static const char *RcsId = "$Id: $"; +//+============================================================================= +// +// file : Pco.cpp +// +// description : C++ source for the Pco 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 +// Pco are implemented in this file. +// +// project : TANGO Device Server +// +// $Author: $ +// +// $Revision: $ +// +// $Revision: $ +// $Date: $ +// +// SVN only: +// $HeadURL: $ +// +// CVS only: +// $Source: $ +// $Log: $ +// +// copyleft : Synchrotron SOLEIL +// L'Orme des merisiers - Saint Aubin +// BP48 - 91192 Gif sur Yvette +// FRANCE +// +//-============================================================================= +// +// This file is generated by POGO +// (Program Obviously used to Generate tango Object) +// +// (c) - Software Engineering Group - ESRF +//============================================================================= + + + +//=================================================================== +// +// The following table gives the correspondence +// between commands and method name. +// +// Command name| Method name +// ---------------------------------------- +// State | dev_state() +// Status | dev_status() +// Talk | talk() +// GetCamInfo | get_cam_info() +// +//=================================================================== +#include +#include + +#include "Pco.h" +#include + + +namespace Pco_ns +{ + +//+---------------------------------------------------------------------------- +// +// method : Pco::Pco(string &s) +// +// description : constructor for simulated Pco +// +// in : - cl : Pointer to the DeviceClass object +// - s : Device name +// +//----------------------------------------------------------------------------- +Pco::Pco(Tango::DeviceClass *cl, string &s) + :Tango::Device_4Impl(cl, s.c_str()), m_dim(this) +{ + init_device(); +} +Pco::Pco(Tango::DeviceClass *cl, const char *s) + : Tango::Device_4Impl(cl, s), m_dim(this) +{ + init_device(); +} +Pco::Pco(Tango::DeviceClass *cl, const char *s, const char *d) + : Tango::Device_4Impl(cl, s, d), m_dim(this) +{ + init_device(); +} +//+---------------------------------------------------------------------------- +// +// method : Pco::delete_device() +// +// description : will be called at device destruction or at init command. +// +//----------------------------------------------------------------------------- +void Pco::delete_device() +{ + INFO_STREAM << "Pco::Pco() delete device " << device_name << endl; + // Delete device allocated objects + + DELETE_DEVSTRING_ATTRIBUTE(attr_pixelRate_read); + DELETE_SCALAR_ATTRIBUTE(attr_currentRecordedFrame_read); + DELETE_DEVSTRING_ATTRIBUTE(attr_cameraModel_read); + DELETE_DEVSTRING_ATTRIBUTE(attr_dllVersion_read); + DELETE_SCALAR_ATTRIBUTE(attr_sensorTemperature_read); + + DELETE_DEVSTRING_ATTRIBUTE(attr_storageMode_read); + DELETE_SCALAR_ATTRIBUTE(attr_ringBuffer_read); + + //- For dyn attr + DELETE_SCALAR_ATTRIBUTE(attr_maxNbImage_read); + DELETE_SCALAR_ATTRIBUTE(attr_cdiMode_read); + DELETE_SCALAR_ATTRIBUTE(attr_frameRate_read); + DELETE_SCALAR_ATTRIBUTE(attr_coolingSetPoint_read); + DELETE_SCALAR_ATTRIBUTE(attr_adcOperation_read); + DELETE_DEVSTRING_ATTRIBUTE(attr_shutterMode_read); + DELETE_SCALAR_ATTRIBUTE(attr_doubleImage_read); + DELETE_SCALAR_ATTRIBUTE(attr_forcedFIFOMode_read); + + INFO_STREAM << "Remove the inner-appender." << endl; + yat4tango::InnerAppender::release(this); + + //!!!! ONLY LimaDetector device can do this !!!! + //if(m_ct!=0) + //{ + // ControlFactory::instance().reset("Pco"); + // m_ct = 0; + //} + + //remove attributes from dam + INFO_STREAM << "Remove dynamic attributes." << endl; + m_dim.remove(); +} + +//+---------------------------------------------------------------------------- +// +// method : Pco::init_device() +// +// description : will be called at device initialization. +// +//----------------------------------------------------------------------------- +void Pco::init_device() +{ + INFO_STREAM << "Pco::Pco() create device " << device_name << endl; + + // Initialise variables to default values + //-------------------------------------------- + get_device_property(); + + CREATE_DEVSTRING_ATTRIBUTE(attr_pixelRate_read, MAX_ATTRIBUTE_STRING_LENGTH); + CREATE_SCALAR_ATTRIBUTE(attr_currentRecordedFrame_read); + CREATE_DEVSTRING_ATTRIBUTE(attr_cameraModel_read, MAX_ATTRIBUTE_STRING_LENGTH); + CREATE_DEVSTRING_ATTRIBUTE(attr_dllVersion_read, MAX_ATTRIBUTE_STRING_LENGTH); + CREATE_SCALAR_ATTRIBUTE(attr_sensorTemperature_read); + + CREATE_DEVSTRING_ATTRIBUTE(attr_storageMode_read, MAX_ATTRIBUTE_STRING_LENGTH); + CREATE_SCALAR_ATTRIBUTE(attr_ringBuffer_read); + + //- For dyn attr + CREATE_SCALAR_ATTRIBUTE(attr_maxNbImage_read); + CREATE_SCALAR_ATTRIBUTE(attr_cdiMode_read); + CREATE_SCALAR_ATTRIBUTE(attr_frameRate_read); + CREATE_SCALAR_ATTRIBUTE(attr_coolingSetPoint_read); + CREATE_DEVSTRING_ATTRIBUTE(attr_adcOperation_read, MAX_ATTRIBUTE_STRING_LENGTH); + CREATE_DEVSTRING_ATTRIBUTE(attr_shutterMode_read, MAX_ATTRIBUTE_STRING_LENGTH); + CREATE_SCALAR_ATTRIBUTE(attr_doubleImage_read); + CREATE_SCALAR_ATTRIBUTE(attr_forcedFIFOMode_read); + + m_is_device_initialized = false; + strcpy(*attr_pixelRate_read, "Not Initialised"); + m_camera_model = "Not Initialised"; + m_dll_version = "Not Initialised"; + set_state(Tango::INIT); + m_status_message.str(""); + + strcpy(*attr_storageMode_read, "Not Initialised"); + + INFO_STREAM << "Create the inner-appender in order to manage logs." << endl; + yat4tango::InnerAppender::initialize(this, 512); + + try + { + //- initialize Lima camera + //- get the main object used to pilot the lima framework + m_ct = ControlFactory::instance().get_control("Pco"); + + //- get interface to specific camera + m_hw = dynamic_cast(m_ct->hwInterface()); + + //- get camera to specific detector + m_camera = (m_hw->getCamera()); + + //- + m_camera->getCameraNameBase(m_camera_model); + INFO_STREAM << "Camera model : " << m_camera_model << endl; + //- + m_camera->getSdkRelease(m_dll_version); + INFO_STREAM << "DLL version : " << m_dll_version << endl; + + //- Create dynamic interface + create_dynamic_interface(); + + INFO_STREAM << "Write tango hardware at Init - pixelRate." << endl; + Tango::WAttribute &pixelRate = dev_attr->get_w_attr_by_name("pixelRate"); + try + { + std::string pixel_rate_str = yat4tango::PropertyHelper::get_memorized_attribute(this, "pixelRate"); + attr_pixelRate_write = const_cast(pixel_rate_str.c_str()); + pixelRate.set_write_value(attr_pixelRate_write); + write_pixelRate(pixelRate); + } + catch(Tango::DevFailed&) + { + ERROR_STREAM << "Failed to write memorized attribute - pixelRate." << endl; + } + + INFO_STREAM << "Write tango hardware at Init - storageMode." << endl; + Tango::WAttribute &storageMode = dev_attr->get_w_attr_by_name("storageMode"); + try + { + std::string storageMode_str = yat4tango::PropertyHelper::get_memorized_attribute(this, "storageMode"); + attr_storageMode_write = const_cast(storageMode_str.c_str()); + storageMode.set_write_value(attr_storageMode_write); + write_storageMode(storageMode); + } + catch(Tango::DevFailed&) + { + ERROR_STREAM << "Failed to write memorized attribute - storageMode." << endl; + } + + + } + catch(lima::Exception& e) + { + m_status_message << "Initialization Failed : " << e.getErrMsg() << endl; + ERROR_STREAM << m_status_message.str() << endl; + return; + } + catch (yat::Exception& ex) + { + m_status_message << "Initialization Failed : " << ex.errors[0].desc << endl; + ERROR_STREAM << m_status_message.str() << endl; + return; + } + catch (Tango::DevFailed& df) + { + m_status_message << "Initialization Failed : " << df.errors[0].desc << endl; + ERROR_STREAM << m_status_message.str() << endl; + return; + } + catch(...) + { + m_status_message << "Initialization Failed : Unknown error" << endl; + ERROR_STREAM << m_status_message.str() << endl; + return; + } + + m_is_device_initialized = true; + dev_state(); +} + +//+---------------------------------------------------------------------------- +// +// method : Pco::get_device_property() +// +// description : Read the device properties from database. +// +//----------------------------------------------------------------------------- +void Pco::get_device_property() +{ + // Initialize your default values here (if not done with POGO). + //------------------------------------------------------------------ + + // Read device properties from database.(Automatic code generation) + //------------------------------------------------------------------ + Tango::DbData dev_prop; + dev_prop.push_back(Tango::DbDatum("SerialNumber")); + + // Call database and extract values + //-------------------------------------------- + if (Tango::Util::instance()->_UseDb==true) + get_db_device()->get_property(dev_prop); + Tango::DbDatum def_prop, cl_prop; + PcoClass *ds_class = + (static_cast(get_device_class())); + int i = -1; + + // Try to initialize SerialNumber from class property + cl_prop = ds_class->get_class_property(dev_prop[++i].name); + if (cl_prop.is_empty()==false) cl_prop >> serialNumber; + else { + // Try to initialize SerialNumber from default device value + def_prop = ds_class->get_default_device_property(dev_prop[i].name); + if (def_prop.is_empty()==false) def_prop >> serialNumber; + } + // And try to extract SerialNumber value from database + if (dev_prop[i].is_empty()==false) dev_prop[i] >> serialNumber; + + + + // End of Automatic code generation + //------------------------------------------------------------------ + + yat4tango::PropertyHelper::create_property_if_empty(this, dev_prop, "0", "SerialNumber"); + +} + +/*------------------------------------------------------------------------- +// Pco::create_dynamic_interface +/-------------------------------------------------------------------------*/ +void Pco::create_dynamic_interface() +{ + DEBUG_STREAM << "Pco::create_dynamic_interface(): entering... !" << endl; + try + { + if (m_camera_model.find("pco.edge") != string::npos) + { + create_pco_edge_dynamic_interface(); + } + else //- Not EDGE + { + // ie: either dimax or XX00 + create_pco_with_ram_dynamic_interface(); + + if (m_camera_model.find("pco.dimax") != string::npos) + { + create_pco_dimax_dynamic_interface(); + } + else if ((m_camera_model.find("pco.4000") != string::npos) || + (m_camera_model.find("pco.2000") != string::npos) || + (m_camera_model.find("pco.1600") != string::npos)) + { + create_pco_xx00_dynamic_interface(); + } + } + } + catch (yat::Exception& ex) + { + THROW_YAT_TO_TANGO_EXCEPTION(ex); + } + catch (Tango::DevFailed& df) + { + ERROR_STREAM << df << endl; + + //- rethrow exception + Tango::Except::re_throw_exception(df, + "TANGO_DEVICE_ERROR", + string(df.errors[0].desc).c_str(), + "Pco::create_dynamic_interface()"); + } +} + +/*------------------------------------------------------------------------- +// Pco::create_pco_edge_dynamic_interface +/-------------------------------------------------------------------------*/ +void Pco::create_pco_edge_dynamic_interface() +{ + Tango::DbData dev_prop; + + //create frameRate dyn attribute + create_attribute("frameRate", + Tango::DEV_DOUBLE, + Tango::SCALAR, + Tango::READ, + Tango::OPERATOR, + "fps", + "%d", + "The frame rate", + "Frame Rate", + /*NOT_MEMORIZED, + NOT_WRITE_MEMORIZED_AT_INIT,*/ + &Pco::read_frameRate_callback, + &Pco::write_callback_null); + + //create coolingSetPoint dyn attribute + create_attribute("coolingSetPoint", + Tango::DEV_SHORT, + Tango::SCALAR, + Tango::READ_WRITE, + Tango::OPERATOR, + "deg C", + "%d", + "set / get the cooling set point", + "Cooling Set Point", + /*MEMORIZED, + WRITE_MEMORIZED_AT_INIT,*/ + &Pco::read_coolingSetPoint_callback, + &Pco::write_coolingSetPoint_callback); + + INFO_STREAM << "Write tango hardware at Init - coolingSetPoint." << endl; + Tango::WAttribute &coolingSetPoint = dev_attr->get_w_attr_by_name("coolingSetPoint"); + dev_prop.push_back(Tango::DbDatum("__MemorizedCoolingSetPoint")); + get_db_device()->get_property(dev_prop); + if (!dev_prop[0].is_empty()) + { + attr_coolingSetPoint_write = yat4tango::PropertyHelper::get_property(this, "__MemorizedCoolingSetPoint"); + coolingSetPoint.set_write_value(attr_coolingSetPoint_write); + yat4tango::DynamicAttributeWriteCallbackData cbd_coolingSetPoint; + cbd_coolingSetPoint.tga = &coolingSetPoint; + write_coolingSetPoint_callback(cbd_coolingSetPoint); + } + dev_prop.clear(); + + //create shutterMode dyn attribute + create_attribute("shutterMode", + Tango::DEV_STRING, + Tango::SCALAR, + Tango::READ_WRITE, + Tango::OPERATOR, + " ", + " ", + "get / set the shutterMode operation: \nROLLING_SHUTTER\nGLOBAL_SHUTTER\nGLOBAL_RESET", + "Shutter Mode", + /*MEMORIZED, + WRITE_MEMORIZED_AT_INIT,*/ + &Pco::read_shutterMode_callback, + &Pco::write_shutterMode_callback); + + INFO_STREAM << "Write tango hardware at Init - shutterMode." << endl; + Tango::WAttribute &shutterMode = dev_attr->get_w_attr_by_name("shutterMode"); + dev_prop.push_back(Tango::DbDatum("__MemorizedShutterMode")); + get_db_device()->get_property(dev_prop); + if (!dev_prop[0].is_empty()) + { + std::string shutter_mode_str = yat4tango::PropertyHelper::get_property(this, "__MemorizedShutterMode"); + attr_shutterMode_write = const_cast(shutter_mode_str.c_str()); + shutterMode.set_write_value(attr_shutterMode_write); + yat4tango::DynamicAttributeWriteCallbackData cbd_shutterMode; + cbd_shutterMode.tga = &shutterMode; + write_shutterMode_callback(cbd_shutterMode); + } + dev_prop.clear(); +} + +/*------------------------------------------------------------------------- +// Pco::create_pco_with_ram_dynamic_interface +/-------------------------------------------------------------------------*/ +void Pco::create_pco_with_ram_dynamic_interface() +{ + Tango::DbData dev_prop; + + //create doubleImage dyn attribute + create_attribute("doubleImage", + Tango::DEV_BOOLEAN, + Tango::SCALAR, + Tango::READ_WRITE, + Tango::OPERATOR, + " ", + " ", + "Set / Get the double image mode", + "Double Image", + /*MEMORIZED, + WRITE_MEMORIZED_AT_INIT,*/ + &Pco::read_doubleImage_callback, + &Pco::write_doubleImage_callback); + + INFO_STREAM << "Write tango hardware at Init - doubleImage." << endl; + Tango::WAttribute &doubleImage = dev_attr->get_w_attr_by_name("doubleImage"); + dev_prop.push_back(Tango::DbDatum("__MemorizedDoubleImage")); + get_db_device()->get_property(dev_prop); + if (!dev_prop[0].is_empty()) + { + attr_doubleImage_write = yat4tango::PropertyHelper::get_property(this, "__MemorizedDoubleImage"); + doubleImage.set_write_value(attr_doubleImage_write); + yat4tango::DynamicAttributeWriteCallbackData cbd_doubleImage; + cbd_doubleImage.tga = &doubleImage; + write_doubleImage_callback(cbd_doubleImage); + } + dev_prop.clear(); + + + //create currentRecordedFrame dyn attribute + create_attribute("currentRecordedFrame", + Tango::DEV_ULONG, + Tango::SCALAR, + Tango::READ, + Tango::OPERATOR, + " ", + "%d", + "current recorded frame : frames recorded in the Camera RAM", + "Current Recorded Frame", + /*NOT_MEMORIZED, + NOT_WRITE_MEMORIZED_AT_INIT,*/ + &Pco::read_currentRecordedFrame_callback, + &Pco::write_callback_null); + + //create forcedFIFOMode dyn attribute + create_attribute("forcedFIFOMode", + Tango::DEV_BOOLEAN, + Tango::SCALAR, + Tango::READ_WRITE, + Tango::OPERATOR, + " ", + " ", + "Forced FIFO mode", + "Forced FIFO mode", + /*MEMORIZED, + WRITE_MEMORIZED_AT_INIT,*/ + &Pco::read_forcedFIFOMode_callback, + &Pco::write_forcedFIFOMode_callback); + + INFO_STREAM << "Write tango hardware at Init - forcedFIFOMode." << endl; + Tango::WAttribute &forcedFIFOMode = dev_attr->get_w_attr_by_name("forcedFIFOMode"); + dev_prop.push_back(Tango::DbDatum("__MemorizedforcedFIFOMode")); + get_db_device()->get_property(dev_prop); + if (!dev_prop[0].is_empty()) + { + attr_forcedFIFOMode_write = yat4tango::PropertyHelper::get_property(this, "__MemorizedforcedFIFOMode"); + forcedFIFOMode.set_write_value(attr_forcedFIFOMode_write); + yat4tango::DynamicAttributeWriteCallbackData cbd_forcedFIFOMode; + cbd_forcedFIFOMode.tga = &forcedFIFOMode; + write_forcedFIFOMode_callback(cbd_forcedFIFOMode); + } + dev_prop.clear(); +} + +/*------------------------------------------------------------------------- +// Pco::create_pco_dimax_dynamic_interface +/-------------------------------------------------------------------------*/ +void Pco::create_pco_dimax_dynamic_interface() +{ + Tango::DbData dev_prop; + + //create maxNbImage dyn attribute + create_attribute("maxNbImage", + Tango::DEV_ULONG, + Tango::SCALAR, + Tango::READ, + Tango::OPERATOR, + " ", + "%d", + "get the max number of images available in the Camera RAM", + "Max Nb Image", + /*NOT_MEMORIZED, + NOT_WRITE_MEMORIZED_AT_INIT,*/ + &Pco::read_maxNbImage_callback, + &Pco::write_callback_null); + + //create cdiMode dyn attribute + create_attribute("cdiMode", + Tango::DEV_BOOLEAN, + Tango::SCALAR, + Tango::READ_WRITE, + Tango::OPERATOR, + " ", + "%1d", + "enable / disable the cdi mode", + "CDI mode", + /*MEMORIZED, + WRITE_MEMORIZED_AT_INIT,*/ + &Pco::read_cdiMode_callback, + &Pco::write_cdiMode_callback); + + INFO_STREAM << "Write tango hardware at Init - cdiMode." << endl; + Tango::WAttribute &cdiMode = dev_attr->get_w_attr_by_name("cdiMode"); + dev_prop.push_back(Tango::DbDatum("__MemorizedCdiMode")); + get_db_device()->get_property(dev_prop); + if (!dev_prop[0].is_empty()) + { + attr_cdiMode_write = yat4tango::PropertyHelper::get_property(this, "__MemorizedCdiMode"); + cdiMode.set_write_value(attr_cdiMode_write); + yat4tango::DynamicAttributeWriteCallbackData cbd_cdiMode; + cbd_cdiMode.tga = &cdiMode; + write_cdiMode_callback(cbd_cdiMode); + } + dev_prop.clear(); + + //create frameRate dyn attribute + create_attribute("frameRate", + Tango::DEV_DOUBLE, + Tango::SCALAR, + Tango::READ, + Tango::OPERATOR, + "fps", + "%d", + "get the frame rate", + "Frame Rate", + /*NOT_MEMORIZED, + NOT_WRITE_MEMORIZED_AT_INIT,*/ + &Pco::read_frameRate_callback, + &Pco::write_callback_null); +} + +/*------------------------------------------------------------------------- +// Pco::create_pco_xx00_dynamic_interface +/-------------------------------------------------------------------------*/ +void Pco::create_pco_xx00_dynamic_interface() +{ + Tango::DbData dev_prop; + + //create maxNbImage dyn attribute + create_attribute("maxNbImage", + Tango::DEV_ULONG, + Tango::SCALAR, + Tango::READ, + Tango::OPERATOR, + " ", + "%d", + "get the max number of images available in the Camera RAM", + "Max Nb Image", + /*NOT_MEMORIZED, + NOT_WRITE_MEMORIZED_AT_INIT,*/ + &Pco::read_maxNbImage_callback, + &Pco::write_callback_null); + + //create adcOperation dyn attribute + create_attribute("adcOperation", + Tango::DEV_STRING, + Tango::SCALAR, + Tango::READ_WRITE, + Tango::OPERATOR, + " ", + "%1d", + "get / set the adc operation: \nSINGLE\nDUAL", + "ADC Operation", + /*MEMORIZED, + WRITE_MEMORIZED_AT_INIT,*/ + &Pco::read_adcOperation_callback, + &Pco::write_adcOperation_callback); + + INFO_STREAM << "Write tango hardware at Init - adcOperation." << endl; + Tango::WAttribute &adcOperation = dev_attr->get_w_attr_by_name("adcOperation"); + dev_prop.push_back(Tango::DbDatum("__MemorizedAdcOperation")); + get_db_device()->get_property(dev_prop); + if (!dev_prop[0].is_empty()) + { + std::string adc_op_str = yat4tango::PropertyHelper::get_property(this, "__MemorizedAdcOperation"); + attr_adcOperation_write = const_cast(adc_op_str.c_str()); + adcOperation.set_write_value(attr_adcOperation_write); + yat4tango::DynamicAttributeWriteCallbackData cbd_adcOperation; + cbd_adcOperation.tga = &adcOperation; + write_adcOperation_callback(cbd_adcOperation); + } + dev_prop.clear(); + + //create coolingSetPoint dyn attribute + create_attribute("coolingSetPoint", + Tango::DEV_SHORT, + Tango::SCALAR, + Tango::READ_WRITE, + Tango::OPERATOR, + "deg C", + "%d", + "get / set the cooling set point", + "Cooling Set Point", + /*MEMORIZED, + WRITE_MEMORIZED_AT_INIT,*/ + &Pco::read_coolingSetPoint_callback, + &Pco::write_coolingSetPoint_callback); + + INFO_STREAM << "Write tango hardware at Init - coolingSetPoint." << endl; + Tango::WAttribute &coolingSetPoint = dev_attr->get_w_attr_by_name("coolingSetPoint"); + dev_prop.push_back(Tango::DbDatum("__MemorizedCoolingSetPoint")); + get_db_device()->get_property(dev_prop); + if (!dev_prop[0].is_empty()) + { + attr_coolingSetPoint_write = yat4tango::PropertyHelper::get_property(this, "__MemorizedCoolingSetPoint"); + coolingSetPoint.set_write_value(attr_coolingSetPoint_write); + yat4tango::DynamicAttributeWriteCallbackData cbd_coolingSetPoint; + cbd_coolingSetPoint.tga = &coolingSetPoint; + write_coolingSetPoint_callback(cbd_coolingSetPoint); + } + dev_prop.clear(); +} + +//+---------------------------------------------------------------------------- +// +// method : Pco::always_executed_hook() +// +// description : method always executed before any command is executed +// +//----------------------------------------------------------------------------- +void Pco::always_executed_hook() +{ + DEBUG_STREAM << "Pco::always_executed_hook() entering... "<< endl; + + //- update state + dev_state(); +} +//+---------------------------------------------------------------------------- +// +// method : Pco::read_attr_hardware +// +// description : Hardware acquisition for attributes. +// +//----------------------------------------------------------------------------- +void Pco::read_attr_hardware(vector &attr_list) +{ + DEBUG_STREAM << "Pco::read_attr_hardware(vector &attr_list) entering... "<< endl; + // Add your own code here +} +//+---------------------------------------------------------------------------- +// +// method : Pco::read_storageMode +// +// description : Extract real attribute values for storageMode acquisition result. +// +//----------------------------------------------------------------------------- +void Pco::read_storageMode(Tango::Attribute &attr) +{ + DEBUG_STREAM << "Pco::read_storageMode(Tango::Attribute &attr) entering... "<< endl; + + try + { + //const char* storage_mode_str = talk("storageMode"); + //strcpy(*attr_storageMode_read, storage_mode_str); + //strcpy(*attr_storageMode_read, storage_mode_str); + std::string storage_mode; + m_camera->getStorageMode(storage_mode); + strcpy(*attr_storageMode_read, storage_mode.c_str()); + attr.set_value(attr_storageMode_read); + } + catch (yat::Exception& ex) + { + THROW_YAT_TO_TANGO_EXCEPTION(ex); + } + catch (lima::Exception& e) + { + ERROR_STREAM << e.getErrMsg() << endl; + //- throw exception + Tango::Except::throw_exception("LIMA_ERROR", + e.getErrMsg().c_str(), + "Pco::read_storageMode"); + } + +} + +//+---------------------------------------------------------------------------- +// +// method : Pco::write_storageMode +// +// description : Write storageMode attribute values to hardware. +// +//----------------------------------------------------------------------------- +void Pco::write_storageMode(Tango::WAttribute &attr) +{ + DEBUG_STREAM << "Pco::write_storageMode(Tango::WAttribute &attr) entering... "<< endl; + + try + { + std::string previous = *attr_storageMode_read; + attr.get_write_value(attr_storageMode_write); + std::string current = attr_storageMode_write; + + if (!m_camera->isStorageModeValidValue(current)) + { + Tango::Except::throw_exception( "CONFIGURATION_ERROR", + "Available storageMode values are: RECORDER, FIFO\n", + "Pco::write_storageMode"); + } + m_camera->setStorageMode(current); + } + catch (yat::Exception& ex) + { + THROW_YAT_TO_TANGO_EXCEPTION(ex); + } + catch (lima::Exception& e) + { + ERROR_STREAM << e.getErrMsg() << endl; + //- throw exception + Tango::Except::throw_exception("LIMA_ERROR", + e.getErrMsg().c_str(), + "Pco::write_storageMode"); + } +} + +//+---------------------------------------------------------------------------- +// +// method : Pco::read_ringBuffer +// +// description : Extract real attribute values for ringBuffer acquisition result. +// +//----------------------------------------------------------------------------- +void Pco::read_ringBuffer(Tango::Attribute &attr) +{ + DEBUG_STREAM << "Pco::read_ringBuffer(Tango::Attribute &attr) entering... "<< endl; + try + { + bool ringBuffer; + m_camera->getRingBuffer(ringBuffer); + *attr_ringBuffer_read = ringBuffer; //yat::StringUtil::to_num(ringBuffer);; + attr.set_value(attr_ringBuffer_read); + } + catch (lima::Exception& e) + { + ERROR_STREAM << e.getErrMsg() << endl; + //- throw exception + Tango::Except::throw_exception( + "LIMA_ERROR", + e.getErrMsg().c_str(), + "Pco::read_ringBuffer"); + } +} + +//+---------------------------------------------------------------------------- +// +// method : Pco::write_ringBuffer +// +// description : Write ringBuffer attribute values to hardware. +// +//----------------------------------------------------------------------------- +void Pco::write_ringBuffer(Tango::WAttribute &attr) +{ + DEBUG_STREAM << "Pco::write_ringBuffer(Tango::WAttribute &attr) entering... "<< endl; + + try + { + attr.get_write_value(attr_ringBuffer_write); + bool ringBuffer = attr_ringBuffer_write; + m_camera->setRingBuffer(ringBuffer); + } + catch (yat::Exception& ex) + { + THROW_YAT_TO_TANGO_EXCEPTION(ex); + } + catch (lima::Exception& e) + { + ERROR_STREAM << e.getErrMsg() << endl; + //- throw exception + Tango::Except::throw_exception("LIMA_ERROR", + e.getErrMsg().c_str(), + "Pco::write_ringBuffer"); + } +} + + +//+---------------------------------------------------------------------------- +// +// method : Pco::read_sensorTemperature +// +// description : Extract real attribute values for sensorTemperature acquisition result. +// +//----------------------------------------------------------------------------- +void Pco::read_sensorTemperature(Tango::Attribute &attr) +{ + DEBUG_STREAM << "Pco::read_sensorTemperature(Tango::Attribute &attr) entering... "<< endl; + + try + { + std::string temp_temperature_info,temp_temperature; + m_camera->getTemperatureInfo(temp_temperature_info); + yat::StringUtil::extract_token(&temp_temperature_info, '[', ']', &temp_temperature); + *attr_sensorTemperature_read = yat::StringUtil::to_num(temp_temperature); + attr.set_value(attr_sensorTemperature_read); + } + catch (lima::Exception& e) + { + ERROR_STREAM << e.getErrMsg() << endl; + //- throw exception + Tango::Except::throw_exception( + "LIMA_ERROR", + e.getErrMsg().c_str(), + "Pco::read_sensorTemperature"); + } +} + +//+---------------------------------------------------------------------------- +// +// method : Pco::read_maxNbImage_callback() +// +// description : Extract real attribute values for maxNbImage +// +//----------------------------------------------------------------------------- +void Pco::read_maxNbImage_callback(yat4tango::DynamicAttributeReadCallbackData& cbd) +{ + DEBUG_STREAM << "Pco::read_maxNbImage_callback()" << endl; // << cbd.dya->get_name() << endl; + + try + { + m_camera->getMaxNbImages(*attr_maxNbImage_read); + cbd.tga->set_value(attr_maxNbImage_read); + } + catch (lima::Exception& e) + { + ERROR_STREAM << e.getErrMsg() << endl; + //- throw exception + Tango::Except::throw_exception( + "LIMA_ERROR", + e.getErrMsg().c_str(), + "Pco::read_maxNbImage_callback"); + } +} + +//+---------------------------------------------------------------------------- +// +// method : Pco::read_cdiMode_callback() +// +// description : Extract real attribute values for cdi +// +//----------------------------------------------------------------------------- +void Pco::read_cdiMode_callback(yat4tango::DynamicAttributeReadCallbackData& cbd) +{ + DEBUG_STREAM << "Pco::read_cdiMode_callback()" << endl; // << cbd.dya->get_name() << endl; + + try + { + int cdi_mode_temp = -1; + m_camera->getCDIMode(cdi_mode_temp); + *attr_cdiMode_read = cdi_mode_temp; + cbd.tga->set_value(attr_cdiMode_read); + } + catch (lima::Exception& e) + { + ERROR_STREAM << e.getErrMsg() << endl; + //- throw exception + Tango::Except::throw_exception( + "LIMA_ERROR", + e.getErrMsg().c_str(), + "Pco::read_cdiMode_callback"); + } +} + + +//+---------------------------------------------------------------------------- +// +// method : Pco::write_cdiMode_callback() +// +// description : Extract real attribute values for cdi +// +//----------------------------------------------------------------------------- +void Pco::write_cdiMode_callback(yat4tango::DynamicAttributeWriteCallbackData& cbd) +{ + INFO_STREAM << "Pco::write_cdiMode_callback()" << endl; // << cbd.dya->get_name() << endl; + + try + { + cbd.tga->get_write_value(attr_cdiMode_write); + m_camera->setCDIMode(attr_cdiMode_write); + } + catch (lima::Exception& e) + { + ERROR_STREAM << e.getErrMsg() << endl; + //- throw exception + Tango::Except::throw_exception( + "LIMA_ERROR", + e.getErrMsg().c_str(), + "Pco::write_cdiMode_callback"); + } +} + +//+---------------------------------------------------------------------------- +// +// method : Pco::read_frameRate_callback() +// +// description : Extract real attribute values for frameRate +// +//----------------------------------------------------------------------------- +void Pco::read_frameRate_callback(yat4tango::DynamicAttributeReadCallbackData& cbd) +{ + DEBUG_STREAM << "Pco::read_frameRate_callback()" << endl; // << cbd.dya->get_name() << endl; + + try + { + //- "manual" state machine as this is a dynamic attribute + if (get_state() == Tango::DISABLE || get_state() == Tango::FAULT) + return; + + m_camera->getFrameRate(*attr_frameRate_read); + + cbd.tga->set_value(attr_frameRate_read); + } + catch (lima::Exception& e) + { + ERROR_STREAM << e.getErrMsg() << endl; + //- throw exception + Tango::Except::throw_exception( + "LIMA_ERROR", + e.getErrMsg().c_str(), + "Pco::read_frameRate_callback"); + } +} + +//+---------------------------------------------------------------------------- +// +// method : Pco::read_coolingSetPoint_callback() +// +// description : Extract real attribute values for coolingSetPoint +// +//----------------------------------------------------------------------------- +void Pco::read_coolingSetPoint_callback(yat4tango::DynamicAttributeReadCallbackData& cbd) +{ + DEBUG_STREAM << "Pco::read_coolingSetPoint_callback()" << endl; // << cbd.dya->get_name() << endl; + + try + { + //- "manual" state machine as this is a dynamic attribute + if (get_state() == Tango::DISABLE || get_state() == Tango::FAULT) + return; + + int temp_cooling_set_point = -1; + m_camera->getCoolingTemperature(temp_cooling_set_point); + *attr_coolingSetPoint_read = temp_cooling_set_point; + + cbd.tga->set_value(attr_coolingSetPoint_read); + } + catch (lima::Exception& e) + { + ERROR_STREAM << e.getErrMsg() << endl; + //- throw exception + Tango::Except::throw_exception( + "LIMA_ERROR", + e.getErrMsg().c_str(), + "Pco::read_coolingSetPoint_callback"); + } +} + +//+---------------------------------------------------------------------------- +// +// method : Pco::write_coolingSetPoint_callback() +// +// description : Extract real attribute values for coolingSetPoint +// +//----------------------------------------------------------------------------- +void Pco::write_coolingSetPoint_callback(yat4tango::DynamicAttributeWriteCallbackData& cbd) +{ + INFO_STREAM << "Pco::write_coolingSetPoint_callback()" << endl; // << cbd.dya->get_name() << endl; + + if (get_state() == Tango::FAULT || + get_state() == Tango::RUNNING || + get_state() == Tango::DISABLE) + { + std::string reason = "It's currently not allowed to write attribute coolingSetPoint. The device state is " + std::string(Tango::DevStateName[get_state()]); + Tango::Except::throw_exception( "TANGO_DEVICE_ERROR", + reason.c_str(), + "Pco::write_coolingSetPoint_callback()"); + } + + try + { + cbd.tga->get_write_value(attr_coolingSetPoint_write); + m_camera->setCoolingTemperature(attr_coolingSetPoint_write); + + //- Memorize the value + yat4tango::PropertyHelper::set_property(this, "__MemorizedCoolingSetPoint", attr_coolingSetPoint_write); + } + catch (lima::Exception& e) + { + ERROR_STREAM << e.getErrMsg() << endl; + //- throw exception + Tango::Except::throw_exception( + "LIMA_ERROR", + e.getErrMsg().c_str(), + "Pco::write_coolingSetPoint_callback"); + } +} + +//+---------------------------------------------------------------------------- +// +// method : Pco::read_adcOperation_callback() +// +// description : Extract real attribute values for adcOperation +// +//----------------------------------------------------------------------------- +void Pco::read_adcOperation_callback(yat4tango::DynamicAttributeReadCallbackData& cbd) +{ + DEBUG_STREAM << "Pco::read_adcOperation_callback()" << endl; // << cbd.dya->get_name() << endl; + + try + { + int adc_temp = -1; + m_camera->getAdc(adc_temp); + switch (adc_temp) + { + case 1: + strcpy(*attr_adcOperation_read, "SINGLE"); + break; + case 2: + strcpy(*attr_adcOperation_read, "DUAL"); + break; + default: + strcpy(*attr_adcOperation_read, "UNKNOWN"); + break; + } + + cbd.tga->set_value(attr_adcOperation_read); + } + catch (lima::Exception& e) + { + ERROR_STREAM << e.getErrMsg() << endl; + //- throw exception + Tango::Except::throw_exception( + "LIMA_ERROR", + e.getErrMsg().c_str(), + "Pco::read_adcOperation_callback"); + } +} + +//+---------------------------------------------------------------------------- +// +// method : Pco::write_adcOperation_callback() +// +// description : Extract real attribute values for adcOperation +// +//----------------------------------------------------------------------------- +void Pco::write_adcOperation_callback(yat4tango::DynamicAttributeWriteCallbackData& cbd) +{ + INFO_STREAM << "Pco::write_adcOperation_callback()" << endl; // << cbd.dya->get_name() << endl; + + if (get_state() == Tango::FAULT || get_state() == Tango::RUNNING) + { + std::string reason = "It's currently not allowed to write attribute adcOperation. The device state is " + std::string(Tango::DevStateName[get_state()]); + Tango::Except::throw_exception( "TANGO_DEVICE_ERROR", + reason.c_str(), + "Pco::write_adcOperation_callback()"); + } + + try + { + std::string previous = *attr_adcOperation_read; + cbd.tga->get_write_value(attr_adcOperation_write); + std::string current = attr_adcOperation_write; + + int value_to_write; + + if(current == "SINGLE") + value_to_write = 1; + else if(current == "DUAL") + value_to_write = 2; + else + Tango::Except::throw_exception("CONFIGURATION_ERROR", + "Available ADC values are: \n- SINGLE\n- DUAL" , + "Pco::write_adcOperation_callback"); + + m_camera->setAdc(value_to_write); + //- Memorize the value + yat4tango::PropertyHelper::set_property(this, "__MemorizedAdcOperation", static_cast(attr_adcOperation_write)); + } + catch (lima::Exception& e) + { + ERROR_STREAM << e.getErrMsg() << endl; + //- throw exception + Tango::Except::throw_exception( + "LIMA_ERROR", + e.getErrMsg().c_str(), + "Pco::write_adcOperation_callback"); + } +} + +//+---------------------------------------------------------------------------- +// +// method : Pco::read_shutterMode_callback +// +// description : Extract real attribute values for shutterMode acquisition result. +// +//----------------------------------------------------------------------------- +void Pco::read_shutterMode_callback(yat4tango::DynamicAttributeReadCallbackData& cbd) +{ + DEBUG_STREAM << "Pco::read_shutterMode_callback(Tango::Attribute &attr) entering... "<< endl; + + try + { + //- "manual" state machine as this is a dynamic attribute + if (get_state() == Tango::DISABLE || get_state() == Tango::FAULT) + return; + + int shutter_temp = -1; + m_camera->getRollingShutter(shutter_temp); + switch (shutter_temp) + { + case 1: + strcpy(*attr_shutterMode_read, "ROLLING_SHUTTER"); + break; + case 2: + strcpy(*attr_shutterMode_read, "GLOBAL_SHUTTER"); + break; + case 4: + strcpy(*attr_shutterMode_read, "GLOBAL_RESET"); + break; + default: + strcpy(*attr_shutterMode_read, "UNKNOWN"); + break; + } + + cbd.tga->set_value(attr_shutterMode_read); + } + catch (lima::Exception& e) + { + ERROR_STREAM << e.getErrMsg() << endl; + //- throw exception + Tango::Except::throw_exception( + "LIMA_ERROR", + e.getErrMsg().c_str(), + "Pco::read_shutterMode_callback"); + } +} + +//+---------------------------------------------------------------------------- +// +// method : Pco::write_shutterMode_callback +// +// description : Write shutterMode attribute values to hardware. +// +//----------------------------------------------------------------------------- +void Pco::write_shutterMode_callback(yat4tango::DynamicAttributeWriteCallbackData& cbd) +{ + INFO_STREAM << "Pco::write_shutterMode_callback(Tango::WAttribute &attr) entering... "<< endl; + + if (get_state() == Tango::FAULT || + get_state() == Tango::RUNNING || + get_state() == Tango::DISABLE) + { + std::string reason = "It's currently not allowed to write attribute shutterMode. The device state is " + std::string(Tango::DevStateName[get_state()]); + Tango::Except::throw_exception( "TANGO_DEVICE_ERROR", + reason.c_str(), + "Pco::write_adcOperation_callback()"); + } + + try + { + + std::string previous = *attr_shutterMode_read; + cbd.tga->get_write_value(attr_shutterMode_write); + std::string current = attr_shutterMode_write; + + int value_to_write; + + if (current == "ROLLING_SHUTTER") + value_to_write = 1; + else if (current == "GLOBAL_SHUTTER") + value_to_write = 2; + else if (current == "GLOBAL_RESET") + value_to_write = 4; + else + Tango::Except::throw_exception( "CONFIGURATION_ERROR", + "Available Shutter values are: \n- ROLLING_SHUTTER\n- GLOBAL_SHUTTER\n- GLOBAL_RESET", + "Pco::write_shutterMode_callback"); + + m_camera->setRollingShutter(value_to_write); + + //- Memorize the value + yat4tango::PropertyHelper::set_property(this, "__MemorizedShutterMode", static_cast(attr_shutterMode_write)); + } + catch (lima::Exception& e) + { + ERROR_STREAM << e.getErrMsg() << endl; + //- throw exception + Tango::Except::throw_exception( + "LIMA_ERROR", + e.getErrMsg().c_str(), + "Pco::write_shutterMode_callback"); + } +} + +//+---------------------------------------------------------------------------- +// +// method : Pco::read_pixelRate +// +// description : Extract real attribute values for pixelRate acquisition result. +// +//----------------------------------------------------------------------------- +void Pco::read_pixelRate(Tango::Attribute &attr) +{ + DEBUG_STREAM << "Pco::read_pixelRate(Tango::Attribute &attr) entering... "<< endl; + + try + { + const char * pixel_rate_str = talk("pixelRate"); + strcpy(*attr_pixelRate_read, pixel_rate_str); + attr.set_value(attr_pixelRate_read); + } + catch (yat::Exception& ex) + { + THROW_YAT_TO_TANGO_EXCEPTION(ex); + } + catch (lima::Exception& e) + { + ERROR_STREAM << e.getErrMsg() << endl; + //- throw exception + Tango::Except::throw_exception("LIMA_ERROR", + e.getErrMsg().c_str(), + "Pco::read_pixelRate"); + } +} + +//+---------------------------------------------------------------------------- +// +// method : Pco::write_pixelRate +// +// description : Write pixelRate attribute values to hardware. +// +//----------------------------------------------------------------------------- +void Pco::write_pixelRate(Tango::WAttribute &attr) +{ + INFO_STREAM << "Pco::write_pixelRate(Tango::WAttribute &attr) entering... "<< endl; + + try + { + std::string previous = *attr_pixelRate_read; + attr.get_write_value(attr_pixelRate_write); + std::string current = attr_pixelRate_write; + + std::string pixel_rate_valid_values; + m_camera->getPixelRateValidValues(pixel_rate_valid_values); + if (pixel_rate_valid_values.find(current) == std::string::npos) + { + Tango::Except::throw_exception( "CONFIGURATION_ERROR", + "Available pixelRate values are:\n" + pixel_rate_valid_values, + "Pco::write_shutterMode_callback"); + } + + int value_to_write = yat::StringUtil::to_num(std::string(attr_pixelRate_write)); + m_camera->setPixelRate(value_to_write); + } + catch (yat::Exception& ex) + { + THROW_YAT_TO_TANGO_EXCEPTION(ex); + } + catch (lima::Exception& e) + { + ERROR_STREAM << e.getErrMsg() << endl; + //- throw exception + Tango::Except::throw_exception("LIMA_ERROR", + e.getErrMsg().c_str(), + "Pco::write_pixelScanRate"); + } +} + +//+---------------------------------------------------------------------------- +// +// method : Pco::read_cameraModel +// +// description : Extract real attribute values for cameraModel acquisition result. +// +//----------------------------------------------------------------------------- +void Pco::read_cameraModel(Tango::Attribute &attr) +{ + DEBUG_STREAM << "Pco::read_cameraModel(Tango::Attribute &attr) entering... "<< endl; + + try + { + strcpy(*attr_cameraModel_read, m_camera_model.c_str()); + attr.set_value(attr_cameraModel_read); + } + catch (yat::Exception& ex) + { + THROW_YAT_TO_TANGO_EXCEPTION(ex); + } + catch (lima::Exception& e) + { + ERROR_STREAM << e.getErrMsg() << endl; + //- throw exception + Tango::Except::throw_exception( + "LIMA_ERROR", + e.getErrMsg().c_str(), + "Pco::read_cameraModel"); + } +} + +//+---------------------------------------------------------------------------- +// +// method : Pco::read_dllVersion +// +// description : Extract real attribute values for dllVersion acquisition result. +// +//----------------------------------------------------------------------------- +void Pco::read_dllVersion(Tango::Attribute &attr) +{ + DEBUG_STREAM << "Pco::read_dllVersion(Tango::Attribute &attr) entering... "<< endl; + + try + { + strcpy(*attr_dllVersion_read, m_dll_version.c_str()); + attr.set_value(attr_dllVersion_read); + } + catch (yat::Exception& ex) + { + THROW_YAT_TO_TANGO_EXCEPTION(ex); + } + catch (lima::Exception& e) + { + ERROR_STREAM << e.getErrMsg() << endl; + //- throw exception + Tango::Except::throw_exception( + "LIMA_ERROR", + e.getErrMsg().c_str(), + "Pco::read_dllVersion"); + } +} + +//+---------------------------------------------------------------------------- +// +// method : Pco::read_doubleImage_callback() +// +// description : Extract real attribute values for cdi +// +//----------------------------------------------------------------------------- +void Pco::read_doubleImage_callback(yat4tango::DynamicAttributeReadCallbackData& cbd) +{ + DEBUG_STREAM << "Pco::read_doubleImage_callback()" << endl; + + try + { + WORD wDoubleImage = 0; + int dummy_err = -10; + m_camera->_pco_GetDoubleImageMode(wDoubleImage, dummy_err); + *attr_doubleImage_read = (Tango::DevBoolean)wDoubleImage; + cbd.tga->set_value(attr_doubleImage_read); + } + catch (lima::Exception& e) + { + ERROR_STREAM << e.getErrMsg() << endl; + //- throw exception + Tango::Except::throw_exception( "LIMA_ERROR", + e.getErrMsg().c_str(), + "Pco::read_doubleImage_callback"); + } +} + +//+---------------------------------------------------------------------------- +// +// method : Pco::write_doubleImage_callback() +// +// description : Extract real attribute values for cdi +// +//----------------------------------------------------------------------------- +void Pco::write_doubleImage_callback(yat4tango::DynamicAttributeWriteCallbackData& cbd) +{ + INFO_STREAM << "Pco::write_doubleImage_callback()" << endl; + + if (get_state() == Tango::FAULT || + get_state() == Tango::RUNNING || + get_state() == Tango::DISABLE) + { + std::string reason = "It's currently not allowed to write attribute doubleImage. The device state is " + std::string(Tango::DevStateName[get_state()]); + Tango::Except::throw_exception( "TANGO_DEVICE_ERROR", + reason.c_str(), + "Pco::write_doubleImage_callback()"); + } + + try + { + cbd.tga->get_write_value(attr_doubleImage_write); + m_camera->setDoubleImageMode(attr_doubleImage_write); + + //- Memorize the value + yat4tango::PropertyHelper::set_property(this, "__MemorizedDoubleImage", attr_doubleImage_write); + } + catch (lima::Exception& e) + { + ERROR_STREAM << e.getErrMsg() << endl; + //- throw exception + Tango::Except::throw_exception( "LIMA_ERROR", + e.getErrMsg().c_str(), + "Pco::write_doubleImage_callback"); + } +} + +//+---------------------------------------------------------------------------- +// +// method : Pco::read_forcedFIFOMode_callback() +// +// description : Extract real attribute values for forcedFIFOMod +// +//----------------------------------------------------------------------------- +void Pco::read_forcedFIFOMode_callback(yat4tango::DynamicAttributeReadCallbackData& cbd) +{ + DEBUG_STREAM << "Pco::read_forcedFIFOMode_callback()" << endl; + + try + { + int temp_fifo = -1; + m_camera->getRecorderForcedFifo(temp_fifo); + *attr_forcedFIFOMode_read = (Tango::DevBoolean) temp_fifo; + cbd.tga->set_value(attr_forcedFIFOMode_read); + } + catch (lima::Exception& e) + { + ERROR_STREAM << e.getErrMsg() << endl; + //- throw exception + Tango::Except::throw_exception( "LIMA_ERROR", + e.getErrMsg().c_str(), + "Pco::read_forcedFIFOMode_callback"); + } +} + +//+---------------------------------------------------------------------------- +// +// method : Pco::write_forcedFIFOMode_callback() +// +// description : Extract real attribute values for forcedFIFOMode +// +//----------------------------------------------------------------------------- +void Pco::write_forcedFIFOMode_callback(yat4tango::DynamicAttributeWriteCallbackData& cbd) +{ + INFO_STREAM << "Pco::write_forcedFIFOMode_callback()" << endl; + + if (get_state() == Tango::FAULT || + get_state() == Tango::RUNNING || + get_state() == Tango::DISABLE) + { + std::string reason = "It's currently not allowed to write attribute forcedFIFOMode. The device state is " + std::string(Tango::DevStateName[get_state()]); + Tango::Except::throw_exception( "TANGO_DEVICE_ERROR", + reason.c_str(), + "Pco::write_forcedFIFOMode_callback()"); + } + + try + { + cbd.tga->get_write_value(attr_forcedFIFOMode_write); + m_camera->setRecorderForcedFifo((int)attr_forcedFIFOMode_write); + + //- Memorize the value + yat4tango::PropertyHelper::set_property(this, "__MemorizedForcedFIFOMode", attr_forcedFIFOMode_write); + } + catch (lima::Exception& e) + { + ERROR_STREAM << e.getErrMsg() << endl; + //- throw exception + Tango::Except::throw_exception( "LIMA_ERROR", + e.getErrMsg().c_str(), + "Pco::write_forcedFIFOMode_callback"); + } +} + +//+---------------------------------------------------------------------------- +// +// method : Pco::read_currentRecordedFrame_callback() +// +// description : Extract real attribute values for maxNbImage +// +//----------------------------------------------------------------------------- +void Pco::read_currentRecordedFrame_callback(yat4tango::DynamicAttributeReadCallbackData& cbd) +{ + DEBUG_STREAM << "Pco::read_currentRecordedFrame_callback()" << endl; // << cbd.dya->get_name() << endl; + + try + { + if (get_state() == Tango::RUNNING || get_state() == Tango::STANDBY) + { + m_camera->getLastImgRecorded(*attr_currentRecordedFrame_read); + } + cbd.tga->set_value(attr_currentRecordedFrame_read); + } + catch (lima::Exception& e) + { + ERROR_STREAM << e.getErrMsg() << endl; + //- throw exception + Tango::Except::throw_exception( + "LIMA_ERROR", + e.getErrMsg().c_str(), + "Pco::read_currentRecordedFrame_callback"); + } +} + +//+------------------------------------------------------------------ +/** + * method: Pco::talk + * + * description: method to execute "Talk" + * Availables values are:
+ * lasterror
+ * camInfo
+ * camType
+ * clTransferParam
+ * cocRunTime
+ * frameRate
+ * maxNbImages
+ * timestamp
+ * " "
+ * + * @param argin str argin + * @return str argout + * + */ +//+------------------------------------------------------------------ +Tango::DevString Pco::talk(Tango::DevString argin) +{ + // POGO has generated a method core with argout allocation. + // If you would like to use a static reference without copying, + // See "TANGO Device Server Programmer's Manual" + // (chapter : Writing a TANGO DS / Exchanging data) + //------------------------------------------------------------ + DEBUG_STREAM << "Pco::talk(): entering... !" << endl; + + // Add your own code to control device here + Tango::DevString argout; + try + { + string result(""); + result = m_camera->talk(std::string(argin)); + + argout = new char[result.size() + 1]; + if (result.size() > 0) + { + result.copy(argout, result.size()); + } + argout[result.size()] = 0; + return argout; + } + catch(lima::Exception& e) + { + ERROR_STREAM << e.getErrMsg() << endl; + //- throw exception + Tango::Except::throw_exception("LIMA_ERROR", + e.getErrMsg().c_str(), + "Pco::talk"); + } +} + +//+------------------------------------------------------------------ +/** + * method: Pco::get_cam_info + * + * description: method to execute "GetCamInfo" + * Get Camera Infos + * + * @return cam infos + * + */ +//+------------------------------------------------------------------ +Tango::DevString Pco::get_cam_info() +{ + // POGO has generated a method core with argout allocation. + // If you would like to use a static reference without copying, + // See "TANGO Device Server Programmer's Manual" + // (chapter : Writing a TANGO DS / Exchanging data) + //------------------------------------------------------------ + INFO_STREAM << "Pco::get_cam_info(): entering... !" << endl; + + // Add your own code to control device here + Tango::DevString argout; + try + { + string result(""); + result = m_camera->talk(std::string("camInfo")); + + argout = new char[result.size() + 1]; + if (result.size() > 0) + { + result.copy(argout, result.size()); + } + argout[result.size()] = 0; + return argout; + } + catch(lima::Exception& e) + { + ERROR_STREAM << e.getErrMsg() << endl; + //- throw exception + Tango::Except::throw_exception("LIMA_ERROR", + e.getErrMsg().c_str(), + "Pco::get_cam_info"); + } +} + +//+------------------------------------------------------------------ +/** + * method: Pco::dev_state + * + * description: method to execute "State" + * This command gets the device state (stored in its device_state data member) and returns it to the caller. + * + * @return State Code + * + */ +//+------------------------------------------------------------------ +Tango::DevState Pco::dev_state() +{ + Tango::DevState argout = DeviceImpl::dev_state(); + DEBUG_STREAM << "Pco::dev_state(): entering... !" << endl; + + // Add your own code to control device here + + stringstream DeviceStatus; + DeviceStatus.str(""); + Tango::DevState DeviceState = Tango::STANDBY; + + //if error during init_device + if(!m_is_device_initialized) + { + DeviceState = Tango::FAULT; + DeviceStatus << m_status_message.str(); + DeviceStatus << endl; + } + else + { + // let's take a look at the status of control & the status of the plugin + DeviceState = ControlFactory::instance().get_state(); + DeviceStatus << ControlFactory::instance().get_status(); + } + + set_state(DeviceState); + set_status(DeviceStatus.str()); + + argout = DeviceState; + return argout; +} + + + + + + + + + + + +} // namespace diff --git a/specifics/Pco/Pco.h b/specifics/Pco/Pco.h index 08087c97..b9b03d7c 100755 --- a/specifics/Pco/Pco.h +++ b/specifics/Pco/Pco.h @@ -1,372 +1,400 @@ -//============================================================================= -// -// file : Pco.h -// -// description : Include for the Pco class. -// -// project : Device specific for Pco detector -// -// $Author: $ -// -// $Revision: $ -// $Date: $ -// -// SVN only: -// $HeadURL: $ -// -// CVS only: -// $Source: $ -// $Log: $ -// -// copyleft : Synchrotron SOLEIL -// L'Orme des merisiers - Saint Aubin -// BP48 - 91192 Gif sur Yvette -// FRANCE -// -//============================================================================= -// -// This file is generated by POGO -// (Program Obviously used to Generate tango Object) -// -// (c) - Software Engineering Group - ESRF -//============================================================================= -#ifndef _PCO_H -#define _PCO_H - -#include "tango.h" -#include "Factory.h" - -#include "lima/HwInterface.h" -#include "lima/CtControl.h" -#include "lima/CtAcquisition.h" -#include "lima/CtImage.h" -#include - -// YAT / 4Tango -#include -#include -#include -#include -#include -#include -#include - -/** - * @author $Author: $ - * @version $Revision: $ - */ - -// Add your own constant definitions here. -//----------------------------------------------- - -#define MAX_ATTRIBUTE_STRING_LENGTH 256 -const bool NOT_MEMORIZED = false; -const bool NOT_WRITE_MEMORIZED_AT_INIT = false; -const bool MEMORIZED = true; -const bool WRITE_MEMORIZED_AT_INIT = true; - - - -namespace Pco_ns -{ - - /** - * Class Description: - * - */ - -/* - * Device States Description: -* Tango::INIT : -* Tango::STANDBY : -* Tango::FAULT : -* Tango::RUNNING : - */ - - - class Pco : public Tango::Device_4Impl - { - public: - // Add your own data members here - //----------------------------------------- - //- Used for dynamic attributes - Tango::DevULong *attr_maxNbImage_read; - Tango::DevBoolean *attr_cdiMode_read; - Tango::DevBoolean attr_cdiMode_write; - Tango::DevDouble *attr_frameRate_read; - Tango::DevShort *attr_coolingSetPoint_read; - Tango::DevShort attr_coolingSetPoint_write; - Tango::DevString *attr_adcOperation_read; - Tango::DevString attr_adcOperation_write; - Tango::DevString *attr_shutterMode_read; - Tango::DevString attr_shutterMode_write; - Tango::DevBoolean *attr_doubleImage_read; - Tango::DevBoolean attr_doubleImage_write; - Tango::DevULong *attr_currentRecordedFrame_read; - Tango::DevBoolean *attr_forcedFIFOMode_read; - Tango::DevBoolean attr_forcedFIFOMode_write; - - // Here is the Start of the automatic code generation part - //------------------------------------------------------------- - /** - * @name attributes - * Attribute member data. - */ - //@{ - Tango::DevString *attr_pixelRate_read; - Tango::DevString attr_pixelRate_write; - Tango::DevString *attr_cameraModel_read; - Tango::DevFloat *attr_sensorTemperature_read; - Tango::DevString *attr_dllVersion_read; -//@} - - /** - * @name Device properties - * Device properties member data. - */ - //@{ -/** - * Serial Number of the camera: used to select camera if several connected to the same host - */ - string serialNumber; -//@} - - /** - * @name Device properties - * Device property member data. - */ - //@{ - //@} - - /**@name Constructors - * Miscellaneous constructors */ - //@{ - /** - * Constructs a newly allocated Command object. - * - * @param cl Class. - * @param s Device Name - */ - Pco(Tango::DeviceClass *cl, string &s); - /** - * Constructs a newly allocated Command object. - * - * @param cl Class. - * @param s Device Name - */ - Pco(Tango::DeviceClass *cl, const char *s); - /** - * Constructs a newly allocated Command object. - * - * @param cl Class. - * @param s Device name - * @param d Device description. - */ - Pco(Tango::DeviceClass *cl, const char *s, const char *d); - //@} - - /**@name Destructor - * Only one destructor is defined for this class */ - //@{ - - /** - * The object destructor. - */ - ~Pco() - { - delete_device(); - }; - /** - * will be called at device destruction or at init command. - */ - void delete_device(); - //@} - - - /**@name Miscellaneous methods */ - //@{ - /** - * Initialize the device - */ - virtual void init_device(); - /** - * Always executed method before execution command method. - */ - virtual void always_executed_hook(); - -//@} - -/** - * @name Pco methods prototypes - */ - -//@{ -/** - * Hardware acquisition for attributes. - */ - virtual void read_attr_hardware(vector &attr_list); -/** - * Extract real attribute values for pixelRate acquisition result. - */ - virtual void read_pixelRate(Tango::Attribute &attr); -/** - * Write pixelRate attribute values to hardware. - */ - virtual void write_pixelRate(Tango::WAttribute &attr); -/** - * Extract real attribute values for cameraModel acquisition result. - */ - virtual void read_cameraModel(Tango::Attribute &attr); -/** - * Extract real attribute values for sensorTemperature acquisition result. - */ - virtual void read_sensorTemperature(Tango::Attribute &attr); -/** - * Extract real attribute values for dllVersion acquisition result. - */ - virtual void read_dllVersion(Tango::Attribute &attr); -/** - * Read/Write allowed for pixelRate attribute. - */ - virtual bool is_pixelRate_allowed(Tango::AttReqType type); -/** - * Read/Write allowed for cameraModel attribute. - */ - virtual bool is_cameraModel_allowed(Tango::AttReqType type); -/** - * Read/Write allowed for sensorTemperature attribute. - */ - virtual bool is_sensorTemperature_allowed(Tango::AttReqType type); -/** - * Read/Write allowed for dllVersion attribute. - */ - virtual bool is_dllVersion_allowed(Tango::AttReqType type); -/** - * Execution allowed for Talk command. - */ - virtual bool is_Talk_allowed(const CORBA::Any &any); -/** - * Execution allowed for GetCamInfo command. - */ - virtual bool is_GetCamInfo_allowed(const CORBA::Any &any); -/** - * This command gets the device state (stored in its device_state data member) and returns it to the caller. - * @return State Code - * @exception DevFailed - */ - virtual Tango::DevState dev_state(); -/** - * Availables values are:
- * lasterror
- * camInfo
- * camType
- * clTransferParam
- * cocRunTime
- * frameRate
- * maxNbImages
- * timestamp
- * " "
- * @param argin str argin - * @return str argout - * @exception DevFailed - */ - Tango::DevString talk(Tango::DevString); -/** - * Get Camera Infos - * @return cam infos - * @exception DevFailed - */ - Tango::DevString get_cam_info(); - -/** - * Read the device properties from database - */ - void get_device_property(); -//@} - - // Here is the end of the automatic code generation part - //------------------------------------------------------------- - - - protected: - // Add your own data members here - //----------------------------------------- - - std::string m_camera_model, m_dll_version; - - ///generic method to create a tango dynamic attribute - void create_dynamic_interface(); - void create_pco_with_ram_dynamic_interface(); - void create_pco_edge_dynamic_interface(); - void create_pco_dimax_dynamic_interface(); - void create_pco_xx00_dynamic_interface(); - template - void create_attribute(std::string name, - int data_type, - Tango::AttrDataFormat data_format, - Tango::AttrWriteType access_type, - Tango::DispLevel disp_level, - const std::string& unit, - const std::string& format, - const std::string& desc, - const std::string& label, - /*bool memorized, - bool write_memorized_value_at_init,*/ - F1 read_callback, - F2 write_callback); - - //- maxNbImage - void read_maxNbImage_callback(yat4tango::DynamicAttributeReadCallbackData& cbd); - //- cdi - void read_cdiMode_callback(yat4tango::DynamicAttributeReadCallbackData& cbd); - void write_cdiMode_callback(yat4tango::DynamicAttributeWriteCallbackData& cbd); - //bool is_cdiMode_allowed(Tango::AttReqType type); - //- frameRate - void read_frameRate_callback(yat4tango::DynamicAttributeReadCallbackData& cbd); - //- coolingSetPoint - void read_coolingSetPoint_callback(yat4tango::DynamicAttributeReadCallbackData& cbd); - void write_coolingSetPoint_callback(yat4tango::DynamicAttributeWriteCallbackData& cbd); - //- adcOperation - void read_adcOperation_callback(yat4tango::DynamicAttributeReadCallbackData& cbd); - void write_adcOperation_callback(yat4tango::DynamicAttributeWriteCallbackData& cbd); - //- shutterMode - void read_shutterMode_callback(yat4tango::DynamicAttributeReadCallbackData& cbd); - void write_shutterMode_callback(yat4tango::DynamicAttributeWriteCallbackData& cbd); - // method for tango dyn attributes WHEN no write part is available - NULL - void write_callback_null(yat4tango::DynamicAttributeWriteCallbackData& cbd){/*nop*/} - //- doubleImage - void read_doubleImage_callback(yat4tango::DynamicAttributeReadCallbackData& cbd); - void write_doubleImage_callback(yat4tango::DynamicAttributeWriteCallbackData& cbd); - //- currentRecordedFrame - void read_currentRecordedFrame_callback(yat4tango::DynamicAttributeReadCallbackData& cbd); - //- forcedFIFOMode - void read_forcedFIFOMode_callback(yat4tango::DynamicAttributeReadCallbackData& cbd); - void write_forcedFIFOMode_callback(yat4tango::DynamicAttributeWriteCallbackData& cbd); - - //state & status stuff - // return true if the device is correctly initialized in init_device - bool is_device_initialized() {return m_is_device_initialized;}; - bool m_is_device_initialized; - stringstream m_status_message; - //lima OBJECTS - lima::Pco::Interface* m_hw; - lima::CtControl* m_ct; - lima::Pco::Camera* m_camera; - - std::string m_pixel_scan_rate; //pixel scan rate (SLOW, FAST) - std::string m_shutter_mode; //shutter mode name (GLOBAL, ROLLING) - Tango::DevString m_dev_string_val; - map m_map_scan_rate_frequencies; - - //- yat4tango Dynamic Interface Manager - yat4tango::DynamicInterfaceManager m_dim; - }; - -} // namespace_ns - -/////////////////////////////////////////////////////////////////////////////// -//// INCLUDE TEMPLATE IMPLEMENTAION -/////////////////////////////////////////////////////////////////////////////// -#include "Pco.hpp" - -#endif // _PCO_H +//============================================================================= +// +// file : Pco.h +// +// description : Include for the Pco class. +// +// project : Device specific for Pco detector +// +// $Author: $ +// +// $Revision: $ +// $Date: $ +// +// SVN only: +// $HeadURL: $ +// +// CVS only: +// $Source: $ +// $Log: $ +// +// copyleft : Synchrotron SOLEIL +// L'Orme des merisiers - Saint Aubin +// BP48 - 91192 Gif sur Yvette +// FRANCE +// +//============================================================================= +// +// This file is generated by POGO +// (Program Obviously used to Generate tango Object) +// +// (c) - Software Engineering Group - ESRF +//============================================================================= +#ifndef _PCO_H +#define _PCO_H + +#include "tango.h" +#include "Factory.h" + +#include "lima/HwInterface.h" +#include "lima/CtControl.h" +#include "lima/CtAcquisition.h" +#include "lima/CtImage.h" +#include + +// YAT / 4Tango +#include +#include +#include +#include +#include +#include +#include + +/** + * @author $Author: $ + * @version $Revision: $ + */ + +// Add your own constant definitions here. +//----------------------------------------------- + +#define MAX_ATTRIBUTE_STRING_LENGTH 256 +const bool NOT_MEMORIZED = false; +const bool NOT_WRITE_MEMORIZED_AT_INIT = false; +const bool MEMORIZED = true; +const bool WRITE_MEMORIZED_AT_INIT = true; + + + +namespace Pco_ns +{ + + /** + * Class Description: + * + */ + +/* + * Device States Description: +* Tango::INIT : +* Tango::STANDBY : +* Tango::FAULT : +* Tango::RUNNING : + */ + + + class Pco : public Tango::Device_4Impl + { + public: + // Add your own data members here + //----------------------------------------- + //- Used for dynamic attributes + Tango::DevULong *attr_maxNbImage_read; + Tango::DevBoolean *attr_cdiMode_read; + Tango::DevBoolean attr_cdiMode_write; + Tango::DevDouble *attr_frameRate_read; + Tango::DevShort *attr_coolingSetPoint_read; + Tango::DevShort attr_coolingSetPoint_write; + Tango::DevString *attr_adcOperation_read; + Tango::DevString attr_adcOperation_write; + Tango::DevString *attr_shutterMode_read; + Tango::DevString attr_shutterMode_write; + Tango::DevBoolean *attr_doubleImage_read; + Tango::DevBoolean attr_doubleImage_write; + Tango::DevULong *attr_currentRecordedFrame_read; + Tango::DevBoolean *attr_forcedFIFOMode_read; + Tango::DevBoolean attr_forcedFIFOMode_write; + + // Here is the Start of the automatic code generation part + //------------------------------------------------------------- + /** + * @name attributes + * Attribute member data. + */ + //@{ + Tango::DevString *attr_pixelRate_read; + Tango::DevString attr_pixelRate_write; + Tango::DevString *attr_cameraModel_read; + Tango::DevFloat *attr_sensorTemperature_read; + Tango::DevString *attr_dllVersion_read; + Tango::DevString *attr_storageMode_read; + Tango::DevString attr_storageMode_write; + Tango::DevBoolean *attr_ringBuffer_read; + Tango::DevBoolean attr_ringBuffer_write; +//@} + + /** + * @name Device properties + * Device properties member data. + */ + //@{ +/** + * Serial Number of the camera: used to select camera if several connected to the same host + */ + string serialNumber; +//@} + + /** + * @name Device properties + * Device property member data. + */ + //@{ + //@} + + /**@name Constructors + * Miscellaneous constructors */ + //@{ + /** + * Constructs a newly allocated Command object. + * + * @param cl Class. + * @param s Device Name + */ + Pco(Tango::DeviceClass *cl, string &s); + /** + * Constructs a newly allocated Command object. + * + * @param cl Class. + * @param s Device Name + */ + Pco(Tango::DeviceClass *cl, const char *s); + /** + * Constructs a newly allocated Command object. + * + * @param cl Class. + * @param s Device name + * @param d Device description. + */ + Pco(Tango::DeviceClass *cl, const char *s, const char *d); + //@} + + /**@name Destructor + * Only one destructor is defined for this class */ + //@{ + + /** + * The object destructor. + */ + ~Pco() + { + delete_device(); + }; + /** + * will be called at device destruction or at init command. + */ + void delete_device(); + //@} + + + /**@name Miscellaneous methods */ + //@{ + /** + * Initialize the device + */ + virtual void init_device(); + /** + * Always executed method before execution command method. + */ + virtual void always_executed_hook(); + +//@} + +/** + * @name Pco methods prototypes + */ + +//@{ +/** + * Hardware acquisition for attributes. + */ + virtual void read_attr_hardware(vector &attr_list); +/** + * Extract real attribute values for pixelRate acquisition result. + */ + virtual void read_pixelRate(Tango::Attribute &attr); +/** + * Write pixelRate attribute values to hardware. + */ + virtual void write_pixelRate(Tango::WAttribute &attr); +/** + * Extract real attribute values for cameraModel acquisition result. + */ + virtual void read_cameraModel(Tango::Attribute &attr); +/** + * Extract real attribute values for sensorTemperature acquisition result. + */ + virtual void read_sensorTemperature(Tango::Attribute &attr); +/** + * Extract real attribute values for dllVersion acquisition result. + */ + virtual void read_dllVersion(Tango::Attribute &attr); +/** + * Extract real attribute values for storageMode acquisition result. + */ + virtual void read_storageMode(Tango::Attribute &attr); +/** + * Write storageMode attribute values to hardware. + */ + virtual void write_storageMode(Tango::WAttribute &attr); +/** + * Extract real attribute values for ringBuffer acquisition result. + */ + virtual void read_ringBuffer(Tango::Attribute &attr); +/** + * Write ringBuffer attribute values to hardware. + */ + virtual void write_ringBuffer(Tango::WAttribute &attr); +/** + * Read/Write allowed for pixelRate attribute. + */ + virtual bool is_pixelRate_allowed(Tango::AttReqType type); +/** + * Read/Write allowed for cameraModel attribute. + */ + virtual bool is_cameraModel_allowed(Tango::AttReqType type); +/** + * Read/Write allowed for sensorTemperature attribute. + */ + virtual bool is_sensorTemperature_allowed(Tango::AttReqType type); +/** + * Read/Write allowed for dllVersion attribute. + */ + virtual bool is_dllVersion_allowed(Tango::AttReqType type); +/** + * Read/Write allowed for storageMode attribute. + */ + virtual bool is_storageMode_allowed(Tango::AttReqType type); +/** + * Read/Write allowed for ringBuffer attribute. + */ + virtual bool is_ringBuffer_allowed(Tango::AttReqType type); +/** + * Execution allowed for Talk command. + */ + virtual bool is_Talk_allowed(const CORBA::Any &any); +/** + * Execution allowed for GetCamInfo command. + */ + virtual bool is_GetCamInfo_allowed(const CORBA::Any &any); +/** + * This command gets the device state (stored in its device_state data member) and returns it to the caller. + * @return State Code + * @exception DevFailed + */ + virtual Tango::DevState dev_state(); +/** + * Availables values are:
+ * lasterror
+ * camInfo
+ * camType
+ * clTransferParam
+ * cocRunTime
+ * frameRate
+ * maxNbImages
+ * timestamp
+ * " "
+ * @param argin str argin + * @return str argout + * @exception DevFailed + */ + Tango::DevString talk(Tango::DevString); +/** + * Get Camera Infos + * @return cam infos + * @exception DevFailed + */ + Tango::DevString get_cam_info(); + +/** + * Read the device properties from database + */ + void get_device_property(); +//@} + + // Here is the end of the automatic code generation part + //------------------------------------------------------------- + + + protected: + // Add your own data members here + //----------------------------------------- + + std::string m_camera_model, m_dll_version; + + ///generic method to create a tango dynamic attribute + void create_dynamic_interface(); + void create_pco_with_ram_dynamic_interface(); + void create_pco_edge_dynamic_interface(); + void create_pco_dimax_dynamic_interface(); + void create_pco_xx00_dynamic_interface(); + template + void create_attribute(std::string name, + int data_type, + Tango::AttrDataFormat data_format, + Tango::AttrWriteType access_type, + Tango::DispLevel disp_level, + const std::string& unit, + const std::string& format, + const std::string& desc, + const std::string& label, + /*bool memorized, + bool write_memorized_value_at_init,*/ + F1 read_callback, + F2 write_callback); + + //- maxNbImage + void read_maxNbImage_callback(yat4tango::DynamicAttributeReadCallbackData& cbd); + //- cdi + void read_cdiMode_callback(yat4tango::DynamicAttributeReadCallbackData& cbd); + void write_cdiMode_callback(yat4tango::DynamicAttributeWriteCallbackData& cbd); + //bool is_cdiMode_allowed(Tango::AttReqType type); + //- frameRate + void read_frameRate_callback(yat4tango::DynamicAttributeReadCallbackData& cbd); + //- coolingSetPoint + void read_coolingSetPoint_callback(yat4tango::DynamicAttributeReadCallbackData& cbd); + void write_coolingSetPoint_callback(yat4tango::DynamicAttributeWriteCallbackData& cbd); + //- adcOperation + void read_adcOperation_callback(yat4tango::DynamicAttributeReadCallbackData& cbd); + void write_adcOperation_callback(yat4tango::DynamicAttributeWriteCallbackData& cbd); + //- shutterMode + void read_shutterMode_callback(yat4tango::DynamicAttributeReadCallbackData& cbd); + void write_shutterMode_callback(yat4tango::DynamicAttributeWriteCallbackData& cbd); + // method for tango dyn attributes WHEN no write part is available - NULL + void write_callback_null(yat4tango::DynamicAttributeWriteCallbackData& cbd){/*nop*/} + //- doubleImage + void read_doubleImage_callback(yat4tango::DynamicAttributeReadCallbackData& cbd); + void write_doubleImage_callback(yat4tango::DynamicAttributeWriteCallbackData& cbd); + //- currentRecordedFrame + void read_currentRecordedFrame_callback(yat4tango::DynamicAttributeReadCallbackData& cbd); + //- forcedFIFOMode + void read_forcedFIFOMode_callback(yat4tango::DynamicAttributeReadCallbackData& cbd); + void write_forcedFIFOMode_callback(yat4tango::DynamicAttributeWriteCallbackData& cbd); + + //state & status stuff + // return true if the device is correctly initialized in init_device + bool is_device_initialized() {return m_is_device_initialized;}; + bool m_is_device_initialized; + stringstream m_status_message; + //lima OBJECTS + lima::Pco::Interface* m_hw; + lima::CtControl* m_ct; + lima::Pco::Camera* m_camera; + + std::string m_pixel_scan_rate; //pixel scan rate (SLOW, FAST) + std::string m_shutter_mode; //shutter mode name (GLOBAL, ROLLING) + Tango::DevString m_dev_string_val; + map m_map_scan_rate_frequencies; + + //- yat4tango Dynamic Interface Manager + yat4tango::DynamicInterfaceManager m_dim; + }; + +} // namespace_ns + +/////////////////////////////////////////////////////////////////////////////// +//// INCLUDE TEMPLATE IMPLEMENTAION +/////////////////////////////////////////////////////////////////////////////// +#include "Pco.hpp" + +#endif // _PCO_H diff --git a/specifics/Pco/PcoClass.cpp b/specifics/Pco/PcoClass.cpp index 430c541d..b885517f 100755 --- a/specifics/Pco/PcoClass.cpp +++ b/specifics/Pco/PcoClass.cpp @@ -1,554 +1,571 @@ -static const char *ClassId = "$Id: $"; -static const char *TagName = "$Name: $"; -static const char *CvsPath = "$Source: $"; -static const char *SvnPath = "$HeadURL: $"; -static const char *HttpServer = "http://www.esrf.fr/computing/cs/tango/tango_doc/ds_doc/"; -//+============================================================================= -// -// file : PcoClass.cpp -// -// description : C++ source for the PcoClass. A singleton -// class derived from DeviceClass. It implements the -// command list and all properties and methods required -// by the Pco once per process. -// -// project : TANGO Device Server -// -// $Author: $ -// -// $Revision: $ -// -// $Log: $ -// -// copyleft : European Synchrotron Radiation Facility -// BP 220, Grenoble 38043 -// FRANCE -// -//-============================================================================= -// -// This file is generated by POGO -// (Program Obviously used to Generate tango Object) -// -// (c) - Software Engineering Group - ESRF -//============================================================================= - - -#include - -#include "Pco.h" -#include - - -//+---------------------------------------------------------------------------- -/** - * Create PcoClass singleton and return it in a C function for Python usage - */ -//+---------------------------------------------------------------------------- -extern "C" { -#ifdef WIN32 - -__declspec(dllexport) - -#endif - - Tango::DeviceClass *_create_Pco_class(const char *name) { - return Pco_ns::PcoClass::init(name); - } -} - - -namespace Pco_ns -{ - - -//+---------------------------------------------------------------------------- -// -// method : GetCamInfoCmd::execute() -// -// description : method to trigger the execution of the command. -// PLEASE DO NOT MODIFY this method core without pogo -// -// in : - device : The device on which the command must be executed -// - in_any : The command input data -// -// returns : The command output data (packed in the Any object) -// -//----------------------------------------------------------------------------- -CORBA::Any *GetCamInfoCmd::execute(Tango::DeviceImpl *device,const CORBA::Any &in_any) -{ - - cout2 << "GetCamInfoCmd::execute(): arrived" << endl; - - return insert((static_cast(device))->get_cam_info()); -} - - -//+---------------------------------------------------------------------------- -// -// method : TalkCmd::execute() -// -// description : method to trigger the execution of the command. -// PLEASE DO NOT MODIFY this method core without pogo -// -// in : - device : The device on which the command must be executed -// - in_any : The command input data -// -// returns : The command output data (packed in the Any object) -// -//----------------------------------------------------------------------------- -CORBA::Any *TalkCmd::execute(Tango::DeviceImpl *device,const CORBA::Any &in_any) -{ - - cout2 << "TalkCmd::execute(): arrived" << endl; - - Tango::DevString argin; - extract(in_any, argin); - - return insert((static_cast(device))->talk(argin)); -} - - - - -// -//---------------------------------------------------------------- -// Initialize pointer for singleton pattern -//---------------------------------------------------------------- -// -PcoClass *PcoClass::_instance = NULL; - -//+---------------------------------------------------------------------------- -// -// method : PcoClass::PcoClass(string &s) -// -// description : constructor for the PcoClass -// -// in : - s : The class name -// -//----------------------------------------------------------------------------- -PcoClass::PcoClass(string &s):DeviceClass(s) -{ - - cout2 << "Entering PcoClass constructor" << endl; - set_default_property(); - get_class_property(); - write_class_property(); - - cout2 << "Leaving PcoClass constructor" << endl; - -} -//+---------------------------------------------------------------------------- -// -// method : PcoClass::~PcoClass() -// -// description : destructor for the PcoClass -// -//----------------------------------------------------------------------------- -PcoClass::~PcoClass() -{ - _instance = NULL; -} - -//+---------------------------------------------------------------------------- -// -// method : PcoClass::instance -// -// description : Create the object if not already done. Otherwise, just -// return a pointer to the object -// -// in : - name : The class name -// -//----------------------------------------------------------------------------- -PcoClass *PcoClass::init(const char *name) -{ - if (_instance == NULL) - { - try - { - string s(name); - _instance = new PcoClass(s); - } - catch (bad_alloc) - { - throw; - } - } - return _instance; -} - -PcoClass *PcoClass::instance() -{ - if (_instance == NULL) - { - cerr << "Class is not initialised !!" << endl; - exit(-1); - } - return _instance; -} - -//+---------------------------------------------------------------------------- -// -// method : PcoClass::command_factory -// -// description : Create the command object(s) and store them in the -// command list -// -//----------------------------------------------------------------------------- -void PcoClass::command_factory() -{ - command_list.push_back(new TalkCmd("Talk", - Tango::DEV_STRING, Tango::DEV_STRING, - "str argin", - "str argout", - Tango::EXPERT)); - command_list.push_back(new GetCamInfoCmd("GetCamInfo", - Tango::DEV_VOID, Tango::DEV_STRING, - "", - "cam infos", - Tango::OPERATOR)); - - // add polling if any - for (unsigned int i=0 ; ilength() ; i++) - { - cout4 << "Device name : " << (*devlist_ptr)[i].in() << endl; - - // Create devices and add it into the device list - //---------------------------------------------------- - device_list.push_back(new Pco(this, (*devlist_ptr)[i])); - - // Export device to the outside world - // Check before if database used. - //--------------------------------------------- - if ((Tango::Util::_UseDb == true) && (Tango::Util::_FileDb == false)) - export_device(device_list.back()); - else - export_device(device_list.back(), (*devlist_ptr)[i]); - } - // End of Automatic code generation - //------------------------------------------------------------- - -} -//+---------------------------------------------------------------------------- -// Method: PcoClass::attribute_factory(vector &att_list) -//----------------------------------------------------------------------------- -void PcoClass::attribute_factory(vector &att_list) -{ - // Attribute : pixelRate - pixelRateAttrib *pixel_rate = new pixelRateAttrib(); - Tango::UserDefaultAttrProp pixel_rate_prop; - pixel_rate_prop.set_label("Pixel Rate (Hz)"); - pixel_rate_prop.set_unit("Hz"); - pixel_rate_prop.set_description("Set / Get the Pixel Rate in Hz"); - pixel_rate->set_default_properties(pixel_rate_prop); - pixel_rate->set_memorized(); - pixel_rate->set_memorized_init(true); - att_list.push_back(pixel_rate); - - // Attribute : cameraModel - cameraModelAttrib *camera_model = new cameraModelAttrib(); - Tango::UserDefaultAttrProp camera_model_prop; - camera_model_prop.set_label("camera Model"); - camera_model_prop.set_description("Model of the camera"); - camera_model->set_default_properties(camera_model_prop); - att_list.push_back(camera_model); - - // Attribute : sensorTemperature - sensorTemperatureAttrib *sensor_temperature = new sensorTemperatureAttrib(); - Tango::UserDefaultAttrProp sensor_temperature_prop; - sensor_temperature_prop.set_label("sensor Temperature"); - sensor_temperature_prop.set_unit("deg C"); - sensor_temperature_prop.set_format("%6.2f"); - sensor_temperature_prop.set_description("image sensor temperature in degree"); - sensor_temperature->set_default_properties(sensor_temperature_prop); - att_list.push_back(sensor_temperature); - - // Attribute : dllVersion - dllVersionAttrib *dll_version = new dllVersionAttrib(); - Tango::UserDefaultAttrProp dll_version_prop; - dll_version_prop.set_label("dll Version"); - dll_version_prop.set_description("Version of the SC2_cam.dll "); - dll_version->set_default_properties(dll_version_prop); - dll_version->set_disp_level(Tango::EXPERT); - att_list.push_back(dll_version); - - // End of Automatic code generation - //------------------------------------------------------------- -} - -//+---------------------------------------------------------------------------- -// -// method : PcoClass::get_class_property() -// -// description : Read the class properties from database. -// -//----------------------------------------------------------------------------- -void PcoClass::get_class_property() -{ - // Initialize your default values here (if not done with POGO). - //------------------------------------------------------------------ - - // Read class properties from database.(Automatic code generation) - //------------------------------------------------------------------ - - // Call database and extract values - //-------------------------------------------- - if (Tango::Util::instance()->_UseDb==true) - get_db_class()->get_property(cl_prop); - Tango::DbDatum def_prop; - int i = -1; - - - // End of Automatic code generation - //------------------------------------------------------------------ - -} - -//+---------------------------------------------------------------------------- -// -// method : PcoClass::set_default_property -// -// description: Set default property (class and device) for wizard. -// For each property, add to wizard property name and description -// If default value has been set, add it to wizard property and -// store it in a DbDatum. -// -//----------------------------------------------------------------------------- -void PcoClass::set_default_property() -{ - string prop_name; - string prop_desc; - string prop_def; - - vector vect_data; - // Set Default Class Properties - // Set Default Device Properties - prop_name = "SerialNumber"; - prop_desc = "Serial Number of the camera: used to select camera if several connected to the same host"; - prop_def = "0"; - vect_data.clear(); - vect_data.push_back("0"); - 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 : PcoClass::write_class_property -// -// description : Set class description as property in database -// -//----------------------------------------------------------------------------- -void PcoClass::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("Device specific for Pco detector"); - 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 cvs or svn location - string filename(classname); - filename += "Class.cpp"; - - // Create a string with the class ID to - // get the string into the binary - string class_id(ClassId); - - // check for cvs information - string src_path(CvsPath); - start = src_path.find("/"); - if (start!=string::npos) - { - end = src_path.find(filename); - if (end>start) - { - string strloc = src_path.substr(start, end-start); - // Check if specific repository - start = strloc.find("/cvsroot/"); - if (start!=string::npos && start>0) - { - string repository = strloc.substr(0, start); - if (repository.find("/segfs/")!=string::npos) - strloc = "ESRF:" + strloc.substr(start, strloc.length()-start); - } - Tango::DbDatum cvs_loc("cvs_location"); - cvs_loc << strloc; - data.push_back(cvs_loc); - } - } - // check for svn information - else - { - string src_path(SvnPath); - start = src_path.find("://"); - if (start!=string::npos) - { - end = src_path.find(filename); - if (end>start) - { - header = "$HeadURL: "; - start = header.length(); - string strloc = src_path.substr(start, (end-start)); - - Tango::DbDatum svn_loc("svn_location"); - svn_loc << strloc; - data.push_back(svn_loc); - } - } - } - - // Get CVS or SVN revision tag - - // CVS tag - string tagname(TagName); - header = "$Name: "; - start = header.length(); - string endstr(" $"); - - end = tagname.find(endstr); - if (end!=string::npos && end>start) - { - string strtag = tagname.substr(start, end-start); - Tango::DbDatum cvs_tag("cvs_tag"); - cvs_tag << strtag; - data.push_back(cvs_tag); - } - - // SVN tag - string svnpath(SvnPath); - header = "$HeadURL: "; - start = header.length(); - - end = svnpath.find(endstr); - if (end!=string::npos && end>start) - { - string strloc = svnpath.substr(start, end-start); - - string tagstr ("/tags/"); - start = strloc.find(tagstr); - if ( start!=string::npos ) - { - start = start + tagstr.length(); - end = strloc.find(filename); - string strtag = strloc.substr(start, end-start-1); - - Tango::DbDatum svn_tag("svn_tag"); - svn_tag << strtag; - data.push_back(svn_tag); - } - } - - // Get URL location - string httpServ(HttpServer); - if (httpServ.length()>0) - { - Tango::DbDatum db_doc_url("doc_url"); - db_doc_url << httpServ; - data.push_back(db_doc_url); - } - - // Put inheritance - Tango::DbDatum inher_datum("InheritedFrom"); - vector inheritance; - inheritance.push_back("Device_4Impl"); - inher_datum << inheritance; - data.push_back(inher_datum); - - // Call database and and values - //-------------------------------------------- - get_db_class()->put_property(data); -} - -} // namespace +static const char *ClassId = "$Id: $"; +static const char *TagName = "$Name: $"; +static const char *CvsPath = "$Source: $"; +static const char *SvnPath = "$HeadURL: $"; +static const char *HttpServer = "http://www.esrf.fr/computing/cs/tango/tango_doc/ds_doc/"; +//+============================================================================= +// +// file : PcoClass.cpp +// +// description : C++ source for the PcoClass. A singleton +// class derived from DeviceClass. It implements the +// command list and all properties and methods required +// by the Pco once per process. +// +// project : TANGO Device Server +// +// $Author: $ +// +// $Revision: $ +// +// $Log: $ +// +// copyleft : European Synchrotron Radiation Facility +// BP 220, Grenoble 38043 +// FRANCE +// +//-============================================================================= +// +// This file is generated by POGO +// (Program Obviously used to Generate tango Object) +// +// (c) - Software Engineering Group - ESRF +//============================================================================= + + +#include + +#include "Pco.h" +#include + + +//+---------------------------------------------------------------------------- +/** + * Create PcoClass singleton and return it in a C function for Python usage + */ +//+---------------------------------------------------------------------------- +extern "C" { +#ifdef WIN32 + +__declspec(dllexport) + +#endif + + Tango::DeviceClass *_create_Pco_class(const char *name) { + return Pco_ns::PcoClass::init(name); + } +} + + +namespace Pco_ns +{ + + +//+---------------------------------------------------------------------------- +// +// method : GetCamInfoCmd::execute() +// +// description : method to trigger the execution of the command. +// PLEASE DO NOT MODIFY this method core without pogo +// +// in : - device : The device on which the command must be executed +// - in_any : The command input data +// +// returns : The command output data (packed in the Any object) +// +//----------------------------------------------------------------------------- +CORBA::Any *GetCamInfoCmd::execute(Tango::DeviceImpl *device,const CORBA::Any &in_any) +{ + + cout2 << "GetCamInfoCmd::execute(): arrived" << endl; + + return insert((static_cast(device))->get_cam_info()); +} + + +//+---------------------------------------------------------------------------- +// +// method : TalkCmd::execute() +// +// description : method to trigger the execution of the command. +// PLEASE DO NOT MODIFY this method core without pogo +// +// in : - device : The device on which the command must be executed +// - in_any : The command input data +// +// returns : The command output data (packed in the Any object) +// +//----------------------------------------------------------------------------- +CORBA::Any *TalkCmd::execute(Tango::DeviceImpl *device,const CORBA::Any &in_any) +{ + + cout2 << "TalkCmd::execute(): arrived" << endl; + + Tango::DevString argin; + extract(in_any, argin); + + return insert((static_cast(device))->talk(argin)); +} + + + + +// +//---------------------------------------------------------------- +// Initialize pointer for singleton pattern +//---------------------------------------------------------------- +// +PcoClass *PcoClass::_instance = NULL; + +//+---------------------------------------------------------------------------- +// +// method : PcoClass::PcoClass(string &s) +// +// description : constructor for the PcoClass +// +// in : - s : The class name +// +//----------------------------------------------------------------------------- +PcoClass::PcoClass(string &s):DeviceClass(s) +{ + + cout2 << "Entering PcoClass constructor" << endl; + set_default_property(); + get_class_property(); + write_class_property(); + + cout2 << "Leaving PcoClass constructor" << endl; + +} +//+---------------------------------------------------------------------------- +// +// method : PcoClass::~PcoClass() +// +// description : destructor for the PcoClass +// +//----------------------------------------------------------------------------- +PcoClass::~PcoClass() +{ + _instance = NULL; +} + +//+---------------------------------------------------------------------------- +// +// method : PcoClass::instance +// +// description : Create the object if not already done. Otherwise, just +// return a pointer to the object +// +// in : - name : The class name +// +//----------------------------------------------------------------------------- +PcoClass *PcoClass::init(const char *name) +{ + if (_instance == NULL) + { + try + { + string s(name); + _instance = new PcoClass(s); + } + catch (bad_alloc) + { + throw; + } + } + return _instance; +} + +PcoClass *PcoClass::instance() +{ + if (_instance == NULL) + { + cerr << "Class is not initialised !!" << endl; + exit(-1); + } + return _instance; +} + +//+---------------------------------------------------------------------------- +// +// method : PcoClass::command_factory +// +// description : Create the command object(s) and store them in the +// command list +// +//----------------------------------------------------------------------------- +void PcoClass::command_factory() +{ + command_list.push_back(new TalkCmd("Talk", + Tango::DEV_STRING, Tango::DEV_STRING, + "str argin", + "str argout", + Tango::EXPERT)); + command_list.push_back(new GetCamInfoCmd("GetCamInfo", + Tango::DEV_VOID, Tango::DEV_STRING, + "", + "cam infos", + Tango::OPERATOR)); + + // add polling if any + for (unsigned int i=0 ; ilength() ; i++) + { + cout4 << "Device name : " << (*devlist_ptr)[i].in() << endl; + + // Create devices and add it into the device list + //---------------------------------------------------- + device_list.push_back(new Pco(this, (*devlist_ptr)[i])); + + // Export device to the outside world + // Check before if database used. + //--------------------------------------------- + if ((Tango::Util::_UseDb == true) && (Tango::Util::_FileDb == false)) + export_device(device_list.back()); + else + export_device(device_list.back(), (*devlist_ptr)[i]); + } + // End of Automatic code generation + //------------------------------------------------------------- + +} +//+---------------------------------------------------------------------------- +// Method: PcoClass::attribute_factory(vector &att_list) +//----------------------------------------------------------------------------- +void PcoClass::attribute_factory(vector &att_list) +{ + // Attribute : pixelRate + pixelRateAttrib *pixel_rate = new pixelRateAttrib(); + Tango::UserDefaultAttrProp pixel_rate_prop; + pixel_rate_prop.set_label("Pixel Rate (Hz)"); + pixel_rate_prop.set_unit("Hz"); + pixel_rate_prop.set_description("Set / Get the Pixel Rate in Hz"); + pixel_rate->set_default_properties(pixel_rate_prop); + pixel_rate->set_memorized(); + pixel_rate->set_memorized_init(true); + att_list.push_back(pixel_rate); + + // Attribute : cameraModel + cameraModelAttrib *camera_model = new cameraModelAttrib(); + Tango::UserDefaultAttrProp camera_model_prop; + camera_model_prop.set_label("camera Model"); + camera_model_prop.set_description("Model of the camera"); + camera_model->set_default_properties(camera_model_prop); + att_list.push_back(camera_model); + + // Attribute : sensorTemperature + sensorTemperatureAttrib *sensor_temperature = new sensorTemperatureAttrib(); + Tango::UserDefaultAttrProp sensor_temperature_prop; + sensor_temperature_prop.set_label("sensor Temperature"); + sensor_temperature_prop.set_unit("deg C"); + sensor_temperature_prop.set_format("%6.2f"); + sensor_temperature_prop.set_description("image sensor temperature in degree"); + sensor_temperature->set_default_properties(sensor_temperature_prop); + att_list.push_back(sensor_temperature); + + // Attribute : dllVersion + dllVersionAttrib *dll_version = new dllVersionAttrib(); + Tango::UserDefaultAttrProp dll_version_prop; + dll_version_prop.set_label("dll Version"); + dll_version_prop.set_description("Version of the SC2_cam.dll "); + dll_version->set_default_properties(dll_version_prop); + dll_version->set_disp_level(Tango::EXPERT); + att_list.push_back(dll_version); + + // Attribute : storageMode + storageModeAttrib *storage_mode = new storageModeAttrib(); + Tango::UserDefaultAttrProp storage_mode_prop; + storage_mode_prop.set_label("Storage Mode"); + storage_mode_prop.set_unit(""); + storage_mode_prop.set_description("Set/Get the storage mode. Values :\n RECORDER\n FIFO\n"); + storage_mode->set_default_properties(storage_mode_prop); + storage_mode->set_memorized(); + storage_mode->set_memorized_init(false); + att_list.push_back(storage_mode); + + // Attribute : ringBuffer + ringBufferAttrib *ring_buffer = new ringBufferAttrib(); + ring_buffer->set_memorized(); + ring_buffer->set_memorized_init(false); + att_list.push_back(ring_buffer); + + // End of Automatic code generation + //------------------------------------------------------------- +} + +//+---------------------------------------------------------------------------- +// +// method : PcoClass::get_class_property() +// +// description : Read the class properties from database. +// +//----------------------------------------------------------------------------- +void PcoClass::get_class_property() +{ + // Initialize your default values here (if not done with POGO). + //------------------------------------------------------------------ + + // Read class properties from database.(Automatic code generation) + //------------------------------------------------------------------ + + // Call database and extract values + //-------------------------------------------- + if (Tango::Util::instance()->_UseDb==true) + get_db_class()->get_property(cl_prop); + Tango::DbDatum def_prop; + int i = -1; + + + // End of Automatic code generation + //------------------------------------------------------------------ + +} + +//+---------------------------------------------------------------------------- +// +// method : PcoClass::set_default_property +// +// description: Set default property (class and device) for wizard. +// For each property, add to wizard property name and description +// If default value has been set, add it to wizard property and +// store it in a DbDatum. +// +//----------------------------------------------------------------------------- +void PcoClass::set_default_property() +{ + string prop_name; + string prop_desc; + string prop_def; + + vector vect_data; + // Set Default Class Properties + // Set Default Device Properties + prop_name = "SerialNumber"; + prop_desc = "Serial Number of the camera: used to select camera if several connected to the same host"; + prop_def = "0"; + vect_data.clear(); + vect_data.push_back("0"); + 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 : PcoClass::write_class_property +// +// description : Set class description as property in database +// +//----------------------------------------------------------------------------- +void PcoClass::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("Device specific for Pco detector"); + 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 cvs or svn location + string filename(classname); + filename += "Class.cpp"; + + // Create a string with the class ID to + // get the string into the binary + string class_id(ClassId); + + // check for cvs information + string src_path(CvsPath); + start = src_path.find("/"); + if (start!=string::npos) + { + end = src_path.find(filename); + if (end>start) + { + string strloc = src_path.substr(start, end-start); + // Check if specific repository + start = strloc.find("/cvsroot/"); + if (start!=string::npos && start>0) + { + string repository = strloc.substr(0, start); + if (repository.find("/segfs/")!=string::npos) + strloc = "ESRF:" + strloc.substr(start, strloc.length()-start); + } + Tango::DbDatum cvs_loc("cvs_location"); + cvs_loc << strloc; + data.push_back(cvs_loc); + } + } + // check for svn information + else + { + string src_path(SvnPath); + start = src_path.find("://"); + if (start!=string::npos) + { + end = src_path.find(filename); + if (end>start) + { + header = "$HeadURL: "; + start = header.length(); + string strloc = src_path.substr(start, (end-start)); + + Tango::DbDatum svn_loc("svn_location"); + svn_loc << strloc; + data.push_back(svn_loc); + } + } + } + + // Get CVS or SVN revision tag + + // CVS tag + string tagname(TagName); + header = "$Name: "; + start = header.length(); + string endstr(" $"); + + end = tagname.find(endstr); + if (end!=string::npos && end>start) + { + string strtag = tagname.substr(start, end-start); + Tango::DbDatum cvs_tag("cvs_tag"); + cvs_tag << strtag; + data.push_back(cvs_tag); + } + + // SVN tag + string svnpath(SvnPath); + header = "$HeadURL: "; + start = header.length(); + + end = svnpath.find(endstr); + if (end!=string::npos && end>start) + { + string strloc = svnpath.substr(start, end-start); + + string tagstr ("/tags/"); + start = strloc.find(tagstr); + if ( start!=string::npos ) + { + start = start + tagstr.length(); + end = strloc.find(filename); + string strtag = strloc.substr(start, end-start-1); + + Tango::DbDatum svn_tag("svn_tag"); + svn_tag << strtag; + data.push_back(svn_tag); + } + } + + // Get URL location + string httpServ(HttpServer); + if (httpServ.length()>0) + { + Tango::DbDatum db_doc_url("doc_url"); + db_doc_url << httpServ; + data.push_back(db_doc_url); + } + + // Put inheritance + Tango::DbDatum inher_datum("InheritedFrom"); + vector inheritance; + inheritance.push_back("Device_4Impl"); + inher_datum << inheritance; + data.push_back(inher_datum); + + // Call database and and values + //-------------------------------------------- + get_db_class()->put_property(data); +} + +} // namespace diff --git a/specifics/Pco/PcoClass.h b/specifics/Pco/PcoClass.h index f52f660a..ae4ca4cc 100644 --- a/specifics/Pco/PcoClass.h +++ b/specifics/Pco/PcoClass.h @@ -1,197 +1,225 @@ -//============================================================================= -// -// file : PcoClass.h -// -// description : Include for the PcoClass root class. -// This class is the singleton class for -// the Pco device class. -// It contains all properties and methods which the -// Pco requires only once e.g. the commands. -// -// project : TANGO Device Server -// -// $Author: $ -// -// $Revision: $ -// $Date: $ -// -// SVN only: -// $HeadURL: $ -// -// CVS only: -// $Source: $ -// $Log: $ -// -// copyleft : European Synchrotron Radiation Facility -// BP 220, Grenoble 38043 -// FRANCE -// -//============================================================================= -// -// This file is generated by POGO -// (Program Obviously used to Generate tango Object) -// -// (c) - Software Engineering Group - ESRF -//============================================================================= - -#ifndef _PCOCLASS_H -#define _PCOCLASS_H - -#include -#include -#include "Pco.h" - - -namespace Pco_ns -{//===================================== -// Define classes for attributes -//===================================== -class dllVersionAttrib: public Tango::Attr -{ -public: - dllVersionAttrib():Attr("dllVersion", Tango::DEV_STRING, Tango::READ) {}; - ~dllVersionAttrib() {}; - - virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att) - {(static_cast(dev))->read_dllVersion(att);} - virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty) - {return (static_cast(dev))->is_dllVersion_allowed(ty);} -}; - -class sensorTemperatureAttrib: public Tango::Attr -{ -public: - sensorTemperatureAttrib():Attr("sensorTemperature", Tango::DEV_FLOAT, Tango::READ) {}; - ~sensorTemperatureAttrib() {}; - - virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att) - {(static_cast(dev))->read_sensorTemperature(att);} - virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty) - {return (static_cast(dev))->is_sensorTemperature_allowed(ty);} -}; - -class cameraModelAttrib: public Tango::Attr -{ -public: - cameraModelAttrib():Attr("cameraModel", Tango::DEV_STRING, Tango::READ) {}; - ~cameraModelAttrib() {}; - - virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att) - {(static_cast(dev))->read_cameraModel(att);} - virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty) - {return (static_cast(dev))->is_cameraModel_allowed(ty);} -}; - -class pixelRateAttrib: public Tango::Attr -{ -public: - pixelRateAttrib():Attr("pixelRate", Tango::DEV_STRING, Tango::READ_WRITE) {}; - ~pixelRateAttrib() {}; - - virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att) - {(static_cast(dev))->read_pixelRate(att);} - virtual void write(Tango::DeviceImpl *dev,Tango::WAttribute &att) - {(static_cast(dev))->write_pixelRate(att);} - virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty) - {return (static_cast(dev))->is_pixelRate_allowed(ty);} -}; - -//========================================= -// Define classes for commands -//========================================= -class GetCamInfoCmd : public Tango::Command -{ -public: - GetCamInfoCmd(const char *name, - Tango::CmdArgType in, - Tango::CmdArgType out, - const char *in_desc, - const char *out_desc, - Tango::DispLevel level) - :Command(name,in,out,in_desc,out_desc, level) {}; - - GetCamInfoCmd(const char *name, - Tango::CmdArgType in, - Tango::CmdArgType out) - :Command(name,in,out) {}; - ~GetCamInfoCmd() {}; - - virtual CORBA::Any *execute (Tango::DeviceImpl *dev, const CORBA::Any &any); - virtual bool is_allowed (Tango::DeviceImpl *dev, const CORBA::Any &any) - {return (static_cast(dev))->is_GetCamInfo_allowed(any);} -}; - - - -class TalkCmd : public Tango::Command -{ -public: - TalkCmd(const char *name, - Tango::CmdArgType in, - Tango::CmdArgType out, - const char *in_desc, - const char *out_desc, - Tango::DispLevel level) - :Command(name,in,out,in_desc,out_desc, level) {}; - - TalkCmd(const char *name, - Tango::CmdArgType in, - Tango::CmdArgType out) - :Command(name,in,out) {}; - ~TalkCmd() {}; - - virtual CORBA::Any *execute (Tango::DeviceImpl *dev, const CORBA::Any &any); - virtual bool is_allowed (Tango::DeviceImpl *dev, const CORBA::Any &any) - {return (static_cast(dev))->is_Talk_allowed(any);} -}; - - - -// -// The PcoClass singleton definition -// - -class -#ifdef WIN32 - __declspec(dllexport) -#endif - PcoClass : public Tango::DeviceClass -{ -public: -// properties member data - -// add your own data members here -//------------------------------------ - -public: - Tango::DbData cl_prop; - Tango::DbData cl_def_prop; - Tango::DbData dev_def_prop; - -// Method prototypes - static PcoClass *init(const char *); - static PcoClass *instance(); - ~PcoClass(); - Tango::DbDatum get_class_property(string &); - Tango::DbDatum get_default_device_property(string &); - Tango::DbDatum get_default_class_property(string &); - -protected: - PcoClass(string &); - static PcoClass *_instance; - void command_factory(); - void get_class_property(); - void attribute_factory(vector &); - void write_class_property(); - void set_default_property(); - string get_cvstag(); - string get_cvsroot(); - -private: - void device_factory(const Tango::DevVarStringArray *); -}; - - -} // namespace Pco_ns - -#endif // _PCOCLASS_H +//============================================================================= +// +// file : PcoClass.h +// +// description : Include for the PcoClass root class. +// This class is the singleton class for +// the Pco device class. +// It contains all properties and methods which the +// Pco requires only once e.g. the commands. +// +// project : TANGO Device Server +// +// $Author: $ +// +// $Revision: $ +// $Date: $ +// +// SVN only: +// $HeadURL: $ +// +// CVS only: +// $Source: $ +// $Log: $ +// +// copyleft : European Synchrotron Radiation Facility +// BP 220, Grenoble 38043 +// FRANCE +// +//============================================================================= +// +// This file is generated by POGO +// (Program Obviously used to Generate tango Object) +// +// (c) - Software Engineering Group - ESRF +//============================================================================= + +#ifndef _PCOCLASS_H +#define _PCOCLASS_H + +#include +#include +#include "Pco.h" + + +namespace Pco_ns +{//===================================== +// Define classes for attributes +//===================================== +class ringBufferAttrib: public Tango::Attr +{ +public: + ringBufferAttrib():Attr("ringBuffer", Tango::DEV_BOOLEAN, Tango::READ_WRITE) {}; + ~ringBufferAttrib() {}; + + virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att) + {(static_cast(dev))->read_ringBuffer(att);} + virtual void write(Tango::DeviceImpl *dev,Tango::WAttribute &att) + {(static_cast(dev))->write_ringBuffer(att);} + virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty) + {return (static_cast(dev))->is_ringBuffer_allowed(ty);} +}; + +class storageModeAttrib: public Tango::Attr +{ +public: + storageModeAttrib():Attr("storageMode", Tango::DEV_STRING, Tango::READ_WRITE) {}; + ~storageModeAttrib() {}; + + virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att) + {(static_cast(dev))->read_storageMode(att);} + virtual void write(Tango::DeviceImpl *dev,Tango::WAttribute &att) + {(static_cast(dev))->write_storageMode(att);} + virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty) + {return (static_cast(dev))->is_storageMode_allowed(ty);} +}; + +class dllVersionAttrib: public Tango::Attr +{ +public: + dllVersionAttrib():Attr("dllVersion", Tango::DEV_STRING, Tango::READ) {}; + ~dllVersionAttrib() {}; + + virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att) + {(static_cast(dev))->read_dllVersion(att);} + virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty) + {return (static_cast(dev))->is_dllVersion_allowed(ty);} +}; + +class sensorTemperatureAttrib: public Tango::Attr +{ +public: + sensorTemperatureAttrib():Attr("sensorTemperature", Tango::DEV_FLOAT, Tango::READ) {}; + ~sensorTemperatureAttrib() {}; + + virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att) + {(static_cast(dev))->read_sensorTemperature(att);} + virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty) + {return (static_cast(dev))->is_sensorTemperature_allowed(ty);} +}; + +class cameraModelAttrib: public Tango::Attr +{ +public: + cameraModelAttrib():Attr("cameraModel", Tango::DEV_STRING, Tango::READ) {}; + ~cameraModelAttrib() {}; + + virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att) + {(static_cast(dev))->read_cameraModel(att);} + virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty) + {return (static_cast(dev))->is_cameraModel_allowed(ty);} +}; + +class pixelRateAttrib: public Tango::Attr +{ +public: + pixelRateAttrib():Attr("pixelRate", Tango::DEV_STRING, Tango::READ_WRITE) {}; + ~pixelRateAttrib() {}; + + virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att) + {(static_cast(dev))->read_pixelRate(att);} + virtual void write(Tango::DeviceImpl *dev,Tango::WAttribute &att) + {(static_cast(dev))->write_pixelRate(att);} + virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty) + {return (static_cast(dev))->is_pixelRate_allowed(ty);} +}; + +//========================================= +// Define classes for commands +//========================================= +class GetCamInfoCmd : public Tango::Command +{ +public: + GetCamInfoCmd(const char *name, + Tango::CmdArgType in, + Tango::CmdArgType out, + const char *in_desc, + const char *out_desc, + Tango::DispLevel level) + :Command(name,in,out,in_desc,out_desc, level) {}; + + GetCamInfoCmd(const char *name, + Tango::CmdArgType in, + Tango::CmdArgType out) + :Command(name,in,out) {}; + ~GetCamInfoCmd() {}; + + virtual CORBA::Any *execute (Tango::DeviceImpl *dev, const CORBA::Any &any); + virtual bool is_allowed (Tango::DeviceImpl *dev, const CORBA::Any &any) + {return (static_cast(dev))->is_GetCamInfo_allowed(any);} +}; + + + +class TalkCmd : public Tango::Command +{ +public: + TalkCmd(const char *name, + Tango::CmdArgType in, + Tango::CmdArgType out, + const char *in_desc, + const char *out_desc, + Tango::DispLevel level) + :Command(name,in,out,in_desc,out_desc, level) {}; + + TalkCmd(const char *name, + Tango::CmdArgType in, + Tango::CmdArgType out) + :Command(name,in,out) {}; + ~TalkCmd() {}; + + virtual CORBA::Any *execute (Tango::DeviceImpl *dev, const CORBA::Any &any); + virtual bool is_allowed (Tango::DeviceImpl *dev, const CORBA::Any &any) + {return (static_cast(dev))->is_Talk_allowed(any);} +}; + + + +// +// The PcoClass singleton definition +// + +class +#ifdef WIN32 + __declspec(dllexport) +#endif + PcoClass : public Tango::DeviceClass +{ +public: +// properties member data + +// add your own data members here +//------------------------------------ + +public: + Tango::DbData cl_prop; + Tango::DbData cl_def_prop; + Tango::DbData dev_def_prop; + +// Method prototypes + static PcoClass *init(const char *); + static PcoClass *instance(); + ~PcoClass(); + Tango::DbDatum get_class_property(string &); + Tango::DbDatum get_default_device_property(string &); + Tango::DbDatum get_default_class_property(string &); + +protected: + PcoClass(string &); + static PcoClass *_instance; + void command_factory(); + void get_class_property(); + void attribute_factory(vector &); + void write_class_property(); + void set_default_property(); + string get_cvstag(); + string get_cvsroot(); + +private: + void device_factory(const Tango::DevVarStringArray *); +}; + + +} // namespace Pco_ns + +#endif // _PCOCLASS_H diff --git a/specifics/Pco/PcoStateMachine.cpp b/specifics/Pco/PcoStateMachine.cpp index 91b9f268..b3e05f39 100644 --- a/specifics/Pco/PcoStateMachine.cpp +++ b/specifics/Pco/PcoStateMachine.cpp @@ -1,192 +1,242 @@ -static const char *RcsId = "$Id $"; -//+============================================================================= -// -// file : PcoStateMachine.cpp -// -// description : C++ source for the Pco and its alowed -// methods for commands and attributes -// -// project : TANGO Device Server -// -// $Author: $ -// -// $Revision: $ -// $Date: $ -// -// SVN only: -// $HeadURL: $ -// -// CVS only: -// $Source: $ -// $Log: $ -// -// copyleft : European Synchrotron Radiation Facility -// BP 220, Grenoble 38043 -// FRANCE -// -//-============================================================================= -// -// This file is generated by POGO -// (Program Obviously used to Generate tango Object) -// -// (c) - Software Engineering Group - ESRF -//============================================================================= - -#include -#include "Pco.h" -#include - -/*==================================================================== - * This file contains the methods to allow commands and attributes - * read or write execution. - * - * If you wand to add your own code, add it between - * the "End/Re-Start of Generated Code" comments. - * - * If you want, you can also add your own methods. - *==================================================================== - */ - -namespace Pco_ns -{ - -//================================================= -// Attributes Allowed Methods -//================================================= - -//+---------------------------------------------------------------------------- -// -// method : Pco::is_cameraModel_allowed -// -// description : Read/Write allowed for cameraModel attribute. -// -//----------------------------------------------------------------------------- -bool Pco::is_cameraModel_allowed(Tango::AttReqType type) -{ - if (get_state() == Tango::INIT || - get_state() == Tango::FAULT || - get_state() == Tango::DISABLE || - get_state() == Tango::ON) - { - // End of Generated Code - - // Re-Start of Generated Code - return false; - } - return true; -} -//+---------------------------------------------------------------------------- -// -// method : Pco::is_dllVersion_allowed -// -// description : Read/Write allowed for dllVersion attribute. -// -//----------------------------------------------------------------------------- -bool Pco::is_dllVersion_allowed(Tango::AttReqType type) -{ - if (get_state() == Tango::INIT || - get_state() == Tango::FAULT || - get_state() == Tango::DISABLE || - get_state() == Tango::ON) - { - // End of Generated Code - - // Re-Start of Generated Code - return false; - } - return true; -} -//+---------------------------------------------------------------------------- -// -// method : Pco::is_pixelRate_allowed -// -// description : Read/Write allowed for pixelRate attribute. -// -//----------------------------------------------------------------------------- -bool Pco::is_pixelRate_allowed(Tango::AttReqType type) -{ - if (get_state() == Tango::INIT || - get_state() == Tango::FAULT || - get_state() == Tango::DISABLE || - get_state() == Tango::RUNNING) - { - // End of Generated Code - if (get_state() == Tango::RUNNING && type == Tango::READ_REQ) - { - return true; - } - - // Re-Start of Generated Code - return false; - } - return true; -} -//+---------------------------------------------------------------------------- -// -// method : Pco::is_sensorTemperature_allowed -// -// description : Read/Write allowed for sensorTemperature attribute. -// -//----------------------------------------------------------------------------- -bool Pco::is_sensorTemperature_allowed(Tango::AttReqType type) -{ - if (get_state() == Tango::INIT || - get_state() == Tango::DISABLE || - get_state() == Tango::FAULT) - { - // End of Generated Code - - // Re-Start of Generated Code - return false; - } - return true; -} - -//================================================= -// Commands Allowed Methods -//================================================= - -//+---------------------------------------------------------------------------- -// -// method : Pco::is_Talk_allowed -// -// description : Execution allowed for Talk command. -// -//----------------------------------------------------------------------------- -bool Pco::is_Talk_allowed(const CORBA::Any &any) -{ - if (get_state() == Tango::INIT || - get_state() == Tango::FAULT || - get_state() == Tango::DISABLE || - get_state() == Tango::RUNNING) - { - // End of Generated Code - - // Re-Start of Generated Code - return false; - } - return true; -} -//+---------------------------------------------------------------------------- -// -// method : Pco::is_GetCamInfo_allowed -// -// description : Execution allowed for GetCamInfo command. -// -//----------------------------------------------------------------------------- -bool Pco::is_GetCamInfo_allowed(const CORBA::Any &any) -{ - if (get_state() == Tango::INIT || - get_state() == Tango::FAULT || - get_state() == Tango::DISABLE || - get_state() == Tango::RUNNING) - { - // End of Generated Code - - // Re-Start of Generated Code - return false; - } - return true; -} - -} // namespace Pco_ns +static const char *RcsId = "$Id $"; +//+============================================================================= +// +// file : PcoStateMachine.cpp +// +// description : C++ source for the Pco and its alowed +// methods for commands and attributes +// +// project : TANGO Device Server +// +// $Author: $ +// +// $Revision: $ +// $Date: $ +// +// SVN only: +// $HeadURL: $ +// +// CVS only: +// $Source: $ +// $Log: $ +// +// copyleft : European Synchrotron Radiation Facility +// BP 220, Grenoble 38043 +// FRANCE +// +//-============================================================================= +// +// This file is generated by POGO +// (Program Obviously used to Generate tango Object) +// +// (c) - Software Engineering Group - ESRF +//============================================================================= + +#include +#include "Pco.h" +#include + +/*==================================================================== + * This file contains the methods to allow commands and attributes + * read or write execution. + * + * If you wand to add your own code, add it between + * the "End/Re-Start of Generated Code" comments. + * + * If you want, you can also add your own methods. + *==================================================================== + */ + +namespace Pco_ns +{ + +//================================================= +// Attributes Allowed Methods +//================================================= + +//+---------------------------------------------------------------------------- +// +// method : Pco::is_cameraModel_allowed +// +// description : Read/Write allowed for cameraModel attribute. +// +//----------------------------------------------------------------------------- +bool Pco::is_cameraModel_allowed(Tango::AttReqType type) +{ + if (get_state() == Tango::INIT || + get_state() == Tango::FAULT || + get_state() == Tango::DISABLE || + get_state() == Tango::ON) + { + // End of Generated Code + + // Re-Start of Generated Code + return false; + } + return true; +} +//+---------------------------------------------------------------------------- +// +// method : Pco::is_dllVersion_allowed +// +// description : Read/Write allowed for dllVersion attribute. +// +//----------------------------------------------------------------------------- +bool Pco::is_dllVersion_allowed(Tango::AttReqType type) +{ + if (get_state() == Tango::INIT || + get_state() == Tango::FAULT || + get_state() == Tango::DISABLE || + get_state() == Tango::ON) + { + // End of Generated Code + + // Re-Start of Generated Code + return false; + } + return true; +} +//+---------------------------------------------------------------------------- +// +// method : Pco::is_pixelRate_allowed +// +// description : Read/Write allowed for pixelRate attribute. +// +//----------------------------------------------------------------------------- +bool Pco::is_pixelRate_allowed(Tango::AttReqType type) +{ + if (get_state() == Tango::INIT || + get_state() == Tango::FAULT || + get_state() == Tango::DISABLE || + get_state() == Tango::RUNNING) + { + // End of Generated Code + if (get_state() == Tango::RUNNING && type == Tango::READ_REQ) + { + return true; + } + + // Re-Start of Generated Code + return false; + } + return true; +} +//+---------------------------------------------------------------------------- +// +// method : Pco::is_sensorTemperature_allowed +// +// description : Read/Write allowed for sensorTemperature attribute. +// +//----------------------------------------------------------------------------- +bool Pco::is_sensorTemperature_allowed(Tango::AttReqType type) +{ + if (get_state() == Tango::INIT || + get_state() == Tango::DISABLE || + get_state() == Tango::FAULT) + { + // End of Generated Code + + // Re-Start of Generated Code + return false; + } + return true; +} +//+---------------------------------------------------------------------------- +// +// method : Pco::is_storageMode_allowed +// +// description : Read/Write allowed for storageMode attribute. +// +//----------------------------------------------------------------------------- +bool Pco::is_storageMode_allowed(Tango::AttReqType type) +{ + if (get_state() == Tango::INIT || + get_state() == Tango::FAULT || + get_state() == Tango::DISABLE || + get_state() == Tango::RUNNING) + { + // End of Generated Code + if (get_state() == Tango::RUNNING && type == Tango::READ_REQ) + { + return true; + } + + // Re-Start of Generated Code + return false; + } + return true; +} +//+---------------------------------------------------------------------------- +// +// method : Pco::is_ringBuffer_allowed +// +// description : Read/Write allowed for ringBuffer attribute. +// +//----------------------------------------------------------------------------- +bool Pco::is_ringBuffer_allowed(Tango::AttReqType type) +{ + if (get_state() == Tango::INIT || + get_state() == Tango::FAULT || + get_state() == Tango::DISABLE || + get_state() == Tango::RUNNING) + { + // End of Generated Code + if (get_state() == Tango::RUNNING && type == Tango::READ_REQ) + { + return true; + } + + // Re-Start of Generated Code + return false; + } + return true; +} + +//================================================= +// Commands Allowed Methods +//================================================= + +//+---------------------------------------------------------------------------- +// +// method : Pco::is_Talk_allowed +// +// description : Execution allowed for Talk command. +// +//----------------------------------------------------------------------------- +bool Pco::is_Talk_allowed(const CORBA::Any &any) +{ + if (get_state() == Tango::INIT || + get_state() == Tango::FAULT || + get_state() == Tango::DISABLE || + get_state() == Tango::RUNNING) + { + // End of Generated Code + + // Re-Start of Generated Code + return false; + } + return true; +} +//+---------------------------------------------------------------------------- +// +// method : Pco::is_GetCamInfo_allowed +// +// description : Execution allowed for GetCamInfo command. +// +//----------------------------------------------------------------------------- +bool Pco::is_GetCamInfo_allowed(const CORBA::Any &any) +{ + if (get_state() == Tango::INIT || + get_state() == Tango::FAULT || + get_state() == Tango::DISABLE || + get_state() == Tango::RUNNING) + { + // End of Generated Code + + // Re-Start of Generated Code + return false; + } + return true; +} + +} // namespace Pco_ns