﻿Option Strict Off
Option Explicit On 
Imports System.Text
Public Class BankMlt
	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 LDeviceName As System.Windows.Forms.Label
	Friend WithEvents txtDeviceName As System.Windows.Forms.TextBox
	Friend WithEvents Label1 As System.Windows.Forms.Label
	Friend WithEvents cboTargetAxis As System.Windows.Forms.ComboBox
	Friend WithEvents txt2ndAxis As System.Windows.Forms.TextBox
	Friend WithEvents txt3rdAxis As System.Windows.Forms.TextBox
	Friend WithEvents MOTION As System.Windows.Forms.GroupBox
	Friend WithEvents cboBankNum As System.Windows.Forms.ComboBox
	Friend WithEvents btnComMove As System.Windows.Forms.Button
	Friend WithEvents btnComStop As System.Windows.Forms.Button
	Friend WithEvents GroupBox2 As System.Windows.Forms.GroupBox
	Friend WithEvents btnComEnd As System.Windows.Forms.Button
	Friend WithEvents GroupBox3 As System.Windows.Forms.GroupBox
	Friend WithEvents txtComment As System.Windows.Forms.Label
	Friend WithEvents chk3rdAxis As System.Windows.Forms.CheckBox
	Friend WithEvents rdoOptionSingle As System.Windows.Forms.RadioButton
	Friend WithEvents rdoOptionLoop As System.Windows.Forms.RadioButton
	Friend WithEvents lblSetList As System.Windows.Forms.Label
	Friend WithEvents Label10 As System.Windows.Forms.Label
	<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
		Me.LDeviceName = New System.Windows.Forms.Label()
		Me.txtDeviceName = New System.Windows.Forms.TextBox()
		Me.Label1 = New System.Windows.Forms.Label()
		Me.cboTargetAxis = New System.Windows.Forms.ComboBox()
		Me.txt2ndAxis = New System.Windows.Forms.TextBox()
		Me.txt3rdAxis = New System.Windows.Forms.TextBox()
		Me.MOTION = New System.Windows.Forms.GroupBox()
		Me.Label10 = New System.Windows.Forms.Label()
		Me.btnComStop = New System.Windows.Forms.Button()
		Me.btnComMove = New System.Windows.Forms.Button()
		Me.cboBankNum = New System.Windows.Forms.ComboBox()
		Me.GroupBox2 = New System.Windows.Forms.GroupBox()
		Me.rdoOptionLoop = New System.Windows.Forms.RadioButton()
		Me.rdoOptionSingle = New System.Windows.Forms.RadioButton()
		Me.btnComEnd = New System.Windows.Forms.Button()
		Me.GroupBox3 = New System.Windows.Forms.GroupBox()
		Me.txtComment = New System.Windows.Forms.Label()
		Me.lblSetList = New System.Windows.Forms.Label()
		Me.chk3rdAxis = New System.Windows.Forms.CheckBox()
		Me.MOTION.SuspendLayout()
		Me.GroupBox2.SuspendLayout()
		Me.GroupBox3.SuspendLayout()
		Me.SuspendLayout()
		'
		'LDeviceName
		'
		Me.LDeviceName.AutoSize = True
		Me.LDeviceName.Location = New System.Drawing.Point(16, 18)
		Me.LDeviceName.Name = "LDeviceName"
		Me.LDeviceName.Size = New System.Drawing.Size(79, 14)
		Me.LDeviceName.TabIndex = 0
		Me.LDeviceName.Text = "Device Name"
		'
		'txtDeviceName
		'
		Me.txtDeviceName.Location = New System.Drawing.Point(104, 16)
		Me.txtDeviceName.Name = "txtDeviceName"
		Me.txtDeviceName.Size = New System.Drawing.Size(88, 21)
		Me.txtDeviceName.TabIndex = 0
		Me.txtDeviceName.Text = "SMC000"
		'
		'Label1
		'
		Me.Label1.AutoSize = True
		Me.Label1.Location = New System.Drawing.Point(208, 18)
		Me.Label1.Name = "Label1"
		Me.Label1.Size = New System.Drawing.Size(44, 14)
		Me.Label1.TabIndex = 2
		Me.Label1.Text = "AxisNo"
		'
		'cboTargetAxis
		'
		Me.cboTargetAxis.Location = New System.Drawing.Point(264, 16)
		Me.cboTargetAxis.Name = "cboTargetAxis"
		Me.cboTargetAxis.Size = New System.Drawing.Size(64, 23)
		Me.cboTargetAxis.TabIndex = 1
		'
		'txt2ndAxis
		'
		Me.txt2ndAxis.BackColor = System.Drawing.SystemColors.Window
		Me.txt2ndAxis.Enabled = False
		Me.txt2ndAxis.Location = New System.Drawing.Point(336, 16)
		Me.txt2ndAxis.Name = "txt2ndAxis"
		Me.txt2ndAxis.ReadOnly = True
		Me.txt2ndAxis.Size = New System.Drawing.Size(40, 21)
		Me.txt2ndAxis.TabIndex = 2
		Me.txt2ndAxis.Text = ""
		'
		'txt3rdAxis
		'
		Me.txt3rdAxis.BackColor = System.Drawing.SystemColors.Window
		Me.txt3rdAxis.Enabled = False
		Me.txt3rdAxis.Location = New System.Drawing.Point(384, 16)
		Me.txt3rdAxis.Name = "txt3rdAxis"
		Me.txt3rdAxis.ReadOnly = True
		Me.txt3rdAxis.Size = New System.Drawing.Size(40, 21)
		Me.txt3rdAxis.TabIndex = 3
		Me.txt3rdAxis.Text = ""
		'
		'MOTION
		'
		Me.MOTION.Controls.AddRange(New System.Windows.Forms.Control() {Me.Label10, Me.btnComStop, Me.btnComMove, Me.cboBankNum})
		Me.MOTION.Location = New System.Drawing.Point(16, 56)
		Me.MOTION.Name = "MOTION"
		Me.MOTION.Size = New System.Drawing.Size(192, 112)
		Me.MOTION.TabIndex = 5
		Me.MOTION.TabStop = False
		Me.MOTION.Text = "MOTION"
		'
		'Label10
		'
		Me.Label10.AutoSize = True
		Me.Label10.Location = New System.Drawing.Point(16, 36)
		Me.Label10.Name = "Label10"
		Me.Label10.Size = New System.Drawing.Size(59, 14)
		Me.Label10.TabIndex = 4
		Me.Label10.Text = "BankNum"
		'
		'btnComStop
		'
		Me.btnComStop.Location = New System.Drawing.Point(104, 72)
		Me.btnComStop.Name = "btnComStop"
		Me.btnComStop.Size = New System.Drawing.Size(72, 24)
		Me.btnComStop.TabIndex = 3
		Me.btnComStop.Text = "STOP"
		'
		'btnComMove
		'
		Me.btnComMove.Location = New System.Drawing.Point(16, 72)
		Me.btnComMove.Name = "btnComMove"
		Me.btnComMove.Size = New System.Drawing.Size(72, 24)
		Me.btnComMove.TabIndex = 2
		Me.btnComMove.Text = "START"
		'
		'cboBankNum
		'
		Me.cboBankNum.Location = New System.Drawing.Point(88, 32)
		Me.cboBankNum.Name = "cboBankNum"
		Me.cboBankNum.Size = New System.Drawing.Size(64, 23)
		Me.cboBankNum.TabIndex = 1
		'
		'GroupBox2
		'
		Me.GroupBox2.Controls.AddRange(New System.Windows.Forms.Control() {Me.rdoOptionLoop, Me.rdoOptionSingle})
		Me.GroupBox2.Location = New System.Drawing.Point(224, 80)
		Me.GroupBox2.Name = "GroupBox2"
		Me.GroupBox2.Size = New System.Drawing.Size(96, 88)
		Me.GroupBox2.TabIndex = 6
		Me.GroupBox2.TabStop = False
		Me.GroupBox2.Text = "TYPE"
		'
		'rdoOptionLoop
		'
		Me.rdoOptionLoop.Location = New System.Drawing.Point(16, 48)
		Me.rdoOptionLoop.Name = "rdoOptionLoop"
		Me.rdoOptionLoop.Size = New System.Drawing.Size(72, 24)
		Me.rdoOptionLoop.TabIndex = 1
		Me.rdoOptionLoop.Text = "Loop"
		'
		'rdoOptionSingle
		'
		Me.rdoOptionSingle.Location = New System.Drawing.Point(16, 16)
		Me.rdoOptionSingle.Name = "rdoOptionSingle"
		Me.rdoOptionSingle.Size = New System.Drawing.Size(72, 24)
		Me.rdoOptionSingle.TabIndex = 0
		Me.rdoOptionSingle.Text = "Single"
		'
		'btnComEnd
		'
		Me.btnComEnd.Location = New System.Drawing.Point(336, 128)
		Me.btnComEnd.Name = "btnComEnd"
		Me.btnComEnd.Size = New System.Drawing.Size(80, 24)
		Me.btnComEnd.TabIndex = 7
		Me.btnComEnd.Text = "E&XIT"
		'
		'GroupBox3
		'
		Me.GroupBox3.Controls.AddRange(New System.Windows.Forms.Control() {Me.txtComment})
		Me.GroupBox3.Location = New System.Drawing.Point(16, 184)
		Me.GroupBox3.Name = "GroupBox3"
		Me.GroupBox3.Size = New System.Drawing.Size(408, 104)
		Me.GroupBox3.TabIndex = 11
		Me.GroupBox3.TabStop = False
		Me.GroupBox3.Text = "COMMENT"
		'
		'txtComment
		'
		Me.txtComment.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D
		Me.txtComment.Location = New System.Drawing.Point(8, 24)
		Me.txtComment.Name = "txtComment"
		Me.txtComment.Size = New System.Drawing.Size(392, 72)
		Me.txtComment.TabIndex = 0
		'
		'lblSetList
		'
		Me.lblSetList.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D
		Me.lblSetList.Location = New System.Drawing.Point(16, 304)
		Me.lblSetList.Name = "lblSetList"
		Me.lblSetList.Size = New System.Drawing.Size(408, 128)
		Me.lblSetList.TabIndex = 12
		'
		'chk3rdAxis
		'
		Me.chk3rdAxis.Location = New System.Drawing.Point(264, 48)
		Me.chk3rdAxis.Name = "chk3rdAxis"
		Me.chk3rdAxis.Size = New System.Drawing.Size(120, 24)
		Me.chk3rdAxis.TabIndex = 4
		Me.chk3rdAxis.Text = "3rdAxisEnable"
		'
		'BankMlt
		'
		Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
		Me.ClientSize = New System.Drawing.Size(440, 446)
		Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.lblSetList, Me.GroupBox3, Me.btnComEnd, Me.chk3rdAxis, Me.GroupBox2, Me.MOTION, Me.txt3rdAxis, Me.txt2ndAxis, Me.cboTargetAxis, Me.Label1, Me.txtDeviceName, Me.LDeviceName})
		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 = "BankMlt"
		Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
		Me.Text = "BANKMLT"
		Me.MOTION.ResumeLayout(False)
		Me.GroupBox2.ResumeLayout(False)
		Me.GroupBox3.ResumeLayout(False)
		Me.ResumeLayout(False)

	End Sub

#End Region

	Dim dwRet As Integer
	Dim MotionType As Short
	Dim szComment As String
	Dim bRet As Boolean
	Dim Id As Short
	Dim AxisNo As Short
    Dim wBankNum As Short
    Dim ErrorString As New StringBuilder("", 256)   'ErrorString

	Private Sub chk3rdAxis_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles chk3rdAxis.Click

		If chk3rdAxis.Checked = True Then
			txt3rdAxis.Text = txt2ndAxis.Text + 1
		Else
			txt3rdAxis.Text = ""
		End If

	End Sub

	Private Sub cboBankNum_SelectedIndexChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cboBankNum.SelectedIndexChanged

		wBankNum = cboBankNum.SelectedIndex + 1

	End Sub

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

		AxisNo = cboTargetAxis.SelectedIndex + 1
		txt2ndAxis.Text = AxisNo + 1

		If chk3rdAxis.Checked = True Then
			txt3rdAxis.Text = txt2ndAxis.Text + 1
		End If

	End Sub

	Private Sub btnComEnd_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnComEnd.Click

		SmcWExit(Id)
		End

	End Sub

	Private Sub btnComMove_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnComMove.Click

		Dim n As Short
		'----------------------------------
		' Set parameters to Driver
		'----------------------------------
		bRet = SetBankParam()
		If bRet = False Then
			Exit Sub
		End If

		'---------------
		' Ready motion
		'---------------
		dwRet = SmcWSetBankReady(Id, AxisNo, MotionType)
        If dwRet <> 0 Then
            SmcWGetErrorString(dwRet, ErrorString)
            txtComment.Text = "SmcWSetBankReady = " & dwRet & " : " & ErrorString.ToString
            Exit Sub
        End If

        lblSetList.Text = ""
        For n = 1 To wBankNum
            bRet = GetMoveParam(n)
            If bRet = False Then
                Exit Sub
            End If
        Next

        '---------------
        ' Start Motion
        '---------------
        dwRet = SmcWMotionStart(Id, AxisNo)
        If dwRet <> 0 Then
            SmcWGetErrorString(dwRet, ErrorString)
            txtComment.Text = "SmcMotionStart = " & dwRet & " : " & ErrorString.ToString
            Exit Sub
        End If
        
        txtComment.Text = "OK "

    End Sub

    Private Sub btnComStop_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnComStop.Click

        dwRet = SmcWMotionStop(Id, AxisNo)
        If dwRet <> 0 Then
            SmcWGetErrorString(dwRet, ErrorString)
            txtComment.Text = "SmcMotionStop = " & dwRet & " : " & ErrorString.ToString
            Exit Sub
        End If
        
        txtComment.Text = "OK "

    End Sub

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

        Dim BankNum As Short
        Dim n As Short
        ' Centering
        Me.Left = (Screen.PrimaryScreen.Bounds.Width - Me.Width) / 2
        Me.Top = (Screen.PrimaryScreen.Bounds.Height - Me.Height) / 2
        '-------------
        ' Initialize
        '-------------
        AxisNo = 1
        rdoOptionSingle.Checked = True

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

        chk3rdAxis.Checked = False

        BankNum = 1
        ' BankNum ComboBox
        cboBankNum.Items.Clear()
        For n = 1 To 4
            cboBankNum.Items.Add(Str(n))
        Next
        ' ComboBox Initialise
        cboBankNum.SelectedIndex = BankNum - 1

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

        For n = 1 To wBankNum
            bRet = GetMoveParam(n)
            If bRet = False Then
                Exit Sub
            End If
        Next

        txtComment.Text = "OK "
        
    End Sub

    Function SetBankParam() As Boolean

        Dim InterAxis As Short

        Dim Reserved As Short
        Dim BankNo As Short
        Dim InterType As Short
        '----------------------------
        ' Set Bank Number to Driver
        '----------------------------
        dwRet = SmcWSetBankNumber(Id, AxisNo, wBankNum)
        If dwRet <> 0 Then
            SmcWGetErrorString(dwRet, ErrorString)
            txtComment.Text = "SmcWSetBankNumber = " & dwRet & " : " & ErrorString.ToString
            SetBankParam = False
            Exit Function
        End If

        '----------------------------
        ' Set Interpolation to Driver
        '----------------------------
        InterAxis = (2 ^ (AxisNo - 1)) Or (2 ^ AxisNo)
        If chk3rdAxis.Checked = True Then
            InterAxis = InterAxis Or (2 ^ (AxisNo + 1))
        End If

        InterType = 1 'line interpolation

        For BankNo = 1 To wBankNum
            dwRet = SmcWSetBankInterpolation(Id, AxisNo, BankNo, InterType, InterAxis, Reserved)
            If dwRet <> 0 Then
                SmcWGetErrorString(dwRet, ErrorString)
                txtComment.Text = "SmcWSetBankInterpolation = " & dwRet & " : " & ErrorString.ToString
                SetBankParam = False
                Exit Function
            End If

        Next

        '-------------------------
        ' Set Distance to Driver
        '-------------------------
        dwRet = SmcWSetBankDistance(Id, AxisNo, 1, 500)
        If wBankNum > 1 Then
            dwRet = SmcWSetBankDistance(Id, AxisNo, 2, 1000)
            If dwRet <> 0 Then
                SmcWGetErrorString(dwRet, ErrorString)
                txtComment.Text = "SmcWSetBankDistance = " & dwRet & " : " & ErrorString.ToString
                SetBankParam = False
                Exit Function
            End If

            dwRet = SmcWSetBankDistance(Id, AxisNo, 3, 1500)
            dwRet = SmcWSetBankDistance(Id, AxisNo, 4, -3000)
        End If

        dwRet = SmcWSetBankDistance(Id, AxisNo + 1, 1, 400)
        If wBankNum > 1 Then
            dwRet = SmcWSetBankDistance(Id, AxisNo + 1, 2, 900)
            If dwRet <> 0 Then
                SmcWGetErrorString(dwRet, ErrorString)
                txtComment.Text = "SmcWSetBankDistance = " & dwRet & " : " & ErrorString.ToString
                SetBankParam = False
                Exit Function
            End If

            dwRet = SmcWSetBankDistance(Id, AxisNo + 1, 3, 1400)
            dwRet = SmcWSetBankDistance(Id, AxisNo + 1, 4, -2700)
        End If

        If chk3rdAxis.Checked = True Then
            dwRet = SmcWSetBankDistance(Id, AxisNo + 2, 1, 300)
            If wBankNum > 1 Then
                dwRet = SmcWSetBankDistance(Id, AxisNo + 2, 2, 800)
                If dwRet <> 0 Then
                    SmcWGetErrorString(dwRet, ErrorString)
                    txtComment.Text = "SmcWSetBankDistance = " & dwRet & " : " & ErrorString.ToString
                    SetBankParam = False
                    Exit Function
                End If

                dwRet = SmcWSetBankDistance(Id, AxisNo + 2, 3, 1300)
                dwRet = SmcWSetBankDistance(Id, AxisNo + 2, 4, -2400)
            End If
        End If

        '----------------------------
        ' Set StartSpeed to Driver
        '----------------------------
        dwRet = SmcWSetBankStartSpeed(Id, AxisNo, 1, 1000.0#)
        If wBankNum > 1 Then
            dwRet = SmcWSetBankStartSpeed(Id, AxisNo, 2, 2000.0#)
            If dwRet <> 0 Then
                SmcWGetErrorString(dwRet, ErrorString)
                txtComment.Text = "SmcWSetBankStartSpeed = " & dwRet & " : " & ErrorString.ToString
                SetBankParam = False
                Exit Function
            End If

            dwRet = SmcWSetBankStartSpeed(Id, AxisNo, 3, 3000.0#)
            dwRet = SmcWSetBankStartSpeed(Id, AxisNo, 4, 4000.0#)
        End If

        '----------------------------
        ' Set TargetSpeed to Driver
        '----------------------------
        dwRet = SmcWSetBankTargetSpeed(Id, AxisNo, 1, 3000.0#)
        If wBankNum > 1 Then
            dwRet = SmcWSetBankTargetSpeed(Id, AxisNo, 2, 4000.0#)
            If dwRet <> 0 Then
                SmcWGetErrorString(dwRet, ErrorString)
                txtComment.Text = "SmcWSetBankTargetSpeed = " & dwRet & " : " & ErrorString.ToString
                SetBankParam = False
                Exit Function
            End If

            dwRet = SmcWSetBankTargetSpeed(Id, AxisNo, 3, 5000.0#)
            dwRet = SmcWSetBankTargetSpeed(Id, AxisNo, 4, 6000.0#)
        End If

        '----------------------------------
        ' Set AccelTime to Driver
        '----------------------------------
        dwRet = SmcWSetBankAccelTime(Id, AxisNo, 1, 50)
        If wBankNum > 1 Then
            dwRet = SmcWSetBankAccelTime(Id, AxisNo, 2, 100)
            If dwRet <> 0 Then
                SmcWGetErrorString(dwRet, ErrorString)
                txtComment.Text = "SmcWSetBankAccelTime = " & dwRet & " : " & ErrorString.ToString
                SetBankParam = False
                Exit Function
            End If

            dwRet = SmcWSetBankAccelTime(Id, AxisNo, 3, 150)
            dwRet = SmcWSetBankAccelTime(Id, AxisNo, 4, 200)
        End If

        '----------------------------------
        ' Set DecelTime to Driver
        '----------------------------------
        dwRet = SmcWSetBankDecelTime(Id, AxisNo, 1, 100)
        If wBankNum > 1 Then
            dwRet = SmcWSetBankDecelTime(Id, AxisNo, 2, 150)
            If dwRet <> 0 Then
                SmcWGetErrorString(dwRet, ErrorString)
                txtComment.Text = "SmcWSetBankDecelTime = " & dwRet & " : " & ErrorString.ToString
                SetBankParam = False
                Exit Function
            End If

            dwRet = SmcWSetBankDecelTime(Id, AxisNo, 3, 200)
            dwRet = SmcWSetBankDecelTime(Id, AxisNo, 4, 250)
        End If

        '-----------------------------
        ' Set SSpeed to Driver
        '-----------------------------
        dwRet = SmcWSetBankSSpeed(Id, AxisNo, 1, 200)
        If wBankNum > 1 Then
            dwRet = SmcWSetBankSSpeed(Id, AxisNo, 2, 400)
            If dwRet <> 0 Then
                SmcWGetErrorString(dwRet, ErrorString)
                txtComment.Text = "SmcWSetBankSSpeed = " & dwRet & " : " & ErrorString.ToString
                SetBankParam = False
                Exit Function
            End If

            dwRet = SmcWSetBankSSpeed(Id, AxisNo, 3, 600)
            dwRet = SmcWSetBankSSpeed(Id, AxisNo, 4, 800)
        End If

        '----------------------------------------
        ' Other parameter use default parameter
        '----------------------------------------
        SetBankParam = True

    End Function

    Function GetMoveParam(ByVal i As Short) As Boolean

        Dim lDistance As Integer
        Dim dblSSpeed As Double
        Dim dblDecelTime As Double
        Dim dblAccelTime As Double
        Dim dblTargetSpeed As Double
        Dim dblStartSpeed As Double
        '----------------------------------
        ' Get default value of StartSpeed
        '----------------------------------
        dwRet = SmcWGetBankStartSpeed(Id, AxisNo, i, dblStartSpeed)
        If dwRet <> 0 Then
            SmcWGetErrorString(dwRet, ErrorString)
            txtComment.Text = "SmcWGetBankStartSpeed = " & dwRet & " : " & ErrorString.ToString
            GetMoveParam = False
            Exit Function
        End If

        lblSetList.Text = lblSetList.Text & "BankNo:" & i & Str(dblStartSpeed)

        '----------------------------------
        ' Get default value of TargetSpeed
        '----------------------------------
        dwRet = SmcWGetBankTargetSpeed(Id, AxisNo, i, dblTargetSpeed)
        If dwRet <> 0 Then
            SmcWGetErrorString(dwRet, ErrorString)
            txtComment.Text = "SmcWGetBankTargetSpeed = " & dwRet & " : " & ErrorString.ToString
            GetMoveParam = False
            Exit Function
        End If

        lblSetList.Text = lblSetList.Text & Str(dblTargetSpeed)

        '----------------------------------
        ' Get default value of AccelRate
        '----------------------------------
        dwRet = SmcWGetBankAccelTime(Id, AxisNo, i, dblAccelTime)
        If dwRet <> 0 Then
            SmcWGetErrorString(dwRet, ErrorString)
            txtComment.Text = "SmcWGetBankAccelTime = " & dwRet & " : " & ErrorString.ToString
            GetMoveParam = False
            Exit Function
        End If

        lblSetList.Text = lblSetList.Text & Str(dblAccelTime)

        '----------------------------------
        ' Get default value of DecelRate
        '----------------------------------
        dwRet = SmcWGetBankDecelTime(Id, AxisNo, i, dblDecelTime)
        If dwRet <> 0 Then
            SmcWGetErrorString(dwRet, ErrorString)
            txtComment.Text = "SmcWGetBankDecelTime = " & dwRet & " : " & ErrorString.ToString
            GetMoveParam = False
            Exit Function
        End If

        lblSetList.Text = lblSetList.Text & Str(dblDecelTime)

        '-----------------------------
        ' Get default value of SSpeed
        '-----------------------------
        dwRet = SmcWGetBankSSpeed(Id, AxisNo, i, dblSSpeed)
        If dwRet <> 0 Then
            SmcWGetErrorString(dwRet, ErrorString)
            txtComment.Text = "SmcWGetBankSSpeed = " & dwRet & " : " & ErrorString.ToString
            GetMoveParam = False
            Exit Function
        End If

        lblSetList.Text = lblSetList.Text & Str(dblSSpeed)

        '----------------------------------
        ' Get default value of lDistance
        '----------------------------------
        dwRet = SmcWGetBankDistance(Id, AxisNo, i, lDistance)
        If dwRet <> 0 Then
            SmcWGetErrorString(dwRet, ErrorString)
            txtComment.Text = "SmcWGetBankDistance = " & dwRet & " : " & ErrorString.ToString
            GetMoveParam = False
            Exit Function
        End If

        lblSetList.Text = lblSetList.Text & Str(lDistance) & vbCrLf

        GetMoveParam = True

    End Function

    Private Sub rdoOptionLoop_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles rdoOptionLoop.CheckedChanged

        MotionType = CSMC_LOOP

        txtComment.Text = "OK "
        
    End Sub

    Private Sub rdoOptionSingle_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles rdoOptionSingle.CheckedChanged

        MotionType = CSMC_SINGLE

        txtComment.Text = "OK "
        
    End Sub

    Private Sub txtDeviceName_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtDeviceName.TextChanged

        Dim n As Short

        '------------
        ' Initialize
        '------------
        dwRet = SmcWInit(txtDeviceName.Text, Id)
        If dwRet <> 0 Then
            SmcWGetErrorString(dwRet, ErrorString)
            txtComment.Text = "SmcWInit = " & dwRet & " : " & ErrorString.ToString
            Exit Sub
        End If

        lblSetList.Text = ""
        For n = 1 To wBankNum
            bRet = GetMoveParam(n)
            If bRet = False Then
                Exit Sub
            End If
        Next

        txtComment.Text = "OK "

    End Sub

End Class
