Imports DCON_PC_DOTNET
Public Class Read_DI
    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 Open_Com As System.Windows.Forms.Button
    Friend WithEvents Close_Com As System.Windows.Forms.Button
    Friend WithEvents Label1 As System.Windows.Forms.Label
    Friend WithEvents Label2 As System.Windows.Forms.Label
    Friend WithEvents Label3 As System.Windows.Forms.Label
    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 GroupBox1 As System.Windows.Forms.GroupBox
    Friend WithEvents Button1 As System.Windows.Forms.Button
    Friend WithEvents TextDIValue As System.Windows.Forms.TextBox
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.TextDIValue = New System.Windows.Forms.TextBox
        Me.Open_Com = New System.Windows.Forms.Button
        Me.Close_Com = New System.Windows.Forms.Button
        Me.Label1 = New System.Windows.Forms.Label
        Me.Label2 = New System.Windows.Forms.Label
        Me.Label3 = New System.Windows.Forms.Label
        Me.Label4 = New System.Windows.Forms.Label
        Me.Label5 = New System.Windows.Forms.Label
        Me.Label6 = New System.Windows.Forms.Label
        Me.Label7 = New System.Windows.Forms.Label
        Me.GroupBox1 = New System.Windows.Forms.GroupBox
        Me.Button1 = New System.Windows.Forms.Button
        Me.SuspendLayout()
        '
        'TextDIValue
        '
        Me.TextDIValue.Location = New System.Drawing.Point(152, 24)
        Me.TextDIValue.Name = "TextDIValue"
        Me.TextDIValue.Size = New System.Drawing.Size(72, 22)
        Me.TextDIValue.TabIndex = 0
        Me.TextDIValue.Text = ""
        '
        'Open_Com
        '
        Me.Open_Com.Location = New System.Drawing.Point(48, 208)
        Me.Open_Com.Name = "Open_Com"
        Me.Open_Com.Size = New System.Drawing.Size(72, 32)
        Me.Open_Com.TabIndex = 1
        Me.Open_Com.Text = "Open Com"
        '
        'Close_Com
        '
        Me.Close_Com.Location = New System.Drawing.Point(152, 208)
        Me.Close_Com.Name = "Close_Com"
        Me.Close_Com.Size = New System.Drawing.Size(72, 32)
        Me.Close_Com.TabIndex = 2
        Me.Close_Com.Text = "Close Com"
        '
        'Label1
        '
        Me.Label1.Location = New System.Drawing.Point(32, 24)
        Me.Label1.Name = "Label1"
        Me.Label1.Size = New System.Drawing.Size(88, 16)
        Me.Label1.TabIndex = 4
        Me.Label1.Text = "ComPort:  4"
        '
        'Label2
        '
        Me.Label2.Location = New System.Drawing.Point(32, 48)
        Me.Label2.Name = "Label2"
        Me.Label2.Size = New System.Drawing.Size(88, 16)
        Me.Label2.TabIndex = 5
        Me.Label2.Text = "Address: 3"
        '
        'Label3
        '
        Me.Label3.Location = New System.Drawing.Point(32, 72)
        Me.Label3.Name = "Label3"
        Me.Label3.Size = New System.Drawing.Size(88, 16)
        Me.Label3.TabIndex = 6
        Me.Label3.Text = "Baudrate: 115200"
        '
        'Label4
        '
        Me.Label4.Location = New System.Drawing.Point(32, 96)
        Me.Label4.Name = "Label4"
        Me.Label4.Size = New System.Drawing.Size(80, 16)
        Me.Label4.TabIndex = 7
        Me.Label4.Text = "Slot: -1"
        '
        'Label5
        '
        Me.Label5.Location = New System.Drawing.Point(32, 120)
        Me.Label5.Name = "Label5"
        Me.Label5.Size = New System.Drawing.Size(88, 16)
        Me.Label5.TabIndex = 8
        Me.Label5.Text = "Total channel: 32"
        '
        'Label6
        '
        Me.Label6.Location = New System.Drawing.Point(32, 144)
        Me.Label6.Name = "Label6"
        Me.Label6.Size = New System.Drawing.Size(80, 16)
        Me.Label6.TabIndex = 9
        Me.Label6.Text = "Checksum: 0"
        '
        'Label7
        '
        Me.Label7.Location = New System.Drawing.Point(32, 168)
        Me.Label7.Name = "Label7"
        Me.Label7.Size = New System.Drawing.Size(80, 16)
        Me.Label7.TabIndex = 10
        Me.Label7.Text = "Timeout: 100"
        '
        'GroupBox1
        '
        Me.GroupBox1.Location = New System.Drawing.Point(16, 8)
        Me.GroupBox1.Name = "GroupBox1"
        Me.GroupBox1.Size = New System.Drawing.Size(112, 184)
        Me.GroupBox1.TabIndex = 11
        Me.GroupBox1.TabStop = False
        '
        'Button1
        '
        Me.Button1.Location = New System.Drawing.Point(152, 56)
        Me.Button1.Name = "Button1"
        Me.Button1.Size = New System.Drawing.Size(72, 32)
        Me.Button1.TabIndex = 12
        Me.Button1.Text = "Read DI"
        '
        'Read_DI
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 15)
        Me.ClientSize = New System.Drawing.Size(304, 293)
        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.Close_Com)
        Me.Controls.Add(Me.Open_Com)
        Me.Controls.Add(Me.TextDIValue)
        Me.Controls.Add(Me.GroupBox1)
        Me.Name = "Read_DI"
        Me.ResumeLayout(False)

    End Sub

#End Region

    Private Sub Open_Com_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Open_Com.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 Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim DIValue As UInt32
        DIValue = DCON.IO_Function.Read_DI(4, 3, -1, 32, 0, 100)
        TextDIValue.Text = Hex(DIValue.ToString)

    End Sub
End Class
