Skip to content

Commit 381ebaa

Browse files
committed
Handle nominal input frequency calibration setting change
The input frequency calibration preference value used to be stored as the index value of the dropdown box in the preferences window; 0 for 50hz, and 1 for 60hz. The new settings system stores the value literally now, although the rest of WinNUT was not updated to reflect this change. - WinNUT.vb now passes the Settings value directly to the `UPS_Device` constructor instead of converting it. - UPS_Device.vb also refers to the value directly when getting parameter info from the UPS. - Prefs upgrade import procedure now has an edge case to convert the old value to the new one.
1 parent 4d9d9bb commit 381ebaa

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

WinNUT_V2/WinNUT-Client/Models/UpgradePrefsDialogModel.vb

+9-1
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,15 @@ Namespace Models
308308
Dim pairLookupRes = oldPrefs.PrefSettingsLookup.First(Function(p As OldParams.UpgradableParams.PrefSettingPair)
309309
Return p.OldPreferenceName.Equals(oldPref.Key)
310310
End Function)
311-
My.Settings.Item(pairLookupRes.NewSettingsName) = oldPref.Value
311+
312+
Dim oldValue = oldPref.Value
313+
' Handle special case of converting the default input frequency calibration value
314+
If oldPref.Key = "FrequencySupply" Then
315+
oldValue = (oldValue * 10) + 50
316+
End If
317+
318+
My.Settings.Item(pairLookupRes.NewSettingsName) = oldValue
319+
312320
ReportProgress(percentComplete, "Imported " & oldPref.Key & " into " & pairLookupRes.NewSettingsName,
313321
LogLvl.LOG_NOTICE, Me)
314322

WinNUT_V2/WinNUT-Client/WinNUT.vb

+1-1
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ Public Class WinNUT
401401
My.Settings.NUT_UPSName,
402402
My.Settings.NUT_AutoReconnect)
403403

404-
UPS_Device = New UPS_Device(Nut_Config, LogFile, My.Settings.NUT_PollIntervalMsec, (50 + My.Settings.CAL_FreqInNom * 10))
404+
UPS_Device = New UPS_Device(Nut_Config, LogFile, My.Settings.NUT_PollIntervalMsec, My.Settings.CAL_FreqInNom)
405405
AddHandler UPS_Device.EncounteredNUTException, AddressOf HandleNUTException
406406
UPS_Device.Connect_UPS(retryOnConnFailure)
407407
End Sub

WinNUT_V2/WinNUT-Client_Common/UPS_Device.vb

+2-1
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ Public Class UPS_Device
129129
Me.LogFile = LogFile
130130
Me.Nut_Config = Nut_Config
131131
PollingInterval = pollInterval
132+
Freq_Fallback = defaultFrequency
132133
Nut_Socket = New Nut_Socket(Me.Nut_Config, LogFile)
133134

134135
With Reconnect_Nut
@@ -264,7 +265,7 @@ Public Class UPS_Device
264265

265266
' Other constant values for UPS calibration.
266267
freshData.UPS_Value.Batt_Capacity = Double.Parse(GetUPSVar("battery.capacity", 7), INVARIANT_CULTURE)
267-
Freq_Fallback = Double.Parse(GetUPSVar("output.frequency.nominal", (50 + CInt(Arr_Reg_Key.Item("FrequencySupply")) * 10)), INVARIANT_CULTURE)
268+
Freq_Fallback = Double.Parse(GetUPSVar("output.frequency.nominal", Freq_Fallback), INVARIANT_CULTURE)
268269

269270
LogFile.LogTracing("Completed retrieval of basic UPS product information.", LogLvl.LOG_NOTICE, Me)
270271
Return freshData

0 commit comments

Comments
 (0)