Exemplo n.º 1
0
        private void btn_start_Click(object sender, RoutedEventArgs e)
        {
            if (!running)
            {
                // If a node has been selected
                if (combobox_nodeSelect.SelectedItem != null)
                {
                    running = true;
                    // Use/Change UI before starting
                    TremorProcessing.Threshold_Frequency = (float)numUpDown_ThresholdFreq.Value;
                    TremorProcessing.Threshold_Amplitude = (float)numUpDown_ThresholdAmp.Value;
                    btn_start.Content = "Stop Collection";

                    // Disables the UI
                    combobox_nodeSelect.IsEnabled     = false;
                    numUpDown_ThresholdAmp.IsEnabled  = false;
                    numUpDown_ThresholdFreq.IsEnabled = false;

                    /* Clear nodes and add the one selected.
                     * Start collecting data on this node.
                     * Set up the data received event
                     */
                    Nodes.NodesList.Clear();
                    Nodes.NodesList.Add(new RazorIMU(combobox_nodeSelect.Text));
                    Nodes.NodesList[0].StartCollection();
                    Nodes.NodesList[0].CapturedData += new RazorDataCaptured(Fusion_CapturedData);

                    // Set up the tremor processing class and tremor calculated event
                    TremorProcessing.Initialize();
                    TremorProcessing.CalculatedTremor += TremorProcessing_CalculatedTremor;
                }
                else
                {
                    System.Windows.MessageBox.Show("Please select a node", "Collection Error", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
            else
            {
                btn_start.Content = "Start Collection";

                // Enables the UI
                combobox_nodeSelect.IsEnabled     = true;
                numUpDown_ThresholdAmp.IsEnabled  = true;
                numUpDown_ThresholdFreq.IsEnabled = true;

                // Stop the collection and calculation events
                Nodes.NodesList[0].CapturedData -= Fusion_CapturedData;
                Nodes.NodesList[0].Dispose();
                Nodes.NodesList.Clear();
                TremorProcessing.CalculatedTremor -= TremorProcessing_CalculatedTremor;
                running = false;
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// This is where the sensor data goes when it has been captured.
 /// </summary>
 /// <param name="data">Data from he sensor. Remember, the structure of data is [accel_x,accel_y,accel_z,gyro_x,gyro_y,gyro_z,mag_x,mag_y,mag_z]</param>
 /// <param name="deltaT">Time since previous data was given.</param>
 private static void Fusion_CapturedData(float[] data, float deltaT)
 {
     TremorProcessing.LogPoint(data[0], data[1], data[2], deltaT);
     DataLogging.LogRawData(deltaT, data[0], data[1], data[2], data[3], data[4], data[5], 0, 0, 0);
 }