//高警告
//PV_WH_Lim
IF PV_WH_EN THEN
IF (PV_Out >=PV_WH_Lim) AND NOT PV_WH_Act THEN
rPV_W_DC:=rPV_W_DC+SampleTime;
IFrPV_W_DC > PV_W_DC THEN
PV_WH_Act := TRUE;
rPV_W_DC:=0.0;
END_IF;
ELSIF (PV_Out< (PV_WH_Lim - rPV_Hyst))AND PV_WH_Act THEN
rPV_W_DG:=rPV_W_DG+SampleTime;
IFrPV_W_DG > PV_W_DG THEN
PV_WH_Act := FALSE;
rPV_W_DG:=0.0;
END_IF;
ELSE
PV_WH_Act:=FALSE;
END_IF;
//低警告
//PV_WL_Lim
IF PV_WL_EN THEN
IF (PV_Out <=PV_WL_Lim) AND NOT PV_WL_Act THEN
PV_WL_Act := TRUE;
ELSIF (PV_Out> (PV_WL_Lim + rPV_Hyst))AND PV_WL_Act THEN
PV_WL_Act := FALSE;
END_IF;
ELSE
PV_WL_Act:=FALSE;
END_IF;
//低低报警
//PV_AL_Lim
IF PV_AL_EN THEN
IF (PV_Out <=PV_AL_Lim ) AND NOT PV_AL_Act THEN
rPV_A_DC:=rPV_A_DC+SampleTime;
IFrPV_A_DC > PV_A_DC THEN
PV_AL_Act := TRUE;
rPV_A_DC:=0.0;
ELSIF (PV_Out> (PV_AL_Lim + rPV_Hyst))AND PV_AL_Act THEN
rPV_A_DG:=rPV_A_DG+SampleTime;
IFrPV_A_DG > PV_A_DG THEN
PV_AL_Act := FALSE;
rPV_A_DG:=0.0;
ELSE
PV_AL_Act:=FALSE;
END_IF;
//操作权限字
// Permission control
xPermPLC[10] := NOT SimOn ;
xPermPLC[11] := SimOn;
bPerm[0] :=bPermPLC[3];
bPerm[1] :=bPermPLC[2];
bPerm[2] :=bPermPLC[1];
bPerm[3] :=bPermPLC[0];
//状态字
// Set Status1 for HMI
xStatus1PLC[0] := Bad1;
xStatus1PLC[1] := Bad2;
xStatus1PLC[2] := Bad3;
xStatus1PLC[3] := Bad4;
xStatus1PLC[4] := Bad5;
xStatus1PLC[5] := Bad6;
xStatus1PLC[6] := Bad7;
xStatus1PLC[7] := Bad8;
xStatus1PLC[8] := 0;
xStatus1PLC[9] := 0;
xStatus1PLC[10] := 0;
xStatus1PLC[11] := 0;
xStatus1PLC[12] := 0;
xStatus1PLC[13] := 0;
xStatus1PLC[14] := 0;
xStatus1PLC[15] := 0;
xStatus1PLC[16] := 0;
xStatus1PLC[17] := 0;
xStatus1PLC[18] := SimOn;
xStatus1PLC[19] := 0;
xStatus1PLC[20] := PV_AH_EN;
xStatus1PLC[21] := PV_WH_EN;
xStatus1PLC[22] := PV_WL_EN;
xStatus1PLC[23] := PV_AL_EN;
xStatus1PLC[24] := 0;
xStatus1PLC[25] := 0;
xStatus1PLC[26] := PV_WH_Act ORPV_WL_Act;
xStatus1PLC[27] := PV_AH_Act ORPV_AL_Act;
xStatus1PLC[28] := PV_AH_Act;
xStatus1PLC[29] := PV_WH_Act;
xStatus1PLC[30] := PV_WL_Act;
xStatus1PLC[31] := PV_AL_Act;
bStatus1[0] :=bStatus1PLC[3];
bStatus1[1] :=bStatus1PLC[2];
bStatus1[2] :=bStatus1PLC[1];
bStatus1[3] :=bStatus1PLC[0];
//报警字
// Bit alarm procedure
xAlarmPLC[0] := PV_AH_Act;
xAlarmPLC[1] := PV_WH_Act;
xAlarmPLC[2] := PV_WL_Act;
xAlarmPLC[3] := PV_AL_Act;
xAlarmPLC[4] := 0;
xAlarmPLC[5] := 0;
xAlarmPLC[6] := 0;
xAlarmPLC[7] := 0;
xAlarmPLC[8] := Bad1;
xAlarmPLC[9] := Bad2;
xAlarmPLC[10] :=Bad3;
xAlarmPLC[11] :=Bad4;
xAlarmPLC[12] :=Bad5;
xAlarmPLC[13] :=Bad6;
xAlarmPLC[14] :=Bad7;
xAlarmPLC[15] :=Bad8;
bAlarm[0] := bAlarmPLC[1];
bAlarm[1] := bAlarmPLC[0];
PV_AL_C_Old := PV_AL_C;
PV_WL_C_Old := PV_WL_C;
PV_AL_G_Old := PV_AL_G;
PV_WL_G_Old := PV_WL_G;
//reset commands
OpCmd := 16#0;
END_FUNCTION_BLOCK