* add an optional printout for test
[diffractometer.git] / src / macros.h
blob7900151c5a0fa7b30214850beec89e0de3f36b1e
1 #ifndef _MACROS_H
2 #define _MACROS_H
4 #include <tango.h>
6 #ifdef _MSC_VER
7 # define strtok_r strtok_s
8 # define snprintf _snprintf
9 # define strcasecmp _stricmp
10 #endif
12 #define AXIS_ATTRIBUTE_POSITION_NAME "position"
13 #define AXIS_COMMAND_STOP_NAME "Stop"
15 #define MAX_LENGTH_COMPUTED_ANGLES 1000
17 // Comment the next line to forbide the proxy write part
18 #define WRITE_TO_PROXY_ALLOWED
20 #define XSTR(s) STR(s)
21 #define STR(s) #s
23 #define TANGO_EXCEPTION_RE_THROW_(tango_ex, b) do{\
24 std::string location(__FILE__);\
25 location += " line : ";\
26 location += XSTR(__LINE__);\
27 ERROR_STREAM << (b) << tango_ex << location;\
28 Tango::Except::re_throw_exception(tango_ex,\
29 static_cast<const char*>(b),\
30 static_cast<const char*>(""),\
31 static_cast<const char*>(location.c_str()));\
32 } while(0);
34 #define TANGO_EXCEPTION_RE_THROW_WITHOUT_LOG_(tango_ex, b) do{\
35 std::string location(__FILE__);\
36 location += " line : ";\
37 location += XSTR(__LINE__);\
38 Tango::Except::re_throw_exception(tango_ex,\
39 static_cast<const char*>(b),\
40 static_cast<const char*>(""),\
41 static_cast<const char*>(location.c_str()));\
42 } while(0);
44 #define TANGO_EXCEPTION_THROW(a,b) do {\
45 std::string location(__FILE__);\
46 location += " line : ";\
47 location += XSTR(__LINE__);\
48 ERROR_STREAM << (a) << (b) << location;\
49 Tango::Except::throw_exception(static_cast<const char*>((a)),\
50 static_cast<const char *>((b)),\
51 static_cast<const char *>(location.c_str()));\
52 } while(0);
54 #define TANGO_EXCEPTION_THROW_WITHOUT_LOG(a,b) do {\
55 std::string location(__FILE__);\
56 location += " line : ";\
57 location += XSTR(__LINE__);\
58 Tango::Except::throw_exception(static_cast<const char*>((a)),\
59 static_cast<const char *>((b)),\
60 static_cast<const char *>(location.c_str()));\
61 } while(0);
63 #define TANGO_EXCEPTION_RE_THROW(tango_ex) do{\
64 TANGO_EXCEPTION_RE_THROW_(tango_ex, "TANGO_ERROR");\
65 } while(0);
67 inline void compose_state(Tango::DevState & state, Tango::DevState const & axe_state)
69 switch(axe_state) {
70 case Tango::OFF:
71 if (state == Tango::MOVING || state == Tango::STANDBY)
72 state = Tango::OFF;
73 break;
74 case Tango::MOVING:
75 if (state == Tango::STANDBY)
76 state = Tango::MOVING;
77 break;
78 case Tango::FAULT:
79 state = Tango::FAULT;
80 break;
81 default:
82 break;
86 #endif // _MACROS_H