author | laurent |
Sat, 12 Dec 2009 20:41:32 +0100 | |
changeset 233 | 3d23a68183d3 |
parent 227 | 560c1231ad1f |
child 235 | ed66dc50f31a |
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 |
|
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 |
|
222 | 19 |
|
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
|
20 |
#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
|
21 |
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
|
22 |
\ |
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 |
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
|
24 |
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
|
25 |
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
|
26 |
} __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
|
27 |
\ |
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 |
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
|
29 |
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
|
30 |
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
|
31 |
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
|
32 |
} __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
|
33 |
|
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 |
#define __DECLARE_DERIVED_TYPE(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
|
35 |
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
|
36 |
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
|
37 |
|
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 |
#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
|
39 |
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
|
40 |
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
|
41 |
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
|
42 |
} __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
|
43 |
\ |
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 |
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
|
45 |
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
|
46 |
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
|
47 |
} __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
|
48 |
|
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 |
#define __DECLARE_ARRAY_TYPE(base, type, size)\ |
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
|
50 |
typedef base type size;\ |
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
|
51 |
__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
|
52 |
|
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
|
53 |
#define __DECLARE_STRUCT_TYPE(elements, 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
|
54 |
typedef elements 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
|
55 |
__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
|
56 |
|
137
9ceda59abd27
Re-organized types headers, to ease debug code generation
etisserant
parents:
diff
changeset
|
57 |
/* Those typdefs clash with windows.h */ |
9ceda59abd27
Re-organized types headers, to ease debug code generation
etisserant
parents:
diff
changeset
|
58 |
/* 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
|
59 |
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
|
60 |
|
137
9ceda59abd27
Re-organized types headers, to ease debug code generation
etisserant
parents:
diff
changeset
|
61 |
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
|
62 |
__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
|
63 |
BOOL prev_state; // previous step state. 0 : inative, 1: active |
9ceda59abd27
Re-organized types headers, to ease debug code generation
etisserant
parents:
diff
changeset
|
64 |
TIME elapsed_time; // time since step is active |
9ceda59abd27
Re-organized types headers, to ease debug code generation
etisserant
parents:
diff
changeset
|
65 |
} STEP; |
9ceda59abd27
Re-organized types headers, to ease debug code generation
etisserant
parents:
diff
changeset
|
66 |
|
9ceda59abd27
Re-organized types headers, to ease debug code generation
etisserant
parents:
diff
changeset
|
67 |
typedef struct { |
9ceda59abd27
Re-organized types headers, to ease debug code generation
etisserant
parents:
diff
changeset
|
68 |
BOOL stored; // action storing state. 0 : not stored, 1: stored |
9ceda59abd27
Re-organized types headers, to ease debug code generation
etisserant
parents:
diff
changeset
|
69 |
BOOL state; // current action state. 0 : inative, 1: active |
9ceda59abd27
Re-organized types headers, to ease debug code generation
etisserant
parents:
diff
changeset
|
70 |
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
|
71 |
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
|
72 |
TIME set_remaining_time; // time before set will be requested |
9ceda59abd27
Re-organized types headers, to ease debug code generation
etisserant
parents:
diff
changeset
|
73 |
TIME reset_remaining_time; // time before reset will be requested |
9ceda59abd27
Re-organized types headers, to ease debug code generation
etisserant
parents:
diff
changeset
|
74 |
} ACTION; |
9ceda59abd27
Re-organized types headers, to ease debug code generation
etisserant
parents:
diff
changeset
|
75 |
|
9ceda59abd27
Re-organized types headers, to ease debug code generation
etisserant
parents:
diff
changeset
|
76 |
/* Extra debug types for SFC */ |
9ceda59abd27
Re-organized types headers, to ease debug code generation
etisserant
parents:
diff
changeset
|
77 |
#define ANY_SFC(DO) DO(STEP) DO(TRANSITION) DO(ACTION) |
9ceda59abd27
Re-organized types headers, to ease debug code generation
etisserant
parents:
diff
changeset
|
78 |
|
9ceda59abd27
Re-organized types headers, to ease debug code generation
etisserant
parents:
diff
changeset
|
79 |
/* Enumerate native types */ |
9ceda59abd27
Re-organized types headers, to ease debug code generation
etisserant
parents:
diff
changeset
|
80 |
#define __decl_enum_type(TYPENAME) TYPENAME##_ENUM, |
224 | 81 |
#define __decl_enum_pointer(TYPENAME) TYPENAME##_P_ENUM, |
137
9ceda59abd27
Re-organized types headers, to ease debug code generation
etisserant
parents:
diff
changeset
|
82 |
typedef enum{ |
9ceda59abd27
Re-organized types headers, to ease debug code generation
etisserant
parents:
diff
changeset
|
83 |
ANY(__decl_enum_type) |
224 | 84 |
ANY(__decl_enum_pointer) |
85 |
/* SFC specific types are never external or global */ |
|
86 |
UNKNOWN_ENUM |
|
137
9ceda59abd27
Re-organized types headers, to ease debug code generation
etisserant
parents:
diff
changeset
|
87 |
} __IEC_types_enum; |
9ceda59abd27
Re-organized types headers, to ease debug code generation
etisserant
parents:
diff
changeset
|
88 |
|
9ceda59abd27
Re-organized types headers, to ease debug code generation
etisserant
parents:
diff
changeset
|
89 |
/* Get size of type from its number */ |
224 | 90 |
#define __decl_size_case(TYPENAME) \ |
91 |
case TYPENAME##_ENUM:\ |
|
92 |
case TYPENAME##_P_ENUM:\ |
|
93 |
return sizeof(TYPENAME); |
|
137
9ceda59abd27
Re-organized types headers, to ease debug code generation
etisserant
parents:
diff
changeset
|
94 |
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
|
95 |
switch(t){ |
9ceda59abd27
Re-organized types headers, to ease debug code generation
etisserant
parents:
diff
changeset
|
96 |
ANY(__decl_size_case) |
9ceda59abd27
Re-organized types headers, to ease debug code generation
etisserant
parents:
diff
changeset
|
97 |
/* size do not correspond to real struct. |
9ceda59abd27
Re-organized types headers, to ease debug code generation
etisserant
parents:
diff
changeset
|
98 |
* only a bool is used to represent state*/ |
224 | 99 |
default: |
100 |
return 0; |
|
137
9ceda59abd27
Re-organized types headers, to ease debug code generation
etisserant
parents:
diff
changeset
|
101 |
} |
199
b075f28ec081
Bug with type conversion EN/ENO not evaluated fixed
laurent
parents:
137
diff
changeset
|
102 |
return 0; |
137
9ceda59abd27
Re-organized types headers, to ease debug code generation
etisserant
parents:
diff
changeset
|
103 |
} |
9ceda59abd27
Re-organized types headers, to ease debug code generation
etisserant
parents:
diff
changeset
|
104 |
|
9ceda59abd27
Re-organized types headers, to ease debug code generation
etisserant
parents:
diff
changeset
|
105 |
#endif /*IEC_TYPES_ALL_H*/ |