public void LoadTech(BinaryReader br, MethodSimple method) { Method = method; int ver = br.ReadInt32(); if (ver != 1) { throw new Exception("Wrong version of the SparkConditionTester"); } chbEnabled.Checked = br.ReadBoolean(); ver = br.ReadInt32(); for (int i = 0; i < ver; i++) { Data.Add(new SparkConditionRecord(br)); } ver = br.ReadInt32(); if (ver != 23852983) { throw new Exception("Wrong final of the SparkConditionTester"); } ReInitList(); }
//static bool Tmp = false; static public void Setup(string name, SimpleFormula formula, MethodSimple ms, SpectrView spv, int element_index, int formula_index) { try { if (Dlg == null || Dlg.IsDisposed) { Dlg = new SimpleFormulaEditor(); } else if (CheckSave() == false) { return; } ElementIndex = element_index; FormulaIndex = formula_index; CurrentFormula = null; if (element_index >= 0 && formula_index >= 0) { Dlg.simpleFormula.InitBy(formula, element_index, formula_index); } CurrentFormula = formula; spv.ClearAnalitMarkers(); Dlg.simpleFormula.Element = formula.Element; Dlg.simpleFormula.SetupSpectrView(spv); Dlg.Text = name + " " + formula.Name; //Dlg.Show(); } catch (Exception ex) { Common.Log(ex); } }
public MeasuringSimpleTask(string path, MethodSimple method, string method_path) { Created = true; Path = path; SrcMethodPath = method_path; MemoryStream ms = new MemoryStream(); BinaryWriter bw = new BinaryWriter(ms); method.Save(bw); bw.Flush(); ms.Seek(0, SeekOrigin.Begin); BinaryReader br = new BinaryReader(ms); Data = new MethodSimple(br); Data.ClearProbRecords(); Data.MethodMovedTo(SrcMethodPath, Path); br.Close(); bw.Close(); try { ms.Close(); } catch { } try { ms.Dispose(); } catch { } }
public void update(MethodSimple method, string element, int formula, double ly, bool isConDlt, bool isRel) { //points = new List<Point>(); points.Clear(); Method = method; if (Method == null) { Data = null; } else { Data = DataShotExtractor.extract(method, element, formula, ly, WindowSize, isConDlt, 0, 20000, isRel); if (Data == null || Data.Count == 0) { Data = null; } else { MinValue = float.MaxValue; MaxValue = -float.MaxValue; for (int i = 0; i < Data.Count; i++) { Data[i].checkMinMax(ref MinValue, ref MaxValue); } } } Invalidate(); }
public void Init(MethodSimple ms, int element, int formula) { Method = ms; Element = element; Formula = formula; InitList(); }
public SpectrCalc(MethodSimple ms, int el_index, int formula_index) { MethodSimpleElement mse = ms.GetElHeader(el_index); Formula = mse.Formula[formula_index]; double ly = (double)Formula.Formula.analitParamCalc.methodLineCalc1.nmLy.Value; bool next = Formula.Formula.analitParamCalc.methodLineCalc1.cbFromSnNum.SelectedIndex == 1; int pr_count = ms.GetProbCount(); for (int pr = 0; pr < pr_count; pr++) { List <Data> prob_data = new List <SpectrCalc.Data>(); MethodSimpleProb msp = ms.GetProbHeader(pr); int sp_count = msp.MeasuredSpectrs.Count; for (int sp = 0; sp < sp_count; sp++) { MethodSimpleCell msc = ms.GetCell(el_index, pr); MethodSimpleCellFormulaResult mscfr = msc.GetData(sp, formula_index); MethodSimpleProbMeasuring mspm = msp.MeasuredSpectrs[sp]; if (mscfr.Enabled) { prob_data.Add(new Data(mspm.Sp, (float)msc.Con, ly, next)); } } DataSet.Add(prob_data); } }
public void SetupSpectrView(SpectrView spv, //MethodSimpleProbMeasuring pm, string name, int base_element, int element, int line_num, MethodSimple method ) { Parent = method; BaseElement = base_element; Element = element; if (Element < 0) { throw new Exception("Wrong element index"); } LineNum = line_num; btRecomendations.Enabled = Element > 0; if (spv == null || nmLy.Value == 0) { return; } MName = name + " " + Math.Round((float)nmLy.Value, 2) + (char)0xC5; Spv = spv; //Mspm = pm; Marker = Spv.AddAnalitMarker((float)nmLy.Value, MName, Color.Red, false); //btSetupSp.Enabled = true; Marker.Visible = nmLy.Enabled; }
public void MakeCopy(bool clear) { try { if (lbMainList.SelectedIndex < 0) { return; } string src_name = (string)lbMainList.Items[lbMainList.SelectedIndex]; src_name = src_name.Trim(); string name = util.StringDialog.GetString(MainForm.MForm, Common.MLS.Get(MLSConst, "Создание копии"), Common.MLS.Get(MLSConst, "Введите имя для пустой копии методики: ") + src_name, "", true); if (name == null) { return; } string base_folder = Folder.GetPath() + src_name + "." + DbFDriver.ElementExt; base_folder = Common.Db.GetFoladerPath(base_folder); src_name = base_folder + "\\method"; if (File.Exists(src_name) == false) { return; } Folder.CreateFolder(name + "." + DbFDriver.ElementExt); string dest_folder = Folder.GetPath() + name + "." + DbFDriver.ElementExt; dest_folder = Common.Db.GetFoladerPath(dest_folder); if (clear) { File.Copy(src_name, dest_folder + "\\method"); MethodSimple ms = new MethodSimple(name + "\\method"); ms.ClearProbRecords(); ms.Save(); } else { string[] list = Directory.GetFiles(base_folder); for (int i = 0; i < list.Length; i++) { int ind = list[i].LastIndexOf('\\'); string fname = list[i].Substring(ind + 1); if (!(fname.EndsWith(".sf") || fname.EndsWith(".ss") || fname.IndexOf("method") == 0)) { continue; } File.Copy(list[i], dest_folder + "\\" + fname); } } ReloadList(); ReIntiTree(); } catch (Exception ex) { Common.Log(ex); } }
public void init(string Element, int formula, MethodSimple Method, bool IsAnalit, double defaultLy, double lyFrom, double lyTo) { this.Formula = formula; this.Method = Method; this.Element = Element; this.IsAnalitPriv = IsAnalit; this.DefaultLy = defaultLy; LyFrom = lyFrom; LyTo = lyTo; }
public static List <MethodData> getData(MethodSimple method, int element, int formula, bool use_all, out int used) { MethodSimpleElementFormula msef = method.GetElHeader(element).Formula[formula]; bool[] used_frames = msef.Formula.GetUsedFrames(); List <MethodData> ret = new List <MethodData>(); int prob_count = method.GetProbCount(); used = 0; for (int pr = 0; pr < prob_count; pr++) { MethodSimpleProb m_prob = method.GetProbHeader(pr); MethodSimpleCell m_cell = method.GetCell(element, pr); double con = m_cell.Con; if (con < 0) { continue; } int sub_prob_count = method.GetSubProbCount(pr); for (int sub_pr = 0; sub_pr < sub_prob_count; sub_pr++) { MethodSimpleProbMeasuring m_prob_measuring = m_prob.MeasuredSpectrs[sub_pr]; Spectr sp = m_prob_measuring.Sp; if (sp == null) { continue; } bool en = m_cell.GetData(sub_pr, formula).Enabled; if (use_all == true) { en = true; } int short_count = sp.GetShotCount(); int[] shorts = sp.GetShotIndexes(); for (int short_index = 0; short_index < shorts.Length; short_index++) { bool fl = en & used_frames[short_index]; if (fl) { used++; } MethodData md = new MethodData(con, fl, pr, sub_pr, short_index, sp.GetViewsSet()[shorts[short_index]], sp.GetNullFor(shorts[short_index]), sp.GetCommonDispers()); ret.Add(md); } } } if (ret.Count == 0) { return(null); } return(ret); }
public static List <MethodData> getData(MethodSimple method, int element, int formula) { int used = 0; List <MethodData> ret = getData(method, element, formula, false, out used); if (used == 0) { ret = getData(method, element, formula, true, out used); } return(ret); }
public void ShowSearchDlg(TaskMethodSimple tms, MethodSimpleElementFormula formula, MethodSimple method, SpectrView spv, string element_name, int el_index, int sel_col) { ElementIndex = el_index; ElementName = element_name; TMS = tms; Method = method; Formula = formula; Spv = spv; SelectedCol = sel_col; Sp = spv.GetSpectr(0); if (Sp == null) { MessageBox.Show(MainForm.MForm, Common.MLS.Get(MLSConst, "Необходимо выбрать спектры по котором будет производится привязка к профилю..."), Common.MLS.Get(MLSConst, "Предупреждение"), MessageBoxButtons.OK, MessageBoxIcon.Information); return; } btSearchStart.Text = Common.MLS.Get(MLSConst, MLSStartButtonText); Saved = new MemoryStream(); BinaryWriter bw = new BinaryWriter(Saved); try { Formula.Save(bw); } catch (Exception ex) { Common.LogNoMsg(ex); MessageBox.Show(MainForm.MForm, Common.MLS.Get(MLSConst, "Нельзя подбирать линии для незаконченной формулы..."), Common.MLS.Get(MLSConst, "Предупреждение"), MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (Formula.Formula.SeachBuffer != null) { MemoryStream ms = new MemoryStream(Formula.Formula.SeachBuffer); BinaryReader br = new BinaryReader(ms); int ver = br.ReadInt32(); if (ver == 1) { int size = br.ReadInt32(); for (int i = 0; i < size; i++) { Results.Add(new CalcResult(br)); } br.Close(); ReloadResultList(); } } this.ShowDialog(MainForm.MForm); }
public String ShowSelector(MethodSimple ms, SimpleFormula editor) { cbElementSelector.Items.Clear(); for (int e = 0; e < ms.GetElementCount(); e++) { cbElementSelector.Items.Add(ms.GetElHeader(e).Element.Name); } ShowDialog(editor); if (cbElementSelector.SelectedIndex < 0) { return(null); } return((String)cbElementSelector.Items[cbElementSelector.SelectedIndex]); }
public void initBy(MethodSimple ms, SpectrView spv) { MS = ms; SpView = spv; try { chEnable.Checked = ms.CommonInformation.WorkingCond.PreSparkEnable; nmLy.Value = (decimal)ms.CommonInformation.WorkingCond.PreSparkLy; nmWidth.Value = (decimal)ms.CommonInformation.WorkingCond.PreSparkWidth; nmLevel.Value = (decimal)ms.CommonInformation.WorkingCond.PreSparkLevel; nmExposition.Value = (decimal)ms.CommonInformation.WorkingCond.PreSparkExp; } catch { } }
public void setupShowFilter(string baseElement, string element, int formula, bool isAnalit, bool isComp, MethodSimple method) { Formula = formula; this.Method = method; this.baseElement = baseElement; this.element = element; this.isAnalit = isAnalit; this.isComp = isComp; listboxGOST.Items.Clear(); listboxLines.Items.Clear(); for (int g = 0; g < GOSTList.Count; g++) { GOST gost = GOSTList[g]; listboxGOST.Items.Add(gost.GOSTIndex + " [" + gost.Description + "]"); } }
public MeasuringSimpleTask(string path) { Path = (string)path.Clone(); path += "method"; FileStream fs = DataBase.OpenFile(ref path, FileMode.Open, FileAccess.Read); try { BinaryReader br = new BinaryReader(fs); string type = br.ReadString(); if (type.Equals("mt1") == false) { throw new Exception("Wrong file type"); } int ver = br.ReadInt32(); if (ver != 1 && ver != 2) { throw new Exception("Unsupported version of file"); } Data = new MethodSimple(br); Data.SetupPath(path); if (ver > 1) { SrcMethodPath = br.ReadString(); } else { SrcMethodPath = ""; } ver = br.ReadInt32(); if (ver != 234324) { throw new Exception("Wrong end of file."); } } finally { fs.Close(); } }
public void Init(MethodSimple ms, int element, int formula) { Method = ms; this.Element = element; Formula = formula; Element[] elist = ms.GetElementList(); MethodSimpleElementFormula msef = Method.GetElHeader(Element).Formula[Formula]; LyFrom = Common.Env.DefaultDisp.GetLyByLocalPixel(0, 10); int[] sizes = Common.Env.DefaultDisp.GetSensorSizes(); LyTo = Common.Env.DefaultDisp.GetLyByLocalPixel(sizes.Length - 1, sizes[sizes.Length - 1] - 10); candidateLineListAnalit.init(elist[element].Name, formula, ms, true, Convert.ToDouble(msef.Formula.analitParamCalc.methodLineCalc1.nmLy.Value), LyFrom, LyTo); candidateLineListComp.init(null, formula, ms, false, Convert.ToDouble(msef.Formula.analitParamCalc.methodLineCalc2.nmLy.Value), LyFrom, LyTo); }
public void LoadTech(BinaryReader br, MethodSimple method) { Method = method; int ver = br.ReadInt32(); if (ver != 1) { throw new Exception("Wrong version of the ExtraLineTester"); } nmMargine.Value = br.ReadDecimal(); nmMinFreeSpaceSize.Value = br.ReadDecimal(); nmMinLineWidth.Value = br.ReadDecimal(); nmMinAmpl.Value = br.ReadDecimal(); int count = br.ReadInt32(); EmptySpaces.Clear(); for (int i = 0; i < count; i++) { int len = br.ReadInt16(); float[] data = new float[len]; for (int j = 0; j < len; j++) { data[j] = br.ReadSingle(); } EmptySpaces.Add(data); } count = br.ReadInt32(); ExceptionLy.Clear(); for (int i = 0; i < count; i++) { ExceptionLy.Add(br.ReadSingle()); } ver = br.ReadInt32(); if (ver != 234853) { throw new Exception("Wrong finish of the ExtraLineTester"); } ReInitList(); }
public void Add(MethodSimple method, int prob, int sub_prob) { DateTime now = DateTime.Now; Element[] elem = method.GetElementList(); MethodSimpleProb msp = method.GetProbHeader(prob); for (int el = 0; el < elem.Length; el++) { MethodSimpleCell cell = method.GetCell(el, prob); MethodSimpleElement mse = method.GetElHeader(el); for (int f = 0; f < mse.Formula.Count; f++) { MethodSimpleElementFormula formula = mse.Formula[f]; MethodSimpleCellFormulaResult mscfr = cell.GetData(sub_prob, f); Records.Add(new StandartHistryRecord(mse, f, formula, mscfr, now)); } } Save(); }
public void initBy(MethodSimple method, SimpleFormula formula) { this.formula = formula; this.method = method; init(); }
static public List <DataShot> extract(MethodSimple method, string element, int formula, double ly, int widthPlusMinus, bool useConDlt, double min, double max, bool relative) { int mul_k = (int)Common.Conf.MultFactor; int is_ok = 0; int is_over = 0; List <DataShot> ret = new List <DataShot>(); Element[] list = method.GetElementList(); for (int el = 0; el < list.Length; el++) { if (list[el].Name.Equals(element) || element == null) { MethodSimpleElementFormula calcFormula = method.GetElHeader(el).Formula[formula]; bool[] frames = calcFormula.Formula.GetUsedFrames(); for (int prob_index = 0; prob_index < method.GetProbCount(); prob_index++) { MethodSimpleProb prob = method.GetProbHeader(prob_index); MethodSimpleCell msc = method.GetCell(el, prob_index); if (useConDlt == false) { double fkVal = msc.Con; double con = fkVal; /*if (useConDlt) * { * double sko, sko1; * double rcon = //msc.CalcRealCon(out sko, out sko1); * fkVal -= rcon; * }//*/ for (int measuring_index = 0; measuring_index < prob.MeasuredSpectrs.Count; measuring_index++) { MethodSimpleCellFormulaResult mscfr = msc.GetData(measuring_index, formula); if (mscfr.Enabled == false) { continue; } MethodSimpleProbMeasuring mspm = prob.MeasuredSpectrs[measuring_index]; Spectr sp = mspm.Sp; if (sp == null) { continue; } List <SpectrDataView> viewSet = sp.GetViewsSet(); int[] shotIndexes = sp.GetShotIndexes(); Dispers disp = sp.GetCommonDispers(); List <int> sensors = disp.FindSensors(ly); bool isEnabled; if (con >= 0) { isEnabled = msc.Enabled; } else { isEnabled = false; } for (int shot_index = 0; shot_index < shotIndexes.Length; shot_index++) { if (frames[shot_index] == false) { continue; } SpectrDataView sig = viewSet[shotIndexes[shot_index]]; SpectrDataView nul = sp.GetNullFor(shotIndexes[shot_index]); for (int sn = 0; sn < 1 && sn < sensors.Count; sn++) { int sensorIndex = sensors[sn]; int n = (int)disp.GetLocalPixelByLy(sensorIndex, ly); float[] sigData = sig.GetSensorData(sensorIndex); float[] nulData = nul.GetSensorData(sensorIndex); float minSignal = float.MaxValue; float[] signal = new float[sigData.Length]; for (int i = 0; i < signal.Length; i++) { signal[i] = sigData[i] - nulData[i]; } for (int i = 500; i < sigData.Length - 500; i++) { float val = (signal[i - 1] + signal[i] + signal[i + 1]) / 3; if (val < minSignal) { minSignal = val; } } float[] data = new float[widthPlusMinus * 2 + 1]; double maxSignal = -double.MaxValue; for (int i = 0; i < data.Length; i++) { int index = n - widthPlusMinus + i; if (index < 0 || index >= sigData.Length) { data[i] = -float.MaxValue; isEnabled = false; continue; } data[i] = signal[index];//sigData[index] - nulData[index]; if (data[i] > max) { isEnabled = false; } if (data[i] > maxSignal && i > widthPlusMinus - 4 && i < widthPlusMinus + 4) { maxSignal = data[i]; } } if (maxSignal < min) { isEnabled = false; } if (isEnabled) { is_ok++; } else { is_over++; } DataShot dsh = new DataShot(ly, fkVal, data, isEnabled); ret.Add(dsh); } } } } else { for (int measuring_index = 0; measuring_index < prob.MeasuredSpectrs.Count; measuring_index++) { MethodSimpleProbMeasuring mspm = prob.MeasuredSpectrs[measuring_index]; Spectr sp = mspm.Sp; if (sp == null) { continue; } List <SpectrDataView> viewSet = sp.GetViewsSet(); int[] shotIndexes = sp.GetShotIndexes(); Dispers disp = sp.GetCommonDispers(); List <int> sensors = disp.FindSensors(ly); bool isEnabled; if (msc.Con >= 0) { isEnabled = msc.Enabled; } else { isEnabled = false; } MethodSimpleCellFormulaResult result = msc.GetData(measuring_index, formula); int data_index = 0; for (int shot_index = 0; shot_index < shotIndexes.Length; shot_index++) { if (frames[shot_index] == false) { continue; } double tmpAnalit = result.AnalitValue[data_index]; double fkVal; if (relative == false) { fkVal = calcFormula.Formula.CalcCon(0, tmpAnalit, 0) - msc.Con; } else { if (msc.Con > 0.01) { fkVal = (calcFormula.Formula.CalcCon(0, tmpAnalit, 0) - msc.Con) / msc.Con; } else { fkVal = Double.NaN; } } SpectrDataView sig = viewSet[shotIndexes[shot_index]]; SpectrDataView nul = sp.GetNullFor(shotIndexes[shot_index]); for (int sn = 0; sn < sensors.Count; sn++) { int sensorIndex = sensors[sn]; int n = (int)disp.GetLocalPixelByLy(sensorIndex, ly); float[] sigData = sig.GetSensorData(sensorIndex); float[] nulData = nul.GetSensorData(sensorIndex); float[] data = new float[widthPlusMinus * 2 + 1]; for (int i = 0; i < data.Length; i++) { int index = n - widthPlusMinus + i; if (index < 0 || index >= sigData.Length) { data[i] = -float.MaxValue; isEnabled = false; continue; } data[i] = sigData[index] - nulData[index]; if (data[i] > max) { isEnabled = false; } } if (isEnabled) { is_ok++; } else { is_over++; } DataShot dsh = new DataShot(ly, fkVal, data, isEnabled); ret.Add(dsh); } data_index++; } } } } break; } } if (is_ok == 0 || is_over / is_ok > 0.1) { return(null); } return(ret); }
public void Setup(MethodSimple method) { Method = method; }
/*public void SetupLy(double ly,Spectr sp) * { * methodLineCalc1.SetupLy(ly, sp); * switch (cbDivType.SelectedIndex) * { * case 0: methodLineCalc2.SetupLy(ly, sp); break; * } * } * * public void ReSetLyEtalon() * { * methodLineCalc1.ReSetLyEtalon(); * methodLineCalc2.ReSetLyEtalon(); * }*/ public void SetupSpectrView(SpectrView spv, string prefix, int base_element, int element, int base_line_index, MethodSimple method) { methodLineCalc1.SetupSpectrView(spv, prefix + Common.MLS.Get(MLSConst, "Аналит.Линия"), base_element, element, base_line_index, method); methodLineCalc2.SetupSpectrView(spv, prefix + Common.MLS.Get(MLSConst, "Линия cравн."), base_element, element, base_line_index + 1, method); }
public SparkConditionTester(BinaryReader br, MethodSimple method) { InitializeComponent(); Common.Reg(this, MLSConst); LoadTech(br, method); }
public void Setup(SpectrView view, MethodSimple method) { Method = method; SpView = view; }
public void Calc(MethodSimple method) { int pr_count = method.GetProbCount(); Params.ResetMinLineValues(); List <double> div = new List <double>(); for (int pri = 0; pri < pr_count; pri++) { MethodSimpleProb pr = method.GetProbHeader(pri); int sp_count = pr.MeasuredSpectrs.Count; for (int spri = 0; spri < sp_count; spri++) { MethodSimpleProbMeasuring prm = pr.MeasuredSpectrs[spri]; int[] shot_index = prm.Sp.GetShotIndexes(); List <SpectrDataView> spv = prm.Sp.GetViewsSet(); for (int spi = 0; spi < shot_index.Length; spi++) { SpectrDataView sig = spv[shot_index[spi]]; SpectrDataView nul = prm.Sp.GetNullFor(shot_index[spi]); List <SpectrDataView> sig_l = new List <SpectrDataView>(); sig_l.Add(sig); List <SpectrDataView> nul_l = new List <SpectrDataView>(); nul_l.Add(nul); List <double> analit1 = new List <double>(); List <double> aq1 = new List <double>(); //bool is_too_low = false; CalcLineAtrib attr = new CalcLineAtrib(); bool rez = Params.Calc(Log, LogSectionName, "", //null, sig_l, nul_l, prm.Sp, analit1, aq1, ref attr, true); if (rez == false) { continue; } if (analit1[0] == 0 || serv.IsValid(analit1[0]) == false) { continue; } div.Add(analit1[0]); } } } AnalitEver = (float)analit.Stat.GetEver(div); if (analit.Stat.LastGoodSKO == 0) { Sko = (float)analit.Stat.LastSKO; } else { Sko = (float)analit.Stat.LastGoodSKO; } float k = (float)Math.Sqrt(2); AnalitFrom = AnalitEver - Sko * k; AnalitTo = AnalitEver + Sko * k; }