Beispiel #1
0
        private static void GetReadings(object sender, ElapsedEventArgs e)
        {
            string line;

            // check we're not at the end of the file
            if ((line = lapData.ReadLine()) != null)
            {
                // get the individual reading values
                string[] readings = line.Split(',');
                string   time     = DateTime.Now.ToString();

                // Add GPS sensor reading to list for this lap
                Location loc = new Location();
                loc.lat = Double.Parse(readings[0]);
                loc.lon = Double.Parse(readings[1]);
                GpsReading gps = new GpsReading();
                gps.Time     = time;
                gps.Position = loc;
                gps.Speed    = Double.Parse(readings[4]);
                GpsReadings.Add(gps);

                // Add Engine sensor reading to list for this lap
                EngineReading eng = new EngineReading();
                eng.Time    = time;
                eng.Revs    = Double.Parse(readings[2]);
                eng.OilTemp = Double.Parse(readings[5]);
                EngineReadings.Add(eng);

                // Add Brake sensor reading to list for this lap
                BrakeReading brake = new BrakeReading();
                brake.Time      = time;
                brake.BrakeTemp = Double.Parse(readings[3]);
                BrakeReadings.Add(brake);

                // Display readings in the console
                Console.WriteLine(time);
                Console.WriteLine("Position: " + gps.Position.lat.ToString() + "," + gps.Position.lon.ToString());
                Console.WriteLine("Speed: " + gps.Speed.ToString());
                Console.WriteLine("Revs: " + eng.Revs.ToString());
                Console.WriteLine("Oil Temp: " + eng.OilTemp.ToString());
                Console.WriteLine("Brake Temp: " + brake.BrakeTemp.ToString());
                Console.WriteLine("-----------------------------------------------------------");
            }
            else
            {
                running = false;
            }
        }
        private static void GetReadings(object sender, ElapsedEventArgs e)
        {
            string line;
            // check we're not at the end of the file
            if ((line = lapData.ReadLine()) != null)
            {
                // get the individual reading values
                string[] readings = line.Split(',') ;
                string time = DateTime.Now.ToString();

                // Add GPS sensor reading to list for this lap
                Location loc = new Location();
                loc.lat = Double.Parse(readings[0]);
                loc.lon = Double.Parse(readings[1]);
                GpsReading gps = new GpsReading();
                gps.Time = time;
                gps.Position = loc;
                gps.Speed = Double.Parse(readings[4]);
                GpsReadings.Add(gps);

                // Add Engine sensor reading to list for this lap
                EngineReading eng = new EngineReading();
                eng.Time = time;
                eng.Revs = Double.Parse(readings[2]);
                eng.OilTemp = Double.Parse(readings[5]);
                EngineReadings.Add(eng);

                // Add Brake sensor reading to list for this lap
                BrakeReading brake = new BrakeReading();
                brake.Time = time;
                brake.BrakeTemp = Double.Parse(readings[3]);
                BrakeReadings.Add(brake);
                
                // Display readings in the console
                Console.WriteLine(time);
                Console.WriteLine("Position: " + gps.Position.lat.ToString() + "," + gps.Position.lon.ToString());
                Console.WriteLine("Speed: " + gps.Speed.ToString());
                Console.WriteLine("Revs: " + eng.Revs.ToString());
                Console.WriteLine("Oil Temp: " + eng.OilTemp.ToString());
                Console.WriteLine("Brake Temp: " + brake.BrakeTemp.ToString());
                Console.WriteLine("-----------------------------------------------------------");

            }
            else
            {
                running = false;
            }
        }