📄 modmain.bas
字号:
Attribute VB_Name = "modMain"
'Uncoment to enter full debug mode
'#Const FullDebugMode = 1
'Uncomment to enter ADI Mode
Public AdiMode As Boolean
Public iDecSep As Integer
Public sDecSep As String
Public iNegSign As Integer
Public sNegSign As String
Public TestMode As Integer
Public strCmdLineArgs As String
Public EvalBd As cls9859EVBD
Public DUT1_CFR2 As String
Public DUT2_CFR2 As String
Public DUT1_Installed As Boolean
Public DUT2_Installed As Boolean
Public DUT1_RAM(0 To 1023) As String 'String array to hold DUT1's RAM Values
Public DUT2_RAM(0 To 1023) As String 'String array to hold DUT2's RAM Values
Public FlashOnColor As Long
Public NormalColor As Long
'Setup a constant that points to the register that this form addresses
Global Const CFR1 = &H0
Global Const CFR2 = &H1
Global Const ASF = &H2
Global Const ARR = &H3
Global Const FTW0 = &H4
Global Const POW0 = &H5
Global Const FTW1 = &H6
Global Const RSCW0 = &H7
Global Const RSCW1 = &H8
Global Const RSCW2 = &H9
Global Const RSCW3 = &HA
Global Const RAM = &HB
Global Const TR = &HC
Public frmRAMEditor As Form
Public EditFileName As String
Public HardwareOnlyReset As Boolean
'Ramsegment control word structure
Private Type RSCWInfo
BeginAddr As Integer
FinalAddr As Integer
NoDwell As Integer
AddressRampRate As Long
ModeControl As Integer
End Type
Public MainWindowTitle As String
Public Sub Main()
Dim CurInstanceHwnd As Long
Dim TestValue As String
Dim ReadValue As String
Dim cntr As Integer
Dim EvalBdDetected As Integer
Dim NumOfDUTsDetected As Integer
' Dim EvBdDetected As Boolean
'Support XP Themes using a manafest file
'EnableXPThemes
'Setup the internationalization class
Dim LocaleInfo As adiLocaleInfo
Set LocaleInfo = New adiLocaleInfo
'Do only hardware resets on startup
HardwareOnlyReset = True
'Get Locale Infomation
sDecSep = LocaleInfo.GetLocaleInfo(adiDecimalSep)
iDecSep = Asc(sDecSep)
sNegSign = LocaleInfo.GetLocaleInfo(adiNegativeSign)
iNegSign = Asc(sDecSep)
Set LocaleInfo = Nothing
'Assign values to variables
FlashOnColor = RGB(0, 255, 0)
NormalColor = vb3DFace
'Get the command line arguments
strCmdLineArgs = UCase(Command())
'set the main window title
MainWindowTitle = App.Title & " Rev " & App.Major & "." & App.Minor & "." & App.Revision
'Activate the currently running instance
CurInstanceHwnd = FindWindow("ThunderMDIForm", MainWindowTitle)
'If the program is already running then quit now!!!
If App.PrevInstance = True Or CurInstanceHwnd <> 0 Then
'If the window is minimized
If IsIconic(CurInstanceHwnd) Then
'Then unminimize it
Call OpenIcon(CurInstanceHwnd)
End If
'Activate the application
' AppActivate MainFrmCaption
Call SetForegroundWindow(CurInstanceHwnd)
'Exit the program before doing anything
End
End If
'Initialize the RAM Arrays
For cntr = 0 To 1023
DUT1_RAM(cntr) = "00000000000000000000000000000000"
DUT2_RAM(cntr) = "00000000000000000000000000000000"
Next cntr
'Load and show the splash screen
Load frmSplash
'frmSplash.Height = 0
frmSplash.Width = 0
frmSplash.Show
'frmSplash.Top = frmSplash.Top - 4245 / 2
'frmSplash.Left = frmSplash.Left - 7380 / 2
'Make the window the topmost window
' MakeTopMost frmSplash, True
MakeFormModeless frmSplash, mdiMain.hWnd
With frmSplash
Do While .Width < 7380
'Resize by 16 pixels
If .Width + Screen.TwipsPerPixelX * 32 > 7380 Then
Exit Do
Else
.Width = .Width + Screen.TwipsPerPixelX * 32
'.Top = .Top - Screen.TwipsPerPixelY * 64
.Left = .Left - Screen.TwipsPerPixelX * 16
.Refresh
End If
'Allow windows to process events
'DoEvents
Delay 0.018, True
Loop
'.Height = 4245
'Finish centering the form
.Left = .Left - Screen.TwipsPerPixelX * 6
.Width = 7380
.Refresh
End With
'Show the splash form
' frmSplash.Show
'Make the splash form topmost
'MakeTopMost frmSplash, True
frmSplash.Refresh
'Load the other forms
frmSplash.AddStatLine "Attempting to load and start the device driver."
frmSplash.AddStatLine "This may take some time, please wait..."
Load frmLPTSelect
frmSplash.AddStatLine "The driver was successfully loaded and started."
frmSplash.AddStatLine "Detecting LPT Ports..."
Call frmLPTSelect.LPTSelectDialog("", "", False, 1)
frmSplash.AddStatLine "Found " & frmLPTSelect.LPTGetPortCount & " LPT Ports..."
frmSplash.AddStatLine "Loading Main Window..."
mdiMain.Show
'Load the Analog Logo window
Load frmMdiBack
'Center the form in the center of the client area of the mdi form
frmMdiBack.Left = (mdiMain.Width - frmMdiBack.Width) / 2
frmMdiBack.Top = (mdiMain.Height - frmMdiBack.Height - 1600) / 2
frmMdiBack.Show
'Create a global link to the evalboard
Set EvalBd = mdiMain.EvBd
frmSplash.AddStatLine "Loading Control Window..."
Load frmControl
' frmSplash.AddStatLine "Loading Configure Window..."
' Load frmConfigureDUT
' frmSplash.AddStatLine "Loading Toolbox Window..."
frmSplash.AddStatLine "Loading Frequency Window..."
Load frmFrequency
frmSplash.AddStatLine "Loading RAM Config Window..."
Load frmRAMConfig
frmSplash.AddStatLine "Loading Amplitude Window..."
Load frmAmplitude
frmSplash.AddStatLine "Loading DUT Signals Tool Window..."
Load frmDUTSignals
frmSplash.AddStatLine "Loading RAM File Editor Window..."
'Create a new instance of the edit ram window
Set frmRAMEditor = New frmEditRam
Load frmRAMEditor
'Detect the DUTS and options
frmSplash.AddStatLine "Detecting Eval Board, and DUT Types..."
'Find the evaluation Board
FindEvBoard NumOfDUTsDetected, EvalBdDetected, False
'Try and detect a DUT on each LPT port connected to the
' For cntr = 0 To frmLPTSelect.LPTGetPortCount() - 1
' 'Select the LPT port to test
' frmLPTSelect.LPTSelectPort cntr
' 'Sync up the PC and Eval Board
' EvalBd.InitEvalBoard
' 'Try to Detect the DUTs
' NumOfDUTsDetected = EvalBd.DetectDUTs
' EvBdDetected = EvalBd.DetectEvalBoard
' If NumOfDUTsDetected Or EvBdDetected Then
' EvalBdDetected = True
' Exit For
' End If
' Next cntr
'Display a status line of what was found
If EvalBdDetected <> -1 Then
frmSplash.AddStatLine " Evaluation Board found at LPT" & EvalBdDetected & "."
Else
frmSplash.txtStatus.ForeColor = RGB(255, 0, 0)
frmSplash.AddStatLine "Error: Evaluation Board Not Found!!!"
frmLPTSelect.LPTSelectPort 0 'Reselect LPT1
End If
Select Case NumOfDUTsDetected
Case 0:
'Display an error message
frmSplash.AddStatLine " DUT1: Not Installed!!!"
frmSplash.AddStatLine " DUT2: Not Installed!!!"
Case 1:
'Read the CFR2 register to detect the DUT
DUT1_CFR2 = EvalBd.SerialRead(1, &H1)
'Trimm off everything except the bond option bits
DUT1_CFR2 = Left(DUT1_CFR2, 8)
'Decode the bits for DUT1
frmSplash.AddStatLine " DUT1: " & GetProductString(DUT1_CFR2) & "."
mdiMain.stbStatusBar.Panels(2).Text = "DUT1: " & GetProductString(DUT1_CFR2) & "."
' Select Case DUT1_CFR2
' Case "00011010": 'Evaluation Product
' frmSplash.AddStatLine " DUT1: AD9954E." 'Evaluation Product"
' mdiMain.stbStatusBar.Panels(2).Text = "DUT1: AD9954E"
' Case "00000101": 'AD9859 - No Options,10 bit DAC
' frmSplash.AddStatLine " DUT1: AD9859."
' mdiMain.stbStatusBar.Panels(2).Text = "DUT1: AD9859"
' Case "00000100": 'AD9951 - No Options,14 bit DAC
' frmSplash.AddStatLine " DUT1: AD9951."
' mdiMain.stbStatusBar.Panels(2).Text = "DUT1: AD9951"
' Case "00000000": 'AD9952 - Comparator Active, 14 bit DAC
' frmSplash.AddStatLine " DUT1: AD9952."
' mdiMain.stbStatusBar.Panels(2).Text = "DUT1: AD9952"
' Case "00010100": 'AD9953 - RAM Active, 14 bit DAC
' frmSplash.AddStatLine " DUT1: AD9953."
' mdiMain.stbStatusBar.Panels(2).Text = "DUT1: AD9953"
' Case "00011000": 'AD9954 - All Options, 14 bit DAC
' frmSplash.AddStatLine " DUT1: AD9954."
' mdiMain.stbStatusBar.Panels(2).Text = "DUT1: AD9954"
' Case "00001100": 'AD80XXX - Linear Sweep, 14 Bit DAC
' frmSplash.AddStatLine " DUT1: AD80XXX."
' mdiMain.stbStatusBar.Panels(2).Text = "DUT1: AD80XXX"
' Case Else:
' frmSplash.AddStatLine " DUT1: Not Installed!!!"
' mdiMain.stbStatusBar.Panels(2).Text = "DUT1: Not Inst."
' End Select
frmSplash.AddStatLine " DUT2: Not Installed."
Case 2:
'Read the CFR2 register to detect the DUT
DUT2_CFR2 = EvalBd.SerialRead(2, &H1)
'Trimm off everything except the bond option bits
DUT2_CFR2 = Left(DUT2_CFR2, 8)
'Decode the bits for DUT2
frmSplash.AddStatLine " DUT2: " & GetProductString(DUT2_CFR2) & "."
mdiMain.stbStatusBar.Panels(3).Text = "DUT2: " & GetProductString(DUT2_CFR2) & "."
'Decode the bits for DUT2
' Select Case DUT2_CFR2
' Case "00011010": 'Evaluation Product
' frmSplash.AddStatLine " DUT2: AD9954E." 'Evaluation Product"
' mdiMain.stbStatusBar.Panels(3).Text = "DUT2: AD9954E"
' Case "00000101": 'AD9859 - No Options,10 bit DAC
' frmSplash.AddStatLine " DUT2: AD9859."
' mdiMain.stbStatusBar.Panels(3).Text = "DUT2: AD9859"
' Case "00000100": 'AD9951 - No Options,14 bit DAC
' frmSplash.AddStatLine " DUT2: AD9951."
' mdiMain.stbStatusBar.Panels(3).Text = "DUT2: AD9951"
' Case "00000000": 'AD9952 - Comparator Active, 14 bit DAC
' frmSplash.AddStatLine " DUT2: AD9952."
' mdiMain.stbStatusBar.Panels(3).Text = "DUT2: AD9952"
' Case "00010100": 'AD9953 - RAM Active, 14 bit DAC
' frmSplash.AddStatLine " DUT2: AD9953."
' mdiMain.stbStatusBar.Panels(3).Text = "DUT2: AD9953"
' Case "00011000": 'AD9954 - All Options, 14 bit DAC
' frmSplash.AddStatLine " DUT2: AD9954."
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -