﻿Option Strict Off
Option Explicit On 
Imports System.Text
Friend Class Setting
	Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

	Public Sub New()
		MyBase.New()

		'This call is required by the Windows Form Designer.
		InitializeComponent()

		'Add any initialization after the InitializeComponent() call

	End Sub

	'Form overrides dispose to clean up the component list.
	Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
		If disposing Then
			If Not (components Is Nothing) Then
				components.Dispose()
			End If
		End If
		MyBase.Dispose(disposing)
	End Sub

	'Required by the Windows Form Designer
	Private components As System.ComponentModel.IContainer

	'NOTE: The following procedure is required by the Windows Form Designer
	'It can be modified using the Windows Form Designer.  
	'Do not modify it using the code editor.
	Friend WithEvents DeviceName As System.Windows.Forms.Label
	Friend WithEvents Label2 As System.Windows.Forms.Label
	Friend WithEvents txtDevice As System.Windows.Forms.TextBox
	Friend WithEvents cboTargetAxis As System.Windows.Forms.ComboBox
	Friend WithEvents GroupBox1 As System.Windows.Forms.GroupBox
	Friend WithEvents Label3 As System.Windows.Forms.Label
	Friend WithEvents chkDirTimer As System.Windows.Forms.CheckBox
	Friend WithEvents chkSAcc As System.Windows.Forms.CheckBox
	Friend WithEvents GroupBox2 As System.Windows.Forms.GroupBox
	Friend WithEvents Label4 As System.Windows.Forms.Label
	Friend WithEvents btnComInOutSet As System.Windows.Forms.Button
	Friend WithEvents btnComLogicSet As System.Windows.Forms.Button
	Friend WithEvents btnComErcAlmClrSet As System.Windows.Forms.Button
	Friend WithEvents btnComLtcClrSet As System.Windows.Forms.Button
	Friend WithEvents btnComSet As System.Windows.Forms.Button
	Friend WithEvents btnComStatus As System.Windows.Forms.Button
	Friend WithEvents btnComOrgSet As System.Windows.Forms.Button
    Friend WithEvents btnComExit As System.Windows.Forms.Button
    Friend WithEvents GroupBox3 As System.Windows.Forms.GroupBox
	Friend WithEvents lblComment As System.Windows.Forms.Label
	Friend WithEvents cboPlstype As System.Windows.Forms.ComboBox
	Friend WithEvents cboEncType As System.Windows.Forms.ComboBox
	<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.DeviceName = New System.Windows.Forms.Label()
        Me.Label2 = New System.Windows.Forms.Label()
        Me.txtDevice = New System.Windows.Forms.TextBox()
        Me.cboTargetAxis = New System.Windows.Forms.ComboBox()
        Me.GroupBox1 = New System.Windows.Forms.GroupBox()
        Me.cboPlstype = New System.Windows.Forms.ComboBox()
        Me.chkSAcc = New System.Windows.Forms.CheckBox()
        Me.chkDirTimer = New System.Windows.Forms.CheckBox()
        Me.Label3 = New System.Windows.Forms.Label()
        Me.GroupBox2 = New System.Windows.Forms.GroupBox()
        Me.cboEncType = New System.Windows.Forms.ComboBox()
        Me.Label4 = New System.Windows.Forms.Label()
        Me.btnComInOutSet = New System.Windows.Forms.Button()
        Me.btnComLogicSet = New System.Windows.Forms.Button()
        Me.btnComErcAlmClrSet = New System.Windows.Forms.Button()
        Me.btnComLtcClrSet = New System.Windows.Forms.Button()
        Me.btnComSet = New System.Windows.Forms.Button()
        Me.btnComStatus = New System.Windows.Forms.Button()
        Me.btnComOrgSet = New System.Windows.Forms.Button()
        Me.btnComExit = New System.Windows.Forms.Button()
        Me.GroupBox3 = New System.Windows.Forms.GroupBox()
        Me.lblComment = New System.Windows.Forms.Label()
        Me.GroupBox1.SuspendLayout()
        Me.GroupBox2.SuspendLayout()
        Me.GroupBox3.SuspendLayout()
        Me.SuspendLayout()
        '
        'DeviceName
        '
        Me.DeviceName.AutoSize = True
        Me.DeviceName.Location = New System.Drawing.Point(16, 18)
        Me.DeviceName.Name = "DeviceName"
        Me.DeviceName.Size = New System.Drawing.Size(79, 14)
        Me.DeviceName.TabIndex = 0
        Me.DeviceName.Text = "DeviceName:"
        '
        'Label2
        '
        Me.Label2.AutoSize = True
        Me.Label2.Location = New System.Drawing.Point(248, 18)
        Me.Label2.Name = "Label2"
        Me.Label2.Size = New System.Drawing.Size(47, 14)
        Me.Label2.TabIndex = 1
        Me.Label2.Text = "AxisNo:"
        '
        'txtDevice
        '
        Me.txtDevice.Location = New System.Drawing.Point(112, 16)
        Me.txtDevice.Name = "txtDevice"
        Me.txtDevice.Size = New System.Drawing.Size(88, 21)
        Me.txtDevice.TabIndex = 2
        Me.txtDevice.Text = ""
        '
        'cboTargetAxis
        '
        Me.cboTargetAxis.Location = New System.Drawing.Point(312, 16)
        Me.cboTargetAxis.Name = "cboTargetAxis"
        Me.cboTargetAxis.Size = New System.Drawing.Size(72, 23)
        Me.cboTargetAxis.TabIndex = 3
        '
        'GroupBox1
        '
        Me.GroupBox1.Controls.AddRange(New System.Windows.Forms.Control() {Me.cboPlstype, Me.chkSAcc, Me.chkDirTimer, Me.Label3})
        Me.GroupBox1.Location = New System.Drawing.Point(16, 48)
        Me.GroupBox1.Name = "GroupBox1"
        Me.GroupBox1.Size = New System.Drawing.Size(424, 120)
        Me.GroupBox1.TabIndex = 4
        Me.GroupBox1.TabStop = False
        Me.GroupBox1.Text = "PulseOut"
        '
        'cboPlstype
        '
        Me.cboPlstype.Location = New System.Drawing.Point(96, 24)
        Me.cboPlstype.Name = "cboPlstype"
        Me.cboPlstype.Size = New System.Drawing.Size(312, 23)
        Me.cboPlstype.TabIndex = 4
        '
        'chkSAcc
        '
        Me.chkSAcc.Location = New System.Drawing.Point(32, 88)
        Me.chkSAcc.Name = "chkSAcc"
        Me.chkSAcc.Size = New System.Drawing.Size(200, 16)
        Me.chkSAcc.TabIndex = 3
        Me.chkSAcc.Text = "S Accel/Decel Use"
        '
        'chkDirTimer
        '
        Me.chkDirTimer.Location = New System.Drawing.Point(32, 56)
        Me.chkDirTimer.Name = "chkDirTimer"
        Me.chkDirTimer.Size = New System.Drawing.Size(200, 16)
        Me.chkDirTimer.TabIndex = 2
        Me.chkDirTimer.Text = "Reverse Direction Timer ON"
        '
        'Label3
        '
        Me.Label3.AutoSize = True
        Me.Label3.Location = New System.Drawing.Point(16, 26)
        Me.Label3.Name = "Label3"
        Me.Label3.Size = New System.Drawing.Size(70, 14)
        Me.Label3.TabIndex = 0
        Me.Label3.Text = "PulseType :"
        '
        'GroupBox2
        '
        Me.GroupBox2.Controls.AddRange(New System.Windows.Forms.Control() {Me.cboEncType, Me.Label4})
        Me.GroupBox2.Location = New System.Drawing.Point(16, 176)
        Me.GroupBox2.Name = "GroupBox2"
        Me.GroupBox2.Size = New System.Drawing.Size(424, 64)
        Me.GroupBox2.TabIndex = 5
        Me.GroupBox2.TabStop = False
        Me.GroupBox2.Text = "PulseIn"
        '
        'cboEncType
        '
        Me.cboEncType.Location = New System.Drawing.Point(120, 22)
        Me.cboEncType.Name = "cboEncType"
        Me.cboEncType.Size = New System.Drawing.Size(288, 23)
        Me.cboEncType.TabIndex = 1
        '
        'Label4
        '
        Me.Label4.AutoSize = True
        Me.Label4.Location = New System.Drawing.Point(16, 26)
        Me.Label4.Name = "Label4"
        Me.Label4.Size = New System.Drawing.Size(85, 14)
        Me.Label4.TabIndex = 0
        Me.Label4.Text = "EncoderType :"
        '
        'btnComInOutSet
        '
        Me.btnComInOutSet.Location = New System.Drawing.Point(16, 256)
        Me.btnComInOutSet.Name = "btnComInOutSet"
        Me.btnComInOutSet.Size = New System.Drawing.Size(112, 24)
        Me.btnComInOutSet.TabIndex = 6
        Me.btnComInOutSet.Text = "In/Out Setting"
        '
        'btnComLogicSet
        '
        Me.btnComLogicSet.Location = New System.Drawing.Point(152, 256)
        Me.btnComLogicSet.Name = "btnComLogicSet"
        Me.btnComLogicSet.Size = New System.Drawing.Size(116, 24)
        Me.btnComLogicSet.TabIndex = 7
        Me.btnComLogicSet.Text = "Logic Setting"
        '
        'btnComErcAlmClrSet
        '
        Me.btnComErcAlmClrSet.Location = New System.Drawing.Point(16, 296)
        Me.btnComErcAlmClrSet.Name = "btnComErcAlmClrSet"
        Me.btnComErcAlmClrSet.Size = New System.Drawing.Size(176, 24)
        Me.btnComErcAlmClrSet.TabIndex = 8
        Me.btnComErcAlmClrSet.Text = "ERC/ALM Clear Setting"
        '
        'btnComLtcClrSet
        '
        Me.btnComLtcClrSet.Location = New System.Drawing.Point(216, 296)
        Me.btnComLtcClrSet.Name = "btnComLtcClrSet"
        Me.btnComLtcClrSet.Size = New System.Drawing.Size(184, 24)
        Me.btnComLtcClrSet.TabIndex = 9
        Me.btnComLtcClrSet.Text = "LTC/CLR Setting"
        '
        'btnComSet
        '
        Me.btnComSet.Location = New System.Drawing.Point(24, 336)
        Me.btnComSet.Name = "btnComSet"
        Me.btnComSet.Size = New System.Drawing.Size(88, 40)
        Me.btnComSet.TabIndex = 10
        Me.btnComSet.Text = "&Set"
        '
        'btnComStatus
        '
        Me.btnComStatus.Location = New System.Drawing.Point(120, 336)
        Me.btnComStatus.Name = "btnComStatus"
        Me.btnComStatus.Size = New System.Drawing.Size(88, 40)
        Me.btnComStatus.TabIndex = 11
        Me.btnComStatus.Text = "S&tatus"
        '
        'btnComOrgSet
        '
        Me.btnComOrgSet.Location = New System.Drawing.Point(296, 256)
        Me.btnComOrgSet.Name = "btnComOrgSet"
        Me.btnComOrgSet.Size = New System.Drawing.Size(112, 24)
        Me.btnComOrgSet.TabIndex = 12
        Me.btnComOrgSet.Text = "ORG Setting"
        '
        'btnComExit
        '
        Me.btnComExit.Location = New System.Drawing.Point(344, 336)
        Me.btnComExit.Name = "btnComExit"
        Me.btnComExit.Size = New System.Drawing.Size(88, 40)
        Me.btnComExit.TabIndex = 14
        Me.btnComExit.Text = "&Exit"
        '
        'GroupBox3
        '
        Me.GroupBox3.Controls.AddRange(New System.Windows.Forms.Control() {Me.lblComment})
        Me.GroupBox3.Location = New System.Drawing.Point(16, 392)
        Me.GroupBox3.Name = "GroupBox3"
        Me.GroupBox3.Size = New System.Drawing.Size(424, 120)
        Me.GroupBox3.TabIndex = 15
        Me.GroupBox3.TabStop = False
        Me.GroupBox3.Text = "COMMENT"
        '
        'lblComment
        '
        Me.lblComment.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D
        Me.lblComment.Location = New System.Drawing.Point(16, 24)
        Me.lblComment.Name = "lblComment"
        Me.lblComment.Size = New System.Drawing.Size(392, 80)
        Me.lblComment.TabIndex = 0
        '
        'Setting
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
        Me.ClientSize = New System.Drawing.Size(456, 526)
        Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.GroupBox3, Me.btnComExit, Me.btnComOrgSet, Me.btnComStatus, Me.btnComSet, Me.btnComLtcClrSet, Me.btnComErcAlmClrSet, Me.btnComLogicSet, Me.btnComInOutSet, Me.GroupBox2, Me.GroupBox1, Me.cboTargetAxis, Me.txtDevice, Me.Label2, Me.DeviceName})
        Me.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog
        Me.MaximizeBox = False
        Me.MinimizeBox = False
        Me.Name = "Setting"
        Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
        Me.Text = "SETTING"
        Me.GroupBox1.ResumeLayout(False)
        Me.GroupBox2.ResumeLayout(False)
        Me.GroupBox3.ResumeLayout(False)
        Me.ResumeLayout(False)

    End Sub

#End Region
	Dim dwRet As Integer
	Dim szComment As String

	Dim gErcAlmClrSet As New ErcAlmClrSet()
	Dim gInOutSet As New InOutSet()
	Dim gLogicSet As New LogicSet()
	Dim gOrgSet As New OrgSet()
    Dim gLtcClrSet As New LtcClrSet()
    Dim ErrorString As New StringBuilder("", 256)  'Error String

	Private Sub chkDirTimer_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles chkDirTimer.Click

		DirTimer = chkDirTimer.CheckState

	End Sub

	Private Sub chkSAcc_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles chkSAcc.Click

		SAccelType = chkSAcc.CheckState

	End Sub

	Private Sub cboEncType_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cboEncType.SelectedIndexChanged

		EncType = cboEncType.SelectedIndex

	End Sub

	Private Sub cboPlstype_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cboPlstype.SelectedIndexChanged

		PulseType = cboPlstype.SelectedIndex

	End Sub

	Private Sub cboTargetAxis_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cboTargetAxis.SelectedIndexChanged

		AxisNo = cboTargetAxis.SelectedIndex + 1

		dwRet = GetInitParam()

		' ComboBox Initialise
		cboPlstype.SelectedIndex = PulseType
		cboEncType.SelectedIndex = EncType

		' CheckBox Initialise
		chkDirTimer.CheckState = DirTimer

		' CheckBox Initialise
		chkSAcc.CheckState = SAccelType

		' ComboBox Initialise
		cboTargetAxis.SelectedIndex = AxisNo - 1

	End Sub

	Private Sub btnComErcAlmClrSet_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnComErcAlmClrSet.Click

		gErcAlmClrSet.ShowDialog()
		
	End Sub

	Private Sub btnComExit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnComExit.Click

		gErcAlmClrSet.Dispose()
		gInOutSet.Dispose()
		gLogicSet.Dispose()
		gLtcClrSet.Dispose()
		gOrgSet.Dispose()
		SmcWExit(Id)
		Me.Close()

	End Sub



    Private Sub btnComInOutSet_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnComInOutSet.Click

        gInOutSet.ShowDialog()

    End Sub

    Private Sub btnComLogicSet_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnComLogicSet.Click

        gLogicSet.ShowDialog()

    End Sub

    Private Sub btnComLtcClrSet_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnComLtcClrSet.Click

        gLtcClrSet.ShowDialog()

    End Sub

    Private Sub btnComOrgSet_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnComOrgSet.Click

        gOrgSet.ShowDialog()

    End Sub

    Private Sub btnComSet_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnComSet.Click

        dwRet = SmcWSetPulseType(Id, AxisNo, PulseType, DirTimer)
        If dwRet <> 0 Then
            SmcWGetErrorString(dwRet, ErrorString)
            lblComment.Text = "SmcWSetPulseType = " & dwRet & " : " & ErrorString.ToString
            Exit Sub
        End If

        dwRet = SmcWSetEncType(Id, AxisNo, EncType)
        If dwRet <> 0 Then
            SmcWGetErrorString(dwRet, ErrorString)
            lblComment.Text = "SmcWSetEncType = " & dwRet & " : " & ErrorString.ToString
            Exit Sub
        End If

        dwRet = SmcWSetCtrlTypeOut(Id, AxisNo, CtrlOut1, CtrlOut2, CtrlOut3)
        If dwRet <> 0 Then
            SmcWGetErrorString(dwRet, ErrorString)
            lblComment.Text = "SmcWSetCtrlTypeOut = " & dwRet & " : " & ErrorString.ToString
            Exit Sub
        End If

        dwRet = SmcWSetCtrlTypeIn(Id, AxisNo, CtrlIn)
        If dwRet <> 0 Then
            SmcWGetErrorString(dwRet, ErrorString)
            lblComment.Text = "SmcWSetCtrlTypeIn = " & dwRet & " : " & ErrorString.ToString
            Exit Sub
        End If

        dwRet = SmcWSetOrgLog(Id, AxisNo, OrgLog)
        If dwRet <> 0 Then
            SmcWGetErrorString(dwRet, ErrorString)
            lblComment.Text = "SmcWSetOrgLog = " & dwRet & " : " & ErrorString.ToString
            Exit Sub
        End If

        dwRet = SmcWSetCtrlInOutLog(Id, AxisNo, CtrlInOutLog)
        If dwRet <> 0 Then
            SmcWGetErrorString(dwRet, ErrorString)
            lblComment.Text = "SmcWSetCtrlInOutLog = " & dwRet & " : " & ErrorString.ToString
            Exit Sub
        End If

        dwRet = SmcWSetErcMode(Id, AxisNo, ErcMode)
        If dwRet <> 0 Then
            SmcWGetErrorString(dwRet, ErrorString)
            lblComment.Text = "SmcWSetErcMode = " & dwRet & " : " & ErrorString.ToString
            Exit Sub
        End If

        dwRet = SmcWSetErcAlmClearTime(Id, AxisNo, ErcTime, ErcOffTimer, AlmTime)
        If dwRet <> 0 Then
            SmcWGetErrorString(dwRet, ErrorString)
            lblComment.Text = "SmcWSetErcAlmClearTime = " & dwRet & " : " & ErrorString.ToString
            Exit Sub
        End If

        dwRet = SmcWSetOrgMode(Id, AxisNo, LimitTurn, OrgType, EndDir, ZCount)
        If dwRet <> 0 Then
            SmcWGetErrorString(dwRet, ErrorString)
            lblComment.Text = "SmcWSetOrgMode = " & dwRet & " : " & ErrorString.ToString
            Exit Sub
        End If

        dwRet = SmcWSetErcMode(Id, AxisNo, ErcMode)
        If dwRet <> 0 Then
            SmcWGetErrorString(dwRet, ErrorString)
            lblComment.Text = "SmcWSetErcMode = " & dwRet & " : " & ErrorString.ToString
            Exit Sub
        End If

        dwRet = SmcWSetSAccelType(Id, AxisNo, SAccelType)
        If dwRet <> 0 Then
            SmcWGetErrorString(dwRet, ErrorString)
            lblComment.Text = "SmcWSetSAccelType = " & dwRet & " : " & ErrorString.ToString
            Exit Sub
        End If

        dwRet = SmcWSetInFilterType(Id, AxisNo, FilterType)
        If dwRet <> 0 Then
            SmcWGetErrorString(dwRet, ErrorString)
            lblComment.Text = "SmcWSetInFilterType = " & dwRet & " : " & ErrorString.ToString
            Exit Sub
        End If

        dwRet = SmcWSetSDMode(Id, AxisNo, SDMode)
        If dwRet <> 0 Then
            SmcWGetErrorString(dwRet, ErrorString)
            lblComment.Text = "SmcWSetSDMode = " & dwRet & " : " & ErrorString.ToString
            Exit Sub
        End If

        dwRet = SmcWSetCounterMode(Id, AxisNo, ClearCntLtc, LtcMode, ClearCntClr, ClrMode)
        If dwRet <> 0 Then
            SmcWGetErrorString(dwRet, ErrorString)
            lblComment.Text = "SmcWSetCounterMode = " & dwRet & " : " & ErrorString.ToString
            Exit Sub
        End If

        dwRet = SmcWSetInitParam(Id, AxisNo)
        If dwRet <> 0 Then
            SmcWGetErrorString(dwRet, ErrorString)
            lblComment.Text = "SmcWSetInitParam = " & dwRet & " : " & ErrorString.ToString
            Exit Sub
        End If

        lblComment.Text = "OK "
        
    End Sub

    Private Sub btnComStatus_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnComStatus.Click

        dwRet = SmcWGetInitParam(Id, AxisNo, InitParam)
        If dwRet <> 0 Then
            SmcWGetErrorString(dwRet, ErrorString)
            lblComment.Text = "SmcGetInitParam = " & dwRet & " : " & ErrorString.ToString
            Exit Sub
        End If

        If InitParam = 1 Then
            lblComment.Text = txtDevice.Text & ": Initial Setting [ OK ]"
        Else
            lblComment.Text = txtDevice.Text & ": Initial Setting [ None ]"
        End If

    End Sub

    Private Sub Setting_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        Dim n As Short
        ' PulseType ComboBox
        cboPlstype.Items.Clear()
        cboPlstype.Items.Add("PULSE/DIR,OUT:Low,DIR+:High,DIR-:Low")
        cboPlstype.Items.Add("PULSE/DIR,OUT:High,DIR+:High,DIR-:Low")
        cboPlstype.Items.Add("PULSE/DIR,OUT:Low,DIR+:Low,DIR-:High")
        cboPlstype.Items.Add("PULSE/DIR,OUT:High,DIR+:Low,DIR-:High")
        cboPlstype.Items.Add("CW/CCW:Low")
        cboPlstype.Items.Add("CW/CCW:High")
        cboPlstype.Items.Add("DIFFERENCE:OUT:Leading,DIR:Trailing")
        cboPlstype.Items.Add("DIFFERENCE:OUT:Trailing,DIR:Leading")

        ' EncoderType ComboBox
        cboEncType.Items.Clear()
        cboEncType.Items.Add("A/B two-phase input 1 times")
        cboEncType.Items.Add("A/B two-phase input 2 times")
        cboEncType.Items.Add("A/B two-phase input 4 times")
        cboEncType.Items.Add("U/D single-phase input 1 times")
        cboEncType.Items.Add("Not use")

        ' AxisNo ComboBox
        cboTargetAxis.Items.Clear()
        For n = 1 To 8
            cboTargetAxis.Items.Add(Str(n))
        Next

        AxisNo = 1

        txtDevice.Text = "SMC000"
        dwRet = SmcWInit(txtDevice.Text, Id)
        If dwRet <> 0 Then
            SmcWGetErrorString(dwRet, ErrorString)
            lblComment.Text = "SmcWInit = " & dwRet & " : " & ErrorString.ToString
            Exit Sub
        End If

        ' ComboBox Initialise
        cboTargetAxis.SelectedIndex = AxisNo - 1

        lblComment.Text = "OK "
        
    End Sub

    Function GetInitParam() As Boolean

        Ret = SmcWGetPulseType(Id, AxisNo, PulseType, DirTimer)
        Ret = SmcWGetEncType(Id, AxisNo, EncType)
        Ret = SmcWGetCtrlTypeOut(Id, AxisNo, CtrlOut1, CtrlOut2, CtrlOut3)
        Ret = SmcWGetCtrlTypeIn(Id, AxisNo, CtrlIn)
        Ret = SmcWGetOrgLog(Id, AxisNo, OrgLog)
        Ret = SmcWGetCtrlInOutLog(Id, AxisNo, CtrlInOutLog)
        Ret = SmcWGetErcMode(Id, AxisNo, ErcMode)
        Ret = SmcWGetErcAlmClearTime(Id, AxisNo, ErcTime, ErcOffTimer, AlmTime)
        Ret = SmcWGetOrgMode(Id, AxisNo, LimitTurn, OrgType, EndDir, ZCount)
        Ret = SmcWGetErcMode(Id, AxisNo, ErcMode)
        Ret = SmcWGetSAccelType(Id, AxisNo, SAccelType)
        Ret = SmcWGetInFilterType(Id, AxisNo, FilterType)
        Ret = SmcWGetSDMode(Id, AxisNo, SDMode)
        Ret = SmcWGetCounterMode(Id, AxisNo, ClearCntLtc, LtcMode, ClearCntClr, ClrMode)
        Ret = SmcWGetInitParam(Id, AxisNo, InitParam)

        GetInitParam = True

    End Function

    Private Sub txtDevice_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtDevice.TextChanged

        dwRet = SmcWInit(txtDevice.Text, Id)
        If dwRet <> 0 Then
            SmcWGetErrorString(dwRet, ErrorString)
            lblComment.Text = "SmcWInit = " & dwRet & " : " & ErrorString.ToString
            Exit Sub
        End If

        dwRet = GetInitParam()

        ' ComboBox Initialise
        cboPlstype.SelectedIndex = PulseType
        cboEncType.SelectedIndex = EncType

        ' CheckBox Initialise
        chkDirTimer.CheckState = DirTimer

        ' CheckBox Initialise
        chkSAcc.CheckState = SAccelType

        ' ComboBox Initialise
        cboTargetAxis.SelectedIndex = AxisNo - 1

        lblComment.Text = "OK "

    End Sub

End Class
