Files
Uniper_PLC/PLC/POUs/FB_Module.TcPOU

505 lines
15 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<TcPlcObject Version="1.1.0.1" ProductVersion="3.1.4024.12">
<POU Name="FB_Module" Id="{87be924f-018d-4c09-997b-f0c0054414cc}" SpecialFunc="None">
<Declaration><![CDATA[FUNCTION_BLOCK FB_Module
VAR_INPUT
// Emergency stop ok
xEmergencyStopOk : BOOL;
// Enable
xEnable : BOOL;
// Module completely off
xOff : BOOL := TRUE;
// All safetyinterlocks are ok
xSafetyIntlksOk : BOOL;
// HMI Interface
stHMIInterface : REFERENCE TO ST_MODULE_HMI_INTERFACE;
// Release alarms
xReleaseErrors : BOOL;
// Release analog io limit errors
xReleaseLimitErrors : BOOL;
// Release manual mode
xReleaseManualMode : BOOL;
// Input to confirm all errors
xConfirmAlarms : BOOL;
END_VAR
VAR_OUTPUT
// Module voltage
rCurrentVoltage : REAL;
// Module ready
xReady : BOOL;
// Module in shutdown segment discharge mode
xInShutdownDischargeMode : BOOL;
// Module can be discharged during shutdown sequence
xShutdownDischargeAllowed : BOOL;
// One unit has an error
xError : BOOL;
// One unit has a warning
xWarning : BOOL;
END_VAR
VAR
_fbUnit1 : FB_Unit('Unit 1');
_fbUnit2 : FB_Unit('Unit 2');
_fbUnit3 : FB_Unit('Unit 3');
_fbUnit4 : FB_Unit('Unit 4');
// Flag for unit balance checking
_xBalanceOk : BOOL;
// All units are ready
_xAllUnitsReady : BOOL;
// Units out of balance alarm
_fbUnitsOutOfBalanceAlarm : FB_TcAlarm;
// Module name
_sName : STRING;
END_VAR
]]></Declaration>
<Implementation>
<ST><![CDATA[// Reset error and warning flag
xError := FALSE;
xWarning := FALSE;
// Reset safety interlocks flag
xSafetyIntlksOk := TRUE;
// ===============================
// Unit 1
// ===============================
_fbUnit1(
xEnable := xEnable,
stUnitConfig:= GVL_CONFIG.stUnitConfig,
stHMIInterface:= stHMIInterface.stHMIInterfaceUnit1,
xEmergencyStopOk:= xEmergencyStopOk,
rSetpointPosolytPumpInlet:= GVL_CONFIG.rPumpPosolytOnPower,
rSetpointNegolytPumpInlet:= GVL_CONFIG.rPumpNegolytOnPower,
xReleaseErrors:= xReleaseErrors,
xReleaseLimitErrors:= xReleaseLimitErrors,
xConfirmAlarms:= xConfirmAlarms,
xReleaseManualMode := xReleaseManualMode,
_xWarningConfirmPending=> );
IF _fbUnit1.xWarning THEN
xWarning := TRUE;
END_IF
IF _fbUnit1.xError THEN
xError := TRUE;
END_IF
IF NOT _fbUnit1.xSafetyIntlksOk THEN
xSafetyIntlksOk := FALSE;
END_IF
// ===============================
// Unit 2
// ===============================
_fbUnit2(
xEnable := xEnable,
stUnitConfig:= GVL_CONFIG.stUnitConfig,
stHMIInterface:= stHMIInterface.stHMIInterfaceUnit2,
xEmergencyStopOk:= xEmergencyStopOk,
rSetpointPosolytPumpInlet:= GVL_CONFIG.rPumpPosolytOnPower,
rSetpointNegolytPumpInlet:= GVL_CONFIG.rPumpNegolytOnPower,
xReleaseErrors:= xReleaseErrors,
xReleaseLimitErrors:= xReleaseLimitErrors,
xConfirmAlarms:= xConfirmAlarms,
xReleaseManualMode := xReleaseManualMode,
_xWarningConfirmPending=> );
IF _fbUnit2.xWarning THEN
xWarning := TRUE;
END_IF
IF _fbUnit2.xError THEN
xError := TRUE;
END_IF
IF NOT _fbUnit2.xSafetyIntlksOk THEN
xSafetyIntlksOk := FALSE;
END_IF
// ===============================
// Unit 3
// ===============================
_fbUnit3(
xEnable := xEnable,
stUnitConfig:= GVL_CONFIG.stUnitConfig,
stHMIInterface:= stHMIInterface.stHMIInterfaceUnit3,
xEmergencyStopOk:= xEmergencyStopOk,
rSetpointPosolytPumpInlet:= GVL_CONFIG.rPumpPosolytOnPower,
rSetpointNegolytPumpInlet:= GVL_CONFIG.rPumpNegolytOnPower,
xReleaseErrors:= xReleaseErrors,
xReleaseLimitErrors:= xReleaseLimitErrors,
xConfirmAlarms:= xConfirmAlarms,
xReleaseManualMode := xReleaseManualMode,
_xWarningConfirmPending=> );
IF _fbUnit3.xWarning THEN
xWarning := TRUE;
END_IF
IF _fbUnit3.xError THEN
xError := TRUE;
END_IF
IF NOT _fbUnit3.xSafetyIntlksOk THEN
xSafetyIntlksOk := FALSE;
END_IF
// ===============================
// Unit 4
// ===============================
_fbUnit4(
xEnable := xEnable,
stUnitConfig:= GVL_CONFIG.stUnitConfig,
stHMIInterface:= stHMIInterface.stHMIInterfaceUnit4,
xEmergencyStopOk:= xEmergencyStopOk,
rSetpointPosolytPumpInlet:= GVL_CONFIG.rPumpPosolytOnPower,
rSetpointNegolytPumpInlet:= GVL_CONFIG.rPumpNegolytOnPower,
xReleaseErrors:= xReleaseErrors,
xReleaseLimitErrors:= xReleaseLimitErrors,
xConfirmAlarms:= xConfirmAlarms,
xReleaseManualMode := xReleaseManualMode,
_xWarningConfirmPending=> );
IF _fbUnit4.xWarning THEN
xWarning := TRUE;
END_IF
IF _fbUnit4.xError THEN
xError := TRUE;
END_IF
IF NOT _fbUnit4.xSafetyIntlksOk THEN
xSafetyIntlksOk := FALSE;
END_IF
// ===============================
// Units ready check
// ===============================
_xAllUnitsReady := _fbUnit1.xReady AND _fbUnit2.xReady AND _fbUnit3.xReady AND _fbUnit4.xReady;
// ===============================
// Units in shutdown discharge mode
// ===============================
xInShutdownDischargeMode := _fbUnit1.xInShutdownDischargeMode AND _fbUnit2.xInShutdownDischargeMode AND _fbUnit3.xInShutdownDischargeMode AND _fbUnit4.xInShutdownDischargeMode;
// ===============================
// Units shutdown discharge allowed
// ===============================
xShutdownDischargeAllowed := _fbUnit1.xShutdownDischargeAllowed AND _fbUnit2.xShutdownDischargeAllowed AND _fbUnit3.xShutdownDischargeAllowed AND _fbUnit4.xShutdownDischargeAllowed;
// ===============================
// All units off
// ===============================
xOff := _fbUnit1.xOff AND _fbUnit2.xOff AND _fbUnit3.xOff AND _fbUnit4.xOff;
// ===============================
// Calculate module voltage
// ===============================
rCurrentVoltage := _fbUnit1.rCurrentVoltage + _fbUnit2.rCurrentVoltage + _fbUnit3.rCurrentVoltage + _fbUnit4.rCurrentVoltage;
stHMIInterface.rVoltage := rCurrentVoltage;
// ===============================
// Module balance check
// ===============================
// Reset balance ok flag
_xBalanceOk := TRUE;
// Test unit 1 with unit 2
IF ABS(_fbUnit1.rCurrentVoltage - _fbUnit2.rCurrentVoltage) > GVL_CONFIG.rMaxAbsDiffVoltageUnitsOnModule THEN
_xBalanceOk := FALSE;
END_IF
// Test unit 1 with unit 3
IF ABS(_fbUnit1.rCurrentVoltage - _fbUnit3.rCurrentVoltage) > GVL_CONFIG.rMaxAbsDiffVoltageUnitsOnModule THEN
_xBalanceOk := FALSE;
END_IF
// Test unit 1 with unit 4
IF ABS(_fbUnit1.rCurrentVoltage - _fbUnit4.rCurrentVoltage) > GVL_CONFIG.rMaxAbsDiffVoltageUnitsOnModule THEN
_xBalanceOk := FALSE;
END_IF
// Test unit 2 with unit 3
IF ABS(_fbUnit2.rCurrentVoltage - _fbUnit3.rCurrentVoltage) > GVL_CONFIG.rMaxAbsDiffVoltageUnitsOnModule THEN
_xBalanceOk := FALSE;
END_IF
// Test unit 2 with unit 4
IF ABS(_fbUnit2.rCurrentVoltage - _fbUnit4.rCurrentVoltage) > GVL_CONFIG.rMaxAbsDiffVoltageUnitsOnModule THEN
_xBalanceOk := FALSE;
END_IF
// Test unit 3 with unit 4
IF ABS(_fbUnit3.rCurrentVoltage - _fbUnit4.rCurrentVoltage) > GVL_CONFIG.rMaxAbsDiffVoltageUnitsOnModule THEN
_xBalanceOk := FALSE;
END_IF
// Signal an error if all units are ready and module is out of balance
IF _xAllUnitsReady AND (NOT _xBalanceOk) THEN
xError := TRUE;
END_IF
// Raise error
IF (NOT _xBalanceOk) AND (NOT _fbUnitsOutOfBalanceAlarm.bRaised) THEN
_fbUnitsOutOfBalanceAlarm.Raise(0);
END_IF
// Clear error
IF _xBalanceOk AND _fbUnitsOutOfBalanceAlarm.bRaised THEN
_fbUnitsOutOfBalanceAlarm.Clear(0, FALSE);
END_IF
// Confirm error
IF _fbUnitsOutOfBalanceAlarm.eConfirmationState = TcEventConfirmationState.WaitForConfirmation AND xConfirmAlarms THEN
_fbUnitsOutOfBalanceAlarm.Confirm(0);
END_IF
// ===============================
// Module ready validation check
// ===============================
IF _xAllUnitsReady AND _xBalanceOk THEN
xReady := TRUE;
ELSE
xReady := FALSE;
END_IF
// ===============================
// Module status sum
// ===============================
IF xOff THEN
stHMIInterface.eStatus := E_COMPONENT_STATUS.OFF;
END_IF
IF xReady THEN
stHMIInterface.eStatus := E_COMPONENT_STATUS.ON;
END_IF
IF xError THEN
stHMIInterface.eStatus := E_COMPONENT_STATUS.ERROR;
END_IF]]></ST>
</Implementation>
<Method Name="FB_init" Id="{369c1d27-76e4-45f8-9dbe-03524d3389df}">
<Declaration><![CDATA[METHOD FB_init : BOOL
VAR_INPUT
bInitRetains : BOOL; // if TRUE, the retain variables are initialized (warm start / cold start)
bInCopyCode : BOOL; // if TRUE, the instance afterwards gets moved into the copy code (online change)
sName : STRING;
END_VAR
]]></Declaration>
<Implementation>
<ST><![CDATA[_sName := sName;
// Set unit names
_fbUnit1.Name := CONCAT(_sName, 'Unit 1');
_fbUnit2.Name := CONCAT(_sName, 'Unit 2');
_fbUnit3.Name := CONCAT(_sName, 'Unit 3');
_fbUnit4.Name := CONCAT(_sName, 'Unit 4');
// Create out of balance alarm
_fbUnitsOutOfBalanceAlarm.CreateEx(stEventEntry := TC_EVENTS.BMSEvents.ModuleImbalance, bWithConfirmation := TRUE, 0);
// Create alarm message
_fbUnitsOutOfBalanceAlarm.ipArguments.Clear().AddString(_sName);]]></ST>
</Implementation>
</Method>
<Property Name="Name" Id="{bc8bc990-5071-47c9-a928-a129c60c6f41}">
<Declaration><![CDATA[PROPERTY Name : String]]></Declaration>
<Get Name="Get" Id="{c00a6d41-9156-49b5-aa08-e4cc4c913fca}">
<Declaration><![CDATA[VAR
END_VAR
]]></Declaration>
<Implementation>
<ST><![CDATA[Name := _sName;]]></ST>
</Implementation>
</Get>
<Set Name="Set" Id="{ade5f4d9-ff42-4236-b5fc-e43a53c9ca28}">
<Declaration><![CDATA[VAR
END_VAR
]]></Declaration>
<Implementation>
<ST><![CDATA[_sName := Name;
// Set unit names
_fbUnit1.Name := CONCAT(_sName, ' - Unit 1');
_fbUnit2.Name := CONCAT(_sName, ' - Unit 2');
_fbUnit3.Name := CONCAT(_sName, ' - Unit 3');
_fbUnit4.Name := CONCAT(_sName, ' - Unit 4');
// Create alarm message
_fbUnitsOutOfBalanceAlarm.ipArguments.Clear().AddString(_sName);]]></ST>
</Implementation>
</Set>
</Property>
<LineIds Name="FB_Module">
<LineId Id="248" Count="2" />
<LineId Id="557" Count="1" />
<LineId Id="556" Count="0" />
<LineId Id="575" Count="0" />
<LineId Id="251" Count="4" />
<LineId Id="456" Count="0" />
<LineId Id="256" Count="7" />
<LineId Id="742" Count="0" />
<LineId Id="264" Count="8" />
<LineId Id="560" Count="0" />
<LineId Id="559" Count="0" />
<LineId Id="561" Count="1" />
<LineId Id="273" Count="5" />
<LineId Id="457" Count="0" />
<LineId Id="279" Count="7" />
<LineId Id="743" Count="0" />
<LineId Id="287" Count="8" />
<LineId Id="563" Count="2" />
<LineId Id="296" Count="0" />
<LineId Id="574" Count="0" />
<LineId Id="297" Count="4" />
<LineId Id="458" Count="0" />
<LineId Id="302" Count="7" />
<LineId Id="744" Count="0" />
<LineId Id="310" Count="8" />
<LineId Id="566" Count="2" />
<LineId Id="319" Count="0" />
<LineId Id="573" Count="0" />
<LineId Id="320" Count="4" />
<LineId Id="459" Count="0" />
<LineId Id="325" Count="7" />
<LineId Id="745" Count="0" />
<LineId Id="333" Count="7" />
<LineId Id="188" Count="0" />
<LineId Id="569" Count="2" />
<LineId Id="441" Count="0" />
<LineId Id="572" Count="0" />
<LineId Id="436" Count="0" />
<LineId Id="438" Count="1" />
<LineId Id="437" Count="0" />
<LineId Id="435" Count="0" />
<LineId Id="465" Count="0" />
<LineId Id="464" Count="0" />
<LineId Id="466" Count="1" />
<LineId Id="448" Count="0" />
<LineId Id="469" Count="0" />
<LineId Id="486" Count="0" />
<LineId Id="483" Count="2" />
<LineId Id="482" Count="0" />
<LineId Id="468" Count="0" />
<LineId Id="495" Count="0" />
<LineId Id="491" Count="1" />
<LineId Id="487" Count="0" />
<LineId Id="494" Count="0" />
<LineId Id="493" Count="0" />
<LineId Id="444" Count="0" />
<LineId Id="446" Count="1" />
<LineId Id="445" Count="0" />
<LineId Id="442" Count="0" />
<LineId Id="659" Count="0" />
<LineId Id="440" Count="0" />
<LineId Id="378" Count="3" />
<LineId Id="387" Count="0" />
<LineId Id="389" Count="0" />
<LineId Id="393" Count="0" />
<LineId Id="388" Count="0" />
<LineId Id="404" Count="2" />
<LineId Id="395" Count="0" />
<LineId Id="394" Count="0" />
<LineId Id="408" Count="1" />
<LineId Id="407" Count="0" />
<LineId Id="397" Count="0" />
<LineId Id="396" Count="0" />
<LineId Id="411" Count="1" />
<LineId Id="410" Count="0" />
<LineId Id="399" Count="0" />
<LineId Id="398" Count="0" />
<LineId Id="414" Count="1" />
<LineId Id="413" Count="0" />
<LineId Id="401" Count="0" />
<LineId Id="400" Count="0" />
<LineId Id="417" Count="1" />
<LineId Id="416" Count="0" />
<LineId Id="403" Count="0" />
<LineId Id="402" Count="0" />
<LineId Id="420" Count="1" />
<LineId Id="419" Count="0" />
<LineId Id="423" Count="0" />
<LineId Id="422" Count="0" />
<LineId Id="377" Count="0" />
<LineId Id="449" Count="1" />
<LineId Id="580" Count="0" />
<LineId Id="579" Count="0" />
<LineId Id="581" Count="0" />
<LineId Id="584" Count="0" />
<LineId Id="583" Count="0" />
<LineId Id="586" Count="0" />
<LineId Id="585" Count="0" />
<LineId Id="587" Count="2" />
<LineId Id="592" Count="0" />
<LineId Id="591" Count="0" />
<LineId Id="593" Count="2" />
<LineId Id="452" Count="0" />
<LineId Id="460" Count="1" />
<LineId Id="451" Count="0" />
<LineId Id="453" Count="1" />
<LineId Id="463" Count="0" />
<LineId Id="462" Count="0" />
<LineId Id="455" Count="0" />
<LineId Id="661" Count="0" />
<LineId Id="660" Count="0" />
<LineId Id="662" Count="4" />
<LineId Id="668" Count="0" />
<LineId Id="667" Count="0" />
<LineId Id="669" Count="1" />
<LineId Id="672" Count="0" />
<LineId Id="671" Count="0" />
<LineId Id="675" Count="0" />
<LineId Id="674" Count="0" />
</LineIds>
<LineIds Name="FB_Module.FB_init">
<LineId Id="7" Count="0" />
<LineId Id="29" Count="0" />
<LineId Id="28" Count="0" />
<LineId Id="31" Count="2" />
<LineId Id="30" Count="0" />
<LineId Id="16" Count="0" />
<LineId Id="15" Count="0" />
<LineId Id="17" Count="0" />
<LineId Id="19" Count="0" />
<LineId Id="18" Count="0" />
<LineId Id="20" Count="0" />
</LineIds>
<LineIds Name="FB_Module.Name.Get">
<LineId Id="2" Count="0" />
</LineIds>
<LineIds Name="FB_Module.Name.Set">
<LineId Id="2" Count="0" />
<LineId Id="8" Count="0" />
<LineId Id="12" Count="3" />
<LineId Id="11" Count="0" />
<LineId Id="6" Count="1" />
<LineId Id="5" Count="0" />
</LineIds>
</POU>
</TcPlcObject>