Imports UTS_Core.UTSModule.Test.Command.ComPortCommand
Imports UTS_Core.UTSModule.Test.Command.ConverterCommand
Imports UTS_Core.UTSModule.Test.Command.ProcessCommand
Imports UTS_Core.UTSModule.Test.Command.SystemCommand
Imports UTS_Core.UTSModule.Test.Command.UtsComPortCommand

Namespace UTSModule.Test.Command
    Public Class TestCommandManger
        ''' <summary>
        ''' 创建命令执行器
        ''' </summary>
        ''' <param name="command"></param>
        ''' <returns></returns>
        Public Shared Function CreateExecutor(command As TestCommand) As TestCommandExecutor
            Select Case command.Type
                Case "System"
                    Return SystemCommandManger.CreateExecutor(command)
                Case "Process"
                    Return ProcessCommandManager.CreateExecutor(command)
                Case "ComPort"
                    Return ComPortCommandManager.CreateExecutor(command)
                Case "UtsComPort"
                    Return UtsComPortCommandManager.CreateExecutor(command)
                Case "Converter"
                    Return ConverterCommandManager.CreateExecutor(command)
                Case Else
                    Throw New Exception($"Unknown CommandType :{command.Type}")
            End Select
        End Function

        ''' <summary>
        ''' 将参数中的相对路径替换为绝对路径
        ''' </summary>
        ''' <param name="srcPath"></param>
        ''' <returns></returns>
        Friend Shared Function ReplacePath(srcPath As String) As String
            If String.IsNullOrWhiteSpace(srcPath) Then Return srcPath
            If srcPath.StartsWith("/"c) = False AndAlso srcPath.StartsWith("\"c) = False Then Return srcPath

            Return $"{UtsPath.StationPacketResourceDirPath}{srcPath}"
        End Function


        Public Enum DealTypes
            ''' <summary>字符串处理</summary>
            [String]

            ''' <summary>字符串处理,以回车换行结尾</summary>
            StringAndCrlf

            ''' <summary>字符串处理,包含关系</summary>
            StringContain

            ''' <summary>十六进制字符串处理</summary>
            ByteString

            ''' <summary>整形字符串处理</summary>
            IntegerString

            ''' <summary>小数型字符串处理</summary>
            DoubleString

            ''' <summary>十六进制处理</summary>
            [Byte]
        End Enum
    End Class
End Namespace