public static Meranie loadMeranie(int headerId) { DbCommunication d=new DbCommunication(); DataRow header=d.header(headerId).Tables[0].Rows[0]; MeasurementParameters parametre = new MeasurementParameters( header["name"].ToString(), header["ion_type"].ToString().Equals("true"), header["note"].ToString(), (int)header["cycles"]); string x = ""; string y = ""; if (header["type_name"].Equals("Energy Scan")) { EnergyScanParameters pp=new EnergyScanParameters(); pp.StartPoint= (double)header["start_point"]; pp.EndPoint= (double)header["end_point"]; pp.Constant= Convert.ToInt32(header["constant"]); pp.StepTime= (double)header["steptime"]; pp.NumberOfSteps=(int)header["pocet_krokov"]; parametre.EnergyScan=pp; parametre.Typ = "Energy Scan"; x = "Electron energy"; y = "m/z"; } else if (header["type_name"].Equals("Mass Scan")) { MassScanParameters mp = new MassScanParameters(); mp.StartPoint = (int)header["start_point"]; mp.EndPoint = (int)header["end_point"]; mp.Constant = (double)header["constant"]; mp.TimePerAmu = (double)header["time_for_amu"]; mp.Density = (double)header["density"]; parametre.MassScan = mp; parametre.Typ = "Mass Scan"; x = "m/z"; y = "Electron energy"; } else if (header["type_name"].Equals("2D Scan")){ EnergyScanParameters ep = new EnergyScanParameters(); ep.StartPoint = (double)header["e_start_point"]; ep.EndPoint = (double)header["e_end_point"]; ep.StepTime = (double)header["e_steptime"]; ep.NumberOfSteps = (int)header["pocet_krokov"]; parametre.EnergyScan = ep; MassScanParameters mp = new MassScanParameters(); mp.StartPoint = (int)header["m_start_point"]; mp.EndPoint = (int)header["m_end_point"]; mp.TimePerAmu = (double)header["time_for_amu"]; mp.Density = (double)header["density"]; parametre.Typ = "2D Scan"; parametre.MassScan = mp; x = "m/z"; y = "Electron energy"; } Meranie m=new Meranie(parametre); m.cykly = new List<CyklusMerania>(); for (int c = 0; c < (int)header["cycles"]; c++) { CyklusMerania cyklus = new CyklusMerania(c); cyklus.KrokyMerania = new List<KrokMerania>(); DataTable data=d.meranie(headerId,c).Tables[0]; for (int i=0;i<data.Rows.Count ;i++ ) { KrokMerania krok = new KrokMerania(); krok.Intensity= (ulong)data.Rows[i]["Intensity"]; krok.Temperature = (double)data.Rows[i]["Temperature"]; krok.Chamber = (double)data.Rows[i]["Chamber pressure"]; krok.Capillar = (double)data.Rows[i]["Capillar pressure"]; krok.X = (double)data.Rows[i][x]; krok.Y = (double)data.Rows[i][y]; cyklus.KrokyMerania.Add(krok); } m.cykly.Add(cyklus); } return m; }
/// <summary> /// tato metoda da do fieldu parametreMerania parametre merania konkretneho typu /// </summary> private void nastavParametre() { try { validateName(); parametreMerania=new MeasurementParameters( nameField.Text, positiveIon.Checked, noteField.Text, Convert.ToInt32(pocetCyklovField.Value), testRun ); if (typyMeraniaTaby.SelectedTab.Text.Equals("Energy scan")) { validateEnergyScanTab(); EnergyScanParameters energyscan = new EnergyScanParameters( Convert.ToDouble(startPointFieldEs.Text), Convert.ToDouble(endPointFieldEs.Text), Convert.ToInt32(constantFieldEs.Text), Convert.ToDouble(stepTimeFieldEs.Text), Convert.ToInt32(pocetKrokovFieldEs.Text) ); parametreMerania.Resolution = Convert.ToDouble(resolutionFieldEs.Text); parametreMerania.EnergyScan = energyscan; parametreMerania.Typ = "Energy Scan"; ulozParametreEnergyScan(); } else if (typyMeraniaTaby.SelectedTab.Text.Equals("Mass scan")) { validateMassScanTab(); MassScanParameters massScan=new MassScanParameters( Convert.ToInt32(startPointFieldMs.Text), Convert.ToInt32(endPointFieldMs.Text), Convert.ToDouble(constantFieldMs.Text), (int)DensOfMeasFieldMs.SelectedValue, (double) timePerAmuFieldMs.SelectedValue ); parametreMerania.Typ = "Mass Scan"; parametreMerania.Resolution= Convert.ToDouble(resolutionFieldMs.Text); parametreMerania.MassScan = massScan; ulozParametreMassScan(); } else if (typyMeraniaTaby.SelectedTab.Text.Equals("2D scan")) { validateMass2DScanTab(); EnergyScanParameters energyScan = new EnergyScanParameters( Convert.ToDouble(startPointField2DEs.Text), Convert.ToDouble(endPointField2DEs.Text), 0, Convert.ToDouble(steptimeField2DEs.Text), Convert.ToInt32(pocetKrokovField2DEs.Text) ); MassScanParameters massScan = new MassScanParameters( Convert.ToInt32(startPointField2DMs.Text), Convert.ToInt32(endPointField2DMs.Text), 0, (int)DensOfMeasField2DMS.SelectedValue, (double)timePerAmuField2DMs.SelectedValue ); parametreMerania.Typ = "2D Scan"; parametreMerania.Resolution= Convert.ToDouble(resolutionField2D.Text); parametreMerania.EnergyScan = energyScan; parametreMerania.MassScan = massScan; ulozParametre2DScan(); } } catch (ValidateParametersException e) { throw e; } }