Skip to content

Commit d2c7c94

Browse files
committed
More logging re: shutdown decision making
Also updating how notification messages determine if the UPS is on line or not.
1 parent 104def9 commit d2c7c94

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

WinNUT_V2/WinNUT-Client/WinNUT.vb

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,7 @@ Public Class WinNUT
509509
Case "Update Data"
510510
FormText &= " - Bat: " & UPS_BattCh & "% - " & StrLog.Item(AppResxStr.STR_MAIN_CONN) & " - "
511511
NotifyStr &= StrLog.Item(AppResxStr.STR_MAIN_CONN) & vbNewLine
512-
If UPS_Status.Trim().StartsWith("OL") Or StrReverse(UPS_Status.Trim()).StartsWith("LO") Then
512+
If UPS_Device.UPS_Datas.UPS_Value.UPS_Status.HasFlag(UPS_States.OL) Then
513513
NotifyStr &= StrLog.Item(AppResxStr.STR_MAIN_OL) & vbNewLine
514514
FormText &= StrLog.Item(AppResxStr.STR_MAIN_OL) & " - "
515515
Else
@@ -1045,12 +1045,16 @@ Public Class WinNUT
10451045
LogFile.LogTracing("Full Shut Down imposed by the NUT server.", LogLvl.LOG_NOTICE, Me, StrLog.Item(AppResxStr.STR_LOG_NUT_FSD))
10461046
Shutdown_Event()
10471047

1048-
ElseIf newStatuses.HasFlag(UPS_States.OB) And
1049-
(.Batt_Charge <= Arr_Reg_Key.Item("ShutdownLimitBatteryCharge") Or
1050-
.Batt_Runtime <= Arr_Reg_Key.Item("ShutdownLimitUPSRemainTime")) And
1051-
Not ShutdownStatus Then
1052-
LogFile.LogTracing("UPS battery has dropped below stop condition limits.", LogLvl.LOG_NOTICE, Me, WinNUT_Globals.StrLog.Item(AppResxStr.STR_LOG_SHUT_START))
1053-
Shutdown_Event()
1048+
ElseIf newStatuses.HasFlag(UPS_States.OB) And Not ShutdownStatus Then
1049+
If .Batt_Charge <= Arr_Reg_Key.Item("ShutdownLimitBatteryCharge") Or
1050+
.Batt_Runtime <= Arr_Reg_Key.Item("ShutdownLimitUPSRemainTime") Then
1051+
LogFile.LogTracing("UPS battery has dropped below stop condition limits.", LogLvl.LOG_NOTICE, Me, WinNUT_Globals.StrLog.Item(AppResxStr.STR_LOG_SHUT_START)) Then
1052+
Shutdown_Event()
1053+
Else
1054+
LogFile.LogTracing(String.Format("UPS charge ({0}%) or Runtime ({1}) have not met shutdown conditions {2} or {3}.",
1055+
.Batt_Charge, .Batt_Runtime, Arr_Reg_Key.Item("ShutdownLimitBatteryCharge"), Arr_Reg_Key.Item("ShutdownLimitUPSRemainTime")),
1056+
LogLvl.LOG_DEBUG, Me)
1057+
End If
10541058

10551059
ElseIf newStatuses.HasFlag(UPS_States.OL) AndAlso ShutdownStatus Then
10561060
LogFile.LogTracing("UPS returned online during a pre-shutdown event.", LogLvl.LOG_NOTICE, Me)

0 commit comments

Comments
 (0)