* add the autotools buildsystem
[diffractometer.git] / src / macros.h
blob15250191b12e13ae97b6758a14ebbc86e38c0011
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 XSTR(s) STR(s)
24 #define STR(s) #s
26 #define TANGO_EXCEPTION_RE_THROW_(tango_ex, b) do{\
27 std::string location(__FILE__);\
28 location += " line : ";\
29 location += XSTR(__LINE__);\
30 ERROR_STREAM << (b) << tango_ex << location;\
31 Tango::Except::re_throw_exception(tango_ex,\
32 static_cast<const char*>(b),\
33 static_cast<const char*>(""),\
34 static_cast<const char*>(location.c_str()));\
35 } while(0);
37 #define TANGO_EXCEPTION_RE_THROW_WITHOUT_LOG_(tango_ex, b) do{\
38 std::string location(__FILE__);\
39 location += " line : ";\
40 location += XSTR(__LINE__);\
41 Tango::Except::re_throw_exception(tango_ex,\
42 static_cast<const char*>(b),\
43 static_cast<const char*>(""),\
44 static_cast<const char*>(location.c_str()));\
45 } while(0);
47 #define TANGO_EXCEPTION_THROW(a,b) do {\
48 std::string location(__FILE__);\
49 location += " line : ";\
50 location += XSTR(__LINE__);\
51 ERROR_STREAM << (a) << (b) << location;\
52 Tango::Except::throw_exception(static_cast<const char*>((a)),\
53 static_cast<const char *>((b)),\
54 static_cast<const char *>(location.c_str()));\
55 } while(0);
57 #define TANGO_EXCEPTION_THROW_WITHOUT_LOG(a,b) do {\
58 std::string location(__FILE__);\
59 location += " line : ";\
60 location += XSTR(__LINE__);\
61 Tango::Except::throw_exception(static_cast<const char*>((a)),\
62 static_cast<const char *>((b)),\
63 static_cast<const char *>(location.c_str()));\
64 } while(0);
66 #define TANGO_EXCEPTION_RE_THROW(tango_ex) do{\
67 TANGO_EXCEPTION_RE_THROW_(tango_ex, "TANGO_ERROR");\
68 } while(0);
70 inline void compose_state(Tango::DevState & state, Tango::DevState const & axe_state)
72 switch(axe_state) {
73 case Tango::OFF:
74 if (state == Tango::MOVING || state == Tango::STANDBY)
75 state = Tango::OFF;
76 break;
77 case Tango::MOVING:
78 if (state == Tango::STANDBY)
79 state = Tango::MOVING;
80 break;
81 case Tango::FAULT:
82 state = Tango::FAULT;
83 break;
84 default:
85 break;
89 #endif // _MACROS_H