Imports System.Xml.Serialization
Imports System.IO
Imports System.Net
Imports System.Drawing


Public Module modSettings
    ' This module is responsible for saveing and loading the User Settings file


 


    Public Sub SaveSettings(ByVal strFileName As String)
        Try
            Dim GotABot_Settings As New BotSettings With {
            .xml_tmcDock = tmcDock,
            .xml_boolDockBackIn = boolDockBackIn,
            .xml_intDockOrientation = intDockOrientation,
            .xml_intDockTriggerPC = intDockTriggerPC,
            .xml_sngDockTriggerBot = sngDockTriggerBot,
            .xml_sngScanFOV = sngScanFOV,
            .xml_sngScannerCalibrate = sngScannerCalibrate,
            .xml_sngScannerCurveAdjust = sngScannerCurveAdjust,
            .xml_intScanOffsetDegrees = intScanOffsetDegrees,
            .xml_tmcScanVectorOffset = tmcScanVectorOffset,
            .xml_intNumberOfBeams = intNumberOfBeams,
            .xml_intNumberOfParticles = intNumberOfParticles,
            .xml_intDefaultElevation = intDefaultElevation,
            .xml_sngLocalizationTime = sngLocalizationTime,
            .xml_sngSteeringBiasOffsetCorrection = sngSteeringBiasOffsetCorrection,
            .xml_sngDistanceCorrectionCoeff_x0 = sngDistanceCorrectionCoeff_x0,
            .xml_sngDistanceCorrectionCoeff_x1 = sngDistanceCorrectionCoeff_x1,
            .xml_sngDistanceCorrectionCoeff_x2 = sngDistanceCorrectionCoeff_x2,
            .xml_sngBotLinearAcceleration = sngBotLinearAcceleration,
            .xml_sngBotLinearVelocity = sngBotLinearVelocity,
            .xml_sngBotAngularVelocity = sngBotAngularVelocity,
            .xml_sngBotAngularAcceleration = sngBotAngularAcceleration,
            .xml_sngBotWheelSeparation = sngBotWheelSeparation,
            .xml_intPowerMoving = intPowerMoving,
            .xml_intPowerStopped = intPowerStopped,
            .xml_strApiPassword = strApiPassword,
            .xml_sngBotDiameter = sngBotDiameter,
            .xml_sngCameraOffset = sngCameraOffset,
            .xml_sngCameraFOV = sngCameraFOV,
            .xml_sngCameraOffsetDegrees = sngCameraOffsetDegrees,
            .xml_ticCameraResolution = ticCameraResolution,
            .xml_sngBotMovementAccuracy = sngBotMovementAccuracy,
            .xml_sngMaxTravel = sngMaxTravel,
            .xml_sngZoom = sngZoom,
            .xml_tbpBotPose = tbpBotPose,
            .xml_tlmLandMarkArray = tlmLandMarkArray,
            .xml_taoObjectArray = frmArm.taoObjectArray,
            .xml_boolSimulatedMovement = boolSimulatedMovement,
            .xml_mnuEnableRcc = boolEnableRcc,
            .xml_mnuEnableArm = frmArm.boolEnableArm,
            .xml_mnuboolEnableFaceRecognition = boolEnableFaceRecognition,
            .xml_mnuboolEnableVideo = boolEnableVideo,
            .xml_boolViewLM = boolViewLM,
            .xml_boolViewDebug = boolViewDebug,
            .xml_boolMute = boolMute,
            .xml_boolLogFileEnable = boolLogFileEnable,
            .xml_boolHeroSelected = boolHeroSelected,
            .xml_boolER1Selected = boolER1Selected,
            .xml_boolEnableBumperSwitches_ER1 = boolEnableBumperSwitches_ER1,
            .xml_intVideoSource = intVideoSource,
            .xml_intArmComPort = frmArm.intArmComPort}
            GotABot_Settings.SaveSettingsXml(strFileName)
        Catch ex As Exception
            frmDebug.subWriteLogs(" EXCEPTION in SaveSettings " & ex.ToString)
        End Try
    End Sub



    Public Sub LoadSettings(ByVal strFileName As String)
        Try
            Dim GotABot_Settings As BotSettings = BotSettings.LoadSettingsXml(strFileName)
            boolDockBackIn = GotABot_Settings.xml_boolDockBackIn
            tmcDock = GotABot_Settings.xml_tmcDock
            intDockOrientation = GotABot_Settings.xml_intDockOrientation
            intDockTriggerPC = GotABot_Settings.xml_intDockTriggerPC
            sngDockTriggerBot = GotABot_Settings.xml_sngDockTriggerBot
            sngScanFOV = GotABot_Settings.xml_sngScanFOV
            If (sngScanFOV = 0) Then sngScanFOV = 58.5
            sngScannerCalibrate = GotABot_Settings.xml_sngScannerCalibrate
            If (sngScannerCalibrate = 0) Then sngScannerCalibrate = 1
            sngScannerCurveAdjust = GotABot_Settings.xml_sngScannerCurveAdjust
            intScanOffsetDegrees = GotABot_Settings.xml_intScanOffsetDegrees
            tmcScanVectorOffset = GotABot_Settings.xml_tmcScanVectorOffset
            intNumberOfBeams = GotABot_Settings.xml_intNumberOfBeams
            intNumberOfParticles = GotABot_Settings.xml_intNumberOfParticles
            If (intNumberOfParticles = 0) Then intNumberOfParticles = 32
            intDefaultElevation = GotABot_Settings.xml_intDefaultElevation
            sngLocalizationTime = GotABot_Settings.xml_sngLocalizationTime
            sngSteeringBiasOffsetCorrection = GotABot_Settings.xml_sngSteeringBiasOffsetCorrection
            sngDistanceCorrectionCoeff_x0 = GotABot_Settings.xml_sngDistanceCorrectionCoeff_x0
            sngDistanceCorrectionCoeff_x1 = GotABot_Settings.xml_sngDistanceCorrectionCoeff_x1
            sngDistanceCorrectionCoeff_x2 = GotABot_Settings.xml_sngDistanceCorrectionCoeff_x2
            If (sngDistanceCorrectionCoeff_x0 = 0) And (sngDistanceCorrectionCoeff_x1 = 0) And (sngDistanceCorrectionCoeff_x2 = 0) Then
                sngDistanceCorrectionCoeff_x0 = 0.0924
                sngDistanceCorrectionCoeff_x1 = 0.8986
                sngDistanceCorrectionCoeff_x2 = -0.0059
            End If
            sngBotLinearAcceleration = GotABot_Settings.xml_sngBotLinearAcceleration
            If (sngBotLinearAcceleration <= 0) Then sngBotLinearAcceleration = 1
            sngBotLinearVelocity = GotABot_Settings.xml_sngBotLinearVelocity
            sngBotLinearVelocityMax = sngBotLinearVelocity
            sngBotAngularVelocity = GotABot_Settings.xml_sngBotAngularVelocity
            sngBotAngularAcceleration = GotABot_Settings.xml_sngBotAngularAcceleration
            If (sngBotAngularAcceleration <= 0) Then sngBotAngularAcceleration = 1
            sngBotWheelSeparation = GotABot_Settings.xml_sngBotWheelSeparation
            If (sngBotWheelSeparation <= 0) Then sngBotWheelSeparation = 38
            If boolBotConnected Then
                ftnSendCommand("set linear velocity " & Int(sngBotLinearVelocity).ToString)
                ftnSendCommand("set angular velocity  " & Int(sngBotAngularVelocity).ToString)
            End If
            intPowerMoving = GotABot_Settings.xml_intPowerMoving
            If (intPowerMoving = 0) Then intPowerMoving = 80
            intPowerStopped = GotABot_Settings.xml_intPowerStopped
            strApiPassword = GotABot_Settings.xml_strApiPassword
            sngBotDiameter = GotABot_Settings.xml_sngBotDiameter
            sngCameraOffset = GotABot_Settings.xml_sngCameraOffset
            sngCameraFOV = GotABot_Settings.xml_sngCameraFOV
            sngCameraOffsetDegrees = GotABot_Settings.xml_sngCameraOffsetDegrees
            ticCameraResolution = GotABot_Settings.xml_ticCameraResolution
            sngMaxTravel = GotABot_Settings.xml_sngMaxTravel
            sngZoom = GotABot_Settings.xml_sngZoom
            tbpBotPose = GotABot_Settings.xml_tbpBotPose
            sngBotMovementAccuracy = GotABot_Settings.xml_sngBotMovementAccuracy
            tlmLandMarkArray = GotABot_Settings.xml_tlmLandMarkArray
            frmArm.taoObjectArray = GotABot_Settings.xml_taoObjectArray
            boolSimulatedMovement = GotABot_Settings.xml_boolSimulatedMovement
            boolEnableRcc = GotABot_Settings.xml_mnuEnableRcc
            frmArm.boolEnableArm = GotABot_Settings.xml_mnuEnableArm
            boolEnableFaceRecognition = GotABot_Settings.xml_mnuboolEnableFaceRecognition
            boolEnableVideo = GotABot_Settings.xml_mnuboolEnableVideo
            boolViewLM = GotABot_Settings.xml_boolViewLM
            boolViewDebug = GotABot_Settings.xml_boolViewDebug
            boolMute = GotABot_Settings.xml_boolMute
            boolLogFileEnable = GotABot_Settings.xml_boolLogFileEnable
            boolHeroSelected = GotABot_Settings.xml_boolHeroSelected
            boolER1Selected = GotABot_Settings.xml_boolER1Selected
            boolEnableBumperSwitches_ER1 = GotABot_Settings.xml_boolEnableBumperSwitches_ER1
            intVideoSource = GotABot_Settings.xml_intVideoSource
            frmArm.intArmComPort = GotABot_Settings.xml_intArmComPort
            subRecalculateVariables()
            ftnSetMoveInfo(TypeOfMove.NONE, tbpBotPose, tbpBotPose, True)
            ftnSetMoveInfo(TypeOfMove.NONE, tbpBotPose, tbpBotPose, False)
            tmiMoveInfo.boolMoveCommandInProgress = False
        Catch ex As Exception
            frmDebug.subWriteLogs(" EXCEPTION in LoadSettings " & ex.ToString)
        End Try
    End Sub



    Public Class BotSettings
        Private _xml_tmcDock As typeMapCoordinate
        Private _xml_boolDockBackIn As Boolean
        Private _xml_intDockOrientation As Integer
        Private _xml_intDockTriggerPC As Integer
        Private _xml_sngDockTriggerBot As Single
        Private _xml_sngScanFOV As Single
        Private _xml_sngScannerCalibrate As Single
        Private _xml_sngScannerCurveAdjust As Single
        Private _xml_intScanOffsetDegrees As Short
        Private _xml_tmcScanVectorOffset As typeMapCoordinate
        Private _xml_intNumberOfBeams As Integer
        Private _xml_intNumberOfParticles As Integer
        Private _xml_intDefaultElevation As Integer
        Private _xml_sngLocalizationTime As Single
        Private _xml_sngSteeringBiasOffsetCorrection As Single
        Private _xml_sngDistanceCorrectionCoeff_x0 As Single
        Private _xml_sngDistanceCorrectionCoeff_x1 As Single
        Private _xml_sngDistanceCorrectionCoeff_x2 As Single
        Private _xml_sngBotLinearAcceleration As Single
        Private _xml_sngBotLinearVelocity As Single
        Private _xml_sngBotAngularVelocity As Single
        Private _xml_sngBotAngularAcceleration As Single
        Private _xml_sngBotWheelSeparation As Single
        Private _xml_intPowerMoving As Integer
        Private _xml_intPowerStopped As Integer
        Private _xml_strApiPassword As String
        Private _xml_sngBotDiameter As Single
        Private _xml_sngCameraOffset As Single
        Private _xml_sngCameraFOV As Single
        Private _xml_sngCameraOffsetDegrees As Single
        Private _xml_ticCameraResolution As typeImageCoordinate
        Private _xml_sngBotMovementAccuracy As Single
        Private _xml_sngMaxTravel As Single
        Private _xml_sngZoom As Single
        Private _xml_tbpBotPose As typeBotPose
        Private _xml_tlmLandMarkArray(128) As typeLandMark
        Private _xml_taoObjectArray(32) As frmArm.typeArmObject
        Private _xml_boolSimulatedMovement As Boolean
        Private _xml_mnuEnableRcc As Boolean
        Private _xml_mnuEnableArm As Boolean
        Private _xml_mnuboolEnableFaceRecognition As Boolean
        Private _xml_mnuboolEnableVideo As Boolean
        Private _xml_boolViewLM As Boolean
        Private _xml_boolViewDebug As Boolean
        Private _xml_boolMute As Boolean
        Private _xml_boolLogFileEnable As Boolean
        Private _xml_boolHeroSelected As Boolean
        Private _xml_boolER1Selected As Boolean
        Private _xml_boolEnableBumperSwitches_ER1 As Boolean
        Private _xml_intVideoSource As Integer
        Private _xml_intArmComPort As Integer


        Public Property xml_tmcDock() As typeMapCoordinate
            Get
                Return _xml_tmcDock
            End Get
            Set(ByVal value As typeMapCoordinate)
                _xml_tmcDock = value
            End Set
        End Property

        Public Property xml_boolDockBackIn() As Boolean
            Get
                Return _xml_boolDockBackIn
            End Get
            Set(ByVal value As Boolean)
                _xml_boolDockBackIn = value
            End Set
        End Property

        Public Property xml_intDockOrientation() As Integer
            Get
                Return _xml_intDockOrientation
            End Get
            Set(ByVal value As Integer)
                _xml_intDockOrientation = value
            End Set
        End Property

        Public Property xml_intDockTriggerPC() As Integer
            Get
                Return _xml_intDockTriggerPC
            End Get
            Set(ByVal value As Integer)
                _xml_intDockTriggerPC = value
            End Set
        End Property

        Public Property xml_sngDockTriggerBot() As Single
            Get
                Return _xml_sngDockTriggerBot
            End Get
            Set(ByVal value As Single)
                _xml_sngDockTriggerBot = value
            End Set
        End Property

        Public Property xml_sngScanFOV() As Single
            Get
                Return _xml_sngScanFOV
            End Get
            Set(ByVal value As Single)
                _xml_sngScanFOV = value
            End Set
        End Property

        Public Property xml_sngScannerCalibrate() As Single
            Get
                Return _xml_sngScannerCalibrate
            End Get
            Set(ByVal value As Single)
                _xml_sngScannerCalibrate = value
            End Set
        End Property

        Public Property xml_sngScannerCurveAdjust() As Single
            Get
                Return _xml_sngScannerCurveAdjust
            End Get
            Set(ByVal value As Single)
                _xml_sngScannerCurveAdjust = value
            End Set
        End Property

        Public Property xml_intScanOffsetDegrees() As Short
            Get
                Return _xml_intScanOffsetDegrees
            End Get
            Set(ByVal value As Short)
                _xml_intScanOffsetDegrees = value
            End Set
        End Property


        Public Property xml_tmcScanVectorOffset() As typeMapCoordinate
            Get
                Return _xml_tmcScanVectorOffset
            End Get
            Set(ByVal value As typeMapCoordinate)
                _xml_tmcScanVectorOffset = value
            End Set
        End Property

        Public Property xml_intNumberOfBeams() As Integer
            Get
                Return _xml_intNumberOfBeams
            End Get
            Set(ByVal value As Integer)
                _xml_intNumberOfBeams = value
            End Set
        End Property

        Public Property xml_intNumberOfParticles() As Integer
            Get
                Return _xml_intNumberOfParticles
            End Get
            Set(ByVal value As Integer)
                _xml_intNumberOfParticles = value
            End Set
        End Property

        Public Property xml_intDefaultElevation() As Integer
            Get
                Return _xml_intDefaultElevation
            End Get
            Set(ByVal value As Integer)
                _xml_intDefaultElevation = value
            End Set
        End Property

        Public Property xml_sngLocalizationTime() As Single
            Get
                Return _xml_sngLocalizationTime
            End Get
            Set(ByVal value As Single)
                _xml_sngLocalizationTime = value
            End Set
        End Property

        Public Property xml_sngSteeringBiasOffsetCorrection() As Single
            Get
                Return _xml_sngSteeringBiasOffsetCorrection
            End Get
            Set(ByVal value As Single)
                _xml_sngSteeringBiasOffsetCorrection = value
            End Set
        End Property

        Public Property xml_sngDistanceCorrectionCoeff_x0() As Single
            Get
                Return _xml_sngDistanceCorrectionCoeff_x0
            End Get
            Set(ByVal value As Single)
                _xml_sngDistanceCorrectionCoeff_x0 = value
            End Set
        End Property

        Public Property xml_sngDistanceCorrectionCoeff_x1() As Single
            Get
                Return _xml_sngDistanceCorrectionCoeff_x1
            End Get
            Set(ByVal value As Single)
                _xml_sngDistanceCorrectionCoeff_x1 = value
            End Set
        End Property

        Public Property xml_sngDistanceCorrectionCoeff_x2() As Single
            Get
                Return _xml_sngDistanceCorrectionCoeff_x2
            End Get
            Set(ByVal value As Single)
                _xml_sngDistanceCorrectionCoeff_x2 = value
            End Set
        End Property

        Public Property xml_sngBotLinearAcceleration() As Single
            Get
                Return _xml_sngBotLinearAcceleration
            End Get
            Set(ByVal value As Single)
                _xml_sngBotLinearAcceleration = value
            End Set
        End Property

        Public Property xml_sngBotLinearVelocity() As Single
            Get
                Return _xml_sngBotLinearVelocity
            End Get
            Set(ByVal value As Single)
                _xml_sngBotLinearVelocity = value
            End Set
        End Property

        Public Property xml_sngBotAngularVelocity() As Single
            Get
                Return _xml_sngBotAngularVelocity
            End Get
            Set(ByVal value As Single)
                _xml_sngBotAngularVelocity = value
            End Set
        End Property

        Public Property xml_sngBotAngularAcceleration() As Single
            Get
                Return _xml_sngBotAngularAcceleration
            End Get
            Set(ByVal value As Single)
                _xml_sngBotAngularAcceleration = value
            End Set
        End Property

        Public Property xml_sngBotWheelSeparation() As Single
            Get
                Return _xml_sngBotWheelSeparation
            End Get
            Set(ByVal value As Single)
                _xml_sngBotWheelSeparation = value
            End Set
        End Property

        Public Property xml_intPowerMoving() As Integer
            Get
                Return _xml_intPowerMoving
            End Get
            Set(ByVal value As Integer)
                _xml_intPowerMoving = value
            End Set
        End Property

        Public Property xml_intPowerStopped() As Integer
            Get
                Return _xml_intPowerStopped
            End Get
            Set(ByVal value As Integer)
                _xml_intPowerStopped = value
            End Set
        End Property

        Public Property xml_strApiPassword() As String
            Get
                Return _xml_strApiPassword
            End Get
            Set(ByVal value As String)
                _xml_strApiPassword = value
            End Set
        End Property

        Public Property xml_sngCameraOffset() As Single
            Get
                Return _xml_sngCameraOffset
            End Get
            Set(ByVal value As Single)
                _xml_sngCameraOffset = value
            End Set
        End Property

        Public Property xml_sngBotDiameter() As Single
            Get
                Return _xml_sngBotDiameter
            End Get
            Set(ByVal value As Single)
                _xml_sngBotDiameter = value
            End Set
        End Property

        Public Property xml_sngCameraFOV() As Single
            Get
                Return _xml_sngCameraFOV
            End Get
            Set(ByVal value As Single)
                _xml_sngCameraFOV = value
            End Set
        End Property

        Public Property xml_sngCameraOffsetDegrees() As Single
            Get
                Return _xml_sngCameraOffsetDegrees
            End Get
            Set(ByVal value As Single)
                _xml_sngCameraOffsetDegrees = value
            End Set
        End Property

        Public Property xml_ticCameraResolution() As typeImageCoordinate
            Get
                Return _xml_ticCameraResolution
            End Get
            Set(ByVal value As typeImageCoordinate)
                _xml_ticCameraResolution = value
            End Set
        End Property

        Public Property xml_sngBotMovementAccuracy() As Single
            Get
                Return _xml_sngBotMovementAccuracy
            End Get
            Set(ByVal value As Single)
                _xml_sngBotMovementAccuracy = value
            End Set
        End Property

        Public Property xml_sngMaxTravel() As Single
            Get
                Return _xml_sngMaxTravel
            End Get
            Set(ByVal value As Single)
                _xml_sngMaxTravel = value
            End Set
        End Property

        Public Property xml_sngZoom() As Single
            Get
                Return _xml_sngZoom
            End Get
            Set(ByVal value As Single)
                _xml_sngZoom = value
            End Set
        End Property

        Public Property xml_tbpBotPose() As typeBotPose
            Get
                Return _xml_tbpBotPose
            End Get
            Set(ByVal value As typeBotPose)
                _xml_tbpBotPose = value
            End Set
        End Property

        Public Property xml_tlmLandMarkArray() As typeLandMark()
            Get
                Return _xml_tlmLandMarkArray
            End Get
            Set(ByVal value As typeLandMark())
                For i = 0 To UBound(tlmLandMarkArray)
                    _xml_tlmLandMarkArray(i) = value(i)
                Next i
            End Set
        End Property

        Public Property xml_taoObjectArray() As frmArm.typeArmObject()
            Get
                Return _xml_taoObjectArray
            End Get
            Set(ByVal value As frmArm.typeArmObject())
                For i = 0 To UBound(frmArm.taoObjectArray)
                    _xml_taoObjectArray(i) = value(i)
                Next i
            End Set
        End Property

        Public Property xml_boolSimulatedMovement() As Boolean
            Get
                Return _xml_boolSimulatedMovement
            End Get
            Set(ByVal value As Boolean)
                _xml_boolSimulatedMovement = value
            End Set
        End Property

        Public Property xml_mnuEnableRcc() As Boolean
            Get
                Return _xml_mnuEnableRcc
            End Get
            Set(ByVal value As Boolean)
                _xml_mnuEnableRcc = value
            End Set
        End Property

        Public Property xml_mnuEnableArm() As Boolean
            Get
                Return _xml_mnuEnableArm
            End Get
            Set(ByVal value As Boolean)
                _xml_mnuEnableArm = value
            End Set
        End Property

        Public Property xml_mnuboolEnableFaceRecognition() As Boolean
            Get
                Return _xml_mnuboolEnableFaceRecognition
            End Get
            Set(ByVal value As Boolean)
                _xml_mnuboolEnableFaceRecognition = value
            End Set
        End Property

        Public Property xml_mnuboolEnableVideo() As Boolean
            Get
                Return _xml_mnuboolEnableVideo
            End Get
            Set(ByVal value As Boolean)
                _xml_mnuboolEnableVideo = value
            End Set
        End Property

        Public Property xml_boolViewLM() As Boolean
            Get
                Return _xml_boolViewLM
            End Get
            Set(ByVal value As Boolean)
                _xml_boolViewLM = value
            End Set
        End Property

        Public Property xml_boolViewDebug() As Boolean
            Get
                Return _xml_boolViewDebug
            End Get
            Set(ByVal value As Boolean)
                _xml_boolViewDebug = value
            End Set
        End Property

        Public Property xml_boolMute() As Boolean
            Get
                Return _xml_boolMute
            End Get
            Set(ByVal value As Boolean)
                _xml_boolMute = value
            End Set
        End Property

        Public Property xml_boolLogFileEnable() As Boolean
            Get
                Return _xml_boolLogFileEnable
            End Get
            Set(ByVal value As Boolean)
                _xml_boolLogFileEnable = value
            End Set
        End Property

        Public Property xml_boolHeroSelected() As Boolean
            Get
                Return _xml_boolHeroSelected
            End Get
            Set(ByVal value As Boolean)
                _xml_boolHeroSelected = value
            End Set
        End Property

        Public Property xml_boolER1Selected() As Boolean
            Get
                Return _xml_boolER1Selected
            End Get
            Set(ByVal value As Boolean)
                _xml_boolER1Selected = value
            End Set
        End Property

        Public Property xml_boolEnableBumperSwitches_ER1() As Boolean
            Get
                Return _xml_boolEnableBumperSwitches_ER1
            End Get
            Set(ByVal value As Boolean)
                _xml_boolEnableBumperSwitches_ER1 = value
            End Set
        End Property


        Public Property xml_intVideoSource() As Integer
            Get
                Return _xml_intVideoSource
            End Get
            Set(ByVal value As Integer)
                _xml_intVideoSource = value
            End Set
        End Property

        Public Property xml_intArmComPort() As Integer
            Get
                Return _xml_intArmComPort
            End Get
            Set(ByVal value As Integer)
                _xml_intArmComPort = value
            End Set
        End Property



        ' Empty constructor required for serialization.
        Public Sub New()
        End Sub

        Public Sub New(
            ByVal _xml_tmcDock As typeMapCoordinate,
            ByVal _xml_boolDockBackIn As Boolean,
            ByVal _xml_intDockOrientation As Integer,
            ByVal _xml_intDockTriggerPC As Integer,
            ByVal _xml_sngDockTriggerBot As Single,
            ByVal _xml_sngScanFOV As Single,
            ByVal _xml_sngScannerCalibrate As Single,
            ByVal _xml_sngScannerCurveAdjust As Single,
            ByVal _xml_intScanOffsetDegrees As Short,
            ByVal _xml_tmcScanVectorOffset As typeMapCoordinate,
            ByVal _xml_intNumberOfBeams As Integer,
            ByVal _xml_intNumberOfParticles As Integer,
            ByVal _xml_intDefaultElevation As Integer,
            ByVal _xml_sngLocalizationTime As Single,
            ByVal _xml_sngSteeringBiasOffsetCorrection As Single,
            ByVal _xml_sngDistanceCorrectionCoeff_x0 As Single,
            ByVal _xml_sngDistanceCorrectionCoeff_x1 As Single,
            ByVal _xml_sngDistanceCorrectionCoeff_x2 As Single,
            ByVal _xml_sngBotLinearAcceleration As Single,
            ByVal _xml_sngBotLinearVelocity As Single,
            ByVal _xml_sngBotAngularVelocity As Single,
            ByVal _xml_sngBotAngularAcceleration As Single,
            ByVal _xml_sngBotWheelSeparation As Single,
            ByVal _xml_intPowerMoving As Integer,
            ByVal _xml_intPowerStopped As Integer,
            ByVal _xml_strApiPassword As String,
            ByVal _xml_sngBotDiameter As Single,
            ByVal _xml_sngCameraOffset As Single,
            ByVal _xml_sngCameraFOV As Single,
            ByVal _xml_sngCameraOffsetDegrees As Single,
            ByVal _xml_ticCameraResolution As typeImageCoordinate,
            ByVal _xml_sngBotMovementAccuracy As Single,
            ByVal _xml_sngMaxTravel As Single,
            ByVal _xml_sngZoom As Single,
            ByVal _xml_tbpBotPose As typeBotPose,
            ByVal _xml_tlmLandMarkArray() As typeLandMark,
            ByVal _xml_taoObjectArray() As typeLandMark,
            ByVal _xml_boolSimulatedMovement As Boolean,
            ByVal _xml_mnuEnableRcc As Boolean,
            ByVal _xml_mnuEnableArm As Boolean,
            ByVal _xml_mnuboolEnableFaceRecognition As Boolean,
            ByVal _xml_mnuboolEnableVideo As Boolean,
            ByVal _xml_boolViewLM As Boolean,
            ByVal _xml_boolViewDebug As Boolean,
            ByVal _xml_boolMute As Boolean,
            ByVal _xml_boolLogFileEnable As Boolean,
            ByVal _xml_boolHeroSelected As Boolean,
            ByVal _xml_boolER1Selected As Boolean,
            ByVal _xml_boolEnableBumperSwitches_ER1 As Boolean,
            ByVal _xml_intVideoSource As Integer,
            ByVal _xml_intArmComPort As Integer
                )
            Try
                tmcDock = xml_tmcDock
                boolDockBackIn = xml_boolDockBackIn
                intDockOrientation = xml_intDockOrientation
                intDockTriggerPC = xml_intDockTriggerPC
                sngDockTriggerBot = xml_sngDockTriggerBot
                sngScanFOV = xml_sngScanFOV
                sngScannerCalibrate = xml_sngScannerCalibrate
                sngScannerCurveAdjust = xml_sngScannerCurveAdjust
                intScanOffsetDegrees = xml_intScanOffsetDegrees
                tmcScanVectorOffset = xml_tmcScanVectorOffset
                intNumberOfBeams = xml_intNumberOfBeams
                intNumberOfParticles = xml_intNumberOfParticles
                intDefaultElevation = xml_intDefaultElevation
                sngLocalizationTime = xml_sngLocalizationTime
                sngSteeringBiasOffsetCorrection = xml_sngSteeringBiasOffsetCorrection
                sngDistanceCorrectionCoeff_x0 = xml_sngDistanceCorrectionCoeff_x0
                sngDistanceCorrectionCoeff_x1 = xml_sngDistanceCorrectionCoeff_x1
                sngDistanceCorrectionCoeff_x2 = xml_sngDistanceCorrectionCoeff_x2
                sngBotLinearAcceleration = xml_sngBotLinearAcceleration
                sngBotLinearVelocity = xml_sngBotLinearVelocity
                sngBotAngularVelocity = xml_sngBotAngularVelocity
                sngBotAngularAcceleration = xml_sngBotAngularAcceleration
                sngBotWheelSeparation = xml_sngBotWheelSeparation
                intPowerMoving = xml_intPowerMoving
                intPowerStopped = xml_intPowerStopped
                If (xml_strApiPassword <> "") Then strApiPassword = xml_strApiPassword
                sngBotDiameter = xml_sngBotDiameter
                sngCameraOffset = xml_sngCameraOffset
                sngCameraFOV = xml_sngCameraFOV
                sngCameraOffsetDegrees = xml_sngCameraOffsetDegrees
                ticCameraResolution = xml_ticCameraResolution
                sngBotMovementAccuracy = xml_sngBotMovementAccuracy
                sngMaxTravel = xml_sngMaxTravel
                sngZoom = xml_sngZoom
                tbpBotPose = xml_tbpBotPose
                tlmLandMarkArray = xml_tlmLandMarkArray
                frmArm.taoObjectArray = xml_taoObjectArray
                boolSimulatedMovement = xml_boolSimulatedMovement
                boolEnableRcc = xml_mnuEnableRcc
                frmArm.boolEnableArm = xml_mnuEnableArm
                boolEnableFaceRecognition = xml_mnuboolEnableFaceRecognition
                boolEnableVideo = xml_mnuboolEnableVideo
                boolViewLM = xml_boolViewLM
                boolViewDebug = xml_boolViewDebug
                boolEnableRBPF = False
                boolMute = xml_boolMute
                boolLogFileEnable = xml_boolLogFileEnable
                boolHeroSelected = xml_boolHeroSelected
                boolER1Selected = xml_boolER1Selected
                boolEnableBumperSwitches_ER1 = xml_boolEnableBumperSwitches_ER1
                intVideoSource = xml_intVideoSource
                frmArm.intArmComPort = xml_intArmComPort
            Catch ex As Exception
                frmDebug.subWriteLogs(" EXCEPTION in New")
            End Try
        End Sub



        Public Sub SaveSettingsXml(ByVal path As String)
            On Error Resume Next
            Dim xserializer As New XmlSerializer(Me.GetType)
            Using file As New FileStream(path, FileMode.Create)
                xserializer.Serialize(file, Me)
            End Using
        End Sub

        Public Shared Function LoadSettingsXml(ByVal path As String) As BotSettings
            On Error Resume Next
            Dim deserializer As New XmlSerializer(GetType(BotSettings))
            Using file As New FileStream(path, FileMode.Open)
                Return DirectCast(deserializer.Deserialize(file), BotSettings)
            End Using
        End Function



    End Class




End Module




