lib/iec_types_all.h
author laurent
Tue, 15 Dec 2009 16:29:44 +0100
changeset 237 cece842c7417
parent 235 ed66dc50f31a
child 246 e8b5b163804d
permissions -rw-r--r--
Adding support for using arrays in POU interface
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
270ba3d91e59 type definition to match accessor and new debug
edouard
parents: 222
diff changeset
    16
#define __IEC_DEBUG_FLAG 0x01
270ba3d91e59 type definition to match accessor and new debug
edouard
parents: 222
diff changeset
    17
#define __IEC_FORCE_FLAG 0x02
270ba3d91e59 type definition to match accessor and new debug
edouard
parents: 222
diff changeset
    18
#define __IEC_RETAIN_FLAG 0x04
222
8b1757417a54 Adding Flags bit symbols
laurent
parents: 221
diff changeset
    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)\
237
cece842c7417 Adding support for using arrays in POU interface
laurent
parents: 235
diff changeset
    50
typedef struct {\
cece842c7417 Adding support for using arrays in POU interface
laurent
parents: 235
diff changeset
    51
  base table size;\
cece842c7417 Adding support for using arrays in POU interface
laurent
parents: 235
diff changeset
    52
} 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
    53
__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
    54
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
#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
    56
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
    57
__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
    58
137
9ceda59abd27 Re-organized types headers, to ease debug code generation
etisserant
parents:
diff changeset
    59
/* Those typdefs clash with windows.h */
9ceda59abd27 Re-organized types headers, to ease debug code generation
etisserant
parents:
diff changeset
    60
/* 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
    61
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
    62
137
9ceda59abd27 Re-organized types headers, to ease debug code generation
etisserant
parents:
diff changeset
    63
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
    64
  __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
    65
  BOOL prev_state;  // previous step state. 0 : inative, 1: active
9ceda59abd27 Re-organized types headers, to ease debug code generation
etisserant
parents:
diff changeset
    66
  TIME elapsed_time;  // time since step is active
9ceda59abd27 Re-organized types headers, to ease debug code generation
etisserant
parents:
diff changeset
    67
} STEP;
9ceda59abd27 Re-organized types headers, to ease debug code generation
etisserant
parents:
diff changeset
    68
9ceda59abd27 Re-organized types headers, to ease debug code generation
etisserant
parents:
diff changeset
    69
typedef struct {
9ceda59abd27 Re-organized types headers, to ease debug code generation
etisserant
parents:
diff changeset
    70
  BOOL stored;  // action storing state. 0 : not stored, 1: stored
9ceda59abd27 Re-organized types headers, to ease debug code generation
etisserant
parents:
diff changeset
    71
  BOOL state; // current action state. 0 : inative, 1: active
9ceda59abd27 Re-organized types headers, to ease debug code generation
etisserant
parents:
diff changeset
    72
  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
    73
  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
    74
  TIME set_remaining_time;    // time before set will be requested
9ceda59abd27 Re-organized types headers, to ease debug code generation
etisserant
parents:
diff changeset
    75
  TIME reset_remaining_time;  // time before reset will be requested
9ceda59abd27 Re-organized types headers, to ease debug code generation
etisserant
parents:
diff changeset
    76
} ACTION;
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
/* Extra debug types for SFC */
9ceda59abd27 Re-organized types headers, to ease debug code generation
etisserant
parents:
diff changeset
    79
#define ANY_SFC(DO) DO(STEP) DO(TRANSITION) DO(ACTION)
9ceda59abd27 Re-organized types headers, to ease debug code generation
etisserant
parents:
diff changeset
    80
9ceda59abd27 Re-organized types headers, to ease debug code generation
etisserant
parents:
diff changeset
    81
/* Enumerate native types */
9ceda59abd27 Re-organized types headers, to ease debug code generation
etisserant
parents:
diff changeset
    82
#define __decl_enum_type(TYPENAME) TYPENAME##_ENUM,
224
270ba3d91e59 type definition to match accessor and new debug
edouard
parents: 222
diff changeset
    83
#define __decl_enum_pointer(TYPENAME) TYPENAME##_P_ENUM,
235
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 227
diff changeset
    84
#define __decl_enum_output(TYPENAME) TYPENAME##_O_ENUM,
137
9ceda59abd27 Re-organized types headers, to ease debug code generation
etisserant
parents:
diff changeset
    85
typedef enum{
9ceda59abd27 Re-organized types headers, to ease debug code generation
etisserant
parents:
diff changeset
    86
  ANY(__decl_enum_type)
224
270ba3d91e59 type definition to match accessor and new debug
edouard
parents: 222
diff changeset
    87
  ANY(__decl_enum_pointer)
235
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 227
diff changeset
    88
  ANY(__decl_enum_output)
224
270ba3d91e59 type definition to match accessor and new debug
edouard
parents: 222
diff changeset
    89
  /* SFC specific types are never external or global */
270ba3d91e59 type definition to match accessor and new debug
edouard
parents: 222
diff changeset
    90
  UNKNOWN_ENUM
137
9ceda59abd27 Re-organized types headers, to ease debug code generation
etisserant
parents:
diff changeset
    91
} __IEC_types_enum;
9ceda59abd27 Re-organized types headers, to ease debug code generation
etisserant
parents:
diff changeset
    92
9ceda59abd27 Re-organized types headers, to ease debug code generation
etisserant
parents:
diff changeset
    93
/* Get size of type from its number */
224
270ba3d91e59 type definition to match accessor and new debug
edouard
parents: 222
diff changeset
    94
#define __decl_size_case(TYPENAME) \
270ba3d91e59 type definition to match accessor and new debug
edouard
parents: 222
diff changeset
    95
	case TYPENAME##_ENUM:\
270ba3d91e59 type definition to match accessor and new debug
edouard
parents: 222
diff changeset
    96
	case TYPENAME##_P_ENUM:\
270ba3d91e59 type definition to match accessor and new debug
edouard
parents: 222
diff changeset
    97
		return sizeof(TYPENAME);
137
9ceda59abd27 Re-organized types headers, to ease debug code generation
etisserant
parents:
diff changeset
    98
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
    99
 switch(t){
9ceda59abd27 Re-organized types headers, to ease debug code generation
etisserant
parents:
diff changeset
   100
  ANY(__decl_size_case)
9ceda59abd27 Re-organized types headers, to ease debug code generation
etisserant
parents:
diff changeset
   101
  /* size do not correspond to real struct.
9ceda59abd27 Re-organized types headers, to ease debug code generation
etisserant
parents:
diff changeset
   102
   * only a bool is used to represent state*/
224
270ba3d91e59 type definition to match accessor and new debug
edouard
parents: 222
diff changeset
   103
  default:
270ba3d91e59 type definition to match accessor and new debug
edouard
parents: 222
diff changeset
   104
	  return 0;
137
9ceda59abd27 Re-organized types headers, to ease debug code generation
etisserant
parents:
diff changeset
   105
 }
199
b075f28ec081 Bug with type conversion EN/ENO not evaluated fixed
laurent
parents: 137
diff changeset
   106
 return 0;
137
9ceda59abd27 Re-organized types headers, to ease debug code generation
etisserant
parents:
diff changeset
   107
}
9ceda59abd27 Re-organized types headers, to ease debug code generation
etisserant
parents:
diff changeset
   108
9ceda59abd27 Re-organized types headers, to ease debug code generation
etisserant
parents:
diff changeset
   109
#endif /*IEC_TYPES_ALL_H*/