From a57c1581da4e195342a8920ff9e65ad3536a1677 Mon Sep 17 00:00:00 2001 From: System User <boissy@flyscan-el6-1.ica.synchrotron-soleil.fr> Date: Tue, 2 Aug 2022 14:01:38 +0200 Subject: [PATCH] Re-indentation of every files --- src/ADLinkContinuousAO.cpp | 24 +- src/ADLinkContinuousAO.h | 54 +- src/ContinuousAO.cpp | 2156 ++++++++++++++++++------------------ src/ContinuousAO.h | 562 +++++----- src/ContinuousAOClass.cpp | 1052 +++++++++--------- src/ContinuousAOClass.h | 136 +-- src/main.cpp | 6 +- 7 files changed, 1995 insertions(+), 1995 deletions(-) diff --git a/src/ADLinkContinuousAO.cpp b/src/ADLinkContinuousAO.cpp index 278c0af..6970a5f 100755 --- a/src/ADLinkContinuousAO.cpp +++ b/src/ADLinkContinuousAO.cpp @@ -7,12 +7,12 @@ //============================================================ //ADLinkContinuousAO::ADLinkContinuousAO //============================================================ -ADLinkContinuousAO::ADLinkContinuousAO (Tango::DeviceImpl* dev) - : Tango::LogAdapter(dev), - asl::ContinuousAO (), - err_ctr(0) + ADLinkContinuousAO::ADLinkContinuousAO (Tango::DeviceImpl* dev) +: Tango::LogAdapter(dev), + asl::ContinuousAO (), + err_ctr(0) { - + } //============================================================ //ADLinkContinuousAO::~ADLinkContinuousAO @@ -25,11 +25,11 @@ ADLinkContinuousAO::~ADLinkContinuousAO (void) //============================================================ void ADLinkContinuousAO::handle_error (const asl::DAQException& de) { - cout<<"error occured during acquisition"<<endl; - lock_data(); - err_ctr++; - unlock_data(); - _ASL_TO_TANGO_EXCEPTION(de, df); - ERROR_STREAM<<"error occured during acquisition"<<endl; - ERROR_STREAM<<df<<endl; + cout<<"error occured during acquisition"<<endl; + lock_data(); + err_ctr++; + unlock_data(); + _ASL_TO_TANGO_EXCEPTION(de, df); + ERROR_STREAM<<"error occured during acquisition"<<endl; + ERROR_STREAM<<df<<endl; } diff --git a/src/ADLinkContinuousAO.h b/src/ADLinkContinuousAO.h index 294ac6d..927b734 100755 --- a/src/ADLinkContinuousAO.h +++ b/src/ADLinkContinuousAO.h @@ -8,32 +8,32 @@ class ADLinkContinuousAO: public asl::ContinuousAO, public Tango::LogAdapter { - -public: - - ADLinkContinuousAO (Tango::DeviceImpl* dev); - virtual ~ADLinkContinuousAO (void) ; - /** - * Receive errors ocurring during the waveform generation. - * @param de The error - */ - virtual void handle_error (const asl::DAQException& de); - /** - * Get the mutex - */ - inline void lock_data(void) - { - data_lock_.acquire(); - }; - /** - * Release the mutex - */ - inline void unlock_data(void) - { - data_lock_.release(); - }; - unsigned long err_ctr; -private: - ACE_Thread_Mutex data_lock_; + + public: + + ADLinkContinuousAO (Tango::DeviceImpl* dev); + virtual ~ADLinkContinuousAO (void) ; + /** + * Receive errors ocurring during the waveform generation. + * @param de The error + */ + virtual void handle_error (const asl::DAQException& de); + /** + * Get the mutex + */ + inline void lock_data(void) + { + data_lock_.acquire(); + }; + /** + * Release the mutex + */ + inline void unlock_data(void) + { + data_lock_.release(); + }; + unsigned long err_ctr; + private: + ACE_Thread_Mutex data_lock_; }; #endif // _ADLinkContinuousAO_H diff --git a/src/ContinuousAO.cpp b/src/ContinuousAO.cpp index fad7822..d720ad4 100755 --- a/src/ContinuousAO.cpp +++ b/src/ContinuousAO.cpp @@ -65,1128 +65,1128 @@ static const char *RcsId = "$Header: /users/chaize/newsvn/cvsroot/InputOutput/AD namespace ContinuousAO { -//+---------------------------------------------------------------------------- -// -// method : ContinuousAO::ContinuousAO(string &s) -// -// description : constructor for simulated ContinuousAO -// -// in : - cl : Pointer to the DeviceClass object -// - s : Device name -// -//----------------------------------------------------------------------------- -ContinuousAO::ContinuousAO(Tango::DeviceClass *cl,string &s) : Tango::Device_2Impl(cl,s.c_str()), + //+---------------------------------------------------------------------------- + // + // method : ContinuousAO::ContinuousAO(string &s) + // + // description : constructor for simulated ContinuousAO + // + // in : - cl : Pointer to the DeviceClass object + // - s : Device name + // + //----------------------------------------------------------------------------- + ContinuousAO::ContinuousAO(Tango::DeviceClass *cl,string &s) : Tango::Device_2Impl(cl,s.c_str()), m_default_waveform(2, asl::AOScaledData(0)) -{ - init_device(); -} + { + init_device(); + } -ContinuousAO::ContinuousAO(Tango::DeviceClass *cl,const char *s) : Tango::Device_2Impl(cl,s), + ContinuousAO::ContinuousAO(Tango::DeviceClass *cl,const char *s) : Tango::Device_2Impl(cl,s), m_default_waveform(2, asl::AOScaledData(0)) -{ - init_device(); -} + { + init_device(); + } -ContinuousAO::ContinuousAO(Tango::DeviceClass *cl,const char *s,const char *d) : Tango::Device_2Impl(cl,s,d), + ContinuousAO::ContinuousAO(Tango::DeviceClass *cl,const char *s,const char *d) : Tango::Device_2Impl(cl,s,d), m_default_waveform(2, asl::AOScaledData(0)) -{ - init_device(); -} -//+---------------------------------------------------------------------------- -// -// method : ContinuousAO::delete_device() -// -// description : will be called at device destruction or at init command. -// -//----------------------------------------------------------------------------- -void ContinuousAO::delete_device() -{ - if(m_ao) { - delete m_ao; - m_ao = 0; + init_device(); } - - for (int i = 0; i < 8; i++) + //+---------------------------------------------------------------------------- + // + // method : ContinuousAO::delete_device() + // + // description : will be called at device destruction or at init command. + // + //----------------------------------------------------------------------------- + void ContinuousAO::delete_device() { - if (m_channel[i] != nullptr) + if(m_ao) { - delete m_channel[i]; - m_channel[i] = nullptr; + delete m_ao; + m_ao = 0; + } + + for (int i = 0; i < 8; i++) + { + if (m_channel[i] != nullptr) + { + delete m_channel[i]; + m_channel[i] = nullptr; + } } } -} -asl::AOScaledData ContinuousAO::assign_default_waveform(Tango::DevDouble p_ref, std::function <double(int, int)> p_lambda, int p_first_channel, int p_last_channel) -{ - // default waveform for group defined - asl::AOScaledData result = asl::AOScaledData(bufferDepth); - - double max_val; - - if(aORefSource == adl::external_reference) - max_val = p_ref; - else - max_val = 10.0; - - // fill buffer with a sin signal - for (unsigned long i = 0; i < bufferDepth; i++) + asl::AOScaledData ContinuousAO::assign_default_waveform(Tango::DevDouble p_ref, std::function <double(int, int)> p_lambda, int p_first_channel, int p_last_channel) { - (result)[i] = p_lambda(i, max_val); - } - - //Assignation of waveform for group - for (int i = p_first_channel; i <= p_last_channel; i++) - { - ACE_OS::memcpy(m_channel[i], result.base(), result.size()); + // default waveform for group defined + asl::AOScaledData result = asl::AOScaledData(bufferDepth); + + double max_val; + + if(aORefSource == adl::external_reference) + max_val = p_ref; + else + max_val = 10.0; + + // fill buffer with a sin signal + for (unsigned long i = 0; i < bufferDepth; i++) + { + (result)[i] = p_lambda(i, max_val); + } + + //Assignation of waveform for group + for (int i = p_first_channel; i <= p_last_channel; i++) + { + ACE_OS::memcpy(m_channel[i], result.base(), result.size()); + } + + return (result); } - - return (result); -} -void ContinuousAO::activate_channel(int p_channel_index, vector<double>& p_channel_wave_form, asl::AOScaledData& p_default_waveform) -{ - m_ac.id = p_channel_index; - if(aORefSource == adl::external_reference) - m_ac.volt_ref = aORefA; - m_config.add_active_channel(m_ac); - - if(p_channel_wave_form.empty()) + void ContinuousAO::activate_channel(int p_channel_index, vector<double>& p_channel_wave_form, asl::AOScaledData& p_default_waveform) { - WARN_STREAM<<"No waveform is saved in database for channel " << p_channel_index << ", using a default one"<<endl; - m_config.set_channel_periodic_data(p_channel_index, p_default_waveform); + m_ac.id = p_channel_index; + if(aORefSource == adl::external_reference) + m_ac.volt_ref = aORefA; + m_config.add_active_channel(m_ac); + + if(p_channel_wave_form.empty()) + { + WARN_STREAM<<"No waveform is saved in database for channel " << p_channel_index << ", using a default one"<<endl; + m_config.set_channel_periodic_data(p_channel_index, p_default_waveform); + } + else if(p_channel_wave_form.size() != bufferDepth) + { + WARN_STREAM<<"The waveform saved in database for channel " << p_channel_index << " has a different size from property BufferDepth, using default waveform"<<endl; + m_config.set_channel_periodic_data(p_channel_index, p_default_waveform); + } + else + { + asl::AOScaledData data(bufferDepth); + for(int i=0; i<bufferDepth; i++) + data[i] = p_channel_wave_form[i]; + // put the waveform in the configuration + m_config.set_channel_periodic_data(p_channel_index, data); + //cpy data in the attribute of the device + ::memcpy(m_channel[p_channel_index], data.base(), data.size()); + } } - else if(p_channel_wave_form.size() != bufferDepth) + + //+---------------------------------------------------------------------------- + // + // method : ContinuousAO::init_device() + // + // description : will be called at device initialization. + // + //----------------------------------------------------------------------------- + void ContinuousAO::init_device() { - WARN_STREAM<<"The waveform saved in database for channel " << p_channel_index << " has a different size from property BufferDepth, using default waveform"<<endl; - m_config.set_channel_periodic_data(p_channel_index, p_default_waveform); + INFO_STREAM << "ContinuousAO::ContinuousAO() create device " << device_name << endl; + + m_ao = nullptr; + + m_error_message = "An error has occured"; + + // Initialise variables to default values + //-------------------------------------------- + get_device_property(); + + //- create a continuous analog output daq + m_ao = new ADLinkContinuousAO(this); + + //- check memory allocation + if (m_ao == nullptr) + { + raise_error("ContinuousAO::init_device\nout of memory error while initializing ADLinkContinuousAO"); + return; + } + + asl::ContinuousAOConfig config; + + for (int i = 0; i < 8; i++) + { + m_channel[i] = new double[bufferDepth]; + if(m_channel[i] == nullptr) + { + raise_error("ContinuousAO::init_device\nout of memory error while initializing channel's datas"); + return; + } + } + + // default waveform for group A (channel 0 to 3) + m_default_waveform[0] = assign_default_waveform(aORefA, [&](int p_value, int p_max_value){ + return (::sin((double)p_value * 2. * 3.14159 / (double) bufferDepth) * p_max_value); + }, 0, 3); + + // default waveform for group A (channel 0 to 3) + m_default_waveform[1] = assign_default_waveform(aORefB, [&](int p_value, int p_max_value){ + if (p_value < bufferDepth/2) + return (p_max_value - 0.01); + else + return (-p_max_value + 0.01); + }, 4, 7); + + //--------------------------channels config------------------------------------ + asl::ActiveAOChannel ac; + + // configure all channels + ac.polarity = (adl::OutputPolarity)polarity; + ac.volt_ref_src = (adl::VoltageReferenceSource)aORefSource; + ac.volt_ref = 10.0; + + //------active/m_config. channel 0--------- + if(channel0Enable) + activate_channel(0, channel0Waveform, m_default_waveform[0]); + + //------active/m_config. channel 1--------- + if(channel1Enable) + activate_channel(1, channel1Waveform, m_default_waveform[0]); + + //------active/m_config. channel 2--------- + if(channel2Enable) + activate_channel(2, channel2Waveform, m_default_waveform[0]); + + //------active/m_config. channel 3--------- + if(channel3Enable) + activate_channel(3, channel3Waveform, m_default_waveform[0]); + + //------active/m_config. channel 4--------- + if(channel4Enable) + activate_channel(4, channel4Waveform, m_default_waveform[1]); + + //------active/m_config. channel 5--------- + if(channel5Enable) + activate_channel(5, channel5Waveform, m_default_waveform[1]); + + //------active/m_config. channel 6--------- + if(channel6Enable) + activate_channel(6, channel6Waveform, m_default_waveform[1]); + + //------active/m_config. channel 7--------- + if(channel7Enable) + activate_channel(7, channel7Waveform, m_default_waveform[1]); + + //--------------------------------start trigger config--------------------------------- + if(startTrigger) + { + config.set_trigger_source((adl::AIOTriggerSource)startTriggerSource); + config.set_trigger_mode(adl::ao_post); + if(startTriggerSource == adl::external_digital) + { + config.set_trigger_polarity((adl::AOTriggerPolarity)dTRIGPolarity); + } + else if(startTriggerSource == adl::external_analog) + { + config.set_analog_trigger_source(adl::analog_trigger_ext); + config.set_analog_trigger_condition((adl::AnalogTriggerCondition)aTRIGSelection); + unsigned short level; + if(aTRIGLevel>=0) + level = (aTRIGLevel / 0.078125) + 127; + else // v < 0 + level = (-aTRIGLevel / 0.078125); + //the voltage is converted in digital value (8 bits of resolution on EXTATRIG with +/-10 V (256/20 = 0.078125)) + config.set_analog_low_level_condition(level); + config.set_analog_high_level_condition(level); + } + } + //--------------------------------stop trigger config--------------------------------- + if(stopTrigger) + { + config.set_stop_mode(adl::wait_end_waveform); + config.set_stop_source ((adl::StopSource)stopTriggerSource); + } + + config.set_output_rate(frequency); + + DEBUG_STREAM<<"ContinuousAO::init_device : init acq"<<std::endl; + try{ + _ASL_TRY( + m_ao->init(adl::DAQ2502, boardNum), + "init", + "ContinuousAO::init_device" + ); + + DEBUG_STREAM<<"ContinuousAO::init_device : config acq"<<std::endl; + try{ + _ASL_TRY( + m_ao->configure(config), + "configure", + "ContinuousAO::init_device" + ); + } + catch (...) + { + raise_error("ContinuousAO::init_device\nError while configuring driver"); + return; + } + } + catch (...) + { + raise_error("ContinuousAO::init_device\nError while initializing the driver"); + return; + } + + //m_ao->configure(config); } - else + + + //+---------------------------------------------------------------------------- + // + // method : ContinuousAO::readDeviceProperies() + // + // description : Read the device properties from database. + // + //----------------------------------------------------------------------------- + void ContinuousAO::get_device_property() { - asl::AOScaledData data(bufferDepth); - for(int i=0; i<bufferDepth; i++) - data[i] = p_channel_wave_form[i]; - // put the waveform in the configuration - m_config.set_channel_periodic_data(p_channel_index, data); - //cpy data in the attribute of the device - ::memcpy(m_channel[p_channel_index], data.base(), data.size()); - } -} + // Initialize your default values here. + //------------------------------------------ + boardNum = 0; + frequency = 50000.0; //50 kHz -//+---------------------------------------------------------------------------- -// -// method : ContinuousAO::init_device() -// -// description : will be called at device initialization. -// -//----------------------------------------------------------------------------- -void ContinuousAO::init_device() -{ - INFO_STREAM << "ContinuousAO::ContinuousAO() create device " << device_name << endl; - - m_ao = nullptr; - - m_error_message = "An error has occured"; - - // Initialise variables to default values - //-------------------------------------------- - get_device_property(); - - //- create a continuous analog output daq - m_ao = new ADLinkContinuousAO(this); - - //- check memory allocation - if (m_ao == nullptr) - { - raise_error("ContinuousAO::init_device\nout of memory error while initializing ADLinkContinuousAO"); - return; - } - - asl::ContinuousAOConfig config; - - for (int i = 0; i < 8; i++) - { - m_channel[i] = new double[bufferDepth]; - if(m_channel[i] == nullptr) - { - raise_error("ContinuousAO::init_device\nout of memory error while initializing channel's datas"); - return; - } - } - - // default waveform for group A (channel 0 to 3) - m_default_waveform[0] = assign_default_waveform(aORefA, [&](int p_value, int p_max_value){ - return (::sin((double)p_value * 2. * 3.14159 / (double) bufferDepth) * p_max_value); - }, 0, 3); - - // default waveform for group A (channel 0 to 3) - m_default_waveform[1] = assign_default_waveform(aORefB, [&](int p_value, int p_max_value){ - if (p_value < bufferDepth/2) - return (p_max_value - 0.01); + startTrigger = 0; //no start trigger + stopTrigger = 0; //no stop trigger + + string default_start_source = "DTRIG"; + startTriggerSource = adl::external_digital; + + string default_stop_source = "AFI1"; + stopTriggerSource = adl::afi1_termination; + + string default_atrig_select = "BELOW"; + aTRIGSelection = adl::below_low_level; + + aTRIGLevel = 5.0; + + string default_dtrig_pol = "RISING"; + dTRIGPolarity = adl::ao_rising_edge ; + + aORefA = 10.0; + aORefB = 10.0; + + string default_pol = "BP"; + polarity = adl::bipolar; + + string default_aoref = "INTERN"; + aORefSource = adl::internal_reference; + + channel0Enable = true; + channel1Enable = false; + channel2Enable = false; + channel3Enable = false; + channel4Enable = false; + channel5Enable = false; + channel6Enable = false; + channel7Enable = false; + + bufferDepth = 4096; + + // Read device properties from database.(Automatic code generation) + //------------------------------------------------------------- + Tango::DbData data; + data.push_back(Tango::DbDatum("BoardNum")); + data.push_back(Tango::DbDatum("Frequency")); + data.push_back(Tango::DbDatum("StartTrigger")); + data.push_back(Tango::DbDatum("StopTrigger")); + data.push_back(Tango::DbDatum("StartTriggerSource")); + data.push_back(Tango::DbDatum("StopTriggerSource")); + data.push_back(Tango::DbDatum("ATRIGSelection")); + data.push_back(Tango::DbDatum("ATRIGLevel")); + data.push_back(Tango::DbDatum("DTRIGPolarity")); + data.push_back(Tango::DbDatum("AORefA")); + data.push_back(Tango::DbDatum("AORefB")); + data.push_back(Tango::DbDatum("Polarity")); + data.push_back(Tango::DbDatum("AORefSource")); + data.push_back(Tango::DbDatum("Channel0Enable")); + data.push_back(Tango::DbDatum("Channel1Enable")); + data.push_back(Tango::DbDatum("Channel2Enable")); + data.push_back(Tango::DbDatum("Channel3Enable")); + data.push_back(Tango::DbDatum("Channel4Enable")); + data.push_back(Tango::DbDatum("Channel5Enable")); + data.push_back(Tango::DbDatum("Channel6Enable")); + data.push_back(Tango::DbDatum("Channel7Enable")); + data.push_back(Tango::DbDatum("BufferDepth")); + data.push_back(Tango::DbDatum("Channel0Waveform")); + data.push_back(Tango::DbDatum("Channel1Waveform")); + data.push_back(Tango::DbDatum("Channel2Waveform")); + data.push_back(Tango::DbDatum("Channel3Waveform")); + data.push_back(Tango::DbDatum("Channel4Waveform")); + data.push_back(Tango::DbDatum("Channel5Waveform")); + data.push_back(Tango::DbDatum("Channel6Waveform")); + data.push_back(Tango::DbDatum("Channel7Waveform")); + + // Call database and extract values + //-------------------------------------------- + get_db_device()->get_property(data); + if (data[0].is_empty()==false) data[0] >> boardNum; + if (data[1].is_empty()==false) data[1] >> frequency; + if (data[2].is_empty()==false) data[2] >> startTrigger; + if (data[3].is_empty()==false) data[3] >> stopTrigger; + if (data[4].is_empty()==false) data[4] >> startTriggerSource; + if (data[5].is_empty()==false) data[5] >> stopTriggerSource; + if (data[6].is_empty()==false) data[6] >> aTRIGSelection; + if (data[7].is_empty()==false) data[7] >> aTRIGLevel; + if (data[8].is_empty()==false) data[8] >> dTRIGPolarity; + if (data[9].is_empty()==false) data[9] >> aORefA; + if (data[10].is_empty()==false) data[10] >> aORefB; + if (data[11].is_empty()==false) data[11] >> polarity; + if (data[12].is_empty()==false) data[12] >> aORefSource; + if (data[13].is_empty()==false) data[13] >> channel0Enable; + if (data[14].is_empty()==false) data[14] >> channel1Enable; + if (data[15].is_empty()==false) data[15] >> channel2Enable; + if (data[16].is_empty()==false) data[16] >> channel3Enable; + if (data[17].is_empty()==false) data[17] >> channel4Enable; + if (data[18].is_empty()==false) data[18] >> channel5Enable; + if (data[19].is_empty()==false) data[19] >> channel6Enable; + if (data[20].is_empty()==false) data[20] >> channel7Enable; + if (data[21].is_empty()==false) data[21] >> bufferDepth; + if (data[22].is_empty()==false) data[22] >> channel0Waveform; + if (data[23].is_empty()==false) data[23] >> channel1Waveform; + if (data[24].is_empty()==false) data[24] >> channel2Waveform; + if (data[25].is_empty()==false) data[25] >> channel3Waveform; + if (data[26].is_empty()==false) data[26] >> channel4Waveform; + if (data[27].is_empty()==false) data[27] >> channel5Waveform; + if (data[28].is_empty()==false) data[28] >> channel6Waveform; + if (data[29].is_empty()==false) data[29] >> channel7Waveform; + + + // End of Automatic code generation + //------------------------------------------------------------- + Tango::DbData data_put; + //------------------------------------------------------------- + if (data[0].is_empty()==false) + { + unsigned short bnum; + data[0] >> bnum; + //check value + if(bnum<0 || bnum>= 7)//num max of boards in chassis + { + WARN_STREAM<<"ContinuousAO::get_device_property: the value of BoardNum is invalid" + <<"using default value "<<boardNum<<endl; + } + else + { + boardNum = bnum; + } + } + else + { + Tango::DbDatum property("BoardNum"); + property << boardNum; + data_put.push_back(property); + WARN_STREAM<<"BoardNum property is not set in database, loading default value in database:" + <<boardNum<<endl; + } + //------------------------------------------------------------- + if (data[1].is_empty()==false) + { + data[1] >> frequency; + } else - return (-p_max_value + 0.01); - }, 4, 7); - - //--------------------------channels config------------------------------------ - asl::ActiveAOChannel ac; - - // configure all channels - ac.polarity = (adl::OutputPolarity)polarity; - ac.volt_ref_src = (adl::VoltageReferenceSource)aORefSource; - ac.volt_ref = 10.0; - - //------active/m_config. channel 0--------- - if(channel0Enable) - activate_channel(0, channel0Waveform, m_default_waveform[0]); - - //------active/m_config. channel 1--------- - if(channel1Enable) - activate_channel(1, channel1Waveform, m_default_waveform[0]); - - //------active/m_config. channel 2--------- - if(channel2Enable) - activate_channel(2, channel2Waveform, m_default_waveform[0]); - - //------active/m_config. channel 3--------- - if(channel3Enable) - activate_channel(3, channel3Waveform, m_default_waveform[0]); - - //------active/m_config. channel 4--------- - if(channel4Enable) - activate_channel(4, channel4Waveform, m_default_waveform[1]); - - //------active/m_config. channel 5--------- - if(channel5Enable) - activate_channel(5, channel5Waveform, m_default_waveform[1]); - - //------active/m_config. channel 6--------- - if(channel6Enable) - activate_channel(6, channel6Waveform, m_default_waveform[1]); - - //------active/m_config. channel 7--------- - if(channel7Enable) - activate_channel(7, channel7Waveform, m_default_waveform[1]); - - //--------------------------------start trigger config--------------------------------- - if(startTrigger) - { - config.set_trigger_source((adl::AIOTriggerSource)startTriggerSource); - config.set_trigger_mode(adl::ao_post); - if(startTriggerSource == adl::external_digital) - { - config.set_trigger_polarity((adl::AOTriggerPolarity)dTRIGPolarity); - } - else if(startTriggerSource == adl::external_analog) - { - config.set_analog_trigger_source(adl::analog_trigger_ext); - config.set_analog_trigger_condition((adl::AnalogTriggerCondition)aTRIGSelection); - unsigned short level; - if(aTRIGLevel>=0) - level = (aTRIGLevel / 0.078125) + 127; - else // v < 0 - level = (-aTRIGLevel / 0.078125); - //the voltage is converted in digital value (8 bits of resolution on EXTATRIG with +/-10 V (256/20 = 0.078125)) - config.set_analog_low_level_condition(level); - config.set_analog_high_level_condition(level); - } - } - //--------------------------------stop trigger config--------------------------------- - if(stopTrigger) - { - config.set_stop_mode(adl::wait_end_waveform); - config.set_stop_source ((adl::StopSource)stopTriggerSource); - } - - config.set_output_rate(frequency); - - DEBUG_STREAM<<"ContinuousAO::init_device : init acq"<<std::endl; - try{ - _ASL_TRY( - m_ao->init(adl::DAQ2502, boardNum), - "init", - "ContinuousAO::init_device" - ); - - DEBUG_STREAM<<"ContinuousAO::init_device : config acq"<<std::endl; - try{ - _ASL_TRY( - m_ao->configure(config), - "configure", - "ContinuousAO::init_device" - ); + { + Tango::DbDatum property("Frequency"); + property << frequency; + data_put.push_back(property); + WARN_STREAM<<"Frequency property is not set in database, loading default value in database:" + <<frequency<<endl; + } + //------------------------------------------------------------- + if (data[2].is_empty()==false) + { + data[2] >> startTrigger; + } + else + { + Tango::DbDatum property("StartTrigger"); + property << startTrigger; + data_put.push_back(property); + WARN_STREAM<<"StartTrigger property is not set in database, loading default value in database:" + <<startTrigger<<endl; + } + //------------------------------------------------------------- + if (data[3].is_empty()==false) + { + data[3] >> stopTrigger; + } + else + { + Tango::DbDatum property("StopTrigger"); + property << stopTrigger; + data_put.push_back(property); + WARN_STREAM<<"StopTrigger property is not set in database, loading default value in database:" + <<stopTrigger<<endl; + } + //------------------------------------------------------------- + if (data[4].is_empty()==false) + { + data[4] >> startTriggerSource; + string start_source; + data[4] >> start_source; + if(start_source == "DTRIG") + startTriggerSource = adl::external_digital; + else if(start_source == "ATRIG") + startTriggerSource = adl::external_analog; + else + WARN_STREAM<<"ContinuousAO::get_device_property: the value of StartTriggerSource is not valid" + <<"using default value "<<default_start_source<<endl; + } + else + { + Tango::DbDatum property("StartTriggerSource"); + property << default_start_source; + data_put.push_back(property); + WARN_STREAM<<"StartTriggerSource property is not set in database, loading default value in database:" + <<default_start_source<<endl; + } + //------------------------------------------------------------- + if (data[5].is_empty()==false) + { + string stop_source; + data[5] >> stop_source; + if(stop_source == "ATRIG") + stopTriggerSource = adl::analog_trigger_termination; + else if(stop_source == "AFI0") + stopTriggerSource = adl::afi0_termination; + else if(stop_source == "AFI1") + stopTriggerSource = adl::afi1_termination; + else + WARN_STREAM<<"ContinuousAO::get_device_property: the value of StopTriggerSource is not valid" + <<"using default value "<<default_stop_source<<endl; + } + else + { + Tango::DbDatum property("StopTriggerSource"); + property << default_stop_source; + data_put.push_back(property); + WARN_STREAM<<"StopTriggerSource property is not set in database, loading default value in database:" + <<default_stop_source<<endl; + } + //------------------------------------------------------------- + if (data[6].is_empty()==false) + { + string atrig_select; + data[6] >> atrig_select; + if(atrig_select == "BELOW") + aTRIGSelection = adl::below_low_level; + else if(atrig_select == "ABOVE") + aTRIGSelection = adl::above_high_level; + else + WARN_STREAM<<"ContinuousAO::get_device_property: the value of ATRIGSelection is not valid" + <<"using default value "<<default_atrig_select<<endl; + } + else + { + Tango::DbDatum property("ATRIGSelection"); + property << default_atrig_select; + data_put.push_back(property); + WARN_STREAM<<"ATRIGSelection property is not set in database, loading default value in database:" + <<default_atrig_select<<endl; + } + //------------------------------------------------------------- + if (data[7].is_empty()==false) + { + data[7] >> aTRIGLevel; + } + else + { + Tango::DbDatum property("ATRIGLevel"); + property << aTRIGLevel; + data_put.push_back(property); + WARN_STREAM<<"ATRIGLevel property is not set in database, loading default value in database:" + <<aTRIGLevel<<endl; + } + //------------------------------------------------------------- + if (data[8].is_empty()==false) + { + string dtrig_pol; + data[8] >> dtrig_pol; + if(dtrig_pol == "RISING") + dTRIGPolarity = adl::ao_rising_edge; + else if(dtrig_pol == "FALLING") + dTRIGPolarity = adl::ao_falling_edge; + else + WARN_STREAM<<"ContinuousAO::get_device_property: the value of DTRIGPolarity is not valid" + <<"using default value "<<default_dtrig_pol<<endl; + } + else + { + Tango::DbDatum property("DTRIGPolarity"); + property << default_dtrig_pol; + data_put.push_back(property); + WARN_STREAM<<"DTRIGPolarity property is not set in database, loading default value in database:" + <<default_dtrig_pol<<endl; + } + //------------------------------------------------------------- + if (data[9].is_empty()==false) + { + double ref; + data[9] >> ref; + if(ref >= -10.0 || ref <= 10.0) + aORefA = ref; + else + WARN_STREAM<<"ContinuousAO::get_device_property: the value of AORefA is not valid" + <<"using default value "<<aORefA<<endl; + } + else + { + Tango::DbDatum property("AORefA"); + property << aORefA; + data_put.push_back(property); + WARN_STREAM<<"AORefA property is not set in database, loading default value in database:" + <<aORefA<<endl; + } + //------------------------------------------------------------- + if (data[10].is_empty()==false) + { + double ref; + data[9] >> ref; + if(ref >= -10.0 || ref <= 10.0) + aORefB = ref; + else + WARN_STREAM<<"ContinuousAO::get_device_property: the value of AORefB is not valid" + <<"using default value "<<aORefB<<endl; + } + else + { + Tango::DbDatum property("AORefB"); + property << aORefB; + data_put.push_back(property); + WARN_STREAM<<"AORefB property is not set in database, loading default value in database:" + <<aORefB<<endl; + } + //------------------------------------------------------------- + if (data[11].is_empty()==false) + { + string pol; + data[11] >> pol; + if(pol == "BP") + polarity = adl::bipolar; + else if(pol == "UP") + polarity = adl::unipolar; + else + WARN_STREAM<<"ContinuousAO::get_device_property: the value of Polarity is not valid" + <<"using default value "<<default_pol<<endl; + } + else + { + Tango::DbDatum property("Polarity"); + property << default_pol; + data_put.push_back(property); + WARN_STREAM<<"Polarity property is not set in database, loading default value in database:" + <<default_pol<<endl; + } + //------------------------------------------------------------- + if (data[12].is_empty()==false) + { + string aoref; + data[12] >> aoref; + if(aoref == "INTERN") + aORefSource = adl::internal_reference; + else if(aoref == "EXTERN") + aORefSource = adl::external_reference; + else + WARN_STREAM<<"ContinuousAO::get_device_property: the value of AORefSource is not valid" + <<"using default value "<<default_aoref<<endl; + } + else + { + Tango::DbDatum property("AORefSource"); + property << default_aoref; + data_put.push_back(property); + WARN_STREAM<<"AORefSource property is not set in database, loading default value in database:" + <<default_aoref<<endl; + } + //------------------------------------------------------------- + if (data[13].is_empty()==false) + { + data[13] >> channel0Enable; + } + else + { + Tango::DbDatum property("Channel0Enable"); + property << channel0Enable; + data_put.push_back(property); + WARN_STREAM<<"Channel0Enable property is not set in database, loading default value in database:" + <<channel0Enable<<endl; + } + //------------------------------------------------------------- + if (data[14].is_empty()==false) + { + data[14] >> channel1Enable; + } + else + { + Tango::DbDatum property("Channel1Enable"); + property << channel1Enable; + data_put.push_back(property); + WARN_STREAM<<"Channel1Enable property is not set in database, loading default value in database:" + <<channel1Enable<<endl; + } + //------------------------------------------------------------- + if (data[15].is_empty()==false) + { + data[15] >> channel2Enable; + } + else + { + Tango::DbDatum property("Channel2Enable"); + property << channel2Enable; + data_put.push_back(property); + WARN_STREAM<<"Channel2Enable property is not set in database, loading default value in database:" + <<channel2Enable<<endl; + } + //------------------------------------------------------------- + if (data[16].is_empty()==false) + { + data[16] >> channel3Enable; + } + else + { + Tango::DbDatum property("Channel3Enable"); + property << channel3Enable; + data_put.push_back(property); + WARN_STREAM<<"Channel3Enable property is not set in database, loading default value in database:" + <<channel3Enable<<endl; + } + //------------------------------------------------------------- + if (data[17].is_empty()==false) + { + data[17] >> channel4Enable; + } + else + { + Tango::DbDatum property("Channel4Enable"); + property << channel4Enable; + data_put.push_back(property); + WARN_STREAM<<"Channel4Enable property is not set in database, loading default value in database:" + <<channel4Enable<<endl; + } + //------------------------------------------------------------- + if (data[18].is_empty()==false) + { + data[18] >> channel5Enable; + } + else + { + Tango::DbDatum property("Channel5Enable"); + property << channel5Enable; + data_put.push_back(property); + WARN_STREAM<<"Channel5Enable property is not set in database, loading default value in database:" + <<channel5Enable<<endl; + } + //------------------------------------------------------------- + if (data[19].is_empty()==false) + { + data[19] >> channel6Enable; + } + else + { + Tango::DbDatum property("Channel6Enable"); + property << channel6Enable; + data_put.push_back(property); + WARN_STREAM<<"Channel6Enable property is not set in database, loading default value in database:" + <<channel6Enable<<endl; + } + //------------------------------------------------------------- + if (data[20].is_empty()==false) + { + data[20] >> channel7Enable; + } + else + { + Tango::DbDatum property("Channel7Enable"); + property << channel7Enable; + data_put.push_back(property); + WARN_STREAM<<"Channel7Enable property is not set in database, loading default value in database:" + <<channel7Enable<<endl; + } + //------------------------------------------------------------- + if (data[21].is_empty()==false) + { + data[21] >> bufferDepth; + } + else + { + Tango::DbDatum property("BufferDepth"); + property << bufferDepth; + data_put.push_back(property); + WARN_STREAM<<"BufferDepth property is not set in database, loading default value in database:" + <<bufferDepth<<endl; + } + //update database for not initiliazed properties + get_db_device()->put_property(data_put); } - catch (...) + //+---------------------------------------------------------------------------- + // + // method : ContinuousAO::always_executed_hook() + // + // description : method always executed before any command is executed + // + //----------------------------------------------------------------------------- + void ContinuousAO::always_executed_hook() { - raise_error("ContinuousAO::init_device\nError while configuring driver"); - return; + set_internal_state(); } - } - catch (...) - { - raise_error("ContinuousAO::init_device\nError while initializing the driver"); - return; - } - //m_ao->configure(config); -} + //+---------------------------------------------------------------------------- + // + // method : ContinuousAO::read_attr_hardware() + // + // description : Hardware acquisition for attributes. + // + //----------------------------------------------------------------------------- + void ContinuousAO::read_attr_hardware(vector<long> &attr_list) + { + DEBUG_STREAM << "In read_attr_hardware for " << attr_list.size(); + DEBUG_STREAM << " attribute(s)" << endl; + // Add your own code here + //--------------------------------- + m_ao->lock_data(); -//+---------------------------------------------------------------------------- -// -// method : ContinuousAO::readDeviceProperies() -// -// description : Read the device properties from database. -// -//----------------------------------------------------------------------------- -void ContinuousAO::get_device_property() -{ - // Initialize your default values here. - //------------------------------------------ - boardNum = 0; - frequency = 50000.0; //50 kHz - - startTrigger = 0; //no start trigger - stopTrigger = 0; //no stop trigger - - string default_start_source = "DTRIG"; - startTriggerSource = adl::external_digital; - - string default_stop_source = "AFI1"; - stopTriggerSource = adl::afi1_termination; - - string default_atrig_select = "BELOW"; - aTRIGSelection = adl::below_low_level; - - aTRIGLevel = 5.0; - - string default_dtrig_pol = "RISING"; - dTRIGPolarity = adl::ao_rising_edge ; - - aORefA = 10.0; - aORefB = 10.0; - - string default_pol = "BP"; - polarity = adl::bipolar; - - string default_aoref = "INTERN"; - aORefSource = adl::internal_reference; - - channel0Enable = true; - channel1Enable = false; - channel2Enable = false; - channel3Enable = false; - channel4Enable = false; - channel5Enable = false; - channel6Enable = false; - channel7Enable = false; - - bufferDepth = 4096; - - // Read device properties from database.(Automatic code generation) - //------------------------------------------------------------- - Tango::DbData data; - data.push_back(Tango::DbDatum("BoardNum")); - data.push_back(Tango::DbDatum("Frequency")); - data.push_back(Tango::DbDatum("StartTrigger")); - data.push_back(Tango::DbDatum("StopTrigger")); - data.push_back(Tango::DbDatum("StartTriggerSource")); - data.push_back(Tango::DbDatum("StopTriggerSource")); - data.push_back(Tango::DbDatum("ATRIGSelection")); - data.push_back(Tango::DbDatum("ATRIGLevel")); - data.push_back(Tango::DbDatum("DTRIGPolarity")); - data.push_back(Tango::DbDatum("AORefA")); - data.push_back(Tango::DbDatum("AORefB")); - data.push_back(Tango::DbDatum("Polarity")); - data.push_back(Tango::DbDatum("AORefSource")); - data.push_back(Tango::DbDatum("Channel0Enable")); - data.push_back(Tango::DbDatum("Channel1Enable")); - data.push_back(Tango::DbDatum("Channel2Enable")); - data.push_back(Tango::DbDatum("Channel3Enable")); - data.push_back(Tango::DbDatum("Channel4Enable")); - data.push_back(Tango::DbDatum("Channel5Enable")); - data.push_back(Tango::DbDatum("Channel6Enable")); - data.push_back(Tango::DbDatum("Channel7Enable")); - data.push_back(Tango::DbDatum("BufferDepth")); - data.push_back(Tango::DbDatum("Channel0Waveform")); - data.push_back(Tango::DbDatum("Channel1Waveform")); - data.push_back(Tango::DbDatum("Channel2Waveform")); - data.push_back(Tango::DbDatum("Channel3Waveform")); - data.push_back(Tango::DbDatum("Channel4Waveform")); - data.push_back(Tango::DbDatum("Channel5Waveform")); - data.push_back(Tango::DbDatum("Channel6Waveform")); - data.push_back(Tango::DbDatum("Channel7Waveform")); - - // Call database and extract values - //-------------------------------------------- - get_db_device()->get_property(data); - if (data[0].is_empty()==false) data[0] >> boardNum; - if (data[1].is_empty()==false) data[1] >> frequency; - if (data[2].is_empty()==false) data[2] >> startTrigger; - if (data[3].is_empty()==false) data[3] >> stopTrigger; - if (data[4].is_empty()==false) data[4] >> startTriggerSource; - if (data[5].is_empty()==false) data[5] >> stopTriggerSource; - if (data[6].is_empty()==false) data[6] >> aTRIGSelection; - if (data[7].is_empty()==false) data[7] >> aTRIGLevel; - if (data[8].is_empty()==false) data[8] >> dTRIGPolarity; - if (data[9].is_empty()==false) data[9] >> aORefA; - if (data[10].is_empty()==false) data[10] >> aORefB; - if (data[11].is_empty()==false) data[11] >> polarity; - if (data[12].is_empty()==false) data[12] >> aORefSource; - if (data[13].is_empty()==false) data[13] >> channel0Enable; - if (data[14].is_empty()==false) data[14] >> channel1Enable; - if (data[15].is_empty()==false) data[15] >> channel2Enable; - if (data[16].is_empty()==false) data[16] >> channel3Enable; - if (data[17].is_empty()==false) data[17] >> channel4Enable; - if (data[18].is_empty()==false) data[18] >> channel5Enable; - if (data[19].is_empty()==false) data[19] >> channel6Enable; - if (data[20].is_empty()==false) data[20] >> channel7Enable; - if (data[21].is_empty()==false) data[21] >> bufferDepth; - if (data[22].is_empty()==false) data[22] >> channel0Waveform; - if (data[23].is_empty()==false) data[23] >> channel1Waveform; - if (data[24].is_empty()==false) data[24] >> channel2Waveform; - if (data[25].is_empty()==false) data[25] >> channel3Waveform; - if (data[26].is_empty()==false) data[26] >> channel4Waveform; - if (data[27].is_empty()==false) data[27] >> channel5Waveform; - if (data[28].is_empty()==false) data[28] >> channel6Waveform; - if (data[29].is_empty()==false) data[29] >> channel7Waveform; - - - // End of Automatic code generation - //------------------------------------------------------------- - Tango::DbData data_put; - //------------------------------------------------------------- - if (data[0].is_empty()==false) - { - unsigned short bnum; - data[0] >> bnum; - //check value - if(bnum<0 || bnum>= 7)//num max of boards in chassis - { - WARN_STREAM<<"ContinuousAO::get_device_property: the value of BoardNum is invalid" - <<"using default value "<<boardNum<<endl; - } - else - { - boardNum = bnum; - } - } - else - { - Tango::DbDatum property("BoardNum"); - property << boardNum; - data_put.push_back(property); - WARN_STREAM<<"BoardNum property is not set in database, loading default value in database:" - <<boardNum<<endl; - } - //------------------------------------------------------------- - if (data[1].is_empty()==false) - { - data[1] >> frequency; - } - else - { - Tango::DbDatum property("Frequency"); - property << frequency; - data_put.push_back(property); - WARN_STREAM<<"Frequency property is not set in database, loading default value in database:" - <<frequency<<endl; - } - //------------------------------------------------------------- - if (data[2].is_empty()==false) - { - data[2] >> startTrigger; - } - else - { - Tango::DbDatum property("StartTrigger"); - property << startTrigger; - data_put.push_back(property); - WARN_STREAM<<"StartTrigger property is not set in database, loading default value in database:" - <<startTrigger<<endl; - } - //------------------------------------------------------------- - if (data[3].is_empty()==false) - { - data[3] >> stopTrigger; - } - else - { - Tango::DbDatum property("StopTrigger"); - property << stopTrigger; - data_put.push_back(property); - WARN_STREAM<<"StopTrigger property is not set in database, loading default value in database:" - <<stopTrigger<<endl; - } - //------------------------------------------------------------- - if (data[4].is_empty()==false) - { - data[4] >> startTriggerSource; - string start_source; - data[4] >> start_source; - if(start_source == "DTRIG") - startTriggerSource = adl::external_digital; - else if(start_source == "ATRIG") - startTriggerSource = adl::external_analog; - else - WARN_STREAM<<"ContinuousAO::get_device_property: the value of StartTriggerSource is not valid" - <<"using default value "<<default_start_source<<endl; - } - else - { - Tango::DbDatum property("StartTriggerSource"); - property << default_start_source; - data_put.push_back(property); - WARN_STREAM<<"StartTriggerSource property is not set in database, loading default value in database:" - <<default_start_source<<endl; - } - //------------------------------------------------------------- - if (data[5].is_empty()==false) - { - string stop_source; - data[5] >> stop_source; - if(stop_source == "ATRIG") - stopTriggerSource = adl::analog_trigger_termination; - else if(stop_source == "AFI0") - stopTriggerSource = adl::afi0_termination; - else if(stop_source == "AFI1") - stopTriggerSource = adl::afi1_termination; - else - WARN_STREAM<<"ContinuousAO::get_device_property: the value of StopTriggerSource is not valid" - <<"using default value "<<default_stop_source<<endl; - } - else - { - Tango::DbDatum property("StopTriggerSource"); - property << default_stop_source; - data_put.push_back(property); - WARN_STREAM<<"StopTriggerSource property is not set in database, loading default value in database:" - <<default_stop_source<<endl; - } - //------------------------------------------------------------- - if (data[6].is_empty()==false) - { - string atrig_select; - data[6] >> atrig_select; - if(atrig_select == "BELOW") - aTRIGSelection = adl::below_low_level; - else if(atrig_select == "ABOVE") - aTRIGSelection = adl::above_high_level; - else - WARN_STREAM<<"ContinuousAO::get_device_property: the value of ATRIGSelection is not valid" - <<"using default value "<<default_atrig_select<<endl; - } - else - { - Tango::DbDatum property("ATRIGSelection"); - property << default_atrig_select; - data_put.push_back(property); - WARN_STREAM<<"ATRIGSelection property is not set in database, loading default value in database:" - <<default_atrig_select<<endl; - } - //------------------------------------------------------------- - if (data[7].is_empty()==false) - { - data[7] >> aTRIGLevel; - } - else - { - Tango::DbDatum property("ATRIGLevel"); - property << aTRIGLevel; - data_put.push_back(property); - WARN_STREAM<<"ATRIGLevel property is not set in database, loading default value in database:" - <<aTRIGLevel<<endl; - } - //------------------------------------------------------------- - if (data[8].is_empty()==false) - { - string dtrig_pol; - data[8] >> dtrig_pol; - if(dtrig_pol == "RISING") - dTRIGPolarity = adl::ao_rising_edge; - else if(dtrig_pol == "FALLING") - dTRIGPolarity = adl::ao_falling_edge; - else - WARN_STREAM<<"ContinuousAO::get_device_property: the value of DTRIGPolarity is not valid" - <<"using default value "<<default_dtrig_pol<<endl; - } - else - { - Tango::DbDatum property("DTRIGPolarity"); - property << default_dtrig_pol; - data_put.push_back(property); - WARN_STREAM<<"DTRIGPolarity property is not set in database, loading default value in database:" - <<default_dtrig_pol<<endl; - } - //------------------------------------------------------------- - if (data[9].is_empty()==false) - { - double ref; - data[9] >> ref; - if(ref >= -10.0 || ref <= 10.0) - aORefA = ref; - else - WARN_STREAM<<"ContinuousAO::get_device_property: the value of AORefA is not valid" - <<"using default value "<<aORefA<<endl; - } - else - { - Tango::DbDatum property("AORefA"); - property << aORefA; - data_put.push_back(property); - WARN_STREAM<<"AORefA property is not set in database, loading default value in database:" - <<aORefA<<endl; - } - //------------------------------------------------------------- - if (data[10].is_empty()==false) - { - double ref; - data[9] >> ref; - if(ref >= -10.0 || ref <= 10.0) - aORefB = ref; - else - WARN_STREAM<<"ContinuousAO::get_device_property: the value of AORefB is not valid" - <<"using default value "<<aORefB<<endl; - } - else - { - Tango::DbDatum property("AORefB"); - property << aORefB; - data_put.push_back(property); - WARN_STREAM<<"AORefB property is not set in database, loading default value in database:" - <<aORefB<<endl; - } - //------------------------------------------------------------- - if (data[11].is_empty()==false) - { - string pol; - data[11] >> pol; - if(pol == "BP") - polarity = adl::bipolar; - else if(pol == "UP") - polarity = adl::unipolar; - else - WARN_STREAM<<"ContinuousAO::get_device_property: the value of Polarity is not valid" - <<"using default value "<<default_pol<<endl; - } - else - { - Tango::DbDatum property("Polarity"); - property << default_pol; - data_put.push_back(property); - WARN_STREAM<<"Polarity property is not set in database, loading default value in database:" - <<default_pol<<endl; - } - //------------------------------------------------------------- - if (data[12].is_empty()==false) - { - string aoref; - data[12] >> aoref; - if(aoref == "INTERN") - aORefSource = adl::internal_reference; - else if(aoref == "EXTERN") - aORefSource = adl::external_reference; - else - WARN_STREAM<<"ContinuousAO::get_device_property: the value of AORefSource is not valid" - <<"using default value "<<default_aoref<<endl; - } - else - { - Tango::DbDatum property("AORefSource"); - property << default_aoref; - data_put.push_back(property); - WARN_STREAM<<"AORefSource property is not set in database, loading default value in database:" - <<default_aoref<<endl; - } - //------------------------------------------------------------- - if (data[13].is_empty()==false) - { - data[13] >> channel0Enable; - } - else - { - Tango::DbDatum property("Channel0Enable"); - property << channel0Enable; - data_put.push_back(property); - WARN_STREAM<<"Channel0Enable property is not set in database, loading default value in database:" - <<channel0Enable<<endl; - } - //------------------------------------------------------------- - if (data[14].is_empty()==false) - { - data[14] >> channel1Enable; - } - else - { - Tango::DbDatum property("Channel1Enable"); - property << channel1Enable; - data_put.push_back(property); - WARN_STREAM<<"Channel1Enable property is not set in database, loading default value in database:" - <<channel1Enable<<endl; - } - //------------------------------------------------------------- - if (data[15].is_empty()==false) - { - data[15] >> channel2Enable; - } - else - { - Tango::DbDatum property("Channel2Enable"); - property << channel2Enable; - data_put.push_back(property); - WARN_STREAM<<"Channel2Enable property is not set in database, loading default value in database:" - <<channel2Enable<<endl; - } - //------------------------------------------------------------- - if (data[16].is_empty()==false) - { - data[16] >> channel3Enable; - } - else - { - Tango::DbDatum property("Channel3Enable"); - property << channel3Enable; - data_put.push_back(property); - WARN_STREAM<<"Channel3Enable property is not set in database, loading default value in database:" - <<channel3Enable<<endl; - } - //------------------------------------------------------------- - if (data[17].is_empty()==false) - { - data[17] >> channel4Enable; - } - else - { - Tango::DbDatum property("Channel4Enable"); - property << channel4Enable; - data_put.push_back(property); - WARN_STREAM<<"Channel4Enable property is not set in database, loading default value in database:" - <<channel4Enable<<endl; - } - //------------------------------------------------------------- - if (data[18].is_empty()==false) - { - data[18] >> channel5Enable; - } - else - { - Tango::DbDatum property("Channel5Enable"); - property << channel5Enable; - data_put.push_back(property); - WARN_STREAM<<"Channel5Enable property is not set in database, loading default value in database:" - <<channel5Enable<<endl; - } - //------------------------------------------------------------- - if (data[19].is_empty()==false) - { - data[19] >> channel6Enable; - } - else - { - Tango::DbDatum property("Channel6Enable"); - property << channel6Enable; - data_put.push_back(property); - WARN_STREAM<<"Channel6Enable property is not set in database, loading default value in database:" - <<channel6Enable<<endl; - } - //------------------------------------------------------------- - if (data[20].is_empty()==false) - { - data[20] >> channel7Enable; - } - else - { - Tango::DbDatum property("Channel7Enable"); - property << channel7Enable; - data_put.push_back(property); - WARN_STREAM<<"Channel7Enable property is not set in database, loading default value in database:" - <<channel7Enable<<endl; - } - //------------------------------------------------------------- - if (data[21].is_empty()==false) - { - data[21] >> bufferDepth; - } - else - { - Tango::DbDatum property("BufferDepth"); - property << bufferDepth; - data_put.push_back(property); - WARN_STREAM<<"BufferDepth property is not set in database, loading default value in database:" - <<bufferDepth<<endl; - } - //update database for not initiliazed properties - get_db_device()->put_property(data_put); -} -//+---------------------------------------------------------------------------- -// -// method : ContinuousAO::always_executed_hook() -// -// description : method always executed before any command is executed -// -//----------------------------------------------------------------------------- -void ContinuousAO::always_executed_hook() -{ - set_internal_state(); -} + m_err_ctr = m_ao->err_ctr; + + m_ao->unlock_data(); -//+---------------------------------------------------------------------------- -// -// method : ContinuousAO::read_attr_hardware() -// -// description : Hardware acquisition for attributes. -// -//----------------------------------------------------------------------------- -void ContinuousAO::read_attr_hardware(vector<long> &attr_list) -{ - DEBUG_STREAM << "In read_attr_hardware for " << attr_list.size(); - DEBUG_STREAM << " attribute(s)" << endl; - - // Add your own code here - //--------------------------------- - m_ao->lock_data(); - - m_err_ctr = m_ao->err_ctr; - - m_ao->unlock_data(); - -} - -//+---------------------------------------------------------------------------- -// -// method : ContinuousAO::read_attr() -// -// description : Extract real attribute values from -// hardware acquisition result. -// -//----------------------------------------------------------------------------- -void ContinuousAO::read_attr(Tango::Attribute &attr) -{ - string &attr_name = attr.get_name(); - - DEBUG_STREAM << "In read_attr for attribute " << attr_name << endl; - - // Switch on attribute name - //--------------------------------- - if (attr_name == "channel0") - { - if(channel0Enable) - attr.set_value(m_channel[0], bufferDepth); - else - attr.set_quality(Tango::ATTR_INVALID); - } - else if (attr_name == "channel1") - { - if(channel1Enable) - attr.set_value(m_channel[1], bufferDepth); - else - attr.set_quality(Tango::ATTR_INVALID); - } - else if (attr_name == "channel2") - { - if(channel2Enable) - attr.set_value(m_channel[2], bufferDepth); - else - attr.set_quality(Tango::ATTR_INVALID); - } - else if (attr_name == "channel3") - { - if(channel3Enable) - attr.set_value(m_channel[3], bufferDepth); - else - attr.set_quality(Tango::ATTR_INVALID); - } - else if (attr_name == "channel4") - { - if(channel4Enable) - attr.set_value(m_channel[4], bufferDepth); - else - attr.set_quality(Tango::ATTR_INVALID); - } - else if (attr_name == "channel5") - { - if(channel5Enable) - attr.set_value(m_channel[5], bufferDepth); - else - attr.set_quality(Tango::ATTR_INVALID); - } - else if (attr_name == "channel6") - { - if(channel6Enable) - attr.set_value(m_channel[6], bufferDepth); - else - attr.set_quality(Tango::ATTR_INVALID); - } - else if (attr_name == "channel7") - { - if(channel7Enable) - attr.set_value(m_channel[7], bufferDepth); - else - attr.set_quality(Tango::ATTR_INVALID); - } - else if (attr_name == "errorCounter") - { - attr.set_value(&m_err_ctr); - } - else if (attr_name == "useBoardFifo") - { - // the information about data loading on fifo in available only after Start command. - if(get_state() == Tango::RUNNING) - attr.set_value(&m_use_fifo); - else - attr.set_quality(Tango::ATTR_INVALID); - } - else - if (attr_name == "channel0Enable") - { - attr.set_value(&channel0Enable); } - else - if (attr_name == "channel1Enable") + + //+---------------------------------------------------------------------------- + // + // method : ContinuousAO::read_attr() + // + // description : Extract real attribute values from + // hardware acquisition result. + // + //----------------------------------------------------------------------------- + void ContinuousAO::read_attr(Tango::Attribute &attr) { - attr.set_value(&channel1Enable); + string &attr_name = attr.get_name(); + + DEBUG_STREAM << "In read_attr for attribute " << attr_name << endl; + + // Switch on attribute name + //--------------------------------- + if (attr_name == "channel0") + { + if(channel0Enable) + attr.set_value(m_channel[0], bufferDepth); + else + attr.set_quality(Tango::ATTR_INVALID); + } + else if (attr_name == "channel1") + { + if(channel1Enable) + attr.set_value(m_channel[1], bufferDepth); + else + attr.set_quality(Tango::ATTR_INVALID); + } + else if (attr_name == "channel2") + { + if(channel2Enable) + attr.set_value(m_channel[2], bufferDepth); + else + attr.set_quality(Tango::ATTR_INVALID); + } + else if (attr_name == "channel3") + { + if(channel3Enable) + attr.set_value(m_channel[3], bufferDepth); + else + attr.set_quality(Tango::ATTR_INVALID); + } + else if (attr_name == "channel4") + { + if(channel4Enable) + attr.set_value(m_channel[4], bufferDepth); + else + attr.set_quality(Tango::ATTR_INVALID); + } + else if (attr_name == "channel5") + { + if(channel5Enable) + attr.set_value(m_channel[5], bufferDepth); + else + attr.set_quality(Tango::ATTR_INVALID); + } + else if (attr_name == "channel6") + { + if(channel6Enable) + attr.set_value(m_channel[6], bufferDepth); + else + attr.set_quality(Tango::ATTR_INVALID); + } + else if (attr_name == "channel7") + { + if(channel7Enable) + attr.set_value(m_channel[7], bufferDepth); + else + attr.set_quality(Tango::ATTR_INVALID); + } + else if (attr_name == "errorCounter") + { + attr.set_value(&m_err_ctr); + } + else if (attr_name == "useBoardFifo") + { + // the information about data loading on fifo in available only after Start command. + if(get_state() == Tango::RUNNING) + attr.set_value(&m_use_fifo); + else + attr.set_quality(Tango::ATTR_INVALID); + } + else + if (attr_name == "channel0Enable") + { + attr.set_value(&channel0Enable); + } + else + if (attr_name == "channel1Enable") + { + attr.set_value(&channel1Enable); + } + else + if (attr_name == "channel2Enable") + { + attr.set_value(&channel2Enable); + } + else + if (attr_name == "channel3Enable") + { + attr.set_value(&channel3Enable); + } + else + if (attr_name == "channel4Enable") + { + attr.set_value(&channel4Enable); + } + else + if (attr_name == "channel5Enable") + { + attr.set_value(&channel5Enable); + } + else + if (attr_name == "channel6Enable") + { + attr.set_value(&channel6Enable); + } + else + if (attr_name == "channel7Enable") + { + attr.set_value(&channel7Enable); + } } - else - if (attr_name == "channel2Enable") + + //+------------------------------------------------------------------ + /** + * method: ContinuousAO::start + * + * description: method to execute "Start" + * start the generation. + * + * + */ + //+------------------------------------------------------------------ + void ContinuousAO::start() { - attr.set_value(&channel2Enable); + DEBUG_STREAM << "ContinuousAO::start(): entering... !" << endl; + + m_ao->lock_data(); + + m_ao->err_ctr = 0; + + m_ao->unlock_data(); + + _ASL_TRY_ACTION + ( + m_ao->start(), + "start", + "ContinuousAO::start", + set_internal_state() + ); + + // get if the output data have been loaded in the onboard FIFO. + // depends on the size of the buffer. + m_use_fifo = m_ao->use_board_fifo(); + } - else - if (attr_name == "channel3Enable") + + //+------------------------------------------------------------------ + /** + * method: ContinuousAO::stop + * + * description: method to execute "Stop" + * stop the generation. + * + * + */ + //+------------------------------------------------------------------ + void ContinuousAO::stop() { - attr.set_value(&channel3Enable); + DEBUG_STREAM << "ContinuousAO::stop(): entering... !" << endl; + + _ASL_TRY_ACTION + ( + m_ao->stop(), + "stop", + "ContinuousAO::stop", + set_internal_state() + ); + } - else - if (attr_name == "channel4Enable") + + //+------------------------------------------------------------------ + /** + * method: ContinuousAO::set_aoscaled_data + * + * description: method to execute "SetAOScaledData" + * Give one period of the signal to generated of a specified channel in volts. + * + * @param argin The channel number ,in string). The output data in volts ,in double) + * + */ + //+------------------------------------------------------------------ + void ContinuousAO::set_aoscaled_data(const Tango::DevVarDoubleStringArray *argin) { - attr.set_value(&channel4Enable); + DEBUG_STREAM << "ContinuousAO::set_aoscaled_data(): entering... !" << endl; + + if((*argin).svalue.length() != 1) + { + Tango::Except::throw_exception( + (const char*)("OPERATION_NOT_ALLOWED"), + (const char*)("The size of the string argument must be 1"), + (const char*)("ContinuousAO::set_aoscaled_data") + ); + } + Tango::DevVarStringArray chan_dvsa = (*argin).svalue; + string chan_s = chan_dvsa[0]; + int channel_index = chan_s[0] - '0'; + if(channel_index < 0 || channel_index > 7) + { + Tango::Except::throw_exception( + (const char*)("OPERATION_NOT_ALLOWED"), + (const char*)("The string argument must be between 0 and 7"), + (const char*)("ContinuousAO::set_aoscaled_data") + ); + } + if((*argin).dvalue.length() != bufferDepth) + { + Tango::Except::throw_exception( + (const char*)("OPERATION_NOT_ALLOWED"), + (const char*)("The depth of the given buffer must be the same as specified in Device Properties"), + (const char*)("ContinuousAO::set_aoscaled_data") + ); + } + + // stop the current generation + _ASL_TRY_ACTION + ( + m_ao->stop(), + "stop", + "ContinuousAO::set_aoscaled_data", + set_internal_state() + ); + + // get the configuration + asl::ContinuousAOConfig config = m_ao->configuration(); + + // copy the input data in a buffer of type asl::AOScaledData + asl::AOScaledData data(bufferDepth); + ::memcpy(data.base(), (*argin).dvalue.get_buffer(), ((*argin).dvalue.length())*sizeof(double)); + + + //NB: if a chan hasn't been enable with properties, 'm_ao' will do nothing + config.set_channel_periodic_data(channel_index, data); + + // copy the new data in the attributes of the device. + ::memcpy(m_channel[channel_index], data.base(), data.size()); + //save the waveform in the database + save_waveform(m_channel[channel_index], "Channel" + std::to_string(channel_index) + "Waveform"); + + // give the configuration with a new channel + _ASL_TRY_ACTION + ( + m_ao->configure(config), + "configure", + "ContinuousAO::set_aoscaled_data", + set_internal_state() + ); + } - else - if (attr_name == "channel5Enable") + //+------------------------------------------------------------------ + /** + * method: ContinuousAO::set_internal_state + */ + //+------------------------------------------------------------------ + void ContinuousAO::set_internal_state(void) { - attr.set_value(&channel5Enable); + if(m_ao == 0) + { + set_state(Tango::UNKNOWN); + set_status("The acquisition was not initialized properly"); + } + else + { + switch(m_ao->state()) + { + case asl::ContinuousAO::STANDBY: + set_state(Tango::STANDBY); + set_status("The generation is stopped"); + break; + case asl::ContinuousAO::RUNNING: + case asl::ContinuousAO::ABORTING: + set_state(Tango::RUNNING); + set_status("The generation is running"); + break; + case asl::ContinuousAO::FAULT: + set_state(Tango::FAULT); + set_status(m_error_message); + break; + case asl::ContinuousAO::UNKNOWN: + default: + set_state(Tango::UNKNOWN); + set_status("The generation is in an unknown state"); + break; + } + } } - else - if (attr_name == "channel6Enable") + //+------------------------------------------------------------------ + /** + * method: ContinuousAO::save_waveform + * Save a waveform in tango database + */ + //+------------------------------------------------------------------ + void ContinuousAO::save_waveform(double* waveform, string wfm_channel) { - attr.set_value(&channel6Enable); + // cpy the waveform in a double vector + vector<double> vec; + for(int i=0; i<bufferDepth; i++) + vec.push_back(waveform[i]); + + //put the vector in a DBDatum + Tango::DbDatum dbdatum(wfm_channel); + dbdatum << vec; + + // put it in a DbData + Tango::DbData db_data; + db_data.push_back(dbdatum); + + get_db_device()->get_dbase()->set_timeout_millis(30000); + + // put the waveform in the database + _DEV_TRY + ( + get_db_device()->put_property(db_data), + "put_property", + "ContinuousAO::save_waveform", + ); } - else - if (attr_name == "channel7Enable") + + void ContinuousAO::raise_error(std::string p_error_message) { - attr.set_value(&channel7Enable); + m_error_message = p_error_message; + set_state(Tango::FAULT); } -} - -//+------------------------------------------------------------------ -/** - * method: ContinuousAO::start - * - * description: method to execute "Start" - * start the generation. - * - * - */ -//+------------------------------------------------------------------ -void ContinuousAO::start() -{ - DEBUG_STREAM << "ContinuousAO::start(): entering... !" << endl; - - m_ao->lock_data(); - - m_ao->err_ctr = 0; - - m_ao->unlock_data(); - - _ASL_TRY_ACTION - ( - m_ao->start(), - "start", - "ContinuousAO::start", - set_internal_state() - ); - - // get if the output data have been loaded in the onboard FIFO. - // depends on the size of the buffer. - m_use_fifo = m_ao->use_board_fifo(); - -} - -//+------------------------------------------------------------------ -/** - * method: ContinuousAO::stop - * - * description: method to execute "Stop" - * stop the generation. - * - * - */ -//+------------------------------------------------------------------ -void ContinuousAO::stop() -{ - DEBUG_STREAM << "ContinuousAO::stop(): entering... !" << endl; - - _ASL_TRY_ACTION - ( - m_ao->stop(), - "stop", - "ContinuousAO::stop", - set_internal_state() - ); - -} - -//+------------------------------------------------------------------ -/** - * method: ContinuousAO::set_aoscaled_data - * - * description: method to execute "SetAOScaledData" - * Give one period of the signal to generated of a specified channel in volts. - * - * @param argin The channel number ,in string). The output data in volts ,in double) - * - */ -//+------------------------------------------------------------------ -void ContinuousAO::set_aoscaled_data(const Tango::DevVarDoubleStringArray *argin) -{ - DEBUG_STREAM << "ContinuousAO::set_aoscaled_data(): entering... !" << endl; - - if((*argin).svalue.length() != 1) - { - Tango::Except::throw_exception( - (const char*)("OPERATION_NOT_ALLOWED"), - (const char*)("The size of the string argument must be 1"), - (const char*)("ContinuousAO::set_aoscaled_data") - ); - } - Tango::DevVarStringArray chan_dvsa = (*argin).svalue; - string chan_s = chan_dvsa[0]; - int channel_index = chan_s[0] - '0'; - if(channel_index < 0 || channel_index > 7) - { - Tango::Except::throw_exception( - (const char*)("OPERATION_NOT_ALLOWED"), - (const char*)("The string argument must be between 0 and 7"), - (const char*)("ContinuousAO::set_aoscaled_data") - ); - } - if((*argin).dvalue.length() != bufferDepth) - { - Tango::Except::throw_exception( - (const char*)("OPERATION_NOT_ALLOWED"), - (const char*)("The depth of the given buffer must be the same as specified in Device Properties"), - (const char*)("ContinuousAO::set_aoscaled_data") - ); - } - - // stop the current generation - _ASL_TRY_ACTION - ( - m_ao->stop(), - "stop", - "ContinuousAO::set_aoscaled_data", - set_internal_state() - ); - - // get the configuration - asl::ContinuousAOConfig config = m_ao->configuration(); - - // copy the input data in a buffer of type asl::AOScaledData - asl::AOScaledData data(bufferDepth); - ::memcpy(data.base(), (*argin).dvalue.get_buffer(), ((*argin).dvalue.length())*sizeof(double)); - - - //NB: if a chan hasn't been enable with properties, 'm_ao' will do nothing - config.set_channel_periodic_data(channel_index, data); - - // copy the new data in the attributes of the device. - ::memcpy(m_channel[channel_index], data.base(), data.size()); - //save the waveform in the database - save_waveform(m_channel[channel_index], "Channel" + std::to_string(channel_index) + "Waveform"); - - // give the configuration with a new channel - _ASL_TRY_ACTION - ( - m_ao->configure(config), - "configure", - "ContinuousAO::set_aoscaled_data", - set_internal_state() - ); - -} -//+------------------------------------------------------------------ -/** -* method: ContinuousAO::set_internal_state -*/ -//+------------------------------------------------------------------ -void ContinuousAO::set_internal_state(void) -{ - if(m_ao == 0) - { - set_state(Tango::UNKNOWN); - set_status("The acquisition was not initialized properly"); - } - else - { - switch(m_ao->state()) - { - case asl::ContinuousAO::STANDBY: - set_state(Tango::STANDBY); - set_status("The generation is stopped"); - break; - case asl::ContinuousAO::RUNNING: - case asl::ContinuousAO::ABORTING: - set_state(Tango::RUNNING); - set_status("The generation is running"); - break; - case asl::ContinuousAO::FAULT: - set_state(Tango::FAULT); - set_status(m_error_message); - break; - case asl::ContinuousAO::UNKNOWN: - default: - set_state(Tango::UNKNOWN); - set_status("The generation is in an unknown state"); - break; - } - } -} -//+------------------------------------------------------------------ -/** -* method: ContinuousAO::save_waveform -* Save a waveform in tango database -*/ -//+------------------------------------------------------------------ -void ContinuousAO::save_waveform(double* waveform, string wfm_channel) -{ - // cpy the waveform in a double vector - vector<double> vec; - for(int i=0; i<bufferDepth; i++) - vec.push_back(waveform[i]); - - //put the vector in a DBDatum - Tango::DbDatum dbdatum(wfm_channel); - dbdatum << vec; - - // put it in a DbData - Tango::DbData db_data; - db_data.push_back(dbdatum); - - get_db_device()->get_dbase()->set_timeout_millis(30000); - - // put the waveform in the database - _DEV_TRY - ( - get_db_device()->put_property(db_data), - "put_property", - "ContinuousAO::save_waveform", - ); -} - -void ContinuousAO::raise_error(std::string p_error_message) -{ - m_error_message = p_error_message; - set_state(Tango::FAULT); -} } // namespace diff --git a/src/ContinuousAO.h b/src/ContinuousAO.h index 4b015d8..724d313 100755 --- a/src/ContinuousAO.h +++ b/src/ContinuousAO.h @@ -47,307 +47,307 @@ * @version $Revision: 1.4 $ $ */ - // Add your own constants definitions here. - //----------------------------------------------- +// Add your own constants definitions here. +//----------------------------------------------- namespace ContinuousAO { -/** - * Class Description: - * Perform continuous anolog ouput (waveform generation) on the selected outputs. - */ + /** + * Class Description: + * Perform continuous anolog ouput (waveform generation) on the selected outputs. + */ -/* - * Device States Description: - * Tango::UNKNOWN : - * Tango::STANDBY : - * Tango::RUNNING : - * Tango::FAULT : - */ + /* + * Device States Description: + * Tango::UNKNOWN : + * Tango::STANDBY : + * Tango::RUNNING : + * Tango::FAULT : + */ -class ContinuousAO: public Tango::Device_2Impl -{ -public : - // Add your own data members here - //----------------------------------------- + class ContinuousAO: public Tango::Device_2Impl + { + public : + // Add your own data members here + //----------------------------------------- - // Here is the Start of the automatic code generation part - //------------------------------------------------------------- -/** - * @name attributes - * Attributs member data. - */ -//@{ - Tango::DevDouble *attr_channel0_read; - Tango::DevDouble *attr_channel1_read; - Tango::DevDouble *attr_channel2_read; - Tango::DevDouble *attr_channel3_read; - Tango::DevDouble *attr_channel4_read; - Tango::DevDouble *attr_channel5_read; - Tango::DevDouble *attr_channel6_read; - Tango::DevDouble *attr_channel7_read; - Tango::DevDouble *attr_errorCounter_read; - Tango::DevShort *attr_useBoardFifo_read; - Tango::DevShort *attr_channel0Enable_read; - Tango::DevShort *attr_channel1Enable_read; - Tango::DevShort *attr_channel2Enable_read; - Tango::DevShort *attr_channel3Enable_read; - Tango::DevShort *attr_channel4Enable_read; - Tango::DevShort *attr_channel5Enable_read; - Tango::DevShort *attr_channel6Enable_read; - Tango::DevShort *attr_channel7Enable_read; -//@} + // Here is the Start of the automatic code generation part + //------------------------------------------------------------- + /** + * @name attributes + * Attributs member data. + */ + //@{ + Tango::DevDouble *attr_channel0_read; + Tango::DevDouble *attr_channel1_read; + Tango::DevDouble *attr_channel2_read; + Tango::DevDouble *attr_channel3_read; + Tango::DevDouble *attr_channel4_read; + Tango::DevDouble *attr_channel5_read; + Tango::DevDouble *attr_channel6_read; + Tango::DevDouble *attr_channel7_read; + Tango::DevDouble *attr_errorCounter_read; + Tango::DevShort *attr_useBoardFifo_read; + Tango::DevShort *attr_channel0Enable_read; + Tango::DevShort *attr_channel1Enable_read; + Tango::DevShort *attr_channel2Enable_read; + Tango::DevShort *attr_channel3Enable_read; + Tango::DevShort *attr_channel4Enable_read; + Tango::DevShort *attr_channel5Enable_read; + Tango::DevShort *attr_channel6Enable_read; + Tango::DevShort *attr_channel7Enable_read; + //@} -/** - * @name Device properties - * Device properties member data. - */ -//@{ -/** - * The number of the board in the chassis cPCI. - */ - Tango::DevUShort boardNum; -/** - * The output frequency (the rate the samples are outputed). - */ - Tango::DevDouble frequency; -/** - * 1 if using a start trigger, 0 otherwise. - */ - Tango::DevShort startTrigger; -/** - * 1 if using a stop trigger, 0 otherwise. - */ - Tango::DevShort stopTrigger; -/** - * The start trigger source. Analog trigger DTRIG or ATRIG. - */ - Tango::DevUShort startTriggerSource; -/** - * The stop trigger source. anolog trigger ATRIG or pin AFI0 of AFI1. - */ - Tango::DevUShort stopTriggerSource; -/** - * select the type of analog trigger. Can be BELOW (trigger occurs below ATRIGLevel) - * or can be ABOVE (trigger occurs above ATRIGLevel). - */ - Tango::DevUShort aTRIGSelection; -/** - * The analog trigger level in volts. - */ - Tango::DevDouble aTRIGLevel; -/** - * The edges on which the trigger are detected. Can be RISING or FALLING. - */ - Tango::DevUShort dTRIGPolarity; -/** - * The value of the reference voltage gave on pin AORefA. - */ - Tango::DevDouble aORefA; -/** - * The value of the reference voltage gave on pin AORefB. - */ - Tango::DevDouble aORefB; -/** - * BP for unipolar outputs or UP for bipolar outputs. - */ - Tango::DevUShort polarity; -/** - * Select the internal reference (10.0 volts) with INTERN or the external references - * AORefA and AORefB with EXTERN. - */ - Tango::DevUShort aORefSource; -/** - * 1 if enable channel 0, 0 otherwise. - */ - Tango::DevShort channel0Enable; -/** - * 1 if enable channel 1, 0 otherwise. - */ - Tango::DevShort channel1Enable; -/** - * 1 if enable channel 2, 0 otherwise. - */ - Tango::DevShort channel2Enable; -/** - * 1 if enable channel 3, 0 otherwise. - */ - Tango::DevShort channel3Enable; -/** - * 1 if enable channel 4, 0 otherwise. - */ - Tango::DevShort channel4Enable; -/** - * 1 if enable channel 5, 0 otherwise. - */ - Tango::DevShort channel5Enable; -/** - * 1 if enable channel 6, 0 otherwise. - */ - Tango::DevShort channel6Enable; -/** - * 1 if enable channel 7, 0 otherwise. - */ - Tango::DevShort channel7Enable; -/** - * The buffer depth for <b>one channel</b>. - */ - Tango::DevUShort bufferDepth; -/** - * The waveform for channel 0 (attribute persistency). - */ - vector<double> channel0Waveform; -/** - * The waveform for channel 1 (attribute persistency). - */ - vector<double> channel1Waveform; -/** - * The waveform for channel 2 (attribute persistency). - */ - vector<double> channel2Waveform; -/** - * The waveform for channel 3 (attribute persistency). - */ - vector<double> channel3Waveform; -/** - * The waveform for channel 4 (attribute persistency). - */ - vector<double> channel4Waveform; -/** - * The waveform for channel 5 (attribute persistency). - */ - vector<double> channel5Waveform; -/** - * The waveform for channel 6 (attribute persistency). - */ - vector<double> channel6Waveform; -/** - * The waveform for channel 7 (attribute persistency). - */ - vector<double> channel7Waveform; -//@} + /** + * @name Device properties + * Device properties member data. + */ + //@{ + /** + * The number of the board in the chassis cPCI. + */ + Tango::DevUShort boardNum; + /** + * The output frequency (the rate the samples are outputed). + */ + Tango::DevDouble frequency; + /** + * 1 if using a start trigger, 0 otherwise. + */ + Tango::DevShort startTrigger; + /** + * 1 if using a stop trigger, 0 otherwise. + */ + Tango::DevShort stopTrigger; + /** + * The start trigger source. Analog trigger DTRIG or ATRIG. + */ + Tango::DevUShort startTriggerSource; + /** + * The stop trigger source. anolog trigger ATRIG or pin AFI0 of AFI1. + */ + Tango::DevUShort stopTriggerSource; + /** + * select the type of analog trigger. Can be BELOW (trigger occurs below ATRIGLevel) + * or can be ABOVE (trigger occurs above ATRIGLevel). + */ + Tango::DevUShort aTRIGSelection; + /** + * The analog trigger level in volts. + */ + Tango::DevDouble aTRIGLevel; + /** + * The edges on which the trigger are detected. Can be RISING or FALLING. + */ + Tango::DevUShort dTRIGPolarity; + /** + * The value of the reference voltage gave on pin AORefA. + */ + Tango::DevDouble aORefA; + /** + * The value of the reference voltage gave on pin AORefB. + */ + Tango::DevDouble aORefB; + /** + * BP for unipolar outputs or UP for bipolar outputs. + */ + Tango::DevUShort polarity; + /** + * Select the internal reference (10.0 volts) with INTERN or the external references + * AORefA and AORefB with EXTERN. + */ + Tango::DevUShort aORefSource; + /** + * 1 if enable channel 0, 0 otherwise. + */ + Tango::DevShort channel0Enable; + /** + * 1 if enable channel 1, 0 otherwise. + */ + Tango::DevShort channel1Enable; + /** + * 1 if enable channel 2, 0 otherwise. + */ + Tango::DevShort channel2Enable; + /** + * 1 if enable channel 3, 0 otherwise. + */ + Tango::DevShort channel3Enable; + /** + * 1 if enable channel 4, 0 otherwise. + */ + Tango::DevShort channel4Enable; + /** + * 1 if enable channel 5, 0 otherwise. + */ + Tango::DevShort channel5Enable; + /** + * 1 if enable channel 6, 0 otherwise. + */ + Tango::DevShort channel6Enable; + /** + * 1 if enable channel 7, 0 otherwise. + */ + Tango::DevShort channel7Enable; + /** + * The buffer depth for <b>one channel</b>. + */ + Tango::DevUShort bufferDepth; + /** + * The waveform for channel 0 (attribute persistency). + */ + vector<double> channel0Waveform; + /** + * The waveform for channel 1 (attribute persistency). + */ + vector<double> channel1Waveform; + /** + * The waveform for channel 2 (attribute persistency). + */ + vector<double> channel2Waveform; + /** + * The waveform for channel 3 (attribute persistency). + */ + vector<double> channel3Waveform; + /** + * The waveform for channel 4 (attribute persistency). + */ + vector<double> channel4Waveform; + /** + * The waveform for channel 5 (attribute persistency). + */ + vector<double> channel5Waveform; + /** + * The waveform for channel 6 (attribute persistency). + */ + vector<double> channel6Waveform; + /** + * The waveform for channel 7 (attribute persistency). + */ + vector<double> channel7Waveform; + //@} -/**@name Constructors - * Miscellaneous constructors */ -//@{ -/** - * Constructs a newly allocated Command object. - * - * @param cl Class. - * @param s Device Name - */ - ContinuousAO(Tango::DeviceClass *,string &); -/** - * Constructs a newly allocated Command object. - * - * @param cl Class. - * @param s Device Name - */ - ContinuousAO(Tango::DeviceClass *,const char *); -/** - * Constructs a newly allocated Command object. - * - * @param cl Class. - * @param s Device name - * @param d Device description. - */ - ContinuousAO(Tango::DeviceClass *,const char *,const char *); -//@} + /**@name Constructors + * Miscellaneous constructors */ + //@{ + /** + * Constructs a newly allocated Command object. + * + * @param cl Class. + * @param s Device Name + */ + ContinuousAO(Tango::DeviceClass *,string &); + /** + * Constructs a newly allocated Command object. + * + * @param cl Class. + * @param s Device Name + */ + ContinuousAO(Tango::DeviceClass *,const char *); + /** + * Constructs a newly allocated Command object. + * + * @param cl Class. + * @param s Device name + * @param d Device description. + */ + ContinuousAO(Tango::DeviceClass *,const char *,const char *); + //@} -/**@name Destructor - * Only one desctructor is defined for this class */ -//@{ -/** - * The object desctructor. - */ - ~ContinuousAO() { delete_device(); }; -/** - * will be called at device destruction or at init command. - */ - void delete_device(); -//@} + /**@name Destructor + * Only one desctructor is defined for this class */ + //@{ + /** + * The object desctructor. + */ + ~ContinuousAO() { 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 befor execution command method. - */ - virtual void always_executed_hook(); -//@} + /**@name Miscellaneous methods */ + //@{ + /** + * Initialize the device + */ + virtual void init_device(); + /** + * Always executed method befor execution command method. + */ + virtual void always_executed_hook(); -/** - * @name ContinuousAO methods prototypes - */ + //@} -//@{ -/** - * Hardware acquisition for attributes. - */ - virtual void read_attr_hardware(vector<long> &attr_list); -/** - * Extract real attribute values from hardware acquisition result. - */ - virtual void read_attr(Tango::Attribute &attr); -/** - * start the generation. - * @exception DevFailed - */ - void start(); -/** - * stop the generation. - * @exception DevFailed - */ - void stop(); -/** - * Give one period of the signal to generated of a specified channel in volts. - * @param argin The channel number ,in string). The output data in volts ,in double) - * @exception DevFailed - */ - void set_aoscaled_data(const Tango::DevVarDoubleStringArray *); + /** + * @name ContinuousAO methods prototypes + */ + + //@{ + /** + * Hardware acquisition for attributes. + */ + virtual void read_attr_hardware(vector<long> &attr_list); + /** + * Extract real attribute values from hardware acquisition result. + */ + virtual void read_attr(Tango::Attribute &attr); + /** + * start the generation. + * @exception DevFailed + */ + void start(); + /** + * stop the generation. + * @exception DevFailed + */ + void stop(); + /** + * Give one period of the signal to generated of a specified channel in volts. + * @param argin The channel number ,in string). The output data in volts ,in double) + * @exception DevFailed + */ + void set_aoscaled_data(const Tango::DevVarDoubleStringArray *); + + /** + * Read the device properties from database + */ + void get_device_property(); + //@} + + // Here is the end of the automatic code generation part + //------------------------------------------------------------- + ADLinkContinuousAO* m_ao; + std::vector<asl::AOScaledData> m_default_waveform; + double* m_channel[8]; + double m_err_ctr; + short m_use_fifo; + std::string m_error_message; + + asl::ActiveAOChannel m_ac; + + asl::ContinuousAOConfig m_config; + asl::ContinuousAOConfig m_stop_config; -/** - * Read the device properties from database - */ - void get_device_property(); -//@} - // Here is the end of the automatic code generation part - //------------------------------------------------------------- - ADLinkContinuousAO* m_ao; - std::vector<asl::AOScaledData> m_default_waveform; - double* m_channel[8]; - double m_err_ctr; - short m_use_fifo; - std::string m_error_message; - - asl::ActiveAOChannel m_ac; - - asl::ContinuousAOConfig m_config; - asl::ContinuousAOConfig m_stop_config; - - - // asl::ContinuousAOConfig* config; - void set_internal_state(void); - void raise_error(std::string p_error_message); - // save a channel waveform in the database - void ContinuousAO::save_waveform(double* waveform, string wfm_channel); - asl::AOScaledData assign_default_waveform(Tango::DevDouble p_ref, std::function <double(int, int)> p_lambda, int p_first_channel, int p_last_channel); - void activate_channel(int p_channel_index, vector<double>& p_channel_wave_form, asl::AOScaledData& p_default_waveform); + // asl::ContinuousAOConfig* config; + void set_internal_state(void); + void raise_error(std::string p_error_message); + // save a channel waveform in the database + void ContinuousAO::save_waveform(double* waveform, string wfm_channel); + asl::AOScaledData assign_default_waveform(Tango::DevDouble p_ref, std::function <double(int, int)> p_lambda, int p_first_channel, int p_last_channel); + void activate_channel(int p_channel_index, vector<double>& p_channel_wave_form, asl::AOScaledData& p_default_waveform); -protected : - // Add your own data members here - //----------------------------------------- -}; + protected : + // Add your own data members here + //----------------------------------------- + }; } // namespace diff --git a/src/ContinuousAOClass.cpp b/src/ContinuousAOClass.cpp index e3e5fb7..e5b48ea 100644 --- a/src/ContinuousAOClass.cpp +++ b/src/ContinuousAOClass.cpp @@ -52,587 +52,587 @@ namespace ContinuousAO { -//+---------------------------------------------------------------------------- -// -// method : StartCmd::StartCmd() -// -// description : constructor for the command of the ContinuousAO. -// -// In : - name : The command name -// - in : The input parameter type -// - out : The output parameter type -// - in_desc : The input parameter description -// - out_desc : The output parameter description -// -//----------------------------------------------------------------------------- -StartCmd::StartCmd( 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) -{ -} -// -// Constructor without in/out parameters description -// -StartCmd::StartCmd( const char *name, - Tango::CmdArgType in, - Tango::CmdArgType out) -:Command(name,in,out) -{ -} -//+---------------------------------------------------------------------------- -// -// method : StartCmd::is_allowed() -// -// description : method to test whether command is allowed or not in this -// state. In this case, the command is allowed only if -// the device is in ON state -// -// in : - device : The device on which the command must be excuted -// - in_any : The command input data -// -// returns : boolean - true == is allowed , false == not allowed -// -//----------------------------------------------------------------------------- -bool StartCmd::is_allowed(Tango::DeviceImpl *device, const CORBA::Any &in_any) -{ + //+---------------------------------------------------------------------------- + // + // method : StartCmd::StartCmd() + // + // description : constructor for the command of the ContinuousAO. + // + // In : - name : The command name + // - in : The input parameter type + // - out : The output parameter type + // - in_desc : The input parameter description + // - out_desc : The output parameter description + // + //----------------------------------------------------------------------------- + StartCmd::StartCmd( 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) + { + } + // + // Constructor without in/out parameters description + // + StartCmd::StartCmd( const char *name, + Tango::CmdArgType in, + Tango::CmdArgType out) + :Command(name,in,out) + { + } + //+---------------------------------------------------------------------------- + // + // method : StartCmd::is_allowed() + // + // description : method to test whether command is allowed or not in this + // state. In this case, the command is allowed only if + // the device is in ON state + // + // in : - device : The device on which the command must be excuted + // - in_any : The command input data + // + // returns : boolean - true == is allowed , false == not allowed + // + //----------------------------------------------------------------------------- + bool StartCmd::is_allowed(Tango::DeviceImpl *device, const CORBA::Any &in_any) + { // End of Generated Code // Re-Start of Generated Code return true; -} -//+---------------------------------------------------------------------------- -// -// method : StartCmd::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 excuted -// - in_any : The command input data -// -// returns : The command output data (packed in the Any object) -// -//----------------------------------------------------------------------------- -CORBA::Any *StartCmd::execute(Tango::DeviceImpl *device,const CORBA::Any &in_any) -{ + } + //+---------------------------------------------------------------------------- + // + // method : StartCmd::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 excuted + // - in_any : The command input data + // + // returns : The command output data (packed in the Any object) + // + //----------------------------------------------------------------------------- + CORBA::Any *StartCmd::execute(Tango::DeviceImpl *device,const CORBA::Any &in_any) + { - cout2 << "DevTemplateCmd::execute(): arrived" << endl; + cout2 << "DevTemplateCmd::execute(): arrived" << endl; - ((static_cast<ContinuousAO *>(device))->start()); - return new CORBA::Any(); -} + ((static_cast<ContinuousAO *>(device))->start()); + return new CORBA::Any(); + } -//+---------------------------------------------------------------------------- -// -// method : StopCmd::StopCmd() -// -// description : constructor for the command of the ContinuousAO. -// -// In : - name : The command name -// - in : The input parameter type -// - out : The output parameter type -// - in_desc : The input parameter description -// - out_desc : The output parameter description -// -//----------------------------------------------------------------------------- -StopCmd::StopCmd( 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) -{ -} -// -// Constructor without in/out parameters description -// -StopCmd::StopCmd( const char *name, - Tango::CmdArgType in, - Tango::CmdArgType out) -:Command(name,in,out) -{ -} -//+---------------------------------------------------------------------------- -// -// method : StopCmd::is_allowed() -// -// description : method to test whether command is allowed or not in this -// state. In this case, the command is allowed only if -// the device is in ON state -// -// in : - device : The device on which the command must be excuted -// - in_any : The command input data -// -// returns : boolean - true == is allowed , false == not allowed -// -//----------------------------------------------------------------------------- -bool StopCmd::is_allowed(Tango::DeviceImpl *device, const CORBA::Any &in_any) -{ + //+---------------------------------------------------------------------------- + // + // method : StopCmd::StopCmd() + // + // description : constructor for the command of the ContinuousAO. + // + // In : - name : The command name + // - in : The input parameter type + // - out : The output parameter type + // - in_desc : The input parameter description + // - out_desc : The output parameter description + // + //----------------------------------------------------------------------------- + StopCmd::StopCmd( 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) + { + } + // + // Constructor without in/out parameters description + // + StopCmd::StopCmd( const char *name, + Tango::CmdArgType in, + Tango::CmdArgType out) + :Command(name,in,out) + { + } + //+---------------------------------------------------------------------------- + // + // method : StopCmd::is_allowed() + // + // description : method to test whether command is allowed or not in this + // state. In this case, the command is allowed only if + // the device is in ON state + // + // in : - device : The device on which the command must be excuted + // - in_any : The command input data + // + // returns : boolean - true == is allowed , false == not allowed + // + //----------------------------------------------------------------------------- + bool StopCmd::is_allowed(Tango::DeviceImpl *device, const CORBA::Any &in_any) + { // End of Generated Code // Re-Start of Generated Code return true; -} -//+---------------------------------------------------------------------------- -// -// method : StopCmd::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 excuted -// - in_any : The command input data -// -// returns : The command output data (packed in the Any object) -// -//----------------------------------------------------------------------------- -CORBA::Any *StopCmd::execute(Tango::DeviceImpl *device,const CORBA::Any &in_any) -{ + } + //+---------------------------------------------------------------------------- + // + // method : StopCmd::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 excuted + // - in_any : The command input data + // + // returns : The command output data (packed in the Any object) + // + //----------------------------------------------------------------------------- + CORBA::Any *StopCmd::execute(Tango::DeviceImpl *device,const CORBA::Any &in_any) + { - cout2 << "DevTemplateCmd::execute(): arrived" << endl; + cout2 << "DevTemplateCmd::execute(): arrived" << endl; - ((static_cast<ContinuousAO *>(device))->stop()); - return new CORBA::Any(); -} + ((static_cast<ContinuousAO *>(device))->stop()); + return new CORBA::Any(); + } -//+---------------------------------------------------------------------------- -// -// method : SetAOScaledDataCmd::SetAOScaledDataCmd() -// -// description : constructor for the command of the ContinuousAO. -// -// In : - name : The command name -// - in : The input parameter type -// - out : The output parameter type -// - in_desc : The input parameter description -// - out_desc : The output parameter description -// -//----------------------------------------------------------------------------- -SetAOScaledDataCmd::SetAOScaledDataCmd( 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) -{ -} -// -// Constructor without in/out parameters description -// -SetAOScaledDataCmd::SetAOScaledDataCmd( const char *name, - Tango::CmdArgType in, - Tango::CmdArgType out) -:Command(name,in,out) -{ -} -//+---------------------------------------------------------------------------- -// -// method : SetAOScaledDataCmd::is_allowed() -// -// description : method to test whether command is allowed or not in this -// state. In this case, the command is allowed only if -// the device is in ON state -// -// in : - device : The device on which the command must be excuted -// - in_any : The command input data -// -// returns : boolean - true == is allowed , false == not allowed -// -//----------------------------------------------------------------------------- -bool SetAOScaledDataCmd::is_allowed(Tango::DeviceImpl *device, const CORBA::Any &in_any) -{ + //+---------------------------------------------------------------------------- + // + // method : SetAOScaledDataCmd::SetAOScaledDataCmd() + // + // description : constructor for the command of the ContinuousAO. + // + // In : - name : The command name + // - in : The input parameter type + // - out : The output parameter type + // - in_desc : The input parameter description + // - out_desc : The output parameter description + // + //----------------------------------------------------------------------------- + SetAOScaledDataCmd::SetAOScaledDataCmd( 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) + { + } + // + // Constructor without in/out parameters description + // + SetAOScaledDataCmd::SetAOScaledDataCmd( const char *name, + Tango::CmdArgType in, + Tango::CmdArgType out) + :Command(name,in,out) + { + } + //+---------------------------------------------------------------------------- + // + // method : SetAOScaledDataCmd::is_allowed() + // + // description : method to test whether command is allowed or not in this + // state. In this case, the command is allowed only if + // the device is in ON state + // + // in : - device : The device on which the command must be excuted + // - in_any : The command input data + // + // returns : boolean - true == is allowed , false == not allowed + // + //----------------------------------------------------------------------------- + bool SetAOScaledDataCmd::is_allowed(Tango::DeviceImpl *device, const CORBA::Any &in_any) + { // End of Generated Code // Re-Start of Generated Code return true; -} + } -//+---------------------------------------------------------------------------- -// -// method : SetAOScaledDataCmd::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 excuted -// - in_any : The command input data -// -// returns : The command output data (packed in the Any object) -// -//----------------------------------------------------------------------------- -CORBA::Any *SetAOScaledDataCmd::execute(Tango::DeviceImpl *device,const CORBA::Any &in_any) -{ + //+---------------------------------------------------------------------------- + // + // method : SetAOScaledDataCmd::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 excuted + // - in_any : The command input data + // + // returns : The command output data (packed in the Any object) + // + //----------------------------------------------------------------------------- + CORBA::Any *SetAOScaledDataCmd::execute(Tango::DeviceImpl *device,const CORBA::Any &in_any) + { - cout2 << "DevTemplateCmd::execute(): arrived" << endl; + cout2 << "DevTemplateCmd::execute(): arrived" << endl; - const Tango::DevVarDoubleStringArray *argin; - extract(in_any, argin); + const Tango::DevVarDoubleStringArray *argin; + extract(in_any, argin); - ((static_cast<ContinuousAO *>(device))->set_aoscaled_data(argin)); - return new CORBA::Any(); -} + ((static_cast<ContinuousAO *>(device))->set_aoscaled_data(argin)); + return new CORBA::Any(); + } -// -//---------------------------------------------------------------- -// Initialize pointer for singleton pattern -//---------------------------------------------------------------- -// -ContinuousAOClass *ContinuousAOClass::_instance = NULL; + // + //---------------------------------------------------------------- + // Initialize pointer for singleton pattern + //---------------------------------------------------------------- + // + ContinuousAOClass *ContinuousAOClass::_instance = NULL; + + //+---------------------------------------------------------------------------- + // + // method : ContinuousAOClass::ContinuousAOClass(string &s) + // + // description : constructor for the ContinuousAOClass + // + // in : - s : The class name + // + //----------------------------------------------------------------------------- + ContinuousAOClass::ContinuousAOClass(string &s):DeviceClass(s) + { -//+---------------------------------------------------------------------------- -// -// method : ContinuousAOClass::ContinuousAOClass(string &s) -// -// description : constructor for the ContinuousAOClass -// -// in : - s : The class name -// -//----------------------------------------------------------------------------- -ContinuousAOClass::ContinuousAOClass(string &s):DeviceClass(s) -{ + cout2 << "Entering ContinuousAOClass constructor" << endl; + write_class_property(); - cout2 << "Entering ContinuousAOClass constructor" << endl; - write_class_property(); - - cout2 << "Leaving ContinuousAOClass constructor" << endl; + cout2 << "Leaving ContinuousAOClass constructor" << endl; -} -//+---------------------------------------------------------------------------- -// -// method : ContinuousAOClass::~ContinuousAOClass() -// -// description : destructor for the ContinuousAOClass -// -//----------------------------------------------------------------------------- -ContinuousAOClass::~ContinuousAOClass() -{ - _instance = NULL; -} + } + //+---------------------------------------------------------------------------- + // + // method : ContinuousAOClass::~ContinuousAOClass() + // + // description : destructor for the ContinuousAOClass + // + //----------------------------------------------------------------------------- + ContinuousAOClass::~ContinuousAOClass() + { + _instance = NULL; + } -//+---------------------------------------------------------------------------- -// -// method : ContinuousAOClass::instance -// -// description : Create the object if not already done. Otherwise, just -// return a pointer to the object -// -// in : - name : The class name -// -//----------------------------------------------------------------------------- -ContinuousAOClass *ContinuousAOClass::init(const char *name) -{ - if (_instance == NULL) + //+---------------------------------------------------------------------------- + // + // method : ContinuousAOClass::instance + // + // description : Create the object if not already done. Otherwise, just + // return a pointer to the object + // + // in : - name : The class name + // + //----------------------------------------------------------------------------- + ContinuousAOClass *ContinuousAOClass::init(const char *name) { - try + if (_instance == NULL) { - string s(name); - _instance = new ContinuousAOClass(s); - } - catch (bad_alloc) - { - throw; + try + { + string s(name); + _instance = new ContinuousAOClass(s); + } + catch (bad_alloc) + { + throw; + } } - } - return _instance; -} + return _instance; + } -ContinuousAOClass *ContinuousAOClass::instance() -{ - if (_instance == NULL) + ContinuousAOClass *ContinuousAOClass::instance() { - cerr << "Class is not initialised !!" << endl; - exit(-1); + if (_instance == NULL) + { + cerr << "Class is not initialised !!" << endl; + exit(-1); + } + return _instance; } - return _instance; -} -//+---------------------------------------------------------------------------- -// -// method : ContinuousAOClass::command_factory -// -// description : Create the command object(s) and store them in the -// command list -// -//----------------------------------------------------------------------------- -void ContinuousAOClass::command_factory() -{ - command_list.push_back(new StartCmd("Start", - Tango::DEV_VOID, Tango::DEV_VOID, - "", - "", - Tango::OPERATOR)); - command_list.push_back(new StopCmd("Stop", - Tango::DEV_VOID, Tango::DEV_VOID, - "", - "", - Tango::OPERATOR)); - command_list.push_back(new SetAOScaledDataCmd("SetAOScaledData", - Tango::DEVVAR_DOUBLESTRINGARRAY, Tango::DEV_VOID, - "The channel number ,in string). The output data in volts ,in double)", - "", - Tango::OPERATOR)); - - // add polling if any - for (unsigned int i=0 ; i<command_list.size(); i++) + //+---------------------------------------------------------------------------- + // + // method : ContinuousAOClass::command_factory + // + // description : Create the command object(s) and store them in the + // command list + // + //----------------------------------------------------------------------------- + void ContinuousAOClass::command_factory() { + command_list.push_back(new StartCmd("Start", + Tango::DEV_VOID, Tango::DEV_VOID, + "", + "", + Tango::OPERATOR)); + command_list.push_back(new StopCmd("Stop", + Tango::DEV_VOID, Tango::DEV_VOID, + "", + "", + Tango::OPERATOR)); + command_list.push_back(new SetAOScaledDataCmd("SetAOScaledData", + Tango::DEVVAR_DOUBLESTRINGARRAY, Tango::DEV_VOID, + "The channel number ,in string). The output data in volts ,in double)", + "", + Tango::OPERATOR)); + + // add polling if any + for (unsigned int i=0 ; i<command_list.size(); i++) + { + } } -} -//+---------------------------------------------------------------------------- -// -// method : ContinuousAOClass::device_factory -// -// description : Create the device object(s) and store them in the -// device list -// -// in : Tango::DevVarStringArray *devlist_ptr : The device name list -// -//----------------------------------------------------------------------------- -void ContinuousAOClass::device_factory(const Tango::DevVarStringArray *devlist_ptr) -{ - - for (long i=0 ; i < devlist_ptr->length() ; i++) + //+---------------------------------------------------------------------------- + // + // method : ContinuousAOClass::device_factory + // + // description : Create the device object(s) and store them in the + // device list + // + // in : Tango::DevVarStringArray *devlist_ptr : The device name list + // + //----------------------------------------------------------------------------- + void ContinuousAOClass::device_factory(const Tango::DevVarStringArray *devlist_ptr) { - cout4 << "Device name : " << (*devlist_ptr)[i].in() << endl; - - // Create device and add it into the device list - //---------------------------------------------------- - device_list.push_back(new ContinuousAO(this, (*devlist_ptr)[i])); - - // Export device to the outside world - // Check before id database used. - //--------------------------------------------- - if (Tango::Util::_UseDb == true) - export_device(device_list.back()); - else - export_device(device_list.back(), (*devlist_ptr)[i]); + + for (long i=0 ; i < devlist_ptr->length() ; i++) + { + cout4 << "Device name : " << (*devlist_ptr)[i].in() << endl; + + // Create device and add it into the device list + //---------------------------------------------------- + device_list.push_back(new ContinuousAO(this, (*devlist_ptr)[i])); + + // Export device to the outside world + // Check before id database used. + //--------------------------------------------- + if (Tango::Util::_UseDb == true) + export_device(device_list.back()); + else + export_device(device_list.back(), (*devlist_ptr)[i]); + } } -} -//+---------------------------------------------------------------------------- -// Method: ContinuousAOClass::attribute_factory(vector<Tango::Attr *> &att_list) -//----------------------------------------------------------------------------- -void ContinuousAOClass::attribute_factory(vector<Tango::Attr *> &att_list) -{ - // Attribute : channel0 - Tango::SpectrumAttr *channel0 = - new Tango::SpectrumAttr("channel0", Tango::DEV_DOUBLE, 1000000); - Tango::UserDefaultAttrProp channel0_prop; - channel0_prop.set_label("channel0"); - channel0_prop.set_unit("volts"); - channel0->set_default_properties(channel0_prop); - att_list.push_back(channel0); - - // Attribute : channel1 - Tango::SpectrumAttr *channel1 = - new Tango::SpectrumAttr("channel1", Tango::DEV_DOUBLE, 100000); - Tango::UserDefaultAttrProp channel1_prop; - channel1_prop.set_label("channel1"); - channel1_prop.set_unit("volts"); - channel1->set_default_properties(channel1_prop); - att_list.push_back(channel1); - - // Attribute : channel2 - Tango::SpectrumAttr *channel2 = - new Tango::SpectrumAttr("channel2", Tango::DEV_DOUBLE, 100000); - Tango::UserDefaultAttrProp channel2_prop; - channel2_prop.set_label("channel2"); - channel2_prop.set_unit("volts"); - channel2->set_default_properties(channel2_prop); - att_list.push_back(channel2); - - // Attribute : channel3 - Tango::SpectrumAttr *channel3 = - new Tango::SpectrumAttr("channel3", Tango::DEV_DOUBLE, 100000); - Tango::UserDefaultAttrProp channel3_prop; - channel3_prop.set_label("channel3"); - channel3->set_default_properties(channel3_prop); - att_list.push_back(channel3); - - // Attribute : channel4 - Tango::SpectrumAttr *channel4 = - new Tango::SpectrumAttr("channel4", Tango::DEV_DOUBLE, 100000); - Tango::UserDefaultAttrProp channel4_prop; - channel4_prop.set_label("channel4"); - channel4_prop.set_unit("volts"); - channel4->set_default_properties(channel4_prop); - att_list.push_back(channel4); - - // Attribute : channel5 - Tango::SpectrumAttr *channel5 = - new Tango::SpectrumAttr("channel5", Tango::DEV_DOUBLE, 100000); - Tango::UserDefaultAttrProp channel5_prop; - channel5_prop.set_label("channel"); - channel5_prop.set_unit("volts"); - channel5->set_default_properties(channel5_prop); - att_list.push_back(channel5); - - // Attribute : channel6 - Tango::SpectrumAttr *channel6 = - new Tango::SpectrumAttr("channel6", Tango::DEV_DOUBLE, 100000); - Tango::UserDefaultAttrProp channel6_prop; - channel6_prop.set_label("channel6"); - channel6_prop.set_unit("volts"); - channel6->set_default_properties(channel6_prop); - att_list.push_back(channel6); - - // Attribute : channel7 - Tango::SpectrumAttr *channel7 = - new Tango::SpectrumAttr("channel7", Tango::DEV_DOUBLE, 100000); - Tango::UserDefaultAttrProp channel7_prop; - channel7_prop.set_label("channel7"); - channel7_prop.set_unit("volts"); - channel7->set_default_properties(channel7_prop); - att_list.push_back(channel7); - - // Attribute : errorCounter - Tango::Attr *error_counter = - new Tango::Attr("errorCounter", Tango::DEV_DOUBLE, Tango::READ); - Tango::UserDefaultAttrProp error_counter_prop; - error_counter_prop.set_label("error counter"); - error_counter_prop.set_format("%i"); - error_counter_prop.set_description("Errors occuring during the waveform generation."); - error_counter->set_default_properties(error_counter_prop); - att_list.push_back(error_counter); - - // Attribute : useBoardFifo - Tango::Attr *use_board_fifo = - new Tango::Attr("useBoardFifo", Tango::DEV_SHORT, Tango::READ); - Tango::UserDefaultAttrProp use_board_fifo_prop; - use_board_fifo_prop.set_label("use board FIFO"); - use_board_fifo_prop.set_description("Set to 1 if data have been loaded in FIFO.\nSet to 0 if data is continuously tranfered through DMA (possible underrun)"); - use_board_fifo->set_default_properties(use_board_fifo_prop); - att_list.push_back(use_board_fifo); - - // Attribute : channel0Enable - Tango::Attr *channel0_enable = - new Tango::Attr("channel0Enable", Tango::DEV_SHORT, Tango::READ); - Tango::UserDefaultAttrProp channel0_enable_prop; - channel0_enable_prop.set_label("channel0Enable"); - channel0_enable_prop.set_description("If equals to 1, data is output on channel 0, otherwise the channel is disable."); - channel0_enable->set_default_properties(channel0_enable_prop); - att_list.push_back(channel0_enable); - - // Attribute : channel1Enable - Tango::Attr *channel1_enable = - new Tango::Attr("channel1Enable", Tango::DEV_SHORT, Tango::READ); - Tango::UserDefaultAttrProp channel1_enable_prop; - channel1_enable_prop.set_label("channel1Enable"); - channel1_enable_prop.set_description("If equals to 1, data is output on channel 1, otherwise the channel is disable."); - channel1_enable->set_default_properties(channel1_enable_prop); - att_list.push_back(channel1_enable); - - // Attribute : channel2Enable - Tango::Attr *channel2_enable = - new Tango::Attr("channel2Enable", Tango::DEV_SHORT, Tango::READ); - Tango::UserDefaultAttrProp channel2_enable_prop; - channel2_enable_prop.set_label("channel2Enable"); - channel2_enable_prop.set_description("If equals to 1, data is output on channel 2, otherwise the channel is disable."); - channel2_enable->set_default_properties(channel2_enable_prop); - att_list.push_back(channel2_enable); - - // Attribute : channel3Enable - Tango::Attr *channel3_enable = - new Tango::Attr("channel3Enable", Tango::DEV_SHORT, Tango::READ); - Tango::UserDefaultAttrProp channel3_enable_prop; - channel3_enable_prop.set_label("channel3Enable"); - channel3_enable_prop.set_description("If equals to 1, data is output on channel 3, otherwise the channel is disable."); - channel3_enable->set_default_properties(channel3_enable_prop); - att_list.push_back(channel3_enable); - - // Attribute : channel4Enable - Tango::Attr *channel4_enable = - new Tango::Attr("channel4Enable", Tango::DEV_SHORT, Tango::READ); - Tango::UserDefaultAttrProp channel4_enable_prop; - channel4_enable_prop.set_label("channel4Enable"); - channel4_enable_prop.set_description("If equals to 1, data is output on channel 4, otherwise the channel is disable."); - channel4_enable->set_default_properties(channel4_enable_prop); - att_list.push_back(channel4_enable); - - // Attribute : channel5Enable - Tango::Attr *channel5_enable = - new Tango::Attr("channel5Enable", Tango::DEV_SHORT, Tango::READ); - Tango::UserDefaultAttrProp channel5_enable_prop; - channel5_enable_prop.set_label("channel5Enable"); - channel5_enable_prop.set_description("If equals to 1, data is output on channel 5, otherwise the channel is disable."); - channel5_enable->set_default_properties(channel5_enable_prop); - att_list.push_back(channel5_enable); - - // Attribute : channel6Enable - Tango::Attr *channel6_enable = - new Tango::Attr("channel6Enable", Tango::DEV_SHORT, Tango::READ); - Tango::UserDefaultAttrProp channel6_enable_prop; - channel6_enable_prop.set_label("channel6Enable"); - channel6_enable_prop.set_description("If equals to 1, data is output on channel 6, otherwise the channel is disable."); - channel6_enable->set_default_properties(channel6_enable_prop); - att_list.push_back(channel6_enable); - - // Attribute : channel7Enable - Tango::Attr *channel7_enable = - new Tango::Attr("channel7Enable", Tango::DEV_SHORT, Tango::READ); - Tango::UserDefaultAttrProp channel7_enable_prop; - channel7_enable_prop.set_label("channel7Enable"); - channel7_enable_prop.set_description("If equals to 1, data is output on channel 7, otherwise the channel is disable."); - channel7_enable->set_default_properties(channel7_enable_prop); - att_list.push_back(channel7_enable); - -} -//+---------------------------------------------------------------------------- -// -// method : ContinuousAOClass::write_class_property -// -// description : Set class description as property in database -// -//----------------------------------------------------------------------------- -void ContinuousAOClass::write_class_property() -{ - // First time, check if database used - //-------------------------------------------- - if (Tango::Util::_UseDb == false) - return; - - // Prepeare DbDatum - //-------------------------------------------- - Tango::DbDatum title("ProjectTitle"); - string str_title("Continuous Anolog Output"); - title << str_title; - - Tango::DbDatum description("Description"); - string str_desc("Perform continuous anolog ouput (waveform generation) on the selected outputs."); - description << str_desc; - + //+---------------------------------------------------------------------------- + // Method: ContinuousAOClass::attribute_factory(vector<Tango::Attr *> &att_list) + //----------------------------------------------------------------------------- + void ContinuousAOClass::attribute_factory(vector<Tango::Attr *> &att_list) + { + // Attribute : channel0 + Tango::SpectrumAttr *channel0 = + new Tango::SpectrumAttr("channel0", Tango::DEV_DOUBLE, 1000000); + Tango::UserDefaultAttrProp channel0_prop; + channel0_prop.set_label("channel0"); + channel0_prop.set_unit("volts"); + channel0->set_default_properties(channel0_prop); + att_list.push_back(channel0); + + // Attribute : channel1 + Tango::SpectrumAttr *channel1 = + new Tango::SpectrumAttr("channel1", Tango::DEV_DOUBLE, 100000); + Tango::UserDefaultAttrProp channel1_prop; + channel1_prop.set_label("channel1"); + channel1_prop.set_unit("volts"); + channel1->set_default_properties(channel1_prop); + att_list.push_back(channel1); + + // Attribute : channel2 + Tango::SpectrumAttr *channel2 = + new Tango::SpectrumAttr("channel2", Tango::DEV_DOUBLE, 100000); + Tango::UserDefaultAttrProp channel2_prop; + channel2_prop.set_label("channel2"); + channel2_prop.set_unit("volts"); + channel2->set_default_properties(channel2_prop); + att_list.push_back(channel2); + + // Attribute : channel3 + Tango::SpectrumAttr *channel3 = + new Tango::SpectrumAttr("channel3", Tango::DEV_DOUBLE, 100000); + Tango::UserDefaultAttrProp channel3_prop; + channel3_prop.set_label("channel3"); + channel3->set_default_properties(channel3_prop); + att_list.push_back(channel3); + + // Attribute : channel4 + Tango::SpectrumAttr *channel4 = + new Tango::SpectrumAttr("channel4", Tango::DEV_DOUBLE, 100000); + Tango::UserDefaultAttrProp channel4_prop; + channel4_prop.set_label("channel4"); + channel4_prop.set_unit("volts"); + channel4->set_default_properties(channel4_prop); + att_list.push_back(channel4); + + // Attribute : channel5 + Tango::SpectrumAttr *channel5 = + new Tango::SpectrumAttr("channel5", Tango::DEV_DOUBLE, 100000); + Tango::UserDefaultAttrProp channel5_prop; + channel5_prop.set_label("channel"); + channel5_prop.set_unit("volts"); + channel5->set_default_properties(channel5_prop); + att_list.push_back(channel5); + + // Attribute : channel6 + Tango::SpectrumAttr *channel6 = + new Tango::SpectrumAttr("channel6", Tango::DEV_DOUBLE, 100000); + Tango::UserDefaultAttrProp channel6_prop; + channel6_prop.set_label("channel6"); + channel6_prop.set_unit("volts"); + channel6->set_default_properties(channel6_prop); + att_list.push_back(channel6); + + // Attribute : channel7 + Tango::SpectrumAttr *channel7 = + new Tango::SpectrumAttr("channel7", Tango::DEV_DOUBLE, 100000); + Tango::UserDefaultAttrProp channel7_prop; + channel7_prop.set_label("channel7"); + channel7_prop.set_unit("volts"); + channel7->set_default_properties(channel7_prop); + att_list.push_back(channel7); + + // Attribute : errorCounter + Tango::Attr *error_counter = + new Tango::Attr("errorCounter", Tango::DEV_DOUBLE, Tango::READ); + Tango::UserDefaultAttrProp error_counter_prop; + error_counter_prop.set_label("error counter"); + error_counter_prop.set_format("%i"); + error_counter_prop.set_description("Errors occuring during the waveform generation."); + error_counter->set_default_properties(error_counter_prop); + att_list.push_back(error_counter); + + // Attribute : useBoardFifo + Tango::Attr *use_board_fifo = + new Tango::Attr("useBoardFifo", Tango::DEV_SHORT, Tango::READ); + Tango::UserDefaultAttrProp use_board_fifo_prop; + use_board_fifo_prop.set_label("use board FIFO"); + use_board_fifo_prop.set_description("Set to 1 if data have been loaded in FIFO.\nSet to 0 if data is continuously tranfered through DMA (possible underrun)"); + use_board_fifo->set_default_properties(use_board_fifo_prop); + att_list.push_back(use_board_fifo); + + // Attribute : channel0Enable + Tango::Attr *channel0_enable = + new Tango::Attr("channel0Enable", Tango::DEV_SHORT, Tango::READ); + Tango::UserDefaultAttrProp channel0_enable_prop; + channel0_enable_prop.set_label("channel0Enable"); + channel0_enable_prop.set_description("If equals to 1, data is output on channel 0, otherwise the channel is disable."); + channel0_enable->set_default_properties(channel0_enable_prop); + att_list.push_back(channel0_enable); + + // Attribute : channel1Enable + Tango::Attr *channel1_enable = + new Tango::Attr("channel1Enable", Tango::DEV_SHORT, Tango::READ); + Tango::UserDefaultAttrProp channel1_enable_prop; + channel1_enable_prop.set_label("channel1Enable"); + channel1_enable_prop.set_description("If equals to 1, data is output on channel 1, otherwise the channel is disable."); + channel1_enable->set_default_properties(channel1_enable_prop); + att_list.push_back(channel1_enable); + + // Attribute : channel2Enable + Tango::Attr *channel2_enable = + new Tango::Attr("channel2Enable", Tango::DEV_SHORT, Tango::READ); + Tango::UserDefaultAttrProp channel2_enable_prop; + channel2_enable_prop.set_label("channel2Enable"); + channel2_enable_prop.set_description("If equals to 1, data is output on channel 2, otherwise the channel is disable."); + channel2_enable->set_default_properties(channel2_enable_prop); + att_list.push_back(channel2_enable); + + // Attribute : channel3Enable + Tango::Attr *channel3_enable = + new Tango::Attr("channel3Enable", Tango::DEV_SHORT, Tango::READ); + Tango::UserDefaultAttrProp channel3_enable_prop; + channel3_enable_prop.set_label("channel3Enable"); + channel3_enable_prop.set_description("If equals to 1, data is output on channel 3, otherwise the channel is disable."); + channel3_enable->set_default_properties(channel3_enable_prop); + att_list.push_back(channel3_enable); + + // Attribute : channel4Enable + Tango::Attr *channel4_enable = + new Tango::Attr("channel4Enable", Tango::DEV_SHORT, Tango::READ); + Tango::UserDefaultAttrProp channel4_enable_prop; + channel4_enable_prop.set_label("channel4Enable"); + channel4_enable_prop.set_description("If equals to 1, data is output on channel 4, otherwise the channel is disable."); + channel4_enable->set_default_properties(channel4_enable_prop); + att_list.push_back(channel4_enable); + + // Attribute : channel5Enable + Tango::Attr *channel5_enable = + new Tango::Attr("channel5Enable", Tango::DEV_SHORT, Tango::READ); + Tango::UserDefaultAttrProp channel5_enable_prop; + channel5_enable_prop.set_label("channel5Enable"); + channel5_enable_prop.set_description("If equals to 1, data is output on channel 5, otherwise the channel is disable."); + channel5_enable->set_default_properties(channel5_enable_prop); + att_list.push_back(channel5_enable); + + // Attribute : channel6Enable + Tango::Attr *channel6_enable = + new Tango::Attr("channel6Enable", Tango::DEV_SHORT, Tango::READ); + Tango::UserDefaultAttrProp channel6_enable_prop; + channel6_enable_prop.set_label("channel6Enable"); + channel6_enable_prop.set_description("If equals to 1, data is output on channel 6, otherwise the channel is disable."); + channel6_enable->set_default_properties(channel6_enable_prop); + att_list.push_back(channel6_enable); + + // Attribute : channel7Enable + Tango::Attr *channel7_enable = + new Tango::Attr("channel7Enable", Tango::DEV_SHORT, Tango::READ); + Tango::UserDefaultAttrProp channel7_enable_prop; + channel7_enable_prop.set_label("channel7Enable"); + channel7_enable_prop.set_description("If equals to 1, data is output on channel 7, otherwise the channel is disable."); + channel7_enable->set_default_properties(channel7_enable_prop); + att_list.push_back(channel7_enable); + + } + //+---------------------------------------------------------------------------- + // + // method : ContinuousAOClass::write_class_property + // + // description : Set class description as property in database + // + //----------------------------------------------------------------------------- + void ContinuousAOClass::write_class_property() + { + // First time, check if database used + //-------------------------------------------- + if (Tango::Util::_UseDb == false) + return; + + // Prepeare DbDatum + //-------------------------------------------- + Tango::DbDatum title("ProjectTitle"); + string str_title("Continuous Anolog Output"); + title << str_title; + + Tango::DbDatum description("Description"); + string str_desc("Perform continuous anolog ouput (waveform generation) on the selected outputs."); + description << str_desc; + // Use the doc_url field to store all information // on the server version and CVS string::size_type pos, len; - + // 1) Manage module name // get rid of the $RCSfile: prefix and of Class.cpp suffix string classname = RCSfile; - + pos = classname.find("$RCSfile: "); len = classname.length(); - + if (pos != string::npos) classname= classname.substr(pos+10, len- pos-10); pos = classname.find ("Class.cpp",0); if (pos != string::npos) classname=classname.substr(0,pos); - + // 2) Manage version number with SOLEIL CVS rules // tag name is in the form : release_1_0 ==> transform it to 1.0 // string version ; string str_TagName=string(TagName); - + pos = str_TagName.find_first_of("_",0); if (pos != string::npos) version= str_TagName.substr(pos+1, 3); @@ -641,15 +641,15 @@ void ContinuousAOClass::write_class_property() if (pos != string::npos) version[pos] = '.'; - - // Store all info in the str_url property - + + // Store all info in the str_url property + string str_url= "Documentation URL = " + string(HttpServer) + classname +"-" + version + "/index.html" + "\n"; str_url= str_url + " Version CVS Tag = " + string(TagName)+ "\n"; str_url= str_url + " CVS location = " + string(FileName)+ "\n"; - + Tango::DbDatum doc_url("doc_url"); - + doc_url << str_url; // Push everything in DataBase @@ -661,6 +661,6 @@ void ContinuousAOClass::write_class_property() // Call database and and values //-------------------------------------------- get_db_class()->put_property(data); -} + } } // namespace diff --git a/src/ContinuousAOClass.h b/src/ContinuousAOClass.h index 428e48a..4870ad5 100644 --- a/src/ContinuousAOClass.h +++ b/src/ContinuousAOClass.h @@ -35,74 +35,74 @@ namespace ContinuousAO { -// -// Define classes for commands -// -class SetAOScaledDataCmd : public Tango::Command -{ -public: - SetAOScaledDataCmd(const char *,Tango::CmdArgType, Tango::CmdArgType,const char *,const char *, Tango::DispLevel); - SetAOScaledDataCmd(const char *,Tango::CmdArgType, Tango::CmdArgType); - ~SetAOScaledDataCmd() {}; - - virtual bool is_allowed (Tango::DeviceImpl *, const CORBA::Any &); - virtual CORBA::Any *execute (Tango::DeviceImpl *, const CORBA::Any &); -}; - - -class StopCmd : public Tango::Command -{ -public: - StopCmd(const char *,Tango::CmdArgType, Tango::CmdArgType,const char *,const char *, Tango::DispLevel); - StopCmd(const char *,Tango::CmdArgType, Tango::CmdArgType); - ~StopCmd() {}; - - virtual bool is_allowed (Tango::DeviceImpl *, const CORBA::Any &); - virtual CORBA::Any *execute (Tango::DeviceImpl *, const CORBA::Any &); -}; - - -class StartCmd : public Tango::Command -{ -public: - StartCmd(const char *,Tango::CmdArgType, Tango::CmdArgType,const char *,const char *, Tango::DispLevel); - StartCmd(const char *,Tango::CmdArgType, Tango::CmdArgType); - ~StartCmd() {}; - - virtual bool is_allowed (Tango::DeviceImpl *, const CORBA::Any &); - virtual CORBA::Any *execute (Tango::DeviceImpl *, const CORBA::Any &); -}; - - - -// -// The ContinuousAOClass singleton definition -// - -class ContinuousAOClass : public Tango::DeviceClass -{ -public: - -// add your own data members here -//------------------------------------ - -public: - -// Method prototypes - static ContinuousAOClass *init(const char *); - static ContinuousAOClass *instance(); - ~ContinuousAOClass(); - -protected: - ContinuousAOClass(string &); - static ContinuousAOClass *_instance; - void command_factory(); - void attribute_factory(vector<Tango::Attr *> &); - void write_class_property(); - -private: - void device_factory(const Tango::DevVarStringArray *); -}; + // + // Define classes for commands + // + class SetAOScaledDataCmd : public Tango::Command + { + public: + SetAOScaledDataCmd(const char *,Tango::CmdArgType, Tango::CmdArgType,const char *,const char *, Tango::DispLevel); + SetAOScaledDataCmd(const char *,Tango::CmdArgType, Tango::CmdArgType); + ~SetAOScaledDataCmd() {}; + + virtual bool is_allowed (Tango::DeviceImpl *, const CORBA::Any &); + virtual CORBA::Any *execute (Tango::DeviceImpl *, const CORBA::Any &); + }; + + + class StopCmd : public Tango::Command + { + public: + StopCmd(const char *,Tango::CmdArgType, Tango::CmdArgType,const char *,const char *, Tango::DispLevel); + StopCmd(const char *,Tango::CmdArgType, Tango::CmdArgType); + ~StopCmd() {}; + + virtual bool is_allowed (Tango::DeviceImpl *, const CORBA::Any &); + virtual CORBA::Any *execute (Tango::DeviceImpl *, const CORBA::Any &); + }; + + + class StartCmd : public Tango::Command + { + public: + StartCmd(const char *,Tango::CmdArgType, Tango::CmdArgType,const char *,const char *, Tango::DispLevel); + StartCmd(const char *,Tango::CmdArgType, Tango::CmdArgType); + ~StartCmd() {}; + + virtual bool is_allowed (Tango::DeviceImpl *, const CORBA::Any &); + virtual CORBA::Any *execute (Tango::DeviceImpl *, const CORBA::Any &); + }; + + + + // + // The ContinuousAOClass singleton definition + // + + class ContinuousAOClass : public Tango::DeviceClass + { + public: + + // add your own data members here + //------------------------------------ + + public: + + // Method prototypes + static ContinuousAOClass *init(const char *); + static ContinuousAOClass *instance(); + ~ContinuousAOClass(); + + protected: + ContinuousAOClass(string &); + static ContinuousAOClass *_instance; + void command_factory(); + void attribute_factory(vector<Tango::Attr *> &); + void write_class_property(); + + private: + void device_factory(const Tango::DevVarStringArray *); + }; } // namespace ContinuousAO diff --git a/src/main.cpp b/src/main.cpp index 12ef034..d8553ad 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -50,7 +50,7 @@ DECLARE_CRASH_HANDLER; int main(int argc, char *argv[]) { - INSTALL_CRASH_HANDLER; + INSTALL_CRASH_HANDLER; Tango::Util *tg = 0; @@ -78,7 +78,7 @@ int main(int argc, char *argv[]) catch (CORBA::Exception &e) { Tango::Except::print_exception(e); - + cout << "Received a CORBA_Exception" << endl; cout << "Exiting" << endl; } @@ -86,6 +86,6 @@ int main(int argc, char *argv[]) // clean ORB, threads..... //-------------------------- tg->server_cleanup(); - + return(0); } -- GitLab