Attribute VB_Name = "ACQUIRE" '**************************************************************************************** ' ' File: ACQUIRE.BAS ' ' Author: Roberto Raso ' Date: 12th July 1994 ' '**************************************************************************************** ' ' Purpose: Provide a collection of MassLynx Acquire functions. ' '**************************************************************************************** '**************************************************************************************** ' ' Constant/Global declarations. ' '**************************************************************************************** Const IDM_ACQ_EXP = 400 Const IDM_ACQ_STOP = 401 Const IDM_ACQ_INS = 402 Const IDM_ACQ_EXIT = 403 Const IDM_ACQ_STATUS = 404 Const IDM_ACQ_START = 406 Const IDM_ACQ_CAL = 407 Const IDM_FILE_SAMPLES = 13 Const IDM_ACQU_STAT_HALT_SAMP = 410 Const IDM_ACQU_STAT_HALT_RUN = 411 Const IDM_ACQU_STAT_EXIT = 412 Const IDM_ACQU_STAT_ABOUT = 413 Const IDM_ACQU_MCA_DISPLAY = 414 Const IDM_ACQU_MCA_LOAD_ON_ACQ_START = 415 Const IDM_ACQU_STAT_LOAD_ON_ACQ_START = 416 Const IDM_ACQU_STAT_ALWAYS_ON_TOP = 417 'Const ID_SAMPLE_LIST_FORMAT = 1106 Const IDM_ACQU_PRINT = 420 Const IDM_ACQU_PRINTER = 421 Const IDM_ACQU_EXIT = 422 Const IDM_ACQU_ABOUT = 423 Const IDM_ACQU_INLET = 430 Const IDM_ACQU_AUTO_INJ = 431 Const IDM_ACQU_SCAN = 432 Const IDM_ACQU_TUNE = 433 Const IDM_ACQU_CHECK = 434 Const IDM_ACQU_LOGBOOK = 436 Const IDM_ACQU_START = 437 Const IDM_ACQU_SAMPLE = 438 Const IDM_ACQU_CONFIG = 439 Const IDM_ACQU_STATUS = 440 Const IDM_ACQU_STOP = 441 Const IDM_ACQU_USER = 442 Const IDM_ACQU_AUTOLOAD = 443 Const IDM_ACQU_THRESHOLD = 444 Const IDM_ACQU_AUTOTUNE = 445 Const IDM_ACQU_SAMPLES_EXIT = 1900 Const IDM_ACQU_SAMPLES_HELP = 1901 Const IDM_ACQU_SAMPLES_NEW = 1902 Const IDM_ACQU_SAMPLES_OPEN = 1903 Const IDM_ACQU_SAMPLES_SAVE = 1904 Const IDM_ACQU_SAMPLES_SAVE_AS = 1905 Const IDM_ACQU_SAMPLES_PRINT = 1906 Const IDM_ACQU_SAMPLES_PRINTER = 1907 Const IDM_ACQU_SAMPLES_EDIT = 1908 Const IDM_ACQU_SAMPLES_DELETE = 1909 Const IDM_ACQU_SAMPLES_INSERT = 1910 Const IDM_ACQU_SAMPLES_CHANGE = 1911 Const IDM_ACQU_SAMPLES_START = 1912 Const IDM_ACQU_SAMPLES_COPY = 1913 Const IDM_ACQU_SAMPLES_PASTE = 1914 Const IDM_ACQU_SAMPLES_FORMAT = 1915 Const IDM_ACQU_SAMPLES_PROPAGATE = 1916 Const IDM_ACQU_SAMPLES_OPTIONS_PROP = 1917 Const IDM_ACQU_SAMPLES_MS = 1918 Const IDM_ACQU_SAMPLES_INLET = 1919 Const IDM_ACQU_SAMPLES_AUTO = 1920 Const IDM_ACQU_SAMPLES_QUAN = 1921 Const IDM_ACQU_SAMPLES_INJ = 1922 Const IDM_TUNE_AUTOTUNE = 1715 Const IDM_TUNE_SOURCE_API_P = 1728 Const IDM_TUNE_SOURCE_API_N = 1729 Const IDM_TUNE_SOURCE_EI_P = 1730 Const IDM_TUNE_SOURCE_EI_N = 1731 Const IDM_TUNE_SOURCE_CI_P = 1732 Const IDM_TUNE_SOURCE_CI_N = 1733 Const IDM_TUNE_SOURCE_FAB_P = 1734 Const IDM_TUNE_SOURCE_FAB_N = 1735 Const IDM_TUNE_SOURCE_TSP_P = 1736 Const IDM_TUNE_SOURCE_TSP_N = 1737 Const IDM_TUNE_SOURCE_PSP_P = 1738 Const IDM_TUNE_SOURCE_PSP_N = 1739 Const IDM_TUNE_SOURCE_ESP_P = 1740 Const IDM_TUNE_SOURCE_ESP_N = 1741 Const ID_AUTOTUNE_START = 1002 Const ID_AUTOTUNE_STATIC = 605 Const ID_AUTOTUNE_SCAN = 606 Const ID_AUTOTUNE_SPEED = 607 Const IDM_ACQU_CALIBRATE = 435 Const ID_CALI_START = 311 Const IDC_ACQU_CAL_MODIFY_TIME = 313 Const IDC_ACQU_CAL_MODIFY_DATE = 314 Const ID_SAMPLE_LIST_APPEND = 1103 Const ID_SAMPLE_LIST_FIELDS = 1104 Const ID_SAMPLE_LIST_FIELDS_TEXT = 1105 Const ID_SAMPLE_LIST_FORMAT = 1106 Const ID_SAMPLE_LIST_FORMAT_TEXT = 1107 Const ID_SAMPLE_LIST_FORMAT_UPDATE = 1108 Const ID_SAMPLE_LIST_INSERT = 1109 Const ID_SAMPLE_LIST_JUST_BUTTON = 1110 Const ID_SAMPLE_LIST_REMOVE = 1111 Const ID_SAMPLE_LIST_REMOVE_ALL = 1112 Const ID_NUM_SAMPLES_NUM = 102 'AIScanStatus return values as constants. Global Const AI_NOT_SCANNING = 0 Global Const AI_SCANNING = 1 Global Const AI_WAIT_INLET_START = 2 Global Const AI_SOLVENT_DELAY = 3 Global Const AI_INLET_RUNNING = 4 Global Const AI_WAIT_INLET_STOP = 5 'Constants used by ConfigureAnalysis. Global Const ACQUIRE = 1 Global Const INTEGRATE = 2 Global Const Calibrate = 4 Global Const QUANTIFY = 8 Global Const QPRINT = 16 '**************************************************************************************** ' ' Data type declarations. ' '**************************************************************************************** '*** '*** MLIONMODE *** '*** MassLynx ionisation modes *** '*** Type MLIONMODE Num As Integer Text As String * 4 IDM As Long End Type '*** '*** DBASEDATA *** '*** Type DBASEDATA Field As String * 64 Value As String * 128 End Type '**************************************************************************************** ' ' Function declarations. ' '**************************************************************************************** Declare Function LCDADAcquisition Lib "ml_vb32.dll" Alias "_LCDADAcquisition@0" () As Integer '**************************************************************************************** ' ' Purpose: Start the instrument calibration facility. ' Using current calibration parameters. ' '**************************************************************************************** Function AcquCalibrate() As Integer Dim bCalOK As Integer Dim bCalInProc As Integer Dim hCtrlPanel As Long Dim hCalibrate As Long Dim hCaliStart As Long Dim hAcquStatus As Long Dim hInstCal As Long Dim wNumCals As Integer Dim wCurCal As Integer Dim dwMsgRtn As Long Dim lpCalibrateCaption As String Dim lpCaliStartCaption As String Dim lpAcquStatus As String Dim lpInstCal As String bCalOK = False wNumCals = 0 lpCaliStartCaption = "Automatic Calibration" lpAcquStatus = "Acquisition Status" lpInstCal = "Instrument Calibration" lpCalibrateCaption = CalibrateCaption() hCtrlPanel = AcquControlPanel() If hCtrlPanel Then hCalibrate = ProcessActive(lpCalibrateCaption) If hCalibrate = 0 Then dwMsgRtn = PostMessage(hCtrlPanel, WM_COMMAND, IDM_ACQU_CALIBRATE, 0) hCalibrate = WaitForProcessStart(lpCalibrateCaption, 10) End If If hCalibrate Then dwMsgRtn = PostMessage(hCalibrate, WM_COMMAND, ID_CALI_START, 0) hCaliStart = WaitForProcessStart(lpCaliStartCaption, 10) If hCaliStart Then If IsDlgButtonChecked(hCaliStart, ID_AUTOTUNE_STATIC) Then wNumCals = 1 End If If IsDlgButtonChecked(hCaliStart, ID_AUTOTUNE_SCAN) Then wNumCals = wNumCals + 1 End If If IsDlgButtonChecked(hCaliStart, ID_AUTOTUNE_SPEED) Then wNumCals = wNumCals + 1 End If dwMsgRtn = PostMessage(hCaliStart, WM_COMMAND, IDOK, 0) If wNumCals Then wCurCal = 1 Do While wCurCal <= wNumCals hAcquStatus = WaitForProcessStart(lpAcquStatus, 10) Call WaitForProcessEnd(lpAcquStatus) wCurCal = wCurCal + 1 Loop bCalInProc = IDYES Do While bCalInProc = IDYES hInstCal = WaitForProcessStart(lpInstCal, 30) If hInstCal = 0 Then bCalInProc = MsgBox("Calibration appears to be taking a long time." & Chr$(13) & Chr$(10) & "Continue Calibration?", 4, App.Title) Else bCalInProc = IDNO End If Loop If hInstCal Then If GetDlgItem32(hInstCal, IDOK) Then dwMsgRtn = PostMessage(hInstCal, WM_COMMAND, IDOK, 0) Call WaitForProcessEnd(lpInstCal) bCalOK = True Else dwMsgRtn = PostMessage(hInstCal, WM_COMMAND, IDCANCEL, 0) 'Call WaitForProcessEnd(lpInstCal) hInstCal = WaitForProcessStart(lpInstCal, 5) dwMsgRtn = PostMessage(hInstCal, WM_COMMAND, IDYES, 0) 'Call WaitForProcessEnd(lpInstCal) hInstCal = WaitForProcessStart(lpInstCal, 5) dwMsgRtn = PostMessage(hInstCal, WM_COMMAND, IDOK, 0) Call WaitForProcessEnd(lpInstCal) End If End If End If End If lpCalibrateCaption = CalibrateCaption() dwMsgRtn = StopProcess(lpCalibrateCaption) End If End If AcquCalibrate = bCalOK End Function '**************************************************************************************** ' ' Purpose: Calibrate the MS, if the calibration was successful then ' return value is True, ie if the calibration was updated. ' If the calibration was unsuccessful then the return value ' is false. ' '**************************************************************************************** Function AcquCaliNew() As Integer Dim bUpdated As Integer Dim hCtrlPanel As Long, hCali As Long, hAutoCali As Long Dim hDate As Long, hTime As Long Dim wBytes As Integer Dim dwMsgRtn As Long Dim lpCali As String, lpAutoCali As String Dim lpDate As String, lpTime As String Dim lpLstCal As Variant, lpCurCal As Variant bUpdated = False lpCali = "Calibrate" lpAutoCali = "Automatic calibration" hCtrlPanel = AcquControlPanel() If hCtrlPanel Then hCali = FindWindowCaption(lpCali) If hCali = 0 Then dwMsgRtn = PostMessage(hCtrlPanel, WM_COMMAND, IDM_ACQU_CALIBRATE, 0) hCali = WaitForWindow(lpCali, 5) End If If hCali Then hDate = GetDlgItem32(hCali, IDC_ACQU_CAL_MODIFY_DATE) hTime = GetDlgItem32(hCali, IDC_ACQU_CAL_MODIFY_TIME) lpDate = Space$(32) lpTime = Space$(32) wBytes = GetDlgItemText(hCali, 314, lpDate, Len(lpDate)) lpDate = Left$(lpDate, wBytes) wBytes = GetDlgItemText(hCali, 313, lpTime, Len(lpTime)) lpTime = Left$(lpTime, wBytes) If (Len(lpDate) > 0) And (Len(lpTime) > 0) Then lpLstCal = DateValue(lpDate) + TimeValue(lpTime) Else lpLstCal = "" End If dwMsgRtn = PostMessage(hCali, WM_COMMAND, ID_CALI_START, 0) hAutoCali = WaitForWindow(lpAutoCali, 2) If hAutoCali Then dwMsgRtn = PostMessage(hAutoCali, WM_COMMAND, IDOK, 0) Do While IsWindow(hCali) lpDate = Space$(32) lpTime = Space$(32) wBytes = GetDlgItemText(hCali, 314, lpDate, Len(lpDate)) lpDate = Left$(lpDate, wBytes) wBytes = GetDlgItemText(hCali, 313, lpTime, Len(lpTime)) lpTime = Left$(lpTime, wBytes) If (Len(lpDate) > 0) And (Len(lpTime) > 0) Then lpCurCal = DateValue(lpDate) + TimeValue(lpTime) Else lpCurCal = "" End If If lpCurCal <> lpLstCal Then bUpdated = True End If DoEvents Loop End If End If End If AcquCaliNew = bUpdated End Function '**************************************************************************************** ' ' Purpose: Start the acquisition control panel. ' Returns handle of Control Panel. ' Returns 0 if not started. ' '**************************************************************************************** Function AcquControlPanel() As Long Dim hWnd As Long Dim hCtrl As Long Dim dwMsgRtn As Long hWnd = MLAppActive(APP_ACQU) If hWnd Then AcquControlPanel = hWnd Else hWnd = ActivateML() dwMsgRtn = MassLynxCommand("app.launch[Instrument:ControlPanel]()", OPEN_WIN_TIMEOUT) hCtrl = WaitForMLApp(APP_ACQU, 30) If hCtrl Then Do Until IsWindowEnabled(hCtrl) DoEvents Loop End If AcquControlPanel = hCtrl End If End Function '**************************************************************************************** ' ' Purpose: Checks to see if data is actually being ' written to disk. Returns True if it is. ' ' '**************************************************************************************** Function AcquDataActive() As Integer Dim wAcquStatus As Integer Dim wRun As Integer wAcquStatus = AiScanStatus() Select Case wAcquStatus Case AI_NOT_SCANNING wRun = False Case AI_SCANNING wRun = True Case AI_WAIT_INLET_START wRun = False Case AI_SOLVENT_DELAY wRun = False Case AI_INLET_RUNNING wRun = True Case AI_WAIT_INLET_STOP wRun = False Case Else wRun = False End Select ' If DAD acquisition going do not process If LCDADAcquisition() Then wRun = True End If AcquDataActive = wRun End Function '**************************************************************************************** ' ' Process: AcquInlet ' ' Author: Roberto Raso ' Date: 29th September 1994 ' ' Purpose: Start the acquisition inlet editor. ' ' Parameters: None. ' ' Return: Void. ' '**************************************************************************************** Sub AcquInlet() Dim hAcquControl As Long Dim dwMsgRtn As Long hAcquControl = AcquControlPanel() If hAcquControl Then dwMsgRtn = SendMessage(hAcquControl, WM_COMMAND, IDM_ACQU_INLET, 0) End If End Sub '**************************************************************************************** ' ' Purpose: Set the instrument into operate or standby. ' If bOperate=True then OPERATE. ' If bOperate=FALSE then STANDBY. ' '**************************************************************************************** Sub AcquOperate(bOperate As Integer) Dim bChangeItem As Integer Dim hTune As Long Dim hMenu As Long Dim wChars As Integer Dim dwMsgRtn As Long Dim lpOperate As String Dim lpStandby As String Dim lpState As String * 80 Dim lpNewState As String * 80 lpOperate = "Opera" lpStandby = "Stand" hTune = AcquTune() If hTune Then hMenu = GetMenu(hTune) wChars = GetMenuString(hMenu, 1712, lpState, Len(lpState), MF_BYCOMMAND) lpNewState = lpState bChangeItem = ((bOperate <> 0) And (InStr(1, lpState, lpOperate, 1) > 0)) bChangeItem = bChangeItem Or ((Not (bOperate <> 0)) And (InStr(1, lpState, lpStandby, 1) > 0)) If bChangeItem Then dwMsgRtn = SendMessage(hTune, WM_COMMAND, 1712, 0) Do Until lpNewState <> lpState wChars = GetMenuString(hMenu, 1712, lpState, Len(lpState), MF_BYCOMMAND) DoEvents Loop End If End If End Sub '________________________________________________________________________________________ ' ' Process: AcquStop ' ' Author: Roberto Raso ' Date: 15th August 1995 ' ' Purpose: Stops the current acquisition. ' ' Parameters: dfTimeOut is the time to wait for the system to stop acquiring. ' Note: Use CDbl(CVDate("hh:mm:ss") to create dfTimeOut. ' ' Return: True if stopped. '________________________________________________________________________________________ Function AcquStop(dfTimeOut As Double) As Integer Dim hCtrlPanel As Long Dim nAIScanStatus As Integer Dim lMsgRtn As Long Dim dfIniTime As Double hCtrlPanel = AcquControlPanel() nAIScanStatus = AiScanStatus() If nAIScanStatus <> AI_NOT_SCANNING And hCtrlPanel <> 0 Then lMsgRtn = SendMessage(hCtrlPanel, WM_COMMAND, IDM_ACQ_STOP, 0) dfIniTime = CDbl(Now) If dfTimeOut <= 0 Then dfTimeOut = CDbl(CVDate("00:01:00")) End If Do While nAIScanStatus <> AI_NOT_SCANNING And CDbl(Now) < dfIniTime + dfTimeOut DoEvents nAIScanStatus = AiScanStatus() Loop If nAIScanStatus = AI_NOT_SCANNING Then AcquStop = True Else AcquStop = False End If ElseIf nAIScanStatus = AI_NOT_SCANNING Then AcquStop = True Else AcquStop = False End If End Function '**************************************************************************************** ' ' Purpose: Start the tune page, using the ' current ionisation mode. ' Returns handle of Tune window. ' Returns 0 if not started. ' '**************************************************************************************** Function AcquTune() As Long Dim hWnd As Long Dim hMenu As Long Dim hMsgBox As Long Dim dwMsgRtn As Long Dim lpTuneCaption As String Dim lpMsgBox As String lpMsgBox = "Tune" lpTuneCaption = AcquTuneCaption() hWnd = MLAppActive(APP_TUNE) If hWnd Then AcquTune = hWnd Else hWnd = AcquControlPanel() dwMsgRtn = MassLynxCommand("app.launch[Instrument:Tune]()", OPEN_WIN_TIMEOUT) DoEvents Do Until ProcessActive(lpMsgBox) Or MLAppActive(APP_TUNE) DoEvents Loop hMsgBox = ProcessActive(lpMsgBox) If hMsgBox Then dwMsgRtn = PostMessage(hMsgBox, WM_COMMAND, IDYES, 0) Call WaitForProcessEnd(lpMsgBox) End If hWnd = WaitForMLApp(APP_TUNE, 30) End If Do Until IsWindowEnabled(hWnd) DoEvents Loop AcquTune = hWnd End Function '**************************************************************************************** ' ' Purpose: Returns the current Tune window caption. ' '**************************************************************************************** Function AcquTuneCaption() As String Dim lpIonMode As String Dim lpTuneFile As String Dim lpMLIonModes() As MLIONMODE Call FillMLIonModes(lpMLIonModes()) lpIonMode = Trim$(lpMLIonModes(CInt(GetMLFileEntry("TUNE_DB") - 1)).Text) lpTuneFile = GetMLFileName("TUNE_DB") AcquTuneCaption = "Tune - [ " + lpTuneFile + " , " + lpIonMode + " ]" End Function '**************************************************************************************** ' ' Purpose: Exit from the tune page ' '**************************************************************************************** Sub AcquTuneExit() Dim hWnd As Long Dim dwMsgRtn As Long hWnd = MLAppActive(APP_TUNE) If hWnd Then dwMsgRtn = SendMessage(hWnd, WM_CLOSE, 0, 0) Do While MLAppActive(APP_TUNE) DoEvents Loop End If End Sub '**************************************************************************************** ' ' Purpose: Set tune page ionisation mode. ' '**************************************************************************************** Sub AcquTuneIonMode(lpIonMode As String) Dim hAcquTune As Long Dim wSetIonMode As Integer Dim wFirstIonMode As Integer Dim wLastIonMode As Integer Dim wStart As Integer Dim wLen As Integer Dim dwMsgRtn As Long Dim lpCurIonMode As String Dim lpCurCaption As String Dim lpSetIonMode As String Dim lpSetCaption As String Dim lpIonModes() As MLIONMODE Call FillMLIonModes(lpIonModes()) lpCurIonMode = Trim$(lpIonModes(CInt(GetMLFileEntry("TUNE_DB") - 1)).Text) lpCurCaption = AcquTuneCaption() wLen = Len(lpCurIonMode) wStart = InStr(1, lpCurCaption, lpCurIonMode) lpSetIonMode = Trim$(lpIonMode) lpSetCaption = lpCurCaption Mid$(lpSetCaption, wStart, wLen) = lpSetIonMode wFirstIonMode = LBound(lpIonModes) wLastIonMode = UBound(lpIonModes) For wSetIonMode = wFirstIonMode To wLastIonMode If lpSetIonMode = Trim$(lpIonModes(wSetIonMode).Text) Then Exit For End If Next wSetIonMode hAcquTune = AcquTune() If hAcquTune And (wSetIonMode <= wLastIonMode) Then dwMsgRtn = PostMessage(hAcquTune, WM_COMMAND, lpIonModes(wSetIonMode).IDM, 0) hAcquTune = WaitForProcessStart(lpSetCaption, 10) End If End Sub '**************************************************************************************** ' ' Purpose: Start the instrument AutoTune facility. ' Using current autotune parameters. ' '**************************************************************************************** Sub AutoTune() Dim hTune As Long Dim hAutoTune As Long Dim dwMsgRtn As Long Dim lpCaption As String lpCaption = "AutoTune" hTune = AcquTune() If hTune Then hAutoTune = ProcessActive(lpCaption) If hAutoTune = 0 Then dwMsgRtn = PostMessage(hTune, WM_COMMAND, IDM_TUNE_AUTOTUNE, 0) hAutoTune = WaitForProcessStart(lpCaption, 5) End If If hAutoTune Then dwMsgRtn = PostMessage(hAutoTune, WM_COMMAND, ID_AUTOTUNE_START, 0) Call WaitForProcessEnd(lpCaption) End If End If End Sub '**************************************************************************************** ' ' Purpose: Returns the current calibration window caption. ' '**************************************************************************************** Function CalibrateCaption() As String Dim lpSavedCaliFile As String lpSavedCaliFile = GetMLFileName("SavedCalibration") + "." + GetMLFileExt("SavedCalibration") CalibrateCaption = "Calibrate - [" + lpSavedCaliFile + "]" End Function '**************************************************************************************** ' ' Purpose: Start the instrument calibration facility. ' Using current calibration parameters. ' '**************************************************************************************** Sub CalibrateMS(idStatus As Control) idStatus.Caption = "MS Calibration" If AcquCalibrate() Then idStatus.Caption = "MS Calibration Completed" Else idStatus.Caption = "MS Calibration not Completed" End If End Sub '**************************************************************************************** ' ' Purpose: Configure how the sample list analysis ' is to be carried out. ' '**************************************************************************************** Function ConfigureAnalysis(wAcquMode As Integer) As Integer Dim hWnd As Long Dim wID As Long Dim wEnable As Long hWnd = WaitForProcessStart("Start Analysis of Sample List...", 10) If hWnd Then wID = 104 wEnable = ((wAcquMode And ACQUIRE) = ACQUIRE) Call CheckDlgButton32(hWnd, wID, wEnable) wID = 124 wEnable = ((wAcquMode And INTEGRATE) = INTEGRATE) 'SCR 501 David Varley 'Exit if dialog items not present. If DlgItemValidate(hWnd, wID) = 0 Then ConfigureAnalysis = hWnd Exit Function End If Call CheckDlgButton32(hWnd, wID, wEnable) wID = 141 wEnable = ((wAcquMode And Calibrate) = Calibrate) Call CheckDlgButton32(hWnd, wID, wEnable) wID = 106 wEnable = ((wAcquMode And QUANTIFY) = QUANTIFY) Call CheckDlgButton32(hWnd, wID, wEnable) wID = 122 wEnable = ((wAcquMode And QPRINT) = QPRINT) Call CheckDlgButton32(hWnd, wID, wEnable) ConfigureAnalysis = hWnd Else ConfigureAnalysis = False End If End Function '**************************************************************************************** ' ' Purpose: Configure the instrument inlet system. ' Note: For "[None]" use "(None)". ' '**************************************************************************************** Function ConfigureInlet(lpInstConfig As String) As Integer Dim hWnd As Long Dim dwMsgRtn As Long Dim lpCaption As String Dim lpConfig As String lpCaption = "Select Inlet" hWnd = ProcessActive(lpCaption) lpConfig = Trim$(lpInstConfig) If hWnd = 0 Then hWnd = AcquControlPanel() dwMsgRtn = PostMessage(hWnd, WM_COMMAND, IDM_ACQU_CONFIG, 0) hWnd = WaitForProcessStart(lpCaption, 10) End If If hWnd Then ConfigureInlet = CBoxSelString(hWnd, 101, lpConfig) dwMsgRtn = PostMessage(hWnd, WM_COMMAND, IDOK, 0) Else ConfigureInlet = False End If End Function '**************************************************************************************** ' ' Purpose: Set the sample list display format. ' '**************************************************************************************** Sub ConfigureSampleList(lpFormat() As String * 8) Dim hWnd As Long Dim hSampleList As Long Dim hFormat As Long Dim dwMsgRtn As Long Dim wLeftField As Integer Dim wCurField As Integer Dim wRightField As Integer Dim lpCaption As String Dim lpFormatCaption As String wLeftField = LBound(lpFormat) wRightField = UBound(lpFormat) lpCaption = SampleListCaption() lpFormatCaption = "Format Sample List" hSampleList = ProcessActive(lpCaption) If hSampleList = 0 Then hWnd = ActivateML() dwMsgRtn = PostMessage(hWnd, WM_COMMAND, IDM_FILE_SAMPLES, 0) hSampleList = WaitForProcessStart(lpCaption, 10) End If If hSampleList Then hFormat = ProcessActive(lpFormatCaption) If hFormat = 0 Then dwMsgRtn = PostMessage(hSampleList, WM_COMMAND, IDM_ACQU_SAMPLES_FORMAT, 0) hFormat = WaitForProcessStart(lpFormatCaption, 10) End If If hFormat Then dwMsgRtn = PostMessage(hFormat, WM_COMMAND, ID_SAMPLE_LIST_REMOVE_ALL, 0) For wCurField = wLeftField To wRightField dwMsgRtn = CBoxSelString(hFormat, ID_SAMPLE_LIST_FIELDS, Trim$(lpFormat(wCurField))) dwMsgRtn = PostMessage(hFormat, WM_COMMAND, ID_SAMPLE_LIST_APPEND, 0) Next wCurField dwMsgRtn = PostMessage(hFormat, WM_COMMAND, IDOK, 0) End If End If End Sub '**************************************************************************************** ' ' Purpose: Fill array with ion mode numbers and associated text. ' '**************************************************************************************** Sub FillMLIonModes(MLModes() As MLIONMODE) ReDim MLModes(11) MLModes(0).Num = 0 MLModes(0).Text = "EI+" MLModes(0).IDM = IDM_TUNE_SOURCE_EI_P MLModes(1).Num = 1 MLModes(1).Text = "EI-" MLModes(1).IDM = IDM_TUNE_SOURCE_EI_N MLModes(2).Num = 2 MLModes(2).Text = "CI+" MLModes(2).IDM = IDM_TUNE_SOURCE_CI_P MLModes(3).Num = 3 MLModes(3).Text = "CI-" MLModes(3).IDM = IDM_TUNE_SOURCE_CI_N MLModes(4).Num = 4 MLModes(4).Text = "FAB+" MLModes(4).IDM = IDM_TUNE_SOURCE_FAB_P MLModes(5).Num = 5 MLModes(5).Text = "FAB-" MLModes(5).IDM = IDM_TUNE_SOURCE_FAB_N MLModes(6).Num = 6 MLModes(6).Text = "TSP+" MLModes(6).IDM = IDM_TUNE_SOURCE_TSP_P MLModes(7).Num = 7 MLModes(7).Text = "TSP-" MLModes(7).IDM = IDM_TUNE_SOURCE_TSP_N MLModes(8).Num = 8 MLModes(8).Text = "ESP+" MLModes(8).IDM = IDM_TUNE_SOURCE_ESP_P MLModes(9).Num = 9 MLModes(9).Text = "ESP-" MLModes(9).IDM = IDM_TUNE_SOURCE_ESP_P MLModes(10).Num = 10 MLModes(10).Text = "API+" MLModes(10).IDM = IDM_TUNE_SOURCE_API_P MLModes(11).Num = 11 MLModes(11).Text = "API-" MLModes(11).IDM = IDM_TUNE_SOURCE_API_N End Sub '**************************************************************************************** ' ' Process: IonMode_Set ' ' Author: Roberto Raso ' Date: 16th December 1994 ' ' Purpose: Sets the current ionisation mode. ' ' Parameters: nModeEntry is the MassLynx ionistaion mode code. ' It starts from 1 and goes to 12, like the ' MASSLYNX.INI file entry. ' ' Return: Current ion mode range 1 to 12. ' '**************************************************************************************** Function IonMode_Set(nReqMode As Integer) As Integer Dim hTune As Long Dim nCurMode As Integer Dim n1st As Integer Dim nLst As Integer Dim lMsgRtn As Long Dim asMLIonMode() As MLIONMODE 'Valid ion modes are 0 to 11. nCurMode = CInt(GetMLFileEntry("TUNE_DB")) If nCurMode <> nReqMode Then Call FillMLIonModes(asMLIonMode()) n1st = LBound(asMLIonMode) nLst = UBound(asMLIonMode) hTune = AcquTune() If hTune And nReqMode - 1 >= n1st And nReqMode - 1 <= nLst Then lMsgRtn = SendMessage(hTune, WM_COMMAND, asMLIonMode(nReqMode - 1).IDM, 0) Do Until IsWindowEnabled(hTune) DoEvents Loop End If nCurMode = GetMLFileEntry("TUNE_DB") End If IonMode_Set = nCurMode End Function '**************************************************************************************** ' ' Purpose: Load the current sample's information ' into the current sample list. ' Order and number of fields must match sample list. ' Use ConfigureSampleList to set display format. ' '**************************************************************************************** Sub LoadSampleListEntry(lpSampInfo() As String * 32) Dim wLeftField As Integer Dim wCurField As Integer Dim wRightField As Integer wLeftField = LBound(lpSampInfo) wRightField = UBound(lpSampInfo) Debug.Print AcquControlPanel() SendKeys "%A", True DoEvents SendKeys "S", True DoEvents For wCurField = wLeftField To wRightField SendKeys Trim$(lpSampInfo(wCurField)), True SendKeys "{RIGHT}", True DoEvents Next wCurField End Sub '**************************************************************************************** ' ' Purpose: Create a new sample list. ' If the file exists the wOverWrite parameter needs to be set to TRUE. ' Functions returns TRUE if successful. ' '**************************************************************************************** Function NewSampleList(lpNewSampleListName As String, wOverWrite As Integer) As Integer Dim dwNumRecords As Integer Dim lpCurSampleList As String Dim lpNewSampleList As String Dim lpMLSLName As String lpCurSampleList = GetMLFileDir("SAMPLES_DB") + GetMLFileName("SAMPLES_DB") + DOS_EXT_SEP + GetMLFileExt("SAMPLES_DB") lpNewSampleList = GetMLFileDir("SAMPLES_DB") + Trim$(lpNewSampleListName) + DOS_EXT_SEP + GetMLFileExt("SAMPLES_DB") If lpCurSampleList <> lpNewSampleList Then If FileExists(lpNewSampleList) And wOverWrite Then Kill lpNewSampleList ElseIf FileExists(lpNewSampleList) Then NewSampleList = False Exit Function End If FileCopy lpCurSampleList, lpNewSampleList NewSampleList = True Else NewSampleList = False End If End Function '**************************************************************************************** ' ' Purpose: Open an existing sample list. ' '**************************************************************************************** Function OpenSampleListFile(lpSampleListName As String) As Integer Dim lpSampleList As String Dim lpCurSampleList As VGFILE If GetMLFileInfo("SAMPLES_DB", lpCurSampleList) Then hWnd = ProcessActive(SampleListCaption()) If hWnd Then wMsgRtn = StopProcess(SampleListCaption()) End If lpCurSampleList.szName = Trim$(lpSampleListName) + Chr$(0) OpenSampleListFile = SetGlobalFile(SYSPARAGRAPH, "SAMPLES_DB", lpCurSampleList, True) OpenSampleListFile = SampleList() End If End Function '**************************************************************************************** ' ' Purpose: Open current sample list. ' '**************************************************************************************** Function SampleList() As Integer Dim hWnd As Long Dim dwMsgRtn As Long hWnd = MLAppActive(APP_SAMPLE) If hWnd = 0 Then hWnd = ActivateML() dwMsgRtn = PostMessage(hWnd, WM_COMMAND, IDM_FILE_SAMPLES, 0) SampleList = WaitForMLApp(APP_SAMPLE, 30) Else SampleList = hWnd End If End Function '**************************************************************************************** ' ' Purpose: Gives the current sample list caption. ' '**************************************************************************************** Function SampleListCaption() As String Dim lpName As String Dim lpExt As String lpName = GetMLFileName("SAMPLES_DB") lpExt = GetMLFileExt("SAMPLES_DB") SampleListCaption = "Sample List - " + lpName + "." + lpExt End Function '**************************************************************************************** ' ' Purpose: Close current sample list. ' '**************************************************************************************** Sub SampleListClose() Dim hWnd As Long Dim hMsgBox As Long Dim dwMsgRtn As Long Dim lpCaption As String Dim lpCaptionMsgBox As String lpCaption = SampleListCaption() hWnd = ProcessActive(lpCaption) lpCaptionMsgBox = "Sample List" If hWnd Then dwMsgRtn = PostMessage(hWnd, WM_CLOSE, 0, 0) hMsgBox = WaitForProcessStart(lpCaptionMsgBox, 5) If hMsgBox Then dwMsgRtn = PostMessage(hMsgBox, WM_COMMAND, IDYES, 0) End If Call WaitForProcessEnd(lpCaption) End If End Sub '**************************************************************************************** ' ' Purpose: Set the number of samples to be acquired ' in the current sample list. ' '**************************************************************************************** Sub SampleListNumSamples(wNumSamps As Integer) Dim hWnd As Long Dim hNumSamps As Long Dim hNumSampsText As Long Dim hMsgBox As Long Dim dwMsgRtn As Long Dim lpNumSamps As String lpNumSamps = CStr(wNumSamps) hWnd = SampleList() If wNumSamps < 1 Then wNumSamps = 1 ElseIf wNumSamps > 300 Then wNumSamps = 300 End If If hWnd Then dwMsgRtn = PostMessage(hWnd, WM_COMMAND, IDM_ACQU_SAMPLES_CHANGE, 0) hNumSamps = WaitForProcessStart("Number Of Samples", 10) hNumSampsText = DlgItemValidate(hNumSamps, ID_NUM_SAMPLES_NUM) dwMsgRtn = SendMessageText(hNumSampsText, lpNumSamps) dwMsgRtn = PostMessage(hNumSamps, WM_COMMAND, IDOK, 0) hMsgBox = WaitForProcessStart("Acquire", 5) If hMsgBox Then dwMsgRtn = PostMessage(hMsgBox, WM_COMMAND, IDOK, 0) End If Call WaitForProcessEnd("Number Of Samples") End If End Sub '**************************************************************************************** ' ' Purpose: Save current sample list. ' Sample list must be active. ' '**************************************************************************************** Sub SaveSampleList() Dim hWnd As Long Dim hMenu As Long Dim wState As Integer Dim dwMsgRtn As Long hWnd = SampleList() hMenu = GetMenu(hWnd) wState = GetMenuState(hMenu, IDM_ACQU_SAMPLES_SAVE, MF_BYCOMMAND) If (Not ((wState And MF_GRAYED) = MF_GRAYED)) And hWnd Then dwMsgRtn = PostMessage(hWnd, WM_COMMAND, IDM_ACQU_SAMPLES_SAVE, 0) End If End Sub '**************************************************************************************** ' ' Process: SetSampMacCaption ' ' Author: Roberto Raso ' Date: 18th August 1994 ' ' Purpose: Sets the window caption for a sample sample list macro. ' Return: Sample number. ' '**************************************************************************************** Function SetSampMacCaption(hWnd) As Integer Dim b1stFound As Integer Dim hSample As Long Dim wLstSample As Integer Dim wCurSample As Integer Dim wNumSamples As Integer Dim lpSmapleList As String For wCurSample = 1 To wLstSample Next wCurSample End Function '**************************************************************************************** ' ' Purpose: Start current sample list. ' Sample list must be active. ' '**************************************************************************************** Function StartSampleList(wAcquMode As Integer) As Integer Dim hWnd As Long Dim hWndConfig As Long Dim hOverWrite As Long Dim dwMsgRtn As Long hWnd = SampleList() If hWnd Then SaveSampleList dwMsgRtn = PostMessage(hWnd, WM_COMMAND, IDM_ACQU_SAMPLES_START, 0) hWndConfig = ConfigureAnalysis(wAcquMode) If hWndConfig Then dwMsgRtn = PostMessage(hWndConfig, WM_COMMAND, IDOK, 0) Call WaitForProcessEnd("Start Analysis of Sample List...") If WaitForProcessStart("Acquisition Status", 10) Then StartSampleList = True Else StartSampleList = False End If End If ' Do not allow sample list start to close down sample list ' DV 21/10/96 ' SampleListClose End If End Function '**************************************************************************************** ' ' Purpose: Start an existing sample list. ' '**************************************************************************************** Function StartSampleListFile(lpSampleListName As String, wAcquMode As Integer) As Integer Dim hWnd As Long Dim dwMsgRtn As Long Dim lpSampleList As String Dim lpCurSampleList As VGFILE If GetMLFileInfo("SAMPLES_DB", lpCurSampleList) Then hWnd = ProcessActive(SampleListCaption()) If hWnd Then dwMsgRtn = StopProcess(SampleListCaption()) End If lpCurSampleList.szName = Trim$(lpSampleListName) + Chr$(0) StartSampleListFile = SetGlobalFile(SYSPARAGRAPH, "SAMPLES_DB", lpCurSampleList, True) If StartSampleList(wAcquMode) Then StartSampleListFile = True End If End If End Function '**************************************************************************************** ' ' Purpose: Update the record with information stored in the array lpRecord(), ' at record number dwRecNum. ' If dwRecNum does not exist the function returns FALSE, else ' the function returns the record number. ' '**************************************************************************************** Function UpdateTableRecord(tblTable As Table, lpRecord() As DBASEDATA, dwRecNum As Long) As Long Dim wField As Integer Dim wFirstField As Integer Dim wLastField As Integer Dim dwRecs As Long Dim fdField As Field tblTable.MoveLast dwRecs = tblTable.RecordCount If dwRecNum >= 1 And dwRecNum <= dwRecs Then wFirstField = LBound(lpRecord) wLastField = UBound(lpRecord) tblTable.MoveFirst dwRecs = 1 Do While dwRecs < dwRecNum tblTable.MoveNext dwRecs = dwRecs + 1 Loop tblTable.Edit For wField = wFirstField To wLastField Set fdField = tblTable.Fields(Trim$(lpRecord(wField).Field)) Select Case fdField.Type Case DB_BOOLEAN fdField.Value = CInt(lpRecord(wField).Value) Case DB_BYTE fdField.Value = CInt(lpRecord(wField).Value) Case DB_INTEGER fdField.Value = CInt(lpRecord(wField).Value) Case DB_LONG fdField.Value = CLng(lpRecord(wField).Value) Case DB_CURRENCY fdField.Value = lpRecord(wField).Value Case DB_SINGLE fdField.Value = CDbl(lpRecord(wField).Value) Case DB_DOUBLE fdField.Value = CDbl(lpRecord(wField).Value) Case DB_DATE fdField.Value = lpRecord(wField).Value Case DB_TEXT fdField.Value = Left$(lpRecord(wField).Value, fdField.Size - 1) + Chr$(0) Case DB_LONGBINARY fdField.Value = CLng(lpRecord(wField).Value) Case DB_MEMO fdField.Value = lpRecord(wField).Value End Select tblTable.Fields(fdField.Name).Value = fdField.Value Next wField tblTable.Update UpdateTableRecord = dwRecNum Else UpdateTableRecord = False End If End Function '**************************************************************************************** ' ' Purpose: Waits for an acquistion to start ' and finish. ' '**************************************************************************************** Sub WaitForAcquisition() Dim hAcquStatus As Long Dim wAcquStatus As Integer Dim lpAcquStatus As String lpAcquStatus = "Acquisition Status" hAcquStatus = WaitForProcessStart(lpAcquStatus, 10) wAcquStatus = AiScanStatus() If hAcquStatus Then Do Until AcquDataActive() DoEvents Loop Do While AcquDataActive() DoEvents Loop End If End Sub '**************************************************************************************** ' ' Purpose: Wait for sample number wSampNum to be acquired. ' '**************************************************************************************** Sub WaitForSampleNum(wSampNum As Integer) Do While (AiSampleNumber() <= wSampNum) And (AiScanStatus() > 0) DoEvents Loop End Sub