Newer
Older
SCADA / plc / GRFICS_Workstation_Docs / Documents / chemical / build / POUS.h
root on 8 May 2022 12 KB playing with modbus day #1
#include "beremiz.h"
#ifndef __POUS_H
#define __POUS_H

#include "accessor.h"
#include "iec_std_lib.h"

__DECLARE_ENUMERATED_TYPE(LOGLEVEL,
  LOGLEVEL__CRITICAL,
  LOGLEVEL__WARNING,
  LOGLEVEL__INFO,
  LOGLEVEL__DEBUG
)
// FUNCTION_BLOCK LOGGER
// Data part
typedef struct {
  // FB Interface - IN, OUT, IN_OUT variables
  __DECLARE_VAR(BOOL,EN)
  __DECLARE_VAR(BOOL,ENO)
  __DECLARE_VAR(BOOL,TRIG)
  __DECLARE_VAR(STRING,MSG)
  __DECLARE_VAR(LOGLEVEL,LEVEL)

  // FB private variables - TEMP, private and located variables
  __DECLARE_VAR(BOOL,TRIG0)

} LOGGER;

void LOGGER_init__(LOGGER *data__, BOOL retain);
// Code part
void LOGGER_body__(LOGGER *data__);
// FUNCTION_BLOCK PYTHON_EVAL
// Data part
typedef struct {
  // FB Interface - IN, OUT, IN_OUT variables
  __DECLARE_VAR(BOOL,EN)
  __DECLARE_VAR(BOOL,ENO)
  __DECLARE_VAR(BOOL,TRIG)
  __DECLARE_VAR(STRING,CODE)
  __DECLARE_VAR(BOOL,ACK)
  __DECLARE_VAR(STRING,RESULT)

  // FB private variables - TEMP, private and located variables
  __DECLARE_VAR(DWORD,STATE)
  __DECLARE_VAR(STRING,BUFFER)
  __DECLARE_VAR(STRING,PREBUFFER)
  __DECLARE_VAR(BOOL,TRIGM1)
  __DECLARE_VAR(BOOL,TRIGGED)

} PYTHON_EVAL;

void PYTHON_EVAL_init__(PYTHON_EVAL *data__, BOOL retain);
// Code part
void PYTHON_EVAL_body__(PYTHON_EVAL *data__);
// FUNCTION_BLOCK PYTHON_POLL
// Data part
typedef struct {
  // FB Interface - IN, OUT, IN_OUT variables
  __DECLARE_VAR(BOOL,EN)
  __DECLARE_VAR(BOOL,ENO)
  __DECLARE_VAR(BOOL,TRIG)
  __DECLARE_VAR(STRING,CODE)
  __DECLARE_VAR(BOOL,ACK)
  __DECLARE_VAR(STRING,RESULT)

  // FB private variables - TEMP, private and located variables
  __DECLARE_VAR(DWORD,STATE)
  __DECLARE_VAR(STRING,BUFFER)
  __DECLARE_VAR(STRING,PREBUFFER)
  __DECLARE_VAR(BOOL,TRIGM1)
  __DECLARE_VAR(BOOL,TRIGGED)

} PYTHON_POLL;

void PYTHON_POLL_init__(PYTHON_POLL *data__, BOOL retain);
// Code part
void PYTHON_POLL_body__(PYTHON_POLL *data__);
// FUNCTION_BLOCK PYTHON_GEAR
// Data part
typedef struct {
  // FB Interface - IN, OUT, IN_OUT variables
  __DECLARE_VAR(BOOL,EN)
  __DECLARE_VAR(BOOL,ENO)
  __DECLARE_VAR(UINT,N)
  __DECLARE_VAR(BOOL,TRIG)
  __DECLARE_VAR(STRING,CODE)
  __DECLARE_VAR(BOOL,ACK)
  __DECLARE_VAR(STRING,RESULT)

  // FB private variables - TEMP, private and located variables
  PYTHON_EVAL PY_EVAL;
  __DECLARE_VAR(UINT,COUNTER)
  __DECLARE_VAR(UINT,ADD10_OUT)
  __DECLARE_VAR(BOOL,EQ13_OUT)
  __DECLARE_VAR(UINT,SEL15_OUT)
  __DECLARE_VAR(BOOL,AND7_OUT)

} PYTHON_GEAR;

void PYTHON_GEAR_init__(PYTHON_GEAR *data__, BOOL retain);
// Code part
void PYTHON_GEAR_body__(PYTHON_GEAR *data__);
// FUNCTION_BLOCK SCALE_TO_REAL
// Data part
typedef struct {
  // FB Interface - IN, OUT, IN_OUT variables
  __DECLARE_VAR(BOOL,EN)
  __DECLARE_VAR(BOOL,ENO)
  __DECLARE_VAR(UINT,RAW_INPUT_VALUE)
  __DECLARE_VAR(REAL,SCALED_REAL)
  __DECLARE_VAR(REAL,REAL_MAX)
  __DECLARE_VAR(REAL,REAL_MIN)

  // FB private variables - TEMP, private and located variables
  __DECLARE_VAR(UINT,RAW_MAX)
  __DECLARE_VAR(UINT,RAW_MIN)
  __DECLARE_VAR(REAL,RATE)
  __DECLARE_VAR(REAL,OFFSET)

} SCALE_TO_REAL;

void SCALE_TO_REAL_init__(SCALE_TO_REAL *data__, BOOL retain);
// Code part
void SCALE_TO_REAL_body__(SCALE_TO_REAL *data__);
// FUNCTION_BLOCK SCALE_TO_UINT
// Data part
typedef struct {
  // FB Interface - IN, OUT, IN_OUT variables
  __DECLARE_VAR(BOOL,EN)
  __DECLARE_VAR(BOOL,ENO)
  __DECLARE_VAR(REAL,REAL_IN)
  __DECLARE_VAR(UINT,UINT_OUT)

  // FB private variables - TEMP, private and located variables
  __DECLARE_VAR(REAL,DIV1_OUT)
  __DECLARE_VAR(REAL,MUL4_OUT)
  __DECLARE_VAR(UINT,REAL_TO_UINT6_OUT)

} SCALE_TO_UINT;

void SCALE_TO_UINT_init__(SCALE_TO_UINT *data__, BOOL retain);
// Code part
void SCALE_TO_UINT_body__(SCALE_TO_UINT *data__);
// FUNCTION_BLOCK COMPOSITION_CONTROL
// Data part
typedef struct {
  // FB Interface - IN, OUT, IN_OUT variables
  __DECLARE_VAR(BOOL,EN)
  __DECLARE_VAR(BOOL,ENO)
  __DECLARE_VAR(UINT,A_IN_PURGE)
  __DECLARE_VAR(UINT,A_SETPOINT)
  __DECLARE_VAR(UINT,CURR_POS)
  __DECLARE_VAR(UINT,NEW_POS)

  // FB private variables - TEMP, private and located variables
  __DECLARE_VAR(REAL,A_IN_PURGE_REAL)
  __DECLARE_VAR(REAL,A_SETPOINT_REAL)
  __DECLARE_VAR(REAL,VALVE_POS_REAL)
  __DECLARE_VAR(REAL,POS_UPDATE_REAL)
  __DECLARE_VAR(REAL,VALVE_POS_NOMINAL)
  __DECLARE_VAR(REAL,COMPOSITION_K)
  __DECLARE_VAR(REAL,COMPOSITION_TI)
  __DECLARE_VAR(TIME,CYCLE_TIME)
  SCALE_TO_REAL SCALE_TO_REAL3;
  SCALE_TO_REAL SCALE_TO_REAL2;
  SCALE_TO_UINT SCALE_TO_UINT0;
  __DECLARE_VAR(REAL,COMP_MAX)
  __DECLARE_VAR(REAL,COMP_MIN)
  __DECLARE_VAR(REAL,POS_MAX)
  __DECLARE_VAR(REAL,POS_MIN)
  SCALE_TO_REAL SCALE_TO_REAL0;
  __DECLARE_VAR(REAL,SUB45_OUT)
  __DECLARE_VAR(REAL,MUL46_OUT)
  __DECLARE_VAR(REAL,ADD42_OUT)
  __DECLARE_VAR(REAL,LIMIT44_OUT)

} COMPOSITION_CONTROL;

void COMPOSITION_CONTROL_init__(COMPOSITION_CONTROL *data__, BOOL retain);
// Code part
void COMPOSITION_CONTROL_body__(COMPOSITION_CONTROL *data__);
// FUNCTION_BLOCK INITIALIZE_SP
// Data part
typedef struct {
  // FB Interface - IN, OUT, IN_OUT variables
  __DECLARE_VAR(BOOL,EN)
  __DECLARE_VAR(BOOL,ENO)
  __DECLARE_VAR(UINT,FLOW_SP)
  __DECLARE_VAR(UINT,A_SP)
  __DECLARE_VAR(UINT,PRESS_SP)
  __DECLARE_VAR(UINT,OVER_SP)
  __DECLARE_VAR(UINT,LEVEL_SP)

  // FB private variables - TEMP, private and located variables
  __DECLARE_VAR(UINT,FLOW_SP_C)
  __DECLARE_VAR(UINT,A_SP_C)
  __DECLARE_VAR(UINT,PRESS_SP_C)
  __DECLARE_VAR(UINT,OVER_SP_C)
  __DECLARE_VAR(UINT,LEVEL_SP_C)
  __DECLARE_VAR(UINT,MOVE3_OUT)
  __DECLARE_VAR(UINT,MOVE7_OUT)
  __DECLARE_VAR(UINT,MOVE11_OUT)
  __DECLARE_VAR(UINT,MOVE15_OUT)
  __DECLARE_VAR(UINT,MOVE19_OUT)

} INITIALIZE_SP;

void INITIALIZE_SP_init__(INITIALIZE_SP *data__, BOOL retain);
// Code part
void INITIALIZE_SP_body__(INITIALIZE_SP *data__);
// FUNCTION_BLOCK PRESSURE_CONTROL
// Data part
typedef struct {
  // FB Interface - IN, OUT, IN_OUT variables
  __DECLARE_VAR(BOOL,EN)
  __DECLARE_VAR(BOOL,ENO)
  __DECLARE_VAR(UINT,PRESSURE)
  __DECLARE_VAR(UINT,PRESSURE_SP)
  __DECLARE_VAR(UINT,CURR_POS)
  __DECLARE_VAR(UINT,VALVE_POS)

  // FB private variables - TEMP, private and located variables
  __DECLARE_VAR(REAL,PRESSURE_REAL)
  __DECLARE_VAR(REAL,PRESSURE_SP_REAL)
  __DECLARE_VAR(REAL,VALVE_POS_REAL)
  __DECLARE_VAR(REAL,POS_UPDATE_REAL)
  __DECLARE_VAR(REAL,VALVE_POS_NOMINAL)
  __DECLARE_VAR(REAL,PRESSURE_K)
  __DECLARE_VAR(REAL,PRESSURE_TI)
  __DECLARE_VAR(TIME,CYCLE_TIME)
  SCALE_TO_REAL SCALE_TO_REAL5;
  SCALE_TO_REAL SCALE_TO_REAL4;
  SCALE_TO_UINT SCALE_TO_UINT0;
  __DECLARE_VAR(REAL,PRESSURE_MAX)
  __DECLARE_VAR(REAL,PRESSURE_MIN)
  __DECLARE_VAR(REAL,POS_MIN)
  __DECLARE_VAR(REAL,POS_MAX)
  SCALE_TO_REAL SCALE_TO_REAL0;
  __DECLARE_VAR(REAL,SUB57_OUT)
  __DECLARE_VAR(REAL,MUL60_OUT)
  __DECLARE_VAR(REAL,SUB53_OUT)
  __DECLARE_VAR(REAL,LIMIT55_OUT)

} PRESSURE_CONTROL;

void PRESSURE_CONTROL_init__(PRESSURE_CONTROL *data__, BOOL retain);
// Code part
void PRESSURE_CONTROL_body__(PRESSURE_CONTROL *data__);
// FUNCTION_BLOCK FLOW_CONTROL
// Data part
typedef struct {
  // FB Interface - IN, OUT, IN_OUT variables
  __DECLARE_VAR(BOOL,EN)
  __DECLARE_VAR(BOOL,ENO)
  __DECLARE_VAR(UINT,PRODUCT_FLOW)
  __DECLARE_VAR(UINT,NEW_POS)
  __DECLARE_VAR(UINT,CURR_POS)
  __DECLARE_VAR(UINT,FLOW_SET_IN)

  // FB private variables - TEMP, private and located variables
  __DECLARE_VAR(REAL,FLOW_K)
  __DECLARE_VAR(REAL,FLOW_TI)
  __DECLARE_VAR(REAL,FLOW_TD)
  __DECLARE_VAR(REAL,PRODUCT_FLOW_REAL)
  __DECLARE_VAR(TIME,CYCLE_TIME)
  __DECLARE_VAR(REAL,POS_UPDATE_REAL)
  __DECLARE_VAR(REAL,CURR_POS_REAL)
  __DECLARE_VAR(REAL,FLOW_SET_REAL)
  SCALE_TO_REAL SCALE_TO_REAL0;
  SCALE_TO_REAL SCALE_TO_REAL1;
  __DECLARE_VAR(REAL,FLOW_MAX)
  __DECLARE_VAR(REAL,FLOW_MIN)
  __DECLARE_VAR(REAL,POS_MIN)
  __DECLARE_VAR(REAL,POS_MAX)
  SCALE_TO_REAL SCALE_TO_REAL2;
  SCALE_TO_UINT SCALE_TO_UINT0;
  __DECLARE_VAR(REAL,SUB59_OUT)
  __DECLARE_VAR(REAL,MUL60_OUT)
  __DECLARE_VAR(REAL,ADD58_OUT)
  __DECLARE_VAR(REAL,LIMIT40_OUT)

} FLOW_CONTROL;

void FLOW_CONTROL_init__(FLOW_CONTROL *data__, BOOL retain);
// Code part
void FLOW_CONTROL_body__(FLOW_CONTROL *data__);
// FUNCTION_BLOCK LEVEL_CONTROL
// Data part
typedef struct {
  // FB Interface - IN, OUT, IN_OUT variables
  __DECLARE_VAR(BOOL,EN)
  __DECLARE_VAR(BOOL,ENO)
  __DECLARE_VAR(UINT,LIQUID_LEVEL)
  __DECLARE_VAR(UINT,LEVEL_SP)
  __DECLARE_VAR(UINT,CURR_POS)
  __DECLARE_VAR(UINT,NEW_POS)

  // FB private variables - TEMP, private and located variables
  __DECLARE_VAR(TIME,CYCLE_TIME)
  __DECLARE_VAR(REAL,LEVEL_K)
  __DECLARE_VAR(REAL,LEVEL_TI)
  SCALE_TO_REAL SCALE_TO_REAL0;
  __DECLARE_VAR(REAL,LEVEL_MAX)
  __DECLARE_VAR(REAL,LEVEL_MIN)
  __DECLARE_VAR(REAL,POS_MAX)
  __DECLARE_VAR(REAL,POS_MIN)
  __DECLARE_VAR(REAL,LEVEL_REAL)
  __DECLARE_VAR(REAL,POS_REAL)
  __DECLARE_VAR(REAL,POS_UPDATE_REAL)
  __DECLARE_VAR(REAL,SP_REAL)
  SCALE_TO_REAL SCALE_TO_REAL1;
  SCALE_TO_REAL SCALE_TO_REAL2;
  SCALE_TO_UINT SCALE_TO_UINT0;
  __DECLARE_VAR(REAL,SUB32_OUT)
  __DECLARE_VAR(REAL,MUL33_OUT)
  __DECLARE_VAR(REAL,SUB30_OUT)
  __DECLARE_VAR(REAL,LIMIT25_OUT)

} LEVEL_CONTROL;

void LEVEL_CONTROL_init__(LEVEL_CONTROL *data__, BOOL retain);
// Code part
void LEVEL_CONTROL_body__(LEVEL_CONTROL *data__);
// FUNCTION_BLOCK PRESSURE_OVERRIDE
// Data part
typedef struct {
  // FB Interface - IN, OUT, IN_OUT variables
  __DECLARE_VAR(BOOL,EN)
  __DECLARE_VAR(BOOL,ENO)
  __DECLARE_VAR(UINT,PRESSURE)
  __DECLARE_VAR(UINT,CURR_SP)
  __DECLARE_VAR(UINT,PRODUCT_SP)
  __DECLARE_VAR(UINT,OVERRIDE_SP)

  // FB private variables - TEMP, private and located variables
  __DECLARE_VAR(REAL,PRESSURE_REAL)
  __DECLARE_VAR(REAL,CURR_SP_REAL)
  __DECLARE_VAR(REAL,PRODUCT_SP_REAL)
  __DECLARE_VAR(REAL,SP_UPDATE)
  __DECLARE_VAR(REAL,PRODUCT_SP_NOMINL)
  __DECLARE_VAR(REAL,OVERRIDE_SP_REAL)
  __DECLARE_VAR(REAL,OVERRIDE_K)
  __DECLARE_VAR(REAL,OVERRIDE_TI)
  __DECLARE_VAR(TIME,CYCLE_TIME)
  SCALE_TO_REAL SCALE_TO_REAL7;
  __DECLARE_VAR(REAL,PRESSURE_MAX)
  __DECLARE_VAR(REAL,PRESSURE_MIN)
  __DECLARE_VAR(REAL,FLOW_MAX)
  __DECLARE_VAR(REAL,FLOW_MIN)
  SCALE_TO_REAL SCALE_TO_REAL0;
  __DECLARE_VAR(REAL,SUB86_OUT)
  __DECLARE_VAR(REAL,MUL87_OUT)
  __DECLARE_VAR(REAL,MAX84_OUT)
  __DECLARE_VAR(REAL,ADD85_OUT)
  __DECLARE_VAR(REAL,LIMIT67_OUT)
  __DECLARE_VAR(REAL,DIV73_OUT)
  __DECLARE_VAR(REAL,MUL75_OUT)
  __DECLARE_VAR(UINT,REAL_TO_UINT79_OUT)

} PRESSURE_OVERRIDE;

void PRESSURE_OVERRIDE_init__(PRESSURE_OVERRIDE *data__, BOOL retain);
// Code part
void PRESSURE_OVERRIDE_body__(PRESSURE_OVERRIDE *data__);
// PROGRAM MAIN
// Data part
typedef struct {
  // PROGRAM Interface - IN, OUT, IN_OUT variables

  // PROGRAM private variables - TEMP, private and located variables
  FLOW_CONTROL FLOW_CONTROL0;
  __DECLARE_VAR(BOOL,FIRST_RUN)
  __DECLARE_VAR(UINT,FLOW_SET)
  __DECLARE_VAR(UINT,A_SETPOINT)
  __DECLARE_VAR(UINT,PRESSURE_SP)
  __DECLARE_VAR(UINT,OVERRIDE_SP)
  __DECLARE_VAR(UINT,LEVEL_SP)
  COMPOSITION_CONTROL COMPOSITION_CONTROL0;
  __DECLARE_VAR(UINT,F1_VALVE_POS)
  __DECLARE_VAR(UINT,F1_FLOW)
  __DECLARE_VAR(UINT,F2_VALVE_POS)
  __DECLARE_VAR(UINT,F2_FLOW)
  __DECLARE_VAR(UINT,PURGE_VALVE_POS)
  __DECLARE_VAR(UINT,PURGE_FLOW)
  __DECLARE_VAR(UINT,PRODUCT_VALVE_POS)
  __DECLARE_VAR(UINT,PRODUCT_FLOW)
  __DECLARE_VAR(UINT,PRESSURE)
  __DECLARE_VAR(UINT,LEVEL)
  __DECLARE_VAR(UINT,A_IN_PURGE)
  __DECLARE_VAR(UINT,B_IN_PURGE)
  __DECLARE_VAR(UINT,C_IN_PURGE)
  __DECLARE_VAR(UINT,F1_VALVE_SP)
  __DECLARE_VAR(UINT,F2_VALVE_SP)
  __DECLARE_VAR(UINT,PURGE_VALVE_SP)
  __DECLARE_VAR(UINT,PRODUCT_VALVE_SP)
  __DECLARE_VAR(UINT,PRODUCT_VALVE_SAFE)
  __DECLARE_VAR(UINT,PURGE_VALVE_SAFE)
  __DECLARE_VAR(UINT,F1_VALVE_SAFE)
  __DECLARE_VAR(UINT,F2_VALVE_SAFE)
  PRESSURE_CONTROL PRESSURE_CONTROL0;
  __DECLARE_VAR(INT,HMI_PRESSURE)
  __DECLARE_VAR(INT,HMI_LEVEL)
  __DECLARE_VAR(INT,HMI_F1_VALVE_POS)
  __DECLARE_VAR(INT,HMI_F1_FLOW)
  __DECLARE_VAR(INT,HMI_F2_VALVE_POS)
  __DECLARE_VAR(INT,HMI_F2_FLOW)
  __DECLARE_VAR(INT,HMI_PURGE_VALVE_POS)
  __DECLARE_VAR(INT,HMI_PURGE_FLOW)
  __DECLARE_VAR(INT,HMI_PRODUCT_VALVE_POS)
  __DECLARE_VAR(INT,HMI_PRODUCT_FLOW)
  __DECLARE_VAR(UINT,SCAN_COUNT)
  PRESSURE_OVERRIDE PRESSURE_OVERRIDE0;
  LEVEL_CONTROL LEVEL_CONTROL0;
  __DECLARE_VAR(BOOL,RUN_BIT)
  __DECLARE_VAR(BOOL,RUN_BIT0)
  INITIALIZE_SP INITIALIZE_SP0;
  __DECLARE_VAR(BOOL,MOVE99_ENO)
  __DECLARE_VAR(UINT,MOVE99_OUT)
  __DECLARE_VAR(BOOL,MOVE4_ENO)
  __DECLARE_VAR(UINT,MOVE4_OUT)
  __DECLARE_VAR(BOOL,MOVE5_ENO)
  __DECLARE_VAR(UINT,MOVE5_OUT)
  __DECLARE_VAR(BOOL,MOVE7_ENO)
  __DECLARE_VAR(UINT,MOVE7_OUT)

} MAIN;

void MAIN_init__(MAIN *data__, BOOL retain);
// Code part
void MAIN_body__(MAIN *data__);
#endif //__POUS_H