author | Mario de Sousa <msousa@fe.up.pt> |
Fri, 10 Jun 2011 06:30:30 +0100 | |
changeset 319 | 1669977e84f4 |
parent 301 | 15bf9ecb936d |
child 327 | da78d0d93c75 |
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 |
|
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 |
#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
|
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 |
|
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 |
#define __DECLARE_ARRAY_TYPE(base, type, size)\ |
237 | 51 |
typedef struct {\ |
52 |
base table size;\ |
|
53 |
} 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
|
54 |
__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
|
55 |
|
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 |
#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
|
57 |
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
|
58 |
__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
|
59 |
|
137
9ceda59abd27
Re-organized types headers, to ease debug code generation
etisserant
parents:
diff
changeset
|
60 |
/* Those typdefs clash with windows.h */ |
9ceda59abd27
Re-organized types headers, to ease debug code generation
etisserant
parents:
diff
changeset
|
61 |
/* 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
|
62 |
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
|
63 |
|
137
9ceda59abd27
Re-organized types headers, to ease debug code generation
etisserant
parents:
diff
changeset
|
64 |
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
|
65 |
__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
|
66 |
BOOL prev_state; // previous step state. 0 : inative, 1: active |
9ceda59abd27
Re-organized types headers, to ease debug code generation
etisserant
parents:
diff
changeset
|
67 |
TIME elapsed_time; // time since step is active |
9ceda59abd27
Re-organized types headers, to ease debug code generation
etisserant
parents:
diff
changeset
|
68 |
} STEP; |
9ceda59abd27
Re-organized types headers, to ease debug code generation
etisserant
parents:
diff
changeset
|
69 |
|
9ceda59abd27
Re-organized types headers, to ease debug code generation
etisserant
parents:
diff
changeset
|
70 |
typedef struct { |
9ceda59abd27
Re-organized types headers, to ease debug code generation
etisserant
parents:
diff
changeset
|
71 |
BOOL stored; // action storing state. 0 : not stored, 1: stored |
9ceda59abd27
Re-organized types headers, to ease debug code generation
etisserant
parents:
diff
changeset
|
72 |
BOOL state; // current action state. 0 : inative, 1: active |
9ceda59abd27
Re-organized types headers, to ease debug code generation
etisserant
parents:
diff
changeset
|
73 |
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
|
74 |
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
|
75 |
TIME set_remaining_time; // time before set will be requested |
9ceda59abd27
Re-organized types headers, to ease debug code generation
etisserant
parents:
diff
changeset
|
76 |
TIME reset_remaining_time; // time before reset will be requested |
9ceda59abd27
Re-organized types headers, to ease debug code generation
etisserant
parents:
diff
changeset
|
77 |
} 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 |
/* Extra debug types for SFC */ |
9ceda59abd27
Re-organized types headers, to ease debug code generation
etisserant
parents:
diff
changeset
|
80 |
#define ANY_SFC(DO) DO(STEP) DO(TRANSITION) DO(ACTION) |
9ceda59abd27
Re-organized types headers, to ease debug code generation
etisserant
parents:
diff
changeset
|
81 |
|
9ceda59abd27
Re-organized types headers, to ease debug code generation
etisserant
parents:
diff
changeset
|
82 |
/* Enumerate native types */ |
9ceda59abd27
Re-organized types headers, to ease debug code generation
etisserant
parents:
diff
changeset
|
83 |
#define __decl_enum_type(TYPENAME) TYPENAME##_ENUM, |
224 | 84 |
#define __decl_enum_pointer(TYPENAME) TYPENAME##_P_ENUM, |
235 | 85 |
#define __decl_enum_output(TYPENAME) TYPENAME##_O_ENUM, |
137
9ceda59abd27
Re-organized types headers, to ease debug code generation
etisserant
parents:
diff
changeset
|
86 |
typedef enum{ |
9ceda59abd27
Re-organized types headers, to ease debug code generation
etisserant
parents:
diff
changeset
|
87 |
ANY(__decl_enum_type) |
224 | 88 |
ANY(__decl_enum_pointer) |
235 | 89 |
ANY(__decl_enum_output) |
224 | 90 |
/* SFC specific types are never external or global */ |
91 |
UNKNOWN_ENUM |
|
137
9ceda59abd27
Re-organized types headers, to ease debug code generation
etisserant
parents:
diff
changeset
|
92 |
} __IEC_types_enum; |
9ceda59abd27
Re-organized types headers, to ease debug code generation
etisserant
parents:
diff
changeset
|
93 |
|
9ceda59abd27
Re-organized types headers, to ease debug code generation
etisserant
parents:
diff
changeset
|
94 |
/* Get size of type from its number */ |
224 | 95 |
#define __decl_size_case(TYPENAME) \ |
96 |
case TYPENAME##_ENUM:\ |
|
246
e8b5b163804d
A forgotten case in type size getter switch prevented debugging outputs.
edouard
parents:
237
diff
changeset
|
97 |
case TYPENAME##_O_ENUM:\ |
224 | 98 |
case TYPENAME##_P_ENUM:\ |
99 |
return sizeof(TYPENAME); |
|
137
9ceda59abd27
Re-organized types headers, to ease debug code generation
etisserant
parents:
diff
changeset
|
100 |
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
|
101 |
switch(t){ |
9ceda59abd27
Re-organized types headers, to ease debug code generation
etisserant
parents:
diff
changeset
|
102 |
ANY(__decl_size_case) |
9ceda59abd27
Re-organized types headers, to ease debug code generation
etisserant
parents:
diff
changeset
|
103 |
/* size do not correspond to real struct. |
9ceda59abd27
Re-organized types headers, to ease debug code generation
etisserant
parents:
diff
changeset
|
104 |
* only a bool is used to represent state*/ |
224 | 105 |
default: |
106 |
return 0; |
|
137
9ceda59abd27
Re-organized types headers, to ease debug code generation
etisserant
parents:
diff
changeset
|
107 |
} |
199
b075f28ec081
Bug with type conversion EN/ENO not evaluated fixed
laurent
parents:
137
diff
changeset
|
108 |
return 0; |
137
9ceda59abd27
Re-organized types headers, to ease debug code generation
etisserant
parents:
diff
changeset
|
109 |
} |
9ceda59abd27
Re-organized types headers, to ease debug code generation
etisserant
parents:
diff
changeset
|
110 |
|
9ceda59abd27
Re-organized types headers, to ease debug code generation
etisserant
parents:
diff
changeset
|
111 |
#endif /*IEC_TYPES_ALL_H*/ |