|
1 /* |
|
2 * Copyright (C) 2007-2011: Edouard TISSERANT and Laurent BESSARD |
|
3 * |
|
4 * See COPYING and COPYING.LESSER files for copyright details. |
|
5 * |
|
6 * This library is free software; you can redistribute it and/or |
|
7 * modify it under the terms of the GNU Lesser General Public |
|
8 * License as published by the Free Software Foundation; either |
|
9 * version 3 of the License, or (at your option) any later version. |
|
10 * |
|
11 * This library is distributed in the hope that it will be useful, |
|
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
14 * Lesser General Public License for more details. |
|
15 * |
|
16 * You should have received a copy of the GNU Lesser General Public License |
|
17 * along with this library. If not, see <http://www.gnu.org/licenses/>. |
|
18 * |
|
19 */ |
|
20 |
1 #ifndef IEC_TYPES_ALL_H |
21 #ifndef IEC_TYPES_ALL_H |
2 #define IEC_TYPES_ALL_H |
22 #define IEC_TYPES_ALL_H |
3 |
23 |
4 #include "iec_std_lib_generated.h" |
24 |
|
25 /* Macro that expand to subtypes */ |
|
26 #define __ANY(DO) __ANY_DERIVED(DO) __ANY_ELEMENTARY(DO) |
|
27 #define __ANY_DERIVED(DO) |
|
28 #define __ANY_ELEMENTARY(DO) __ANY_MAGNITUDE(DO) __ANY_BIT(DO) __ANY_STRING(DO) __ANY_DATE(DO) |
|
29 #define __ANY_MAGNITUDE(DO) __ANY_NUM(DO) DO(TIME) |
|
30 #define __ANY_BIT(DO) __ANY_NBIT(DO) DO(BOOL) |
|
31 #define __ANY_NBIT(DO) DO(BYTE) DO(WORD) DO(DWORD) DO(LWORD) |
|
32 #define __ANY_STRING(DO) DO(STRING) |
|
33 #define __ANY_DATE(DO) DO(DATE) DO(TOD) DO(DT) |
|
34 #define __ANY_NUM(DO) __ANY_REAL(DO) __ANY_INT(DO) |
|
35 #define __ANY_REAL(DO) DO(REAL) DO(LREAL) |
|
36 #define __ANY_INT(DO) __ANY_SINT(DO) __ANY_UINT(DO) |
|
37 #define __ANY_SINT(DO) DO(SINT) DO(INT) DO(DINT) DO(LINT) |
|
38 #define __ANY_UINT(DO) DO(USINT) DO(UINT) DO(UDINT) DO(ULINT) |
|
39 |
|
40 |
|
41 /* Macro that expand to subtypes */ |
|
42 #define __ANY_1(DO,P1) __ANY_DERIVED_1(DO,P1) __ANY_ELEMENTARY_1(DO,P1) |
|
43 #define __ANY_DERIVED_1(DO,P1) |
|
44 #define __ANY_ELEMENTARY_1(DO,P1) __ANY_MAGNITUDE_1(DO,P1) __ANY_BIT_1(DO,P1) __ANY_STRING_1(DO,P1) __ANY_DATE_1(DO,P1) |
|
45 #define __ANY_MAGNITUDE_1(DO,P1) __ANY_NUM_1(DO,P1) DO(TIME,P1) |
|
46 #define __ANY_BIT_1(DO,P1) __ANY_NBIT_1(DO,P1) DO(BOOL,P1) |
|
47 #define __ANY_NBIT_1(DO,P1) DO(BYTE,P1) DO(WORD,P1) DO(DWORD,P1) DO(LWORD,P1) |
|
48 #define __ANY_STRING_1(DO,P1) DO(STRING,P1) |
|
49 #define __ANY_DATE_1(DO,P1) DO(DATE,P1) DO(TOD,P1) DO(DT,P1) |
|
50 #define __ANY_NUM_1(DO,P1) __ANY_REAL_1(DO,P1) __ANY_INT_1(DO,P1) |
|
51 #define __ANY_REAL_1(DO,P1) DO(REAL,P1) DO(LREAL,P1) |
|
52 #define __ANY_INT_1(DO,P1) __ANY_SINT_1(DO,P1) __ANY_UINT_1(DO,P1) |
|
53 #define __ANY_SINT_1(DO,P1) DO(SINT,P1) DO(INT,P1) DO(DINT,P1) DO(LINT,P1) |
|
54 #define __ANY_UINT_1(DO,P1) DO(USINT,P1) DO(UINT,P1) DO(UDINT,P1) DO(ULINT,P1) |
|
55 |
|
56 |
5 |
57 |
6 /*********************/ |
58 /*********************/ |
7 /* IEC Types defs */ |
59 /* IEC Types defs */ |
8 /*********************/ |
60 /*********************/ |
9 |
61 |
65 } type;\ |
117 } type;\ |
66 __DECLARE_COMPLEX_STRUCT(type) |
118 __DECLARE_COMPLEX_STRUCT(type) |
67 |
119 |
68 /* Those typdefs clash with windows.h */ |
120 /* Those typdefs clash with windows.h */ |
69 /* i.e. this file cannot be included aside windows.h */ |
121 /* i.e. this file cannot be included aside windows.h */ |
70 ANY(__DECLARE_IEC_TYPE) |
122 __ANY(__DECLARE_IEC_TYPE) |
71 |
123 |
72 typedef struct { |
124 typedef struct { |
73 __IEC_BOOL_t state; // current step state. 0 : inative, 1: active |
125 __IEC_BOOL_t state; // current step state. 0 : inative, 1: active |
74 BOOL prev_state; // previous step state. 0 : inative, 1: active |
126 BOOL prev_state; // previous step state. 0 : inative, 1: active |
75 TIME elapsed_time; // time since step is active |
127 TIME elapsed_time; // time since step is active |
83 TIME set_remaining_time; // time before set will be requested |
135 TIME set_remaining_time; // time before set will be requested |
84 TIME reset_remaining_time; // time before reset will be requested |
136 TIME reset_remaining_time; // time before reset will be requested |
85 } ACTION; |
137 } ACTION; |
86 |
138 |
87 /* Extra debug types for SFC */ |
139 /* Extra debug types for SFC */ |
88 #define ANY_SFC(DO) DO(STEP) DO(TRANSITION) DO(ACTION) |
140 #define __ANY_SFC(DO) DO(STEP) DO(TRANSITION) DO(ACTION) |
89 |
141 |
90 /* Enumerate native types */ |
142 /* Enumerate native types */ |
91 #define __decl_enum_type(TYPENAME) TYPENAME##_ENUM, |
143 #define __decl_enum_type(TYPENAME) TYPENAME##_ENUM, |
92 #define __decl_enum_pointer(TYPENAME) TYPENAME##_P_ENUM, |
144 #define __decl_enum_pointer(TYPENAME) TYPENAME##_P_ENUM, |
93 #define __decl_enum_output(TYPENAME) TYPENAME##_O_ENUM, |
145 #define __decl_enum_output(TYPENAME) TYPENAME##_O_ENUM, |
94 typedef enum{ |
146 typedef enum{ |
95 ANY(__decl_enum_type) |
147 __ANY(__decl_enum_type) |
96 ANY(__decl_enum_pointer) |
148 __ANY(__decl_enum_pointer) |
97 ANY(__decl_enum_output) |
149 __ANY(__decl_enum_output) |
98 /* SFC specific types are never external or global */ |
150 /* SFC specific types are never external or global */ |
99 UNKNOWN_ENUM |
151 UNKNOWN_ENUM |
100 } __IEC_types_enum; |
152 } __IEC_types_enum; |
101 |
153 |
102 /* Get size of type from its number */ |
154 /* Get size of type from its number */ |