/// <summary> /// Constructor /// </summary> /// <param name="dv">reference to the dataview for this file</param> /// <param name="cyMain">refrenec to the main window</param> /// <param name="file">file, file 1 or file 2</param> public ComparrisonControl(DataViewImproved dv, CyclingMain cyMain, string file) { InitializeComponent(); this.dv = dv; this.hrData = dv.GetFullData(); this.cyMain = cyMain; unit = false; this.file = file; groupBox1.Text = file; chunks = new List <DateTime[]>(); data[0] = hrData.DataEuro; data[1] = hrData.DataUS; UpdateSummaryNoDate(); FullDataNoDate(); //just set the data in the view now }
/// <summary> /// function called to separate the data /// </summary> public void SeparateData() { // Console.WriteLine("We are in separeate data"); try { //Console.WriteLine("We are in try catch"); using (StreamReader sr = new StreamReader(filePath)) { //Console.WriteLine("We are in reader"); bool parameters, note, intTime, intNotes, extraData, lapName, summary123, summaryTh, hrZone, swapTime, trip, hrData; parameters = note = intTime = intNotes = extraData = lapName = summary123 = summaryTh = hrZone = swapTime = trip = hrData = false; string line; //Console.WriteLine("We are meme 1"); // Read and display lines from the file until // the end of the file is reached. while ((line = sr.ReadLine()) != null) { // Console.WriteLine("We are reading data"); if (line.Equals("")) { continue; } switch (line) { case "[Params]": parameters = true; note = false; intTime = false; intNotes = false; extraData = false; lapName = false; summary123 = false; summaryTh = false; hrZone = false; swapTime = false; trip = false; hrData = false; break; case "[Note]": parameters = false; note = true; intTime = false; intNotes = false; extraData = false; lapName = false; summary123 = false; summaryTh = false; hrZone = false; swapTime = false; trip = false; hrData = false; break; case "[IntTimes]": parameters = false; note = false; intTime = true; intNotes = false; extraData = false; lapName = false; summary123 = false; summaryTh = false; hrZone = false; swapTime = false; trip = false; hrData = false; break; case "[IntNotes]": parameters = false; note = false; intTime = false; intNotes = true; extraData = false; lapName = false; summary123 = false; summaryTh = false; hrZone = false; swapTime = false; trip = false; hrData = false; break; case "[ExtraData]": parameters = false; note = false; intTime = false; intNotes = false; extraData = true; lapName = false; summary123 = false; summaryTh = false; hrZone = false; swapTime = false; trip = false; hrData = false; break; case "[LapNames]": parameters = false; note = false; intTime = false; intNotes = false; extraData = false; lapName = true; summary123 = false; summaryTh = false; hrZone = false; swapTime = false; trip = false; hrData = false; break; case "[Summary-123]": parameters = false; note = false; intTime = false; intNotes = false; extraData = false; lapName = false; summary123 = true; summaryTh = false; hrZone = false; swapTime = false; trip = false; hrData = false; break; case "[Summary-TH]": parameters = false; note = false; intTime = false; intNotes = false; extraData = false; lapName = false; summary123 = false; summaryTh = true; hrZone = false; swapTime = false; trip = false; hrData = false; break; case "[HRZones]": parameters = false; note = false; intTime = false; intNotes = false; extraData = false; lapName = false; summary123 = false; summaryTh = false; hrZone = true; swapTime = false; trip = false; hrData = false; break; case "[SwapTimes]": parameters = false; note = false; intTime = false; intNotes = false; extraData = false; lapName = false; summary123 = false; summaryTh = false; hrZone = false; swapTime = true; trip = false; hrData = false; break; case "[Trip]": parameters = false; note = false; intTime = false; intNotes = false; extraData = false; lapName = false; summary123 = false; summaryTh = false; hrZone = false; swapTime = false; trip = true; hrData = false; break; case "[HRData]": parameters = false; note = false; intTime = false; intNotes = false; extraData = false; lapName = false; summary123 = false; summaryTh = false; hrZone = false; swapTime = false; trip = false; hrData = true; break; } if (parameters) { parametersList.Add(line); } else if (note) { noteList.Add(line); } else if (intTime) { intTimeList.Add(line); } else if (intNotes) { intNotesList.Add(line); } else if (extraData) { extraDataList.Add(line); } else if (lapName) { lapNameList.Add(line); } else if (summary123) { summary123List.Add(line); } else if (summaryTh) { summaryThList.Add(line); } else if (hrZone) { hrZoneList.Add(line); } else if (swapTime) { swapTimeList.Add(line); } else if (trip) { tripList.Add(line); } else if (hrData) { hrDataList.Add(line); } } } } catch (Exception e) { Console.WriteLine("Error In reading File: " + e.Message); } //Console.WriteLine("We are meme 2"); //we need to separate the data out futher //Console.WriteLine(parametersList.ElementAt(1)); version = Convert.ToInt32(parametersList.ElementAt(1).Split('=')[1]); monitor = GetMonitorType(parametersList.ElementAt(2)); if (version <= 105) { mode = new Mode(parametersList.ElementAt(3).Split('=')[1]); smode = null; } else if (version >= 106) { smode = new Smode(version, parametersList.ElementAt(3).Split('=')[1]); mode = null; } date = parametersList.ElementAt(4).Split('=')[1]; startTime = parametersList.ElementAt(5).Split('=')[1]; //Console.WriteLine("We are meme 3"); length = parametersList.ElementAt(6).Split('=')[1]; interval = Convert.ToInt32(parametersList.ElementAt(7).Split('=')[1]); upper1 = Convert.ToInt32(parametersList.ElementAt(8).Split('=')[1]); lower1 = Convert.ToInt32(parametersList.ElementAt(9).Split('=')[1]); upper2 = Convert.ToInt32(parametersList.ElementAt(10).Split('=')[1]); lower2 = Convert.ToInt32(parametersList.ElementAt(11).Split('=')[1]); upper3 = Convert.ToInt32(parametersList.ElementAt(12).Split('=')[1]); lower3 = Convert.ToInt32(parametersList.ElementAt(13).Split('=')[1]); timer1 = parametersList.ElementAt(14).Split('=')[1];; timer2 = parametersList.ElementAt(15).Split('=')[1];; timer3 = parametersList.ElementAt(16).Split('=')[1];; activeLimit = parametersList.ElementAt(17).Split('=')[1]; maxHR = Convert.ToInt32(parametersList.ElementAt(18).Split('=')[1]); restHR = Convert.ToInt32(parametersList.ElementAt(19).Split('=')[1]); startDelay = Convert.ToInt32(parametersList.ElementAt(20).Split('=')[1]); VO2max = Convert.ToInt32(parametersList.ElementAt(21).Split('=')[1]); weight = Convert.ToInt32(parametersList.ElementAt(22).Split('=')[1]); date = FlipDate(); rideInfo.Add(date); rideInfo.Add(startTime); rideInfo.Add(length); rideInfo.Add("" + interval); // Console.WriteLine("We are meme 5"); //we remove the header that was used for detection [Hr Data] hrDataList.RemoveAt(0); if (version <= 105) { hrDataExtended = new HrData(unitBool, version, hrDataList, smode, mode.CadAltInt); //Console.WriteLine("We are meme 3.5"); } else { hrDataExtended = new HrData(unitBool, version, hrDataList, smode); //Console.WriteLine("We are meme 3.51"); } //Console.WriteLine("We are meme 3"); //Storing the summary data if (!unitBool) { if (smode.Speed) { //total distance double distance = 0; distance = GetTotalDistance(HrDataExtended.DataEuro); summaryEuro.Add("Total Distance", "" + Math.Round(distance, 2) + "KM"); summaryUS.Add("Total Distance", "" + Math.Round((distance * 0.621371), 2) + "Miles"); //Average Speed double averageSpeed = GetAverageSpeed(hrDataExtended.DataEuro); summaryEuro.Add("Average Speed", "" + Math.Round(averageSpeed) + "KPH"); summaryUS.Add("Average Speed", "" + Math.Round((averageSpeed * 0.6213711922), 2) + "MPH"); //maximum speed double speed = GetMaxSpeed(hrDataExtended.DataEuro); summaryEuro.Add("Maximum Speed", "" + speed + "KPH"); summaryUS.Add("Maximum Speed", "" + Math.Round((speed * 0.6213711922), 2) + "MPH"); } //Average Heart Rate int averageHeartRate = GetAverageHeartRate(HrDataExtended.DataEuro); summaryEuro.Add("Average Heart Rate", "" + averageHeartRate); summaryUS.Add("Average Heart Rate", "" + averageHeartRate); int maxHeartRate = GetMaxHeartRate(hrDataExtended.DataEuro); //Max Heart Rate summaryEuro.Add("Maximum Heart Rate", "" + maxHeartRate + " BPM"); summaryUS.Add("Maximum Heart Rate", "" + maxHeartRate + " BPM"); //Min Heart Rate int minHeartRate = GetMinHeartRate(hrDataExtended.DataEuro);; summaryEuro.Add("Minimum Heart Rate", "" + minHeartRate + " BPM"); summaryUS.Add("Minimum Heart Rate", "" + minHeartRate + " BPM"); if (smode.Power) { //Average power int PowerAverage = GetAveragePower(hrDataExtended.DataEuro); summaryEuro.Add("Average Power", "" + PowerAverage); summaryUS.Add("Average Power", "" + PowerAverage); //Max Power int maxpower = GetMaxPower(hrDataExtended.DataEuro); summaryEuro.Add("Maximum Power", "" + maxpower); summaryUS.Add("Maximum Power", "" + maxpower); } if (smode.Altitude) { //Average Altitude double averageAlt = GetAverageAltitude(hrDataExtended.DataEuro);; summaryEuro.Add("Average Altitude", "" + Math.Round(averageAlt, 2) + " Meters"); SummaryUS.Add("Average Altitude", "" + Math.Round((averageAlt * 3.280839895), 2) + " Feet"); //Max Altitude double maxAlt = GetMaxAltitude(hrDataExtended.DataEuro); summaryEuro.Add("Maximum Altitude", "" + (maxAlt) + " Meters"); SummaryUS.Add("Maximum Altitude", "" + Math.Round((maxAlt * 3.280839895), 2) + " Feet"); } } else { if (smode.Speed) { //total distance not sure if for that trip or the odometer double distance = GetTotalDistance(hrDataExtended.DataUS); summaryEuro.Add("Total Distance", "" + Math.Round((distance * 1.60934), 2) + "KM"); summaryUS.Add("Total Distance", "" + Math.Round(distance, 2) + "Miles"); //Average Speed double averageSpeed = GetAverageSpeed(hrDataExtended.DataUS);; summaryEuro.Add("Average Speed", "" + Math.Round((averageSpeed * 1.60934), 2) + " KPH"); summaryUS.Add("Average Speed", "" + Math.Round(averageSpeed, 2) + " MPH"); //maximum speed double speed = GetMaxSpeed(hrDataExtended.DataUS); summaryEuro.Add("Maximum Speed", "" + Math.Round((speed * 1.60934), 2) + " KMPH"); summaryUS.Add("Maximum Speed", "" + speed + " MPH"); } //us starting values //Average Heart Rate int averageHeartRate = GetAverageHeartRate(hrDataExtended.DataUS); summaryEuro.Add("Average Heart Rate", "" + averageHeartRate + " BPM"); summaryUS.Add("Average Heart Rate", "" + averageHeartRate + " BPM"); int maxHeartRate = GetMaxHeartRate(hrDataExtended.DataUS); //Max Heart Rate summaryEuro.Add("Maximum Heart Rate", "" + maxHeartRate + " BPM"); summaryUS.Add("Maximum Heart Rate", "" + maxHeartRate + " BPM"); //Min Heart Rate int minHeartRate = GetMinHeartRate(hrDataExtended.DataUS); summaryEuro.Add("Minimum Heart Rate", "" + minHeartRate + " BPM"); summaryUS.Add("Minimum Heart Rate", "" + minHeartRate + " BPM"); if (smode.Power) { //Average power int PowerAverage = GetAveragePower(hrDataExtended.DataUS); summaryEuro.Add("Average Power", "" + PowerAverage + " Watts"); summaryUS.Add("Average Power", "" + PowerAverage + " Watts"); //Max Power int maxpower = GetMaxPower(hrDataExtended.DataUS); summaryEuro.Add("Max Power", "" + maxpower + " Watts"); summaryUS.Add("Max Power", "" + maxpower + " Watts"); } if (smode.Altitude) { //Average Altitude double averageAlt = GetAverageAltitude(hrDataExtended.DataUS); summaryEuro.Add("Average Altitude", "" + Math.Round((averageAlt * 0.3048), 2) + " Meters"); SummaryUS.Add("Average Altitude", "" + Math.Round(averageAlt, 2) + " Feet"); //Max Altitude double maxAlt = GetMaxAltitude(hrDataExtended.DataUS); summaryEuro.Add("Max Altitude", "" + Math.Round((maxAlt * 0.3048), 2) + "Meters"); SummaryUS.Add("Max Altitude", "" + Math.Round(maxAlt, 2) + "Feet"); } } //advanced metrics/normalised power if (smode.Power) { //we then can calc, we have the temp data int normPower = GetNormalisedPower(hrDataExtended.DataEuro); summaryEuro.Add("NormalisedPower", "" + normPower + " W"); SummaryUS.Add("NormalisedPower", "" + normPower + " W"); } }