{ Главная форма программы управления масс-спектрометром МИ-1201 АГМ может использоваться автономно (как обычная форма в проекте) или посредством отдельного витка, см. MCAD_MI1201_FormThread (для DLL-проектов) } {--------------------------------------------------------------------------- The control program for mass-spectrometer MI1201-AGM (c) Copyright Aleksandrov O.E., 2001 Molecular Physics department, USTU, Ekaterinsburg, K-2, 620002, RUSSIA phone 75-47-15 E-mail: aleks@dpt.ustu.ru Программа управления масс-спектрометром МИ1201-АГМ (c) Собственность Александрова О.Е., 2001 620002, Екатеринбург, К-2, УГТУ, Кафедра молекулярной физики тел. 75-47-15 E-mail: aleks@dpt.ustu.ru ----------------------------------------------------------------------------} unit MCAD_MI1201_Form; interface uses Registry, Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, CheckLst, Dialogs, StdCtrls, Buttons, ComCtrls, ExtCtrls, Menus, xSystem, c_Mi1201, MITypes, MiscFunc, MCAD_MI1201_Range, MCAD_MI1201_Registry, MCAD_MI1201_Thread0, MCAD_MI1201_Thread, MCAD_MI1201_Thread_Types, MCAD_MI1201_XForm, ActnList; type tFlag=(fMassProcessingInProgress, fCloseWarningForMathCADShowed, fWarningISSB_IsShownOnce); tFlags=set of tFlag; // вспомогательные флаги tSupportFlag=(sfShowWarningISSB); tSupportFlags=set of tSupportFlag; TFormMain = class(TXForm) PageControl: TPageControl; TabSheetTurnON: TTabSheet; TabSheetMass: TTabSheet; TabSheetValves: TTabSheet; TabSheetBlocks: TTabSheet; GroupBoxMassCalibration: TGroupBox; PanelMassCalibrationK: TPanel; EditMassCalibrationK: TEdit; PanelMassCalibrationM0: TPanel; EditMassCalibrationM0: TEdit; ButtonON_OFF: TButton; StatusBarMain: TStatusBar; PanelValvesControlAvailable: TPanel; CheckBoxValvesControlAvailable: TCheckBox; GroupBoxBlocksOn: TGroupBox; GroupBoxON_OFFControl: TGroupBox; GroupBoxConfigFileName: TGroupBox; EditConfigFileName: TEdit; OpenDialog: TOpenDialog; ButtonConfigFileName: TButton; ButtonResetError: TButton; StatusBarMsg: TStatusBar; GroupBoxSources: TGroupBox; RadioButtonSourceAllClosed: TRadioButton; RadioButtonSourceSample1: TRadioButton; RadioButtonSourceSample2: TRadioButton; RadioButtonSourceStandard3: TRadioButton; RadioButtonSourceStandard1: TRadioButton; RadioButtonSourceStandard2: TRadioButton; GroupBoxAutoClose: TGroupBox; EditSourcePumping: TEdit; EditSourceSample1: TEdit; EditSourceSample2: TEdit; EditSourceStandard3: TEdit; EditSourceStandard1: TEdit; EditSourceStandard2: TEdit; LabelSource: TLabel; lConfigFileName: TLabel; GroupBoxCurrentMass: TGroupBox; RadioButtonSourcePumping: TRadioButton; BevelSourceDel0: TBevel; RadioButtonSourceStandard4: TRadioButton; EditSourceStandard4: TEdit; ImageMassCalibration: TImage; TabSheetVoltmeter: TTabSheet; LabelVoltmeter: TLabel; EditVoltmeterUpDateTime: TEdit; LabelVoltmeter_mc: TLabel; EditIMCh: TEdit; CheckBoxIMCh: TCheckBox; CheckBoxMagnet: TCheckBox; EditMagnet: TEdit; CheckBoxAcceleration: TCheckBox; EditAcceleration: TEdit; CheckBoxMutiplicator: TCheckBox; EditMutiplicator: TEdit; CheckBoxAntiDinatron: TCheckBox; EditAntiDinatron: TEdit; CheckBoxBaseUPT: TCheckBox; EditBaseUPT: TEdit; CheckBoxLens: TCheckBox; EditLens: TEdit; GroupBoxVoltmeterUPTs: TGroupBox; EditUPTU: TEdit; CheckBoxUPTU: TCheckBox; CheckBoxUPT8: TCheckBox; EditUPT8: TEdit; CheckBoxUPT7: TCheckBox; EditUPT7: TEdit; CheckBoxUPT6: TCheckBox; EditUPT6: TEdit; CheckBoxUPT5: TCheckBox; EditUPT5: TEdit; CheckBoxUPT4: TCheckBox; EditUPT4: TEdit; CheckBoxUPT3: TCheckBox; EditUPT3: TEdit; CheckBoxUPT2: TCheckBox; EditUPT2: TEdit; CheckBoxUPT1: TCheckBox; EditUPT1: TEdit; TabSheetMeasure: TTabSheet; GroupBoxPNCCalibration: TGroupBox; ComboBoxPNCCalibration: TComboBox; EditPNCCalibration0: TEdit; EditPNCCalibrationK: TEdit; LabelPNCCalibration0: TLabel; LabelPNCCalibrationK: TLabel; ButtonPNCCalibrationDo: TButton; ButtonAbort: TButton; TabSheetIonSource: TTabSheet; BitBtnSpecter: TBitBtn; BitBtnSpectrumX: TBitBtn; LabelISSB: TLabel; PanelISSBAttention: TPanel; ButtonISSBAttention: TButton; LabelISSBWarn: TLabel; GroupBoxScroll: TGroupBox; EditStepMul: TEdit; LabelStepMul: TLabel; UpDownStepMul: TUpDown; SpeedButtonScrollStop: TSpeedButton; SpeedButtonScrollPause: TSpeedButton; SpeedButtonScrollLeft: TSpeedButton; SpeedButtonScrollRight: TSpeedButton; SpeedButtonScrollJumpToLowBound: TSpeedButton; SpeedButtonScrollJumpToUpBound: TSpeedButton; GroupBoxMassNumberIndicator: TGroupBox; LabelEditIMChCalibration: TLabel; ImageEditIMChCalibration: TImage; PanelIMChCalibrationK: TPanel; EditIMChCalibrationK: TEdit; PanelEditIMChCalibrationM0: TPanel; EditIMChCalibrationM0: TEdit; ButtonAskIMCh: TButton; EditMassStepX: TEdit; LabelMassStepX: TLabel; LabelMassCurrentTitle: TLabel; LabelMassCurrent: TLabel; LabelCounterCurrent: TLabel; LabelCounterCurrentTitle: TLabel; LabelMassStepEqual: TLabel; LabelMassStepMin: TLabel; LabelMassStepCurrent: TLabel; ButtonClearAll: TButton; LabelPNCCalibrationZeroLevel: TLabel; EditPNCCalibrationZeroLevel: TEdit; GroupBoxInitialDataStoragelCapacity: TGroupBox; EditInitialDataStorageCapacity: TEdit; LabelInitialDataStorageCapacity: TLabel; LabelInitialDataSize: TLabel; ButtonPNCCalibrationChannelDo: TButton; ScrollBoxON_OFFControl: TScrollBox; CheckBoxSkipValvesExInit: TCheckBox; CheckBoxSkipValvesExDone: TCheckBox; CheckBoxSkipExDoneAtAll: TCheckBox; CheckBoxAutoDataSave: TCheckBox; CheckBoxUseEmulator: TCheckBox; CheckBoxAccumulation: TCheckBox; TabSheetRanges: TTabSheet; LabelRanges: TLabel; ScrollBoxRange: TScrollBox; PanelMass: TPanel; EditRangeTime: TEdit; PanelRangesBottom: TPanel; ButtonAdd: TButton; PanelRangeDescription: TPanel; EditRangeDescription: TEdit; ButtonDelete: TButton; PanelRangesTop: TPanel; CheckListBoxRanges: TCheckListBox; PanelRangesTopRight: TPanel; ButtonRangeUp: TButton; ButtonRangeDown: TButton; LabelRangeTimeHelp: TLabel; ButtonApply: TButton; PanelRangeMass: TPanel; LabelRangeMassMax: TLabel; EditRangeMassMin: TEdit; EditRangeMassMax: TEdit; PanelRangeMassStep: TPanel; LabelMassStepHelp: TLabel; EditRangeMassStep: TEdit; GroupBoxRangeOptions: TGroupBox; CheckBoxRangeClear: TCheckBox; CheckBoxUseRanges: TCheckBox; CheckBoxRangeAccumulation: TCheckBox; CheckBoxRangeUseExistingPoints: TCheckBox; PanelIntegrationTime: TPanel; EditIntegrationTime: TEdit; GroupBoxMainChannel: TGroupBox; ComboBoxMainChannel: TComboBox; lSetupStep: TLabel; CheckBoxRangesDoNotAutoSave: TCheckBox; LabelMass: TLabel; LabelCurrentMass_AEM: TLabel; ButtonJumpToMass: TButton; LabelCurrentMass: TLabel; LabelCounter: TLabel; LabelCurrentCounter: TLabel; GroupBoxMassRefine: TGroupBox; LabelCheckBoxAutoMassScaleSync: TLabel; ButtonSetHardwareZero: TButton; ButtonSetCurrentMassByIMCh: TButton; ButtonSetAsCurrentMass: TButton; CheckBoxDoNotShiftData: TCheckBox; CheckBoxAutoMassScaleSync: TCheckBox; EditAutoMassScaleSyncWithIMChValue: TEdit; pSyncWithIMChMessage: TPanel; PanelMSep1: TPanel; PanelMSep2: TPanel; PanelISSB: TPanel; PanelISSBIndicators: TPanel; LabelCZ: TLabel; LabelCX: TLabel; LabelFV: TLabel; LabelEV: TLabel; LabelEC: TLabel; LabelIV: TLabel; PanelISSBValues: TPanel; EditIonizationVoltage: TEdit; EditEmissionCurrent: TEdit; EditExtractingVoltage: TEdit; EditFocusingVoltage: TEdit; EditCorrectionX: TEdit; EditCorrectionZ: TEdit; UpDownCorrectionZ: TUpDown; UpDownCorrectionX: TUpDown; UpDownFocusingVoltage: TUpDown; UpDownExtractingVoltage: TUpDown; UpDownEmissionCurrent: TUpDown; UpDownIonizationVoltage: TUpDown; PanelISSBReset: TPanel; ButtonIonizationVoltage: TButton; ButtonEmissionCurrent: TButton; ButtonExtractingVoltage: TButton; ButtonFocusingVoltage: TButton; ButtonCorrectionX: TButton; ButtonCorrectionZ: TButton; PanelISSBTitles: TPanel; LabelIonizationVoltage: TLabel; LabelEmissionCurrent: TLabel; LabelExtractingVoltage: TLabel; LabelFocusingVoltage: TLabel; LabelCorrectionX: TLabel; LabelCorrectionZ: TLabel; PanelMassSep2: TPanel; GroupBoxCVF: TGroupBox; CheckBoxDoNotInvertInput: TCheckBox; PanelBlocksSep1: TPanel; CheckBoxBPGI: TCheckBox; CheckBoxBeam: TCheckBox; CheckBox10kV: TCheckBox; PanelSEM: TPanel; LabelSEMVolts: TLabel; CheckBoxSEM: TCheckBox; EditSEM: TEdit; UpDownSEM: TUpDown; PanelBlocksSep2: TPanel; CheckBoxRangesRepeatScroll: TCheckBox; CheckBoxRestoreBlocksState: TCheckBox; PanelMassCalibration_dC: TPanel; LabelMassCalibration_dC: TLabel; RadioGroupCVFBase: TRadioGroup; RadioGroupCVFInput: TRadioGroup; PanelDataAutoSave: TPanel; EditDataAutoSave: TEdit; cbDataAutoSave: TCheckBox; lDataAutoSaveCount: TLabel; EditCurrentMass: TComboBox; pOnOff1: TPanel; GroupBoxON_OFFControllers: TGroupBox; CheckBoxCounter: TCheckBox; CheckBoxVoltmeter: TCheckBox; ButtonAbout: TButton; btApply: TButton; alMain: TActionList; aVEUVoltage: TAction; procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure FormDestroy(Sender: TObject); procedure FormCreate(Sender: TObject); procedure ButtonON_OFFClick(Sender: TObject); procedure CheckBoxSwitches(Sender: TObject); procedure RadioGroupSwitches2(Sender: TObject); procedure ButtonConfigFileNameClick(Sender: TObject); procedure ButtonResetErrorClick(Sender: TObject); procedure EditSEMKeyPress(Sender: TObject; var Key: Char); procedure CheckBoxValvesControlAvailableClick(Sender: TObject); procedure RadioButtonSourceClick(Sender: TObject); // procedure EditSourceExit(Sender: TObject); procedure EditSourceKeyPress(Sender: TObject; var Key: Char); procedure EditConfigFileNameEnter(Sender: TObject); procedure EditConfigFileNameKeyPress(Sender: TObject; var Key: Char); procedure EditMassCalibrationKKeyPress(Sender: TObject; var Key: Char); procedure EditDefaultEnter(Sender: TObject); procedure EditDefaultExit(Sender: TObject); procedure EditMassCalibrationM0KeyPress(Sender: TObject; var Key: Char); procedure CheckBoxVoltmeterClick(Sender: TObject); procedure EditVoltmeterUpDateTimeExit(Sender: TObject); procedure EditVoltmeterUpDateTimeKeyPress(Sender: TObject; var Key: Char); procedure StatusBarMainDblClick(Sender: TObject); procedure xEditCurrentMassKeyPress(Sender: TObject; var Key: Char); procedure ButtonAbortClick(Sender: TObject); procedure ComboBoxPNCCalibrationChange(Sender: TObject); procedure EditPNCCalibration0KeyPress(Sender: TObject; var Key: Char); procedure EditPNCCalibrationKKeyPress(Sender: TObject; var Key: Char); procedure EditISSBExit(Sender: TObject); procedure EditISSBKeyPress(Sender: TObject; var Key: Char); procedure BitBtnSpecterClick(Sender: TObject); procedure BitBtnSpectrumXClick(Sender: TObject); procedure ButtonISSBClick(Sender: TObject); procedure UpDownISSBChangingEx(Sender: TObject; var AllowChange: Boolean; NewValue: Smallint; Direction: TUpDownDirection); procedure ButtonISSBAttentionClick(Sender: TObject); procedure EditIntegrationTimeKeyPress(Sender: TObject; var Key: Char); procedure ButtonJumpToMassClick(Sender: TObject); procedure ButtonSetAsCurrentMassClick(Sender: TObject); procedure EditStepMulKeyPress(Sender: TObject; var Key: Char); procedure ButtonScrollStopClick(Sender: TObject); procedure ButtonScrollJumpToLowBoundClick(Sender: TObject); procedure ButtonScrollJumpToUpBoundClick(Sender: TObject); procedure ButtonScrollLeftClick(Sender: TObject); procedure ButtonScrollRightClick(Sender: TObject); procedure ButtonScrollPauseClick(Sender: TObject); procedure EditIMChCalibrationKKeyPress(Sender: TObject; var Key: Char); procedure EditIMChCalibrationM0KeyPress(Sender: TObject; var Key: Char); procedure ButtonAskIMChClick(Sender: TObject); procedure ButtonSetCurrentMassByIMChClick(Sender: TObject); procedure EditMassStepXKeyPress(Sender: TObject; var Key: Char); procedure ButtonSetHardwareZeroClick(Sender: TObject); procedure ButtonPNCCalibrationDoClick(Sender: TObject); procedure ButtonClearAllClick(Sender: TObject); procedure EditPNCCalibrationZeroLevelKeyPress(Sender: TObject; var Key: Char); procedure EditInitialDataStorageCapacityExit(Sender: TObject); procedure EditInitialDataStorageCapacityKeyPress(Sender: TObject; var Key: Char); procedure ComboBoxMainChannelChange(Sender: TObject); procedure ButtonPNCCalibrationChannelDoClick(Sender: TObject); procedure ButtonAddClick(Sender: TObject); procedure ButtonDeleteClick(Sender: TObject); procedure CheckListBoxRangesClick(Sender: TObject); procedure ButtonApplyClick(Sender: TObject); procedure EditRangeDescriptionKeyPress(Sender: TObject; var Key: Char); procedure CheckListBoxRangesClickCheck(Sender: TObject); procedure ButtonRangeUpClick(Sender: TObject); procedure ButtonRangeDownClick(Sender: TObject); procedure CheckBoxRangeClearClick(Sender: TObject); procedure CheckBoxUseRangesClick(Sender: TObject); procedure ComboBoxRangeCategoryClick(Sender: TObject); procedure EditAutoMassScaleSyncWithIMChValueKeyPress(Sender: TObject; var Key: Char); procedure TabSheetMassShow(Sender: TObject); procedure TabSheetMeasureShow(Sender: TObject); procedure ButtonAboutClick(Sender: TObject); procedure EditConfigFileNameExit(Sender: TObject); procedure EditMassCalibrationKExit(Sender: TObject); procedure EditMassCalibrationM0Exit(Sender: TObject); procedure EditIMChCalibrationKExit(Sender: TObject); procedure EditIMChCalibrationM0Exit(Sender: TObject); procedure EditAutoMassScaleSyncWithIMChValueExit(Sender: TObject); procedure EditSourceExit(Sender: TObject); procedure EditSEMExit(Sender: TObject); procedure EditIntegrationTimeExit(Sender: TObject); procedure EditPNCCalibrationKExit(Sender: TObject); procedure EditPNCCalibrationZeroLevelExit(Sender: TObject); procedure EditStepMulExit(Sender: TObject); procedure UpDownStepMulClick(Sender: TObject; Button: TUDBtnType); procedure FormCanResize(Sender: TObject; var NewWidth, NewHeight: Integer; var Resize: Boolean); procedure EditDataAutoSaveExit(Sender: TObject); procedure EditDataAutoSaveKeyPress(Sender: TObject; var Key: Char); procedure EditCurrentMassKeyPress(Sender: TObject; var Key: Char); procedure btApplyClick(Sender: TObject); procedure aVEUVoltageExecute(Sender: TObject); private { Private declarations } prFlags:tFlags; prSupportFlags:tSupportFlags; procedure NotifyHandler(Sender:TObject; Event:tMI1201_Thread_Event); override; procedure MassSpectrometerSet(const MassSpectr:tMsThread); override; procedure FillInSwitches; procedure FillInSources; procedure FillInVoltmeter; procedure FillInDevices; procedure FillInDevicesStep; procedure InProgressButtonON_OFF; procedure InProgressON; procedure InProgressOFF; procedure ProcessALL; procedure ProcessALLExceptError; procedure ProcessButtonON_OFF; procedure ProcessSwitches; procedure ProcessError; procedure ProcessConfigFileName; procedure ProcessSEMVoltage; procedure ProcessSourcesAutoCloseTime; procedure ProcessSourceAutoClose; procedure ProcessSource; procedure ProcessSourceAutoCloseTime; procedure ProcessVoltmeterUpdateTime; procedure ProcessDevices; procedure ProcessMassSpDestroyFast; procedure ProcessMassSpDestroy; procedure ApplyEditVoltmeterUpDateTime(Sender: TObject); procedure ApplyMassStepXExit(Sender: TObject); procedure ProcessVoltmeterUpdateChannelsChanged; procedure ProcessVoltmeterAutoUpdate; procedure Msg(s:string); procedure ProcessMassCalibration; procedure ProcessMassCalibrationM0; procedure ProcessMassCalibrationK; procedure ProcessMassCalibration_dC; procedure ProcessIntegrationTime; procedure ProcessCurrentMass; procedure InvalidateCurrentMass; procedure ApplyCurrentMass; procedure ProcessPNCCalibration; procedure ProcessPNCCalibrationK; procedure ProcessPNCCalibration0; procedure ProcessPNCCalibrationZeroLevel; procedure ProcessISSBMotors; procedure ProcessStart; procedure ProcessLimit; procedure ProcessRunning; procedure ProcessStepMultiplicator; procedure ProcessMeasureType; procedure ProcessIMChCalibrationK; procedure ProcessIMChCalibrationM0; procedure ProcessIMChCalibration; procedure ProcessMassStepMin; procedure ProcessMassStep; procedure ProcessInitialCapacity; procedure ProcessInitialDataSize; procedure ProcessMainChannel; procedure ProcessEmergency; procedure ProcessDataAutoSaveInterval; procedure ProcessDataAutoSaveEnable; procedure ProcessDataAutoSaveCount; procedure Enable(State:boolean); function ValidComboBoxPNCCalibrationIndex:boolean; procedure ProcessRanges; procedure RangeFillIn; function RangeAdd:integer; procedure RangeDelete(ARangeIndex:integer); procedure RangeApply(ARange:tRange); procedure FillInRange(ARange:tRange); procedure HandleRangeChanged(ARangeIndex:integer; AItem:tRangeItem); procedure ProcessRangesChecked; // procedure ProcessRangeCategoryList; procedure ProcessAutoMassScaleSyncWithIMChValue; procedure ProcessDoAutoMassScaleSyncWithIMCh; procedure ApplyISSB(Sender: TObject); procedure MessageCloseWarningForMathCAD; // Однократно предупреждает об опасности кручения настроек источника ионов function WarningISSB(aIgnoreShowNextTime:boolean):boolean; procedure WMSysCommand(var Message: TWMSysCommand); message WM_SYSCOMMAND; // процедура отработки проблемы с драйвером в W2k public RunDllStarted:boolean; procedure DoMinimize(Sender: TObject); constructor Create(AOwner:tComponent); override; procedure MessageEventBUG(var Msg: TMsg; var Handled: Boolean); end; var FormMain: TFormMain; implementation USES MCAD_MI1201_FormABOUT, MCAD_MI1201_FormSpectrum, MCAD_MI1201_FormEmergencySignals, MCAD_MI1201_FormWarning; const cStatusBarMessage=3; {$R *.DFM} procedure TFormMain.ProcessALLExceptError; begin ProcessSwitches; ProcessSEMVoltage; ProcessSource; ProcessConfigFileName; ProcessDevices; ProcessCurrentMass; ProcessIntegrationTime; ProcessStepMultiplicator; ProcessMassStep; ProcessMassStepMin; ProcessMeasureType; ProcessMassCalibration; ProcessIMChCalibration; ProcessSourcesAutoCloseTime; ProcessStart; ProcessInitialDataSize; ProcessInitialCapacity; ProcessMainChannel; ProcessRanges; ProcessAutoMassScaleSyncWithIMChValue; ProcessDataAutoSaveInterval; ProcessDataAutoSaveEnable; end; procedure TFormMain.ProcessALL; begin ProcessALLExceptError; ProcessError; end; procedure TFormMain.MassSpectrometerSet(const MassSpectr:tMsThread); begin Inherited; if Assigned(MassSpectrometer) then begin Synchronize(FillInDevicesStep); Synchronize(ProcessButtonON_OFF); end; end; constructor TFormMain.Create; begin Inherited Create(AOwner); end; procedure TFormMain.FormClose(Sender: TObject; var Action: TCloseAction); begin if IsLibrary and (not RunDllStarted) then begin if not (fCloseWarningForMathCADShowed in prFlags) then begin MessageCloseWarningForMathCAD; Include(prFlags,fCloseWarningForMathCADShowed); end; Action:=caMinimize; // WindowState := wsMinimized; end else begin Action:=caFree; end; end; procedure TFormMain.FormDestroy(Sender: TObject); begin try MassSpectrometerNIL; try RegistryWriteForm; except end; try if RegistryOpenForWrite then begin prRegistry.WriteInteger('ActivePageIndex',PageControl.ActivePageIndex); RegistryWriteComboBox(EditCurrentMass); prRegistry.WriteInteger('SupportFlags',Byte(prSupportFlags)); end; except end; // prRegistry.Free; except end; if Self=FormMain then FormMain:=NIL; end; procedure TFormMain.FormCreate(Sender: TObject); begin {$IfDef MotorsOFF} LabelISSB.Caption:='Управление недоступно - отключено при компиляции.'; LabelISSB.Font.Style:=[fsBold]; {$EndIf Def MotorsOFF} if not Assigned(FormEmergencySignals) then try FormEmergencySignals:=TFormEmergencySignals.Create(Self); except FormEmergencySignals:=NIL; end; if RegistryOpenForRead then begin try PageControl.ActivePageIndex:=prRegistry.ReadInteger('ActivePageIndex'); except end; RegistryReadComboBox0(EditCurrentMass); try Byte(prSupportFlags):=prRegistry.ReadInteger('SupportFlags'); prSupportFlags:=prSupportFlags*[low(tSupportFlag)..high(tSupportFlag)]; except prSupportFlags:=[]; end; try RegistryReadForm; except end; prRegistry.CloseKey; end; FillInSources; FillInSwitches; FillInVoltmeter; FillInDevices; ProcessError; end; procedure TFormMain.ProcessButtonON_OFF; begin if Assigned(MassSpectrometer) then begin try ButtonON_OFF.Enabled:=FALSE; if MassSpectrometer.IsOn then begin ButtonON_OFF.Caption:='В&ыключить'; ButtonON_OFF.Hint:='Провести деинициализацию оборудования и выключить масс-спектрометр.'; // StatusBarMsg.SimpleText:=''; ProcessAll; end else begin ButtonON_OFF.Caption:='В&ключить'; ButtonON_OFF.Hint:='Включить масс-спектрометр и провести инициализацию оборудования.'; ProcessAll; StatusBarMsg.SimpleText:='Программа отключена от масс-спектрометра.'; end; ButtonON_OFF.Enabled:=TRUE; except end; end else begin ButtonON_OFF.Caption:='НЕДОСТУПНО'; ButtonON_OFF.Hint:='Оборудование масс-спектрометра недоступно.' end; end; procedure TFormMain.InProgressButtonON_OFF; begin ButtonON_OFF.Enabled:=FALSE; ButtonON_OFF.Caption:='выполнение...'; ProcessMessages; end; procedure TFormMain.InProgressON; begin StatusBarMsg.SimpleText:='выполнение ВКЛючения...'; InProgressButtonON_OFF; end; procedure TFormMain.InProgressOFF; begin StatusBarMsg.SimpleText:='выполнение ВЫКЛючения...'; InProgressButtonON_OFF; end; procedure TFormMain.ButtonON_OFFClick(Sender: TObject); resourcestring ConfirmOffTitle='Выключение масс-спектрометра'; resourcestring ConfirmOffQuestion='Вы действительно хотите выключить масс-спектрометр?'; begin if Assigned(MassSpectrometer) then begin try if MassSpectrometer.IsOn then begin if MassSpectrometer.Error<>ecOK then begin MassSpectrometer.ResetError; end else begin if IdYES=MessageBox(Pchar(ConfirmOffQuestion),Pchar(ConfirmOffTitle),MB_YESNO+MB_ICONQUESTION+MB_DEFBUTTON2) then MassSpectrometer.SetOffX; end; end else begin MassSpectrometer.SetOnX; end; except ProcessButtonON_OFF; end; end; end; procedure TFormMain.NotifyHandler(Sender:TObject; Event:tMI1201_Thread_Event); begin if not Assigned(MassSpectrometer) or (Sender<>MassSpectrometer) then Exit; try case Event.EventID of evDestroy,evTerminate: begin prMsSpDestroyed:=TRUE; ProcessMassSpDestroyFast; end; evMassChanged: begin if not (fMassProcessingInProgress in prFlags) then begin Include(prFlags,fMassProcessingInProgress); Synchronize(ProcessCurrentMass); end; end; evMassAboutChangeForLargeValue: begin Synchronize(InvalidateCurrentMass); end; evMassLimit: begin Synchronize(ProcessLimit); end; evMassStepChanged: begin Synchronize(ProcessMassStep); end; evIntegrationTimeChanged:begin Synchronize(ProcessIntegrationTime); end; evStartSetOff:begin Synchronize(InProgressOFF); end; evStartSetON:begin Synchronize(InProgressON); end; evEndSetOff:begin Synchronize(ProcessButtonON_OFF); // ProcessButtonON_OFF; end; evEndSetON:begin Synchronize(ProcessButtonON_OFF); end; evClearError,evError:begin Synchronize(ProcessError); end; evSwitchesChanged:begin Synchronize(ProcessSwitches); end; evConfigFileNameChanged:begin Synchronize(ProcessConfigFileName); end; evDevice:begin case tDevice(Event.ParameterB) of SEM_Voltage: Synchronize(ProcessSEMVoltage); else Synchronize(ProcessISSBMotors); end; end; evSourceChanged:begin Synchronize(ProcessSource); end; evSourceAutoCloseTimeChanged:begin Synchronize(ProcessSourcesAutoCloseTime); end; evValveOneSecondTimerTick:begin Synchronize(ProcessSourceAutoCloseTime); end; evMassCalibrationChanged:begin Synchronize(ProcessMassCalibration); end; evVoltmeterAutoUpdate:begin Synchronize(ProcessVoltmeterAutoUpdate); end; evVoltmeterAutoUpdateTimeChanged:begin Synchronize(ProcessVoltmeterUpdateTime); end; evVoltmeterAutoUpdateChannelsChanged:begin Synchronize(ProcessVoltmeterUpdateChannelsChanged); end; evStart,evStop,evResume:begin Synchronize(ProcessStart); end; evStepMultiplicatorChanged: begin Synchronize(ProcessStepMultiplicator); end; exMNICalibrationChanged: begin Synchronize(ProcessIMChCalibration); end; evSetError: begin Synchronize(ProcessError); end; evInitialCapacityChanged: begin Synchronize(ProcessInitialCapacity); end; evMainChannelChanged: begin Synchronize(ProcessMainChannel); end; evEmergency: begin Synchronize(ProcessEmergency); end; evRangeListChanged:begin Synchronize(ProcessRanges); end; evRangeChanged: begin HandleRangeChanged(Event.ParameterW, tRangeItem(Event.ParameterB)); end; evAutoMassScaleSyncWithIMChValueChanged: begin Synchronize(ProcessAutoMassScaleSyncWithIMChValue); end; evAutoMassScaleSyncWithIMChDone: begin Synchronize(ProcessDoAutoMassScaleSyncWithIMCh); end; evDataAutoSave: begin case Event.ParameterB of 0: Synchronize(ProcessDataAutoSaveEnable); 1: Synchronize(ProcessDataAutoSaveInterval); 2: Synchronize(ProcessDataAutoSaveCount); end; end; else begin end; end; except end; end; procedure TFormMain.ProcessError; resourcestring rsMainStatusBar='главная строка состояния'; resourcestring rsMassSpUnavail='Масс-спектрометр недоступен.'; begin if Assigned(MassSpectrometer) then begin if MassSpectrometer.Error<>ecOK then begin with StatusBarMain.Panels.Items[0] do begin Bevel:=pbRaised; Text:='ОШБК'; end; ButtonResetError.Font.Color:=clYellow; ButtonResetError.Enabled:=True; try StatusBarMain.Hint:=MassSpectrometer.ErrorMsg; except end; StatusBarMsg.SimpleText:=StatusBarMain.Hint; end else begin with StatusBarMain.Panels.Items[0] do begin Bevel:=pbLowered; if MassSpectrometer.IsON then Text:='ВКЛ' else Text:='ВЫКЛ' end; StatusBarMain.Hint:=rsMainStatusBar; StatusBarMsg.SimpleText:=''; ButtonResetError.Enabled:=False; ButtonResetError.Font.Color:=Font.Color; ProcessALLExceptError; end; end else begin with StatusBarMain.Panels.Items[0] do begin Bevel:=pbLowered; Text:='?' end; StatusBarMain.Hint:=rsMassSpUnavail; StatusBarMsg.SimpleText:=StatusBarMain.Hint; ButtonResetError.Font.Color:=Font.Color; end; end; procedure TFormMain.ProcessSwitches; var x:tMSSwitches; begin if not Assigned(MassSpectrometer) then Exit; x:=MassSpectrometer.Switches; CheckBoxSkipValvesExInit.Checked := sffSkipValvesExInit in x; CheckBoxRestoreBlocksState.Checked := sffRestoreBlocksStateOnExInit in x; CheckBoxSkipValvesExDone.Checked := sffSkipValvesExDone in x; CheckBoxSkipExDoneAtAll.Checked := sffSkipExDoneAtAll in x; CheckBoxUseEmulator.Checked := sffUseEmulator in x; CheckBoxVoltmeter.Checked := sVoltmeter in x; CheckBoxCounter.Checked := sCounter in x; CheckBoxBPGI.Checked := sfBPGI in x; CheckBoxSEM.Checked := sfSEM in x; CheckBoxBeam.Checked := sfCVF_Beam in x; CheckBox10kV.Checked := sf10kV in x; CheckBoxDoNotInvertInput.Checked := sfCVF_DoNotInvertInput in x; CheckBoxValvesControlAvailable.Checked:=sfValvesControl in x; GroupBoxSources.Enabled:=CheckBoxValvesControlAvailable.Checked; RadioGroupCVFBase.ItemIndex :=Ord( not (sfCVF_Base0 in x)); RadioGroupCVFInput.ItemIndex :=Ord( not (sfCVF_InputEMU in x)); CheckBoxAutoDataSave.Checked := mstAutoSaveData in x; CheckBoxDoNotShiftData.Checked := mstDoNotShiftDataOnRefineMass in x; CheckBoxAccumulation.Checked := mstAccumulation in x; CheckBoxUseRanges.Checked := mstUseRanges in x; CheckBoxAutoMassScaleSync.Checked := mstAutoMassScaleSyncWithIMCh in x; CheckBoxRangesDoNotAutoSave.Checked := mstDoNotAutoSaveOnRangeScrollCompltete in x; CheckBoxRangesRepeatScroll.Checked := mstRepeatRangesScroll in x; end; procedure TFormMain.FillInSwitches; begin CheckBoxSkipValvesExInit.Tag := Ord(sffSkipValvesExInit); CheckBoxRestoreBlocksState.Tag:= Ord(sffRestoreBlocksStateOnExInit); CheckBoxSkipValvesExDone.Tag := Ord(sffSkipValvesExDone); CheckBoxSkipExDoneAtAll.Tag := Ord(sffSkipExDoneAtAll); CheckBoxUseEmulator.Tag := Ord(sffUseEmulator); CheckBoxVoltmeter.Tag := Ord(sVoltmeter); CheckBoxCounter.Tag := Ord(sCounter); CheckBoxBPGI.Tag := Ord(sfBPGI); CheckBoxSEM.Tag := Ord(sfSEM); CheckBoxBeam.Tag := Ord(sfCVF_Beam); CheckBox10kV.Tag := Ord(sf10kV); CheckBoxDoNotInvertInput.Tag := Ord(sfCVF_DoNotInvertInput); RadioGroupCVFBase.Tag :=Ord(sfCVF_Base0); RadioGroupCVFInput.Tag :=Ord(sfCVF_InputEMU); CheckBoxValvesControlAvailable.Tag:=Ord(sfValvesControl); CheckBoxAutoDataSave.Tag := Ord(mstAutoSaveData); CheckBoxDoNotShiftData.Tag := Ord(mstDoNotShiftDataOnRefineMass); CheckBoxAccumulation.Tag := Ord(mstAccumulation); CheckBoxUseRanges.Tag := Ord(mstUseRanges); CheckBoxAutoMassScaleSync.Tag := Ord(mstAutoMassScaleSyncWithIMCh); CheckBoxRangesDoNotAutoSave.Tag:=Ord(mstDoNotAutoSaveOnRangeScrollCompltete); CheckBoxRangesRepeatScroll.Tag:=Ord(mstRepeatRangesScroll); cbDataAutoSave.Tag := Ord(mstAutoSaveDataOnInterval); end; procedure TFormMain.CheckBoxSwitches(Sender: TObject); begin if Assigned(MassSpectrometer) then begin if Sender.InheritsFrom(TCheckBox) then begin with TCheckBox(Sender) do begin if Checked then MassSpectrometer.SwitchONX(tMsSwitch(Tag)) else MassSpectrometer.SwitchOFFX(tMsSwitch(Tag)); end; CheckBoxBeam.Enabled:=CheckBoxBPGI.Checked; end; end; end; procedure TFormMain.RadioGroupSwitches2(Sender: TObject); begin if Assigned(MassSpectrometer) then begin if Sender.InheritsFrom(TRadioGroup) then begin with TRadioGroup(Sender) do begin case ItemIndex of 0: begin MassSpectrometer.SwitchONX(tMsSwitch(Tag)); end; 1: begin MassSpectrometer.SwitchOffX(tMsSwitch(Tag)); end; else begin end; end; end; end; end; end; procedure TFormMain.ButtonConfigFileNameClick(Sender: TObject); var OldFormStyle:TFormStyle; begin with OpenDialog do begin Title:='Конфигурационный файл МИ-1201 АГМ'; Options:=Options-[ofAllowMultiSelect]; OldFormStyle:=FormStyle; FormStyle:=fsNormal; if Execute then begin EditConfigFileName.Text:=FileName; try prMassSpectrometer.ConfigFileName:=EditConfigFileName.Text; except end; EditConfigFileName.Text:=prMassSpectrometer.ConfigFileName; end; FormStyle:=OldFormStyle; end; end; procedure TFormMain.ProcessConfigFileName; var s:string; begin if not Assigned(MassSpectrometer) then Exit; s:=prMassSpectrometer.ConfigFileName; EditConfigFileName.Text:=s; lConfigFileName.Hint:=s; lConfigFileName.Caption:=ShortenStr(s,38, '...'); end; procedure TFormMain.Enable; var i:integer; begin for i:=0 to Pred(ComponentCount) do begin if Components[i].InheritsFrom(TControl) then begin TControl(Components[i]).Enabled:=State; end; end; end; procedure TFormMain.ButtonResetErrorClick(Sender: TObject); begin if Assigned(prMassSpectrometer) then prMassSpectrometer.ResetError; end; procedure TFormMain.ProcessSEMVoltage; begin try UpDownSEM.Position:=prMassSpectrometer.Device[SEM_Voltage]; except end; end; procedure TFormMain.EditSEMKeyPress(Sender: TObject; var Key: Char); begin if not Assigned(prMassSpectrometer) then Exit; case Key of #13: begin aVEUVoltageExecute(Sender); end; #27: begin EditSEM.Text:=IntToStr(prMassSpectrometer.Device[SEM_Voltage]); end; else; end; end; procedure TFormMain.Msg(s:string); begin StatusBarMsg.SimpleText:=s; if s='' then StatusBarMsg.Hint:='строка подсказки' else StatusBarMsg.Hint:=s; end; procedure TFormMain.CheckBoxValvesControlAvailableClick(Sender: TObject); begin CheckBoxSwitches(Sender); GroupBoxSources.Enabled:=CheckBoxValvesControlAvailable.Checked; end; procedure TFormMain.FillInSources; { tSource=(sCloseAll, sSample1, sSample2, sStandard1, sStandard2, sStandard3, sStandard4, sPumping, sBad);} begin RadioButtonSourceAllClosed.Tag := Ord(sCloseAll); RadioButtonSourcePumping.Tag := Ord(sPumping); RadioButtonSourceSample1.Tag := Ord(sSample1); RadioButtonSourceSample2.Tag := Ord(sSample2); RadioButtonSourceStandard1.Tag := Ord(sStandard1); RadioButtonSourceStandard2.Tag := Ord(sStandard2); RadioButtonSourceStandard3.Tag := Ord(sStandard3); RadioButtonSourceStandard4.Tag := Ord(sStandard4); EditSourcePumping.Tag := Ord(sPumping); EditSourceSample1.Tag := Ord(sSample1); EditSourceSample2.Tag := Ord(sSample2); EditSourceStandard1.Tag := Ord(sStandard1); EditSourceStandard2.Tag := Ord(sStandard2); EditSourceStandard3.Tag := Ord(sStandard3); EditSourceStandard4.Tag := Ord(sStandard4); end; procedure TFormMain.ProcessSourcesAutoCloseTime; begin if not Assigned(prMassSpectrometer) then Exit; EditSourcePumping.Text := IntToStr(prMassSpectrometer.ValveAutoCloseTimes[sPumping]); EditSourceSample1.Text := IntToStr(prMassSpectrometer.ValveAutoCloseTimes[sSample1]); EditSourceSample2.Text := IntToStr(prMassSpectrometer.ValveAutoCloseTimes[sSample2]); EditSourceStandard1.Text := IntToStr(prMassSpectrometer.ValveAutoCloseTimes[sStandard1]); EditSourceStandard2.Text := IntToStr(prMassSpectrometer.ValveAutoCloseTimes[sStandard2]); EditSourceStandard3.Text := IntToStr(prMassSpectrometer.ValveAutoCloseTimes[sStandard3]); EditSourceStandard4.Text := IntToStr(prMassSpectrometer.ValveAutoCloseTimes[sStandard4]); ProcessSource; end; procedure TFormMain.RadioButtonSourceClick(Sender: TObject); begin if not Assigned(MassSpectrometer) then Exit; try MassSpectrometer.Valve:=tSource((Sender as TRadioButton).Tag); except end; end; procedure TFormMain.ProcessSource; var I: Integer; Sibling: TControl; s:tSource; m:tNotifyEvent; begin if not Assigned(MassSpectrometer) then Exit; s:=MassSpectrometer.Valve; StatusBarMain.Panels.Items[1].Text:=cSourceNames[s]; ProcessSourceAutoClose; if RadioButtonSourceAllClosed.Parent <> nil then begin try for I := 0 to RadioButtonSourceAllClosed.Parent.ControlCount - 1 do begin Sibling := RadioButtonSourceAllClosed.Parent.Controls[I]; if (Sibling.InheritsFrom(TRadioButton)) then begin m:= (Sibling as TRadioButton).OnClick; (Sibling as TRadioButton).OnClick:=NIL; (Sibling as TRadioButton).Checked:=((Sibling as TRadioButton).Tag=Ord(s)); (Sibling as TRadioButton).OnClick:=m; end; end; except end; end; end; procedure TFormMain.ProcessSourceAutoCloseTime; begin if not Assigned(MassSpectrometer) then Exit; if MassSpectrometer.Valve=sCloseAll then Exit; StatusBarMain.Panels.Items[2].Text:='Авто. '+IntToStr((MassSpectrometer.ValveAutoCloseTimeLeft+500) div 1000)+' c' end; procedure TFormMain.ProcessSourceAutoClose; begin if not Assigned(MassSpectrometer) then Exit; if MassSpectrometer.ValveAutoCloseEnabled then begin ProcessSourceAutoCloseTime; end else if MassSpectrometer.Valve=sBad then StatusBarMain.Panels.Items[2].Text:='?' else if MassSpectrometer.Valve=sCloseAll then StatusBarMain.Panels.Items[2].Text:='' else StatusBarMain.Panels.Items[2].Text:='Ручн.'; end; (*procedure TFormMain.EditSourceExit(Sender: TObject); resourcestring InvalidNumber='Неправильное число.'#13'Возвратить исходное значение?'; resourcestring Title='Интервал автоматического закрытия'; var i:cardinal; b:boolean; begin if not TObject(Sender).InheritsFrom(TEdit) then Exit; if not TEdit(Sender).Enabled then Exit; if not Assigned(prMassSpectrometer) then Exit; if not TEdit(Sender).Tag in [Ord(Low(tSource))..Ord(High(tSource))] then Exit; try TEdit(Sender).Enabled:=FALSE; try i:= StrToInt(TEdit(Sender).Text); try prMassSpectrometer.ValveAutoCloseTimes[tSource(TEdit(Sender).Tag)]:=i; finally TEdit(Sender).Text:=IntToStr(prMassSpectrometer.ValveAutoCloseTimes[tSource(TEdit(Sender).Tag)]); ProcessSourceAutoClose; end; except b:=TEdit(Sender).HideSelection; TEdit(Sender).HideSelection:=FALSE; if IDCANCEL=MessageBox(PChar(InvalidNumber), PChar(Title),MB_OKCANCEL+MB_ICONWARNING) then begin TEdit(Sender).SetFocus; end else begin TEdit(Sender).Text:=IntToStr(prMassSpectrometer.ValveAutoCloseTimes[tSource(TEdit(Sender).Tag)]); end; TEdit(Sender).HideSelection:=b; end; finally TEdit(Sender).Enabled:=TRUE; end; end; *) procedure TFormMain.EditSourceKeyPress(Sender: TObject; var Key: Char); var sr:tSource; begin if not (Key in [#13,#27]) then Exit; if not Assigned(prMassSpectrometer) then Exit; if not TObject(Sender).InheritsFrom(TEdit) then Exit; with TEdit(Sender) do begin if not Enabled then Exit; if not (Tag in [Ord(Low(sr))..Ord(High(sr))]) then Exit; sr:=tSource(Tag); case Key of #13:begin try prMassSpectrometer.ValveAutoCloseTimes[sr]:=StrToInt_MSG(TEdit(Sender).Text); except Text:=IntToStr(prMassSpectrometer.ValveAutoCloseTimes[sr]); end; end; #27:Text:=IntToStr(prMassSpectrometer.ValveAutoCloseTimes[sr]); else; end; end; end; procedure TFormMain.EditConfigFileNameEnter(Sender: TObject); resourcestring PressEnter='Нажмите: ENTER-применить; ESC-отмена.'; begin Msg(PressEnter); end; procedure TFormMain.EditConfigFileNameKeyPress(Sender: TObject; var Key: Char); begin if not Assigned(MassSpectrometer) then Exit; case Key of #13: begin try MassSpectrometer.ConfigFileName:=EditConfigFileName.Text; except ProcessConfigFileName; end; end; #27: begin ProcessConfigFileName; end; end; end; procedure TFormMain.EditMassCalibrationKKeyPress(Sender: TObject; var Key: Char); begin if not Assigned(prMassSpectrometer) then Exit; case Key of #13: begin try prMassSpectrometer.K:=StrToFloat_MSG(EditMassCalibrationK.Text); except // ProcessMassCalibrationK; end; end; #27: begin ProcessMassCalibrationK; end; else; end; end; procedure TFormMain.EditDefaultEnter(Sender: TObject); resourcestring PressEnter='Нажмите: ENTER-применить; ESC-отмена.'; begin Msg(PressEnter); end; procedure TFormMain.EditDefaultExit(Sender: TObject); begin Msg(''); end; procedure TFormMain.EditMassCalibrationM0KeyPress(Sender: TObject; var Key: Char); begin if not Assigned(prMassSpectrometer) then Exit; case Key of #13: begin try prMassSpectrometer.M0:=StrToFloat_MSG(EditMassCalibrationM0.Text); except // ProcessMassCalibrationM0; end; end; #27: begin ProcessMassCalibrationM0; end; else; end; end; procedure TFormMain.ProcessMassCalibrationK; begin if not Assigned(MassSpectrometer) then Exit; EditMassCalibrationK.Text:=FloatToStr(prMassSpectrometer.K); end; procedure TFormMain.ProcessMassCalibrationM0; begin if not Assigned(MassSpectrometer) then Exit; EditMassCalibrationM0.Text:=FloatToStr(prMassSpectrometer.M0); end; procedure TFormMain.ProcessMassCalibration_dC; begin if not Assigned(MassSpectrometer) then Exit; LabelMassCalibration_dC.Caption:=FloatToStrF(prMassSpectrometer.dC,ffGeneral,7,10); end; procedure TFormMain.ProcessMassCalibration; begin ProcessMassCalibrationK; ProcessMassCalibrationM0; ProcessMassCalibration_dC; end; procedure TFormMain.CheckBoxVoltmeterClick(Sender: TObject); begin if not Assigned(MassSpectrometer) then Exit; if not TObject(Sender).InheritsFrom(TCheckBox) then Exit; if (TCheckBox(Sender).TagSucc(Ord(High(tVoltageChannel)))) then Exit; if TCheckBox(Sender).Checked then begin MassSpectrometer.VoltmeterUpdateChannels:=MassSpectrometer.VoltmeterUpdateChannels+[tVoltageChannel(Pred(TCheckBox(Sender).Tag))]; end else begin MassSpectrometer.VoltmeterUpdateChannels:=MassSpectrometer.VoltmeterUpdateChannels-[tVoltageChannel(Pred(TCheckBox(Sender).Tag))]; end; end; procedure TFormMain.ProcessVoltmeterUpdateTime; begin if not Assigned(prMassSpectrometer) then Exit; EditVoltmeterUpdateTime.Text:=IntToStr(MassSpectrometer.VoltmeterUpdateTime div 1000); end; procedure TFormMain.EditVoltmeterUpDateTimeExit(Sender: TObject); begin EditDefaultExit(Sender); ApplyEditVoltmeterUpDateTime(Sender); end; procedure TFormMain.ApplyEditVoltmeterUpDateTime(Sender: TObject); begin if not TObject(Sender).InheritsFrom(TEdit) then Exit; if not Assigned(MassSpectrometer) then Exit; try MassSpectrometer.VoltmeterUpdateTime:=1000*StrToInt_MSG(GetIntStr(TEdit(Sender).Text)); finally ProcessVoltmeterUpdateTime; end; end; procedure TFormMain.EditVoltmeterUpDateTimeKeyPress(Sender: TObject; var Key: Char); begin case Key of #13: ApplyEditVoltmeterUpDateTime(Sender); #27:ProcessVoltmeterUpdateTime; else; end; end; procedure TFormMain.FillInVoltmeter; begin EditIMCh.Tag:=Succ(Ord(IMCh)); CheckBoxIMCh.Tag:=Succ(Ord(IMCh)); EditAcceleration.Tag:=Succ(Ord(Acceleration)); CheckBoxAcceleration.Tag:=Succ(Ord(Acceleration)); EditMagnet.Tag:=Succ(Ord(Magnet)); CheckBoxMagnet.Tag:=Succ(Ord(Magnet)); EditMutiplicator.Tag:=Succ(Ord(Mutiplicator)); CheckBoxMutiplicator.Tag:=Succ(Ord(Mutiplicator)); EditAntiDinatron.Tag:=Succ(Ord(AntiDinatron)); CheckBoxAntiDinatron.Tag:=Succ(Ord(AntiDinatron)); EditBaseUPT.Tag:=Succ(Ord(BaseUPT)); CheckBoxBaseUPT.Tag:=Succ(Ord(BaseUPT)); EditUPT1.Tag:=Succ(Ord(UPT1)); CheckBoxUPT1.Tag:=Succ(Ord(UPT1)); EditUPT2.Tag:=Succ(Ord(UPT2)); CheckBoxUPT2.Tag:=Succ(Ord(UPT2)); EditUPT3.Tag:=Succ(Ord(UPT3)); CheckBoxUPT3.Tag:=Succ(Ord(UPT3)); EditUPT4.Tag:=Succ(Ord(UPT4)); CheckBoxUPT4.Tag:=Succ(Ord(UPT4)); EditUPT5.Tag:=Succ(Ord(UPT5)); CheckBoxUPT5.Tag:=Succ(Ord(UPT5)); EditUPT6.Tag:=Succ(Ord(UPT6)); CheckBoxUPT6.Tag:=Succ(Ord(UPT6)); EditUPT7.Tag:=Succ(Ord(UPT7)); CheckBoxUPT7.Tag:=Succ(Ord(UPT7)); EditUPT8.Tag:=Succ(Ord(UPT8)); CheckBoxUPT8.Tag:=Succ(Ord(UPT8)); EditUPTu.Tag:=Succ(Ord(UPTu)); CheckBoxUPTu.Tag:=Succ(Ord(UPTu)); EditLens.Tag:=Succ(Ord(Lens)); CheckBoxLens.Tag:=Succ(Ord(Lens)); end; procedure TFormMain.ProcessVoltmeterAutoUpdate; var vcs:tVoltageChannels; procedure ProcessE(e:TEdit); var c:tVoltageChannel; begin c:=tVoltageChannel(Pred(e.Tag)); if (c in vcs) then e.Text:=IntToStr(MassSpectrometer.VoltmeterUpdateData[c]); end; begin if not Assigned(MassSpectrometer) then Exit; vcs:=MassSpectrometer.VoltmeterUpdateChannels; ProcessE(EditIMCh); ProcessE(EditAcceleration); ProcessE(EditMagnet); ProcessE(EditMutiplicator); ProcessE(EditAntiDinatron); ProcessE(EditBaseUPT); ProcessE(EditUPT1); ProcessE(EditUPT2); ProcessE(EditUPT3); ProcessE(EditUPT4); ProcessE(EditUPT5); ProcessE(EditUPT6); ProcessE(EditUPT7); ProcessE(EditUPT8); ProcessE(EditUPTu); ProcessE(EditLens); end; procedure TFormMain.ProcessVoltmeterUpdateChannelsChanged; var vcs:tVoltageChannels; procedure ProcessE(e:TCheckBox); begin e.Checked:=tVoltageChannel(Pred(e.Tag)) in vcs; end; begin if not Assigned(MassSpectrometer) then Exit; vcs:=MassSpectrometer.VoltmeterUpdateChannels; ProcessE(CheckBoxIMCh); ProcessE(CheckBoxAcceleration); ProcessE(CheckBoxMagnet); ProcessE(CheckBoxMutiplicator); ProcessE(CheckBoxAntiDinatron); ProcessE(CheckBoxBaseUPT); ProcessE(CheckBoxUPT1); ProcessE(CheckBoxUPT2); ProcessE(CheckBoxUPT3); ProcessE(CheckBoxUPT4); ProcessE(CheckBoxUPT5); ProcessE(CheckBoxUPT6); ProcessE(CheckBoxUPT7); ProcessE(CheckBoxUPT8); ProcessE(CheckBoxUPTu); ProcessE(CheckBoxLens); end; procedure TFormMain.StatusBarMainDblClick(Sender: TObject); begin MessageBoxError; end; procedure TFormMain.ProcessCurrentMass; var m,c:string; begin Exclude(prFlags,fMassProcessingInProgress); if not Assigned(MassSpectrometer) then Exit; if NotVisible then Exit; if TabSheetMass.Visible or TabSheetMeasure.Visible then begin m:=FloatToStr(MassSpectrometer.Mass); c:=IntToStr(MassSpectrometer.Counter); if TabSheetMass.Visible then begin LabelCurrentMass.Caption:=m; LabelCurrentCounter.Caption:=c; end else begin LabelMassCurrent.Caption:=m; LabelCounterCurrent.Caption:=c; end; end; end; procedure TFormMain.InvalidateCurrentMass; begin LabelCurrentMass.Caption:='...изменение...'; LabelCurrentCounter.Caption:=LabelCurrentMass.Caption; LabelMassCurrent.Caption:=LabelCurrentMass.Caption; LabelCounterCurrent.Caption:=LabelCurrentMass.Caption; ProcessMessages; end; procedure TFormMain.xEditCurrentMassKeyPress(Sender: TObject; var Key: Char); begin if not Assigned(MassSpectrometer) then Exit; case Key of #13: ApplyCurrentMass; #27: EditCurrentMass.Text:=FloatToStr(MassSpectrometer.Mass); else; end; end; procedure TFormMain.ApplyCurrentMass; begin if not Assigned(MassSpectrometer) then Exit; try MassSpectrometer.MassX:=StrToFloat_MSG(EditCurrentMass.Text); AddTextToStringsList0(EditCurrentMass); except end; end; procedure TFormMain.ButtonAbortClick(Sender: TObject); begin if not Assigned(MassSpectrometer) then Exit; if not MassSpectrometer.IsON then Exit; if MassSpectrometer.IsError then Exit; MassSpectrometer.Abort; end; procedure TFormMain.ComboBoxPNCCalibrationChange(Sender: TObject); begin if not Assigned(MassSpectrometer) then Exit; ButtonPNCCalibrationChannelDo.Enabled:=ValidComboBoxPNCCalibrationIndex; ProcessPNCCalibration; end; function TFormMain.ValidComboBoxPNCCalibrationIndex:boolean; begin Result:=(ComboBoxPNCCalibration.ItemIndex>=Ord(Low(tChannel))) and (ComboBoxPNCCalibration.ItemIndex<=Ord(High(tChannel))) end; procedure TFormMain.ProcessPNCCalibrationK; begin if not Assigned(MassSpectrometer) then Exit; if not ValidComboBoxPNCCalibrationIndex then begin EditPNCCalibrationK.Text:=''; end else begin EditPNCCalibrationK.Text:=FloatToStr(MassSpectrometer.PNCCalibration[tChannel(ComboBoxPNCCalibration.ItemIndex), pncK]); end; end; procedure TFormMain.ProcessPNCCalibration0; begin if not Assigned(MassSpectrometer) then Exit; if not ValidComboBoxPNCCalibrationIndex then begin EditPNCCalibration0.Text:=''; end else begin EditPNCCalibration0.Text:= FloatToStr(MassSpectrometer.PNCCalibration[tChannel(ComboBoxPNCCalibration.ItemIndex), pncU0]); end; end; procedure TFormMain.ProcessPNCCalibrationZeroLevel; begin if not Assigned(MassSpectrometer) then Exit; if not ValidComboBoxPNCCalibrationIndex then begin EditPNCCalibrationZeroLevel.Text:=''; end else begin EditPNCCalibrationZeroLevel.Text:= FloatToStr(MassSpectrometer.PNCCalibration[tChannel(ComboBoxPNCCalibration.ItemIndex), pncZeroLevel]); end; end; procedure TFormMain.ProcessPNCCalibration; begin ProcessPNCCalibrationK; ProcessPNCCalibration0; ProcessPNCCalibrationZeroLevel; end; procedure TFormMain.EditPNCCalibration0KeyPress(Sender: TObject; var Key: Char); begin if not Assigned(MassSpectrometer) then Exit; if not ValidComboBoxPNCCalibrationIndex then Exit; case Key of #13: begin try MassSpectrometer.PNCCalibration[tChannel(ComboBoxPNCCalibration.ItemIndex), pncU0]:= StrToFloat_MSG(EditPNCCalibration0.Text); finally ProcessPNCCalibration0; end; end; #27: ProcessPNCCalibration0; else; end; end; procedure TFormMain.EditPNCCalibrationKKeyPress(Sender: TObject; var Key: Char); begin if not Assigned(MassSpectrometer) then Exit; if not ValidComboBoxPNCCalibrationIndex then Exit; case Key of #13: begin try MassSpectrometer.PNCCalibration[tChannel(ComboBoxPNCCalibration.ItemIndex), pncK]:= StrToFloat_MSG(EditPNCCalibrationK.Text); except end; ProcessPNCCalibrationK; end; #27: ProcessPNCCalibrationK; else; end; end; procedure TFormMain.EditPNCCalibrationZeroLevelKeyPress(Sender: TObject; var Key: Char); begin if not Assigned(MassSpectrometer) then Exit; if not ValidComboBoxPNCCalibrationIndex then Exit; case Key of #13: begin try MassSpectrometer.PNCCalibration[tChannel(ComboBoxPNCCalibration.ItemIndex), pncZeroLevel]:= StrToFloat_MSG(EditPNCCalibrationZeroLevel.Text); except end; ProcessPNCCalibrationZeroLevel; end; #27: ProcessPNCCalibrationZeroLevel; else; end; end; procedure TFormMain.ProcessISSBMotors; var d:tDevices; begin if not Assigned(MassSpectrometer) then Exit; EditIonizationVoltage.Text:=IntToStr(MassSpectrometer.Device[IonizationVoltage]); EditEmissionCurrent.Text:=IntToStr(MassSpectrometer.Device[EmissionCurrent]); EditExtractingVoltage.Text:=IntToStr(MassSpectrometer.Device[ExtractingVoltage]); EditFocusingVoltage.Text:=IntToStr(MassSpectrometer.Device[FocusingVoltage]); EditCorrectionX.Text:=IntToStr(MassSpectrometer.Device[CorrectionX]); EditCorrectionZ.Text:=IntToStr(MassSpectrometer.Device[CorrectionZ]); LabelIV.Caption:=IntToStr(MassSpectrometer.DeviceIndicators[IonizationVoltage]); LabelEC.Caption:=IntToStr(MassSpectrometer.DeviceIndicators[EmissionCurrent]); LabelEV.Caption:=IntToStr(MassSpectrometer.DeviceIndicators[ExtractingVoltage]); LabelFV.Caption:=IntToStr(MassSpectrometer.DeviceIndicators[FocusingVoltage]); LabelCX.Caption:=IntToStr(MassSpectrometer.DeviceIndicators[CorrectionX]); LabelCZ.Caption:=IntToStr(MassSpectrometer.DeviceIndicators[CorrectionZ]); d:=MassSpectrometer.DevicesValidated; if IonizationVoltage in d then begin EditIonizationVoltage.Font.Style:=[fsBold]; ButtonIonizationVoltage.Enabled:=FALSE; end; if EmissionCurrent in d then begin EditEmissionCurrent.Font.Style:=[fsBold]; ButtonEmissionCurrent.Enabled:=FALSE; end; if ExtractingVoltage in d then begin EditExtractingVoltage.Font.Style:=[fsBold]; ButtonExtractingVoltage.Enabled:=FALSE; end; if FocusingVoltage in d then begin EditFocusingVoltage.Font.Style:=[fsBold]; ButtonFocusingVoltage.Enabled:=FALSE; end; if CorrectionX in d then begin EditCorrectionX.Font.Style:=[fsBold]; ButtonCorrectionX.Enabled:=FALSE; end; if CorrectionZ in d then begin EditCorrectionZ.Font.Style:=[fsBold]; ButtonCorrectionZ.Enabled:=FALSE; end; end; procedure TFormMain.ApplyISSB(Sender: TObject); var d:tDevice; s:string; n:cardinal; i:integer; begin if not Assigned(MassSpectrometer) then Exit; if not Sender.InheritsFrom(TEdit) then Exit; with TEdit(Sender) do begin if (Tag=Ord(High(tDevice))) then Exit; d:=tDevice(Tag); s:=StatusBarMsg.SimpleText; try i:=StrToInt_MSG(Text); n:=MassSpectrometer.DeviceOperationTime_msToSetValue(d,MassSpectrometer.Device[d]); if n>500 then StatusBarMsg.SimpleText:='Ожидайте примерно '+IntToStr(Succ((MassSpectrometer.DeviceOperationTime_ms(d,$FFFF)+500) div 1000))+'c ...'; MassSpectrometer.Device[d]:=i; except end; StatusBarMsg.SimpleText:=s; end; end; procedure TFormMain.EditISSBExit(Sender: TObject); begin if not Assigned(MassSpectrometer) then Exit; if not Sender.InheritsFrom(TEdit) then Exit; with TEdit(Sender) do begin if (Tag=Ord(High(tDevice))) then Exit; Text:=IntToStr(MassSpectrometer.Device[tDevice(Tag)]); end; end; procedure TFormMain.EditISSBKeyPress(Sender: TObject; var Key: Char); begin if not Assigned(MassSpectrometer) then Exit; if not Sender.InheritsFrom(TEdit) then Exit; if (TEdit(Sender).Tag=Ord(High(tDevice))) then Exit; case Key of #13: begin if not WarningISSB(False) then Exit; ApplyISSB(Sender); end; #27: TEdit(Sender).Text:=IntToStr(MassSpectrometer.Device[tDevice(TEdit(Sender).Tag)]); else; end; end; procedure TFormMain.FillInDevices; begin EditIonizationVoltage.Tag:=Ord(IonizationVoltage); UpDownIonizationVoltage.Tag:=Ord(IonizationVoltage); ButtonIonizationVoltage.Tag:=Ord(IonizationVoltage); EditEmissionCurrent.Tag:=Ord(EmissionCurrent); UpDownEmissionCurrent.Tag:=Ord(EmissionCurrent); ButtonEmissionCurrent.Tag:=Ord(EmissionCurrent); EditExtractingVoltage.Tag:=Ord(ExtractingVoltage); UpDownExtractingVoltage.Tag:=Ord(ExtractingVoltage); ButtonExtractingVoltage.Tag:=Ord(ExtractingVoltage); EditFocusingVoltage.Tag:=Ord(FocusingVoltage); UpDownFocusingVoltage.Tag:=Ord(FocusingVoltage); ButtonFocusingVoltage.Tag:=Ord(FocusingVoltage); EditCorrectionX.Tag:=Ord(CorrectionX); UpDownCorrectionX.Tag:=Ord(CorrectionX); ButtonCorrectionX.Tag:=Ord(CorrectionX); EditCorrectionZ.Tag:=Ord(CorrectionZ); UpDownCorrectionZ.Tag:=Ord(CorrectionZ); ButtonCorrectionZ.Tag:=Ord(CorrectionZ); end; procedure TFormMain.FillInDevicesStep; begin if not Assigned(MassSpectrometer) then Exit; UpDownIonizationVoltage.Increment:=MassSpectrometer.DeviceStep[IonizationVoltage]; UpDownEmissionCurrent.Increment:=MassSpectrometer.DeviceStep[EmissionCurrent]; UpDownExtractingVoltage.Increment:=MassSpectrometer.DeviceStep[ExtractingVoltage]; UpDownFocusingVoltage.Increment:=MassSpectrometer.DeviceStep[FocusingVoltage]; UpDownCorrectionX.Increment:=MassSpectrometer.DeviceStep[CorrectionX]; UpDownCorrectionZ.Increment:=MassSpectrometer.DeviceStep[CorrectionZ]; end; procedure TFormMain.ProcessDevices; begin ProcessSEMVoltage; ProcessISSBMotors; end; function TFormMain.WarningISSB(aIgnoreShowNextTime:boolean):boolean; resourcestring rsMessage='Не рекомендуется изменять параметры источника ионов без необходимости.'#13+ 'Изменение параметров может привести к повреждению источника ионов.'; begin if not (fWarningISSB_IsShownOnce in prFlags) or (not aIgnoreShowNextTime and (sfShowWarningISSB in prSupportFlags)) then begin if FormWarningCreate(Self) then begin FormWarning.Msg:=rsMessage; FormWarning.ShowModal; Result:=FormWarning.ModalResult=idOK; if FormWarning.ShowNextTime then Include(prSupportFlags,sfShowWarningISSB) else Exclude(prSupportFlags,sfShowWarningISSB); Include(prFlags,fWarningISSB_IsShownOnce) end else begin Result:=TRUE; end; end else begin Result:=TRUE; end; end; procedure TFormMain.ButtonISSBClick(Sender: TObject); function MessageBoxResetDevice(Dev:tDevice):integer; begin Result:=MessageBox( 'Сейчас шаговый двигатель будет повернут до нижнего предела,'+ ' а затем будет установлено текущее значение для: "'+ cDeviceName[Dev]+ '".'+ #13'_______________________________'+ #13#13'Выполнить операцию?', 'Переустановка параметра источника ионов', MB_YESNO+MB_ICONQUESTION); end; var d:tDevice; begin if not Assigned(MassSpectrometer) then Exit; if not MsON_WithMsg then Exit; if not WarningISSB(false) then Exit; if not Sender.InheritsFrom(TButton) then Exit; if (TButton(Sender).Tag=Ord(High(tDevice))) then Exit; d:=tDevice(TButton(Sender).Tag); if MessageBoxResetDevice(d)=IDYES then begin StatusBarMsg.SimpleText:='Ожидайте примерно '+IntToStr(Succ((MassSpectrometer.DeviceOperationTime_ms(d,$FFFF)+500) div 1000))+'cекунд...'; ProcessMessages; MassSpectrometer.DeviceReset(tDevice(TButton(Sender).Tag)); StatusBarMsg.SimpleText:=''; end; end; procedure TFormMain.UpDownISSBChangingEx(Sender: TObject; var AllowChange: Boolean; NewValue: Smallint; Direction: TUpDownDirection); var d:tDevice; begin if not Assigned(MassSpectrometer) then Exit; if not Sender.InheritsFrom(TUpDown) then Exit; if (TUpDown(Sender).Tag=Ord(High(tDevice))) then Exit; // if WarningISSB(true) then begin if MassSpectrometer.IsON then begin d:=tDevice(TButton(Sender).Tag); MassSpectrometer.DeviceDoStep(d,Direction); AllowChange:=TRUE; end else begin AllowChange:=TRUE; ProcessISSBMotors; end; // AllowChange:=TRUE; // end else begin // ProcessISSBMotors; // AllowChange:=FALSE; // end; end; procedure TFormMain.BitBtnSpecterClick(Sender: TObject); begin if not Assigned(FormSpectrum) then begin FormSpectrum:=tFormSpectrum.CreateX(Self,MassSpectrometer); end; if Assigned(FormSpectrum) then begin if FormSpectrum.WindowState=wsMinimized then FormSpectrum.WindowState:=wsNormal; FormSpectrum.Show; end; end; procedure TFormMain.BitBtnSpectrumXClick(Sender: TObject); begin FreeAndNil(FormSpectrum); end; procedure TFormMain.ButtonISSBAttentionClick(Sender: TObject); resourcestring rsTitle='Регулировка источника ионов'; resourcestring rsText= 'На МИ-1201 АГМ программа не может '+ 'получить положения регуляторов источника ионов.'+ #13' При запуске показываются значения предыдущего '+ 'сеанса работы, но другие программы могут изменить положение регуляторов.'+ #13' Достоверно задать параметры можно только предварительно '+ 'установив регуляторы на нижнюю границу. '+ 'Установка регуляторов на нижний предел нежелательна.'+ #13' ЕСЛИ НЕОБХОДИМО ГАРАНТИРОВАННО установить значение параметра, то '+ 'нажмите кнопку "Уст..." справа от параметра. Регулятор будет выведен на нулевую'+ ' позицию и затем установлен на указанное значение.'+ #13' ЕСЛИ НЕОБХОДИМО ИЗМЕНИТЬ ЗНАЧЕНИЕ '+ 'параметра, относительно указанного в программе, то '+ 'измените его - регулятор изменит положение. '+ #13' При задании большого изменения программа'+ ' выполнит попытку повернуть его ДО ГРАНИЦЫ и установит значение, '+ 'равное максимальному или минимальному.'+ #13' Перейти границу значения невозможно, НО ПРИ КАЖДОЙ ПОПЫТКЕ'+ ' программа пытается повернуть регулятор в указанную сторону'+ ' на указанное число шагов, не более максимального числа шагов регулятора.'; begin MessageBox(rsText, rsTitle, MB_OK+MB_ICONINFORMATION); end; procedure TFormMain.ProcessIntegrationTime; begin if not Assigned(MassSpectrometer) then Exit; EditIntegrationTime.Text:=IntToStr(MassSpectrometer.IntegrationTime); end; procedure TFormMain.EditIntegrationTimeKeyPress(Sender: TObject; var Key: Char); begin if not Assigned(MassSpectrometer) then Exit; case Key of #13: begin try MassSpectrometer.IntegrationTimeX:=StrToInt_MSG(EditIntegrationTime.Text); except EditIntegrationTime.Text:=IntToStr(MassSpectrometer.IntegrationTime) end; end; #27: EditIntegrationTime.Text:=IntToStr(MassSpectrometer.IntegrationTime); else; end; end; procedure TFormMain.ButtonJumpToMassClick(Sender: TObject); begin if not MsON_WithMSG then Exit; if Length(EditCurrentMass.Text)>0 then begin try MassSpectrometer.Stop; ApplyCurrentMass; except end; end; end; procedure TFormMain.ButtonSetAsCurrentMassClick(Sender: TObject); begin if not MsON_WithMSG then Exit; if Length(EditCurrentMass.Text)>0 then begin try MassSpectrometer.Stop; MassSpectrometer.RefineMass(StrToFloat_MSG(EditCurrentMass.Text)); AddTextToStringsList0(EditCurrentMass); except end; end; end; procedure TFormMain.ProcessRunning; begin if MassSpectrometer.StepMultiplicator=0 then SpeedButtonScrollPause.Down:=TRUE else if MassSpectrometer.StepMultiplicator>0 then SpeedButtonScrollRight.Down:=TRUE else SpeedButtonScrollLeft.Down:=TRUE; end; procedure TFormMain.ProcessStart; var s:string; procedure ProcessStep; begin case MassSpectrometer.ScrollDirection of sdNoScroll: SpeedButtonScrollPause.Down:=TRUE; sdUp: SpeedButtonScrollRight.Down:=TRUE; sdDown: SpeedButtonScrollLeft.Down:=TRUE; else SpeedButtonScrollStop.Down:=TRUE; end; end; begin if not Assigned(MassSpectrometer) then Exit; case MassSpectrometer.MeasureState of msErrorStopped: begin s:='Остан. с ОШИБКОЙ'; SpeedButtonScrollStop.Down:=TRUE; end; msNotAvailableStopped: begin s:='Недоступна'; SpeedButtonScrollStop.Down:=TRUE; end; msStopped: begin s:='Остановлена'; SpeedButtonScrollStop.Down:=TRUE; end; msPaused: begin s:='Пауза'; SpeedButtonScrollPause.Down:=TRUE; end; msScroll: begin s:='Развертка'; ProcessStep; end; { msSinglePass: begin s:='Один проход'; ProcessStep; end; msRepeatedlyWithDataReplace: begin s:='Повтор с заменой'; ProcessStep; end; msRepeatedlyWithDataAccumulation: begin s:='Повтор с накоплением'; ProcessStep; end;} else begin s:='Развертка?'; ProcessStep; end; end; StatusBarMain.Panels.Items[3].Text:=s; end; procedure TFormMain.ProcessLimit; begin if not Assigned(MassSpectrometer) then Exit; if MassSpectrometer.MassLimitLow then StatusBarMain.Panels.Items[3].Text:='Нижний предел' else if MassSpectrometer.MassLimitUp then StatusBarMain.Panels.Items[3].Text:='Верхний предел' else StatusBarMain.Panels.Items[3].Text:=''; end; procedure TFormMain.EditStepMulKeyPress(Sender: TObject; var Key: Char); begin if not Assigned(MassSpectrometer) then Exit; case Key of #13: begin try MassSpectrometer.StepMultiplicator:=StrToInt_MSG(EditStepMul.Text); except ProcessStepMultiplicator; end; end; #27: ProcessStepMultiplicator; end; end; procedure TFormMain.ProcessStepMultiplicator; begin if not Assigned(MassSpectrometer) then Exit; EditStepMul.Text:=IntToStr(MassSpectrometer.StepMultiplicator); ProcessMassStepMin; ProcessStart; end; procedure TFormMain.ProcessMassStepMin; begin if not Assigned(MassSpectrometer) then Exit; LabelMassStepMin.Caption:=FloatToStr(MassSpectrometer.MassStepMin); end; procedure TFormMain.ProcessMassStep; begin if not Assigned(MassSpectrometer) then Exit; LabelMassStepCurrent.Caption:=FloatToStr(MassSpectrometer.MassStep); ProcessMassStepMin; ProcessStart; end; procedure TFormMain.ButtonScrollStopClick(Sender: TObject); begin if not MsON_WithMSG then Exit; case MassSpectrometer.MeasureState of msUnknown:; msStopped: MassSpectrometer.Resume; else MassSpectrometer.Stop; end; end; procedure TFormMain.ButtonScrollJumpToLowBoundClick(Sender: TObject); begin if not MsON_WithMSG then Exit; MassSpectrometer.Stop; MassSpectrometer.MassX:=0; end; procedure TFormMain.ButtonScrollJumpToUpBoundClick(Sender: TObject); begin if not MsON_WithMSG then Exit; MassSpectrometer.Stop; MassSpectrometer.MassX:=MassSpectrometer.Counter2Mass(Pred(High(tCounter))); end; procedure TFormMain.ButtonScrollLeftClick(Sender: TObject); begin if not MsON_WithMSG then Exit; case MassSpectrometer.MeasureState of msUnknown, msErrorStopped:; msStopped: begin MassSpectrometer.Resume; if MassSpectrometer.StepMultiplicator>=0 then MassSpectrometer.StepMultiplicator:=-1 end; else begin if MassSpectrometer.StepMultiplicator=0 then MassSpectrometer.StepMultiplicator:=-1 else if MassSpectrometer.StepMultiplicator>0 then MassSpectrometer.StepMultiplicator:=-MassSpectrometer.StepMultiplicator else MassSpectrometer.StepMultiplicator:=2*MassSpectrometer.StepMultiplicator; end; end; end; procedure TFormMain.ButtonScrollRightClick(Sender: TObject); begin if not MsON_WithMSG then Exit; case MassSpectrometer.MeasureState of msUnknown, msErrorStopped:; msStopped: begin MassSpectrometer.Resume; if MassSpectrometer.StepMultiplicator>=0 then MassSpectrometer.StepMultiplicator:=1 end; else begin if MassSpectrometer.StepMultiplicator=0 then MassSpectrometer.StepMultiplicator:=1 else if MassSpectrometer.StepMultiplicator<0 then MassSpectrometer.StepMultiplicator:=-MassSpectrometer.StepMultiplicator else MassSpectrometer.StepMultiplicator:=2*MassSpectrometer.StepMultiplicator; end; end; end; procedure TFormMain.ProcessMeasureType; begin if not Assigned(MassSpectrometer) then Exit; (*case MassSpectrometer.MeasureType of mSinglePass: begin // ComboBoxMeasureType.ItemIndex:=0; end; mRepeatedlyWithDataReplace: begin // ComboBoxMeasureType.ItemIndex:=1; end; mRepeatedlyWithDataAccumulation: begin // ComboBoxMeasureType.ItemIndex:=2; end; else begin // ComboBoxMeasureType.ItemIndex:=-1; end; end;*) end; procedure TFormMain.ButtonScrollPauseClick(Sender: TObject); begin if not Assigned(MassSpectrometer) or not MassSpectrometer.IsON then begin MessageBoxMsIsOFF; Exit; end; MassSpectrometer.StepMultiplicator:=0; MassSpectrometer.Resume; end; procedure TFormMain.ProcessIMChCalibrationK; begin if not Assigned(MassSpectrometer) then Exit; EditIMChCalibrationK.Text:=FloatToStr(MassSpectrometer.IMCh_K); end; procedure TFormMain.ProcessIMChCalibrationM0; begin if not Assigned(MassSpectrometer) then Exit; EditIMChCalibrationM0.Text:=FloatToStr(MassSpectrometer.IMCh_M0); end; procedure TFormMain.ProcessIMChCalibration; begin ProcessIMChCalibrationK; ProcessIMChCalibrationM0; end; procedure TFormMain.EditIMChCalibrationKKeyPress(Sender: TObject; var Key: Char); begin if not Assigned(prMassSpectrometer) then Exit; case Key of #13: begin try MassSpectrometer.IMCh_K:=StrToFloat_MSG(EditIMChCalibrationK.Text); except ProcessIMChCalibrationK; end; end; #27: begin ProcessIMChCalibrationK; end; end; end; procedure TFormMain.EditIMChCalibrationM0KeyPress(Sender: TObject; var Key: Char); begin if not Assigned(prMassSpectrometer) then Exit; case Key of #13: begin try MassSpectrometer.IMCh_M0:=StrToFloat_MSG(EditIMChCalibrationM0.Text); except ProcessIMChCalibrationM0; end; end; #27: begin ProcessIMChCalibrationM0; end; end; end; procedure TFormMain.ButtonAskIMChClick(Sender: TObject); resourcestring rsTitle='Масса с ИМЧ'; begin if not MsON_WithMSG then Exit; try MessageBox(FloatToStrF(MassSpectrometer.IMCh_Mass,ffGeneral,4,2),rsTitle,MB_OK); except end; end; procedure TFormMain.ButtonSetCurrentMassByIMChClick(Sender: TObject); resourcestring rsTitle='Установка массы по ИМЧ'; rsText1='ВНИМАНИЕ! ИМЧ показывает массу недостаточно точно.'+ #13'____________'+ #13#13'Значение массы по ИМЧ: '; rsText2=' аем.'+ #13'____________'+ #13#13'Установить его как текущее значение массы?'; rsTextErr='ВНИМАНИЕ! ОПЕРАЦИЯ ЧТЕНИЕ ДАННЫХ с ИМЧ завершилась неудачно.'; var m:tMass; begin if not MsON_WithMSG then Exit; if MsERROR_WithMSG then Exit; MassSpectrometer.Stop; m:=MassSpectrometer.IMCh_Mass; if MassSpectrometer.IsError or (m<0) then begin MessageBox(rsTextErr,rsTitle,MB_OK); end else If MessageBox(rsText1+FloatToStr(m)+rsText2,rsTitle,MB_OKCANCEL)=IDOK then begin try MassSpectrometer.RefineMass(m); except end; end; end; procedure TFormMain.ApplyMassStepXExit(Sender: TObject); begin if not Assigned(MassSpectrometer) then Exit; if not Sender.InheritsFrom(TEdit) then Exit; if Length(TEdit(Sender).Text)=0 then Exit; try MassSpectrometer.MassStep:=StrToFloat_MSG(TEdit(Sender).Text); except end; end; procedure TFormMain.EditMassStepXKeyPress(Sender: TObject; var Key: Char); begin if not Assigned(MassSpectrometer) then Exit; case Key of #13: ApplyMassStepXExit(Sender); #27:EditMassStepX.Text:=FloatToStr(MassSpectrometer.MassStep); else; end; end; procedure TFormMain.ButtonSetHardwareZeroClick(Sender: TObject); resourcestring rsTitle='Установка массы по АППАРАТНОМУ 0'; rsText1='ВНИМАНИЕ! Длительная (до 2 минут) и не очень точная установка.'+ #13#9'1) Ток электромагнита будет уменьшен до нижней аппаратной границы.'+ #13#9'2) Для этого значения тока будет установлена масса=0 аем.'+ #13'____________'+ #13#13'Если работает ИМЧ (вольтметр), то лучше установить массу по ИМЧ.'+ #13'____________'+ #13#13'Выполнить операцию?'; begin if not MsON_WithMSG then Exit; If MessageBox(rsText1,rsTitle,MB_OKCANCEL)=IDOK then begin try MassSpectrometer.Stop; MassSpectrometer.MassZeroSetByHardwareX; except end; end; end; procedure TFormMain.ButtonPNCCalibrationDoClick(Sender: TObject); resourcestring rsTitle='Калибровка ПНЧ каналов'; rsText1='ВНИМАНИЕ! Для ВСЕХ каналов ПНЧ будут перевычислен 0-уровень и '+ 'коэффициент перевода импульсов в напряжение.'+ #13'____________'+ #13#13'Выполнить операцию?'; begin if not MsON_WithMSG then Exit; If MessageBox(rsText1,rsTitle,MB_OKCANCEL)=IDOK then begin ProcessMessages; try MassSpectrometer.Stop; MassSpectrometer.PNCCalibrateX; except end; end; end; procedure TFormMain.ButtonPNCCalibrationChannelDoClick(Sender: TObject); resourcestring rsTitle='Калибровка канала '; rsText1='ВНИМАНИЕ! Для канала '; rsText2=' будут перевычислен 0-уровень и '+ 'коэффициент перевода импульсов в напряжение.'+ #13'____________'+ #13#13'Выполнить операцию?'; var c:string; i:integer; begin if not MsON_WithMSG then Exit; if not ValidComboBoxPNCCalibrationIndex then Exit; i:=ComboBoxPNCCalibration.ItemIndex; c:=ComboBoxPNCCalibration.Items[i]; If MessageBox(rsText1+c+rsText2,rsTitle+c,MB_OKCANCEL)=IDOK then begin ProcessMessages; try MassSpectrometer.Stop; MassSpectrometer.PNCCalibrateExX([tChannel(i)]); except end; end; end; procedure TFormMain.ButtonClearAllClick(Sender: TObject); begin ClearAll; end; procedure TFormMain.ProcessInitialCapacity; begin if not Assigned(MassSpectrometer) then Exit; try EditInitialDataStorageCapacity.Text:=IntToStr(MassSpectrometer.InitialCapacity); except end; end; procedure TFormMain.ProcessInitialDataSize; begin if not Assigned(MassSpectrometer) then Exit; try LabelInitialDataSize.Caption:='~'+IntToStr(MassSpectrometer.InitialDataSize)+' байт.'; except end; end; procedure TFormMain.EditInitialDataStorageCapacityExit(Sender: TObject); begin EditDefaultExit(Sender); ProcessInitialCapacity; end; procedure TFormMain.EditInitialDataStorageCapacityKeyPress( Sender: TObject; var Key: Char); begin if not Assigned(prMassSpectrometer) then Exit; case Key of #13: begin try MassSpectrometer.InitialCapacity:=StrToInt_MSG(EditInitialDataStorageCapacity.Text); except ProcessInitialCapacity; end; end; #27: begin ProcessInitialCapacity; end; end; end; procedure TFormMain.ProcessMassSpDestroyFast; begin prMassSpectrometer:=NIL; Synchronize(ProcessMassSpDestroy); end; procedure TFormMain.ProcessMassSpDestroy; begin // ProcessALL; end; procedure TFormMain.ProcessMainChannel; begin if Assigned(MassSpectrometer) then begin ComboBoxMainChannel.ItemIndex:=Ord(MassSpectrometer.MainChannel); end else begin ComboBoxMainChannel.ItemIndex:=-1; end; end; procedure TFormMain.ComboBoxMainChannelChange(Sender: TObject); begin if Assigned(MassSpectrometer) then begin try MassSpectrometer.MainChannel:=tSeries(ComboBoxMainChannel.ItemIndex); except ProcessMainChannel; end; end else begin ComboBoxMainChannel.ItemIndex:=-1; end; end; procedure TFormMain.ProcessEmergency; var EFs:tCtrlFlags; begin if not Assigned(MassSpectrometer) then Exit; if not Assigned(FormEmergencySignals) then try FormEmergencySignals:=TFormEmergencySignals.Create(Self); except FormEmergencySignals:=NIL; end; if Assigned(FormEmergencySignals) then begin EFs:=MassSpectrometer.EmergencyFlags; if MassSpectrometer.IsNoError then begin FormEmergencySignals.Show; if MassSpectrometer.IsPowerON then begin FormEmergencySignals.LabelOverload.Visible:=(fOverload in EFs); FormEmergencySignals.LabelCatodBurnOut.Visible:=not (fCatodOK in EFs); FormEmergencySignals.LabelPowerOff.Visible:=FALSE; end else begin FormEmergencySignals.LabelOverload.Visible:=FALSE; FormEmergencySignals.LabelCatodBurnOut.Visible:=FALSE; FormEmergencySignals.LabelPowerOff.Visible:=TRUE; end; end; end; end; procedure TFormMain.ProcessRanges; var i,n:integer; s:string; r:tRange; begin CheckListBoxRanges.Clear; if Assigned(MassSpectrometer) then begin try for i:=0 to Pred(MassSpectrometer.Ranges.Count) do begin r:=MassSpectrometer.Ranges[i]; s:=r.RangeCaption(i); n:=CheckListBoxRanges.Items.Add(s); CheckListBoxRanges.Checked[n]:=r.Enabled; end; CheckListBoxRanges.Enabled:=TRUE; except CheckListBoxRanges.Clear; end; end else begin CheckListBoxRanges.Enabled:=FALSE; end; end; (*procedure TFormMain.ProcessRangeCategoryList; var i,n:integer; s:string; begin if Assigned(MassSpectrometer) then begin { try for i:=0 to Pred(MassSpectrometer.Ranges.Categories.Count) do begin s:=MassSpectrometer.Ranges.Categories[i]; if ComboBoxRangeCategory.Items.IndexOf(s)=-1 then begin ComboBoxRangeCategory.Items.Add(s) end; end; CheckListBoxRanges.Enabled:=TRUE; except CheckListBoxRanges.Clear; end;} end; end;*) procedure TFormMain.ProcessRangesChecked; var i:integer; begin if Assigned(MassSpectrometer) then begin if MassSpectrometer.Ranges.Count=CheckListBoxRanges.Items.Count then try for i:=0 to Pred(MassSpectrometer.Ranges.Count) do begin if i=0 then begin RangeApply(MassSpectrometer.Ranges[Result]); end; ProcessRanges; except end; end; end; procedure TFormMain.RangeDelete(ARangeIndex:integer); begin if Assigned(MassSpectrometer) then begin if (ARangeIndex>=0) and (ARangeIndex'' then try min:=StrToFloat_MSG(EditRangeMassMin.Text); except end; max:=0; if EditRangeMassMax.Text<>'' then try max:=StrToFloat_MSG(EditRangeMassMax.Text); except end; if min>max then begin x:=max; max:=min; min:=x; end; x:=0; if EditRangeMassStep.Text<>'' then try x:=StrToFloat_MSG(EditRangeMassStep.Text); except end; t:=0; if EditRangeTime.Text<>'' then try t:=StrToInt_MSG(EditRangeTime.Text); except end; ARange.Description:=EditRangeDescription.Text; ARange.Min:=min; ARange.Max:=max; ARange.Step:=x; ARange.IntegrationTime:=t; ARange.ClearOnStart:=CheckBoxRangeClear.Checked; ARange.UseExistingPoints:=CheckBoxRangeUseExistingPoints.Checked; ARange.Accumulation:=tRangeState(CheckBoxRangeAccumulation.State); FillInRange(ARange); end; end; procedure TFormMain.ButtonAddClick(Sender: TObject); begin CheckListBoxRanges.ItemIndex:=RangeAdd; end; procedure TFormMain.ButtonDeleteClick(Sender: TObject); var i:integer; begin i:=CheckListBoxRanges.ItemIndex; RangeDelete(CheckListBoxRanges.ItemIndex); if i=0) and (CheckListBoxRanges.ItemIndex=0) and (i=0) and (CheckListBoxRanges.ItemIndex=0) and (CheckListBoxRanges.ItemIndex=Pred(CheckListBoxRanges.Items.Count)) then Exit; CheckListBoxRanges.ItemIndex:=MassSpectrometer.Ranges.MoveDown(CheckListBoxRanges.ItemIndex); end; procedure TFormMain.CheckBoxRangeClearClick(Sender: TObject); begin CheckBoxRangeUseExistingPoints.Enabled:=not CheckBoxRangeClear.Checked; end; procedure TFormMain.CheckBoxUseRangesClick(Sender: TObject); begin CheckBoxSwitches(Sender); EditMassStepX.Enabled:=not CheckBoxUseRanges.Checked; CheckBoxAccumulation.Enabled:=not CheckBoxUseRanges.Checked; EditIntegrationTime.Enabled:=not CheckBoxUseRanges.Checked; end; procedure TFormMain.ComboBoxRangeCategoryClick(Sender: TObject); begin if not Assigned(MassSpectrometer) then Exit; // if ComboBoxRangeCategory.ItemIndex=-1 then Exit; // MassSpectrometer.Ranges.Category:=ComboBoxRangeCategory.Items[ComboBoxRangeCategory.ItemIndex]; end; procedure TFormMain.ProcessAutoMassScaleSyncWithIMChValue; begin if not Assigned(MassSpectrometer) then Exit; EditAutoMassScaleSyncWithIMChValue.Text:=FloatToStr(MassSpectrometer.AutoMassScaleSyncWithIMChValue); end; procedure TFormMain.ProcessDoAutoMassScaleSyncWithIMCh; resourcestring rsSyncWithIMChMessage='Проведена синхронизация с ИМЧ: '; begin if not Assigned(MassSpectrometer) then Exit; pSyncWithIMChMessage.Caption:=rsSyncWithIMChMessage+IntToStr(MassSpectrometer.AutoMassScaleSyncWithIMChCount); end; procedure TFormMain.EditAutoMassScaleSyncWithIMChValueKeyPress( Sender: TObject; var Key: Char); begin case Key of #13: begin if not Assigned(MassSpectrometer) then Exit; try MassSpectrometer.AutoMassScaleSyncWithIMChValue:=StrToFloat_MSG(EditAutoMassScaleSyncWithIMChValue.Text); except ProcessAutoMassScaleSyncWithIMChValue; end; end; #27: ProcessAutoMassScaleSyncWithIMChValue; end; end; procedure TFormMain.TabSheetMassShow(Sender: TObject); begin ProcessCurrentMass; end; procedure TFormMain.TabSheetMeasureShow(Sender: TObject); begin ProcessCurrentMass; end; procedure TFormMain.ButtonAboutClick(Sender: TObject); begin AboutShow; end; procedure TFormMain.EditConfigFileNameExit(Sender: TObject); begin EditDefaultExit(Sender); ProcessConfigFileName; end; procedure TFormMain.EditMassCalibrationKExit(Sender: TObject); begin ProcessMassCalibrationK; end; procedure TFormMain.EditMassCalibrationM0Exit(Sender: TObject); begin ProcessMassCalibrationM0; end; procedure TFormMain.EditIMChCalibrationKExit(Sender: TObject); begin ProcessIMChCalibrationK; end; procedure TFormMain.EditIMChCalibrationM0Exit(Sender: TObject); begin ProcessIMChCalibrationM0; end; procedure TFormMain.EditAutoMassScaleSyncWithIMChValueExit( Sender: TObject); begin EditDefaultExit(Sender); ProcessAutoMassScaleSyncWithIMChValue; end; procedure TFormMain.EditSourceExit(Sender: TObject); var sr:tSource; begin if not Assigned(prMassSpectrometer) then Exit; if not TObject(Sender).InheritsFrom(TEdit) then Exit; with TEdit(Sender) do begin if not Enabled then Exit; if not (Tag in [Ord(Low(sr))..Ord(High(sr))]) then Exit; sr:=tSource(Tag); Text:=IntToStr(prMassSpectrometer.ValveAutoCloseTimes[sr]); end; end; procedure TFormMain.EditSEMExit(Sender: TObject); begin EditDefaultExit(Sender); ProcessSEMVoltage; end; procedure TFormMain.EditIntegrationTimeExit(Sender: TObject); begin EditDefaultExit(Sender); ProcessIntegrationTime; end; procedure TFormMain.EditPNCCalibrationKExit(Sender: TObject); begin EditDefaultExit(Sender); ProcessPNCCalibrationK; end; procedure TFormMain.EditPNCCalibrationZeroLevelExit(Sender: TObject); begin EditDefaultExit(Sender); ProcessPNCCalibrationZeroLevel; end; procedure TFormMain.EditStepMulExit(Sender: TObject); begin EditDefaultExit(Sender); ProcessStepMultiplicator; end; procedure TFormMain.DoMinimize(Sender: TObject); begin WindowState:=wsMinimized; end; procedure TFormMain.UpDownStepMulClick(Sender: TObject; Button: TUDBtnType); begin try MassSpectrometer.StepMultiplicator:=StrToInt(EditStepMul.Text); except end; end; procedure TFormMain.FormCanResize(Sender: TObject; var NewWidth, NewHeight: Integer; var Resize: Boolean); begin if NewHeight<>0 then ProcessCurrentMass; end; procedure TFormMain.WMSysCommand(var Message: TWMSysCommand); begin Inherited; with Message do begin if (CmdType and $FFF0 = SC_MINIMIZE) and not RunDllStarted then WindowState:=wsMinimized; end; end; procedure TFormMain.MessageCloseWarningForMathCAD; resourcestring rsTitle='Завершение программы в MathCAD'; rsMsg= 'Для завершения программы МИ-1201 АГМ в MathCAD' +#13'закройте главное окно MathCAD.' +#13'________________________________' +#13 +#13'Сейчас и при следующих нажатиях на кнопку "X"' +#13'окно МИ-1201 АГМ будет минимизировано.'; begin MessageBox(rsMsg, rsTitle, MB_OK+MB_ICONINFORMATION); end; procedure TFormMain.EditDataAutoSaveExit(Sender: TObject); begin EditDefaultExit(Sender); ProcessDataAutoSaveInterval; end; procedure TFormMain.ProcessDataAutoSaveInterval; begin if Assigned(MassSpectrometer) then begin EditDataAutoSave.Text:=IntToStr(MassSpectrometer.DataAutoSaveInterval); end; end; procedure TFormMain.ProcessDataAutoSaveEnable; begin if Assigned(MassSpectrometer) then begin cbDataAutoSave.Checked:=mstAutosaveDataOnInterval in MassSpectrometer.Switches; end; end; procedure TFormMain.ProcessDataAutoSaveCount; begin if Assigned(MassSpectrometer) then begin lDataAutoSaveCount.Caption:='('+IntToStr(MassSpectrometer.DataAutoSaveCount)+')'; end; end; procedure TFormMain.EditDataAutoSaveKeyPress(Sender: TObject; var Key: Char); begin if not Assigned(MassSpectrometer) then Exit; case Key of #13: begin try MassSpectrometer.DataAutoSaveInterval:=StrToInt_MSG(EditDataAutoSave.Text); except end; ProcessDataAutoSaveInterval; end; #27: ProcessDataAutoSaveInterval; else; end; end; procedure TFormMain.EditCurrentMassKeyPress(Sender: TObject; var Key: Char); begin if not Assigned(MassSpectrometer) then Exit; case Key of #13: ApplyCurrentMass; #27: EditCurrentMass.Text:=FloatToStr(MassSpectrometer.Mass); else; end; end; procedure TFormMain.btApplyClick(Sender: TObject); begin aVEUVoltageExecute(Sender); end; procedure TFormMain.aVEUVoltageExecute(Sender: TObject); begin if not Assigned(prMassSpectrometer) then Exit; try MassSpectrometer.Device[SEM_Voltage]:=StrToInt_MSG(GetIntStr(EditSEM.Text)); except EditSEM.Text:=IntToStr(MassSpectrometer.Device[SEM_Voltage]); end; end; procedure TFormMain.MessageEventBUG(var Msg: TMsg; var Handled: Boolean); begin if ((Msg.wParam=27) and (Msg.message=258)) or ((Msg.wParam=13) and (Msg.message=258)) then Handled:=TRUE; end; END.