author | Edouard Tisserant <edouard.tisserant@gmail.com> |
Fri, 26 Apr 2024 09:27:21 +0200 | |
changeset 1105 | 8128cad6a6e3 |
parent 1096 | fad6e7a818e2 |
permissions | -rwxr-xr-x |
350
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
327
diff
changeset
|
1 |
/* |
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
327
diff
changeset
|
2 |
* Copyright (C) 2007-2011: Edouard TISSERANT and Laurent BESSARD |
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
327
diff
changeset
|
3 |
* |
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
327
diff
changeset
|
4 |
* See COPYING and COPYING.LESSER files for copyright details. |
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
327
diff
changeset
|
5 |
* |
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
327
diff
changeset
|
6 |
* This library is free software; you can redistribute it and/or |
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
327
diff
changeset
|
7 |
* modify it under the terms of the GNU Lesser General Public |
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
327
diff
changeset
|
8 |
* License as published by the Free Software Foundation; either |
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
327
diff
changeset
|
9 |
* version 3 of the License, or (at your option) any later version. |
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
327
diff
changeset
|
10 |
* |
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
327
diff
changeset
|
11 |
* This library is distributed in the hope that it will be useful, |
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
327
diff
changeset
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
327
diff
changeset
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
327
diff
changeset
|
14 |
* Lesser General Public License for more details. |
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
327
diff
changeset
|
15 |
* |
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
327
diff
changeset
|
16 |
* You should have received a copy of the GNU Lesser General Public License |
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
327
diff
changeset
|
17 |
* along with this library. If not, see <http://www.gnu.org/licenses/>. |
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
327
diff
changeset
|
18 |
* |
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
327
diff
changeset
|
19 |
*/ |
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
327
diff
changeset
|
20 |
|
137
9ceda59abd27
Re-organized types headers, to ease debug code generation
etisserant
parents:
diff
changeset
|
21 |
#ifndef IEC_TYPES_ALL_H |
9ceda59abd27
Re-organized types headers, to ease debug code generation
etisserant
parents:
diff
changeset
|
22 |
#define IEC_TYPES_ALL_H |
9ceda59abd27
Re-organized types headers, to ease debug code generation
etisserant
parents:
diff
changeset
|
23 |
|
350
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
327
diff
changeset
|
24 |
|
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
327
diff
changeset
|
25 |
/* Macro that expand to subtypes */ |
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
327
diff
changeset
|
26 |
#define __ANY(DO) __ANY_DERIVED(DO) __ANY_ELEMENTARY(DO) |
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
327
diff
changeset
|
27 |
#define __ANY_DERIVED(DO) |
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
327
diff
changeset
|
28 |
#define __ANY_ELEMENTARY(DO) __ANY_MAGNITUDE(DO) __ANY_BIT(DO) __ANY_STRING(DO) __ANY_DATE(DO) |
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
327
diff
changeset
|
29 |
#define __ANY_MAGNITUDE(DO) __ANY_NUM(DO) DO(TIME) |
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
327
diff
changeset
|
30 |
#define __ANY_BIT(DO) __ANY_NBIT(DO) DO(BOOL) |
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
327
diff
changeset
|
31 |
#define __ANY_NBIT(DO) DO(BYTE) DO(WORD) DO(DWORD) DO(LWORD) |
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
327
diff
changeset
|
32 |
#define __ANY_STRING(DO) DO(STRING) |
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
327
diff
changeset
|
33 |
#define __ANY_DATE(DO) DO(DATE) DO(TOD) DO(DT) |
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
327
diff
changeset
|
34 |
#define __ANY_NUM(DO) __ANY_REAL(DO) __ANY_INT(DO) |
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
327
diff
changeset
|
35 |
#define __ANY_REAL(DO) DO(REAL) DO(LREAL) |
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
327
diff
changeset
|
36 |
#define __ANY_INT(DO) __ANY_SINT(DO) __ANY_UINT(DO) |
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
327
diff
changeset
|
37 |
#define __ANY_SINT(DO) DO(SINT) DO(INT) DO(DINT) DO(LINT) |
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
327
diff
changeset
|
38 |
#define __ANY_UINT(DO) DO(USINT) DO(UINT) DO(UDINT) DO(ULINT) |
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
327
diff
changeset
|
39 |
|
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
327
diff
changeset
|
40 |
|
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
327
diff
changeset
|
41 |
/* Macro that expand to subtypes */ |
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
327
diff
changeset
|
42 |
#define __ANY_1(DO,P1) __ANY_DERIVED_1(DO,P1) __ANY_ELEMENTARY_1(DO,P1) |
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
327
diff
changeset
|
43 |
#define __ANY_DERIVED_1(DO,P1) |
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
327
diff
changeset
|
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) |
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
327
diff
changeset
|
45 |
#define __ANY_MAGNITUDE_1(DO,P1) __ANY_NUM_1(DO,P1) DO(TIME,P1) |
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
327
diff
changeset
|
46 |
#define __ANY_BIT_1(DO,P1) __ANY_NBIT_1(DO,P1) DO(BOOL,P1) |
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
327
diff
changeset
|
47 |
#define __ANY_NBIT_1(DO,P1) DO(BYTE,P1) DO(WORD,P1) DO(DWORD,P1) DO(LWORD,P1) |
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
327
diff
changeset
|
48 |
#define __ANY_STRING_1(DO,P1) DO(STRING,P1) |
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
327
diff
changeset
|
49 |
#define __ANY_DATE_1(DO,P1) DO(DATE,P1) DO(TOD,P1) DO(DT,P1) |
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
327
diff
changeset
|
50 |
#define __ANY_NUM_1(DO,P1) __ANY_REAL_1(DO,P1) __ANY_INT_1(DO,P1) |
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
327
diff
changeset
|
51 |
#define __ANY_REAL_1(DO,P1) DO(REAL,P1) DO(LREAL,P1) |
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
327
diff
changeset
|
52 |
#define __ANY_INT_1(DO,P1) __ANY_SINT_1(DO,P1) __ANY_UINT_1(DO,P1) |
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
327
diff
changeset
|
53 |
#define __ANY_SINT_1(DO,P1) DO(SINT,P1) DO(INT,P1) DO(DINT,P1) DO(LINT,P1) |
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
327
diff
changeset
|
54 |
#define __ANY_UINT_1(DO,P1) DO(USINT,P1) DO(UINT,P1) DO(UDINT,P1) DO(ULINT,P1) |
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
327
diff
changeset
|
55 |
|
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
327
diff
changeset
|
56 |
|
137
9ceda59abd27
Re-organized types headers, to ease debug code generation
etisserant
parents:
diff
changeset
|
57 |
|
9ceda59abd27
Re-organized types headers, to ease debug code generation
etisserant
parents:
diff
changeset
|
58 |
/*********************/ |
9ceda59abd27
Re-organized types headers, to ease debug code generation
etisserant
parents:
diff
changeset
|
59 |
/* IEC Types defs */ |
9ceda59abd27
Re-organized types headers, to ease debug code generation
etisserant
parents:
diff
changeset
|
60 |
/*********************/ |
9ceda59abd27
Re-organized types headers, to ease debug code generation
etisserant
parents:
diff
changeset
|
61 |
|
9ceda59abd27
Re-organized types headers, to ease debug code generation
etisserant
parents:
diff
changeset
|
62 |
/* Include non windows.h clashing typedefs */ |
9ceda59abd27
Re-organized types headers, to ease debug code generation
etisserant
parents:
diff
changeset
|
63 |
#include "iec_types.h" |
9ceda59abd27
Re-organized types headers, to ease debug code generation
etisserant
parents:
diff
changeset
|
64 |
|
743
fbf77edf54ca
Be sure to not redefine TRUE and FALSE macros.
Manuele Conti <conti.ma@alice.it>
parents:
628
diff
changeset
|
65 |
#ifndef TRUE |
fbf77edf54ca
Be sure to not redefine TRUE and FALSE macros.
Manuele Conti <conti.ma@alice.it>
parents:
628
diff
changeset
|
66 |
#define TRUE 1 |
fbf77edf54ca
Be sure to not redefine TRUE and FALSE macros.
Manuele Conti <conti.ma@alice.it>
parents:
628
diff
changeset
|
67 |
#define FALSE 0 |
fbf77edf54ca
Be sure to not redefine TRUE and FALSE macros.
Manuele Conti <conti.ma@alice.it>
parents:
628
diff
changeset
|
68 |
#endif |
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
|
69 |
|
224 | 70 |
#define __IEC_DEBUG_FLAG 0x01 |
71 |
#define __IEC_FORCE_FLAG 0x02 |
|
72 |
#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
|
73 |
#define __IEC_OUTPUT_FLAG 0x08 |
222 | 74 |
|
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
|
75 |
#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
|
76 |
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
|
77 |
\ |
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
|
78 |
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
|
79 |
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
|
80 |
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
|
81 |
} __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
|
82 |
\ |
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
|
83 |
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
|
84 |
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
|
85 |
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
|
86 |
} __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
|
87 |
|
909
8b2a31dea131
Add support for REF_TO derived datatypes (along with datatype verification)
mjsousa
parents:
904
diff
changeset
|
88 |
|
8b2a31dea131
Add support for REF_TO derived datatypes (along with datatype verification)
mjsousa
parents:
904
diff
changeset
|
89 |
|
327 | 90 |
#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
|
91 |
typedef base type;\ |
404
ff3313e22883
Fix bug pointed structure not declared for directly derived datatypes
laurent
parents:
394
diff
changeset
|
92 |
typedef __IEC_##base##_t __IEC_##type##_t;\ |
ff3313e22883
Fix bug pointed structure not declared for directly derived datatypes
laurent
parents:
394
diff
changeset
|
93 |
typedef __IEC_##base##_p __IEC_##type##_p; |
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
|
94 |
|
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
|
95 |
#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
|
96 |
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
|
97 |
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
|
98 |
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
|
99 |
} __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
|
100 |
\ |
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
|
101 |
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
|
102 |
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
|
103 |
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
|
104 |
} __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
|
105 |
|
327 | 106 |
#define __DECLARE_ENUMERATED_TYPE(type, ...)\ |
107 |
typedef enum {\ |
|
108 |
__VA_ARGS__\ |
|
109 |
} type;\ |
|
110 |
__DECLARE_COMPLEX_STRUCT(type) |
|
111 |
||
112 |
#define __DECLARE_ARRAY_TYPE(type, base, size)\ |
|
237 | 113 |
typedef struct {\ |
114 |
base table size;\ |
|
115 |
} type;\ |
|
327 | 116 |
__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
|
117 |
|
327 | 118 |
#define __DECLARE_STRUCT_TYPE(type, elements)\ |
119 |
typedef struct {\ |
|
120 |
elements\ |
|
121 |
} type;\ |
|
122 |
__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
|
123 |
|
909
8b2a31dea131
Add support for REF_TO derived datatypes (along with datatype verification)
mjsousa
parents:
904
diff
changeset
|
124 |
#define __DECLARE_REFTO_TYPE(type, name)\ |
932
061824c45a5b
Add support for REF_TO inside arrays and structs (a non-standard feature!)
mjsousa
parents:
909
diff
changeset
|
125 |
typedef name type;\ |
909
8b2a31dea131
Add support for REF_TO derived datatypes (along with datatype verification)
mjsousa
parents:
904
diff
changeset
|
126 |
__DECLARE_COMPLEX_STRUCT(type) |
8b2a31dea131
Add support for REF_TO derived datatypes (along with datatype verification)
mjsousa
parents:
904
diff
changeset
|
127 |
|
8b2a31dea131
Add support for REF_TO derived datatypes (along with datatype verification)
mjsousa
parents:
904
diff
changeset
|
128 |
|
137
9ceda59abd27
Re-organized types headers, to ease debug code generation
etisserant
parents:
diff
changeset
|
129 |
/* Those typdefs clash with windows.h */ |
9ceda59abd27
Re-organized types headers, to ease debug code generation
etisserant
parents:
diff
changeset
|
130 |
/* i.e. this file cannot be included aside windows.h */ |
350
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
327
diff
changeset
|
131 |
__ANY(__DECLARE_IEC_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
|
132 |
|
137
9ceda59abd27
Re-organized types headers, to ease debug code generation
etisserant
parents:
diff
changeset
|
133 |
typedef struct { |
897 | 134 |
__IEC_BOOL_t X; // state; --> current step state. 0 : inative, 1: active. We name it 'X' as it may be accessed from IEC 61131.3 code using stepname.X syntax!! |
899 | 135 |
BOOL prev_state; // previous step state. 0 : inative, 1: active |
136 |
__IEC_TIME_t T; // elapsed_time; --> time since step is active. We name it 'T' as it may be accessed from IEC 61131.3 code using stepname.T syntax!! |
|
137
9ceda59abd27
Re-organized types headers, to ease debug code generation
etisserant
parents:
diff
changeset
|
137 |
} STEP; |
9ceda59abd27
Re-organized types headers, to ease debug code generation
etisserant
parents:
diff
changeset
|
138 |
|
897 | 139 |
|
137
9ceda59abd27
Re-organized types headers, to ease debug code generation
etisserant
parents:
diff
changeset
|
140 |
typedef struct { |
9ceda59abd27
Re-organized types headers, to ease debug code generation
etisserant
parents:
diff
changeset
|
141 |
BOOL stored; // action storing state. 0 : not stored, 1: stored |
628
fe0d516fe291
Fix bug in SFC generated code. Action state was declared in the list of variables to debug, but wasn't stored using structure with flags. This error had side effects that makes Beremiz debug crash.
Laurent Bessard
parents:
404
diff
changeset
|
142 |
__IEC_BOOL_t state; // current action state. 0 : inative, 1: active |
137
9ceda59abd27
Re-organized types headers, to ease debug code generation
etisserant
parents:
diff
changeset
|
143 |
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
|
144 |
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
|
145 |
TIME set_remaining_time; // time before set will be requested |
9ceda59abd27
Re-organized types headers, to ease debug code generation
etisserant
parents:
diff
changeset
|
146 |
TIME reset_remaining_time; // time before reset will be requested |
9ceda59abd27
Re-organized types headers, to ease debug code generation
etisserant
parents:
diff
changeset
|
147 |
} ACTION; |
9ceda59abd27
Re-organized types headers, to ease debug code generation
etisserant
parents:
diff
changeset
|
148 |
|
9ceda59abd27
Re-organized types headers, to ease debug code generation
etisserant
parents:
diff
changeset
|
149 |
/* Extra debug types for SFC */ |
350
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
327
diff
changeset
|
150 |
#define __ANY_SFC(DO) DO(STEP) DO(TRANSITION) DO(ACTION) |
137
9ceda59abd27
Re-organized types headers, to ease debug code generation
etisserant
parents:
diff
changeset
|
151 |
|
9ceda59abd27
Re-organized types headers, to ease debug code generation
etisserant
parents:
diff
changeset
|
152 |
/* Enumerate native types */ |
9ceda59abd27
Re-organized types headers, to ease debug code generation
etisserant
parents:
diff
changeset
|
153 |
#define __decl_enum_type(TYPENAME) TYPENAME##_ENUM, |
224 | 154 |
#define __decl_enum_pointer(TYPENAME) TYPENAME##_P_ENUM, |
235 | 155 |
#define __decl_enum_output(TYPENAME) TYPENAME##_O_ENUM, |
137
9ceda59abd27
Re-organized types headers, to ease debug code generation
etisserant
parents:
diff
changeset
|
156 |
typedef enum{ |
350
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
327
diff
changeset
|
157 |
__ANY(__decl_enum_type) |
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
327
diff
changeset
|
158 |
__ANY(__decl_enum_pointer) |
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
327
diff
changeset
|
159 |
__ANY(__decl_enum_output) |
224 | 160 |
/* SFC specific types are never external or global */ |
161 |
UNKNOWN_ENUM |
|
137
9ceda59abd27
Re-organized types headers, to ease debug code generation
etisserant
parents:
diff
changeset
|
162 |
} __IEC_types_enum; |
9ceda59abd27
Re-organized types headers, to ease debug code generation
etisserant
parents:
diff
changeset
|
163 |
|
9ceda59abd27
Re-organized types headers, to ease debug code generation
etisserant
parents:
diff
changeset
|
164 |
/* Get size of type from its number */ |
224 | 165 |
#define __decl_size_case(TYPENAME) \ |
166 |
case TYPENAME##_ENUM:\ |
|
246
e8b5b163804d
A forgotten case in type size getter switch prevented debugging outputs.
edouard
parents:
237
diff
changeset
|
167 |
case TYPENAME##_O_ENUM:\ |
224 | 168 |
case TYPENAME##_P_ENUM:\ |
169 |
return sizeof(TYPENAME); |
|
137
9ceda59abd27
Re-organized types headers, to ease debug code generation
etisserant
parents:
diff
changeset
|
170 |
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
|
171 |
switch(t){ |
350
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
327
diff
changeset
|
172 |
__ANY(__decl_size_case) |
137
9ceda59abd27
Re-organized types headers, to ease debug code generation
etisserant
parents:
diff
changeset
|
173 |
/* size do not correspond to real struct. |
9ceda59abd27
Re-organized types headers, to ease debug code generation
etisserant
parents:
diff
changeset
|
174 |
* only a bool is used to represent state*/ |
224 | 175 |
default: |
176 |
return 0; |
|
137
9ceda59abd27
Re-organized types headers, to ease debug code generation
etisserant
parents:
diff
changeset
|
177 |
} |
199
b075f28ec081
Bug with type conversion EN/ENO not evaluated fixed
laurent
parents:
137
diff
changeset
|
178 |
return 0; |
137
9ceda59abd27
Re-organized types headers, to ease debug code generation
etisserant
parents:
diff
changeset
|
179 |
} |
9ceda59abd27
Re-organized types headers, to ease debug code generation
etisserant
parents:
diff
changeset
|
180 |
|
9ceda59abd27
Re-organized types headers, to ease debug code generation
etisserant
parents:
diff
changeset
|
181 |
#endif /*IEC_TYPES_ALL_H*/ |