Fixed Modbus register access

This commit is contained in:
Matthias Heisig
2024-01-17 11:26:11 +01:00
parent 82826c258a
commit 57987cb19f
24 changed files with 1310 additions and 572 deletions

View File

@@ -12,6 +12,9 @@ VAR_INPUT
// Module completely off
xOff : BOOL := TRUE;
// All safetyinterlocks are ok
xSafetyIntlksOk : BOOL;
// HMI Interface
stHMIInterface : REFERENCE TO ST_MODULE_HMI_INTERFACE;
@@ -44,10 +47,10 @@ VAR_OUTPUT
xWarning : BOOL;
END_VAR
VAR
_fbUnit1 : FB_Unit(CONCAT(_sName, ' Unit 1'));
_fbUnit2 : FB_Unit(CONCAT(_sName, ' Unit 2'));
_fbUnit3 : FB_Unit(CONCAT(_sName, ' Unit 3'));
_fbUnit4 : FB_Unit(CONCAT(_sName, ' Unit 4'));
_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;
@@ -55,6 +58,9 @@ VAR
// All units are ready
_xAllUnitsReady : BOOL;
// Units out of balance alarm
_fbUnitsOutOfBalanceAlarm : FB_TcAlarm;
// Module name
_sName : STRING;
END_VAR
@@ -64,6 +70,10 @@ END_VAR
xError := FALSE;
xWarning := FALSE;
// Reset safety interlocks flag
xSafetyIntlksOk := TRUE;
// ===============================
// Unit 1
// ===============================
@@ -87,6 +97,10 @@ IF _fbUnit1.xError THEN
xError := TRUE;
END_IF
IF NOT _fbUnit1.xSafetyIntlksOk THEN
xSafetyIntlksOk := FALSE;
END_IF
// ===============================
// Unit 2
@@ -111,6 +125,10 @@ IF _fbUnit2.xError THEN
xError := TRUE;
END_IF
IF NOT _fbUnit2.xSafetyIntlksOk THEN
xSafetyIntlksOk := FALSE;
END_IF
// ===============================
// Unit 3
@@ -135,6 +153,10 @@ IF _fbUnit3.xError THEN
xError := TRUE;
END_IF
IF NOT _fbUnit3.xSafetyIntlksOk THEN
xSafetyIntlksOk := FALSE;
END_IF
// ===============================
// Unit 4
@@ -159,6 +181,10 @@ IF _fbUnit4.xError THEN
xError := TRUE;
END_IF
IF NOT _fbUnit4.xSafetyIntlksOk THEN
xSafetyIntlksOk := FALSE;
END_IF
// ===============================
// Units ready check
@@ -230,6 +256,21 @@ 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
// ===============================
@@ -249,21 +290,79 @@ VAR_INPUT
END_VAR
]]></Declaration>
<Implementation>
<ST><![CDATA[_sName := sName;]]></ST>
<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="7" />
<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="22" />
<LineId Id="256" Count="16" />
<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="22" />
<LineId Id="279" Count="16" />
<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="22" />
<LineId Id="302" Count="16" />
<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="15" />
<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" />
@@ -317,6 +416,17 @@ END_VAR
<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" />
@@ -327,6 +437,27 @@ END_VAR
</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>