Namespace UTSModule.Test.StatusMonitor

    Public Class ComportStatusChangedEventArgs
        Inherits EventArgs

        Public Property Status As ComportStatusMonitor.ComPortConnectStatusEnum

    End Class


    Public Class ComportStatusMonitor
        Enum ComPortConnectStatusEnum
            Connected
            Connecting
            UnConnected
        End Enum

        Public Delegate Sub ComportStatusChangedEventHandler(sender As Object, e As ComportStatusChangedEventArgs)

        ''' <summary>
        ''' 在测试状态更改时发生
        ''' </summary>
        Public Shared Event ComportStatusChanged As ComportStatusChangedEventHandler


        Private Shared _comportStatus As ComPortConnectStatusEnum = ComPortConnectStatusEnum.UnConnected

        ''' <summary>
        ''' 串口连接状态
        ''' </summary>
        ''' <returns></returns>
        Public Shared Property ComportStatus() As ComPortConnectStatusEnum
            Get
                Return _comportStatus
            End Get
            Set(value As ComPortConnectStatusEnum)
                If _comportStatus = value Then Return
                _comportStatus = value
                RaiseEvent ComportStatusChanged(Nothing, New ComportStatusChangedEventArgs() With {.Status = _comportStatus})
            End Set
        End Property
    End Class


    Public Class ControllerComPortStatusMonitor

        Public Delegate Sub ComportStatusChangedEventHandler(sender As Object, e As ComportStatusChangedEventArgs)

        ''' <summary>
        ''' 在测试状态更改时发生
        ''' </summary>
        Public Shared Event ComportStatusChanged As ComportStatusChangedEventHandler


        Private Shared _comportStatus As ComportStatusMonitor.ComPortConnectStatusEnum = ComportStatusMonitor.ComPortConnectStatusEnum.UnConnected

        ''' <summary>
        ''' 串口连接状态
        ''' </summary>
        ''' <returns></returns>
        Public Shared Property ComportStatus() As ComportStatusMonitor.ComPortConnectStatusEnum
            Get
                Return _comportStatus
            End Get
            Set(value As ComportStatusMonitor.ComPortConnectStatusEnum)
                If _comportStatus = value Then Return
                _comportStatus = value
                RaiseEvent ComportStatusChanged(Nothing, New ComportStatusChangedEventArgs() With {.Status = _comportStatus})
            End Set
        End Property
    End Class
End Namespace