Namespace UTSModule.Test.Command.ComPortCommand
    Public Class CloseComPortExecutor
        Inherits TestCommandExecutor

        Private ReadOnly _portName As String

        Private _comPort As ComPort
        Public Sub New(command As TestCommand)
            MyBase.New(command)

            _portName = command.Parameter(0)
        End Sub

        Public Overrides Function Execute() As TestCommandReturn
            '查询串口成功则关闭,未查询成功则视为已关闭
            If ComPortCommandManager.FindComPort(_portName, _comPort) then 
                _comPort.Close()
            End If


            CommandReturn.ExecuteResultTipString = $"串口关闭成功"
            CommandReturn.ExecuteResult = True
            Return CommandReturn
        End Function
    End Class
End Namespace