Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • cs/ds/alarm-handler
  • francesco.tripaldi/alarm-handler
2 results
Show changes
Showing
with 425 additions and 156 deletions
...@@ -14,7 +14,7 @@ static const char __FILE__rev[] = __FILE__ " $Revision: 1.7 $"; ...@@ -14,7 +14,7 @@ static const char __FILE__rev[] = __FILE__ " $Revision: 1.7 $";
*/ */
alarm_thread::alarm_thread(AlarmHandler_ns::AlarmHandler *p) : p_Alarm(p) alarm_thread::alarm_thread(AlarmHandler_ns::AlarmHandler *p) : p_Alarm(p)
{ {
//cout << __FILE__rev << endl; //TANGO_LOG << __FILE__rev << endl;
} }
/* /*
...@@ -120,21 +120,21 @@ void alarm_thread::run(void *) ...@@ -120,21 +120,21 @@ void alarm_thread::run(void *)
ostringstream err; ostringstream err;
err << "omni_thread_fatal exception running alarm thread, err=" << ex.error << ends; err << "omni_thread_fatal exception running alarm thread, err=" << ex.error << ends;
//WARN_STREAM << "alarm_thread::run(): " << err.str() << endl; //WARN_STREAM << "alarm_thread::run(): " << err.str() << endl;
printf("alarm_thread::run(): %s", err.str().c_str()); printf("alarm_thread::run(): %s\n", err.str().c_str());
} }
catch(Tango::DevFailed& ex) catch(Tango::DevFailed& ex)
{ {
ostringstream err; ostringstream err;
err << "exception running alarm thread: '" << ex.errors[0].desc << "'" << ends; err << "exception running alarm thread: '" << ex.errors[0].desc << "'" << ends;
//WARN_STREAM << "alarm_thread::run(): " << err.str() << endl; //WARN_STREAM << "alarm_thread::run(): " << err.str() << endl;
printf("alarm_thread::run(): %s", err.str().c_str()); printf("alarm_thread::run(): %s\n", err.str().c_str());
Tango::Except::print_exception(ex); //Tango::Except::print_exception(ex);
} }
catch(...) catch(...)
{ {
//WARN_STREAM << "alarm_thread::run(): catched unknown exception!!" << endl; //WARN_STREAM << "alarm_thread::run(): catched unknown exception!!" << endl;
printf("alarm_thread::run(): catched unknown exception!!"); printf("alarm_thread::run(): catched unknown exception!!\n");
} }
} }
//cout << "alarm_thread::run(): returning" << endl; //TANGO_LOG << "alarm_thread::run(): returning" << endl;
} /* alarm_thread::run() */ } /* alarm_thread::run() */
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
#define ALARM_THREAD_H #define ALARM_THREAD_H
#include <omnithread.h> #include <omnithread.h>
#include <tango.h> #include <tango/tango.h>
#include <AlarmHandler.h> #include <AlarmHandler.h>
#define ALARM_THREAD_EXIT "alarm_thread_exit" #define ALARM_THREAD_EXIT "alarm_thread_exit"
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
*/ */
#include <sys/time.h> #include <sys/time.h>
#include <tango.h> #include <tango/tango.h>
#include "alarm_table.h" #include "alarm_table.h"
#include "alarm_grammar.h" #include "alarm_grammar.h"
#include "cmd_thread.h" #include "cmd_thread.h"
...@@ -374,14 +374,14 @@ bool alarm_table::update(const string& alm_name, Tango::TimeVal ts, formula_res_ ...@@ -374,14 +374,14 @@ bool alarm_table::update(const string& alm_name, Tango::TimeVal ts, formula_res_
found->second.quality = res.quality; found->second.quality = res.quality;
bool status_on_delay; bool status_on_delay;
if(found->second.on_delay > 0) //if enabled on delay if(found->second.on_delay > 0) //if enabled on delay
status_on_delay = ((bool)(res.value != 0)) && (found->second.on_counter >= 1) && ((ts.tv_sec - found->second.on_delay) > found->second.ts_on_delay.tv_sec); //formula gives true and on delay has passed status_on_delay = ((bool)(!res.value.empty() && res.value[0] != 0)) && (found->second.on_counter >= 1) && ((ts.tv_sec - found->second.on_delay) > found->second.ts_on_delay.tv_sec); //formula gives true and on delay has passed
else else
status_on_delay = (bool)(res.value != 0); status_on_delay = (bool)(!res.value.empty() && res.value[0] != 0);
bool status_off_delay; bool status_off_delay;
if(found->second.off_delay > 0) //if enabled off delay if(found->second.off_delay > 0) //if enabled off delay
status_off_delay = (!(bool)(res.value != 0)) && (found->second.off_counter >= 1) && ((ts.tv_sec - found->second.off_delay) > found->second.ts_off_delay.tv_sec); //formula gives false and off delay has passed status_off_delay = (!(bool)(!res.value.empty() && res.value[0] != 0)) && (found->second.off_counter >= 1) && ((ts.tv_sec - found->second.off_delay) > found->second.ts_off_delay.tv_sec); //formula gives false and off delay has passed
else else
status_off_delay = !(bool)(res.value != 0); status_off_delay = !(bool)(!res.value.empty() && res.value[0] != 0);
//if status changed: //if status changed:
// - from S_NORMAL to S_ALARM considering also on delay // - from S_NORMAL to S_ALARM considering also on delay
//or //or
...@@ -389,12 +389,12 @@ bool alarm_table::update(const string& alm_name, Tango::TimeVal ts, formula_res_ ...@@ -389,12 +389,12 @@ bool alarm_table::update(const string& alm_name, Tango::TimeVal ts, formula_res_
if((status_on_delay && (found->second.stat == S_NORMAL)) || (status_off_delay && (found->second.stat == S_ALARM))) if((status_on_delay && (found->second.stat == S_NORMAL)) || (status_off_delay && (found->second.stat == S_ALARM)))
{ {
ret_changed=true; ret_changed=true;
if((bool)(res.value != 0)) if((bool)(!res.value.empty() && res.value[0] != 0))
found->second.ack = NOT_ACK; //if changing from NORMAL to ALARM -> NACK found->second.ack = NOT_ACK; //if changing from NORMAL to ALARM -> NACK
//a.grp = found->second.grp2str(); //a.grp = found->second.grp2str();
//a.msg = (int)(res.value) ? found->second.msg : ""; //a.msg = (int)(res.value[0]) ? found->second.msg : "";
found->second.ts = ts; /* store event timestamp into alarm timestamp */ //here update ts only if status changed found->second.ts = ts; /* store event timestamp into alarm timestamp */ //here update ts only if status changed
if((bool)(res.value != 0)) if((bool)(!res.value.empty() && res.value[0] != 0))
{ {
found->second.is_new = 1; //here set this alarm as new, read attribute set it to 0 //12-06-08: StopNew command set it to 0 found->second.is_new = 1; //here set this alarm as new, read attribute set it to 0 //12-06-08: StopNew command set it to 0
if(found->second.dp_a && ((ts.tv_sec - startup_complete.tv_sec) > 10)) //action from S_NORMAL to S_ALARM if(found->second.dp_a && ((ts.tv_sec - startup_complete.tv_sec) > 10)) //action from S_NORMAL to S_ALARM
...@@ -525,7 +525,7 @@ bool alarm_table::update(const string& alm_name, Tango::TimeVal ts, formula_res_ ...@@ -525,7 +525,7 @@ bool alarm_table::update(const string& alm_name, Tango::TimeVal ts, formula_res_
found->second.error = true; found->second.error = true;
} }
if((bool)(res.value != 0)) { if((bool)(!res.value.empty() && res.value[0] != 0)) {
found->second.on_counter++; found->second.on_counter++;
found->second.off_counter = 0; found->second.off_counter = 0;
} else { } else {
...@@ -863,7 +863,13 @@ void alarm_table::new_rwlock() ...@@ -863,7 +863,13 @@ void alarm_table::new_rwlock()
} }
void alarm_table::del_rwlock() void alarm_table::del_rwlock()
{ {
delete vlock; if(nullptr != vlock)
{
// Try to avoid a race condition.
auto _ptr{vlock};
vlock = nullptr;
delete _ptr;
}
} }
void alarm_table::init_cmdthread() void alarm_table::init_cmdthread()
...@@ -940,7 +946,7 @@ void alarm_table::save_alarm_conf_db(const string &att_name, const string &name, ...@@ -940,7 +946,7 @@ void alarm_table::save_alarm_conf_db(const string &att_name, const string &name,
} }
catch(Tango::DevFailed &e) 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 +994,7 @@ void alarm_table::delete_alarm_conf_db(string att_name) ...@@ -988,7 +994,7 @@ void alarm_table::delete_alarm_conf_db(string att_name)
} }
catch(Tango::DevFailed &e) 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 +1018,7 @@ void alarm_table::get_alarm_list_db(vector<string> &al_list, map<string, string> ...@@ -1012,7 +1018,7 @@ void alarm_table::get_alarm_list_db(vector<string> &al_list, map<string, string>
} }
catch(Tango::DevFailed &e) 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(); savedlock->writerIn();
saved_alarms.clear(); saved_alarms.clear();
...@@ -1067,7 +1073,7 @@ void alarm_table::get_alarm_list_db(vector<string> &al_list, map<string, string> ...@@ -1067,7 +1073,7 @@ void alarm_table::get_alarm_list_db(vector<string> &al_list, map<string, string>
db_data[i] >> alm_receivers; db_data[i] >> alm_receivers;
else 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++; i++;
continue; continue;
} }
...@@ -1092,7 +1098,7 @@ void alarm_table::get_alarm_list_db(vector<string> &al_list, map<string, string> ...@@ -1092,7 +1098,7 @@ void alarm_table::get_alarm_list_db(vector<string> &al_list, map<string, string>
KEY(ENABLED_KEY)<< alm_enabled; 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 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; continue;
} }
al_list.push_back(alm.str()); al_list.push_back(alm.str());
......
...@@ -14,8 +14,9 @@ ...@@ -14,8 +14,9 @@
#include <iostream> #include <iostream>
#include <string> #include <string>
#include <map> #include <map>
#include <numeric> //for std::accumulate
#include <tango.h> #include <tango/tango.h>
//spirit defines have to be put befor first inclusion of spirit headers //spirit defines have to be put befor first inclusion of spirit headers
#ifndef BOOST_SPIRIT_RULE_SCANNERTYPE_LIMIT #ifndef BOOST_SPIRIT_RULE_SCANNERTYPE_LIMIT
...@@ -44,11 +45,12 @@ ...@@ -44,11 +45,12 @@
#endif #endif
//#include "log_thread.h" //#include "log_thread.h"
#define MAX_ARRAY_PRINTED_CHARS 1000
#define LOG_STREAM cout #define LOG_STREAM TANGO_LOG
using namespace std; using namespace std;
typedef vector<Tango::DevDouble> value_t;
#if BOOST_VERSION < 103600 #if BOOST_VERSION < 103600
typedef std::string::iterator iterator_t; typedef std::string::iterator iterator_t;
...@@ -102,18 +104,153 @@ struct rwlock_t ...@@ -102,18 +104,153 @@ struct rwlock_t
rwlock_t(string n){name=n;}; rwlock_t(string n){name=n;};
rwlock_t(){name=string("RWLOCK");}; rwlock_t(){name=string("RWLOCK");};
boost::shared_mutex mut; boost::shared_mutex mut;
void readerIn(){cout<<name<<": " << __func__<<endl;mut.lock_shared();} void readerIn(){TANGO_LOG<<name<<": " << __func__<<endl;mut.lock_shared();}
void readerOut(){cout<<name<<": " << __func__<<endl;mut.unlock_shared();} void readerOut(){TANGO_LOG<<name<<": " << __func__<<endl;mut.unlock_shared();}
void writerIn(){cout<<name<<": " << __func__<<endl;mut.lock();} void writerIn(){TANGO_LOG<<name<<": " << __func__<<endl;mut.lock();}
void writerOut(){cout<<name<<": " << __func__<<endl;mut.unlock();} void writerOut(){TANGO_LOG<<name<<": " << __func__<<endl;mut.unlock();}
}; };
#endif #endif
template <typename T>
string print_vector(const std::vector<T>& v, const char * const separator = ",")
{
ostringstream out;
if(!v.empty())
{
std::copy(v.begin(),
--v.end(),
std::ostream_iterator<T>(out, separator));
out << v.back();
}
return out.str();
}
template <typename T>
string print_array(const std::vector<T>& v, long dim_x, long dim_y, const char * const separator = ",")
{
ostringstream out;
if(dim_y <1)
{
out <<"["<< print_vector(v);
out.seekp(0, ios::end);
stringstream::pos_type offset = out.tellp();
if(offset > MAX_ARRAY_PRINTED_CHARS)
{
out.seekp(MAX_ARRAY_PRINTED_CHARS, ios::beg);//limit size
out << "...]" << ends;
}
else
out << "]";
return out.str();
}
out << "[";
for(long i=0; i<dim_y; i++)
{
auto vstart = v.begin();//start iterator of a row in a vector containing a 2D array
auto vend = v.begin();//end iterator of a row in a vector containing a 2D array
advance(vstart,(int)(i * (dim_x)));
advance(vend,(int)((i+1) * dim_x));
value_t row = value_t(vstart,vend);
out <<"["<< print_vector(row);
out.seekp(0, ios::end);
stringstream::pos_type offset = out.tellp();
if(offset > MAX_ARRAY_PRINTED_CHARS)
{
out.seekp(MAX_ARRAY_PRINTED_CHARS, ios::beg);//limit size
out << "...]]" << ends;
break;
}
else
out << "]";
if(i < dim_y-1)
{
out << ",";
}
}
out << "]";
return out.str();
}
struct vectorUtils
{
static double fBitAnd(long a, long b){ return (double)(a & b);}
static double fBitOr(long a, long b){ return (double)(a | b);}
static double fBitXor(long a, long b){ return (double)(a ^ b);}
static double fBitShiftL(long a, long b){ return (double)(a << b);}
static double fBitShiftR(long a, long b){ return (double)(a >> b);}
static double fMin(double a, double b){ return (double)min(a, b);}
static double fMax(double a, double b){ return (double)max(a, b);}
static double fPow(double a, double b){ return (double)pow(a, b);}
static double fEqual(double a, double b){ return (double)(a == b);}
static double fDifferent(double a, double b){ return (double)(a != b);}
static double fGreaterEqual(double a, double b){ return (double)(a >= b);}
static double fGreater(double a, double b){ return (double)(a > b);}
static double fLessEqual(double a, double b){ return (double)(a <= b);}
static double fLess(double a, double b){ return (double)(a < b);}
static double fPlus(double a, double b){ return (double)(a + b);}
static double fMinus(double a, double b){ return (double)(a - b);}
static double fMult(double a, double b){ return (double)(a * b);}
static double fDiv(double a, double b){ return (double)(a / b);}
static double fAnd(double a, double b){ return (double)((bool)a && (bool)b);}
static double fOr(double a, double b){ return (double)((bool)a || (bool)b);}
template<class T >
static void applyVectorFunc(const vector<T> & v1, long v1_x, long v1_y, const vector<T> & v2, long v2_x, long v2_y, value_t &res, long &res_x, long &res_y, const string& origin, double (*func)(T, T))
{
if(v1.size() > 0 && v2.size() > 0 && (v1.size() == v2.size()))
{
res_x = v1_x;
res_y = v1_y;
if(v1_x != v2_x || (v1_y != v2_y && (v1_y > 1 || v2_y > 1)))//dim_y 0 and 1 are the same
{
ostringstream o;
o << "Array sizes do not match: " << (v1_y ? v1_y : 1) << "x" << v1_x << " != " << (v2_y ? v2_y : 1) << "x" << v2_x;
Tango::Except::throw_exception( //throw exception to have error not delayed
"FORMULA_ERROR",
o.str(),
origin);
}
res.resize(v1.size());
std::transform(v1.begin(), v1.end(), v2.begin(),res.begin(),
[func](T a, T b) { return func(a, b); });
}
else if(v2.size() == 1)
{
res_x = v1_x;
res_y = v1_y;
T b = v2[0];
res.resize(v1.size());
std::transform(v1.begin(), v1.end(), res.begin(),
[b,func](T a) { return func(a, b); });
}
else if(v1.size() == 1)
{
res_x = v2_x;
res_y = v2_y;
T a = v1[0];
res.resize(v2.size());
std::transform(v2.begin(), v2.end(), res.begin(),
[a,func](T b) { return func(a, b); });
}
else if(v1.size() > 0 && v2.size() > 0)
{
ostringstream o;
o << "Array sizes do not match: " << (v1_y ? v1_y : 1) << "x" << v1_x << " != " << (v2_y ? v2_y : 1) << "x" << v2_x;
Tango::Except::throw_exception( //throw exception to have error not delayed
"FORMULA_ERROR",
o.str(),
origin);
}
}
};
struct formula_res_t struct formula_res_t
{ {
formula_res_t(){value=0;valid=false;quality=Tango::ATTR_VALID;ex_reason=string("");ex_desc=string("");ex_origin=string("");} formula_res_t(){valid=false;quality=Tango::ATTR_VALID;ex_reason=string("");ex_desc=string("");ex_origin=string("");dim_x=0;dim_y=0;}
double value; value_t value;
long dim_x;
long dim_y;
int quality; int quality;
bool valid; bool valid;
string error; string error;
...@@ -121,6 +258,7 @@ struct formula_res_t ...@@ -121,6 +258,7 @@ struct formula_res_t
string ex_reason; string ex_reason;
string ex_desc; string ex_desc;
string ex_origin; string ex_origin;
string attr_name; //last evaluated attr name
int combine_quality(int quality1, int quality2) int combine_quality(int quality1, int quality2)
{ {
int res; int res;
...@@ -143,10 +281,19 @@ struct formula_res_t ...@@ -143,10 +281,19 @@ struct formula_res_t
else else
return ex_2; return ex_2;
} }
void extract_result()
{
if(!value.empty())
{
value = {(double)std::accumulate(value.begin(), value.end(), (bool)false, [](bool a, double b) { return (bool)(a || (bool)b); })};
dim_x=1;
dim_y=0;
}
}
formula_res_t operator==(const formula_res_t& e) formula_res_t operator==(const formula_res_t& e)
{ {
formula_res_t res; formula_res_t res;
res.value = value == e.value;
res.valid = valid && e.valid; res.valid = valid && e.valid;
res.quality = combine_quality(quality, e.quality); res.quality = combine_quality(quality, e.quality);
if(!res.valid) if(!res.valid)
...@@ -155,12 +302,12 @@ struct formula_res_t ...@@ -155,12 +302,12 @@ struct formula_res_t
res.ex_desc = combine_exception(ex_desc, e.ex_desc); res.ex_desc = combine_exception(ex_desc, e.ex_desc);
res.ex_origin = combine_exception(ex_origin, e.ex_origin); res.ex_origin = combine_exception(ex_origin, e.ex_origin);
} }
vectorUtils::applyVectorFunc(value,dim_x,dim_y,e.value,e.dim_x,e.dim_y,res.value,res.dim_x,res.dim_y,__func__,vectorUtils::fEqual);
return res; return res;
} }
formula_res_t operator!=(const formula_res_t& e) formula_res_t operator!=(const formula_res_t& e)
{ {
formula_res_t res; formula_res_t res;
res.value = value != e.value;
res.valid = valid && e.valid; res.valid = valid && e.valid;
res.quality = combine_quality(quality, e.quality); res.quality = combine_quality(quality, e.quality);
if(!res.valid) if(!res.valid)
...@@ -169,12 +316,12 @@ struct formula_res_t ...@@ -169,12 +316,12 @@ struct formula_res_t
res.ex_desc = combine_exception(ex_desc, e.ex_desc); res.ex_desc = combine_exception(ex_desc, e.ex_desc);
res.ex_origin = combine_exception(ex_origin, e.ex_origin); res.ex_origin = combine_exception(ex_origin, e.ex_origin);
} }
vectorUtils::applyVectorFunc(value,dim_x,dim_y,e.value,e.dim_x,e.dim_y,res.value,res.dim_x,res.dim_y,__func__,vectorUtils::fDifferent);
return res; return res;
} }
formula_res_t operator<=(const formula_res_t& e) formula_res_t operator<=(const formula_res_t& e)
{ {
formula_res_t res; formula_res_t res;
res.value = value <= e.value;
res.valid = valid && e.valid; res.valid = valid && e.valid;
res.quality = combine_quality(quality, e.quality); res.quality = combine_quality(quality, e.quality);
if(!res.valid) if(!res.valid)
...@@ -183,12 +330,12 @@ struct formula_res_t ...@@ -183,12 +330,12 @@ struct formula_res_t
res.ex_desc = combine_exception(ex_desc, e.ex_desc); res.ex_desc = combine_exception(ex_desc, e.ex_desc);
res.ex_origin = combine_exception(ex_origin, e.ex_origin); res.ex_origin = combine_exception(ex_origin, e.ex_origin);
} }
vectorUtils::applyVectorFunc(value,dim_x,dim_y,e.value,e.dim_x,e.dim_y,res.value,res.dim_x,res.dim_y,__func__,vectorUtils::fLessEqual);
return res; return res;
} }
formula_res_t operator>=(const formula_res_t& e) formula_res_t operator>=(const formula_res_t& e)
{ {
formula_res_t res; formula_res_t res;
res.value = value >= e.value;
res.valid = valid && e.valid; res.valid = valid && e.valid;
res.quality = combine_quality(quality, e.quality); res.quality = combine_quality(quality, e.quality);
if(!res.valid) if(!res.valid)
...@@ -197,12 +344,12 @@ struct formula_res_t ...@@ -197,12 +344,12 @@ struct formula_res_t
res.ex_desc = combine_exception(ex_desc, e.ex_desc); res.ex_desc = combine_exception(ex_desc, e.ex_desc);
res.ex_origin = combine_exception(ex_origin, e.ex_origin); res.ex_origin = combine_exception(ex_origin, e.ex_origin);
} }
vectorUtils::applyVectorFunc(value,dim_x,dim_y,e.value,e.dim_x,e.dim_y,res.value,res.dim_x,res.dim_y,__func__,vectorUtils::fGreaterEqual);
return res; return res;
} }
formula_res_t operator<(const formula_res_t& e) formula_res_t operator<(const formula_res_t& e)
{ {
formula_res_t res; formula_res_t res;
res.value = value < e.value;
res.valid = valid && e.valid; res.valid = valid && e.valid;
res.quality = combine_quality(quality, e.quality); res.quality = combine_quality(quality, e.quality);
if(!res.valid) if(!res.valid)
...@@ -211,12 +358,12 @@ struct formula_res_t ...@@ -211,12 +358,12 @@ struct formula_res_t
res.ex_desc = combine_exception(ex_desc, e.ex_desc); res.ex_desc = combine_exception(ex_desc, e.ex_desc);
res.ex_origin = combine_exception(ex_origin, e.ex_origin); res.ex_origin = combine_exception(ex_origin, e.ex_origin);
} }
vectorUtils::applyVectorFunc(value,dim_x,dim_y,e.value,e.dim_x,e.dim_y,res.value,res.dim_x,res.dim_y,__func__,vectorUtils::fLess);
return res; return res;
} }
formula_res_t operator>(const formula_res_t& e) formula_res_t operator>(const formula_res_t& e)
{ {
formula_res_t res; formula_res_t res;
res.value = value > e.value;
res.valid = valid && e.valid; res.valid = valid && e.valid;
res.quality = combine_quality(quality, e.quality); res.quality = combine_quality(quality, e.quality);
if(!res.valid) if(!res.valid)
...@@ -225,13 +372,19 @@ struct formula_res_t ...@@ -225,13 +372,19 @@ struct formula_res_t
res.ex_desc = combine_exception(ex_desc, e.ex_desc); res.ex_desc = combine_exception(ex_desc, e.ex_desc);
res.ex_origin = combine_exception(ex_origin, e.ex_origin); res.ex_origin = combine_exception(ex_origin, e.ex_origin);
} }
vectorUtils::applyVectorFunc(value,dim_x,dim_y,e.value,e.dim_x,e.dim_y,res.value,res.dim_x,res.dim_y,__func__,vectorUtils::fGreater);
return res; return res;
} }
formula_res_t operator||(const formula_res_t& e) formula_res_t operator||(const formula_res_t& e)
{ {
formula_res_t res; formula_res_t res;
res.value = (valid && value) || (e.valid && e.value); if(value.size() <= 1 && e.value.size() <= 1) //apply special logic ov validity only if comparing scalars. Being careful that if valid=false, then size could be 0
res.valid = (valid && value) || (e.valid && e.value) || (valid && e.valid); {
res.value = {(double)((valid && value[0]) || (e.valid && e.value[0]))}; //in OR one operand TRUE and valid is enough
res.valid = (valid && value[0]) || (e.valid && e.value[0]) || (valid && e.valid); //in OR one operand TRUE and valid is enough, otherwise both valid as usual
}
else
res.valid = valid && e.valid;
res.quality = combine_quality(quality, e.quality); res.quality = combine_quality(quality, e.quality);
if(!res.valid) if(!res.valid)
{ {
...@@ -239,13 +392,22 @@ struct formula_res_t ...@@ -239,13 +392,22 @@ struct formula_res_t
res.ex_desc = combine_exception(ex_desc, e.ex_desc); res.ex_desc = combine_exception(ex_desc, e.ex_desc);
res.ex_origin = combine_exception(ex_origin, e.ex_origin); res.ex_origin = combine_exception(ex_origin, e.ex_origin);
} }
if(!(value.size() <= 1 && e.value.size() <= 1))
{
vectorUtils::applyVectorFunc(value,dim_x,dim_y,e.value,e.dim_x,e.dim_y,res.value,res.dim_x,res.dim_y,__func__,vectorUtils::fOr);
}
return res; return res;
} }
formula_res_t operator&&(const formula_res_t& e) formula_res_t operator&&(const formula_res_t& e)
{ {
formula_res_t res; formula_res_t res;
res.value = !((valid && !value) || (e.valid && !e.value)) || (valid && value && e.valid && e.value); if(value.size() <= 1 && e.value.size() <= 1) //apply special logic ov validity only if comparing scalars
res.valid = (valid && !value) || (e.valid && !e.value) || (valid && e.valid); {
res.value = {(double)(!((valid && !value[0]) || (e.valid && !e.value[0])) || (valid && value[0] && e.valid && e.value[0]))}; //if at least one operand is FALSE and valid, result is FALSE for sure (and valid)
res.valid = (valid && !value[0]) || (e.valid && !e.value[0]) || (valid && e.valid);
}
else
res.valid = valid && e.valid;
res.quality = combine_quality(quality, e.quality); res.quality = combine_quality(quality, e.quality);
if(!res.valid) if(!res.valid)
{ {
...@@ -253,12 +415,15 @@ struct formula_res_t ...@@ -253,12 +415,15 @@ struct formula_res_t
res.ex_desc = combine_exception(ex_desc, e.ex_desc); res.ex_desc = combine_exception(ex_desc, e.ex_desc);
res.ex_origin = combine_exception(ex_origin, e.ex_origin); res.ex_origin = combine_exception(ex_origin, e.ex_origin);
} }
if(!(value.size() <= 1 && e.value.size() <= 1))
{
vectorUtils::applyVectorFunc(value,dim_x,dim_y,e.value,e.dim_x,e.dim_y,res.value,res.dim_x,res.dim_y,__func__,vectorUtils::fAnd);
}
return res; return res;
} }
formula_res_t operator+(const formula_res_t& e) formula_res_t operator+(const formula_res_t& e)
{ {
formula_res_t res; formula_res_t res;
res.value = value + e.value;
res.valid = valid && e.valid; res.valid = valid && e.valid;
res.quality = combine_quality(quality, e.quality); res.quality = combine_quality(quality, e.quality);
if(!res.valid) if(!res.valid)
...@@ -267,12 +432,12 @@ struct formula_res_t ...@@ -267,12 +432,12 @@ struct formula_res_t
res.ex_desc = combine_exception(ex_desc, e.ex_desc); res.ex_desc = combine_exception(ex_desc, e.ex_desc);
res.ex_origin = combine_exception(ex_origin, e.ex_origin); res.ex_origin = combine_exception(ex_origin, e.ex_origin);
} }
vectorUtils::applyVectorFunc(value,dim_x,dim_y,e.value,e.dim_x,e.dim_y,res.value,res.dim_x,res.dim_y,__func__,vectorUtils::fPlus);
return res; return res;
} }
formula_res_t operator-(const formula_res_t& e) formula_res_t operator-(const formula_res_t& e)
{ {
formula_res_t res; formula_res_t res;
res.value = value - e.value;
res.valid = valid && e.valid; res.valid = valid && e.valid;
res.quality = combine_quality(quality, e.quality); res.quality = combine_quality(quality, e.quality);
if(!res.valid) if(!res.valid)
...@@ -281,12 +446,12 @@ struct formula_res_t ...@@ -281,12 +446,12 @@ struct formula_res_t
res.ex_desc = combine_exception(ex_desc, e.ex_desc); res.ex_desc = combine_exception(ex_desc, e.ex_desc);
res.ex_origin = combine_exception(ex_origin, e.ex_origin); res.ex_origin = combine_exception(ex_origin, e.ex_origin);
} }
vectorUtils::applyVectorFunc(value,dim_x,dim_y,e.value,e.dim_x,e.dim_y,res.value,res.dim_x,res.dim_y,__func__,vectorUtils::fMinus);
return res; return res;
} }
formula_res_t operator*(const formula_res_t& e) formula_res_t operator*(const formula_res_t& e)
{ {
formula_res_t res; formula_res_t res;
res.value = value * e.value;
res.valid = valid && e.valid; res.valid = valid && e.valid;
res.quality = combine_quality(quality, e.quality); res.quality = combine_quality(quality, e.quality);
if(!res.valid) if(!res.valid)
...@@ -295,12 +460,12 @@ struct formula_res_t ...@@ -295,12 +460,12 @@ struct formula_res_t
res.ex_desc = combine_exception(ex_desc, e.ex_desc); res.ex_desc = combine_exception(ex_desc, e.ex_desc);
res.ex_origin = combine_exception(ex_origin, e.ex_origin); res.ex_origin = combine_exception(ex_origin, e.ex_origin);
} }
vectorUtils::applyVectorFunc(value,dim_x,dim_y,e.value,e.dim_x,e.dim_y,res.value,res.dim_x,res.dim_y,__func__,vectorUtils::fMult);
return res; return res;
} }
formula_res_t operator/(const formula_res_t& e) formula_res_t operator/(const formula_res_t& e)
{ {
formula_res_t res; formula_res_t res;
res.value = value / e.value;
res.valid = valid && e.valid; res.valid = valid && e.valid;
res.quality = combine_quality(quality, e.quality); res.quality = combine_quality(quality, e.quality);
if(!res.valid) if(!res.valid)
...@@ -309,6 +474,25 @@ struct formula_res_t ...@@ -309,6 +474,25 @@ struct formula_res_t
res.ex_desc = combine_exception(ex_desc, e.ex_desc); res.ex_desc = combine_exception(ex_desc, e.ex_desc);
res.ex_origin = combine_exception(ex_origin, e.ex_origin); res.ex_origin = combine_exception(ex_origin, e.ex_origin);
} }
vectorUtils::applyVectorFunc(value,dim_x,dim_y,e.value,e.dim_x,e.dim_y,res.value,res.dim_x,res.dim_y,__func__,vectorUtils::fDiv);
return res;
}
formula_res_t operator!()
{
formula_res_t res;
for(size_t ii=0; ii < value.size(); ii++)
{
res.value.push_back(!value[ii]);
}
return res;
}
formula_res_t operator-()
{
formula_res_t res;
for(size_t ii=0; ii < value.size(); ii++)
{
res.value.push_back(-value[ii]);
}
return res; return res;
} }
/*string operator<<(const formula_res_t& e) /*string operator<<(const formula_res_t& e)
......
...@@ -14,8 +14,8 @@ static const char __FILE__rev[] = __FILE__ " $Revision: 1.3 $"; ...@@ -14,8 +14,8 @@ static const char __FILE__rev[] = __FILE__ " $Revision: 1.3 $";
*/ */
cmd_thread::cmd_thread() cmd_thread::cmd_thread()
{ {
cout << __FILE__rev << endl; TANGO_LOG << __FILE__rev << endl;
cout << gettime().tv_sec << " cmd_thread::cmd_thread(): constructor... !" << endl; TANGO_LOG << gettime().tv_sec << " cmd_thread::cmd_thread(): constructor... !" << endl;
//mutex_dp = new omni_mutex::omni_mutex(); //mutex_dp = new omni_mutex::omni_mutex();
} }
...@@ -24,7 +24,7 @@ cmd_thread::cmd_thread() ...@@ -24,7 +24,7 @@ cmd_thread::cmd_thread()
*/ */
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; //delete mutex_dp;
} }
...@@ -44,13 +44,13 @@ void cmd_thread::run(void *) ...@@ -44,13 +44,13 @@ void cmd_thread::run(void *)
switch(cmd.cmd_id) switch(cmd.cmd_id)
{ {
case CMD_THREAD_EXIT: 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; return;
case CMD_COMMAND: case CMD_COMMAND:
{ {
try { 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; dp = (Tango::DeviceProxy *)cmd.dp_add;
if(cmd.arg_b) if(cmd.arg_b)
{ {
...@@ -64,7 +64,7 @@ void cmd_thread::run(void *) ...@@ -64,7 +64,7 @@ void cmd_thread::run(void *)
} }
else else
call_id = dp->command_inout_asynch(cmd.arg_s2); 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; /*cmd_t arg;
arg.cmd_id = CMD_RESPONSE; arg.cmd_id = CMD_RESPONSE;
arg.call_id = call_id; arg.call_id = call_id;
...@@ -83,11 +83,11 @@ void cmd_thread::run(void *) ...@@ -83,11 +83,11 @@ void cmd_thread::run(void *)
if(err.find("is not yet arrived") == string::npos) //TODO: change this!! 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; 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 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.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 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 list.push_back(cmd); //if no exception till now push in list request of response
...@@ -99,12 +99,12 @@ void cmd_thread::run(void *) ...@@ -99,12 +99,12 @@ void cmd_thread::run(void *)
case CMD_RESPONSE: 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; Tango::DeviceData resp;
dp = (Tango::DeviceProxy *)cmd.dp_add; dp = (Tango::DeviceProxy *)cmd.dp_add;
try { try {
resp = dp->command_inout_reply(cmd.call_id); 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) } catch(Tango::DevFailed &e)
{ {
TangoSys_MemStream out_stream; TangoSys_MemStream out_stream;
...@@ -118,7 +118,7 @@ void cmd_thread::run(void *) ...@@ -118,7 +118,7 @@ void cmd_thread::run(void *)
} }
else 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); Tango::Except::print_exception(e);
} }
} }
...@@ -127,19 +127,19 @@ void cmd_thread::run(void *) ...@@ -127,19 +127,19 @@ void cmd_thread::run(void *)
} }
/* if(cmd.arg_s == CMD_THREAD_EXIT) /* 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; return;
} }
else 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; Tango::DeviceData resp;
dp = (Tango::DeviceProxy *)cmd.dp_add; dp = (Tango::DeviceProxy *)cmd.dp_add;
try { try {
mutex_dp->lock(); mutex_dp->lock();
resp = dp->command_inout_reply(cmd.cmd_id); resp = dp->command_inout_reply(cmd.cmd_id);
mutex_dp->unlock(); 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) } catch(Tango::DevFailed &e)
{ {
TangoSys_MemStream out_stream; TangoSys_MemStream out_stream;
...@@ -152,7 +152,7 @@ void cmd_thread::run(void *) ...@@ -152,7 +152,7 @@ void cmd_thread::run(void *)
omni_thread::sleep(0,300000000); //0.2 s omni_thread::sleep(0,300000000); //0.2 s
} }
else 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 *) ...@@ -178,7 +178,7 @@ void cmd_thread::run(void *)
printf("cmd_thread::run(): catched unknown exception!!"); printf("cmd_thread::run(): catched unknown exception!!");
} }
} }
//cout << "alarm_thread::run(): returning" << endl; //TANGO_LOG << "alarm_thread::run(): returning" << endl;
} /* cmd_thread::run() */ } /* cmd_thread::run() */
/* /*
...@@ -188,7 +188,7 @@ void cmd_list::push_back(cmd_t& cmd) ...@@ -188,7 +188,7 @@ void cmd_list::push_back(cmd_t& cmd)
{ {
this->lock(); 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{ try{
l_cmd.push_back(cmd); l_cmd.push_back(cmd);
empty.signal(); empty.signal();
...@@ -255,7 +255,7 @@ const cmd_t cmd_list::pop_front(void) ...@@ -255,7 +255,7 @@ const cmd_t cmd_list::pop_front(void)
/*const*/ cmd_t cmd; /*const*/ cmd_t cmd;
cmd = *(l_cmd.begin()); 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(); l_cmd.pop_front();
this->unlock(); this->unlock();
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
#define CMD_THREAD_EXIT 3 #define CMD_THREAD_EXIT 3
#include <omnithread.h> #include <omnithread.h>
#include <tango.h> #include <tango/tango.h>
#include "AlarmHandler.h" #include "AlarmHandler.h"
struct cmd_t struct cmd_t
......
...@@ -7,13 +7,11 @@ ...@@ -7,13 +7,11 @@
*/ */
#include <sys/time.h> #include <sys/time.h>
#include <tango.h> #include <tango/tango.h>
#include "event_table.h" #include "event_table.h"
#include "AlarmHandler.h" #include "AlarmHandler.h"
#include "alarm_grammar.h" #include "alarm_grammar.h"
//for get_event_system_for_event_id, to know if ZMQ
#include <eventconsumer.h>
#include <regex> #include <regex>
static const char __FILE__rev[] = __FILE__ " $Revision: 1.5 $"; static const char __FILE__rev[] = __FILE__ " $Revision: 1.5 $";
...@@ -41,8 +39,8 @@ void event_list::push_back(bei_t& e) ...@@ -41,8 +39,8 @@ void event_list::push_back(bei_t& e)
ostringstream err; ostringstream err;
err << "exception signaling omni_condition: '" << ex.errors[0].desc << "'"; err << "exception signaling omni_condition: '" << ex.errors[0].desc << "'";
//WARN_STREAM << "event_list::push_back(): " << err.str() << endl; //WARN_STREAM << "event_list::push_back(): " << err.str() << endl;
printf("event_list::push_back: %s", err.str().c_str()); //printf("event_list::push_back: %s", err.str().c_str());
Tango::Except::print_exception(ex); //Tango::Except::print_exception(ex);
} }
catch(...) catch(...)
{ {
...@@ -76,8 +74,8 @@ const bei_t event_list::pop_front(void) ...@@ -76,8 +74,8 @@ const bei_t event_list::pop_front(void)
ostringstream err; ostringstream err;
err << "exception waiting on omni_condition: '" << ex.errors[0].desc << "'"; err << "exception waiting on omni_condition: '" << ex.errors[0].desc << "'";
//WARN_STREAM << "event_list::pop_front(): " << err.str() << endl; //WARN_STREAM << "event_list::pop_front(): " << err.str() << endl;
printf("event_list::pop_front: %s", err.str().c_str()); //printf("event_list::pop_front: %s", err.str().c_str());
Tango::Except::print_exception(ex); //Tango::Except::print_exception(ex);
bei_t e; bei_t e;
this->unlock(); this->unlock();
sleep(1); sleep(1);
...@@ -147,7 +145,7 @@ void alarm_list::pop(const string& a) ...@@ -147,7 +145,7 @@ void alarm_list::pop(const string& a)
if(it != l_alarm.end()) if(it != l_alarm.end())
l_alarm.erase(it); l_alarm.erase(it);
else else
cout << "alarm_list::"<<__func__<< ": ALARM '"<< a << "' NOT FOUND!"<< endl; TANGO_LOG << "alarm_list::"<<__func__<< ": ALARM '"<< a << "' NOT FOUND!"<< endl;
l.unlock(); l.unlock();
return; return;
...@@ -203,6 +201,8 @@ event::event(string& s, value_t& v, Tango::TimeVal& t) : \ ...@@ -203,6 +201,8 @@ event::event(string& s, value_t& v, Tango::TimeVal& t) : \
event_id = SUB_ERR; event_id = SUB_ERR;
err_counter = 0; err_counter = 0;
valid = false; valid = false;
dim_x=0;
dim_y=0;
} }
event::event(string& s) : name(s) event::event(string& s) : name(s)
...@@ -224,7 +224,9 @@ event::event(string& s) : name(s) ...@@ -224,7 +224,9 @@ event::event(string& s) : name(s)
type = -1; type = -1;
event_id = SUB_ERR; event_id = SUB_ERR;
err_counter = 0; err_counter = 0;
valid = false; valid = false;
dim_x=0;
dim_y=0;
} }
bool event::operator==(const event& e) bool event::operator==(const event& e)
...@@ -291,27 +293,10 @@ void event_table::summary(list<string> &evs) ...@@ -291,27 +293,10 @@ void event_table::summary(list<string> &evs)
ev_summary << KEY(EVENT_TIME_KEY) << time_buf << SEP; ev_summary << KEY(EVENT_TIME_KEY) << time_buf << SEP;
ostringstream tmp_val; ostringstream tmp_val;
//if(i->valid) if(i->type != Tango::DEV_STRING)
{ tmp_val << print_array(i->value,i->dim_x,i->dim_y);
tmp_val << "[" ; else
if(i->type != Tango::DEV_STRING) tmp_val << "[\""<<i->value_string<<"\"]";
{
if(i->read_size > 0 && i->value.size() > 0)
{
for(size_t k=0; k<i->read_size && k<i->value.size(); k++)
{
tmp_val << i->value[k];
if(k < i->read_size-1 && k<i->value.size()-1)
tmp_val << ",";
}
}
}
else
{
tmp_val << "\""<<i->value_string<<"\"";
}
tmp_val << "]";
}
ev_summary << KEY(ATTR_VALUES_KEY) << tmp_val.str() << SEP; ev_summary << KEY(ATTR_VALUES_KEY) << tmp_val.str() << SEP;
ostringstream tmp_ex; ostringstream tmp_ex;
//tmp_ex.str(""); //tmp_ex.str("");
...@@ -387,7 +372,7 @@ void event_table::free_proxy(void) ...@@ -387,7 +372,7 @@ void event_table::free_proxy(void)
} }
} }
void event_table::subscribe(EventCallBack& ecb) throw(vector<string> &)//throw(string&) void event_table::subscribe(EventCallBack& ecb)
{ {
vector<string> subscribe_error; vector<string> subscribe_error;
if (v_event.empty() == false) { if (v_event.empty() == false) {
...@@ -411,7 +396,7 @@ void event_table::subscribe(EventCallBack& ecb) throw(vector<string> &)//throw(s ...@@ -411,7 +396,7 @@ void event_table::subscribe(EventCallBack& ecb) throw(vector<string> &)//throw(s
throw subscribe_error; throw subscribe_error;
} }
void event_table::unsubscribe(void) throw(string&) void event_table::unsubscribe(void)
{ {
ostringstream o; ostringstream o;
if (v_event.empty() == false) { if (v_event.empty() == false) {
...@@ -840,6 +825,9 @@ void event_table::add(string &signame, vector<string> contexts, int to_do, bool ...@@ -840,6 +825,9 @@ void event_table::add(string &signame, vector<string> contexts, int to_do, bool
signal->running = false; signal->running = false;
signal->stopped = true; signal->stopped = true;
signal->paused = false; signal->paused = false;
signal->valid = false;
signal->dim_x=0;
signal->dim_y=0;
//DEBUG_STREAM << "event_table::"<<__func__<<": signame="<<signame<<" created signal"<< endl; //DEBUG_STREAM << "event_table::"<<__func__<<": signame="<<signame<<" created signal"<< endl;
} }
else if(found && start) else if(found && start)
...@@ -1008,7 +996,7 @@ void event_table::subscribe_events() ...@@ -1008,7 +996,7 @@ void event_table::subscribe_events()
<< sig_name << "' error=" << ex_desc; << sig_name << "' error=" << ex_desc;
INFO_STREAM <<"event_table::"<<__func__<<": sig->attr->subscribe_event: " << o.str() << endl; INFO_STREAM <<"event_table::"<<__func__<<": sig->attr->subscribe_event: " << o.str() << endl;
err = true; err = true;
Tango::Except::print_exception(e); //Tango::Except::print_exception(e);
//sig->siglock->writerIn(); //not yet subscribed, no one can modify //sig->siglock->writerIn(); //not yet subscribed, no one can modify
sig->ex_reason = ex.ex_reason = ex_reason; sig->ex_reason = ex.ex_reason = ex_reason;
sig->ex_desc = ex.ex_desc = ex_desc; sig->ex_desc = ex.ex_desc = ex_desc;
...@@ -1264,7 +1252,7 @@ void EventCallBack::push_event(Tango::EventData* ev) ...@@ -1264,7 +1252,7 @@ void EventCallBack::push_event(Tango::EventData* ev)
try { try {
//e.errors = ev->errors; //e.errors = ev->errors;
e.quality = Tango::ATTR_VALID; 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) { if (!ev->err) {
e.quality = (int)ev->attr_value->get_quality(); e.quality = (int)ev->attr_value->get_quality();
#if 0//TANGO_VER >= 711 #if 0//TANGO_VER >= 711
...@@ -1280,7 +1268,7 @@ void EventCallBack::push_event(Tango::EventData* ev) ...@@ -1280,7 +1268,7 @@ void EventCallBack::push_event(Tango::EventData* ev)
e.ev_name = ev->attr_name; e.ev_name = ev->attr_name;
#endif #endif
e.ts = ev->attr_value->time; e.ts = ev->attr_value->time;
extract_values(ev->attr_value, e.value, e.value_string, e.type, e.read_size); extract_values(ev->attr_value, e.value, e.value_string, e.type, e.read_size, e.dim_x, e.dim_y);
} else { } else {
e.quality = Tango::ATTR_INVALID; e.quality = Tango::ATTR_INVALID;
#if 0//TANGO_VER >= 711 #if 0//TANGO_VER >= 711
...@@ -1343,7 +1331,7 @@ void EventCallBack::push_event(Tango::EventData* ev) ...@@ -1343,7 +1331,7 @@ void EventCallBack::push_event(Tango::EventData* ev)
static_cast<AlarmHandler_ns::AlarmHandler *>(mydev)->evlist.push_back(e); static_cast<AlarmHandler_ns::AlarmHandler *>(mydev)->evlist.push_back(e);
} /* push_event() */ } /* push_event() */
void EventCallBack::extract_values(Tango::DeviceAttribute *attr_value, vector<double> &val, string &val_string, int &type, int &read_size) void EventCallBack::extract_values(Tango::DeviceAttribute *attr_value, vector<double> &val, string &val_string, int &type, int &read_size, long &dim_x, long &dim_y)
{ {
Tango::DevState stval; Tango::DevState stval;
vector<Tango::DevState> v_st; vector<Tango::DevState> v_st;
...@@ -1377,76 +1365,79 @@ void EventCallBack::extract_values(Tango::DeviceAttribute *attr_value, vector<do ...@@ -1377,76 +1365,79 @@ void EventCallBack::extract_values(Tango::DeviceAttribute *attr_value, vector<do
attr_r_dim.dim_y = 0; attr_r_dim.dim_y = 0;
//attr_w_dim.dim_y = 0; //attr_w_dim.dim_y = 0;
} }
dim_x = attr_r_dim.dim_x;
dim_y = attr_r_dim.dim_y;
read_size = attr_r_dim.dim_x; read_size = attr_r_dim.dim_x;
if(attr_r_dim.dim_y > 1) if(attr_r_dim.dim_y > 1)
read_size *= attr_r_dim.dim_y; read_size *= attr_r_dim.dim_y;
if (attr_value->get_type() == Tango::DEV_UCHAR) { if (attr_value->get_type() == Tango::DEV_UCHAR) {
*(attr_value) >> v_uch; attr_value->extract_read(v_uch);
for(vector<Tango::DevUChar>::iterator it = v_uch.begin(); it != v_uch.end(); it++) for(vector<Tango::DevUChar>::iterator it = v_uch.begin(); it != v_uch.end(); it++)
val.push_back((double)(*it)); //convert all to double val.push_back((double)(*it)); //convert all to double
type = Tango::DEV_UCHAR; type = Tango::DEV_UCHAR;
} else if (attr_value->get_type() == Tango::DEV_SHORT) { } else if (attr_value->get_type() == Tango::DEV_SHORT) {
*(attr_value) >> v_sh; attr_value->extract_read(v_sh);
for(vector<Tango::DevShort>::iterator it = v_sh.begin(); it != v_sh.end(); it++) for(vector<Tango::DevShort>::iterator it = v_sh.begin(); it != v_sh.end(); it++)
val.push_back((double)(*it)); //convert all to double val.push_back((double)(*it)); //convert all to double
type = Tango::DEV_SHORT; type = Tango::DEV_SHORT;
} else if (attr_value->get_type() == Tango::DEV_USHORT) { } else if (attr_value->get_type() == Tango::DEV_USHORT) {
*(attr_value) >> v_ush; attr_value->extract_read(v_ush);
for(vector<Tango::DevUShort>::iterator it = v_ush.begin(); it != v_ush.end(); it++) for(vector<Tango::DevUShort>::iterator it = v_ush.begin(); it != v_ush.end(); it++)
val.push_back((double)(*it)); //convert all to double val.push_back((double)(*it)); //convert all to double
type = Tango::DEV_USHORT; type = Tango::DEV_USHORT;
} else if (attr_value->get_type() == Tango::DEV_LONG) { } else if (attr_value->get_type() == Tango::DEV_LONG) {
*(attr_value) >> v_lo; attr_value->extract_read(v_lo);
for(vector<Tango::DevLong>::iterator it = v_lo.begin(); it != v_lo.end(); it++) for(vector<Tango::DevLong>::iterator it = v_lo.begin(); it != v_lo.end(); it++)
val.push_back((double)(*it)); //convert all to double val.push_back((double)(*it)); //convert all to double
type = Tango::DEV_LONG; type = Tango::DEV_LONG;
} else if (attr_value->get_type() == Tango::DEV_STATE) { } else if (attr_value->get_type() == Tango::DEV_STATE) {
//*(attr_value) >> v_st; //doesn't work in tango 5 //*(attr_value) >> v_st; //doesn't work in tango 5
*(attr_value) >> stval; *(attr_value) >> stval;
v_st.push_back(stval); //v_st.push_back(stval);
for(vector<Tango::DevState>::iterator it = v_st.begin(); it != v_st.end(); it++) //attr_value->extract_read(stval);
val.push_back((double)(*it)); //convert all to double //for(vector<Tango::DevState>::iterator it = v_st.begin(); it != v_st.end(); it++)
val.push_back((double)(stval)); //convert all to double
type = Tango::DEV_STATE; type = Tango::DEV_STATE;
#if 1//TANGO_VER >= 600 #if 1//TANGO_VER >= 600
} else if (attr_value->get_type() == Tango::DEV_ULONG) { } else if (attr_value->get_type() == Tango::DEV_ULONG) {
*(attr_value) >> v_ulo; attr_value->extract_read(v_ulo);
for(vector<Tango::DevULong>::iterator it = v_ulo.begin(); it != v_ulo.end(); it++) for(vector<Tango::DevULong>::iterator it = v_ulo.begin(); it != v_ulo.end(); it++)
val.push_back((double)(*it)); //convert all to double val.push_back((double)(*it)); //convert all to double
type = Tango::DEV_ULONG; type = Tango::DEV_ULONG;
#endif //TANGO_VER >= 600 #endif //TANGO_VER >= 600
} else if (attr_value->get_type() == Tango::DEV_DOUBLE) { } else if (attr_value->get_type() == Tango::DEV_DOUBLE) {
*(attr_value) >> v_do; attr_value->extract_read(v_do);
for(vector<Tango::DevDouble>::iterator it = v_do.begin(); it != v_do.end(); it++) for(vector<Tango::DevDouble>::iterator it = v_do.begin(); it != v_do.end(); it++)
val.push_back((double)(*it)); //convert all to double val.push_back((double)(*it)); //convert all to double
type = Tango::DEV_DOUBLE; type = Tango::DEV_DOUBLE;
} else if (attr_value->get_type() == Tango::DEV_FLOAT) { } else if (attr_value->get_type() == Tango::DEV_FLOAT) {
*(attr_value) >> v_fl; attr_value->extract_read(v_fl);
for(vector<Tango::DevFloat>::iterator it = v_fl.begin(); it != v_fl.end(); it++) for(vector<Tango::DevFloat>::iterator it = v_fl.begin(); it != v_fl.end(); it++)
val.push_back((double)(*it)); //convert all to double val.push_back((double)(*it)); //convert all to double
type = Tango::DEV_FLOAT; type = Tango::DEV_FLOAT;
} else if (attr_value->get_type() == Tango::DEV_BOOLEAN) { } else if (attr_value->get_type() == Tango::DEV_BOOLEAN) {
*(attr_value) >> v_bo; attr_value->extract_read(v_bo);
for(vector<Tango::DevBoolean>::iterator it = v_bo.begin(); it != v_bo.end(); it++) for(vector<Tango::DevBoolean>::iterator it = v_bo.begin(); it != v_bo.end(); it++)
val.push_back((double)(*it)); //convert all to double val.push_back((double)(*it)); //convert all to double
type = Tango::DEV_BOOLEAN; type = Tango::DEV_BOOLEAN;
} else if (attr_value->get_type() == Tango::DEV_LONG64) { } else if (attr_value->get_type() == Tango::DEV_LONG64) {
*(attr_value) >> v_lo64; attr_value->extract_read(v_lo64);
for(vector<Tango::DevLong64>::iterator it = v_lo64.begin(); it != v_lo64.end(); it++) for(vector<Tango::DevLong64>::iterator it = v_lo64.begin(); it != v_lo64.end(); it++)
val.push_back((double)(*it)); //convert all to double val.push_back((double)(*it)); //convert all to double
type = Tango::DEV_LONG64; type = Tango::DEV_LONG64;
} else if (attr_value->get_type() == Tango::DEV_ULONG64) { } else if (attr_value->get_type() == Tango::DEV_ULONG64) {
*(attr_value) >> v_ulo64; attr_value->extract_read(v_ulo64);
for(vector<Tango::DevULong64>::iterator it = v_ulo64.begin(); it != v_ulo64.end(); it++) for(vector<Tango::DevULong64>::iterator it = v_ulo64.begin(); it != v_ulo64.end(); it++)
val.push_back((double)(*it)); //convert all to double val.push_back((double)(*it)); //convert all to double
type = Tango::DEV_ULONG64; type = Tango::DEV_ULONG64;
} else if (attr_value->get_type() == Tango::DEV_ENUM) { } else if (attr_value->get_type() == Tango::DEV_ENUM) {
*(attr_value) >> v_enum; attr_value->extract_read(v_enum);
for(vector<Tango::DevEnum>::iterator it = v_enum.begin(); it != v_enum.end(); it++) for(vector<Tango::DevEnum>::iterator it = v_enum.begin(); it != v_enum.end(); it++)
val.push_back((double)(*it)); //convert all to double val.push_back((double)(*it)); //convert all to double
type = Tango::DEV_ENUM; type = Tango::DEV_ENUM;
} else if (attr_value->get_type() == Tango::DEV_STRING) { } else if (attr_value->get_type() == Tango::DEV_STRING) {
*(attr_value) >> v_string; attr_value->extract_read(v_string);
val_string = *(v_string.begin()); //TODO: support string spectrum attrbutes val_string = *(v_string.begin()); //TODO: support string spectrum attrbutes
type = Tango::DEV_STRING; type = Tango::DEV_STRING;
} }
...@@ -1454,7 +1445,7 @@ void EventCallBack::extract_values(Tango::DeviceAttribute *attr_value, vector<do ...@@ -1454,7 +1445,7 @@ void EventCallBack::extract_values(Tango::DeviceAttribute *attr_value, vector<do
ostringstream o; ostringstream o;
o << "unknown type"; o << "unknown type";
throw o.str(); throw o.str();
} }
} }
/*void EventCallBack::init(event_list* e) /*void EventCallBack::init(event_list* e)
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
#include <string> #include <string>
#include <map> #include <map>
#include <atomic> #include <atomic>
#include <tango.h> #include <tango/tango.h>
using namespace std; using namespace std;
...@@ -66,7 +66,8 @@ class event { ...@@ -66,7 +66,8 @@ class event {
int type, /* attribute data type */ int type, /* attribute data type */
read_size, /* attribute size of read part */ read_size, /* attribute size of read part */
counter, /* molteplicita' */ counter, /* molteplicita' */
err_counter; /* molteplicita' errore */ err_counter; /* molteplicita' errore */
long dim_x, dim_y;
alarm_list m_alarm; alarm_list m_alarm;
bool valid; //TODO: old bool valid; //TODO: old
bool first;//TODO: new bool first;//TODO: new
...@@ -116,6 +117,8 @@ typedef struct basic_event_info_s { ...@@ -116,6 +117,8 @@ typedef struct basic_event_info_s {
string ex_origin; string ex_origin;
int type; int type;
int read_size; int read_size;
long dim_x;
long dim_y;
Tango::TimeVal ts; Tango::TimeVal ts;
string msg; string msg;
} bei_t; } bei_t;
...@@ -154,8 +157,8 @@ class event_table : public Tango::TangoMonitor, public Tango::LogAdapter { ...@@ -154,8 +157,8 @@ class event_table : public Tango::TangoMonitor, public Tango::LogAdapter {
#if 0 #if 0
void init_proxy(void) throw(vector<string> &); void init_proxy(void) throw(vector<string> &);
void free_proxy(void); void free_proxy(void);
void subscribe(EventCallBack& ecb) throw(vector<string> &);//throw(string&); void subscribe(EventCallBack& ecb);
void unsubscribe(void) throw(string&); void unsubscribe(void);
#endif #endif
/** /**
* Add a new signal. * Add a new signal.
...@@ -202,7 +205,7 @@ class EventCallBack : public Tango::CallBack, public Tango::LogAdapter ...@@ -202,7 +205,7 @@ class EventCallBack : public Tango::CallBack, public Tango::LogAdapter
~EventCallBack(void); ~EventCallBack(void);
void push_event(Tango::EventData* ev); void push_event(Tango::EventData* ev);
//void init(event_list* e); //void init(event_list* e);
void extract_values(Tango::DeviceAttribute *attr_value, vector<double> &val, string &val_string, int &type, int &read_size); void extract_values(Tango::DeviceAttribute *attr_value, vector<double> &val, string &val_string, int &type, int &read_size, long &dim_x, long &dim_y);
private: private:
//event_list* e_ptr; //event_list* e_ptr;
Tango::DeviceImpl *mydev; Tango::DeviceImpl *mydev;
......
...@@ -125,6 +125,8 @@ struct formula_grammar : public grammar<formula_grammar> ...@@ -125,6 +125,8 @@ struct formula_grammar : public grammar<formula_grammar>
static const int val_qualityID = 23; static const int val_qualityID = 23;
static const int val_alarm_enum_stID = 24; static const int val_alarm_enum_stID = 24;
static const int propertyID = 25; static const int propertyID = 25;
static const int index_rangeID = 26;
static const int index_listID = 27;
symbols<unsigned int> tango_states; symbols<unsigned int> tango_states;
...@@ -207,9 +209,18 @@ struct formula_grammar : public grammar<formula_grammar> ...@@ -207,9 +209,18 @@ struct formula_grammar : public grammar<formula_grammar>
] ]
] ]
// = repeat_p(3)[(+symbol) >> ch_p('/')] >> (+symbol) // = repeat_p(3)[(+symbol) >> ch_p('/')] >> (+symbol)
; ;
index_range
=
( uint_p >> !(discard_node_d[ch_p('-')] >> uint_p)) // n or n-m
;
index_list
= (index_range >> *(discard_node_d[ch_p(',')] >> index_range)) // n-m,k,s-t,..
;
index index
= inner_node_d[ch_p('[') >> uint_p >> ch_p(']')] = discard_node_d[ch_p('[')] >>
(str_p("-1") | index_list) >>
discard_node_d[ch_p(']')]
; ;
property property
= str_p(".quality") = str_p(".quality")
...@@ -263,8 +274,8 @@ struct formula_grammar : public grammar<formula_grammar> ...@@ -263,8 +274,8 @@ struct formula_grammar : public grammar<formula_grammar>
event_ event_
= name = name
>> !( (index) >> ( *(index)//0 or more indexex
| (property) >> !(property) //followed by 0 or 1 property
) )
; ;
...@@ -399,6 +410,8 @@ struct formula_grammar : public grammar<formula_grammar> ...@@ -399,6 +410,8 @@ struct formula_grammar : public grammar<formula_grammar>
rule<ScannerT, parser_context<>, parser_tag<expr_atomID> > expr_atom; rule<ScannerT, parser_context<>, parser_tag<expr_atomID> > expr_atom;
rule<ScannerT, parser_context<>, parser_tag<funcID> > function; rule<ScannerT, parser_context<>, parser_tag<funcID> > function;
rule<ScannerT, parser_context<>, parser_tag<nameID> > name; rule<ScannerT, parser_context<>, parser_tag<nameID> > name;
rule<ScannerT, parser_context<>, parser_tag<index_rangeID> > index_range;
rule<ScannerT, parser_context<>, parser_tag<index_listID> > index_list;
rule<ScannerT, parser_context<>, parser_tag<indexID> > index; rule<ScannerT, parser_context<>, parser_tag<indexID> > index;
rule<ScannerT, parser_context<>, parser_tag<val_stringID> > val_string; rule<ScannerT, parser_context<>, parser_tag<val_stringID> > val_string;
rule<ScannerT, parser_context<>, parser_tag<func_dualID> > function_dual; rule<ScannerT, parser_context<>, parser_tag<func_dualID> > function_dual;
......
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
// This file is generated by POGO // This file is generated by POGO
// (Program Obviously used to Generate tango Object) // (Program Obviously used to Generate tango Object)
//============================================================================= //=============================================================================
#include <tango.h> #include <tango/tango.h>
// Check if crash reporting is used. // Check if crash reporting is used.
#if defined(ENABLE_CRASH_REPORT) #if defined(ENABLE_CRASH_REPORT)
...@@ -43,8 +43,15 @@ ...@@ -43,8 +43,15 @@
DECLARE_CRASH_HANDLER; DECLARE_CRASH_HANDLER;
#ifndef TANGO_LOG
#define TANGO_LOG cout
#endif
int main(int argc,char *argv[]) int main(int argc,char *argv[])
{ {
using std::endl;
using std::bad_alloc;
INSTALL_CRASH_HANDLER INSTALL_CRASH_HANDLER
try try
{ {
...@@ -59,20 +66,20 @@ int main(int argc,char *argv[]) ...@@ -59,20 +66,20 @@ int main(int argc,char *argv[])
// Run the endless loop // Run the endless loop
//---------------------------------------- //----------------------------------------
cout << "Ready to accept request" << endl; TANGO_LOG << "Ready to accept request" << endl;
tg->server_run(); tg->server_run();
} }
catch (bad_alloc &) catch (bad_alloc &)
{ {
cout << "Can't allocate memory to store device object !!!" << endl; TANGO_LOG << "Can't allocate memory to store device object !!!" << endl;
cout << "Exiting" << endl; TANGO_LOG << "Exiting" << endl;
} }
catch (CORBA::Exception &e) catch (CORBA::Exception &e)
{ {
Tango::Except::print_exception(e); Tango::Except::print_exception(e);
cout << "Received a CORBA_Exception" << endl; TANGO_LOG << "Received a CORBA_Exception" << endl;
cout << "Exiting" << endl; TANGO_LOG << "Exiting" << endl;
} }
Tango::Util::instance()->server_cleanup(); Tango::Util::instance()->server_cleanup();
return(0); return(0);
......
...@@ -10,7 +10,7 @@ static const char __FILE__rev[] = __FILE__ " $Revision: 1.2 $"; ...@@ -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) update_thread::update_thread(AlarmHandler_ns::AlarmHandler *p) : p_Alarm(p),Tango::LogAdapter(p)
{ {
//cout << __FILE__rev << endl; //TANGO_LOG << __FILE__rev << endl;
} }
/* /*
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
#define UPDATE_THREAD_H #define UPDATE_THREAD_H
#include <omnithread.h> #include <omnithread.h>
#include <tango.h> #include <tango/tango.h>
#include <AlarmHandler.h> #include <AlarmHandler.h>
class update_thread : public omni_thread, public Tango::TangoMonitor, public Tango::LogAdapter { class update_thread : public omni_thread, public Tango::TangoMonitor, public Tango::LogAdapter {
......
cmake_minimum_required(VERSION 3.2) cmake_minimum_required(VERSION 3.8)
project(test NONE) project(test NONE)
include(ExternalProject) include(ExternalProject)
......
#! /usr/bin/env python
import re
import sys
import tango
if __name__ == "__main__":
device_name: str = ""
for arg in sys.argv:
word = "([a-z0-9._\-\*]*)"
wordpath = "([a-z0-9._\-\*/]*)"
m: (re.Match[str] | None) = re.compile("--device=" + word + "/{0,1}" + word + "/{0,1}" + word).match(arg.lower())
if m is not None:
domain: str = m.groups()[0]
family: str = m.groups()[1]
member: str = m.groups()[2]
if domain == "":
domain = "*"
if family == "":
family = "*"
if member == "":
member = "*"
device_name: str = f"{domain}/{family}/{member}"
try:
dev: tango.DeviceProxy = tango.DeviceProxy(device_name)
except (tango.DevFailed, tango.ConnectionFailed, tango.EventSystemFailed) as ex:
print(f"ERROR connecting proxy \"{device_name}\": {ex[0].desc}")
sys.exit(-1)
try:
admin_device_name: str = dev.adm_name()
admin_device = tango.DeviceProxy(admin_device_name)
except (tango.DevFailed, tango.ConnectionFailed, tango.EventSystemFailed) as ex:
print(f"ERROR connecting proxy \"{admin_device_name}\": {ex[0].desc}")
sys.exit(-1)
try:
admin_device.command_inout("RestartServer")
print("OK!")
except (tango.DevFailed, tango.ConnectionFailed, tango.EventSystemFailed) as ex:
print(f"ERROR: {ex[0].desc}")
sys.exit(-1)
if len(sys.argv) < 1:
print(f"Usage: {sys.argv[0]} --device=ALARM_HANDLER_TRL\n"
"Example:\n"
"\t{sys.argv[0]} --device=alarm/handler/01")
sys.exit(-1)
...@@ -76,11 +76,19 @@ target_include_directories(testdevice ...@@ -76,11 +76,19 @@ target_include_directories(testdevice
"${PROJECT_BINARY_DIR}" "${PROJECT_BINARY_DIR}"
) )
set_target_properties(testdevice if(NOT (CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang"))
PROPERTIES set_target_properties(testdevice
PROPERTIES
OUTPUT_NAME ${DEV_NAME} OUTPUT_NAME ${DEV_NAME}
LINK_FLAGS "-Wl,--no-undefined" LINK_FLAGS "-Wl,--no-undefined"
CXX_STANDARD 11) CXX_STANDARD 17)
else()
set_target_properties(testdevice
PROPERTIES
OUTPUT_NAME ${DEV_NAME}
LINK_FLAGS ""
CXX_STANDARD 17)
endif()
target_compile_options(testdevice target_compile_options(testdevice
PRIVATE "$<$<CONFIG:DEBUG>:-g>") PRIVATE "$<$<CONFIG:DEBUG>:-g>")
......
cmake_minimum_required(VERSION 3.2) cmake_minimum_required(VERSION 3.8)
# source files # source files
set(SRC_FILES ${SRC_FILES} set(SRC_FILES ${SRC_FILES}
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
//============================================================================= //=============================================================================
#include <tango.h> #include <tango/tango.h>
#include <TestDeviceClass.h> #include <TestDeviceClass.h>
// Add class header files if needed // Add class header files if needed
......
...@@ -1609,7 +1609,7 @@ void TestDevice::set_write_value(Tango::DevString value, string attrname) ...@@ -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) 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; //const Tango::DevVarLongArray *argin;
//extract(in_any, argin); //extract(in_any, argin);
......
...@@ -18,11 +18,21 @@ ...@@ -18,11 +18,21 @@
#define TestDevice_H #define TestDevice_H
#include <tango.h> #include <tango/tango.h>
#define MAX_ATTR_SIZE 3000 #define MAX_ATTR_SIZE 3000
#define MAX_SPECTRUM_SIZE 100 #define MAX_SPECTRUM_SIZE 100
#ifndef TANGO_LOG
#define TANGO_LOG cout
#endif
#ifndef TANGO_LOG_INFO
#define TANGO_LOG_INFO cout2
#endif
#ifndef TANGO_LOG_DEBUG
#define TANGO_LOG_DEBUG cout4
#endif
/*----- PROTECTED REGION END -----*/ /*----- PROTECTED REGION END -----*/
...@@ -34,6 +44,7 @@ ...@@ -34,6 +44,7 @@
namespace TestDevice_ns namespace TestDevice_ns
{ {
/*----- PROTECTED REGION ID(TestDevice::Additional Class Declarations) ENABLED START -----*/ /*----- PROTECTED REGION ID(TestDevice::Additional Class Declarations) ENABLED START -----*/
using namespace std;
// Additional Class Declarations // Additional Class Declarations
typedef struct { typedef struct {
...@@ -53,7 +64,6 @@ enum { typeDouble, typeLong, typeBool, typeString, typeUchar}; ...@@ -53,7 +64,6 @@ enum { typeDouble, typeLong, typeBool, typeString, typeUchar};
class TestDevice : public TANGO_BASE_CLASS class TestDevice : public TANGO_BASE_CLASS
{ {
friend class CmdClass; friend class CmdClass;
/*----- PROTECTED REGION ID(TestDevice::Data Members) ENABLED START -----*/ /*----- PROTECTED REGION ID(TestDevice::Data Members) ENABLED START -----*/
......
...@@ -60,7 +60,7 @@ TestDeviceClass *TestDeviceClass::_instance = NULL; ...@@ -60,7 +60,7 @@ TestDeviceClass *TestDeviceClass::_instance = NULL;
//-------------------------------------------------------- //--------------------------------------------------------
TestDeviceClass::TestDeviceClass(string &s):DeviceClass(s) TestDeviceClass::TestDeviceClass(string &s):DeviceClass(s)
{ {
cout2 << "Entering TestDeviceClass constructor" << endl; TANGO_LOG_INFO << "Entering TestDeviceClass constructor" << endl;
set_default_property(); set_default_property();
get_class_property(); get_class_property();
write_class_property(); write_class_property();
...@@ -69,7 +69,7 @@ TestDeviceClass::TestDeviceClass(string &s):DeviceClass(s) ...@@ -69,7 +69,7 @@ TestDeviceClass::TestDeviceClass(string &s):DeviceClass(s)
/*----- PROTECTED REGION END -----*/ // TestDevice::Class::constructor /*----- 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() ...@@ -151,7 +151,7 @@ TestDeviceClass *TestDeviceClass::instance()
//-------------------------------------------------------- //--------------------------------------------------------
CORBA::Any *WriteAttrnameClass::execute(Tango::DeviceImpl *device, const CORBA::Any &in_any) 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; const Tango::DevVarDoubleStringArray *argin;
extract(in_any, argin); extract(in_any, argin);
...@@ -172,7 +172,7 @@ CORBA::Any *WriteAttrnameClass::execute(Tango::DeviceImpl *device, const CORBA:: ...@@ -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) 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; const Tango::DevVarStringArray *argin;
extract(in_any, argin); extract(in_any, argin);
...@@ -192,7 +192,7 @@ CORBA::Any *ReadAttrnameClass::execute(Tango::DeviceImpl *device, const CORBA::A ...@@ -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) 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; const Tango::DevVarStringArray *argin;
extract(in_any, argin); extract(in_any, argin);
...@@ -213,7 +213,7 @@ CORBA::Any *ConfigClass::execute(Tango::DeviceImpl *device, const CORBA::Any &in ...@@ -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) 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; const Tango::DevVarStringArray *argin;
extract(in_any, argin); extract(in_any, argin);
...@@ -234,7 +234,7 @@ CORBA::Any *AddClass::execute(Tango::DeviceImpl *device, const CORBA::Any &in_an ...@@ -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) 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; const Tango::DevVarStringArray *argin;
extract(in_any, argin); extract(in_any, argin);
...@@ -255,7 +255,7 @@ CORBA::Any *AddDoubleClass::execute(Tango::DeviceImpl *device, const CORBA::Any ...@@ -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) 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; const Tango::DevVarStringArray *argin;
extract(in_any, argin); extract(in_any, argin);
...@@ -276,7 +276,7 @@ CORBA::Any *AddLongClass::execute(Tango::DeviceImpl *device, const CORBA::Any &i ...@@ -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) 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; const Tango::DevVarStringArray *argin;
extract(in_any, argin); extract(in_any, argin);
...@@ -297,7 +297,7 @@ CORBA::Any *AddBoolClass::execute(Tango::DeviceImpl *device, const CORBA::Any &i ...@@ -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) 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; const Tango::DevVarStringArray *argin;
extract(in_any, argin); extract(in_any, argin);
...@@ -318,7 +318,7 @@ CORBA::Any *AddStringClass::execute(Tango::DeviceImpl *device, const CORBA::Any ...@@ -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) 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; const Tango::DevVarStringArray *argin;
extract(in_any, argin); extract(in_any, argin);
...@@ -514,7 +514,7 @@ void TestDeviceClass::device_factory(const Tango::DevVarStringArray *devlist_ptr ...@@ -514,7 +514,7 @@ void TestDeviceClass::device_factory(const Tango::DevVarStringArray *devlist_ptr
// Create devices and add it into the device list // Create devices and add it into the device list
for (unsigned long i=0 ; i<devlist_ptr->length() ; i++) 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])); 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 ...@@ -695,7 +695,7 @@ void TestDeviceClass::create_static_attribute_list(vector<Tango::Attr *> &att_li
defaultAttList.push_back(att_name); 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 -----*/ /*----- PROTECTED REGION ID(TestDevice::Class::create_static_att_list) ENABLED START -----*/
...@@ -733,7 +733,7 @@ void TestDeviceClass::erase_dynamic_attributes(const Tango::DevVarStringArray *d ...@@ -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); vector<string>::iterator ite_str = find(defaultAttList.begin(), defaultAttList.end(), att_name);
if (ite_str == defaultAttList.end()) 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()); 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); dev->remove_attribute(att_list[att.get_attr_idx()],true);
--ite_att; --ite_att;
......