unit MCAD_MI1201_FormPeakCentripetal; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls, Buttons, ActnList, Grids, ComCtrls, MCAD_MI1201_XForm, MCAD_MI1201_Thread_Types, MCAD_MI1201_Thread2, MCAD_MI1201_Thread, MCAD_MI1201_ThreadPeakCentering, Menus; type TFormPeakCentripetal = class(TXForm) FormPeakCentripetalActionList: TActionList; ActionMain: TAction; SetCurMassAction: TAction; BreakAction: TAction; NoiseRatioFormAction: TAction; PageControl1: TPageControl; FindTabSheet: TTabSheet; TuningTabSheet: TTabSheet; GroupBox1: TGroupBox; MassSetComboBox: TComboBox; BitBtn1: TBitBtn; CheckBox1: TCheckBox; BitBtn3: TBitBtn; GroupBoxParameterPeak: TGroupBox; Center: TLabel; MaxSignal: TLabel; LeftBorder: TLabel; RightBorder: TLabel; GroupBox2: TGroupBox; ColonLabel: TLabel; BackGroundLabel: TLabel; PeakLabel: TLabel; BackGroundCombo: TComboBox; PeakCombo: TComboBox; Apply: TButton; Help: TButton; StatusBar1: TStatusBar; RadioGroup1: TRadioGroup; PeakGrid: TStringGrid; procedure DataShowOnForm; procedure ActionMainExecute(Sender: TObject); procedure SetCurMassActionExecute(Sender: TObject); procedure BreakActionExecute(Sender: TObject); procedure ComboBoxItemsFill(ComboB: TComboBox); procedure ApplyClick(Sender: TObject); procedure RadioGroup1IndexCheck; procedure CheckBox1Click(Sender: TObject); private procedure NotifyHandler(Sender:TObject; Event:tMI1201_Thread_Event); override; function Dialog(Sender: TObject):boolean; procedure NoiseRatioFilling; procedure InitFilling; public constructor Create(AOwner:TComponent); override; end; const PeakGridRowsName:array[0..3] of string[30]= ('Öåíòð','Ìàêñèìàëüíûé ñèãíàë','Ëåâûé êðàé','Ïðàâûé êðàé'); var FormPeakCentripetal: TFormPeakCentripetal; implementation //uses PeakCentering_Dialog; {$R *.DFM} constructor TFormPeakCentripetal.Create(AOwner:TComponent); begin Inherited Create(AOwner); InitFilling; end; procedure TFormPeakCentripetal.InitFilling; var i:byte; begin try BackGroundCombo.Text:='10'; PeakCombo.Text:='1'; RadioGroup1.ItemIndex:=1; ComboBoxItemsFill(BackGroundCombo); ComboBoxItemsFill(PeakCombo); PeakGrid.Height:=GroupBoxParameterPeak.Height-5*PeakGrid.GridLineWidth-16; PeakGrid.Width:=GroupBoxParameterPeak.Width-3*PeakGrid.GridLineWidth-16; PeakGrid.ColWidths[0]:=175; PeakGrid.ColWidths[1]:=PeakGrid.Width - 175-8*PeakGrid.GridLineWidth; for i:=0 to 3 do begin PeakGrid.Rows[i].Text:=PeakGridRowsName[i]; end; except end; end; procedure TFormPeakCentripetal.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 MassSpectrometerNIL; end; evPeakCenter:case Event.ParameterB of ord(mevStart): begin StatusBar1.Panels[0].Text:='ÈÄÅÒ ÏÎÈÑÊ...'; BitBtn1.Action:=BreakAction; BitBtn1.Caption:='Ïðåðâàòü'; MassSpectrometer.FlagStatus:= MassSpectrometer.FlagStatus +[pcRunning]; end; ord(mevEnd): begin statusBar1.Panels[0].Text:='ÏÎÈÑÊ ÇÀÂÅÐØÅÍ'; Synchronize(DataShowOnForm); //BitBtn1.Caption:='Íàéòè'; BitBtn1.Action:=ActionMain; BitBtn1.Caption:='Íàéòè'; MassSpectrometer.FlagStatus:= MassSpectrometer.FlagStatus -[pcRunning]; end; ord(mevBreak): begin statusBar1.Panels[0].Text:='ÏÎÈÑÊ ÏÐÅÐÂÀÍ'; BitBtn1.Action:=ActionMain; BitBtn1.Caption:='Íàéòè'; MassSpectrometer.FlagStatus:= MassSpectrometer.FlagStatus -[pcRunning]; end; end; end;{case} except end; end; procedure TFormPeakCentripetal.DataShowOnForm; begin if Assigned(MassSpectrometer) then try with MassSpectrometer do begin PeakGrid.Cells[1,0]:=FloatToStrF(GetPeakParameter.Center,ffNumber,7,4); PeakGrid.Cells[1,1]:=FloatToStrF(GetPeakParameter.MaxSignal,ffNumber,7,4); PeakGrid.Cells[1,2]:=FloatToStrF(GetPeakParameter.LeftBorder,ffNumber,7,4); PeakGrid.Cells[1,3]:=FloatToStrF(GetPeakParameter.RightBorder,ffNumber,7,4); end; except end; end; procedure TFormPeakCentripetal.ActionMainExecute(Sender: TObject); begin if Assigned(MassSpectrometer) then begin try MassSpectrometer.FlagStatus:=[]; MCAD_MI1201_ThreadPeakCentering.tMsThread(MassSpectrometer).PeakCenterMass0:=StrToFloat_MSG(MassSetComboBox.Text); ComboBoxItemsFill(MassSetComboBox); if CheckBox1.Checked then MassSpectrometer.FlagStatus:=[pcReMeasure]; NoiseRatioFilling; MassSpectrometer.FindPeakCenterX; except end; end; end; procedure TFormPeakCentripetal.SetCurMassActionExecute(Sender: TObject); begin if Assigned(MassSpectrometer) then try MassSetComboBox.Text:=FloatToStr(MassSpectrometer.Mass); MassSetComboBox.SetFocus; except end; end; procedure TFormPeakCentripetal.BreakActionExecute(Sender: TObject); begin if Assigned(MassSpectrometer) then try MassSpectrometer.FlagStatus:=MassSpectrometer.FlagStatus+[pcBreak]; except end; end; procedure TFormPeakCentripetal.ComboBoxItemsFill(ComboB:TComboBox); var i:integer; begin for i:=0 to ComboB.Items.Count-1 do if ComboB.Text=ComboB.Items[i] then exit; ComboB.Items.Add(ComboB.Text); end; procedure TFormPeakCentripetal.ApplyClick(Sender: TObject); begin ComboBoxItemsFill(BackGroundCombo); ComboBoxItemsFill(PeakCombo); if pcRunning in MassSpectrometer.FlagStatus then begin if Dialog(Sender) then begin MassSpectrometer.FlagStatus:=MassSpectrometer.FlagStatus +[pcBreak]; NoiseRatioFilling; end; end else NoiseRatioFilling; end; procedure TFormPeakCentripetal.NoiseRatioFilling; var CurNoiseRatio:tNoiseRatio; begin try CurNoiseRatio.BackGround:=StrToFloat_MSG(BackGroundCombo.Text); CurNoiseRatio.Peak:=StrToFloat_MSG(PeakCombo.Text); MassSpectrometer.NoiseRatioValue:=CurNoiseRatio; RadioGroup1IndexCheck; except end; end; function TFormPeakCentripetal.Dialog(Sender: TObject):boolean; begin Result:=True; exit; { if not Assigned(MassSpectrometer) then Exit; try if not Assigned(OKBottomDlg) then begin OKBottomDlg.Create(Self); OKBottomDlg.Show; end else begin OKBottomDlg.Show; end; if OKBottomDlg.ClickResult then Result:=True; except end; } end; procedure TFormPeakCentripetal.RadioGroup1IndexCheck; begin case RadioGroup1.ItemIndex of 0: try MassSpectrometer.FlagStatus:=MassSpectrometer.FlagStatus -[pcInterpolate]; except end; 1: try MassSpectrometer.FlagStatus:=MassSpectrometer.FlagStatus+[pcInterpolate]; except end; end; end; procedure TFormPeakCentripetal.CheckBox1Click(Sender: TObject); begin if not Assigned(MassSpectrometer) then exit; if CheckBox1.Checked then try MassSpectrometer.FlagStatus:=MassSpectrometer.FlagStatus-[pcInterpolate]; RadioGroup1.ItemIndex:=0; RadioGroup1.Enabled:=False; except end else RadioGroup1.Enabled:=True; end; End.