From f8bd8dc821a24b5024d036b109482d806dddc6b9 Mon Sep 17 00:00:00 2001 From: Thomas Juerges <203795-tjuerges@users.noreply.gitlab.com> Date: Wed, 24 Jan 2024 09:50:10 +0000 Subject: [PATCH] cppTango 9.5.0 compatibility - Change cout, cout2, cout3 to the new TANGO_LOG macros - Add using std::endl and using std::bad_alloc to main.cpp - Correct tango.h inclusion path - Correct eventconsumer.h inclusion path - Change C++ standard to C++17 (this adds compatibility for upcoming cppTango 10.0.0) --- CMakeLists.txt | 2 +- src/AlarmHandler.cpp | 12 ++++---- src/AlarmHandler.h | 2 +- src/AlarmHandlerClass.cpp | 38 ++++++++++++------------- src/AlarmHandlerClass.h | 2 +- src/ClassFactory.cpp | 2 +- src/SubscribeThread.h | 4 +-- src/alarm-thread.cpp | 4 +-- src/alarm-thread.h | 2 +- src/alarm_table.cpp | 12 ++++---- src/alarm_table.h | 12 ++++---- src/cmd_thread.cpp | 36 +++++++++++------------ src/cmd_thread.h | 2 +- src/event_table.cpp | 8 +++--- src/event_table.h | 2 +- src/main.cpp | 14 +++++---- src/update-thread.cpp | 2 +- src/update-thread.h | 2 +- test/testdevice/CMakeLists.txt | 2 +- test/testdevice/src/ClassFactory.cpp | 2 +- test/testdevice/src/TestDevice.cpp | 2 +- test/testdevice/src/TestDevice.h | 2 +- test/testdevice/src/TestDeviceClass.cpp | 28 +++++++++--------- test/testdevice/src/TestDeviceClass.h | 2 +- test/testdevice/src/main.cpp | 12 ++++---- 25 files changed, 105 insertions(+), 103 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f106d8e..3b1253b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -107,7 +107,7 @@ set_target_properties(alarm_handler PROPERTIES OUTPUT_NAME ${AH_NAME} LINK_FLAGS "-Wl,--no-undefined" - CXX_STANDARD 11) + CXX_STANDARD 17) if(DO_CLANG_TIDY) set_target_properties(alarm_handler diff --git a/src/AlarmHandler.cpp b/src/AlarmHandler.cpp index 1add621..36a0fad 100644 --- a/src/AlarmHandler.cpp +++ b/src/AlarmHandler.cpp @@ -372,7 +372,7 @@ void AlarmHandler::init_device() if(instanceCounter > 1) { ERROR_STREAM << "More than one instance in the same executable of Alarm Server is not allowed!!" << endl; - cout << "ERROR: second instance of Alarm Server, exiting..." << endl; + TANGO_LOG << "ERROR: second instance of Alarm Server, exiting..." << endl; exit(-1); } //------------------------------------------- alarmedlock = new(ReadersWritersLock); @@ -524,7 +524,7 @@ void AlarmHandler::init_device() } catch(string & e) { ERROR_STREAM << "AlarmHandler::init_device(): " << e << endl; - cout << "Error: " << e << ". Exiting..." << endl; + TANGO_LOG << "Error: " << e << ". Exiting..." << endl; exit(-4); } @@ -5359,7 +5359,7 @@ void AlarmHandler::eval_node_event(iter_t const& i, vector<string> & ev) std::transform(s.begin(), s.end(), s.begin(), (int(*)(int))tolower); //transform to lowercase ev.push_back(s); } - //cout << endl; + //TANGO_LOG << endl; //iter_t it = i->children.begin(); for(iter_t it = i->children.begin(); it != i->children.end(); it++) eval_node_event(it, ev); @@ -5478,7 +5478,7 @@ void AlarmHandler::prepare_alarm_attr() if(almstate == "OOSRV" || almstate == "SHLVD") { - //cout << __func__ << ": " << ai->first << " silenced="<< ai->second.silenced << endl; + //TANGO_LOG << __func__ << ": " << ai->first << " silenced="<< ai->second.silenced << endl; #if 0 alm_disabled << KEY(ALARM_TIME_KEY) << time_buf << "." << ai->second.ts.tv_usec << SEP; alm_disabled << KEY(NAME_KEY) << ai->first << SEP; @@ -5614,7 +5614,7 @@ void AlarmHandler::prepare_alarm_attr() * found, change stat only if switching from * S_NORMAL or S_ALARM status to S_ERROR */ - //cout << "read_attr(): S_ERROR: found: " << aid->name << endl; + //TANGO_LOG << "read_attr(): S_ERROR: found: " << aid->name << endl; if (aid->stat != S_ERROR) { aid->stat = S_ERROR; aid->ack = NOT_ACK; @@ -5665,7 +5665,7 @@ void AlarmHandler::prepare_alarm_attr() * found, change stat only if switching from * S_NORMAL to S_ALARM status */ - //cout << "read_attr(): S_ALARM: found: " << aid->name << endl; + //TANGO_LOG << "read_attr(): S_ALARM: found: " << aid->name << endl; if (aid->stat == S_NORMAL || aid->stat == S_ERROR) { aid->stat = S_ALARM; aid->ack = NOT_ACK; diff --git a/src/AlarmHandler.h b/src/AlarmHandler.h index f9827b4..5a3eb35 100644 --- a/src/AlarmHandler.h +++ b/src/AlarmHandler.h @@ -33,7 +33,7 @@ #ifndef AlarmHandler_H #define AlarmHandler_H -#include <tango.h> +#include <tango/tango.h> #include <boost/version.hpp> #if BOOST_VERSION >= 103600 diff --git a/src/AlarmHandlerClass.cpp b/src/AlarmHandlerClass.cpp index 12694d4..945b330 100644 --- a/src/AlarmHandlerClass.cpp +++ b/src/AlarmHandlerClass.cpp @@ -73,7 +73,7 @@ AlarmHandlerClass *AlarmHandlerClass::_instance = NULL; //-------------------------------------------------------- AlarmHandlerClass::AlarmHandlerClass(string &s):Tango::DeviceClass(s) { - cout2 << "Entering AlarmHandlerClass constructor" << endl; + TANGO_LOG_INFO << "Entering AlarmHandlerClass constructor" << endl; set_default_property(); get_class_property(); write_class_property(); @@ -82,7 +82,7 @@ AlarmHandlerClass::AlarmHandlerClass(string &s):Tango::DeviceClass(s) /*----- PROTECTED REGION END -----*/ // AlarmHandlerClass::constructor - cout2 << "Leaving AlarmHandlerClass constructor" << endl; + TANGO_LOG_INFO << "Leaving AlarmHandlerClass constructor" << endl; } //-------------------------------------------------------- @@ -162,7 +162,7 @@ AlarmHandlerClass *AlarmHandlerClass::instance() //-------------------------------------------------------- CORBA::Any *AckClass::execute(Tango::DeviceImpl *device, const CORBA::Any &in_any) { - cout2 << "AckClass::execute(): arrived" << endl; + TANGO_LOG_INFO << "AckClass::execute(): arrived" << endl; const Tango::DevVarStringArray *argin; extract(in_any, argin); ((static_cast<AlarmHandler *>(device))->ack(argin)); @@ -182,7 +182,7 @@ CORBA::Any *AckClass::execute(Tango::DeviceImpl *device, const CORBA::Any &in_an //-------------------------------------------------------- CORBA::Any *LoadClass::execute(Tango::DeviceImpl *device, const CORBA::Any &in_any) { - cout2 << "LoadClass::execute(): arrived" << endl; + TANGO_LOG_INFO << "LoadClass::execute(): arrived" << endl; Tango::DevString argin; extract(in_any, argin); ((static_cast<AlarmHandler *>(device))->load(argin)); @@ -202,7 +202,7 @@ CORBA::Any *LoadClass::execute(Tango::DeviceImpl *device, const CORBA::Any &in_a //-------------------------------------------------------- CORBA::Any *RemoveClass::execute(Tango::DeviceImpl *device, const CORBA::Any &in_any) { - cout2 << "RemoveClass::execute(): arrived" << endl; + TANGO_LOG_INFO << "RemoveClass::execute(): arrived" << endl; Tango::DevString argin; extract(in_any, argin); ((static_cast<AlarmHandler *>(device))->remove(argin)); @@ -222,7 +222,7 @@ CORBA::Any *RemoveClass::execute(Tango::DeviceImpl *device, const CORBA::Any &in //-------------------------------------------------------- CORBA::Any *SearchAlarmClass::execute(Tango::DeviceImpl *device, const CORBA::Any &in_any) { - cout2 << "SearchAlarmClass::execute(): arrived" << endl; + TANGO_LOG_INFO << "SearchAlarmClass::execute(): arrived" << endl; Tango::DevString argin; extract(in_any, argin); return insert((static_cast<AlarmHandler *>(device))->search_alarm(argin)); @@ -241,7 +241,7 @@ CORBA::Any *SearchAlarmClass::execute(Tango::DeviceImpl *device, const CORBA::An //-------------------------------------------------------- CORBA::Any *StopAudibleClass::execute(Tango::DeviceImpl *device, TANGO_UNUSED(const CORBA::Any &in_any)) { - cout2 << "StopAudibleClass::execute(): arrived" << endl; + TANGO_LOG_INFO << "StopAudibleClass::execute(): arrived" << endl; ((static_cast<AlarmHandler *>(device))->stop_audible()); return new CORBA::Any(); } @@ -259,7 +259,7 @@ CORBA::Any *StopAudibleClass::execute(Tango::DeviceImpl *device, TANGO_UNUSED(co //-------------------------------------------------------- CORBA::Any *SilenceClass::execute(Tango::DeviceImpl *device, const CORBA::Any &in_any) { - cout2 << "SilenceClass::execute(): arrived" << endl; + TANGO_LOG_INFO << "SilenceClass::execute(): arrived" << endl; const Tango::DevVarStringArray *argin; extract(in_any, argin); ((static_cast<AlarmHandler *>(device))->silence(argin)); @@ -279,7 +279,7 @@ CORBA::Any *SilenceClass::execute(Tango::DeviceImpl *device, const CORBA::Any &i //-------------------------------------------------------- CORBA::Any *ModifyClass::execute(Tango::DeviceImpl *device, const CORBA::Any &in_any) { - cout2 << "ModifyClass::execute(): arrived" << endl; + TANGO_LOG_INFO << "ModifyClass::execute(): arrived" << endl; Tango::DevString argin; extract(in_any, argin); ((static_cast<AlarmHandler *>(device))->modify(argin)); @@ -299,7 +299,7 @@ CORBA::Any *ModifyClass::execute(Tango::DeviceImpl *device, const CORBA::Any &in //-------------------------------------------------------- CORBA::Any *ShelveClass::execute(Tango::DeviceImpl *device, const CORBA::Any &in_any) { - cout2 << "ShelveClass::execute(): arrived" << endl; + TANGO_LOG_INFO << "ShelveClass::execute(): arrived" << endl; const Tango::DevVarStringArray *argin; extract(in_any, argin); ((static_cast<AlarmHandler *>(device))->shelve(argin)); @@ -319,7 +319,7 @@ CORBA::Any *ShelveClass::execute(Tango::DeviceImpl *device, const CORBA::Any &in //-------------------------------------------------------- CORBA::Any *EnableClass::execute(Tango::DeviceImpl *device, const CORBA::Any &in_any) { - cout2 << "EnableClass::execute(): arrived" << endl; + TANGO_LOG_INFO << "EnableClass::execute(): arrived" << endl; Tango::DevString argin; extract(in_any, argin); ((static_cast<AlarmHandler *>(device))->enable(argin)); @@ -339,7 +339,7 @@ CORBA::Any *EnableClass::execute(Tango::DeviceImpl *device, const CORBA::Any &in //-------------------------------------------------------- CORBA::Any *DisableClass::execute(Tango::DeviceImpl *device, const CORBA::Any &in_any) { - cout2 << "DisableClass::execute(): arrived" << endl; + TANGO_LOG_INFO << "DisableClass::execute(): arrived" << endl; Tango::DevString argin; extract(in_any, argin); ((static_cast<AlarmHandler *>(device))->disable(argin)); @@ -359,7 +359,7 @@ CORBA::Any *DisableClass::execute(Tango::DeviceImpl *device, const CORBA::Any &i //-------------------------------------------------------- CORBA::Any *ResetStatisticsClass::execute(Tango::DeviceImpl *device, TANGO_UNUSED(const CORBA::Any &in_any)) { - cout2 << "ResetStatisticsClass::execute(): arrived" << endl; + TANGO_LOG_INFO << "ResetStatisticsClass::execute(): arrived" << endl; ((static_cast<AlarmHandler *>(device))->reset_statistics()); return new CORBA::Any(); } @@ -377,7 +377,7 @@ CORBA::Any *ResetStatisticsClass::execute(Tango::DeviceImpl *device, TANGO_UNUSE //-------------------------------------------------------- CORBA::Any *StopNewClass::execute(Tango::DeviceImpl *device, TANGO_UNUSED(const CORBA::Any &in_any)) { - cout2 << "StopNewClass::execute(): arrived" << endl; + TANGO_LOG_INFO << "StopNewClass::execute(): arrived" << endl; ((static_cast<AlarmHandler *>(device))->stop_new()); return new CORBA::Any(); } @@ -395,7 +395,7 @@ CORBA::Any *StopNewClass::execute(Tango::DeviceImpl *device, TANGO_UNUSED(const //-------------------------------------------------------- CORBA::Any *GetAlarmInfoClass::execute(Tango::DeviceImpl *device, const CORBA::Any &in_any) { - cout2 << "GetAlarmInfoClass::execute(): arrived" << endl; + TANGO_LOG_INFO << "GetAlarmInfoClass::execute(): arrived" << endl; const Tango::DevVarStringArray *argin; extract(in_any, argin); return insert((static_cast<AlarmHandler *>(device))->get_alarm_info(argin)); @@ -414,7 +414,7 @@ CORBA::Any *GetAlarmInfoClass::execute(Tango::DeviceImpl *device, const CORBA::A //-------------------------------------------------------- CORBA::Any *ReLoadAllClass::execute(Tango::DeviceImpl *device, TANGO_UNUSED(const CORBA::Any &in_any)) { - cout2 << "ReLoadAllClass::execute(): arrived" << endl; + TANGO_LOG_INFO << "ReLoadAllClass::execute(): arrived" << endl; ((static_cast<AlarmHandler *>(device))->re_load_all()); return new CORBA::Any(); } @@ -784,7 +784,7 @@ void AlarmHandlerClass::device_factory(const Tango::DevVarStringArray *devlist_p // Create devices and add it into the device list for (unsigned long i=0 ; i<devlist_ptr->length() ; i++) { - cout4 << "Device name : " << (*devlist_ptr)[i].in() << endl; + TANGO_LOG_DEBUG << "Device name : " << (*devlist_ptr)[i].in() << endl; device_list.push_back(new AlarmHandler(this, (*devlist_ptr)[i])); } @@ -1432,7 +1432,7 @@ void AlarmHandlerClass::create_static_attribute_list(vector<Tango::Attr *> &att_ defaultAttList.push_back(att_name); } - cout2 << defaultAttList.size() << " attributes in default list" << endl; + TANGO_LOG_INFO << defaultAttList.size() << " attributes in default list" << endl; /*----- PROTECTED REGION ID(AlarmHandlerClass::create_static_att_list) ENABLED START -----*/ @@ -1468,7 +1468,7 @@ void AlarmHandlerClass::erase_dynamic_attributes(const Tango::DevVarStringArray vector<string>::iterator ite_str = find(defaultAttList.begin(), defaultAttList.end(), att_name); if (ite_str == defaultAttList.end()) { - cout2 << att_name << " is a UNWANTED dynamic attribute for device " << (*devlist_ptr)[i] << endl; + TANGO_LOG_INFO << att_name << " is a UNWANTED dynamic attribute for device " << (*devlist_ptr)[i] << endl; Tango::Attribute &att = dev->get_device_attr()->get_attr_by_name(att_name.c_str()); dev->remove_attribute(att_list[att.get_attr_idx()], true, false); --ite_att; diff --git a/src/AlarmHandlerClass.h b/src/AlarmHandlerClass.h index 7a0925c..4735716 100644 --- a/src/AlarmHandlerClass.h +++ b/src/AlarmHandlerClass.h @@ -37,7 +37,7 @@ #ifndef AlarmHandlerClass_H #define AlarmHandlerClass_H -#include <tango.h> +#include <tango/tango.h> #include <AlarmHandler.h> diff --git a/src/ClassFactory.cpp b/src/ClassFactory.cpp index a847816..fb181ee 100644 --- a/src/ClassFactory.cpp +++ b/src/ClassFactory.cpp @@ -32,7 +32,7 @@ // (Program Obviously used to Generate tango Object) //============================================================================= -#include <tango.h> +#include <tango/tango.h> #include <AlarmHandlerClass.h> // Add class header files if needed diff --git a/src/SubscribeThread.h b/src/SubscribeThread.h index 191ac98..a6ec960 100644 --- a/src/SubscribeThread.h +++ b/src/SubscribeThread.h @@ -1,8 +1,8 @@ #ifndef _SUBSCRIBE_THREAD_H #define _SUBSCRIBE_THREAD_H -#include <tango.h> -#include <eventconsumer.h> +#include <tango/tango.h> +#include <tango/client/eventconsumer.h> #include <stdint.h> #include "event_table.h" diff --git a/src/alarm-thread.cpp b/src/alarm-thread.cpp index cb5d595..9a98744 100644 --- a/src/alarm-thread.cpp +++ b/src/alarm-thread.cpp @@ -14,7 +14,7 @@ static const char __FILE__rev[] = __FILE__ " $Revision: 1.7 $"; */ alarm_thread::alarm_thread(AlarmHandler_ns::AlarmHandler *p) : p_Alarm(p) { - //cout << __FILE__rev << endl; + //TANGO_LOG << __FILE__rev << endl; } /* @@ -136,5 +136,5 @@ void alarm_thread::run(void *) printf("alarm_thread::run(): catched unknown exception!!"); } } - //cout << "alarm_thread::run(): returning" << endl; + //TANGO_LOG << "alarm_thread::run(): returning" << endl; } /* alarm_thread::run() */ diff --git a/src/alarm-thread.h b/src/alarm-thread.h index 721c4a7..a5b7ccc 100644 --- a/src/alarm-thread.h +++ b/src/alarm-thread.h @@ -10,7 +10,7 @@ #define ALARM_THREAD_H #include <omnithread.h> -#include <tango.h> +#include <tango/tango.h> #include <AlarmHandler.h> #define ALARM_THREAD_EXIT "alarm_thread_exit" diff --git a/src/alarm_table.cpp b/src/alarm_table.cpp index 9ca66f8..1783cda 100644 --- a/src/alarm_table.cpp +++ b/src/alarm_table.cpp @@ -7,7 +7,7 @@ */ #include <sys/time.h> -#include <tango.h> +#include <tango/tango.h> #include "alarm_table.h" #include "alarm_grammar.h" #include "cmd_thread.h" @@ -940,7 +940,7 @@ void alarm_table::save_alarm_conf_db(const string &att_name, const string &name, } catch(Tango::DevFailed &e) { - cout << __func__ << ": Exception saving configuration = " << e.errors[0].desc<<endl; + TANGO_LOG << __func__ << ": Exception saving configuration = " << e.errors[0].desc<<endl; } } @@ -988,7 +988,7 @@ void alarm_table::delete_alarm_conf_db(string att_name) } catch(Tango::DevFailed &e) { - cout << __func__ << ": Exception deleting " << att_name << " = " << e.errors[0].desc<<endl; + TANGO_LOG << __func__ << ": Exception deleting " << att_name << " = " << e.errors[0].desc<<endl; } } @@ -1012,7 +1012,7 @@ void alarm_table::get_alarm_list_db(vector<string> &al_list, map<string, string> } catch(Tango::DevFailed &e) { - cout << __func__ << ": Exception reading configuration = " << e.errors[0].desc<<endl; + TANGO_LOG << __func__ << ": Exception reading configuration = " << e.errors[0].desc<<endl; } savedlock->writerIn(); saved_alarms.clear(); @@ -1067,7 +1067,7 @@ void alarm_table::get_alarm_list_db(vector<string> &al_list, map<string, string> db_data[i] >> alm_receivers; else { - cout << "att_name="<<att_name<<" UNKWNOWN prop_name="<<prop_name<<endl; + TANGO_LOG << "att_name="<<att_name<<" UNKWNOWN prop_name="<<prop_name<<endl; i++; continue; } @@ -1092,7 +1092,7 @@ void alarm_table::get_alarm_list_db(vector<string> &al_list, map<string, string> KEY(ENABLED_KEY)<< alm_enabled; if(alm_name.empty() || alm_formula.empty() || alm_level.empty() || alm_group.empty() || alm_message.empty()) //TODO: decide if all mandatory { - cout << __func__ << ": skipped '" << alm.str() << "'" << endl; + TANGO_LOG << __func__ << ": skipped '" << alm.str() << "'" << endl; continue; } al_list.push_back(alm.str()); diff --git a/src/alarm_table.h b/src/alarm_table.h index 321b8e3..8155101 100644 --- a/src/alarm_table.h +++ b/src/alarm_table.h @@ -15,7 +15,7 @@ #include <string> #include <map> -#include <tango.h> +#include <tango/tango.h> //spirit defines have to be put befor first inclusion of spirit headers #ifndef BOOST_SPIRIT_RULE_SCANNERTYPE_LIMIT @@ -45,7 +45,7 @@ //#include "log_thread.h" -#define LOG_STREAM cout +#define LOG_STREAM TANGO_LOG using namespace std; @@ -102,10 +102,10 @@ struct rwlock_t rwlock_t(string n){name=n;}; rwlock_t(){name=string("RWLOCK");}; boost::shared_mutex mut; - void readerIn(){cout<<name<<": " << __func__<<endl;mut.lock_shared();} - void readerOut(){cout<<name<<": " << __func__<<endl;mut.unlock_shared();} - void writerIn(){cout<<name<<": " << __func__<<endl;mut.lock();} - void writerOut(){cout<<name<<": " << __func__<<endl;mut.unlock();} + void readerIn(){TANGO_LOG<<name<<": " << __func__<<endl;mut.lock_shared();} + void readerOut(){TANGO_LOG<<name<<": " << __func__<<endl;mut.unlock_shared();} + void writerIn(){TANGO_LOG<<name<<": " << __func__<<endl;mut.lock();} + void writerOut(){TANGO_LOG<<name<<": " << __func__<<endl;mut.unlock();} }; #endif diff --git a/src/cmd_thread.cpp b/src/cmd_thread.cpp index 809f233..7426030 100644 --- a/src/cmd_thread.cpp +++ b/src/cmd_thread.cpp @@ -14,8 +14,8 @@ static const char __FILE__rev[] = __FILE__ " $Revision: 1.3 $"; */ cmd_thread::cmd_thread() { - cout << __FILE__rev << endl; - cout << gettime().tv_sec << " cmd_thread::cmd_thread(): constructor... !" << endl; + TANGO_LOG << __FILE__rev << endl; + TANGO_LOG << gettime().tv_sec << " cmd_thread::cmd_thread(): constructor... !" << endl; //mutex_dp = new omni_mutex::omni_mutex(); } @@ -24,7 +24,7 @@ cmd_thread::cmd_thread() */ cmd_thread::~cmd_thread() { - cout << gettime().tv_sec << " cmd_thread::~cmd_thread(): delete device entering..." << endl; + TANGO_LOG << gettime().tv_sec << " cmd_thread::~cmd_thread(): delete device entering..." << endl; //delete mutex_dp; } @@ -44,13 +44,13 @@ void cmd_thread::run(void *) switch(cmd.cmd_id) { case CMD_THREAD_EXIT: - cout << gettime().tv_sec << " cmd_thread::run(): received command THREAD_EXIT -> exiting..." << endl; + TANGO_LOG << gettime().tv_sec << " cmd_thread::run(): received command THREAD_EXIT -> exiting..." << endl; return; case CMD_COMMAND: { try { - cout << gettime().tv_sec << " cmd_thread::run(): COMMAND ... action=" << cmd.arg_s3 << endl; + TANGO_LOG << gettime().tv_sec << " cmd_thread::run(): COMMAND ... action=" << cmd.arg_s3 << endl; dp = (Tango::DeviceProxy *)cmd.dp_add; if(cmd.arg_b) { @@ -64,7 +64,7 @@ void cmd_thread::run(void *) } else call_id = dp->command_inout_asynch(cmd.arg_s2); - cout << gettime().tv_sec << " cmd_thread::run() executed action: " << cmd.arg_s3 << " !!! call_id=" << call_id << endl; + TANGO_LOG << gettime().tv_sec << " cmd_thread::run() executed action: " << cmd.arg_s3 << " !!! call_id=" << call_id << endl; /*cmd_t arg; arg.cmd_id = CMD_RESPONSE; arg.call_id = call_id; @@ -83,11 +83,11 @@ void cmd_thread::run(void *) if(err.find("is not yet arrived") == string::npos) //TODO: change this!! { out_stream << "Failed to execute action " << cmd.arg_s3 << ", err=" << e.errors[0].desc << ends; - cout << gettime().tv_sec << " cmd_thread::run() ERROR: " << out_stream.str() << endl; + TANGO_LOG << gettime().tv_sec << " cmd_thread::run() ERROR: " << out_stream.str() << endl; } else { - cout << gettime().tv_sec << " cmd_thread::run() exception 'is not yet arrived': pushing request of response, call_id=" << call_id << endl; + TANGO_LOG << gettime().tv_sec << " cmd_thread::run() exception 'is not yet arrived': pushing request of response, call_id=" << call_id << endl; cmd.cmd_id = CMD_RESPONSE; //if no exception till now push in list request of response cmd.call_id = call_id; //if no exception till now push in list request of response list.push_back(cmd); //if no exception till now push in list request of response @@ -99,12 +99,12 @@ void cmd_thread::run(void *) case CMD_RESPONSE: { - //cout << gettime().tv_sec << " cmd_thread::run(): RESPONSE WAKE UP... action=" << cmd.arg_s3 << " call_id=" << cmd.call_id << endl; + //TANGO_LOG << gettime().tv_sec << " cmd_thread::run(): RESPONSE WAKE UP... action=" << cmd.arg_s3 << " call_id=" << cmd.call_id << endl; Tango::DeviceData resp; dp = (Tango::DeviceProxy *)cmd.dp_add; try { resp = dp->command_inout_reply(cmd.call_id); - cout << gettime().tv_sec << " cmd_thread::run() RECEIVED response to action " << cmd.arg_s3 << endl; + TANGO_LOG << gettime().tv_sec << " cmd_thread::run() RECEIVED response to action " << cmd.arg_s3 << endl; } catch(Tango::DevFailed &e) { TangoSys_MemStream out_stream; @@ -118,7 +118,7 @@ void cmd_thread::run(void *) } else { - cout << gettime().tv_sec << " cmd_thread::run() " << out_stream.str() << endl; + TANGO_LOG << gettime().tv_sec << " cmd_thread::run() " << out_stream.str() << endl; Tango::Except::print_exception(e); } } @@ -127,19 +127,19 @@ void cmd_thread::run(void *) } /* if(cmd.arg_s == CMD_THREAD_EXIT) { - cout << gettime().tv_sec << " cmd_thread::run(): received command THREAD_EXIT -> exiting..." << endl; + TANGO_LOG << gettime().tv_sec << " cmd_thread::run(): received command THREAD_EXIT -> exiting..." << endl; return; } else { - cout << gettime().tv_sec << " cmd_thread::run(): WAKE UP... action=" << cmd.arg_s << endl; + TANGO_LOG << gettime().tv_sec << " cmd_thread::run(): WAKE UP... action=" << cmd.arg_s << endl; Tango::DeviceData resp; dp = (Tango::DeviceProxy *)cmd.dp_add; try { mutex_dp->lock(); resp = dp->command_inout_reply(cmd.cmd_id); mutex_dp->unlock(); - cout << gettime().tv_sec << " cmd_thread::run() received response to action " << cmd.arg_s << endl; + TANGO_LOG << gettime().tv_sec << " cmd_thread::run() received response to action " << cmd.arg_s << endl; } catch(Tango::DevFailed &e) { TangoSys_MemStream out_stream; @@ -152,7 +152,7 @@ void cmd_thread::run(void *) omni_thread::sleep(0,300000000); //0.2 s } else - cout << gettime().tv_sec << " cmd_thread::run() " << out_stream.str() << endl; + TANGO_LOG << gettime().tv_sec << " cmd_thread::run() " << out_stream.str() << endl; } }*/ @@ -178,7 +178,7 @@ void cmd_thread::run(void *) printf("cmd_thread::run(): catched unknown exception!!"); } } - //cout << "alarm_thread::run(): returning" << endl; + //TANGO_LOG << "alarm_thread::run(): returning" << endl; } /* cmd_thread::run() */ /* @@ -188,7 +188,7 @@ void cmd_list::push_back(cmd_t& cmd) { this->lock(); - //cout << "cmd_list::push_back: cmd_id=" << cmd.cmd_id << " call_id=" << cmd.call_id << endl; + //TANGO_LOG << "cmd_list::push_back: cmd_id=" << cmd.cmd_id << " call_id=" << cmd.call_id << endl; try{ l_cmd.push_back(cmd); empty.signal(); @@ -255,7 +255,7 @@ const cmd_t cmd_list::pop_front(void) /*const*/ cmd_t cmd; cmd = *(l_cmd.begin()); - //cout << "cmd_list::pop_front: " << e.name << " value=" << e.value[0] << endl; + //TANGO_LOG << "cmd_list::pop_front: " << e.name << " value=" << e.value[0] << endl; l_cmd.pop_front(); this->unlock(); diff --git a/src/cmd_thread.h b/src/cmd_thread.h index b9b32ca..4fbbf49 100644 --- a/src/cmd_thread.h +++ b/src/cmd_thread.h @@ -19,7 +19,7 @@ #define CMD_THREAD_EXIT 3 #include <omnithread.h> -#include <tango.h> +#include <tango/tango.h> #include "AlarmHandler.h" struct cmd_t diff --git a/src/event_table.cpp b/src/event_table.cpp index 315b627..1b8f46d 100644 --- a/src/event_table.cpp +++ b/src/event_table.cpp @@ -7,13 +7,13 @@ */ #include <sys/time.h> -#include <tango.h> +#include <tango/tango.h> #include "event_table.h" #include "AlarmHandler.h" #include "alarm_grammar.h" //for get_event_system_for_event_id, to know if ZMQ -#include <eventconsumer.h> +#include <tango/client/eventconsumer.h> #include <regex> static const char __FILE__rev[] = __FILE__ " $Revision: 1.5 $"; @@ -147,7 +147,7 @@ void alarm_list::pop(const string& a) if(it != l_alarm.end()) l_alarm.erase(it); else - cout << "alarm_list::"<<__func__<< ": ALARM '"<< a << "' NOT FOUND!"<< endl; + TANGO_LOG << "alarm_list::"<<__func__<< ": ALARM '"<< a << "' NOT FOUND!"<< endl; l.unlock(); return; @@ -1264,7 +1264,7 @@ void EventCallBack::push_event(Tango::EventData* ev) try { //e.errors = ev->errors; e.quality = Tango::ATTR_VALID; - //cout << "EVENT="<<ev->attr_name<<" quality="<<e.quality<<endl; + //TANGO_LOG << "EVENT="<<ev->attr_name<<" quality="<<e.quality<<endl; if (!ev->err) { e.quality = (int)ev->attr_value->get_quality(); #if 0//TANGO_VER >= 711 diff --git a/src/event_table.h b/src/event_table.h index 3c5980e..24220d8 100644 --- a/src/event_table.h +++ b/src/event_table.h @@ -13,7 +13,7 @@ #include <string> #include <map> #include <atomic> -#include <tango.h> +#include <tango/tango.h> using namespace std; diff --git a/src/main.cpp b/src/main.cpp index 52ab468..adb9bdd 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -31,7 +31,7 @@ // This file is generated by POGO // (Program Obviously used to Generate tango Object) //============================================================================= -#include <tango.h> +#include <tango/tango.h> // Check if crash reporting is used. #if defined(ENABLE_CRASH_REPORT) @@ -45,6 +45,8 @@ DECLARE_CRASH_HANDLER; int main(int argc,char *argv[]) { + using std::endl; + using std::bad_alloc; INSTALL_CRASH_HANDLER try { @@ -59,20 +61,20 @@ int main(int argc,char *argv[]) // Run the endless loop //---------------------------------------- - cout << "Ready to accept request" << endl; + TANGO_LOG << "Ready to accept request" << endl; tg->server_run(); } catch (bad_alloc &) { - cout << "Can't allocate memory to store device object !!!" << endl; - cout << "Exiting" << endl; + TANGO_LOG << "Can't allocate memory to store device object !!!" << endl; + TANGO_LOG << "Exiting" << endl; } catch (CORBA::Exception &e) { Tango::Except::print_exception(e); - cout << "Received a CORBA_Exception" << endl; - cout << "Exiting" << endl; + TANGO_LOG << "Received a CORBA_Exception" << endl; + TANGO_LOG << "Exiting" << endl; } Tango::Util::instance()->server_cleanup(); return(0); diff --git a/src/update-thread.cpp b/src/update-thread.cpp index 6cac548..06ed89c 100644 --- a/src/update-thread.cpp +++ b/src/update-thread.cpp @@ -10,7 +10,7 @@ static const char __FILE__rev[] = __FILE__ " $Revision: 1.2 $"; */ update_thread::update_thread(AlarmHandler_ns::AlarmHandler *p) : p_Alarm(p),Tango::LogAdapter(p) { - //cout << __FILE__rev << endl; + //TANGO_LOG << __FILE__rev << endl; } /* diff --git a/src/update-thread.h b/src/update-thread.h index 75ce00e..59688d1 100644 --- a/src/update-thread.h +++ b/src/update-thread.h @@ -6,7 +6,7 @@ #define UPDATE_THREAD_H #include <omnithread.h> -#include <tango.h> +#include <tango/tango.h> #include <AlarmHandler.h> class update_thread : public omni_thread, public Tango::TangoMonitor, public Tango::LogAdapter { diff --git a/test/testdevice/CMakeLists.txt b/test/testdevice/CMakeLists.txt index 47e5ffd..bfba52a 100644 --- a/test/testdevice/CMakeLists.txt +++ b/test/testdevice/CMakeLists.txt @@ -80,7 +80,7 @@ set_target_properties(testdevice PROPERTIES OUTPUT_NAME ${DEV_NAME} LINK_FLAGS "-Wl,--no-undefined" - CXX_STANDARD 11) + CXX_STANDARD 17) target_compile_options(testdevice PRIVATE "$<$<CONFIG:DEBUG>:-g>") diff --git a/test/testdevice/src/ClassFactory.cpp b/test/testdevice/src/ClassFactory.cpp index 1b23633..74f08f7 100644 --- a/test/testdevice/src/ClassFactory.cpp +++ b/test/testdevice/src/ClassFactory.cpp @@ -18,7 +18,7 @@ //============================================================================= -#include <tango.h> +#include <tango/tango.h> #include <TestDeviceClass.h> // Add class header files if needed diff --git a/test/testdevice/src/TestDevice.cpp b/test/testdevice/src/TestDevice.cpp index ab7a8fc..75aed61 100644 --- a/test/testdevice/src/TestDevice.cpp +++ b/test/testdevice/src/TestDevice.cpp @@ -1609,7 +1609,7 @@ void TestDevice::set_write_value(Tango::DevString value, string attrname) CORBA::Any *CmdClass::execute(Tango::DeviceImpl *device,const CORBA::Any &in_any) { - cout << "CmdClass::" << get_name() << ": entering..." << endl; + TANGO_LOG << "CmdClass::" << get_name() << ": entering..." << endl; //const Tango::DevVarLongArray *argin; //extract(in_any, argin); diff --git a/test/testdevice/src/TestDevice.h b/test/testdevice/src/TestDevice.h index d8b28e5..a597ad3 100644 --- a/test/testdevice/src/TestDevice.h +++ b/test/testdevice/src/TestDevice.h @@ -18,7 +18,7 @@ #define TestDevice_H -#include <tango.h> +#include <tango/tango.h> #define MAX_ATTR_SIZE 3000 #define MAX_SPECTRUM_SIZE 100 diff --git a/test/testdevice/src/TestDeviceClass.cpp b/test/testdevice/src/TestDeviceClass.cpp index c9390d9..eafabed 100644 --- a/test/testdevice/src/TestDeviceClass.cpp +++ b/test/testdevice/src/TestDeviceClass.cpp @@ -60,7 +60,7 @@ TestDeviceClass *TestDeviceClass::_instance = NULL; //-------------------------------------------------------- TestDeviceClass::TestDeviceClass(string &s):DeviceClass(s) { - cout2 << "Entering TestDeviceClass constructor" << endl; + TANGO_LOG_INFO << "Entering TestDeviceClass constructor" << endl; set_default_property(); get_class_property(); write_class_property(); @@ -69,7 +69,7 @@ TestDeviceClass::TestDeviceClass(string &s):DeviceClass(s) /*----- PROTECTED REGION END -----*/ // TestDevice::Class::constructor - cout2 << "Leaving TestDeviceClass constructor" << endl; + TANGO_LOG_INFO << "Leaving TestDeviceClass constructor" << endl; } @@ -151,7 +151,7 @@ TestDeviceClass *TestDeviceClass::instance() //-------------------------------------------------------- CORBA::Any *WriteAttrnameClass::execute(Tango::DeviceImpl *device, const CORBA::Any &in_any) { - cout2 << "WriteAttrnameClass::execute(): arrived" << endl; + TANGO_LOG_INFO << "WriteAttrnameClass::execute(): arrived" << endl; const Tango::DevVarDoubleStringArray *argin; extract(in_any, argin); @@ -172,7 +172,7 @@ CORBA::Any *WriteAttrnameClass::execute(Tango::DeviceImpl *device, const CORBA:: //-------------------------------------------------------- CORBA::Any *ReadAttrnameClass::execute(Tango::DeviceImpl *device, const CORBA::Any &in_any) { - cout2 << "ReadAttrnameClass::execute(): arrived" << endl; + TANGO_LOG_INFO << "ReadAttrnameClass::execute(): arrived" << endl; const Tango::DevVarStringArray *argin; extract(in_any, argin); @@ -192,7 +192,7 @@ CORBA::Any *ReadAttrnameClass::execute(Tango::DeviceImpl *device, const CORBA::A //-------------------------------------------------------- CORBA::Any *ConfigClass::execute(Tango::DeviceImpl *device, const CORBA::Any &in_any) { - cout2 << "ConfigClass::execute(): arrived" << endl; + TANGO_LOG_INFO << "ConfigClass::execute(): arrived" << endl; const Tango::DevVarStringArray *argin; extract(in_any, argin); @@ -213,7 +213,7 @@ CORBA::Any *ConfigClass::execute(Tango::DeviceImpl *device, const CORBA::Any &in //-------------------------------------------------------- CORBA::Any *AddClass::execute(Tango::DeviceImpl *device, const CORBA::Any &in_any) { - cout2 << "AddClass::execute(): arrived" << endl; + TANGO_LOG_INFO << "AddClass::execute(): arrived" << endl; const Tango::DevVarStringArray *argin; extract(in_any, argin); @@ -234,7 +234,7 @@ CORBA::Any *AddClass::execute(Tango::DeviceImpl *device, const CORBA::Any &in_an //-------------------------------------------------------- CORBA::Any *AddDoubleClass::execute(Tango::DeviceImpl *device, const CORBA::Any &in_any) { - cout2 << "AddDoubleClass::execute(): arrived" << endl; + TANGO_LOG_INFO << "AddDoubleClass::execute(): arrived" << endl; const Tango::DevVarStringArray *argin; extract(in_any, argin); @@ -255,7 +255,7 @@ CORBA::Any *AddDoubleClass::execute(Tango::DeviceImpl *device, const CORBA::Any //-------------------------------------------------------- CORBA::Any *AddLongClass::execute(Tango::DeviceImpl *device, const CORBA::Any &in_any) { - cout2 << "AddLongClass::execute(): arrived" << endl; + TANGO_LOG_INFO << "AddLongClass::execute(): arrived" << endl; const Tango::DevVarStringArray *argin; extract(in_any, argin); @@ -276,7 +276,7 @@ CORBA::Any *AddLongClass::execute(Tango::DeviceImpl *device, const CORBA::Any &i //-------------------------------------------------------- CORBA::Any *AddBoolClass::execute(Tango::DeviceImpl *device, const CORBA::Any &in_any) { - cout2 << "AddBoolClass::execute(): arrived" << endl; + TANGO_LOG_INFO << "AddBoolClass::execute(): arrived" << endl; const Tango::DevVarStringArray *argin; extract(in_any, argin); @@ -297,7 +297,7 @@ CORBA::Any *AddBoolClass::execute(Tango::DeviceImpl *device, const CORBA::Any &i //-------------------------------------------------------- CORBA::Any *AddStringClass::execute(Tango::DeviceImpl *device, const CORBA::Any &in_any) { - cout2 << "AddStringClass::execute(): arrived" << endl; + TANGO_LOG_INFO << "AddStringClass::execute(): arrived" << endl; const Tango::DevVarStringArray *argin; extract(in_any, argin); @@ -318,7 +318,7 @@ CORBA::Any *AddStringClass::execute(Tango::DeviceImpl *device, const CORBA::Any //-------------------------------------------------------- CORBA::Any *RemoveClass::execute(Tango::DeviceImpl *device, const CORBA::Any &in_any) { - cout2 << "RemoveClass::execute(): arrived" << endl; + TANGO_LOG_INFO << "RemoveClass::execute(): arrived" << endl; const Tango::DevVarStringArray *argin; extract(in_any, argin); @@ -514,7 +514,7 @@ void TestDeviceClass::device_factory(const Tango::DevVarStringArray *devlist_ptr // Create devices and add it into the device list for (unsigned long i=0 ; i<devlist_ptr->length() ; i++) { - cout4 << "Device name : " << (*devlist_ptr)[i].in() << endl; + TANGO_LOG_DEBUG << "Device name : " << (*devlist_ptr)[i].in() << endl; device_list.push_back(new TestDevice(this, (*devlist_ptr)[i])); } @@ -695,7 +695,7 @@ void TestDeviceClass::create_static_attribute_list(vector<Tango::Attr *> &att_li defaultAttList.push_back(att_name); } - cout2 << defaultAttList.size() << " attributes in default list" << endl; + TANGO_LOG_INFO << defaultAttList.size() << " attributes in default list" << endl; /*----- PROTECTED REGION ID(TestDevice::Class::create_static_att_list) ENABLED START -----*/ @@ -733,7 +733,7 @@ void TestDeviceClass::erase_dynamic_attributes(const Tango::DevVarStringArray *d vector<string>::iterator ite_str = find(defaultAttList.begin(), defaultAttList.end(), att_name); if (ite_str == defaultAttList.end()) { - cout2 << att_name << " is a UNWANTED dynamic attribute for device " << (*devlist_ptr)[i] << endl; + TANGO_LOG_INFO << att_name << " is a UNWANTED dynamic attribute for device " << (*devlist_ptr)[i] << endl; Tango::Attribute &att = dev->get_device_attr()->get_attr_by_name(att_name.c_str()); dev->remove_attribute(att_list[att.get_attr_idx()],true); --ite_att; diff --git a/test/testdevice/src/TestDeviceClass.h b/test/testdevice/src/TestDeviceClass.h index 0a58fc9..145ecd5 100644 --- a/test/testdevice/src/TestDeviceClass.h +++ b/test/testdevice/src/TestDeviceClass.h @@ -22,7 +22,7 @@ #ifndef TestDeviceCLASS_H #define TestDeviceCLASS_H -#include <tango.h> +#include <tango/tango.h> #include <TestDevice.h> /*----- PROTECTED REGION END -----*/ diff --git a/test/testdevice/src/main.cpp b/test/testdevice/src/main.cpp index 1dfa5f9..cc365f3 100644 --- a/test/testdevice/src/main.cpp +++ b/test/testdevice/src/main.cpp @@ -18,7 +18,7 @@ // (Program Obviously used to Generate tango Object) //============================================================================= -#include <tango.h> +#include <tango/tango.h> int main(int argc,char *argv[]) @@ -37,20 +37,20 @@ int main(int argc,char *argv[]) // Run the endless loop //---------------------------------------- - cout << "Ready to accept request" << endl; + TANGO_LOG << "Ready to accept request" << endl; tg->server_run(); } catch (bad_alloc) { - cout << "Can't allocate memory to store device object !!!" << endl; - cout << "Exiting" << endl; + TANGO_LOG << "Can't allocate memory to store device object !!!" << endl; + TANGO_LOG << "Exiting" << endl; } catch (CORBA::Exception &e) { Tango::Except::print_exception(e); - cout << "Received a CORBA_Exception" << endl; - cout << "Exiting" << endl; + TANGO_LOG << "Received a CORBA_Exception" << endl; + TANGO_LOG << "Exiting" << endl; } if (tg!=NULL) tg->server_cleanup(); -- GitLab