public static FormViewMeasure getFormForMeasure(MeasureData data) { FormViewMeasure form = new FormViewMeasure(data); form.Text = "Просмотр измерения: " + data.ToString() + (data.ID != -1 ? "" : " * "); form.ShowReport(); form.Show(); return(form); }
public void initWData(MeasureData data) { if (data != null) { this.measureData = data; this.mask = data.DefaultMask; plotter.Viewport = new RectangleD(0, -100, data.FullMeasureLength + 0.5d, 200); plotter.Label = data.ToString(); RePlot(); } }
public MovableGraph(MeasureData measureData) { InitializeComponent(); if (measureData != null) { this.measureData = measureData; this.mask = measureData.DefaultMask; plotter.Viewport = new RectangleD(0, -100, measureData.FullMeasureLength + 0.5d, 200); plotter.Label = measureData.ToString(); RePlot(); } }
/// <summary> /// "Get current values" button pressed. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void _btnGetMeasureData_Click(object sender, EventArgs e) { LJV7IF_MEASURE_DATA[] measureData = new LJV7IF_MEASURE_DATA[NativeMethods.MesurementDataCount]; Rc rc = (Rc)NativeMethods.LJV7IF_GetMeasurementValue(DEVICE_ID, measureData); if (!CheckReturnCode(rc)) { return; } MeasureData data = new MeasureData(measureData); _txtMeasureData.Text = data.ToString(); }
public void initWData(MeasureData data) { if (data != null) { this.measureData = data; this.mask = data.DefaultMask; plotter.Viewport = new RectangleD(0, -100, data.FullMeasureLength + 0.5d, 200); plotter.Label = data.ToString(); if (data.quality != -1) { comboBox1.SelectedIndex = data.quality; } RePlot(); } }
private void buttonSave_Click(object sender, EventArgs e) { longitude = textBox6.Text; latitude = textBox7.Text; if (saved) { Data.quality = comboBox1.SelectedIndex; Data.lng = longitude; Data.ltt = latitude; Data.Description = textBox8.Text; Program.DataProvider.updateMeasureData(Data); } else { if (MessageBox.Show("Сохранить измерение\r\n'" + Data.ToString() + "'?", "Сохранение", MessageBoxButtons.YesNo) == DialogResult.Yes) { DataProvider.GroupTreeNode node = FormSelectOneGroup.getNode(); if (node != null) { Data.GroupID = node.ID; } else { Data.GroupID = -1; } try { measureData.quality = comboBox1.SelectedIndex; measureData.Description = textBox8.Text; measureData.lng = longitude; measureData.ltt = latitude; int id = Program.DataProvider.insertMeasureData(measureData); saved = true; measureData = Program.DataProvider.getMeasureDataByID(id); RePlot(); Text = measureData.ToString(); } catch (Exception ex) { Error.Log(ex); MessageBox.Show("Ошибка сохранения:\r\n" + ex.Message); } } } }
//-----------------------------------------------------------// public GroupTreeNode GetMeasuresTreeFrom(List <int> statMeasures, GroupTreeNode node) { if (statMeasures == null) { statMeasures = GetStatMeasures(); } string query = "SELECT * FROM GroupTree WHERE ParentID" + ((node.ID == -1) ? (" IS NULL") : ("=" + node.ID)); IDataReader reader = executeSelect(query); if (node.SubNodes == null) { node.SubNodes = new List <GroupTreeNode>(); } if (node.Measures == null) { node.Measures = new Dictionary <int, string>(); } while (reader.Read()) { int id = (int)reader["ID"]; string name = reader["Name"] as string; string description = reader["Description"] == DBNull.Value ? null : (reader["Description"] as string); node.SubNodes.Add(new GroupTreeNode(id, name, description)); } reader.Close(); query = "SELECT ID, [Name], StartTime, IsMeasured, FullLength FROM Measures WHERE GroupID" + ((node.ID == -1) ? (" IS NULL") : ("=" + node.ID)); reader = executeSelect(query); while (reader.Read()) { int id = (int)reader["ID"]; string name = reader["Name"] as string; DateTime dt = (DateTime)reader["StartTime"]; bool IsMeasured = Convert.ToBoolean(reader["IsMeasured"]); int flen = (int)((double)reader["FullLength"]); MeasureData md = new MeasureData(new Dictionary <Sensor, List <PointD> >(), id, name, dt, "", -1, flen, 1, IsMeasured, null); if (statMeasures.Contains(id)) { md.DispData = new Dictionary <Sensor, Dictionary <double, double> >(); md.DispData.Add(sensorList[0], new Dictionary <double, double>()); } node.Measures.Add(id, md.ToString()); } reader.Close(); for (int i = 0; i < node.SubNodes.Count; i++) { node.SubNodes[i] = GetMeasuresTreeFrom(statMeasures, node.SubNodes[i]); } return(node); }
/// <summary> /// Сравнение измерений /// </summary> /// <param name="baseData">базовое, статистически усреднённое измерение, содержащее данные о доверительном интервале</param> /// <param name="compared">сравниваемое измерение</param> /// <param name="timeCorrection">коррекция времени сравниваемого измерения</param> /// <returns>набор данных с некоторыми результатами</returns> public static Dictionary <string, object> Correspondence(MeasureData baseData, MeasureData compared, double timeCorrection) { Dictionary <string, object> result = new Dictionary <string, object>(); string errorlog = ""; if (baseData.IsMeasured || baseData.DispData == null) { errorlog += "Базовое измерение не является статистическим средним."; result.Add("ok", false); result.Add("errorlog", errorlog); return(result); } Dictionary <Sensor, List <double> > inSigma = new Dictionary <Sensor, List <double> >(); Dictionary <Sensor, List <double> > in3Sigma = new Dictionary <Sensor, List <double> >(); Dictionary <Sensor, List <double> > outOf3Sigma = new Dictionary <Sensor, List <double> >(); foreach (Sensor sensor in baseData.Data.Keys) { if (compared.Data.ContainsKey(sensor)) { inSigma.Add(sensor, new List <double>()); in3Sigma.Add(sensor, new List <double>()); outOf3Sigma.Add(sensor, new List <double>()); foreach (PointD point in baseData.Data[sensor]) { double time = point.X; if (time >= 0d) { double value = point.Y; double dX = baseData.DispData[sensor][time]; double comparedvalue = compared.GetDataAtTheMoment(compared.StartTime.AddSeconds(time - timeCorrection))[sensor]; if (Math.Abs(comparedvalue - value) < dX) { inSigma[sensor].Add(time); } else if (Math.Abs(comparedvalue - value) < 3 * dX) { in3Sigma[sensor].Add(time); } else { outOf3Sigma[sensor].Add(time); } } } } else { errorlog += "<<" + sensor.ToString() + ">> : не найден в измерении <<" + compared.ToString() + ">>"; } } result.Add("ok", true); result.Add("errorlog", errorlog); result.Add("sigma", inSigma); result.Add("3sigma", in3Sigma); result.Add("unstable", outOf3Sigma); return(result); }
private void buttonStart_Click(object sender, EventArgs e) { try { Dictionary <MeasureData, double> _measures = new Dictionary <MeasureData, double>(); string err = "Должно быть выбрано ровно 2 измерения.\r\nПервое должно быть 'усреднённым' и содержать статистическую информацию [Σ+]."; foreach (object o in listBoxMeasures.Items) { if (multiGraph.Plotters.ContainsKey(o)) { _measures.Add(o as MeasureData, (multiGraph.Plotters[o] as MovableGraph).Correcture); } } Mask _mask = comboBoxMasks.SelectedItem as Mask; if (_measures.Count < 2) { MessageBox.Show(err); return; } double _maxlen = double.MaxValue; foreach (MeasureData data in _measures.Keys) { _maxlen = Math.Min(_maxlen, data.FullMeasureLength); } if (_maxlen < 1d) { return; } if (_measures.Count != 2) { MessageBox.Show(err); return; } else if ((listBoxMeasures.Items[0] as MeasureData).IsMeasured) { MessageBox.Show("Первое измерение не является 'усреднённым' [Σ]."); return; } else if ((listBoxMeasures.Items[0] as MeasureData).DispData == null) { MessageBox.Show("Первое измерение не содержит статистической информации [+]."); return; } else { MeasureData bm = listBoxMeasures.Items[0] as MeasureData; MeasureData cm = listBoxMeasures.Items[1] as MeasureData; double corr = (multiGraph.Plotters[cm] as MovableGraph).Correcture - (multiGraph.Plotters[bm] as MovableGraph).Correcture; #region зачистка foreach (Sensor s in cm.AllData.Keys) { if (!bm.Data.ContainsKey(s)) { cm.Used[s] = false; } } foreach (Sensor s in bm.AllData.Keys) { if (!cm.Data.ContainsKey(s)) { bm.Used[s] = false; } } #endregion Зачистка Dictionary <string, object> objs = AlgsList.Correspondence(bm, cm, corr); if ((bool)objs["ok"]) { Dictionary <Sensor, List <double> > insigma = objs["sigma"] as Dictionary <Sensor, List <double> >; Dictionary <Sensor, List <double> > in3sigma = objs["3sigma"] as Dictionary <Sensor, List <double> >; Dictionary <Sensor, List <double> > outof3sigma = objs["unstable"] as Dictionary <Sensor, List <double> >; int count, in1, in3, out3; count = in1 = in3 = out3 = 0; foreach (Sensor sensor in insigma.Keys) { foreach (double d in insigma[sensor]) { count++; in1++; } } foreach (Sensor sensor in in3sigma.Keys) { foreach (double d in in3sigma[sensor]) { count++; in3++; } } foreach (Sensor sensor in outof3sigma.Keys) { foreach (double d in outof3sigma[sensor]) { count++; out3++; } } FormCompare report = new FormCompare(); report.RTB.SelectionFont = report.Bold.Font; report.RTB.AppendText("Сводка по сравнению:\r\n"); report.RTB.SelectionFont = report.Normal.Font; report.RTB.AppendText(" Базовое измерение: " + bm.ToString() + "\r\n"); report.RTB.SelectionFont = report.Normal.Font; report.RTB.AppendText(" Сравниваемое измерение: " + cm.ToString() + "\r\n"); report.RTB.SelectionFont = report.Italic.Font; report.RTB.AppendText(" Всего сравнивалось точек: "); report.RTB.SelectionFont = report.Normal.Font; report.RTB.AppendText("" + count + " (" + ((100d / count) * count).ToString("0.00") + "%)\r\n"); report.RTB.SelectionColor = Color.Green; report.RTB.SelectionFont = report.Italic.Font; report.RTB.AppendText(" Попало в X±σ: "); report.RTB.SelectionFont = report.Normal.Font; report.RTB.AppendText("" + in1 + " (" + ((100d / count) * in1).ToString("0.00") + "%)\r\n"); report.RTB.SelectionColor = Color.Orange; report.RTB.SelectionFont = report.Italic.Font; report.RTB.AppendText(" Попало в X±3σ: "); report.RTB.SelectionFont = report.Normal.Font; report.RTB.AppendText("" + (in1 + in3) + " (" + ((100d / count) * (in3 + in1)).ToString("0.00") + "%)\r\n"); report.RTB.SelectionFont = report.Normal.Font; report.RTB.AppendText(" Значения точек в интервале\r\n (-3σ; -σ)U(σ; 3σ):\r\n"); foreach (Sensor s in in3sigma.Keys) { report.RTB.SelectionFont = report.Normal.Font; report.RTB.AppendText(" " + s.ToString() + ": "); foreach (double d in in3sigma[s]) { report.RTB.SelectionFont = report.Normal.Font; report.RTB.AppendText(d.ToString() + "; "); } report.RTB.SelectionFont = report.Normal.Font; report.RTB.AppendText("\r\n"); } report.RTB.SelectionColor = Color.Red; report.RTB.SelectionFont = report.Italic.Font; report.RTB.AppendText(" Не попало в X±3σ: "); report.RTB.SelectionFont = report.Normal.Font; report.RTB.AppendText("" + out3 + " (" + ((100d / count) * out3).ToString("0.00") + "%)\r\n"); foreach (Sensor s in outof3sigma.Keys) { report.RTB.SelectionFont = report.Normal.Font; report.RTB.AppendText(" " + s.ToString() + ": "); foreach (double d in outof3sigma[s]) { report.RTB.SelectionFont = report.Normal.Font; report.RTB.AppendText(d.ToString() + "; "); } report.RTB.SelectionFont = report.Normal.Font; report.RTB.AppendText("\r\n"); } report.RTB.SelectionColor = Color.Black; report.setValues(bm, _measures[bm], cm, _measures[cm], _mask); report.Show(); } else { MessageBox.Show("Ошибка сравнения: " + objs["errorlog"]); } } } catch (Exception ex) { MessageBox.Show("Ошибка:\r\n" + ex.Message); } }