Some refactoring

This commit is contained in:
Matthias Heisig
2025-01-17 08:08:37 +01:00
parent 39a02352f6
commit 0345f57a3f
10 changed files with 2921 additions and 934 deletions

View File

@@ -40,7 +40,7 @@ VAR
_iWMaxSF : INT;
// Unscaled converter max power
_iWMax : UINT;
_uiWMax : UINT;
// Scaled converter max power
_rWMax : REAL;
@@ -53,7 +53,7 @@ VAR
// Reread set power limit
_iWMaxLimPctRead : INT;
_iWMaxLimPctReadScaled : REAL;
_rWMaxLimPctReadScaled : REAL;
// Scaling factor for power limiting
_iWMaxLimPctSF : INT;
@@ -114,10 +114,10 @@ VAR
_xInverterHBCounterIncremented : BOOL := TRUE;
// Inverter alarm
_fbErrorInverterAlarm : Fb_TcAlarm;
_fbErrorInverterAlarm : FB_TcAlarm;
// Heartbeat timeout
_tonHeartbeatTimeout : TON;
_fbHeartbeatTimeout : TON;
_sName : STRING;
@@ -580,8 +580,8 @@ CASE _iState OF
nUnitID:= 16#FF, // 16#FF for Modbus TCP
nQuantity:= 1,
nMBAddr:= W_MAX_REGISTER,
cbLength:= SIZEOF(_iWMax),
pDestAddr:= ADR(_iWMax),
cbLength:= SIZEOF(_uiWMax),
pDestAddr:= ADR(_uiWMax),
bExecute:= TRUE,
tTimeout:= T#5S,
bBusy=> ,
@@ -595,7 +595,7 @@ CASE _iState OF
IF NOT _fbReadRegister.bError THEN
_iState := 40;
// Reading a register with scaling factor = value * 10^SF
_rWMax := LREAL_TO_REAL(_iWMax * EXPT(10,_iWMaxSF));
_rWMax := LREAL_TO_REAL(_uiWMax * EXPT(10,_iWMaxSF));
// Calculate power to write to register
_iWMaxLimPct := LREAL_TO_INT((rPower*100)/(_rWMax * EXPT(10,_iWMaxLimPctSF)));
@@ -1147,15 +1147,15 @@ END_CASE
// ===============================
// Heartbeat check
// ===============================
_tonHeartbeatTimeout(IN := (NOT _xInverterHBCounterIncremented), PT := T#5S);
_fbHeartbeatTimeout(IN := (NOT _xInverterHBCounterIncremented), PT := T#5S);
// Reset heartbeat ok signal
IF xReset AND (NOT _tonHeartbeatTimeout.Q) THEN
IF xReset AND (NOT _fbHeartbeatTimeout.Q) THEN
xHeartbeatOk := TRUE;
END_IF
// Check for heartbeat
IF _tonHeartbeatTimeout.Q THEN
IF _fbHeartbeatTimeout.Q THEN
xHeartbeatOk := FALSE;
END_IF
@@ -1214,255 +1214,5 @@ _fbErrorInverterAlarm.ipArguments.Clear().AddString(_sName);]]></ST>
</Implementation>
</Set>
</Property>
<LineIds Name="FB_PowerSupplySunspec">
<LineId Id="774" Count="10" />
<LineId Id="1550" Count="0" />
<LineId Id="785" Count="0" />
<LineId Id="4104" Count="2" />
<LineId Id="4103" Count="0" />
<LineId Id="4107" Count="0" />
<LineId Id="786" Count="2" />
<LineId Id="2615" Count="0" />
<LineId Id="790" Count="0" />
<LineId Id="2614" Count="0" />
<LineId Id="2613" Count="0" />
<LineId Id="2616" Count="0" />
<LineId Id="2619" Count="1" />
<LineId Id="3661" Count="0" />
<LineId Id="2621" Count="0" />
<LineId Id="2623" Count="15" />
<LineId Id="2622" Count="0" />
<LineId Id="2639" Count="0" />
<LineId Id="2644" Count="0" />
<LineId Id="2641" Count="0" />
<LineId Id="2643" Count="0" />
<LineId Id="2642" Count="0" />
<LineId Id="2721" Count="0" />
<LineId Id="2640" Count="0" />
<LineId Id="2645" Count="0" />
<LineId Id="3660" Count="0" />
<LineId Id="2646" Count="0" />
<LineId Id="2648" Count="1" />
<LineId Id="2651" Count="0" />
<LineId Id="2722" Count="0" />
<LineId Id="2652" Count="0" />
<LineId Id="2650" Count="0" />
<LineId Id="2653" Count="0" />
<LineId Id="3659" Count="0" />
<LineId Id="2656" Count="31" />
<LineId Id="3658" Count="0" />
<LineId Id="2688" Count="22" />
<LineId Id="3862" Count="3" />
<LineId Id="2711" Count="9" />
<LineId Id="2654" Count="0" />
<LineId Id="3422" Count="2" />
<LineId Id="3438" Count="0" />
<LineId Id="3440" Count="19" />
<LineId Id="3464" Count="5" />
<LineId Id="3439" Count="0" />
<LineId Id="3425" Count="0" />
<LineId Id="3474" Count="0" />
<LineId Id="3426" Count="0" />
<LineId Id="3475" Count="12" />
<LineId Id="2655" Count="0" />
<LineId Id="3488" Count="0" />
<LineId Id="3607" Count="19" />
<LineId Id="3489" Count="0" />
<LineId Id="2647" Count="0" />
<LineId Id="791" Count="22" />
<LineId Id="1701" Count="5" />
<LineId Id="814" Count="1" />
<LineId Id="1714" Count="0" />
<LineId Id="1719" Count="0" />
<LineId Id="1715" Count="0" />
<LineId Id="1718" Count="0" />
<LineId Id="1716" Count="1" />
<LineId Id="1707" Count="0" />
<LineId Id="3657" Count="0" />
<LineId Id="1708" Count="0" />
<LineId Id="1710" Count="2" />
<LineId Id="1709" Count="0" />
<LineId Id="1713" Count="0" />
<LineId Id="1720" Count="0" />
<LineId Id="1722" Count="1" />
<LineId Id="1726" Count="0" />
<LineId Id="1725" Count="0" />
<LineId Id="1721" Count="0" />
<LineId Id="1433" Count="0" />
<LineId Id="816" Count="24" />
<LineId Id="4096" Count="0" />
<LineId Id="841" Count="3" />
<LineId Id="1171" Count="0" />
<LineId Id="845" Count="5" />
<LineId Id="3656" Count="0" />
<LineId Id="851" Count="27" />
<LineId Id="1172" Count="0" />
<LineId Id="879" Count="4" />
<LineId Id="1981" Count="0" />
<LineId Id="3655" Count="0" />
<LineId Id="1982" Count="0" />
<LineId Id="1991" Count="0" />
<LineId Id="1993" Count="12" />
<LineId Id="1992" Count="0" />
<LineId Id="2006" Count="0" />
<LineId Id="2008" Count="15" />
<LineId Id="2007" Count="0" />
<LineId Id="1983" Count="0" />
<LineId Id="884" Count="28" />
<LineId Id="1173" Count="0" />
<LineId Id="913" Count="5" />
<LineId Id="3654" Count="0" />
<LineId Id="919" Count="22" />
<LineId Id="2024" Count="1" />
<LineId Id="942" Count="0" />
<LineId Id="1174" Count="0" />
<LineId Id="943" Count="4" />
<LineId Id="1928" Count="3" />
<LineId Id="1934" Count="18" />
<LineId Id="1955" Count="5" />
<LineId Id="1933" Count="0" />
<LineId Id="2030" Count="0" />
<LineId Id="3653" Count="0" />
<LineId Id="2031" Count="0" />
<LineId Id="2033" Count="25" />
<LineId Id="2032" Count="0" />
<LineId Id="3639" Count="0" />
<LineId Id="948" Count="23" />
<LineId Id="1175" Count="0" />
<LineId Id="972" Count="4" />
<LineId Id="2907" Count="0" />
<LineId Id="3640" Count="0" />
<LineId Id="2908" Count="0" />
<LineId Id="2969" Count="18" />
<LineId Id="3031" Count="0" />
<LineId Id="2988" Count="5" />
<LineId Id="2909" Count="0" />
<LineId Id="2996" Count="0" />
<LineId Id="977" Count="28" />
<LineId Id="3641" Count="0" />
<LineId Id="1006" Count="8" />
<LineId Id="1560" Count="1" />
<LineId Id="1015" Count="3" />
<LineId Id="1127" Count="0" />
<LineId Id="1019" Count="3" />
<LineId Id="3642" Count="0" />
<LineId Id="1023" Count="21" />
<LineId Id="1097" Count="1" />
<LineId Id="1100" Count="1" />
<LineId Id="1099" Count="0" />
<LineId Id="1045" Count="0" />
<LineId Id="1176" Count="0" />
<LineId Id="2723" Count="0" />
<LineId Id="1046" Count="5" />
<LineId Id="3643" Count="0" />
<LineId Id="1052" Count="0" />
<LineId Id="1063" Count="20" />
<LineId Id="1090" Count="0" />
<LineId Id="1092" Count="0" />
<LineId Id="1775" Count="0" />
<LineId Id="1084" Count="4" />
<LineId Id="1062" Count="0" />
<LineId Id="1736" Count="0" />
<LineId Id="3644" Count="0" />
<LineId Id="1737" Count="0" />
<LineId Id="1739" Count="19" />
<LineId Id="1781" Count="0" />
<LineId Id="1759" Count="0" />
<LineId Id="4066" Count="7" />
<LineId Id="1777" Count="0" />
<LineId Id="1762" Count="4" />
<LineId Id="1738" Count="0" />
<LineId Id="3213" Count="0" />
<LineId Id="3645" Count="0" />
<LineId Id="3214" Count="0" />
<LineId Id="3216" Count="15" />
<LineId Id="3215" Count="0" />
<LineId Id="3232" Count="0" />
<LineId Id="3240" Count="0" />
<LineId Id="3234" Count="0" />
<LineId Id="3236" Count="2" />
<LineId Id="3235" Count="0" />
<LineId Id="3239" Count="0" />
<LineId Id="3233" Count="0" />
<LineId Id="3529" Count="0" />
<LineId Id="3646" Count="0" />
<LineId Id="3531" Count="47" />
<LineId Id="3590" Count="0" />
<LineId Id="3593" Count="9" />
<LineId Id="3591" Count="0" />
<LineId Id="3603" Count="0" />
<LineId Id="3605" Count="1" />
<LineId Id="3604" Count="0" />
<LineId Id="3592" Count="0" />
<LineId Id="3588" Count="1" />
<LineId Id="3530" Count="0" />
<LineId Id="1093" Count="0" />
<LineId Id="3647" Count="0" />
<LineId Id="1094" Count="0" />
<LineId Id="1102" Count="24" />
<LineId Id="1054" Count="0" />
<LineId Id="1295" Count="0" />
<LineId Id="3648" Count="0" />
<LineId Id="1296" Count="3" />
<LineId Id="1128" Count="0" />
<LineId Id="1300" Count="1" />
<LineId Id="3649" Count="0" />
<LineId Id="1129" Count="0" />
<LineId Id="1132" Count="20" />
<LineId Id="1163" Count="0" />
<LineId Id="1294" Count="0" />
<LineId Id="1161" Count="1" />
<LineId Id="1130" Count="1" />
<LineId Id="3650" Count="0" />
<LineId Id="1055" Count="0" />
<LineId Id="1177" Count="20" />
<LineId Id="1199" Count="1" />
<LineId Id="1169" Count="0" />
<LineId Id="1265" Count="0" />
<LineId Id="3651" Count="0" />
<LineId Id="1266" Count="1" />
<LineId Id="1269" Count="2" />
<LineId Id="3652" Count="0" />
<LineId Id="1272" Count="0" />
<LineId Id="1274" Count="11" />
<LineId Id="1273" Count="0" />
<LineId Id="1289" Count="1" />
<LineId Id="1293" Count="0" />
<LineId Id="2235" Count="0" />
<LineId Id="1291" Count="1" />
<LineId Id="12" Count="0" />
<LineId Id="3629" Count="1" />
<LineId Id="3628" Count="0" />
<LineId Id="3631" Count="1" />
<LineId Id="3524" Count="0" />
<LineId Id="3633" Count="0" />
<LineId Id="3525" Count="3" />
<LineId Id="3516" Count="0" />
<LineId Id="3627" Count="0" />
<LineId Id="3521" Count="2" />
<LineId Id="3635" Count="1" />
<LineId Id="3634" Count="0" />
<LineId Id="3637" Count="1" />
<LineId Id="2418" Count="0" />
<LineId Id="2417" Count="0" />
<LineId Id="2419" Count="1" />
<LineId Id="2422" Count="0" />
<LineId Id="2421" Count="0" />
<LineId Id="2423" Count="1" />
<LineId Id="2426" Count="0" />
<LineId Id="2425" Count="0" />
<LineId Id="2427" Count="1" />
</LineIds>
<LineIds Name="FB_PowerSupplySunspec.FB_init">
<LineId Id="15" Count="1" />
<LineId Id="11" Count="0" />
<LineId Id="7" Count="1" />
</LineIds>
<LineIds Name="FB_PowerSupplySunspec.Name.Get">
<LineId Id="1" Count="0" />
</LineIds>
<LineIds Name="FB_PowerSupplySunspec.Name.Set">
<LineId Id="1" Count="2" />
</LineIds>
</POU>
</TcPlcObject>