public I_MR_List Values(int dimensionId)
        {
            I_MR_List    yValues = new I_MR_List();
            DbDataReader reader;

            cmd.CommandText = "EXECUTE sp_GetLastMeasurements @n=" + numOfPoints.ToString() + ", @dimensionId=" + dimensionId.ToString() + ";";

            using (reader = cmd.ExecuteReader())
            {
                int ind;

                while (reader.Read())
                {
                    I_MR_Point yValue = new I_MR_Point();

                    ind = reader.GetOrdinal("value");
                    try
                    {
                        yValue.I = decimal.Parse(reader.GetValue(ind).ToString());
                    }
                    catch
                    {
                        yValue.I = 0;
                    }

                    ind = reader.GetOrdinal("min");
                    try
                    {
                        yValue.TolMin = decimal.Parse(reader.GetValue(ind).ToString());
                    }
                    catch
                    {
                        yValue.TolMin = 0;
                    }

                    ind = reader.GetOrdinal("max");
                    try
                    {
                        yValue.TolMax = decimal.Parse(reader.GetValue(ind).ToString());
                    }
                    catch
                    {
                        yValue.TolMax = 0;
                    }

                    yValues.Add(yValue);
                }
            }
            return(yValues);
        }
示例#2
0
 private void Update_I_MR_Chart(I_MR_Chart chart)
 {
     if (chart.chart_I.InvokeRequired)
     {
         var d = new SafeCallUpdateIMRChart(Update_I_MR_Chart);
         Invoke(d, new object[] { chart });
     }
     else
     {
         I_MR_List yValues       = sqlDataSet.Values(chart.DimensionId);
         decimal   lastValue     = Math.Round(sqlDataSet.LastValue(chart.DimensionId), 3);
         bool      lastValueIsOk = sqlDataSet.LastValueIsOk;
         chart.UpdateChart(yValues, lastValue, lastValueIsOk);
     }
 }
示例#3
0
        public void UpdateChart(I_MR_List yValues, decimal lastValue, bool lastValueIsOk)
        {
            chart_I.Series["Values"].Points.Clear();
            chart_I.Series["TolMin"].Points.Clear();
            chart_I.Series["TolMax"].Points.Clear();
            chart_I.Series["Med"].Points.Clear();
            chart_I.Series["Target"].Points.Clear();

            if (yValues.Count > 0)
            {
                chart_I.ChartAreas[0].AxisY.Minimum = (double)Math.Round(yValues[yValues.Count - 1].TolMin - (yValues[yValues.Count - 1].TolMax - yValues[yValues.Count - 1].TolMin) / 4, 2);
                chart_I.ChartAreas[0].AxisY.Maximum = (double)Math.Round(yValues[yValues.Count - 1].TolMax + (yValues[yValues.Count - 1].TolMax - yValues[yValues.Count - 1].TolMin) / 4, 2);

                foreach (I_MR_Point yValue in yValues)
                {
                    chart_I.Series["Values"].Points.AddY(yValue.I);
                    chart_I.Series["TolMin"].Points.AddY(yValue.TolMin);
                    chart_I.Series["TolMax"].Points.AddY(yValue.TolMax);
                    chart_I.Series["Med"].Points.AddY(yValues.MedI);
                    chart_I.Series["Target"].Points.AddY(yValue.Target);
                }

                label_LastValue.Text = lastValue.ToString();
                if (lastValueIsOk)
                {
                    label_LastValue.BackColor = Color.LightGreen;
                    label_LastValue.ForeColor = Color.Black;
                }

                else
                {
                    label_LastValue.BackColor = Color.Red;
                    label_LastValue.ForeColor = Color.White;
                }
            }
        }