Exemplo n.º 1
0
        public MainPage()
        {
            InitializeComponent();
            panelLists.AddRange(new List <Panel>()
            {
                PanelRFID, PanelEMG, PanelHAND, PanelGLOVE, panelConnect, panelControls, panelCharts
            });

            // EMG 8 Channel
            emg.ConnectionTerminateHandler += Emg_ConnectionTerminateHandler;
            //emg.ReceiveMessageHandler += Emg_ReceiveMessageHandler;
            emg.ConnectionEstablishHandler += Emg_ConnectionEstablishHandler;

            // EMG 1 Channel
            emg1c.ConnectionEstablished += Emg1c_ConnectionEstablished;
            //emg1c.MessageReceived += Emg1c_MessageReceived;
            emg1c.ConnectionFailed += Emg1c_ConnectionFailed;

            // Image Processing :D
            rfid.ConnectionTerminateHandler += Rfid_ConnectionTerminateHandler;
            //rfid.ReceiveMessageHandler += Rfid_ReceiveMessageHandler;
            rfid.ConnectionEstablishHandler += Rfid_ConnectionEstablishHandler;

            // Hand
            hand.ConnectionTerminateHandler += Hand_ConnectionTerminateHandler;
            //hand.ReceiveMessageHandler += Hand_ReceiveMessageHandler;
            hand.ConnectionEstablishHandler += Hand_ConnectionEstablishHandler;

            // Deprecated
            glove.ConnectionTerminateHandler += Glove_ConnectionTerminateHandler;
            //glove.ReceiveMessageHandler += Glove_ReceiveMessageHandler;

            // Set Model of data shown in chart
            var mapper = Mappers.Xy <ChartModel>().X(a => a.Time.Ticks).Y(a => a.Data);

            Charting.For <ChartModel>(mapper);
        }
Exemplo n.º 2
0
        public void FillIn(int n, double limityMin, double limityMax)
        {
            for (int k = 0; k < checkedListBox.Items.Count; k++)
            {
                if (checkedListBox.GetItemChecked(k) == true)
                {
                    Charting plot = new Charting();
                    plot.Visible = true;
                    if (checkedListBox.Items[k] == "Betta")
                    {
                        plot.Text = "Betta распределение";
                    }
                    if (checkedListBox.Items[k] == "Нормальное(Гаусса)")
                    {
                        plot.Text = "Нормальное(Гаусса) распределение";
                    }
                    if (checkedListBox.Items[k] == "Равновероятное")
                    {
                        plot.Text = "Равновероятное распределение";
                    }
                    Grid = new SortedList <double, double>();
                    plot.chart1.Series[0].Points.Clear();
                    plot.chart1.Series[1].Points.Clear();
                    plot.chart1.Series[2].Points.Clear();


                    for (int i = 0; i < n; i++)
                    {
                        double y = 0;
                        if (checkedListBox.Items[k].ToString() == "Betta")
                        {
                            y = random.NextBetta(limityMin, limityMax);
                        }
                        if (checkedListBox.Items[k].ToString() == "Нормальное(Гаусса)")
                        {
                            y = (limityMax - limityMin) * (random.NextGaussian() / 6 + 0.5) + 1;
                        }
                        if (checkedListBox.Items[k].ToString() == "Равновероятное")
                        {
                            y = (limityMax - limityMin) * random.NextDouble() + 1;
                        }
                        Grid.Add(i, y);
                        plot.chart1.Series[0].Points.Add(new System.Windows.Forms.DataVisualization.Charting.DataPoint(i, y));
                        plot.chart1.Series[1].Points.Add(new System.Windows.Forms.DataVisualization.Charting.DataPoint(i, y));
                        plot.dataGridView1.Rows.Add(i + "", y + "");
                    }
                    Spline splayn = new Spline(Grid);
                    for (int i = 0; i < dataGridView1.Rows.Count - 1; i++)
                    {
                        try
                        {
                            double resDouble = 0;
                            int    resInt    = 0;
                            if (double.TryParse(dataGridView1.Rows[i].Cells[0].Value.ToString(), out resDouble) == true && int.TryParse(dataGridView1.Rows[i].Cells[1].Value.ToString(), out resInt))
                            {
                                plot.chart1.Series[2].Points.Add(new System.Windows.Forms.DataVisualization.Charting.DataPoint(resDouble, Math.Round(splayn.InterpolationPoint(resDouble, n), resInt)));
                                plot.dataGridView2.Rows.Add(resDouble + "", Math.Round(splayn.InterpolationPoint(resDouble, n), resInt) + "");
                            }
                            else
                            {
                                throw new Exception("Что то не так с " + i + "-м значением ");
                            }
                        }
                        catch (Exception e)
                        {
                            MessageBox.Show(e.Message);
                        }
                    }
                }
            }
        }