lib/C/iec_types_all.h
author mjsousa
Sun, 06 Jul 2014 11:07:38 +0100
changeset 904 423ea3749212
parent 899 lib/iec_types_all.h@a3f734a23566
child 909 8b2a31dea131
permissions -rwxr-xr-x
Move library files compiled to C to their own subdiectory.
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
270ba3d91e59 type definition to match accessor and new debug
edouard
parents: 222
diff changeset
    70
#define __IEC_DEBUG_FLAG 0x01
270ba3d91e59 type definition to match accessor and new debug
edouard
parents: 222
diff changeset
    71
#define __IEC_FORCE_FLAG 0x02
270ba3d91e59 type definition to match accessor and new debug
edouard
parents: 222
diff changeset
    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
8b1757417a54 Adding Flags bit symbols
laurent
parents: 221
diff changeset
    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 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
    87
} __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
    88
327
da78d0d93c75 Fix bug in declaring variable of enumerated type
laurent
parents: 301
diff changeset
    89
#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
    90
typedef base type;\
404
ff3313e22883 Fix bug pointed structure not declared for directly derived datatypes
laurent
parents: 394
diff changeset
    91
typedef __IEC_##base##_t __IEC_##type##_t;\
ff3313e22883 Fix bug pointed structure not declared for directly derived datatypes
laurent
parents: 394
diff changeset
    92
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
    93
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
#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
    95
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
    96
  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
    97
  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
    98
} __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
    99
\
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
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
   101
  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
   102
  IEC_BYTE flags;\
394
8a04e93f9ef2 Fixing bug in generated code for complex type external variable
laurent
parents: 350
diff changeset
   103
  type fvalue;\
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
   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
da78d0d93c75 Fix bug in declaring variable of enumerated type
laurent
parents: 301
diff changeset
   106
#define __DECLARE_ENUMERATED_TYPE(type, ...)\
da78d0d93c75 Fix bug in declaring variable of enumerated type
laurent
parents: 301
diff changeset
   107
typedef enum {\
da78d0d93c75 Fix bug in declaring variable of enumerated type
laurent
parents: 301
diff changeset
   108
  __VA_ARGS__\
da78d0d93c75 Fix bug in declaring variable of enumerated type
laurent
parents: 301
diff changeset
   109
} type;\
da78d0d93c75 Fix bug in declaring variable of enumerated type
laurent
parents: 301
diff changeset
   110
__DECLARE_COMPLEX_STRUCT(type)
da78d0d93c75 Fix bug in declaring variable of enumerated type
laurent
parents: 301
diff changeset
   111
da78d0d93c75 Fix bug in declaring variable of enumerated type
laurent
parents: 301
diff changeset
   112
#define __DECLARE_ARRAY_TYPE(type, base, size)\
237
cece842c7417 Adding support for using arrays in POU interface
laurent
parents: 235
diff changeset
   113
typedef struct {\
cece842c7417 Adding support for using arrays in POU interface
laurent
parents: 235
diff changeset
   114
  base table size;\
cece842c7417 Adding support for using arrays in POU interface
laurent
parents: 235
diff changeset
   115
} type;\
327
da78d0d93c75 Fix bug in declaring variable of enumerated type
laurent
parents: 301
diff changeset
   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
da78d0d93c75 Fix bug in declaring variable of enumerated type
laurent
parents: 301
diff changeset
   118
#define __DECLARE_STRUCT_TYPE(type, elements)\
da78d0d93c75 Fix bug in declaring variable of enumerated type
laurent
parents: 301
diff changeset
   119
typedef struct {\
da78d0d93c75 Fix bug in declaring variable of enumerated type
laurent
parents: 301
diff changeset
   120
  elements\
da78d0d93c75 Fix bug in declaring variable of enumerated type
laurent
parents: 301
diff changeset
   121
} type;\
da78d0d93c75 Fix bug in declaring variable of enumerated type
laurent
parents: 301
diff changeset
   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
137
9ceda59abd27 Re-organized types headers, to ease debug code generation
etisserant
parents:
diff changeset
   124
/* Those typdefs clash with windows.h */
9ceda59abd27 Re-organized types headers, to ease debug code generation
etisserant
parents:
diff changeset
   125
/* 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
   126
__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
   127
137
9ceda59abd27 Re-organized types headers, to ease debug code generation
etisserant
parents:
diff changeset
   128
typedef struct {
897
8c3e91c385f5 Add support for Stepname.X syntax.
mjsousa
parents: 743
diff changeset
   129
  __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
a3f734a23566 Add support for the stepname.T syntax.
mjsousa
parents: 897
diff changeset
   130
  BOOL prev_state; // previous step state. 0 : inative, 1: active
a3f734a23566 Add support for the stepname.T syntax.
mjsousa
parents: 897
diff changeset
   131
  __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
   132
} STEP;
9ceda59abd27 Re-organized types headers, to ease debug code generation
etisserant
parents:
diff changeset
   133
897
8c3e91c385f5 Add support for Stepname.X syntax.
mjsousa
parents: 743
diff changeset
   134
137
9ceda59abd27 Re-organized types headers, to ease debug code generation
etisserant
parents:
diff changeset
   135
typedef struct {
9ceda59abd27 Re-organized types headers, to ease debug code generation
etisserant
parents:
diff changeset
   136
  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
   137
  __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
   138
  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
   139
  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
   140
  TIME set_remaining_time;    // time before set will be requested
9ceda59abd27 Re-organized types headers, to ease debug code generation
etisserant
parents:
diff changeset
   141
  TIME reset_remaining_time;  // time before reset will be requested
9ceda59abd27 Re-organized types headers, to ease debug code generation
etisserant
parents:
diff changeset
   142
} ACTION;
9ceda59abd27 Re-organized types headers, to ease debug code generation
etisserant
parents:
diff changeset
   143
9ceda59abd27 Re-organized types headers, to ease debug code generation
etisserant
parents:
diff changeset
   144
/* 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
   145
#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
   146
9ceda59abd27 Re-organized types headers, to ease debug code generation
etisserant
parents:
diff changeset
   147
/* Enumerate native types */
9ceda59abd27 Re-organized types headers, to ease debug code generation
etisserant
parents:
diff changeset
   148
#define __decl_enum_type(TYPENAME) TYPENAME##_ENUM,
224
270ba3d91e59 type definition to match accessor and new debug
edouard
parents: 222
diff changeset
   149
#define __decl_enum_pointer(TYPENAME) TYPENAME##_P_ENUM,
235
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 227
diff changeset
   150
#define __decl_enum_output(TYPENAME) TYPENAME##_O_ENUM,
137
9ceda59abd27 Re-organized types headers, to ease debug code generation
etisserant
parents:
diff changeset
   151
typedef enum{
350
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 327
diff changeset
   152
  __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
   153
  __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
   154
  __ANY(__decl_enum_output)
224
270ba3d91e59 type definition to match accessor and new debug
edouard
parents: 222
diff changeset
   155
  /* SFC specific types are never external or global */
270ba3d91e59 type definition to match accessor and new debug
edouard
parents: 222
diff changeset
   156
  UNKNOWN_ENUM
137
9ceda59abd27 Re-organized types headers, to ease debug code generation
etisserant
parents:
diff changeset
   157
} __IEC_types_enum;
9ceda59abd27 Re-organized types headers, to ease debug code generation
etisserant
parents:
diff changeset
   158
9ceda59abd27 Re-organized types headers, to ease debug code generation
etisserant
parents:
diff changeset
   159
/* Get size of type from its number */
224
270ba3d91e59 type definition to match accessor and new debug
edouard
parents: 222
diff changeset
   160
#define __decl_size_case(TYPENAME) \
270ba3d91e59 type definition to match accessor and new debug
edouard
parents: 222
diff changeset
   161
	case TYPENAME##_ENUM:\
246
e8b5b163804d A forgotten case in type size getter switch prevented debugging outputs.
edouard
parents: 237
diff changeset
   162
	case TYPENAME##_O_ENUM:\
224
270ba3d91e59 type definition to match accessor and new debug
edouard
parents: 222
diff changeset
   163
	case TYPENAME##_P_ENUM:\
270ba3d91e59 type definition to match accessor and new debug
edouard
parents: 222
diff changeset
   164
		return sizeof(TYPENAME);
137
9ceda59abd27 Re-organized types headers, to ease debug code generation
etisserant
parents:
diff changeset
   165
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
   166
 switch(t){
350
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 327
diff changeset
   167
  __ANY(__decl_size_case)
137
9ceda59abd27 Re-organized types headers, to ease debug code generation
etisserant
parents:
diff changeset
   168
  /* size do not correspond to real struct.
9ceda59abd27 Re-organized types headers, to ease debug code generation
etisserant
parents:
diff changeset
   169
   * only a bool is used to represent state*/
224
270ba3d91e59 type definition to match accessor and new debug
edouard
parents: 222
diff changeset
   170
  default:
270ba3d91e59 type definition to match accessor and new debug
edouard
parents: 222
diff changeset
   171
	  return 0;
137
9ceda59abd27 Re-organized types headers, to ease debug code generation
etisserant
parents:
diff changeset
   172
 }
199
b075f28ec081 Bug with type conversion EN/ENO not evaluated fixed
laurent
parents: 137
diff changeset
   173
 return 0;
137
9ceda59abd27 Re-organized types headers, to ease debug code generation
etisserant
parents:
diff changeset
   174
}
9ceda59abd27 Re-organized types headers, to ease debug code generation
etisserant
parents:
diff changeset
   175
9ceda59abd27 Re-organized types headers, to ease debug code generation
etisserant
parents:
diff changeset
   176
#endif /*IEC_TYPES_ALL_H*/