/// <summary>
        /// Searches the data for tyre readings and also removes spikes in data
        /// </summary>
        void Tyre_Detection()
        {
            int        highest_temp    = -999;
            List <int> wheel_detection = new List <int>();

            // Right Wheel
            for (int i = 0; i < Right_Sensor_Data.Length; i++)
            {
                // Knowing the ambient temperature, and setting up a sensitivity value
                // loop through data to find (relatively) dramatic increases in temperature
                if (Right_Sensor_Data[i] > (Right_Sensor_Ambient + Sensor_Sensitivity))
                {
                    // A value that supasses (ambient temperature + sensitivity), Now each Subsequent value is recorded
                    // Until it drops down below the threshold, which implies the tyre has passed
                    for (int x = i; x < Right_Sensor_Data.Length; x++)
                    {
                        // This is here to see if it drops below the threshold
                        if (Right_Sensor_Data[x] > (Right_Sensor_Ambient + Sensor_Sensitivity))
                        {
                            // Add to collection of tyre readings
                            wheel_detection.Add(Right_Sensor_Data[x]);

                            // Since we are looping through the tyre readings, we might aswell look for the highest value
                            if (Right_Sensor_Data[x] > highest_temp)
                            {
                                highest_temp = Right_Sensor_Data[x];
                            }
                        }
                        else
                        {
                            // Stopped recording, this statement checks if it could of been a spike/glitch
                            // If the sample size was too small it wont create a wheel data
                            // This could be improved/more advanced
                            if (wheel_detection.Count > Spike_Tolerance)
                            {
                                Wheel_Data rightwheel = new Wheel_Data(wheel_detection.ToArray(), highest_temp);
                                CarData.Right_Wheel_Logs.Add(rightwheel);
                            }

                            // Step out and continue where we left off
                            i = x;
                            // Reset
                            highest_temp = -999;
                            wheel_detection.Clear();
                            break;
                        }
                    }
                }
            }

            // Left Wheel
            for (int i = 0; i < Left_Sensor_Data.Length; i++)
            {
                if (Left_Sensor_Data[i] > (Left_Sensor_Ambient + Sensor_Sensitivity))
                {
                    for (int x = i; x < Left_Sensor_Data.Length; x++)
                    {
                        if (Left_Sensor_Data[x] > (Left_Sensor_Ambient + Sensor_Sensitivity))
                        {
                            wheel_detection.Add(Left_Sensor_Data[x]);

                            if (Left_Sensor_Data[x] > highest_temp)
                            {
                                highest_temp = Left_Sensor_Data[x];
                            }
                        }
                        else
                        {
                            if (wheel_detection.Count > Spike_Tolerance)
                            {
                                Wheel_Data leftwheel = new Wheel_Data(wheel_detection.ToArray(), highest_temp);
                                CarData.Left_Wheel_Logs.Add(leftwheel);
                            }

                            i            = x;
                            highest_temp = -999;
                            wheel_detection.Clear();
                            break;
                        }
                    }
                }
            }
        }
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            // Create OpenFileDialog
            Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();



            // Set filter for file
            dlg.DefaultExt = ".txt";
            dlg.Filter     = "Text Files (*.txt)|*.txt";


            Nullable <bool> result = dlg.ShowDialog();


            if (result == true)
            {
                // Open document
                string filename = dlg.FileName;
                searchBox.Text = filename;


                // Used to debug the sensor sensitivity
                int sensor_sensitivity;
                try
                {
                    // Range of 1 - 6
                    if (Int32.Parse(sensSensivity.Text) > 0 && Int32.Parse(sensSensivity.Text) <= 6)
                    {
                        sensor_sensitivity = Int32.Parse(sensSensivity.Text);
                    }
                    else
                    {
                        // Invalid
                        MessageBox.Show("Sensitivity range is 1 - 6, sensitivity has been set to 2 (default)", "Invalid Input", MessageBoxButton.OK, MessageBoxImage.Exclamation, MessageBoxResult.OK);
                        sensor_sensitivity = 2;
                        sensSensivity.Text = "2";
                    }
                }
                catch (System.FormatException)
                {
                    // Error
                    MessageBox.Show("Single number only, sensitivity has been set to 2 (default)", "Invalid Input", MessageBoxButton.OK, MessageBoxImage.Exclamation, MessageBoxResult.OK);
                    sensor_sensitivity = 2;
                    sensSensivity.Text = "2";
                }

                // Create object with all data given in parameters
                Sensor_Data dataSet = new Sensor_Data(Read_textData(filename), sensor_sensitivity);

                // Load in Ambient temperatures
                leftSensorAmbient.Text  = dataSet.Left_Sensor_Ambient.ToString() + "°C";
                rightSensorAmbient.Text = dataSet.Right_Sensor_Ambient.ToString() + "°C";

                // Clear datagrid if new text file is loaded
                leftSensorGrid.Items.Clear();
                rightSensorGrid.Items.Clear();

                id = 1;
                // Load in type data, highest and average temperatures (Left sensor)
                for (int i = 0; i < dataSet.CarData.Left_Wheel_Logs.Count; i++)
                {
                    Wheel_Data current = dataSet.CarData.Left_Wheel_Logs[i];
                    current.Id = GenerateId();
                    leftSensorGrid.Items.Add(current);
                }
                id = 1;
                // Load in type data, highest and average temperatures (right sensor)
                for (int i = 0; i < dataSet.CarData.Right_Wheel_Logs.Count; i++)
                {
                    Wheel_Data current = dataSet.CarData.Right_Wheel_Logs[i];
                    current.Id = GenerateId();
                    rightSensorGrid.Items.Add(current);
                }
            }
        }