Пример #1
0
        public bool Load(string filePath)
        {
            FileStream   fs = new FileStream(filePath, FileMode.Open, FileAccess.Read);
            StreamReader sr = new StreamReader(fs);

            string line = sr.ReadLine();

            if (!line.Contains("Time"))
            {
                return(false);
            }


            List <MeassurePoint> allData = new List <MeassurePoint>();

            while (!sr.EndOfStream)
            {
                MeassurePoint mp = MeassurePoint.Load(sr);
                allData.Add(mp);
            }


            List <MeassurePoint> startPoints = (from mp in allData where mp.TotalMinutes == 0 select mp).ToList();

            ///split stages
            StageData currentStage = null;

            foreach (MeassurePoint mp in allData)
            {
                if (startPoints.Contains(mp))
                {
                    currentStage = new StageData();
                    stagesData.Add(currentStage);
                }

                currentStage.Add(mp);
            }


            foreach (StageData stage in stagesData)
            {
                stage.ProcessData();
            }


            return(true);
        }
Пример #2
0
        static public MeassurePoint Load(StreamReader sr)
        {
            string[] vals = null;
            try
            {
                vals = sr.ReadLine().Split(',', ';');
            }
            catch (Exception e)
            {
                return(null);
            }

            MeassurePoint mp = new MeassurePoint()
            {
                Time               = DateTime.ParseExact(vals[0], "HH:mm:ss", System.Globalization.CultureInfo.CurrentCulture),
                TotalMinutes       = double.Parse(vals[1]),
                BatteryVoltage     = double.Parse(vals[2]),
                BatteryCurrent     = double.Parse(vals[3]),
                PowerSourceVoltage = double.Parse(vals[5]),
                PowerSourceCurrent = double.Parse(vals[7])
            };

            return(mp);
        }