unit uMainForm; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, Menus, ComCtrls, ExtCtrls, Spin, Grids, MMTimer; type TMainForm = class(TForm) PageControl1: TPageControl; tsGeneral: TTabSheet; ts_Roll: TTabSheet; tsPeakGener: TTabSheet; rgModePeak: TRadioGroup; bSaveParams: TButton; gbParamModePeak: TGroupBox; PanelMode0: TPanel; eCountPeak: TSpinEdit; lCountPeak: TLabel; lMass: TLabel; eMimM: TSpinEdit; eMaxM: TSpinEdit; lMinM: TLabel; lMaxM: TLabel; lAmpl: TLabel; lMinA: TLabel; eMinA: TSpinEdit; lMaxA: TLabel; eMaxA: TSpinEdit; lSigmas: TLabel; lSigmaSigma: TLabel; eSigma: TSpinEdit; eSigmaSigma: TSpinEdit; eNoise0: TSpinEdit; lNoise0: TLabel; PanelMode2: TPanel; lNameSpectrFile: TLabel; eNameSpectrFile: TEdit; bNameSpectrFile: TButton; PanelMode1: TPanel; lNamePeakFile: TLabel; eNamePeakFile: TEdit; bNamePeakFile: TButton; OpenDialog: TOpenDialog; tsCVF: TTabSheet; gbCM: TGroupBox; lRollCounter: TLabel; stRollCounter: TStaticText; eRollCounter: TEdit; eMassCounter: TEdit; stMassCounter: TStaticText; lMassCounter: TLabel; lMassCounterCoef: TLabel; eMassCounterCoef: TEdit; lMCComment: TLabel; StatusBar1: TStatusBar; lMass0: TLabel; ImageMassCalibration: TImage; eMass0: TEdit; ldC: TLabel; pcMassScale: TPageControl; tsCounterCoef: TTabSheet; gbMassScale: TGroupBox; tsShiftChannel: TTabSheet; gbCounterCoef: TGroupBox; gbShiftChannel: TGroupBox; strgShiftChannel: TStringGrid; gbCoefCVF: TGroupBox; strgCoefCVF: TStringGrid; lSigma: TLabel; lNoise1: TLabel; eNoise1: TSpinEdit; edC: TEdit; procedure FormCreate(Sender: TObject); procedure eRollCounterKeyPress(Sender: TObject; var Key: Char); procedure bSaveParamsClick(Sender: TObject); procedure rgModePeakClick(Sender: TObject); procedure eMassCounterKeyPress(Sender: TObject; var Key: Char); procedure bNamePeakFileClick(Sender: TObject); procedure bNameSpectrFileClick(Sender: TObject); private procedure LockObj; // отключаем управление элементами при запуске эмулятора не по коменде RUN procedure ValueSet; // устанавливаем значения элементов в соотв. прочитанными из файла параметров protected procedure SetUnRollingCounter(xC:cardinal); public { Public declarations } end; var MainForm: TMainForm; implementation uses Math, Hardware, Peak, Controller_UnRolling; {$R *.dfm} //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- procedure TMainForm.FormCreate(Sender: TObject); begin ValueSet; //Подписываем столбцы в таблицах формы strgShiftChannel.Cells[0,0]:='Канал'; strgShiftChannel.Cells[1,0]:='C сдвиг/масса'; strgShiftChannel.Cells[0,1]:='ПНЧ1'; strgShiftChannel.Cells[0,2]:='ПНЧ2'; strgShiftChannel.Cells[0,3]:='ПНЧ3'; strgShiftChannel.Cells[0,4]:='ПНЧ4'; strgShiftChannel.Cells[0,5]:='ПНЧ5'; strgShiftChannel.Cells[0,6]:='ПНЧ6'; strgShiftChannel.Cells[0,7]:='ПНЧ7'; strgShiftChannel.Cells[0,8]:='ПНЧ8'; strgShiftChannel.Cells[0,9]:='ВЭУ'; strgShiftChannel.Cells[0,10]:='Счет'; strgCoefCVF.Cells[0,0]:='Канал'; strgCoefCVF.Cells[1,0]:='Коэф., В(имп/мс)'; strgCoefCVF.Cells[0,1]:='ПНЧ1'; strgCoefCVF.Cells[0,2]:='ПНЧ2'; strgCoefCVF.Cells[0,3]:='ПНЧ3'; strgCoefCVF.Cells[0,4]:='ПНЧ4'; strgCoefCVF.Cells[0,5]:='ПНЧ5'; strgCoefCVF.Cells[0,6]:='ПНЧ6'; strgCoefCVF.Cells[0,7]:='ПНЧ7'; strgCoefCVF.Cells[0,8]:='ПНЧ8'; strgCoefCVF.Cells[0,9]:='ВЭУ'; end; //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- procedure TMainForm.SetUnRollingCounter(xC:cardinal); begin TUnRolling(MI1201AGM.Controllers[ctrlUnRolling]).SetCounter(xC); end; //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- procedure TMainForm.eRollCounterKeyPress(Sender: TObject; var Key: Char); var xM:real; xC:tRollCounter; begin if Key=#13 then begin try xC:=StrToInt(eRollCounter.Text); xM:=Params.CounterMassCoef*Power(xC+Params.CounterdC,2); SetUnRollingCounter(xC); stRollCounter.Caption:=eRollCounter.Text; stMassCounter.Caption:=format('%3.3f',[xM]); eMassCounter.Text:=''; eRollCounter.Text:=''; except end; end; end; //----------------------------------------------------------------------------- // Созраняем начальные параметры в файле //----------------------------------------------------------------------------- procedure TMainForm.bSaveParamsClick(Sender: TObject); begin Params.ModeGenPeak:=rgModePeak.ItemIndex; Params.PeakCount:=eCountPeak.Value; Params.MinMass:=eMimM.Value; Params.MaxMass:=eMaxM.Value; Params.MinAmplitude:=eMinA.Value; Params.MaxAmplitude:=eMaxA.Value; Params.Sigma:=eSigma.Value; Params.SigmaSigma:=eSigmaSigma.Value; Params.Noise0:=eNoise0.Value; Params.Noise1:=eNoise1.Value; Params.NamePeakFile:=eNamePeakFile.Text; Params.NameSpectrFile:=eNameSpectrFile.Text; try Params.CounterMassCoef:=StrToFloat(eMassCounterCoef.Text); except end; try Params.CounterdC:=StrToFloat(edC.Text); except end; MI1201AGM.WriteParams; MI1201AGM.ReInitPeaks; end; //----------------------------------------------------------------------------- // делаем неактивными некоторые элементы формы при запуске эмулятора не по команде RUN //----------------------------------------------------------------------------- procedure TMainForm.LockObj; begin bSaveParams.Enabled:=false; rgModePeak.Enabled:=false; PanelMode0.Enabled:=false; PanelMode2.Enabled:=false; // gbMassCounterCoef.Enabled:=false; end; //----------------------------------------------------------------------------- // устанавливаем значения элементов в соотв. прочитанными из файла параметров //----------------------------------------------------------------------------- procedure TMainForm.ValueSet; var aC:cardinal; i:byte; begin aC:=TUnRolling(MI1201AGM.Controllers[ctrlUnRolling]).GetCounter; stRollCounter.Caption:=IntToStr(aC); stMassCounter.Caption:=format('%.3f',[Params.CounterMassCoef*Power(aC,2)]); rgModePeak.ItemIndex:=Params.ModeGenPeak; eCountPeak.Value:=Params.PeakCount; eMimM.Value:=Params.MinMass; eMaxM.Value:=Params.MaxMass; eMinA.Value:=Params.MinAmplitude; eMaxA.Value:=Params.MaxAmplitude; eSigma.Value:=Params.Sigma; eSigmaSigma.Value:=Params.SigmaSigma; eNoise0.Value:=Params.Noise0; eNoise1.Value:=Params.Noise1; rgModePeak.OnClick(rgModePeak); eNameSpectrFile.Text:=Params.NameSpectrFile; eNamePeakFile.Text:=Params.NamePeakFile; eMassCounterCoef.Text:=FloatToStr(Params.CounterMassCoef); edC.Text:=FloatToStr(Params.CounterdC); for i:=1 to 10 do begin strgShiftChannel.Cells[1,i]:=FloatToStr(Params.ShiftChannel[i]); end; end; //----------------------------------------------------------------------------- // выбор режима генерации спекта //----------------------------------------------------------------------------- procedure TMainForm.rgModePeakClick(Sender: TObject); begin case rgModePeak.ItemIndex of 0: PanelMode0.BringToFront; 1: PanelMode1.BringToFront; 2: PanelMode2.BringToFront; end; end; //----------------------------------------------------------------------------- // устанавливаем счетчик магнитов в соответсвии с выбранной массой //----------------------------------------------------------------------------- procedure TMainForm.eMassCounterKeyPress(Sender: TObject; var Key: Char); var xM:real; xC:tRollCounter; begin if Key=#13 then begin try xM:=StrToFloat(eMassCounter.Text); xC:=Round(sqrt((xM)/Params.CounterMassCoef)-Params.CounterdC); SetUnRollingCounter(xC); stRollCounter.Caption:=IntToStr(xC); stMassCounter.Caption:=format('%3.3f',[xM]); eRollCounter.Text:=''; eMassCounter.Text:=''; except end; end; end; //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- procedure TMainForm.bNamePeakFileClick(Sender: TObject); begin if OpenDialog.Execute then begin eNamePeakFile.Text:=OpenDialog.FileName; end; end; //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- procedure TMainForm.bNameSpectrFileClick(Sender: TObject); begin if OpenDialog.Execute then begin eNameSpectrFile.Text:=OpenDialog.FileName; end; end; end.