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