Attribute VB_Name = "i7000u"
Option Explicit

'------------------------ Win32 API ---------------------------
Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Long) As Long
Declare Function GetTickCount Lib "kernel32" () As Long
Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Declare Function OpenFile Lib "kernel32" (ByVal lpFileName As String, lpReOpenBuff As OFSTRUCT, ByVal wStyle As Long) As Long
Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
Declare Function RealizePalette Lib "gdi32" (ByVal hdc As Long) As Long
Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Public Declare Function GetVersionEx Lib "kernel32" Alias "GetVersionExA" (lpVersionInformation As OSVERSIONINFO) As Boolean


'Public Const EM_LINESCROLL = &HB6
Public Declare Function SendMessageBynum Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long




Type OSVERSIONINFO
    dwOSVersionInfoSize As Long
    dwMajorVersion As Long
    dwMinorVersion As Long
    dwBuildNumber As Long
    dwPlatformId As Long
    szCSDVersion As String * 128
End Type

Public Const VER_PLATFORM_WIN32s = 0
Public Const VER_PLATFORM_WIN32_WINDOWS = 1
Public Const VER_PLATFORM_WIN32_NT = 2


Type SystemTime
 wYear As Integer
 wMonth As Integer
 wDayOfWeek As Integer
 wDay As Integer
 wHour As Integer
 wMinute As Integer
 wSecond As Integer
 wMilliseconds As Integer
End Type
Declare Sub GetLocalTime Lib "kernel32" (lpSystemTime As SystemTime)


'------------------------ Message ID ---------------------
Global Const WM_USER = &H400
Global Const EM_SETREADONLY = (WM_USER + 31)
Global Const EM_LINESCROLL = &HB6


Type ModuleConfigType
    FilterSetting     As Byte      ' 0:60Hz rejection, 1:50Hz rejection
    ModuleType        As String * 10
    OperationPrefix   As String * 10
    BaudRate          As Long
    ModuleAddress     As Integer
    InputRange        As Byte      ' 7080 for Counter and Frequence
    InputRange2       As Byte      ' for second channel of 7022
    InputRangeCode    As Byte      ' 7011, 7012, 7014  !aaTTccff   ->TT(Decimal)
    CheckSum          As Byte
    Format            As Byte      ' 7080 Freq mode, 0.1 or 1.0 seconds,
    SlewRate          As Byte      ' 7021 only
    SlewRate2         As Byte      ' for second channel of 7022
    Slot              As Byte      ' for 8000 Series
    ChannelSelect     As Integer   ' 7017, 7018 only
    DDEInit           As Integer
    LedChannel        As Integer   ' 7033 for LED channel
    DigitalInOutType  As Integer   ' 0:No  1:In  2:Out
                                     ' for 7080 use, Counter Gate Mode
                                     ' 0: Low,  1: High,  2: None
    DigitalOutData    As Integer   ' the data to output
    value             As Single    ' 7021 output value
    value2            As Single    ' for second channel of 7022
    '--- The following element is for 8024 ---
    OutputRange8024(0 To 3)  As Byte
    SlewRate8024(0 To 3)    As Byte
    Value8024(0 To 3)       As Single
    
    '--- The following element is for 7080 ---
    ModuleAlarmMode           As Integer
    CounterStatus(0 To 1)     As Integer
    CounterClearCount(0 To 1) As Integer
    CounterPresetCount(0 To 1) As Double
    CounterMaxCount(0 To 1)   As Double
    CounterAlarmState(0 To 1) As Integer
    CounterAlarmValue(0 To 1) As Double
    CounterSignalMode(0 To 1) As Integer
    CounterHighLevelVolt      As Single  '7011, 7012, 7014 High Alarm Limit Value
    CounterLowLevelVolt       As Single  '7011, 7012, 7014 Low Alarm Limit Value
    HighLevelMinWidth         As Long
    LowLevelMinWidth          As Long
End Type

Type DDENameType
    Service As String
    Topic   As String
    Item    As String
    Enabled As Integer
End Type

' Determining whether a file already exist, please see MSDN VB Tip 162
Public Const OFS_MAXPATHNAME = 128
Type OFSTRUCT
    cBytes     As Byte
    fFixedDisk As Byte
    nErrCode   As Integer
    Reserved1  As Integer
    Reserved2  As Integer
    szPathName(OFS_MAXPATHNAME) As Byte
End Type

Global ModuleConfig(0 To 1499) As ModuleConfigType  ' Max 1500 Module

Global ConvIndex As Integer
Global ChannelSelect7017 As Integer
Global gModuleType(0 To 15) As String * 6

Global SendTo7000 As String
Global ReceiveFrom7000  As String
Global SendTo8000 As String
Global ReceiveFrom8000  As String
Global dwBuf(0 To 11) As Long
Global w7000(0 To 11) As Integer
Global f7000(0 To 11) As Single
Global dw8000(0 To 11) As Long
Global f8000(0 To 11) As Single
Global fBuf(0 To 11) As Single
Global gPort     As Integer        ' the select COM Port
Global gBaudRateSelect As Integer  ' the select baudrateS
' Ex,   115200:1    57600:2   38400:4   19200:8
'        9600:16    4800:32   2400:64   1200:128
Global gChecksumSearch As Integer   ' 0: not to search   1: to search

Global gBaudRate As Long
Global gBaudrateCheck(0 To 10) As Byte
Global gSetupModuleIndex As Integer
Global gActiveCount As Integer
Global gFoundCount As Integer  ' How many module be found out

Global gValue As Single            '7021 Digital Output
Global gDigitalInOutType As Integer    'indicate digital In/Out 0:No, 1:In, 2:Out
Global gDigitalOutData As Integer  'the data to digital output
Global gRightButton
Global gStopSearch As Integer  ' form 4, decide to stop search module
Global gAutoSearch As Integer  ' form 4, auto search
Global gLastBaudRate As Long
Global gFirstTime As Integer
Global gOpenCount, gCloseCount  As Integer
Global gModuleInformation(0 To 255) As String * 80  ' stored the found out module information
Global gTimeoutTick As Integer
Global Const gconUtilityTitle As String = "7000 Utility"
Global Const gAboutTitle As String = "About 7000 Utility..."


