|
1 #ifndef IEC_TYPES_ALL_H |
|
2 #define IEC_TYPES_ALL_H |
|
3 |
|
4 #include "iec_std_lib_generated.h" |
|
5 |
|
6 /*********************/ |
|
7 /* IEC Types defs */ |
|
8 /*********************/ |
|
9 |
|
10 /* Include non windows.h clashing typedefs */ |
|
11 #include "iec_types.h" |
|
12 |
|
13 /* Those typdefs clash with windows.h */ |
|
14 /* i.e. this file cannot be included aside windows.h */ |
|
15 typedef IEC_BOOL BOOL; |
|
16 |
|
17 #define TRUE 1 |
|
18 #define FALSE 0 |
|
19 |
|
20 typedef IEC_SINT SINT; |
|
21 typedef IEC_INT INT; |
|
22 typedef IEC_DINT DINT; |
|
23 typedef IEC_LINT LINT; |
|
24 |
|
25 typedef IEC_USINT USINT; |
|
26 typedef IEC_UINT UINT; |
|
27 typedef IEC_UDINT UDINT; |
|
28 typedef IEC_ULINT ULINT; |
|
29 |
|
30 typedef IEC_BYTE BYTE; |
|
31 typedef IEC_WORD WORD; |
|
32 typedef IEC_DWORD DWORD; |
|
33 typedef IEC_LWORD LWORD; |
|
34 |
|
35 typedef IEC_REAL REAL; |
|
36 typedef IEC_LREAL LREAL; |
|
37 |
|
38 typedef IEC_TIME TIME; |
|
39 typedef IEC_DATE DATE; |
|
40 typedef IEC_DT DT; |
|
41 typedef IEC_TOD TOD; |
|
42 |
|
43 typedef IEC_STRING STRING; |
|
44 |
|
45 typedef struct { |
|
46 BOOL state; // current step state. 0 : inative, 1: active |
|
47 BOOL prev_state; // previous step state. 0 : inative, 1: active |
|
48 TIME elapsed_time; // time since step is active |
|
49 } STEP; |
|
50 |
|
51 typedef struct { |
|
52 BOOL stored; // action storing state. 0 : not stored, 1: stored |
|
53 BOOL state; // current action state. 0 : inative, 1: active |
|
54 BOOL set; // set have been requested (reset each time the body is evaluated) |
|
55 BOOL reset; // reset have been requested (reset each time the body is evaluated) |
|
56 TIME set_remaining_time; // time before set will be requested |
|
57 TIME reset_remaining_time; // time before reset will be requested |
|
58 } ACTION; |
|
59 |
|
60 /* Extra debug types for SFC */ |
|
61 #define ANY_SFC(DO) DO(STEP) DO(TRANSITION) DO(ACTION) |
|
62 |
|
63 /* Enumerate native types */ |
|
64 #define __decl_enum_type(TYPENAME) TYPENAME##_ENUM, |
|
65 typedef enum{ |
|
66 ANY(__decl_enum_type) |
|
67 ANY_SFC(__decl_enum_type) |
|
68 /*TODO handle custom types*/ |
|
69 } __IEC_types_enum; |
|
70 |
|
71 /* Get size of type from its number */ |
|
72 #define __decl_size_case(TYPENAME) case TYPENAME##_ENUM: return sizeof(TYPENAME); |
|
73 #define __decl_size_case_force_BOOL(TYPENAME) case TYPENAME##_ENUM: return sizeof(BOOL); |
|
74 static inline USINT __get_type_enum_size(__IEC_types_enum t){ |
|
75 switch(t){ |
|
76 ANY(__decl_size_case) |
|
77 /* size do not correspond to real struct. |
|
78 * only a bool is used to represent state*/ |
|
79 ANY_SFC(__decl_size_case_force_BOOL) |
|
80 /*TODO handle custom types*/ |
|
81 } |
|
82 } |
|
83 |
|
84 /* Get name of type from its number */ |
|
85 #define __decl_typename_case(TYPENAME) case TYPENAME##_ENUM: return #TYPENAME ; |
|
86 static inline const char* __get_type_enum_name(__IEC_types_enum t){ |
|
87 switch(t){ |
|
88 ANY(__decl_typename_case) |
|
89 /* size do not correspond to real struct. |
|
90 * only a bool is used to represent state*/ |
|
91 ANY_SFC(__decl_typename_case) |
|
92 /*TODO handle custom types*/ |
|
93 } |
|
94 } |
|
95 |
|
96 |
|
97 #endif /*IEC_TYPES_ALL_H*/ |