Imports DCON_PC_DOTNET
Public Class Form1
    Inherits System.Windows.Forms.Form

#Region " Windows Form 設計工具產生的程式碼 "

    Public Sub New()
        MyBase.New()

        '此為 Windows Form 設計工具所需的呼叫。
        InitializeComponent()

        '在 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 Form 設計工具的必要項
    Private components As System.ComponentModel.IContainer

    '注意: 以下為 Windows Form 設計工具所需的程序
    '您可以使用 Windows Form 設計工具進行修改。
    '請勿使用程式碼編輯器來修改這些程序。
    Friend WithEvents Label7 As System.Windows.Forms.Label
    Friend WithEvents Label6 As System.Windows.Forms.Label
    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 Label2 As System.Windows.Forms.Label
    Friend WithEvents Label1 As System.Windows.Forms.Label
    Friend WithEvents GroupBox1 As System.Windows.Forms.GroupBox
    Friend WithEvents Button1 As System.Windows.Forms.Button
    Friend WithEvents TextValue As System.Windows.Forms.TextBox
    Friend WithEvents Write_DO As System.Windows.Forms.Button
    Friend WithEvents Button3 As System.Windows.Forms.Button
    Friend WithEvents GroupBox2 As System.Windows.Forms.GroupBox
    Friend WithEvents GroupBox3 As System.Windows.Forms.GroupBox
    Friend WithEvents Close_Com As System.Windows.Forms.Button
    Friend WithEvents TextRdvalue As System.Windows.Forms.TextBox
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        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.Label3 = New System.Windows.Forms.Label
        Me.Label2 = New System.Windows.Forms.Label
        Me.Label1 = New System.Windows.Forms.Label
        Me.GroupBox1 = New System.Windows.Forms.GroupBox
        Me.Button1 = New System.Windows.Forms.Button
        Me.Close_Com = New System.Windows.Forms.Button
        Me.TextValue = New System.Windows.Forms.TextBox
        Me.Write_DO = New System.Windows.Forms.Button
        Me.TextRdvalue = New System.Windows.Forms.TextBox
        Me.Button3 = New System.Windows.Forms.Button
        Me.GroupBox2 = New System.Windows.Forms.GroupBox
        Me.GroupBox3 = New System.Windows.Forms.GroupBox
        Me.SuspendLayout()
        '
        'Label7
        '
        Me.Label7.Location = New System.Drawing.Point(24, 168)
        Me.Label7.Name = "Label7"
        Me.Label7.Size = New System.Drawing.Size(80, 16)
        Me.Label7.TabIndex = 18
        Me.Label7.Text = "Timeout: 100"
        '
        'Label6
        '
        Me.Label6.Location = New System.Drawing.Point(24, 144)
        Me.Label6.Name = "Label6"
        Me.Label6.Size = New System.Drawing.Size(80, 16)
        Me.Label6.TabIndex = 17
        Me.Label6.Text = "Checksum: 0"
        '
        'Label5
        '
        Me.Label5.Location = New System.Drawing.Point(24, 120)
        Me.Label5.Name = "Label5"
        Me.Label5.Size = New System.Drawing.Size(88, 16)
        Me.Label5.TabIndex = 16
        Me.Label5.Text = "Total channel: 8"
        '
        'Label4
        '
        Me.Label4.Location = New System.Drawing.Point(24, 96)
        Me.Label4.Name = "Label4"
        Me.Label4.Size = New System.Drawing.Size(80, 16)
        Me.Label4.TabIndex = 15
        Me.Label4.Text = "Slot: -1"
        '
        'Label3
        '
        Me.Label3.Location = New System.Drawing.Point(24, 72)
        Me.Label3.Name = "Label3"
        Me.Label3.Size = New System.Drawing.Size(96, 16)
        Me.Label3.TabIndex = 14
        Me.Label3.Text = "Baudrate: 115200"
        '
        'Label2
        '
        Me.Label2.Location = New System.Drawing.Point(24, 48)
        Me.Label2.Name = "Label2"
        Me.Label2.Size = New System.Drawing.Size(88, 16)
        Me.Label2.TabIndex = 13
        Me.Label2.Text = "Address: 1"
        '
        'Label1
        '
        Me.Label1.Location = New System.Drawing.Point(24, 24)
        Me.Label1.Name = "Label1"
        Me.Label1.Size = New System.Drawing.Size(88, 16)
        Me.Label1.TabIndex = 12
        Me.Label1.Text = "ComPort:  4"
        '
        'GroupBox1
        '
        Me.GroupBox1.Location = New System.Drawing.Point(8, 0)
        Me.GroupBox1.Name = "GroupBox1"
        Me.GroupBox1.Size = New System.Drawing.Size(136, 192)
        Me.GroupBox1.TabIndex = 19
        Me.GroupBox1.TabStop = False
        '
        'Button1
        '
        Me.Button1.Location = New System.Drawing.Point(64, 200)
        Me.Button1.Name = "Button1"
        Me.Button1.Size = New System.Drawing.Size(72, 32)
        Me.Button1.TabIndex = 20
        Me.Button1.Text = "Open Com"
        '
        'Close_Com
        '
        Me.Close_Com.Location = New System.Drawing.Point(168, 200)
        Me.Close_Com.Name = "Close_Com"
        Me.Close_Com.Size = New System.Drawing.Size(72, 32)
        Me.Close_Com.TabIndex = 21
        Me.Close_Com.Text = "Close Com"
        '
        'TextValue
        '
        Me.TextValue.Location = New System.Drawing.Point(176, 16)
        Me.TextValue.Name = "TextValue"
        Me.TextValue.Size = New System.Drawing.Size(72, 22)
        Me.TextValue.TabIndex = 22
        Me.TextValue.Text = ""
        '
        'Write_DO
        '
        Me.Write_DO.Location = New System.Drawing.Point(176, 48)
        Me.Write_DO.Name = "Write_DO"
        Me.Write_DO.Size = New System.Drawing.Size(72, 24)
        Me.Write_DO.TabIndex = 23
        Me.Write_DO.Text = "Write DO"
        '
        'TextRdvalue
        '
        Me.TextRdvalue.Location = New System.Drawing.Point(176, 120)
        Me.TextRdvalue.Name = "TextRdvalue"
        Me.TextRdvalue.Size = New System.Drawing.Size(80, 22)
        Me.TextRdvalue.TabIndex = 24
        Me.TextRdvalue.Text = ""
        '
        'Button3
        '
        Me.Button3.Location = New System.Drawing.Point(176, 152)
        Me.Button3.Name = "Button3"
        Me.Button3.Size = New System.Drawing.Size(80, 24)
        Me.Button3.TabIndex = 25
        Me.Button3.Text = "Read DO"
        '
        'GroupBox2
        '
        Me.GroupBox2.Location = New System.Drawing.Point(160, 0)
        Me.GroupBox2.Name = "GroupBox2"
        Me.GroupBox2.Size = New System.Drawing.Size(104, 96)
        Me.GroupBox2.TabIndex = 26
        Me.GroupBox2.TabStop = False
        Me.GroupBox2.Text = "Write DO"
        '
        'GroupBox3
        '
        Me.GroupBox3.Location = New System.Drawing.Point(160, 96)
        Me.GroupBox3.Name = "GroupBox3"
        Me.GroupBox3.Size = New System.Drawing.Size(104, 96)
        Me.GroupBox3.TabIndex = 27
        Me.GroupBox3.TabStop = False
        Me.GroupBox3.Text = "Read DO"
        '
        'Form1
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 15)
        Me.ClientSize = New System.Drawing.Size(272, 253)
        Me.Controls.Add(Me.Button3)
        Me.Controls.Add(Me.TextRdvalue)
        Me.Controls.Add(Me.Write_DO)
        Me.Controls.Add(Me.TextValue)
        Me.Controls.Add(Me.Close_Com)
        Me.Controls.Add(Me.Button1)
        Me.Controls.Add(Me.Label7)
        Me.Controls.Add(Me.Label6)
        Me.Controls.Add(Me.Label5)
        Me.Controls.Add(Me.Label4)
        Me.Controls.Add(Me.Label3)
        Me.Controls.Add(Me.Label2)
        Me.Controls.Add(Me.Label1)
        Me.Controls.Add(Me.GroupBox1)
        Me.Controls.Add(Me.GroupBox2)
        Me.Controls.Add(Me.GroupBox3)
        Me.Name = "Form1"
        Me.Text = "Form1"
        Me.ResumeLayout(False)

    End Sub

#End Region

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        DCON.UART.Open_Com(4, Convert.ToUInt32(115200), 8, 0, 1)
    End Sub

    Private Sub Close_Com_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Close_Com.Click
        DCON.UART.Close_Com(4)
    End Sub

    Private Sub Write_DO_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Write_DO.Click
        DCON.IO_Function.Write_DO(4, 1, -1, 8, Convert.ToUInt32(TextValue.Text, 16), 0, 100)
    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        Dim DOValue As UInt32
        DOValue = DCON.IO_Function.Read_DO(4, 1, -1, 8, 0, 100)

        TextRdvalue.Text = Hex(DOValue.ToString)
    End Sub
End Class
