Beispiel #1
0
        public Segment_cls(int Segment_id, raw_kinematics_data_cls Raw_data)
        {
            raw_data     = Raw_data;
            segment_id   = Segment_id;
            segment_axis = new Double[3];
            x            = new Double[3];
            y            = new Double[3];
            z            = new Double[3];
            xl           = new Double[3];
            yl           = new Double[3];
            zl           = new Double[3];

            Accelerometer = new sensor_cls();
            Gyroscope     = new sensor_cls();
            Magnetometer  = new sensor_cls();

            Sensors_array[0] = Accelerometer;
            Sensors_array[1] = Gyroscope;
            Sensors_array[2] = Magnetometer;
        }
        }// end dataReceivingMethod

        private void UpdateUserInterface()
        {
            info_panel_label.Content = debug_string;
            info_panel_label.UpdateLayout();

            //*
            // zapolnenie tablicy dannyh datchikov
            if (raw_data.Kinematics_Data.Length == raw_data.Raw_Data_Length)
            {
                data_panel_label.Content = "";
                for (int i = 0; i < 19; i++)
                {
                    string data_string = "";
                    for (int j = 0; j < 9; j++)
                    {
                        Int16 data = (Int16)((Int16)raw_data.Kinematics_Data[i * 18 + j * 2] + ((Int16)(raw_data.Kinematics_Data[i * 18 + j * 2 + 1]) << 8));
                        data_string += String.Format("{0, 10}  ", data);
                    }
                    data_string += "\n";
                    data_panel_label.Content += data_string;
                }
            }
            data_panel_label.UpdateLayout();

            //*/
            Double angle1 = (model.Channels.ToArray())[0].Angle.Angle;
            Double angle2 = (model.Channels.ToArray())[1].Angle.Angle;
            Double angle3 = (model.Channels.ToArray())[3].Angle.Angle;

            angle_chart0.add_stroke(angle1);
            angle_chart1.add_stroke(angle2);
            angle_chart2.add_stroke(angle3);

            segment1_axis.Content     = String.Format("{0,10:F3}", angle1);
            segment2_axis.Content     = String.Format("{0,10:F3}", angle2);
            segment_1_2_angle.Content = String.Format("{0,10:F3}", angle3);
            //********************************************************************

            //*
            double ratio       = 0;
            int    sensor_type = 0; // 0 - accel, 1 - gyro, 2 - magnet;

            histogram_cls[,] hist = new histogram_cls[5, 4];
            sensor_cls[] sensor = new sensor_cls[5];

            for (int i = 1; i < 5; i++)
            {
                sensor[i] = model.Segments[i].sensors_array[sensor_type];
            }


            for (int i = 1; i < 5; i++)
            {
                for (int j = 1; j < 4; j++)
                {
                    hist[i, j] = sensor[i].histogram_array[j - 1];
                }
            }

            // add value
            for (int i = 1; i < 5; i++)
            {
                for (int j = 1; j < 4; j++)
                {
                    hist[i, j].add_value(sensor[i].xyz[j - 1]);
                }
            }

            Label[,] labels = new Label[5, 4];
            labels[1, 1]    = hist_1_1_label; labels[1, 2] = hist_1_2_label; labels[1, 3] = hist_1_3_label;
            labels[2, 1]    = hist_2_1_label; labels[2, 2] = hist_2_2_label; labels[2, 3] = hist_2_3_label;
            labels[3, 1]    = hist_3_1_label; labels[3, 2] = hist_3_2_label; labels[3, 3] = hist_3_3_label;
            labels[4, 1]    = hist_4_1_label; labels[4, 2] = hist_4_2_label; labels[4, 3] = hist_4_3_label;

            Canvas[,] canvases = new Canvas[5, 4];
            canvases[1, 1]     = hist_1_1_canvas; canvases[1, 2] = hist_1_2_canvas; canvases[1, 3] = hist_1_3_canvas;
            canvases[2, 1]     = hist_2_1_canvas; canvases[2, 2] = hist_2_2_canvas; canvases[2, 3] = hist_2_3_canvas;
            canvases[3, 1]     = hist_3_1_canvas; canvases[3, 2] = hist_3_2_canvas; canvases[3, 3] = hist_3_3_canvas;
            canvases[4, 1]     = hist_4_1_canvas; canvases[4, 2] = hist_4_2_canvas; canvases[4, 3] = hist_4_3_canvas;

            if (packet_counter % 40 == 0)
            {
                for (int i = 1; i < 5; i++)
                {
                    for (int j = 1; j < 4; j++)
                    {
                        labels[i, j].Content = "";
                        canvases[i, j].Children.Clear();
                        ratio = 0;
                        if (hist[i, j].main_bin_value != 0)
                        {
                            ratio = canvases[i, j].ActualHeight * 0.75 / hist[i, j].main_bin_value;
                        }
                        for (int k = 0; k < hist[i, j].bins.Length; k++)
                        {
                            Line bin_stroke;
                            bin_stroke = new Line();
                            bin_stroke.StrokeThickness = 13;
                            bin_stroke.Stroke          = System.Windows.Media.Brushes.LightSteelBlue;
                            bin_stroke.X1 = 40 + k * 15;
                            bin_stroke.X2 = 40 + k * 15;
                            bin_stroke.Y1 = canvases[i, j].ActualHeight;
                            bin_stroke.Y2 = canvases[i, j].ActualHeight - (hist[i, j].bins[k] * ratio);
                            canvases[i, j].Children.Add(bin_stroke);
                            canvases[i, j].UpdateLayout();
                        }
                        labels[i, j].Content += hist[i, j].main_bin.ToString();
                        labels[i, j].UpdateLayout();
                    }
                }
            }
            //*/
        }// end update user interface