etisserant@137: #ifndef IEC_TYPES_ALL_H etisserant@137: #define IEC_TYPES_ALL_H etisserant@137: etisserant@137: #include "iec_std_lib_generated.h" etisserant@137: etisserant@137: /*********************/ etisserant@137: /* IEC Types defs */ etisserant@137: /*********************/ etisserant@137: etisserant@137: /* Include non windows.h clashing typedefs */ etisserant@137: #include "iec_types.h" etisserant@137: laurent@221: #define TRUE 1 laurent@221: #define FALSE 0 laurent@221: edouard@224: #define __IEC_DEBUG_FLAG 0x01 edouard@224: #define __IEC_FORCE_FLAG 0x02 edouard@224: #define __IEC_RETAIN_FLAG 0x04 laurent@222: laurent@221: #define __DECLARE_IEC_TYPE(type)\ laurent@221: typedef IEC_##type type;\ laurent@221: \ laurent@221: typedef struct {\ laurent@221: IEC_##type value;\ laurent@221: IEC_BYTE flags;\ laurent@221: } __IEC_##type##_t;\ laurent@221: \ laurent@221: typedef struct {\ laurent@221: IEC_##type *value;\ laurent@221: IEC_BYTE flags;\ laurent@221: IEC_##type fvalue;\ laurent@221: } __IEC_##type##_p; laurent@221: laurent@221: #define __DECLARE_DERIVED_TYPE(base, type)\ laurent@221: typedef base type;\ laurent@221: typedef __IEC_##base##_t __IEC_##type##_t; laurent@221: laurent@221: #define __DECLARE_COMPLEX_STRUCT(type)\ laurent@221: typedef struct {\ laurent@221: type value;\ laurent@221: IEC_BYTE flags;\ laurent@221: } __IEC_##type##_t;\ laurent@221: \ laurent@221: typedef struct {\ laurent@221: type *value;\ laurent@221: IEC_BYTE flags;\ laurent@221: } __IEC_##type##_p; laurent@221: laurent@221: #define __DECLARE_ARRAY_TYPE(base, type, size)\ laurent@237: typedef struct {\ laurent@237: base table size;\ laurent@237: } type;\ laurent@221: __DECLARE_COMPLEX_STRUCT(type); laurent@221: laurent@221: #define __DECLARE_STRUCT_TYPE(elements, type)\ laurent@221: typedef elements type;\ laurent@221: __DECLARE_COMPLEX_STRUCT(type); laurent@221: etisserant@137: /* Those typdefs clash with windows.h */ etisserant@137: /* i.e. this file cannot be included aside windows.h */ laurent@221: ANY(__DECLARE_IEC_TYPE) laurent@221: etisserant@137: typedef struct { laurent@221: __IEC_BOOL_t state; // current step state. 0 : inative, 1: active etisserant@137: BOOL prev_state; // previous step state. 0 : inative, 1: active etisserant@137: TIME elapsed_time; // time since step is active etisserant@137: } STEP; etisserant@137: etisserant@137: typedef struct { etisserant@137: BOOL stored; // action storing state. 0 : not stored, 1: stored etisserant@137: BOOL state; // current action state. 0 : inative, 1: active etisserant@137: BOOL set; // set have been requested (reset each time the body is evaluated) etisserant@137: BOOL reset; // reset have been requested (reset each time the body is evaluated) etisserant@137: TIME set_remaining_time; // time before set will be requested etisserant@137: TIME reset_remaining_time; // time before reset will be requested etisserant@137: } ACTION; etisserant@137: etisserant@137: /* Extra debug types for SFC */ etisserant@137: #define ANY_SFC(DO) DO(STEP) DO(TRANSITION) DO(ACTION) etisserant@137: etisserant@137: /* Enumerate native types */ etisserant@137: #define __decl_enum_type(TYPENAME) TYPENAME##_ENUM, edouard@224: #define __decl_enum_pointer(TYPENAME) TYPENAME##_P_ENUM, laurent@235: #define __decl_enum_output(TYPENAME) TYPENAME##_O_ENUM, etisserant@137: typedef enum{ etisserant@137: ANY(__decl_enum_type) edouard@224: ANY(__decl_enum_pointer) laurent@235: ANY(__decl_enum_output) edouard@224: /* SFC specific types are never external or global */ edouard@224: UNKNOWN_ENUM etisserant@137: } __IEC_types_enum; etisserant@137: etisserant@137: /* Get size of type from its number */ edouard@224: #define __decl_size_case(TYPENAME) \ edouard@224: case TYPENAME##_ENUM:\ edouard@224: case TYPENAME##_P_ENUM:\ edouard@224: return sizeof(TYPENAME); etisserant@137: static inline USINT __get_type_enum_size(__IEC_types_enum t){ etisserant@137: switch(t){ etisserant@137: ANY(__decl_size_case) etisserant@137: /* size do not correspond to real struct. etisserant@137: * only a bool is used to represent state*/ edouard@224: default: edouard@224: return 0; etisserant@137: } laurent@199: return 0; etisserant@137: } etisserant@137: etisserant@137: #endif /*IEC_TYPES_ALL_H*/