VAR_IN_OUT
OpCmd {S7_m_c:='true';S7_visible:='false' }: DWORD :=16#0; // control word wincc
END_VAR
VAR_OUTPUT
Status1 {S7_m_c:='true';S7_visible:='false'} : DWORD:=0; // Status WinCC
bStatus1 AT Status1 : ARRAY [0..3] OF BYTE; // look at Status1 byte-wise
OS_PermOut {S7_m_c:='true';S7_visible:='false'}: DWORD :=16#FFFFFFFF;// Permssion word wincc
bPerm AT OS_PermOut: ARRAY [0..3] OF BYTE;
Alarm {S7_m_c:='true';S7_visible:='false'} : WORD := 16#0; // Bit Alarm Procedure
bAlarm AT Alarm : ARRAY [0..1] OF BYTE; // look at QwAlarm byte-wise
PV_Out {S7_m_c:='true'; S7_archive:='shortterm'} : REAL := 0.0; // Process Value out
PV_AH_Act {S7_dynamic:='true'}: BOOL := FALSE; // H Alarm is Active
PV_WH_Act {S7_dynamic:='true'}: BOOL := FALSE; // H Warning is Active
PV_WL_Act {S7_dynamic:='true'}: BOOL := FALSE; // L Warning is Active
PV_AL_Act {S7_dynamic:='true'} : BOOL := FALSE; // L Alarm is Active
AvePV{S7_m_c:='true';S7_visible:='false'}:REAL;
MaxPV{S7_m_c:='true';S7_visible:='false'}:REAL;
MinPV{S7_m_c:='true';S7_visible:='false'}:REAL;
END_VAR
VAR
dwCmdHMI : DWORD := 16#0;
bCmdHMI AT dwCmdHMI : ARRAY [0..3] OF BYTE;
dwCmdPLC : DWORD := 16#0;
bCmdPLC AT dwCmdPLC : ARRAY [0..3] OF BYTE;
xCmdPLC AT dwCmdPLC : ARRAY [0..31] OF BOOL;
dwStatus1PLC : DWORD := 16#0;
bStatus1PLC AT dwStatus1PLC : ARRAY [0..3] OF BYTE;
xStatus1PLC AT dwStatus1PLC : ARRAY [0..31] OF BOOL;
dwPermPLC : DWORD := 16#FFFFFFFF;
bPermPLC AT dwPermPLC : ARRAY [0..3] OF BYTE;
xPermPLC AT dwPermPLC : ARRAY [0..31] OF BOOL;
wAlarmPLC : WORD := 16#0;
bAlarmPLC AT wAlarmPLC : ARRAY [0..1] OF BYTE;
xAlarmPLC AT wAlarmPLC : ARRAY [0..15] OF BOOL;
rPV_A_DC : REAL:= 0.0;
rPV_W_DC : REAL:= 0.0;
rPV_A_DG : REAL:= 0.0;
rPV_W_DG : REAL:= 0.0;
PV_AL_C,PV_AL_G,PV_WL_G,PV_WL_C:BOOL;
PV_AL_C_Old,PV_WL_C_Old,PV_AL_G_Old,PV_WL_G_Old:BOOL;
rPV_Hyst : REAL := 0.0;
rPV:REAL;
END_VAR
VAR_TEMP
rPVsExchange: REAL;
xBadsExchange:BOOL;
rPVsAdd: REAL;
aryPVs:ARRAY[1..8]OF REAL;
aryBads:ARRAY[1..8]OF BOOL;
iBadCount:INT;
iIndex1,iIndex2,iIndex3:INT;
END_VAR
—————————————————————————————————————————————————
BEGIN
// Change lowbyte to highbyte for HMI command word
dwCmdHMI := OpCmd;
bCmdPLC[0] := bCmdHMI[3];
bCmdPLC[1] := bCmdHMI[2];
bCmdPLC[2] := bCmdHMI[1];
bCmdPLC[3] := bCmdHMI[0];
//-----------------------------------------------------------------
// Begin: Operation functions
//-----------------------------------------------------------------
//限幅操作
// Toggle Message 1-4 ON/OFF
IF (xCmdPLC[12] ) THEN
PV_AH_EN := NOT PV_AH_EN;
END_IF;
IF (xCmdPLC[13] ) THEN
PV_WH_EN := NOT PV_WH_EN;
END_IF;
IF (xCmdPLC[14] ) THEN
PV_WL_EN := NOT PV_WL_EN;
END_IF;
IF (xCmdPLC[15] ) THEN
PV_AL_EN := NOT PV_AL_EN;
END_IF;
// Simulation Toggle
IF xCmdPLC[10] THEN
SimOn:= TRUE;
ELSIF xCmdPLC[11] THEN
SimOn:= FALSE;
END_IF;
// END: Operation functions
aryBads[1]:=Bad1;
aryBads[2]:=Bad2;
aryBads[3]:=Bad3;
aryBads[4]:=Bad4;
aryBads[5]:=Bad5;
aryBads[6]:=Bad6;
aryBads[7]:=Bad7;
aryBads[8]:=Bad8;
aryPVs[1]:=PV1;
aryPVs[2]:=PV2;
aryPVs[3]:=PV3;
aryPVs[4]:=PV4;
aryPVs[5]:=PV5;
aryPVs[6]:=PV6;
aryPVs[7]:=PV7;
aryPVs[8]:=PV8;