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 Open_Com As System.Windows.Forms.Button
    Friend WithEvents Close_Com As System.Windows.Forms.Button
    Friend WithEvents Button1 As System.Windows.Forms.Button
    Friend WithEvents GroupBox2 As System.Windows.Forms.GroupBox
    Friend WithEvents Read_AO As System.Windows.Forms.Button
    Friend WithEvents GroupBox3 As System.Windows.Forms.GroupBox
    Friend WithEvents TextWrValue As System.Windows.Forms.TextBox
    Friend WithEvents TextRdValue As System.Windows.Forms.TextBox
    Friend WithEvents Label8 As System.Windows.Forms.Label
    <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.Label8 = New System.Windows.Forms.Label
        Me.Open_Com = New System.Windows.Forms.Button
        Me.Close_Com = New System.Windows.Forms.Button
        Me.TextWrValue = New System.Windows.Forms.TextBox
        Me.Button1 = New System.Windows.Forms.Button
        Me.GroupBox2 = New System.Windows.Forms.GroupBox
        Me.TextRdValue = New System.Windows.Forms.TextBox
        Me.Read_AO = New System.Windows.Forms.Button
        Me.GroupBox3 = New System.Windows.Forms.GroupBox
        Me.GroupBox1.SuspendLayout()
        Me.SuspendLayout()
        '
        'Label7
        '
        Me.Label7.Location = New System.Drawing.Point(24, 176)
        Me.Label7.Name = "Label7"
        Me.Label7.Size = New System.Drawing.Size(80, 16)
        Me.Label7.TabIndex = 26
        Me.Label7.Text = "Timeout: 100"
        '
        'Label6
        '
        Me.Label6.Location = New System.Drawing.Point(24, 152)
        Me.Label6.Name = "Label6"
        Me.Label6.Size = New System.Drawing.Size(80, 16)
        Me.Label6.TabIndex = 25
        Me.Label6.Text = "Checksum: 0"
        '
        'Label5
        '
        Me.Label5.Location = New System.Drawing.Point(24, 128)
        Me.Label5.Name = "Label5"
        Me.Label5.Size = New System.Drawing.Size(88, 16)
        Me.Label5.TabIndex = 24
        Me.Label5.Text = "Total channel: 4"
        '
        'Label4
        '
        Me.Label4.Location = New System.Drawing.Point(24, 104)
        Me.Label4.Name = "Label4"
        Me.Label4.Size = New System.Drawing.Size(80, 16)
        Me.Label4.TabIndex = 23
        Me.Label4.Text = "Slot: -1"
        '
        'Label3
        '
        Me.Label3.Location = New System.Drawing.Point(24, 80)
        Me.Label3.Name = "Label3"
        Me.Label3.Size = New System.Drawing.Size(96, 16)
        Me.Label3.TabIndex = 22
        Me.Label3.Text = "Baudrate: 115200"
        '
        'Label2
        '
        Me.Label2.Location = New System.Drawing.Point(24, 56)
        Me.Label2.Name = "Label2"
        Me.Label2.Size = New System.Drawing.Size(88, 16)
        Me.Label2.TabIndex = 21
        Me.Label2.Text = "Address: 5"
        '
        'Label1
        '
        Me.Label1.Location = New System.Drawing.Point(24, 32)
        Me.Label1.Name = "Label1"
        Me.Label1.Size = New System.Drawing.Size(88, 16)
        Me.Label1.TabIndex = 20
        Me.Label1.Text = "ComPort:  4"
        '
        'GroupBox1
        '
        Me.GroupBox1.Controls.Add(Me.Label8)
        Me.GroupBox1.Location = New System.Drawing.Point(8, 8)
        Me.GroupBox1.Name = "GroupBox1"
        Me.GroupBox1.Size = New System.Drawing.Size(136, 216)
        Me.GroupBox1.TabIndex = 27
        Me.GroupBox1.TabStop = False
        '
        'Label8
        '
        Me.Label8.Location = New System.Drawing.Point(16, 192)
        Me.Label8.Name = "Label8"
        Me.Label8.Size = New System.Drawing.Size(104, 16)
        Me.Label8.TabIndex = 0
        Me.Label8.Text = "Channel Number: 0"
        '
        'Open_Com
        '
        Me.Open_Com.Location = New System.Drawing.Point(56, 240)
        Me.Open_Com.Name = "Open_Com"
        Me.Open_Com.Size = New System.Drawing.Size(72, 32)
        Me.Open_Com.TabIndex = 28
        Me.Open_Com.Text = "Open Com"
        '
        'Close_Com
        '
        Me.Close_Com.Location = New System.Drawing.Point(168, 240)
        Me.Close_Com.Name = "Close_Com"
        Me.Close_Com.Size = New System.Drawing.Size(72, 32)
        Me.Close_Com.TabIndex = 29
        Me.Close_Com.Text = "Close Com"
        '
        'TextWrValue
        '
        Me.TextWrValue.Location = New System.Drawing.Point(168, 32)
        Me.TextWrValue.Name = "TextWrValue"
        Me.TextWrValue.Size = New System.Drawing.Size(80, 22)
        Me.TextWrValue.TabIndex = 30
        Me.TextWrValue.Text = ""
        '
        'Button1
        '
        Me.Button1.Location = New System.Drawing.Point(168, 64)
        Me.Button1.Name = "Button1"
        Me.Button1.Size = New System.Drawing.Size(80, 32)
        Me.Button1.TabIndex = 31
        Me.Button1.Text = "Write AO"
        '
        'GroupBox2
        '
        Me.GroupBox2.Location = New System.Drawing.Point(152, 8)
        Me.GroupBox2.Name = "GroupBox2"
        Me.GroupBox2.Size = New System.Drawing.Size(112, 96)
        Me.GroupBox2.TabIndex = 32
        Me.GroupBox2.TabStop = False
        Me.GroupBox2.Text = "Write AO"
        '
        'TextRdValue
        '
        Me.TextRdValue.Location = New System.Drawing.Point(168, 128)
        Me.TextRdValue.Name = "TextRdValue"
        Me.TextRdValue.Size = New System.Drawing.Size(80, 22)
        Me.TextRdValue.TabIndex = 33
        Me.TextRdValue.Text = ""
        '
        'Read_AO
        '
        Me.Read_AO.Location = New System.Drawing.Point(168, 160)
        Me.Read_AO.Name = "Read_AO"
        Me.Read_AO.Size = New System.Drawing.Size(80, 24)
        Me.Read_AO.TabIndex = 34
        Me.Read_AO.Text = "Read AO"
        '
        'GroupBox3
        '
        Me.GroupBox3.Location = New System.Drawing.Point(152, 104)
        Me.GroupBox3.Name = "GroupBox3"
        Me.GroupBox3.Size = New System.Drawing.Size(112, 96)
        Me.GroupBox3.TabIndex = 35
        Me.GroupBox3.TabStop = False
        Me.GroupBox3.Text = "Read AO"
        '
        'Form1
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 15)
        Me.ClientSize = New System.Drawing.Size(272, 285)
        Me.Controls.Add(Me.Read_AO)
        Me.Controls.Add(Me.TextRdValue)
        Me.Controls.Add(Me.Button1)
        Me.Controls.Add(Me.TextWrValue)
        Me.Controls.Add(Me.Close_Com)
        Me.Controls.Add(Me.Open_Com)
        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.GroupBox1.ResumeLayout(False)
        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
        DCON.IO_Function.Write_AO(4, 5, -1, 0, 4, Convert.ToSingle(TextWrValue.Text), 0, 100)
    End Sub

  
    Private Sub Read_AO_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Read_AO.Click
        Dim AOValue As Single
        AOValue = DCON.IO_Function.Read_AO(4, 5, -1, 0, 4, 0, 100)
        TextRdValue.Text = Convert.ToString(AOValue)
    End Sub
End Class
