Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 18 additions & 18 deletions WinNUT_V2/WinNUT-Client/WinNUT.vb
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,24 @@ Public Class WinNUT
End If
End Sub

Private Sub UPS_Lostconnect() Handles UPS_Device.Lost_Connect
LogFile.LogTracing("Notify user of lost connection", LogLvl.LOG_ERROR, Me,
String.Format(StrLog.Item(AppResxStr.STR_MAIN_LOSTCONNECT), UPS_Device.Nut_Config.Host, UPS_Device.Nut_Config.Port))
' UPSDisconnect()

ReInitDisplayValues()
If UPS_Device.Nut_Config.AutoReconnect And UPS_Retry <= UPS_MaxRetry Then
ActualAppIconIdx = AppIconIdx.IDX_ICO_RETRY
Else
ActualAppIconIdx = AppIconIdx.IDX_ICO_OFFLINE
End If

UpdateIcon_NotifyIcon()
RaiseEvent UpdateNotifyIconStr("Lost Connect", Nothing)
RaiseEvent UpdateBatteryState("Lost Connect")
LogFile.LogTracing("Update Icon", LogLvl.LOG_DEBUG, Me)
End Sub

''' <summary>
''' Perform final actions to wrap up a disconnected UPS.
''' </summary>
Expand Down Expand Up @@ -587,24 +605,6 @@ Public Class WinNUT
HasFocus = False
End Sub

Private Sub UPS_Lostconnect() Handles UPS_Device.Lost_Connect
LogFile.LogTracing("Notify user of lost connection", LogLvl.LOG_ERROR, Me,
String.Format(StrLog.Item(AppResxStr.STR_MAIN_LOSTCONNECT), UPS_Device.Nut_Config.Host, UPS_Device.Nut_Config.Port))
' UPSDisconnect()

'ReInitDisplayValues()
If UPS_Device.Nut_Config.AutoReconnect And UPS_Retry <= UPS_MaxRetry Then
ActualAppIconIdx = AppIconIdx.IDX_ICO_RETRY
Else
ActualAppIconIdx = AppIconIdx.IDX_ICO_OFFLINE
End If

UpdateIcon_NotifyIcon()
RaiseEvent UpdateNotifyIconStr("Lost Connect", Nothing)
RaiseEvent UpdateBatteryState("Lost Connect")
LogFile.LogTracing("Update Icon", LogLvl.LOG_DEBUG, Me)
End Sub

Public Shared Sub Event_ChangeStatus() Handles Me.On_Battery, Me.On_Line,
UPS_Device.Lost_Connect, UPS_Device.Connected, UPS_Device.Disconnected, UPS_Device.New_Retry, UPS_Device.ReConnected
', UPS_Device.Unknown_UPS
Expand Down
25 changes: 13 additions & 12 deletions WinNUT_V2/WinNUT-Client_Common/Nut_Socket.vb
Original file line number Diff line number Diff line change
Expand Up @@ -188,30 +188,31 @@ Public Class Nut_Socket
''' </summary>
''' <param name="Query_Msg">The query to be sent to the server, within specifications of the NUT protocol.</param>
''' <returns>The full <see cref="Transaction"/> of this function call.</returns>
''' <exception cref="InvalidOperationException">Thrown when calling this function while disconnected.</exception>"
''' <exception cref="InvalidOperationException">Thrown when calling this function while disconnected, or another
''' call is in progress.</exception>
''' <exception cref="NutException">Thrown when the NUT server returns an error or unexpected response.</exception>
Function Query_Data(Query_Msg As String) As Transaction
Dim Response As NUTResponse
Dim DataResult As String
Dim finalTransaction As Transaction

If streamInUse Then
LogFile.LogTracing("Attempted to query " & Query_Msg & " while using the stream.", LogLvl.LOG_ERROR, Me)
Return Nothing
Throw New InvalidOperationException("Attempted to query " & Query_Msg & " while stream is in use.")
End If

streamInUse = True

If ConnectionStatus Then
' LogFile.LogTracing("Query: " & Query_Msg, LogLvl.LOG_DEBUG, Me)
WriterStream.WriteLine(Query_Msg & vbCr)
WriterStream.Flush()
streamInUse = True

DataResult = Trim(ReaderStream.ReadLine())
' LogFile.LogTracing(vbTab & "Response: " & DataResult, LogLvl.LOG_DEBUG, Me)
streamInUse = False
' LogFile.LogTracing("Done processing response for query " & Query_Msg, LogLvl.LOG_DEBUG, Me)
Try
WriterStream.WriteLine(Query_Msg & vbCr)
WriterStream.Flush()
Catch
Throw
Finally
streamInUse = False
End Try

DataResult = Trim(ReaderStream.ReadLine())
Response = EnumResponse(DataResult)
finalTransaction = New Transaction(Query_Msg, DataResult, Response)

Expand Down