Option Strict Off
Option Explicit On
Friend Class frmSndRecv
	Inherits System.Windows.Forms.Form
#Region "Windows フォーム デザイナによって生成されたコード"
	Public Sub New()
		MyBase.New()
		If m_vb6FormDefInstance Is Nothing Then
			If m_InitializingDefInstance Then
				m_vb6FormDefInstance = Me
			Else
				Try 
					'スタートアップ フォームについては、最初に作成されたインスタンスが既定インスタンスになります。
					If System.Reflection.Assembly.GetExecutingAssembly.EntryPoint.DeclaringType Is Me.GetType Then
						m_vb6FormDefInstance = Me
					End If
				Catch
				End Try
			End If
		End If
		'この呼び出しは、Windows フォーム デザイナで必要です。
		InitializeComponent()
	End Sub
	'Form は、コンポーネント一覧に後処理を実行するために dispose をオーバーライドします。
	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 フォーム デザイナで必要です。
	Private components As System.ComponentModel.IContainer
	Public ToolTip1 As System.Windows.Forms.ToolTip
	Public WithEvents CsvDownIrda As System.Windows.Forms.Button
	Public WithEvents Timer1 As System.Windows.Forms.Timer
	Public WithEvents cmdPartsTst4 As System.Windows.Forms.Button
	Public WithEvents lblStatus As System.Windows.Forms.Label
	Public WithEvents Frame1 As System.Windows.Forms.GroupBox
	Public WithEvents CsvUpIrda As System.Windows.Forms.Button
	Public WithEvents cmdEnd As System.Windows.Forms.Button
	'メモ : 以下のプロシージャは Windows フォーム デザイナで必要です。
	'Windows フォーム デザイナを使って変更できます。
	'コードエディタを使って修正しないでください。


	<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
		Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(frmSndRecv))
		Me.components = New System.ComponentModel.Container()
		Me.ToolTip1 = New System.Windows.Forms.ToolTip(components)
		Me.ToolTip1.Active = True
		Me.CsvDownIrda = New System.Windows.Forms.Button
		Me.Timer1 = New System.Windows.Forms.Timer(components)
		Me.cmdPartsTst4 = New System.Windows.Forms.Button
		Me.Frame1 = New System.Windows.Forms.GroupBox
		Me.lblStatus = New System.Windows.Forms.Label
		Me.CsvUpIrda = New System.Windows.Forms.Button
		Me.cmdEnd = New System.Windows.Forms.Button
		Me.Text = "UploadCsv・DownloadCsv　サンプル"
		Me.ClientSize = New System.Drawing.Size(588, 237)
		Me.Location = New System.Drawing.Point(4, 30)
		Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
		Me.AutoScaleBaseSize = New System.Drawing.Size(5, 12)
		Me.BackColor = System.Drawing.SystemColors.Control
		Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Sizable
		Me.ControlBox = True
		Me.Enabled = True
		Me.KeyPreview = False
		Me.MaximizeBox = True
		Me.MinimizeBox = True
		Me.Cursor = System.Windows.Forms.Cursors.Default
		Me.RightToLeft = System.Windows.Forms.RightToLeft.No
		Me.ShowInTaskbar = True
		Me.HelpButton = False
		Me.WindowState = System.Windows.Forms.FormWindowState.Normal
		Me.Name = "frmSndRecv"
		Me.CsvDownIrda.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
		Me.CsvDownIrda.Text = "Download CSV(Model8000・Irda)"
		Me.CsvDownIrda.Size = New System.Drawing.Size(129, 41)
		Me.CsvDownIrda.Location = New System.Drawing.Point(200, 32)
		Me.CsvDownIrda.TabIndex = 1
		Me.CsvDownIrda.BackColor = System.Drawing.SystemColors.Control
		Me.CsvDownIrda.CausesValidation = True
		Me.CsvDownIrda.Enabled = True
		Me.CsvDownIrda.ForeColor = System.Drawing.SystemColors.ControlText
		Me.CsvDownIrda.Cursor = System.Windows.Forms.Cursors.Default
		Me.CsvDownIrda.RightToLeft = System.Windows.Forms.RightToLeft.No
		Me.CsvDownIrda.TabStop = True
		Me.CsvDownIrda.Name = "CsvDownIrda"
		Me.Timer1.Interval = 100
		Me.Timer1.Enabled = True
		Me.cmdPartsTst4.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
		Me.cmdPartsTst4.Text = "通信中断"
		Me.cmdPartsTst4.Size = New System.Drawing.Size(97, 81)
		Me.cmdPartsTst4.Location = New System.Drawing.Point(472, 120)
		Me.cmdPartsTst4.TabIndex = 2
		Me.cmdPartsTst4.BackColor = System.Drawing.SystemColors.Control
		Me.cmdPartsTst4.CausesValidation = True
		Me.cmdPartsTst4.Enabled = True
		Me.cmdPartsTst4.ForeColor = System.Drawing.SystemColors.ControlText
		Me.cmdPartsTst4.Cursor = System.Windows.Forms.Cursors.Default
		Me.cmdPartsTst4.RightToLeft = System.Windows.Forms.RightToLeft.No
		Me.cmdPartsTst4.TabStop = True
		Me.cmdPartsTst4.Name = "cmdPartsTst4"
		Me.Frame1.Text = "送受信状態"
		Me.Frame1.Size = New System.Drawing.Size(425, 97)
		Me.Frame1.Location = New System.Drawing.Point(32, 112)
		Me.Frame1.TabIndex = 4
		Me.Frame1.BackColor = System.Drawing.SystemColors.Control
		Me.Frame1.Enabled = True
		Me.Frame1.ForeColor = System.Drawing.SystemColors.ControlText
		Me.Frame1.RightToLeft = System.Windows.Forms.RightToLeft.No
		Me.Frame1.Visible = True
		Me.Frame1.Name = "Frame1"
		Me.lblStatus.Size = New System.Drawing.Size(393, 57)
		Me.lblStatus.Location = New System.Drawing.Point(16, 24)
		Me.lblStatus.TabIndex = 5
		Me.lblStatus.TextAlign = System.Drawing.ContentAlignment.TopLeft
		Me.lblStatus.BackColor = System.Drawing.SystemColors.Control
		Me.lblStatus.Enabled = True
		Me.lblStatus.ForeColor = System.Drawing.SystemColors.ControlText
		Me.lblStatus.Cursor = System.Windows.Forms.Cursors.Default
		Me.lblStatus.RightToLeft = System.Windows.Forms.RightToLeft.No
		Me.lblStatus.UseMnemonic = True
		Me.lblStatus.Visible = True
		Me.lblStatus.AutoSize = False
		Me.lblStatus.BorderStyle = System.Windows.Forms.BorderStyle.None
		Me.lblStatus.Name = "lblStatus"
		Me.CsvUpIrda.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
		Me.CsvUpIrda.Text = "Upload CSV　(Model8000・ Irda )"
		Me.CsvUpIrda.Size = New System.Drawing.Size(129, 41)
		Me.CsvUpIrda.Location = New System.Drawing.Point(32, 32)
		Me.CsvUpIrda.TabIndex = 0
		Me.CsvUpIrda.BackColor = System.Drawing.SystemColors.Control
		Me.CsvUpIrda.CausesValidation = True
		Me.CsvUpIrda.Enabled = True
		Me.CsvUpIrda.ForeColor = System.Drawing.SystemColors.ControlText
		Me.CsvUpIrda.Cursor = System.Windows.Forms.Cursors.Default
		Me.CsvUpIrda.RightToLeft = System.Windows.Forms.RightToLeft.No
		Me.CsvUpIrda.TabStop = True
		Me.CsvUpIrda.Name = "CsvUpIrda"
		Me.cmdEnd.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
		Me.CancelButton = Me.cmdEnd
		Me.cmdEnd.Text = "終了"
		Me.cmdEnd.Size = New System.Drawing.Size(97, 41)
		Me.cmdEnd.Location = New System.Drawing.Point(472, 32)
		Me.cmdEnd.TabIndex = 3
		Me.cmdEnd.BackColor = System.Drawing.SystemColors.Control
		Me.cmdEnd.CausesValidation = True
		Me.cmdEnd.Enabled = True
		Me.cmdEnd.ForeColor = System.Drawing.SystemColors.ControlText
		Me.cmdEnd.Cursor = System.Windows.Forms.Cursors.Default
		Me.cmdEnd.RightToLeft = System.Windows.Forms.RightToLeft.No
		Me.cmdEnd.TabStop = True
		Me.cmdEnd.Name = "cmdEnd"
		Me.Controls.Add(CsvDownIrda)
		Me.Controls.Add(cmdPartsTst4)
		Me.Controls.Add(Frame1)
		Me.Controls.Add(CsvUpIrda)
		Me.Controls.Add(cmdEnd)
		Me.Frame1.Controls.Add(lblStatus)
	End Sub
#End Region 
#Region "アップグレード ウィザードのサポート コード"
	Private Shared m_vb6FormDefInstance As frmSndRecv
	Private Shared m_InitializingDefInstance As Boolean
	Public Shared Property DefInstance() As frmSndRecv
		Get
			If m_vb6FormDefInstance Is Nothing OrElse m_vb6FormDefInstance.IsDisposed Then
				m_InitializingDefInstance = True
				m_vb6FormDefInstance = New frmSndRecv()
				m_InitializingDefInstance = False
			End If
			DefInstance = m_vb6FormDefInstance
		End Get
		Set
			m_vb6FormDefInstance = Value
		End Set
	End Property
#End Region 
	
	Private Sub cmdEnd_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdEnd.Click
		Me.Close()
	End Sub
	
	Private Sub CsvUpIrda_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles CsvUpIrda.Click
		Dim ret As Integer
		Dim comst As WelHComSetTMPL
		Dim editst As WelHTComEditTMPL
		Dim csvst As WelHTCsvTMPL
		Dim wkmsg As String
		Dim wkerror As Integer
		Dim wkreccnt As Integer
		Dim wkallcnt As Integer
		
		CsvUpIrda.Enabled = False
		CsvDownIrda.Enabled = False
		cmdEnd.Enabled = False
		Me.Cursor = System.Windows.Forms.Cursors.WaitCursor
		
		' ポートの設定
		comst.port = WelHTCom.PortNoENum.HT_COM5
		comst.baud = WelHTCom.BaudRaitENum.HT_BAUD115200
		comst.mode = WelHTCom.ConnectModeENum.HT_IR705
		comst.crctype = WelHTCom.CrcTypeENum.HT_CRC1
		comst.protocol = WelHTCom.ProtoTypeENum.HT_PROTO_WONLY
		comst.sendcod = WelHTCom.UploadStartCdENum.HT_SENDVOL
		
		' ＣＳＶ形式の設定
		csvst.textquote = WelHTCom.TextQuoteEnum.HT_QUOTE_DOUBLE
		csvst.textsep = WelHTCom.TextSepEnum.HT_CSVSEP_COMMA
		csvst.openmode = WelHTCom.OpenModeEnum.HT_CSVAPPEND
		
		editst.nametype = 0
		
        ret = vbWelHTUploadCsv("", "RcvTest.Csv", comst, editst, csvst)
		
		vbWelHTStatusGet(wkmsg, wkerror, wkreccnt, wkallcnt)
		
		MsgBox("ハンディターミナルとの通信が終了しました" & vbCr & vbCr & "  　エラー番号 = &H" & Hex(wkerror) & vbCr & " 　 " & wkmsg)
		
		Me.Cursor = System.Windows.Forms.Cursors.Default
		
		CsvDownIrda.Enabled = True
		CsvUpIrda.Enabled = True
		cmdEnd.Enabled = True
	End Sub
	
	Private Sub cmdPartsTst4_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdPartsTst4.Click
		vbWelHTCancelCom()
	End Sub
	
	Private Sub CsvDownIrda_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles CsvDownIrda.Click
		Dim ret As Integer
		Dim comst As WelHComSetTMPL
		Dim editst As WelHTComEditTMPL
		Dim csvst As WelHTCsvTMPL
		Dim wkmsg As String
		Dim wkerror As Integer
		Dim wkreccnt As Integer
		Dim wkallcnt As Integer
		
		CsvUpIrda.Enabled = False
		CsvDownIrda.Enabled = False
		cmdEnd.Enabled = False
		
		Me.Cursor = System.Windows.Forms.Cursors.WaitCursor
		
		' ポートの設定
		comst.port = WelHTCom.PortNoENum.HT_COM5
		comst.baud = WelHTCom.BaudRaitENum.HT_BAUD115200
		comst.mode = WelHTCom.ConnectModeENum.HT_IR705
		comst.crctype = WelHTCom.CrcTypeENum.HT_CRC1
		comst.protocol = WelHTCom.ProtoTypeENum.HT_PROTO_WONLY
		comst.sendcod = WelHTCom.UploadStartCdENum.HT_SENDVOL
		
		' ＣＳＶ形式の設定
		csvst.textquote = WelHTCom.TextQuoteEnum.HT_QUOTE_DOUBLE
		csvst.textsep = WelHTCom.TextSepEnum.HT_CSVSEP_COMMA
		csvst.withtitle = WelHTCom.TitlePermEnum.HT_WITH_TITLE
		
		editst.nametype = 0
		
		ret = vbWelHTDownloadCsv("", "", "SndDataKD.csv", comst, editst, csvst)
		
		vbWelHTStatusGet(wkmsg, wkerror, wkreccnt, wkallcnt)
		
		MsgBox("ハンディターミナルとの通信が終了しました" & vbCr & vbCr & "  　エラー番号 = &H" & Hex(wkerror) & vbCr & " 　 " & wkmsg)
		
		Me.Cursor = System.Windows.Forms.Cursors.Default
		
		CsvDownIrda.Enabled = True
		CsvUpIrda.Enabled = True
		cmdEnd.Enabled = True
	End Sub
	
	Private Sub Timer1_Tick(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Timer1.Tick
		Dim wkerror As Integer
		Dim wkreccnt As Integer
		Dim wkallcnt As Integer
		Dim wkmsg As String
		
		vbWelHTStatusGet(wkmsg, wkerror, wkreccnt, wkallcnt)
		lblStatus.Text = wkmsg
	End Sub
End Class