Option Strict Off
Option Explicit On 
Public Class Pti4
	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 Label1 As System.Windows.Forms.Label
	Friend WithEvents cboDevice As System.Windows.Forms.ComboBox
	Friend WithEvents GroupBox1 As System.Windows.Forms.GroupBox
	Friend WithEvents Label2 As System.Windows.Forms.Label
	Friend WithEvents Label3 As System.Windows.Forms.Label
	Friend WithEvents lblStart As System.Windows.Forms.Label
	Friend WithEvents lblErr As System.Windows.Forms.Label
	Friend WithEvents GroupBox2 As System.Windows.Forms.GroupBox
	Friend WithEvents Label4 As System.Windows.Forms.Label
	Friend WithEvents Label5 As System.Windows.Forms.Label
	Friend WithEvents Label6 As System.Windows.Forms.Label
	Friend WithEvents Label7 As System.Windows.Forms.Label
	Friend WithEvents txtCh0 As System.Windows.Forms.TextBox
	Friend WithEvents txtCh1 As System.Windows.Forms.TextBox
	Friend WithEvents txtCh2 As System.Windows.Forms.TextBox
	Friend WithEvents txtCh3 As System.Windows.Forms.TextBox
	Friend WithEvents Label8 As System.Windows.Forms.Label
	Friend WithEvents Label9 As System.Windows.Forms.Label
	Friend WithEvents Label10 As System.Windows.Forms.Label
	Friend WithEvents Label11 As System.Windows.Forms.Label
	Friend WithEvents GroupBox3 As System.Windows.Forms.GroupBox
	Friend WithEvents txtStsDc As System.Windows.Forms.TextBox
	Friend WithEvents txtStsUAlarm As System.Windows.Forms.TextBox
	Friend WithEvents txtStsLAlarm As System.Windows.Forms.TextBox
	Friend WithEvents Label15 As System.Windows.Forms.Label
	Friend WithEvents Label16 As System.Windows.Forms.Label
	Friend WithEvents Label17 As System.Windows.Forms.Label
	Friend WithEvents Label18 As System.Windows.Forms.Label
	Friend WithEvents txtRet As System.Windows.Forms.TextBox
	Friend WithEvents btnInit As System.Windows.Forms.Button
	Friend WithEvents btnMSet As System.Windows.Forms.Button
	Friend WithEvents btnASet As System.Windows.Forms.Button
	Friend WithEvents btnStart As System.Windows.Forms.Button
	Friend WithEvents btnStop As System.Windows.Forms.Button
	Friend WithEvents btnInput As System.Windows.Forms.Button
	Friend WithEvents btnStatus As System.Windows.Forms.Button
	Friend WithEvents btnExit As System.Windows.Forms.Button
	Friend WithEvents btnOK As System.Windows.Forms.Button
	Friend WithEvents Label14 As System.Windows.Forms.Label
	Friend WithEvents Label13 As System.Windows.Forms.Label
	Friend WithEvents Label12 As System.Windows.Forms.Label
	<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
		Me.Label1 = New System.Windows.Forms.Label()
		Me.cboDevice = New System.Windows.Forms.ComboBox()
		Me.GroupBox1 = New System.Windows.Forms.GroupBox()
		Me.lblErr = New System.Windows.Forms.Label()
		Me.lblStart = New System.Windows.Forms.Label()
		Me.Label3 = New System.Windows.Forms.Label()
		Me.Label2 = New System.Windows.Forms.Label()
		Me.GroupBox2 = New System.Windows.Forms.GroupBox()
		Me.Label11 = New System.Windows.Forms.Label()
		Me.Label10 = New System.Windows.Forms.Label()
		Me.Label9 = New System.Windows.Forms.Label()
		Me.Label8 = New System.Windows.Forms.Label()
		Me.txtCh3 = New System.Windows.Forms.TextBox()
		Me.txtCh2 = New System.Windows.Forms.TextBox()
		Me.txtCh1 = New System.Windows.Forms.TextBox()
		Me.txtCh0 = New System.Windows.Forms.TextBox()
		Me.Label7 = New System.Windows.Forms.Label()
		Me.Label6 = New System.Windows.Forms.Label()
		Me.Label5 = New System.Windows.Forms.Label()
		Me.Label4 = New System.Windows.Forms.Label()
		Me.GroupBox3 = New System.Windows.Forms.GroupBox()
		Me.Label14 = New System.Windows.Forms.Label()
		Me.Label13 = New System.Windows.Forms.Label()
		Me.Label12 = New System.Windows.Forms.Label()
		Me.Label17 = New System.Windows.Forms.Label()
		Me.Label16 = New System.Windows.Forms.Label()
		Me.Label15 = New System.Windows.Forms.Label()
		Me.txtStsLAlarm = New System.Windows.Forms.TextBox()
		Me.txtStsUAlarm = New System.Windows.Forms.TextBox()
		Me.txtStsDc = New System.Windows.Forms.TextBox()
		Me.Label18 = New System.Windows.Forms.Label()
		Me.txtRet = New System.Windows.Forms.TextBox()
		Me.btnInit = New System.Windows.Forms.Button()
		Me.btnMSet = New System.Windows.Forms.Button()
		Me.btnASet = New System.Windows.Forms.Button()
		Me.btnStart = New System.Windows.Forms.Button()
		Me.btnStop = New System.Windows.Forms.Button()
		Me.btnInput = New System.Windows.Forms.Button()
		Me.btnStatus = New System.Windows.Forms.Button()
		Me.btnExit = New System.Windows.Forms.Button()
		Me.btnOK = New System.Windows.Forms.Button()
		Me.GroupBox1.SuspendLayout()
		Me.GroupBox2.SuspendLayout()
		Me.GroupBox3.SuspendLayout()
		Me.SuspendLayout()
		'
		'Label1
		'
		Me.Label1.Location = New System.Drawing.Point(16, 15)
		Me.Label1.Name = "Label1"
		Me.Label1.Size = New System.Drawing.Size(48, 16)
		Me.Label1.TabIndex = 0
		Me.Label1.Text = "Device"
		'
		'cboDevice
		'
		Me.cboDevice.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList
		Me.cboDevice.Location = New System.Drawing.Point(66, 13)
		Me.cboDevice.Name = "cboDevice"
		Me.cboDevice.Size = New System.Drawing.Size(264, 21)
		Me.cboDevice.TabIndex = 1
		'
		'GroupBox1
		'
		Me.GroupBox1.Controls.AddRange(New System.Windows.Forms.Control() {Me.lblErr, Me.lblStart, Me.Label3, Me.Label2})
		Me.GroupBox1.Location = New System.Drawing.Point(16, 48)
		Me.GroupBox1.Name = "GroupBox1"
		Me.GroupBox1.Size = New System.Drawing.Size(312, 56)
		Me.GroupBox1.TabIndex = 2
		Me.GroupBox1.TabStop = False
		Me.GroupBox1.Text = "Start/Error Register"
		'
		'lblErr
		'
		Me.lblErr.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D
		Me.lblErr.Location = New System.Drawing.Point(235, 24)
		Me.lblErr.Name = "lblErr"
		Me.lblErr.Size = New System.Drawing.Size(40, 18)
		Me.lblErr.TabIndex = 3
		'
		'lblStart
		'
		Me.lblStart.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D
		Me.lblStart.Location = New System.Drawing.Point(102, 24)
		Me.lblStart.Name = "lblStart"
		Me.lblStart.Size = New System.Drawing.Size(40, 18)
		Me.lblStart.TabIndex = 2
		'
		'Label3
		'
		Me.Label3.Location = New System.Drawing.Point(155, 25)
		Me.Label3.Name = "Label3"
		Me.Label3.Size = New System.Drawing.Size(80, 16)
		Me.Label3.TabIndex = 1
		Me.Label3.Text = "Error Register"
		'
		'Label2
		'
		Me.Label2.Location = New System.Drawing.Point(22, 25)
		Me.Label2.Name = "Label2"
		Me.Label2.Size = New System.Drawing.Size(80, 16)
		Me.Label2.TabIndex = 0
		Me.Label2.Text = "Start Register"
		'
		'GroupBox2
		'
		Me.GroupBox2.Controls.AddRange(New System.Windows.Forms.Control() {Me.Label11, Me.Label10, Me.Label9, Me.Label8, Me.txtCh3, Me.txtCh2, Me.txtCh1, Me.txtCh0, Me.Label7, Me.Label6, Me.Label5, Me.Label4})
		Me.GroupBox2.Location = New System.Drawing.Point(16, 116)
		Me.GroupBox2.Name = "GroupBox2"
		Me.GroupBox2.Size = New System.Drawing.Size(312, 136)
		Me.GroupBox2.TabIndex = 3
		Me.GroupBox2.TabStop = False
		Me.GroupBox2.Text = "Input Value"
		'
		'Label11
		'
		Me.Label11.Location = New System.Drawing.Point(237, 106)
		Me.Label11.Name = "Label11"
		Me.Label11.Size = New System.Drawing.Size(32, 16)
		Me.Label11.TabIndex = 11
		Me.Label11.Text = "C"
		'
		'Label10
		'
		Me.Label10.Location = New System.Drawing.Point(237, 81)
		Me.Label10.Name = "Label10"
		Me.Label10.Size = New System.Drawing.Size(32, 16)
		Me.Label10.TabIndex = 10
		Me.Label10.Text = "C"
		'
		'Label9
		'
		Me.Label9.Location = New System.Drawing.Point(237, 54)
		Me.Label9.Name = "Label9"
		Me.Label9.Size = New System.Drawing.Size(32, 16)
		Me.Label9.TabIndex = 9
		Me.Label9.Text = "C"
		'
		'Label8
		'
		Me.Label8.Location = New System.Drawing.Point(237, 29)
		Me.Label8.Name = "Label8"
		Me.Label8.Size = New System.Drawing.Size(32, 16)
		Me.Label8.TabIndex = 8
		Me.Label8.Text = "C"
		'
		'txtCh3
		'
		Me.txtCh3.Location = New System.Drawing.Point(106, 102)
		Me.txtCh3.Name = "txtCh3"
		Me.txtCh3.Size = New System.Drawing.Size(120, 20)
		Me.txtCh3.TabIndex = 7
		Me.txtCh3.Text = ""
		'
		'txtCh2
		'
		Me.txtCh2.Location = New System.Drawing.Point(106, 76)
		Me.txtCh2.Name = "txtCh2"
		Me.txtCh2.Size = New System.Drawing.Size(120, 20)
		Me.txtCh2.TabIndex = 6
		Me.txtCh2.Text = ""
		'
		'txtCh1
		'
		Me.txtCh1.Location = New System.Drawing.Point(106, 50)
		Me.txtCh1.Name = "txtCh1"
		Me.txtCh1.Size = New System.Drawing.Size(120, 20)
		Me.txtCh1.TabIndex = 5
		Me.txtCh1.Text = ""
		'
		'txtCh0
		'
		Me.txtCh0.Location = New System.Drawing.Point(106, 24)
		Me.txtCh0.Name = "txtCh0"
		Me.txtCh0.Size = New System.Drawing.Size(120, 20)
		Me.txtCh0.TabIndex = 4
		Me.txtCh0.Text = ""
		'
		'Label7
		'
		Me.Label7.Location = New System.Drawing.Point(8, 104)
		Me.Label7.Name = "Label7"
		Me.Label7.Size = New System.Drawing.Size(90, 16)
		Me.Label7.TabIndex = 3
		Me.Label7.Text = "Channel 3 :"
		Me.Label7.TextAlign = System.Drawing.ContentAlignment.MiddleRight
		'
		'Label6
		'
		Me.Label6.Location = New System.Drawing.Point(8, 77)
		Me.Label6.Name = "Label6"
		Me.Label6.Size = New System.Drawing.Size(90, 16)
		Me.Label6.TabIndex = 2
		Me.Label6.Text = "Channel 2 :"
		Me.Label6.TextAlign = System.Drawing.ContentAlignment.MiddleRight
		'
		'Label5
		'
		Me.Label5.Location = New System.Drawing.Point(8, 52)
		Me.Label5.Name = "Label5"
		Me.Label5.Size = New System.Drawing.Size(90, 16)
		Me.Label5.TabIndex = 1
		Me.Label5.Text = "Channel 1 :"
		Me.Label5.TextAlign = System.Drawing.ContentAlignment.MiddleRight
		'
		'Label4
		'
		Me.Label4.Location = New System.Drawing.Point(8, 25)
		Me.Label4.Name = "Label4"
		Me.Label4.Size = New System.Drawing.Size(90, 16)
		Me.Label4.TabIndex = 0
		Me.Label4.Text = "Channel 0 :"
		Me.Label4.TextAlign = System.Drawing.ContentAlignment.MiddleRight
		'
		'GroupBox3
		'
		Me.GroupBox3.Controls.AddRange(New System.Windows.Forms.Control() {Me.Label14, Me.Label13, Me.Label12, Me.Label17, Me.Label16, Me.Label15, Me.txtStsLAlarm, Me.txtStsUAlarm, Me.txtStsDc})
		Me.GroupBox3.Location = New System.Drawing.Point(16, 264)
		Me.GroupBox3.Name = "GroupBox3"
		Me.GroupBox3.Size = New System.Drawing.Size(312, 104)
		Me.GroupBox3.TabIndex = 4
		Me.GroupBox3.TabStop = False
		Me.GroupBox3.Text = "Status"
		'
		'Label14
		'
		Me.Label14.Location = New System.Drawing.Point(15, 73)
		Me.Label14.Name = "Label14"
		Me.Label14.Size = New System.Drawing.Size(90, 16)
		Me.Label14.TabIndex = 14
		Me.Label14.Text = "Low-limit Alarm :"
		Me.Label14.TextAlign = System.Drawing.ContentAlignment.MiddleRight
		'
		'Label13
		'
		Me.Label13.Location = New System.Drawing.Point(16, 45)
		Me.Label13.Name = "Label13"
		Me.Label13.Size = New System.Drawing.Size(90, 16)
		Me.Label13.TabIndex = 13
		Me.Label13.Text = "High-limit Alarm :"
		Me.Label13.TextAlign = System.Drawing.ContentAlignment.MiddleRight
		'
		'Label12
		'
		Me.Label12.Location = New System.Drawing.Point(8, 18)
		Me.Label12.Name = "Label12"
		Me.Label12.Size = New System.Drawing.Size(90, 16)
		Me.Label12.TabIndex = 12
		Me.Label12.Text = "Disconnect :"
		Me.Label12.TextAlign = System.Drawing.ContentAlignment.MiddleRight
		'
		'Label17
		'
		Me.Label17.Location = New System.Drawing.Point(237, 75)
		Me.Label17.Name = "Label17"
		Me.Label17.Size = New System.Drawing.Size(32, 16)
		Me.Label17.TabIndex = 11
		Me.Label17.Text = "Hex"
		'
		'Label16
		'
		Me.Label16.Location = New System.Drawing.Point(237, 47)
		Me.Label16.Name = "Label16"
		Me.Label16.Size = New System.Drawing.Size(32, 16)
		Me.Label16.TabIndex = 10
		Me.Label16.Text = "Hex"
		'
		'Label15
		'
		Me.Label15.Location = New System.Drawing.Point(237, 20)
		Me.Label15.Name = "Label15"
		Me.Label15.Size = New System.Drawing.Size(32, 16)
		Me.Label15.TabIndex = 9
		Me.Label15.Text = "Hex"
		'
		'txtStsLAlarm
		'
		Me.txtStsLAlarm.Location = New System.Drawing.Point(106, 72)
		Me.txtStsLAlarm.Name = "txtStsLAlarm"
		Me.txtStsLAlarm.Size = New System.Drawing.Size(120, 20)
		Me.txtStsLAlarm.TabIndex = 7
		Me.txtStsLAlarm.Text = ""
		'
		'txtStsUAlarm
		'
		Me.txtStsUAlarm.Location = New System.Drawing.Point(106, 44)
		Me.txtStsUAlarm.Name = "txtStsUAlarm"
		Me.txtStsUAlarm.Size = New System.Drawing.Size(120, 20)
		Me.txtStsUAlarm.TabIndex = 6
		Me.txtStsUAlarm.Text = ""
		'
		'txtStsDc
		'
		Me.txtStsDc.Location = New System.Drawing.Point(106, 16)
		Me.txtStsDc.Name = "txtStsDc"
		Me.txtStsDc.Size = New System.Drawing.Size(120, 20)
		Me.txtStsDc.TabIndex = 5
		Me.txtStsDc.Text = ""
		'
		'Label18
		'
		Me.Label18.Location = New System.Drawing.Point(16, 394)
		Me.Label18.Name = "Label18"
		Me.Label18.Size = New System.Drawing.Size(80, 16)
		Me.Label18.TabIndex = 5
		Me.Label18.Text = "Return Value :"
		'
		'txtRet
		'
		Me.txtRet.Location = New System.Drawing.Point(96, 392)
		Me.txtRet.Name = "txtRet"
		Me.txtRet.Size = New System.Drawing.Size(400, 20)
		Me.txtRet.TabIndex = 6
		Me.txtRet.Text = ""
		'
		'btnInit
		'
		Me.btnInit.Location = New System.Drawing.Point(352, 10)
		Me.btnInit.Name = "btnInit"
		Me.btnInit.Size = New System.Drawing.Size(144, 24)
		Me.btnInit.TabIndex = 7
		Me.btnInit.Text = "Initialization"
		'
		'btnMSet
		'
		Me.btnMSet.Location = New System.Drawing.Point(352, 56)
		Me.btnMSet.Name = "btnMSet"
		Me.btnMSet.Size = New System.Drawing.Size(144, 24)
		Me.btnMSet.TabIndex = 8
		Me.btnMSet.Text = "Measurement Setting..."
		'
		'btnASet
		'
		Me.btnASet.Location = New System.Drawing.Point(352, 88)
		Me.btnASet.Name = "btnASet"
		Me.btnASet.Size = New System.Drawing.Size(144, 24)
		Me.btnASet.TabIndex = 9
		Me.btnASet.Text = "Alarm Setting..."
		'
		'btnStart
		'
		Me.btnStart.Location = New System.Drawing.Point(352, 136)
		Me.btnStart.Name = "btnStart"
		Me.btnStart.Size = New System.Drawing.Size(144, 24)
		Me.btnStart.TabIndex = 10
		Me.btnStart.Text = "Start"
		'
		'btnStop
		'
		Me.btnStop.Location = New System.Drawing.Point(352, 168)
		Me.btnStop.Name = "btnStop"
		Me.btnStop.Size = New System.Drawing.Size(144, 24)
		Me.btnStop.TabIndex = 11
		Me.btnStop.Text = "Stop"
		'
		'btnInput
		'
		Me.btnInput.Location = New System.Drawing.Point(352, 216)
		Me.btnInput.Name = "btnInput"
		Me.btnInput.Size = New System.Drawing.Size(144, 24)
		Me.btnInput.TabIndex = 12
		Me.btnInput.Text = "Input Value"
		'
		'btnStatus
		'
		Me.btnStatus.Location = New System.Drawing.Point(352, 248)
		Me.btnStatus.Name = "btnStatus"
		Me.btnStatus.Size = New System.Drawing.Size(144, 24)
		Me.btnStatus.TabIndex = 13
		Me.btnStatus.Text = "Status"
		'
		'btnExit
		'
		Me.btnExit.Location = New System.Drawing.Point(352, 296)
		Me.btnExit.Name = "btnExit"
		Me.btnExit.Size = New System.Drawing.Size(144, 24)
		Me.btnExit.TabIndex = 14
		Me.btnExit.Text = "Termination"
		'
		'btnOK
		'
		Me.btnOK.Location = New System.Drawing.Point(352, 344)
		Me.btnOK.Name = "btnOK"
		Me.btnOK.Size = New System.Drawing.Size(144, 24)
		Me.btnOK.TabIndex = 15
		Me.btnOK.Text = "Exit"
		'
		'Pti4
		'
		Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
		Me.ClientSize = New System.Drawing.Size(512, 429)
		Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.btnOK, Me.btnExit, Me.btnStatus, Me.btnInput, Me.btnStop, Me.btnStart, Me.btnASet, Me.btnMSet, Me.btnInit, Me.txtRet, Me.Label18, Me.GroupBox3, Me.GroupBox2, Me.GroupBox1, Me.cboDevice, Me.Label1})
		Me.Name = "Pti4"
		Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
		Me.Text = "Temperature/Resistance measurement sample program"
		Me.GroupBox1.ResumeLayout(False)
		Me.GroupBox2.ResumeLayout(False)
		Me.GroupBox3.ResumeLayout(False)
		Me.ResumeLayout(False)

	End Sub

#End Region
	Dim m_Id As Short	 'ID

	'	Initialize dialog
	Private Sub Pti4_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

		' Get the list of devices registered
		Dim ret As Integer
		Dim device As New System.Text.StringBuilder("", 50)
		Dim devicename As New System.Text.StringBuilder("", 50)
		Dim str As New String("", 100)
		Dim index As Short
		Dim group_id, unit_id, device_id As Short
		index = 0
		Do
			ret = PtQueryDeviceName(index, group_id, unit_id, device_id, devicename, device)
			If ret = 0 Then
				str = String.Format("{0} [{1}]", devicename, device)
				cboDevice.Items.Add(str)
				index += 1
			End If
		Loop While (ret = 0)
		cboDevice.SelectedIndex = 0

		txtCh0.Text = "0"
		txtCh1.Text = "0"
		txtCh2.Text = "0"
		txtCh3.Text = "0"

	End Sub

	'	Click the [Initialization] button
	Private Sub btnInit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnInit.Click

		Dim ret As Integer
		Dim devicename As New System.Text.StringBuilder("", 50)
		Dim tmp As New System.Text.StringBuilder("", 50)
		Dim index As Short
		Dim group_id, unit_id, device_id As Short
		' Detect device
		index = cboDevice.SelectedIndex
		ret = PtQueryDeviceName(index, group_id, unit_id, device_id, devicename, tmp)
		If ret <> 0 Then
			ErrorHandling("PtQueryDeviceName", ret)
			Exit Sub
		End If

		' Initialization
		ret = PtInit(devicename.ToString(), m_Id)
		If ret <> 0 Then
			ErrorHandling("PtInit", ret)
			Exit Sub
		End If

		txtRet.Text = "Initialization : Successed"
		ShowRemoteStatus()

	End Sub

	'	Click the [Measurement Setting] button
	Private Sub btnMSet_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnMSet.Click

		Dim measureDlg As New measure()

		' Invoke the Measurement Setting dialog
		measureDlg.SetId(m_Id)
		measureDlg.ShowDialog()
		measureDlg.Dispose()

	End Sub

	'	Click the [Alarm Setting] button
	Private Sub btnASet_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnASet.Click

		Dim alarmDlg As New alarm()

		' Invoke the Alarm Setting dialog
		alarmDlg.SetId(m_Id)
		alarmDlg.ShowDialog()
		alarmDlg.Dispose()

	End Sub

	'	Click the [Start] button
	Private Sub btnStart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStart.Click

		'-----------------------------------
		' Start
		'-----------------------------------
		Dim ret As Integer
		ret = PtStartIO(m_Id, &H1)
		'-----------------------------------
		' Process error
		'-----------------------------------
		If ret <> 0 Then
			ErrorHandling("PtStartIO", ret)
			Exit Sub
		End If
		txtRet.Text = "Start : Successed"
		ShowRemoteStatus()

	End Sub

	'	Click the [Stop] button
	Private Sub btnStop_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStop.Click

		'-----------------------------------
		' Stop
		'-----------------------------------
		Dim ret As Integer
		ret = PtStartIO(m_Id, &H0)
		'-----------------------------------
		' Process error
		'-----------------------------------
		If ret <> 0 Then
			ErrorHandling("PtStartIO", ret)
			Exit Sub
		End If
		txtRet.Text = "Stop : Successed"
		ShowRemoteStatus()

	End Sub

	'	Click the [Input Value] button
	Private Sub btnInput_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnInput.Click

		Dim ret As Integer
		Dim data(3) As Single

		' Input the temperature or capacity value for 4 channels
        ret = PtMultiInputEx(m_Id, 4, data)
		If ret <> 0 Then
			ErrorHandling("PtMultiInputEx", ret)
			If ret <> 20102 Then
				Exit Sub
			End If
		End If

		txtCh0.Text = data(0)
		txtCh1.Text = data(1)
		txtCh2.Text = data(2)
		txtCh3.Text = data(3)

		txtRet.Text = "Input Value : Successed"

	End Sub

	'	Click the [Status] button
	Private Sub btnStatus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStatus.Click

		Dim ret As Integer
		Dim disconnectstatus, upperstatus, lowerstatus As Integer
		Dim str As New String("", 32)

		' Get the disconnect status
		ret = PtGetDisconnectStatus(m_Id, disconnectstatus)
		If ret <> 0 Then
			ErrorHandling("PtGetDisconnectStatus", ret)
			Exit Sub
		End If

		' Get the alarm status
		ret = PtGetCurrentAlarmStatus(m_Id, upperstatus, lowerstatus)
		If ret <> 0 Then
			ErrorHandling("PtGetCurrentAlarmStatus", ret)
			Exit Sub
		End If

		str = String.Format("{0:x}", disconnectstatus)
		txtStsDc.Text = str
		str = String.Format("{0:x}", upperstatus)
		txtStsUAlarm.Text = str
		str = String.Format("{0:x}", lowerstatus)
		txtStsLAlarm.Text = str

		txtRet.Text = "Getting Status : Successed"

	End Sub

	'	Click the [Termination] button
	Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click

		Dim ret As Integer

		' Termination
		ret = PtExit(m_Id)
		If ret <> 0 Then
			ErrorHandling("PtExit", ret)
			Exit Sub
		End If

		txtRet.Text = "Termination : Successed"

	End Sub

	'	Exit dialog
	Private Sub btnOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOK.Click

		End

	End Sub

	'	Process error
	Private Sub ErrorHandling(ByVal Dfunction As String, ByVal ret As Integer)

		Dim errstr As New System.Text.StringBuilder("", 256)
		Dim str As New String("", 256)
		PtGetErrorString(ret, errstr)
		str = String.Format("[{0}] {1}", Dfunction, errstr)
		txtRet.Text = str

	End Sub

	'	Display remote status
	Private Sub ShowRemoteStatus()

		Dim Start, Err As Byte
		Dim szText As New String("", 100)
		Dim ret As Integer

		' Input remote status
		ret = PtGetRemoteStatus(m_Id, Start, Err)
		' Process error
		If ret <> 0 Then
			ErrorHandling("PtGetRemoteStatus", ret)
			Exit Sub
		End If
		' Display remote status
		szText = String.Format("{0:X2}", Start)
		lblStart.Text = szText
		szText = String.Format("{0:X2}", Err)
		lblErr.Text = szText

	End Sub

	Private Sub Pti4_Closed(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles MyBase.Closed

		Dim ret As Integer

		' Termination
		ret = PtExit(m_Id)

	End Sub
End Class
