author | laurent |
Fri, 02 Sep 2011 18:16:33 +0200 | |
changeset 348 | 990ecb883731 |
parent 327 | da78d0d93c75 |
child 350 | 2c3c4dc34979 |
permissions | -rwxr-xr-x |
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 |
|
221
c6aed7e5f070
Adding support for flags on Function Block variables for marking which variable must be debugged, retained or is forced
laurent
parents:
199
diff
changeset
|
13 |
#define TRUE 1 |
c6aed7e5f070
Adding support for flags on Function Block variables for marking which variable must be debugged, retained or is forced
laurent
parents:
199
diff
changeset
|
14 |
#define FALSE 0 |
c6aed7e5f070
Adding support for flags on Function Block variables for marking which variable must be debugged, retained or is forced
laurent
parents:
199
diff
changeset
|
15 |
|
224 | 16 |
#define __IEC_DEBUG_FLAG 0x01 |
17 |
#define __IEC_FORCE_FLAG 0x02 |
|
18 |
#define __IEC_RETAIN_FLAG 0x04 |
|
301
15bf9ecb936d
Added __IEC_OUTPUT_FLAG, to mark variable whose forcing implies refresh on eache cycle.
Edouard Tisserant
parents:
246
diff
changeset
|
19 |
#define __IEC_OUTPUT_FLAG 0x08 |
222 | 20 |
|
221
c6aed7e5f070
Adding support for flags on Function Block variables for marking which variable must be debugged, retained or is forced
laurent
parents:
199
diff
changeset
|
21 |
#define __DECLARE_IEC_TYPE(type)\ |
c6aed7e5f070
Adding support for flags on Function Block variables for marking which variable must be debugged, retained or is forced
laurent
parents:
199
diff
changeset
|
22 |
typedef IEC_##type type;\ |
c6aed7e5f070
Adding support for flags on Function Block variables for marking which variable must be debugged, retained or is forced
laurent
parents:
199
diff
changeset
|
23 |
\ |
c6aed7e5f070
Adding support for flags on Function Block variables for marking which variable must be debugged, retained or is forced
laurent
parents:
199
diff
changeset
|
24 |
typedef struct {\ |
c6aed7e5f070
Adding support for flags on Function Block variables for marking which variable must be debugged, retained or is forced
laurent
parents:
199
diff
changeset
|
25 |
IEC_##type value;\ |
c6aed7e5f070
Adding support for flags on Function Block variables for marking which variable must be debugged, retained or is forced
laurent
parents:
199
diff
changeset
|
26 |
IEC_BYTE flags;\ |
c6aed7e5f070
Adding support for flags on Function Block variables for marking which variable must be debugged, retained or is forced
laurent
parents:
199
diff
changeset
|
27 |
} __IEC_##type##_t;\ |
c6aed7e5f070
Adding support for flags on Function Block variables for marking which variable must be debugged, retained or is forced
laurent
parents:
199
diff
changeset
|
28 |
\ |
c6aed7e5f070
Adding support for flags on Function Block variables for marking which variable must be debugged, retained or is forced
laurent
parents:
199
diff
changeset
|
29 |
typedef struct {\ |
c6aed7e5f070
Adding support for flags on Function Block variables for marking which variable must be debugged, retained or is forced
laurent
parents:
199
diff
changeset
|
30 |
IEC_##type *value;\ |
c6aed7e5f070
Adding support for flags on Function Block variables for marking which variable must be debugged, retained or is forced
laurent
parents:
199
diff
changeset
|
31 |
IEC_BYTE flags;\ |
c6aed7e5f070
Adding support for flags on Function Block variables for marking which variable must be debugged, retained or is forced
laurent
parents:
199
diff
changeset
|
32 |
IEC_##type fvalue;\ |
c6aed7e5f070
Adding support for flags on Function Block variables for marking which variable must be debugged, retained or is forced
laurent
parents:
199
diff
changeset
|
33 |
} __IEC_##type##_p; |
c6aed7e5f070
Adding support for flags on Function Block variables for marking which variable must be debugged, retained or is forced
laurent
parents:
199
diff
changeset
|
34 |
|
327 | 35 |
#define __DECLARE_DERIVED_TYPE(type, base)\ |
221
c6aed7e5f070
Adding support for flags on Function Block variables for marking which variable must be debugged, retained or is forced
laurent
parents:
199
diff
changeset
|
36 |
typedef base type;\ |
c6aed7e5f070
Adding support for flags on Function Block variables for marking which variable must be debugged, retained or is forced
laurent
parents:
199
diff
changeset
|
37 |
typedef __IEC_##base##_t __IEC_##type##_t; |
c6aed7e5f070
Adding support for flags on Function Block variables for marking which variable must be debugged, retained or is forced
laurent
parents:
199
diff
changeset
|
38 |
|
c6aed7e5f070
Adding support for flags on Function Block variables for marking which variable must be debugged, retained or is forced
laurent
parents:
199
diff
changeset
|
39 |
#define __DECLARE_COMPLEX_STRUCT(type)\ |
c6aed7e5f070
Adding support for flags on Function Block variables for marking which variable must be debugged, retained or is forced
laurent
parents:
199
diff
changeset
|
40 |
typedef struct {\ |
c6aed7e5f070
Adding support for flags on Function Block variables for marking which variable must be debugged, retained or is forced
laurent
parents:
199
diff
changeset
|
41 |
type value;\ |
c6aed7e5f070
Adding support for flags on Function Block variables for marking which variable must be debugged, retained or is forced
laurent
parents:
199
diff
changeset
|
42 |
IEC_BYTE flags;\ |
c6aed7e5f070
Adding support for flags on Function Block variables for marking which variable must be debugged, retained or is forced
laurent
parents:
199
diff
changeset
|
43 |
} __IEC_##type##_t;\ |
c6aed7e5f070
Adding support for flags on Function Block variables for marking which variable must be debugged, retained or is forced
laurent
parents:
199
diff
changeset
|
44 |
\ |
c6aed7e5f070
Adding support for flags on Function Block variables for marking which variable must be debugged, retained or is forced
laurent
parents:
199
diff
changeset
|
45 |
typedef struct {\ |
c6aed7e5f070
Adding support for flags on Function Block variables for marking which variable must be debugged, retained or is forced
laurent
parents:
199
diff
changeset
|
46 |
type *value;\ |
c6aed7e5f070
Adding support for flags on Function Block variables for marking which variable must be debugged, retained or is forced
laurent
parents:
199
diff
changeset
|
47 |
IEC_BYTE flags;\ |
c6aed7e5f070
Adding support for flags on Function Block variables for marking which variable must be debugged, retained or is forced
laurent
parents:
199
diff
changeset
|
48 |
} __IEC_##type##_p; |
c6aed7e5f070
Adding support for flags on Function Block variables for marking which variable must be debugged, retained or is forced
laurent
parents:
199
diff
changeset
|
49 |
|
327 | 50 |
#define __DECLARE_ENUMERATED_TYPE(type, ...)\ |
51 |
typedef enum {\ |
|
52 |
__VA_ARGS__\ |
|
53 |
} type;\ |
|
54 |
__DECLARE_COMPLEX_STRUCT(type) |
|
55 |
||
56 |
#define __DECLARE_ARRAY_TYPE(type, base, size)\ |
|
237 | 57 |
typedef struct {\ |
58 |
base table size;\ |
|
59 |
} type;\ |
|
327 | 60 |
__DECLARE_COMPLEX_STRUCT(type) |
221
c6aed7e5f070
Adding support for flags on Function Block variables for marking which variable must be debugged, retained or is forced
laurent
parents:
199
diff
changeset
|
61 |
|
327 | 62 |
#define __DECLARE_STRUCT_TYPE(type, elements)\ |
63 |
typedef struct {\ |
|
64 |
elements\ |
|
65 |
} type;\ |
|
66 |
__DECLARE_COMPLEX_STRUCT(type) |
|
221
c6aed7e5f070
Adding support for flags on Function Block variables for marking which variable must be debugged, retained or is forced
laurent
parents:
199
diff
changeset
|
67 |
|
137
9ceda59abd27
Re-organized types headers, to ease debug code generation
etisserant
parents:
diff
changeset
|
68 |
/* Those typdefs clash with windows.h */ |
9ceda59abd27
Re-organized types headers, to ease debug code generation
etisserant
parents:
diff
changeset
|
69 |
/* i.e. this file cannot be included aside windows.h */ |
221
c6aed7e5f070
Adding support for flags on Function Block variables for marking which variable must be debugged, retained or is forced
laurent
parents:
199
diff
changeset
|
70 |
ANY(__DECLARE_IEC_TYPE) |
c6aed7e5f070
Adding support for flags on Function Block variables for marking which variable must be debugged, retained or is forced
laurent
parents:
199
diff
changeset
|
71 |
|
137
9ceda59abd27
Re-organized types headers, to ease debug code generation
etisserant
parents:
diff
changeset
|
72 |
typedef struct { |
221
c6aed7e5f070
Adding support for flags on Function Block variables for marking which variable must be debugged, retained or is forced
laurent
parents:
199
diff
changeset
|
73 |
__IEC_BOOL_t state; // current step state. 0 : inative, 1: active |
137
9ceda59abd27
Re-organized types headers, to ease debug code generation
etisserant
parents:
diff
changeset
|
74 |
BOOL prev_state; // previous step state. 0 : inative, 1: active |
9ceda59abd27
Re-organized types headers, to ease debug code generation
etisserant
parents:
diff
changeset
|
75 |
TIME elapsed_time; // time since step is active |
9ceda59abd27
Re-organized types headers, to ease debug code generation
etisserant
parents:
diff
changeset
|
76 |
} STEP; |
9ceda59abd27
Re-organized types headers, to ease debug code generation
etisserant
parents:
diff
changeset
|
77 |
|
9ceda59abd27
Re-organized types headers, to ease debug code generation
etisserant
parents:
diff
changeset
|
78 |
typedef struct { |
9ceda59abd27
Re-organized types headers, to ease debug code generation
etisserant
parents:
diff
changeset
|
79 |
BOOL stored; // action storing state. 0 : not stored, 1: stored |
9ceda59abd27
Re-organized types headers, to ease debug code generation
etisserant
parents:
diff
changeset
|
80 |
BOOL state; // current action state. 0 : inative, 1: active |
9ceda59abd27
Re-organized types headers, to ease debug code generation
etisserant
parents:
diff
changeset
|
81 |
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
|
82 |
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
|
83 |
TIME set_remaining_time; // time before set will be requested |
9ceda59abd27
Re-organized types headers, to ease debug code generation
etisserant
parents:
diff
changeset
|
84 |
TIME reset_remaining_time; // time before reset will be requested |
9ceda59abd27
Re-organized types headers, to ease debug code generation
etisserant
parents:
diff
changeset
|
85 |
} ACTION; |
9ceda59abd27
Re-organized types headers, to ease debug code generation
etisserant
parents:
diff
changeset
|
86 |
|
9ceda59abd27
Re-organized types headers, to ease debug code generation
etisserant
parents:
diff
changeset
|
87 |
/* Extra debug types for SFC */ |
9ceda59abd27
Re-organized types headers, to ease debug code generation
etisserant
parents:
diff
changeset
|
88 |
#define ANY_SFC(DO) DO(STEP) DO(TRANSITION) DO(ACTION) |
9ceda59abd27
Re-organized types headers, to ease debug code generation
etisserant
parents:
diff
changeset
|
89 |
|
9ceda59abd27
Re-organized types headers, to ease debug code generation
etisserant
parents:
diff
changeset
|
90 |
/* Enumerate native types */ |
9ceda59abd27
Re-organized types headers, to ease debug code generation
etisserant
parents:
diff
changeset
|
91 |
#define __decl_enum_type(TYPENAME) TYPENAME##_ENUM, |
224 | 92 |
#define __decl_enum_pointer(TYPENAME) TYPENAME##_P_ENUM, |
235 | 93 |
#define __decl_enum_output(TYPENAME) TYPENAME##_O_ENUM, |
137
9ceda59abd27
Re-organized types headers, to ease debug code generation
etisserant
parents:
diff
changeset
|
94 |
typedef enum{ |
9ceda59abd27
Re-organized types headers, to ease debug code generation
etisserant
parents:
diff
changeset
|
95 |
ANY(__decl_enum_type) |
224 | 96 |
ANY(__decl_enum_pointer) |
235 | 97 |
ANY(__decl_enum_output) |
224 | 98 |
/* SFC specific types are never external or global */ |
99 |
UNKNOWN_ENUM |
|
137
9ceda59abd27
Re-organized types headers, to ease debug code generation
etisserant
parents:
diff
changeset
|
100 |
} __IEC_types_enum; |
9ceda59abd27
Re-organized types headers, to ease debug code generation
etisserant
parents:
diff
changeset
|
101 |
|
9ceda59abd27
Re-organized types headers, to ease debug code generation
etisserant
parents:
diff
changeset
|
102 |
/* Get size of type from its number */ |
224 | 103 |
#define __decl_size_case(TYPENAME) \ |
104 |
case TYPENAME##_ENUM:\ |
|
246
e8b5b163804d
A forgotten case in type size getter switch prevented debugging outputs.
edouard
parents:
237
diff
changeset
|
105 |
case TYPENAME##_O_ENUM:\ |
224 | 106 |
case TYPENAME##_P_ENUM:\ |
107 |
return sizeof(TYPENAME); |
|
137
9ceda59abd27
Re-organized types headers, to ease debug code generation
etisserant
parents:
diff
changeset
|
108 |
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
|
109 |
switch(t){ |
9ceda59abd27
Re-organized types headers, to ease debug code generation
etisserant
parents:
diff
changeset
|
110 |
ANY(__decl_size_case) |
9ceda59abd27
Re-organized types headers, to ease debug code generation
etisserant
parents:
diff
changeset
|
111 |
/* size do not correspond to real struct. |
9ceda59abd27
Re-organized types headers, to ease debug code generation
etisserant
parents:
diff
changeset
|
112 |
* only a bool is used to represent state*/ |
224 | 113 |
default: |
114 |
return 0; |
|
137
9ceda59abd27
Re-organized types headers, to ease debug code generation
etisserant
parents:
diff
changeset
|
115 |
} |
199
b075f28ec081
Bug with type conversion EN/ENO not evaluated fixed
laurent
parents:
137
diff
changeset
|
116 |
return 0; |
137
9ceda59abd27
Re-organized types headers, to ease debug code generation
etisserant
parents:
diff
changeset
|
117 |
} |
9ceda59abd27
Re-organized types headers, to ease debug code generation
etisserant
parents:
diff
changeset
|
118 |
|
9ceda59abd27
Re-organized types headers, to ease debug code generation
etisserant
parents:
diff
changeset
|
119 |
#endif /*IEC_TYPES_ALL_H*/ |