Imports UTS_Core.UTSModule.DbTableModel.Manage

Namespace UTSModule.Production
    Public Class TestCmd
        Sub New()
            Params = New List(Of TestCmdParam)()
        End Sub


        Public Property CommandIndex() As String

        Public Property CommandType() As String

        Public Property CommandName() As String

        Public Property CommandDesc() As String

        Public Property ParamCount() As Integer

        Public Property Params() As List(Of TestCmdParam)

        Public Function InitCommand(dtRow As DataRow) As Boolean
            CommandIndex = dtRow.Item(UtsCmdListTable.ColNamesEnum.ID.ToString()).ToString()
            CommandType = dtRow.Item(UtsCmdListTable.ColNamesEnum.CmdType.ToString()).ToString()
            CommandName = dtRow.Item(UtsCmdListTable.ColNamesEnum.CmdName.ToString()).ToString()
            CommandDesc = dtRow.Item(UtsCmdListTable.ColNamesEnum.CmdDesc.ToString()).ToString()

            ParamCount = CInt(dtRow.Item(UtsCmdListTable.ColNamesEnum.ParamCount.ToString()))

            Params.Clear()

            For i As Integer = 1 To ParamCount
                Try
                    Dim param As New TestCmdParam With {
                        .Desc = dtRow.Item("ParamDesc" & i).ToString(),
                        .Type = dtRow.Item("ParamType" & i).ToString(),
                        .LowerLimit = dtRow.Item("ParamLower" & i).ToString(),
                        .UpperLimit = dtRow.Item("ParamUpper" & i).ToString(),
                        .Value = dtRow.Item("ParamValue" & i).ToString()
                    }
                    Params.Add(param)
                Catch ex As Exception
                    MsgBox($"CommandName :{CommandName},ParamCount:ParamCount,Error:{ex.Message}")
                    Exit For
                End Try
            Next
            Return True
        End Function
    End Class
End Namespace