Skip to content

Commit 3821312

Browse files
committed
List_Var_Gui enhancements
LVG form now refers to its own instance of UPSDevice, and pauses it when a list query needs to run.
1 parent b4c1b1b commit 3821312

File tree

3 files changed

+26
-12
lines changed

3 files changed

+26
-12
lines changed

WinNUT_V2/WinNUT-Client/List_Var_Gui.vb

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,17 @@ Imports WinNUT_Client_Common
1111

1212
Public Class List_Var_Gui
1313
Private List_Var_Datas As List(Of UPS_List_Datas)
14+
Private UPSDevice As UPS_Device
1415
Private UPS_Name = WinNUT.UPS_Device.Nut_Config.UPSName
1516

17+
Public Sub New(upsDev As UPS_Device)
18+
' This call is required by the designer.
19+
InitializeComponent()
20+
21+
' Add any initialization after the InitializeComponent() call.
22+
UPSDevice = upsDev
23+
End Sub
24+
1625
Private Sub List_Var_Gui_Load(sender As Object, e As EventArgs) Handles MyBase.Load
1726
LogFile.LogTracing("Load List Var Gui", LogLvl.LOG_DEBUG, Me)
1827
Icon = WinNUT.Icon
@@ -22,10 +31,13 @@ Public Class List_Var_Gui
2231
End Sub
2332

2433
Private Sub PopulateTreeView()
25-
Dim action As Action
2634
LogFile.LogTracing("Populate TreeView", LogLvl.LOG_DEBUG, Me)
35+
Dim action As Action
36+
2737
Try
38+
UPSDevice.IsUpdatingData = False
2839
List_Var_Datas = WinNUT.UPS_Device.GetUPS_ListVar()
40+
UPSDevice.IsUpdatingData = True
2941
Catch ex As Exception
3042
' TODO: Internationalize?
3143
MessageBox.Show("Error encountered trying to get variables from the UPS: " & vbNewLine & ex.Message, "Error Encountered")

WinNUT_V2/WinNUT-Client/WinNUT.vb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1006,9 +1006,8 @@ Public Class WinNUT
10061006

10071007
Private Sub Menu_UPS_Var_Click(sender As Object, e As EventArgs) Handles Menu_UPS_Var.Click
10081008
LogFile.LogTracing("Open List Var Gui", LogLvl.LOG_DEBUG, Me)
1009-
List_Var_Gui.Activate()
1010-
List_Var_Gui.Visible = True
1011-
HasFocus = False
1009+
Dim lvgForm = New List_Var_Gui(UPS_Device)
1010+
lvgForm.Show()
10121011
End Sub
10131012

10141013
Public Sub Update_InstantLog(sender As Object) Handles LogFile.NewData

WinNUT_V2/WinNUT-Client_Common/UPS_Device.vb

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,16 @@ Public Class UPS_Device
4040
End Set
4141
End Property
4242

43+
Public Property IsUpdatingData As Boolean
44+
Get
45+
Return Update_Data.Enabled
46+
End Get
47+
Set(value As Boolean)
48+
LogFile.LogTracing("UPS device updating status is now [" & value & "]", LogLvl.LOG_NOTICE, Me)
49+
Update_Data.Enabled = value
50+
End Set
51+
End Property
52+
4353
Private upsData As UPSData
4454
Public Property UPS_Datas As UPSData
4555
Get
@@ -303,15 +313,8 @@ Public Class UPS_Device
303313
Try
304314
Dim UPS_rt_Status As String
305315
Dim InputA As Double
306-
' LogFile.LogTracing("Enter Retrieve_UPS_Data", LogLvl.LOG_DEBUG, Me)
307-
If IsConnected Then
308-
'With UPS_Datas
309-
' Select Case "Unknown"
310-
' Case .Mfr, .Model, .Serial, .Firmware
311-
' UPS_Datas = GetUPSProductInfo()
312-
' End Select
313-
'End With
314316

317+
If IsConnected Then
315318
With UPS_Datas.UPS_Value
316319
.Batt_Charge = Double.Parse(GetUPSVar("battery.charge", 255), ciClone)
317320
.Batt_Voltage = Double.Parse(GetUPSVar("battery.voltage", 12), ciClone)

0 commit comments

Comments
 (0)