public void AddSensorDataInfo(SensorDataItemXD sditemXD)
        {
            DataRow row = SensorsTable.NewRow();

            row["Type"]         = sditemXD.Type;
            row["Timestamp/ms"] = sditemXD.Timestamp;
            row["Dimension"]    = sditemXD.Dimension;

            row["X"] = sditemXD.SensorsArr[0];
            row["Y"] = sditemXD.SensorsArr[1];
            row["Z"] = sditemXD.SensorsArr[2];
            row["A"] = sditemXD.SensorsArr[3];
            row["B"] = sditemXD.SensorsArr[4];
            row["C"] = sditemXD.SensorsArr[5];
            row["D"] = sditemXD.SensorsArr[6];
            row["E"] = sditemXD.SensorsArr[7];
            row["F"] = sditemXD.SensorsArr[8];
            row["G"] = sditemXD.SensorsArr[9];
            row["H"] = sditemXD.SensorsArr[10];
            row["I"] = sditemXD.SensorsArr[11];
            row["J"] = sditemXD.SensorsArr[12];
            row["K"] = sditemXD.SensorsArr[13];
            row["L"] = sditemXD.SensorsArr[14];
            row["M"] = sditemXD.SensorsArr[15];
            SensorsTable.Rows.


            Add(row);
        }
Esempio n. 2
0
        public void UpdateGraph(SensorDataItemXD sensorDataXD)
        {
            if (firstdata_b)
            {
                Title title = new Title(sensorName, Docking.Top);
                title.Alignment = System.Drawing.ContentAlignment.MiddleCenter;
                title.Font      = new System.Drawing.Font("Microsoft Sans Serif", 20, System.Drawing.FontStyle.Bold);
                chart1.Titles.Add(title);

                for (int i = 0; i < sensorDataXD.Dimension; i++)
                {
                    String axis = null;
                    double data = 0;
                    switch (i)
                    {
                    case 0:
                        axis = "X";
                        break;

                    case 1:
                        axis = "Y";
                        break;

                    case 2:
                        axis = "Z";
                        break;

                    case 3:
                        axis = "A";
                        break;

                    case 4:
                        axis = "B";
                        break;

                    case 5:
                        axis = "C";
                        break;

                    case 6:
                        axis = "D";
                        break;

                    case 7:
                        axis = "E";
                        break;

                    case 8:
                        axis = "F";
                        break;

                    case 9:
                        axis = "G";
                        break;

                    case 10:
                        axis = "H";
                        break;

                    case 11:
                        axis = "I";
                        break;

                    case 12:
                        axis = "J";
                        break;

                    case 13:
                        axis = "K";
                        break;

                    case 14:
                        axis = "L";
                        break;

                    case 15:
                        axis = "M";
                        break;
                    }
                    data = sensorDataXD.SensorsArr[i];
                    //Create a new curve
                    Series series = new Series(axis);
                    //Set chart type
                    series.ChartType = (SeriesChartType)Enum.Parse(typeof(SeriesChartType), toolStripComboBoxLineType.Text.Trim());
                    //Set curve width
                    series.BorderWidth = Convert.ToInt32(toolStripComboBoxLineWidth.Text.Trim());
                    chart1.Series.Add(series);

                    //Create a new legend
                    Legend legend = new Legend(axis);
                    //Set legend properities
                    legend.Title     = sensorName;
                    legend.TitleFont = new System.Drawing.Font("Microsoft Sans Serif", 12, System.Drawing.FontStyle.Bold);
                    legend.Font      = new System.Drawing.Font("Microsoft Sans Serif", 10, System.Drawing.FontStyle.Bold);

                    legend.LegendStyle             = LegendStyle.Table;
                    legend.Alignment               = System.Drawing.StringAlignment.Center;
                    legend.IsDockedInsideChartArea = false;
                    legend.Docking = Docking.Bottom;

                    legend.BorderDashStyle = ChartDashStyle.Dash;
                    legend.BorderColor     = System.Drawing.Color.LightBlue;
                    legend.BorderWidth     = 3;

                    chart1.Legends.Add(legend);
                    //Set Docking of the legend chart to the Default Chart Area
                    chart1.Legends[axis].DockedToChartArea = "ChartArea1";

                    series.Points.AddXY(sensorDataXD.Timestamp, data);
                }
                firstdata_b = false;//init is finished.
            }
            else
            {
                for (int i = 0; i < sensorDataXD.Dimension; i++)
                {
                    String axis = null;
                    double data = 0;
                    switch (i)
                    {
                    case 0:
                        axis = "X";
                        break;

                    case 1:
                        axis = "Y";
                        break;

                    case 2:
                        axis = "Z";
                        break;

                    case 3:
                        axis = "A";
                        break;

                    case 4:
                        axis = "B";
                        break;

                    case 5:
                        axis = "C";
                        break;

                    case 6:
                        axis = "D";
                        break;

                    case 7:
                        axis = "E";
                        break;

                    case 8:
                        axis = "F";
                        break;

                    case 9:
                        axis = "G";
                        break;

                    case 10:
                        axis = "H";
                        break;

                    case 11:
                        axis = "I";
                        break;

                    case 12:
                        axis = "J";
                        break;

                    case 13:
                        axis = "K";
                        break;

                    case 14:
                        axis = "L";
                        break;

                    case 15:
                        axis = "M";
                        break;
                    }
                    data = sensorDataXD.SensorsArr[i];
                    chart1.Series[axis].Points.AddXY(sensorDataXD.Timestamp, data);
                }
            }
        }