Merge branch 'maint' into next
[diffractometer.git] / src / macros.h
blob1c6446bd452c970ff28a8bb9ee2bf54389f0331b
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 // version of the save/load format method
21 #define FORMAT_VERSION 1
23 #define AVAILABLE_DIFFRACTOMETER_TYPE "2CV, E4CV, K4CV, E6C, K6C, ZAXIS"
25 #define XSTR(s) STR(s)
26 #define STR(s) #s
28 #define TANGO_EXCEPTION_RE_THROW_(tango_ex, b) do{\
29 std::string location(__FILE__);\
30 location += " line : ";\
31 location += XSTR(__LINE__);\
32 ERROR_STREAM << (b) << tango_ex << location;\
33 Tango::Except::re_throw_exception(tango_ex,\
34 static_cast<const char*>(b),\
35 static_cast<const char*>(""),\
36 static_cast<const char*>(location.c_str()));\
37 } while(0);
39 #define TANGO_EXCEPTION_RE_THROW_WITHOUT_LOG_(tango_ex, b) do{\
40 std::string location(__FILE__);\
41 location += " line : ";\
42 location += XSTR(__LINE__);\
43 Tango::Except::re_throw_exception(tango_ex,\
44 static_cast<const char*>(b),\
45 static_cast<const char*>(""),\
46 static_cast<const char*>(location.c_str()));\
47 } while(0);
49 #define TANGO_EXCEPTION_THROW(a,b) do {\
50 std::string location(__FILE__);\
51 location += " line : ";\
52 location += XSTR(__LINE__);\
53 ERROR_STREAM << (a) << (b) << location;\
54 Tango::Except::throw_exception(static_cast<const char*>((a)),\
55 static_cast<const char *>((b)),\
56 static_cast<const char *>(location.c_str()));\
57 } while(0);
59 #define TANGO_EXCEPTION_THROW_WITHOUT_LOG(a,b) do {\
60 std::string location(__FILE__);\
61 location += " line : ";\
62 location += XSTR(__LINE__);\
63 Tango::Except::throw_exception(static_cast<const char*>((a)),\
64 static_cast<const char *>((b)),\
65 static_cast<const char *>(location.c_str()));\
66 } while(0);
68 #define TANGO_EXCEPTION_RE_THROW(tango_ex) do{\
69 TANGO_EXCEPTION_RE_THROW_(tango_ex, "TANGO_ERROR");\
70 } while(0);
72 inline void compose_state(Tango::DevState & state, Tango::DevState const & axe_state)
74 switch(axe_state) {
75 case Tango::OFF:
76 if (state == Tango::MOVING || state == Tango::STANDBY)
77 state = Tango::OFF;
78 break;
79 case Tango::MOVING:
80 if (state == Tango::STANDBY)
81 state = Tango::MOVING;
82 break;
83 case Tango::FAULT:
84 state = Tango::FAULT;
85 break;
86 default:
87 break;
91 #endif // _MACROS_H