From be1204128ec1e3634a03e28ea395fef71fcc54e8 Mon Sep 17 00:00:00 2001 From: ingvord Date: Thu, 23 Aug 2018 13:41:18 +0300 Subject: [PATCH 01/18] Backport #357: DevEnum support for commands [2h] --- .travis.yml | 2 +- CMakeLists.txt | 1 + cpp_test_suite/cpp_test_ds/DevTest.cpp | 2911 +++++++++-------- cpp_test_suite/cpp_test_ds/DevTestClass.cpp | 1654 +++++----- cpp_test_suite/cpp_test_ds/TypeCmds.cpp | 20 + cpp_test_suite/cpp_test_ds/TypeCmds.h | 10 + cpp_test_suite/cxxtest/CMakeLists.txt | 2 + cpp_test_suite/event/CMakeLists.txt | 34 +- cpp_test_suite/event/att_conf_event.cpp | 5 +- cpp_test_suite/event/change_event.cpp | 5 +- cpp_test_suite/new_tests/cxx_blackbox.cpp | 3 +- .../new_tests/cxx_cmd_inout_enum.cpp | 201 ++ .../new_tests/cxx_misc_devproxy.cpp | 447 +++ cpp_test_suite/old_tests/CMakeLists.txt | 3 - cpp_test_suite/old_tests/copy_devproxy.cpp | 4 +- cpp_test_suite/old_tests/misc_devproxy.cpp | 369 --- cpp_test_suite/old_tests/size.cpp | 16 +- cppapi/client/CMakeLists.txt | 6 +- cppapi/client/Connection.h | 4 +- cppapi/client/DeviceProxy.h | 2 + cppapi/client/devapi.h | 48 +- cppapi/client/devapi_base.cpp | 270 +- cppapi/client/device_command_info.cpp | 89 + cppapi/client/device_command_info.h | 126 + cppapi/client/proxy_asyn.cpp | 20 +- cppapi/client/proxy_asyn_cb.cpp | 5 +- cppapi/server/CMakeLists.txt | 2 + cppapi/server/attribute.cpp | 48 +- cppapi/server/attribute.h | 30 +- cppapi/server/blackbox.cpp | 4 +- cppapi/server/device_2.cpp | 132 +- cppapi/server/device_2.h | 3 + cppapi/server/device_6.cpp | 85 + cppapi/server/device_6.h | 84 + cppapi/server/eventcmds.cpp | 27 +- cppapi/server/eventsupplier.cpp | 18 +- cppapi/server/tango.h | 1 + cppapi/server/tango_const.h.in | 4 +- cppapi/server/zmqeventsupplier.cpp | 6 +- 39 files changed, 3767 insertions(+), 2934 deletions(-) create mode 100644 cpp_test_suite/new_tests/cxx_cmd_inout_enum.cpp create mode 100644 cpp_test_suite/new_tests/cxx_misc_devproxy.cpp delete mode 100644 cpp_test_suite/old_tests/misc_devproxy.cpp create mode 100644 cppapi/client/device_command_info.cpp create mode 100644 cppapi/client/device_command_info.h create mode 100644 cppapi/server/device_6.cpp create mode 100644 cppapi/server/device_6.h diff --git a/.travis.yml b/.travis.yml index 69cc95516..c2af78013 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,7 +24,7 @@ before_install: - .travis/${OS_TYPE}/before_install.sh - docker pull tangocs/mysql:9.2.2 - docker pull tangocs/tango-cs:latest - - git clone -b tango-9-lts https://${CI_USER_TOKEN}@github.com/tango-controls/tango-idl.git idl + - git clone -b cppTango-351 https://${CI_USER_TOKEN}@github.com/tango-controls/tango-idl.git idl - chmod +x .travis/${OS_TYPE}/run.sh before_script: diff --git a/CMakeLists.txt b/CMakeLists.txt index 89d9c767d..9adf9121a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,5 @@ cmake_minimum_required(VERSION 2.8.12) +project(tango) include(CTest) enable_testing() diff --git a/cpp_test_suite/cpp_test_ds/DevTest.cpp b/cpp_test_suite/cpp_test_ds/DevTest.cpp index 1698bd917..4b3fd066b 100644 --- a/cpp_test_suite/cpp_test_ds/DevTest.cpp +++ b/cpp_test_suite/cpp_test_ds/DevTest.cpp @@ -1,40 +1,38 @@ #include #include +#include "IOAddAttribute.h" #ifdef WIN32 #include #include #else -#include #endif -#include - -void EventCallBack::push_event(Tango::EventData* event_data) +void EventCallBack::push_event(Tango::EventData *event_data) { - short value; + short value; - cb_executed++; - try - { - cout << "EventCallBack::push_event(): called attribute " << event_data->attr_name; - cout << " event " << event_data->event << endl; - if (!event_data->err) - { - *(event_data->attr_value) >> value; - cout << "CallBack vector value : " << value << endl; - } - else - { - cout << "Error sent to callback" << endl; + cb_executed++; + try + { + cout << "EventCallBack::push_event(): called attribute " << event_data->attr_name; + cout << " event " << event_data->event << endl; + if (!event_data->err) + { + *(event_data->attr_value) >> value; + cout << "CallBack vector value : " << value << endl; + } + else + { + cout << "Error sent to callback" << endl; // Tango::Except::print_error_stack(event_data->errors); - cb_err++; - } - } - catch (...) - { - cout << "EventCallBack::push_event(): could not extract data !\n"; - } + cb_err++; + } + } + catch (...) + { + cout << "EventCallBack::push_event(): could not extract data !\n"; + } } @@ -51,126 +49,113 @@ void EventCallBack::push_event(Tango::EventData* event_data) //----------------------------------------------------------------------------- #ifndef COMPAT -DevTest::DevTest(Tango::DeviceClass *cl,string &s):TANGO_BASE_CLASS(cl,s.c_str()) -{ - init_device(); -} -DevTest::DevTest(Tango::DeviceClass *cl,const char *s):TANGO_BASE_CLASS(cl,s) +DevTest::DevTest(Tango::DeviceClass *cl, string &s) + : TANGO_BASE_CLASS(cl, s) { - init_device(); -} - -DevTest::DevTest(Tango::DeviceClass *cl,const char *s,const char *d) -:TANGO_BASE_CLASS(cl,s,d) -{ - init_device(); -} - -DevTest::DevTest(Tango::DeviceClass *cl,const char *s,const char *d, Tango::DevState state, const char *status ) -:TANGO_BASE_CLASS(cl,s,d, state, status) -{ - init_device(); + init_device(); } #else DevTest::DevTest(Tango::DeviceClass *cl,string &s):Tango::Device_3Impl(cl,s.c_str()) { - init_device(); + init_device(); } DevTest::DevTest(Tango::DeviceClass *cl,const char *s):Tango::Device_3Impl(cl,s) { - init_device(); + init_device(); } DevTest::DevTest(Tango::DeviceClass *cl,const char *s,const char *d) :Tango::Device_3Impl(cl,s,d) { - init_device(); + init_device(); } DevTest::DevTest(Tango::DeviceClass *cl,const char *s,const char *d, Tango::DevState state, const char *status ) :Tango::Device_3Impl(cl,s,d, state, status) { - init_device(); + init_device(); } #endif void DevTest::init_device() { - cout << "DevTest::DevTest() create " << device_name << endl; - DEBUG_STREAM << "Creating " << device_name << endl; - - Tango::Util *tg = Tango::Util::instance(); - - set_state(Tango::ON); - attr_long = 1246; - attr_short_rw = 66; - attr_long64_rw = 0x800000000LL; - attr_ulong_rw = 0xC0000000L; - attr_ulong64_rw = 0xC000000000000000LL; - attr_state_rw = Tango::FAULT; - PollLong_attr_num = 0; - PollString_spec_attr_num = 0; - - Short_attr_except = false; - if (tg->is_svr_starting() == true || tg->is_device_restarting(device_name) == true) - Short_attr_w_except = false; - event_change_attr_except = false; - event_quality_attr_except = false; - event_throw_out_of_sync = false; - - attr_sub_device_tst = false; - - attr_event_size = 4; - attr_event[0] = 10; - attr_event[1] = 20; - attr_event[2] = 30; - attr_event[3] = 40; - attr_event[4] = 50; - attr_event[5] = 60; - attr_event[6] = 70; - attr_event[7] = 80; - attr_event[8] = 90; - attr_event[9] = 100; - - attr_event64_size = 2; - attr_event64[0] = 0x800000000LL; - attr_event64[1] = 44; - attr_event64[2] = 55; - - attr_qua_event[0] = 1.2; - attr_qua_event[1] = 2.4; - attr_event_qua = Tango::ATTR_VALID; - remote_dev = NULL; - - slow_actua_write.tv_sec = 0; - slow_actua = 0; - - attr_spec_long64_rw[0] = 1000; - attr_spec_long64_rw[1] = 10000; - attr_spec_long64_rw[2] = 100000; - attr_spec_ulong_rw[0] = 2222; - attr_spec_ulong_rw[1] = 22222; - attr_spec_ulong_rw[2] = 222222; - attr_spec_ulong64_rw[0] = 8888; - attr_spec_ulong64_rw[1] = 88888; - attr_spec_ulong64_rw[2] = 888888; - attr_spec_state_rw[0] = Tango::ON; - attr_spec_state_rw[1] = Tango::OFF; - - attr_slow = 3.3; + cout << "DevTest::DevTest() create " << device_name << endl; + DEBUG_STREAM << "Creating " << device_name << endl; + + Tango::Util *tg = Tango::Util::instance(); + + set_state(Tango::ON); + attr_long = 1246; + attr_short_rw = 66; + attr_long64_rw = 0x800000000LL; + attr_ulong_rw = 0xC0000000L; + attr_ulong64_rw = 0xC000000000000000LL; + attr_state_rw = Tango::FAULT; + PollLong_attr_num = 0; + PollString_spec_attr_num = 0; + + Short_attr_except = false; + if (tg->is_svr_starting() == true || tg->is_device_restarting(device_name) == true) + { + Short_attr_w_except = false; + } + event_change_attr_except = false; + event_quality_attr_except = false; + event_throw_out_of_sync = false; + + attr_sub_device_tst = false; + + attr_event_size = 4; + attr_event[0] = 10; + attr_event[1] = 20; + attr_event[2] = 30; + attr_event[3] = 40; + attr_event[4] = 50; + attr_event[5] = 60; + attr_event[6] = 70; + attr_event[7] = 80; + attr_event[8] = 90; + attr_event[9] = 100; + + attr_event64_size = 2; + attr_event64[0] = 0x800000000LL; + attr_event64[1] = 44; + attr_event64[2] = 55; + + attr_qua_event[0] = 1.2; + attr_qua_event[1] = 2.4; + attr_event_qua = Tango::ATTR_VALID; + remote_dev = NULL; + + slow_actua_write.tv_sec = 0; + slow_actua = 0; + + attr_spec_long64_rw[0] = 1000; + attr_spec_long64_rw[1] = 10000; + attr_spec_long64_rw[2] = 100000; + attr_spec_ulong_rw[0] = 2222; + attr_spec_ulong_rw[1] = 22222; + attr_spec_ulong_rw[2] = 222222; + attr_spec_ulong64_rw[0] = 8888; + attr_spec_ulong64_rw[1] = 88888; + attr_spec_ulong64_rw[2] = 888888; + attr_spec_state_rw[0] = Tango::ON; + attr_spec_state_rw[1] = Tango::OFF; + + attr_slow = 3.3; #ifndef COMPAT - enc_attr.encoded_format = CORBA::string_dup("Which format?"); + enc_attr.encoded_format = CORBA::string_dup("Which format?"); /* enc_attr.encoded_data.length(200 * 1024 * 1024); for (int i = 0;i < (200 * 1024 * 1024);i++) enc_attr.encoded_data[i] = (unsigned char)(i % 256);*/ - enc_attr.encoded_data.length(4); - enc_attr.encoded_data[0] = (unsigned char)97; - enc_attr.encoded_data[1] = (unsigned char)98; - enc_attr.encoded_data[2] = (unsigned char)99; - enc_attr.encoded_data[3] = (unsigned char)100; + enc_attr.encoded_data.length(4); + enc_attr.encoded_data[0] = (unsigned char) 97; + enc_attr.encoded_data[1] = (unsigned char) 98; + enc_attr.encoded_data[2] = (unsigned char) 99; + enc_attr.encoded_data[3] = (unsigned char) 100; /* enc_format = new char[40]; strcpy(enc_format,"Forth try"); @@ -180,23 +165,56 @@ void DevTest::init_device() att_conf = 10; wattr_throw = 0; - enum_value = 2; + enum_value = 2; - Tango::Attribute &att = (get_device_attr())->get_attr_by_name("DynEnum_attr"); - Tango::MultiAttrProp multi_prop; - att.get_properties(multi_prop); - if (multi_prop.enum_labels.empty() == true) - multi_prop.enum_labels.push_back("Dummy_label"); - att.set_properties(multi_prop); + Tango::Attribute &att = (get_device_attr())->get_attr_by_name("DynEnum_attr"); + Tango::MultiAttrProp multi_prop; + att.get_properties(multi_prop); + if (multi_prop.enum_labels.empty() == true) + { + multi_prop.enum_labels.push_back("Dummy_label"); + } + att.set_properties(multi_prop); - rpipe_type = 0; - Tango::Pipe &pi = get_device_class()->get_pipe_by_name("RWPipe",device_name_lower); - pi.set_pipe_serial_model(Tango::PIPE_BY_USER); + rpipe_type = 0; + Tango::Pipe &pi = get_device_class()->get_pipe_by_name("RWPipe", device_name_lower); + pi.set_pipe_serial_model(Tango::PIPE_BY_USER); Reynald_ctr = 0; Reynald_val = 9.9; - cout << "DevTest::DevTest(): End of init_device() method for device " << device_name << endl; + class EnumLabelsDynCommand: public DynCommand + { + public: + EnumLabelsDynCommand() + : DynCommand( + "EnumLabelsDynCommand", Tango::CmdArgType::DEV_ENUM, Tango::CmdArgType::DEV_ENUM, "", "Enum labels") + { + set_in_enum_labels({"IN Dyn Label 1", "IN Dyn Label 2", "IN Dyn Label 3"}); + set_out_enum_labels({"OUT Dyn Label 1", "OUT Dyn Label 2", "OUT Dyn Label 3"}); + } + }; + + class EnumLabelsDynCommandPolled: public DynCommand + { + public: + EnumLabelsDynCommandPolled() + : DynCommand( + "EnumLabelsDynCommandPolled", Tango::CmdArgType::DEV_VOID, Tango::CmdArgType::DEV_ENUM, "", "Enum labels") + { + set_out_enum_labels({"OUT Dyn Label 1", "OUT Dyn Label 2", "OUT Dyn Label 3"}); + } + + virtual CORBA::Any *execute(Tango::DeviceImpl *, const CORBA::Any &) + { + return insert((Tango::DevEnum) 1); + } + }; + + this->add_command(new EnumLabelsDynCommand(), true); + this->add_command(new EnumLabelsDynCommandPolled(), false); + + cout << "DevTest::DevTest(): End of init_device() method for device " << device_name << endl; } @@ -212,7 +230,7 @@ void DevTest::init_device() void DevTest::always_executed_hook() { - cout2 << "In always_executed_hook method" << endl; + cout2 << "In always_executed_hook method" << endl; } @@ -229,13 +247,13 @@ void DevTest::always_executed_hook() Tango::ConstDevString DevTest::dev_status() { - cout2 << "In DayOfWeek state command" << endl; + cout2 << "In DayOfWeek state command" << endl; #ifdef WIN32 - Tango::ConstDevString stat = DeviceImpl::dev_status(); + Tango::ConstDevString stat = DeviceImpl::dev_status(); #else - Tango::ConstDevString stat = Tango::DeviceImpl::dev_status(); + Tango::ConstDevString stat = Tango::DeviceImpl::dev_status(); #endif - return stat; + return stat; } //+---------------------------------------------------------------------------- @@ -252,65 +270,68 @@ bool DevTest::templ_state(const CORBA::Any &) // command allowed only if the device is on // - if (device_state == Tango::ON) - return(true); - else - return(false); + if (device_state == Tango::ON) + { + return (true); + } + else + { + return (false); + } } void DevTest::IOTempl() { - cout << "[DevTest::IOTempl]" << endl; + cout << "[DevTest::IOTempl]" << endl; } Tango::DevVarLongArray *DevTest::IOTemplOut() { - cout << "[DevTest::IOTemplOut]" << endl; + cout << "[DevTest::IOTemplOut]" << endl; - Tango::DevVarLongArray *argout; - argout = new Tango::DevVarLongArray(); + Tango::DevVarLongArray *argout; + argout = new Tango::DevVarLongArray(); - argout->length(4); - (*argout)[0] = 10; - (*argout)[1] = 20; - (*argout)[2] = 30; - (*argout)[3] = 40; + argout->length(4); + (*argout)[0] = 10; + (*argout)[1] = 20; + (*argout)[2] = 30; + (*argout)[3] = 40; - return argout; + return argout; } void DevTest::IOTemplIn(Tango::DevLong received) { - cout << "[DevTest::IOTemplIn] received " << received << endl; + cout << "[DevTest::IOTemplIn] received " << received << endl; } void DevTest::IOPushEvent() { - cout << "[DevTest::IOPushEvent] received " << endl; + cout << "[DevTest::IOPushEvent] received " << endl; - vector f_names; - vector f_val; + vector f_names; + vector f_val; - push_event("event_change_tst",f_names,f_val,attr_event,attr_event_size); + push_event("event_change_tst", f_names, f_val, attr_event, attr_event_size); } void DevTest::IOPushDevEncodedEvent() { - cout << "[DevTest::IOPushDevEncodedEvent] received " << endl; + cout << "[DevTest::IOPushDevEncodedEvent] received " << endl; #ifndef COMPAT - vector f_names; - vector f_val; + vector f_names; + vector f_val; - push_event("encoded_attr",f_names,f_val,&enc_attr); + push_event("encoded_attr", f_names, f_val, &enc_attr); #endif } - Tango::DevLong DevTest::IOSubscribeEvent(const Tango::DevVarStringArray *in_data) { - cout << "[DevTest::IOSubscribeEvent] received " << endl; + cout << "[DevTest::IOSubscribeEvent] received " << endl; //TODO: modify conf_devtest.cpp to automatically create a remote device based on the instance name @@ -339,58 +360,64 @@ Tango::DevLong DevTest::IOSubscribeEvent(const Tango::DevVarStringArray *in_data // eve_id = remote_dev->subscribe_event(att_name,Tango::PERIODIC_EVENT,&cb,filters); - vector filters; + vector filters; - if (remote_dev == NULL) - { - remote_dev = new Tango::DeviceProxy((*in_data)[0]); - } - string att_name((*in_data)[1]); - cb.cb_executed = 0; + if (remote_dev == NULL) + { + remote_dev = new Tango::DeviceProxy((*in_data)[0]); + } + string att_name((*in_data)[1]); + cb.cb_executed = 0; - // start the polling first! - remote_dev->poll_attribute(att_name,1000); + // start the polling first! + remote_dev->poll_attribute(att_name, 1000); - string eve_type((*in_data)[2]); - transform(eve_type.begin(),eve_type.end(),eve_type.begin(),::tolower); - Tango::EventType eve; - if (eve_type == "change") - eve = Tango::CHANGE_EVENT; - else if (eve_type == "periodic") - eve = Tango::PERIODIC_EVENT; - else if (eve_type == "archive") - eve = Tango::ARCHIVE_EVENT; - else - { - stringstream ss; - ss << "Event type " << (*in_data)[2] << " not recognized as a valid event type"; - Tango::Except::throw_exception("DevTest_WrongEventType",ss.str(),"DevTest::IOSubscribeEvent"); - } + string eve_type((*in_data)[2]); + transform(eve_type.begin(), eve_type.end(), eve_type.begin(), ::tolower); + Tango::EventType eve; + if (eve_type == "change") + { + eve = Tango::CHANGE_EVENT; + } + else if (eve_type == "periodic") + { + eve = Tango::PERIODIC_EVENT; + } + else if (eve_type == "archive") + { + eve = Tango::ARCHIVE_EVENT; + } + else + { + stringstream ss; + ss << "Event type " << (*in_data)[2] << " not recognized as a valid event type"; + Tango::Except::throw_exception("DevTest_WrongEventType", ss.str(), "DevTest::IOSubscribeEvent"); + } - int eve_id = remote_dev->subscribe_event(att_name,eve,&cb,filters); + int eve_id = remote_dev->subscribe_event(att_name, eve, &cb, filters); - event_atts.insert(make_pair(eve_id,att_name)); + event_atts.insert(make_pair(eve_id, att_name)); - return eve_id; + return eve_id; } void DevTest::IOUnSubscribeEvent(Tango::DevLong &in_data) { - cout << "[DevTest::IOUnSubscribeEvent] received " << endl; + cout << "[DevTest::IOUnSubscribeEvent] received " << endl; - if (in_data != 0) - { - map::iterator ite = event_atts.find(in_data); - if (ite == event_atts.end()) - { - Tango::Except::throw_exception("DevTest_WrongEventID", - "Cant find event id in map", - "DevTest::IOUnSubscribeEvent"); - } - remote_dev->unsubscribe_event(in_data); + if (in_data != 0) + { + map::iterator ite = event_atts.find(in_data); + if (ite == event_atts.end()) + { + Tango::Except::throw_exception("DevTest_WrongEventID", + "Cant find event id in map", + "DevTest::IOUnSubscribeEvent"); + } + remote_dev->unsubscribe_event(in_data); - remote_dev->stop_poll_attribute(ite->second); - } + remote_dev->stop_poll_attribute(ite->second); + } } @@ -398,96 +425,96 @@ void DevTest::IOFillPollBuffAttr() { cout << "[DevTest::IOFillPollBuffAttr] received " << endl; - Tango::AttrHistoryStack ahs; - ahs.length(3); - Tango::Util *tg = Tango::Util::instance(); - Tango::DevString *main_array[3]; - string att_name("Poll_buff"); + Tango::AttrHistoryStack ahs; + ahs.length(3); + Tango::Util *tg = Tango::Util::instance(); + Tango::DevString *main_array[3]; + string att_name("Poll_buff"); - Tango::DevString *array_1 = new Tango::DevString [4]; + Tango::DevString *array_1 = new Tango::DevString[4]; // array_1[0] = CORBA::string_dup("One_1"); // array_1[1] = CORBA::string_dup("Two_1"); // array_1[2] = CORBA::string_dup("Three_1"); // array_1[3] = CORBA::string_dup("Four_1"); - array_1[0] = Tango::string_dup("One_1"); - array_1[1] = Tango::string_dup("Two_1"); - array_1[2] = Tango::string_dup("Three_1"); - array_1[3] = Tango::string_dup("Four_1"); - main_array[0] = array_1; - - Tango::DevString *array_2 = new Tango::DevString [4]; - array_2[0] = CORBA::string_dup("One_2"); - array_2[1] = CORBA::string_dup("Two_2"); - array_2[2] = CORBA::string_dup("Three_2"); - array_2[3] = CORBA::string_dup("Four_2"); - main_array[1] = array_2; - - Tango::DevString *array_3 = new Tango::DevString [4]; - array_3[0] = CORBA::string_dup("One_3"); - array_3[1] = CORBA::string_dup("Two_3"); - array_3[2] = CORBA::string_dup("Three_3"); - array_3[3] = CORBA::string_dup("Four_3"); - main_array[2] = array_3; - - ahs.clear(); - time_t when = time(NULL); - for (int k = 0;k < 3;k++) - { - Tango::TimedAttrData tad(main_array[k],2,2,Tango::ATTR_VALID,true,when); - ahs.push(tad); - } + array_1[0] = Tango::string_dup("One_1"); + array_1[1] = Tango::string_dup("Two_1"); + array_1[2] = Tango::string_dup("Three_1"); + array_1[3] = Tango::string_dup("Four_1"); + main_array[0] = array_1; + + Tango::DevString *array_2 = new Tango::DevString[4]; + array_2[0] = CORBA::string_dup("One_2"); + array_2[1] = CORBA::string_dup("Two_2"); + array_2[2] = CORBA::string_dup("Three_2"); + array_2[3] = CORBA::string_dup("Four_2"); + main_array[1] = array_2; + + Tango::DevString *array_3 = new Tango::DevString[4]; + array_3[0] = CORBA::string_dup("One_3"); + array_3[1] = CORBA::string_dup("Two_3"); + array_3[2] = CORBA::string_dup("Three_3"); + array_3[3] = CORBA::string_dup("Four_3"); + main_array[2] = array_3; + + ahs.clear(); + time_t when = time(NULL); + for (int k = 0; k < 3; k++) + { + Tango::TimedAttrData tad(main_array[k], 2, 2, Tango::ATTR_VALID, true, when); + ahs.push(tad); + } - tg->fill_attr_polling_buffer(this,att_name,ahs); + tg->fill_attr_polling_buffer(this, att_name, ahs); - ahs.clear(); - att_name = "Poll_buffRW"; - when = time(NULL); + ahs.clear(); + att_name = "Poll_buffRW"; + when = time(NULL); - Tango::DevString *rd_array_1 = new Tango::DevString[4]; - Tango::DevString *wr_array_1 = new Tango::DevString[2]; + Tango::DevString *rd_array_1 = new Tango::DevString[4]; + Tango::DevString *wr_array_1 = new Tango::DevString[2]; - rd_array_1[0] = CORBA::string_dup("One_rd_1"); - rd_array_1[1] = CORBA::string_dup("Two_rd_1"); - rd_array_1[2] = CORBA::string_dup("Three_rd_1"); - rd_array_1[3] = CORBA::string_dup("Four_rd_1"); + rd_array_1[0] = CORBA::string_dup("One_rd_1"); + rd_array_1[1] = CORBA::string_dup("Two_rd_1"); + rd_array_1[2] = CORBA::string_dup("Three_rd_1"); + rd_array_1[3] = CORBA::string_dup("Four_rd_1"); - wr_array_1[0] = CORBA::string_dup("One_wr_1"); - wr_array_1[1] = CORBA::string_dup("Two_wr_1"); + wr_array_1[0] = CORBA::string_dup("One_wr_1"); + wr_array_1[1] = CORBA::string_dup("Two_wr_1"); - Tango::TimedAttrData tad_1(rd_array_1,2,2,wr_array_1,2,1,Tango::ATTR_VALID,true,when); - ahs.push(tad_1); + Tango::TimedAttrData tad_1(rd_array_1, 2, 2, wr_array_1, 2, 1, Tango::ATTR_VALID, true, when); + ahs.push(tad_1); - Tango::DevString *rd_array_2 = new Tango::DevString[4]; - Tango::DevString *wr_array_2 = new Tango::DevString[2]; + Tango::DevString *rd_array_2 = new Tango::DevString[4]; + Tango::DevString *wr_array_2 = new Tango::DevString[2]; - rd_array_2[0] = CORBA::string_dup("One_rd_2"); - rd_array_2[1] = CORBA::string_dup("Two_rd_2"); - rd_array_2[2] = CORBA::string_dup("Three_rd_2"); - rd_array_2[3] = CORBA::string_dup("Four_rd_2"); + rd_array_2[0] = CORBA::string_dup("One_rd_2"); + rd_array_2[1] = CORBA::string_dup("Two_rd_2"); + rd_array_2[2] = CORBA::string_dup("Three_rd_2"); + rd_array_2[3] = CORBA::string_dup("Four_rd_2"); - wr_array_2[0] = CORBA::string_dup("One_wr_2"); - wr_array_2[1] = CORBA::string_dup("Two_wr_2"); + wr_array_2[0] = CORBA::string_dup("One_wr_2"); + wr_array_2[1] = CORBA::string_dup("Two_wr_2"); - Tango::TimedAttrData tad_2(rd_array_2,2,2,wr_array_2,2,1,Tango::ATTR_VALID,true,when); - ahs.push(tad_2); + Tango::TimedAttrData tad_2(rd_array_2, 2, 2, wr_array_2, 2, 1, Tango::ATTR_VALID, true, when); + ahs.push(tad_2); - Tango::DevString *rd_array_3 = new Tango::DevString[4]; - Tango::DevString *wr_array_3 = new Tango::DevString[2]; + Tango::DevString *rd_array_3 = new Tango::DevString[4]; + Tango::DevString *wr_array_3 = new Tango::DevString[2]; - rd_array_3[0] = CORBA::string_dup("One_rd_3"); - rd_array_3[1] = CORBA::string_dup("Two_rd_3"); - rd_array_3[2] = CORBA::string_dup("Three_rd_3"); - rd_array_3[3] = CORBA::string_dup("Four_rd_3"); + rd_array_3[0] = CORBA::string_dup("One_rd_3"); + rd_array_3[1] = CORBA::string_dup("Two_rd_3"); + rd_array_3[2] = CORBA::string_dup("Three_rd_3"); + rd_array_3[3] = CORBA::string_dup("Four_rd_3"); - wr_array_3[0] = CORBA::string_dup("One_wr_3"); - wr_array_3[1] = CORBA::string_dup("Two_wr_3"); + wr_array_3[0] = CORBA::string_dup("One_wr_3"); + wr_array_3[1] = CORBA::string_dup("Two_wr_3"); - Tango::TimedAttrData tad_3(rd_array_3,2,2,wr_array_3,2,1,Tango::ATTR_VALID,true,when); - ahs.push(tad_3); + Tango::TimedAttrData tad_3(rd_array_3, 2, 2, wr_array_3, 2, 1, Tango::ATTR_VALID, true, when); + ahs.push(tad_3); - tg->fill_attr_polling_buffer(this,att_name,ahs); + tg->fill_attr_polling_buffer(this, att_name, ahs); - cout << "Attribute Polling buffer filled" << endl; + cout << "Attribute Polling buffer filled" << endl; } void DevTest::IOFillPollBuffEncodedAttr() @@ -495,113 +522,110 @@ void DevTest::IOFillPollBuffEncodedAttr() cout << "[DevTest::IOFillPollBuffEncodedAttr] received " << endl; #ifndef COMPAT - Tango::AttrHistoryStack ahs; - ahs.length(3); - string att_name("Encoded_attr"); - Tango::Util *tg = Tango::Util::instance(); - Tango::DevEncoded the_enc; - Tango::DevEncoded the_enc1; - Tango::DevEncoded the_enc2; - - the_enc.encoded_format = CORBA::string_dup("First value"); - the_enc.encoded_data.length(2); - the_enc.encoded_data[0] = 22; - the_enc.encoded_data[1] = 33; - - time_t when = time(NULL); - Tango::TimedAttrData tad(&the_enc,when); - ahs.push(tad); - - the_enc1.encoded_format = CORBA::string_dup("Second value"); - the_enc1.encoded_data.length(2); - the_enc1.encoded_data[0] = 33; - the_enc1.encoded_data[1] = 44; - - when = time(NULL); - Tango::TimedAttrData tad1(&the_enc1,when); - ahs.push(tad1); - - the_enc2.encoded_format = CORBA::string_dup("Third value"); - the_enc2.encoded_data.length(2); - the_enc2.encoded_data[0] = 44; - the_enc2.encoded_data[1] = 55; - - when = time(NULL); - Tango::TimedAttrData tad2(&the_enc2,when); - ahs.push(tad2); - - tg->fill_attr_polling_buffer(this,att_name,ahs); - cout << "Attribute (DevEncoded data type) polling buffer filled" << endl; + Tango::AttrHistoryStack ahs; + ahs.length(3); + string att_name("Encoded_attr"); + Tango::Util *tg = Tango::Util::instance(); + Tango::DevEncoded the_enc; + Tango::DevEncoded the_enc1; + Tango::DevEncoded the_enc2; + + the_enc.encoded_format = CORBA::string_dup("First value"); + the_enc.encoded_data.length(2); + the_enc.encoded_data[0] = 22; + the_enc.encoded_data[1] = 33; + + time_t when = time(NULL); + Tango::TimedAttrData tad(&the_enc, when); + ahs.push(tad); + + the_enc1.encoded_format = CORBA::string_dup("Second value"); + the_enc1.encoded_data.length(2); + the_enc1.encoded_data[0] = 33; + the_enc1.encoded_data[1] = 44; + + when = time(NULL); + Tango::TimedAttrData tad1(&the_enc1, when); + ahs.push(tad1); + + the_enc2.encoded_format = CORBA::string_dup("Third value"); + the_enc2.encoded_data.length(2); + the_enc2.encoded_data[0] = 44; + the_enc2.encoded_data[1] = 55; + + when = time(NULL); + Tango::TimedAttrData tad2(&the_enc2, when); + ahs.push(tad2); + + tg->fill_attr_polling_buffer(this, att_name, ahs); + cout << "Attribute (DevEncoded data type) polling buffer filled" << endl; #endif } - void DevTest::IOFillPollBuffCmd() { cout << "[DevTest::IOFillPollBuffCmd] received " << endl; - Tango::CmdHistoryStack chs; - chs.length(3); - Tango::Util *tg = Tango::Util::instance(); + Tango::CmdHistoryStack chs; + chs.length(3); + Tango::Util *tg = Tango::Util::instance(); - Tango::DevVarLongArray dvla_array[10]; - string cmd_name("IOArray1"); + Tango::DevVarLongArray dvla_array[10]; + string cmd_name("IOArray1"); - for (int j = 0;j < 10;j++) - { - dvla_array[j].length(3); - dvla_array[j][0] = 10 + j; - dvla_array[j][1] = 11 + j; - dvla_array[j][2] = 12 + j; - } + for (int j = 0; j < 10; j++) + { + dvla_array[j].length(3); + dvla_array[j][0] = 10 + j; + dvla_array[j][1] = 11 + j; + dvla_array[j][2] = 12 + j; + } - chs.clear(); - time_t when = time(NULL); - for (int k = 0;k < 3;k++) - { - Tango::TimedCmdData tad(&dvla_array[k],when); - chs.push(tad); - } + chs.clear(); + time_t when = time(NULL); + for (int k = 0; k < 3; k++) + { + Tango::TimedCmdData tad(&dvla_array[k], when); + chs.push(tad); + } - tg->fill_cmd_polling_buffer(this,cmd_name,chs); + tg->fill_cmd_polling_buffer(this, cmd_name, chs); - cout << "Command Polling buffer filled" << endl; + cout << "Command Polling buffer filled" << endl; } - Tango::DevVarDoubleArray *DevTest::IOTemplInOut(Tango::DevDouble db) { - cout << "[DevTest::IOTemplInOut] received " << db << endl; + cout << "[DevTest::IOTemplInOut] received " << db << endl; - Tango::DevVarDoubleArray *argout; - argout = new Tango::DevVarDoubleArray(); + Tango::DevVarDoubleArray *argout; + argout = new Tango::DevVarDoubleArray(); - argout->length(2); - (*argout)[0] = db; - (*argout)[1] = db * 2; + argout->length(2); + (*argout)[0] = db; + (*argout)[1] = db * 2; - return argout; + return argout; } void DevTest::IOSetWAttrLimit(const Tango::DevVarDoubleArray *in) { - Tango::WAttribute &w_attr = dev_attr->get_w_attr_by_name("Double_attr_w"); - Tango::DevDouble limit = (*in)[1]; - if ((*in)[0] == 0.0) - { - w_attr.set_min_value(limit); - } - else - { - w_attr.set_max_value(limit); - } + Tango::WAttribute &w_attr = dev_attr->get_w_attr_by_name("Double_attr_w"); + Tango::DevDouble limit = (*in)[1]; + if ((*in)[0] == 0.0) + { + w_attr.set_min_value(limit); + } + else + { + w_attr.set_max_value(limit); + } } - void DevTest::push_data_ready(const Tango::DevVarLongStringArray *in) { - cout << "Pushing Data Ready event for attribute " << in->svalue[0].in() << endl; - push_data_ready_event(in->svalue[0].in(),in->lvalue[0]); + cout << "Pushing Data Ready event for attribute " << in->svalue[0].in() << endl; + push_data_ready_event(in->svalue[0].in(), in->lvalue[0]); } Tango::DevVarStringArray *DevTest::IOPollingInDevice() @@ -644,8 +668,8 @@ Tango::DevVarStringArray *DevTest::IOPollingInDevice() // poll_xxx - poll_attribute(att_name,250); - poll_command(cmd_name,250); + poll_attribute(att_name, 250); + poll_command(cmd_name, 250); Tango_sleep(1); @@ -731,9 +755,9 @@ void DevTest::IOSophisticatedPollInDevice() // poll the 3 atts - poll_attribute(att1_name,500); - poll_attribute(att2_name,250); - poll_attribute(att3_name,250); + poll_attribute(att1_name, 500); + poll_attribute(att2_name, 250); + poll_attribute(att3_name, 250); } Tango::DevVarStringArray *DevTest::IOGetPollMess() @@ -741,7 +765,7 @@ Tango::DevVarStringArray *DevTest::IOGetPollMess() Tango::DevVarStringArray *dvsa = new Tango::DevVarStringArray(); dvsa->length(poll_messages.size()); - for (size_t loop = 0;loop < poll_messages.size();loop++) + for (size_t loop = 0; loop < poll_messages.size(); loop++) (*dvsa)[loop] = Tango::string_dup(poll_messages[loop].c_str()); poll_messages.clear(); @@ -751,26 +775,26 @@ Tango::DevVarStringArray *DevTest::IOGetPollMess() void DevTest::set_enum_labels() { - Tango::Attribute &att = (get_device_attr())->get_attr_by_name("DynEnum_attr"); - Tango::MultiAttrProp multi_prop; - att.get_properties(multi_prop); + Tango::Attribute &att = (get_device_attr())->get_attr_by_name("DynEnum_attr"); + Tango::MultiAttrProp multi_prop; + att.get_properties(multi_prop); - vector v_s; - v_s.push_back("Zero"); - v_s.push_back("One"); - v_s.push_back("Two"); - v_s.push_back("Three"); - multi_prop.enum_labels = v_s; - att.set_properties(multi_prop); + vector v_s; + v_s.push_back("Zero"); + v_s.push_back("One"); + v_s.push_back("Two"); + v_s.push_back("Three"); + multi_prop.enum_labels = v_s; + att.set_properties(multi_prop); } void DevTest::add_enum_label(Tango::DevString new_label) { - Tango::Attribute &att = (get_device_attr())->get_attr_by_name("DynEnum_attr"); - Tango::MultiAttrProp multi_prop; - att.get_properties(multi_prop); - multi_prop.enum_labels.push_back(new_label); - att.set_properties(multi_prop); + Tango::Attribute &att = (get_device_attr())->get_attr_by_name("DynEnum_attr"); + Tango::MultiAttrProp multi_prop; + att.get_properties(multi_prop); + multi_prop.enum_labels.push_back(new_label); + att.set_properties(multi_prop); } //+---------------------------------------------------------------------------- @@ -785,14 +809,14 @@ void DevTest::add_enum_label(Tango::DevString new_label) void DevTest::signal_handler(long signo) { - cout << "[Device signal handler] received signal number " << signo; - cout << " for device " << device_name << endl; + cout << "[Device signal handler] received signal number " << signo; + cout << " for device " << device_name << endl; - DEBUG_STREAM << "[Device signal handler] received signal number " - << signo - << " for device " - << device_name - << endl; + DEBUG_STREAM << "[Device signal handler] received signal number " + << signo + << " for device " + << device_name + << endl; } @@ -808,442 +832,466 @@ void DevTest::write_Short_attr_w(Tango::WAttribute &att) { // cout << "In write_Short_attr_w for attribute " << att.get_name() << endl; - Tango::DevShort sh; - att.get_write_value(sh); + Tango::DevShort sh; + att.get_write_value(sh); // cout << "Attribute value = " << sh << endl; - if (Short_attr_w_except == true) - Tango::Except::throw_exception("Aaaa","Bbbb","Cccc"); + if (Short_attr_w_except == true) + { + Tango::Except::throw_exception("Aaaa", "Bbbb", "Cccc"); + } } void DevTest::write_Short_attr_w2(Tango::WAttribute &att) { - cout << "In write_Short_attr_w2 for attribute " << att.get_name() << endl; + cout << "In write_Short_attr_w2 for attribute " << att.get_name() << endl; - Tango::DevShort sh; - att.get_write_value(sh); - cout << "Attribute value = " << sh << endl; + Tango::DevShort sh; + att.get_write_value(sh); + cout << "Attribute value = " << sh << endl; } void DevTest::write_Long_attr_w(Tango::WAttribute &att) { - cout << "In write_Long_attr_w for attribute " << att.get_name() << endl; + cout << "In write_Long_attr_w for attribute " << att.get_name() << endl; - Tango::DevLong lg; - att.get_write_value(lg); - cout << "Attribute value = " << lg << endl; + Tango::DevLong lg; + att.get_write_value(lg); + cout << "Attribute value = " << lg << endl; } void DevTest::write_Double_attr_w(Tango::WAttribute &att) { - cout << "In write_Double_attr_w for attribute " << att.get_name() << endl; + cout << "In write_Double_attr_w for attribute " << att.get_name() << endl; - Tango::DevDouble db; - att.get_write_value(db); - cout << "Attribute value = " << db << endl; + Tango::DevDouble db; + att.get_write_value(db); + cout << "Attribute value = " << db << endl; } void DevTest::write_String_attr_w(Tango::WAttribute &att) { // cout << "In write_String_attr_w for attribute " << att.get_name() << endl; - Tango::DevString str; - att.get_write_value(str); + Tango::DevString str; + att.get_write_value(str); // cout << "Attribute value = " << str << endl; } void DevTest::write_String_attr_w2(Tango::WAttribute &att) { - cout << "In write_String_attr_w2 for attribute " << att.get_name() << endl; + cout << "In write_String_attr_w2 for attribute " << att.get_name() << endl; - Tango::DevString str; - att.get_write_value(str); - cout << "Attribute value = " << str << endl; + Tango::DevString str; + att.get_write_value(str); + cout << "Attribute value = " << str << endl; } - void DevTest::write_attr_asyn_write(Tango::WAttribute &att) { - cout << "In write_attr_asyn_write for attribute " << att.get_name() << endl; + cout << "In write_attr_asyn_write for attribute " << att.get_name() << endl; - Tango::DevLong lg; - att.get_write_value(lg); - cout << "Attribute value = " << lg << endl; - Tango_sleep(2); + Tango::DevLong lg; + att.get_write_value(lg); + cout << "Attribute value = " << lg << endl; + Tango_sleep(2); } void DevTest::write_attr_asyn_write_to(Tango::WAttribute &att) { - cout << "In write_attr_asyn_write_to for attribute " << att.get_name() << endl; + cout << "In write_attr_asyn_write_to for attribute " << att.get_name() << endl; - Tango::DevLong lg; - att.get_write_value(lg); - cout << "Attribute value = " << lg << endl; - Tango_sleep(4); + Tango::DevLong lg; + att.get_write_value(lg); + cout << "Attribute value = " << lg << endl; + Tango_sleep(4); } void DevTest::write_attr_asyn_write_except(Tango::WAttribute &att) { - cout << "In write_attr_asyn_write_except for attribute " << att.get_name() << endl; + cout << "In write_attr_asyn_write_except for attribute " << att.get_name() << endl; - Tango::DevLong lg; - att.get_write_value(lg); - cout << "Attribute value = " << lg << endl; - Tango_sleep(2); - Tango::Except::throw_exception((const char *)"aaa", - (const char *)"This is a test", - (const char *)"DevTest::write_attr_hardware"); + Tango::DevLong lg; + att.get_write_value(lg); + cout << "Attribute value = " << lg << endl; + Tango_sleep(2); + Tango::Except::throw_exception((const char *) "aaa", + (const char *) "This is a test", + (const char *) "DevTest::write_attr_hardware"); } void DevTest::write_String_spec_attr_w(Tango::WAttribute &att) { - cout << "In write_String_spec_attr_w for attribute " << att.get_name() << endl; + cout << "In write_String_spec_attr_w for attribute " << att.get_name() << endl; - const Tango::ConstDevString *ptr; - att.get_write_value(ptr); - long nb_str = att.get_write_value_length(); - cout << ", Elt nb = " << nb_str << endl; - for (int k = 0;k < nb_str;k++) - cout << ptr[k] << endl; + const Tango::ConstDevString *ptr; + att.get_write_value(ptr); + long nb_str = att.get_write_value_length(); + cout << ", Elt nb = " << nb_str << endl; + for (int k = 0; k < nb_str; k++) + { + cout << ptr[k] << endl; + } } void DevTest::write_Short_attr_rw(Tango::WAttribute &att) { - cout << "In write_Short_attr_rw for attribute " << att.get_name() << endl; - att.get_write_value(attr_short_rw); + cout << "In write_Short_attr_rw for attribute " << att.get_name() << endl; + att.get_write_value(attr_short_rw); } void DevTest::write_Long64_attr_rw(Tango::WAttribute &att) { - cout << "In write_Long64_attr_rw for attribute " << att.get_name() << endl; - att.get_write_value(attr_long64_rw); + cout << "In write_Long64_attr_rw for attribute " << att.get_name() << endl; + att.get_write_value(attr_long64_rw); } void DevTest::write_ULong_attr_rw(Tango::WAttribute &att) { - cout << "In write_ULong_attr_rw for attribute " << att.get_name() << endl; - att.get_write_value(attr_ulong_rw); + cout << "In write_ULong_attr_rw for attribute " << att.get_name() << endl; + att.get_write_value(attr_ulong_rw); - if (attr_ulong_rw > 1000) - att.set_write_value((Tango::DevULong)1111); + if (attr_ulong_rw > 1000) + { + att.set_write_value((Tango::DevULong) 1111); + } } void DevTest::write_ULong64_attr_rw(Tango::WAttribute &att) { - cout << "In write_ULong64_attr_rw for attribute " << att.get_name() << endl; - att.get_write_value(attr_ulong64_rw); + cout << "In write_ULong64_attr_rw for attribute " << att.get_name() << endl; + att.get_write_value(attr_ulong64_rw); } void DevTest::write_State_attr_rw(Tango::WAttribute &att) { - cout << "In write_State_attr_rw for attribute " << att.get_name() << endl; - att.get_write_value(attr_state_rw); + cout << "In write_State_attr_rw for attribute " << att.get_name() << endl; + att.get_write_value(attr_state_rw); } void DevTest::write_Float_attr_w(Tango::WAttribute &att) { - cout << "In write_Float_attr_w for attribute " << att.get_name() << endl; + cout << "In write_Float_attr_w for attribute " << att.get_name() << endl; - Tango::DevFloat fl; - att.get_write_value(fl); - cout << "Attribute value = " << fl << endl; + Tango::DevFloat fl; + att.get_write_value(fl); + cout << "Attribute value = " << fl << endl; } void DevTest::write_Boolean_attr_w(Tango::WAttribute &att) { - cout << "In write_Boolean_attr_w for attribute " << att.get_name() << endl; + cout << "In write_Boolean_attr_w for attribute " << att.get_name() << endl; - Tango::DevBoolean bo; - att.get_write_value(bo); - cout << "Attribute value = " << bo << endl; + Tango::DevBoolean bo; + att.get_write_value(bo); + cout << "Attribute value = " << bo << endl; } void DevTest::write_UShort_attr_w(Tango::WAttribute &att) { - cout << "In write_UShort_attr_w for attribute " << att.get_name() << endl; + cout << "In write_UShort_attr_w for attribute " << att.get_name() << endl; - Tango::DevUShort ush; - att.get_write_value(ush); - cout << "Attribute value = " << ush << endl; + Tango::DevUShort ush; + att.get_write_value(ush); + cout << "Attribute value = " << ush << endl; } void DevTest::write_UChar_attr_w(Tango::WAttribute &att) { - cout << "In write_UChar_attr_w for attribute " << att.get_name() << endl; + cout << "In write_UChar_attr_w for attribute " << att.get_name() << endl; - Tango::DevUChar uch; - att.get_write_value(uch); - cout << "Attribute value = " << uch << endl; + Tango::DevUChar uch; + att.get_write_value(uch); + cout << "Attribute value = " << uch << endl; } void DevTest::write_Float_spec_attr_w(Tango::WAttribute &att) { - cout << "In write_Float_spec_attr_w for attribute " << att.get_name() << endl; + cout << "In write_Float_spec_attr_w for attribute " << att.get_name() << endl; - const Tango::DevFloat *fl; - att.get_write_value(fl); - long nb_fl = att.get_write_value_length(); - cout << ", Elt nb = " << nb_fl << endl; - for (int k = 0;k < nb_fl;k++) - cout << fl[k] << endl; + const Tango::DevFloat *fl; + att.get_write_value(fl); + long nb_fl = att.get_write_value_length(); + cout << ", Elt nb = " << nb_fl << endl; + for (int k = 0; k < nb_fl; k++) + { + cout << fl[k] << endl; + } } void DevTest::write_Boolean_spec_attr_w(Tango::WAttribute &att) { - cout << "In write_Boolean_spec_attr_w for attribute " << att.get_name() << endl; + cout << "In write_Boolean_spec_attr_w for attribute " << att.get_name() << endl; - const Tango::DevBoolean *bo; - att.get_write_value(bo); - long nb_bo = att.get_write_value_length(); - cout << ", Elt nb = " << nb_bo << endl; - for (int k = 0;k < nb_bo;k++) - cout << bo[k] << endl; + const Tango::DevBoolean *bo; + att.get_write_value(bo); + long nb_bo = att.get_write_value_length(); + cout << ", Elt nb = " << nb_bo << endl; + for (int k = 0; k < nb_bo; k++) + { + cout << bo[k] << endl; + } } void DevTest::write_UShort_spec_attr_w(Tango::WAttribute &att) { - cout << "In write_UShort_spec_attr_w for attribute " << att.get_name() << endl; + cout << "In write_UShort_spec_attr_w for attribute " << att.get_name() << endl; - const Tango::DevUShort *ush; - att.get_write_value(ush); - long nb_ush = att.get_write_value_length(); - cout << ", Elt nb = " << nb_ush << endl; - for (int k = 0;k < nb_ush;k++) - cout << ush[k] << endl; + const Tango::DevUShort *ush; + att.get_write_value(ush); + long nb_ush = att.get_write_value_length(); + cout << ", Elt nb = " << nb_ush << endl; + for (int k = 0; k < nb_ush; k++) + { + cout << ush[k] << endl; + } } void DevTest::write_UChar_spec_attr_w(Tango::WAttribute &att) { - cout << "In write_UChar_spec_attr_w for attribute " << att.get_name() << endl; + cout << "In write_UChar_spec_attr_w for attribute " << att.get_name() << endl; - const Tango::DevUChar *uch; - att.get_write_value(uch); - long nb_uch = att.get_write_value_length(); - cout << ", Elt nb = " << nb_uch << endl; + const Tango::DevUChar *uch; + att.get_write_value(uch); + long nb_uch = att.get_write_value_length(); + cout << ", Elt nb = " << nb_uch << endl; // for (int k = 0;k < nb_uch;k++) // cout << uch[k] << endl; } void DevTest::write_Float_ima_attr_w(Tango::WAttribute &att) { - cout << "In write_Float_ima_attr_w for attribute " << att.get_name() << endl; + cout << "In write_Float_ima_attr_w for attribute " << att.get_name() << endl; - const Tango::DevFloat *fl; - att.get_write_value(fl); - long nb_fl = att.get_write_value_length(); - cout << ", Elt nb = " << nb_fl << endl; + const Tango::DevFloat *fl; + att.get_write_value(fl); + long nb_fl = att.get_write_value_length(); + cout << ", Elt nb = " << nb_fl << endl; // for (int k = 0;k < nb_fl;k++) // cout << fl[k] << endl; } void DevTest::write_UShort_ima_attr_w(Tango::WAttribute &att) { - cout << "In write_UShort_ima_attr_w for attribute " << att.get_name() << endl; + cout << "In write_UShort_ima_attr_w for attribute " << att.get_name() << endl; - const Tango::DevUShort *ush; - att.get_write_value(ush); - long nb_ush = att.get_write_value_length(); - cout << ", Elt nb = " << nb_ush << endl; + const Tango::DevUShort *ush; + att.get_write_value(ush); + long nb_ush = att.get_write_value_length(); + cout << ", Elt nb = " << nb_ush << endl; // for (int k = 0;k < nb_ush;k++) // cout << ush[k] << endl; } void DevTest::write_Float_spec_attr_rw(Tango::WAttribute &att) { - cout << "In write_Float_spec_attr_rw for attribute " << att.get_name() << endl; + cout << "In write_Float_spec_attr_rw for attribute " << att.get_name() << endl; - const Tango::DevFloat *fl; - att.get_write_value(fl); - long nb_fl = att.get_write_value_length(); - cout << ", Elt nb = " << nb_fl << endl; + const Tango::DevFloat *fl; + att.get_write_value(fl); + long nb_fl = att.get_write_value_length(); + cout << ", Elt nb = " << nb_fl << endl; // for (int k = 0;k < nb_fl;k++) // cout << fl[k] << endl; } void DevTest::write_Long_spec_attr_rw(Tango::WAttribute &att) { - cout << "In write_Long_spec_attr_rw for attribute " << att.get_name() << endl; + cout << "In write_Long_spec_attr_rw for attribute " << att.get_name() << endl; - const Tango::DevLong *fl; - att.get_write_value(fl); - long nb_fl = att.get_write_value_length(); - cout << ", Elt nb = " << nb_fl << endl; - for (int k = 0;k < nb_fl;k++) - cout << fl[k] << endl; + const Tango::DevLong *fl; + att.get_write_value(fl); + long nb_fl = att.get_write_value_length(); + cout << ", Elt nb = " << nb_fl << endl; + for (int k = 0; k < nb_fl; k++) + { + cout << fl[k] << endl; + } } void DevTest::write_UChar_spec_attr_rw(Tango::WAttribute &att) { - cout << "In write_UShort_spec_attr_rw for attribute " << att.get_name() << endl; + cout << "In write_UShort_spec_attr_rw for attribute " << att.get_name() << endl; - const Tango::DevUChar *uch; - att.get_write_value(uch); - long nb_uch = att.get_write_value_length(); - cout << ", Elt nb = " << nb_uch << endl; + const Tango::DevUChar *uch; + att.get_write_value(uch); + long nb_uch = att.get_write_value_length(); + cout << ", Elt nb = " << nb_uch << endl; // for (int k = 0;k < nb_uch;k++) // cout << uch[k] << endl; } void DevTest::write_Boolean_ima_attr_rw(Tango::WAttribute &att) { - cout << "In write_Boolean_ima_attr_rw for attribute " << att.get_name() << endl; + cout << "In write_Boolean_ima_attr_rw for attribute " << att.get_name() << endl; - const Tango::DevBoolean *bo; - att.get_write_value(bo); - long nb_bo = att.get_write_value_length(); - cout << ", Elt nb = " << nb_bo << endl; + const Tango::DevBoolean *bo; + att.get_write_value(bo); + long nb_bo = att.get_write_value_length(); + cout << ", Elt nb = " << nb_bo << endl; // for (int k = 0;k < nb_bo;k++) // cout << bo[k] << endl; } void DevTest::write_UShort_ima_attr_rw(Tango::WAttribute &att) { - cout << "In write_UShort_ima_attr_rw for attribute " << att.get_name() << endl; + cout << "In write_UShort_ima_attr_rw for attribute " << att.get_name() << endl; - const Tango::DevUShort *ush; - att.get_write_value(ush); - long nb_ush = att.get_write_value_length(); - cout << ", Elt nb = " << nb_ush << endl; + const Tango::DevUShort *ush; + att.get_write_value(ush); + long nb_ush = att.get_write_value_length(); + cout << ", Elt nb = " << nb_ush << endl; // for (int k = 0;k < nb_ush;k++) // cout << ush[k] << endl; } - void DevTest::write_slow_actuator(Tango::WAttribute &att) { - cout << "In write_slow_actuator for attribute " << att.get_name() << endl; + cout << "In write_slow_actuator for attribute " << att.get_name() << endl; - att.get_write_value(slow_actua); + att.get_write_value(slow_actua); #ifdef WIN32 - struct _timeb before_win; - _ftime(&before_win); - slow_actua_write.tv_sec = (unsigned long)before_win.time; - slow_actua_write.tv_usec = (long)before_win.millitm * 1000; + struct _timeb before_win; + _ftime(&before_win); + slow_actua_write.tv_sec = (unsigned long)before_win.time; + slow_actua_write.tv_usec = (long)before_win.millitm * 1000; #else - gettimeofday(&slow_actua_write,NULL); + gettimeofday(&slow_actua_write, NULL); #endif } - void DevTest::write_fast_actuator(Tango::WAttribute &att) { - cout << "In write_fast_actuator for attribute " << att.get_name() << endl; + cout << "In write_fast_actuator for attribute " << att.get_name() << endl; - att.get_write_value(fast_actua); + att.get_write_value(fast_actua); - att.set_value(&fast_actua); - att.set_quality(Tango::ATTR_CHANGING, true); - att.set_value(&fast_actua); - att.set_quality(Tango::ATTR_VALID, true); + att.set_value(&fast_actua); + att.set_quality(Tango::ATTR_CHANGING, true); + att.set_value(&fast_actua); + att.set_quality(Tango::ATTR_VALID, true); } - void DevTest::write_Long64_spec_attr_rw(Tango::WAttribute &att) { - cout << "In write_Long64_spec_attr_rw for attribute " << att.get_name() << endl; - const Tango::DevLong64 *lg64; - long nb_data = att.get_write_value_length(); - att.get_write_value(lg64); - cout << "Received " << nb_data << " for attribute " << att.get_name() << endl; + cout << "In write_Long64_spec_attr_rw for attribute " << att.get_name() << endl; + const Tango::DevLong64 *lg64; + long nb_data = att.get_write_value_length(); + att.get_write_value(lg64); + cout << "Received " << nb_data << " for attribute " << att.get_name() << endl; } void DevTest::write_ULong_spec_attr_rw(Tango::WAttribute &att) { - cout << "In write_ULong_spec_attr_rw for attribute " << att.get_name() << endl; - const Tango::DevULong *ulg; - long nb_data = att.get_write_value_length(); - att.get_write_value(ulg); - cout << "Received " << nb_data << " for attribute " << att.get_name() << endl; + cout << "In write_ULong_spec_attr_rw for attribute " << att.get_name() << endl; + const Tango::DevULong *ulg; + long nb_data = att.get_write_value_length(); + att.get_write_value(ulg); + cout << "Received " << nb_data << " for attribute " << att.get_name() << endl; } void DevTest::write_ULong64_spec_attr_rw(Tango::WAttribute &att) { - cout << "In write_ULong64_spec_attr_rw for attribute " << att.get_name() << endl; - const Tango::DevULong64 *ulg64; - long nb_data = att.get_write_value_length(); - att.get_write_value(ulg64); - cout << "Received " << nb_data << " for attribute " << att.get_name() << endl; + cout << "In write_ULong64_spec_attr_rw for attribute " << att.get_name() << endl; + const Tango::DevULong64 *ulg64; + long nb_data = att.get_write_value_length(); + att.get_write_value(ulg64); + cout << "Received " << nb_data << " for attribute " << att.get_name() << endl; } void DevTest::write_State_spec_attr_rw(Tango::WAttribute &att) { - cout << "In write_State_aspec_ttr_rw for attribute " << att.get_name() << endl; - const Tango::DevState *sta; - long nb_data = att.get_write_value_length(); - att.get_write_value(sta); - cout << "Received " << nb_data << " for attribute " << att.get_name() << endl; + cout << "In write_State_aspec_ttr_rw for attribute " << att.get_name() << endl; + const Tango::DevState *sta; + long nb_data = att.get_write_value_length(); + att.get_write_value(sta); + cout << "Received " << nb_data << " for attribute " << att.get_name() << endl; } void DevTest::write_Encoded_attr_rw(Tango::WAttribute &att) { - cout << "In write_Encoded_attr_rw for attribute " << att.get_name() << endl; + cout << "In write_Encoded_attr_rw for attribute " << att.get_name() << endl; #ifndef COMPAT - const Tango::DevEncoded *enc; - att.get_write_value(enc); - cout << "\tReceived string = " << enc->encoded_format << endl; - cout << "\tReceived data nb = " << enc->encoded_data.length() << endl; - for (unsigned int i = 0;i < enc->encoded_data.length();i++) - cout << "\t\tdata[" << i << "] = " << (unsigned long)enc->encoded_data[i] << endl; + const Tango::DevEncoded *enc; + att.get_write_value(enc); + cout << "\tReceived string = " << enc->encoded_format << endl; + cout << "\tReceived data nb = " << enc->encoded_data.length() << endl; + for (unsigned int i = 0; i < enc->encoded_data.length(); i++) + { + cout << "\t\tdata[" << i << "] = " << (unsigned long) enc->encoded_data[i] << endl; + } #endif } void DevTest::write_Poll_buffRW(Tango::WAttribute &att) { - cout << "In write_Poll_buffRW for attribute " << att.get_name() << endl; + cout << "In write_Poll_buffRW for attribute " << att.get_name() << endl; } void DevTest::write_Def_attr(Tango::WAttribute &att) { - cout << "In write_Def_attr for attribute " << att.get_name() << endl; + cout << "In write_Def_attr for attribute " << att.get_name() << endl; } void DevTest::write_DefUser_attr(Tango::WAttribute &att) { - cout << "In write_DefUser_attr for attribute " << att.get_name() << endl; + cout << "In write_DefUser_attr for attribute " << att.get_name() << endl; } void DevTest::write_DefClass_attr(Tango::WAttribute &att) { - cout << "In write_DefClass_attr for attribute " << att.get_name() << endl; + cout << "In write_DefClass_attr for attribute " << att.get_name() << endl; } void DevTest::write_DefClassUser_attr(Tango::WAttribute &att) { - cout << "In write_DefClassUser_attr for attribute " << att.get_name() << endl; + cout << "In write_DefClassUser_attr for attribute " << att.get_name() << endl; } void DevTest::write_Enum_attr(Tango::WAttribute &att) { - cout << "In write_Enum_attr for attribute " << att.get_name() << endl; + cout << "In write_Enum_attr for attribute " << att.get_name() << endl; } void DevTest::write_Enum_spec_attr_rw(Tango::WAttribute &att) { - cout << "In write_Enum_spec_attr_rw for attribute " << att.get_name() << endl; + cout << "In write_Enum_spec_attr_rw for attribute " << att.get_name() << endl; } void DevTest::write_attr_hardware(vector &att_idx) { - switch (wattr_throw) - { - case 0: - default: - break; - - case 1: - Tango::Except::throw_exception("DevTest_WriteAttrHardware","DevFailed from write_attr_hardware","DevTest::write_attr_hardware"); - break; - - case 2: - if (att_idx.empty() == false) - Tango::Except::throw_named_exception(get_device_attr()->get_attr_by_ind(att_idx[0]).get_name().c_str(), - "DevTest_WriteAttrHardware","aaa","DevTest::write_attr_hardware"); - break; - - case 3: - if (att_idx.size() >= 2) - Tango::Except::throw_named_exception(this,att_idx[2],"DevTest_WriteAttrHardware","bbb","DevTest::write_attr_hardware"); - break; - } + switch (wattr_throw) + { + case 0: + default: + break; + + case 1: + Tango::Except::throw_exception("DevTest_WriteAttrHardware", + "DevFailed from write_attr_hardware", + "DevTest::write_attr_hardware"); + break; + + case 2: + if (att_idx.empty() == false) + { + Tango::Except::throw_named_exception(get_device_attr()->get_attr_by_ind(att_idx[0]).get_name().c_str(), + "DevTest_WriteAttrHardware", + "aaa", + "DevTest::write_attr_hardware"); + } + break; + + case 3: + if (att_idx.size() >= 2) + { + Tango::Except::throw_named_exception(this, + att_idx[2], + "DevTest_WriteAttrHardware", + "bbb", + "DevTest::write_attr_hardware"); + } + break; + } } //+---------------------------------------------------------------------------- @@ -1256,686 +1304,697 @@ void DevTest::write_attr_hardware(vector &att_idx) void DevTest::read_Short_attr(Tango::Attribute &att) { - cout << "[DevTest::read_attr] attribute name Short_attr" << endl; - attr_short = 12; - if (Short_attr_except == false) - { - att.set_value(&attr_short); - } - else - { - Tango::Except::throw_exception((const char *)"aaa", - (const char *)"This is a test", - (const char *)"DevTest::read_attr"); - } + cout << "[DevTest::read_attr] attribute name Short_attr" << endl; + attr_short = 12; + if (Short_attr_except == false) + { + att.set_value(&attr_short); + } + else + { + Tango::Except::throw_exception((const char *) "aaa", + (const char *) "This is a test", + (const char *) "DevTest::read_attr"); + } } void DevTest::read_Long_attr(Tango::Attribute &att) { - cout << "[DevTest::read_attr] attribute name Long_attr" << endl; - att.set_value(&attr_long); + cout << "[DevTest::read_attr] attribute name Long_attr" << endl; + att.set_value(&attr_long); } void DevTest::read_Long64_attr(Tango::Attribute &att) { - cout << "[DevTest::read_attr] attribute name Long64_attr" << endl; - attr_long64 = 300; - att.set_value(&attr_long64); + cout << "[DevTest::read_attr] attribute name Long64_attr" << endl; + attr_long64 = 300; + att.set_value(&attr_long64); } void DevTest::read_Double_attr(Tango::Attribute &att) { - cout << "[DevTest::read_attr] attribute name Double_attr" << endl; - attr_double = 3.2; - att.set_value(&attr_double); + cout << "[DevTest::read_attr] attribute name Double_attr" << endl; + attr_double = 3.2; + att.set_value(&attr_double); } void DevTest::read_String_attr(Tango::Attribute &att) { - static Tango::DevString s = NULL; + static Tango::DevString s = NULL; - cout << "[DevTest::read_attr] attribute name String_attr" << endl; - if (s == NULL) - s = CORBA::string_dup("test_string"); + cout << "[DevTest::read_attr] attribute name String_attr" << endl; + if (s == NULL) + { + s = CORBA::string_dup("test_string"); + } - att.set_value(&s); + att.set_value(&s); } void DevTest::read_Short_spec_attr(Tango::Attribute &att) { - static short attr_short_array[20]; + static short attr_short_array[20]; - cout << "[DevTest::read_attr] attribute name Short_spec_attr" << endl; - attr_short_array[0] = 10; - attr_short_array[1] = 20; - attr_short_array[2] = 30; - attr_short_array[3] = 40; + cout << "[DevTest::read_attr] attribute name Short_spec_attr" << endl; + attr_short_array[0] = 10; + attr_short_array[1] = 20; + attr_short_array[2] = 30; + attr_short_array[3] = 40; - att.set_value(attr_short_array, 4); + att.set_value(attr_short_array, 4); } void DevTest::read_Long_spec_attr(Tango::Attribute &att) { - cout << "[DevTest::read_attr] attribute name Long_spec_attr" << endl; - attr_long_array[0] = 0; - attr_long_array[1] = 1; - attr_long_array[2] = 2; - attr_long_array[3] = 3; - attr_long_array[4] = 4; - attr_long_array[5] = 5; - attr_long_array[6] = 6; - attr_long_array[7] = 7; - attr_long_array[8] = 8; - attr_long_array[9] = 9; + cout << "[DevTest::read_attr] attribute name Long_spec_attr" << endl; + attr_long_array[0] = 0; + attr_long_array[1] = 1; + attr_long_array[2] = 2; + attr_long_array[3] = 3; + attr_long_array[4] = 4; + attr_long_array[5] = 5; + attr_long_array[6] = 6; + attr_long_array[7] = 7; + attr_long_array[8] = 8; + attr_long_array[9] = 9; - att.set_value(attr_long_array, 10); + att.set_value(attr_long_array, 10); } void DevTest::read_Double_spec_attr(Tango::Attribute &att) { - cout << "[DevTest::read_attr] attribute name Double_spec_attr" << endl; - attr_db_array[0] = 1.11; - attr_db_array[1] = 2.22; + cout << "[DevTest::read_attr] attribute name Double_spec_attr" << endl; + attr_db_array[0] = 1.11; + attr_db_array[1] = 2.22; - att.set_value(attr_db_array, 2); + att.set_value(attr_db_array, 2); } void DevTest::read_String_spec_attr(Tango::Attribute &att) { - cout << "[DevTest::read_attr] attribute name String_spec_attr" << endl; - attr_str_array[0] = (char *)"Hello world"; - attr_str_array[1] = (char *)"Hello universe"; + cout << "[DevTest::read_attr] attribute name String_spec_attr" << endl; + attr_str_array[0] = (char *) "Hello world"; + attr_str_array[1] = (char *) "Hello universe"; - att.set_value(attr_str_array, 2); + att.set_value(attr_str_array, 2); } void DevTest::read_Short_ima_attr(Tango::Attribute &att) { - static short attr_short_array_1[20]; + static short attr_short_array_1[20]; - cout << "[DevTest::read_attr] attribute name Short_ima_attr" << endl; - attr_short_array_1[0] = 40; - attr_short_array_1[1] = 60; - attr_short_array_1[2] = 80; - attr_short_array_1[3] = 100; + cout << "[DevTest::read_attr] attribute name Short_ima_attr" << endl; + attr_short_array_1[0] = 40; + attr_short_array_1[1] = 60; + attr_short_array_1[2] = 80; + attr_short_array_1[3] = 100; - att.set_value(attr_short_array_1,2,2); + att.set_value(attr_short_array_1, 2, 2); } void DevTest::read_Long_ima_attr(Tango::Attribute &att) { - cout << "[DevTest::read_attr] attribute name Long_ima_attr" << endl; - attr_long_array[0] = 0; - attr_long_array[1] = 1; - attr_long_array[2] = 2; - attr_long_array[3] = 3; - attr_long_array[4] = 4; - attr_long_array[5] = 5; + cout << "[DevTest::read_attr] attribute name Long_ima_attr" << endl; + attr_long_array[0] = 0; + attr_long_array[1] = 1; + attr_long_array[2] = 2; + attr_long_array[3] = 3; + attr_long_array[4] = 4; + attr_long_array[5] = 5; - att.set_value(attr_long_array,3,2); + att.set_value(attr_long_array, 3, 2); } void DevTest::read_Double_ima_attr(Tango::Attribute &att) { - cout << "[DevTest::read_attr] attribute name Double_ima_attr" << endl; - attr_db_array[0] = 5.55; - attr_db_array[1] = 6.66; + cout << "[DevTest::read_attr] attribute name Double_ima_attr" << endl; + attr_db_array[0] = 5.55; + attr_db_array[1] = 6.66; - att.set_value(attr_db_array,2,1); + att.set_value(attr_db_array, 2, 1); } void DevTest::read_String_ima_attr(Tango::Attribute &att) { - cout << "[DevTest::read_attr] attribute name String_ima_attr" << endl; - attr_str_array[0] = (char *)"Hello milky way"; - attr_str_array[1] = (char *)"Hello moon"; + cout << "[DevTest::read_attr] attribute name String_ima_attr" << endl; + attr_str_array[0] = (char *) "Hello milky way"; + attr_str_array[1] = (char *) "Hello moon"; - att.set_value(attr_str_array,1,2); + att.set_value(attr_str_array, 1, 2); } void DevTest::read_attr_no_data(Tango::Attribute &att) { - cout << "[DevTest::read_attr] attribute name attr_no_data" << endl; - att.set_quality(Tango::ATTR_VALID); + cout << "[DevTest::read_attr] attribute name attr_no_data" << endl; + att.set_quality(Tango::ATTR_VALID); } void DevTest::read_attr_wrong_type(Tango::Attribute &att) { - cout << "[DevTest::read_attr] attribute name attr_wrong_type" << endl; - attr_long = 1246; - att.set_value(&attr_long); + cout << "[DevTest::read_attr] attribute name attr_wrong_type" << endl; + attr_long = 1246; + att.set_value(&attr_long); } void DevTest::read_attr_wrong_size(Tango::Attribute &att) { - cout << "[DevTest::read_attr] attribute name attr_wrong_size" << endl; - att.set_value(&attr_long,1000,1000); + cout << "[DevTest::read_attr] attribute name attr_wrong_size" << endl; + att.set_value(&attr_long, 1000, 1000); } void DevTest::read_attr_no_alarm(Tango::Attribute &att) { - cout << "[DevTest::read_attr] attribute name attr_no_alarm" << endl; - attr_long = 1246; - att.check_alarm(); - att.set_value(&attr_long); + cout << "[DevTest::read_attr] attribute name attr_no_alarm" << endl; + attr_long = 1246; + att.check_alarm(); + att.set_value(&attr_long); } void DevTest::read_Short_attr_with_w(Tango::Attribute &att) { - cout << "[DevTest::read_attr] attribute name Short_attr_with_w" << endl; - attr_short = 44; - att.set_value(&attr_short); + cout << "[DevTest::read_attr] attribute name Short_attr_with_w" << endl; + attr_short = 44; + att.set_value(&attr_short); } void DevTest::read_Long_attr_with_w(Tango::Attribute &att) { - cout << "[DevTest::read_attr] attribute name Long_attr_with_w" << endl; - attr_long = 1246; - att.set_value(&attr_long); + cout << "[DevTest::read_attr] attribute name Long_attr_with_w" << endl; + attr_long = 1246; + att.set_value(&attr_long); } void DevTest::read_Short_attr_rw(Tango::Attribute &att) { - cout << "[DevTest::read_attr] attribute name Short_attr_rw" << endl; - att.set_value(&attr_short_rw); + cout << "[DevTest::read_attr] attribute name Short_attr_rw" << endl; + att.set_value(&attr_short_rw); } void DevTest::read_Long64_attr_rw(Tango::Attribute &att) { - cout << "[DevTest::read_attr] attribute name Long64_attr_rw" << endl; - att.set_value(&attr_long64_rw); + cout << "[DevTest::read_attr] attribute name Long64_attr_rw" << endl; + att.set_value(&attr_long64_rw); } void DevTest::read_ULong_attr_rw(Tango::Attribute &att) { - cout << "[DevTest::read_attr] attribute name ULong_attr_rw" << endl; - att.set_value(&attr_ulong_rw); + cout << "[DevTest::read_attr] attribute name ULong_attr_rw" << endl; + att.set_value(&attr_ulong_rw); } void DevTest::read_ULong64_attr_rw(Tango::Attribute &att) { - cout << "[DevTest::read_attr] attribute name ULong64_attr_rw" << endl; - att.set_value(&attr_ulong64_rw); + cout << "[DevTest::read_attr] attribute name ULong64_attr_rw" << endl; + att.set_value(&attr_ulong64_rw); } void DevTest::read_State_attr_rw(Tango::Attribute &att) { - cout << "[DevTest::read_attr] attribute name State_attr_rw" << endl; - att.set_value(&attr_state_rw); + cout << "[DevTest::read_attr] attribute name State_attr_rw" << endl; + att.set_value(&attr_state_rw); } void DevTest::read_attr_asyn(Tango::Attribute &att) { - cout << "[DevTest::read_attr] attribute attr_asyn" << endl; - Tango_sleep(2); - attr_double = 5.55; - att.set_value(&attr_double); - cout << "Leaving reading attr_asyn attribute" << endl; + cout << "[DevTest::read_attr] attribute attr_asyn" << endl; + Tango_sleep(2); + attr_double = 5.55; + att.set_value(&attr_double); + cout << "Leaving reading attr_asyn attribute" << endl; } void DevTest::read_attr_asyn_to(Tango::Attribute &att) { - cout << "[DevTest::read_attr] attribute attr_asyn_to" << endl; - Tango_sleep(4); - attr_double = 5.55; - att.set_value(&attr_double); - cout << "Leaving reading attr_asyn_to attribute" << endl; + cout << "[DevTest::read_attr] attribute attr_asyn_to" << endl; + Tango_sleep(4); + attr_double = 5.55; + att.set_value(&attr_double); + cout << "Leaving reading attr_asyn_to attribute" << endl; } void DevTest::read_attr_asyn_except(TANGO_UNUSED(Tango::Attribute &att)) { - cout << "[DevTest::read_attr] attribute attr_asyn_except" << endl; - Tango_sleep(2); - cout << "Leaving reading attr_asyn_except attribute" << endl; + cout << "[DevTest::read_attr] attribute attr_asyn_except" << endl; + Tango_sleep(2); + cout << "Leaving reading attr_asyn_except attribute" << endl; - Tango::Except::throw_exception((const char *)"aaa", - (const char *)"This is a test", - (const char *)"DevTest::read_attr"); + Tango::Except::throw_exception((const char *) "aaa", + (const char *) "This is a test", + (const char *) "DevTest::read_attr"); } void DevTest::read_PollLong_attr(Tango::Attribute &att) { - cout << "[DevTest::read_attr] attribute name PollLong_attr" << endl; - PollLong_attr_num++; - if ((PollLong_attr_num % 2) == 0) - Poll_attr_long = 5555; - else - Poll_attr_long = 6666; - att.set_value(&Poll_attr_long); + cout << "[DevTest::read_attr] attribute name PollLong_attr" << endl; + PollLong_attr_num++; + if ((PollLong_attr_num % 2) == 0) + { + Poll_attr_long = 5555; + } + else + { + Poll_attr_long = 6666; + } + att.set_value(&Poll_attr_long); } void DevTest::read_PollString_spec_attr(Tango::Attribute &att) { - cout << "[DevTest::read_attr] attribute name PollString_spec_attr" << endl; - PollString_spec_attr_num++; - if ((PollString_spec_attr_num % 4) == 0) - { - attr_str_array[0] = (char *)"Hello world"; - attr_str_array[1] = (char *)"Hello universe"; - att.set_value(attr_str_array, 2); - } - else if ((PollString_spec_attr_num % 4) == 1) - { - attr_str_array[0] = (char *)"Hello Grenoble"; + cout << "[DevTest::read_attr] attribute name PollString_spec_attr" << endl; + PollString_spec_attr_num++; + if ((PollString_spec_attr_num % 4) == 0) + { + attr_str_array[0] = (char *) "Hello world"; + attr_str_array[1] = (char *) "Hello universe"; + att.set_value(attr_str_array, 2); + } + else if ((PollString_spec_attr_num % 4) == 1) + { + attr_str_array[0] = (char *) "Hello Grenoble"; // attr_str_array[1] = (char *)"Hello Paris"; - att.set_value(attr_str_array, 1); - } - else if ((PollString_spec_attr_num % 4) == 2) - { - Tango::Except::throw_exception((const char *)"aaaa",(const char *)"bbb",(const char *)"ccc"); - } - else - { - Tango::Except::throw_exception((const char *)"xxx",(const char *)"yyy",(const char *)"zzz"); - } + att.set_value(attr_str_array, 1); + } + else if ((PollString_spec_attr_num % 4) == 2) + { + Tango::Except::throw_exception((const char *) "aaaa", (const char *) "bbb", (const char *) "ccc"); + } + else + { + Tango::Except::throw_exception((const char *) "xxx", (const char *) "yyy", (const char *) "zzz"); + } // att.set_value(attr_str_array, 2); } void DevTest::read_attr_dq_sh(Tango::Attribute &att) { - cout << "[DevTest::read_attr] attribute name attr_dq_sh" << endl; - attr_dq_short = 77; + cout << "[DevTest::read_attr] attribute name attr_dq_sh" << endl; + attr_dq_short = 77; #ifndef WIN32 - struct timeval tv; - struct timezone tz; - gettimeofday(&tv,&tz); - att.set_value_date_quality(&attr_dq_short,tv,Tango::ATTR_VALID); + struct timeval tv; + struct timezone tz; + gettimeofday(&tv, &tz); + att.set_value_date_quality(&attr_dq_short, tv, Tango::ATTR_VALID); #else - struct _timeb tv; - _ftime(&tv); - att.set_value_date_quality(&attr_dq_short,tv,Tango::ATTR_VALID); + struct _timeb tv; + _ftime(&tv); + att.set_value_date_quality(&attr_dq_short,tv,Tango::ATTR_VALID); #endif } void DevTest::read_attr_dq_lo(Tango::Attribute &att) { - cout << "[DevTest::read_attr] attribute name attr_dq_lo" << endl; - attr_dq_long = 7777; - time_t da; - time(&da); - att.set_value_date_quality(&attr_dq_long,da,Tango::ATTR_ALARM); + cout << "[DevTest::read_attr] attribute name attr_dq_lo" << endl; + attr_dq_long = 7777; + time_t da; + time(&da); + att.set_value_date_quality(&attr_dq_long, da, Tango::ATTR_ALARM); } void DevTest::read_attr_dq_db(Tango::Attribute &att) { - cout << "[DevTest::read_attr] attribute name attr_dq_db" << endl; - attr_dq_double = 8.888; + cout << "[DevTest::read_attr] attribute name attr_dq_db" << endl; + attr_dq_double = 8.888; #ifndef WIN32 - struct timeval tv; - struct timezone tz; - gettimeofday(&tv,&tz); - att.set_value_date_quality(&attr_dq_double,tv,Tango::ATTR_VALID); + struct timeval tv; + struct timezone tz; + gettimeofday(&tv, &tz); + att.set_value_date_quality(&attr_dq_double, tv, Tango::ATTR_VALID); #else - struct _timeb tv; - _ftime(&tv); - att.set_value_date_quality(&attr_dq_double,tv,Tango::ATTR_VALID); + struct _timeb tv; + _ftime(&tv); + att.set_value_date_quality(&attr_dq_double,tv,Tango::ATTR_VALID); #endif } void DevTest::read_attr_dq_str(Tango::Attribute &att) { - static Tango::DevString s = NULL; + static Tango::DevString s = NULL; - cout << "[DevTest::read_attr] attribute name attr_dq_str" << endl; - s = attr_dq_str; - strcpy(attr_dq_str,"Setting value date and quality"); - time_t da; - time(&da); - att.set_value_date_quality(&s,da,Tango::ATTR_ALARM); + cout << "[DevTest::read_attr] attribute name attr_dq_str" << endl; + s = attr_dq_str; + strcpy(attr_dq_str, "Setting value date and quality"); + time_t da; + time(&da); + att.set_value_date_quality(&s, da, Tango::ATTR_ALARM); } void DevTest::read_Short_spec_attr_rw(Tango::Attribute &att) { - cout << "[DevTest::read_attr] attribute name Short_spec_attr_rw" << endl; - short_spec_attr[0] = 8; - short_spec_attr[1] = 9; + cout << "[DevTest::read_attr] attribute name Short_spec_attr_rw" << endl; + short_spec_attr[0] = 8; + short_spec_attr[1] = 9; - att.set_value(short_spec_attr, 2); + att.set_value(short_spec_attr, 2); } void DevTest::read_String_spec_attr_rw(Tango::Attribute &att) { - cout << "[DevTest::read_attr] attribute name String_spec_attr_rw" << endl; - string_spec_attr[0] = "Thank's god"; - string_spec_attr[1] = "It's friday"; + cout << "[DevTest::read_attr] attribute name String_spec_attr_rw" << endl; + string_spec_attr[0] = "Thank's god"; + string_spec_attr[1] = "It's friday"; - att.set_value(const_cast(string_spec_attr), 2); + att.set_value(const_cast(string_spec_attr), 2); } void DevTest::read_Long_spec_attr_rw(Tango::Attribute &att) { - cout << "[DevTest::read_attr] attribute name Long_spec_attr_rw" << endl; - long_spec_attr[0] = 88; - long_spec_attr[1] = 99; - long_spec_attr[2] = 111; + cout << "[DevTest::read_attr] attribute name Long_spec_attr_rw" << endl; + long_spec_attr[0] = 88; + long_spec_attr[1] = 99; + long_spec_attr[2] = 111; - att.set_value(long_spec_attr, 3); + att.set_value(long_spec_attr, 3); } void DevTest::read_Short_ima_attr_rw(Tango::Attribute &att) { - cout << "[DevTest::read_attr] attribute name Short_ima_attr_rw" << endl; - short_ima_attr[0] = 6; - short_ima_attr[1] = 7; - short_ima_attr[2] = 8; - short_ima_attr[3] = 9; + cout << "[DevTest::read_attr] attribute name Short_ima_attr_rw" << endl; + short_ima_attr[0] = 6; + short_ima_attr[1] = 7; + short_ima_attr[2] = 8; + short_ima_attr[3] = 9; - att.set_value(short_ima_attr, 2,2); + att.set_value(short_ima_attr, 2, 2); } void DevTest::read_String_ima_attr_rw(Tango::Attribute &att) { - cout << "[DevTest::read_attr] attribute name String_ima_attr_rw" << endl; - string_ima_attr[0] = "Alors la, pour une surprise"; - string_ima_attr[1] = "c'est une surprise"; + cout << "[DevTest::read_attr] attribute name String_ima_attr_rw" << endl; + string_ima_attr[0] = "Alors la, pour une surprise"; + string_ima_attr[1] = "c'est une surprise"; - att.set_value(const_cast(string_ima_attr), 2,1); + att.set_value(const_cast(string_ima_attr), 2, 1); } void DevTest::read_Event_change_tst(Tango::Attribute &att) { - cout << "[DevTest::read_attr] attribute name event_change_tst" << endl; - if (event_change_attr_except == false) - { - if (event_throw_out_of_sync == true) - { + cout << "[DevTest::read_attr] attribute name event_change_tst" << endl; + if (event_change_attr_except == false) + { + if (event_throw_out_of_sync == true) + { #ifdef WIN32 - Sleep(400); + Sleep(400); #else - struct timespec sleep_time; - sleep_time.tv_sec = 0; - sleep_time.tv_nsec = 400000000; - nanosleep(&sleep_time,NULL); + struct timespec sleep_time; + sleep_time.tv_sec = 0; + sleep_time.tv_nsec = 400000000; + nanosleep(&sleep_time, NULL); #endif - } - att.set_value(attr_event,attr_event_size); - } - else - { - Tango::Except::throw_exception((const char *)"bbb", - (const char *)"This is a test", - (const char *)"DevTest::read_attr"); - } + } + att.set_value(attr_event, attr_event_size); + } + else + { + Tango::Except::throw_exception((const char *) "bbb", + (const char *) "This is a test", + (const char *) "DevTest::read_attr"); + } } void DevTest::read_Event64_change_tst(Tango::Attribute &att) { - cout << "[DevTest::read_attr] attribute name event64_change_tst" << endl; - if (event_change_attr_except == false) - { - att.set_value(attr_event64,attr_event64_size); - } - else - { - Tango::Except::throw_exception((const char *)"bbb64", - (const char *)"This is a test", - (const char *)"DevTest::read_attr"); - } + cout << "[DevTest::read_attr] attribute name event64_change_tst" << endl; + if (event_change_attr_except == false) + { + att.set_value(attr_event64, attr_event64_size); + } + else + { + Tango::Except::throw_exception((const char *) "bbb64", + (const char *) "This is a test", + (const char *) "DevTest::read_attr"); + } } void DevTest::read_Event_quality_tst(Tango::Attribute &att) { - cout << "[DevTest::read_attr] attribute name event_quality_tst" << endl; - if (event_quality_attr_except == false) - { - if (attr_event_qua != Tango::ATTR_INVALID) - att.set_value(attr_qua_event,2); - att.set_quality(attr_event_qua); - } - else - { - Tango::Except::throw_exception((const char *)"ccc", - (const char *)"This is a test", - (const char *)"DevTest::read_attr"); - } + cout << "[DevTest::read_attr] attribute name event_quality_tst" << endl; + if (event_quality_attr_except == false) + { + if (attr_event_qua != Tango::ATTR_INVALID) + { + att.set_value(attr_qua_event, 2); + } + att.set_quality(attr_event_qua); + } + else + { + Tango::Except::throw_exception((const char *) "ccc", + (const char *) "This is a test", + (const char *) "DevTest::read_attr"); + } } - void DevTest::read_Poll_buff(TANGO_UNUSED(Tango::Attribute &att)) { - cout << "[DevTest::read_attr] attribute name Poll_buff" << endl; + cout << "[DevTest::read_attr] attribute name Poll_buff" << endl; } void DevTest::read_Poll_buffRW(TANGO_UNUSED(Tango::Attribute &att)) { - cout << "[DevTest::read_attr] attribute name Poll_buffRW" << endl; + cout << "[DevTest::read_attr] attribute name Poll_buffRW" << endl; } void DevTest::read_Float_attr(Tango::Attribute &att) { - cout << "[DevTest::read_attr] attribute name Float_attr" << endl; - attr_float = 4.5; - att.set_value(&attr_float); + cout << "[DevTest::read_attr] attribute name Float_attr" << endl; + attr_float = 4.5; + att.set_value(&attr_float); } void DevTest::read_Boolean_attr(Tango::Attribute &att) { - cout << "[DevTest::read_attr] attribute name Boolean_attr" << endl; - attr_boolean = true; - att.set_value(&attr_boolean); + cout << "[DevTest::read_attr] attribute name Boolean_attr" << endl; + attr_boolean = true; + att.set_value(&attr_boolean); } void DevTest::read_UShort_attr(Tango::Attribute &att) { - cout << "[DevTest::read_attr] attribute name UShort_attr" << endl; - attr_ushort = 111; - att.set_value(&attr_ushort); + cout << "[DevTest::read_attr] attribute name UShort_attr" << endl; + attr_ushort = 111; + att.set_value(&attr_ushort); } void DevTest::read_UChar_attr(Tango::Attribute &att) { - cout << "[DevTest::read_attr] attribute name UChar_attr" << endl; - attr_uchar = 88; - att.set_value(&attr_uchar); + cout << "[DevTest::read_attr] attribute name UChar_attr" << endl; + attr_uchar = 88; + att.set_value(&attr_uchar); } void DevTest::read_ULong_attr(Tango::Attribute &att) { - cout << "[DevTest::read_attr] attribute name ULong_attr" << endl; - attr_ulong = 100; - att.set_value(&attr_ulong); + cout << "[DevTest::read_attr] attribute name ULong_attr" << endl; + attr_ulong = 100; + att.set_value(&attr_ulong); } void DevTest::read_ULong64_attr(Tango::Attribute &att) { - cout << "[DevTest::read_attr] attribute name ULong64_attr" << endl; - attr_ulong64 = 200; - att.set_value(&attr_ulong64); + cout << "[DevTest::read_attr] attribute name ULong64_attr" << endl; + attr_ulong64 = 200; + att.set_value(&attr_ulong64); } void DevTest::read_Float_spec_attr(Tango::Attribute &att) { - cout << "[DevTest::read_attr] attribute name Float_spec_attr" << endl; - attr_spec_float[0] = 4.5; - attr_spec_float[1] = 8.5; - attr_spec_float[2] = 16.5; - att.set_value(attr_spec_float,3); + cout << "[DevTest::read_attr] attribute name Float_spec_attr" << endl; + attr_spec_float[0] = 4.5; + attr_spec_float[1] = 8.5; + attr_spec_float[2] = 16.5; + att.set_value(attr_spec_float, 3); } void DevTest::read_Boolean_spec_attr(Tango::Attribute &att) { - cout << "[DevTest::read_attr] attribute name Boolean_spec_attr" << endl; - attr_spec_boolean[0] = true; - attr_spec_boolean[1] = true; - attr_spec_boolean[2] = false; - attr_spec_boolean[3] = true; - attr_spec_boolean[4] = true; - att.set_value(attr_spec_boolean,5); + cout << "[DevTest::read_attr] attribute name Boolean_spec_attr" << endl; + attr_spec_boolean[0] = true; + attr_spec_boolean[1] = true; + attr_spec_boolean[2] = false; + attr_spec_boolean[3] = true; + attr_spec_boolean[4] = true; + att.set_value(attr_spec_boolean, 5); } void DevTest::read_UShort_spec_attr(Tango::Attribute &att) { - cout << "[DevTest::read_attr] attribute name UShort_spec_attr" << endl; - attr_spec_ushort[0] = 333; - attr_spec_ushort[1] = 444; - att.set_value(attr_spec_ushort,2); + cout << "[DevTest::read_attr] attribute name UShort_spec_attr" << endl; + attr_spec_ushort[0] = 333; + attr_spec_ushort[1] = 444; + att.set_value(attr_spec_ushort, 2); } void DevTest::read_UChar_spec_attr(Tango::Attribute &att) { - cout << "[DevTest::read_attr] attribute name UChar_spec_attr" << endl; - attr_spec_uchar[0] = 28; - attr_spec_uchar[1] = 45; - attr_spec_uchar[2] = 156; - attr_spec_uchar[3] = 34; - attr_spec_uchar[4] = 200; - attr_spec_uchar[5] = 12; - att.set_value(attr_spec_uchar,6); + cout << "[DevTest::read_attr] attribute name UChar_spec_attr" << endl; + attr_spec_uchar[0] = 28; + attr_spec_uchar[1] = 45; + attr_spec_uchar[2] = 156; + attr_spec_uchar[3] = 34; + attr_spec_uchar[4] = 200; + attr_spec_uchar[5] = 12; + att.set_value(attr_spec_uchar, 6); } void DevTest::read_Float_spec_attr_rw(Tango::Attribute &att) { - cout << "[DevTest::read_attr] attribute name Float_spec_attr_rw" << endl; - attr_spec_float[0] = 5.5; - attr_spec_float[1] = 11.5; + cout << "[DevTest::read_attr] attribute name Float_spec_attr_rw" << endl; + attr_spec_float[0] = 5.5; + attr_spec_float[1] = 11.5; - att.set_value(attr_spec_float, 2); + att.set_value(attr_spec_float, 2); } void DevTest::read_UChar_spec_attr_rw(Tango::Attribute &att) { - cout << "[DevTest::read_attr] attribute name UChar_spec_attr_rw" << endl; - attr_spec_uchar[0] = 22; - attr_spec_uchar[1] = 44; - attr_spec_uchar[2] = 66; + cout << "[DevTest::read_attr] attribute name UChar_spec_attr_rw" << endl; + attr_spec_uchar[0] = 22; + attr_spec_uchar[1] = 44; + attr_spec_uchar[2] = 66; - att.set_value(attr_spec_uchar, 3); + att.set_value(attr_spec_uchar, 3); } void DevTest::read_Boolean_ima_attr_rw(Tango::Attribute &att) { - cout << "[DevTest::read_attr] attribute name Boolean_ima_attr_rw" << endl; - attr_spec_boolean[0] = true; - attr_spec_boolean[1] = false; + cout << "[DevTest::read_attr] attribute name Boolean_ima_attr_rw" << endl; + attr_spec_boolean[0] = true; + attr_spec_boolean[1] = false; - att.set_value(attr_spec_boolean, 2,1); + att.set_value(attr_spec_boolean, 2, 1); } void DevTest::read_UShort_ima_attr_rw(Tango::Attribute &att) { - cout << "[DevTest::read_attr] attribute name UShort_ima_attr_rw" << endl; - attr_spec_ushort[0] = 2; - attr_spec_ushort[1] = 3; + cout << "[DevTest::read_attr] attribute name UShort_ima_attr_rw" << endl; + attr_spec_ushort[0] = 2; + attr_spec_ushort[1] = 3; - att.set_value(attr_spec_ushort, 2,1); + att.set_value(attr_spec_ushort, 2, 1); } void DevTest::read_slow_actuator(Tango::Attribute &att) { - cout << "[DevTest::read_attr] attribute name slow_actuator" << endl; - slow_actua++; - att.set_value(&slow_actua); + cout << "[DevTest::read_attr] attribute name slow_actuator" << endl; + slow_actua++; + att.set_value(&slow_actua); - struct timeval now; + struct timeval now; #ifdef WIN32 - struct _timeb before_win; - _ftime(&before_win); - now.tv_sec = (unsigned long)before_win.time; - now.tv_usec = (long)before_win.millitm * 1000; + struct _timeb before_win; + _ftime(&before_win); + now.tv_sec = (unsigned long)before_win.time; + now.tv_usec = (long)before_win.millitm * 1000; #else - gettimeofday(&now,NULL); + gettimeofday(&now, NULL); #endif - long delta; - if (slow_actua_write.tv_sec != 0) - { - COMPUTE_TIME_DIFF(delta,slow_actua_write,now); - cout << "Delta time = " << delta << endl; - if (delta > 3000) - { - att.set_quality(Tango::ATTR_VALID); - slow_actua_write.tv_sec = 0; - } - else - { - att.set_quality(Tango::ATTR_CHANGING); - } - } + long delta; + if (slow_actua_write.tv_sec != 0) + { + COMPUTE_TIME_DIFF(delta, slow_actua_write, now); + cout << "Delta time = " << delta << endl; + if (delta > 3000) + { + att.set_quality(Tango::ATTR_VALID); + slow_actua_write.tv_sec = 0; + } + else + { + att.set_quality(Tango::ATTR_CHANGING); + } + } } void DevTest::read_fast_actuator(Tango::Attribute &att) { - cout << "[DevTest::read_attr] attribute name fast_actuator" << endl; - att.set_value(&fast_actua); + cout << "[DevTest::read_attr] attribute name fast_actuator" << endl; + att.set_value(&fast_actua); } void DevTest::read_Long64_spec_attr_rw(Tango::Attribute &att) { - cout << "[DevTest::read_attr] attribute name Long64_spec_attr_rw" << endl; - att.set_value(attr_spec_long64_rw,3); + cout << "[DevTest::read_attr] attribute name Long64_spec_attr_rw" << endl; + att.set_value(attr_spec_long64_rw, 3); } void DevTest::read_ULong_spec_attr_rw(Tango::Attribute &att) { - cout << "[DevTest::read_attr] attribute name ULong_spec_attr_rw" << endl; - att.set_value(attr_spec_ulong_rw,3); + cout << "[DevTest::read_attr] attribute name ULong_spec_attr_rw" << endl; + att.set_value(attr_spec_ulong_rw, 3); } void DevTest::read_ULong64_spec_attr_rw(Tango::Attribute &att) { - cout << "[DevTest::read_attr] attribute name ULong64_spec_attr_rw" << endl; - att.set_value(attr_spec_ulong64_rw,3); + cout << "[DevTest::read_attr] attribute name ULong64_spec_attr_rw" << endl; + att.set_value(attr_spec_ulong64_rw, 3); } void DevTest::read_State_spec_attr_rw(Tango::Attribute &att) { - cout << "[DevTest::read_attr] attribute name State_spec_attr_rw" << endl; - att.set_value(attr_spec_state_rw,2); + cout << "[DevTest::read_attr] attribute name State_spec_attr_rw" << endl; + att.set_value(attr_spec_state_rw, 2); } void DevTest::read_Sub_device_tst(Tango::Attribute &att) { - cout << "[DevTest::read_attr] attribute name Sub_device_tst" << endl; + cout << "[DevTest::read_attr] attribute name Sub_device_tst" << endl; - Tango::Util *tg = Tango::Util::instance(); + Tango::Util *tg = Tango::Util::instance(); // // sort the devices in the ascending name order // - vector &dev_list = tg->get_device_list_by_class("DevTest"); - vector dev_list_sorted = dev_list; - - size_t n = dev_list_sorted.size(); - // the second device on the list is selected to be the sub device, so the list has to comprise of 2 or more elements - if(n > 1) { - // bubble sort - do { - size_t i; - for(i = 0; i < n-1; i++) - { - if(dev_list_sorted[i]->get_name() > dev_list_sorted[i+1]->get_name()) - { - Tango::DeviceImpl *dev_tmp; - dev_tmp = dev_list_sorted[i]; - dev_list_sorted[i] = dev_list_sorted[i+1]; - dev_list_sorted[i+1] = dev_tmp; - } - } - n = i; - } - while(n != 1); - - try - { - Tango::DeviceProxy *remote_dev; - remote_dev = new Tango::DeviceProxy(dev_list_sorted[1]->get_name()); - attr_sub_device_tst = true; - } - catch (...) - { - attr_sub_device_tst = false; - } - } - else - attr_sub_device_tst = false; + vector &dev_list = tg->get_device_list_by_class("DevTest"); + vector dev_list_sorted = dev_list; + + size_t n = dev_list_sorted.size(); + // the second device on the list is selected to be the sub device, so the list has to comprise of 2 or more elements + if (n > 1) + { + // bubble sort + do + { + size_t i; + for (i = 0; i < n - 1; i++) + { + if (dev_list_sorted[i]->get_name() > dev_list_sorted[i + 1]->get_name()) + { + Tango::DeviceImpl *dev_tmp; + dev_tmp = dev_list_sorted[i]; + dev_list_sorted[i] = dev_list_sorted[i + 1]; + dev_list_sorted[i + 1] = dev_tmp; + } + } + n = i; + } + while (n != 1); + + try + { + Tango::DeviceProxy *remote_dev; + remote_dev = new Tango::DeviceProxy(dev_list_sorted[1]->get_name()); + attr_sub_device_tst = true; + } + catch (...) + { + attr_sub_device_tst = false; + } + } + else + { + attr_sub_device_tst = false; + } - att.set_value(&attr_sub_device_tst); + att.set_value(&attr_sub_device_tst); } void DevTest::read_Encoded_attr_rw(Tango::Attribute &att) { // static int count = 0; - cout << "[DevTest::read_attr] attribute name Encoded_attr_rw" << endl; + cout << "[DevTest::read_attr] attribute name Encoded_attr_rw" << endl; #ifndef COMPAT /* if ((count % 2) == 0) @@ -1949,7 +2008,7 @@ void DevTest::read_Encoded_attr_rw(Tango::Attribute &att) enc_attr.encoded_data[0] = 22; }*/ - att.set_value(&enc_attr); + att.set_value(&enc_attr); // count++; /* enc_attr_ptr = new Tango::DevEncoded; @@ -1979,21 +2038,23 @@ void DevTest::read_Encoded_attr_rw(Tango::Attribute &att) void DevTest::read_Encoded_attr_image(Tango::Attribute &att) { - cout << "[DevTest::read_attr] attribute name Encoded_attr_image" << endl; + cout << "[DevTest::read_attr] attribute name Encoded_attr_image" << endl; #ifndef COMPAT - // Build a dummy image - unsigned char *imageData = (unsigned char *)malloc(256*256); - for(int i=0;i<256;i++) { - for(int j=0;j<256;j++) { - imageData[i+j*256] = i; + // Build a dummy image + unsigned char *imageData = (unsigned char *) malloc(256 * 256); + for (int i = 0; i < 256; i++) + { + for (int j = 0; j < 256; j++) + { + imageData[i + j * 256] = i; + } } - } - // Encode a JPEG image - jpeg.encode_jpeg_gray8(imageData,256,256,50.0); - att.set_value(&jpeg); - free(imageData); + // Encode a JPEG image + jpeg.encode_jpeg_gray8(imageData, 256, 256, 50.0); + att.set_value(&jpeg); + free(imageData); #endif } @@ -2001,12 +2062,12 @@ void DevTest::read_Encoded_attr_image(Tango::Attribute &att) void DevTest::read_Slow_attr(Tango::Attribute &att) { #ifdef WIN32 - Sleep(500); + Sleep(500); #else struct timespec sl; sl.tv_sec = 0; sl.tv_nsec = 500000000; - nanosleep(&sl,NULL); + nanosleep(&sl, NULL); #endif att.set_value(&attr_slow); @@ -2014,69 +2075,69 @@ void DevTest::read_Slow_attr(Tango::Attribute &att) void DevTest::read_Def_attr(Tango::Attribute &att) { - cout << "[DevTest::read_attr] attribute name DefAttr" << endl; - att.set_value(&att_conf); + cout << "[DevTest::read_attr] attribute name DefAttr" << endl; + att.set_value(&att_conf); } void DevTest::read_DefUser_attr(Tango::Attribute &att) { - cout << "[DevTest::read_attr] attribute name DefUserAttr" << endl; - att.set_value(&att_conf); + cout << "[DevTest::read_attr] attribute name DefUserAttr" << endl; + att.set_value(&att_conf); } void DevTest::read_DefClass_attr(Tango::Attribute &att) { - cout << "[DevTest::read_attr] attribute name DefClassAttr" << endl; - att.set_value(&att_conf); + cout << "[DevTest::read_attr] attribute name DefClassAttr" << endl; + att.set_value(&att_conf); } void DevTest::read_DefClassUser_attr(Tango::Attribute &att) { - cout << "[DevTest::read_attr] attribute name DefClassUserAttr" << endl; - att.set_value(&att_conf); + cout << "[DevTest::read_attr] attribute name DefClassUserAttr" << endl; + att.set_value(&att_conf); } void DevTest::read_Enum_attr(Tango::Attribute &att) { - cout << "[DevTest::read_attr] attribute name EnumAttr" << endl; - cp = SOUTH; - att.set_value(&cp); + cout << "[DevTest::read_attr] attribute name EnumAttr" << endl; + cp = SOUTH; + att.set_value(&cp); } void DevTest::read_Enum_spec_attr_rw(Tango::Attribute &att) { - cout << "[DevTest::read_attr] attribute name Enum_spec_attr_rw" << endl; - cp_array[0] = SOUTH; - cp_array[1] = NORTH; - cp_array[2] = WEST; - att.set_value(cp_array,3); + cout << "[DevTest::read_attr] attribute name Enum_spec_attr_rw" << endl; + cp_array[0] = SOUTH; + cp_array[1] = NORTH; + cp_array[2] = WEST; + att.set_value(cp_array, 3); } void DevTest::read_DynEnum_attr(Tango::Attribute &att) { - cout << "[DevTest::read_attr] attribute name DynEnum_attr" << endl; - att.set_value(&enum_value); + cout << "[DevTest::read_attr] attribute name DynEnum_attr" << endl; + att.set_value(&enum_value); } void DevTest::read_ReynaldPoll_attr(TANGO_UNUSED(Tango::Attribute &att)) { - cout << "[DevTest::read_attr] attribute name ReynaldPoll_attr" << endl; + cout << "[DevTest::read_attr] attribute name ReynaldPoll_attr" << endl; - Reynald_ctr++; - if ((Reynald_ctr % 3) == 0) + Reynald_ctr++; + if ((Reynald_ctr % 3) == 0) { int poll_period = get_attribute_poll_period("Short_attr"); if (poll_period == 250) { -cout << "ReynaldPollAttr: Setting period to 500" << endl; - poll_attribute("Short_attr",500); - poll_attribute("ReynaldPollAttr",500); + cout << "ReynaldPollAttr: Setting period to 500" << endl; + poll_attribute("Short_attr", 500); + poll_attribute("ReynaldPollAttr", 500); } else { -cout << "ReynaldPollAttr: Setting period to 250" << endl; - poll_attribute("Short_attr",250); - poll_attribute("ReynaldPollAttr",250); + cout << "ReynaldPollAttr: Setting period to 250" << endl; + poll_attribute("Short_attr", 250); + poll_attribute("ReynaldPollAttr", 250); } } } @@ -2091,515 +2152,535 @@ cout << "ReynaldPollAttr: Setting period to 250" << endl; bool DevTest::is_RPipe_allowed(Tango::PipeReqType) { - if (get_state() == Tango::ON) - return true; - else - return false; + if (get_state() == Tango::ON) + { + return true; + } + else + { + return false; + } } void DevTest::read_RPipe(Tango::Pipe &pipe) { - switch (rpipe_type) - { - case 0: - { - pipe.set_root_blob_name("BlobCase0"); - - vector de_names; - de_names.push_back(string("FirstDE")); - de_names.push_back(string("SecondDE")); - de_names.push_back(string("ThirdDE")); - de_names.push_back(string("ForthDE")); - - pipe.set_data_elt_names(de_names); - - dl = 666; - v_db.clear(); - v_db.push_back(1.11); - v_db.push_back(2.22); - - unsigned short *array = new unsigned short [100]; - for (unsigned short i = 0;i < 100;i++) - array[i] = i; - Tango::DevVarUShortArray *dvush = create_DevVarUShortArray(array,100); - - dvsa.length(2); - dvsa[0] = Tango::ON; - dvsa[1] = Tango::OFF; - - try - { - pipe << dl << v_db << dvush << dvsa; - cout << "Data type 0 inserted in pipe" << endl; - } - catch (Tango::DevFailed &e) - { - Tango::Except::print_exception(e); - throw e; - } - } - break; + switch (rpipe_type) + { + case 0: + { + pipe.set_root_blob_name("BlobCase0"); + + vector de_names; + de_names.push_back(string("FirstDE")); + de_names.push_back(string("SecondDE")); + de_names.push_back(string("ThirdDE")); + de_names.push_back(string("ForthDE")); + + pipe.set_data_elt_names(de_names); + + dl = 666; + v_db.clear(); + v_db.push_back(1.11); + v_db.push_back(2.22); + + unsigned short *array = new unsigned short[100]; + for (unsigned short i = 0; i < 100; i++) + { + array[i] = i; + } + Tango::DevVarUShortArray *dvush = create_DevVarUShortArray(array, 100); + + dvsa.length(2); + dvsa[0] = Tango::ON; + dvsa[1] = Tango::OFF; + + try + { + pipe << dl << v_db << dvush << dvsa; + cout << "Data type 0 inserted in pipe" << endl; + } + catch (Tango::DevFailed &e) + { + Tango::Except::print_exception(e); + throw e; + } + } + break; - case 1: - { - pipe.set_root_blob_name("BlobCase1"); - - pipe.set_data_elt_nb(5); - - pipe_str.name = "stringDE"; - pipe_str.value = "Hello"; - - pipe_devstr.name = "DevStringDE"; - pipe_devstr.value = const_cast("Hola"); - - pipe_enc.name = "DevEncodedDE"; - pipe_enc.value.encoded_format = "Format"; - pipe_enc.value.encoded_data.length(2); - pipe_enc.value.encoded_data[0] = 0; - pipe_enc.value.encoded_data[1] = 1; - - pipe_v_str.name = "VectorStringDE"; - pipe_v_str.value.clear(); - pipe_v_str.value.push_back(string("Bonjour")); - pipe_v_str.value.push_back(string("le")); - pipe_v_str.value.push_back(string("monde")); - - pipe_dvsa.name = "DevVarStringArrayDE"; - pipe_dvsa.value.length(1); - (pipe_dvsa.value)[0] = "Why not?"; - - try - { - pipe << pipe_str << pipe_devstr << pipe_enc << pipe_v_str << pipe_dvsa; - cout << "Data type 1 inserted in pipe" << endl; - } - catch (Tango::DevFailed &e) - { - Tango::Except::print_exception(e); - throw e; - } - } - break; + case 1: + { + pipe.set_root_blob_name("BlobCase1"); + + pipe.set_data_elt_nb(5); + + pipe_str.name = "stringDE"; + pipe_str.value = "Hello"; + + pipe_devstr.name = "DevStringDE"; + pipe_devstr.value = const_cast("Hola"); + + pipe_enc.name = "DevEncodedDE"; + pipe_enc.value.encoded_format = "Format"; + pipe_enc.value.encoded_data.length(2); + pipe_enc.value.encoded_data[0] = 0; + pipe_enc.value.encoded_data[1] = 1; + + pipe_v_str.name = "VectorStringDE"; + pipe_v_str.value.clear(); + pipe_v_str.value.push_back(string("Bonjour")); + pipe_v_str.value.push_back(string("le")); + pipe_v_str.value.push_back(string("monde")); + + pipe_dvsa.name = "DevVarStringArrayDE"; + pipe_dvsa.value.length(1); + (pipe_dvsa.value)[0] = "Why not?"; + + try + { + pipe << pipe_str << pipe_devstr << pipe_enc << pipe_v_str << pipe_dvsa; + cout << "Data type 1 inserted in pipe" << endl; + } + catch (Tango::DevFailed &e) + { + Tango::Except::print_exception(e); + throw e; + } + } + break; - case 2: - { - pipe.set_root_blob_name("BlobCase2"); + case 2: + { + pipe.set_root_blob_name("BlobCase2"); - vector de_names; - de_names.push_back(string("FirstDE")); - de_names.push_back(string("SecondDE")); - pipe.set_data_elt_names(de_names); + vector de_names; + de_names.push_back(string("FirstDE")); + de_names.push_back(string("SecondDE")); + pipe.set_data_elt_names(de_names); - dl = 999; - v_db.clear(); - v_db.push_back(3.33); - v_db.push_back(4.44); - v_db.push_back(5.55); + dl = 999; + v_db.clear(); + v_db.push_back(3.33); + v_db.push_back(4.44); + v_db.push_back(5.55); - pipe["SecondDE"] << v_db; - pipe["FirstDE"] << dl; + pipe["SecondDE"] << v_db; + pipe["FirstDE"] << dl; - cout << "Data type 2 inserted in pipe" << endl; - } - break; + cout << "Data type 2 inserted in pipe" << endl; + } + break; - case 3: - { - pipe.set_root_blob_name("BlobCase3"); + case 3: + { + pipe.set_root_blob_name("BlobCase3"); - vector de_inner_inner_names; - de_inner_inner_names.push_back(string("InnerInnerFirstDE")); - de_inner_inner_names.push_back("InnerInnerSecondDE"); - inner_inner_blob.set_data_elt_names(de_inner_inner_names); - inner_inner_blob.set_name("InnerInner"); + vector de_inner_inner_names; + de_inner_inner_names.push_back(string("InnerInnerFirstDE")); + de_inner_inner_names.push_back("InnerInnerSecondDE"); + inner_inner_blob.set_data_elt_names(de_inner_inner_names); + inner_inner_blob.set_name("InnerInner"); - dl = 111; - v_db.clear(); - v_db.push_back(3.33); + dl = 111; + v_db.clear(); + v_db.push_back(3.33); - inner_inner_blob["InnerInnerSecondDE"] << v_db; - inner_inner_blob["InnerInnerFirstDE"] << dl; + inner_inner_blob["InnerInnerSecondDE"] << v_db; + inner_inner_blob["InnerInnerFirstDE"] << dl; - vector de_inner_names; - de_inner_names.push_back("InnerFirstDE"); - de_inner_names.push_back("InnerSecondDE"); - de_inner_names.push_back("InnerThirdDE"); - inner_blob.set_data_elt_names(de_inner_names); - inner_blob.set_name("Inner"); + vector de_inner_names; + de_inner_names.push_back("InnerFirstDE"); + de_inner_names.push_back("InnerSecondDE"); + de_inner_names.push_back("InnerThirdDE"); + inner_blob.set_data_elt_names(de_inner_names); + inner_blob.set_name("Inner"); - inner_str = "Grenoble"; - inner_bool = true; + inner_str = "Grenoble"; + inner_bool = true; - inner_blob << inner_str << inner_inner_blob << inner_bool; + inner_blob << inner_str << inner_inner_blob << inner_bool; - vector de_names; - de_names.push_back("1DE"); - de_names.push_back("2DE"); - pipe.set_data_elt_names(de_names); + vector de_names; + de_names.push_back("1DE"); + de_names.push_back("2DE"); + pipe.set_data_elt_names(de_names); - v_dl.clear(); - v_dl.push_back(3); - v_dl.push_back(4); - v_dl.push_back(5); - v_dl.push_back(6); + v_dl.clear(); + v_dl.push_back(3); + v_dl.push_back(4); + v_dl.push_back(5); + v_dl.push_back(6); - pipe << inner_blob << v_dl; + pipe << inner_blob << v_dl; - cout << "Data type 3 inserted in pipe" << endl; - } - break; + cout << "Data type 3 inserted in pipe" << endl; + } + break; - case 4: - { - pipe.set_root_blob_name("BlobCase4"); - vector de_names; - de_names.push_back("1DE"); - de_names.push_back("2DE"); - pipe.set_data_elt_names(de_names); + case 4: + { + pipe.set_root_blob_name("BlobCase4"); + vector de_names; + de_names.push_back("1DE"); + de_names.push_back("2DE"); + pipe.set_data_elt_names(de_names); - pipe << dl; + pipe << dl; - cout << "Data type 4 inserted in pipe" << endl; - } - break; + cout << "Data type 4 inserted in pipe" << endl; + } + break; - case 5: - { - pipe.set_root_blob_name("BlobCase5"); - vector de_names; - de_names.push_back("1DE"); - pipe.set_data_elt_names(de_names); + case 5: + { + pipe.set_root_blob_name("BlobCase5"); + vector de_names; + de_names.push_back("1DE"); + pipe.set_data_elt_names(de_names); - cout << "Data type 5 inserted in pipe" << endl; - } - break; + cout << "Data type 5 inserted in pipe" << endl; + } + break; - case 6: - { - pipe.set_root_blob_name("BlobCase6"); - vector de_names; - de_names.push_back("1DE"); - de_names.push_back("2DE"); - de_names.push_back("1de"); - pipe.set_data_elt_names(de_names); - } - break; + case 6: + { + pipe.set_root_blob_name("BlobCase6"); + vector de_names; + de_names.push_back("1DE"); + de_names.push_back("2DE"); + de_names.push_back("1de"); + pipe.set_data_elt_names(de_names); + } + break; - case 7: - { - pipe.set_root_blob_name("BlobCase7"); - pipe << dl; - } - break; + case 7: + { + pipe.set_root_blob_name("BlobCase7"); + pipe << dl; + } + break; - case 8: - { - pipe.set_root_blob_name("BlobCase8"); + case 8: + { + pipe.set_root_blob_name("BlobCase8"); - vector de_names; - de_names.push_back("1DE"); - de_names.push_back("2DE"); - de_names.push_back("3de"); - pipe.set_data_elt_names(de_names); + vector de_names; + de_names.push_back("1DE"); + de_names.push_back("2DE"); + de_names.push_back("3de"); + pipe.set_data_elt_names(de_names); - pipe << dl; - pipe["2DE"] << v_dl; - } - break; + pipe << dl; + pipe["2DE"] << v_dl; + } + break; - case 9: - { - vector de_names; - de_names.push_back("Another_1DE"); - de_names.push_back("Another_2DE"); + case 9: + { + vector de_names; + de_names.push_back("Another_1DE"); + de_names.push_back("Another_2DE"); - v_dl.clear(); - v_dl.push_back(2); - string str("Barcelona"); + v_dl.clear(); + v_dl.push_back(2); + string str("Barcelona"); - pipe.set_root_blob_name("BlobCase9"); - pipe.set_data_elt_names(de_names); - pipe << v_dl << str; + pipe.set_root_blob_name("BlobCase9"); + pipe.set_data_elt_names(de_names); + pipe << v_dl << str; - Tango::DevicePipeBlob &bl = pipe.get_blob(); - this->push_pipe_event("RPipe",&bl,true); - } - break; + Tango::DevicePipeBlob &bl = pipe.get_blob(); + this->push_pipe_event("RPipe", &bl, true); + } + break; - case 10: - { - pipe.set_root_blob_name("BlobCase10"); + case 10: + { + pipe.set_root_blob_name("BlobCase10"); - vector de_names; - de_names.push_back("1DE"); - pipe.set_data_elt_names(de_names); + vector de_names; + de_names.push_back("1DE"); + pipe.set_data_elt_names(de_names); - v_dl.clear(); - v_dl.push_back(22); - string str("Barcelona"); + v_dl.clear(); + v_dl.push_back(22); + string str("Barcelona"); - pipe << v_dl << str; - } - break; + pipe << v_dl << str; + } + break; - case 11: - { - pipe.set_root_blob_name("BlobCase11"); + case 11: + { + pipe.set_root_blob_name("BlobCase11"); - vector de_names; - de_names.push_back("1DE"); - de_names.push_back("2DE"); - pipe.set_data_elt_names(de_names); + vector de_names; + de_names.push_back("1DE"); + de_names.push_back("2DE"); + pipe.set_data_elt_names(de_names); - Tango::DevULong64 dul64 = 123456; - v_bool.clear(); - v_bool.push_back(true); - v_bool.push_back(true); - v_bool.push_back(false); + Tango::DevULong64 dul64 = 123456; + v_bool.clear(); + v_bool.push_back(true); + v_bool.push_back(true); + v_bool.push_back(false); - pipe << dul64 << v_bool; - } - break; + pipe << dul64 << v_bool; + } + break; - case 12: - { - pipe.set_root_blob_name("BlobCase12"); + case 12: + { + pipe.set_root_blob_name("BlobCase12"); - vector de_names; - de_names.push_back("1DE_Array"); - de_names.push_back("2DE_Array"); - pipe.set_data_elt_names(de_names); + vector de_names; + de_names.push_back("1DE_Array"); + de_names.push_back("2DE_Array"); + pipe.set_data_elt_names(de_names); - v_bool.clear(); - v_bool.push_back(false); + v_bool.clear(); + v_bool.push_back(false); v_dl.clear(); v_dl.push_back(9); - pipe << v_dl << v_bool; - } - break; - } + pipe << v_dl << v_bool; + } + break; + } } // RWPipe bool DevTest::is_RWPipe_allowed(Tango::PipeReqType) { - return true; + return true; } void DevTest::read_RWPipe(Tango::Pipe &pipe) { - pipe_mutex.lock(); - pipe.set_user_pipe_mutex(&pipe_mutex); + pipe_mutex.lock(); + pipe.set_user_pipe_mutex(&pipe_mutex); - pipe.set_root_blob_name("RWPipeBlob"); + pipe.set_root_blob_name("RWPipeBlob"); - vector de_names; - de_names.push_back("RW_1DE"); - de_names.push_back("RW_2DE"); - pipe.set_data_elt_names(de_names); + vector de_names; + de_names.push_back("RW_1DE"); + de_names.push_back("RW_2DE"); + pipe.set_data_elt_names(de_names); - dl = 666; - v_db.clear(); - v_db.push_back(1.11); - v_db.push_back(2.22); + dl = 666; + v_db.clear(); + v_db.push_back(1.11); + v_db.push_back(2.22); - try - { - pipe << dl << v_db; - } - catch (Tango::DevFailed &e) - { - Tango::Except::print_exception(e); - throw e; - } + try + { + pipe << dl << v_db; + } + catch (Tango::DevFailed &e) + { + Tango::Except::print_exception(e); + throw e; + } } void DevTest::write_RWPipe(Tango::WPipe &w_pipe) { - string str; - vector v_fl; + string str; + vector v_fl; - vector de_names = w_pipe.get_data_elt_names(); - for (size_t loop = 0;loop < de_names.size();loop++) - cout << "RWPipe: Received data element name = " << de_names[loop] << endl; + vector de_names = w_pipe.get_data_elt_names(); + for (size_t loop = 0; loop < de_names.size(); loop++) + { + cout << "RWPipe: Received data element name = " << de_names[loop] << endl; + } - w_pipe >> str >> v_fl; + w_pipe >> str >> v_fl; } // RPipeDE bool DevTest::is_RPipeDE_allowed(Tango::PipeReqType) { - if (get_state() == Tango::ON) - return true; - else - return false; + if (get_state() == Tango::ON) + { + return true; + } + else + { + return false; + } } void DevTest::read_RPipeDE(Tango::Pipe &pipe) { - pipe.set_root_blob_name("BlobDE"); + pipe.set_root_blob_name("BlobDE"); - vector de_names; - de_names.push_back(string("FirstDE")); - de_names.push_back(string("SecondDE")); - de_names.push_back(string("ThirdDE")); - de_names.push_back(string("ForthDE")); + vector de_names; + de_names.push_back(string("FirstDE")); + de_names.push_back(string("SecondDE")); + de_names.push_back(string("ThirdDE")); + de_names.push_back(string("ForthDE")); - pipe.set_data_elt_names(de_names); + pipe.set_data_elt_names(de_names); - dl = 666; - v_db.clear(); - v_db.push_back(1.11); - v_db.push_back(2.22); + dl = 666; + v_db.clear(); + v_db.push_back(1.11); + v_db.push_back(2.22); - unsigned short *array = new unsigned short [100]; - for (unsigned short i = 0;i < 100;i++) - array[i] = i; - Tango::DevVarUShortArray *dvush = create_DevVarUShortArray(array,100); + unsigned short *array = new unsigned short[100]; + for (unsigned short i = 0; i < 100; i++) + { + array[i] = i; + } + Tango::DevVarUShortArray *dvush = create_DevVarUShortArray(array, 100); - dvsa.length(2); - dvsa[0] = Tango::ON; - dvsa[1] = Tango::OFF; + dvsa.length(2); + dvsa[0] = Tango::ON; + dvsa[1] = Tango::OFF; - try - { - pipe << dl << v_db << dvush << dvsa; - cout << "Data inserted in pipe (using DataElement classes)" << endl; - } - catch (Tango::DevFailed &e) - { - Tango::Except::print_exception(e); - throw e; - } + try + { + pipe << dl << v_db << dvush << dvsa; + cout << "Data inserted in pipe (using DataElement classes)" << endl; + } + catch (Tango::DevFailed &e) + { + Tango::Except::print_exception(e); + throw e; + } } void DevTest::cmd_push_pipe_event(Tango::DevShort in) { if (in == 0) - { - Tango::DevicePipeBlob dpb("PipeEventCase0"); - - vector de_inner_inner_names; - de_inner_inner_names.push_back("InnerInnerFirstDE"); - de_inner_inner_names.push_back("InneraaaaaaaInnerSecondDE"); - inner_inner_blob.set_data_elt_names(de_inner_inner_names); - inner_inner_blob.set_name("InnerInner"); - - dl = 111; - v_db.clear(); - v_db.push_back(3.33); - v_db.push_back(3.33); - - inner_inner_blob["InneraaaaaaaInnerSecondDE"] << v_db; - inner_inner_blob["InnerInnerFirstDE"] << dl; - - vector de_inner_names; - de_inner_names.push_back("InnerFirstDE"); - de_inner_names.push_back("InnerSecondDE"); - de_inner_names.push_back("InnerThirdDE"); - inner_blob.set_data_elt_names(de_inner_names); - inner_blob.set_name("Inner"); - - inner_str = "Grenoble"; - inner_bool = true; - - inner_blob << inner_str << inner_inner_blob << inner_bool; - - vector de_names; - de_names.push_back("1DE"); - de_names.push_back("2DE"); - dpb.set_data_elt_names(de_names); - - v_dl.clear(); - v_dl.push_back(3); - v_dl.push_back(4); - v_dl.push_back(5); - v_dl.push_back(6); - - dpb << inner_blob << v_dl; - this->push_pipe_event("RWPipe",&dpb); - } - else if (in == 1) - { - Tango::DevicePipeBlob dpb("PipeEventCase1"); - vector de_names; - de_names.push_back("Another_1DE"); - de_names.push_back("Another_2DE"); - dpb.set_data_elt_names(de_names); - - v_dl.clear(); - v_dl.push_back(2); - string str("Barcelona"); - - dpb << v_dl << str; - - this->push_pipe_event("RWPipe",&dpb); - } - else if (in == 2) - { - Tango::DevicePipeBlob dpb("PipeEventCase2"); - vector de_names; - de_names.push_back("Qwerty_1DE"); - de_names.push_back("Azerty_2DE"); - dpb.set_data_elt_names(de_names); - - string str("Barcelona"); - - dpb << str << v_dl; + { + Tango::DevicePipeBlob dpb("PipeEventCase0"); + + vector de_inner_inner_names; + de_inner_inner_names.push_back("InnerInnerFirstDE"); + de_inner_inner_names.push_back("InneraaaaaaaInnerSecondDE"); + inner_inner_blob.set_data_elt_names(de_inner_inner_names); + inner_inner_blob.set_name("InnerInner"); + + dl = 111; + v_db.clear(); + v_db.push_back(3.33); + v_db.push_back(3.33); + + inner_inner_blob["InneraaaaaaaInnerSecondDE"] << v_db; + inner_inner_blob["InnerInnerFirstDE"] << dl; + + vector de_inner_names; + de_inner_names.push_back("InnerFirstDE"); + de_inner_names.push_back("InnerSecondDE"); + de_inner_names.push_back("InnerThirdDE"); + inner_blob.set_data_elt_names(de_inner_names); + inner_blob.set_name("Inner"); + + inner_str = "Grenoble"; + inner_bool = true; + + inner_blob << inner_str << inner_inner_blob << inner_bool; + + vector de_names; + de_names.push_back("1DE"); + de_names.push_back("2DE"); + dpb.set_data_elt_names(de_names); + + v_dl.clear(); + v_dl.push_back(3); + v_dl.push_back(4); + v_dl.push_back(5); + v_dl.push_back(6); + + dpb << inner_blob << v_dl; + this->push_pipe_event("RWPipe", &dpb); + } + else if (in == 1) + { + Tango::DevicePipeBlob dpb("PipeEventCase1"); + vector de_names; + de_names.push_back("Another_1DE"); + de_names.push_back("Another_2DE"); + dpb.set_data_elt_names(de_names); + + v_dl.clear(); + v_dl.push_back(2); + string str("Barcelona"); + + dpb << v_dl << str; + + this->push_pipe_event("RWPipe", &dpb); + } + else if (in == 2) + { + Tango::DevicePipeBlob dpb("PipeEventCase2"); + vector de_names; + de_names.push_back("Qwerty_1DE"); + de_names.push_back("Azerty_2DE"); + dpb.set_data_elt_names(de_names); + + string str("Barcelona"); + + dpb << str << v_dl; #ifdef WIN32 - struct _timeb tv; - tv.time = 10; - tv.millitm = 0; - this->push_pipe_event("RWPipe",&dpb,tv); + struct _timeb tv; + tv.time = 10; + tv.millitm = 0; + this->push_pipe_event("RWPipe",&dpb,tv); #else - struct timeval tv; - tv.tv_sec = 10; - tv.tv_usec = 0; - this->push_pipe_event("RWPipe",&dpb,tv); + struct timeval tv; + tv.tv_sec = 10; + tv.tv_usec = 0; + this->push_pipe_event("RWPipe", &dpb, tv); #endif - } - else if (in == 3) - { - Tango::DevErrorList del; - del.length(1); - del[0].reason = CORBA::string_dup("aaa"); - del[0].desc = CORBA::string_dup("bbb"); - del[0].origin = CORBA::string_dup("ccc"); - Tango::DevFailed df(del); - this->push_pipe_event("RWPipe",&df); - } - else if (in == 4) - { - Tango::DevicePipeBlob dpb("PipeEventCase4"); - vector de_names; - de_names.push_back("Lunes"); - de_names.push_back("Martes"); - dpb.set_data_elt_names(de_names); - - string str("Girona"); - - v_dl.clear(); - for (int loop = 0;loop < 3000;loop++) - v_dl.push_back(loop); - - dpb << str << v_dl; - - this->push_pipe_event("RWPipe",&dpb); - } + } + else if (in == 3) + { + Tango::DevErrorList del; + del.length(1); + del[0].reason = CORBA::string_dup("aaa"); + del[0].desc = CORBA::string_dup("bbb"); + del[0].origin = CORBA::string_dup("ccc"); + Tango::DevFailed df(del); + this->push_pipe_event("RWPipe", &df); + } + else if (in == 4) + { + Tango::DevicePipeBlob dpb("PipeEventCase4"); + vector de_names; + de_names.push_back("Lunes"); + de_names.push_back("Martes"); + dpb.set_data_elt_names(de_names); + + string str("Girona"); + + v_dl.clear(); + for (int loop = 0; loop < 3000; loop++) + { + v_dl.push_back(loop); + } + + dpb << str << v_dl; + + this->push_pipe_event("RWPipe", &dpb); + } } // ConfPipe bool DevTest::is_ConfPipe_allowed(Tango::PipeReqType) { - if (get_state() == Tango::ON) - return true; - else - return false; + if (get_state() == Tango::ON) + { + return true; + } + else + { + return false; + } } void DevTest::read_ConfPipe(TANGO_UNUSED(Tango::Pipe &pipe)) @@ -2609,13 +2690,13 @@ void DevTest::read_ConfPipe(TANGO_UNUSED(Tango::Pipe &pipe)) void DevTest::cmd_push_state_status_event() { - set_change_event("State",true,false); - set_change_event("Status",true,false); + set_change_event("State", true, false); + set_change_event("Status", true, false); this->push_change_event("state"); this->push_change_event("status"); - set_change_event("State",false,false); - set_change_event("Status",false,false); + set_change_event("State", false, false); + set_change_event("Status", false, false); } diff --git a/cpp_test_suite/cpp_test_ds/DevTestClass.cpp b/cpp_test_suite/cpp_test_ds/DevTestClass.cpp index 297013232..0b18dcdcc 100644 --- a/cpp_test_suite/cpp_test_ds/DevTestClass.cpp +++ b/cpp_test_suite/cpp_test_ds/DevTestClass.cpp @@ -19,7 +19,6 @@ #include "IOAddAttribute.h" - DevTestClass *DevTestClass::_instance = NULL; //+---------------------------------------------------------------------------- @@ -32,14 +31,15 @@ DevTestClass *DevTestClass::_instance = NULL; // //----------------------------------------------------------------------------- -DevTestClass::DevTestClass(string &s):Tango::DeviceClass(s) +DevTestClass::DevTestClass(string &s) + : Tango::DeviceClass(s) { - cout2 << "Entering DevTestClass constructor" << endl; + cout2 << "Entering DevTestClass constructor" << endl; - set_type("TestDevice"); + set_type("TestDevice"); - cout2 << "Leaving DevTestClass constructor" << endl; + cout2 << "Leaving DevTestClass constructor" << endl; } @@ -56,29 +56,29 @@ DevTestClass::DevTestClass(string &s):Tango::DeviceClass(s) DevTestClass *DevTestClass::init(const char *name) { - if (_instance == NULL) - { - try - { - string s(name); - _instance = new DevTestClass(s); - } - catch (bad_alloc) - { - throw; - } - } - return _instance; + if (_instance == NULL) + { + try + { + string s(name); + _instance = new DevTestClass(s); + } + catch (bad_alloc) + { + throw; + } + } + return _instance; } DevTestClass *DevTestClass::instance() { - if (_instance == NULL) - { - cerr << "Class is not initialised !!" << endl; - exit(-1); - } - return _instance; + if (_instance == NULL) + { + cerr << "Class is not initialised !!" << endl; + exit(-1); + } + return _instance; } //+---------------------------------------------------------------------------- @@ -92,563 +92,566 @@ DevTestClass *DevTestClass::instance() void DevTestClass::command_factory() { - command_list.push_back(new IOString("IOString", - Tango::DEV_STRING, - Tango::DEV_STRING, - "Word", - "the pallindrome is")); - command_list.push_back(new IOBool("IOBool", - Tango::DEV_BOOLEAN, - Tango::DEV_BOOLEAN, - "Number", - "Not number")); - command_list.push_back(new IOShort("IOShort", - Tango::DEV_SHORT, - Tango::DEV_SHORT, - "Number", - "Number * 2")); - command_list.push_back(new IOLong("IOLong", - Tango::DEV_LONG, - Tango::DEV_LONG, - "Number", - "Number * 2")); - command_list.push_back(new IOFloat("IOFloat", - Tango::DEV_FLOAT, - Tango::DEV_FLOAT, - "Number", - "Number * 2")); - command_list.push_back(new IODouble("IODouble", - Tango::DEV_DOUBLE, - Tango::DEV_DOUBLE, - "Number", - "Number * 2")); - command_list.push_back(new IOUShort("IOUShort", - Tango::DEV_USHORT, - Tango::DEV_USHORT, - "Number", - "Number * 2")); - command_list.push_back(new IOULong("IOULong", - Tango::DEV_ULONG, - Tango::DEV_ULONG, - "Number", - "Number * 2")); - command_list.push_back(new IOBooleanArray("IOBoolArray", + command_list.push_back(new IOString("IOString", + Tango::DEV_STRING, + Tango::DEV_STRING, + "Word", + "the pallindrome is")); + command_list.push_back(new IOBool("IOBool", + Tango::DEV_BOOLEAN, + Tango::DEV_BOOLEAN, + "Number", + "Not number")); + command_list.push_back(new IOShort("IOShort", + Tango::DEV_SHORT, + Tango::DEV_SHORT, + "Number", + "Number * 2")); + command_list.push_back(new IOLong("IOLong", + Tango::DEV_LONG, + Tango::DEV_LONG, + "Number", + "Number * 2")); + command_list.push_back(new IOFloat("IOFloat", + Tango::DEV_FLOAT, + Tango::DEV_FLOAT, + "Number", + "Number * 2")); + command_list.push_back(new IODouble("IODouble", + Tango::DEV_DOUBLE, + Tango::DEV_DOUBLE, + "Number", + "Number * 2")); + command_list.push_back(new IOUShort("IOUShort", + Tango::DEV_USHORT, + Tango::DEV_USHORT, + "Number", + "Number * 2")); + command_list.push_back(new IOULong("IOULong", + Tango::DEV_ULONG, + Tango::DEV_ULONG, + "Number", + "Number * 2")); + command_list.push_back(new IOBooleanArray("IOBoolArray", Tango::DEVVAR_BOOLEANARRAY, Tango::DEVVAR_BOOLEANARRAY, "Array of boolean", "Echo")); command_list.push_back(new IOCharArray("IOCharArray", - Tango::DEVVAR_CHARARRAY, - Tango::DEVVAR_CHARARRAY, - "Array of char", - "This reversed array")); - command_list.push_back(new IOShortArray("IOShortArray", - Tango::DEVVAR_SHORTARRAY, - Tango::DEVVAR_SHORTARRAY, - "Array of short", - "This array * 2")); - command_list.push_back(new IOLongArray("IOLongArray", - Tango::DEVVAR_LONGARRAY, - Tango::DEVVAR_LONGARRAY, - "Array of long", - "This array * 2")); - command_list.push_back(new IOFloatArray("IOFloatArray", - Tango::DEVVAR_FLOATARRAY, - Tango::DEVVAR_FLOATARRAY, - "Array of float", - "This array * 2")); - command_list.push_back(new IODoubleArray("IODoubleArray", - Tango::DEVVAR_DOUBLEARRAY, - Tango::DEVVAR_DOUBLEARRAY, - "Array of double", - "This array * 2")); - command_list.push_back(new IOUShortArray("IOUShortArray", - Tango::DEVVAR_USHORTARRAY, - Tango::DEVVAR_USHORTARRAY, - "Array of unsigned short", - "This array * 2")); - command_list.push_back(new IOULongArray("IOULongArray", - Tango::DEVVAR_ULONGARRAY, - Tango::DEVVAR_ULONGARRAY, - "Array of unsigned long", - "This array * 2")); - command_list.push_back(new IOStringArray("IOStringArray", - Tango::DEVVAR_STRINGARRAY, - Tango::DEVVAR_STRINGARRAY, - "Array of string", - "This reversed array ")); - command_list.push_back(new IOLongString("IOLongString", - Tango::DEVVAR_LONGSTRINGARRAY, - Tango::DEVVAR_LONGSTRINGARRAY, - "Array of long and string", - "This array of long * 2")); - command_list.push_back(new IODoubleString("IODoubleString", - Tango::DEVVAR_DOUBLESTRINGARRAY, - Tango::DEVVAR_DOUBLESTRINGARRAY, - "Array of double and string", - "This array of long * 2")); - command_list.push_back(new IOThrow("IOThrow", - Tango::DEVVAR_LONGSTRINGARRAY, - Tango::DEV_VOID, - "Error facility", - "An exception")); - command_list.push_back(new IOReThrow("IOReThrow", - Tango::DEVVAR_LONGSTRINGARRAY, - Tango::DEV_VOID, - "Error facility", - "An exception")); - command_list.push_back(new IOExcept("IOExcept", - Tango::DEV_VOID, - Tango::DEV_VOID, - "Void", - "An exception")); - command_list.push_back(new IOVoid("IOVoid", - Tango::DEV_VOID, - Tango::DEV_VOID, - "void", - "void")); - command_list.push_back(new IOSleep("IOSleep", - Tango::DEV_USHORT, - Tango::DEV_VOID, - "sleeping time", - "void")); - command_list.push_back(new IOState("IOState", - Tango::DEV_STATE, - Tango::DEV_VOID, - "New device state", - "void")); - command_list.push_back(new IORegSig("IORegSig", - Tango::DEV_LONG, - Tango::DEV_VOID, - "Signal number", - "void")); - command_list.push_back(new IORegSigOwn("IORegSigOwn", - Tango::DEV_LONG, - Tango::DEV_VOID, - "Signal number", - "void")); - command_list.push_back(new IOUnregSig("IOUnregSig", - Tango::DEV_LONG, - Tango::DEV_VOID, - "Signal number", - "void")); - command_list.push_back(new IORegClassSig("IORegClassSig", - Tango::DEV_LONG, - Tango::DEV_VOID, - "Signal number", - "void")); - command_list.push_back(new IOUnregClassSig("IOUnregClassSig", - Tango::DEV_LONG, - Tango::DEV_VOID, - "Signal number", - "void")); - command_list.push_back(new IOStr1("IOStr1", - Tango::DEV_VOID, - Tango::DEV_STRING, - "void", - "Just a string dynamically allocated")); - command_list.push_back(new IOPollStr1("IOPollStr1", - Tango::DEV_VOID, - Tango::DEV_STRING, - "void", - "Just a string dynamically allocated changing at each call")); - command_list.push_back(new IOStr2("IOStr2", - Tango::DEV_VOID, - Tango::DEV_STRING, - "void", - "A constant string")); - command_list.push_back(new IOArray1("IOArray1", - Tango::DEV_VOID, - Tango::DEVVAR_LONGARRAY, - "void", - "An array allocated")); - command_list.push_back(new IOArray2("IOArray2", - Tango::DEV_VOID, - Tango::DEVVAR_SHORTARRAY, - "void", - "An array without copying")); - command_list.push_back(new IOPollArray2("IOPollArray2", - Tango::DEV_VOID, - Tango::DEVVAR_SHORTARRAY, - "void", - "An array without copying changing at each call")); - command_list.push_back(new IOStrArray("IOStrArray", - Tango::DEV_VOID, - Tango::DEVVAR_STRINGARRAY, - "void", - "A string array")); - command_list.push_back(new IOStruct("IOStruct", - Tango::DEV_VOID, - Tango::DEVVAR_LONGSTRINGARRAY, - "void", - "A structure type")); - command_list.push_back(new IODevListByClass("IODevListByClass", - Tango::DEV_STRING, - Tango::DEV_STRING, - "class name", - "class first device name")); - command_list.push_back(new IODevByName("IODevByName", - Tango::DEV_STRING, - Tango::DEV_STRING, - "device name", - "device name (returned by name()")); - command_list.push_back(new IODServDevice("IODServDevice", - Tango::DEV_VOID, - Tango::DEV_STRING, - "void", - "dserver device name")); - command_list.push_back(new IOSetAttr("IOSetAttr", - Tango::DEV_LONG, - Tango::DEV_VOID, - "New attr value", - "void")); - command_list.push_back(new IOAddAttribute("IOAddAttribute", - Tango::DEV_STRING, - Tango::DEV_VOID, - "New attribute name", - "void")); - command_list.push_back(new IORemoveAttribute("IORemoveAttribute", - Tango::DEV_STRING, - Tango::DEV_VOID, - "Attribute name", - "void")); - command_list.push_back(new IOSeqVecChar("IOSeqVecChar", - Tango::DEVVAR_CHARARRAY, - Tango::DEVVAR_CHARARRAY, - "Input char array", - "Output char array")); - command_list.push_back(new IOSeqVecShort("IOSeqVecShort", - Tango::DEVVAR_SHORTARRAY, - Tango::DEVVAR_SHORTARRAY, - "Input short array", - "Output short array")); - command_list.push_back(new IOSeqVecLong("IOSeqVecLong", - Tango::DEVVAR_LONGARRAY, - Tango::DEVVAR_LONGARRAY, - "Input long array", - "Output long array")); - command_list.push_back(new IOSeqVecFloat("IOSeqVecFloat", - Tango::DEVVAR_FLOATARRAY, - Tango::DEVVAR_FLOATARRAY, - "Input float array", - "Output float array")); - command_list.push_back(new IOSeqVecDouble("IOSeqVecDouble", - Tango::DEVVAR_DOUBLEARRAY, - Tango::DEVVAR_DOUBLEARRAY, - "Input double array", - "Output double array")); - command_list.push_back(new IOSeqVecUShort("IOSeqVecUShort", - Tango::DEVVAR_USHORTARRAY, - Tango::DEVVAR_USHORTARRAY, - "Input unsigned short array", - "Output unsigned short array")); - command_list.push_back(new IOSeqVecULong("IOSeqVecULong", - Tango::DEVVAR_ULONGARRAY, - Tango::DEVVAR_ULONGARRAY, - "Input unsigned long array", - "Output unsigned long array")); - command_list.push_back(new IOSeqVecString("IOSeqVecString", - Tango::DEVVAR_STRINGARRAY, - Tango::DEVVAR_STRINGARRAY, - "Input string array", - "Output string array")); - command_list.push_back(new IOStartPoll("IOStartPoll", - Tango::DEV_VOID, - Tango::DEV_LONG, - "Void", - "Constant number set to 11")); + Tango::DEVVAR_CHARARRAY, + Tango::DEVVAR_CHARARRAY, + "Array of char", + "This reversed array")); + command_list.push_back(new IOShortArray("IOShortArray", + Tango::DEVVAR_SHORTARRAY, + Tango::DEVVAR_SHORTARRAY, + "Array of short", + "This array * 2")); + command_list.push_back(new IOLongArray("IOLongArray", + Tango::DEVVAR_LONGARRAY, + Tango::DEVVAR_LONGARRAY, + "Array of long", + "This array * 2")); + command_list.push_back(new IOFloatArray("IOFloatArray", + Tango::DEVVAR_FLOATARRAY, + Tango::DEVVAR_FLOATARRAY, + "Array of float", + "This array * 2")); + command_list.push_back(new IODoubleArray("IODoubleArray", + Tango::DEVVAR_DOUBLEARRAY, + Tango::DEVVAR_DOUBLEARRAY, + "Array of double", + "This array * 2")); + command_list.push_back(new IOUShortArray("IOUShortArray", + Tango::DEVVAR_USHORTARRAY, + Tango::DEVVAR_USHORTARRAY, + "Array of unsigned short", + "This array * 2")); + command_list.push_back(new IOULongArray("IOULongArray", + Tango::DEVVAR_ULONGARRAY, + Tango::DEVVAR_ULONGARRAY, + "Array of unsigned long", + "This array * 2")); + command_list.push_back(new IOStringArray("IOStringArray", + Tango::DEVVAR_STRINGARRAY, + Tango::DEVVAR_STRINGARRAY, + "Array of string", + "This reversed array ")); + command_list.push_back(new IOLongString("IOLongString", + Tango::DEVVAR_LONGSTRINGARRAY, + Tango::DEVVAR_LONGSTRINGARRAY, + "Array of long and string", + "This array of long * 2")); + command_list.push_back(new IODoubleString("IODoubleString", + Tango::DEVVAR_DOUBLESTRINGARRAY, + Tango::DEVVAR_DOUBLESTRINGARRAY, + "Array of double and string", + "This array of long * 2")); + command_list.push_back(new IOThrow("IOThrow", + Tango::DEVVAR_LONGSTRINGARRAY, + Tango::DEV_VOID, + "Error facility", + "An exception")); + command_list.push_back(new IOReThrow("IOReThrow", + Tango::DEVVAR_LONGSTRINGARRAY, + Tango::DEV_VOID, + "Error facility", + "An exception")); + command_list.push_back(new IOExcept("IOExcept", + Tango::DEV_VOID, + Tango::DEV_VOID, + "Void", + "An exception")); + command_list.push_back(new IOVoid("IOVoid", + Tango::DEV_VOID, + Tango::DEV_VOID, + "void", + "void")); + command_list.push_back(new IOSleep("IOSleep", + Tango::DEV_USHORT, + Tango::DEV_VOID, + "sleeping time", + "void")); + command_list.push_back(new IOState("IOState", + Tango::DEV_STATE, + Tango::DEV_VOID, + "New device state", + "void")); + command_list.push_back(new IORegSig("IORegSig", + Tango::DEV_LONG, + Tango::DEV_VOID, + "Signal number", + "void")); + command_list.push_back(new IORegSigOwn("IORegSigOwn", + Tango::DEV_LONG, + Tango::DEV_VOID, + "Signal number", + "void")); + command_list.push_back(new IOUnregSig("IOUnregSig", + Tango::DEV_LONG, + Tango::DEV_VOID, + "Signal number", + "void")); + command_list.push_back(new IORegClassSig("IORegClassSig", + Tango::DEV_LONG, + Tango::DEV_VOID, + "Signal number", + "void")); + command_list.push_back(new IOUnregClassSig("IOUnregClassSig", + Tango::DEV_LONG, + Tango::DEV_VOID, + "Signal number", + "void")); + command_list.push_back(new IOStr1("IOStr1", + Tango::DEV_VOID, + Tango::DEV_STRING, + "void", + "Just a string dynamically allocated")); + command_list.push_back(new IOPollStr1("IOPollStr1", + Tango::DEV_VOID, + Tango::DEV_STRING, + "void", + "Just a string dynamically allocated changing at each call")); + command_list.push_back(new IOStr2("IOStr2", + Tango::DEV_VOID, + Tango::DEV_STRING, + "void", + "A constant string")); + command_list.push_back(new IOArray1("IOArray1", + Tango::DEV_VOID, + Tango::DEVVAR_LONGARRAY, + "void", + "An array allocated")); + command_list.push_back(new IOArray2("IOArray2", + Tango::DEV_VOID, + Tango::DEVVAR_SHORTARRAY, + "void", + "An array without copying")); + command_list.push_back(new IOPollArray2("IOPollArray2", + Tango::DEV_VOID, + Tango::DEVVAR_SHORTARRAY, + "void", + "An array without copying changing at each call")); + command_list.push_back(new IOStrArray("IOStrArray", + Tango::DEV_VOID, + Tango::DEVVAR_STRINGARRAY, + "void", + "A string array")); + command_list.push_back(new IOStruct("IOStruct", + Tango::DEV_VOID, + Tango::DEVVAR_LONGSTRINGARRAY, + "void", + "A structure type")); + command_list.push_back(new IODevListByClass("IODevListByClass", + Tango::DEV_STRING, + Tango::DEV_STRING, + "class name", + "class first device name")); + command_list.push_back(new IODevByName("IODevByName", + Tango::DEV_STRING, + Tango::DEV_STRING, + "device name", + "device name (returned by name()")); + command_list.push_back(new IODServDevice("IODServDevice", + Tango::DEV_VOID, + Tango::DEV_STRING, + "void", + "dserver device name")); + command_list.push_back(new IOSetAttr("IOSetAttr", + Tango::DEV_LONG, + Tango::DEV_VOID, + "New attr value", + "void")); + command_list.push_back(new IOAddAttribute("IOAddAttribute", + Tango::DEV_STRING, + Tango::DEV_VOID, + "New attribute name", + "void")); + command_list.push_back(new IORemoveAttribute("IORemoveAttribute", + Tango::DEV_STRING, + Tango::DEV_VOID, + "Attribute name", + "void")); + command_list.push_back(new IOSeqVecChar("IOSeqVecChar", + Tango::DEVVAR_CHARARRAY, + Tango::DEVVAR_CHARARRAY, + "Input char array", + "Output char array")); + command_list.push_back(new IOSeqVecShort("IOSeqVecShort", + Tango::DEVVAR_SHORTARRAY, + Tango::DEVVAR_SHORTARRAY, + "Input short array", + "Output short array")); + command_list.push_back(new IOSeqVecLong("IOSeqVecLong", + Tango::DEVVAR_LONGARRAY, + Tango::DEVVAR_LONGARRAY, + "Input long array", + "Output long array")); + command_list.push_back(new IOSeqVecFloat("IOSeqVecFloat", + Tango::DEVVAR_FLOATARRAY, + Tango::DEVVAR_FLOATARRAY, + "Input float array", + "Output float array")); + command_list.push_back(new IOSeqVecDouble("IOSeqVecDouble", + Tango::DEVVAR_DOUBLEARRAY, + Tango::DEVVAR_DOUBLEARRAY, + "Input double array", + "Output double array")); + command_list.push_back(new IOSeqVecUShort("IOSeqVecUShort", + Tango::DEVVAR_USHORTARRAY, + Tango::DEVVAR_USHORTARRAY, + "Input unsigned short array", + "Output unsigned short array")); + command_list.push_back(new IOSeqVecULong("IOSeqVecULong", + Tango::DEVVAR_ULONGARRAY, + Tango::DEVVAR_ULONGARRAY, + "Input unsigned long array", + "Output unsigned long array")); + command_list.push_back(new IOSeqVecString("IOSeqVecString", + Tango::DEVVAR_STRINGARRAY, + Tango::DEVVAR_STRINGARRAY, + "Input string array", + "Output string array")); + command_list.push_back(new IOStartPoll("IOStartPoll", + Tango::DEV_VOID, + Tango::DEV_LONG, + "Void", + "Constant number set to 11")); // command_list.back()->set_polling_period(400); - command_list.push_back(new IOShortSleep("IOShortSleep", - Tango::DEVVAR_SHORTARRAY, - Tango::DEV_SHORT, - "Input short and sleeping time in sec", - "Output short (in * 2)")); - command_list.push_back(new IOSleepExcept("IOSleepExcept", - Tango::DEV_SHORT, - Tango::DEV_VOID, - "Sleep time (sec)", - "An exception")); - command_list.push_back(new IOExit("IOExit", - Tango::DEV_VOID, - Tango::DEV_VOID, - "void", - "void")); - command_list.push_back(new IOTrigPoll("IOTrigPoll", - Tango::DEV_STRING, - Tango::DEV_VOID, - "Command's name to trig polling", - "void")); - command_list.push_back(new IOAttrTrigPoll("IOAttrTrigPoll", - Tango::DEV_STRING, - Tango::DEV_VOID, - "Attribute's name to trig polling", - "void")); - command_list.push_back(new IOInitWAttr("IOInitWAttr", - Tango::DEV_VOID, - Tango::DEV_VOID, - "void", - "void")); - command_list.push_back(new IOAttrThrowEx("IOAttrThrowEx", - Tango::DEVVAR_SHORTARRAY, - Tango::DEV_VOID, - "2 elts : Attr code and throw except flag", - "void")); - command_list.push_back(new IOAddOneElt("IOAddOneElt", - Tango::DEV_VOID, - Tango::DEV_VOID, - "void", - "void")); - command_list.push_back(new IORemoveOneElt("IORemoveOneElt", - Tango::DEV_VOID, - Tango::DEV_VOID, - "void", - "void")); - command_list.push_back(new IOIncValue("IOIncValue", - Tango::DEV_VOID, - Tango::DEV_VOID, - "void", - "void")); - command_list.push_back(new IODecValue("IODecValue", - Tango::DEV_VOID, - Tango::DEV_VOID, - "void", - "void")); - command_list.push_back(new IOChangeQuality("IOChangeQuality", - Tango::DEV_SHORT, - Tango::DEV_VOID, - "0->VALID, 1->INVALID, 2->ALARM, 3->CHANGING", - "void")); - command_list.push_back(new IOPushEvent("IOPushEvent", - Tango::DEV_VOID, - Tango::DEV_VOID, - "void", - "void")); - command_list.push_back(new IOPushDevEncodedEvent("IOPushDevEncodedEvent", - Tango::DEV_VOID, - Tango::DEV_VOID, - "void", - "void")); - command_list.push_back(new IOSubscribeEvent("IOSubscribeEvent", - Tango::DEVVAR_STRINGARRAY, - Tango::DEV_LONG, - "str[0] = device name, str[1] = attribute name, str[2] = event type", - "Event identifier")); - command_list.push_back(new IOUnSubscribeEvent("IOUnSubscribeEvent", - Tango::DEV_LONG, - Tango::DEV_VOID, - "Event identifier", - "void")); - command_list.push_back(new IOGetCbExecuted("IOGetCbExecuted", - Tango::DEV_VOID, - Tango::DEV_LONG, - "void", - "Number of times the CB has been executed")); - command_list.push_back(new IOFillPollBuffAttr("IOFillPollBuffAttr", - Tango::DEV_VOID, - Tango::DEV_VOID, - "void", - "void")); - command_list.push_back(new IOFillPollBuffEncodedAttr("IOFillPollBuffEncodedAttr", - Tango::DEV_VOID, - Tango::DEV_VOID, - "void", - "void")); - command_list.push_back(new IOFillPollBuffCmd("IOFillPollBuffCmd", - Tango::DEV_VOID, - Tango::DEV_VOID, - "void", - "void")); - command_list.push_back(new FileDbCmd("FileDb", - Tango::DEV_VOID, - Tango::DEV_VOID, - "void", - "void")); - command_list.push_back(new OLong("OLong", - Tango::DEV_VOID, - Tango::DEV_LONG, - "void", - "A long")); - command_list.push_back(new OULong("OULong", - Tango::DEV_VOID, - Tango::DEV_ULONG, - "void", - "An unsigned long")); - command_list.push_back(new OLongArray("OLongArray", - Tango::DEV_VOID, - Tango::DEVVAR_LONGARRAY, - "void", - "A long array")); - command_list.push_back(new OULongArray("OULongArray", - Tango::DEV_VOID, - Tango::DEVVAR_ULONGARRAY, - "void", - "A unsigned long array")); - command_list.push_back(new OLongString("OLongString", - Tango::DEV_VOID, - Tango::DEVVAR_LONGSTRINGARRAY, - "void", - "A unsigned long and string array")); - command_list.push_back(new GetLongSize("GetLongSize", - Tango::DEV_VOID, - Tango::DEV_SHORT, - "void", - "Sizeof long (32 or 64 bits)")); - command_list.push_back(new IOSetWAttrLimit("IOSetWAttrLimit", - Tango::DEVVAR_DOUBLEARRAY, - Tango::DEV_VOID, - "arr[0]==0 -> min_value, arr[0]==1 -> max_value, arr[1]=limit", - "void")); - command_list.push_back(new IOLong64("IOLong64", - Tango::DEV_LONG64, - Tango::DEV_LONG64, - "Number", - "Number * 2")); - command_list.push_back(new IOULong64("IOULong64", - Tango::DEV_ULONG64, - Tango::DEV_ULONG64, - "Number", - "Number * 2")); - command_list.push_back(new ChangeEncodedFormat("ChangeEncodedFormat", - Tango::DEV_VOID, - Tango::DEV_VOID, - "void", - "void")); - command_list.push_back(new ChangeEncodedData("ChangeEncodedData", - Tango::DEV_VOID, - Tango::DEV_VOID, - "void", - "void")); - command_list.push_back(new PushDataReady("PushDataReady", - Tango::DEVVAR_LONGSTRINGARRAY, - Tango::DEV_VOID, - "s[0] = attribute name, l[0] = user counter", - "void")); - command_list.push_back(new SubDeviceTst("SubDeviceTst", - Tango::DEV_VOID, - Tango::DEV_BOOLEAN, - "void", - "true = sub device connected")); - command_list.push_back(new IOEncoded("IOEncoded", - Tango::DEV_ENCODED, - Tango::DEV_ENCODED, - "DevEncoded structure", - "DevEncoded structure")); - command_list.push_back(new OEncoded("OEncoded", - Tango::DEV_VOID, - Tango::DEV_ENCODED, - "void", - "DevEncoded structure to test polling/history")); - command_list.push_back(new PollingPoolTst("PollingPoolTst", - Tango::DEV_VOID, - Tango::DEVVAR_STRINGARRAY, - "void", - "Polling threads pool configuration")); - command_list.push_back(new SetGetAlarms("SetGetAlarms", - Tango::DEV_VOID, - Tango::DEVVAR_STRINGARRAY, - "void", - "DevVarStringArray containing alarm values")); - command_list.push_back(new SetGetRanges("SetGetRanges", - Tango::DEV_VOID, - Tango::DEVVAR_STRINGARRAY, - "void", - "DevVarStringArray containing ranges values")); - command_list.push_back(new SetGetProperties("SetGetProperties", - Tango::DEV_VOID, - Tango::DEVVAR_STRINGARRAY, - "void", - "DevVarStringArray containing properties values")); - command_list.push_back(new PollingInDeviceTst("IOPollingInDevice", - Tango::DEV_VOID, - Tango::DEVVAR_STRINGARRAY, - "void", - "Polling in device test outputs")); - command_list.push_back(new SophisPollInDeviceTst("IOSophisticatedPollInDevice", - Tango::DEV_VOID, - Tango::DEV_VOID, - "void", - "void")); - command_list.push_back(new GetPollMess("IOGetPollMess", - Tango::DEV_VOID, - Tango::DEVVAR_STRINGARRAY, - "void", - "SophisticatedPollInDevice polling messages")); - command_list.push_back(new WriteAttrHardwareThrow("WriteAttrHardwareThrow", - Tango::DEV_SHORT, - Tango::DEV_VOID, - "Type of exception to be thrown by write_attr_hardware() method", - "void")); - command_list.push_back(new IOAddCommand("IOAddCommand", - Tango::DEV_LONG, - Tango::DEV_VOID, - "True if command must be added at device level", - "void")); - command_list.push_back(new IORemoveCommand("IORemoveCommand", - Tango::DEV_VOID, - Tango::DEV_VOID, - "void", - "void")); - command_list.push_back(new SetEnumLabels("SetEnumLabels", - Tango::DEV_VOID, - Tango::DEV_VOID, - "void", - "void")); - command_list.push_back(new AddEnumLabel("AddEnumLabel", - Tango::DEV_STRING, - Tango::DEV_VOID, - "New enum label", - "void")); - command_list.push_back(new ForbiddenEnumValue("ForbiddenEnumValue", - Tango::DEV_SHORT, - Tango::DEV_VOID, - "New value for setting enum (Must be > 100)", - "void")); - - command_list.push_back(new SetPipeOutput("SetPipeOutput", - Tango::DEV_SHORT, - Tango::DEV_VOID, - "Select RPipe output type", - "void")); - - command_list.push_back(new PushPipeEvent("PushPipeEvent", - Tango::DEV_SHORT, - Tango::DEV_VOID, - "Pipe data type", - "void")); - - command_list.push_back(new PushStateStatusChangeEvent("PushStateStatusChangeEvent", - Tango::DEV_VOID, - Tango::DEV_VOID, - "void", - "void")); - - command_list.push_back(new Tango::TemplCommand((const char *)"IOTempl", - static_cast(&DevTest::IOTempl))); - - command_list.push_back(new Tango::TemplCommand((const char *)"IOTemplState", - static_cast(&DevTest::IOTempl), - static_cast(&DevTest::templ_state))); - - command_list.push_back(new Tango::TemplCommandIn((const char *)"IOTemplIn", - static_cast(&DevTest::IOTemplIn))); - - command_list.push_back(new Tango::TemplCommandIn((const char *)"IOTemplInState", - static_cast(&DevTest::IOTemplIn), - static_cast(&DevTest::templ_state))); - - command_list.push_back(new Tango::TemplCommandOut((const char *)"IOTemplOut", - static_cast(&DevTest::IOTemplOut))); - - command_list.push_back(new Tango::TemplCommandOut((const char *)"IOTemplOutState", - static_cast(&DevTest::IOTemplOut), - static_cast(&DevTest::templ_state))); - - command_list.push_back(new Tango::TemplCommandInOut((const char *)"IOTemplInOut", - static_cast(&DevTest::IOTemplInOut))); - - command_list.push_back(new Tango::TemplCommandInOut((const char *)"IOTemplInOutState", - static_cast(&DevTest::IOTemplInOut), - static_cast(&DevTest::templ_state))); + command_list.push_back(new IOShortSleep("IOShortSleep", + Tango::DEVVAR_SHORTARRAY, + Tango::DEV_SHORT, + "Input short and sleeping time in sec", + "Output short (in * 2)")); + command_list.push_back(new IOSleepExcept("IOSleepExcept", + Tango::DEV_SHORT, + Tango::DEV_VOID, + "Sleep time (sec)", + "An exception")); + command_list.push_back(new IOExit("IOExit", + Tango::DEV_VOID, + Tango::DEV_VOID, + "void", + "void")); + command_list.push_back(new IOTrigPoll("IOTrigPoll", + Tango::DEV_STRING, + Tango::DEV_VOID, + "Command's name to trig polling", + "void")); + command_list.push_back(new IOAttrTrigPoll("IOAttrTrigPoll", + Tango::DEV_STRING, + Tango::DEV_VOID, + "Attribute's name to trig polling", + "void")); + command_list.push_back(new IOInitWAttr("IOInitWAttr", + Tango::DEV_VOID, + Tango::DEV_VOID, + "void", + "void")); + command_list.push_back(new IOAttrThrowEx("IOAttrThrowEx", + Tango::DEVVAR_SHORTARRAY, + Tango::DEV_VOID, + "2 elts : Attr code and throw except flag", + "void")); + command_list.push_back(new IOAddOneElt("IOAddOneElt", + Tango::DEV_VOID, + Tango::DEV_VOID, + "void", + "void")); + command_list.push_back(new IORemoveOneElt("IORemoveOneElt", + Tango::DEV_VOID, + Tango::DEV_VOID, + "void", + "void")); + command_list.push_back(new IOIncValue("IOIncValue", + Tango::DEV_VOID, + Tango::DEV_VOID, + "void", + "void")); + command_list.push_back(new IODecValue("IODecValue", + Tango::DEV_VOID, + Tango::DEV_VOID, + "void", + "void")); + command_list.push_back(new IOChangeQuality("IOChangeQuality", + Tango::DEV_SHORT, + Tango::DEV_VOID, + "0->VALID, 1->INVALID, 2->ALARM, 3->CHANGING", + "void")); + command_list.push_back(new IOPushEvent("IOPushEvent", + Tango::DEV_VOID, + Tango::DEV_VOID, + "void", + "void")); + command_list.push_back(new IOPushDevEncodedEvent("IOPushDevEncodedEvent", + Tango::DEV_VOID, + Tango::DEV_VOID, + "void", + "void")); + command_list.push_back(new IOSubscribeEvent("IOSubscribeEvent", + Tango::DEVVAR_STRINGARRAY, + Tango::DEV_LONG, + "str[0] = device name, str[1] = attribute name, str[2] = event type", + "Event identifier")); + command_list.push_back(new IOUnSubscribeEvent("IOUnSubscribeEvent", + Tango::DEV_LONG, + Tango::DEV_VOID, + "Event identifier", + "void")); + command_list.push_back(new IOGetCbExecuted("IOGetCbExecuted", + Tango::DEV_VOID, + Tango::DEV_LONG, + "void", + "Number of times the CB has been executed")); + command_list.push_back(new IOFillPollBuffAttr("IOFillPollBuffAttr", + Tango::DEV_VOID, + Tango::DEV_VOID, + "void", + "void")); + command_list.push_back(new IOFillPollBuffEncodedAttr("IOFillPollBuffEncodedAttr", + Tango::DEV_VOID, + Tango::DEV_VOID, + "void", + "void")); + command_list.push_back(new IOFillPollBuffCmd("IOFillPollBuffCmd", + Tango::DEV_VOID, + Tango::DEV_VOID, + "void", + "void")); + command_list.push_back(new FileDbCmd("FileDb", + Tango::DEV_VOID, + Tango::DEV_VOID, + "void", + "void")); + command_list.push_back(new OLong("OLong", + Tango::DEV_VOID, + Tango::DEV_LONG, + "void", + "A long")); + command_list.push_back(new OULong("OULong", + Tango::DEV_VOID, + Tango::DEV_ULONG, + "void", + "An unsigned long")); + command_list.push_back(new OLongArray("OLongArray", + Tango::DEV_VOID, + Tango::DEVVAR_LONGARRAY, + "void", + "A long array")); + command_list.push_back(new OULongArray("OULongArray", + Tango::DEV_VOID, + Tango::DEVVAR_ULONGARRAY, + "void", + "A unsigned long array")); + command_list.push_back(new OLongString("OLongString", + Tango::DEV_VOID, + Tango::DEVVAR_LONGSTRINGARRAY, + "void", + "A unsigned long and string array")); + command_list.push_back(new GetLongSize("GetLongSize", + Tango::DEV_VOID, + Tango::DEV_SHORT, + "void", + "Sizeof long (32 or 64 bits)")); + command_list.push_back(new IOSetWAttrLimit("IOSetWAttrLimit", + Tango::DEVVAR_DOUBLEARRAY, + Tango::DEV_VOID, + "arr[0]==0 -> min_value, arr[0]==1 -> max_value, arr[1]=limit", + "void")); + command_list.push_back(new IOLong64("IOLong64", + Tango::DEV_LONG64, + Tango::DEV_LONG64, + "Number", + "Number * 2")); + command_list.push_back(new IOULong64("IOULong64", + Tango::DEV_ULONG64, + Tango::DEV_ULONG64, + "Number", + "Number * 2")); + command_list.push_back(new ChangeEncodedFormat("ChangeEncodedFormat", + Tango::DEV_VOID, + Tango::DEV_VOID, + "void", + "void")); + command_list.push_back(new ChangeEncodedData("ChangeEncodedData", + Tango::DEV_VOID, + Tango::DEV_VOID, + "void", + "void")); + command_list.push_back(new PushDataReady("PushDataReady", + Tango::DEVVAR_LONGSTRINGARRAY, + Tango::DEV_VOID, + "s[0] = attribute name, l[0] = user counter", + "void")); + command_list.push_back(new SubDeviceTst("SubDeviceTst", + Tango::DEV_VOID, + Tango::DEV_BOOLEAN, + "void", + "true = sub device connected")); + command_list.push_back(new IOEncoded("IOEncoded", + Tango::DEV_ENCODED, + Tango::DEV_ENCODED, + "DevEncoded structure", + "DevEncoded structure")); + command_list.push_back(new OEncoded("OEncoded", + Tango::DEV_VOID, + Tango::DEV_ENCODED, + "void", + "DevEncoded structure to test polling/history")); + command_list.push_back(new IODevEnum()); + command_list.push_back(new PollingPoolTst("PollingPoolTst", + Tango::DEV_VOID, + Tango::DEVVAR_STRINGARRAY, + "void", + "Polling threads pool configuration")); + command_list.push_back(new SetGetAlarms("SetGetAlarms", + Tango::DEV_VOID, + Tango::DEVVAR_STRINGARRAY, + "void", + "DevVarStringArray containing alarm values")); + command_list.push_back(new SetGetRanges("SetGetRanges", + Tango::DEV_VOID, + Tango::DEVVAR_STRINGARRAY, + "void", + "DevVarStringArray containing ranges values")); + command_list.push_back(new SetGetProperties("SetGetProperties", + Tango::DEV_VOID, + Tango::DEVVAR_STRINGARRAY, + "void", + "DevVarStringArray containing properties values")); + command_list.push_back(new PollingInDeviceTst("IOPollingInDevice", + Tango::DEV_VOID, + Tango::DEVVAR_STRINGARRAY, + "void", + "Polling in device test outputs")); + command_list.push_back(new SophisPollInDeviceTst("IOSophisticatedPollInDevice", + Tango::DEV_VOID, + Tango::DEV_VOID, + "void", + "void")); + command_list.push_back(new GetPollMess("IOGetPollMess", + Tango::DEV_VOID, + Tango::DEVVAR_STRINGARRAY, + "void", + "SophisticatedPollInDevice polling messages")); + command_list.push_back(new WriteAttrHardwareThrow("WriteAttrHardwareThrow", + Tango::DEV_SHORT, + Tango::DEV_VOID, + "Type of exception to be thrown by write_attr_hardware() method", + "void")); + command_list.push_back(new IOAddCommand("IOAddCommand", + Tango::DEV_LONG, + Tango::DEV_VOID, + "True if command must be added at device level", + "void")); + command_list.push_back(new IORemoveCommand("IORemoveCommand", + Tango::DEV_VOID, + Tango::DEV_VOID, + "void", + "void")); + command_list.push_back(new SetEnumLabels("SetEnumLabels", + Tango::DEV_VOID, + Tango::DEV_VOID, + "void", + "void")); + command_list.push_back(new AddEnumLabel("AddEnumLabel", + Tango::DEV_STRING, + Tango::DEV_VOID, + "New enum label", + "void")); + command_list.push_back(new ForbiddenEnumValue("ForbiddenEnumValue", + Tango::DEV_SHORT, + Tango::DEV_VOID, + "New value for setting enum (Must be > 100)", + "void")); + + command_list.push_back(new SetPipeOutput("SetPipeOutput", + Tango::DEV_SHORT, + Tango::DEV_VOID, + "Select RPipe output type", + "void")); + + command_list.push_back(new PushPipeEvent("PushPipeEvent", + Tango::DEV_SHORT, + Tango::DEV_VOID, + "Pipe data type", + "void")); + + command_list.push_back(new PushStateStatusChangeEvent("PushStateStatusChangeEvent", + Tango::DEV_VOID, + Tango::DEV_VOID, + "void", + "void")); + + command_list.push_back(new Tango::TemplCommand((const char *) "IOTempl", + static_cast(&DevTest::IOTempl))); + + command_list.push_back(new Tango::TemplCommand((const char *) "IOTemplState", + static_cast(&DevTest::IOTempl), + static_cast(&DevTest::templ_state))); + + command_list.push_back(new Tango::TemplCommandIn((const char *) "IOTemplIn", + static_cast(&DevTest::IOTemplIn))); + + command_list.push_back(new Tango::TemplCommandIn((const char *) "IOTemplInState", + static_cast(&DevTest::IOTemplIn), + static_cast(&DevTest::templ_state))); + + command_list.push_back(new Tango::TemplCommandOut((const char *) "IOTemplOut", + static_cast(&DevTest::IOTemplOut))); + + command_list.push_back(new Tango::TemplCommandOut((const char *) "IOTemplOutState", + static_cast(&DevTest::IOTemplOut), + static_cast(&DevTest::templ_state))); + + command_list.push_back( + new Tango::TemplCommandInOut((const char *) "IOTemplInOut", + static_cast(&DevTest::IOTemplInOut))); + + command_list.push_back(new Tango::TemplCommandInOut( + (const char *) "IOTemplInOutState", + static_cast(&DevTest::IOTemplInOut), + static_cast(&DevTest::templ_state))); } @@ -665,29 +668,34 @@ void DevTestClass::command_factory() //----------------------------------------------------------------------------- void DevTestClass::device_factory(const Tango::DevVarStringArray *devlist_ptr) { - for (unsigned long i = 0;i < devlist_ptr->length();i++) { - cout4 << "Device name : " << (*devlist_ptr)[i] << endl; + for (unsigned long i = 0; i < devlist_ptr->length(); i++) + { + cout4 << "Device name : " << (*devlist_ptr)[i] << endl; // // Create device and add it into the device list // - device_list.push_back(new DevTest(this, - (*devlist_ptr)[i])); - - // - // Export device to the outside world - // - if ((Tango::Util::_UseDb == true) && (Tango::Util::_FileDb == false)) - export_device(device_list.back()); - else - export_device(device_list.back(),(*devlist_ptr)[i]); - } + string dev_name((*devlist_ptr)[i]); + device_list.push_back(new DevTest(this, dev_name)); + + // + // Export device to the outside world + // + if ((Tango::Util::_UseDb == true) && (Tango::Util::_FileDb == false)) + { + export_device(device_list.back()); + } + else + { + export_device(device_list.back(), (*devlist_ptr)[i]); + } + } } void DevTestClass::device_name_factory(vector &list_name) { - list_name.push_back("The_first_device"); - list_name.push_back("The_second_device"); + list_name.push_back("The_first_device"); + list_name.push_back("The_second_device"); } void DevTestClass::signal_handler(long signo) @@ -697,254 +705,254 @@ void DevTestClass::signal_handler(long signo) // With logging, we must attach a log message to a device // - cout1 << "[Class signal handler] received signal number " - << signo - << " for class " - << name - << endl; + cout1 << "[Class signal handler] received signal number " + << signo + << " for class " + << name + << endl; } void DevTestClass::attribute_factory(vector &att_list) { - att_list.push_back(new Short_attrAttr()); - att_list.push_back(new Long_attrAttr()); - att_list.back()->set_data_ready_event(true); - att_list.push_back(new Long64_attrAttr()); - att_list.back()->set_data_ready_event(true); - att_list.push_back(new Double_attrAttr()); - att_list.push_back(new String_attrAttr()); + att_list.push_back(new Short_attrAttr()); + att_list.push_back(new Long_attrAttr()); + att_list.back()->set_data_ready_event(true); + att_list.push_back(new Long64_attrAttr()); + att_list.back()->set_data_ready_event(true); + att_list.push_back(new Double_attrAttr()); + att_list.push_back(new String_attrAttr()); // att_list.back()->set_polling_period(250); - att_list.push_back(new Short_spec_attrAttr()); - att_list.push_back(new Long_spec_attrAttr()); - att_list.push_back(new Double_spec_attrAttr()); - att_list.push_back(new String_spec_attrAttr()); - - att_list.push_back(new Short_ima_attrAttr()); - att_list.push_back(new Long_ima_attrAttr()); - att_list.push_back(new Double_ima_attrAttr()); - att_list.push_back(new String_ima_attrAttr()); - - att_list.push_back(new attr_no_dataAttr()); - att_list.push_back(new attr_wrong_typeAttr()); - att_list.push_back(new attr_wrong_sizeAttr()); - att_list.push_back(new attr_no_alarmAttr()); - - att_list.push_back(new Short_attr_with_wAttr()); - att_list.push_back(new Short_attr_rwAttr()); - att_list.push_back(new Short_attr_wAttr()); - - Tango::UserDefaultAttrProp def_prop; - def_prop.set_label("Test label"); - def_prop.set_description("Test description"); - def_prop.set_unit("Kilogramme"); - def_prop.set_standard_unit("100"); - def_prop.set_display_unit("Et ta soeur"); - def_prop.set_format("Tres long"); - def_prop.set_min_value("0"); - def_prop.set_max_value("100000"); - def_prop.set_min_alarm("1"); - def_prop.set_max_alarm("99999"); - def_prop.set_min_warning("2"); - def_prop.set_max_warning("99998"); - def_prop.set_delta_val("10000"); - def_prop.set_delta_t("1"); - def_prop.set_event_abs_change("30000"); - def_prop.set_event_rel_change("20000"); - def_prop.set_event_period("2000"); - def_prop.set_archive_event_abs_change("33333"); - def_prop.set_archive_event_rel_change("22222"); - def_prop.set_archive_event_period("3000"); + att_list.push_back(new Short_spec_attrAttr()); + att_list.push_back(new Long_spec_attrAttr()); + att_list.push_back(new Double_spec_attrAttr()); + att_list.push_back(new String_spec_attrAttr()); + + att_list.push_back(new Short_ima_attrAttr()); + att_list.push_back(new Long_ima_attrAttr()); + att_list.push_back(new Double_ima_attrAttr()); + att_list.push_back(new String_ima_attrAttr()); + + att_list.push_back(new attr_no_dataAttr()); + att_list.push_back(new attr_wrong_typeAttr()); + att_list.push_back(new attr_wrong_sizeAttr()); + att_list.push_back(new attr_no_alarmAttr()); + + att_list.push_back(new Short_attr_with_wAttr()); + att_list.push_back(new Short_attr_rwAttr()); + att_list.push_back(new Short_attr_wAttr()); + + Tango::UserDefaultAttrProp def_prop; + def_prop.set_label("Test label"); + def_prop.set_description("Test description"); + def_prop.set_unit("Kilogramme"); + def_prop.set_standard_unit("100"); + def_prop.set_display_unit("Et ta soeur"); + def_prop.set_format("Tres long"); + def_prop.set_min_value("0"); + def_prop.set_max_value("100000"); + def_prop.set_min_alarm("1"); + def_prop.set_max_alarm("99999"); + def_prop.set_min_warning("2"); + def_prop.set_max_warning("99998"); + def_prop.set_delta_val("10000"); + def_prop.set_delta_t("1"); + def_prop.set_event_abs_change("30000"); + def_prop.set_event_rel_change("20000"); + def_prop.set_event_period("2000"); + def_prop.set_archive_event_abs_change("33333"); + def_prop.set_archive_event_rel_change("22222"); + def_prop.set_archive_event_period("3000"); // Tango::Attr *at = new Tango::Attr("Long_attr_w", Tango::DEV_LONG, Tango::WRITE); - Tango::Attr *at = new Long_attr_wAttr(); - at->set_default_properties(def_prop); - att_list.push_back(at); - - att_list.push_back(new Double_attr_wAttr()); - att_list.push_back(new String_attr_wAttr()); - - att_list.push_back(new attr_asynAttr()); - att_list.push_back(new attr_asyn_toAttr()); - att_list.push_back(new attr_asyn_exceptAttr()); - att_list.push_back(new attr_asyn_writeAttr()); - att_list.push_back(new attr_asyn_write_toAttr()); - att_list.push_back(new attr_asyn_write_exceptAttr()); - - att_list.push_back(new PollLong_attrAttr()); - att_list.push_back(new PollString_spec_attrAttr()); - - att_list.push_back(new attr_dq_shAttr()); - att_list.push_back(new attr_dq_loAttr()); - att_list.push_back(new attr_dq_dbAttr()); - att_list.push_back(new attr_dq_strAttr()); - - Tango::UserDefaultAttrProp def_prop_1; - def_prop_1.set_max_value("100"); + Tango::Attr *at = new Long_attr_wAttr(); + at->set_default_properties(def_prop); + att_list.push_back(at); + + att_list.push_back(new Double_attr_wAttr()); + att_list.push_back(new String_attr_wAttr()); + + att_list.push_back(new attr_asynAttr()); + att_list.push_back(new attr_asyn_toAttr()); + att_list.push_back(new attr_asyn_exceptAttr()); + att_list.push_back(new attr_asyn_writeAttr()); + att_list.push_back(new attr_asyn_write_toAttr()); + att_list.push_back(new attr_asyn_write_exceptAttr()); + + att_list.push_back(new PollLong_attrAttr()); + att_list.push_back(new PollString_spec_attrAttr()); + + att_list.push_back(new attr_dq_shAttr()); + att_list.push_back(new attr_dq_loAttr()); + att_list.push_back(new attr_dq_dbAttr()); + att_list.push_back(new attr_dq_strAttr()); + + Tango::UserDefaultAttrProp def_prop_1; + def_prop_1.set_max_value("100"); // Tango::SpectrumAttr *sat = new Tango::SpectrumAttr("Short_spec_attr_w", Tango::DEV_SHORT,Tango::WRITE, 4); - Tango::SpectrumAttr *sat = new Short_spec_attr_wAttr(); - sat->set_default_properties(def_prop_1); - att_list.push_back(sat); - - att_list.push_back(new Long_spec_attr_wAttr()); - att_list.push_back(new Double_spec_attr_wAttr()); - att_list.push_back(new String_spec_attr_wAttr()); - att_list.push_back(new Short_ima_attr_wAttr()); - att_list.push_back(new String_ima_attr_wAttr()); - - att_list.push_back(new Short_spec_attr_rwAttr()); - att_list.push_back(new String_spec_attr_rwAttr()); - att_list.push_back(new Long_spec_attr_rwAttr()); - att_list.push_back(new Short_ima_attr_rwAttr()); - att_list.push_back(new String_ima_attr_rwAttr()); - - att_list.push_back(new Event_change_tstAttr()); - att_list.push_back(new Event64_change_tstAttr()); - att_list.push_back(new Event_quality_tstAttr()); - att_list.push_back(new Long_attr_with_wAttr()); - - att_list.push_back(new Short_attr_w2Attr()); - att_list.push_back(new String_attr_w2Attr()); - - att_list.push_back(new Poll_buffAttr()); - att_list.push_back(new Poll_buffRWAttr()); - - att_list.push_back(new Float_attrAttr()); - att_list.push_back(new Boolean_attrAttr()); - att_list.push_back(new UShort_attrAttr()); - att_list.push_back(new UChar_attrAttr()); - att_list.push_back(new ULong_attrAttr()); - att_list.push_back(new ULong64_attrAttr()); - - att_list.push_back(new Float_spec_attrAttr()); - att_list.push_back(new Boolean_spec_attrAttr()); - att_list.push_back(new UShort_spec_attrAttr()); - att_list.push_back(new UChar_spec_attrAttr()); - - att_list.push_back(new Float_attr_wAttr()); - att_list.push_back(new Boolean_attr_wAttr()); - att_list.push_back(new UShort_attr_wAttr()); - att_list.push_back(new UChar_attr_wAttr()); - - att_list.push_back(new Float_spec_attr_wAttr()); - att_list.push_back(new Boolean_spec_attr_wAttr()); - att_list.push_back(new UShort_spec_attr_wAttr()); - att_list.push_back(new UChar_spec_attr_wAttr()); - - att_list.push_back(new Float_ima_attr_wAttr()); - att_list.push_back(new UShort_ima_attr_wAttr()); - - att_list.push_back(new Float_spec_attr_rwAttr()); - att_list.push_back(new UChar_spec_attr_rwAttr()); - - att_list.push_back(new Boolean_ima_attr_rwAttr()); - att_list.push_back(new UShort_ima_attr_rwAttr()); - - att_list.push_back(new slow_actuatorAttr()); - att_list.push_back(new fast_actuatorAttr()); - - att_list.push_back(new Long64_attr_rwAttr()); - att_list.push_back(new ULong_attr_rwAttr()); - att_list.push_back(new ULong64_attr_rwAttr()); - att_list.push_back(new State_attr_rwAttr()); - - att_list.push_back(new Long64_spec_attr_rwAttr()); - att_list.push_back(new ULong_spec_attr_rwAttr()); - att_list.push_back(new ULong64_spec_attr_rwAttr()); - att_list.push_back(new State_spec_attr_rwAttr()); - - att_list.push_back(new Sub_device_tstAttr()); - att_list.push_back(new SlowAttr()); + Tango::SpectrumAttr *sat = new Short_spec_attr_wAttr(); + sat->set_default_properties(def_prop_1); + att_list.push_back(sat); + + att_list.push_back(new Long_spec_attr_wAttr()); + att_list.push_back(new Double_spec_attr_wAttr()); + att_list.push_back(new String_spec_attr_wAttr()); + att_list.push_back(new Short_ima_attr_wAttr()); + att_list.push_back(new String_ima_attr_wAttr()); + + att_list.push_back(new Short_spec_attr_rwAttr()); + att_list.push_back(new String_spec_attr_rwAttr()); + att_list.push_back(new Long_spec_attr_rwAttr()); + att_list.push_back(new Short_ima_attr_rwAttr()); + att_list.push_back(new String_ima_attr_rwAttr()); + + att_list.push_back(new Event_change_tstAttr()); + att_list.push_back(new Event64_change_tstAttr()); + att_list.push_back(new Event_quality_tstAttr()); + att_list.push_back(new Long_attr_with_wAttr()); + + att_list.push_back(new Short_attr_w2Attr()); + att_list.push_back(new String_attr_w2Attr()); + + att_list.push_back(new Poll_buffAttr()); + att_list.push_back(new Poll_buffRWAttr()); + + att_list.push_back(new Float_attrAttr()); + att_list.push_back(new Boolean_attrAttr()); + att_list.push_back(new UShort_attrAttr()); + att_list.push_back(new UChar_attrAttr()); + att_list.push_back(new ULong_attrAttr()); + att_list.push_back(new ULong64_attrAttr()); + + att_list.push_back(new Float_spec_attrAttr()); + att_list.push_back(new Boolean_spec_attrAttr()); + att_list.push_back(new UShort_spec_attrAttr()); + att_list.push_back(new UChar_spec_attrAttr()); + + att_list.push_back(new Float_attr_wAttr()); + att_list.push_back(new Boolean_attr_wAttr()); + att_list.push_back(new UShort_attr_wAttr()); + att_list.push_back(new UChar_attr_wAttr()); + + att_list.push_back(new Float_spec_attr_wAttr()); + att_list.push_back(new Boolean_spec_attr_wAttr()); + att_list.push_back(new UShort_spec_attr_wAttr()); + att_list.push_back(new UChar_spec_attr_wAttr()); + + att_list.push_back(new Float_ima_attr_wAttr()); + att_list.push_back(new UShort_ima_attr_wAttr()); + + att_list.push_back(new Float_spec_attr_rwAttr()); + att_list.push_back(new UChar_spec_attr_rwAttr()); + + att_list.push_back(new Boolean_ima_attr_rwAttr()); + att_list.push_back(new UShort_ima_attr_rwAttr()); + + att_list.push_back(new slow_actuatorAttr()); + att_list.push_back(new fast_actuatorAttr()); + + att_list.push_back(new Long64_attr_rwAttr()); + att_list.push_back(new ULong_attr_rwAttr()); + att_list.push_back(new ULong64_attr_rwAttr()); + att_list.push_back(new State_attr_rwAttr()); + + att_list.push_back(new Long64_spec_attr_rwAttr()); + att_list.push_back(new ULong_spec_attr_rwAttr()); + att_list.push_back(new ULong64_spec_attr_rwAttr()); + att_list.push_back(new State_spec_attr_rwAttr()); + + att_list.push_back(new Sub_device_tstAttr()); + att_list.push_back(new SlowAttr()); #ifndef COMPAT - att_list.push_back(new Encoded_attr_rwAttr()); - att_list.push_back(new Encoded_attr_image()); + att_list.push_back(new Encoded_attr_rwAttr()); + att_list.push_back(new Encoded_attr_image()); #endif - Tango::UserDefaultAttrProp att_no_data_prop; - att_no_data_prop.set_description("User desc"); - att_no_data_prop.set_min_value("30"); - att_no_data_prop.set_delta_val("77"); - att_no_data_prop.set_delta_t("88"); - att_no_data_prop.set_event_rel_change("55"); - att_no_data_prop.set_event_period("1500"); - Tango::Attr *db_att = new DefUserAttr(); - db_att->set_default_properties(att_no_data_prop); - att_list.push_back(db_att); - - Tango::Attr *uclass_att = new DefClassUserAttr(); - uclass_att->set_default_properties(att_no_data_prop); - att_list.push_back(uclass_att); - - att_list.push_back(new DefAttr()); - att_list.push_back(new DefClassAttr()); - - Tango::UserDefaultAttrProp att_enum_prop; - vector v_s; - v_s.push_back("North"); - v_s.push_back("South"); - v_s.push_back("East"); - v_s.push_back("West"); - att_enum_prop.set_enum_labels(v_s); - Tango::Attr *en_att = new EnumAttr(); - en_att->set_default_properties(att_enum_prop); - en_att->set_memorized(); - en_att->set_memorized_init(true); - att_list.push_back(en_att); - - Tango::Attr *en_s_att = new EnumSpecAttr(); - en_s_att->set_default_properties(att_enum_prop); - att_list.push_back(en_s_att); - - att_list.push_back(new DynEnumAttr()); - att_list.push_back(new ReynaldPollAttr()); + Tango::UserDefaultAttrProp att_no_data_prop; + att_no_data_prop.set_description("User desc"); + att_no_data_prop.set_min_value("30"); + att_no_data_prop.set_delta_val("77"); + att_no_data_prop.set_delta_t("88"); + att_no_data_prop.set_event_rel_change("55"); + att_no_data_prop.set_event_period("1500"); + Tango::Attr *db_att = new DefUserAttr(); + db_att->set_default_properties(att_no_data_prop); + att_list.push_back(db_att); + + Tango::Attr *uclass_att = new DefClassUserAttr(); + uclass_att->set_default_properties(att_no_data_prop); + att_list.push_back(uclass_att); + + att_list.push_back(new DefAttr()); + att_list.push_back(new DefClassAttr()); + + Tango::UserDefaultAttrProp att_enum_prop; + vector v_s; + v_s.push_back("North"); + v_s.push_back("South"); + v_s.push_back("East"); + v_s.push_back("West"); + att_enum_prop.set_enum_labels(v_s); + Tango::Attr *en_att = new EnumAttr(); + en_att->set_default_properties(att_enum_prop); + en_att->set_memorized(); + en_att->set_memorized_init(true); + att_list.push_back(en_att); + + Tango::Attr *en_s_att = new EnumSpecAttr(); + en_s_att->set_default_properties(att_enum_prop); + att_list.push_back(en_s_att); + + att_list.push_back(new DynEnumAttr()); + att_list.push_back(new ReynaldPollAttr()); } void DevTestClass::pipe_factory() { - RPipeClass *pRPipe = new RPipeClass("RPipe",Tango::OPERATOR); - Tango::UserDefaultPipeProp udpp; - udpp.set_description("The read pipe"); - udpp.set_label("ReadPipeLabel"); - pRPipe->set_default_properties(udpp); - pipe_list.push_back(pRPipe); - - RWPipeClass *pRWPipe = new RWPipeClass("RWPipe",Tango::OPERATOR); - udpp.set_description("The read_write pipe"); - udpp.set_label("ReadWritePipeLabel"); - pRWPipe->set_default_properties(udpp); - pipe_list.push_back(pRWPipe); - - ConfPipeClass *pPipe1 = new ConfPipeClass("PipeConf1",Tango::OPERATOR); - pipe_list.push_back(pPipe1); - - ConfPipeClass *pPipe2 = new ConfPipeClass("PipeConf2",Tango::OPERATOR); - udpp.set_description("A Tango pipe with user defined desc"); - udpp.set_label("PipeLabel"); - pPipe2->set_default_properties(udpp); - pipe_list.push_back(pPipe2); - - ConfPipeClass *pPipe3 = new ConfPipeClass("PipeConf3",Tango::OPERATOR); - udpp.description.clear(); - udpp.set_label("BasePipeLabel"); - pPipe3->set_default_properties(udpp); - pipe_list.push_back(pPipe3); - - ConfPipeClass *pPipe4 = new ConfPipeClass("PipeConf4",Tango::OPERATOR); - pipe_list.push_back(pPipe4); - - ConfPipeClass *pPipe5 = new ConfPipeClass("PipeConf5",Tango::OPERATOR); - pipe_list.push_back(pPipe5); - - ConfPipeClass *pPipe6 = new ConfPipeClass("PipeConf6",Tango::OPERATOR); - udpp.label.clear(); - udpp.set_description("UserDefinedDesc"); - pPipe6->set_default_properties(udpp); - pipe_list.push_back(pPipe6); - - ConfPipeClass *pPipe7 = new ConfPipeClass("PipeConf7",Tango::OPERATOR); - pipe_list.push_back(pPipe7); - - RPipeDEClass *pRPipeDE = new RPipeDEClass("RPipeDE",Tango::OPERATOR); - pipe_list.push_back(pRPipeDE); + RPipeClass *pRPipe = new RPipeClass("RPipe", Tango::OPERATOR); + Tango::UserDefaultPipeProp udpp; + udpp.set_description("The read pipe"); + udpp.set_label("ReadPipeLabel"); + pRPipe->set_default_properties(udpp); + pipe_list.push_back(pRPipe); + + RWPipeClass *pRWPipe = new RWPipeClass("RWPipe", Tango::OPERATOR); + udpp.set_description("The read_write pipe"); + udpp.set_label("ReadWritePipeLabel"); + pRWPipe->set_default_properties(udpp); + pipe_list.push_back(pRWPipe); + + ConfPipeClass *pPipe1 = new ConfPipeClass("PipeConf1", Tango::OPERATOR); + pipe_list.push_back(pPipe1); + + ConfPipeClass *pPipe2 = new ConfPipeClass("PipeConf2", Tango::OPERATOR); + udpp.set_description("A Tango pipe with user defined desc"); + udpp.set_label("PipeLabel"); + pPipe2->set_default_properties(udpp); + pipe_list.push_back(pPipe2); + + ConfPipeClass *pPipe3 = new ConfPipeClass("PipeConf3", Tango::OPERATOR); + udpp.description.clear(); + udpp.set_label("BasePipeLabel"); + pPipe3->set_default_properties(udpp); + pipe_list.push_back(pPipe3); + + ConfPipeClass *pPipe4 = new ConfPipeClass("PipeConf4", Tango::OPERATOR); + pipe_list.push_back(pPipe4); + + ConfPipeClass *pPipe5 = new ConfPipeClass("PipeConf5", Tango::OPERATOR); + pipe_list.push_back(pPipe5); + + ConfPipeClass *pPipe6 = new ConfPipeClass("PipeConf6", Tango::OPERATOR); + udpp.label.clear(); + udpp.set_description("UserDefinedDesc"); + pPipe6->set_default_properties(udpp); + pipe_list.push_back(pPipe6); + + ConfPipeClass *pPipe7 = new ConfPipeClass("PipeConf7", Tango::OPERATOR); + pipe_list.push_back(pPipe7); + + RPipeDEClass *pRPipeDE = new RPipeDEClass("RPipeDE", Tango::OPERATOR); + pipe_list.push_back(pRPipeDE); } diff --git a/cpp_test_suite/cpp_test_ds/TypeCmds.cpp b/cpp_test_suite/cpp_test_ds/TypeCmds.cpp index 73319e197..f2b06cbf0 100644 --- a/cpp_test_suite/cpp_test_ds/TypeCmds.cpp +++ b/cpp_test_suite/cpp_test_ds/TypeCmds.cpp @@ -1687,3 +1687,23 @@ CORBA::Any *OEncoded::execute(TANGO_UNUSED(Tango::DeviceImpl *device),TANGO_UNUS } } #endif + +IODevEnum::IODevEnum() + : + Command("IODevEnum", Tango::CmdArgType::DEV_ENUM, Tango::CmdArgType::DEV_ENUM, "DevEnum", "DevEnum") +{ + set_in_enum_labels({"IN Label 1", "IN Label 2", "IN Label 3"}); + set_out_enum_labels({"OUT Label 1", "OUT Label 2", "OUT Label 3"}); +} + +bool IODevEnum::is_allowed(Tango::DeviceImpl *, const CORBA::Any &) +{ + return true; +} + +CORBA::Any *IODevEnum::execute(Tango::DeviceImpl *, const CORBA::Any &any) +{ + Tango::DevShort in; + extract(any, in); + return insert(in); +} diff --git a/cpp_test_suite/cpp_test_ds/TypeCmds.h b/cpp_test_suite/cpp_test_ds/TypeCmds.h index 905d4998e..e861820ce 100644 --- a/cpp_test_suite/cpp_test_ds/TypeCmds.h +++ b/cpp_test_suite/cpp_test_ds/TypeCmds.h @@ -313,3 +313,13 @@ class OEncoded : public Tango::Command Tango::DevLong encoded_cmd_ctr; }; + +struct IODevEnum: public Tango::Command +{ + IODevEnum(); + ~IODevEnum() + {}; + + virtual bool is_allowed(Tango::DeviceImpl *, const CORBA::Any &); + virtual CORBA::Any *execute(Tango::DeviceImpl *, const CORBA::Any &); +}; diff --git a/cpp_test_suite/cxxtest/CMakeLists.txt b/cpp_test_suite/cxxtest/CMakeLists.txt index 76bf52f49..6f9347b06 100644 --- a/cpp_test_suite/cxxtest/CMakeLists.txt +++ b/cpp_test_suite/cxxtest/CMakeLists.txt @@ -36,6 +36,8 @@ execute_process(COMMAND python cxxtestgen.py --template=${CMAKE_CURRENT_SOURCE_D ../../new_tests/cxx_pipe.cpp ../../new_tests/cxx_z00_dyn_cmd.cpp ../../new_tests/cxx_nan_inf_in_prop.cpp + ../../new_tests/cxx_cmd_inout_enum.cpp + ../../new_tests/cxx_misc_devproxy.cpp WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/bin) add_executable(runner $ ${CMAKE_CURRENT_SOURCE_DIR}/runner.cpp) diff --git a/cpp_test_suite/event/CMakeLists.txt b/cpp_test_suite/event/CMakeLists.txt index fbb1a34ec..7985128f3 100644 --- a/cpp_test_suite/event/CMakeLists.txt +++ b/cpp_test_suite/event/CMakeLists.txt @@ -28,23 +28,23 @@ foreach(TEST ${TESTS}) TEST_SUITE_ADD_TEST(${TEST}) endforeach(TEST) -add_test(NAME "event::per_event" COMMAND $ ${DEV1} ${DEV2}) -add_test(NAME "event::att_type_event" COMMAND $ ${DEV1}) -add_test(NAME "event::change_event" COMMAND $ ${DEV1}) -add_test(NAME "event::change_event64" COMMAND $ ${DEV1}) -add_test(NAME "event::change_event_buffer" COMMAND $ ${DEV1}) -add_test(NAME "event::archive_event" COMMAND $ ${DEV1}) -add_test(NAME "event::user_event" COMMAND $ ${DEV1}) -add_test(NAME "event::multi_event" COMMAND $ ${DEV1}) -add_test(NAME "event::state_event" COMMAND $ ${DEV1}) -add_test(NAME "event::att_conf_event" COMMAND $ ${DEV1}) -add_test(NAME "event::att_conf_event_buffer" COMMAND $ ${DEV1}) -add_test(NAME "event::data_ready_event" COMMAND $ ${DEV1}) -add_test(NAME "event::data_ready_event_buffer" COMMAND $ ${DEV1}) -add_test(NAME "event::multi_dev_event" COMMAND $ ${DEV1} ${DEV2} ${DEV3}) -add_test(NAME "event::dev_intr_event" COMMAND $ ${DEV1}) -add_test(NAME "event::pipe_event" COMMAND $ ${DEV1}) -add_test(NAME "event::event_lock" COMMAND $ ${DEV1}) +add_test(NAME "event::per_event" COMMAND $ ${DEV1} ${DEV2}) +add_test(NAME "event::att_type_event" COMMAND $ ${DEV1}) +add_test(NAME "event::change_event" COMMAND $ ${DEV1}) +add_test(NAME "event::change_event64" COMMAND $ ${DEV1}) +add_test(NAME "event::change_event_buffer" COMMAND $ ${DEV1}) +add_test(NAME "event::archive_event" COMMAND $ ${DEV1}) +add_test(NAME "event::user_event" COMMAND $ ${DEV1}) +add_test(NAME "event::multi_event" COMMAND $ ${DEV1}) +add_test(NAME "event::state_event" COMMAND $ ${DEV1}) +add_test(NAME "event::att_conf_event" COMMAND $ ${DEV1}) +add_test(NAME "event::att_conf_event_buffer" COMMAND $ ${DEV1}) +add_test(NAME "event::data_ready_event" COMMAND $ ${DEV1}) +add_test(NAME "event::data_ready_event_buffer" COMMAND $ ${DEV1}) +add_test(NAME "event::multi_dev_event" COMMAND $ ${DEV1} ${DEV2} ${DEV3}) +add_test(NAME "event::dev_intr_event" COMMAND $ ${DEV1}) +add_test(NAME "event::pipe_event" COMMAND $ ${DEV1}) +add_test(NAME "event::event_lock" COMMAND $ ${DEV1}) #the following test performs several kill/start sequences, but must keep DEV1 alive in the end diff --git a/cpp_test_suite/event/att_conf_event.cpp b/cpp_test_suite/event/att_conf_event.cpp index fcaffa494..d760c6761 100644 --- a/cpp_test_suite/event/att_conf_event.cpp +++ b/cpp_test_suite/event/att_conf_event.cpp @@ -163,7 +163,10 @@ int main(int argc, char **argv) device->command_inout("IOSetWAttrLimit",d_in); Tango_sleep(1); - + + coutv << "cb_executed = " << cb.cb_executed << endl; + coutv << "min_value = " << cb.min_value << endl; + coutv << "max_value = " << cb.max_value << endl; assert (cb.cb_executed == 6); assert (cb.min_value == "0"); assert (cb.max_value == "10"); diff --git a/cpp_test_suite/event/change_event.cpp b/cpp_test_suite/event/change_event.cpp index d8496fe2d..9af81ee8c 100644 --- a/cpp_test_suite/event/change_event.cpp +++ b/cpp_test_suite/event/change_event.cpp @@ -2,6 +2,7 @@ * example of a client using the TANGO device api. */ +#include #include #include @@ -13,7 +14,7 @@ #include #endif -#define coutv if (verbose == true) cout +#define coutv if (verbose == true) cout << "[" << std::this_thread::get_id() << "] " using namespace Tango; @@ -245,6 +246,8 @@ int main(int argc, char **argv) #endif coutv << "cb excuted = " << cb.cb_executed << endl; + coutv << "cb val = " << cb.val << endl; + coutv << "cb val_size = " << cb.val_size << endl; assert (cb.cb_executed == 2); assert (cb.val == 31); assert (cb.val_size == 4); diff --git a/cpp_test_suite/new_tests/cxx_blackbox.cpp b/cpp_test_suite/new_tests/cxx_blackbox.cpp index bafd8bff9..da6ac2408 100644 --- a/cpp_test_suite/new_tests/cxx_blackbox.cpp +++ b/cpp_test_suite/new_tests/cxx_blackbox.cpp @@ -158,7 +158,8 @@ class BlackboxTestSuite: public CxxTest::TestSuite break; case 4: case 5: - version_str = "_4"; + case 6: + version_str = "_4"; break; default: version_str = ""; diff --git a/cpp_test_suite/new_tests/cxx_cmd_inout_enum.cpp b/cpp_test_suite/new_tests/cxx_cmd_inout_enum.cpp new file mode 100644 index 000000000..1631c4713 --- /dev/null +++ b/cpp_test_suite/new_tests/cxx_cmd_inout_enum.cpp @@ -0,0 +1,201 @@ +// +// Created by ingvord on 3/13/17. +// +#ifndef CmdInOutEnumTestSuite_h +#define CmdInOutEnumTestSuite_h + +#include +#include +#include +#include +#include + +using namespace Tango; +using namespace std; + +#define cout cout << "\t" + +#undef SUITE_NAME +#define SUITE_NAME CmdInOutEnumTestSuite + +class CmdInOutEnumTestSuite: public CxxTest::TestSuite +{ +protected: + DeviceProxy *device1, *dserver; + +public: + SUITE_NAME() + { + +// +// Arguments check ------------------------------------------------- +// + + string device1_name, dserver_name; + + device1_name = CxxTest::TangoPrinter::get_param("device1"); + dserver_name = "dserver/" + CxxTest::TangoPrinter::get_param("fulldsname"); + + CxxTest::TangoPrinter::validate_args(); + + +// +// Initialization -------------------------------------------------- +// + + try + { + device1 = new DeviceProxy(device1_name); + dserver = new DeviceProxy(dserver_name); + device1->ping(); + dserver->ping(); + } + catch (CORBA::Exception &e) + { + Except::print_exception(e); + exit(-1); + } + + } + + virtual ~SUITE_NAME() + { + if (CxxTest::TangoPrinter::is_restore_set("dev1_EnumLabelsDynCommandPolled_polling")) + { + DeviceData din; + DevVarStringArray rem_attr_poll; + rem_attr_poll.length(3); + rem_attr_poll[0] = device1->name().c_str(); + rem_attr_poll[1] = "command"; + rem_attr_poll[2] = "EnumLabelsDynCommandPolled"; + din << rem_attr_poll; + try + { + dserver->command_inout("RemObjPolling", din); + } + catch (DevFailed &e) + { + cout << endl << "Exception in suite tearDown():" << endl; + Except::print_exception(e); + } + } + + delete device1; + delete dserver; + } + + static SUITE_NAME *createSuite() + { + return new SUITE_NAME(); + } + + static void destroySuite(SUITE_NAME *suite) + { + delete suite; + } + +// +// Tests ------------------------------------------------------- +// + + void test_cmd_DevEnum_in(void) + { + DeviceData in, out; + in << (DevEnum) 1; + + out = device1->command_inout("IODevEnum", in); + + + short result; + out >> result; + + TS_ASSERT_EQUALS(1, result); + } + + void test_cmd_DevEnum_query(void) + { + CommandInfo cmd_info; + + cmd_info = device1->command_query("IODevEnum"); + + + TS_ASSERT_EQUALS("IODevEnum", cmd_info.cmd_name); + TS_ASSERT_EQUALS(3, cmd_info.in_enum_labels.size()); + TS_ASSERT_EQUALS("IN Label 1", cmd_info.in_enum_labels[0]); + TS_ASSERT_EQUALS("IN Label 2", cmd_info.in_enum_labels[1]); + TS_ASSERT_EQUALS("IN Label 3", cmd_info.in_enum_labels[2]); + TS_ASSERT_EQUALS(3, cmd_info.out_enum_labels.size()); + TS_ASSERT_EQUALS("OUT Label 1", cmd_info.out_enum_labels[0]); + TS_ASSERT_EQUALS("OUT Label 2", cmd_info.out_enum_labels[1]); + TS_ASSERT_EQUALS("OUT Label 3", cmd_info.out_enum_labels[2]); + } + + void test_cmd_DevEnum_query_list(void) + { + auto cmd_info_list = device1->command_list_query(); + + CommandInfo cmd_info; + auto found = find_if(cmd_info_list->begin(), cmd_info_list->end(), [](CommandInfo item) + { + return item.cmd_name == "IODevEnum"; + }); + cmd_info = *found; + + TS_ASSERT_EQUALS("IODevEnum", cmd_info.cmd_name); + TS_ASSERT_EQUALS(3, cmd_info.in_enum_labels.size()); + TS_ASSERT_EQUALS("IN Label 1", cmd_info.in_enum_labels[0]); + TS_ASSERT_EQUALS("IN Label 2", cmd_info.in_enum_labels[1]); + TS_ASSERT_EQUALS("IN Label 3", cmd_info.in_enum_labels[2]); + TS_ASSERT_EQUALS(3, cmd_info.out_enum_labels.size()); + TS_ASSERT_EQUALS("OUT Label 1", cmd_info.out_enum_labels[0]); + TS_ASSERT_EQUALS("OUT Label 2", cmd_info.out_enum_labels[1]); + TS_ASSERT_EQUALS("OUT Label 3", cmd_info.out_enum_labels[2]); + } + + void test_dyn_cmd_DevEnum_query(void) + { + auto cmd_info = device1->command_query("EnumLabelsDynCommand"); + + TS_ASSERT_EQUALS("EnumLabelsDynCommand", cmd_info.cmd_name); + TS_ASSERT_EQUALS(3, cmd_info.in_enum_labels.size()); + TS_ASSERT_EQUALS("IN Dyn Label 1", cmd_info.in_enum_labels[0]); + TS_ASSERT_EQUALS("IN Dyn Label 2", cmd_info.in_enum_labels[1]); + TS_ASSERT_EQUALS("IN Dyn Label 3", cmd_info.in_enum_labels[2]); + TS_ASSERT_EQUALS(3, cmd_info.out_enum_labels.size()); + TS_ASSERT_EQUALS("OUT Dyn Label 1", cmd_info.out_enum_labels[0]); + TS_ASSERT_EQUALS("OUT Dyn Label 2", cmd_info.out_enum_labels[1]); + TS_ASSERT_EQUALS("OUT Dyn Label 3", cmd_info.out_enum_labels[2]); + } + + void test_poll_cmd_DevEnum(void) + { + DevVarLongStringArray cmd_poll; + DeviceData din; + + cmd_poll.lvalue.length(1); + cmd_poll.lvalue[0] = 200; + cmd_poll.svalue.length(3); + cmd_poll.svalue[0] = device1->name().c_str(); + cmd_poll.svalue[1] = "command"; + cmd_poll.svalue[2] = "EnumLabelsDynCommandPolled"; + din << cmd_poll; + TS_ASSERT_THROWS_NOTHING(dserver->command_inout("AddObjPolling", din)); + CxxTest::TangoPrinter::restore_set("dev1_EnumLabelsDynCommandPolled_polling"); + + TS_ASSERT_THROWS_NOTHING(device1->set_source(Tango::CACHE)); + + std::this_thread::sleep_for( + std::chrono::milliseconds(1000)); + + DeviceData dout; + DevEnum result; + TS_ASSERT_THROWS_NOTHING(dout = device1->command_inout("EnumLabelsDynCommandPolled")); + dout >> result; + TS_ASSERT_EQUALS(result, 1); + + } +}; +#undef cout +#endif // CmdInOutEnumTestSuite_h + + diff --git a/cpp_test_suite/new_tests/cxx_misc_devproxy.cpp b/cpp_test_suite/new_tests/cxx_misc_devproxy.cpp new file mode 100644 index 000000000..d4e38f217 --- /dev/null +++ b/cpp_test_suite/new_tests/cxx_misc_devproxy.cpp @@ -0,0 +1,447 @@ +//=================================================================================================================== +// +// file : cxx_misc_devproxy.cpp +// +// project : tango +// +// author(s) : ingvord +// +// Copyright (C) : 2004-2017 +// European Synchrotron Radiation Facility +// BP 220, Grenoble 38043 +// FRANCE +// +// This file is part of Tango. +// +// Tango is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Tango is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty +// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License along with Tango. +// If not, see . +//=================================================================================================================== +#ifndef MiscDevProxyTestSuite_h +#define MiscDevProxyTestSuite_h + + +#include +#include +#include + +using namespace Tango; +using namespace std; + +#define cout cout << "\t" +#define coutv if (verbose == true) cout + +#undef SUITE_NAME +#define SUITE_NAME MiscDevProxyTestSuite + +class MiscDevProxyTestSuite: public CxxTest::TestSuite +{ +protected: + DeviceProxy *device; + + string device_name, ds_name, admin_name; + bool verbose; + +public: + SUITE_NAME() + { + +// +// Arguments check ------------------------------------------------- +// + + device_name = CxxTest::TangoPrinter::get_param("device1"); + ds_name = CxxTest::TangoPrinter::get_param("fulldsname"); + admin_name = "dserver/" + ds_name; + + verbose = CxxTest::TangoPrinter::is_param_defined("verbose"); + + CxxTest::TangoPrinter::validate_args(); + + +// +// Initialization -------------------------------------------------- +// + + try + { + device = new DeviceProxy(device_name); + } + catch (CORBA::Exception &e) + { + Except::print_exception(e); + exit(-1); + } + + } + + virtual ~SUITE_NAME() + { + delete device; + } + + static SUITE_NAME *createSuite() + { + return new SUITE_NAME(); + } + + static void destroySuite(SUITE_NAME *suite) + { + delete suite; + } + +// +// Tests ------------------------------------------------------- +// + + void test_get_timeout(void) + { + int to; + TS_ASSERT_THROWS_NOTHING(to = device->get_timeout_millis()); + + TS_ASSERT_EQUALS(3000, to); + } + + // Test set_timeout + void test_set_get_timeout(void) + { + int new_to; + TS_ASSERT_THROWS_NOTHING(device->set_timeout_millis(2000)); + TS_ASSERT_THROWS_NOTHING(new_to = device->get_timeout_millis()); + + TS_ASSERT_EQUALS(2000, new_to); + + TS_ASSERT_THROWS_NOTHING(device->set_timeout_millis(3000)); + TS_ASSERT_THROWS_NOTHING(new_to = device->get_timeout_millis()); + TS_ASSERT_EQUALS(3000, new_to); + } + + // Test ping + void test_ping(void) + { + int elapsed; + TS_ASSERT_THROWS_NOTHING(elapsed = device->ping()); + + cout << " Ping ( " << elapsed << " us ) --> OK" << endl; + ETS_ASSERT_LESS_THAN(0, elapsed); + } + + // Test state + + void test_state(void) + { + DevState sta; + TS_ASSERT_THROWS_NOTHING(sta = device->state()); + + TS_ASSERT_EQUALS(Tango::ON, sta); + } + + // Test status + void test_status(void) + { + string str; + TS_ASSERT_THROWS_NOTHING(str = device->status()); + + TS_ASSERT_EQUALS("The device is in ON state.", str); + } + + // Test Tango lib version + void test_lib_version(void) + { + int tg_version; + TS_ASSERT_THROWS_NOTHING(tg_version = device->get_tango_lib_version()); + + TS_ASSERT_LESS_THAN_EQUALS(810, tg_version); + } + + // Test adm_name + void test_adm_name(void) + { + string str_adm; + TS_ASSERT_THROWS_NOTHING(str_adm = device->adm_name()); + + transform(str_adm.begin(), str_adm.end(), str_adm.begin(), ::tolower); + transform(admin_name.begin(), admin_name.end(), admin_name.begin(), ::tolower); + + TS_ASSERT_EQUALS(admin_name, str_adm); + } + + // Test description + void test_description(void) + { + string desc; + TS_ASSERT_THROWS_NOTHING(desc = device->description()); + + TS_ASSERT_EQUALS("A TANGO device", desc); + } + + // Test name + void test_name(void) + { + string name; + TS_ASSERT_THROWS_NOTHING(name = device->name()); + + TS_ASSERT_EQUALS(device_name, name); + } + + // Test blackbox + void test_blackbox(void) + { + vector *ptr; + TS_ASSERT_THROWS_NOTHING(ptr = device->black_box(3)); + + TS_ASSERT_EQUALS(3, ptr->size()); + + string tmp = (*ptr)[0]; + string::size_type pos, end; + pos = tmp.find('A'); + end = tmp.find("from"); + string ans = tmp.substr(pos, end - pos); + + TS_ASSERT_EQUALS("Attribute name requested ", ans); + + tmp = (*ptr)[1]; + end = tmp.find("from"); + ans = tmp.substr(pos, end - pos); + TS_ASSERT_EQUALS("Attribute description requested ", ans); + + tmp = (*ptr)[2]; + end = tmp.find("from"); + ans = tmp.substr(pos, end - pos); + TS_ASSERT_EQUALS("Attribute adm_name requested ", ans); + + delete ptr; + } + + // Test info + void test_info(void) + { + DeviceInfo inf; + TS_ASSERT_THROWS_NOTHING(inf = device->info()); + TS_ASSERT_EQUALS("DevTest", inf.dev_class); + + transform(inf.server_id.begin(), inf.server_id.end(), inf.server_id.begin(), ::tolower); + transform(ds_name.begin(), ds_name.end(), ds_name.begin(), ::tolower); + + TS_ASSERT_EQUALS(ds_name, inf.server_id); + TS_ASSERT_EQUALS("Doc URL = http://www.tango-controls.org", inf.doc_url); + TS_ASSERT_EQUALS("TestDevice", inf.dev_type); + } + + // Test command_query + void test_command_query(void) + { + DevCommandInfo cmd_info; + TS_ASSERT_THROWS_NOTHING(cmd_info = device->command_query("IODoubleArray")); + + TS_ASSERT_EQUALS("IODoubleArray", cmd_info.cmd_name); + TS_ASSERT_EQUALS(DEVVAR_DOUBLEARRAY, cmd_info.in_type); + TS_ASSERT_EQUALS(DEVVAR_DOUBLEARRAY, cmd_info.out_type); + TS_ASSERT_EQUALS("Array of double", cmd_info.in_type_desc); + TS_ASSERT_EQUALS("This array * 2", cmd_info.out_type_desc); + } + + // Test command_list_query and get_command_list + void test_command_list_query(void) + { + CommandInfoList *cmd_list; + TS_ASSERT_THROWS_NOTHING(cmd_list = device->command_list_query()); + cout << "cmd list size = " << cmd_list->size() << endl; + + vector *cmd_name_list; + TS_ASSERT_THROWS_NOTHING(cmd_name_list = device->get_command_list()); + + cout << "cmd_name_list size = " << cmd_name_list->size() << endl; + + TS_ASSERT_EQUALS(cmd_name_list->size(), cmd_list->size()); + delete cmd_list; + delete cmd_name_list; + } + + void test_get_command_list(void) + { + vector *cmd_name_list; + TS_ASSERT_THROWS_NOTHING(cmd_name_list = device->get_command_list()); + + cout << "cmd_name_list size = " << cmd_name_list->size() << endl; + TS_ASSERT_EQUALS(118, cmd_name_list->size()); +// TS_ASSERT_EQUALS ("FileDb" , (*cmd_list)[0].cmd_name); +// TS_ASSERT_EQUALS ("Status", (*cmd_list)[87].cmd_name); + + delete cmd_name_list; + } + + // Test get_attribute_list + void test_get_attribute_list(void) + { + vector *att_list; + TS_ASSERT_THROWS_NOTHING(att_list = device->get_attribute_list()); + + cout << "att_list size = " << att_list->size() << endl; + TS_ASSERT_EQUALS(103, att_list->size()); +// assert ( (*att_list)[0] == "Short_attr"); +// assert ( (*att_list)[1] == "Long_attr"); +// assert ( (*att_list)[21] == "String_attr_w"); + + delete att_list; + } + + // Test attribute query + void test_attribute_query(void) + { + DeviceAttributeConfig attr_conf; + TS_ASSERT_THROWS_NOTHING(attr_conf = device->attribute_query("Short_attr")); + + TS_ASSERT_EQUALS(attr_conf.name, "Short_attr"); + TS_ASSERT_EQUALS(attr_conf.data_format, SCALAR); + TS_ASSERT_EQUALS(attr_conf.data_type, DEV_SHORT); + TS_ASSERT_EQUALS(attr_conf.description, "No description"); + TS_ASSERT_EQUALS(attr_conf.max_dim_x, 1); + } + + // Test get_attribute_config + void test_get_attribute_config(void) + { + AttributeInfoList *attr_conf_ptr; + vector li; + li.push_back("Long_attr"); + li.push_back("Double_attr"); + + TS_ASSERT_THROWS_NOTHING(attr_conf_ptr = device->get_attribute_config(li)); + + TS_ASSERT_EQUALS(attr_conf_ptr->size(), 2); + + TS_ASSERT_EQUALS((*attr_conf_ptr)[0].name, "Long_attr"); + TS_ASSERT_EQUALS((*attr_conf_ptr)[0].data_format, SCALAR); + TS_ASSERT_EQUALS((*attr_conf_ptr)[0].data_type, DEV_LONG); + + TS_ASSERT_EQUALS((*attr_conf_ptr)[1].name, "Double_attr"); + TS_ASSERT_EQUALS((*attr_conf_ptr)[1].data_format, SCALAR); + TS_ASSERT_EQUALS((*attr_conf_ptr)[1].data_type, DEV_DOUBLE); + + delete attr_conf_ptr; + } + + // Test get_command_config + void test_get_command_config(void) + { + CommandInfoList *cmd_conf_ptr; + vector li; + li.push_back("state"); + li.push_back("status"); + + TS_ASSERT_THROWS_NOTHING(cmd_conf_ptr = device->get_command_config(li)); + + TS_ASSERT_EQUALS(cmd_conf_ptr->size(), 2); + + TS_ASSERT_EQUALS((*cmd_conf_ptr)[0].cmd_name, "State"); + TS_ASSERT_EQUALS((*cmd_conf_ptr)[0].in_type, DEV_VOID); + TS_ASSERT_EQUALS((*cmd_conf_ptr)[0].out_type, DEV_STATE); + + TS_ASSERT_EQUALS((*cmd_conf_ptr)[1].cmd_name, "Status"); + TS_ASSERT_EQUALS((*cmd_conf_ptr)[1].in_type, DEV_VOID); + TS_ASSERT_EQUALS((*cmd_conf_ptr)[1].out_type, DEV_STRING); + + } + + // test attribute_list_query + +// AttributeInfoList *attr_confs; +// attr_confs = device->attribute_list_query(); + +// assert ( attr_confs->size() == 77 ); +// assert ( (*attr_confs)[0].name == "Short_attr"); +// assert ( (*attr_confs)[0].data_format == SCALAR); +// assert ( (*attr_confs)[0].data_type == DEV_SHORT); + +// assert ( (*attr_confs)[1].name == "Long_attr"); +// assert ( (*attr_confs)[1].data_type == DEV_LONG); +// assert ( (*attr_confs)[1].data_format == SCALAR); + +// assert ( (*attr_confs)[21].name == "String_attr_w"); +// assert ( (*attr_confs)[21].data_type == DEV_STRING); +// assert ( (*attr_confs)[21].data_format == SCALAR); + +// cout << " Attribute list query --> OK " << endl; +// delete attr_confs; + + // Test set_attribute_config + void test_set_attribute_config(void) + { + AttributeInfoList v_conf; + AttributeInfo co; + TS_ASSERT_THROWS_NOTHING(co = device->attribute_query("Short_attr")); + +#ifdef WIN32 + int pid = _getpid(); +#else + pid_t pid = getpid(); +#endif + + stringstream st; + + string s; + st << pid; + st >> s; + + co.format = s; + v_conf.push_back(co); + + TS_ASSERT_THROWS_NOTHING(device->set_attribute_config(v_conf)); + + DeviceAttributeConfig res = device->attribute_query("Short_attr"); + TS_ASSERT_EQUALS(res.format, s); + + } + + // Test device version + void test_device_version(void) + { +#ifndef COMPAT + int vers; + TS_ASSERT_THROWS_NOTHING(vers = device->get_idl_version()); + TS_ASSERT_EQUALS(vers, 6); +#endif + } + + // Test source + void test_source(void) + { + Tango::DevSource so; + TS_ASSERT_THROWS_NOTHING(so = device->get_source()); + TS_ASSERT_EQUALS(so, Tango::CACHE_DEV); + + TS_ASSERT_THROWS_NOTHING(device->set_source(Tango::DEV)); + TS_ASSERT_THROWS_NOTHING(so = device->get_source()); + TS_ASSERT_EQUALS(so, Tango::DEV); + + TS_ASSERT_THROWS_NOTHING(device->set_source(Tango::CACHE_DEV)); + } + + // Test get property list + void test_get_property_list(void) + { +#ifndef COMPAT + vector props; + TS_ASSERT_THROWS_NOTHING(device->get_property_list("*", props)); + + cout << "NB prop = " << props.size() << endl; + for (unsigned long l = 0; l < props.size(); l++) + cout << "prop = " << props[l] << endl; + TS_ASSERT_EQUALS(props.size(), 3); + TS_ASSERT_EQUALS(props[0], "cmd_min_poll_period"); + TS_ASSERT_EQUALS(props[1], "min_poll_period"); + TS_ASSERT_EQUALS(props[2], "tst_property"); +#endif + } +}; + +#undef cout +#endif // MiscDevProxyTestSuite_h diff --git a/cpp_test_suite/old_tests/CMakeLists.txt b/cpp_test_suite/old_tests/CMakeLists.txt index 21e1fa37f..eb3b79ecb 100644 --- a/cpp_test_suite/old_tests/CMakeLists.txt +++ b/cpp_test_suite/old_tests/CMakeLists.txt @@ -19,7 +19,6 @@ set(TESTS acc_right mem_att misc_devattr misc_devdata - misc_devproxy multiple_new new_devproxy obj_prop @@ -57,8 +56,6 @@ endforeach(TEST) configure_file(locked_device_cmd.h.cmake locked_device_cmd.h @ONLY) target_include_directories(lock PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) -add_test(NAME "old_tests::misc_devproxy" COMMAND $ ${DEV1} ${SERV_NAME}/${INST_NAME}) - add_test(NAME "old_tests::cmd_types" COMMAND $ ${DEV1} 10) add_test(NAME "old_tests::attr_types" COMMAND $ ${DEV1} 10) diff --git a/cpp_test_suite/old_tests/copy_devproxy.cpp b/cpp_test_suite/old_tests/copy_devproxy.cpp index b0c0249d0..9ea656a24 100644 --- a/cpp_test_suite/old_tests/copy_devproxy.cpp +++ b/cpp_test_suite/old_tests/copy_devproxy.cpp @@ -44,7 +44,7 @@ int main(int argc, char **argv) assert (dev2.name() == device1_name); #ifndef COMPAT - assert (dev2.get_idl_version() == 5); + assert (dev2.get_idl_version() == 6); #endif } @@ -65,7 +65,7 @@ int main(int argc, char **argv) assert (dev3.name() == device1_name); #ifndef COMPAT - assert (dev3.get_idl_version() == 5); + assert (dev3.get_idl_version() == 6); #endif cout << " Assignement operator --> OK" << endl; diff --git a/cpp_test_suite/old_tests/misc_devproxy.cpp b/cpp_test_suite/old_tests/misc_devproxy.cpp deleted file mode 100644 index 36eda18ca..000000000 --- a/cpp_test_suite/old_tests/misc_devproxy.cpp +++ /dev/null @@ -1,369 +0,0 @@ -/* - * example of a client using the TANGO device api. - */ - -#include -#include - -#ifdef WIN32 -#include -#endif - - -using namespace Tango; -using namespace std; - -int main(int argc, char **argv) -{ - DeviceProxy *device; - - if (argc != 3) - { - cout << "usage: " << argv[0] << " " << endl; - exit(-1); - } - - string device_name = argv[1]; - string ds_name = argv[2]; - string admin_device("dserver/"); - admin_device = admin_device + ds_name; - - try - { - device = new DeviceProxy(device_name); - } - catch (CORBA::Exception &e) - { - Except::print_exception(e); - exit(1); - } - - cout << '\n' << "new DeviceProxy(" << device->name() << ") returned" << '\n' << endl; - - int elapsed; - try - { - -// Test get_timeout - - int to; - to = device->get_timeout_millis(); - - assert( to == 3000 ); - cout << " Get timeout --> OK" << endl; - -// Test set_timeout - - int new_to; - device->set_timeout_millis(2000); - new_to = device->get_timeout_millis(); - - assert ( new_to == 2000 ); - - cout << " Set timeout --> OK" << endl; - - device->set_timeout_millis(3000); - -// Test ping - - elapsed = device->ping(); - - cout << " Ping ( " << elapsed << " us ) --> OK" << endl; - -// Test state - - DevState sta; - sta = device->state(); - - assert ( sta == Tango::ON); - cout << " State --> OK" << endl; - -// Test status - - string str; - str = device->status(); - - assert ( str == "The device is in ON state."); - cout << " Status --> OK" << endl; - -// Test Tango lib version - - int tg_version; - tg_version = device->get_tango_lib_version(); - - assert ( tg_version >= 810 ); - cout << " Tango lib version --> OK" << endl; - -// Test adm_name - - string str_adm; - str_adm = device->adm_name(); - - transform(str_adm.begin(),str_adm.end(),str_adm.begin(),::tolower); - transform(admin_device.begin(),admin_device.end(),admin_device.begin(),::tolower); - - assert ( str_adm == admin_device); - cout << " Adm_name --> OK" << endl; - -// Test description - - string desc; - desc = device->description(); - - assert ( desc == "A TANGO device"); - cout << " Description --> OK" << endl; - -// Test name - - string name; - name = device->name(); - - assert ( name == device_name); - cout << " Name --> OK" << endl; - -// Test blackbox - - vector *ptr; - ptr = device->black_box(3); - - assert ( ptr->size() == 3 ); - - string tmp = (*ptr)[0]; - string::size_type pos,end; - pos = tmp.find('A'); - end = tmp.find("from"); - string ans = tmp.substr(pos,end - pos); - assert ( ans == "Attribute name requested " ); - - tmp = (*ptr)[1]; - end = tmp.find("from"); - ans = tmp.substr(pos,end - pos); - assert ( ans == "Attribute description requested "); - - tmp = (*ptr)[2]; - end = tmp.find("from"); - ans = tmp.substr(pos,end - pos); - assert ( ans == "Attribute adm_name requested "); - - cout << " Black box --> OK" << endl; - delete ptr; - -// Test info - - DeviceInfo inf; - inf = device->info(); - assert( inf.dev_class == "DevTest" ); - - transform(inf.server_id.begin(),inf.server_id.end(),inf.server_id.begin(),::tolower); - transform(ds_name.begin(),ds_name.end(),ds_name.begin(),::tolower); - - assert( inf.server_id == ds_name ); - assert( inf.doc_url == "Doc URL = http://www.tango-controls.org" ); - assert( inf.dev_type == "TestDevice"); - - cout << " Info --> OK" << endl; - -// Test command_query - - DevCommandInfo cmd_info; - cmd_info = device->command_query("IODoubleArray"); - - assert( cmd_info.cmd_name == "IODoubleArray" ); - assert( cmd_info.in_type == DEVVAR_DOUBLEARRAY ); - assert( cmd_info.out_type == DEVVAR_DOUBLEARRAY ); - assert( cmd_info.in_type_desc == "Array of double" ); - assert( cmd_info.out_type_desc == "This array * 2" ); - - cout << " Command_query --> OK" << endl; - -// Test command_list_query and get_command_list - - CommandInfoList *cmd_list; - cmd_list = device->command_list_query(); - cout << "cmd list size = " << cmd_list->size() << endl; - - vector *cmd_name_list; - cmd_name_list = device->get_command_list(); - - cout << "cmd_name_list size = " << cmd_name_list->size() << endl; - - assert (cmd_name_list->size() == cmd_list->size()); - - cout << " Command list --> OK" << endl; - -// assert (cmd_list->size() == 88 ); -// assert ((*cmd_list)[0].cmd_name == "FileDb" ); -// assert ((*cmd_list)[87].cmd_name == "Status"); - -// cout << " Command_list_query --> OK" << endl; - delete cmd_list; - delete cmd_name_list; - -// Test get_attribute_list - - vector *att_list; - att_list = device->get_attribute_list(); - - cout << "att_list size = " << att_list->size() << endl; -// assert ( att_list->size() == 77 ); -// assert ( (*att_list)[0] == "Short_attr"); -// assert ( (*att_list)[1] == "Long_attr"); -// assert ( (*att_list)[21] == "String_attr_w"); - -// cout << " Get attribute list --> OK" << endl; - delete att_list; - -// Test attribute query - - DeviceAttributeConfig attr_conf; - attr_conf = device->attribute_query("Short_attr"); - - assert ( attr_conf.name == "Short_attr" ); - assert ( attr_conf.data_format == SCALAR ); - assert ( attr_conf.data_type == DEV_SHORT ); - assert ( attr_conf.description == "No description" ); - assert ( attr_conf.max_dim_x == 1 ); - - cout << " Attribute config --> OK" << endl; - -// Test get_attribute_config - - AttributeInfoList *attr_conf_ptr; - vector li; - li.push_back("Long_attr"); - li.push_back("Double_attr"); - - attr_conf_ptr = device->get_attribute_config(li); - - assert ( attr_conf_ptr->size() == 2 ); - - assert ( (*attr_conf_ptr)[0].name == "Long_attr" ); - assert ( (*attr_conf_ptr)[0].data_format == SCALAR ); - assert ( (*attr_conf_ptr)[0].data_type == DEV_LONG ); - - assert ( (*attr_conf_ptr)[1].name == "Double_attr" ); - assert ( (*attr_conf_ptr)[1].data_format == SCALAR ); - assert ( (*attr_conf_ptr)[1].data_type == DEV_DOUBLE ); - - cout << " Get attribute config --> OK" << endl; - delete attr_conf_ptr; - -// Test get_command_config - - CommandInfoList *cmd_conf_ptr; - li.clear(); - li.push_back("state"); - li.push_back("status"); - - cmd_conf_ptr = device->get_command_config(li); - - assert ( cmd_conf_ptr->size() == 2 ); - - assert ( (*cmd_conf_ptr)[0].cmd_name == "State" ); - assert ( (*cmd_conf_ptr)[0].in_type == DEV_VOID ); - assert ( (*cmd_conf_ptr)[0].out_type == DEV_STATE ); - - assert ( (*cmd_conf_ptr)[1].cmd_name == "Status" ); - assert ( (*cmd_conf_ptr)[1].in_type == DEV_VOID ); - assert ( (*cmd_conf_ptr)[1].out_type == DEV_STRING ); - - cout << " Get command config --> OK" << endl; - -// test attribute_list_query - -// AttributeInfoList *attr_confs; -// attr_confs = device->attribute_list_query(); - -// assert ( attr_confs->size() == 77 ); -// assert ( (*attr_confs)[0].name == "Short_attr"); -// assert ( (*attr_confs)[0].data_format == SCALAR); -// assert ( (*attr_confs)[0].data_type == DEV_SHORT); - -// assert ( (*attr_confs)[1].name == "Long_attr"); -// assert ( (*attr_confs)[1].data_type == DEV_LONG); -// assert ( (*attr_confs)[1].data_format == SCALAR); - -// assert ( (*attr_confs)[21].name == "String_attr_w"); -// assert ( (*attr_confs)[21].data_type == DEV_STRING); -// assert ( (*attr_confs)[21].data_format == SCALAR); - -// cout << " Attribute list query --> OK " << endl; -// delete attr_confs; - -// Test set_attribute_config - - AttributeInfoList v_conf; - AttributeInfo co = device->attribute_query("Short_attr"); - -#ifdef WIN32 - int pid = _getpid(); -#else - pid_t pid = getpid(); -#endif - - stringstream st; - - string s; - st << pid; - st >> s; - - co.format = s; - v_conf.push_back(co); - - device->set_attribute_config(v_conf); - - DeviceAttributeConfig res = device->attribute_query("Short_attr"); - assert ( res.format == s ); - - cout << " Set attribute config --> OK" << endl; - -// Test device version - -#ifndef COMPAT - int vers = device->get_idl_version(); - assert (vers == 5); - - cout << " Get IDL version --> OK" << endl; -#endif - -// Test source - - Tango::DevSource so = device->get_source(); - assert( so == Tango::CACHE_DEV ); - - device->set_source(Tango::DEV); - assert (device->get_source() == Tango::DEV); - - device->set_source(Tango::CACHE_DEV); - - cout << " Source parameter --> OK" << endl; - -// Test get property list - -#ifndef COMPAT - vector props; - device->get_property_list("*",props); - - cout << "NB prop = " << props.size() << endl; - for (unsigned long l = 0;l < props.size();l++) - cout << "prop = " << props[l] << endl; - //TODO conf_devtest defines only 3 properties - assert (props.size() == 3); - assert (props[0] == "cmd_min_poll_period"); - assert (props[1] == "min_poll_period"); - assert (props[2] == "tst_property"); -// assert (props[3] == "__SubDevices"); - - cout << " Get property list --> OK" << endl; -#endif - } - catch (Tango::DevFailed &e) - { - Except::print_exception(e); - exit(-1); - } - - delete device; - - return 0; -} diff --git a/cpp_test_suite/old_tests/size.cpp b/cpp_test_suite/old_tests/size.cpp index 0bb245411..24cafb391 100644 --- a/cpp_test_suite/old_tests/size.cpp +++ b/cpp_test_suite/old_tests/size.cpp @@ -41,21 +41,21 @@ int main(int argc, char **argv) check_size("Attribute",sizeof(Attribute),2536, &isOK); // Was 208 in V4 check_size("WAttribute",sizeof(WAttribute),3200, &isOK); // Was 252 in V4 check_size("MultiAttribute",sizeof(MultiAttribute),80, &isOK); - - check_size("Command",sizeof(Command),72, &isOK); - check_size("TemplCommand",sizeof(TemplCommand),112, &isOK); - check_size("TemplCommandIn",sizeof(TemplCommandIn),136, &isOK); - check_size("TemplCommandOut",sizeof(TemplCommandOut),136, &isOK); - check_size("TemplCommandInOut",sizeof(TemplCommandInOut),136, &isOK); - check_size("DeviceProxy",sizeof(DeviceProxy),576, &isOK); // Was 100 in V4 + check_size("Command", sizeof(Command), 80, &isOK); + check_size("TemplCommand", sizeof(TemplCommand), 120, &isOK); + check_size("TemplCommandIn", sizeof(TemplCommandIn), 144, &isOK); + check_size("TemplCommandOut", sizeof(TemplCommandOut), 144, &isOK); + check_size("TemplCommandInOut", sizeof(TemplCommandInOut), 144, &isOK); + + check_size("DeviceProxy", sizeof(DeviceProxy), 584, &isOK); // Was 100 in V4 check_size("DeviceData",sizeof(DeviceData),32, &isOK); check_size("DeviceDataHistory",sizeof(DeviceDataHistory),80, &isOK); check_size("DeviceAttribute",sizeof(DeviceAttribute),200, &isOK); // Was 52 in V4 check_size("DeviceAttributeHistory",sizeof(DeviceAttributeHistory),232, &isOK); // Was 76 in V4 check_size("ApiUtil",sizeof(ApiUtil),312, &isOK); - check_size("Database",sizeof(Database),624, &isOK); // Was 108 in V4 + check_size("Database", sizeof(Database), 632, &isOK); // Was 108 in V4 check_size("DbDevice",sizeof(DbDevice),32, &isOK); check_size("DbClass",sizeof(DbClass),32, &isOK); check_size("DbServer",sizeof(DbServer),32, &isOK); diff --git a/cppapi/client/CMakeLists.txt b/cppapi/client/CMakeLists.txt index 5be303501..c2c755e79 100644 --- a/cppapi/client/CMakeLists.txt +++ b/cppapi/client/CMakeLists.txt @@ -28,7 +28,8 @@ set(SOURCES dbapi_class.cpp eventkeepalive.cpp eventqueue.cpp notifdeventconsumer.cpp - zmqeventconsumer.cpp) + zmqeventconsumer.cpp + device_command_info.cpp) set(HEADERS accessproxy.h apiexcept.h @@ -54,7 +55,8 @@ set(HEADERS accessproxy.h devapi_attr.tpp devapi_utils.tpp api_util.tpp - devapi_pipe.tpp) + devapi_pipe.tpp + device_command_info.h) add_subdirectory(helpers) if(WIN32) diff --git a/cppapi/client/Connection.h b/cppapi/client/Connection.h index bceba553d..03277f6dd 100644 --- a/cppapi/client/Connection.h +++ b/cppapi/client/Connection.h @@ -137,7 +137,8 @@ protected : int user_connect_timeout; bool tango_host_localhost; - Tango::Device_5_var device_5; + Tango::Device_5_var device_5; + Tango::Device_6_var device_6; public : ///@publicsection @@ -568,6 +569,7 @@ public : void omni420_timeout(int,char *); DeviceData omni420_except(int,char *,TgRequest &); void toIOR(const char*,IOP::IOR&); + void resolve_obj_version(const string &corba_name, const CORBA::Object_var &obj); }; diff --git a/cppapi/client/DeviceProxy.h b/cppapi/client/DeviceProxy.h index 45a561a7c..a1e77af39 100644 --- a/cppapi/client/DeviceProxy.h +++ b/cppapi/client/DeviceProxy.h @@ -29,6 +29,8 @@ #define _DEVICEPROXY_H +#include + /**************************************************************************************** * * * The DeviceProxy class * diff --git a/cppapi/client/devapi.h b/cppapi/client/devapi.h index a32d75bce..50b930b8f 100644 --- a/cppapi/client/devapi.h +++ b/cppapi/client/devapi.h @@ -30,6 +30,7 @@ #include #include +#include #include #include #include @@ -89,28 +90,6 @@ struct LockingThread LockThread *l_thread; }; -/** - * Base structure for command information - * - * @headerfile tango.h - */ -#ifdef GEN_DOC -typedef struct DevCommandInfo -#else -typedef struct _DevCommandInfo -#endif -{ - string cmd_name; ///< The command name - long cmd_tag; ///< The command tag - long in_type; ///< Input parameter data type - long out_type; ///< Output parameter data type - string in_type_desc; ///< Input parameter description - string out_type_desc; ///< Ouptput parameter description - -///@privatesection - bool operator==(const _DevCommandInfo &); -}DevCommandInfo; - struct AttributeDimension { @@ -118,32 +97,7 @@ struct AttributeDimension long dim_y; }; -/** - * Command information data extension - * - * @headerfile tango.h - * @ingroup Client - */ -#ifdef GEN_DOC -typedef struct CommandInfo : public DevCommandInfo -#else -typedef struct _CommandInfo : public DevCommandInfo -#endif -{ - Tango::DispLevel disp_level; ///< The command display level -/// @privatesection - friend ostream &operator<<(ostream &,_CommandInfo &); - bool operator==(const _CommandInfo &); -}CommandInfo; - -/** - * A vector of CommandInfo structure - * - * @headerfile tango.h - * @ingroup Client - */ -typedef vector CommandInfoList; struct _DeviceInfo { diff --git a/cppapi/client/devapi_base.cpp b/cppapi/client/devapi_base.cpp index 6c05e8bd9..06a30d80e 100644 --- a/cppapi/client/devapi_base.cpp +++ b/cppapi/client/devapi_base.cpp @@ -271,6 +271,8 @@ Connection &Connection::operator=(const Connection &rval) tango_host_localhost = rval.tango_host_localhost; device_5 = rval.device_5; + device_6 = rval.device_6; + #ifdef HAS_UNIQUE_PTR if (rval.ext.get() != NULL) @@ -420,7 +422,8 @@ void Connection::connect(string &corba_name) Object_var obj; obj = ApiUtil::instance()->get_orb()->string_to_object(corba_name.c_str()); - +//TODO this should be dramatically refactored +// some thoughts: extract ConnectionFactory; make Connection interface implemented by Connection_V1, Connection_V2 etc; inject Connection (or Factory) into DeviceProxy // // Narrow CORBA string name to CORBA object // First, try as a Device_5, then as a Device_4, then as .... and finally as a Device @@ -453,73 +456,7 @@ void Connection::connect(string &corba_name) } } - device_5 = Device_5::_narrow(obj); - - if (CORBA::is_nil(device_5)) - { - device_4 = Device_4::_narrow(obj); - - if (CORBA::is_nil(device_4)) - { - device_3 = Device_3::_narrow(obj); - - if (CORBA::is_nil(device_3)) - { - device_2 = Device_2::_narrow(obj); - if (CORBA::is_nil(device_2)) - { - device = Device::_narrow(obj); - if (CORBA::is_nil(device)) - { - cerr << "Can't build connection to object " << corba_name << endl; - connection_state = CONNECTION_NOTOK; - - TangoSys_OMemStream desc; - desc << "Failed to connect to device " << dev_name(); - desc << " (device nil after _narrowing)" << ends; - ApiConnExcept::throw_exception((const char *) API_CantConnectToDevice, - desc.str(), - (const char *) "Connection::connect()"); - } - else - { - device->_non_existent(); - version = 1; - } - } - else - { - device_2->_non_existent(); - version = 2; - device = Device_2::_duplicate(device_2); - } - } - else - { - device_3->_non_existent(); - version = 3; - device_2 = Device_3::_duplicate(device_3); - device = Device_3::_duplicate(device_3); - } - } - else - { - device_4->_non_existent(); - version = 4; - device_3 = Device_4::_duplicate(device_4); - device_2 = Device_4::_duplicate(device_4); - device = Device_4::_duplicate(device_4); - } - } - else - { - device_5->_non_existent(); - version = 5; - device_4 = Device_5::_duplicate(device_5); - device_3 = Device_5::_duplicate(device_5); - device_2 = Device_5::_duplicate(device_5); - device = Device_5::_duplicate(device_5); - } + resolve_obj_version(corba_name, obj); // // Warning! Some non standard code (omniORB specific). @@ -534,9 +471,9 @@ void Connection::connect(string &corba_name) IIOP::ProfileBody pBody; IIOP::unmarshalProfile(ior.profiles[0], pBody); - CORBA::ULong total = pBody.components.length(); + DevULong total = pBody.components.length(); - for (CORBA::ULong index = 0; index < total; index++) + for (DevULong index = 0; index < total; index++) { IOP::TaggedComponent &c = pBody.components[index]; if (c.tag == 3) @@ -643,6 +580,89 @@ void Connection::connect(string &corba_name) } } +void Connection::resolve_obj_version(const string &corba_name, const Object_var &obj) +{ + //TODO extract template or Macro or class hierarchy, 'cauz this code clearly is a duplication + device_6 = Device_6::_narrow(obj); + + if (not is_nil(device_6)) + { + version = 6; + device_6->_non_existent(); + device_5 = Device_6::_duplicate(device_6); + device_4 = Device_6::_duplicate(device_6); + device_3 = Device_6::_duplicate(device_6); + device_2 = Device_6::_duplicate(device_6); + device = Device_6::_duplicate(device_6); + return; + } + + device_5 = Device_5::_narrow(obj); + + if (not is_nil(device_5)) + { + version = 5; + device_5->_non_existent(); + device_4 = Device_5::_duplicate(device_5); + device_3 = Device_5::_duplicate(device_5); + device_2 = Device_5::_duplicate(device_5); + device = Device_5::_duplicate(device_5); + return; + } + + device_4 = Device_4::_narrow(obj); + + if (not is_nil(device_4)) + { + version = 4; + device_4->_non_existent(); + device_3 = Device_4::_duplicate(device_4); + device_2 = Device_4::_duplicate(device_4); + device = Device_4::_duplicate(device_4); + return; + } + + device_3 = Device_3::_narrow(obj); + + if (not is_nil(device_3)) + { + version = 3; + device_3->_non_existent(); + device_2 = Device_3::_duplicate(device_3); + device = Device_3::_duplicate(device_3); + return; + } + + device_2 = Device_2::_narrow(obj); + + if (not is_nil(device_2)) + { + version = 2; + device_2->_non_existent(); + device = Device_2::_duplicate(device_2); + return; + } + + device = Device::_narrow(obj); + + if (not is_nil(device)) + { + version = 1; + device->_non_existent(); + return; + } + + cerr << "Can't build connection to object " << corba_name << endl; + connection_state = CONNECTION_NOTOK; + + TangoSys_OMemStream desc; + desc << "Failed to connect to device " << dev_name(); + desc << " (device nil after _narrowing)" << ends; + ApiConnExcept::throw_exception((const char *) API_CantConnectToDevice, + desc.str(), + (const char *) "Connection::resolve_obj_version()"); +} + //----------------------------------------------------------------------------- // @@ -671,12 +691,12 @@ void Connection::toIOR(const char *iorstr, IOP::IOR &ior) s = (s - 4) / 2; // how many octets are there in the string p += 4; - cdrMemoryStream buf((CORBA::ULong) s, 0); + cdrMemoryStream buf((DevULong) s, 0); for (int i = 0; i < (int) s; i++) { int j = i * 2; - CORBA::Octet v; + DevUChar v; if (p[j] >= '0' && p[j] <= '9') { @@ -716,7 +736,7 @@ void Connection::toIOR(const char *iorstr, IOP::IOR &ior) } buf.rewindInputPtr(); - CORBA::Boolean b = buf.unmarshalBoolean(); + DevBoolean b = buf.unmarshalBoolean(); buf.setByteSwapFlag(b); ior.type_id = IOP::IOR::unmarshaltype_id(buf); @@ -3401,6 +3421,7 @@ CommandInfo DeviceProxy::command_query(string cmd) CommandInfo command_info; DevCmdInfo_var cmd_info; DevCmdInfo_2_var cmd_info_2; + DevCmdInfo_6_var cmd_info_6; int ctr = 0; while (ctr < 2) @@ -3409,31 +3430,31 @@ CommandInfo DeviceProxy::command_query(string cmd) { check_and_reconnect(); - if (version == 1) + + Device_var dev; + Device_2_var dev_2; + Device_6_var dev_6; + switch (version) { - Device_var dev = Device::_duplicate(device); + case 1: + dev = Device::_duplicate(device); cmd_info = dev->command_query(cmd.c_str()); - command_info.cmd_name = cmd_info->cmd_name; - command_info.cmd_tag = cmd_info->cmd_tag; - command_info.in_type = cmd_info->in_type; - command_info.out_type = cmd_info->out_type; - command_info.in_type_desc = cmd_info->in_type_desc; - command_info.out_type_desc = cmd_info->out_type_desc; - command_info.disp_level = Tango::OPERATOR; - } - else - { - Device_2_var dev = Device_2::_duplicate(device_2); - cmd_info_2 = dev->command_query_2(cmd.c_str()); + return create_CommandInfo(cmd_info.in()); + case 2: + case 3: + case 4: + case 5: + dev_2 = Device_2::_duplicate(device_2); + cmd_info_2 = dev_2->command_query_2(cmd.c_str()); + + return create_CommandInfo(cmd_info_2.in()); + case 6: + default: + dev_6 = Device_6::_duplicate(device_6); + cmd_info_6 = dev_6->command_query_6(cmd.c_str()); - command_info.cmd_name = cmd_info_2->cmd_name; - command_info.cmd_tag = cmd_info_2->cmd_tag; - command_info.in_type = cmd_info_2->in_type; - command_info.out_type = cmd_info_2->out_type; - command_info.in_type_desc = cmd_info_2->in_type_desc; - command_info.out_type_desc = cmd_info_2->out_type_desc; - command_info.disp_level = cmd_info_2->level; + return create_CommandInfo(cmd_info_6.in()); } ctr = 2; } @@ -3550,6 +3571,7 @@ CommandInfoList *DeviceProxy::command_list_query() CommandInfoList *command_info_list = NULL; DevCmdInfoList_var cmd_info_list; DevCmdInfoList_2_var cmd_info_list_2; + DevCmdInfoList_6_var cmd_info_list_6; int ctr = 0; while (ctr < 2) @@ -3558,42 +3580,30 @@ CommandInfoList *DeviceProxy::command_list_query() { check_and_reconnect(); - if (version == 1) + Device_var dev; + Device_2_var dev_2; + Device_6_var dev_6; + switch (version) { - Device_var dev = Device::_duplicate(device); + case 1: + dev = Device::_duplicate(device); cmd_info_list = dev->command_list_query(); - command_info_list = new CommandInfoList(cmd_info_list->length()); -// command_info_list->resize(cmd_info_list->length()); - - for (unsigned int i = 0; i < cmd_info_list->length(); i++) - { - (*command_info_list)[i].cmd_name = cmd_info_list[i].cmd_name; - (*command_info_list)[i].cmd_tag = cmd_info_list[i].cmd_tag; - (*command_info_list)[i].in_type = cmd_info_list[i].in_type; - (*command_info_list)[i].out_type = cmd_info_list[i].out_type; - (*command_info_list)[i].in_type_desc = cmd_info_list[i].in_type_desc; - (*command_info_list)[i].out_type_desc = cmd_info_list[i].out_type_desc; - (*command_info_list)[i].disp_level = Tango::OPERATOR; - } - } - else - { - Device_2_var dev = Device_2::_duplicate(device_2); - cmd_info_list_2 = dev->command_list_query_2(); + return newCommandInfoList(cmd_info_list); + case 2: + case 3: + case 4: + case 5: + dev_2 = Device_2::_duplicate(device_2); + cmd_info_list_2 = dev_2->command_list_query_2(); - command_info_list = new CommandInfoList(cmd_info_list_2->length()); -// command_info_list->resize(cmd_info_list_2->length()); + return newCommandInfoList(cmd_info_list_2); + case 6: + default: + dev_6 = Device_6::_duplicate(device_6); + cmd_info_list_6 = dev_6->command_list_query_6(); - for (unsigned int i = 0; i < cmd_info_list_2->length(); i++) - { - (*command_info_list)[i].cmd_name = cmd_info_list_2[i].cmd_name; - (*command_info_list)[i].cmd_tag = cmd_info_list_2[i].cmd_tag; - (*command_info_list)[i].in_type = cmd_info_list_2[i].in_type; - (*command_info_list)[i].out_type = cmd_info_list_2[i].out_type; - (*command_info_list)[i].in_type_desc = cmd_info_list_2[i].in_type_desc; - (*command_info_list)[i].out_type_desc = cmd_info_list_2[i].out_type_desc; - (*command_info_list)[i].disp_level = cmd_info_list_2[i].level; + return newCommandInfoList(cmd_info_list_6); } } ctr = 2; @@ -4219,6 +4229,7 @@ AttributeInfoListEx *DeviceProxy::get_attribute_config_ex(vector &attr_s break; case 5: + case 6: { Device_5_var dev = Device_5::_duplicate(device_5); attr_config_list_5 = dev->get_attribute_config_5(attr_list); @@ -4267,6 +4278,8 @@ AttributeInfoListEx *DeviceProxy::get_attribute_config_ex(vector &attr_s break; default: + //TODO an exception must be thrown here, but it produces segfault in ~AttributeProxy + //Tango::Except::throw_exception("Unsupported TANGO protocol version=" + version,"Unsupported TANGO protocol version=" + version,"DeviceProxy::get_attribute_config_ex"); break; } @@ -5839,7 +5852,7 @@ vector *DeviceProxy::read_attributes(vector &attr_strin { if (version >= 3) { - if (version == 5) + if (version >= 5) { ApiUtil::attr_to_device(&(attr_value_list_5[i]), version, &(*dev_attr)[i]); } @@ -10254,6 +10267,11 @@ int DeviceProxy::get_tango_lib_version() ret = 902; break; + //TODO extract class hierarchy based on version!!! + case 6: + ret = 1001; + break; + default: break; } diff --git a/cppapi/client/device_command_info.cpp b/cppapi/client/device_command_info.cpp new file mode 100644 index 000000000..54a3bd6a8 --- /dev/null +++ b/cppapi/client/device_command_info.cpp @@ -0,0 +1,89 @@ +//=================================================================================================================== +// +// file : device_command_info.cpp +// +// project : tango +// +// author(s) : ingvord +// +// Copyright (C) : 2004-2017 +// European Synchrotron Radiation Facility +// BP 220, Grenoble 38043 +// FRANCE +// +// This file is part of Tango. +// +// Tango is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Tango is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty +// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License along with Tango. +// If not, see . +//=================================================================================================================== + +#include +#include + +namespace Tango +{ + + +CommandInfo create_CommandInfo(const DevCmdInfo &devCmdInfo) +{ + CommandInfo result; + + result.cmd_name = devCmdInfo.cmd_name; + result.cmd_tag = devCmdInfo.cmd_tag; + result.in_type = devCmdInfo.in_type; + result.out_type = devCmdInfo.out_type; + result.in_type_desc = devCmdInfo.in_type_desc; + result.out_type_desc = devCmdInfo.out_type_desc; + result.disp_level = Tango::OPERATOR; + return (result); +} + +CommandInfo create_CommandInfo(const DevCmdInfo_2 &devCmdInfo_2) +{ + CommandInfo result; + + result.cmd_name = devCmdInfo_2.cmd_name; + result.cmd_tag = devCmdInfo_2.cmd_tag; + result.in_type = devCmdInfo_2.in_type; + result.out_type = devCmdInfo_2.out_type; + result.in_type_desc = devCmdInfo_2.in_type_desc; + result.out_type_desc = devCmdInfo_2.out_type_desc; + result.disp_level = devCmdInfo_2.level; + return (result); +} + +CommandInfo create_CommandInfo(const DevCmdInfo_6 &devCmdInfo_3) +{ + CommandInfo result; + + result.cmd_name = devCmdInfo_3.cmd_name; + result.cmd_tag = devCmdInfo_3.cmd_tag; + result.in_type = devCmdInfo_3.in_type; + result.out_type = devCmdInfo_3.out_type; + result.in_type_desc = devCmdInfo_3.in_type_desc; + result.out_type_desc = devCmdInfo_3.out_type_desc; + result.disp_level = devCmdInfo_3.level; + + fill_vector(result.in_enum_labels, devCmdInfo_3.in_enum_labels); + fill_vector(result.out_enum_labels, devCmdInfo_3.out_enum_labels); + + return (result); +} + +void fill_vector(vector &dst, const DevVarStringArray &src) +{ + dst.resize(src.length()); + for (size_t i = 0, size = src.length(); i < size; ++i) + { + dst[i] = src[i].in(); + } +} +}//namespace Tango diff --git a/cppapi/client/device_command_info.h b/cppapi/client/device_command_info.h new file mode 100644 index 000000000..5444443f1 --- /dev/null +++ b/cppapi/client/device_command_info.h @@ -0,0 +1,126 @@ +//=================================================================================================================== +// +// file : device_command_info.h +// +// project : tango +// +// author(s) : ingvord +// +// Copyright (C) : 2004-2017 +// European Synchrotron Radiation Facility +// BP 220, Grenoble 38043 +// FRANCE +// +// This file is part of Tango. +// +// Tango is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Tango is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty +// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License along with Tango. +// If not, see . +//=================================================================================================================== + +#pragma once + + +namespace Tango +{ +/** + * Base structure for command information + * + * @headerfile tango.h + */ +#ifdef GEN_DOC +typedef struct DevCommandInfo +#else + +typedef struct _DevCommandInfo +#endif +{ + string cmd_name; ///< The command name + long cmd_tag; ///< The command tag + long in_type; ///< Input parameter data type + long out_type; ///< Output parameter data type + string in_type_desc; ///< Input parameter description + string out_type_desc; ///< Ouptput parameter description +///@privatesection + bool operator==(const _DevCommandInfo &); +} DevCommandInfo; + +/** + * Command information data extension + * + * @headerfile tango.h + * @ingroup Client + */ +#ifdef GEN_DOC +typedef struct CommandInfo : public DevCommandInfo +#else + +typedef struct _CommandInfo: public DevCommandInfo +#endif +{ + Tango::DispLevel disp_level; ///< The command display level + + vector in_enum_labels; ///< Labels for enum arg or empty + vector out_enum_labels; ///< Labels for enum result or empty + + _CommandInfo() + : DevCommandInfo(), + in_enum_labels(), + out_enum_labels() + {} + +/// @privatesection + friend ostream &operator<<(ostream &, _CommandInfo &); + + bool operator==(const _CommandInfo &); +} CommandInfo; + +/** + * + * @return CommandInfo created on stack + */ +CommandInfo create_CommandInfo(const DevCmdInfo &); + +/** + * + * @return CommandInfo created on stack + */ +CommandInfo create_CommandInfo(const DevCmdInfo_2 &); + +/** + * + * @return CommandInfo created on stack + */ +CommandInfo create_CommandInfo(const DevCmdInfo_6 &); + +//TODO template +void fill_vector(vector &, const DevVarStringArray &); + +/** + * A vector of CommandInfo structure + * + * @headerfile tango.h + * @ingroup Client + */ +typedef vector CommandInfoList; + +template +CommandInfoList *newCommandInfoList(DevCommandInfoList devCmdInfoList_var) +{ + auto result = new CommandInfoList(devCmdInfoList_var->length()); + + for (size_t i = 0, size = devCmdInfoList_var->length(); i < size; ++i) + { + (*result)[i] = create_CommandInfo(devCmdInfoList_var[i]); + } + + return (result); +} +} \ No newline at end of file diff --git a/cppapi/client/proxy_asyn.cpp b/cppapi/client/proxy_asyn.cpp index a925b0e07..aedd45833 100644 --- a/cppapi/client/proxy_asyn.cpp +++ b/cppapi/client/proxy_asyn.cpp @@ -1059,8 +1059,9 @@ vector *DeviceProxy::read_attributes_reply(long id) switch (version) { + case 6: case 5: - dii_any >>= received_5; + dii_any >>= received_5; nb_received = received_5->length(); break; @@ -1086,7 +1087,7 @@ vector *DeviceProxy::read_attributes_reply(long id) { if (version >= 3) { - if (version == 5) + if (version >= 5) ApiUtil::attr_to_device(&((*received_5)[i]),version,&((*dev_attr)[i])); else if (version == 4) ApiUtil::attr_to_device(&((*received_4)[i]),version,&((*dev_attr)[i])); @@ -1263,8 +1264,9 @@ DeviceAttribute *DeviceProxy::read_attribute_reply(long id) switch (version) { + case 6: case 5: - dii_any >>= received_5; + dii_any >>= received_5; break; case 4: @@ -1282,7 +1284,7 @@ DeviceAttribute *DeviceProxy::read_attribute_reply(long id) if (version >= 3) { - if (version == 5) + if (version >= 5) ApiUtil::attr_to_device(&((*received_5)[0]),version,dev_attr); else if (version == 4) ApiUtil::attr_to_device(&((*received_4)[0]),version,dev_attr); @@ -1503,8 +1505,9 @@ vector *DeviceProxy::read_attributes_reply(long id,long call_ti switch (version) { + case 6: case 5: - dii_any >>= received_5; + dii_any >>= received_5; nb_received = received_5->length(); break; @@ -1530,7 +1533,7 @@ vector *DeviceProxy::read_attributes_reply(long id,long call_ti { if (version >= 3) { - if (version == 5) + if (version >= 5) ApiUtil::attr_to_device(&((*received_5)[i]),version,&((*dev_attr)[i])); else if (version == 4) ApiUtil::attr_to_device(&((*received_4)[i]),version,&((*dev_attr)[i])); @@ -1747,8 +1750,9 @@ DeviceAttribute *DeviceProxy::read_attribute_reply(long id,long call_timeout) switch (version) { + case 6: case 5: - dii_any >>= received_5; + dii_any >>= received_5; break; case 4: @@ -1766,7 +1770,7 @@ DeviceAttribute *DeviceProxy::read_attribute_reply(long id,long call_timeout) if (version >= 3) { - if (version == 5) + if (version >= 5) ApiUtil::attr_to_device(&((*received_5)[0]),version,dev_attr); else if (version == 4) ApiUtil::attr_to_device(&((*received_4)[0]),version,dev_attr); diff --git a/cppapi/client/proxy_asyn_cb.cpp b/cppapi/client/proxy_asyn_cb.cpp index 886adb5d5..5b4975e33 100644 --- a/cppapi/client/proxy_asyn_cb.cpp +++ b/cppapi/client/proxy_asyn_cb.cpp @@ -476,8 +476,9 @@ void Connection::Cb_ReadAttr_Request(CORBA::Request_ptr req,Tango::CallBack *cb_ switch (version) { + case 6: case 5: - dii_any >>= received_5; + dii_any >>= received_5; nb_received = received_5->length(); break; @@ -503,7 +504,7 @@ void Connection::Cb_ReadAttr_Request(CORBA::Request_ptr req,Tango::CallBack *cb_ { if (version >= 3) { - if (version == 5) + if (version >= 5) ApiUtil::attr_to_device(&((*received_5)[i]),version,&((*dev_attr)[i])); else if (version == 4) ApiUtil::attr_to_device(&((*received_4)[i]),version,&((*dev_attr)[i])); diff --git a/cppapi/server/CMakeLists.txt b/cppapi/server/CMakeLists.txt index 1475915ea..1654f9271 100644 --- a/cppapi/server/CMakeLists.txt +++ b/cppapi/server/CMakeLists.txt @@ -17,6 +17,7 @@ set(SOURCES attrdesc.cpp device_3.cpp device_4.cpp device_5.cpp + device_6.cpp deviceclass.cpp devicelog.cpp devintr.cpp @@ -81,6 +82,7 @@ set(HEADERS attrdesc.h device_3.tpp device_4.h device_5.h + device_6.h deviceclass.h devintr.h dintrthread.h diff --git a/cppapi/server/attribute.cpp b/cppapi/server/attribute.cpp index 80b7fb96d..e79214c57 100644 --- a/cppapi/server/attribute.cpp +++ b/cppapi/server/attribute.cpp @@ -3817,10 +3817,14 @@ void Attribute::fire_change_event(DevFailed *except) { switch (*ite) { - case 5: - if (change5_subscription >= EVENT_RESUBSCRIBE_PERIOD) - remove_client_lib(5,string(EventName[CHANGE_EVENT])); - break; + //TODO extract class hierarchy based on version!!! + case 6: + case 5: + if (change5_subscription >= EVENT_RESUBSCRIBE_PERIOD) + { + remove_client_lib(5, string(EventName[CHANGE_EVENT])); + } + break; case 4: if (change4_subscription >= EVENT_RESUBSCRIBE_PERIOD) @@ -4241,10 +4245,14 @@ void Attribute::fire_archive_event(DevFailed *except) { switch (*ite) { - case 5: - if (archive5_subscription >= EVENT_RESUBSCRIBE_PERIOD) - remove_client_lib(5,string(EventName[ARCHIVE_EVENT])); - break; + //TODO extract class hierarchy based on version!!! + case 6: + case 5: + if (archive5_subscription >= EVENT_RESUBSCRIBE_PERIOD) + { + remove_client_lib(5, string(EventName[ARCHIVE_EVENT])); + } + break; case 4: if (archive4_subscription >= EVENT_RESUBSCRIBE_PERIOD) @@ -4684,10 +4692,14 @@ void Attribute::fire_event(vector &filt_names,vector &filt_vals, { switch (*ite) { - case 5: - if (user5_subscription >= EVENT_RESUBSCRIBE_PERIOD) - remove_client_lib(5,string(EventName[USER_EVENT])); - break; + //TODO extract class hierarchy based on version!!! + case 6: + case 5: + if (user5_subscription >= EVENT_RESUBSCRIBE_PERIOD) + { + remove_client_lib(5, string(EventName[USER_EVENT])); + } + break; case 4: if (user4_subscription >= EVENT_RESUBSCRIBE_PERIOD) @@ -4925,10 +4937,14 @@ void Attribute::fire_error_periodic_event(DevFailed *except) { switch (*ite) { - case 5: - if (periodic5_subscription >= EVENT_RESUBSCRIBE_PERIOD) - remove_client_lib(5,string(EventName[PERIODIC_EVENT])); - break; + //TODO extract class hierarchy based on version!!! + case 6: + case 5: + if (periodic5_subscription >= EVENT_RESUBSCRIBE_PERIOD) + { + remove_client_lib(5, string(EventName[PERIODIC_EVENT])); + } + break; case 4: if (periodic4_subscription >= EVENT_RESUBSCRIBE_PERIOD) diff --git a/cppapi/server/attribute.h b/cppapi/server/attribute.h index 296f360e6..1d9dd4458 100644 --- a/cppapi/server/attribute.h +++ b/cppapi/server/attribute.h @@ -2584,8 +2584,10 @@ inline void Attribute::set_change_event_sub(int cl_lib) { switch (cl_lib) { - case 5: - event_change5_subscription = time(NULL); + //TODO extract class hierarchy based on version!!! + case 6: + case 5: + event_change5_subscription = time(NULL); break; case 4: @@ -2603,8 +2605,10 @@ inline void Attribute::set_periodic_event_sub(int cl_lib) { switch (cl_lib) { - case 5: - event_periodic5_subscription = time(NULL); + //TODO extract class hierarchy based on version!!! + case 6: + case 5: + event_periodic5_subscription = time(NULL); break; case 4: @@ -2622,8 +2626,10 @@ inline void Attribute::set_archive_event_sub(int cl_lib) { switch (cl_lib) { - case 5: - event_archive5_subscription = time(NULL); + //TODO extract class hierarchy based on version!!! + case 6: + case 5: + event_archive5_subscription = time(NULL); break; case 4: @@ -2641,8 +2647,10 @@ inline void Attribute::set_user_event_sub(int cl_lib) { switch (cl_lib) { - case 5: - event_user5_subscription = time(NULL); + //TODO extract class hierarchy based on version!!! + case 6: + case 5: + event_user5_subscription = time(NULL); break; case 4: @@ -2660,8 +2668,10 @@ inline void Attribute::set_att_conf_event_sub(int cl_lib) { switch (cl_lib) { - case 5: - event_attr_conf5_subscription = time(NULL); + //TODO extract class hierarchy based on version!!! + case 6: + case 5: + event_attr_conf5_subscription = time(NULL); break; default: diff --git a/cppapi/server/blackbox.cpp b/cppapi/server/blackbox.cpp index 7f7835174..f0e41865d 100644 --- a/cppapi/server/blackbox.cpp +++ b/cppapi/server/blackbox.cpp @@ -612,7 +612,7 @@ void BlackBox::insert_attr(const Tango::DevVarStringArray &names, const ClntIden box[insert_elt].req_type = Req_Operation; box[insert_elt].attr_type = Attr_Unknown; - if (vers == 5) + if (vers >= 5) { box[insert_elt].op_type = Op_Read_Attr_5; } @@ -1057,7 +1057,7 @@ void BlackBox::insert_attr_wr_nl(const Tango::AttributeValueList_4 &att_list, box[insert_elt].req_type = Req_Operation; box[insert_elt].attr_type = Attr_Unknown; - if (vers == 5) + if (vers >= 5) { box[insert_elt].op_type = Op_Write_Read_Attributes_5; } diff --git a/cppapi/server/device_2.cpp b/cppapi/server/device_2.cpp index 019198cbe..b5c2113db 100644 --- a/cppapi/server/device_2.cpp +++ b/cppapi/server/device_2.cpp @@ -1095,8 +1095,6 @@ Tango::DevCmdInfo_2 *Device_2Impl::command_query_2(const char *command) cout4 << "DeviceImpl::command_query_2 arrived" << endl; Tango::DevCmdInfo_2 *back = NULL; - string cmd(command); - transform(cmd.begin(),cmd.end(),cmd.begin(),::tolower); // // Record operation request in black box @@ -1124,57 +1122,39 @@ Tango::DevCmdInfo_2 *Device_2Impl::command_query_2(const char *command) // (in case of dyn command instaleld at device level) // - long i; - bool found = false; - Command *cmd_ptr = Tango_nullptr; - long nb_cmd = device_class->get_command_list().size(); - for (i = 0;i < nb_cmd;i++) - { - if (device_class->get_command_list()[i]->get_lower_name() == cmd) - { - found = true; - cmd_ptr = device_class->get_command_list()[i]; - break; - } - } - - if (found == false) - { - nb_cmd = get_local_command_list().size(); - for (i = 0;i < nb_cmd;i++) - { - if (get_local_command_list()[i]->get_lower_name() == cmd) - { - found = true; - cmd_ptr = get_local_command_list()[i]; - break; - } - } - } - - - if (found == true) - { - back->cmd_name = CORBA::string_dup(cmd_ptr->get_name().c_str()); - back->cmd_tag = 0; - back->level = cmd_ptr->get_disp_level(); - back->in_type = (long)(cmd_ptr->get_in_type()); - back->out_type = (long)(cmd_ptr->get_out_type()); - string &str_in = cmd_ptr->get_in_type_desc(); - if (str_in.size() != 0) - back->in_type_desc = CORBA::string_dup(str_in.c_str()); - else - back->in_type_desc = CORBA::string_dup(NotSet); - string &str_out = cmd_ptr->get_out_type_desc(); - if (str_out.size() != 0) - back->out_type_desc = CORBA::string_dup(str_out.c_str()); - else - back->out_type_desc = CORBA::string_dup(NotSet); - } - else - { - delete back; - cout3 << "Device_2Impl::command_query_2(): command " << command << " not found" << endl; + string cmd(command); + Command *cmd_ptr = get_cmd_ptr(cmd); + + if (cmd_ptr != Tango_nullptr) + { + back->cmd_name = CORBA::string_dup(cmd_ptr->get_name().c_str()); + back->cmd_tag = 0; + back->level = cmd_ptr->get_disp_level(); + back->in_type = (long) (cmd_ptr->get_in_type()); + back->out_type = (long) (cmd_ptr->get_out_type()); + string &str_in = cmd_ptr->get_in_type_desc(); + if (str_in.size() != 0) + { + back->in_type_desc = CORBA::string_dup(str_in.c_str()); + } + else + { + back->in_type_desc = CORBA::string_dup(NotSet); + } + string &str_out = cmd_ptr->get_out_type_desc(); + if (str_out.size() != 0) + { + back->out_type_desc = CORBA::string_dup(str_out.c_str()); + } + else + { + back->out_type_desc = CORBA::string_dup(NotSet); + } + } + else + { + delete back; + cout3 << "Device_2Impl::command_query_2(): command " << command << " not found" << endl; // // throw an exception to client @@ -1196,6 +1176,32 @@ Tango::DevCmdInfo_2 *Device_2Impl::command_query_2(const char *command) return back; } +Command *Device_2Impl::get_cmd_ptr(const string &cmd_name) +{ + string cmd_name_lower{cmd_name}; + transform(cmd_name.begin(), cmd_name.end(), cmd_name_lower.begin(), ::tolower); + //TODO +// auto found = find_if(device_class->get_command_list().begin(), device_class->get_command_list().end(),[](){device_class->get_command_list()[i]->get_lower_name() == cmd_name}) +// if(found != device_class->get_command_list().end()) return *found; + for (size_t i = 0, size = device_class->get_command_list().size(); i < size; i++) + { + if (device_class->get_command_list()[i]->get_lower_name() == cmd_name_lower) + { + return device_class->get_command_list()[i]; + } + } + + for (size_t i = 0, size = get_local_command_list().size(); i < size; i++) + { + if (get_local_command_list()[i]->get_lower_name() == cmd_name_lower) + { + return get_local_command_list()[i]; + } + } + + return Tango_nullptr; +} + //+------------------------------------------------------------------------- // // method : Device_2Impl::get_attribute_config_2 @@ -1217,10 +1223,10 @@ Tango::DevCmdInfo_2 *Device_2Impl::command_query_2(const char *command) // //-------------------------------------------------------------------------- -Tango::AttributeConfigList_2 *Device_2Impl::get_attribute_config_2(const Tango::DevVarStringArray& names) +Tango::AttributeConfigList_2 *Device_2Impl::get_attribute_config_2(const Tango::DevVarStringArray &names) { - TangoMonitor &mon = get_att_conf_monitor(); - AutoTangoMonitor sync(&mon); + TangoMonitor &mon = get_att_conf_monitor(); + AutoTangoMonitor sync(&mon); cout4 << "Device_2Impl::get_attribute_config_2 arrived" << endl; @@ -1332,11 +1338,11 @@ Tango::AttributeConfigList_2 *Device_2Impl::get_attribute_config_2(const Tango:: // //-------------------------------------------------------------------------- -Tango::DevCmdHistoryList *Device_2Impl::command_inout_history_2(const char* command, - CORBA::Long n) +Tango::DevCmdHistoryList *Device_2Impl::command_inout_history_2(const char *command, + CORBA::Long n) { - TangoMonitor &mon = get_poll_monitor(); - AutoTangoMonitor sync(&mon); + TangoMonitor &mon = get_poll_monitor(); + AutoTangoMonitor sync(&mon); cout4 << "Device_2Impl::command_inout_history_2 arrived" << endl; Tango::DevCmdHistoryList *back = NULL; @@ -1529,10 +1535,10 @@ Tango::DevCmdHistoryList *Device_2Impl::command_inout_history_2(const char* comm //-------------------------------------------------------------------------- Tango::DevAttrHistoryList *Device_2Impl::read_attribute_history_2(const char* name, - CORBA::Long n) + CORBA::Long n) { - TangoMonitor &mon = get_poll_monitor(); - AutoTangoMonitor sync(&mon); + TangoMonitor &mon = get_poll_monitor(); + AutoTangoMonitor sync(&mon); cout4 << "Device_2Impl::read_attribute_history_2 arrived" << endl; diff --git a/cppapi/server/device_2.h b/cppapi/server/device_2.h index e3651de23..b48d87505 100644 --- a/cppapi/server/device_2.h +++ b/cppapi/server/device_2.h @@ -325,6 +325,9 @@ class Device_2Impl : public virtual POA_Tango::Device_2, #else Device_2ImplExt *ext_2; #endif + +protected: + Command *get_cmd_ptr(const string &cmd_name); }; } // End of Tango namespace diff --git a/cppapi/server/device_6.cpp b/cppapi/server/device_6.cpp new file mode 100644 index 000000000..11a9804d0 --- /dev/null +++ b/cppapi/server/device_6.cpp @@ -0,0 +1,85 @@ +//=================================================================================================================== +// +// file : device_6.cpp +// +// project : tango +// +// author(s) : ingvord +// +// Copyright (C) : 2004-2017 +// European Synchrotron Radiation Facility +// BP 220, Grenoble 38043 +// FRANCE +// +// This file is part of Tango. +// +// Tango is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Tango is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty +// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License along with Tango. +// If not, see . +//=================================================================================================================== + +#include + +Tango::DevCmdInfo_6 *Tango::Device_6Impl::command_query_6(const char *cmd_name) +{ + cout4 << "Device_6Impl::command_query_6 arrived" << endl; + + DevCmdInfo_2 *cmdInfo_2 = command_query_2(cmd_name); + + DevCmdInfo_6 *result = new DevCmdInfo_6(); + result->cmd_name = cmdInfo_2->cmd_name; + result->level = cmdInfo_2->level; + result->cmd_tag = cmdInfo_2->cmd_tag; + result->in_type = cmdInfo_2->in_type; + result->out_type = cmdInfo_2->out_type; + result->in_type_desc = cmdInfo_2->in_type_desc; + result->out_type_desc = cmdInfo_2->out_type_desc; + + string cmd(cmd_name); + Command *cmd_ptr = get_cmd_ptr(cmd); + + vector &in_enum_labels = cmd_ptr->get_ext()->in_enum_labels; + vector &out_enum_labels = cmd_ptr->get_ext()->out_enum_labels; + + handle_cmd_info_enum_labels(&(result->in_enum_labels), in_enum_labels); + handle_cmd_info_enum_labels(&(result->out_enum_labels), out_enum_labels); + + cout4 << "Leaving Device_6Impl::command_query_6" << endl; + return result; +} + +Tango::DevCmdInfoList_6 *Tango::Device_6Impl::command_list_query_6() +{ + cout4 << "Device_6Impl::command_list_query_6 arrived" << endl; + + DevCmdInfoList_2 *cmdInfoList_2 = command_list_query_2(); + + DevCmdInfoList_6 *result = new DevCmdInfoList_6(); + result->length(cmdInfoList_2->length()); + + for (size_t i = 0, size = cmdInfoList_2->length(); i < size; ++i) + { + (*result)[i] = *command_query_6((*cmdInfoList_2)[i].cmd_name); + } + + cout4 << "Leaving Device_6Impl::command_list_query_6" << endl; + return result; +} + +void Tango::handle_cmd_info_enum_labels(Tango::DevVarStringArray *result, const vector &enum_labels) +{ + *result = DevVarStringArray(); + result->length(enum_labels.size()); + + for (size_t i = 0, size = enum_labels.size(); i < size; ++i) + { + (*result)[i] = string_dup(enum_labels[i].c_str()); + } +} diff --git a/cppapi/server/device_6.h b/cppapi/server/device_6.h new file mode 100644 index 000000000..c33404484 --- /dev/null +++ b/cppapi/server/device_6.h @@ -0,0 +1,84 @@ +//=================================================================================================================== +// +// file : device_6.h +// +// project : tango +// +// author(s) : ingvord +// +// Copyright (C) : 2004-2017 +// European Synchrotron Radiation Facility +// BP 220, Grenoble 38043 +// FRANCE +// +// This file is part of Tango. +// +// Tango is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Tango is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty +// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License along with Tango. +// If not, see . +//=================================================================================================================== +#ifndef TANGO_DEVICE_6_H +#define TANGO_DEVICE_6_H + +#include + +namespace Tango +{ + +void handle_cmd_info_enum_labels(DevVarStringArray *, const vector &); + +class Device_6Impl: public virtual POA_Tango::Device_6, + public Device_5Impl +{ +public: + Device_6Impl(DeviceClass *device_class, string &dev_name) + : Device_5Impl(device_class, dev_name) + { + idl_version = 6; + } + + Device_6Impl(DeviceClass *device_class, string &dev_name, string &desc) + : Device_5Impl(device_class, dev_name, + desc) + { + idl_version = 6; + } + + Device_6Impl(DeviceClass *device_class, string &dev_name, string &desc, DevState dev_state, string &dev_status) + : Device_5Impl(device_class, dev_name, desc, dev_state, dev_status) + { + idl_version = 6; + } + + Device_6Impl(DeviceClass *device_class, const char *dev_name, const char *desc, DevState dev_state, + const char *dev_status) + : Device_5Impl(device_class, dev_name, desc, dev_state, dev_status) + { + idl_version = 6; + } + + virtual ~Device_6Impl() = default; + + /** + * + * @param cmd_name + * @return CommandInfo with enum labels + */ + DevCmdInfo_6 *command_query_6(const char *cmd_name) override; + + DevCmdInfoList_6 *command_list_query_6() override; + +private: + friend void handle_cmd_info_enum_labels(DevVarStringArray *result, const vector &enum_labels); +}; + +}//EOF namespace Tango + +#endif //TANGO_DEVICE_6_H diff --git a/cppapi/server/eventcmds.cpp b/cppapi/server/eventcmds.cpp index 8666e8b70..704c3ce53 100644 --- a/cppapi/server/eventcmds.cpp +++ b/cppapi/server/eventcmds.cpp @@ -248,8 +248,10 @@ void DServer::event_subscription(string &dev_name,string &obj_name,string &actio omni_mutex_lock oml(EventSupplier::get_event_mutex()); switch (client_lib) { - case 5: - attribute.event_user5_subscription = time(NULL); + //TODO extract class hierarchy based on version!!! + case 6: + case 5: + attribute.event_user5_subscription = time(NULL); break; case 4: @@ -266,7 +268,8 @@ void DServer::event_subscription(string &dev_name,string &obj_name,string &actio cout4 << "DServer::event_subscription(): update attr_conf subscription\n"; omni_mutex_lock oml(EventSupplier::get_event_mutex()); - if (client_lib == 5) + //TODO extract class hierarchy based on versions + if (client_lib >= 5) attribute.event_attr_conf5_subscription = time(NULL); else attribute.event_attr_conf_subscription = time(NULL); @@ -369,8 +372,10 @@ void DServer::event_subscription(string &dev_name,string &obj_name,string &actio switch (client_lib) { - case 5: - attribute.event_change5_subscription = time(NULL); + //TODO extract class hierarchy based on version!!! + case 6: + case 5: + attribute.event_change5_subscription = time(NULL); break; case 4: @@ -394,8 +399,10 @@ void DServer::event_subscription(string &dev_name,string &obj_name,string &actio omni_mutex_lock oml(EventSupplier::get_event_mutex()); switch (client_lib) { - case 5: - attribute.event_periodic5_subscription = time(NULL); + //TODO extract class hierarchy based on version!!! + case 6: + case 5: + attribute.event_periodic5_subscription = time(NULL); break; case 4: @@ -447,8 +454,10 @@ void DServer::event_subscription(string &dev_name,string &obj_name,string &actio omni_mutex_lock oml(EventSupplier::get_event_mutex()); switch (client_lib) { - case 5: - attribute.event_archive5_subscription = time(NULL); + //TODO extract class hierarchy based on version!!! + case 6: + case 5: + attribute.event_archive5_subscription = time(NULL); break; case 4: diff --git a/cppapi/server/eventsupplier.cpp b/cppapi/server/eventsupplier.cpp index b74c47d53..d16e57ae0 100644 --- a/cppapi/server/eventsupplier.cpp +++ b/cppapi/server/eventsupplier.cpp @@ -150,10 +150,12 @@ SendEventType EventSupplier::detect_and_push_events(DeviceImpl *device_impl, str { switch (*ite) { + //TODO extract class hierarchy based on version!!! + case 6: case 5: if (change5_subscription >= EVENT_RESUBSCRIBE_PERIOD) { - attr.remove_client_lib(5, string(EventName[CHANGE_EVENT])); + attr.remove_client_lib(*ite, string(EventName[CHANGE_EVENT])); } break; @@ -194,10 +196,12 @@ SendEventType EventSupplier::detect_and_push_events(DeviceImpl *device_impl, str { switch (*ite) { + //TODO extract class hierarchy based on version!!! + case 6: case 5: if (periodic5_subscription >= EVENT_RESUBSCRIBE_PERIOD) { - attr.remove_client_lib(5, string(EventName[PERIODIC_EVENT])); + attr.remove_client_lib(*ite, string(EventName[PERIODIC_EVENT])); } break; @@ -238,10 +242,12 @@ SendEventType EventSupplier::detect_and_push_events(DeviceImpl *device_impl, str { switch (*ite) { + //TODO extract class hierarchy based on version!!! + case 6: case 5: if (archive5_subscription >= EVENT_RESUBSCRIBE_PERIOD) { - attr.remove_client_lib(5, string(EventName[ARCHIVE_EVENT])); + attr.remove_client_lib(*ite, string(EventName[ARCHIVE_EVENT])); } break; @@ -477,6 +483,8 @@ bool EventSupplier::detect_and_push_change_event(DeviceImpl *device_impl, struct switch (*ite) { + //TODO extract class hierarchy based on version + case 6: case 5: { convert_att_event_to_5(attr_value, sent_value, need_free, attr); @@ -857,6 +865,8 @@ bool EventSupplier::detect_and_push_archive_event(DeviceImpl *device_impl, switch (*ite) { + //TODO extract class hierarchy based on version + case 6: case 5: { convert_att_event_to_5(attr_value, sent_value, need_free, attr); @@ -1071,6 +1081,8 @@ bool EventSupplier::detect_and_push_periodic_event(DeviceImpl *device_impl, switch (*ite) { + //TODO extract class hierarchy based on version + case 6: case 5: { convert_att_event_to_5(attr_value, sent_value, need_free, attr); diff --git a/cppapi/server/tango.h b/cppapi/server/tango.h index c22b98ca2..2d59979e4 100644 --- a/cppapi/server/tango.h +++ b/cppapi/server/tango.h @@ -118,6 +118,7 @@ #include #include #include +#include #include #include #include diff --git a/cppapi/server/tango_const.h.in b/cppapi/server/tango_const.h.in index 7322aea9f..721dba015 100644 --- a/cppapi/server/tango_const.h.in +++ b/cppapi/server/tango_const.h.in @@ -44,7 +44,7 @@ namespace Tango #define TANGO_VERSION_MINOR @MINOR_VERSION@ #define TANGO_VERSION_PATCH @PATCH_VERSION@ -#define TANGO_BASE_CLASS Tango::Device_5Impl +#define TANGO_BASE_CLASS Tango::Device_6Impl #define TBS(s) #s #define XTBS(s) TBS(s) @@ -54,7 +54,7 @@ const char * const TgLibMajorVers = XTBS(TANGO_VERSION_MAJOR); const int TgLibVersNb = TANGO_VERSION_MAJOR*10000 + TANGO_VERSION_MINOR*100 + TANGO_VERSION_PATCH; -const int DevVersion = 5; // IDL version number +const int DevVersion = 6; // IDL version number const int DefaultMaxSeq = 20; const int DefaultBlackBoxDepth = 50; const int DefaultPollRingDepth = 10; diff --git a/cppapi/server/zmqeventsupplier.cpp b/cppapi/server/zmqeventsupplier.cpp index 7da7507bc..3d586b935 100644 --- a/cppapi/server/zmqeventsupplier.cpp +++ b/cppapi/server/zmqeventsupplier.cpp @@ -1190,7 +1190,7 @@ void ZmqEventSupplier::push_event(DeviceImpl *device_impl,string event_type, *(ev_value.attr_val_4) >>= data_call_cdr; mess_ptr = data_call_cdr.bufPtr(); - mess_ptr = (char *)mess_ptr + (sizeof(CORBA::Long) << 1); + mess_ptr = (char *) mess_ptr + (sizeof(DevLong) << 1); int nb_data; int data_discr = ((int *)mess_ptr)[0]; @@ -1733,9 +1733,11 @@ void ZmqEventSupplier::push_event_loop(DeviceImpl *device_impl,EventType event_t { switch (*ite) { + //TODO extract class hierarchy based on version + case 6: case 5: { - convert_att_event_to_5(attr_value,sent_value,need_free,att); + convert_att_event_to_5(attr_value, sent_value, need_free, att); } break; From 0a4bd1f353de1dde38b175ca83b95c48e818f5d4 Mon Sep 17 00:00:00 2001 From: Ingvord Date: Thu, 23 Aug 2018 14:33:07 +0300 Subject: [PATCH 02/18] Update .travis.yml --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index c2af78013..9555f015a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,7 +24,7 @@ before_install: - .travis/${OS_TYPE}/before_install.sh - docker pull tangocs/mysql:9.2.2 - docker pull tangocs/tango-cs:latest - - git clone -b cppTango-351 https://${CI_USER_TOKEN}@github.com/tango-controls/tango-idl.git idl + - git clone https://${CI_USER_TOKEN}@github.com/tango-controls/tango-idl.git idl - chmod +x .travis/${OS_TYPE}/run.sh before_script: From f31a2f0e4750b0fb40c4d75c97e1d0f9ad9b81ff Mon Sep 17 00:00:00 2001 From: ingvord Date: Thu, 23 Aug 2018 18:54:22 +0300 Subject: [PATCH 03/18] fix compilation [1h] --- cppapi/client/devapi_base.cpp | 11 ++---- cppapi/client/device_command_info.cpp | 2 +- cppapi/server/command.h | 54 +++++++++++++++++++++++---- 3 files changed, 52 insertions(+), 15 deletions(-) diff --git a/cppapi/client/devapi_base.cpp b/cppapi/client/devapi_base.cpp index 06a30d80e..1bc973153 100644 --- a/cppapi/client/devapi_base.cpp +++ b/cppapi/client/devapi_base.cpp @@ -3415,10 +3415,9 @@ DeviceInfo const &DeviceProxy::info() // command implemented for this TANGO device // //----------------------------------------------------------------------------- - +//TODO make cmd const & CommandInfo DeviceProxy::command_query(string cmd) { - CommandInfo command_info; DevCmdInfo_var cmd_info; DevCmdInfo_2_var cmd_info_2; DevCmdInfo_6_var cmd_info_6; @@ -3509,7 +3508,7 @@ CommandInfo DeviceProxy::command_query(string cmd) } } - return (command_info); + assert(false);//should not reach this line } //----------------------------------------------------------------------------- @@ -3568,7 +3567,6 @@ CommandInfoList *DeviceProxy::get_command_config(vector &cmd_names) CommandInfoList *DeviceProxy::command_list_query() { - CommandInfoList *command_info_list = NULL; DevCmdInfoList_var cmd_info_list; DevCmdInfoList_2_var cmd_info_list_2; DevCmdInfoList_6_var cmd_info_list_6; @@ -3587,7 +3585,7 @@ CommandInfoList *DeviceProxy::command_list_query() { case 1: dev = Device::_duplicate(device); - cmd_info_list = dev->command_list_query(); + cmd_info_list = dev->command_list_query(); return newCommandInfoList(cmd_info_list); case 2: @@ -3605,7 +3603,6 @@ CommandInfoList *DeviceProxy::command_list_query() return newCommandInfoList(cmd_info_list_6); } - } ctr = 2; } catch (CORBA::TRANSIENT &trans) @@ -3659,7 +3656,7 @@ CommandInfoList *DeviceProxy::command_list_query() } } - return (command_info_list); + assert(false); } //----------------------------------------------------------------------------- diff --git a/cppapi/client/device_command_info.cpp b/cppapi/client/device_command_info.cpp index 54a3bd6a8..5f06a6593 100644 --- a/cppapi/client/device_command_info.cpp +++ b/cppapi/client/device_command_info.cpp @@ -26,7 +26,7 @@ //=================================================================================================================== #include -#include +#include namespace Tango { diff --git a/cppapi/server/command.h b/cppapi/server/command.h index 3e976aeb7..b09d9794b 100644 --- a/cppapi/server/command.h +++ b/cppapi/server/command.h @@ -385,6 +385,39 @@ class Command //@} +//TODO unit tests +/** + * Set in_enum_labels from vector ref + */ + void set_in_enum_labels(vector &v) + { + this->get_ext()->in_enum_labels = v; + } + +/** + * Set in_enum_labels from vector rvalue + */ + void set_in_enum_labels(vector &&v) + { + this->get_ext()->in_enum_labels = move(v); + } + + /** + * Set in_enum_labels from vector ref + */ + void set_out_enum_labels(vector &v) + { + this->get_ext()->out_enum_labels = v; + } + +/** + * Set in_enum_labels from vector rvalue + */ + void set_out_enum_labels(vector &&v) + { + this->get_ext()->out_enum_labels = move(v); + } + /**@name Extract methods. * All these methods extract data from the CORBA Any object received as * command input data @@ -1228,17 +1261,20 @@ class Command class CommandExt { public: - CommandExt() {} + CommandExt() + : + in_enum_labels(), + out_enum_labels() + {} + + vector in_enum_labels; + vector out_enum_labels; }; void alloc_any(CORBA::Any *&); void throw_bad_type(const char *); -#ifdef HAS_UNIQUE_PTR - unique_ptr ext; // Class extension -#else - CommandExt *ext; -#endif + shared_ptr ext; //Class extension // // Ported from the extension class @@ -1246,7 +1282,11 @@ class Command Tango::DispLevel cmd_disp_level; // Display level long poll_period; // Polling period - +public: + shared_ptr get_ext() + { + return ext; + } }; //============================================================================= From 807c815026a7ae89ac0defc852d343491da0ffb5 Mon Sep 17 00:00:00 2001 From: ingvord Date: Thu, 23 Aug 2018 13:41:18 +0300 Subject: [PATCH 04/18] Backport #357: DevEnum support for commands [2h] --- .travis.yml | 2 +- CMakeLists.txt | 1 + cpp_test_suite/cpp_test_ds/DevTest.cpp | 2911 +++++++++-------- cpp_test_suite/cpp_test_ds/DevTestClass.cpp | 1654 +++++----- cpp_test_suite/cpp_test_ds/TypeCmds.cpp | 20 + cpp_test_suite/cpp_test_ds/TypeCmds.h | 10 + cpp_test_suite/cxxtest/CMakeLists.txt | 2 + cpp_test_suite/event/CMakeLists.txt | 34 +- cpp_test_suite/event/att_conf_event.cpp | 5 +- cpp_test_suite/event/change_event.cpp | 5 +- cpp_test_suite/new_tests/cxx_blackbox.cpp | 3 +- .../new_tests/cxx_cmd_inout_enum.cpp | 201 ++ .../new_tests/cxx_misc_devproxy.cpp | 447 +++ cpp_test_suite/old_tests/CMakeLists.txt | 3 - cpp_test_suite/old_tests/copy_devproxy.cpp | 4 +- cpp_test_suite/old_tests/misc_devproxy.cpp | 369 --- cpp_test_suite/old_tests/size.cpp | 16 +- cppapi/client/CMakeLists.txt | 6 +- cppapi/client/Connection.h | 4 +- cppapi/client/DeviceProxy.h | 2 + cppapi/client/devapi.h | 48 +- cppapi/client/devapi_base.cpp | 270 +- cppapi/client/device_command_info.cpp | 89 + cppapi/client/device_command_info.h | 126 + cppapi/client/proxy_asyn.cpp | 20 +- cppapi/client/proxy_asyn_cb.cpp | 5 +- cppapi/server/CMakeLists.txt | 2 + cppapi/server/attribute.cpp | 48 +- cppapi/server/attribute.h | 30 +- cppapi/server/blackbox.cpp | 4 +- cppapi/server/device_2.cpp | 132 +- cppapi/server/device_2.h | 3 + cppapi/server/device_6.cpp | 85 + cppapi/server/device_6.h | 84 + cppapi/server/eventcmds.cpp | 27 +- cppapi/server/eventsupplier.cpp | 18 +- cppapi/server/tango.h | 1 + cppapi/server/tango_const.h.in | 4 +- cppapi/server/zmqeventsupplier.cpp | 6 +- 39 files changed, 3767 insertions(+), 2934 deletions(-) create mode 100644 cpp_test_suite/new_tests/cxx_cmd_inout_enum.cpp create mode 100644 cpp_test_suite/new_tests/cxx_misc_devproxy.cpp delete mode 100644 cpp_test_suite/old_tests/misc_devproxy.cpp create mode 100644 cppapi/client/device_command_info.cpp create mode 100644 cppapi/client/device_command_info.h create mode 100644 cppapi/server/device_6.cpp create mode 100644 cppapi/server/device_6.h diff --git a/.travis.yml b/.travis.yml index 3406550ae..927fb980c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -31,7 +31,7 @@ before_install: - docker pull tangocs/tango-cs:latest - git clone https://github.com/JoakimSoderberg/coveralls-cmake.git - git clone -b v4.2.2 https://${CI_USER_TOKEN}@github.com/zeromq/cppzmq.git cppzmq - - git clone -b tango-9-lts https://${CI_USER_TOKEN}@github.com/tango-controls/tango-idl.git idl + - git clone https://${CI_USER_TOKEN}@github.com/tango-controls/tango-idl.git idl before_script: - docker run --name mysql_db -e MYSQL_ROOT_PASSWORD=root -d tangocs/mysql:9.2.2 --sql-mode="" diff --git a/CMakeLists.txt b/CMakeLists.txt index 89d9c767d..9adf9121a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,5 @@ cmake_minimum_required(VERSION 2.8.12) +project(tango) include(CTest) enable_testing() diff --git a/cpp_test_suite/cpp_test_ds/DevTest.cpp b/cpp_test_suite/cpp_test_ds/DevTest.cpp index 1698bd917..4b3fd066b 100644 --- a/cpp_test_suite/cpp_test_ds/DevTest.cpp +++ b/cpp_test_suite/cpp_test_ds/DevTest.cpp @@ -1,40 +1,38 @@ #include #include +#include "IOAddAttribute.h" #ifdef WIN32 #include #include #else -#include #endif -#include - -void EventCallBack::push_event(Tango::EventData* event_data) +void EventCallBack::push_event(Tango::EventData *event_data) { - short value; + short value; - cb_executed++; - try - { - cout << "EventCallBack::push_event(): called attribute " << event_data->attr_name; - cout << " event " << event_data->event << endl; - if (!event_data->err) - { - *(event_data->attr_value) >> value; - cout << "CallBack vector value : " << value << endl; - } - else - { - cout << "Error sent to callback" << endl; + cb_executed++; + try + { + cout << "EventCallBack::push_event(): called attribute " << event_data->attr_name; + cout << " event " << event_data->event << endl; + if (!event_data->err) + { + *(event_data->attr_value) >> value; + cout << "CallBack vector value : " << value << endl; + } + else + { + cout << "Error sent to callback" << endl; // Tango::Except::print_error_stack(event_data->errors); - cb_err++; - } - } - catch (...) - { - cout << "EventCallBack::push_event(): could not extract data !\n"; - } + cb_err++; + } + } + catch (...) + { + cout << "EventCallBack::push_event(): could not extract data !\n"; + } } @@ -51,126 +49,113 @@ void EventCallBack::push_event(Tango::EventData* event_data) //----------------------------------------------------------------------------- #ifndef COMPAT -DevTest::DevTest(Tango::DeviceClass *cl,string &s):TANGO_BASE_CLASS(cl,s.c_str()) -{ - init_device(); -} -DevTest::DevTest(Tango::DeviceClass *cl,const char *s):TANGO_BASE_CLASS(cl,s) +DevTest::DevTest(Tango::DeviceClass *cl, string &s) + : TANGO_BASE_CLASS(cl, s) { - init_device(); -} - -DevTest::DevTest(Tango::DeviceClass *cl,const char *s,const char *d) -:TANGO_BASE_CLASS(cl,s,d) -{ - init_device(); -} - -DevTest::DevTest(Tango::DeviceClass *cl,const char *s,const char *d, Tango::DevState state, const char *status ) -:TANGO_BASE_CLASS(cl,s,d, state, status) -{ - init_device(); + init_device(); } #else DevTest::DevTest(Tango::DeviceClass *cl,string &s):Tango::Device_3Impl(cl,s.c_str()) { - init_device(); + init_device(); } DevTest::DevTest(Tango::DeviceClass *cl,const char *s):Tango::Device_3Impl(cl,s) { - init_device(); + init_device(); } DevTest::DevTest(Tango::DeviceClass *cl,const char *s,const char *d) :Tango::Device_3Impl(cl,s,d) { - init_device(); + init_device(); } DevTest::DevTest(Tango::DeviceClass *cl,const char *s,const char *d, Tango::DevState state, const char *status ) :Tango::Device_3Impl(cl,s,d, state, status) { - init_device(); + init_device(); } #endif void DevTest::init_device() { - cout << "DevTest::DevTest() create " << device_name << endl; - DEBUG_STREAM << "Creating " << device_name << endl; - - Tango::Util *tg = Tango::Util::instance(); - - set_state(Tango::ON); - attr_long = 1246; - attr_short_rw = 66; - attr_long64_rw = 0x800000000LL; - attr_ulong_rw = 0xC0000000L; - attr_ulong64_rw = 0xC000000000000000LL; - attr_state_rw = Tango::FAULT; - PollLong_attr_num = 0; - PollString_spec_attr_num = 0; - - Short_attr_except = false; - if (tg->is_svr_starting() == true || tg->is_device_restarting(device_name) == true) - Short_attr_w_except = false; - event_change_attr_except = false; - event_quality_attr_except = false; - event_throw_out_of_sync = false; - - attr_sub_device_tst = false; - - attr_event_size = 4; - attr_event[0] = 10; - attr_event[1] = 20; - attr_event[2] = 30; - attr_event[3] = 40; - attr_event[4] = 50; - attr_event[5] = 60; - attr_event[6] = 70; - attr_event[7] = 80; - attr_event[8] = 90; - attr_event[9] = 100; - - attr_event64_size = 2; - attr_event64[0] = 0x800000000LL; - attr_event64[1] = 44; - attr_event64[2] = 55; - - attr_qua_event[0] = 1.2; - attr_qua_event[1] = 2.4; - attr_event_qua = Tango::ATTR_VALID; - remote_dev = NULL; - - slow_actua_write.tv_sec = 0; - slow_actua = 0; - - attr_spec_long64_rw[0] = 1000; - attr_spec_long64_rw[1] = 10000; - attr_spec_long64_rw[2] = 100000; - attr_spec_ulong_rw[0] = 2222; - attr_spec_ulong_rw[1] = 22222; - attr_spec_ulong_rw[2] = 222222; - attr_spec_ulong64_rw[0] = 8888; - attr_spec_ulong64_rw[1] = 88888; - attr_spec_ulong64_rw[2] = 888888; - attr_spec_state_rw[0] = Tango::ON; - attr_spec_state_rw[1] = Tango::OFF; - - attr_slow = 3.3; + cout << "DevTest::DevTest() create " << device_name << endl; + DEBUG_STREAM << "Creating " << device_name << endl; + + Tango::Util *tg = Tango::Util::instance(); + + set_state(Tango::ON); + attr_long = 1246; + attr_short_rw = 66; + attr_long64_rw = 0x800000000LL; + attr_ulong_rw = 0xC0000000L; + attr_ulong64_rw = 0xC000000000000000LL; + attr_state_rw = Tango::FAULT; + PollLong_attr_num = 0; + PollString_spec_attr_num = 0; + + Short_attr_except = false; + if (tg->is_svr_starting() == true || tg->is_device_restarting(device_name) == true) + { + Short_attr_w_except = false; + } + event_change_attr_except = false; + event_quality_attr_except = false; + event_throw_out_of_sync = false; + + attr_sub_device_tst = false; + + attr_event_size = 4; + attr_event[0] = 10; + attr_event[1] = 20; + attr_event[2] = 30; + attr_event[3] = 40; + attr_event[4] = 50; + attr_event[5] = 60; + attr_event[6] = 70; + attr_event[7] = 80; + attr_event[8] = 90; + attr_event[9] = 100; + + attr_event64_size = 2; + attr_event64[0] = 0x800000000LL; + attr_event64[1] = 44; + attr_event64[2] = 55; + + attr_qua_event[0] = 1.2; + attr_qua_event[1] = 2.4; + attr_event_qua = Tango::ATTR_VALID; + remote_dev = NULL; + + slow_actua_write.tv_sec = 0; + slow_actua = 0; + + attr_spec_long64_rw[0] = 1000; + attr_spec_long64_rw[1] = 10000; + attr_spec_long64_rw[2] = 100000; + attr_spec_ulong_rw[0] = 2222; + attr_spec_ulong_rw[1] = 22222; + attr_spec_ulong_rw[2] = 222222; + attr_spec_ulong64_rw[0] = 8888; + attr_spec_ulong64_rw[1] = 88888; + attr_spec_ulong64_rw[2] = 888888; + attr_spec_state_rw[0] = Tango::ON; + attr_spec_state_rw[1] = Tango::OFF; + + attr_slow = 3.3; #ifndef COMPAT - enc_attr.encoded_format = CORBA::string_dup("Which format?"); + enc_attr.encoded_format = CORBA::string_dup("Which format?"); /* enc_attr.encoded_data.length(200 * 1024 * 1024); for (int i = 0;i < (200 * 1024 * 1024);i++) enc_attr.encoded_data[i] = (unsigned char)(i % 256);*/ - enc_attr.encoded_data.length(4); - enc_attr.encoded_data[0] = (unsigned char)97; - enc_attr.encoded_data[1] = (unsigned char)98; - enc_attr.encoded_data[2] = (unsigned char)99; - enc_attr.encoded_data[3] = (unsigned char)100; + enc_attr.encoded_data.length(4); + enc_attr.encoded_data[0] = (unsigned char) 97; + enc_attr.encoded_data[1] = (unsigned char) 98; + enc_attr.encoded_data[2] = (unsigned char) 99; + enc_attr.encoded_data[3] = (unsigned char) 100; /* enc_format = new char[40]; strcpy(enc_format,"Forth try"); @@ -180,23 +165,56 @@ void DevTest::init_device() att_conf = 10; wattr_throw = 0; - enum_value = 2; + enum_value = 2; - Tango::Attribute &att = (get_device_attr())->get_attr_by_name("DynEnum_attr"); - Tango::MultiAttrProp multi_prop; - att.get_properties(multi_prop); - if (multi_prop.enum_labels.empty() == true) - multi_prop.enum_labels.push_back("Dummy_label"); - att.set_properties(multi_prop); + Tango::Attribute &att = (get_device_attr())->get_attr_by_name("DynEnum_attr"); + Tango::MultiAttrProp multi_prop; + att.get_properties(multi_prop); + if (multi_prop.enum_labels.empty() == true) + { + multi_prop.enum_labels.push_back("Dummy_label"); + } + att.set_properties(multi_prop); - rpipe_type = 0; - Tango::Pipe &pi = get_device_class()->get_pipe_by_name("RWPipe",device_name_lower); - pi.set_pipe_serial_model(Tango::PIPE_BY_USER); + rpipe_type = 0; + Tango::Pipe &pi = get_device_class()->get_pipe_by_name("RWPipe", device_name_lower); + pi.set_pipe_serial_model(Tango::PIPE_BY_USER); Reynald_ctr = 0; Reynald_val = 9.9; - cout << "DevTest::DevTest(): End of init_device() method for device " << device_name << endl; + class EnumLabelsDynCommand: public DynCommand + { + public: + EnumLabelsDynCommand() + : DynCommand( + "EnumLabelsDynCommand", Tango::CmdArgType::DEV_ENUM, Tango::CmdArgType::DEV_ENUM, "", "Enum labels") + { + set_in_enum_labels({"IN Dyn Label 1", "IN Dyn Label 2", "IN Dyn Label 3"}); + set_out_enum_labels({"OUT Dyn Label 1", "OUT Dyn Label 2", "OUT Dyn Label 3"}); + } + }; + + class EnumLabelsDynCommandPolled: public DynCommand + { + public: + EnumLabelsDynCommandPolled() + : DynCommand( + "EnumLabelsDynCommandPolled", Tango::CmdArgType::DEV_VOID, Tango::CmdArgType::DEV_ENUM, "", "Enum labels") + { + set_out_enum_labels({"OUT Dyn Label 1", "OUT Dyn Label 2", "OUT Dyn Label 3"}); + } + + virtual CORBA::Any *execute(Tango::DeviceImpl *, const CORBA::Any &) + { + return insert((Tango::DevEnum) 1); + } + }; + + this->add_command(new EnumLabelsDynCommand(), true); + this->add_command(new EnumLabelsDynCommandPolled(), false); + + cout << "DevTest::DevTest(): End of init_device() method for device " << device_name << endl; } @@ -212,7 +230,7 @@ void DevTest::init_device() void DevTest::always_executed_hook() { - cout2 << "In always_executed_hook method" << endl; + cout2 << "In always_executed_hook method" << endl; } @@ -229,13 +247,13 @@ void DevTest::always_executed_hook() Tango::ConstDevString DevTest::dev_status() { - cout2 << "In DayOfWeek state command" << endl; + cout2 << "In DayOfWeek state command" << endl; #ifdef WIN32 - Tango::ConstDevString stat = DeviceImpl::dev_status(); + Tango::ConstDevString stat = DeviceImpl::dev_status(); #else - Tango::ConstDevString stat = Tango::DeviceImpl::dev_status(); + Tango::ConstDevString stat = Tango::DeviceImpl::dev_status(); #endif - return stat; + return stat; } //+---------------------------------------------------------------------------- @@ -252,65 +270,68 @@ bool DevTest::templ_state(const CORBA::Any &) // command allowed only if the device is on // - if (device_state == Tango::ON) - return(true); - else - return(false); + if (device_state == Tango::ON) + { + return (true); + } + else + { + return (false); + } } void DevTest::IOTempl() { - cout << "[DevTest::IOTempl]" << endl; + cout << "[DevTest::IOTempl]" << endl; } Tango::DevVarLongArray *DevTest::IOTemplOut() { - cout << "[DevTest::IOTemplOut]" << endl; + cout << "[DevTest::IOTemplOut]" << endl; - Tango::DevVarLongArray *argout; - argout = new Tango::DevVarLongArray(); + Tango::DevVarLongArray *argout; + argout = new Tango::DevVarLongArray(); - argout->length(4); - (*argout)[0] = 10; - (*argout)[1] = 20; - (*argout)[2] = 30; - (*argout)[3] = 40; + argout->length(4); + (*argout)[0] = 10; + (*argout)[1] = 20; + (*argout)[2] = 30; + (*argout)[3] = 40; - return argout; + return argout; } void DevTest::IOTemplIn(Tango::DevLong received) { - cout << "[DevTest::IOTemplIn] received " << received << endl; + cout << "[DevTest::IOTemplIn] received " << received << endl; } void DevTest::IOPushEvent() { - cout << "[DevTest::IOPushEvent] received " << endl; + cout << "[DevTest::IOPushEvent] received " << endl; - vector f_names; - vector f_val; + vector f_names; + vector f_val; - push_event("event_change_tst",f_names,f_val,attr_event,attr_event_size); + push_event("event_change_tst", f_names, f_val, attr_event, attr_event_size); } void DevTest::IOPushDevEncodedEvent() { - cout << "[DevTest::IOPushDevEncodedEvent] received " << endl; + cout << "[DevTest::IOPushDevEncodedEvent] received " << endl; #ifndef COMPAT - vector f_names; - vector f_val; + vector f_names; + vector f_val; - push_event("encoded_attr",f_names,f_val,&enc_attr); + push_event("encoded_attr", f_names, f_val, &enc_attr); #endif } - Tango::DevLong DevTest::IOSubscribeEvent(const Tango::DevVarStringArray *in_data) { - cout << "[DevTest::IOSubscribeEvent] received " << endl; + cout << "[DevTest::IOSubscribeEvent] received " << endl; //TODO: modify conf_devtest.cpp to automatically create a remote device based on the instance name @@ -339,58 +360,64 @@ Tango::DevLong DevTest::IOSubscribeEvent(const Tango::DevVarStringArray *in_data // eve_id = remote_dev->subscribe_event(att_name,Tango::PERIODIC_EVENT,&cb,filters); - vector filters; + vector filters; - if (remote_dev == NULL) - { - remote_dev = new Tango::DeviceProxy((*in_data)[0]); - } - string att_name((*in_data)[1]); - cb.cb_executed = 0; + if (remote_dev == NULL) + { + remote_dev = new Tango::DeviceProxy((*in_data)[0]); + } + string att_name((*in_data)[1]); + cb.cb_executed = 0; - // start the polling first! - remote_dev->poll_attribute(att_name,1000); + // start the polling first! + remote_dev->poll_attribute(att_name, 1000); - string eve_type((*in_data)[2]); - transform(eve_type.begin(),eve_type.end(),eve_type.begin(),::tolower); - Tango::EventType eve; - if (eve_type == "change") - eve = Tango::CHANGE_EVENT; - else if (eve_type == "periodic") - eve = Tango::PERIODIC_EVENT; - else if (eve_type == "archive") - eve = Tango::ARCHIVE_EVENT; - else - { - stringstream ss; - ss << "Event type " << (*in_data)[2] << " not recognized as a valid event type"; - Tango::Except::throw_exception("DevTest_WrongEventType",ss.str(),"DevTest::IOSubscribeEvent"); - } + string eve_type((*in_data)[2]); + transform(eve_type.begin(), eve_type.end(), eve_type.begin(), ::tolower); + Tango::EventType eve; + if (eve_type == "change") + { + eve = Tango::CHANGE_EVENT; + } + else if (eve_type == "periodic") + { + eve = Tango::PERIODIC_EVENT; + } + else if (eve_type == "archive") + { + eve = Tango::ARCHIVE_EVENT; + } + else + { + stringstream ss; + ss << "Event type " << (*in_data)[2] << " not recognized as a valid event type"; + Tango::Except::throw_exception("DevTest_WrongEventType", ss.str(), "DevTest::IOSubscribeEvent"); + } - int eve_id = remote_dev->subscribe_event(att_name,eve,&cb,filters); + int eve_id = remote_dev->subscribe_event(att_name, eve, &cb, filters); - event_atts.insert(make_pair(eve_id,att_name)); + event_atts.insert(make_pair(eve_id, att_name)); - return eve_id; + return eve_id; } void DevTest::IOUnSubscribeEvent(Tango::DevLong &in_data) { - cout << "[DevTest::IOUnSubscribeEvent] received " << endl; + cout << "[DevTest::IOUnSubscribeEvent] received " << endl; - if (in_data != 0) - { - map::iterator ite = event_atts.find(in_data); - if (ite == event_atts.end()) - { - Tango::Except::throw_exception("DevTest_WrongEventID", - "Cant find event id in map", - "DevTest::IOUnSubscribeEvent"); - } - remote_dev->unsubscribe_event(in_data); + if (in_data != 0) + { + map::iterator ite = event_atts.find(in_data); + if (ite == event_atts.end()) + { + Tango::Except::throw_exception("DevTest_WrongEventID", + "Cant find event id in map", + "DevTest::IOUnSubscribeEvent"); + } + remote_dev->unsubscribe_event(in_data); - remote_dev->stop_poll_attribute(ite->second); - } + remote_dev->stop_poll_attribute(ite->second); + } } @@ -398,96 +425,96 @@ void DevTest::IOFillPollBuffAttr() { cout << "[DevTest::IOFillPollBuffAttr] received " << endl; - Tango::AttrHistoryStack ahs; - ahs.length(3); - Tango::Util *tg = Tango::Util::instance(); - Tango::DevString *main_array[3]; - string att_name("Poll_buff"); + Tango::AttrHistoryStack ahs; + ahs.length(3); + Tango::Util *tg = Tango::Util::instance(); + Tango::DevString *main_array[3]; + string att_name("Poll_buff"); - Tango::DevString *array_1 = new Tango::DevString [4]; + Tango::DevString *array_1 = new Tango::DevString[4]; // array_1[0] = CORBA::string_dup("One_1"); // array_1[1] = CORBA::string_dup("Two_1"); // array_1[2] = CORBA::string_dup("Three_1"); // array_1[3] = CORBA::string_dup("Four_1"); - array_1[0] = Tango::string_dup("One_1"); - array_1[1] = Tango::string_dup("Two_1"); - array_1[2] = Tango::string_dup("Three_1"); - array_1[3] = Tango::string_dup("Four_1"); - main_array[0] = array_1; - - Tango::DevString *array_2 = new Tango::DevString [4]; - array_2[0] = CORBA::string_dup("One_2"); - array_2[1] = CORBA::string_dup("Two_2"); - array_2[2] = CORBA::string_dup("Three_2"); - array_2[3] = CORBA::string_dup("Four_2"); - main_array[1] = array_2; - - Tango::DevString *array_3 = new Tango::DevString [4]; - array_3[0] = CORBA::string_dup("One_3"); - array_3[1] = CORBA::string_dup("Two_3"); - array_3[2] = CORBA::string_dup("Three_3"); - array_3[3] = CORBA::string_dup("Four_3"); - main_array[2] = array_3; - - ahs.clear(); - time_t when = time(NULL); - for (int k = 0;k < 3;k++) - { - Tango::TimedAttrData tad(main_array[k],2,2,Tango::ATTR_VALID,true,when); - ahs.push(tad); - } + array_1[0] = Tango::string_dup("One_1"); + array_1[1] = Tango::string_dup("Two_1"); + array_1[2] = Tango::string_dup("Three_1"); + array_1[3] = Tango::string_dup("Four_1"); + main_array[0] = array_1; + + Tango::DevString *array_2 = new Tango::DevString[4]; + array_2[0] = CORBA::string_dup("One_2"); + array_2[1] = CORBA::string_dup("Two_2"); + array_2[2] = CORBA::string_dup("Three_2"); + array_2[3] = CORBA::string_dup("Four_2"); + main_array[1] = array_2; + + Tango::DevString *array_3 = new Tango::DevString[4]; + array_3[0] = CORBA::string_dup("One_3"); + array_3[1] = CORBA::string_dup("Two_3"); + array_3[2] = CORBA::string_dup("Three_3"); + array_3[3] = CORBA::string_dup("Four_3"); + main_array[2] = array_3; + + ahs.clear(); + time_t when = time(NULL); + for (int k = 0; k < 3; k++) + { + Tango::TimedAttrData tad(main_array[k], 2, 2, Tango::ATTR_VALID, true, when); + ahs.push(tad); + } - tg->fill_attr_polling_buffer(this,att_name,ahs); + tg->fill_attr_polling_buffer(this, att_name, ahs); - ahs.clear(); - att_name = "Poll_buffRW"; - when = time(NULL); + ahs.clear(); + att_name = "Poll_buffRW"; + when = time(NULL); - Tango::DevString *rd_array_1 = new Tango::DevString[4]; - Tango::DevString *wr_array_1 = new Tango::DevString[2]; + Tango::DevString *rd_array_1 = new Tango::DevString[4]; + Tango::DevString *wr_array_1 = new Tango::DevString[2]; - rd_array_1[0] = CORBA::string_dup("One_rd_1"); - rd_array_1[1] = CORBA::string_dup("Two_rd_1"); - rd_array_1[2] = CORBA::string_dup("Three_rd_1"); - rd_array_1[3] = CORBA::string_dup("Four_rd_1"); + rd_array_1[0] = CORBA::string_dup("One_rd_1"); + rd_array_1[1] = CORBA::string_dup("Two_rd_1"); + rd_array_1[2] = CORBA::string_dup("Three_rd_1"); + rd_array_1[3] = CORBA::string_dup("Four_rd_1"); - wr_array_1[0] = CORBA::string_dup("One_wr_1"); - wr_array_1[1] = CORBA::string_dup("Two_wr_1"); + wr_array_1[0] = CORBA::string_dup("One_wr_1"); + wr_array_1[1] = CORBA::string_dup("Two_wr_1"); - Tango::TimedAttrData tad_1(rd_array_1,2,2,wr_array_1,2,1,Tango::ATTR_VALID,true,when); - ahs.push(tad_1); + Tango::TimedAttrData tad_1(rd_array_1, 2, 2, wr_array_1, 2, 1, Tango::ATTR_VALID, true, when); + ahs.push(tad_1); - Tango::DevString *rd_array_2 = new Tango::DevString[4]; - Tango::DevString *wr_array_2 = new Tango::DevString[2]; + Tango::DevString *rd_array_2 = new Tango::DevString[4]; + Tango::DevString *wr_array_2 = new Tango::DevString[2]; - rd_array_2[0] = CORBA::string_dup("One_rd_2"); - rd_array_2[1] = CORBA::string_dup("Two_rd_2"); - rd_array_2[2] = CORBA::string_dup("Three_rd_2"); - rd_array_2[3] = CORBA::string_dup("Four_rd_2"); + rd_array_2[0] = CORBA::string_dup("One_rd_2"); + rd_array_2[1] = CORBA::string_dup("Two_rd_2"); + rd_array_2[2] = CORBA::string_dup("Three_rd_2"); + rd_array_2[3] = CORBA::string_dup("Four_rd_2"); - wr_array_2[0] = CORBA::string_dup("One_wr_2"); - wr_array_2[1] = CORBA::string_dup("Two_wr_2"); + wr_array_2[0] = CORBA::string_dup("One_wr_2"); + wr_array_2[1] = CORBA::string_dup("Two_wr_2"); - Tango::TimedAttrData tad_2(rd_array_2,2,2,wr_array_2,2,1,Tango::ATTR_VALID,true,when); - ahs.push(tad_2); + Tango::TimedAttrData tad_2(rd_array_2, 2, 2, wr_array_2, 2, 1, Tango::ATTR_VALID, true, when); + ahs.push(tad_2); - Tango::DevString *rd_array_3 = new Tango::DevString[4]; - Tango::DevString *wr_array_3 = new Tango::DevString[2]; + Tango::DevString *rd_array_3 = new Tango::DevString[4]; + Tango::DevString *wr_array_3 = new Tango::DevString[2]; - rd_array_3[0] = CORBA::string_dup("One_rd_3"); - rd_array_3[1] = CORBA::string_dup("Two_rd_3"); - rd_array_3[2] = CORBA::string_dup("Three_rd_3"); - rd_array_3[3] = CORBA::string_dup("Four_rd_3"); + rd_array_3[0] = CORBA::string_dup("One_rd_3"); + rd_array_3[1] = CORBA::string_dup("Two_rd_3"); + rd_array_3[2] = CORBA::string_dup("Three_rd_3"); + rd_array_3[3] = CORBA::string_dup("Four_rd_3"); - wr_array_3[0] = CORBA::string_dup("One_wr_3"); - wr_array_3[1] = CORBA::string_dup("Two_wr_3"); + wr_array_3[0] = CORBA::string_dup("One_wr_3"); + wr_array_3[1] = CORBA::string_dup("Two_wr_3"); - Tango::TimedAttrData tad_3(rd_array_3,2,2,wr_array_3,2,1,Tango::ATTR_VALID,true,when); - ahs.push(tad_3); + Tango::TimedAttrData tad_3(rd_array_3, 2, 2, wr_array_3, 2, 1, Tango::ATTR_VALID, true, when); + ahs.push(tad_3); - tg->fill_attr_polling_buffer(this,att_name,ahs); + tg->fill_attr_polling_buffer(this, att_name, ahs); - cout << "Attribute Polling buffer filled" << endl; + cout << "Attribute Polling buffer filled" << endl; } void DevTest::IOFillPollBuffEncodedAttr() @@ -495,113 +522,110 @@ void DevTest::IOFillPollBuffEncodedAttr() cout << "[DevTest::IOFillPollBuffEncodedAttr] received " << endl; #ifndef COMPAT - Tango::AttrHistoryStack ahs; - ahs.length(3); - string att_name("Encoded_attr"); - Tango::Util *tg = Tango::Util::instance(); - Tango::DevEncoded the_enc; - Tango::DevEncoded the_enc1; - Tango::DevEncoded the_enc2; - - the_enc.encoded_format = CORBA::string_dup("First value"); - the_enc.encoded_data.length(2); - the_enc.encoded_data[0] = 22; - the_enc.encoded_data[1] = 33; - - time_t when = time(NULL); - Tango::TimedAttrData tad(&the_enc,when); - ahs.push(tad); - - the_enc1.encoded_format = CORBA::string_dup("Second value"); - the_enc1.encoded_data.length(2); - the_enc1.encoded_data[0] = 33; - the_enc1.encoded_data[1] = 44; - - when = time(NULL); - Tango::TimedAttrData tad1(&the_enc1,when); - ahs.push(tad1); - - the_enc2.encoded_format = CORBA::string_dup("Third value"); - the_enc2.encoded_data.length(2); - the_enc2.encoded_data[0] = 44; - the_enc2.encoded_data[1] = 55; - - when = time(NULL); - Tango::TimedAttrData tad2(&the_enc2,when); - ahs.push(tad2); - - tg->fill_attr_polling_buffer(this,att_name,ahs); - cout << "Attribute (DevEncoded data type) polling buffer filled" << endl; + Tango::AttrHistoryStack ahs; + ahs.length(3); + string att_name("Encoded_attr"); + Tango::Util *tg = Tango::Util::instance(); + Tango::DevEncoded the_enc; + Tango::DevEncoded the_enc1; + Tango::DevEncoded the_enc2; + + the_enc.encoded_format = CORBA::string_dup("First value"); + the_enc.encoded_data.length(2); + the_enc.encoded_data[0] = 22; + the_enc.encoded_data[1] = 33; + + time_t when = time(NULL); + Tango::TimedAttrData tad(&the_enc, when); + ahs.push(tad); + + the_enc1.encoded_format = CORBA::string_dup("Second value"); + the_enc1.encoded_data.length(2); + the_enc1.encoded_data[0] = 33; + the_enc1.encoded_data[1] = 44; + + when = time(NULL); + Tango::TimedAttrData tad1(&the_enc1, when); + ahs.push(tad1); + + the_enc2.encoded_format = CORBA::string_dup("Third value"); + the_enc2.encoded_data.length(2); + the_enc2.encoded_data[0] = 44; + the_enc2.encoded_data[1] = 55; + + when = time(NULL); + Tango::TimedAttrData tad2(&the_enc2, when); + ahs.push(tad2); + + tg->fill_attr_polling_buffer(this, att_name, ahs); + cout << "Attribute (DevEncoded data type) polling buffer filled" << endl; #endif } - void DevTest::IOFillPollBuffCmd() { cout << "[DevTest::IOFillPollBuffCmd] received " << endl; - Tango::CmdHistoryStack chs; - chs.length(3); - Tango::Util *tg = Tango::Util::instance(); + Tango::CmdHistoryStack chs; + chs.length(3); + Tango::Util *tg = Tango::Util::instance(); - Tango::DevVarLongArray dvla_array[10]; - string cmd_name("IOArray1"); + Tango::DevVarLongArray dvla_array[10]; + string cmd_name("IOArray1"); - for (int j = 0;j < 10;j++) - { - dvla_array[j].length(3); - dvla_array[j][0] = 10 + j; - dvla_array[j][1] = 11 + j; - dvla_array[j][2] = 12 + j; - } + for (int j = 0; j < 10; j++) + { + dvla_array[j].length(3); + dvla_array[j][0] = 10 + j; + dvla_array[j][1] = 11 + j; + dvla_array[j][2] = 12 + j; + } - chs.clear(); - time_t when = time(NULL); - for (int k = 0;k < 3;k++) - { - Tango::TimedCmdData tad(&dvla_array[k],when); - chs.push(tad); - } + chs.clear(); + time_t when = time(NULL); + for (int k = 0; k < 3; k++) + { + Tango::TimedCmdData tad(&dvla_array[k], when); + chs.push(tad); + } - tg->fill_cmd_polling_buffer(this,cmd_name,chs); + tg->fill_cmd_polling_buffer(this, cmd_name, chs); - cout << "Command Polling buffer filled" << endl; + cout << "Command Polling buffer filled" << endl; } - Tango::DevVarDoubleArray *DevTest::IOTemplInOut(Tango::DevDouble db) { - cout << "[DevTest::IOTemplInOut] received " << db << endl; + cout << "[DevTest::IOTemplInOut] received " << db << endl; - Tango::DevVarDoubleArray *argout; - argout = new Tango::DevVarDoubleArray(); + Tango::DevVarDoubleArray *argout; + argout = new Tango::DevVarDoubleArray(); - argout->length(2); - (*argout)[0] = db; - (*argout)[1] = db * 2; + argout->length(2); + (*argout)[0] = db; + (*argout)[1] = db * 2; - return argout; + return argout; } void DevTest::IOSetWAttrLimit(const Tango::DevVarDoubleArray *in) { - Tango::WAttribute &w_attr = dev_attr->get_w_attr_by_name("Double_attr_w"); - Tango::DevDouble limit = (*in)[1]; - if ((*in)[0] == 0.0) - { - w_attr.set_min_value(limit); - } - else - { - w_attr.set_max_value(limit); - } + Tango::WAttribute &w_attr = dev_attr->get_w_attr_by_name("Double_attr_w"); + Tango::DevDouble limit = (*in)[1]; + if ((*in)[0] == 0.0) + { + w_attr.set_min_value(limit); + } + else + { + w_attr.set_max_value(limit); + } } - void DevTest::push_data_ready(const Tango::DevVarLongStringArray *in) { - cout << "Pushing Data Ready event for attribute " << in->svalue[0].in() << endl; - push_data_ready_event(in->svalue[0].in(),in->lvalue[0]); + cout << "Pushing Data Ready event for attribute " << in->svalue[0].in() << endl; + push_data_ready_event(in->svalue[0].in(), in->lvalue[0]); } Tango::DevVarStringArray *DevTest::IOPollingInDevice() @@ -644,8 +668,8 @@ Tango::DevVarStringArray *DevTest::IOPollingInDevice() // poll_xxx - poll_attribute(att_name,250); - poll_command(cmd_name,250); + poll_attribute(att_name, 250); + poll_command(cmd_name, 250); Tango_sleep(1); @@ -731,9 +755,9 @@ void DevTest::IOSophisticatedPollInDevice() // poll the 3 atts - poll_attribute(att1_name,500); - poll_attribute(att2_name,250); - poll_attribute(att3_name,250); + poll_attribute(att1_name, 500); + poll_attribute(att2_name, 250); + poll_attribute(att3_name, 250); } Tango::DevVarStringArray *DevTest::IOGetPollMess() @@ -741,7 +765,7 @@ Tango::DevVarStringArray *DevTest::IOGetPollMess() Tango::DevVarStringArray *dvsa = new Tango::DevVarStringArray(); dvsa->length(poll_messages.size()); - for (size_t loop = 0;loop < poll_messages.size();loop++) + for (size_t loop = 0; loop < poll_messages.size(); loop++) (*dvsa)[loop] = Tango::string_dup(poll_messages[loop].c_str()); poll_messages.clear(); @@ -751,26 +775,26 @@ Tango::DevVarStringArray *DevTest::IOGetPollMess() void DevTest::set_enum_labels() { - Tango::Attribute &att = (get_device_attr())->get_attr_by_name("DynEnum_attr"); - Tango::MultiAttrProp multi_prop; - att.get_properties(multi_prop); + Tango::Attribute &att = (get_device_attr())->get_attr_by_name("DynEnum_attr"); + Tango::MultiAttrProp multi_prop; + att.get_properties(multi_prop); - vector v_s; - v_s.push_back("Zero"); - v_s.push_back("One"); - v_s.push_back("Two"); - v_s.push_back("Three"); - multi_prop.enum_labels = v_s; - att.set_properties(multi_prop); + vector v_s; + v_s.push_back("Zero"); + v_s.push_back("One"); + v_s.push_back("Two"); + v_s.push_back("Three"); + multi_prop.enum_labels = v_s; + att.set_properties(multi_prop); } void DevTest::add_enum_label(Tango::DevString new_label) { - Tango::Attribute &att = (get_device_attr())->get_attr_by_name("DynEnum_attr"); - Tango::MultiAttrProp multi_prop; - att.get_properties(multi_prop); - multi_prop.enum_labels.push_back(new_label); - att.set_properties(multi_prop); + Tango::Attribute &att = (get_device_attr())->get_attr_by_name("DynEnum_attr"); + Tango::MultiAttrProp multi_prop; + att.get_properties(multi_prop); + multi_prop.enum_labels.push_back(new_label); + att.set_properties(multi_prop); } //+---------------------------------------------------------------------------- @@ -785,14 +809,14 @@ void DevTest::add_enum_label(Tango::DevString new_label) void DevTest::signal_handler(long signo) { - cout << "[Device signal handler] received signal number " << signo; - cout << " for device " << device_name << endl; + cout << "[Device signal handler] received signal number " << signo; + cout << " for device " << device_name << endl; - DEBUG_STREAM << "[Device signal handler] received signal number " - << signo - << " for device " - << device_name - << endl; + DEBUG_STREAM << "[Device signal handler] received signal number " + << signo + << " for device " + << device_name + << endl; } @@ -808,442 +832,466 @@ void DevTest::write_Short_attr_w(Tango::WAttribute &att) { // cout << "In write_Short_attr_w for attribute " << att.get_name() << endl; - Tango::DevShort sh; - att.get_write_value(sh); + Tango::DevShort sh; + att.get_write_value(sh); // cout << "Attribute value = " << sh << endl; - if (Short_attr_w_except == true) - Tango::Except::throw_exception("Aaaa","Bbbb","Cccc"); + if (Short_attr_w_except == true) + { + Tango::Except::throw_exception("Aaaa", "Bbbb", "Cccc"); + } } void DevTest::write_Short_attr_w2(Tango::WAttribute &att) { - cout << "In write_Short_attr_w2 for attribute " << att.get_name() << endl; + cout << "In write_Short_attr_w2 for attribute " << att.get_name() << endl; - Tango::DevShort sh; - att.get_write_value(sh); - cout << "Attribute value = " << sh << endl; + Tango::DevShort sh; + att.get_write_value(sh); + cout << "Attribute value = " << sh << endl; } void DevTest::write_Long_attr_w(Tango::WAttribute &att) { - cout << "In write_Long_attr_w for attribute " << att.get_name() << endl; + cout << "In write_Long_attr_w for attribute " << att.get_name() << endl; - Tango::DevLong lg; - att.get_write_value(lg); - cout << "Attribute value = " << lg << endl; + Tango::DevLong lg; + att.get_write_value(lg); + cout << "Attribute value = " << lg << endl; } void DevTest::write_Double_attr_w(Tango::WAttribute &att) { - cout << "In write_Double_attr_w for attribute " << att.get_name() << endl; + cout << "In write_Double_attr_w for attribute " << att.get_name() << endl; - Tango::DevDouble db; - att.get_write_value(db); - cout << "Attribute value = " << db << endl; + Tango::DevDouble db; + att.get_write_value(db); + cout << "Attribute value = " << db << endl; } void DevTest::write_String_attr_w(Tango::WAttribute &att) { // cout << "In write_String_attr_w for attribute " << att.get_name() << endl; - Tango::DevString str; - att.get_write_value(str); + Tango::DevString str; + att.get_write_value(str); // cout << "Attribute value = " << str << endl; } void DevTest::write_String_attr_w2(Tango::WAttribute &att) { - cout << "In write_String_attr_w2 for attribute " << att.get_name() << endl; + cout << "In write_String_attr_w2 for attribute " << att.get_name() << endl; - Tango::DevString str; - att.get_write_value(str); - cout << "Attribute value = " << str << endl; + Tango::DevString str; + att.get_write_value(str); + cout << "Attribute value = " << str << endl; } - void DevTest::write_attr_asyn_write(Tango::WAttribute &att) { - cout << "In write_attr_asyn_write for attribute " << att.get_name() << endl; + cout << "In write_attr_asyn_write for attribute " << att.get_name() << endl; - Tango::DevLong lg; - att.get_write_value(lg); - cout << "Attribute value = " << lg << endl; - Tango_sleep(2); + Tango::DevLong lg; + att.get_write_value(lg); + cout << "Attribute value = " << lg << endl; + Tango_sleep(2); } void DevTest::write_attr_asyn_write_to(Tango::WAttribute &att) { - cout << "In write_attr_asyn_write_to for attribute " << att.get_name() << endl; + cout << "In write_attr_asyn_write_to for attribute " << att.get_name() << endl; - Tango::DevLong lg; - att.get_write_value(lg); - cout << "Attribute value = " << lg << endl; - Tango_sleep(4); + Tango::DevLong lg; + att.get_write_value(lg); + cout << "Attribute value = " << lg << endl; + Tango_sleep(4); } void DevTest::write_attr_asyn_write_except(Tango::WAttribute &att) { - cout << "In write_attr_asyn_write_except for attribute " << att.get_name() << endl; + cout << "In write_attr_asyn_write_except for attribute " << att.get_name() << endl; - Tango::DevLong lg; - att.get_write_value(lg); - cout << "Attribute value = " << lg << endl; - Tango_sleep(2); - Tango::Except::throw_exception((const char *)"aaa", - (const char *)"This is a test", - (const char *)"DevTest::write_attr_hardware"); + Tango::DevLong lg; + att.get_write_value(lg); + cout << "Attribute value = " << lg << endl; + Tango_sleep(2); + Tango::Except::throw_exception((const char *) "aaa", + (const char *) "This is a test", + (const char *) "DevTest::write_attr_hardware"); } void DevTest::write_String_spec_attr_w(Tango::WAttribute &att) { - cout << "In write_String_spec_attr_w for attribute " << att.get_name() << endl; + cout << "In write_String_spec_attr_w for attribute " << att.get_name() << endl; - const Tango::ConstDevString *ptr; - att.get_write_value(ptr); - long nb_str = att.get_write_value_length(); - cout << ", Elt nb = " << nb_str << endl; - for (int k = 0;k < nb_str;k++) - cout << ptr[k] << endl; + const Tango::ConstDevString *ptr; + att.get_write_value(ptr); + long nb_str = att.get_write_value_length(); + cout << ", Elt nb = " << nb_str << endl; + for (int k = 0; k < nb_str; k++) + { + cout << ptr[k] << endl; + } } void DevTest::write_Short_attr_rw(Tango::WAttribute &att) { - cout << "In write_Short_attr_rw for attribute " << att.get_name() << endl; - att.get_write_value(attr_short_rw); + cout << "In write_Short_attr_rw for attribute " << att.get_name() << endl; + att.get_write_value(attr_short_rw); } void DevTest::write_Long64_attr_rw(Tango::WAttribute &att) { - cout << "In write_Long64_attr_rw for attribute " << att.get_name() << endl; - att.get_write_value(attr_long64_rw); + cout << "In write_Long64_attr_rw for attribute " << att.get_name() << endl; + att.get_write_value(attr_long64_rw); } void DevTest::write_ULong_attr_rw(Tango::WAttribute &att) { - cout << "In write_ULong_attr_rw for attribute " << att.get_name() << endl; - att.get_write_value(attr_ulong_rw); + cout << "In write_ULong_attr_rw for attribute " << att.get_name() << endl; + att.get_write_value(attr_ulong_rw); - if (attr_ulong_rw > 1000) - att.set_write_value((Tango::DevULong)1111); + if (attr_ulong_rw > 1000) + { + att.set_write_value((Tango::DevULong) 1111); + } } void DevTest::write_ULong64_attr_rw(Tango::WAttribute &att) { - cout << "In write_ULong64_attr_rw for attribute " << att.get_name() << endl; - att.get_write_value(attr_ulong64_rw); + cout << "In write_ULong64_attr_rw for attribute " << att.get_name() << endl; + att.get_write_value(attr_ulong64_rw); } void DevTest::write_State_attr_rw(Tango::WAttribute &att) { - cout << "In write_State_attr_rw for attribute " << att.get_name() << endl; - att.get_write_value(attr_state_rw); + cout << "In write_State_attr_rw for attribute " << att.get_name() << endl; + att.get_write_value(attr_state_rw); } void DevTest::write_Float_attr_w(Tango::WAttribute &att) { - cout << "In write_Float_attr_w for attribute " << att.get_name() << endl; + cout << "In write_Float_attr_w for attribute " << att.get_name() << endl; - Tango::DevFloat fl; - att.get_write_value(fl); - cout << "Attribute value = " << fl << endl; + Tango::DevFloat fl; + att.get_write_value(fl); + cout << "Attribute value = " << fl << endl; } void DevTest::write_Boolean_attr_w(Tango::WAttribute &att) { - cout << "In write_Boolean_attr_w for attribute " << att.get_name() << endl; + cout << "In write_Boolean_attr_w for attribute " << att.get_name() << endl; - Tango::DevBoolean bo; - att.get_write_value(bo); - cout << "Attribute value = " << bo << endl; + Tango::DevBoolean bo; + att.get_write_value(bo); + cout << "Attribute value = " << bo << endl; } void DevTest::write_UShort_attr_w(Tango::WAttribute &att) { - cout << "In write_UShort_attr_w for attribute " << att.get_name() << endl; + cout << "In write_UShort_attr_w for attribute " << att.get_name() << endl; - Tango::DevUShort ush; - att.get_write_value(ush); - cout << "Attribute value = " << ush << endl; + Tango::DevUShort ush; + att.get_write_value(ush); + cout << "Attribute value = " << ush << endl; } void DevTest::write_UChar_attr_w(Tango::WAttribute &att) { - cout << "In write_UChar_attr_w for attribute " << att.get_name() << endl; + cout << "In write_UChar_attr_w for attribute " << att.get_name() << endl; - Tango::DevUChar uch; - att.get_write_value(uch); - cout << "Attribute value = " << uch << endl; + Tango::DevUChar uch; + att.get_write_value(uch); + cout << "Attribute value = " << uch << endl; } void DevTest::write_Float_spec_attr_w(Tango::WAttribute &att) { - cout << "In write_Float_spec_attr_w for attribute " << att.get_name() << endl; + cout << "In write_Float_spec_attr_w for attribute " << att.get_name() << endl; - const Tango::DevFloat *fl; - att.get_write_value(fl); - long nb_fl = att.get_write_value_length(); - cout << ", Elt nb = " << nb_fl << endl; - for (int k = 0;k < nb_fl;k++) - cout << fl[k] << endl; + const Tango::DevFloat *fl; + att.get_write_value(fl); + long nb_fl = att.get_write_value_length(); + cout << ", Elt nb = " << nb_fl << endl; + for (int k = 0; k < nb_fl; k++) + { + cout << fl[k] << endl; + } } void DevTest::write_Boolean_spec_attr_w(Tango::WAttribute &att) { - cout << "In write_Boolean_spec_attr_w for attribute " << att.get_name() << endl; + cout << "In write_Boolean_spec_attr_w for attribute " << att.get_name() << endl; - const Tango::DevBoolean *bo; - att.get_write_value(bo); - long nb_bo = att.get_write_value_length(); - cout << ", Elt nb = " << nb_bo << endl; - for (int k = 0;k < nb_bo;k++) - cout << bo[k] << endl; + const Tango::DevBoolean *bo; + att.get_write_value(bo); + long nb_bo = att.get_write_value_length(); + cout << ", Elt nb = " << nb_bo << endl; + for (int k = 0; k < nb_bo; k++) + { + cout << bo[k] << endl; + } } void DevTest::write_UShort_spec_attr_w(Tango::WAttribute &att) { - cout << "In write_UShort_spec_attr_w for attribute " << att.get_name() << endl; + cout << "In write_UShort_spec_attr_w for attribute " << att.get_name() << endl; - const Tango::DevUShort *ush; - att.get_write_value(ush); - long nb_ush = att.get_write_value_length(); - cout << ", Elt nb = " << nb_ush << endl; - for (int k = 0;k < nb_ush;k++) - cout << ush[k] << endl; + const Tango::DevUShort *ush; + att.get_write_value(ush); + long nb_ush = att.get_write_value_length(); + cout << ", Elt nb = " << nb_ush << endl; + for (int k = 0; k < nb_ush; k++) + { + cout << ush[k] << endl; + } } void DevTest::write_UChar_spec_attr_w(Tango::WAttribute &att) { - cout << "In write_UChar_spec_attr_w for attribute " << att.get_name() << endl; + cout << "In write_UChar_spec_attr_w for attribute " << att.get_name() << endl; - const Tango::DevUChar *uch; - att.get_write_value(uch); - long nb_uch = att.get_write_value_length(); - cout << ", Elt nb = " << nb_uch << endl; + const Tango::DevUChar *uch; + att.get_write_value(uch); + long nb_uch = att.get_write_value_length(); + cout << ", Elt nb = " << nb_uch << endl; // for (int k = 0;k < nb_uch;k++) // cout << uch[k] << endl; } void DevTest::write_Float_ima_attr_w(Tango::WAttribute &att) { - cout << "In write_Float_ima_attr_w for attribute " << att.get_name() << endl; + cout << "In write_Float_ima_attr_w for attribute " << att.get_name() << endl; - const Tango::DevFloat *fl; - att.get_write_value(fl); - long nb_fl = att.get_write_value_length(); - cout << ", Elt nb = " << nb_fl << endl; + const Tango::DevFloat *fl; + att.get_write_value(fl); + long nb_fl = att.get_write_value_length(); + cout << ", Elt nb = " << nb_fl << endl; // for (int k = 0;k < nb_fl;k++) // cout << fl[k] << endl; } void DevTest::write_UShort_ima_attr_w(Tango::WAttribute &att) { - cout << "In write_UShort_ima_attr_w for attribute " << att.get_name() << endl; + cout << "In write_UShort_ima_attr_w for attribute " << att.get_name() << endl; - const Tango::DevUShort *ush; - att.get_write_value(ush); - long nb_ush = att.get_write_value_length(); - cout << ", Elt nb = " << nb_ush << endl; + const Tango::DevUShort *ush; + att.get_write_value(ush); + long nb_ush = att.get_write_value_length(); + cout << ", Elt nb = " << nb_ush << endl; // for (int k = 0;k < nb_ush;k++) // cout << ush[k] << endl; } void DevTest::write_Float_spec_attr_rw(Tango::WAttribute &att) { - cout << "In write_Float_spec_attr_rw for attribute " << att.get_name() << endl; + cout << "In write_Float_spec_attr_rw for attribute " << att.get_name() << endl; - const Tango::DevFloat *fl; - att.get_write_value(fl); - long nb_fl = att.get_write_value_length(); - cout << ", Elt nb = " << nb_fl << endl; + const Tango::DevFloat *fl; + att.get_write_value(fl); + long nb_fl = att.get_write_value_length(); + cout << ", Elt nb = " << nb_fl << endl; // for (int k = 0;k < nb_fl;k++) // cout << fl[k] << endl; } void DevTest::write_Long_spec_attr_rw(Tango::WAttribute &att) { - cout << "In write_Long_spec_attr_rw for attribute " << att.get_name() << endl; + cout << "In write_Long_spec_attr_rw for attribute " << att.get_name() << endl; - const Tango::DevLong *fl; - att.get_write_value(fl); - long nb_fl = att.get_write_value_length(); - cout << ", Elt nb = " << nb_fl << endl; - for (int k = 0;k < nb_fl;k++) - cout << fl[k] << endl; + const Tango::DevLong *fl; + att.get_write_value(fl); + long nb_fl = att.get_write_value_length(); + cout << ", Elt nb = " << nb_fl << endl; + for (int k = 0; k < nb_fl; k++) + { + cout << fl[k] << endl; + } } void DevTest::write_UChar_spec_attr_rw(Tango::WAttribute &att) { - cout << "In write_UShort_spec_attr_rw for attribute " << att.get_name() << endl; + cout << "In write_UShort_spec_attr_rw for attribute " << att.get_name() << endl; - const Tango::DevUChar *uch; - att.get_write_value(uch); - long nb_uch = att.get_write_value_length(); - cout << ", Elt nb = " << nb_uch << endl; + const Tango::DevUChar *uch; + att.get_write_value(uch); + long nb_uch = att.get_write_value_length(); + cout << ", Elt nb = " << nb_uch << endl; // for (int k = 0;k < nb_uch;k++) // cout << uch[k] << endl; } void DevTest::write_Boolean_ima_attr_rw(Tango::WAttribute &att) { - cout << "In write_Boolean_ima_attr_rw for attribute " << att.get_name() << endl; + cout << "In write_Boolean_ima_attr_rw for attribute " << att.get_name() << endl; - const Tango::DevBoolean *bo; - att.get_write_value(bo); - long nb_bo = att.get_write_value_length(); - cout << ", Elt nb = " << nb_bo << endl; + const Tango::DevBoolean *bo; + att.get_write_value(bo); + long nb_bo = att.get_write_value_length(); + cout << ", Elt nb = " << nb_bo << endl; // for (int k = 0;k < nb_bo;k++) // cout << bo[k] << endl; } void DevTest::write_UShort_ima_attr_rw(Tango::WAttribute &att) { - cout << "In write_UShort_ima_attr_rw for attribute " << att.get_name() << endl; + cout << "In write_UShort_ima_attr_rw for attribute " << att.get_name() << endl; - const Tango::DevUShort *ush; - att.get_write_value(ush); - long nb_ush = att.get_write_value_length(); - cout << ", Elt nb = " << nb_ush << endl; + const Tango::DevUShort *ush; + att.get_write_value(ush); + long nb_ush = att.get_write_value_length(); + cout << ", Elt nb = " << nb_ush << endl; // for (int k = 0;k < nb_ush;k++) // cout << ush[k] << endl; } - void DevTest::write_slow_actuator(Tango::WAttribute &att) { - cout << "In write_slow_actuator for attribute " << att.get_name() << endl; + cout << "In write_slow_actuator for attribute " << att.get_name() << endl; - att.get_write_value(slow_actua); + att.get_write_value(slow_actua); #ifdef WIN32 - struct _timeb before_win; - _ftime(&before_win); - slow_actua_write.tv_sec = (unsigned long)before_win.time; - slow_actua_write.tv_usec = (long)before_win.millitm * 1000; + struct _timeb before_win; + _ftime(&before_win); + slow_actua_write.tv_sec = (unsigned long)before_win.time; + slow_actua_write.tv_usec = (long)before_win.millitm * 1000; #else - gettimeofday(&slow_actua_write,NULL); + gettimeofday(&slow_actua_write, NULL); #endif } - void DevTest::write_fast_actuator(Tango::WAttribute &att) { - cout << "In write_fast_actuator for attribute " << att.get_name() << endl; + cout << "In write_fast_actuator for attribute " << att.get_name() << endl; - att.get_write_value(fast_actua); + att.get_write_value(fast_actua); - att.set_value(&fast_actua); - att.set_quality(Tango::ATTR_CHANGING, true); - att.set_value(&fast_actua); - att.set_quality(Tango::ATTR_VALID, true); + att.set_value(&fast_actua); + att.set_quality(Tango::ATTR_CHANGING, true); + att.set_value(&fast_actua); + att.set_quality(Tango::ATTR_VALID, true); } - void DevTest::write_Long64_spec_attr_rw(Tango::WAttribute &att) { - cout << "In write_Long64_spec_attr_rw for attribute " << att.get_name() << endl; - const Tango::DevLong64 *lg64; - long nb_data = att.get_write_value_length(); - att.get_write_value(lg64); - cout << "Received " << nb_data << " for attribute " << att.get_name() << endl; + cout << "In write_Long64_spec_attr_rw for attribute " << att.get_name() << endl; + const Tango::DevLong64 *lg64; + long nb_data = att.get_write_value_length(); + att.get_write_value(lg64); + cout << "Received " << nb_data << " for attribute " << att.get_name() << endl; } void DevTest::write_ULong_spec_attr_rw(Tango::WAttribute &att) { - cout << "In write_ULong_spec_attr_rw for attribute " << att.get_name() << endl; - const Tango::DevULong *ulg; - long nb_data = att.get_write_value_length(); - att.get_write_value(ulg); - cout << "Received " << nb_data << " for attribute " << att.get_name() << endl; + cout << "In write_ULong_spec_attr_rw for attribute " << att.get_name() << endl; + const Tango::DevULong *ulg; + long nb_data = att.get_write_value_length(); + att.get_write_value(ulg); + cout << "Received " << nb_data << " for attribute " << att.get_name() << endl; } void DevTest::write_ULong64_spec_attr_rw(Tango::WAttribute &att) { - cout << "In write_ULong64_spec_attr_rw for attribute " << att.get_name() << endl; - const Tango::DevULong64 *ulg64; - long nb_data = att.get_write_value_length(); - att.get_write_value(ulg64); - cout << "Received " << nb_data << " for attribute " << att.get_name() << endl; + cout << "In write_ULong64_spec_attr_rw for attribute " << att.get_name() << endl; + const Tango::DevULong64 *ulg64; + long nb_data = att.get_write_value_length(); + att.get_write_value(ulg64); + cout << "Received " << nb_data << " for attribute " << att.get_name() << endl; } void DevTest::write_State_spec_attr_rw(Tango::WAttribute &att) { - cout << "In write_State_aspec_ttr_rw for attribute " << att.get_name() << endl; - const Tango::DevState *sta; - long nb_data = att.get_write_value_length(); - att.get_write_value(sta); - cout << "Received " << nb_data << " for attribute " << att.get_name() << endl; + cout << "In write_State_aspec_ttr_rw for attribute " << att.get_name() << endl; + const Tango::DevState *sta; + long nb_data = att.get_write_value_length(); + att.get_write_value(sta); + cout << "Received " << nb_data << " for attribute " << att.get_name() << endl; } void DevTest::write_Encoded_attr_rw(Tango::WAttribute &att) { - cout << "In write_Encoded_attr_rw for attribute " << att.get_name() << endl; + cout << "In write_Encoded_attr_rw for attribute " << att.get_name() << endl; #ifndef COMPAT - const Tango::DevEncoded *enc; - att.get_write_value(enc); - cout << "\tReceived string = " << enc->encoded_format << endl; - cout << "\tReceived data nb = " << enc->encoded_data.length() << endl; - for (unsigned int i = 0;i < enc->encoded_data.length();i++) - cout << "\t\tdata[" << i << "] = " << (unsigned long)enc->encoded_data[i] << endl; + const Tango::DevEncoded *enc; + att.get_write_value(enc); + cout << "\tReceived string = " << enc->encoded_format << endl; + cout << "\tReceived data nb = " << enc->encoded_data.length() << endl; + for (unsigned int i = 0; i < enc->encoded_data.length(); i++) + { + cout << "\t\tdata[" << i << "] = " << (unsigned long) enc->encoded_data[i] << endl; + } #endif } void DevTest::write_Poll_buffRW(Tango::WAttribute &att) { - cout << "In write_Poll_buffRW for attribute " << att.get_name() << endl; + cout << "In write_Poll_buffRW for attribute " << att.get_name() << endl; } void DevTest::write_Def_attr(Tango::WAttribute &att) { - cout << "In write_Def_attr for attribute " << att.get_name() << endl; + cout << "In write_Def_attr for attribute " << att.get_name() << endl; } void DevTest::write_DefUser_attr(Tango::WAttribute &att) { - cout << "In write_DefUser_attr for attribute " << att.get_name() << endl; + cout << "In write_DefUser_attr for attribute " << att.get_name() << endl; } void DevTest::write_DefClass_attr(Tango::WAttribute &att) { - cout << "In write_DefClass_attr for attribute " << att.get_name() << endl; + cout << "In write_DefClass_attr for attribute " << att.get_name() << endl; } void DevTest::write_DefClassUser_attr(Tango::WAttribute &att) { - cout << "In write_DefClassUser_attr for attribute " << att.get_name() << endl; + cout << "In write_DefClassUser_attr for attribute " << att.get_name() << endl; } void DevTest::write_Enum_attr(Tango::WAttribute &att) { - cout << "In write_Enum_attr for attribute " << att.get_name() << endl; + cout << "In write_Enum_attr for attribute " << att.get_name() << endl; } void DevTest::write_Enum_spec_attr_rw(Tango::WAttribute &att) { - cout << "In write_Enum_spec_attr_rw for attribute " << att.get_name() << endl; + cout << "In write_Enum_spec_attr_rw for attribute " << att.get_name() << endl; } void DevTest::write_attr_hardware(vector &att_idx) { - switch (wattr_throw) - { - case 0: - default: - break; - - case 1: - Tango::Except::throw_exception("DevTest_WriteAttrHardware","DevFailed from write_attr_hardware","DevTest::write_attr_hardware"); - break; - - case 2: - if (att_idx.empty() == false) - Tango::Except::throw_named_exception(get_device_attr()->get_attr_by_ind(att_idx[0]).get_name().c_str(), - "DevTest_WriteAttrHardware","aaa","DevTest::write_attr_hardware"); - break; - - case 3: - if (att_idx.size() >= 2) - Tango::Except::throw_named_exception(this,att_idx[2],"DevTest_WriteAttrHardware","bbb","DevTest::write_attr_hardware"); - break; - } + switch (wattr_throw) + { + case 0: + default: + break; + + case 1: + Tango::Except::throw_exception("DevTest_WriteAttrHardware", + "DevFailed from write_attr_hardware", + "DevTest::write_attr_hardware"); + break; + + case 2: + if (att_idx.empty() == false) + { + Tango::Except::throw_named_exception(get_device_attr()->get_attr_by_ind(att_idx[0]).get_name().c_str(), + "DevTest_WriteAttrHardware", + "aaa", + "DevTest::write_attr_hardware"); + } + break; + + case 3: + if (att_idx.size() >= 2) + { + Tango::Except::throw_named_exception(this, + att_idx[2], + "DevTest_WriteAttrHardware", + "bbb", + "DevTest::write_attr_hardware"); + } + break; + } } //+---------------------------------------------------------------------------- @@ -1256,686 +1304,697 @@ void DevTest::write_attr_hardware(vector &att_idx) void DevTest::read_Short_attr(Tango::Attribute &att) { - cout << "[DevTest::read_attr] attribute name Short_attr" << endl; - attr_short = 12; - if (Short_attr_except == false) - { - att.set_value(&attr_short); - } - else - { - Tango::Except::throw_exception((const char *)"aaa", - (const char *)"This is a test", - (const char *)"DevTest::read_attr"); - } + cout << "[DevTest::read_attr] attribute name Short_attr" << endl; + attr_short = 12; + if (Short_attr_except == false) + { + att.set_value(&attr_short); + } + else + { + Tango::Except::throw_exception((const char *) "aaa", + (const char *) "This is a test", + (const char *) "DevTest::read_attr"); + } } void DevTest::read_Long_attr(Tango::Attribute &att) { - cout << "[DevTest::read_attr] attribute name Long_attr" << endl; - att.set_value(&attr_long); + cout << "[DevTest::read_attr] attribute name Long_attr" << endl; + att.set_value(&attr_long); } void DevTest::read_Long64_attr(Tango::Attribute &att) { - cout << "[DevTest::read_attr] attribute name Long64_attr" << endl; - attr_long64 = 300; - att.set_value(&attr_long64); + cout << "[DevTest::read_attr] attribute name Long64_attr" << endl; + attr_long64 = 300; + att.set_value(&attr_long64); } void DevTest::read_Double_attr(Tango::Attribute &att) { - cout << "[DevTest::read_attr] attribute name Double_attr" << endl; - attr_double = 3.2; - att.set_value(&attr_double); + cout << "[DevTest::read_attr] attribute name Double_attr" << endl; + attr_double = 3.2; + att.set_value(&attr_double); } void DevTest::read_String_attr(Tango::Attribute &att) { - static Tango::DevString s = NULL; + static Tango::DevString s = NULL; - cout << "[DevTest::read_attr] attribute name String_attr" << endl; - if (s == NULL) - s = CORBA::string_dup("test_string"); + cout << "[DevTest::read_attr] attribute name String_attr" << endl; + if (s == NULL) + { + s = CORBA::string_dup("test_string"); + } - att.set_value(&s); + att.set_value(&s); } void DevTest::read_Short_spec_attr(Tango::Attribute &att) { - static short attr_short_array[20]; + static short attr_short_array[20]; - cout << "[DevTest::read_attr] attribute name Short_spec_attr" << endl; - attr_short_array[0] = 10; - attr_short_array[1] = 20; - attr_short_array[2] = 30; - attr_short_array[3] = 40; + cout << "[DevTest::read_attr] attribute name Short_spec_attr" << endl; + attr_short_array[0] = 10; + attr_short_array[1] = 20; + attr_short_array[2] = 30; + attr_short_array[3] = 40; - att.set_value(attr_short_array, 4); + att.set_value(attr_short_array, 4); } void DevTest::read_Long_spec_attr(Tango::Attribute &att) { - cout << "[DevTest::read_attr] attribute name Long_spec_attr" << endl; - attr_long_array[0] = 0; - attr_long_array[1] = 1; - attr_long_array[2] = 2; - attr_long_array[3] = 3; - attr_long_array[4] = 4; - attr_long_array[5] = 5; - attr_long_array[6] = 6; - attr_long_array[7] = 7; - attr_long_array[8] = 8; - attr_long_array[9] = 9; + cout << "[DevTest::read_attr] attribute name Long_spec_attr" << endl; + attr_long_array[0] = 0; + attr_long_array[1] = 1; + attr_long_array[2] = 2; + attr_long_array[3] = 3; + attr_long_array[4] = 4; + attr_long_array[5] = 5; + attr_long_array[6] = 6; + attr_long_array[7] = 7; + attr_long_array[8] = 8; + attr_long_array[9] = 9; - att.set_value(attr_long_array, 10); + att.set_value(attr_long_array, 10); } void DevTest::read_Double_spec_attr(Tango::Attribute &att) { - cout << "[DevTest::read_attr] attribute name Double_spec_attr" << endl; - attr_db_array[0] = 1.11; - attr_db_array[1] = 2.22; + cout << "[DevTest::read_attr] attribute name Double_spec_attr" << endl; + attr_db_array[0] = 1.11; + attr_db_array[1] = 2.22; - att.set_value(attr_db_array, 2); + att.set_value(attr_db_array, 2); } void DevTest::read_String_spec_attr(Tango::Attribute &att) { - cout << "[DevTest::read_attr] attribute name String_spec_attr" << endl; - attr_str_array[0] = (char *)"Hello world"; - attr_str_array[1] = (char *)"Hello universe"; + cout << "[DevTest::read_attr] attribute name String_spec_attr" << endl; + attr_str_array[0] = (char *) "Hello world"; + attr_str_array[1] = (char *) "Hello universe"; - att.set_value(attr_str_array, 2); + att.set_value(attr_str_array, 2); } void DevTest::read_Short_ima_attr(Tango::Attribute &att) { - static short attr_short_array_1[20]; + static short attr_short_array_1[20]; - cout << "[DevTest::read_attr] attribute name Short_ima_attr" << endl; - attr_short_array_1[0] = 40; - attr_short_array_1[1] = 60; - attr_short_array_1[2] = 80; - attr_short_array_1[3] = 100; + cout << "[DevTest::read_attr] attribute name Short_ima_attr" << endl; + attr_short_array_1[0] = 40; + attr_short_array_1[1] = 60; + attr_short_array_1[2] = 80; + attr_short_array_1[3] = 100; - att.set_value(attr_short_array_1,2,2); + att.set_value(attr_short_array_1, 2, 2); } void DevTest::read_Long_ima_attr(Tango::Attribute &att) { - cout << "[DevTest::read_attr] attribute name Long_ima_attr" << endl; - attr_long_array[0] = 0; - attr_long_array[1] = 1; - attr_long_array[2] = 2; - attr_long_array[3] = 3; - attr_long_array[4] = 4; - attr_long_array[5] = 5; + cout << "[DevTest::read_attr] attribute name Long_ima_attr" << endl; + attr_long_array[0] = 0; + attr_long_array[1] = 1; + attr_long_array[2] = 2; + attr_long_array[3] = 3; + attr_long_array[4] = 4; + attr_long_array[5] = 5; - att.set_value(attr_long_array,3,2); + att.set_value(attr_long_array, 3, 2); } void DevTest::read_Double_ima_attr(Tango::Attribute &att) { - cout << "[DevTest::read_attr] attribute name Double_ima_attr" << endl; - attr_db_array[0] = 5.55; - attr_db_array[1] = 6.66; + cout << "[DevTest::read_attr] attribute name Double_ima_attr" << endl; + attr_db_array[0] = 5.55; + attr_db_array[1] = 6.66; - att.set_value(attr_db_array,2,1); + att.set_value(attr_db_array, 2, 1); } void DevTest::read_String_ima_attr(Tango::Attribute &att) { - cout << "[DevTest::read_attr] attribute name String_ima_attr" << endl; - attr_str_array[0] = (char *)"Hello milky way"; - attr_str_array[1] = (char *)"Hello moon"; + cout << "[DevTest::read_attr] attribute name String_ima_attr" << endl; + attr_str_array[0] = (char *) "Hello milky way"; + attr_str_array[1] = (char *) "Hello moon"; - att.set_value(attr_str_array,1,2); + att.set_value(attr_str_array, 1, 2); } void DevTest::read_attr_no_data(Tango::Attribute &att) { - cout << "[DevTest::read_attr] attribute name attr_no_data" << endl; - att.set_quality(Tango::ATTR_VALID); + cout << "[DevTest::read_attr] attribute name attr_no_data" << endl; + att.set_quality(Tango::ATTR_VALID); } void DevTest::read_attr_wrong_type(Tango::Attribute &att) { - cout << "[DevTest::read_attr] attribute name attr_wrong_type" << endl; - attr_long = 1246; - att.set_value(&attr_long); + cout << "[DevTest::read_attr] attribute name attr_wrong_type" << endl; + attr_long = 1246; + att.set_value(&attr_long); } void DevTest::read_attr_wrong_size(Tango::Attribute &att) { - cout << "[DevTest::read_attr] attribute name attr_wrong_size" << endl; - att.set_value(&attr_long,1000,1000); + cout << "[DevTest::read_attr] attribute name attr_wrong_size" << endl; + att.set_value(&attr_long, 1000, 1000); } void DevTest::read_attr_no_alarm(Tango::Attribute &att) { - cout << "[DevTest::read_attr] attribute name attr_no_alarm" << endl; - attr_long = 1246; - att.check_alarm(); - att.set_value(&attr_long); + cout << "[DevTest::read_attr] attribute name attr_no_alarm" << endl; + attr_long = 1246; + att.check_alarm(); + att.set_value(&attr_long); } void DevTest::read_Short_attr_with_w(Tango::Attribute &att) { - cout << "[DevTest::read_attr] attribute name Short_attr_with_w" << endl; - attr_short = 44; - att.set_value(&attr_short); + cout << "[DevTest::read_attr] attribute name Short_attr_with_w" << endl; + attr_short = 44; + att.set_value(&attr_short); } void DevTest::read_Long_attr_with_w(Tango::Attribute &att) { - cout << "[DevTest::read_attr] attribute name Long_attr_with_w" << endl; - attr_long = 1246; - att.set_value(&attr_long); + cout << "[DevTest::read_attr] attribute name Long_attr_with_w" << endl; + attr_long = 1246; + att.set_value(&attr_long); } void DevTest::read_Short_attr_rw(Tango::Attribute &att) { - cout << "[DevTest::read_attr] attribute name Short_attr_rw" << endl; - att.set_value(&attr_short_rw); + cout << "[DevTest::read_attr] attribute name Short_attr_rw" << endl; + att.set_value(&attr_short_rw); } void DevTest::read_Long64_attr_rw(Tango::Attribute &att) { - cout << "[DevTest::read_attr] attribute name Long64_attr_rw" << endl; - att.set_value(&attr_long64_rw); + cout << "[DevTest::read_attr] attribute name Long64_attr_rw" << endl; + att.set_value(&attr_long64_rw); } void DevTest::read_ULong_attr_rw(Tango::Attribute &att) { - cout << "[DevTest::read_attr] attribute name ULong_attr_rw" << endl; - att.set_value(&attr_ulong_rw); + cout << "[DevTest::read_attr] attribute name ULong_attr_rw" << endl; + att.set_value(&attr_ulong_rw); } void DevTest::read_ULong64_attr_rw(Tango::Attribute &att) { - cout << "[DevTest::read_attr] attribute name ULong64_attr_rw" << endl; - att.set_value(&attr_ulong64_rw); + cout << "[DevTest::read_attr] attribute name ULong64_attr_rw" << endl; + att.set_value(&attr_ulong64_rw); } void DevTest::read_State_attr_rw(Tango::Attribute &att) { - cout << "[DevTest::read_attr] attribute name State_attr_rw" << endl; - att.set_value(&attr_state_rw); + cout << "[DevTest::read_attr] attribute name State_attr_rw" << endl; + att.set_value(&attr_state_rw); } void DevTest::read_attr_asyn(Tango::Attribute &att) { - cout << "[DevTest::read_attr] attribute attr_asyn" << endl; - Tango_sleep(2); - attr_double = 5.55; - att.set_value(&attr_double); - cout << "Leaving reading attr_asyn attribute" << endl; + cout << "[DevTest::read_attr] attribute attr_asyn" << endl; + Tango_sleep(2); + attr_double = 5.55; + att.set_value(&attr_double); + cout << "Leaving reading attr_asyn attribute" << endl; } void DevTest::read_attr_asyn_to(Tango::Attribute &att) { - cout << "[DevTest::read_attr] attribute attr_asyn_to" << endl; - Tango_sleep(4); - attr_double = 5.55; - att.set_value(&attr_double); - cout << "Leaving reading attr_asyn_to attribute" << endl; + cout << "[DevTest::read_attr] attribute attr_asyn_to" << endl; + Tango_sleep(4); + attr_double = 5.55; + att.set_value(&attr_double); + cout << "Leaving reading attr_asyn_to attribute" << endl; } void DevTest::read_attr_asyn_except(TANGO_UNUSED(Tango::Attribute &att)) { - cout << "[DevTest::read_attr] attribute attr_asyn_except" << endl; - Tango_sleep(2); - cout << "Leaving reading attr_asyn_except attribute" << endl; + cout << "[DevTest::read_attr] attribute attr_asyn_except" << endl; + Tango_sleep(2); + cout << "Leaving reading attr_asyn_except attribute" << endl; - Tango::Except::throw_exception((const char *)"aaa", - (const char *)"This is a test", - (const char *)"DevTest::read_attr"); + Tango::Except::throw_exception((const char *) "aaa", + (const char *) "This is a test", + (const char *) "DevTest::read_attr"); } void DevTest::read_PollLong_attr(Tango::Attribute &att) { - cout << "[DevTest::read_attr] attribute name PollLong_attr" << endl; - PollLong_attr_num++; - if ((PollLong_attr_num % 2) == 0) - Poll_attr_long = 5555; - else - Poll_attr_long = 6666; - att.set_value(&Poll_attr_long); + cout << "[DevTest::read_attr] attribute name PollLong_attr" << endl; + PollLong_attr_num++; + if ((PollLong_attr_num % 2) == 0) + { + Poll_attr_long = 5555; + } + else + { + Poll_attr_long = 6666; + } + att.set_value(&Poll_attr_long); } void DevTest::read_PollString_spec_attr(Tango::Attribute &att) { - cout << "[DevTest::read_attr] attribute name PollString_spec_attr" << endl; - PollString_spec_attr_num++; - if ((PollString_spec_attr_num % 4) == 0) - { - attr_str_array[0] = (char *)"Hello world"; - attr_str_array[1] = (char *)"Hello universe"; - att.set_value(attr_str_array, 2); - } - else if ((PollString_spec_attr_num % 4) == 1) - { - attr_str_array[0] = (char *)"Hello Grenoble"; + cout << "[DevTest::read_attr] attribute name PollString_spec_attr" << endl; + PollString_spec_attr_num++; + if ((PollString_spec_attr_num % 4) == 0) + { + attr_str_array[0] = (char *) "Hello world"; + attr_str_array[1] = (char *) "Hello universe"; + att.set_value(attr_str_array, 2); + } + else if ((PollString_spec_attr_num % 4) == 1) + { + attr_str_array[0] = (char *) "Hello Grenoble"; // attr_str_array[1] = (char *)"Hello Paris"; - att.set_value(attr_str_array, 1); - } - else if ((PollString_spec_attr_num % 4) == 2) - { - Tango::Except::throw_exception((const char *)"aaaa",(const char *)"bbb",(const char *)"ccc"); - } - else - { - Tango::Except::throw_exception((const char *)"xxx",(const char *)"yyy",(const char *)"zzz"); - } + att.set_value(attr_str_array, 1); + } + else if ((PollString_spec_attr_num % 4) == 2) + { + Tango::Except::throw_exception((const char *) "aaaa", (const char *) "bbb", (const char *) "ccc"); + } + else + { + Tango::Except::throw_exception((const char *) "xxx", (const char *) "yyy", (const char *) "zzz"); + } // att.set_value(attr_str_array, 2); } void DevTest::read_attr_dq_sh(Tango::Attribute &att) { - cout << "[DevTest::read_attr] attribute name attr_dq_sh" << endl; - attr_dq_short = 77; + cout << "[DevTest::read_attr] attribute name attr_dq_sh" << endl; + attr_dq_short = 77; #ifndef WIN32 - struct timeval tv; - struct timezone tz; - gettimeofday(&tv,&tz); - att.set_value_date_quality(&attr_dq_short,tv,Tango::ATTR_VALID); + struct timeval tv; + struct timezone tz; + gettimeofday(&tv, &tz); + att.set_value_date_quality(&attr_dq_short, tv, Tango::ATTR_VALID); #else - struct _timeb tv; - _ftime(&tv); - att.set_value_date_quality(&attr_dq_short,tv,Tango::ATTR_VALID); + struct _timeb tv; + _ftime(&tv); + att.set_value_date_quality(&attr_dq_short,tv,Tango::ATTR_VALID); #endif } void DevTest::read_attr_dq_lo(Tango::Attribute &att) { - cout << "[DevTest::read_attr] attribute name attr_dq_lo" << endl; - attr_dq_long = 7777; - time_t da; - time(&da); - att.set_value_date_quality(&attr_dq_long,da,Tango::ATTR_ALARM); + cout << "[DevTest::read_attr] attribute name attr_dq_lo" << endl; + attr_dq_long = 7777; + time_t da; + time(&da); + att.set_value_date_quality(&attr_dq_long, da, Tango::ATTR_ALARM); } void DevTest::read_attr_dq_db(Tango::Attribute &att) { - cout << "[DevTest::read_attr] attribute name attr_dq_db" << endl; - attr_dq_double = 8.888; + cout << "[DevTest::read_attr] attribute name attr_dq_db" << endl; + attr_dq_double = 8.888; #ifndef WIN32 - struct timeval tv; - struct timezone tz; - gettimeofday(&tv,&tz); - att.set_value_date_quality(&attr_dq_double,tv,Tango::ATTR_VALID); + struct timeval tv; + struct timezone tz; + gettimeofday(&tv, &tz); + att.set_value_date_quality(&attr_dq_double, tv, Tango::ATTR_VALID); #else - struct _timeb tv; - _ftime(&tv); - att.set_value_date_quality(&attr_dq_double,tv,Tango::ATTR_VALID); + struct _timeb tv; + _ftime(&tv); + att.set_value_date_quality(&attr_dq_double,tv,Tango::ATTR_VALID); #endif } void DevTest::read_attr_dq_str(Tango::Attribute &att) { - static Tango::DevString s = NULL; + static Tango::DevString s = NULL; - cout << "[DevTest::read_attr] attribute name attr_dq_str" << endl; - s = attr_dq_str; - strcpy(attr_dq_str,"Setting value date and quality"); - time_t da; - time(&da); - att.set_value_date_quality(&s,da,Tango::ATTR_ALARM); + cout << "[DevTest::read_attr] attribute name attr_dq_str" << endl; + s = attr_dq_str; + strcpy(attr_dq_str, "Setting value date and quality"); + time_t da; + time(&da); + att.set_value_date_quality(&s, da, Tango::ATTR_ALARM); } void DevTest::read_Short_spec_attr_rw(Tango::Attribute &att) { - cout << "[DevTest::read_attr] attribute name Short_spec_attr_rw" << endl; - short_spec_attr[0] = 8; - short_spec_attr[1] = 9; + cout << "[DevTest::read_attr] attribute name Short_spec_attr_rw" << endl; + short_spec_attr[0] = 8; + short_spec_attr[1] = 9; - att.set_value(short_spec_attr, 2); + att.set_value(short_spec_attr, 2); } void DevTest::read_String_spec_attr_rw(Tango::Attribute &att) { - cout << "[DevTest::read_attr] attribute name String_spec_attr_rw" << endl; - string_spec_attr[0] = "Thank's god"; - string_spec_attr[1] = "It's friday"; + cout << "[DevTest::read_attr] attribute name String_spec_attr_rw" << endl; + string_spec_attr[0] = "Thank's god"; + string_spec_attr[1] = "It's friday"; - att.set_value(const_cast(string_spec_attr), 2); + att.set_value(const_cast(string_spec_attr), 2); } void DevTest::read_Long_spec_attr_rw(Tango::Attribute &att) { - cout << "[DevTest::read_attr] attribute name Long_spec_attr_rw" << endl; - long_spec_attr[0] = 88; - long_spec_attr[1] = 99; - long_spec_attr[2] = 111; + cout << "[DevTest::read_attr] attribute name Long_spec_attr_rw" << endl; + long_spec_attr[0] = 88; + long_spec_attr[1] = 99; + long_spec_attr[2] = 111; - att.set_value(long_spec_attr, 3); + att.set_value(long_spec_attr, 3); } void DevTest::read_Short_ima_attr_rw(Tango::Attribute &att) { - cout << "[DevTest::read_attr] attribute name Short_ima_attr_rw" << endl; - short_ima_attr[0] = 6; - short_ima_attr[1] = 7; - short_ima_attr[2] = 8; - short_ima_attr[3] = 9; + cout << "[DevTest::read_attr] attribute name Short_ima_attr_rw" << endl; + short_ima_attr[0] = 6; + short_ima_attr[1] = 7; + short_ima_attr[2] = 8; + short_ima_attr[3] = 9; - att.set_value(short_ima_attr, 2,2); + att.set_value(short_ima_attr, 2, 2); } void DevTest::read_String_ima_attr_rw(Tango::Attribute &att) { - cout << "[DevTest::read_attr] attribute name String_ima_attr_rw" << endl; - string_ima_attr[0] = "Alors la, pour une surprise"; - string_ima_attr[1] = "c'est une surprise"; + cout << "[DevTest::read_attr] attribute name String_ima_attr_rw" << endl; + string_ima_attr[0] = "Alors la, pour une surprise"; + string_ima_attr[1] = "c'est une surprise"; - att.set_value(const_cast(string_ima_attr), 2,1); + att.set_value(const_cast(string_ima_attr), 2, 1); } void DevTest::read_Event_change_tst(Tango::Attribute &att) { - cout << "[DevTest::read_attr] attribute name event_change_tst" << endl; - if (event_change_attr_except == false) - { - if (event_throw_out_of_sync == true) - { + cout << "[DevTest::read_attr] attribute name event_change_tst" << endl; + if (event_change_attr_except == false) + { + if (event_throw_out_of_sync == true) + { #ifdef WIN32 - Sleep(400); + Sleep(400); #else - struct timespec sleep_time; - sleep_time.tv_sec = 0; - sleep_time.tv_nsec = 400000000; - nanosleep(&sleep_time,NULL); + struct timespec sleep_time; + sleep_time.tv_sec = 0; + sleep_time.tv_nsec = 400000000; + nanosleep(&sleep_time, NULL); #endif - } - att.set_value(attr_event,attr_event_size); - } - else - { - Tango::Except::throw_exception((const char *)"bbb", - (const char *)"This is a test", - (const char *)"DevTest::read_attr"); - } + } + att.set_value(attr_event, attr_event_size); + } + else + { + Tango::Except::throw_exception((const char *) "bbb", + (const char *) "This is a test", + (const char *) "DevTest::read_attr"); + } } void DevTest::read_Event64_change_tst(Tango::Attribute &att) { - cout << "[DevTest::read_attr] attribute name event64_change_tst" << endl; - if (event_change_attr_except == false) - { - att.set_value(attr_event64,attr_event64_size); - } - else - { - Tango::Except::throw_exception((const char *)"bbb64", - (const char *)"This is a test", - (const char *)"DevTest::read_attr"); - } + cout << "[DevTest::read_attr] attribute name event64_change_tst" << endl; + if (event_change_attr_except == false) + { + att.set_value(attr_event64, attr_event64_size); + } + else + { + Tango::Except::throw_exception((const char *) "bbb64", + (const char *) "This is a test", + (const char *) "DevTest::read_attr"); + } } void DevTest::read_Event_quality_tst(Tango::Attribute &att) { - cout << "[DevTest::read_attr] attribute name event_quality_tst" << endl; - if (event_quality_attr_except == false) - { - if (attr_event_qua != Tango::ATTR_INVALID) - att.set_value(attr_qua_event,2); - att.set_quality(attr_event_qua); - } - else - { - Tango::Except::throw_exception((const char *)"ccc", - (const char *)"This is a test", - (const char *)"DevTest::read_attr"); - } + cout << "[DevTest::read_attr] attribute name event_quality_tst" << endl; + if (event_quality_attr_except == false) + { + if (attr_event_qua != Tango::ATTR_INVALID) + { + att.set_value(attr_qua_event, 2); + } + att.set_quality(attr_event_qua); + } + else + { + Tango::Except::throw_exception((const char *) "ccc", + (const char *) "This is a test", + (const char *) "DevTest::read_attr"); + } } - void DevTest::read_Poll_buff(TANGO_UNUSED(Tango::Attribute &att)) { - cout << "[DevTest::read_attr] attribute name Poll_buff" << endl; + cout << "[DevTest::read_attr] attribute name Poll_buff" << endl; } void DevTest::read_Poll_buffRW(TANGO_UNUSED(Tango::Attribute &att)) { - cout << "[DevTest::read_attr] attribute name Poll_buffRW" << endl; + cout << "[DevTest::read_attr] attribute name Poll_buffRW" << endl; } void DevTest::read_Float_attr(Tango::Attribute &att) { - cout << "[DevTest::read_attr] attribute name Float_attr" << endl; - attr_float = 4.5; - att.set_value(&attr_float); + cout << "[DevTest::read_attr] attribute name Float_attr" << endl; + attr_float = 4.5; + att.set_value(&attr_float); } void DevTest::read_Boolean_attr(Tango::Attribute &att) { - cout << "[DevTest::read_attr] attribute name Boolean_attr" << endl; - attr_boolean = true; - att.set_value(&attr_boolean); + cout << "[DevTest::read_attr] attribute name Boolean_attr" << endl; + attr_boolean = true; + att.set_value(&attr_boolean); } void DevTest::read_UShort_attr(Tango::Attribute &att) { - cout << "[DevTest::read_attr] attribute name UShort_attr" << endl; - attr_ushort = 111; - att.set_value(&attr_ushort); + cout << "[DevTest::read_attr] attribute name UShort_attr" << endl; + attr_ushort = 111; + att.set_value(&attr_ushort); } void DevTest::read_UChar_attr(Tango::Attribute &att) { - cout << "[DevTest::read_attr] attribute name UChar_attr" << endl; - attr_uchar = 88; - att.set_value(&attr_uchar); + cout << "[DevTest::read_attr] attribute name UChar_attr" << endl; + attr_uchar = 88; + att.set_value(&attr_uchar); } void DevTest::read_ULong_attr(Tango::Attribute &att) { - cout << "[DevTest::read_attr] attribute name ULong_attr" << endl; - attr_ulong = 100; - att.set_value(&attr_ulong); + cout << "[DevTest::read_attr] attribute name ULong_attr" << endl; + attr_ulong = 100; + att.set_value(&attr_ulong); } void DevTest::read_ULong64_attr(Tango::Attribute &att) { - cout << "[DevTest::read_attr] attribute name ULong64_attr" << endl; - attr_ulong64 = 200; - att.set_value(&attr_ulong64); + cout << "[DevTest::read_attr] attribute name ULong64_attr" << endl; + attr_ulong64 = 200; + att.set_value(&attr_ulong64); } void DevTest::read_Float_spec_attr(Tango::Attribute &att) { - cout << "[DevTest::read_attr] attribute name Float_spec_attr" << endl; - attr_spec_float[0] = 4.5; - attr_spec_float[1] = 8.5; - attr_spec_float[2] = 16.5; - att.set_value(attr_spec_float,3); + cout << "[DevTest::read_attr] attribute name Float_spec_attr" << endl; + attr_spec_float[0] = 4.5; + attr_spec_float[1] = 8.5; + attr_spec_float[2] = 16.5; + att.set_value(attr_spec_float, 3); } void DevTest::read_Boolean_spec_attr(Tango::Attribute &att) { - cout << "[DevTest::read_attr] attribute name Boolean_spec_attr" << endl; - attr_spec_boolean[0] = true; - attr_spec_boolean[1] = true; - attr_spec_boolean[2] = false; - attr_spec_boolean[3] = true; - attr_spec_boolean[4] = true; - att.set_value(attr_spec_boolean,5); + cout << "[DevTest::read_attr] attribute name Boolean_spec_attr" << endl; + attr_spec_boolean[0] = true; + attr_spec_boolean[1] = true; + attr_spec_boolean[2] = false; + attr_spec_boolean[3] = true; + attr_spec_boolean[4] = true; + att.set_value(attr_spec_boolean, 5); } void DevTest::read_UShort_spec_attr(Tango::Attribute &att) { - cout << "[DevTest::read_attr] attribute name UShort_spec_attr" << endl; - attr_spec_ushort[0] = 333; - attr_spec_ushort[1] = 444; - att.set_value(attr_spec_ushort,2); + cout << "[DevTest::read_attr] attribute name UShort_spec_attr" << endl; + attr_spec_ushort[0] = 333; + attr_spec_ushort[1] = 444; + att.set_value(attr_spec_ushort, 2); } void DevTest::read_UChar_spec_attr(Tango::Attribute &att) { - cout << "[DevTest::read_attr] attribute name UChar_spec_attr" << endl; - attr_spec_uchar[0] = 28; - attr_spec_uchar[1] = 45; - attr_spec_uchar[2] = 156; - attr_spec_uchar[3] = 34; - attr_spec_uchar[4] = 200; - attr_spec_uchar[5] = 12; - att.set_value(attr_spec_uchar,6); + cout << "[DevTest::read_attr] attribute name UChar_spec_attr" << endl; + attr_spec_uchar[0] = 28; + attr_spec_uchar[1] = 45; + attr_spec_uchar[2] = 156; + attr_spec_uchar[3] = 34; + attr_spec_uchar[4] = 200; + attr_spec_uchar[5] = 12; + att.set_value(attr_spec_uchar, 6); } void DevTest::read_Float_spec_attr_rw(Tango::Attribute &att) { - cout << "[DevTest::read_attr] attribute name Float_spec_attr_rw" << endl; - attr_spec_float[0] = 5.5; - attr_spec_float[1] = 11.5; + cout << "[DevTest::read_attr] attribute name Float_spec_attr_rw" << endl; + attr_spec_float[0] = 5.5; + attr_spec_float[1] = 11.5; - att.set_value(attr_spec_float, 2); + att.set_value(attr_spec_float, 2); } void DevTest::read_UChar_spec_attr_rw(Tango::Attribute &att) { - cout << "[DevTest::read_attr] attribute name UChar_spec_attr_rw" << endl; - attr_spec_uchar[0] = 22; - attr_spec_uchar[1] = 44; - attr_spec_uchar[2] = 66; + cout << "[DevTest::read_attr] attribute name UChar_spec_attr_rw" << endl; + attr_spec_uchar[0] = 22; + attr_spec_uchar[1] = 44; + attr_spec_uchar[2] = 66; - att.set_value(attr_spec_uchar, 3); + att.set_value(attr_spec_uchar, 3); } void DevTest::read_Boolean_ima_attr_rw(Tango::Attribute &att) { - cout << "[DevTest::read_attr] attribute name Boolean_ima_attr_rw" << endl; - attr_spec_boolean[0] = true; - attr_spec_boolean[1] = false; + cout << "[DevTest::read_attr] attribute name Boolean_ima_attr_rw" << endl; + attr_spec_boolean[0] = true; + attr_spec_boolean[1] = false; - att.set_value(attr_spec_boolean, 2,1); + att.set_value(attr_spec_boolean, 2, 1); } void DevTest::read_UShort_ima_attr_rw(Tango::Attribute &att) { - cout << "[DevTest::read_attr] attribute name UShort_ima_attr_rw" << endl; - attr_spec_ushort[0] = 2; - attr_spec_ushort[1] = 3; + cout << "[DevTest::read_attr] attribute name UShort_ima_attr_rw" << endl; + attr_spec_ushort[0] = 2; + attr_spec_ushort[1] = 3; - att.set_value(attr_spec_ushort, 2,1); + att.set_value(attr_spec_ushort, 2, 1); } void DevTest::read_slow_actuator(Tango::Attribute &att) { - cout << "[DevTest::read_attr] attribute name slow_actuator" << endl; - slow_actua++; - att.set_value(&slow_actua); + cout << "[DevTest::read_attr] attribute name slow_actuator" << endl; + slow_actua++; + att.set_value(&slow_actua); - struct timeval now; + struct timeval now; #ifdef WIN32 - struct _timeb before_win; - _ftime(&before_win); - now.tv_sec = (unsigned long)before_win.time; - now.tv_usec = (long)before_win.millitm * 1000; + struct _timeb before_win; + _ftime(&before_win); + now.tv_sec = (unsigned long)before_win.time; + now.tv_usec = (long)before_win.millitm * 1000; #else - gettimeofday(&now,NULL); + gettimeofday(&now, NULL); #endif - long delta; - if (slow_actua_write.tv_sec != 0) - { - COMPUTE_TIME_DIFF(delta,slow_actua_write,now); - cout << "Delta time = " << delta << endl; - if (delta > 3000) - { - att.set_quality(Tango::ATTR_VALID); - slow_actua_write.tv_sec = 0; - } - else - { - att.set_quality(Tango::ATTR_CHANGING); - } - } + long delta; + if (slow_actua_write.tv_sec != 0) + { + COMPUTE_TIME_DIFF(delta, slow_actua_write, now); + cout << "Delta time = " << delta << endl; + if (delta > 3000) + { + att.set_quality(Tango::ATTR_VALID); + slow_actua_write.tv_sec = 0; + } + else + { + att.set_quality(Tango::ATTR_CHANGING); + } + } } void DevTest::read_fast_actuator(Tango::Attribute &att) { - cout << "[DevTest::read_attr] attribute name fast_actuator" << endl; - att.set_value(&fast_actua); + cout << "[DevTest::read_attr] attribute name fast_actuator" << endl; + att.set_value(&fast_actua); } void DevTest::read_Long64_spec_attr_rw(Tango::Attribute &att) { - cout << "[DevTest::read_attr] attribute name Long64_spec_attr_rw" << endl; - att.set_value(attr_spec_long64_rw,3); + cout << "[DevTest::read_attr] attribute name Long64_spec_attr_rw" << endl; + att.set_value(attr_spec_long64_rw, 3); } void DevTest::read_ULong_spec_attr_rw(Tango::Attribute &att) { - cout << "[DevTest::read_attr] attribute name ULong_spec_attr_rw" << endl; - att.set_value(attr_spec_ulong_rw,3); + cout << "[DevTest::read_attr] attribute name ULong_spec_attr_rw" << endl; + att.set_value(attr_spec_ulong_rw, 3); } void DevTest::read_ULong64_spec_attr_rw(Tango::Attribute &att) { - cout << "[DevTest::read_attr] attribute name ULong64_spec_attr_rw" << endl; - att.set_value(attr_spec_ulong64_rw,3); + cout << "[DevTest::read_attr] attribute name ULong64_spec_attr_rw" << endl; + att.set_value(attr_spec_ulong64_rw, 3); } void DevTest::read_State_spec_attr_rw(Tango::Attribute &att) { - cout << "[DevTest::read_attr] attribute name State_spec_attr_rw" << endl; - att.set_value(attr_spec_state_rw,2); + cout << "[DevTest::read_attr] attribute name State_spec_attr_rw" << endl; + att.set_value(attr_spec_state_rw, 2); } void DevTest::read_Sub_device_tst(Tango::Attribute &att) { - cout << "[DevTest::read_attr] attribute name Sub_device_tst" << endl; + cout << "[DevTest::read_attr] attribute name Sub_device_tst" << endl; - Tango::Util *tg = Tango::Util::instance(); + Tango::Util *tg = Tango::Util::instance(); // // sort the devices in the ascending name order // - vector &dev_list = tg->get_device_list_by_class("DevTest"); - vector dev_list_sorted = dev_list; - - size_t n = dev_list_sorted.size(); - // the second device on the list is selected to be the sub device, so the list has to comprise of 2 or more elements - if(n > 1) { - // bubble sort - do { - size_t i; - for(i = 0; i < n-1; i++) - { - if(dev_list_sorted[i]->get_name() > dev_list_sorted[i+1]->get_name()) - { - Tango::DeviceImpl *dev_tmp; - dev_tmp = dev_list_sorted[i]; - dev_list_sorted[i] = dev_list_sorted[i+1]; - dev_list_sorted[i+1] = dev_tmp; - } - } - n = i; - } - while(n != 1); - - try - { - Tango::DeviceProxy *remote_dev; - remote_dev = new Tango::DeviceProxy(dev_list_sorted[1]->get_name()); - attr_sub_device_tst = true; - } - catch (...) - { - attr_sub_device_tst = false; - } - } - else - attr_sub_device_tst = false; + vector &dev_list = tg->get_device_list_by_class("DevTest"); + vector dev_list_sorted = dev_list; + + size_t n = dev_list_sorted.size(); + // the second device on the list is selected to be the sub device, so the list has to comprise of 2 or more elements + if (n > 1) + { + // bubble sort + do + { + size_t i; + for (i = 0; i < n - 1; i++) + { + if (dev_list_sorted[i]->get_name() > dev_list_sorted[i + 1]->get_name()) + { + Tango::DeviceImpl *dev_tmp; + dev_tmp = dev_list_sorted[i]; + dev_list_sorted[i] = dev_list_sorted[i + 1]; + dev_list_sorted[i + 1] = dev_tmp; + } + } + n = i; + } + while (n != 1); + + try + { + Tango::DeviceProxy *remote_dev; + remote_dev = new Tango::DeviceProxy(dev_list_sorted[1]->get_name()); + attr_sub_device_tst = true; + } + catch (...) + { + attr_sub_device_tst = false; + } + } + else + { + attr_sub_device_tst = false; + } - att.set_value(&attr_sub_device_tst); + att.set_value(&attr_sub_device_tst); } void DevTest::read_Encoded_attr_rw(Tango::Attribute &att) { // static int count = 0; - cout << "[DevTest::read_attr] attribute name Encoded_attr_rw" << endl; + cout << "[DevTest::read_attr] attribute name Encoded_attr_rw" << endl; #ifndef COMPAT /* if ((count % 2) == 0) @@ -1949,7 +2008,7 @@ void DevTest::read_Encoded_attr_rw(Tango::Attribute &att) enc_attr.encoded_data[0] = 22; }*/ - att.set_value(&enc_attr); + att.set_value(&enc_attr); // count++; /* enc_attr_ptr = new Tango::DevEncoded; @@ -1979,21 +2038,23 @@ void DevTest::read_Encoded_attr_rw(Tango::Attribute &att) void DevTest::read_Encoded_attr_image(Tango::Attribute &att) { - cout << "[DevTest::read_attr] attribute name Encoded_attr_image" << endl; + cout << "[DevTest::read_attr] attribute name Encoded_attr_image" << endl; #ifndef COMPAT - // Build a dummy image - unsigned char *imageData = (unsigned char *)malloc(256*256); - for(int i=0;i<256;i++) { - for(int j=0;j<256;j++) { - imageData[i+j*256] = i; + // Build a dummy image + unsigned char *imageData = (unsigned char *) malloc(256 * 256); + for (int i = 0; i < 256; i++) + { + for (int j = 0; j < 256; j++) + { + imageData[i + j * 256] = i; + } } - } - // Encode a JPEG image - jpeg.encode_jpeg_gray8(imageData,256,256,50.0); - att.set_value(&jpeg); - free(imageData); + // Encode a JPEG image + jpeg.encode_jpeg_gray8(imageData, 256, 256, 50.0); + att.set_value(&jpeg); + free(imageData); #endif } @@ -2001,12 +2062,12 @@ void DevTest::read_Encoded_attr_image(Tango::Attribute &att) void DevTest::read_Slow_attr(Tango::Attribute &att) { #ifdef WIN32 - Sleep(500); + Sleep(500); #else struct timespec sl; sl.tv_sec = 0; sl.tv_nsec = 500000000; - nanosleep(&sl,NULL); + nanosleep(&sl, NULL); #endif att.set_value(&attr_slow); @@ -2014,69 +2075,69 @@ void DevTest::read_Slow_attr(Tango::Attribute &att) void DevTest::read_Def_attr(Tango::Attribute &att) { - cout << "[DevTest::read_attr] attribute name DefAttr" << endl; - att.set_value(&att_conf); + cout << "[DevTest::read_attr] attribute name DefAttr" << endl; + att.set_value(&att_conf); } void DevTest::read_DefUser_attr(Tango::Attribute &att) { - cout << "[DevTest::read_attr] attribute name DefUserAttr" << endl; - att.set_value(&att_conf); + cout << "[DevTest::read_attr] attribute name DefUserAttr" << endl; + att.set_value(&att_conf); } void DevTest::read_DefClass_attr(Tango::Attribute &att) { - cout << "[DevTest::read_attr] attribute name DefClassAttr" << endl; - att.set_value(&att_conf); + cout << "[DevTest::read_attr] attribute name DefClassAttr" << endl; + att.set_value(&att_conf); } void DevTest::read_DefClassUser_attr(Tango::Attribute &att) { - cout << "[DevTest::read_attr] attribute name DefClassUserAttr" << endl; - att.set_value(&att_conf); + cout << "[DevTest::read_attr] attribute name DefClassUserAttr" << endl; + att.set_value(&att_conf); } void DevTest::read_Enum_attr(Tango::Attribute &att) { - cout << "[DevTest::read_attr] attribute name EnumAttr" << endl; - cp = SOUTH; - att.set_value(&cp); + cout << "[DevTest::read_attr] attribute name EnumAttr" << endl; + cp = SOUTH; + att.set_value(&cp); } void DevTest::read_Enum_spec_attr_rw(Tango::Attribute &att) { - cout << "[DevTest::read_attr] attribute name Enum_spec_attr_rw" << endl; - cp_array[0] = SOUTH; - cp_array[1] = NORTH; - cp_array[2] = WEST; - att.set_value(cp_array,3); + cout << "[DevTest::read_attr] attribute name Enum_spec_attr_rw" << endl; + cp_array[0] = SOUTH; + cp_array[1] = NORTH; + cp_array[2] = WEST; + att.set_value(cp_array, 3); } void DevTest::read_DynEnum_attr(Tango::Attribute &att) { - cout << "[DevTest::read_attr] attribute name DynEnum_attr" << endl; - att.set_value(&enum_value); + cout << "[DevTest::read_attr] attribute name DynEnum_attr" << endl; + att.set_value(&enum_value); } void DevTest::read_ReynaldPoll_attr(TANGO_UNUSED(Tango::Attribute &att)) { - cout << "[DevTest::read_attr] attribute name ReynaldPoll_attr" << endl; + cout << "[DevTest::read_attr] attribute name ReynaldPoll_attr" << endl; - Reynald_ctr++; - if ((Reynald_ctr % 3) == 0) + Reynald_ctr++; + if ((Reynald_ctr % 3) == 0) { int poll_period = get_attribute_poll_period("Short_attr"); if (poll_period == 250) { -cout << "ReynaldPollAttr: Setting period to 500" << endl; - poll_attribute("Short_attr",500); - poll_attribute("ReynaldPollAttr",500); + cout << "ReynaldPollAttr: Setting period to 500" << endl; + poll_attribute("Short_attr", 500); + poll_attribute("ReynaldPollAttr", 500); } else { -cout << "ReynaldPollAttr: Setting period to 250" << endl; - poll_attribute("Short_attr",250); - poll_attribute("ReynaldPollAttr",250); + cout << "ReynaldPollAttr: Setting period to 250" << endl; + poll_attribute("Short_attr", 250); + poll_attribute("ReynaldPollAttr", 250); } } } @@ -2091,515 +2152,535 @@ cout << "ReynaldPollAttr: Setting period to 250" << endl; bool DevTest::is_RPipe_allowed(Tango::PipeReqType) { - if (get_state() == Tango::ON) - return true; - else - return false; + if (get_state() == Tango::ON) + { + return true; + } + else + { + return false; + } } void DevTest::read_RPipe(Tango::Pipe &pipe) { - switch (rpipe_type) - { - case 0: - { - pipe.set_root_blob_name("BlobCase0"); - - vector de_names; - de_names.push_back(string("FirstDE")); - de_names.push_back(string("SecondDE")); - de_names.push_back(string("ThirdDE")); - de_names.push_back(string("ForthDE")); - - pipe.set_data_elt_names(de_names); - - dl = 666; - v_db.clear(); - v_db.push_back(1.11); - v_db.push_back(2.22); - - unsigned short *array = new unsigned short [100]; - for (unsigned short i = 0;i < 100;i++) - array[i] = i; - Tango::DevVarUShortArray *dvush = create_DevVarUShortArray(array,100); - - dvsa.length(2); - dvsa[0] = Tango::ON; - dvsa[1] = Tango::OFF; - - try - { - pipe << dl << v_db << dvush << dvsa; - cout << "Data type 0 inserted in pipe" << endl; - } - catch (Tango::DevFailed &e) - { - Tango::Except::print_exception(e); - throw e; - } - } - break; + switch (rpipe_type) + { + case 0: + { + pipe.set_root_blob_name("BlobCase0"); + + vector de_names; + de_names.push_back(string("FirstDE")); + de_names.push_back(string("SecondDE")); + de_names.push_back(string("ThirdDE")); + de_names.push_back(string("ForthDE")); + + pipe.set_data_elt_names(de_names); + + dl = 666; + v_db.clear(); + v_db.push_back(1.11); + v_db.push_back(2.22); + + unsigned short *array = new unsigned short[100]; + for (unsigned short i = 0; i < 100; i++) + { + array[i] = i; + } + Tango::DevVarUShortArray *dvush = create_DevVarUShortArray(array, 100); + + dvsa.length(2); + dvsa[0] = Tango::ON; + dvsa[1] = Tango::OFF; + + try + { + pipe << dl << v_db << dvush << dvsa; + cout << "Data type 0 inserted in pipe" << endl; + } + catch (Tango::DevFailed &e) + { + Tango::Except::print_exception(e); + throw e; + } + } + break; - case 1: - { - pipe.set_root_blob_name("BlobCase1"); - - pipe.set_data_elt_nb(5); - - pipe_str.name = "stringDE"; - pipe_str.value = "Hello"; - - pipe_devstr.name = "DevStringDE"; - pipe_devstr.value = const_cast("Hola"); - - pipe_enc.name = "DevEncodedDE"; - pipe_enc.value.encoded_format = "Format"; - pipe_enc.value.encoded_data.length(2); - pipe_enc.value.encoded_data[0] = 0; - pipe_enc.value.encoded_data[1] = 1; - - pipe_v_str.name = "VectorStringDE"; - pipe_v_str.value.clear(); - pipe_v_str.value.push_back(string("Bonjour")); - pipe_v_str.value.push_back(string("le")); - pipe_v_str.value.push_back(string("monde")); - - pipe_dvsa.name = "DevVarStringArrayDE"; - pipe_dvsa.value.length(1); - (pipe_dvsa.value)[0] = "Why not?"; - - try - { - pipe << pipe_str << pipe_devstr << pipe_enc << pipe_v_str << pipe_dvsa; - cout << "Data type 1 inserted in pipe" << endl; - } - catch (Tango::DevFailed &e) - { - Tango::Except::print_exception(e); - throw e; - } - } - break; + case 1: + { + pipe.set_root_blob_name("BlobCase1"); + + pipe.set_data_elt_nb(5); + + pipe_str.name = "stringDE"; + pipe_str.value = "Hello"; + + pipe_devstr.name = "DevStringDE"; + pipe_devstr.value = const_cast("Hola"); + + pipe_enc.name = "DevEncodedDE"; + pipe_enc.value.encoded_format = "Format"; + pipe_enc.value.encoded_data.length(2); + pipe_enc.value.encoded_data[0] = 0; + pipe_enc.value.encoded_data[1] = 1; + + pipe_v_str.name = "VectorStringDE"; + pipe_v_str.value.clear(); + pipe_v_str.value.push_back(string("Bonjour")); + pipe_v_str.value.push_back(string("le")); + pipe_v_str.value.push_back(string("monde")); + + pipe_dvsa.name = "DevVarStringArrayDE"; + pipe_dvsa.value.length(1); + (pipe_dvsa.value)[0] = "Why not?"; + + try + { + pipe << pipe_str << pipe_devstr << pipe_enc << pipe_v_str << pipe_dvsa; + cout << "Data type 1 inserted in pipe" << endl; + } + catch (Tango::DevFailed &e) + { + Tango::Except::print_exception(e); + throw e; + } + } + break; - case 2: - { - pipe.set_root_blob_name("BlobCase2"); + case 2: + { + pipe.set_root_blob_name("BlobCase2"); - vector de_names; - de_names.push_back(string("FirstDE")); - de_names.push_back(string("SecondDE")); - pipe.set_data_elt_names(de_names); + vector de_names; + de_names.push_back(string("FirstDE")); + de_names.push_back(string("SecondDE")); + pipe.set_data_elt_names(de_names); - dl = 999; - v_db.clear(); - v_db.push_back(3.33); - v_db.push_back(4.44); - v_db.push_back(5.55); + dl = 999; + v_db.clear(); + v_db.push_back(3.33); + v_db.push_back(4.44); + v_db.push_back(5.55); - pipe["SecondDE"] << v_db; - pipe["FirstDE"] << dl; + pipe["SecondDE"] << v_db; + pipe["FirstDE"] << dl; - cout << "Data type 2 inserted in pipe" << endl; - } - break; + cout << "Data type 2 inserted in pipe" << endl; + } + break; - case 3: - { - pipe.set_root_blob_name("BlobCase3"); + case 3: + { + pipe.set_root_blob_name("BlobCase3"); - vector de_inner_inner_names; - de_inner_inner_names.push_back(string("InnerInnerFirstDE")); - de_inner_inner_names.push_back("InnerInnerSecondDE"); - inner_inner_blob.set_data_elt_names(de_inner_inner_names); - inner_inner_blob.set_name("InnerInner"); + vector de_inner_inner_names; + de_inner_inner_names.push_back(string("InnerInnerFirstDE")); + de_inner_inner_names.push_back("InnerInnerSecondDE"); + inner_inner_blob.set_data_elt_names(de_inner_inner_names); + inner_inner_blob.set_name("InnerInner"); - dl = 111; - v_db.clear(); - v_db.push_back(3.33); + dl = 111; + v_db.clear(); + v_db.push_back(3.33); - inner_inner_blob["InnerInnerSecondDE"] << v_db; - inner_inner_blob["InnerInnerFirstDE"] << dl; + inner_inner_blob["InnerInnerSecondDE"] << v_db; + inner_inner_blob["InnerInnerFirstDE"] << dl; - vector de_inner_names; - de_inner_names.push_back("InnerFirstDE"); - de_inner_names.push_back("InnerSecondDE"); - de_inner_names.push_back("InnerThirdDE"); - inner_blob.set_data_elt_names(de_inner_names); - inner_blob.set_name("Inner"); + vector de_inner_names; + de_inner_names.push_back("InnerFirstDE"); + de_inner_names.push_back("InnerSecondDE"); + de_inner_names.push_back("InnerThirdDE"); + inner_blob.set_data_elt_names(de_inner_names); + inner_blob.set_name("Inner"); - inner_str = "Grenoble"; - inner_bool = true; + inner_str = "Grenoble"; + inner_bool = true; - inner_blob << inner_str << inner_inner_blob << inner_bool; + inner_blob << inner_str << inner_inner_blob << inner_bool; - vector de_names; - de_names.push_back("1DE"); - de_names.push_back("2DE"); - pipe.set_data_elt_names(de_names); + vector de_names; + de_names.push_back("1DE"); + de_names.push_back("2DE"); + pipe.set_data_elt_names(de_names); - v_dl.clear(); - v_dl.push_back(3); - v_dl.push_back(4); - v_dl.push_back(5); - v_dl.push_back(6); + v_dl.clear(); + v_dl.push_back(3); + v_dl.push_back(4); + v_dl.push_back(5); + v_dl.push_back(6); - pipe << inner_blob << v_dl; + pipe << inner_blob << v_dl; - cout << "Data type 3 inserted in pipe" << endl; - } - break; + cout << "Data type 3 inserted in pipe" << endl; + } + break; - case 4: - { - pipe.set_root_blob_name("BlobCase4"); - vector de_names; - de_names.push_back("1DE"); - de_names.push_back("2DE"); - pipe.set_data_elt_names(de_names); + case 4: + { + pipe.set_root_blob_name("BlobCase4"); + vector de_names; + de_names.push_back("1DE"); + de_names.push_back("2DE"); + pipe.set_data_elt_names(de_names); - pipe << dl; + pipe << dl; - cout << "Data type 4 inserted in pipe" << endl; - } - break; + cout << "Data type 4 inserted in pipe" << endl; + } + break; - case 5: - { - pipe.set_root_blob_name("BlobCase5"); - vector de_names; - de_names.push_back("1DE"); - pipe.set_data_elt_names(de_names); + case 5: + { + pipe.set_root_blob_name("BlobCase5"); + vector de_names; + de_names.push_back("1DE"); + pipe.set_data_elt_names(de_names); - cout << "Data type 5 inserted in pipe" << endl; - } - break; + cout << "Data type 5 inserted in pipe" << endl; + } + break; - case 6: - { - pipe.set_root_blob_name("BlobCase6"); - vector de_names; - de_names.push_back("1DE"); - de_names.push_back("2DE"); - de_names.push_back("1de"); - pipe.set_data_elt_names(de_names); - } - break; + case 6: + { + pipe.set_root_blob_name("BlobCase6"); + vector de_names; + de_names.push_back("1DE"); + de_names.push_back("2DE"); + de_names.push_back("1de"); + pipe.set_data_elt_names(de_names); + } + break; - case 7: - { - pipe.set_root_blob_name("BlobCase7"); - pipe << dl; - } - break; + case 7: + { + pipe.set_root_blob_name("BlobCase7"); + pipe << dl; + } + break; - case 8: - { - pipe.set_root_blob_name("BlobCase8"); + case 8: + { + pipe.set_root_blob_name("BlobCase8"); - vector de_names; - de_names.push_back("1DE"); - de_names.push_back("2DE"); - de_names.push_back("3de"); - pipe.set_data_elt_names(de_names); + vector de_names; + de_names.push_back("1DE"); + de_names.push_back("2DE"); + de_names.push_back("3de"); + pipe.set_data_elt_names(de_names); - pipe << dl; - pipe["2DE"] << v_dl; - } - break; + pipe << dl; + pipe["2DE"] << v_dl; + } + break; - case 9: - { - vector de_names; - de_names.push_back("Another_1DE"); - de_names.push_back("Another_2DE"); + case 9: + { + vector de_names; + de_names.push_back("Another_1DE"); + de_names.push_back("Another_2DE"); - v_dl.clear(); - v_dl.push_back(2); - string str("Barcelona"); + v_dl.clear(); + v_dl.push_back(2); + string str("Barcelona"); - pipe.set_root_blob_name("BlobCase9"); - pipe.set_data_elt_names(de_names); - pipe << v_dl << str; + pipe.set_root_blob_name("BlobCase9"); + pipe.set_data_elt_names(de_names); + pipe << v_dl << str; - Tango::DevicePipeBlob &bl = pipe.get_blob(); - this->push_pipe_event("RPipe",&bl,true); - } - break; + Tango::DevicePipeBlob &bl = pipe.get_blob(); + this->push_pipe_event("RPipe", &bl, true); + } + break; - case 10: - { - pipe.set_root_blob_name("BlobCase10"); + case 10: + { + pipe.set_root_blob_name("BlobCase10"); - vector de_names; - de_names.push_back("1DE"); - pipe.set_data_elt_names(de_names); + vector de_names; + de_names.push_back("1DE"); + pipe.set_data_elt_names(de_names); - v_dl.clear(); - v_dl.push_back(22); - string str("Barcelona"); + v_dl.clear(); + v_dl.push_back(22); + string str("Barcelona"); - pipe << v_dl << str; - } - break; + pipe << v_dl << str; + } + break; - case 11: - { - pipe.set_root_blob_name("BlobCase11"); + case 11: + { + pipe.set_root_blob_name("BlobCase11"); - vector de_names; - de_names.push_back("1DE"); - de_names.push_back("2DE"); - pipe.set_data_elt_names(de_names); + vector de_names; + de_names.push_back("1DE"); + de_names.push_back("2DE"); + pipe.set_data_elt_names(de_names); - Tango::DevULong64 dul64 = 123456; - v_bool.clear(); - v_bool.push_back(true); - v_bool.push_back(true); - v_bool.push_back(false); + Tango::DevULong64 dul64 = 123456; + v_bool.clear(); + v_bool.push_back(true); + v_bool.push_back(true); + v_bool.push_back(false); - pipe << dul64 << v_bool; - } - break; + pipe << dul64 << v_bool; + } + break; - case 12: - { - pipe.set_root_blob_name("BlobCase12"); + case 12: + { + pipe.set_root_blob_name("BlobCase12"); - vector de_names; - de_names.push_back("1DE_Array"); - de_names.push_back("2DE_Array"); - pipe.set_data_elt_names(de_names); + vector de_names; + de_names.push_back("1DE_Array"); + de_names.push_back("2DE_Array"); + pipe.set_data_elt_names(de_names); - v_bool.clear(); - v_bool.push_back(false); + v_bool.clear(); + v_bool.push_back(false); v_dl.clear(); v_dl.push_back(9); - pipe << v_dl << v_bool; - } - break; - } + pipe << v_dl << v_bool; + } + break; + } } // RWPipe bool DevTest::is_RWPipe_allowed(Tango::PipeReqType) { - return true; + return true; } void DevTest::read_RWPipe(Tango::Pipe &pipe) { - pipe_mutex.lock(); - pipe.set_user_pipe_mutex(&pipe_mutex); + pipe_mutex.lock(); + pipe.set_user_pipe_mutex(&pipe_mutex); - pipe.set_root_blob_name("RWPipeBlob"); + pipe.set_root_blob_name("RWPipeBlob"); - vector de_names; - de_names.push_back("RW_1DE"); - de_names.push_back("RW_2DE"); - pipe.set_data_elt_names(de_names); + vector de_names; + de_names.push_back("RW_1DE"); + de_names.push_back("RW_2DE"); + pipe.set_data_elt_names(de_names); - dl = 666; - v_db.clear(); - v_db.push_back(1.11); - v_db.push_back(2.22); + dl = 666; + v_db.clear(); + v_db.push_back(1.11); + v_db.push_back(2.22); - try - { - pipe << dl << v_db; - } - catch (Tango::DevFailed &e) - { - Tango::Except::print_exception(e); - throw e; - } + try + { + pipe << dl << v_db; + } + catch (Tango::DevFailed &e) + { + Tango::Except::print_exception(e); + throw e; + } } void DevTest::write_RWPipe(Tango::WPipe &w_pipe) { - string str; - vector v_fl; + string str; + vector v_fl; - vector de_names = w_pipe.get_data_elt_names(); - for (size_t loop = 0;loop < de_names.size();loop++) - cout << "RWPipe: Received data element name = " << de_names[loop] << endl; + vector de_names = w_pipe.get_data_elt_names(); + for (size_t loop = 0; loop < de_names.size(); loop++) + { + cout << "RWPipe: Received data element name = " << de_names[loop] << endl; + } - w_pipe >> str >> v_fl; + w_pipe >> str >> v_fl; } // RPipeDE bool DevTest::is_RPipeDE_allowed(Tango::PipeReqType) { - if (get_state() == Tango::ON) - return true; - else - return false; + if (get_state() == Tango::ON) + { + return true; + } + else + { + return false; + } } void DevTest::read_RPipeDE(Tango::Pipe &pipe) { - pipe.set_root_blob_name("BlobDE"); + pipe.set_root_blob_name("BlobDE"); - vector de_names; - de_names.push_back(string("FirstDE")); - de_names.push_back(string("SecondDE")); - de_names.push_back(string("ThirdDE")); - de_names.push_back(string("ForthDE")); + vector de_names; + de_names.push_back(string("FirstDE")); + de_names.push_back(string("SecondDE")); + de_names.push_back(string("ThirdDE")); + de_names.push_back(string("ForthDE")); - pipe.set_data_elt_names(de_names); + pipe.set_data_elt_names(de_names); - dl = 666; - v_db.clear(); - v_db.push_back(1.11); - v_db.push_back(2.22); + dl = 666; + v_db.clear(); + v_db.push_back(1.11); + v_db.push_back(2.22); - unsigned short *array = new unsigned short [100]; - for (unsigned short i = 0;i < 100;i++) - array[i] = i; - Tango::DevVarUShortArray *dvush = create_DevVarUShortArray(array,100); + unsigned short *array = new unsigned short[100]; + for (unsigned short i = 0; i < 100; i++) + { + array[i] = i; + } + Tango::DevVarUShortArray *dvush = create_DevVarUShortArray(array, 100); - dvsa.length(2); - dvsa[0] = Tango::ON; - dvsa[1] = Tango::OFF; + dvsa.length(2); + dvsa[0] = Tango::ON; + dvsa[1] = Tango::OFF; - try - { - pipe << dl << v_db << dvush << dvsa; - cout << "Data inserted in pipe (using DataElement classes)" << endl; - } - catch (Tango::DevFailed &e) - { - Tango::Except::print_exception(e); - throw e; - } + try + { + pipe << dl << v_db << dvush << dvsa; + cout << "Data inserted in pipe (using DataElement classes)" << endl; + } + catch (Tango::DevFailed &e) + { + Tango::Except::print_exception(e); + throw e; + } } void DevTest::cmd_push_pipe_event(Tango::DevShort in) { if (in == 0) - { - Tango::DevicePipeBlob dpb("PipeEventCase0"); - - vector de_inner_inner_names; - de_inner_inner_names.push_back("InnerInnerFirstDE"); - de_inner_inner_names.push_back("InneraaaaaaaInnerSecondDE"); - inner_inner_blob.set_data_elt_names(de_inner_inner_names); - inner_inner_blob.set_name("InnerInner"); - - dl = 111; - v_db.clear(); - v_db.push_back(3.33); - v_db.push_back(3.33); - - inner_inner_blob["InneraaaaaaaInnerSecondDE"] << v_db; - inner_inner_blob["InnerInnerFirstDE"] << dl; - - vector de_inner_names; - de_inner_names.push_back("InnerFirstDE"); - de_inner_names.push_back("InnerSecondDE"); - de_inner_names.push_back("InnerThirdDE"); - inner_blob.set_data_elt_names(de_inner_names); - inner_blob.set_name("Inner"); - - inner_str = "Grenoble"; - inner_bool = true; - - inner_blob << inner_str << inner_inner_blob << inner_bool; - - vector de_names; - de_names.push_back("1DE"); - de_names.push_back("2DE"); - dpb.set_data_elt_names(de_names); - - v_dl.clear(); - v_dl.push_back(3); - v_dl.push_back(4); - v_dl.push_back(5); - v_dl.push_back(6); - - dpb << inner_blob << v_dl; - this->push_pipe_event("RWPipe",&dpb); - } - else if (in == 1) - { - Tango::DevicePipeBlob dpb("PipeEventCase1"); - vector de_names; - de_names.push_back("Another_1DE"); - de_names.push_back("Another_2DE"); - dpb.set_data_elt_names(de_names); - - v_dl.clear(); - v_dl.push_back(2); - string str("Barcelona"); - - dpb << v_dl << str; - - this->push_pipe_event("RWPipe",&dpb); - } - else if (in == 2) - { - Tango::DevicePipeBlob dpb("PipeEventCase2"); - vector de_names; - de_names.push_back("Qwerty_1DE"); - de_names.push_back("Azerty_2DE"); - dpb.set_data_elt_names(de_names); - - string str("Barcelona"); - - dpb << str << v_dl; + { + Tango::DevicePipeBlob dpb("PipeEventCase0"); + + vector de_inner_inner_names; + de_inner_inner_names.push_back("InnerInnerFirstDE"); + de_inner_inner_names.push_back("InneraaaaaaaInnerSecondDE"); + inner_inner_blob.set_data_elt_names(de_inner_inner_names); + inner_inner_blob.set_name("InnerInner"); + + dl = 111; + v_db.clear(); + v_db.push_back(3.33); + v_db.push_back(3.33); + + inner_inner_blob["InneraaaaaaaInnerSecondDE"] << v_db; + inner_inner_blob["InnerInnerFirstDE"] << dl; + + vector de_inner_names; + de_inner_names.push_back("InnerFirstDE"); + de_inner_names.push_back("InnerSecondDE"); + de_inner_names.push_back("InnerThirdDE"); + inner_blob.set_data_elt_names(de_inner_names); + inner_blob.set_name("Inner"); + + inner_str = "Grenoble"; + inner_bool = true; + + inner_blob << inner_str << inner_inner_blob << inner_bool; + + vector de_names; + de_names.push_back("1DE"); + de_names.push_back("2DE"); + dpb.set_data_elt_names(de_names); + + v_dl.clear(); + v_dl.push_back(3); + v_dl.push_back(4); + v_dl.push_back(5); + v_dl.push_back(6); + + dpb << inner_blob << v_dl; + this->push_pipe_event("RWPipe", &dpb); + } + else if (in == 1) + { + Tango::DevicePipeBlob dpb("PipeEventCase1"); + vector de_names; + de_names.push_back("Another_1DE"); + de_names.push_back("Another_2DE"); + dpb.set_data_elt_names(de_names); + + v_dl.clear(); + v_dl.push_back(2); + string str("Barcelona"); + + dpb << v_dl << str; + + this->push_pipe_event("RWPipe", &dpb); + } + else if (in == 2) + { + Tango::DevicePipeBlob dpb("PipeEventCase2"); + vector de_names; + de_names.push_back("Qwerty_1DE"); + de_names.push_back("Azerty_2DE"); + dpb.set_data_elt_names(de_names); + + string str("Barcelona"); + + dpb << str << v_dl; #ifdef WIN32 - struct _timeb tv; - tv.time = 10; - tv.millitm = 0; - this->push_pipe_event("RWPipe",&dpb,tv); + struct _timeb tv; + tv.time = 10; + tv.millitm = 0; + this->push_pipe_event("RWPipe",&dpb,tv); #else - struct timeval tv; - tv.tv_sec = 10; - tv.tv_usec = 0; - this->push_pipe_event("RWPipe",&dpb,tv); + struct timeval tv; + tv.tv_sec = 10; + tv.tv_usec = 0; + this->push_pipe_event("RWPipe", &dpb, tv); #endif - } - else if (in == 3) - { - Tango::DevErrorList del; - del.length(1); - del[0].reason = CORBA::string_dup("aaa"); - del[0].desc = CORBA::string_dup("bbb"); - del[0].origin = CORBA::string_dup("ccc"); - Tango::DevFailed df(del); - this->push_pipe_event("RWPipe",&df); - } - else if (in == 4) - { - Tango::DevicePipeBlob dpb("PipeEventCase4"); - vector de_names; - de_names.push_back("Lunes"); - de_names.push_back("Martes"); - dpb.set_data_elt_names(de_names); - - string str("Girona"); - - v_dl.clear(); - for (int loop = 0;loop < 3000;loop++) - v_dl.push_back(loop); - - dpb << str << v_dl; - - this->push_pipe_event("RWPipe",&dpb); - } + } + else if (in == 3) + { + Tango::DevErrorList del; + del.length(1); + del[0].reason = CORBA::string_dup("aaa"); + del[0].desc = CORBA::string_dup("bbb"); + del[0].origin = CORBA::string_dup("ccc"); + Tango::DevFailed df(del); + this->push_pipe_event("RWPipe", &df); + } + else if (in == 4) + { + Tango::DevicePipeBlob dpb("PipeEventCase4"); + vector de_names; + de_names.push_back("Lunes"); + de_names.push_back("Martes"); + dpb.set_data_elt_names(de_names); + + string str("Girona"); + + v_dl.clear(); + for (int loop = 0; loop < 3000; loop++) + { + v_dl.push_back(loop); + } + + dpb << str << v_dl; + + this->push_pipe_event("RWPipe", &dpb); + } } // ConfPipe bool DevTest::is_ConfPipe_allowed(Tango::PipeReqType) { - if (get_state() == Tango::ON) - return true; - else - return false; + if (get_state() == Tango::ON) + { + return true; + } + else + { + return false; + } } void DevTest::read_ConfPipe(TANGO_UNUSED(Tango::Pipe &pipe)) @@ -2609,13 +2690,13 @@ void DevTest::read_ConfPipe(TANGO_UNUSED(Tango::Pipe &pipe)) void DevTest::cmd_push_state_status_event() { - set_change_event("State",true,false); - set_change_event("Status",true,false); + set_change_event("State", true, false); + set_change_event("Status", true, false); this->push_change_event("state"); this->push_change_event("status"); - set_change_event("State",false,false); - set_change_event("Status",false,false); + set_change_event("State", false, false); + set_change_event("Status", false, false); } diff --git a/cpp_test_suite/cpp_test_ds/DevTestClass.cpp b/cpp_test_suite/cpp_test_ds/DevTestClass.cpp index 297013232..0b18dcdcc 100644 --- a/cpp_test_suite/cpp_test_ds/DevTestClass.cpp +++ b/cpp_test_suite/cpp_test_ds/DevTestClass.cpp @@ -19,7 +19,6 @@ #include "IOAddAttribute.h" - DevTestClass *DevTestClass::_instance = NULL; //+---------------------------------------------------------------------------- @@ -32,14 +31,15 @@ DevTestClass *DevTestClass::_instance = NULL; // //----------------------------------------------------------------------------- -DevTestClass::DevTestClass(string &s):Tango::DeviceClass(s) +DevTestClass::DevTestClass(string &s) + : Tango::DeviceClass(s) { - cout2 << "Entering DevTestClass constructor" << endl; + cout2 << "Entering DevTestClass constructor" << endl; - set_type("TestDevice"); + set_type("TestDevice"); - cout2 << "Leaving DevTestClass constructor" << endl; + cout2 << "Leaving DevTestClass constructor" << endl; } @@ -56,29 +56,29 @@ DevTestClass::DevTestClass(string &s):Tango::DeviceClass(s) DevTestClass *DevTestClass::init(const char *name) { - if (_instance == NULL) - { - try - { - string s(name); - _instance = new DevTestClass(s); - } - catch (bad_alloc) - { - throw; - } - } - return _instance; + if (_instance == NULL) + { + try + { + string s(name); + _instance = new DevTestClass(s); + } + catch (bad_alloc) + { + throw; + } + } + return _instance; } DevTestClass *DevTestClass::instance() { - if (_instance == NULL) - { - cerr << "Class is not initialised !!" << endl; - exit(-1); - } - return _instance; + if (_instance == NULL) + { + cerr << "Class is not initialised !!" << endl; + exit(-1); + } + return _instance; } //+---------------------------------------------------------------------------- @@ -92,563 +92,566 @@ DevTestClass *DevTestClass::instance() void DevTestClass::command_factory() { - command_list.push_back(new IOString("IOString", - Tango::DEV_STRING, - Tango::DEV_STRING, - "Word", - "the pallindrome is")); - command_list.push_back(new IOBool("IOBool", - Tango::DEV_BOOLEAN, - Tango::DEV_BOOLEAN, - "Number", - "Not number")); - command_list.push_back(new IOShort("IOShort", - Tango::DEV_SHORT, - Tango::DEV_SHORT, - "Number", - "Number * 2")); - command_list.push_back(new IOLong("IOLong", - Tango::DEV_LONG, - Tango::DEV_LONG, - "Number", - "Number * 2")); - command_list.push_back(new IOFloat("IOFloat", - Tango::DEV_FLOAT, - Tango::DEV_FLOAT, - "Number", - "Number * 2")); - command_list.push_back(new IODouble("IODouble", - Tango::DEV_DOUBLE, - Tango::DEV_DOUBLE, - "Number", - "Number * 2")); - command_list.push_back(new IOUShort("IOUShort", - Tango::DEV_USHORT, - Tango::DEV_USHORT, - "Number", - "Number * 2")); - command_list.push_back(new IOULong("IOULong", - Tango::DEV_ULONG, - Tango::DEV_ULONG, - "Number", - "Number * 2")); - command_list.push_back(new IOBooleanArray("IOBoolArray", + command_list.push_back(new IOString("IOString", + Tango::DEV_STRING, + Tango::DEV_STRING, + "Word", + "the pallindrome is")); + command_list.push_back(new IOBool("IOBool", + Tango::DEV_BOOLEAN, + Tango::DEV_BOOLEAN, + "Number", + "Not number")); + command_list.push_back(new IOShort("IOShort", + Tango::DEV_SHORT, + Tango::DEV_SHORT, + "Number", + "Number * 2")); + command_list.push_back(new IOLong("IOLong", + Tango::DEV_LONG, + Tango::DEV_LONG, + "Number", + "Number * 2")); + command_list.push_back(new IOFloat("IOFloat", + Tango::DEV_FLOAT, + Tango::DEV_FLOAT, + "Number", + "Number * 2")); + command_list.push_back(new IODouble("IODouble", + Tango::DEV_DOUBLE, + Tango::DEV_DOUBLE, + "Number", + "Number * 2")); + command_list.push_back(new IOUShort("IOUShort", + Tango::DEV_USHORT, + Tango::DEV_USHORT, + "Number", + "Number * 2")); + command_list.push_back(new IOULong("IOULong", + Tango::DEV_ULONG, + Tango::DEV_ULONG, + "Number", + "Number * 2")); + command_list.push_back(new IOBooleanArray("IOBoolArray", Tango::DEVVAR_BOOLEANARRAY, Tango::DEVVAR_BOOLEANARRAY, "Array of boolean", "Echo")); command_list.push_back(new IOCharArray("IOCharArray", - Tango::DEVVAR_CHARARRAY, - Tango::DEVVAR_CHARARRAY, - "Array of char", - "This reversed array")); - command_list.push_back(new IOShortArray("IOShortArray", - Tango::DEVVAR_SHORTARRAY, - Tango::DEVVAR_SHORTARRAY, - "Array of short", - "This array * 2")); - command_list.push_back(new IOLongArray("IOLongArray", - Tango::DEVVAR_LONGARRAY, - Tango::DEVVAR_LONGARRAY, - "Array of long", - "This array * 2")); - command_list.push_back(new IOFloatArray("IOFloatArray", - Tango::DEVVAR_FLOATARRAY, - Tango::DEVVAR_FLOATARRAY, - "Array of float", - "This array * 2")); - command_list.push_back(new IODoubleArray("IODoubleArray", - Tango::DEVVAR_DOUBLEARRAY, - Tango::DEVVAR_DOUBLEARRAY, - "Array of double", - "This array * 2")); - command_list.push_back(new IOUShortArray("IOUShortArray", - Tango::DEVVAR_USHORTARRAY, - Tango::DEVVAR_USHORTARRAY, - "Array of unsigned short", - "This array * 2")); - command_list.push_back(new IOULongArray("IOULongArray", - Tango::DEVVAR_ULONGARRAY, - Tango::DEVVAR_ULONGARRAY, - "Array of unsigned long", - "This array * 2")); - command_list.push_back(new IOStringArray("IOStringArray", - Tango::DEVVAR_STRINGARRAY, - Tango::DEVVAR_STRINGARRAY, - "Array of string", - "This reversed array ")); - command_list.push_back(new IOLongString("IOLongString", - Tango::DEVVAR_LONGSTRINGARRAY, - Tango::DEVVAR_LONGSTRINGARRAY, - "Array of long and string", - "This array of long * 2")); - command_list.push_back(new IODoubleString("IODoubleString", - Tango::DEVVAR_DOUBLESTRINGARRAY, - Tango::DEVVAR_DOUBLESTRINGARRAY, - "Array of double and string", - "This array of long * 2")); - command_list.push_back(new IOThrow("IOThrow", - Tango::DEVVAR_LONGSTRINGARRAY, - Tango::DEV_VOID, - "Error facility", - "An exception")); - command_list.push_back(new IOReThrow("IOReThrow", - Tango::DEVVAR_LONGSTRINGARRAY, - Tango::DEV_VOID, - "Error facility", - "An exception")); - command_list.push_back(new IOExcept("IOExcept", - Tango::DEV_VOID, - Tango::DEV_VOID, - "Void", - "An exception")); - command_list.push_back(new IOVoid("IOVoid", - Tango::DEV_VOID, - Tango::DEV_VOID, - "void", - "void")); - command_list.push_back(new IOSleep("IOSleep", - Tango::DEV_USHORT, - Tango::DEV_VOID, - "sleeping time", - "void")); - command_list.push_back(new IOState("IOState", - Tango::DEV_STATE, - Tango::DEV_VOID, - "New device state", - "void")); - command_list.push_back(new IORegSig("IORegSig", - Tango::DEV_LONG, - Tango::DEV_VOID, - "Signal number", - "void")); - command_list.push_back(new IORegSigOwn("IORegSigOwn", - Tango::DEV_LONG, - Tango::DEV_VOID, - "Signal number", - "void")); - command_list.push_back(new IOUnregSig("IOUnregSig", - Tango::DEV_LONG, - Tango::DEV_VOID, - "Signal number", - "void")); - command_list.push_back(new IORegClassSig("IORegClassSig", - Tango::DEV_LONG, - Tango::DEV_VOID, - "Signal number", - "void")); - command_list.push_back(new IOUnregClassSig("IOUnregClassSig", - Tango::DEV_LONG, - Tango::DEV_VOID, - "Signal number", - "void")); - command_list.push_back(new IOStr1("IOStr1", - Tango::DEV_VOID, - Tango::DEV_STRING, - "void", - "Just a string dynamically allocated")); - command_list.push_back(new IOPollStr1("IOPollStr1", - Tango::DEV_VOID, - Tango::DEV_STRING, - "void", - "Just a string dynamically allocated changing at each call")); - command_list.push_back(new IOStr2("IOStr2", - Tango::DEV_VOID, - Tango::DEV_STRING, - "void", - "A constant string")); - command_list.push_back(new IOArray1("IOArray1", - Tango::DEV_VOID, - Tango::DEVVAR_LONGARRAY, - "void", - "An array allocated")); - command_list.push_back(new IOArray2("IOArray2", - Tango::DEV_VOID, - Tango::DEVVAR_SHORTARRAY, - "void", - "An array without copying")); - command_list.push_back(new IOPollArray2("IOPollArray2", - Tango::DEV_VOID, - Tango::DEVVAR_SHORTARRAY, - "void", - "An array without copying changing at each call")); - command_list.push_back(new IOStrArray("IOStrArray", - Tango::DEV_VOID, - Tango::DEVVAR_STRINGARRAY, - "void", - "A string array")); - command_list.push_back(new IOStruct("IOStruct", - Tango::DEV_VOID, - Tango::DEVVAR_LONGSTRINGARRAY, - "void", - "A structure type")); - command_list.push_back(new IODevListByClass("IODevListByClass", - Tango::DEV_STRING, - Tango::DEV_STRING, - "class name", - "class first device name")); - command_list.push_back(new IODevByName("IODevByName", - Tango::DEV_STRING, - Tango::DEV_STRING, - "device name", - "device name (returned by name()")); - command_list.push_back(new IODServDevice("IODServDevice", - Tango::DEV_VOID, - Tango::DEV_STRING, - "void", - "dserver device name")); - command_list.push_back(new IOSetAttr("IOSetAttr", - Tango::DEV_LONG, - Tango::DEV_VOID, - "New attr value", - "void")); - command_list.push_back(new IOAddAttribute("IOAddAttribute", - Tango::DEV_STRING, - Tango::DEV_VOID, - "New attribute name", - "void")); - command_list.push_back(new IORemoveAttribute("IORemoveAttribute", - Tango::DEV_STRING, - Tango::DEV_VOID, - "Attribute name", - "void")); - command_list.push_back(new IOSeqVecChar("IOSeqVecChar", - Tango::DEVVAR_CHARARRAY, - Tango::DEVVAR_CHARARRAY, - "Input char array", - "Output char array")); - command_list.push_back(new IOSeqVecShort("IOSeqVecShort", - Tango::DEVVAR_SHORTARRAY, - Tango::DEVVAR_SHORTARRAY, - "Input short array", - "Output short array")); - command_list.push_back(new IOSeqVecLong("IOSeqVecLong", - Tango::DEVVAR_LONGARRAY, - Tango::DEVVAR_LONGARRAY, - "Input long array", - "Output long array")); - command_list.push_back(new IOSeqVecFloat("IOSeqVecFloat", - Tango::DEVVAR_FLOATARRAY, - Tango::DEVVAR_FLOATARRAY, - "Input float array", - "Output float array")); - command_list.push_back(new IOSeqVecDouble("IOSeqVecDouble", - Tango::DEVVAR_DOUBLEARRAY, - Tango::DEVVAR_DOUBLEARRAY, - "Input double array", - "Output double array")); - command_list.push_back(new IOSeqVecUShort("IOSeqVecUShort", - Tango::DEVVAR_USHORTARRAY, - Tango::DEVVAR_USHORTARRAY, - "Input unsigned short array", - "Output unsigned short array")); - command_list.push_back(new IOSeqVecULong("IOSeqVecULong", - Tango::DEVVAR_ULONGARRAY, - Tango::DEVVAR_ULONGARRAY, - "Input unsigned long array", - "Output unsigned long array")); - command_list.push_back(new IOSeqVecString("IOSeqVecString", - Tango::DEVVAR_STRINGARRAY, - Tango::DEVVAR_STRINGARRAY, - "Input string array", - "Output string array")); - command_list.push_back(new IOStartPoll("IOStartPoll", - Tango::DEV_VOID, - Tango::DEV_LONG, - "Void", - "Constant number set to 11")); + Tango::DEVVAR_CHARARRAY, + Tango::DEVVAR_CHARARRAY, + "Array of char", + "This reversed array")); + command_list.push_back(new IOShortArray("IOShortArray", + Tango::DEVVAR_SHORTARRAY, + Tango::DEVVAR_SHORTARRAY, + "Array of short", + "This array * 2")); + command_list.push_back(new IOLongArray("IOLongArray", + Tango::DEVVAR_LONGARRAY, + Tango::DEVVAR_LONGARRAY, + "Array of long", + "This array * 2")); + command_list.push_back(new IOFloatArray("IOFloatArray", + Tango::DEVVAR_FLOATARRAY, + Tango::DEVVAR_FLOATARRAY, + "Array of float", + "This array * 2")); + command_list.push_back(new IODoubleArray("IODoubleArray", + Tango::DEVVAR_DOUBLEARRAY, + Tango::DEVVAR_DOUBLEARRAY, + "Array of double", + "This array * 2")); + command_list.push_back(new IOUShortArray("IOUShortArray", + Tango::DEVVAR_USHORTARRAY, + Tango::DEVVAR_USHORTARRAY, + "Array of unsigned short", + "This array * 2")); + command_list.push_back(new IOULongArray("IOULongArray", + Tango::DEVVAR_ULONGARRAY, + Tango::DEVVAR_ULONGARRAY, + "Array of unsigned long", + "This array * 2")); + command_list.push_back(new IOStringArray("IOStringArray", + Tango::DEVVAR_STRINGARRAY, + Tango::DEVVAR_STRINGARRAY, + "Array of string", + "This reversed array ")); + command_list.push_back(new IOLongString("IOLongString", + Tango::DEVVAR_LONGSTRINGARRAY, + Tango::DEVVAR_LONGSTRINGARRAY, + "Array of long and string", + "This array of long * 2")); + command_list.push_back(new IODoubleString("IODoubleString", + Tango::DEVVAR_DOUBLESTRINGARRAY, + Tango::DEVVAR_DOUBLESTRINGARRAY, + "Array of double and string", + "This array of long * 2")); + command_list.push_back(new IOThrow("IOThrow", + Tango::DEVVAR_LONGSTRINGARRAY, + Tango::DEV_VOID, + "Error facility", + "An exception")); + command_list.push_back(new IOReThrow("IOReThrow", + Tango::DEVVAR_LONGSTRINGARRAY, + Tango::DEV_VOID, + "Error facility", + "An exception")); + command_list.push_back(new IOExcept("IOExcept", + Tango::DEV_VOID, + Tango::DEV_VOID, + "Void", + "An exception")); + command_list.push_back(new IOVoid("IOVoid", + Tango::DEV_VOID, + Tango::DEV_VOID, + "void", + "void")); + command_list.push_back(new IOSleep("IOSleep", + Tango::DEV_USHORT, + Tango::DEV_VOID, + "sleeping time", + "void")); + command_list.push_back(new IOState("IOState", + Tango::DEV_STATE, + Tango::DEV_VOID, + "New device state", + "void")); + command_list.push_back(new IORegSig("IORegSig", + Tango::DEV_LONG, + Tango::DEV_VOID, + "Signal number", + "void")); + command_list.push_back(new IORegSigOwn("IORegSigOwn", + Tango::DEV_LONG, + Tango::DEV_VOID, + "Signal number", + "void")); + command_list.push_back(new IOUnregSig("IOUnregSig", + Tango::DEV_LONG, + Tango::DEV_VOID, + "Signal number", + "void")); + command_list.push_back(new IORegClassSig("IORegClassSig", + Tango::DEV_LONG, + Tango::DEV_VOID, + "Signal number", + "void")); + command_list.push_back(new IOUnregClassSig("IOUnregClassSig", + Tango::DEV_LONG, + Tango::DEV_VOID, + "Signal number", + "void")); + command_list.push_back(new IOStr1("IOStr1", + Tango::DEV_VOID, + Tango::DEV_STRING, + "void", + "Just a string dynamically allocated")); + command_list.push_back(new IOPollStr1("IOPollStr1", + Tango::DEV_VOID, + Tango::DEV_STRING, + "void", + "Just a string dynamically allocated changing at each call")); + command_list.push_back(new IOStr2("IOStr2", + Tango::DEV_VOID, + Tango::DEV_STRING, + "void", + "A constant string")); + command_list.push_back(new IOArray1("IOArray1", + Tango::DEV_VOID, + Tango::DEVVAR_LONGARRAY, + "void", + "An array allocated")); + command_list.push_back(new IOArray2("IOArray2", + Tango::DEV_VOID, + Tango::DEVVAR_SHORTARRAY, + "void", + "An array without copying")); + command_list.push_back(new IOPollArray2("IOPollArray2", + Tango::DEV_VOID, + Tango::DEVVAR_SHORTARRAY, + "void", + "An array without copying changing at each call")); + command_list.push_back(new IOStrArray("IOStrArray", + Tango::DEV_VOID, + Tango::DEVVAR_STRINGARRAY, + "void", + "A string array")); + command_list.push_back(new IOStruct("IOStruct", + Tango::DEV_VOID, + Tango::DEVVAR_LONGSTRINGARRAY, + "void", + "A structure type")); + command_list.push_back(new IODevListByClass("IODevListByClass", + Tango::DEV_STRING, + Tango::DEV_STRING, + "class name", + "class first device name")); + command_list.push_back(new IODevByName("IODevByName", + Tango::DEV_STRING, + Tango::DEV_STRING, + "device name", + "device name (returned by name()")); + command_list.push_back(new IODServDevice("IODServDevice", + Tango::DEV_VOID, + Tango::DEV_STRING, + "void", + "dserver device name")); + command_list.push_back(new IOSetAttr("IOSetAttr", + Tango::DEV_LONG, + Tango::DEV_VOID, + "New attr value", + "void")); + command_list.push_back(new IOAddAttribute("IOAddAttribute", + Tango::DEV_STRING, + Tango::DEV_VOID, + "New attribute name", + "void")); + command_list.push_back(new IORemoveAttribute("IORemoveAttribute", + Tango::DEV_STRING, + Tango::DEV_VOID, + "Attribute name", + "void")); + command_list.push_back(new IOSeqVecChar("IOSeqVecChar", + Tango::DEVVAR_CHARARRAY, + Tango::DEVVAR_CHARARRAY, + "Input char array", + "Output char array")); + command_list.push_back(new IOSeqVecShort("IOSeqVecShort", + Tango::DEVVAR_SHORTARRAY, + Tango::DEVVAR_SHORTARRAY, + "Input short array", + "Output short array")); + command_list.push_back(new IOSeqVecLong("IOSeqVecLong", + Tango::DEVVAR_LONGARRAY, + Tango::DEVVAR_LONGARRAY, + "Input long array", + "Output long array")); + command_list.push_back(new IOSeqVecFloat("IOSeqVecFloat", + Tango::DEVVAR_FLOATARRAY, + Tango::DEVVAR_FLOATARRAY, + "Input float array", + "Output float array")); + command_list.push_back(new IOSeqVecDouble("IOSeqVecDouble", + Tango::DEVVAR_DOUBLEARRAY, + Tango::DEVVAR_DOUBLEARRAY, + "Input double array", + "Output double array")); + command_list.push_back(new IOSeqVecUShort("IOSeqVecUShort", + Tango::DEVVAR_USHORTARRAY, + Tango::DEVVAR_USHORTARRAY, + "Input unsigned short array", + "Output unsigned short array")); + command_list.push_back(new IOSeqVecULong("IOSeqVecULong", + Tango::DEVVAR_ULONGARRAY, + Tango::DEVVAR_ULONGARRAY, + "Input unsigned long array", + "Output unsigned long array")); + command_list.push_back(new IOSeqVecString("IOSeqVecString", + Tango::DEVVAR_STRINGARRAY, + Tango::DEVVAR_STRINGARRAY, + "Input string array", + "Output string array")); + command_list.push_back(new IOStartPoll("IOStartPoll", + Tango::DEV_VOID, + Tango::DEV_LONG, + "Void", + "Constant number set to 11")); // command_list.back()->set_polling_period(400); - command_list.push_back(new IOShortSleep("IOShortSleep", - Tango::DEVVAR_SHORTARRAY, - Tango::DEV_SHORT, - "Input short and sleeping time in sec", - "Output short (in * 2)")); - command_list.push_back(new IOSleepExcept("IOSleepExcept", - Tango::DEV_SHORT, - Tango::DEV_VOID, - "Sleep time (sec)", - "An exception")); - command_list.push_back(new IOExit("IOExit", - Tango::DEV_VOID, - Tango::DEV_VOID, - "void", - "void")); - command_list.push_back(new IOTrigPoll("IOTrigPoll", - Tango::DEV_STRING, - Tango::DEV_VOID, - "Command's name to trig polling", - "void")); - command_list.push_back(new IOAttrTrigPoll("IOAttrTrigPoll", - Tango::DEV_STRING, - Tango::DEV_VOID, - "Attribute's name to trig polling", - "void")); - command_list.push_back(new IOInitWAttr("IOInitWAttr", - Tango::DEV_VOID, - Tango::DEV_VOID, - "void", - "void")); - command_list.push_back(new IOAttrThrowEx("IOAttrThrowEx", - Tango::DEVVAR_SHORTARRAY, - Tango::DEV_VOID, - "2 elts : Attr code and throw except flag", - "void")); - command_list.push_back(new IOAddOneElt("IOAddOneElt", - Tango::DEV_VOID, - Tango::DEV_VOID, - "void", - "void")); - command_list.push_back(new IORemoveOneElt("IORemoveOneElt", - Tango::DEV_VOID, - Tango::DEV_VOID, - "void", - "void")); - command_list.push_back(new IOIncValue("IOIncValue", - Tango::DEV_VOID, - Tango::DEV_VOID, - "void", - "void")); - command_list.push_back(new IODecValue("IODecValue", - Tango::DEV_VOID, - Tango::DEV_VOID, - "void", - "void")); - command_list.push_back(new IOChangeQuality("IOChangeQuality", - Tango::DEV_SHORT, - Tango::DEV_VOID, - "0->VALID, 1->INVALID, 2->ALARM, 3->CHANGING", - "void")); - command_list.push_back(new IOPushEvent("IOPushEvent", - Tango::DEV_VOID, - Tango::DEV_VOID, - "void", - "void")); - command_list.push_back(new IOPushDevEncodedEvent("IOPushDevEncodedEvent", - Tango::DEV_VOID, - Tango::DEV_VOID, - "void", - "void")); - command_list.push_back(new IOSubscribeEvent("IOSubscribeEvent", - Tango::DEVVAR_STRINGARRAY, - Tango::DEV_LONG, - "str[0] = device name, str[1] = attribute name, str[2] = event type", - "Event identifier")); - command_list.push_back(new IOUnSubscribeEvent("IOUnSubscribeEvent", - Tango::DEV_LONG, - Tango::DEV_VOID, - "Event identifier", - "void")); - command_list.push_back(new IOGetCbExecuted("IOGetCbExecuted", - Tango::DEV_VOID, - Tango::DEV_LONG, - "void", - "Number of times the CB has been executed")); - command_list.push_back(new IOFillPollBuffAttr("IOFillPollBuffAttr", - Tango::DEV_VOID, - Tango::DEV_VOID, - "void", - "void")); - command_list.push_back(new IOFillPollBuffEncodedAttr("IOFillPollBuffEncodedAttr", - Tango::DEV_VOID, - Tango::DEV_VOID, - "void", - "void")); - command_list.push_back(new IOFillPollBuffCmd("IOFillPollBuffCmd", - Tango::DEV_VOID, - Tango::DEV_VOID, - "void", - "void")); - command_list.push_back(new FileDbCmd("FileDb", - Tango::DEV_VOID, - Tango::DEV_VOID, - "void", - "void")); - command_list.push_back(new OLong("OLong", - Tango::DEV_VOID, - Tango::DEV_LONG, - "void", - "A long")); - command_list.push_back(new OULong("OULong", - Tango::DEV_VOID, - Tango::DEV_ULONG, - "void", - "An unsigned long")); - command_list.push_back(new OLongArray("OLongArray", - Tango::DEV_VOID, - Tango::DEVVAR_LONGARRAY, - "void", - "A long array")); - command_list.push_back(new OULongArray("OULongArray", - Tango::DEV_VOID, - Tango::DEVVAR_ULONGARRAY, - "void", - "A unsigned long array")); - command_list.push_back(new OLongString("OLongString", - Tango::DEV_VOID, - Tango::DEVVAR_LONGSTRINGARRAY, - "void", - "A unsigned long and string array")); - command_list.push_back(new GetLongSize("GetLongSize", - Tango::DEV_VOID, - Tango::DEV_SHORT, - "void", - "Sizeof long (32 or 64 bits)")); - command_list.push_back(new IOSetWAttrLimit("IOSetWAttrLimit", - Tango::DEVVAR_DOUBLEARRAY, - Tango::DEV_VOID, - "arr[0]==0 -> min_value, arr[0]==1 -> max_value, arr[1]=limit", - "void")); - command_list.push_back(new IOLong64("IOLong64", - Tango::DEV_LONG64, - Tango::DEV_LONG64, - "Number", - "Number * 2")); - command_list.push_back(new IOULong64("IOULong64", - Tango::DEV_ULONG64, - Tango::DEV_ULONG64, - "Number", - "Number * 2")); - command_list.push_back(new ChangeEncodedFormat("ChangeEncodedFormat", - Tango::DEV_VOID, - Tango::DEV_VOID, - "void", - "void")); - command_list.push_back(new ChangeEncodedData("ChangeEncodedData", - Tango::DEV_VOID, - Tango::DEV_VOID, - "void", - "void")); - command_list.push_back(new PushDataReady("PushDataReady", - Tango::DEVVAR_LONGSTRINGARRAY, - Tango::DEV_VOID, - "s[0] = attribute name, l[0] = user counter", - "void")); - command_list.push_back(new SubDeviceTst("SubDeviceTst", - Tango::DEV_VOID, - Tango::DEV_BOOLEAN, - "void", - "true = sub device connected")); - command_list.push_back(new IOEncoded("IOEncoded", - Tango::DEV_ENCODED, - Tango::DEV_ENCODED, - "DevEncoded structure", - "DevEncoded structure")); - command_list.push_back(new OEncoded("OEncoded", - Tango::DEV_VOID, - Tango::DEV_ENCODED, - "void", - "DevEncoded structure to test polling/history")); - command_list.push_back(new PollingPoolTst("PollingPoolTst", - Tango::DEV_VOID, - Tango::DEVVAR_STRINGARRAY, - "void", - "Polling threads pool configuration")); - command_list.push_back(new SetGetAlarms("SetGetAlarms", - Tango::DEV_VOID, - Tango::DEVVAR_STRINGARRAY, - "void", - "DevVarStringArray containing alarm values")); - command_list.push_back(new SetGetRanges("SetGetRanges", - Tango::DEV_VOID, - Tango::DEVVAR_STRINGARRAY, - "void", - "DevVarStringArray containing ranges values")); - command_list.push_back(new SetGetProperties("SetGetProperties", - Tango::DEV_VOID, - Tango::DEVVAR_STRINGARRAY, - "void", - "DevVarStringArray containing properties values")); - command_list.push_back(new PollingInDeviceTst("IOPollingInDevice", - Tango::DEV_VOID, - Tango::DEVVAR_STRINGARRAY, - "void", - "Polling in device test outputs")); - command_list.push_back(new SophisPollInDeviceTst("IOSophisticatedPollInDevice", - Tango::DEV_VOID, - Tango::DEV_VOID, - "void", - "void")); - command_list.push_back(new GetPollMess("IOGetPollMess", - Tango::DEV_VOID, - Tango::DEVVAR_STRINGARRAY, - "void", - "SophisticatedPollInDevice polling messages")); - command_list.push_back(new WriteAttrHardwareThrow("WriteAttrHardwareThrow", - Tango::DEV_SHORT, - Tango::DEV_VOID, - "Type of exception to be thrown by write_attr_hardware() method", - "void")); - command_list.push_back(new IOAddCommand("IOAddCommand", - Tango::DEV_LONG, - Tango::DEV_VOID, - "True if command must be added at device level", - "void")); - command_list.push_back(new IORemoveCommand("IORemoveCommand", - Tango::DEV_VOID, - Tango::DEV_VOID, - "void", - "void")); - command_list.push_back(new SetEnumLabels("SetEnumLabels", - Tango::DEV_VOID, - Tango::DEV_VOID, - "void", - "void")); - command_list.push_back(new AddEnumLabel("AddEnumLabel", - Tango::DEV_STRING, - Tango::DEV_VOID, - "New enum label", - "void")); - command_list.push_back(new ForbiddenEnumValue("ForbiddenEnumValue", - Tango::DEV_SHORT, - Tango::DEV_VOID, - "New value for setting enum (Must be > 100)", - "void")); - - command_list.push_back(new SetPipeOutput("SetPipeOutput", - Tango::DEV_SHORT, - Tango::DEV_VOID, - "Select RPipe output type", - "void")); - - command_list.push_back(new PushPipeEvent("PushPipeEvent", - Tango::DEV_SHORT, - Tango::DEV_VOID, - "Pipe data type", - "void")); - - command_list.push_back(new PushStateStatusChangeEvent("PushStateStatusChangeEvent", - Tango::DEV_VOID, - Tango::DEV_VOID, - "void", - "void")); - - command_list.push_back(new Tango::TemplCommand((const char *)"IOTempl", - static_cast(&DevTest::IOTempl))); - - command_list.push_back(new Tango::TemplCommand((const char *)"IOTemplState", - static_cast(&DevTest::IOTempl), - static_cast(&DevTest::templ_state))); - - command_list.push_back(new Tango::TemplCommandIn((const char *)"IOTemplIn", - static_cast(&DevTest::IOTemplIn))); - - command_list.push_back(new Tango::TemplCommandIn((const char *)"IOTemplInState", - static_cast(&DevTest::IOTemplIn), - static_cast(&DevTest::templ_state))); - - command_list.push_back(new Tango::TemplCommandOut((const char *)"IOTemplOut", - static_cast(&DevTest::IOTemplOut))); - - command_list.push_back(new Tango::TemplCommandOut((const char *)"IOTemplOutState", - static_cast(&DevTest::IOTemplOut), - static_cast(&DevTest::templ_state))); - - command_list.push_back(new Tango::TemplCommandInOut((const char *)"IOTemplInOut", - static_cast(&DevTest::IOTemplInOut))); - - command_list.push_back(new Tango::TemplCommandInOut((const char *)"IOTemplInOutState", - static_cast(&DevTest::IOTemplInOut), - static_cast(&DevTest::templ_state))); + command_list.push_back(new IOShortSleep("IOShortSleep", + Tango::DEVVAR_SHORTARRAY, + Tango::DEV_SHORT, + "Input short and sleeping time in sec", + "Output short (in * 2)")); + command_list.push_back(new IOSleepExcept("IOSleepExcept", + Tango::DEV_SHORT, + Tango::DEV_VOID, + "Sleep time (sec)", + "An exception")); + command_list.push_back(new IOExit("IOExit", + Tango::DEV_VOID, + Tango::DEV_VOID, + "void", + "void")); + command_list.push_back(new IOTrigPoll("IOTrigPoll", + Tango::DEV_STRING, + Tango::DEV_VOID, + "Command's name to trig polling", + "void")); + command_list.push_back(new IOAttrTrigPoll("IOAttrTrigPoll", + Tango::DEV_STRING, + Tango::DEV_VOID, + "Attribute's name to trig polling", + "void")); + command_list.push_back(new IOInitWAttr("IOInitWAttr", + Tango::DEV_VOID, + Tango::DEV_VOID, + "void", + "void")); + command_list.push_back(new IOAttrThrowEx("IOAttrThrowEx", + Tango::DEVVAR_SHORTARRAY, + Tango::DEV_VOID, + "2 elts : Attr code and throw except flag", + "void")); + command_list.push_back(new IOAddOneElt("IOAddOneElt", + Tango::DEV_VOID, + Tango::DEV_VOID, + "void", + "void")); + command_list.push_back(new IORemoveOneElt("IORemoveOneElt", + Tango::DEV_VOID, + Tango::DEV_VOID, + "void", + "void")); + command_list.push_back(new IOIncValue("IOIncValue", + Tango::DEV_VOID, + Tango::DEV_VOID, + "void", + "void")); + command_list.push_back(new IODecValue("IODecValue", + Tango::DEV_VOID, + Tango::DEV_VOID, + "void", + "void")); + command_list.push_back(new IOChangeQuality("IOChangeQuality", + Tango::DEV_SHORT, + Tango::DEV_VOID, + "0->VALID, 1->INVALID, 2->ALARM, 3->CHANGING", + "void")); + command_list.push_back(new IOPushEvent("IOPushEvent", + Tango::DEV_VOID, + Tango::DEV_VOID, + "void", + "void")); + command_list.push_back(new IOPushDevEncodedEvent("IOPushDevEncodedEvent", + Tango::DEV_VOID, + Tango::DEV_VOID, + "void", + "void")); + command_list.push_back(new IOSubscribeEvent("IOSubscribeEvent", + Tango::DEVVAR_STRINGARRAY, + Tango::DEV_LONG, + "str[0] = device name, str[1] = attribute name, str[2] = event type", + "Event identifier")); + command_list.push_back(new IOUnSubscribeEvent("IOUnSubscribeEvent", + Tango::DEV_LONG, + Tango::DEV_VOID, + "Event identifier", + "void")); + command_list.push_back(new IOGetCbExecuted("IOGetCbExecuted", + Tango::DEV_VOID, + Tango::DEV_LONG, + "void", + "Number of times the CB has been executed")); + command_list.push_back(new IOFillPollBuffAttr("IOFillPollBuffAttr", + Tango::DEV_VOID, + Tango::DEV_VOID, + "void", + "void")); + command_list.push_back(new IOFillPollBuffEncodedAttr("IOFillPollBuffEncodedAttr", + Tango::DEV_VOID, + Tango::DEV_VOID, + "void", + "void")); + command_list.push_back(new IOFillPollBuffCmd("IOFillPollBuffCmd", + Tango::DEV_VOID, + Tango::DEV_VOID, + "void", + "void")); + command_list.push_back(new FileDbCmd("FileDb", + Tango::DEV_VOID, + Tango::DEV_VOID, + "void", + "void")); + command_list.push_back(new OLong("OLong", + Tango::DEV_VOID, + Tango::DEV_LONG, + "void", + "A long")); + command_list.push_back(new OULong("OULong", + Tango::DEV_VOID, + Tango::DEV_ULONG, + "void", + "An unsigned long")); + command_list.push_back(new OLongArray("OLongArray", + Tango::DEV_VOID, + Tango::DEVVAR_LONGARRAY, + "void", + "A long array")); + command_list.push_back(new OULongArray("OULongArray", + Tango::DEV_VOID, + Tango::DEVVAR_ULONGARRAY, + "void", + "A unsigned long array")); + command_list.push_back(new OLongString("OLongString", + Tango::DEV_VOID, + Tango::DEVVAR_LONGSTRINGARRAY, + "void", + "A unsigned long and string array")); + command_list.push_back(new GetLongSize("GetLongSize", + Tango::DEV_VOID, + Tango::DEV_SHORT, + "void", + "Sizeof long (32 or 64 bits)")); + command_list.push_back(new IOSetWAttrLimit("IOSetWAttrLimit", + Tango::DEVVAR_DOUBLEARRAY, + Tango::DEV_VOID, + "arr[0]==0 -> min_value, arr[0]==1 -> max_value, arr[1]=limit", + "void")); + command_list.push_back(new IOLong64("IOLong64", + Tango::DEV_LONG64, + Tango::DEV_LONG64, + "Number", + "Number * 2")); + command_list.push_back(new IOULong64("IOULong64", + Tango::DEV_ULONG64, + Tango::DEV_ULONG64, + "Number", + "Number * 2")); + command_list.push_back(new ChangeEncodedFormat("ChangeEncodedFormat", + Tango::DEV_VOID, + Tango::DEV_VOID, + "void", + "void")); + command_list.push_back(new ChangeEncodedData("ChangeEncodedData", + Tango::DEV_VOID, + Tango::DEV_VOID, + "void", + "void")); + command_list.push_back(new PushDataReady("PushDataReady", + Tango::DEVVAR_LONGSTRINGARRAY, + Tango::DEV_VOID, + "s[0] = attribute name, l[0] = user counter", + "void")); + command_list.push_back(new SubDeviceTst("SubDeviceTst", + Tango::DEV_VOID, + Tango::DEV_BOOLEAN, + "void", + "true = sub device connected")); + command_list.push_back(new IOEncoded("IOEncoded", + Tango::DEV_ENCODED, + Tango::DEV_ENCODED, + "DevEncoded structure", + "DevEncoded structure")); + command_list.push_back(new OEncoded("OEncoded", + Tango::DEV_VOID, + Tango::DEV_ENCODED, + "void", + "DevEncoded structure to test polling/history")); + command_list.push_back(new IODevEnum()); + command_list.push_back(new PollingPoolTst("PollingPoolTst", + Tango::DEV_VOID, + Tango::DEVVAR_STRINGARRAY, + "void", + "Polling threads pool configuration")); + command_list.push_back(new SetGetAlarms("SetGetAlarms", + Tango::DEV_VOID, + Tango::DEVVAR_STRINGARRAY, + "void", + "DevVarStringArray containing alarm values")); + command_list.push_back(new SetGetRanges("SetGetRanges", + Tango::DEV_VOID, + Tango::DEVVAR_STRINGARRAY, + "void", + "DevVarStringArray containing ranges values")); + command_list.push_back(new SetGetProperties("SetGetProperties", + Tango::DEV_VOID, + Tango::DEVVAR_STRINGARRAY, + "void", + "DevVarStringArray containing properties values")); + command_list.push_back(new PollingInDeviceTst("IOPollingInDevice", + Tango::DEV_VOID, + Tango::DEVVAR_STRINGARRAY, + "void", + "Polling in device test outputs")); + command_list.push_back(new SophisPollInDeviceTst("IOSophisticatedPollInDevice", + Tango::DEV_VOID, + Tango::DEV_VOID, + "void", + "void")); + command_list.push_back(new GetPollMess("IOGetPollMess", + Tango::DEV_VOID, + Tango::DEVVAR_STRINGARRAY, + "void", + "SophisticatedPollInDevice polling messages")); + command_list.push_back(new WriteAttrHardwareThrow("WriteAttrHardwareThrow", + Tango::DEV_SHORT, + Tango::DEV_VOID, + "Type of exception to be thrown by write_attr_hardware() method", + "void")); + command_list.push_back(new IOAddCommand("IOAddCommand", + Tango::DEV_LONG, + Tango::DEV_VOID, + "True if command must be added at device level", + "void")); + command_list.push_back(new IORemoveCommand("IORemoveCommand", + Tango::DEV_VOID, + Tango::DEV_VOID, + "void", + "void")); + command_list.push_back(new SetEnumLabels("SetEnumLabels", + Tango::DEV_VOID, + Tango::DEV_VOID, + "void", + "void")); + command_list.push_back(new AddEnumLabel("AddEnumLabel", + Tango::DEV_STRING, + Tango::DEV_VOID, + "New enum label", + "void")); + command_list.push_back(new ForbiddenEnumValue("ForbiddenEnumValue", + Tango::DEV_SHORT, + Tango::DEV_VOID, + "New value for setting enum (Must be > 100)", + "void")); + + command_list.push_back(new SetPipeOutput("SetPipeOutput", + Tango::DEV_SHORT, + Tango::DEV_VOID, + "Select RPipe output type", + "void")); + + command_list.push_back(new PushPipeEvent("PushPipeEvent", + Tango::DEV_SHORT, + Tango::DEV_VOID, + "Pipe data type", + "void")); + + command_list.push_back(new PushStateStatusChangeEvent("PushStateStatusChangeEvent", + Tango::DEV_VOID, + Tango::DEV_VOID, + "void", + "void")); + + command_list.push_back(new Tango::TemplCommand((const char *) "IOTempl", + static_cast(&DevTest::IOTempl))); + + command_list.push_back(new Tango::TemplCommand((const char *) "IOTemplState", + static_cast(&DevTest::IOTempl), + static_cast(&DevTest::templ_state))); + + command_list.push_back(new Tango::TemplCommandIn((const char *) "IOTemplIn", + static_cast(&DevTest::IOTemplIn))); + + command_list.push_back(new Tango::TemplCommandIn((const char *) "IOTemplInState", + static_cast(&DevTest::IOTemplIn), + static_cast(&DevTest::templ_state))); + + command_list.push_back(new Tango::TemplCommandOut((const char *) "IOTemplOut", + static_cast(&DevTest::IOTemplOut))); + + command_list.push_back(new Tango::TemplCommandOut((const char *) "IOTemplOutState", + static_cast(&DevTest::IOTemplOut), + static_cast(&DevTest::templ_state))); + + command_list.push_back( + new Tango::TemplCommandInOut((const char *) "IOTemplInOut", + static_cast(&DevTest::IOTemplInOut))); + + command_list.push_back(new Tango::TemplCommandInOut( + (const char *) "IOTemplInOutState", + static_cast(&DevTest::IOTemplInOut), + static_cast(&DevTest::templ_state))); } @@ -665,29 +668,34 @@ void DevTestClass::command_factory() //----------------------------------------------------------------------------- void DevTestClass::device_factory(const Tango::DevVarStringArray *devlist_ptr) { - for (unsigned long i = 0;i < devlist_ptr->length();i++) { - cout4 << "Device name : " << (*devlist_ptr)[i] << endl; + for (unsigned long i = 0; i < devlist_ptr->length(); i++) + { + cout4 << "Device name : " << (*devlist_ptr)[i] << endl; // // Create device and add it into the device list // - device_list.push_back(new DevTest(this, - (*devlist_ptr)[i])); - - // - // Export device to the outside world - // - if ((Tango::Util::_UseDb == true) && (Tango::Util::_FileDb == false)) - export_device(device_list.back()); - else - export_device(device_list.back(),(*devlist_ptr)[i]); - } + string dev_name((*devlist_ptr)[i]); + device_list.push_back(new DevTest(this, dev_name)); + + // + // Export device to the outside world + // + if ((Tango::Util::_UseDb == true) && (Tango::Util::_FileDb == false)) + { + export_device(device_list.back()); + } + else + { + export_device(device_list.back(), (*devlist_ptr)[i]); + } + } } void DevTestClass::device_name_factory(vector &list_name) { - list_name.push_back("The_first_device"); - list_name.push_back("The_second_device"); + list_name.push_back("The_first_device"); + list_name.push_back("The_second_device"); } void DevTestClass::signal_handler(long signo) @@ -697,254 +705,254 @@ void DevTestClass::signal_handler(long signo) // With logging, we must attach a log message to a device // - cout1 << "[Class signal handler] received signal number " - << signo - << " for class " - << name - << endl; + cout1 << "[Class signal handler] received signal number " + << signo + << " for class " + << name + << endl; } void DevTestClass::attribute_factory(vector &att_list) { - att_list.push_back(new Short_attrAttr()); - att_list.push_back(new Long_attrAttr()); - att_list.back()->set_data_ready_event(true); - att_list.push_back(new Long64_attrAttr()); - att_list.back()->set_data_ready_event(true); - att_list.push_back(new Double_attrAttr()); - att_list.push_back(new String_attrAttr()); + att_list.push_back(new Short_attrAttr()); + att_list.push_back(new Long_attrAttr()); + att_list.back()->set_data_ready_event(true); + att_list.push_back(new Long64_attrAttr()); + att_list.back()->set_data_ready_event(true); + att_list.push_back(new Double_attrAttr()); + att_list.push_back(new String_attrAttr()); // att_list.back()->set_polling_period(250); - att_list.push_back(new Short_spec_attrAttr()); - att_list.push_back(new Long_spec_attrAttr()); - att_list.push_back(new Double_spec_attrAttr()); - att_list.push_back(new String_spec_attrAttr()); - - att_list.push_back(new Short_ima_attrAttr()); - att_list.push_back(new Long_ima_attrAttr()); - att_list.push_back(new Double_ima_attrAttr()); - att_list.push_back(new String_ima_attrAttr()); - - att_list.push_back(new attr_no_dataAttr()); - att_list.push_back(new attr_wrong_typeAttr()); - att_list.push_back(new attr_wrong_sizeAttr()); - att_list.push_back(new attr_no_alarmAttr()); - - att_list.push_back(new Short_attr_with_wAttr()); - att_list.push_back(new Short_attr_rwAttr()); - att_list.push_back(new Short_attr_wAttr()); - - Tango::UserDefaultAttrProp def_prop; - def_prop.set_label("Test label"); - def_prop.set_description("Test description"); - def_prop.set_unit("Kilogramme"); - def_prop.set_standard_unit("100"); - def_prop.set_display_unit("Et ta soeur"); - def_prop.set_format("Tres long"); - def_prop.set_min_value("0"); - def_prop.set_max_value("100000"); - def_prop.set_min_alarm("1"); - def_prop.set_max_alarm("99999"); - def_prop.set_min_warning("2"); - def_prop.set_max_warning("99998"); - def_prop.set_delta_val("10000"); - def_prop.set_delta_t("1"); - def_prop.set_event_abs_change("30000"); - def_prop.set_event_rel_change("20000"); - def_prop.set_event_period("2000"); - def_prop.set_archive_event_abs_change("33333"); - def_prop.set_archive_event_rel_change("22222"); - def_prop.set_archive_event_period("3000"); + att_list.push_back(new Short_spec_attrAttr()); + att_list.push_back(new Long_spec_attrAttr()); + att_list.push_back(new Double_spec_attrAttr()); + att_list.push_back(new String_spec_attrAttr()); + + att_list.push_back(new Short_ima_attrAttr()); + att_list.push_back(new Long_ima_attrAttr()); + att_list.push_back(new Double_ima_attrAttr()); + att_list.push_back(new String_ima_attrAttr()); + + att_list.push_back(new attr_no_dataAttr()); + att_list.push_back(new attr_wrong_typeAttr()); + att_list.push_back(new attr_wrong_sizeAttr()); + att_list.push_back(new attr_no_alarmAttr()); + + att_list.push_back(new Short_attr_with_wAttr()); + att_list.push_back(new Short_attr_rwAttr()); + att_list.push_back(new Short_attr_wAttr()); + + Tango::UserDefaultAttrProp def_prop; + def_prop.set_label("Test label"); + def_prop.set_description("Test description"); + def_prop.set_unit("Kilogramme"); + def_prop.set_standard_unit("100"); + def_prop.set_display_unit("Et ta soeur"); + def_prop.set_format("Tres long"); + def_prop.set_min_value("0"); + def_prop.set_max_value("100000"); + def_prop.set_min_alarm("1"); + def_prop.set_max_alarm("99999"); + def_prop.set_min_warning("2"); + def_prop.set_max_warning("99998"); + def_prop.set_delta_val("10000"); + def_prop.set_delta_t("1"); + def_prop.set_event_abs_change("30000"); + def_prop.set_event_rel_change("20000"); + def_prop.set_event_period("2000"); + def_prop.set_archive_event_abs_change("33333"); + def_prop.set_archive_event_rel_change("22222"); + def_prop.set_archive_event_period("3000"); // Tango::Attr *at = new Tango::Attr("Long_attr_w", Tango::DEV_LONG, Tango::WRITE); - Tango::Attr *at = new Long_attr_wAttr(); - at->set_default_properties(def_prop); - att_list.push_back(at); - - att_list.push_back(new Double_attr_wAttr()); - att_list.push_back(new String_attr_wAttr()); - - att_list.push_back(new attr_asynAttr()); - att_list.push_back(new attr_asyn_toAttr()); - att_list.push_back(new attr_asyn_exceptAttr()); - att_list.push_back(new attr_asyn_writeAttr()); - att_list.push_back(new attr_asyn_write_toAttr()); - att_list.push_back(new attr_asyn_write_exceptAttr()); - - att_list.push_back(new PollLong_attrAttr()); - att_list.push_back(new PollString_spec_attrAttr()); - - att_list.push_back(new attr_dq_shAttr()); - att_list.push_back(new attr_dq_loAttr()); - att_list.push_back(new attr_dq_dbAttr()); - att_list.push_back(new attr_dq_strAttr()); - - Tango::UserDefaultAttrProp def_prop_1; - def_prop_1.set_max_value("100"); + Tango::Attr *at = new Long_attr_wAttr(); + at->set_default_properties(def_prop); + att_list.push_back(at); + + att_list.push_back(new Double_attr_wAttr()); + att_list.push_back(new String_attr_wAttr()); + + att_list.push_back(new attr_asynAttr()); + att_list.push_back(new attr_asyn_toAttr()); + att_list.push_back(new attr_asyn_exceptAttr()); + att_list.push_back(new attr_asyn_writeAttr()); + att_list.push_back(new attr_asyn_write_toAttr()); + att_list.push_back(new attr_asyn_write_exceptAttr()); + + att_list.push_back(new PollLong_attrAttr()); + att_list.push_back(new PollString_spec_attrAttr()); + + att_list.push_back(new attr_dq_shAttr()); + att_list.push_back(new attr_dq_loAttr()); + att_list.push_back(new attr_dq_dbAttr()); + att_list.push_back(new attr_dq_strAttr()); + + Tango::UserDefaultAttrProp def_prop_1; + def_prop_1.set_max_value("100"); // Tango::SpectrumAttr *sat = new Tango::SpectrumAttr("Short_spec_attr_w", Tango::DEV_SHORT,Tango::WRITE, 4); - Tango::SpectrumAttr *sat = new Short_spec_attr_wAttr(); - sat->set_default_properties(def_prop_1); - att_list.push_back(sat); - - att_list.push_back(new Long_spec_attr_wAttr()); - att_list.push_back(new Double_spec_attr_wAttr()); - att_list.push_back(new String_spec_attr_wAttr()); - att_list.push_back(new Short_ima_attr_wAttr()); - att_list.push_back(new String_ima_attr_wAttr()); - - att_list.push_back(new Short_spec_attr_rwAttr()); - att_list.push_back(new String_spec_attr_rwAttr()); - att_list.push_back(new Long_spec_attr_rwAttr()); - att_list.push_back(new Short_ima_attr_rwAttr()); - att_list.push_back(new String_ima_attr_rwAttr()); - - att_list.push_back(new Event_change_tstAttr()); - att_list.push_back(new Event64_change_tstAttr()); - att_list.push_back(new Event_quality_tstAttr()); - att_list.push_back(new Long_attr_with_wAttr()); - - att_list.push_back(new Short_attr_w2Attr()); - att_list.push_back(new String_attr_w2Attr()); - - att_list.push_back(new Poll_buffAttr()); - att_list.push_back(new Poll_buffRWAttr()); - - att_list.push_back(new Float_attrAttr()); - att_list.push_back(new Boolean_attrAttr()); - att_list.push_back(new UShort_attrAttr()); - att_list.push_back(new UChar_attrAttr()); - att_list.push_back(new ULong_attrAttr()); - att_list.push_back(new ULong64_attrAttr()); - - att_list.push_back(new Float_spec_attrAttr()); - att_list.push_back(new Boolean_spec_attrAttr()); - att_list.push_back(new UShort_spec_attrAttr()); - att_list.push_back(new UChar_spec_attrAttr()); - - att_list.push_back(new Float_attr_wAttr()); - att_list.push_back(new Boolean_attr_wAttr()); - att_list.push_back(new UShort_attr_wAttr()); - att_list.push_back(new UChar_attr_wAttr()); - - att_list.push_back(new Float_spec_attr_wAttr()); - att_list.push_back(new Boolean_spec_attr_wAttr()); - att_list.push_back(new UShort_spec_attr_wAttr()); - att_list.push_back(new UChar_spec_attr_wAttr()); - - att_list.push_back(new Float_ima_attr_wAttr()); - att_list.push_back(new UShort_ima_attr_wAttr()); - - att_list.push_back(new Float_spec_attr_rwAttr()); - att_list.push_back(new UChar_spec_attr_rwAttr()); - - att_list.push_back(new Boolean_ima_attr_rwAttr()); - att_list.push_back(new UShort_ima_attr_rwAttr()); - - att_list.push_back(new slow_actuatorAttr()); - att_list.push_back(new fast_actuatorAttr()); - - att_list.push_back(new Long64_attr_rwAttr()); - att_list.push_back(new ULong_attr_rwAttr()); - att_list.push_back(new ULong64_attr_rwAttr()); - att_list.push_back(new State_attr_rwAttr()); - - att_list.push_back(new Long64_spec_attr_rwAttr()); - att_list.push_back(new ULong_spec_attr_rwAttr()); - att_list.push_back(new ULong64_spec_attr_rwAttr()); - att_list.push_back(new State_spec_attr_rwAttr()); - - att_list.push_back(new Sub_device_tstAttr()); - att_list.push_back(new SlowAttr()); + Tango::SpectrumAttr *sat = new Short_spec_attr_wAttr(); + sat->set_default_properties(def_prop_1); + att_list.push_back(sat); + + att_list.push_back(new Long_spec_attr_wAttr()); + att_list.push_back(new Double_spec_attr_wAttr()); + att_list.push_back(new String_spec_attr_wAttr()); + att_list.push_back(new Short_ima_attr_wAttr()); + att_list.push_back(new String_ima_attr_wAttr()); + + att_list.push_back(new Short_spec_attr_rwAttr()); + att_list.push_back(new String_spec_attr_rwAttr()); + att_list.push_back(new Long_spec_attr_rwAttr()); + att_list.push_back(new Short_ima_attr_rwAttr()); + att_list.push_back(new String_ima_attr_rwAttr()); + + att_list.push_back(new Event_change_tstAttr()); + att_list.push_back(new Event64_change_tstAttr()); + att_list.push_back(new Event_quality_tstAttr()); + att_list.push_back(new Long_attr_with_wAttr()); + + att_list.push_back(new Short_attr_w2Attr()); + att_list.push_back(new String_attr_w2Attr()); + + att_list.push_back(new Poll_buffAttr()); + att_list.push_back(new Poll_buffRWAttr()); + + att_list.push_back(new Float_attrAttr()); + att_list.push_back(new Boolean_attrAttr()); + att_list.push_back(new UShort_attrAttr()); + att_list.push_back(new UChar_attrAttr()); + att_list.push_back(new ULong_attrAttr()); + att_list.push_back(new ULong64_attrAttr()); + + att_list.push_back(new Float_spec_attrAttr()); + att_list.push_back(new Boolean_spec_attrAttr()); + att_list.push_back(new UShort_spec_attrAttr()); + att_list.push_back(new UChar_spec_attrAttr()); + + att_list.push_back(new Float_attr_wAttr()); + att_list.push_back(new Boolean_attr_wAttr()); + att_list.push_back(new UShort_attr_wAttr()); + att_list.push_back(new UChar_attr_wAttr()); + + att_list.push_back(new Float_spec_attr_wAttr()); + att_list.push_back(new Boolean_spec_attr_wAttr()); + att_list.push_back(new UShort_spec_attr_wAttr()); + att_list.push_back(new UChar_spec_attr_wAttr()); + + att_list.push_back(new Float_ima_attr_wAttr()); + att_list.push_back(new UShort_ima_attr_wAttr()); + + att_list.push_back(new Float_spec_attr_rwAttr()); + att_list.push_back(new UChar_spec_attr_rwAttr()); + + att_list.push_back(new Boolean_ima_attr_rwAttr()); + att_list.push_back(new UShort_ima_attr_rwAttr()); + + att_list.push_back(new slow_actuatorAttr()); + att_list.push_back(new fast_actuatorAttr()); + + att_list.push_back(new Long64_attr_rwAttr()); + att_list.push_back(new ULong_attr_rwAttr()); + att_list.push_back(new ULong64_attr_rwAttr()); + att_list.push_back(new State_attr_rwAttr()); + + att_list.push_back(new Long64_spec_attr_rwAttr()); + att_list.push_back(new ULong_spec_attr_rwAttr()); + att_list.push_back(new ULong64_spec_attr_rwAttr()); + att_list.push_back(new State_spec_attr_rwAttr()); + + att_list.push_back(new Sub_device_tstAttr()); + att_list.push_back(new SlowAttr()); #ifndef COMPAT - att_list.push_back(new Encoded_attr_rwAttr()); - att_list.push_back(new Encoded_attr_image()); + att_list.push_back(new Encoded_attr_rwAttr()); + att_list.push_back(new Encoded_attr_image()); #endif - Tango::UserDefaultAttrProp att_no_data_prop; - att_no_data_prop.set_description("User desc"); - att_no_data_prop.set_min_value("30"); - att_no_data_prop.set_delta_val("77"); - att_no_data_prop.set_delta_t("88"); - att_no_data_prop.set_event_rel_change("55"); - att_no_data_prop.set_event_period("1500"); - Tango::Attr *db_att = new DefUserAttr(); - db_att->set_default_properties(att_no_data_prop); - att_list.push_back(db_att); - - Tango::Attr *uclass_att = new DefClassUserAttr(); - uclass_att->set_default_properties(att_no_data_prop); - att_list.push_back(uclass_att); - - att_list.push_back(new DefAttr()); - att_list.push_back(new DefClassAttr()); - - Tango::UserDefaultAttrProp att_enum_prop; - vector v_s; - v_s.push_back("North"); - v_s.push_back("South"); - v_s.push_back("East"); - v_s.push_back("West"); - att_enum_prop.set_enum_labels(v_s); - Tango::Attr *en_att = new EnumAttr(); - en_att->set_default_properties(att_enum_prop); - en_att->set_memorized(); - en_att->set_memorized_init(true); - att_list.push_back(en_att); - - Tango::Attr *en_s_att = new EnumSpecAttr(); - en_s_att->set_default_properties(att_enum_prop); - att_list.push_back(en_s_att); - - att_list.push_back(new DynEnumAttr()); - att_list.push_back(new ReynaldPollAttr()); + Tango::UserDefaultAttrProp att_no_data_prop; + att_no_data_prop.set_description("User desc"); + att_no_data_prop.set_min_value("30"); + att_no_data_prop.set_delta_val("77"); + att_no_data_prop.set_delta_t("88"); + att_no_data_prop.set_event_rel_change("55"); + att_no_data_prop.set_event_period("1500"); + Tango::Attr *db_att = new DefUserAttr(); + db_att->set_default_properties(att_no_data_prop); + att_list.push_back(db_att); + + Tango::Attr *uclass_att = new DefClassUserAttr(); + uclass_att->set_default_properties(att_no_data_prop); + att_list.push_back(uclass_att); + + att_list.push_back(new DefAttr()); + att_list.push_back(new DefClassAttr()); + + Tango::UserDefaultAttrProp att_enum_prop; + vector v_s; + v_s.push_back("North"); + v_s.push_back("South"); + v_s.push_back("East"); + v_s.push_back("West"); + att_enum_prop.set_enum_labels(v_s); + Tango::Attr *en_att = new EnumAttr(); + en_att->set_default_properties(att_enum_prop); + en_att->set_memorized(); + en_att->set_memorized_init(true); + att_list.push_back(en_att); + + Tango::Attr *en_s_att = new EnumSpecAttr(); + en_s_att->set_default_properties(att_enum_prop); + att_list.push_back(en_s_att); + + att_list.push_back(new DynEnumAttr()); + att_list.push_back(new ReynaldPollAttr()); } void DevTestClass::pipe_factory() { - RPipeClass *pRPipe = new RPipeClass("RPipe",Tango::OPERATOR); - Tango::UserDefaultPipeProp udpp; - udpp.set_description("The read pipe"); - udpp.set_label("ReadPipeLabel"); - pRPipe->set_default_properties(udpp); - pipe_list.push_back(pRPipe); - - RWPipeClass *pRWPipe = new RWPipeClass("RWPipe",Tango::OPERATOR); - udpp.set_description("The read_write pipe"); - udpp.set_label("ReadWritePipeLabel"); - pRWPipe->set_default_properties(udpp); - pipe_list.push_back(pRWPipe); - - ConfPipeClass *pPipe1 = new ConfPipeClass("PipeConf1",Tango::OPERATOR); - pipe_list.push_back(pPipe1); - - ConfPipeClass *pPipe2 = new ConfPipeClass("PipeConf2",Tango::OPERATOR); - udpp.set_description("A Tango pipe with user defined desc"); - udpp.set_label("PipeLabel"); - pPipe2->set_default_properties(udpp); - pipe_list.push_back(pPipe2); - - ConfPipeClass *pPipe3 = new ConfPipeClass("PipeConf3",Tango::OPERATOR); - udpp.description.clear(); - udpp.set_label("BasePipeLabel"); - pPipe3->set_default_properties(udpp); - pipe_list.push_back(pPipe3); - - ConfPipeClass *pPipe4 = new ConfPipeClass("PipeConf4",Tango::OPERATOR); - pipe_list.push_back(pPipe4); - - ConfPipeClass *pPipe5 = new ConfPipeClass("PipeConf5",Tango::OPERATOR); - pipe_list.push_back(pPipe5); - - ConfPipeClass *pPipe6 = new ConfPipeClass("PipeConf6",Tango::OPERATOR); - udpp.label.clear(); - udpp.set_description("UserDefinedDesc"); - pPipe6->set_default_properties(udpp); - pipe_list.push_back(pPipe6); - - ConfPipeClass *pPipe7 = new ConfPipeClass("PipeConf7",Tango::OPERATOR); - pipe_list.push_back(pPipe7); - - RPipeDEClass *pRPipeDE = new RPipeDEClass("RPipeDE",Tango::OPERATOR); - pipe_list.push_back(pRPipeDE); + RPipeClass *pRPipe = new RPipeClass("RPipe", Tango::OPERATOR); + Tango::UserDefaultPipeProp udpp; + udpp.set_description("The read pipe"); + udpp.set_label("ReadPipeLabel"); + pRPipe->set_default_properties(udpp); + pipe_list.push_back(pRPipe); + + RWPipeClass *pRWPipe = new RWPipeClass("RWPipe", Tango::OPERATOR); + udpp.set_description("The read_write pipe"); + udpp.set_label("ReadWritePipeLabel"); + pRWPipe->set_default_properties(udpp); + pipe_list.push_back(pRWPipe); + + ConfPipeClass *pPipe1 = new ConfPipeClass("PipeConf1", Tango::OPERATOR); + pipe_list.push_back(pPipe1); + + ConfPipeClass *pPipe2 = new ConfPipeClass("PipeConf2", Tango::OPERATOR); + udpp.set_description("A Tango pipe with user defined desc"); + udpp.set_label("PipeLabel"); + pPipe2->set_default_properties(udpp); + pipe_list.push_back(pPipe2); + + ConfPipeClass *pPipe3 = new ConfPipeClass("PipeConf3", Tango::OPERATOR); + udpp.description.clear(); + udpp.set_label("BasePipeLabel"); + pPipe3->set_default_properties(udpp); + pipe_list.push_back(pPipe3); + + ConfPipeClass *pPipe4 = new ConfPipeClass("PipeConf4", Tango::OPERATOR); + pipe_list.push_back(pPipe4); + + ConfPipeClass *pPipe5 = new ConfPipeClass("PipeConf5", Tango::OPERATOR); + pipe_list.push_back(pPipe5); + + ConfPipeClass *pPipe6 = new ConfPipeClass("PipeConf6", Tango::OPERATOR); + udpp.label.clear(); + udpp.set_description("UserDefinedDesc"); + pPipe6->set_default_properties(udpp); + pipe_list.push_back(pPipe6); + + ConfPipeClass *pPipe7 = new ConfPipeClass("PipeConf7", Tango::OPERATOR); + pipe_list.push_back(pPipe7); + + RPipeDEClass *pRPipeDE = new RPipeDEClass("RPipeDE", Tango::OPERATOR); + pipe_list.push_back(pRPipeDE); } diff --git a/cpp_test_suite/cpp_test_ds/TypeCmds.cpp b/cpp_test_suite/cpp_test_ds/TypeCmds.cpp index 73319e197..f2b06cbf0 100644 --- a/cpp_test_suite/cpp_test_ds/TypeCmds.cpp +++ b/cpp_test_suite/cpp_test_ds/TypeCmds.cpp @@ -1687,3 +1687,23 @@ CORBA::Any *OEncoded::execute(TANGO_UNUSED(Tango::DeviceImpl *device),TANGO_UNUS } } #endif + +IODevEnum::IODevEnum() + : + Command("IODevEnum", Tango::CmdArgType::DEV_ENUM, Tango::CmdArgType::DEV_ENUM, "DevEnum", "DevEnum") +{ + set_in_enum_labels({"IN Label 1", "IN Label 2", "IN Label 3"}); + set_out_enum_labels({"OUT Label 1", "OUT Label 2", "OUT Label 3"}); +} + +bool IODevEnum::is_allowed(Tango::DeviceImpl *, const CORBA::Any &) +{ + return true; +} + +CORBA::Any *IODevEnum::execute(Tango::DeviceImpl *, const CORBA::Any &any) +{ + Tango::DevShort in; + extract(any, in); + return insert(in); +} diff --git a/cpp_test_suite/cpp_test_ds/TypeCmds.h b/cpp_test_suite/cpp_test_ds/TypeCmds.h index 905d4998e..e861820ce 100644 --- a/cpp_test_suite/cpp_test_ds/TypeCmds.h +++ b/cpp_test_suite/cpp_test_ds/TypeCmds.h @@ -313,3 +313,13 @@ class OEncoded : public Tango::Command Tango::DevLong encoded_cmd_ctr; }; + +struct IODevEnum: public Tango::Command +{ + IODevEnum(); + ~IODevEnum() + {}; + + virtual bool is_allowed(Tango::DeviceImpl *, const CORBA::Any &); + virtual CORBA::Any *execute(Tango::DeviceImpl *, const CORBA::Any &); +}; diff --git a/cpp_test_suite/cxxtest/CMakeLists.txt b/cpp_test_suite/cxxtest/CMakeLists.txt index 76bf52f49..6f9347b06 100644 --- a/cpp_test_suite/cxxtest/CMakeLists.txt +++ b/cpp_test_suite/cxxtest/CMakeLists.txt @@ -36,6 +36,8 @@ execute_process(COMMAND python cxxtestgen.py --template=${CMAKE_CURRENT_SOURCE_D ../../new_tests/cxx_pipe.cpp ../../new_tests/cxx_z00_dyn_cmd.cpp ../../new_tests/cxx_nan_inf_in_prop.cpp + ../../new_tests/cxx_cmd_inout_enum.cpp + ../../new_tests/cxx_misc_devproxy.cpp WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/bin) add_executable(runner $ ${CMAKE_CURRENT_SOURCE_DIR}/runner.cpp) diff --git a/cpp_test_suite/event/CMakeLists.txt b/cpp_test_suite/event/CMakeLists.txt index fbb1a34ec..7985128f3 100644 --- a/cpp_test_suite/event/CMakeLists.txt +++ b/cpp_test_suite/event/CMakeLists.txt @@ -28,23 +28,23 @@ foreach(TEST ${TESTS}) TEST_SUITE_ADD_TEST(${TEST}) endforeach(TEST) -add_test(NAME "event::per_event" COMMAND $ ${DEV1} ${DEV2}) -add_test(NAME "event::att_type_event" COMMAND $ ${DEV1}) -add_test(NAME "event::change_event" COMMAND $ ${DEV1}) -add_test(NAME "event::change_event64" COMMAND $ ${DEV1}) -add_test(NAME "event::change_event_buffer" COMMAND $ ${DEV1}) -add_test(NAME "event::archive_event" COMMAND $ ${DEV1}) -add_test(NAME "event::user_event" COMMAND $ ${DEV1}) -add_test(NAME "event::multi_event" COMMAND $ ${DEV1}) -add_test(NAME "event::state_event" COMMAND $ ${DEV1}) -add_test(NAME "event::att_conf_event" COMMAND $ ${DEV1}) -add_test(NAME "event::att_conf_event_buffer" COMMAND $ ${DEV1}) -add_test(NAME "event::data_ready_event" COMMAND $ ${DEV1}) -add_test(NAME "event::data_ready_event_buffer" COMMAND $ ${DEV1}) -add_test(NAME "event::multi_dev_event" COMMAND $ ${DEV1} ${DEV2} ${DEV3}) -add_test(NAME "event::dev_intr_event" COMMAND $ ${DEV1}) -add_test(NAME "event::pipe_event" COMMAND $ ${DEV1}) -add_test(NAME "event::event_lock" COMMAND $ ${DEV1}) +add_test(NAME "event::per_event" COMMAND $ ${DEV1} ${DEV2}) +add_test(NAME "event::att_type_event" COMMAND $ ${DEV1}) +add_test(NAME "event::change_event" COMMAND $ ${DEV1}) +add_test(NAME "event::change_event64" COMMAND $ ${DEV1}) +add_test(NAME "event::change_event_buffer" COMMAND $ ${DEV1}) +add_test(NAME "event::archive_event" COMMAND $ ${DEV1}) +add_test(NAME "event::user_event" COMMAND $ ${DEV1}) +add_test(NAME "event::multi_event" COMMAND $ ${DEV1}) +add_test(NAME "event::state_event" COMMAND $ ${DEV1}) +add_test(NAME "event::att_conf_event" COMMAND $ ${DEV1}) +add_test(NAME "event::att_conf_event_buffer" COMMAND $ ${DEV1}) +add_test(NAME "event::data_ready_event" COMMAND $ ${DEV1}) +add_test(NAME "event::data_ready_event_buffer" COMMAND $ ${DEV1}) +add_test(NAME "event::multi_dev_event" COMMAND $ ${DEV1} ${DEV2} ${DEV3}) +add_test(NAME "event::dev_intr_event" COMMAND $ ${DEV1}) +add_test(NAME "event::pipe_event" COMMAND $ ${DEV1}) +add_test(NAME "event::event_lock" COMMAND $ ${DEV1}) #the following test performs several kill/start sequences, but must keep DEV1 alive in the end diff --git a/cpp_test_suite/event/att_conf_event.cpp b/cpp_test_suite/event/att_conf_event.cpp index fcaffa494..d760c6761 100644 --- a/cpp_test_suite/event/att_conf_event.cpp +++ b/cpp_test_suite/event/att_conf_event.cpp @@ -163,7 +163,10 @@ int main(int argc, char **argv) device->command_inout("IOSetWAttrLimit",d_in); Tango_sleep(1); - + + coutv << "cb_executed = " << cb.cb_executed << endl; + coutv << "min_value = " << cb.min_value << endl; + coutv << "max_value = " << cb.max_value << endl; assert (cb.cb_executed == 6); assert (cb.min_value == "0"); assert (cb.max_value == "10"); diff --git a/cpp_test_suite/event/change_event.cpp b/cpp_test_suite/event/change_event.cpp index d8496fe2d..9af81ee8c 100644 --- a/cpp_test_suite/event/change_event.cpp +++ b/cpp_test_suite/event/change_event.cpp @@ -2,6 +2,7 @@ * example of a client using the TANGO device api. */ +#include #include #include @@ -13,7 +14,7 @@ #include #endif -#define coutv if (verbose == true) cout +#define coutv if (verbose == true) cout << "[" << std::this_thread::get_id() << "] " using namespace Tango; @@ -245,6 +246,8 @@ int main(int argc, char **argv) #endif coutv << "cb excuted = " << cb.cb_executed << endl; + coutv << "cb val = " << cb.val << endl; + coutv << "cb val_size = " << cb.val_size << endl; assert (cb.cb_executed == 2); assert (cb.val == 31); assert (cb.val_size == 4); diff --git a/cpp_test_suite/new_tests/cxx_blackbox.cpp b/cpp_test_suite/new_tests/cxx_blackbox.cpp index bafd8bff9..da6ac2408 100644 --- a/cpp_test_suite/new_tests/cxx_blackbox.cpp +++ b/cpp_test_suite/new_tests/cxx_blackbox.cpp @@ -158,7 +158,8 @@ class BlackboxTestSuite: public CxxTest::TestSuite break; case 4: case 5: - version_str = "_4"; + case 6: + version_str = "_4"; break; default: version_str = ""; diff --git a/cpp_test_suite/new_tests/cxx_cmd_inout_enum.cpp b/cpp_test_suite/new_tests/cxx_cmd_inout_enum.cpp new file mode 100644 index 000000000..1631c4713 --- /dev/null +++ b/cpp_test_suite/new_tests/cxx_cmd_inout_enum.cpp @@ -0,0 +1,201 @@ +// +// Created by ingvord on 3/13/17. +// +#ifndef CmdInOutEnumTestSuite_h +#define CmdInOutEnumTestSuite_h + +#include +#include +#include +#include +#include + +using namespace Tango; +using namespace std; + +#define cout cout << "\t" + +#undef SUITE_NAME +#define SUITE_NAME CmdInOutEnumTestSuite + +class CmdInOutEnumTestSuite: public CxxTest::TestSuite +{ +protected: + DeviceProxy *device1, *dserver; + +public: + SUITE_NAME() + { + +// +// Arguments check ------------------------------------------------- +// + + string device1_name, dserver_name; + + device1_name = CxxTest::TangoPrinter::get_param("device1"); + dserver_name = "dserver/" + CxxTest::TangoPrinter::get_param("fulldsname"); + + CxxTest::TangoPrinter::validate_args(); + + +// +// Initialization -------------------------------------------------- +// + + try + { + device1 = new DeviceProxy(device1_name); + dserver = new DeviceProxy(dserver_name); + device1->ping(); + dserver->ping(); + } + catch (CORBA::Exception &e) + { + Except::print_exception(e); + exit(-1); + } + + } + + virtual ~SUITE_NAME() + { + if (CxxTest::TangoPrinter::is_restore_set("dev1_EnumLabelsDynCommandPolled_polling")) + { + DeviceData din; + DevVarStringArray rem_attr_poll; + rem_attr_poll.length(3); + rem_attr_poll[0] = device1->name().c_str(); + rem_attr_poll[1] = "command"; + rem_attr_poll[2] = "EnumLabelsDynCommandPolled"; + din << rem_attr_poll; + try + { + dserver->command_inout("RemObjPolling", din); + } + catch (DevFailed &e) + { + cout << endl << "Exception in suite tearDown():" << endl; + Except::print_exception(e); + } + } + + delete device1; + delete dserver; + } + + static SUITE_NAME *createSuite() + { + return new SUITE_NAME(); + } + + static void destroySuite(SUITE_NAME *suite) + { + delete suite; + } + +// +// Tests ------------------------------------------------------- +// + + void test_cmd_DevEnum_in(void) + { + DeviceData in, out; + in << (DevEnum) 1; + + out = device1->command_inout("IODevEnum", in); + + + short result; + out >> result; + + TS_ASSERT_EQUALS(1, result); + } + + void test_cmd_DevEnum_query(void) + { + CommandInfo cmd_info; + + cmd_info = device1->command_query("IODevEnum"); + + + TS_ASSERT_EQUALS("IODevEnum", cmd_info.cmd_name); + TS_ASSERT_EQUALS(3, cmd_info.in_enum_labels.size()); + TS_ASSERT_EQUALS("IN Label 1", cmd_info.in_enum_labels[0]); + TS_ASSERT_EQUALS("IN Label 2", cmd_info.in_enum_labels[1]); + TS_ASSERT_EQUALS("IN Label 3", cmd_info.in_enum_labels[2]); + TS_ASSERT_EQUALS(3, cmd_info.out_enum_labels.size()); + TS_ASSERT_EQUALS("OUT Label 1", cmd_info.out_enum_labels[0]); + TS_ASSERT_EQUALS("OUT Label 2", cmd_info.out_enum_labels[1]); + TS_ASSERT_EQUALS("OUT Label 3", cmd_info.out_enum_labels[2]); + } + + void test_cmd_DevEnum_query_list(void) + { + auto cmd_info_list = device1->command_list_query(); + + CommandInfo cmd_info; + auto found = find_if(cmd_info_list->begin(), cmd_info_list->end(), [](CommandInfo item) + { + return item.cmd_name == "IODevEnum"; + }); + cmd_info = *found; + + TS_ASSERT_EQUALS("IODevEnum", cmd_info.cmd_name); + TS_ASSERT_EQUALS(3, cmd_info.in_enum_labels.size()); + TS_ASSERT_EQUALS("IN Label 1", cmd_info.in_enum_labels[0]); + TS_ASSERT_EQUALS("IN Label 2", cmd_info.in_enum_labels[1]); + TS_ASSERT_EQUALS("IN Label 3", cmd_info.in_enum_labels[2]); + TS_ASSERT_EQUALS(3, cmd_info.out_enum_labels.size()); + TS_ASSERT_EQUALS("OUT Label 1", cmd_info.out_enum_labels[0]); + TS_ASSERT_EQUALS("OUT Label 2", cmd_info.out_enum_labels[1]); + TS_ASSERT_EQUALS("OUT Label 3", cmd_info.out_enum_labels[2]); + } + + void test_dyn_cmd_DevEnum_query(void) + { + auto cmd_info = device1->command_query("EnumLabelsDynCommand"); + + TS_ASSERT_EQUALS("EnumLabelsDynCommand", cmd_info.cmd_name); + TS_ASSERT_EQUALS(3, cmd_info.in_enum_labels.size()); + TS_ASSERT_EQUALS("IN Dyn Label 1", cmd_info.in_enum_labels[0]); + TS_ASSERT_EQUALS("IN Dyn Label 2", cmd_info.in_enum_labels[1]); + TS_ASSERT_EQUALS("IN Dyn Label 3", cmd_info.in_enum_labels[2]); + TS_ASSERT_EQUALS(3, cmd_info.out_enum_labels.size()); + TS_ASSERT_EQUALS("OUT Dyn Label 1", cmd_info.out_enum_labels[0]); + TS_ASSERT_EQUALS("OUT Dyn Label 2", cmd_info.out_enum_labels[1]); + TS_ASSERT_EQUALS("OUT Dyn Label 3", cmd_info.out_enum_labels[2]); + } + + void test_poll_cmd_DevEnum(void) + { + DevVarLongStringArray cmd_poll; + DeviceData din; + + cmd_poll.lvalue.length(1); + cmd_poll.lvalue[0] = 200; + cmd_poll.svalue.length(3); + cmd_poll.svalue[0] = device1->name().c_str(); + cmd_poll.svalue[1] = "command"; + cmd_poll.svalue[2] = "EnumLabelsDynCommandPolled"; + din << cmd_poll; + TS_ASSERT_THROWS_NOTHING(dserver->command_inout("AddObjPolling", din)); + CxxTest::TangoPrinter::restore_set("dev1_EnumLabelsDynCommandPolled_polling"); + + TS_ASSERT_THROWS_NOTHING(device1->set_source(Tango::CACHE)); + + std::this_thread::sleep_for( + std::chrono::milliseconds(1000)); + + DeviceData dout; + DevEnum result; + TS_ASSERT_THROWS_NOTHING(dout = device1->command_inout("EnumLabelsDynCommandPolled")); + dout >> result; + TS_ASSERT_EQUALS(result, 1); + + } +}; +#undef cout +#endif // CmdInOutEnumTestSuite_h + + diff --git a/cpp_test_suite/new_tests/cxx_misc_devproxy.cpp b/cpp_test_suite/new_tests/cxx_misc_devproxy.cpp new file mode 100644 index 000000000..d4e38f217 --- /dev/null +++ b/cpp_test_suite/new_tests/cxx_misc_devproxy.cpp @@ -0,0 +1,447 @@ +//=================================================================================================================== +// +// file : cxx_misc_devproxy.cpp +// +// project : tango +// +// author(s) : ingvord +// +// Copyright (C) : 2004-2017 +// European Synchrotron Radiation Facility +// BP 220, Grenoble 38043 +// FRANCE +// +// This file is part of Tango. +// +// Tango is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Tango is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty +// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License along with Tango. +// If not, see . +//=================================================================================================================== +#ifndef MiscDevProxyTestSuite_h +#define MiscDevProxyTestSuite_h + + +#include +#include +#include + +using namespace Tango; +using namespace std; + +#define cout cout << "\t" +#define coutv if (verbose == true) cout + +#undef SUITE_NAME +#define SUITE_NAME MiscDevProxyTestSuite + +class MiscDevProxyTestSuite: public CxxTest::TestSuite +{ +protected: + DeviceProxy *device; + + string device_name, ds_name, admin_name; + bool verbose; + +public: + SUITE_NAME() + { + +// +// Arguments check ------------------------------------------------- +// + + device_name = CxxTest::TangoPrinter::get_param("device1"); + ds_name = CxxTest::TangoPrinter::get_param("fulldsname"); + admin_name = "dserver/" + ds_name; + + verbose = CxxTest::TangoPrinter::is_param_defined("verbose"); + + CxxTest::TangoPrinter::validate_args(); + + +// +// Initialization -------------------------------------------------- +// + + try + { + device = new DeviceProxy(device_name); + } + catch (CORBA::Exception &e) + { + Except::print_exception(e); + exit(-1); + } + + } + + virtual ~SUITE_NAME() + { + delete device; + } + + static SUITE_NAME *createSuite() + { + return new SUITE_NAME(); + } + + static void destroySuite(SUITE_NAME *suite) + { + delete suite; + } + +// +// Tests ------------------------------------------------------- +// + + void test_get_timeout(void) + { + int to; + TS_ASSERT_THROWS_NOTHING(to = device->get_timeout_millis()); + + TS_ASSERT_EQUALS(3000, to); + } + + // Test set_timeout + void test_set_get_timeout(void) + { + int new_to; + TS_ASSERT_THROWS_NOTHING(device->set_timeout_millis(2000)); + TS_ASSERT_THROWS_NOTHING(new_to = device->get_timeout_millis()); + + TS_ASSERT_EQUALS(2000, new_to); + + TS_ASSERT_THROWS_NOTHING(device->set_timeout_millis(3000)); + TS_ASSERT_THROWS_NOTHING(new_to = device->get_timeout_millis()); + TS_ASSERT_EQUALS(3000, new_to); + } + + // Test ping + void test_ping(void) + { + int elapsed; + TS_ASSERT_THROWS_NOTHING(elapsed = device->ping()); + + cout << " Ping ( " << elapsed << " us ) --> OK" << endl; + ETS_ASSERT_LESS_THAN(0, elapsed); + } + + // Test state + + void test_state(void) + { + DevState sta; + TS_ASSERT_THROWS_NOTHING(sta = device->state()); + + TS_ASSERT_EQUALS(Tango::ON, sta); + } + + // Test status + void test_status(void) + { + string str; + TS_ASSERT_THROWS_NOTHING(str = device->status()); + + TS_ASSERT_EQUALS("The device is in ON state.", str); + } + + // Test Tango lib version + void test_lib_version(void) + { + int tg_version; + TS_ASSERT_THROWS_NOTHING(tg_version = device->get_tango_lib_version()); + + TS_ASSERT_LESS_THAN_EQUALS(810, tg_version); + } + + // Test adm_name + void test_adm_name(void) + { + string str_adm; + TS_ASSERT_THROWS_NOTHING(str_adm = device->adm_name()); + + transform(str_adm.begin(), str_adm.end(), str_adm.begin(), ::tolower); + transform(admin_name.begin(), admin_name.end(), admin_name.begin(), ::tolower); + + TS_ASSERT_EQUALS(admin_name, str_adm); + } + + // Test description + void test_description(void) + { + string desc; + TS_ASSERT_THROWS_NOTHING(desc = device->description()); + + TS_ASSERT_EQUALS("A TANGO device", desc); + } + + // Test name + void test_name(void) + { + string name; + TS_ASSERT_THROWS_NOTHING(name = device->name()); + + TS_ASSERT_EQUALS(device_name, name); + } + + // Test blackbox + void test_blackbox(void) + { + vector *ptr; + TS_ASSERT_THROWS_NOTHING(ptr = device->black_box(3)); + + TS_ASSERT_EQUALS(3, ptr->size()); + + string tmp = (*ptr)[0]; + string::size_type pos, end; + pos = tmp.find('A'); + end = tmp.find("from"); + string ans = tmp.substr(pos, end - pos); + + TS_ASSERT_EQUALS("Attribute name requested ", ans); + + tmp = (*ptr)[1]; + end = tmp.find("from"); + ans = tmp.substr(pos, end - pos); + TS_ASSERT_EQUALS("Attribute description requested ", ans); + + tmp = (*ptr)[2]; + end = tmp.find("from"); + ans = tmp.substr(pos, end - pos); + TS_ASSERT_EQUALS("Attribute adm_name requested ", ans); + + delete ptr; + } + + // Test info + void test_info(void) + { + DeviceInfo inf; + TS_ASSERT_THROWS_NOTHING(inf = device->info()); + TS_ASSERT_EQUALS("DevTest", inf.dev_class); + + transform(inf.server_id.begin(), inf.server_id.end(), inf.server_id.begin(), ::tolower); + transform(ds_name.begin(), ds_name.end(), ds_name.begin(), ::tolower); + + TS_ASSERT_EQUALS(ds_name, inf.server_id); + TS_ASSERT_EQUALS("Doc URL = http://www.tango-controls.org", inf.doc_url); + TS_ASSERT_EQUALS("TestDevice", inf.dev_type); + } + + // Test command_query + void test_command_query(void) + { + DevCommandInfo cmd_info; + TS_ASSERT_THROWS_NOTHING(cmd_info = device->command_query("IODoubleArray")); + + TS_ASSERT_EQUALS("IODoubleArray", cmd_info.cmd_name); + TS_ASSERT_EQUALS(DEVVAR_DOUBLEARRAY, cmd_info.in_type); + TS_ASSERT_EQUALS(DEVVAR_DOUBLEARRAY, cmd_info.out_type); + TS_ASSERT_EQUALS("Array of double", cmd_info.in_type_desc); + TS_ASSERT_EQUALS("This array * 2", cmd_info.out_type_desc); + } + + // Test command_list_query and get_command_list + void test_command_list_query(void) + { + CommandInfoList *cmd_list; + TS_ASSERT_THROWS_NOTHING(cmd_list = device->command_list_query()); + cout << "cmd list size = " << cmd_list->size() << endl; + + vector *cmd_name_list; + TS_ASSERT_THROWS_NOTHING(cmd_name_list = device->get_command_list()); + + cout << "cmd_name_list size = " << cmd_name_list->size() << endl; + + TS_ASSERT_EQUALS(cmd_name_list->size(), cmd_list->size()); + delete cmd_list; + delete cmd_name_list; + } + + void test_get_command_list(void) + { + vector *cmd_name_list; + TS_ASSERT_THROWS_NOTHING(cmd_name_list = device->get_command_list()); + + cout << "cmd_name_list size = " << cmd_name_list->size() << endl; + TS_ASSERT_EQUALS(118, cmd_name_list->size()); +// TS_ASSERT_EQUALS ("FileDb" , (*cmd_list)[0].cmd_name); +// TS_ASSERT_EQUALS ("Status", (*cmd_list)[87].cmd_name); + + delete cmd_name_list; + } + + // Test get_attribute_list + void test_get_attribute_list(void) + { + vector *att_list; + TS_ASSERT_THROWS_NOTHING(att_list = device->get_attribute_list()); + + cout << "att_list size = " << att_list->size() << endl; + TS_ASSERT_EQUALS(103, att_list->size()); +// assert ( (*att_list)[0] == "Short_attr"); +// assert ( (*att_list)[1] == "Long_attr"); +// assert ( (*att_list)[21] == "String_attr_w"); + + delete att_list; + } + + // Test attribute query + void test_attribute_query(void) + { + DeviceAttributeConfig attr_conf; + TS_ASSERT_THROWS_NOTHING(attr_conf = device->attribute_query("Short_attr")); + + TS_ASSERT_EQUALS(attr_conf.name, "Short_attr"); + TS_ASSERT_EQUALS(attr_conf.data_format, SCALAR); + TS_ASSERT_EQUALS(attr_conf.data_type, DEV_SHORT); + TS_ASSERT_EQUALS(attr_conf.description, "No description"); + TS_ASSERT_EQUALS(attr_conf.max_dim_x, 1); + } + + // Test get_attribute_config + void test_get_attribute_config(void) + { + AttributeInfoList *attr_conf_ptr; + vector li; + li.push_back("Long_attr"); + li.push_back("Double_attr"); + + TS_ASSERT_THROWS_NOTHING(attr_conf_ptr = device->get_attribute_config(li)); + + TS_ASSERT_EQUALS(attr_conf_ptr->size(), 2); + + TS_ASSERT_EQUALS((*attr_conf_ptr)[0].name, "Long_attr"); + TS_ASSERT_EQUALS((*attr_conf_ptr)[0].data_format, SCALAR); + TS_ASSERT_EQUALS((*attr_conf_ptr)[0].data_type, DEV_LONG); + + TS_ASSERT_EQUALS((*attr_conf_ptr)[1].name, "Double_attr"); + TS_ASSERT_EQUALS((*attr_conf_ptr)[1].data_format, SCALAR); + TS_ASSERT_EQUALS((*attr_conf_ptr)[1].data_type, DEV_DOUBLE); + + delete attr_conf_ptr; + } + + // Test get_command_config + void test_get_command_config(void) + { + CommandInfoList *cmd_conf_ptr; + vector li; + li.push_back("state"); + li.push_back("status"); + + TS_ASSERT_THROWS_NOTHING(cmd_conf_ptr = device->get_command_config(li)); + + TS_ASSERT_EQUALS(cmd_conf_ptr->size(), 2); + + TS_ASSERT_EQUALS((*cmd_conf_ptr)[0].cmd_name, "State"); + TS_ASSERT_EQUALS((*cmd_conf_ptr)[0].in_type, DEV_VOID); + TS_ASSERT_EQUALS((*cmd_conf_ptr)[0].out_type, DEV_STATE); + + TS_ASSERT_EQUALS((*cmd_conf_ptr)[1].cmd_name, "Status"); + TS_ASSERT_EQUALS((*cmd_conf_ptr)[1].in_type, DEV_VOID); + TS_ASSERT_EQUALS((*cmd_conf_ptr)[1].out_type, DEV_STRING); + + } + + // test attribute_list_query + +// AttributeInfoList *attr_confs; +// attr_confs = device->attribute_list_query(); + +// assert ( attr_confs->size() == 77 ); +// assert ( (*attr_confs)[0].name == "Short_attr"); +// assert ( (*attr_confs)[0].data_format == SCALAR); +// assert ( (*attr_confs)[0].data_type == DEV_SHORT); + +// assert ( (*attr_confs)[1].name == "Long_attr"); +// assert ( (*attr_confs)[1].data_type == DEV_LONG); +// assert ( (*attr_confs)[1].data_format == SCALAR); + +// assert ( (*attr_confs)[21].name == "String_attr_w"); +// assert ( (*attr_confs)[21].data_type == DEV_STRING); +// assert ( (*attr_confs)[21].data_format == SCALAR); + +// cout << " Attribute list query --> OK " << endl; +// delete attr_confs; + + // Test set_attribute_config + void test_set_attribute_config(void) + { + AttributeInfoList v_conf; + AttributeInfo co; + TS_ASSERT_THROWS_NOTHING(co = device->attribute_query("Short_attr")); + +#ifdef WIN32 + int pid = _getpid(); +#else + pid_t pid = getpid(); +#endif + + stringstream st; + + string s; + st << pid; + st >> s; + + co.format = s; + v_conf.push_back(co); + + TS_ASSERT_THROWS_NOTHING(device->set_attribute_config(v_conf)); + + DeviceAttributeConfig res = device->attribute_query("Short_attr"); + TS_ASSERT_EQUALS(res.format, s); + + } + + // Test device version + void test_device_version(void) + { +#ifndef COMPAT + int vers; + TS_ASSERT_THROWS_NOTHING(vers = device->get_idl_version()); + TS_ASSERT_EQUALS(vers, 6); +#endif + } + + // Test source + void test_source(void) + { + Tango::DevSource so; + TS_ASSERT_THROWS_NOTHING(so = device->get_source()); + TS_ASSERT_EQUALS(so, Tango::CACHE_DEV); + + TS_ASSERT_THROWS_NOTHING(device->set_source(Tango::DEV)); + TS_ASSERT_THROWS_NOTHING(so = device->get_source()); + TS_ASSERT_EQUALS(so, Tango::DEV); + + TS_ASSERT_THROWS_NOTHING(device->set_source(Tango::CACHE_DEV)); + } + + // Test get property list + void test_get_property_list(void) + { +#ifndef COMPAT + vector props; + TS_ASSERT_THROWS_NOTHING(device->get_property_list("*", props)); + + cout << "NB prop = " << props.size() << endl; + for (unsigned long l = 0; l < props.size(); l++) + cout << "prop = " << props[l] << endl; + TS_ASSERT_EQUALS(props.size(), 3); + TS_ASSERT_EQUALS(props[0], "cmd_min_poll_period"); + TS_ASSERT_EQUALS(props[1], "min_poll_period"); + TS_ASSERT_EQUALS(props[2], "tst_property"); +#endif + } +}; + +#undef cout +#endif // MiscDevProxyTestSuite_h diff --git a/cpp_test_suite/old_tests/CMakeLists.txt b/cpp_test_suite/old_tests/CMakeLists.txt index 21e1fa37f..eb3b79ecb 100644 --- a/cpp_test_suite/old_tests/CMakeLists.txt +++ b/cpp_test_suite/old_tests/CMakeLists.txt @@ -19,7 +19,6 @@ set(TESTS acc_right mem_att misc_devattr misc_devdata - misc_devproxy multiple_new new_devproxy obj_prop @@ -57,8 +56,6 @@ endforeach(TEST) configure_file(locked_device_cmd.h.cmake locked_device_cmd.h @ONLY) target_include_directories(lock PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) -add_test(NAME "old_tests::misc_devproxy" COMMAND $ ${DEV1} ${SERV_NAME}/${INST_NAME}) - add_test(NAME "old_tests::cmd_types" COMMAND $ ${DEV1} 10) add_test(NAME "old_tests::attr_types" COMMAND $ ${DEV1} 10) diff --git a/cpp_test_suite/old_tests/copy_devproxy.cpp b/cpp_test_suite/old_tests/copy_devproxy.cpp index b0c0249d0..9ea656a24 100644 --- a/cpp_test_suite/old_tests/copy_devproxy.cpp +++ b/cpp_test_suite/old_tests/copy_devproxy.cpp @@ -44,7 +44,7 @@ int main(int argc, char **argv) assert (dev2.name() == device1_name); #ifndef COMPAT - assert (dev2.get_idl_version() == 5); + assert (dev2.get_idl_version() == 6); #endif } @@ -65,7 +65,7 @@ int main(int argc, char **argv) assert (dev3.name() == device1_name); #ifndef COMPAT - assert (dev3.get_idl_version() == 5); + assert (dev3.get_idl_version() == 6); #endif cout << " Assignement operator --> OK" << endl; diff --git a/cpp_test_suite/old_tests/misc_devproxy.cpp b/cpp_test_suite/old_tests/misc_devproxy.cpp deleted file mode 100644 index 36eda18ca..000000000 --- a/cpp_test_suite/old_tests/misc_devproxy.cpp +++ /dev/null @@ -1,369 +0,0 @@ -/* - * example of a client using the TANGO device api. - */ - -#include -#include - -#ifdef WIN32 -#include -#endif - - -using namespace Tango; -using namespace std; - -int main(int argc, char **argv) -{ - DeviceProxy *device; - - if (argc != 3) - { - cout << "usage: " << argv[0] << " " << endl; - exit(-1); - } - - string device_name = argv[1]; - string ds_name = argv[2]; - string admin_device("dserver/"); - admin_device = admin_device + ds_name; - - try - { - device = new DeviceProxy(device_name); - } - catch (CORBA::Exception &e) - { - Except::print_exception(e); - exit(1); - } - - cout << '\n' << "new DeviceProxy(" << device->name() << ") returned" << '\n' << endl; - - int elapsed; - try - { - -// Test get_timeout - - int to; - to = device->get_timeout_millis(); - - assert( to == 3000 ); - cout << " Get timeout --> OK" << endl; - -// Test set_timeout - - int new_to; - device->set_timeout_millis(2000); - new_to = device->get_timeout_millis(); - - assert ( new_to == 2000 ); - - cout << " Set timeout --> OK" << endl; - - device->set_timeout_millis(3000); - -// Test ping - - elapsed = device->ping(); - - cout << " Ping ( " << elapsed << " us ) --> OK" << endl; - -// Test state - - DevState sta; - sta = device->state(); - - assert ( sta == Tango::ON); - cout << " State --> OK" << endl; - -// Test status - - string str; - str = device->status(); - - assert ( str == "The device is in ON state."); - cout << " Status --> OK" << endl; - -// Test Tango lib version - - int tg_version; - tg_version = device->get_tango_lib_version(); - - assert ( tg_version >= 810 ); - cout << " Tango lib version --> OK" << endl; - -// Test adm_name - - string str_adm; - str_adm = device->adm_name(); - - transform(str_adm.begin(),str_adm.end(),str_adm.begin(),::tolower); - transform(admin_device.begin(),admin_device.end(),admin_device.begin(),::tolower); - - assert ( str_adm == admin_device); - cout << " Adm_name --> OK" << endl; - -// Test description - - string desc; - desc = device->description(); - - assert ( desc == "A TANGO device"); - cout << " Description --> OK" << endl; - -// Test name - - string name; - name = device->name(); - - assert ( name == device_name); - cout << " Name --> OK" << endl; - -// Test blackbox - - vector *ptr; - ptr = device->black_box(3); - - assert ( ptr->size() == 3 ); - - string tmp = (*ptr)[0]; - string::size_type pos,end; - pos = tmp.find('A'); - end = tmp.find("from"); - string ans = tmp.substr(pos,end - pos); - assert ( ans == "Attribute name requested " ); - - tmp = (*ptr)[1]; - end = tmp.find("from"); - ans = tmp.substr(pos,end - pos); - assert ( ans == "Attribute description requested "); - - tmp = (*ptr)[2]; - end = tmp.find("from"); - ans = tmp.substr(pos,end - pos); - assert ( ans == "Attribute adm_name requested "); - - cout << " Black box --> OK" << endl; - delete ptr; - -// Test info - - DeviceInfo inf; - inf = device->info(); - assert( inf.dev_class == "DevTest" ); - - transform(inf.server_id.begin(),inf.server_id.end(),inf.server_id.begin(),::tolower); - transform(ds_name.begin(),ds_name.end(),ds_name.begin(),::tolower); - - assert( inf.server_id == ds_name ); - assert( inf.doc_url == "Doc URL = http://www.tango-controls.org" ); - assert( inf.dev_type == "TestDevice"); - - cout << " Info --> OK" << endl; - -// Test command_query - - DevCommandInfo cmd_info; - cmd_info = device->command_query("IODoubleArray"); - - assert( cmd_info.cmd_name == "IODoubleArray" ); - assert( cmd_info.in_type == DEVVAR_DOUBLEARRAY ); - assert( cmd_info.out_type == DEVVAR_DOUBLEARRAY ); - assert( cmd_info.in_type_desc == "Array of double" ); - assert( cmd_info.out_type_desc == "This array * 2" ); - - cout << " Command_query --> OK" << endl; - -// Test command_list_query and get_command_list - - CommandInfoList *cmd_list; - cmd_list = device->command_list_query(); - cout << "cmd list size = " << cmd_list->size() << endl; - - vector *cmd_name_list; - cmd_name_list = device->get_command_list(); - - cout << "cmd_name_list size = " << cmd_name_list->size() << endl; - - assert (cmd_name_list->size() == cmd_list->size()); - - cout << " Command list --> OK" << endl; - -// assert (cmd_list->size() == 88 ); -// assert ((*cmd_list)[0].cmd_name == "FileDb" ); -// assert ((*cmd_list)[87].cmd_name == "Status"); - -// cout << " Command_list_query --> OK" << endl; - delete cmd_list; - delete cmd_name_list; - -// Test get_attribute_list - - vector *att_list; - att_list = device->get_attribute_list(); - - cout << "att_list size = " << att_list->size() << endl; -// assert ( att_list->size() == 77 ); -// assert ( (*att_list)[0] == "Short_attr"); -// assert ( (*att_list)[1] == "Long_attr"); -// assert ( (*att_list)[21] == "String_attr_w"); - -// cout << " Get attribute list --> OK" << endl; - delete att_list; - -// Test attribute query - - DeviceAttributeConfig attr_conf; - attr_conf = device->attribute_query("Short_attr"); - - assert ( attr_conf.name == "Short_attr" ); - assert ( attr_conf.data_format == SCALAR ); - assert ( attr_conf.data_type == DEV_SHORT ); - assert ( attr_conf.description == "No description" ); - assert ( attr_conf.max_dim_x == 1 ); - - cout << " Attribute config --> OK" << endl; - -// Test get_attribute_config - - AttributeInfoList *attr_conf_ptr; - vector li; - li.push_back("Long_attr"); - li.push_back("Double_attr"); - - attr_conf_ptr = device->get_attribute_config(li); - - assert ( attr_conf_ptr->size() == 2 ); - - assert ( (*attr_conf_ptr)[0].name == "Long_attr" ); - assert ( (*attr_conf_ptr)[0].data_format == SCALAR ); - assert ( (*attr_conf_ptr)[0].data_type == DEV_LONG ); - - assert ( (*attr_conf_ptr)[1].name == "Double_attr" ); - assert ( (*attr_conf_ptr)[1].data_format == SCALAR ); - assert ( (*attr_conf_ptr)[1].data_type == DEV_DOUBLE ); - - cout << " Get attribute config --> OK" << endl; - delete attr_conf_ptr; - -// Test get_command_config - - CommandInfoList *cmd_conf_ptr; - li.clear(); - li.push_back("state"); - li.push_back("status"); - - cmd_conf_ptr = device->get_command_config(li); - - assert ( cmd_conf_ptr->size() == 2 ); - - assert ( (*cmd_conf_ptr)[0].cmd_name == "State" ); - assert ( (*cmd_conf_ptr)[0].in_type == DEV_VOID ); - assert ( (*cmd_conf_ptr)[0].out_type == DEV_STATE ); - - assert ( (*cmd_conf_ptr)[1].cmd_name == "Status" ); - assert ( (*cmd_conf_ptr)[1].in_type == DEV_VOID ); - assert ( (*cmd_conf_ptr)[1].out_type == DEV_STRING ); - - cout << " Get command config --> OK" << endl; - -// test attribute_list_query - -// AttributeInfoList *attr_confs; -// attr_confs = device->attribute_list_query(); - -// assert ( attr_confs->size() == 77 ); -// assert ( (*attr_confs)[0].name == "Short_attr"); -// assert ( (*attr_confs)[0].data_format == SCALAR); -// assert ( (*attr_confs)[0].data_type == DEV_SHORT); - -// assert ( (*attr_confs)[1].name == "Long_attr"); -// assert ( (*attr_confs)[1].data_type == DEV_LONG); -// assert ( (*attr_confs)[1].data_format == SCALAR); - -// assert ( (*attr_confs)[21].name == "String_attr_w"); -// assert ( (*attr_confs)[21].data_type == DEV_STRING); -// assert ( (*attr_confs)[21].data_format == SCALAR); - -// cout << " Attribute list query --> OK " << endl; -// delete attr_confs; - -// Test set_attribute_config - - AttributeInfoList v_conf; - AttributeInfo co = device->attribute_query("Short_attr"); - -#ifdef WIN32 - int pid = _getpid(); -#else - pid_t pid = getpid(); -#endif - - stringstream st; - - string s; - st << pid; - st >> s; - - co.format = s; - v_conf.push_back(co); - - device->set_attribute_config(v_conf); - - DeviceAttributeConfig res = device->attribute_query("Short_attr"); - assert ( res.format == s ); - - cout << " Set attribute config --> OK" << endl; - -// Test device version - -#ifndef COMPAT - int vers = device->get_idl_version(); - assert (vers == 5); - - cout << " Get IDL version --> OK" << endl; -#endif - -// Test source - - Tango::DevSource so = device->get_source(); - assert( so == Tango::CACHE_DEV ); - - device->set_source(Tango::DEV); - assert (device->get_source() == Tango::DEV); - - device->set_source(Tango::CACHE_DEV); - - cout << " Source parameter --> OK" << endl; - -// Test get property list - -#ifndef COMPAT - vector props; - device->get_property_list("*",props); - - cout << "NB prop = " << props.size() << endl; - for (unsigned long l = 0;l < props.size();l++) - cout << "prop = " << props[l] << endl; - //TODO conf_devtest defines only 3 properties - assert (props.size() == 3); - assert (props[0] == "cmd_min_poll_period"); - assert (props[1] == "min_poll_period"); - assert (props[2] == "tst_property"); -// assert (props[3] == "__SubDevices"); - - cout << " Get property list --> OK" << endl; -#endif - } - catch (Tango::DevFailed &e) - { - Except::print_exception(e); - exit(-1); - } - - delete device; - - return 0; -} diff --git a/cpp_test_suite/old_tests/size.cpp b/cpp_test_suite/old_tests/size.cpp index 0bb245411..24cafb391 100644 --- a/cpp_test_suite/old_tests/size.cpp +++ b/cpp_test_suite/old_tests/size.cpp @@ -41,21 +41,21 @@ int main(int argc, char **argv) check_size("Attribute",sizeof(Attribute),2536, &isOK); // Was 208 in V4 check_size("WAttribute",sizeof(WAttribute),3200, &isOK); // Was 252 in V4 check_size("MultiAttribute",sizeof(MultiAttribute),80, &isOK); - - check_size("Command",sizeof(Command),72, &isOK); - check_size("TemplCommand",sizeof(TemplCommand),112, &isOK); - check_size("TemplCommandIn",sizeof(TemplCommandIn),136, &isOK); - check_size("TemplCommandOut",sizeof(TemplCommandOut),136, &isOK); - check_size("TemplCommandInOut",sizeof(TemplCommandInOut),136, &isOK); - check_size("DeviceProxy",sizeof(DeviceProxy),576, &isOK); // Was 100 in V4 + check_size("Command", sizeof(Command), 80, &isOK); + check_size("TemplCommand", sizeof(TemplCommand), 120, &isOK); + check_size("TemplCommandIn", sizeof(TemplCommandIn), 144, &isOK); + check_size("TemplCommandOut", sizeof(TemplCommandOut), 144, &isOK); + check_size("TemplCommandInOut", sizeof(TemplCommandInOut), 144, &isOK); + + check_size("DeviceProxy", sizeof(DeviceProxy), 584, &isOK); // Was 100 in V4 check_size("DeviceData",sizeof(DeviceData),32, &isOK); check_size("DeviceDataHistory",sizeof(DeviceDataHistory),80, &isOK); check_size("DeviceAttribute",sizeof(DeviceAttribute),200, &isOK); // Was 52 in V4 check_size("DeviceAttributeHistory",sizeof(DeviceAttributeHistory),232, &isOK); // Was 76 in V4 check_size("ApiUtil",sizeof(ApiUtil),312, &isOK); - check_size("Database",sizeof(Database),624, &isOK); // Was 108 in V4 + check_size("Database", sizeof(Database), 632, &isOK); // Was 108 in V4 check_size("DbDevice",sizeof(DbDevice),32, &isOK); check_size("DbClass",sizeof(DbClass),32, &isOK); check_size("DbServer",sizeof(DbServer),32, &isOK); diff --git a/cppapi/client/CMakeLists.txt b/cppapi/client/CMakeLists.txt index 5be303501..c2c755e79 100644 --- a/cppapi/client/CMakeLists.txt +++ b/cppapi/client/CMakeLists.txt @@ -28,7 +28,8 @@ set(SOURCES dbapi_class.cpp eventkeepalive.cpp eventqueue.cpp notifdeventconsumer.cpp - zmqeventconsumer.cpp) + zmqeventconsumer.cpp + device_command_info.cpp) set(HEADERS accessproxy.h apiexcept.h @@ -54,7 +55,8 @@ set(HEADERS accessproxy.h devapi_attr.tpp devapi_utils.tpp api_util.tpp - devapi_pipe.tpp) + devapi_pipe.tpp + device_command_info.h) add_subdirectory(helpers) if(WIN32) diff --git a/cppapi/client/Connection.h b/cppapi/client/Connection.h index bceba553d..03277f6dd 100644 --- a/cppapi/client/Connection.h +++ b/cppapi/client/Connection.h @@ -137,7 +137,8 @@ protected : int user_connect_timeout; bool tango_host_localhost; - Tango::Device_5_var device_5; + Tango::Device_5_var device_5; + Tango::Device_6_var device_6; public : ///@publicsection @@ -568,6 +569,7 @@ public : void omni420_timeout(int,char *); DeviceData omni420_except(int,char *,TgRequest &); void toIOR(const char*,IOP::IOR&); + void resolve_obj_version(const string &corba_name, const CORBA::Object_var &obj); }; diff --git a/cppapi/client/DeviceProxy.h b/cppapi/client/DeviceProxy.h index 45a561a7c..a1e77af39 100644 --- a/cppapi/client/DeviceProxy.h +++ b/cppapi/client/DeviceProxy.h @@ -29,6 +29,8 @@ #define _DEVICEPROXY_H +#include + /**************************************************************************************** * * * The DeviceProxy class * diff --git a/cppapi/client/devapi.h b/cppapi/client/devapi.h index a32d75bce..50b930b8f 100644 --- a/cppapi/client/devapi.h +++ b/cppapi/client/devapi.h @@ -30,6 +30,7 @@ #include #include +#include #include #include #include @@ -89,28 +90,6 @@ struct LockingThread LockThread *l_thread; }; -/** - * Base structure for command information - * - * @headerfile tango.h - */ -#ifdef GEN_DOC -typedef struct DevCommandInfo -#else -typedef struct _DevCommandInfo -#endif -{ - string cmd_name; ///< The command name - long cmd_tag; ///< The command tag - long in_type; ///< Input parameter data type - long out_type; ///< Output parameter data type - string in_type_desc; ///< Input parameter description - string out_type_desc; ///< Ouptput parameter description - -///@privatesection - bool operator==(const _DevCommandInfo &); -}DevCommandInfo; - struct AttributeDimension { @@ -118,32 +97,7 @@ struct AttributeDimension long dim_y; }; -/** - * Command information data extension - * - * @headerfile tango.h - * @ingroup Client - */ -#ifdef GEN_DOC -typedef struct CommandInfo : public DevCommandInfo -#else -typedef struct _CommandInfo : public DevCommandInfo -#endif -{ - Tango::DispLevel disp_level; ///< The command display level -/// @privatesection - friend ostream &operator<<(ostream &,_CommandInfo &); - bool operator==(const _CommandInfo &); -}CommandInfo; - -/** - * A vector of CommandInfo structure - * - * @headerfile tango.h - * @ingroup Client - */ -typedef vector CommandInfoList; struct _DeviceInfo { diff --git a/cppapi/client/devapi_base.cpp b/cppapi/client/devapi_base.cpp index 6c05e8bd9..06a30d80e 100644 --- a/cppapi/client/devapi_base.cpp +++ b/cppapi/client/devapi_base.cpp @@ -271,6 +271,8 @@ Connection &Connection::operator=(const Connection &rval) tango_host_localhost = rval.tango_host_localhost; device_5 = rval.device_5; + device_6 = rval.device_6; + #ifdef HAS_UNIQUE_PTR if (rval.ext.get() != NULL) @@ -420,7 +422,8 @@ void Connection::connect(string &corba_name) Object_var obj; obj = ApiUtil::instance()->get_orb()->string_to_object(corba_name.c_str()); - +//TODO this should be dramatically refactored +// some thoughts: extract ConnectionFactory; make Connection interface implemented by Connection_V1, Connection_V2 etc; inject Connection (or Factory) into DeviceProxy // // Narrow CORBA string name to CORBA object // First, try as a Device_5, then as a Device_4, then as .... and finally as a Device @@ -453,73 +456,7 @@ void Connection::connect(string &corba_name) } } - device_5 = Device_5::_narrow(obj); - - if (CORBA::is_nil(device_5)) - { - device_4 = Device_4::_narrow(obj); - - if (CORBA::is_nil(device_4)) - { - device_3 = Device_3::_narrow(obj); - - if (CORBA::is_nil(device_3)) - { - device_2 = Device_2::_narrow(obj); - if (CORBA::is_nil(device_2)) - { - device = Device::_narrow(obj); - if (CORBA::is_nil(device)) - { - cerr << "Can't build connection to object " << corba_name << endl; - connection_state = CONNECTION_NOTOK; - - TangoSys_OMemStream desc; - desc << "Failed to connect to device " << dev_name(); - desc << " (device nil after _narrowing)" << ends; - ApiConnExcept::throw_exception((const char *) API_CantConnectToDevice, - desc.str(), - (const char *) "Connection::connect()"); - } - else - { - device->_non_existent(); - version = 1; - } - } - else - { - device_2->_non_existent(); - version = 2; - device = Device_2::_duplicate(device_2); - } - } - else - { - device_3->_non_existent(); - version = 3; - device_2 = Device_3::_duplicate(device_3); - device = Device_3::_duplicate(device_3); - } - } - else - { - device_4->_non_existent(); - version = 4; - device_3 = Device_4::_duplicate(device_4); - device_2 = Device_4::_duplicate(device_4); - device = Device_4::_duplicate(device_4); - } - } - else - { - device_5->_non_existent(); - version = 5; - device_4 = Device_5::_duplicate(device_5); - device_3 = Device_5::_duplicate(device_5); - device_2 = Device_5::_duplicate(device_5); - device = Device_5::_duplicate(device_5); - } + resolve_obj_version(corba_name, obj); // // Warning! Some non standard code (omniORB specific). @@ -534,9 +471,9 @@ void Connection::connect(string &corba_name) IIOP::ProfileBody pBody; IIOP::unmarshalProfile(ior.profiles[0], pBody); - CORBA::ULong total = pBody.components.length(); + DevULong total = pBody.components.length(); - for (CORBA::ULong index = 0; index < total; index++) + for (DevULong index = 0; index < total; index++) { IOP::TaggedComponent &c = pBody.components[index]; if (c.tag == 3) @@ -643,6 +580,89 @@ void Connection::connect(string &corba_name) } } +void Connection::resolve_obj_version(const string &corba_name, const Object_var &obj) +{ + //TODO extract template or Macro or class hierarchy, 'cauz this code clearly is a duplication + device_6 = Device_6::_narrow(obj); + + if (not is_nil(device_6)) + { + version = 6; + device_6->_non_existent(); + device_5 = Device_6::_duplicate(device_6); + device_4 = Device_6::_duplicate(device_6); + device_3 = Device_6::_duplicate(device_6); + device_2 = Device_6::_duplicate(device_6); + device = Device_6::_duplicate(device_6); + return; + } + + device_5 = Device_5::_narrow(obj); + + if (not is_nil(device_5)) + { + version = 5; + device_5->_non_existent(); + device_4 = Device_5::_duplicate(device_5); + device_3 = Device_5::_duplicate(device_5); + device_2 = Device_5::_duplicate(device_5); + device = Device_5::_duplicate(device_5); + return; + } + + device_4 = Device_4::_narrow(obj); + + if (not is_nil(device_4)) + { + version = 4; + device_4->_non_existent(); + device_3 = Device_4::_duplicate(device_4); + device_2 = Device_4::_duplicate(device_4); + device = Device_4::_duplicate(device_4); + return; + } + + device_3 = Device_3::_narrow(obj); + + if (not is_nil(device_3)) + { + version = 3; + device_3->_non_existent(); + device_2 = Device_3::_duplicate(device_3); + device = Device_3::_duplicate(device_3); + return; + } + + device_2 = Device_2::_narrow(obj); + + if (not is_nil(device_2)) + { + version = 2; + device_2->_non_existent(); + device = Device_2::_duplicate(device_2); + return; + } + + device = Device::_narrow(obj); + + if (not is_nil(device)) + { + version = 1; + device->_non_existent(); + return; + } + + cerr << "Can't build connection to object " << corba_name << endl; + connection_state = CONNECTION_NOTOK; + + TangoSys_OMemStream desc; + desc << "Failed to connect to device " << dev_name(); + desc << " (device nil after _narrowing)" << ends; + ApiConnExcept::throw_exception((const char *) API_CantConnectToDevice, + desc.str(), + (const char *) "Connection::resolve_obj_version()"); +} + //----------------------------------------------------------------------------- // @@ -671,12 +691,12 @@ void Connection::toIOR(const char *iorstr, IOP::IOR &ior) s = (s - 4) / 2; // how many octets are there in the string p += 4; - cdrMemoryStream buf((CORBA::ULong) s, 0); + cdrMemoryStream buf((DevULong) s, 0); for (int i = 0; i < (int) s; i++) { int j = i * 2; - CORBA::Octet v; + DevUChar v; if (p[j] >= '0' && p[j] <= '9') { @@ -716,7 +736,7 @@ void Connection::toIOR(const char *iorstr, IOP::IOR &ior) } buf.rewindInputPtr(); - CORBA::Boolean b = buf.unmarshalBoolean(); + DevBoolean b = buf.unmarshalBoolean(); buf.setByteSwapFlag(b); ior.type_id = IOP::IOR::unmarshaltype_id(buf); @@ -3401,6 +3421,7 @@ CommandInfo DeviceProxy::command_query(string cmd) CommandInfo command_info; DevCmdInfo_var cmd_info; DevCmdInfo_2_var cmd_info_2; + DevCmdInfo_6_var cmd_info_6; int ctr = 0; while (ctr < 2) @@ -3409,31 +3430,31 @@ CommandInfo DeviceProxy::command_query(string cmd) { check_and_reconnect(); - if (version == 1) + + Device_var dev; + Device_2_var dev_2; + Device_6_var dev_6; + switch (version) { - Device_var dev = Device::_duplicate(device); + case 1: + dev = Device::_duplicate(device); cmd_info = dev->command_query(cmd.c_str()); - command_info.cmd_name = cmd_info->cmd_name; - command_info.cmd_tag = cmd_info->cmd_tag; - command_info.in_type = cmd_info->in_type; - command_info.out_type = cmd_info->out_type; - command_info.in_type_desc = cmd_info->in_type_desc; - command_info.out_type_desc = cmd_info->out_type_desc; - command_info.disp_level = Tango::OPERATOR; - } - else - { - Device_2_var dev = Device_2::_duplicate(device_2); - cmd_info_2 = dev->command_query_2(cmd.c_str()); + return create_CommandInfo(cmd_info.in()); + case 2: + case 3: + case 4: + case 5: + dev_2 = Device_2::_duplicate(device_2); + cmd_info_2 = dev_2->command_query_2(cmd.c_str()); + + return create_CommandInfo(cmd_info_2.in()); + case 6: + default: + dev_6 = Device_6::_duplicate(device_6); + cmd_info_6 = dev_6->command_query_6(cmd.c_str()); - command_info.cmd_name = cmd_info_2->cmd_name; - command_info.cmd_tag = cmd_info_2->cmd_tag; - command_info.in_type = cmd_info_2->in_type; - command_info.out_type = cmd_info_2->out_type; - command_info.in_type_desc = cmd_info_2->in_type_desc; - command_info.out_type_desc = cmd_info_2->out_type_desc; - command_info.disp_level = cmd_info_2->level; + return create_CommandInfo(cmd_info_6.in()); } ctr = 2; } @@ -3550,6 +3571,7 @@ CommandInfoList *DeviceProxy::command_list_query() CommandInfoList *command_info_list = NULL; DevCmdInfoList_var cmd_info_list; DevCmdInfoList_2_var cmd_info_list_2; + DevCmdInfoList_6_var cmd_info_list_6; int ctr = 0; while (ctr < 2) @@ -3558,42 +3580,30 @@ CommandInfoList *DeviceProxy::command_list_query() { check_and_reconnect(); - if (version == 1) + Device_var dev; + Device_2_var dev_2; + Device_6_var dev_6; + switch (version) { - Device_var dev = Device::_duplicate(device); + case 1: + dev = Device::_duplicate(device); cmd_info_list = dev->command_list_query(); - command_info_list = new CommandInfoList(cmd_info_list->length()); -// command_info_list->resize(cmd_info_list->length()); - - for (unsigned int i = 0; i < cmd_info_list->length(); i++) - { - (*command_info_list)[i].cmd_name = cmd_info_list[i].cmd_name; - (*command_info_list)[i].cmd_tag = cmd_info_list[i].cmd_tag; - (*command_info_list)[i].in_type = cmd_info_list[i].in_type; - (*command_info_list)[i].out_type = cmd_info_list[i].out_type; - (*command_info_list)[i].in_type_desc = cmd_info_list[i].in_type_desc; - (*command_info_list)[i].out_type_desc = cmd_info_list[i].out_type_desc; - (*command_info_list)[i].disp_level = Tango::OPERATOR; - } - } - else - { - Device_2_var dev = Device_2::_duplicate(device_2); - cmd_info_list_2 = dev->command_list_query_2(); + return newCommandInfoList(cmd_info_list); + case 2: + case 3: + case 4: + case 5: + dev_2 = Device_2::_duplicate(device_2); + cmd_info_list_2 = dev_2->command_list_query_2(); - command_info_list = new CommandInfoList(cmd_info_list_2->length()); -// command_info_list->resize(cmd_info_list_2->length()); + return newCommandInfoList(cmd_info_list_2); + case 6: + default: + dev_6 = Device_6::_duplicate(device_6); + cmd_info_list_6 = dev_6->command_list_query_6(); - for (unsigned int i = 0; i < cmd_info_list_2->length(); i++) - { - (*command_info_list)[i].cmd_name = cmd_info_list_2[i].cmd_name; - (*command_info_list)[i].cmd_tag = cmd_info_list_2[i].cmd_tag; - (*command_info_list)[i].in_type = cmd_info_list_2[i].in_type; - (*command_info_list)[i].out_type = cmd_info_list_2[i].out_type; - (*command_info_list)[i].in_type_desc = cmd_info_list_2[i].in_type_desc; - (*command_info_list)[i].out_type_desc = cmd_info_list_2[i].out_type_desc; - (*command_info_list)[i].disp_level = cmd_info_list_2[i].level; + return newCommandInfoList(cmd_info_list_6); } } ctr = 2; @@ -4219,6 +4229,7 @@ AttributeInfoListEx *DeviceProxy::get_attribute_config_ex(vector &attr_s break; case 5: + case 6: { Device_5_var dev = Device_5::_duplicate(device_5); attr_config_list_5 = dev->get_attribute_config_5(attr_list); @@ -4267,6 +4278,8 @@ AttributeInfoListEx *DeviceProxy::get_attribute_config_ex(vector &attr_s break; default: + //TODO an exception must be thrown here, but it produces segfault in ~AttributeProxy + //Tango::Except::throw_exception("Unsupported TANGO protocol version=" + version,"Unsupported TANGO protocol version=" + version,"DeviceProxy::get_attribute_config_ex"); break; } @@ -5839,7 +5852,7 @@ vector *DeviceProxy::read_attributes(vector &attr_strin { if (version >= 3) { - if (version == 5) + if (version >= 5) { ApiUtil::attr_to_device(&(attr_value_list_5[i]), version, &(*dev_attr)[i]); } @@ -10254,6 +10267,11 @@ int DeviceProxy::get_tango_lib_version() ret = 902; break; + //TODO extract class hierarchy based on version!!! + case 6: + ret = 1001; + break; + default: break; } diff --git a/cppapi/client/device_command_info.cpp b/cppapi/client/device_command_info.cpp new file mode 100644 index 000000000..54a3bd6a8 --- /dev/null +++ b/cppapi/client/device_command_info.cpp @@ -0,0 +1,89 @@ +//=================================================================================================================== +// +// file : device_command_info.cpp +// +// project : tango +// +// author(s) : ingvord +// +// Copyright (C) : 2004-2017 +// European Synchrotron Radiation Facility +// BP 220, Grenoble 38043 +// FRANCE +// +// This file is part of Tango. +// +// Tango is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Tango is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty +// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License along with Tango. +// If not, see . +//=================================================================================================================== + +#include +#include + +namespace Tango +{ + + +CommandInfo create_CommandInfo(const DevCmdInfo &devCmdInfo) +{ + CommandInfo result; + + result.cmd_name = devCmdInfo.cmd_name; + result.cmd_tag = devCmdInfo.cmd_tag; + result.in_type = devCmdInfo.in_type; + result.out_type = devCmdInfo.out_type; + result.in_type_desc = devCmdInfo.in_type_desc; + result.out_type_desc = devCmdInfo.out_type_desc; + result.disp_level = Tango::OPERATOR; + return (result); +} + +CommandInfo create_CommandInfo(const DevCmdInfo_2 &devCmdInfo_2) +{ + CommandInfo result; + + result.cmd_name = devCmdInfo_2.cmd_name; + result.cmd_tag = devCmdInfo_2.cmd_tag; + result.in_type = devCmdInfo_2.in_type; + result.out_type = devCmdInfo_2.out_type; + result.in_type_desc = devCmdInfo_2.in_type_desc; + result.out_type_desc = devCmdInfo_2.out_type_desc; + result.disp_level = devCmdInfo_2.level; + return (result); +} + +CommandInfo create_CommandInfo(const DevCmdInfo_6 &devCmdInfo_3) +{ + CommandInfo result; + + result.cmd_name = devCmdInfo_3.cmd_name; + result.cmd_tag = devCmdInfo_3.cmd_tag; + result.in_type = devCmdInfo_3.in_type; + result.out_type = devCmdInfo_3.out_type; + result.in_type_desc = devCmdInfo_3.in_type_desc; + result.out_type_desc = devCmdInfo_3.out_type_desc; + result.disp_level = devCmdInfo_3.level; + + fill_vector(result.in_enum_labels, devCmdInfo_3.in_enum_labels); + fill_vector(result.out_enum_labels, devCmdInfo_3.out_enum_labels); + + return (result); +} + +void fill_vector(vector &dst, const DevVarStringArray &src) +{ + dst.resize(src.length()); + for (size_t i = 0, size = src.length(); i < size; ++i) + { + dst[i] = src[i].in(); + } +} +}//namespace Tango diff --git a/cppapi/client/device_command_info.h b/cppapi/client/device_command_info.h new file mode 100644 index 000000000..5444443f1 --- /dev/null +++ b/cppapi/client/device_command_info.h @@ -0,0 +1,126 @@ +//=================================================================================================================== +// +// file : device_command_info.h +// +// project : tango +// +// author(s) : ingvord +// +// Copyright (C) : 2004-2017 +// European Synchrotron Radiation Facility +// BP 220, Grenoble 38043 +// FRANCE +// +// This file is part of Tango. +// +// Tango is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Tango is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty +// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License along with Tango. +// If not, see . +//=================================================================================================================== + +#pragma once + + +namespace Tango +{ +/** + * Base structure for command information + * + * @headerfile tango.h + */ +#ifdef GEN_DOC +typedef struct DevCommandInfo +#else + +typedef struct _DevCommandInfo +#endif +{ + string cmd_name; ///< The command name + long cmd_tag; ///< The command tag + long in_type; ///< Input parameter data type + long out_type; ///< Output parameter data type + string in_type_desc; ///< Input parameter description + string out_type_desc; ///< Ouptput parameter description +///@privatesection + bool operator==(const _DevCommandInfo &); +} DevCommandInfo; + +/** + * Command information data extension + * + * @headerfile tango.h + * @ingroup Client + */ +#ifdef GEN_DOC +typedef struct CommandInfo : public DevCommandInfo +#else + +typedef struct _CommandInfo: public DevCommandInfo +#endif +{ + Tango::DispLevel disp_level; ///< The command display level + + vector in_enum_labels; ///< Labels for enum arg or empty + vector out_enum_labels; ///< Labels for enum result or empty + + _CommandInfo() + : DevCommandInfo(), + in_enum_labels(), + out_enum_labels() + {} + +/// @privatesection + friend ostream &operator<<(ostream &, _CommandInfo &); + + bool operator==(const _CommandInfo &); +} CommandInfo; + +/** + * + * @return CommandInfo created on stack + */ +CommandInfo create_CommandInfo(const DevCmdInfo &); + +/** + * + * @return CommandInfo created on stack + */ +CommandInfo create_CommandInfo(const DevCmdInfo_2 &); + +/** + * + * @return CommandInfo created on stack + */ +CommandInfo create_CommandInfo(const DevCmdInfo_6 &); + +//TODO template +void fill_vector(vector &, const DevVarStringArray &); + +/** + * A vector of CommandInfo structure + * + * @headerfile tango.h + * @ingroup Client + */ +typedef vector CommandInfoList; + +template +CommandInfoList *newCommandInfoList(DevCommandInfoList devCmdInfoList_var) +{ + auto result = new CommandInfoList(devCmdInfoList_var->length()); + + for (size_t i = 0, size = devCmdInfoList_var->length(); i < size; ++i) + { + (*result)[i] = create_CommandInfo(devCmdInfoList_var[i]); + } + + return (result); +} +} \ No newline at end of file diff --git a/cppapi/client/proxy_asyn.cpp b/cppapi/client/proxy_asyn.cpp index a925b0e07..aedd45833 100644 --- a/cppapi/client/proxy_asyn.cpp +++ b/cppapi/client/proxy_asyn.cpp @@ -1059,8 +1059,9 @@ vector *DeviceProxy::read_attributes_reply(long id) switch (version) { + case 6: case 5: - dii_any >>= received_5; + dii_any >>= received_5; nb_received = received_5->length(); break; @@ -1086,7 +1087,7 @@ vector *DeviceProxy::read_attributes_reply(long id) { if (version >= 3) { - if (version == 5) + if (version >= 5) ApiUtil::attr_to_device(&((*received_5)[i]),version,&((*dev_attr)[i])); else if (version == 4) ApiUtil::attr_to_device(&((*received_4)[i]),version,&((*dev_attr)[i])); @@ -1263,8 +1264,9 @@ DeviceAttribute *DeviceProxy::read_attribute_reply(long id) switch (version) { + case 6: case 5: - dii_any >>= received_5; + dii_any >>= received_5; break; case 4: @@ -1282,7 +1284,7 @@ DeviceAttribute *DeviceProxy::read_attribute_reply(long id) if (version >= 3) { - if (version == 5) + if (version >= 5) ApiUtil::attr_to_device(&((*received_5)[0]),version,dev_attr); else if (version == 4) ApiUtil::attr_to_device(&((*received_4)[0]),version,dev_attr); @@ -1503,8 +1505,9 @@ vector *DeviceProxy::read_attributes_reply(long id,long call_ti switch (version) { + case 6: case 5: - dii_any >>= received_5; + dii_any >>= received_5; nb_received = received_5->length(); break; @@ -1530,7 +1533,7 @@ vector *DeviceProxy::read_attributes_reply(long id,long call_ti { if (version >= 3) { - if (version == 5) + if (version >= 5) ApiUtil::attr_to_device(&((*received_5)[i]),version,&((*dev_attr)[i])); else if (version == 4) ApiUtil::attr_to_device(&((*received_4)[i]),version,&((*dev_attr)[i])); @@ -1747,8 +1750,9 @@ DeviceAttribute *DeviceProxy::read_attribute_reply(long id,long call_timeout) switch (version) { + case 6: case 5: - dii_any >>= received_5; + dii_any >>= received_5; break; case 4: @@ -1766,7 +1770,7 @@ DeviceAttribute *DeviceProxy::read_attribute_reply(long id,long call_timeout) if (version >= 3) { - if (version == 5) + if (version >= 5) ApiUtil::attr_to_device(&((*received_5)[0]),version,dev_attr); else if (version == 4) ApiUtil::attr_to_device(&((*received_4)[0]),version,dev_attr); diff --git a/cppapi/client/proxy_asyn_cb.cpp b/cppapi/client/proxy_asyn_cb.cpp index 886adb5d5..5b4975e33 100644 --- a/cppapi/client/proxy_asyn_cb.cpp +++ b/cppapi/client/proxy_asyn_cb.cpp @@ -476,8 +476,9 @@ void Connection::Cb_ReadAttr_Request(CORBA::Request_ptr req,Tango::CallBack *cb_ switch (version) { + case 6: case 5: - dii_any >>= received_5; + dii_any >>= received_5; nb_received = received_5->length(); break; @@ -503,7 +504,7 @@ void Connection::Cb_ReadAttr_Request(CORBA::Request_ptr req,Tango::CallBack *cb_ { if (version >= 3) { - if (version == 5) + if (version >= 5) ApiUtil::attr_to_device(&((*received_5)[i]),version,&((*dev_attr)[i])); else if (version == 4) ApiUtil::attr_to_device(&((*received_4)[i]),version,&((*dev_attr)[i])); diff --git a/cppapi/server/CMakeLists.txt b/cppapi/server/CMakeLists.txt index 1475915ea..1654f9271 100644 --- a/cppapi/server/CMakeLists.txt +++ b/cppapi/server/CMakeLists.txt @@ -17,6 +17,7 @@ set(SOURCES attrdesc.cpp device_3.cpp device_4.cpp device_5.cpp + device_6.cpp deviceclass.cpp devicelog.cpp devintr.cpp @@ -81,6 +82,7 @@ set(HEADERS attrdesc.h device_3.tpp device_4.h device_5.h + device_6.h deviceclass.h devintr.h dintrthread.h diff --git a/cppapi/server/attribute.cpp b/cppapi/server/attribute.cpp index 80b7fb96d..e79214c57 100644 --- a/cppapi/server/attribute.cpp +++ b/cppapi/server/attribute.cpp @@ -3817,10 +3817,14 @@ void Attribute::fire_change_event(DevFailed *except) { switch (*ite) { - case 5: - if (change5_subscription >= EVENT_RESUBSCRIBE_PERIOD) - remove_client_lib(5,string(EventName[CHANGE_EVENT])); - break; + //TODO extract class hierarchy based on version!!! + case 6: + case 5: + if (change5_subscription >= EVENT_RESUBSCRIBE_PERIOD) + { + remove_client_lib(5, string(EventName[CHANGE_EVENT])); + } + break; case 4: if (change4_subscription >= EVENT_RESUBSCRIBE_PERIOD) @@ -4241,10 +4245,14 @@ void Attribute::fire_archive_event(DevFailed *except) { switch (*ite) { - case 5: - if (archive5_subscription >= EVENT_RESUBSCRIBE_PERIOD) - remove_client_lib(5,string(EventName[ARCHIVE_EVENT])); - break; + //TODO extract class hierarchy based on version!!! + case 6: + case 5: + if (archive5_subscription >= EVENT_RESUBSCRIBE_PERIOD) + { + remove_client_lib(5, string(EventName[ARCHIVE_EVENT])); + } + break; case 4: if (archive4_subscription >= EVENT_RESUBSCRIBE_PERIOD) @@ -4684,10 +4692,14 @@ void Attribute::fire_event(vector &filt_names,vector &filt_vals, { switch (*ite) { - case 5: - if (user5_subscription >= EVENT_RESUBSCRIBE_PERIOD) - remove_client_lib(5,string(EventName[USER_EVENT])); - break; + //TODO extract class hierarchy based on version!!! + case 6: + case 5: + if (user5_subscription >= EVENT_RESUBSCRIBE_PERIOD) + { + remove_client_lib(5, string(EventName[USER_EVENT])); + } + break; case 4: if (user4_subscription >= EVENT_RESUBSCRIBE_PERIOD) @@ -4925,10 +4937,14 @@ void Attribute::fire_error_periodic_event(DevFailed *except) { switch (*ite) { - case 5: - if (periodic5_subscription >= EVENT_RESUBSCRIBE_PERIOD) - remove_client_lib(5,string(EventName[PERIODIC_EVENT])); - break; + //TODO extract class hierarchy based on version!!! + case 6: + case 5: + if (periodic5_subscription >= EVENT_RESUBSCRIBE_PERIOD) + { + remove_client_lib(5, string(EventName[PERIODIC_EVENT])); + } + break; case 4: if (periodic4_subscription >= EVENT_RESUBSCRIBE_PERIOD) diff --git a/cppapi/server/attribute.h b/cppapi/server/attribute.h index 296f360e6..1d9dd4458 100644 --- a/cppapi/server/attribute.h +++ b/cppapi/server/attribute.h @@ -2584,8 +2584,10 @@ inline void Attribute::set_change_event_sub(int cl_lib) { switch (cl_lib) { - case 5: - event_change5_subscription = time(NULL); + //TODO extract class hierarchy based on version!!! + case 6: + case 5: + event_change5_subscription = time(NULL); break; case 4: @@ -2603,8 +2605,10 @@ inline void Attribute::set_periodic_event_sub(int cl_lib) { switch (cl_lib) { - case 5: - event_periodic5_subscription = time(NULL); + //TODO extract class hierarchy based on version!!! + case 6: + case 5: + event_periodic5_subscription = time(NULL); break; case 4: @@ -2622,8 +2626,10 @@ inline void Attribute::set_archive_event_sub(int cl_lib) { switch (cl_lib) { - case 5: - event_archive5_subscription = time(NULL); + //TODO extract class hierarchy based on version!!! + case 6: + case 5: + event_archive5_subscription = time(NULL); break; case 4: @@ -2641,8 +2647,10 @@ inline void Attribute::set_user_event_sub(int cl_lib) { switch (cl_lib) { - case 5: - event_user5_subscription = time(NULL); + //TODO extract class hierarchy based on version!!! + case 6: + case 5: + event_user5_subscription = time(NULL); break; case 4: @@ -2660,8 +2668,10 @@ inline void Attribute::set_att_conf_event_sub(int cl_lib) { switch (cl_lib) { - case 5: - event_attr_conf5_subscription = time(NULL); + //TODO extract class hierarchy based on version!!! + case 6: + case 5: + event_attr_conf5_subscription = time(NULL); break; default: diff --git a/cppapi/server/blackbox.cpp b/cppapi/server/blackbox.cpp index 7f7835174..f0e41865d 100644 --- a/cppapi/server/blackbox.cpp +++ b/cppapi/server/blackbox.cpp @@ -612,7 +612,7 @@ void BlackBox::insert_attr(const Tango::DevVarStringArray &names, const ClntIden box[insert_elt].req_type = Req_Operation; box[insert_elt].attr_type = Attr_Unknown; - if (vers == 5) + if (vers >= 5) { box[insert_elt].op_type = Op_Read_Attr_5; } @@ -1057,7 +1057,7 @@ void BlackBox::insert_attr_wr_nl(const Tango::AttributeValueList_4 &att_list, box[insert_elt].req_type = Req_Operation; box[insert_elt].attr_type = Attr_Unknown; - if (vers == 5) + if (vers >= 5) { box[insert_elt].op_type = Op_Write_Read_Attributes_5; } diff --git a/cppapi/server/device_2.cpp b/cppapi/server/device_2.cpp index 019198cbe..b5c2113db 100644 --- a/cppapi/server/device_2.cpp +++ b/cppapi/server/device_2.cpp @@ -1095,8 +1095,6 @@ Tango::DevCmdInfo_2 *Device_2Impl::command_query_2(const char *command) cout4 << "DeviceImpl::command_query_2 arrived" << endl; Tango::DevCmdInfo_2 *back = NULL; - string cmd(command); - transform(cmd.begin(),cmd.end(),cmd.begin(),::tolower); // // Record operation request in black box @@ -1124,57 +1122,39 @@ Tango::DevCmdInfo_2 *Device_2Impl::command_query_2(const char *command) // (in case of dyn command instaleld at device level) // - long i; - bool found = false; - Command *cmd_ptr = Tango_nullptr; - long nb_cmd = device_class->get_command_list().size(); - for (i = 0;i < nb_cmd;i++) - { - if (device_class->get_command_list()[i]->get_lower_name() == cmd) - { - found = true; - cmd_ptr = device_class->get_command_list()[i]; - break; - } - } - - if (found == false) - { - nb_cmd = get_local_command_list().size(); - for (i = 0;i < nb_cmd;i++) - { - if (get_local_command_list()[i]->get_lower_name() == cmd) - { - found = true; - cmd_ptr = get_local_command_list()[i]; - break; - } - } - } - - - if (found == true) - { - back->cmd_name = CORBA::string_dup(cmd_ptr->get_name().c_str()); - back->cmd_tag = 0; - back->level = cmd_ptr->get_disp_level(); - back->in_type = (long)(cmd_ptr->get_in_type()); - back->out_type = (long)(cmd_ptr->get_out_type()); - string &str_in = cmd_ptr->get_in_type_desc(); - if (str_in.size() != 0) - back->in_type_desc = CORBA::string_dup(str_in.c_str()); - else - back->in_type_desc = CORBA::string_dup(NotSet); - string &str_out = cmd_ptr->get_out_type_desc(); - if (str_out.size() != 0) - back->out_type_desc = CORBA::string_dup(str_out.c_str()); - else - back->out_type_desc = CORBA::string_dup(NotSet); - } - else - { - delete back; - cout3 << "Device_2Impl::command_query_2(): command " << command << " not found" << endl; + string cmd(command); + Command *cmd_ptr = get_cmd_ptr(cmd); + + if (cmd_ptr != Tango_nullptr) + { + back->cmd_name = CORBA::string_dup(cmd_ptr->get_name().c_str()); + back->cmd_tag = 0; + back->level = cmd_ptr->get_disp_level(); + back->in_type = (long) (cmd_ptr->get_in_type()); + back->out_type = (long) (cmd_ptr->get_out_type()); + string &str_in = cmd_ptr->get_in_type_desc(); + if (str_in.size() != 0) + { + back->in_type_desc = CORBA::string_dup(str_in.c_str()); + } + else + { + back->in_type_desc = CORBA::string_dup(NotSet); + } + string &str_out = cmd_ptr->get_out_type_desc(); + if (str_out.size() != 0) + { + back->out_type_desc = CORBA::string_dup(str_out.c_str()); + } + else + { + back->out_type_desc = CORBA::string_dup(NotSet); + } + } + else + { + delete back; + cout3 << "Device_2Impl::command_query_2(): command " << command << " not found" << endl; // // throw an exception to client @@ -1196,6 +1176,32 @@ Tango::DevCmdInfo_2 *Device_2Impl::command_query_2(const char *command) return back; } +Command *Device_2Impl::get_cmd_ptr(const string &cmd_name) +{ + string cmd_name_lower{cmd_name}; + transform(cmd_name.begin(), cmd_name.end(), cmd_name_lower.begin(), ::tolower); + //TODO +// auto found = find_if(device_class->get_command_list().begin(), device_class->get_command_list().end(),[](){device_class->get_command_list()[i]->get_lower_name() == cmd_name}) +// if(found != device_class->get_command_list().end()) return *found; + for (size_t i = 0, size = device_class->get_command_list().size(); i < size; i++) + { + if (device_class->get_command_list()[i]->get_lower_name() == cmd_name_lower) + { + return device_class->get_command_list()[i]; + } + } + + for (size_t i = 0, size = get_local_command_list().size(); i < size; i++) + { + if (get_local_command_list()[i]->get_lower_name() == cmd_name_lower) + { + return get_local_command_list()[i]; + } + } + + return Tango_nullptr; +} + //+------------------------------------------------------------------------- // // method : Device_2Impl::get_attribute_config_2 @@ -1217,10 +1223,10 @@ Tango::DevCmdInfo_2 *Device_2Impl::command_query_2(const char *command) // //-------------------------------------------------------------------------- -Tango::AttributeConfigList_2 *Device_2Impl::get_attribute_config_2(const Tango::DevVarStringArray& names) +Tango::AttributeConfigList_2 *Device_2Impl::get_attribute_config_2(const Tango::DevVarStringArray &names) { - TangoMonitor &mon = get_att_conf_monitor(); - AutoTangoMonitor sync(&mon); + TangoMonitor &mon = get_att_conf_monitor(); + AutoTangoMonitor sync(&mon); cout4 << "Device_2Impl::get_attribute_config_2 arrived" << endl; @@ -1332,11 +1338,11 @@ Tango::AttributeConfigList_2 *Device_2Impl::get_attribute_config_2(const Tango:: // //-------------------------------------------------------------------------- -Tango::DevCmdHistoryList *Device_2Impl::command_inout_history_2(const char* command, - CORBA::Long n) +Tango::DevCmdHistoryList *Device_2Impl::command_inout_history_2(const char *command, + CORBA::Long n) { - TangoMonitor &mon = get_poll_monitor(); - AutoTangoMonitor sync(&mon); + TangoMonitor &mon = get_poll_monitor(); + AutoTangoMonitor sync(&mon); cout4 << "Device_2Impl::command_inout_history_2 arrived" << endl; Tango::DevCmdHistoryList *back = NULL; @@ -1529,10 +1535,10 @@ Tango::DevCmdHistoryList *Device_2Impl::command_inout_history_2(const char* comm //-------------------------------------------------------------------------- Tango::DevAttrHistoryList *Device_2Impl::read_attribute_history_2(const char* name, - CORBA::Long n) + CORBA::Long n) { - TangoMonitor &mon = get_poll_monitor(); - AutoTangoMonitor sync(&mon); + TangoMonitor &mon = get_poll_monitor(); + AutoTangoMonitor sync(&mon); cout4 << "Device_2Impl::read_attribute_history_2 arrived" << endl; diff --git a/cppapi/server/device_2.h b/cppapi/server/device_2.h index e3651de23..b48d87505 100644 --- a/cppapi/server/device_2.h +++ b/cppapi/server/device_2.h @@ -325,6 +325,9 @@ class Device_2Impl : public virtual POA_Tango::Device_2, #else Device_2ImplExt *ext_2; #endif + +protected: + Command *get_cmd_ptr(const string &cmd_name); }; } // End of Tango namespace diff --git a/cppapi/server/device_6.cpp b/cppapi/server/device_6.cpp new file mode 100644 index 000000000..11a9804d0 --- /dev/null +++ b/cppapi/server/device_6.cpp @@ -0,0 +1,85 @@ +//=================================================================================================================== +// +// file : device_6.cpp +// +// project : tango +// +// author(s) : ingvord +// +// Copyright (C) : 2004-2017 +// European Synchrotron Radiation Facility +// BP 220, Grenoble 38043 +// FRANCE +// +// This file is part of Tango. +// +// Tango is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Tango is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty +// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License along with Tango. +// If not, see . +//=================================================================================================================== + +#include + +Tango::DevCmdInfo_6 *Tango::Device_6Impl::command_query_6(const char *cmd_name) +{ + cout4 << "Device_6Impl::command_query_6 arrived" << endl; + + DevCmdInfo_2 *cmdInfo_2 = command_query_2(cmd_name); + + DevCmdInfo_6 *result = new DevCmdInfo_6(); + result->cmd_name = cmdInfo_2->cmd_name; + result->level = cmdInfo_2->level; + result->cmd_tag = cmdInfo_2->cmd_tag; + result->in_type = cmdInfo_2->in_type; + result->out_type = cmdInfo_2->out_type; + result->in_type_desc = cmdInfo_2->in_type_desc; + result->out_type_desc = cmdInfo_2->out_type_desc; + + string cmd(cmd_name); + Command *cmd_ptr = get_cmd_ptr(cmd); + + vector &in_enum_labels = cmd_ptr->get_ext()->in_enum_labels; + vector &out_enum_labels = cmd_ptr->get_ext()->out_enum_labels; + + handle_cmd_info_enum_labels(&(result->in_enum_labels), in_enum_labels); + handle_cmd_info_enum_labels(&(result->out_enum_labels), out_enum_labels); + + cout4 << "Leaving Device_6Impl::command_query_6" << endl; + return result; +} + +Tango::DevCmdInfoList_6 *Tango::Device_6Impl::command_list_query_6() +{ + cout4 << "Device_6Impl::command_list_query_6 arrived" << endl; + + DevCmdInfoList_2 *cmdInfoList_2 = command_list_query_2(); + + DevCmdInfoList_6 *result = new DevCmdInfoList_6(); + result->length(cmdInfoList_2->length()); + + for (size_t i = 0, size = cmdInfoList_2->length(); i < size; ++i) + { + (*result)[i] = *command_query_6((*cmdInfoList_2)[i].cmd_name); + } + + cout4 << "Leaving Device_6Impl::command_list_query_6" << endl; + return result; +} + +void Tango::handle_cmd_info_enum_labels(Tango::DevVarStringArray *result, const vector &enum_labels) +{ + *result = DevVarStringArray(); + result->length(enum_labels.size()); + + for (size_t i = 0, size = enum_labels.size(); i < size; ++i) + { + (*result)[i] = string_dup(enum_labels[i].c_str()); + } +} diff --git a/cppapi/server/device_6.h b/cppapi/server/device_6.h new file mode 100644 index 000000000..c33404484 --- /dev/null +++ b/cppapi/server/device_6.h @@ -0,0 +1,84 @@ +//=================================================================================================================== +// +// file : device_6.h +// +// project : tango +// +// author(s) : ingvord +// +// Copyright (C) : 2004-2017 +// European Synchrotron Radiation Facility +// BP 220, Grenoble 38043 +// FRANCE +// +// This file is part of Tango. +// +// Tango is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Tango is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty +// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License along with Tango. +// If not, see . +//=================================================================================================================== +#ifndef TANGO_DEVICE_6_H +#define TANGO_DEVICE_6_H + +#include + +namespace Tango +{ + +void handle_cmd_info_enum_labels(DevVarStringArray *, const vector &); + +class Device_6Impl: public virtual POA_Tango::Device_6, + public Device_5Impl +{ +public: + Device_6Impl(DeviceClass *device_class, string &dev_name) + : Device_5Impl(device_class, dev_name) + { + idl_version = 6; + } + + Device_6Impl(DeviceClass *device_class, string &dev_name, string &desc) + : Device_5Impl(device_class, dev_name, + desc) + { + idl_version = 6; + } + + Device_6Impl(DeviceClass *device_class, string &dev_name, string &desc, DevState dev_state, string &dev_status) + : Device_5Impl(device_class, dev_name, desc, dev_state, dev_status) + { + idl_version = 6; + } + + Device_6Impl(DeviceClass *device_class, const char *dev_name, const char *desc, DevState dev_state, + const char *dev_status) + : Device_5Impl(device_class, dev_name, desc, dev_state, dev_status) + { + idl_version = 6; + } + + virtual ~Device_6Impl() = default; + + /** + * + * @param cmd_name + * @return CommandInfo with enum labels + */ + DevCmdInfo_6 *command_query_6(const char *cmd_name) override; + + DevCmdInfoList_6 *command_list_query_6() override; + +private: + friend void handle_cmd_info_enum_labels(DevVarStringArray *result, const vector &enum_labels); +}; + +}//EOF namespace Tango + +#endif //TANGO_DEVICE_6_H diff --git a/cppapi/server/eventcmds.cpp b/cppapi/server/eventcmds.cpp index 8666e8b70..704c3ce53 100644 --- a/cppapi/server/eventcmds.cpp +++ b/cppapi/server/eventcmds.cpp @@ -248,8 +248,10 @@ void DServer::event_subscription(string &dev_name,string &obj_name,string &actio omni_mutex_lock oml(EventSupplier::get_event_mutex()); switch (client_lib) { - case 5: - attribute.event_user5_subscription = time(NULL); + //TODO extract class hierarchy based on version!!! + case 6: + case 5: + attribute.event_user5_subscription = time(NULL); break; case 4: @@ -266,7 +268,8 @@ void DServer::event_subscription(string &dev_name,string &obj_name,string &actio cout4 << "DServer::event_subscription(): update attr_conf subscription\n"; omni_mutex_lock oml(EventSupplier::get_event_mutex()); - if (client_lib == 5) + //TODO extract class hierarchy based on versions + if (client_lib >= 5) attribute.event_attr_conf5_subscription = time(NULL); else attribute.event_attr_conf_subscription = time(NULL); @@ -369,8 +372,10 @@ void DServer::event_subscription(string &dev_name,string &obj_name,string &actio switch (client_lib) { - case 5: - attribute.event_change5_subscription = time(NULL); + //TODO extract class hierarchy based on version!!! + case 6: + case 5: + attribute.event_change5_subscription = time(NULL); break; case 4: @@ -394,8 +399,10 @@ void DServer::event_subscription(string &dev_name,string &obj_name,string &actio omni_mutex_lock oml(EventSupplier::get_event_mutex()); switch (client_lib) { - case 5: - attribute.event_periodic5_subscription = time(NULL); + //TODO extract class hierarchy based on version!!! + case 6: + case 5: + attribute.event_periodic5_subscription = time(NULL); break; case 4: @@ -447,8 +454,10 @@ void DServer::event_subscription(string &dev_name,string &obj_name,string &actio omni_mutex_lock oml(EventSupplier::get_event_mutex()); switch (client_lib) { - case 5: - attribute.event_archive5_subscription = time(NULL); + //TODO extract class hierarchy based on version!!! + case 6: + case 5: + attribute.event_archive5_subscription = time(NULL); break; case 4: diff --git a/cppapi/server/eventsupplier.cpp b/cppapi/server/eventsupplier.cpp index b74c47d53..d16e57ae0 100644 --- a/cppapi/server/eventsupplier.cpp +++ b/cppapi/server/eventsupplier.cpp @@ -150,10 +150,12 @@ SendEventType EventSupplier::detect_and_push_events(DeviceImpl *device_impl, str { switch (*ite) { + //TODO extract class hierarchy based on version!!! + case 6: case 5: if (change5_subscription >= EVENT_RESUBSCRIBE_PERIOD) { - attr.remove_client_lib(5, string(EventName[CHANGE_EVENT])); + attr.remove_client_lib(*ite, string(EventName[CHANGE_EVENT])); } break; @@ -194,10 +196,12 @@ SendEventType EventSupplier::detect_and_push_events(DeviceImpl *device_impl, str { switch (*ite) { + //TODO extract class hierarchy based on version!!! + case 6: case 5: if (periodic5_subscription >= EVENT_RESUBSCRIBE_PERIOD) { - attr.remove_client_lib(5, string(EventName[PERIODIC_EVENT])); + attr.remove_client_lib(*ite, string(EventName[PERIODIC_EVENT])); } break; @@ -238,10 +242,12 @@ SendEventType EventSupplier::detect_and_push_events(DeviceImpl *device_impl, str { switch (*ite) { + //TODO extract class hierarchy based on version!!! + case 6: case 5: if (archive5_subscription >= EVENT_RESUBSCRIBE_PERIOD) { - attr.remove_client_lib(5, string(EventName[ARCHIVE_EVENT])); + attr.remove_client_lib(*ite, string(EventName[ARCHIVE_EVENT])); } break; @@ -477,6 +483,8 @@ bool EventSupplier::detect_and_push_change_event(DeviceImpl *device_impl, struct switch (*ite) { + //TODO extract class hierarchy based on version + case 6: case 5: { convert_att_event_to_5(attr_value, sent_value, need_free, attr); @@ -857,6 +865,8 @@ bool EventSupplier::detect_and_push_archive_event(DeviceImpl *device_impl, switch (*ite) { + //TODO extract class hierarchy based on version + case 6: case 5: { convert_att_event_to_5(attr_value, sent_value, need_free, attr); @@ -1071,6 +1081,8 @@ bool EventSupplier::detect_and_push_periodic_event(DeviceImpl *device_impl, switch (*ite) { + //TODO extract class hierarchy based on version + case 6: case 5: { convert_att_event_to_5(attr_value, sent_value, need_free, attr); diff --git a/cppapi/server/tango.h b/cppapi/server/tango.h index c22b98ca2..2d59979e4 100644 --- a/cppapi/server/tango.h +++ b/cppapi/server/tango.h @@ -118,6 +118,7 @@ #include #include #include +#include #include #include #include diff --git a/cppapi/server/tango_const.h.in b/cppapi/server/tango_const.h.in index 7322aea9f..721dba015 100644 --- a/cppapi/server/tango_const.h.in +++ b/cppapi/server/tango_const.h.in @@ -44,7 +44,7 @@ namespace Tango #define TANGO_VERSION_MINOR @MINOR_VERSION@ #define TANGO_VERSION_PATCH @PATCH_VERSION@ -#define TANGO_BASE_CLASS Tango::Device_5Impl +#define TANGO_BASE_CLASS Tango::Device_6Impl #define TBS(s) #s #define XTBS(s) TBS(s) @@ -54,7 +54,7 @@ const char * const TgLibMajorVers = XTBS(TANGO_VERSION_MAJOR); const int TgLibVersNb = TANGO_VERSION_MAJOR*10000 + TANGO_VERSION_MINOR*100 + TANGO_VERSION_PATCH; -const int DevVersion = 5; // IDL version number +const int DevVersion = 6; // IDL version number const int DefaultMaxSeq = 20; const int DefaultBlackBoxDepth = 50; const int DefaultPollRingDepth = 10; diff --git a/cppapi/server/zmqeventsupplier.cpp b/cppapi/server/zmqeventsupplier.cpp index 7da7507bc..3d586b935 100644 --- a/cppapi/server/zmqeventsupplier.cpp +++ b/cppapi/server/zmqeventsupplier.cpp @@ -1190,7 +1190,7 @@ void ZmqEventSupplier::push_event(DeviceImpl *device_impl,string event_type, *(ev_value.attr_val_4) >>= data_call_cdr; mess_ptr = data_call_cdr.bufPtr(); - mess_ptr = (char *)mess_ptr + (sizeof(CORBA::Long) << 1); + mess_ptr = (char *) mess_ptr + (sizeof(DevLong) << 1); int nb_data; int data_discr = ((int *)mess_ptr)[0]; @@ -1733,9 +1733,11 @@ void ZmqEventSupplier::push_event_loop(DeviceImpl *device_impl,EventType event_t { switch (*ite) { + //TODO extract class hierarchy based on version + case 6: case 5: { - convert_att_event_to_5(attr_value,sent_value,need_free,att); + convert_att_event_to_5(attr_value, sent_value, need_free, att); } break; From f08d2e70908b3f8bffa3958fc3e9586bcf3e9bff Mon Sep 17 00:00:00 2001 From: ingvord Date: Thu, 23 Aug 2018 18:54:22 +0300 Subject: [PATCH 05/18] fix compilation [1h] --- cppapi/client/devapi_base.cpp | 11 ++---- cppapi/client/device_command_info.cpp | 2 +- cppapi/server/command.h | 54 +++++++++++++++++++++++---- 3 files changed, 52 insertions(+), 15 deletions(-) diff --git a/cppapi/client/devapi_base.cpp b/cppapi/client/devapi_base.cpp index 06a30d80e..1bc973153 100644 --- a/cppapi/client/devapi_base.cpp +++ b/cppapi/client/devapi_base.cpp @@ -3415,10 +3415,9 @@ DeviceInfo const &DeviceProxy::info() // command implemented for this TANGO device // //----------------------------------------------------------------------------- - +//TODO make cmd const & CommandInfo DeviceProxy::command_query(string cmd) { - CommandInfo command_info; DevCmdInfo_var cmd_info; DevCmdInfo_2_var cmd_info_2; DevCmdInfo_6_var cmd_info_6; @@ -3509,7 +3508,7 @@ CommandInfo DeviceProxy::command_query(string cmd) } } - return (command_info); + assert(false);//should not reach this line } //----------------------------------------------------------------------------- @@ -3568,7 +3567,6 @@ CommandInfoList *DeviceProxy::get_command_config(vector &cmd_names) CommandInfoList *DeviceProxy::command_list_query() { - CommandInfoList *command_info_list = NULL; DevCmdInfoList_var cmd_info_list; DevCmdInfoList_2_var cmd_info_list_2; DevCmdInfoList_6_var cmd_info_list_6; @@ -3587,7 +3585,7 @@ CommandInfoList *DeviceProxy::command_list_query() { case 1: dev = Device::_duplicate(device); - cmd_info_list = dev->command_list_query(); + cmd_info_list = dev->command_list_query(); return newCommandInfoList(cmd_info_list); case 2: @@ -3605,7 +3603,6 @@ CommandInfoList *DeviceProxy::command_list_query() return newCommandInfoList(cmd_info_list_6); } - } ctr = 2; } catch (CORBA::TRANSIENT &trans) @@ -3659,7 +3656,7 @@ CommandInfoList *DeviceProxy::command_list_query() } } - return (command_info_list); + assert(false); } //----------------------------------------------------------------------------- diff --git a/cppapi/client/device_command_info.cpp b/cppapi/client/device_command_info.cpp index 54a3bd6a8..5f06a6593 100644 --- a/cppapi/client/device_command_info.cpp +++ b/cppapi/client/device_command_info.cpp @@ -26,7 +26,7 @@ //=================================================================================================================== #include -#include +#include namespace Tango { diff --git a/cppapi/server/command.h b/cppapi/server/command.h index 3e976aeb7..b09d9794b 100644 --- a/cppapi/server/command.h +++ b/cppapi/server/command.h @@ -385,6 +385,39 @@ class Command //@} +//TODO unit tests +/** + * Set in_enum_labels from vector ref + */ + void set_in_enum_labels(vector &v) + { + this->get_ext()->in_enum_labels = v; + } + +/** + * Set in_enum_labels from vector rvalue + */ + void set_in_enum_labels(vector &&v) + { + this->get_ext()->in_enum_labels = move(v); + } + + /** + * Set in_enum_labels from vector ref + */ + void set_out_enum_labels(vector &v) + { + this->get_ext()->out_enum_labels = v; + } + +/** + * Set in_enum_labels from vector rvalue + */ + void set_out_enum_labels(vector &&v) + { + this->get_ext()->out_enum_labels = move(v); + } + /**@name Extract methods. * All these methods extract data from the CORBA Any object received as * command input data @@ -1228,17 +1261,20 @@ class Command class CommandExt { public: - CommandExt() {} + CommandExt() + : + in_enum_labels(), + out_enum_labels() + {} + + vector in_enum_labels; + vector out_enum_labels; }; void alloc_any(CORBA::Any *&); void throw_bad_type(const char *); -#ifdef HAS_UNIQUE_PTR - unique_ptr ext; // Class extension -#else - CommandExt *ext; -#endif + shared_ptr ext; //Class extension // // Ported from the extension class @@ -1246,7 +1282,11 @@ class Command Tango::DispLevel cmd_disp_level; // Display level long poll_period; // Polling period - +public: + shared_ptr get_ext() + { + return ext; + } }; //============================================================================= From 40cc9d517aa94fd55ab6f686e5954548ca8aa892 Mon Sep 17 00:00:00 2001 From: ingvord Date: Wed, 29 Aug 2018 15:16:24 +0200 Subject: [PATCH 06/18] fix test [10min] --- cppapi/client/devapi_base.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cppapi/client/devapi_base.cpp b/cppapi/client/devapi_base.cpp index 1bc973153..c3d61fe6e 100644 --- a/cppapi/client/devapi_base.cpp +++ b/cppapi/client/devapi_base.cpp @@ -5710,7 +5710,7 @@ vector *DeviceProxy::read_attributes(vector &attr_strin ApiUtil *au = ApiUtil::instance(); ci.cpp_clnt(au->get_client_pid()); - if (version == 5) + if (version >= 5) { Device_5_var dev = Device_5::_duplicate(device_5); attr_value_list_5 = dev->read_attributes_5(attr_list, local_source, ci); From b9245a7fc39efcd3bf6ee05e407b5a6216015198 Mon Sep 17 00:00:00 2001 From: ingvord Date: Wed, 29 Aug 2018 16:22:02 +0200 Subject: [PATCH 07/18] fix test [10min] --- cppapi/client/devapi_base.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cppapi/client/devapi_base.cpp b/cppapi/client/devapi_base.cpp index c3d61fe6e..721dca7cd 100644 --- a/cppapi/client/devapi_base.cpp +++ b/cppapi/client/devapi_base.cpp @@ -4873,7 +4873,7 @@ void DeviceProxy::set_attribute_config(AttributeInfoListEx &dev_attr_list) ApiUtil *au = ApiUtil::instance(); ci.cpp_clnt(au->get_client_pid()); - if (version == 5) + if (version >= 5) { Device_5_var dev = Device_5::_duplicate(device_5); dev->set_attribute_config_5(attr_config_list_5, ci); From 7ef3ce12f372ba0efd78aecde53e5abfa0ae436c Mon Sep 17 00:00:00 2001 From: ingvord Date: Wed, 29 Aug 2018 17:06:50 +0200 Subject: [PATCH 08/18] fix test [0,25h] --- cppapi/server/zmqeventsupplier.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cppapi/server/zmqeventsupplier.cpp b/cppapi/server/zmqeventsupplier.cpp index 3d586b935..519338863 100644 --- a/cppapi/server/zmqeventsupplier.cpp +++ b/cppapi/server/zmqeventsupplier.cpp @@ -1723,7 +1723,7 @@ void ZmqEventSupplier::push_event_loop(DeviceImpl *device_impl,EventType event_t struct SuppliedEventData sent_value; ::memset(&sent_value,0,sizeof(sent_value)); - if (*ite == 5) + if (*ite >= 5) { ev_name = EVENT_COMPAT_IDL5 + ev_name; name_changed = true; From d205d80ea9c48159ff4c7532518ec4c65017a6cb Mon Sep 17 00:00:00 2001 From: ingvord Date: Fri, 31 Aug 2018 13:01:04 +0200 Subject: [PATCH 09/18] fix test [1h] --- cpp_test_suite/new_tests/cxx_misc_devproxy.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cpp_test_suite/new_tests/cxx_misc_devproxy.cpp b/cpp_test_suite/new_tests/cxx_misc_devproxy.cpp index d4e38f217..fa156ce84 100644 --- a/cpp_test_suite/new_tests/cxx_misc_devproxy.cpp +++ b/cpp_test_suite/new_tests/cxx_misc_devproxy.cpp @@ -271,7 +271,7 @@ class MiscDevProxyTestSuite: public CxxTest::TestSuite TS_ASSERT_THROWS_NOTHING(cmd_name_list = device->get_command_list()); cout << "cmd_name_list size = " << cmd_name_list->size() << endl; - TS_ASSERT_EQUALS(118, cmd_name_list->size()); + TS_ASSERT_EQUALS(119, cmd_name_list->size()); // TS_ASSERT_EQUALS ("FileDb" , (*cmd_list)[0].cmd_name); // TS_ASSERT_EQUALS ("Status", (*cmd_list)[87].cmd_name); From 14af12d55f98ae4ae78bcda2ec4446633f6d09b4 Mon Sep 17 00:00:00 2001 From: ingvord Date: Fri, 31 Aug 2018 15:27:35 +0200 Subject: [PATCH 10/18] fix test --- cpp_test_suite/cxxtest/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cpp_test_suite/cxxtest/CMakeLists.txt b/cpp_test_suite/cxxtest/CMakeLists.txt index 6f9347b06..f04971515 100644 --- a/cpp_test_suite/cxxtest/CMakeLists.txt +++ b/cpp_test_suite/cxxtest/CMakeLists.txt @@ -54,7 +54,7 @@ add_test("CXX::runner" runner --fulldsname=${SERV_NAME}/${INST_NAME} --serverhost=${HOST_NAME} --clienthost=${HOST_NAME} - --serverversion=5 + --serverversion=6 --docurl=http://www.tango-controls.org --devtype=TestDevice --dbserver=sys/database/2 From 6236615d3260921f73417e2f8324d3c0177a5c05 Mon Sep 17 00:00:00 2001 From: ingvord Date: Fri, 31 Aug 2018 15:58:40 +0200 Subject: [PATCH 11/18] fix test --- cppapi/server/device.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cppapi/server/device.cpp b/cppapi/server/device.cpp index 27fa3262c..0bd719d82 100644 --- a/cppapi/server/device.cpp +++ b/cppapi/server/device.cpp @@ -123,7 +123,7 @@ DeviceImpl::DeviceImpl(DeviceClass *cl_ptr, string &d_name) min_poll_period(0), run_att_conf_loop(true), force_alarm_state(false), with_fwd_att(false), event_intr_change_subscription(0), intr_change_ev(false), devintr_thread(Tango_nullptr) { - desc = "A Tango device"; + desc = "A TANGO device"; device_state = Tango::UNKNOWN; device_status = StatusNotSet; From a9b8285851ea7ac2f32e123b4e31bedfc2a4de16 Mon Sep 17 00:00:00 2001 From: ingvord Date: Fri, 31 Aug 2018 19:25:08 +0300 Subject: [PATCH 12/18] fix test [5min] --- cpp_test_suite/new_tests/cxx_misc_devproxy.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cpp_test_suite/new_tests/cxx_misc_devproxy.cpp b/cpp_test_suite/new_tests/cxx_misc_devproxy.cpp index d4e38f217..b8cb6e17e 100644 --- a/cpp_test_suite/new_tests/cxx_misc_devproxy.cpp +++ b/cpp_test_suite/new_tests/cxx_misc_devproxy.cpp @@ -285,7 +285,7 @@ class MiscDevProxyTestSuite: public CxxTest::TestSuite TS_ASSERT_THROWS_NOTHING(att_list = device->get_attribute_list()); cout << "att_list size = " << att_list->size() << endl; - TS_ASSERT_EQUALS(103, att_list->size()); + TS_ASSERT_EQUALS(102, att_list->size()); // assert ( (*att_list)[0] == "Short_attr"); // assert ( (*att_list)[1] == "Long_attr"); // assert ( (*att_list)[21] == "String_attr_w"); From 09809d35bd38daf70fd0cef72440826756e23978 Mon Sep 17 00:00:00 2001 From: Ingvord Date: Fri, 31 Aug 2018 19:36:25 +0300 Subject: [PATCH 13/18] fix test [5min] --- cpp_test_suite/new_tests/cxx_misc_devproxy.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cpp_test_suite/new_tests/cxx_misc_devproxy.cpp b/cpp_test_suite/new_tests/cxx_misc_devproxy.cpp index fa156ce84..f310cea42 100644 --- a/cpp_test_suite/new_tests/cxx_misc_devproxy.cpp +++ b/cpp_test_suite/new_tests/cxx_misc_devproxy.cpp @@ -285,7 +285,7 @@ class MiscDevProxyTestSuite: public CxxTest::TestSuite TS_ASSERT_THROWS_NOTHING(att_list = device->get_attribute_list()); cout << "att_list size = " << att_list->size() << endl; - TS_ASSERT_EQUALS(103, att_list->size()); + TS_ASSERT_EQUALS(102, att_list->size()); // assert ( (*att_list)[0] == "Short_attr"); // assert ( (*att_list)[1] == "Long_attr"); // assert ( (*att_list)[21] == "String_attr_w"); From b63d543cb0228d4645201fb48e3f69598f04edab Mon Sep 17 00:00:00 2001 From: ingvord Date: Fri, 31 Aug 2018 21:05:52 +0300 Subject: [PATCH 14/18] fix build --- cpp_test_suite/cxxtest/CMakeLists.txt | 5 ----- 1 file changed, 5 deletions(-) diff --git a/cpp_test_suite/cxxtest/CMakeLists.txt b/cpp_test_suite/cxxtest/CMakeLists.txt index 6de9b1ec7..cb035c3c8 100644 --- a/cpp_test_suite/cxxtest/CMakeLists.txt +++ b/cpp_test_suite/cxxtest/CMakeLists.txt @@ -7,11 +7,6 @@ macro(CXX_GENERATE_TEST name) ../../new_tests/${name}.cpp WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/bin) -add_executable(runner $ ${CMAKE_CURRENT_SOURCE_DIR}/runner.cpp) -target_include_directories(runner PUBLIC include) -target_link_libraries(runner PUBLIC tango ${CMAKE_DL_LIBS}) -target_compile_definitions(runner PUBLIC "-DVALGRIND -D_PTHREADS -D_REENTRANT") - add_executable(${name} $ ${name}.cpp) target_include_directories(${name} PRIVATE include ${CMAKE_CURRENT_BINARY_DIR}/include) target_link_libraries(${name} PRIVATE tango ${CMAKE_THREAD_LIBS_INIT}) From 904a60f39ed4917961ecba14917177e1dd949ae4 Mon Sep 17 00:00:00 2001 From: ingvord Date: Fri, 31 Aug 2018 21:22:46 +0300 Subject: [PATCH 15/18] fix test, again... --- cpp_test_suite/cxxtest/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cpp_test_suite/cxxtest/CMakeLists.txt b/cpp_test_suite/cxxtest/CMakeLists.txt index cb035c3c8..2040c3f9f 100644 --- a/cpp_test_suite/cxxtest/CMakeLists.txt +++ b/cpp_test_suite/cxxtest/CMakeLists.txt @@ -22,7 +22,7 @@ macro(CXX_GENERATE_TEST name) --fulldsname=${SERV_NAME}/${INST_NAME} --serverhost=${HOST_NAME} --clienthost=${HOST_NAME} - --serverversion=5 + --serverversion=6 --docurl=http://www.tango-controls.org --devtype=TestDevice --dbserver=sys/database/2 From 12f0210a35435f70b04e66efdd85332c5247a478 Mon Sep 17 00:00:00 2001 From: Ingvord Date: Fri, 31 Aug 2018 22:07:01 +0300 Subject: [PATCH 16/18] fix test --- cpp_test_suite/new_tests/cxx_misc_devproxy.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cpp_test_suite/new_tests/cxx_misc_devproxy.cpp b/cpp_test_suite/new_tests/cxx_misc_devproxy.cpp index f310cea42..fa156ce84 100644 --- a/cpp_test_suite/new_tests/cxx_misc_devproxy.cpp +++ b/cpp_test_suite/new_tests/cxx_misc_devproxy.cpp @@ -285,7 +285,7 @@ class MiscDevProxyTestSuite: public CxxTest::TestSuite TS_ASSERT_THROWS_NOTHING(att_list = device->get_attribute_list()); cout << "att_list size = " << att_list->size() << endl; - TS_ASSERT_EQUALS(102, att_list->size()); + TS_ASSERT_EQUALS(103, att_list->size()); // assert ( (*att_list)[0] == "Short_attr"); // assert ( (*att_list)[1] == "Long_attr"); // assert ( (*att_list)[21] == "String_attr_w"); From 9c12e29e3f90c49edb0bb0fd7151b76e08442eb0 Mon Sep 17 00:00:00 2001 From: ingvord Date: Wed, 5 Sep 2018 11:31:06 +0200 Subject: [PATCH 17/18] try to fix some windows compilation errors [0,25h] --- cppapi/server/command.h | 19 ++++++++++++------- cppapi/server/device_6.h | 5 +++++ 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/cppapi/server/command.h b/cppapi/server/command.h index b09d9794b..f77710ab3 100644 --- a/cppapi/server/command.h +++ b/cppapi/server/command.h @@ -394,13 +394,16 @@ class Command this->get_ext()->in_enum_labels = v; } -/** - * Set in_enum_labels from vector rvalue - */ - void set_in_enum_labels(vector &&v) - { - this->get_ext()->in_enum_labels = move(v); - } + +#ifndef _TG_WINDOWS_ + /** + * Set in_enum_labels from vector rvalue + */ + void set_in_enum_labels(vector &&v) + { + this->get_ext()->in_enum_labels = move(v); + } +#endif /** * Set in_enum_labels from vector ref @@ -410,6 +413,7 @@ class Command this->get_ext()->out_enum_labels = v; } +#ifndef _TG_WINDOWS_ /** * Set in_enum_labels from vector rvalue */ @@ -417,6 +421,7 @@ class Command { this->get_ext()->out_enum_labels = move(v); } +#endif /**@name Extract methods. * All these methods extract data from the CORBA Any object received as diff --git a/cppapi/server/device_6.h b/cppapi/server/device_6.h index c33404484..3e61c74bc 100644 --- a/cppapi/server/device_6.h +++ b/cppapi/server/device_6.h @@ -64,7 +64,12 @@ class Device_6Impl: public virtual POA_Tango::Device_6, idl_version = 6; } +#ifndef _TG_WINDOWS_ virtual ~Device_6Impl() = default; +#else + virtual ~Device_6Impl(){}; +#endif + /** * From 540dc891695fb6876c53872d32a3dba87d6e61cd Mon Sep 17 00:00:00 2001 From: ingvord Date: Wed, 5 Sep 2018 12:35:43 +0200 Subject: [PATCH 18/18] follow @t-b advice [5min] --- cppapi/server/command.h | 33 ++++++--------------------------- 1 file changed, 6 insertions(+), 27 deletions(-) diff --git a/cppapi/server/command.h b/cppapi/server/command.h index f77710ab3..1966d1292 100644 --- a/cppapi/server/command.h +++ b/cppapi/server/command.h @@ -389,39 +389,18 @@ class Command /** * Set in_enum_labels from vector ref */ - void set_in_enum_labels(vector &v) - { - this->get_ext()->in_enum_labels = v; - } - - -#ifndef _TG_WINDOWS_ - /** - * Set in_enum_labels from vector rvalue - */ - void set_in_enum_labels(vector &&v) + void set_in_enum_labels(std::vector v) { - this->get_ext()->in_enum_labels = move(v); + this->get_ext()->in_enum_labels = std::move(v); } -#endif - - /** - * Set in_enum_labels from vector ref - */ - void set_out_enum_labels(vector &v) - { - this->get_ext()->out_enum_labels = v; - } -#ifndef _TG_WINDOWS_ /** - * Set in_enum_labels from vector rvalue - */ - void set_out_enum_labels(vector &&v) +* Set in_enum_labels from vector ref +*/ + void set_out_enum_labels(vector v) { - this->get_ext()->out_enum_labels = move(v); + this->get_ext()->out_enum_labels = std::move(v); } -#endif /**@name Extract methods. * All these methods extract data from the CORBA Any object received as