﻿Option Strict Off
Option Explicit On 
Imports VB = Microsoft.VisualBasic
Imports System.Text

Public Class Interrupt
    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()
    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
    Public ToolTip1 As System.Windows.Forms.ToolTip
    Public WithEvents Edit_ReturnCode As System.Windows.Forms.TextBox
    Public WithEvents Button_DioExit As System.Windows.Forms.Button
    Public WithEvents Button_Exit As System.Windows.Forms.Button
    Public WithEvents Label3 As System.Windows.Forms.Label
    Public WithEvents Label2 As System.Windows.Forms.Label
    Public WithEvents Frame1 As System.Windows.Forms.GroupBox
    Public WithEvents Edit_DeviceName As System.Windows.Forms.TextBox
    Public WithEvents Label5 As System.Windows.Forms.Label
    Public WithEvents Label1 As System.Windows.Forms.Label
    '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 GroupBox1 As System.Windows.Forms.GroupBox
    Friend WithEvents Radio_Fall As System.Windows.Forms.RadioButton
    Friend WithEvents Radio_Rise As System.Windows.Forms.RadioButton
    Friend WithEvents Label4 As System.Windows.Forms.Label
    Friend WithEvents Label6 As System.Windows.Forms.Label
    Friend WithEvents Label7 As System.Windows.Forms.Label
    Friend WithEvents Label8 As System.Windows.Forms.Label
    Public WithEvents Button_IntStop As System.Windows.Forms.Button
    Public WithEvents Button_IntStart As System.Windows.Forms.Button
    Public WithEvents Button_DioInit As System.Windows.Forms.Button
    Public WithEvents Edit_Down_3 As System.Windows.Forms.TextBox
    Public WithEvents Edit_Down_2 As System.Windows.Forms.TextBox
    Public WithEvents Edit_Down_1 As System.Windows.Forms.TextBox
    Public WithEvents Edit_Down_0 As System.Windows.Forms.TextBox
    Public WithEvents Edit_Up_3 As System.Windows.Forms.TextBox
    Public WithEvents Edit_Up_2 As System.Windows.Forms.TextBox
    Public WithEvents Edit_Up_1 As System.Windows.Forms.TextBox
    Public WithEvents Edit_Up_0 As System.Windows.Forms.TextBox
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.components = New System.ComponentModel.Container
        Me.ToolTip1 = New System.Windows.Forms.ToolTip(Me.components)
        Me.Edit_ReturnCode = New System.Windows.Forms.TextBox
        Me.Button_DioExit = New System.Windows.Forms.Button
        Me.Button_Exit = New System.Windows.Forms.Button
        Me.Frame1 = New System.Windows.Forms.GroupBox
        Me.Label8 = New System.Windows.Forms.Label
        Me.Label7 = New System.Windows.Forms.Label
        Me.Label6 = New System.Windows.Forms.Label
        Me.Label4 = New System.Windows.Forms.Label
        Me.Button_IntStop = New System.Windows.Forms.Button
        Me.GroupBox1 = New System.Windows.Forms.GroupBox
        Me.Radio_Fall = New System.Windows.Forms.RadioButton
        Me.Radio_Rise = New System.Windows.Forms.RadioButton
        Me.Button_IntStart = New System.Windows.Forms.Button
        Me.Edit_Down_3 = New System.Windows.Forms.TextBox
        Me.Edit_Down_2 = New System.Windows.Forms.TextBox
        Me.Edit_Down_1 = New System.Windows.Forms.TextBox
        Me.Edit_Down_0 = New System.Windows.Forms.TextBox
        Me.Edit_Up_3 = New System.Windows.Forms.TextBox
        Me.Edit_Up_2 = New System.Windows.Forms.TextBox
        Me.Edit_Up_1 = New System.Windows.Forms.TextBox
        Me.Edit_Up_0 = New System.Windows.Forms.TextBox
        Me.Label3 = New System.Windows.Forms.Label
        Me.Label2 = New System.Windows.Forms.Label
        Me.Button_DioInit = New System.Windows.Forms.Button
        Me.Edit_DeviceName = New System.Windows.Forms.TextBox
        Me.Label5 = New System.Windows.Forms.Label
        Me.Label1 = New System.Windows.Forms.Label
        Me.Frame1.SuspendLayout()
        Me.GroupBox1.SuspendLayout()
        Me.SuspendLayout()
        '
        'Edit_ReturnCode
        '
        Me.Edit_ReturnCode.AcceptsReturn = True
        Me.Edit_ReturnCode.BackColor = System.Drawing.SystemColors.Window
        Me.Edit_ReturnCode.Cursor = System.Windows.Forms.Cursors.IBeam
        Me.Edit_ReturnCode.ForeColor = System.Drawing.SystemColors.WindowText
        Me.Edit_ReturnCode.Location = New System.Drawing.Point(88, 281)
        Me.Edit_ReturnCode.MaxLength = 0
        Me.Edit_ReturnCode.Name = "Edit_ReturnCode"
        Me.Edit_ReturnCode.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.Edit_ReturnCode.Size = New System.Drawing.Size(249, 22)
        Me.Edit_ReturnCode.TabIndex = 14
        Me.Edit_ReturnCode.Text = "Edit"
        '
        'Button_DioExit
        '
        Me.Button_DioExit.BackColor = System.Drawing.SystemColors.Control
        Me.Button_DioExit.Cursor = System.Windows.Forms.Cursors.Default
        Me.Button_DioExit.ForeColor = System.Drawing.SystemColors.ControlText
        Me.Button_DioExit.Location = New System.Drawing.Point(352, 280)
        Me.Button_DioExit.Name = "Button_DioExit"
        Me.Button_DioExit.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.Button_DioExit.Size = New System.Drawing.Size(113, 24)
        Me.Button_DioExit.TabIndex = 15
        Me.Button_DioExit.Text = "DioExit"
        Me.Button_DioExit.UseVisualStyleBackColor = False
        '
        'Button_Exit
        '
        Me.Button_Exit.BackColor = System.Drawing.SystemColors.Control
        Me.Button_Exit.Cursor = System.Windows.Forms.Cursors.Default
        Me.Button_Exit.ForeColor = System.Drawing.SystemColors.ControlText
        Me.Button_Exit.Location = New System.Drawing.Point(352, 312)
        Me.Button_Exit.Name = "Button_Exit"
        Me.Button_Exit.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.Button_Exit.Size = New System.Drawing.Size(113, 25)
        Me.Button_Exit.TabIndex = 16
        Me.Button_Exit.Text = "Exit"
        Me.Button_Exit.UseVisualStyleBackColor = False
        '
        'Frame1
        '
        Me.Frame1.BackColor = System.Drawing.SystemColors.Control
        Me.Frame1.Controls.Add(Me.Label8)
        Me.Frame1.Controls.Add(Me.Label7)
        Me.Frame1.Controls.Add(Me.Label6)
        Me.Frame1.Controls.Add(Me.Label4)
        Me.Frame1.Controls.Add(Me.Button_IntStop)
        Me.Frame1.Controls.Add(Me.GroupBox1)
        Me.Frame1.Controls.Add(Me.Button_IntStart)
        Me.Frame1.Controls.Add(Me.Edit_Down_3)
        Me.Frame1.Controls.Add(Me.Edit_Down_2)
        Me.Frame1.Controls.Add(Me.Edit_Down_1)
        Me.Frame1.Controls.Add(Me.Edit_Down_0)
        Me.Frame1.Controls.Add(Me.Edit_Up_3)
        Me.Frame1.Controls.Add(Me.Edit_Up_2)
        Me.Frame1.Controls.Add(Me.Edit_Up_1)
        Me.Frame1.Controls.Add(Me.Edit_Up_0)
        Me.Frame1.Controls.Add(Me.Label3)
        Me.Frame1.Controls.Add(Me.Label2)
        Me.Frame1.ForeColor = System.Drawing.SystemColors.ControlText
        Me.Frame1.Location = New System.Drawing.Point(8, 70)
        Me.Frame1.Name = "Frame1"
        Me.Frame1.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.Frame1.Size = New System.Drawing.Size(488, 193)
        Me.Frame1.TabIndex = 13
        Me.Frame1.TabStop = False
        Me.Frame1.Text = "Trigger Monitor"
        '
        'Label8
        '
        Me.Label8.Location = New System.Drawing.Point(240, 21)
        Me.Label8.Name = "Label8"
        Me.Label8.Size = New System.Drawing.Size(12, 19)
        Me.Label8.TabIndex = 36
        Me.Label8.Text = "3"
        '
        'Label7
        '
        Me.Label7.Location = New System.Drawing.Point(200, 21)
        Me.Label7.Name = "Label7"
        Me.Label7.Size = New System.Drawing.Size(12, 19)
        Me.Label7.TabIndex = 35
        Me.Label7.Text = "2"
        '
        'Label6
        '
        Me.Label6.Location = New System.Drawing.Point(160, 21)
        Me.Label6.Name = "Label6"
        Me.Label6.Size = New System.Drawing.Size(8, 19)
        Me.Label6.TabIndex = 34
        Me.Label6.Text = "1"
        '
        'Label4
        '
        Me.Label4.Location = New System.Drawing.Point(120, 21)
        Me.Label4.Name = "Label4"
        Me.Label4.Size = New System.Drawing.Size(12, 19)
        Me.Label4.TabIndex = 33
        Me.Label4.Text = "0"
        '
        'Button_IntStop
        '
        Me.Button_IntStop.BackColor = System.Drawing.SystemColors.Control
        Me.Button_IntStop.Cursor = System.Windows.Forms.Cursors.Default
        Me.Button_IntStop.ForeColor = System.Drawing.SystemColors.ControlText
        Me.Button_IntStop.Location = New System.Drawing.Point(344, 160)
        Me.Button_IntStop.Name = "Button_IntStop"
        Me.Button_IntStop.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.Button_IntStop.Size = New System.Drawing.Size(113, 25)
        Me.Button_IntStop.TabIndex = 13
        Me.Button_IntStop.Text = "Stop Interrupt"
        Me.Button_IntStop.UseVisualStyleBackColor = False
        '
        'GroupBox1
        '
        Me.GroupBox1.Controls.Add(Me.Radio_Fall)
        Me.GroupBox1.Controls.Add(Me.Radio_Rise)
        Me.GroupBox1.Location = New System.Drawing.Point(296, 21)
        Me.GroupBox1.Name = "GroupBox1"
        Me.GroupBox1.Size = New System.Drawing.Size(176, 100)
        Me.GroupBox1.TabIndex = 11
        Me.GroupBox1.TabStop = False
        Me.GroupBox1.Text = "Interrupt Logic"
        '
        'Radio_Fall
        '
        Me.Radio_Fall.Location = New System.Drawing.Point(16, 61)
        Me.Radio_Fall.Name = "Radio_Fall"
        Me.Radio_Fall.Size = New System.Drawing.Size(128, 19)
        Me.Radio_Fall.TabIndex = 11
        Me.Radio_Fall.Text = "1 -> 0 (Falling edge)"
        '
        'Radio_Rise
        '
        Me.Radio_Rise.Checked = True
        Me.Radio_Rise.Location = New System.Drawing.Point(16, 30)
        Me.Radio_Rise.Name = "Radio_Rise"
        Me.Radio_Rise.Size = New System.Drawing.Size(128, 21)
        Me.Radio_Rise.TabIndex = 10
        Me.Radio_Rise.TabStop = True
        Me.Radio_Rise.Text = "0 -> 1 (Rising edge)"
        '
        'Button_IntStart
        '
        Me.Button_IntStart.BackColor = System.Drawing.SystemColors.Control
        Me.Button_IntStart.Cursor = System.Windows.Forms.Cursors.Default
        Me.Button_IntStart.ForeColor = System.Drawing.SystemColors.ControlText
        Me.Button_IntStart.Location = New System.Drawing.Point(344, 129)
        Me.Button_IntStart.Name = "Button_IntStart"
        Me.Button_IntStart.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.Button_IntStart.Size = New System.Drawing.Size(113, 25)
        Me.Button_IntStart.TabIndex = 12
        Me.Button_IntStart.Text = "Start Interrupt"
        Me.Button_IntStart.UseVisualStyleBackColor = False
        '
        'Edit_Down_3
        '
        Me.Edit_Down_3.AcceptsReturn = True
        Me.Edit_Down_3.BackColor = System.Drawing.SystemColors.Window
        Me.Edit_Down_3.Cursor = System.Windows.Forms.Cursors.IBeam
        Me.Edit_Down_3.ForeColor = System.Drawing.SystemColors.WindowText
        Me.Edit_Down_3.Location = New System.Drawing.Point(224, 80)
        Me.Edit_Down_3.MaxLength = 0
        Me.Edit_Down_3.Name = "Edit_Down_3"
        Me.Edit_Down_3.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.Edit_Down_3.Size = New System.Drawing.Size(39, 26)
        Me.Edit_Down_3.TabIndex = 9
        Me.Edit_Down_3.Text = "Edit"
        Me.Edit_Down_3.TextAlign = System.Windows.Forms.HorizontalAlignment.Right
        '
        'Edit_Down_2
        '
        Me.Edit_Down_2.AcceptsReturn = True
        Me.Edit_Down_2.BackColor = System.Drawing.SystemColors.Window
        Me.Edit_Down_2.Cursor = System.Windows.Forms.Cursors.IBeam
        Me.Edit_Down_2.ForeColor = System.Drawing.SystemColors.WindowText
        Me.Edit_Down_2.Location = New System.Drawing.Point(184, 80)
        Me.Edit_Down_2.MaxLength = 0
        Me.Edit_Down_2.Name = "Edit_Down_2"
        Me.Edit_Down_2.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.Edit_Down_2.Size = New System.Drawing.Size(39, 26)
        Me.Edit_Down_2.TabIndex = 8
        Me.Edit_Down_2.Text = "Edit"
        Me.Edit_Down_2.TextAlign = System.Windows.Forms.HorizontalAlignment.Right
        '
        'Edit_Down_1
        '
        Me.Edit_Down_1.AcceptsReturn = True
        Me.Edit_Down_1.BackColor = System.Drawing.SystemColors.Window
        Me.Edit_Down_1.Cursor = System.Windows.Forms.Cursors.IBeam
        Me.Edit_Down_1.ForeColor = System.Drawing.SystemColors.WindowText
        Me.Edit_Down_1.Location = New System.Drawing.Point(144, 80)
        Me.Edit_Down_1.MaxLength = 0
        Me.Edit_Down_1.Name = "Edit_Down_1"
        Me.Edit_Down_1.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.Edit_Down_1.Size = New System.Drawing.Size(39, 26)
        Me.Edit_Down_1.TabIndex = 7
        Me.Edit_Down_1.Text = "Edit"
        Me.Edit_Down_1.TextAlign = System.Windows.Forms.HorizontalAlignment.Right
        '
        'Edit_Down_0
        '
        Me.Edit_Down_0.AcceptsReturn = True
        Me.Edit_Down_0.BackColor = System.Drawing.SystemColors.Window
        Me.Edit_Down_0.Cursor = System.Windows.Forms.Cursors.IBeam
        Me.Edit_Down_0.ForeColor = System.Drawing.SystemColors.WindowText
        Me.Edit_Down_0.Location = New System.Drawing.Point(104, 80)
        Me.Edit_Down_0.MaxLength = 0
        Me.Edit_Down_0.Name = "Edit_Down_0"
        Me.Edit_Down_0.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.Edit_Down_0.Size = New System.Drawing.Size(39, 26)
        Me.Edit_Down_0.TabIndex = 6
        Me.Edit_Down_0.Text = "Edit"
        Me.Edit_Down_0.TextAlign = System.Windows.Forms.HorizontalAlignment.Right
        '
        'Edit_Up_3
        '
        Me.Edit_Up_3.AcceptsReturn = True
        Me.Edit_Up_3.BackColor = System.Drawing.SystemColors.Window
        Me.Edit_Up_3.Cursor = System.Windows.Forms.Cursors.IBeam
        Me.Edit_Up_3.ForeColor = System.Drawing.SystemColors.WindowText
        Me.Edit_Up_3.Location = New System.Drawing.Point(224, 40)
        Me.Edit_Up_3.MaxLength = 0
        Me.Edit_Up_3.Name = "Edit_Up_3"
        Me.Edit_Up_3.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.Edit_Up_3.Size = New System.Drawing.Size(39, 25)
        Me.Edit_Up_3.TabIndex = 5
        Me.Edit_Up_3.Text = "Edit"
        Me.Edit_Up_3.TextAlign = System.Windows.Forms.HorizontalAlignment.Right
        '
        'Edit_Up_2
        '
        Me.Edit_Up_2.AcceptsReturn = True
        Me.Edit_Up_2.BackColor = System.Drawing.SystemColors.Window
        Me.Edit_Up_2.Cursor = System.Windows.Forms.Cursors.IBeam
        Me.Edit_Up_2.ForeColor = System.Drawing.SystemColors.WindowText
        Me.Edit_Up_2.Location = New System.Drawing.Point(184, 40)
        Me.Edit_Up_2.MaxLength = 0
        Me.Edit_Up_2.Name = "Edit_Up_2"
        Me.Edit_Up_2.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.Edit_Up_2.Size = New System.Drawing.Size(39, 25)
        Me.Edit_Up_2.TabIndex = 4
        Me.Edit_Up_2.Text = "Edit"
        Me.Edit_Up_2.TextAlign = System.Windows.Forms.HorizontalAlignment.Right
        '
        'Edit_Up_1
        '
        Me.Edit_Up_1.AcceptsReturn = True
        Me.Edit_Up_1.BackColor = System.Drawing.SystemColors.Window
        Me.Edit_Up_1.Cursor = System.Windows.Forms.Cursors.IBeam
        Me.Edit_Up_1.ForeColor = System.Drawing.SystemColors.WindowText
        Me.Edit_Up_1.Location = New System.Drawing.Point(144, 40)
        Me.Edit_Up_1.MaxLength = 0
        Me.Edit_Up_1.Name = "Edit_Up_1"
        Me.Edit_Up_1.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.Edit_Up_1.Size = New System.Drawing.Size(39, 25)
        Me.Edit_Up_1.TabIndex = 3
        Me.Edit_Up_1.Text = "Edit"
        Me.Edit_Up_1.TextAlign = System.Windows.Forms.HorizontalAlignment.Right
        '
        'Edit_Up_0
        '
        Me.Edit_Up_0.AcceptsReturn = True
        Me.Edit_Up_0.BackColor = System.Drawing.SystemColors.Window
        Me.Edit_Up_0.Cursor = System.Windows.Forms.Cursors.IBeam
        Me.Edit_Up_0.ForeColor = System.Drawing.SystemColors.WindowText
        Me.Edit_Up_0.Location = New System.Drawing.Point(104, 40)
        Me.Edit_Up_0.MaxLength = 0
        Me.Edit_Up_0.Name = "Edit_Up_0"
        Me.Edit_Up_0.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.Edit_Up_0.Size = New System.Drawing.Size(39, 25)
        Me.Edit_Up_0.TabIndex = 2
        Me.Edit_Up_0.Text = "Edit"
        Me.Edit_Up_0.TextAlign = System.Windows.Forms.HorizontalAlignment.Right
        '
        'Label3
        '
        Me.Label3.BackColor = System.Drawing.SystemColors.Control
        Me.Label3.Cursor = System.Windows.Forms.Cursors.Default
        Me.Label3.ForeColor = System.Drawing.SystemColors.ControlText
        Me.Label3.Location = New System.Drawing.Point(20, 80)
        Me.Label3.Name = "Label3"
        Me.Label3.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.Label3.Size = New System.Drawing.Size(84, 21)
        Me.Label3.TabIndex = 30
        Me.Label3.Text = "Down-count :"
        '
        'Label2
        '
        Me.Label2.BackColor = System.Drawing.SystemColors.Control
        Me.Label2.Cursor = System.Windows.Forms.Cursors.Default
        Me.Label2.ForeColor = System.Drawing.SystemColors.ControlText
        Me.Label2.Location = New System.Drawing.Point(20, 40)
        Me.Label2.Name = "Label2"
        Me.Label2.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.Label2.Size = New System.Drawing.Size(64, 21)
        Me.Label2.TabIndex = 29
        Me.Label2.Text = "Up-count :"
        '
        'Button_DioInit
        '
        Me.Button_DioInit.BackColor = System.Drawing.SystemColors.Control
        Me.Button_DioInit.Cursor = System.Windows.Forms.Cursors.Default
        Me.Button_DioInit.ForeColor = System.Drawing.SystemColors.ControlText
        Me.Button_DioInit.Location = New System.Drawing.Point(352, 30)
        Me.Button_DioInit.Name = "Button_DioInit"
        Me.Button_DioInit.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.Button_DioInit.Size = New System.Drawing.Size(113, 25)
        Me.Button_DioInit.TabIndex = 1
        Me.Button_DioInit.Text = "DioInit"
        Me.Button_DioInit.UseVisualStyleBackColor = False
        '
        'Edit_DeviceName
        '
        Me.Edit_DeviceName.AcceptsReturn = True
        Me.Edit_DeviceName.BackColor = System.Drawing.SystemColors.Window
        Me.Edit_DeviceName.Cursor = System.Windows.Forms.Cursors.IBeam
        Me.Edit_DeviceName.ForeColor = System.Drawing.SystemColors.WindowText
        Me.Edit_DeviceName.Location = New System.Drawing.Point(104, 30)
        Me.Edit_DeviceName.MaxLength = 0
        Me.Edit_DeviceName.Name = "Edit_DeviceName"
        Me.Edit_DeviceName.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.Edit_DeviceName.Size = New System.Drawing.Size(97, 23)
        Me.Edit_DeviceName.TabIndex = 0
        Me.Edit_DeviceName.Text = "Edit"
        '
        'Label5
        '
        Me.Label5.BackColor = System.Drawing.SystemColors.Control
        Me.Label5.Cursor = System.Windows.Forms.Cursors.Default
        Me.Label5.ForeColor = System.Drawing.SystemColors.ControlText
        Me.Label5.Location = New System.Drawing.Point(13, 283)
        Me.Label5.Name = "Label5"
        Me.Label5.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.Label5.Size = New System.Drawing.Size(83, 19)
        Me.Label5.TabIndex = 35
        Me.Label5.Text = "Return Code :"
        '
        'Label1
        '
        Me.Label1.BackColor = System.Drawing.SystemColors.Control
        Me.Label1.Cursor = System.Windows.Forms.Cursors.Default
        Me.Label1.ForeColor = System.Drawing.SystemColors.ControlText
        Me.Label1.Location = New System.Drawing.Point(16, 30)
        Me.Label1.Name = "Label1"
        Me.Label1.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.Label1.Size = New System.Drawing.Size(80, 22)
        Me.Label1.TabIndex = 1
        Me.Label1.Text = "Device Name:"
        '
        'Interrupt
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.ClientSize = New System.Drawing.Size(512, 348)
        Me.Controls.Add(Me.Edit_ReturnCode)
        Me.Controls.Add(Me.Button_DioExit)
        Me.Controls.Add(Me.Button_Exit)
        Me.Controls.Add(Me.Frame1)
        Me.Controls.Add(Me.Button_DioInit)
        Me.Controls.Add(Me.Edit_DeviceName)
        Me.Controls.Add(Me.Label5)
        Me.Controls.Add(Me.Label1)
        Me.Location = New System.Drawing.Point(4, 23)
        Me.MaximizeBox = False
        Me.MinimizeBox = False
        Me.Name = "Interrupt"
        Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
        Me.Text = "Interrupt"
        Me.Frame1.ResumeLayout(False)
        Me.GroupBox1.ResumeLayout(False)
        Me.ResumeLayout(False)

    End Sub
#End Region

    Dim Id As Short                     'Device ID
    Dim Ret As Integer                  'Return code
    Dim szError As New StringBuilder("", 256)
    Dim UpCount(4) As Short             'Up counter
    Dim DownCount(4) As Short           'Down counter
    Dim Edit_Up(4) As TextBox
    Dim Edit_Down(4) As TextBox

    '=========================================================
    ' Dialog initialization
    '=========================================================
    Private Sub Interrupt_Load(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles MyBase.Load

        Dim i As Short

        Me.Left = (Screen.PrimaryScreen.Bounds.Width - Me.Width) / 2
        Me.Top = (Screen.PrimaryScreen.Bounds.Height - Me.Height) / 2

        Edit_Up(0) = Edit_Up_0
        Edit_Up(1) = Edit_Up_1
        Edit_Up(2) = Edit_Up_2
        Edit_Up(3) = Edit_Up_3

        Edit_Down(0) = Edit_Down_0
        Edit_Down(1) = Edit_Down_1
        Edit_Down(2) = Edit_Down_2
        Edit_Down(3) = Edit_Down_3

        '--------------------------------------
        ' Screen item initialization
        '--------------------------------------
        Edit_DeviceName.Text = "DIO000"
        Edit_ReturnCode.Text = ""
        'Up counter
        For i = 0 To 3
            Edit_Up(i).Text = ""
        Next i
        'Down counter
        For i = 0 To 3
            Edit_Down(i).Text = ""
        Next i
        Radio_Rise.Checked = True
        Edit_ReturnCode.Text = ""

    End Sub

    '=========================================================
    ' DioInit()
    '=========================================================
    Private Sub Button_DioInit_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Button_DioInit.Click

        Dim szDeviceName As String

        '--------------------------------------
        ' Get device name from screen
        '--------------------------------------
        szDeviceName = Edit_DeviceName.Text
        '--------------------------------------
        ' Execute initialization function and get ID
        '--------------------------------------
        Ret = DioInit(szDeviceName, Id)
        '--------------------------------------
        ' Error process
        '--------------------------------------
        Call DioGetErrorString(Ret, szError)
        Edit_ReturnCode.Text = "DioInit Ret = " & Ret & ":" & szError.ToString()
    End Sub

    '=========================================================
    ' Interrupt observe start
    '=========================================================
    Private Sub Button_IntStart_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Button_IntStart.Click

        Dim i As Short
        Dim BitNo As Short
        Dim Kind As Short

        '--------------------------------------
        ' Parameters initialization
        '--------------------------------------
        For i = 0 To 3
            UpCount(i) = 0                      'Up counter
            DownCount(i) = 0                    'Down counter
        Next i
        If Radio_Rise.Checked = True Then
            Kind = DIO_INT_RISE
        Else
            Kind = DIO_INT_FALL
        End If
        '--------------------------------------
        ' Interrupt start
        '--------------------------------------
        For BitNo = 0 To 3
            '--------------------------------------
            ' Set interrupt event
            '--------------------------------------
            Ret = DioNotifyInterrupt(Id, BitNo, Kind, Me.Handle)
            If (Ret <> DIO_ERR_SUCCESS) Then
                Exit For
            End If
        Next BitNo
        '--------------------------------------
        ' Error process
        '--------------------------------------
        Call DioGetErrorString(Ret, szError)
        Edit_ReturnCode.Text = "DioNotifyInterrupt Ret = " & Ret & ":" & szError.ToString()

    End Sub

    '=========================================================
    ' Interrupt observe stop
    '=========================================================
    Private Sub Button_IntStop_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button_IntStop.Click

        Dim BitNo As Short

        '--------------------------------------
        ' Interrupt stop
        '--------------------------------------
        For BitNo = 0 To 3
            '--------------------------------------
            ' Set interrupt event
            '--------------------------------------
            Ret = DioNotifyInterrupt(Id, BitNo, DIO_INT_NONE, Me.Handle)
            If (Ret <> DIO_ERR_SUCCESS) Then
                Exit For
            End If
        Next BitNo
        '--------------------------------------
        ' Error process
        '--------------------------------------
        Call DioGetErrorString(Ret, szError)
        Edit_ReturnCode.Text = "DioNotifyInterrupt Ret = " & Ret & ":" & szError.ToString()

    End Sub

    '=========================================================
    ' DioExit()
    '=========================================================
    Private Sub Button_DioExit_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Button_DioExit.Click

        '--------------------------------------
        ' DioExit()
        '--------------------------------------
        Ret = DioExit(Id)
        '--------------------------------------
        ' Error process
        '--------------------------------------
        Call DioGetErrorString(Ret, szError)
        Edit_ReturnCode.Text = "DioExit Ret = " & Ret & ":" & szError.ToString()

    End Sub

    '=========================================================
    ' Dialog exit
    '=========================================================
    Private Sub Button_Exit_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Button_Exit.Click

        '--------------------------------------
        ' DioExit
        '--------------------------------------
        Ret = DioExit(Id)
        '--------------------------------------
        ' Dialog exit
        '--------------------------------------
        End
    End Sub

    '=========================================================
    ' Subroutine: Get HIWORD,LOWORD
    '=========================================================
    Function HiLoWord(ByRef Number As Integer, ByRef HiLo As Short) As Integer

        Dim Hi As Integer
        Dim Lo As Integer
        Dim StrData As String
        Dim i As Short

        StrData = Hex(Number)
        If Len(StrData) < 8 Then
            For i = 1 To 8 - Len(StrData)
                StrData = "0" & StrData
            Next i
        End If

        Lo = Val("&h" & VB.Right(StrData, 4))
        Hi = Val("&h" & VB.Left(StrData, 4))
        If HiLo = 0 Then
            HiLoWord = Lo
        ElseIf HiLo = 1 Then
            HiLoWord = Hi
        End If

    End Function

    '=========================================================
    ' Message handler
    '=========================================================
    Protected Overrides Sub WndProc(ByRef m As Message)
        Dim BitNo As Short
        Dim Id As Short
        Dim Kind As Short

        '--------------------------------------
        ' Interrupt message
        '--------------------------------------
        If m.Msg = DIOM_INTERRUPT Then

            Id = HiLoWord(m.WParam.ToInt32(), 0)             'ID getted from DioInit function
            BitNo = HiLoWord(m.LParam.ToInt32(), 0)          'Interrupt BitNo
            Kind = HiLoWord(m.LParam.ToInt32(), 1)           'Rise:1, Fall:2

            If (Kind And DIO_INT_RISE) Then
                UpCount(BitNo) = UpCount(BitNo) + 1          'Up counter
            End If
            If (Kind And DIO_INT_FALL) Then
                DownCount(BitNo) = DownCount(BitNo) + 1      'Down counter
            End If
            '--------------------------------------
            ' Expression
            '--------------------------------------
            Edit_Up(BitNo).Text = CStr(UpCount(BitNo))
            Edit_Down(BitNo).Text = CStr(DownCount(BitNo))
        End If

        MyBase.WndProc(m)
    End Sub
End Class