Public Class measure
    Inherits System.Windows.Forms.Form

#Region " Windows tH[ fUCiŐꂽR[h "

    Public Sub New()
        MyBase.New()

        ' ̌Ăяo Windows tH[ fUCiŕKvłB
        InitializeComponent()

        ' InitializeComponent() Ăяǒɏǉ܂B

    End Sub

    ' Form  dispose I[o[ChăR|[lgꗗ܂B
    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

    ' Windows tH[ fUCiŕKvłB
    Private components As System.ComponentModel.IContainer

    '  : ȉ̃vV[ẂAWindows tH[ fUCiŕKvłB
    ' Windows tH[ fUCigĕύXĂB  
    ' R[h GfB^͎gpȂłB
	Friend WithEvents btnOK As System.Windows.Forms.Button
	Friend WithEvents groupBox1 As System.Windows.Forms.GroupBox
	Friend WithEvents label5 As System.Windows.Forms.Label
	Friend WithEvents label4 As System.Windows.Forms.Label
	Friend WithEvents label3 As System.Windows.Forms.Label
	Friend WithEvents txtAvCondition As System.Windows.Forms.TextBox
	Friend WithEvents cboAverage As System.Windows.Forms.ComboBox
	Friend WithEvents cboUpdate As System.Windows.Forms.ComboBox
	Friend WithEvents cboLinearize As System.Windows.Forms.ComboBox
	Friend WithEvents label2 As System.Windows.Forms.Label
	Friend WithEvents label1 As System.Windows.Forms.Label
	Friend WithEvents btnCancel As System.Windows.Forms.Button
    Friend WithEvents Label6 As System.Windows.Forms.Label
    Friend WithEvents Label7 As System.Windows.Forms.Label
    Friend WithEvents TxtDisable As System.Windows.Forms.TextBox
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.btnOK = New System.Windows.Forms.Button()
        Me.groupBox1 = New System.Windows.Forms.GroupBox()
        Me.label5 = New System.Windows.Forms.Label()
        Me.label4 = New System.Windows.Forms.Label()
        Me.label3 = New System.Windows.Forms.Label()
        Me.txtAvCondition = New System.Windows.Forms.TextBox()
        Me.cboAverage = New System.Windows.Forms.ComboBox()
        Me.cboUpdate = New System.Windows.Forms.ComboBox()
        Me.cboLinearize = New System.Windows.Forms.ComboBox()
        Me.label2 = New System.Windows.Forms.Label()
        Me.label1 = New System.Windows.Forms.Label()
        Me.btnCancel = New System.Windows.Forms.Button()
        Me.Label6 = New System.Windows.Forms.Label()
        Me.Label7 = New System.Windows.Forms.Label()
        Me.TxtDisable = New System.Windows.Forms.TextBox()
        Me.groupBox1.SuspendLayout()
        Me.SuspendLayout()
        '
        'btnOK
        '
        Me.btnOK.Location = New System.Drawing.Point(176, 200)
        Me.btnOK.Name = "btnOK"
        Me.btnOK.Size = New System.Drawing.Size(88, 24)
        Me.btnOK.TabIndex = 4
        Me.btnOK.Text = "OK"
        '
        'groupBox1
        '
        Me.groupBox1.Controls.AddRange(New System.Windows.Forms.Control() {Me.Label6, Me.Label7, Me.TxtDisable, Me.label5, Me.label4, Me.label3, Me.txtAvCondition, Me.cboAverage, Me.cboUpdate, Me.cboLinearize, Me.label2, Me.label1})
        Me.groupBox1.Location = New System.Drawing.Point(8, 15)
        Me.groupBox1.Name = "groupBox1"
        Me.groupBox1.Size = New System.Drawing.Size(368, 177)
        Me.groupBox1.TabIndex = 3
        Me.groupBox1.TabStop = False
        Me.groupBox1.Text = "vݒ"
        '
        'label5
        '
        Me.label5.Location = New System.Drawing.Point(304, 120)
        Me.label5.Name = "label5"
        Me.label5.Size = New System.Drawing.Size(41, 16)
        Me.label5.TabIndex = 8
        Me.label5.Text = "/ms"
        Me.label5.TextAlign = System.Drawing.ContentAlignment.MiddleLeft
        '
        'label4
        '
        Me.label4.Location = New System.Drawing.Point(64, 120)
        Me.label4.Name = "label4"
        Me.label4.Size = New System.Drawing.Size(80, 16)
        Me.label4.TabIndex = 7
        Me.label4.Text = "ωF"
        Me.label4.TextAlign = System.Drawing.ContentAlignment.MiddleRight
        '
        'label3
        '
        Me.label3.Location = New System.Drawing.Point(64, 88)
        Me.label3.Name = "label3"
        Me.label3.Size = New System.Drawing.Size(80, 16)
        Me.label3.TabIndex = 6
        Me.label3.Text = "ωF"
        Me.label3.TextAlign = System.Drawing.ContentAlignment.MiddleRight
        '
        'txtAvCondition
        '
        Me.txtAvCondition.Location = New System.Drawing.Point(152, 120)
        Me.txtAvCondition.Name = "txtAvCondition"
        Me.txtAvCondition.Size = New System.Drawing.Size(144, 19)
        Me.txtAvCondition.TabIndex = 5
        Me.txtAvCondition.Text = ""
        '
        'cboAverage
        '
        Me.cboAverage.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList
        Me.cboAverage.Items.AddRange(New Object() {"ωȂ", "񐔕", "ԕ"})
        Me.cboAverage.Location = New System.Drawing.Point(152, 88)
        Me.cboAverage.Name = "cboAverage"
        Me.cboAverage.Size = New System.Drawing.Size(144, 20)
        Me.cboAverage.TabIndex = 4
        '
        'cboUpdate
        '
        Me.cboUpdate.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList
        Me.cboUpdate.Items.AddRange(New Object() {"150ms", "40ms", "5ms", "1.5ms"})
        Me.cboUpdate.Location = New System.Drawing.Point(152, 56)
        Me.cboUpdate.Name = "cboUpdate"
        Me.cboUpdate.Size = New System.Drawing.Size(144, 20)
        Me.cboUpdate.TabIndex = 3
        '
        'cboLinearize
        '
        Me.cboLinearize.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList
        Me.cboLinearize.Items.AddRange(New Object() {"x", "Rl"})
        Me.cboLinearize.Location = New System.Drawing.Point(152, 24)
        Me.cboLinearize.Name = "cboLinearize"
        Me.cboLinearize.Size = New System.Drawing.Size(144, 20)
        Me.cboLinearize.TabIndex = 2
        '
        'label2
        '
        Me.label2.Location = New System.Drawing.Point(64, 56)
        Me.label2.Name = "label2"
        Me.label2.Size = New System.Drawing.Size(80, 16)
        Me.label2.TabIndex = 1
        Me.label2.Text = "XVF"
        Me.label2.TextAlign = System.Drawing.ContentAlignment.MiddleRight
        '
        'label1
        '
        Me.label1.Location = New System.Drawing.Point(64, 32)
        Me.label1.Name = "label1"
        Me.label1.Size = New System.Drawing.Size(80, 16)
        Me.label1.TabIndex = 0
        Me.label1.Text = "jACYF"
        Me.label1.TextAlign = System.Drawing.ContentAlignment.MiddleRight
        '
        'btnCancel
        '
        Me.btnCancel.Location = New System.Drawing.Point(288, 200)
        Me.btnCancel.Name = "btnCancel"
        Me.btnCancel.Size = New System.Drawing.Size(88, 24)
        Me.btnCancel.TabIndex = 5
        Me.btnCancel.Text = "ݾ"
        '
        'Label6
        '
        Me.Label6.Location = New System.Drawing.Point(304, 144)
        Me.Label6.Name = "Label6"
        Me.Label6.Size = New System.Drawing.Size(41, 16)
        Me.Label6.TabIndex = 11
        Me.Label6.Text = "Hex"
        Me.Label6.TextAlign = System.Drawing.ContentAlignment.MiddleLeft
        '
        'Label7
        '
        Me.Label7.Location = New System.Drawing.Point(8, 144)
        Me.Label7.Name = "Label7"
        Me.Label7.Size = New System.Drawing.Size(136, 16)
        Me.Label7.TabIndex = 10
        Me.Label7.Text = "ϊ֎~`l(0-F)F"
        Me.Label7.TextAlign = System.Drawing.ContentAlignment.MiddleRight
        '
        'TxtDisable
        '
        Me.TxtDisable.Location = New System.Drawing.Point(152, 144)
        Me.TxtDisable.Name = "TxtDisable"
        Me.TxtDisable.Size = New System.Drawing.Size(144, 19)
        Me.TxtDisable.TabIndex = 9
        Me.TxtDisable.Text = ""
        '
        'measure
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 12)
        Me.ClientSize = New System.Drawing.Size(402, 232)
        Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.btnOK, Me.groupBox1, Me.btnCancel})
        Me.Font = New System.Drawing.Font("lr oSVbN", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(128, Byte))
        Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog
        Me.MaximizeBox = False
        Me.MinimizeBox = False
        Me.Name = "measure"
        Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
        Me.Text = "vݒ"
        Me.groupBox1.ResumeLayout(False)
        Me.ResumeLayout(False)

    End Sub

#End Region
	Dim m_Id As Short

	'	R[ID擾
	Public Sub SetId(ByVal id As Short)

		m_Id = id

	End Sub

	'	_CAȌ
	Private Sub measure_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

		Dim ret As Integer
        Dim linearize As Short
        Dim averagetype As Short
        Dim updatetiming As Integer
        Dim averagedata As Integer
        Dim channeldisable As Integer

		txtAvCondition.Text = "0"
		' jACY@\̎擾
		ret = PtGetLinearise(m_Id, linearize)
		If ret <> 0 Then
			ErrorHandling("PtGetLinearise", ret)
			Exit Sub
		End If
		cboLinearize.SelectedIndex = linearize

		' XV^C~O̎擾
		ret = PtGetUpdateTiming(m_Id, updatetiming)
		If ret <> 0 Then
			ErrorHandling("PtGetUpdateTiming", ret)
			Exit Sub
		End If
		Select Case updatetiming
			Case SPEED_150MS
				cboUpdate.SelectedIndex = 0
			Case SPEED_40MS
				cboUpdate.SelectedIndex = 1
			Case SPEED_5MS
				cboUpdate.SelectedIndex = 2
			Case SPEED_1P5MS
				cboUpdate.SelectedIndex = 3
		End Select

		' Ϗ@\̎擾
		ret = PtGetAverage(m_Id, averagetype, averagedata)
		If ret <> 0 Then
			ErrorHandling("PtGetAverage", ret)
			Exit Sub
		End If
		cboAverage.SelectedIndex = averagetype
		txtAvCondition.Text = averagedata

        ' ϊ֎~`l̎擾
        ret = PtGetChannelDisable(m_Id, channeldisable)
        If ret <> 0 Then
            ErrorHandling("PtGetChannelDisable", ret)
            Exit Sub
        End If
        TxtDisable.Text = Hex(channeldisable)

	End Sub

	'	[OK]{^NbN
	Private Sub btnOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOK.Click

		Dim ret As Integer
		Dim index As Integer
		Dim updatetiming As Integer
        Dim str As New String("", 100)
        Dim channeldisable As Integer

		' jACY@\̐ݒ
		index = cboLinearize.SelectedIndex
		ret = PtSetLinearise(m_Id, index)
		If ret <> 0 Then
			ErrorHandling("PtSetLinearise", ret)
		End If

		' XV^C~O̐ݒ
		index = cboUpdate.SelectedIndex
		Select Case index
			Case 0
				updatetiming = SPEED_150MS
			Case 1
				updatetiming = SPEED_40MS
			Case 2
				updatetiming = SPEED_5MS
			Case 3
				updatetiming = SPEED_1P5MS
		End Select
		ret = PtSetUpdateTiming(m_Id, updatetiming)
		If ret <> 0 Then
			ErrorHandling("PtSetUpdateTiming", ret)
		End If

		' Ϗ@\̐ݒ
		index = cboAverage.SelectedIndex
		ret = PtSetAverage(m_Id, index, Val(txtAvCondition.Text))
		If ret <> 0 Then
			ErrorHandling("PtSetAverage", ret)
		End If

        ' ϊ֎~`l̐ݒ
        channeldisable = Val("&H" + TxtDisable.Text)
        ret = PtSetChannelDisable(m_Id, channeldisable)
        If ret <> 0 Then
            ErrorHandling("PtSetChannelDisable", ret)
        End If

        Me.Close()

	End Sub

	'	[LZ]{^NbN
	Private Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancel.Click

		Me.Close()

	End Sub

	'	G[
	Private Sub ErrorHandling(ByVal Dfunction As String, ByVal ret As Integer)

		Dim errstr As New System.Text.StringBuilder("", 256)
		PtGetErrorString(ret, errstr)
        MsgBox(errstr.ToString(), MsgBoxStyle.OKOnly, Dfunction)

	End Sub
End Class
