/// <summary>
        /// Adds the full hr data to the display
        /// </summary>
        private void FullData(string type)
        {
            dataGroupBox.Controls.Clear();
            fullData      = new DataGridView();
            fullData.Dock = DockStyle.Fill;
            fullData.Columns.Add("time", "Time");

            fullData.CellMouseEnter += dataGridView_CellMouseMove;
            fullData.CellMouseLeave += dataGridView_CellMouseLeave;
            Smode smode = dv.GetSmode();

            dataGroupBox.Controls.Add(fullData);

            fullData.Columns.Add("heartRate", "Heart Rate(BPM)");
            if (smode.Speed)
            {
                if (unit)
                {
                    fullData.Columns.Add("speed", "Speed(MPH)");
                }
                else
                {
                    fullData.Columns.Add("speed", "Speed(KPH)");
                }
            }
            if (smode.Cadence)
            {
                fullData.Columns.Add("cadence", "Cadence(RPM)");
            }
            if (smode.Altitude)
            {
                if (unit)
                {
                    fullData.Columns.Add("altitude", "Altitude(Feet)");
                }
                else
                {
                    fullData.Columns.Add("altitude", "Altitude(Meters)");
                }
            }
            if (smode.Power)
            {
                if (unit)
                {
                    fullData.Columns.Add("power", "Power(% of FTP)");
                }
                else
                {
                    fullData.Columns.Add("power", "Power(W)");
                }
            }
            if (smode.PowerLeftRightBalance)
            {
                fullData.Columns.Add("powerBalance", "Power Balance");
            }
            if (smode.PowerPedallingIndex)
            {
                fullData.Columns.Add("powerPedelingIndex", "Power Pedeling Index");
            }
            if (smode.HRCC1)
            {
                //we will need this if hr data only
            }

            if (smode.AirPressure)
            {
                fullData.Columns.Add("airPressure", "Air Pressure");
            }

            //we then need to loop through all data
            List <HrDataSingle> dataSmall;

            if (unit)
            {
                dataSmall = data[0];
            }
            else
            {
                dataSmall = data[1];
            }
            DateTime dateTimeRide = dv.GetRideTime();

            if (type.Equals("chunk"))
            {
                //add the start time of the chunk
                DateTime zeroPoint = new DateTime(chunkStart.Year, chunkStart.Month, chunkStart.Day, 0, 0, 0);
                TimeSpan offset    = chunkStart - zeroPoint;

                dateTimeRide = dateTimeRide.AddSeconds(offset.TotalSeconds);
            }
            int recordingIntervalInt = dv.GetInterval();

            foreach (HrDataSingle dataLine in dataSmall)
            {
                List <string> dataToBeInserted = new List <string>();
                //first add the time column
                //we need to add the interval
                dateTimeRide = dateTimeRide.AddSeconds(recordingIntervalInt);

                dataToBeInserted.Add(dateTimeRide.ToLongTimeString());

                dataToBeInserted.Add("" + dataLine.HeartRate);

                if (smode.Speed)
                {
                    dataToBeInserted.Add("" + Math.Round(dataLine.Speed, 2));
                }
                if (smode.Cadence)
                {
                    dataToBeInserted.Add("" + dataLine.Cadence);
                }
                if (smode.Altitude)
                {
                    dataToBeInserted.Add("" + dataLine.Altitude);
                }
                if (smode.Power)
                {
                    dataToBeInserted.Add("" + dataLine.Power);
                }
                if (smode.PowerLeftRightBalance)
                {
                    dataToBeInserted.Add("" + dataLine.PB);
                }
                if (smode.PowerPedallingIndex)
                {
                    dataToBeInserted.Add("" + dataLine.PI);
                }


                if (smode.AirPressure)
                {
                    dataToBeInserted.Add("" + dataLine.AirPressure);
                }
                fullData.Rows.Add(dataToBeInserted.ToArray());
            }
        }
示例#2
0
        /// <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");
            }
        }
示例#3
0
        /// <summary>
        /// constructor for the data from the cycle
        /// </summary>
        /// <param name="dataType">false for euro units, true for US</param>
        /// <param name="version">version of the file</param>
        /// <param name="rawData">list of the raw HR data</param>
        /// <param name="smode">the SMODE for the currnet file</param>
        /// <param name="cadAlt">Cad aLt if need for an earlier file, defaults to 46 if not provied</param>
        public HrData(Boolean dataType, int version, List <string> rawData, Smode smode, int cadAlt = 46)
        {
            this.smode = smode;
            //means euro data type
            if (!dataType)
            {
                //Console.WriteLine("We are meme 3.512");
                dataEuro = new List <HrDataSingle>();
                dataUS   = new List <HrDataSingle>();
                foreach (string line in rawData)
                {
                    HrDataSingle tempEuro = new HrDataSingle(line.Split('\t').ToList <string>(), version, smode, cadAlt);
                    //Console.WriteLine("We are meme 3.513");
                    //we need to convert form euro to us
                    List <string> lineConverted = new List <string>();
                    lineConverted.Add("" + tempEuro.HeartRate);
                    //we times by 10 to compensate for the divide in hr data single
                    lineConverted.Add("" + ((tempEuro.Speed * 0.621371) * 10));
                    //Console.WriteLine("We are meme 3.513");
                    if (cadAlt == 0)
                    {
                        lineConverted.Add("" + tempEuro.Cadence);
                    }
                    else if (cadAlt == 1)
                    {
                        lineConverted.Add("" + (tempEuro.Altitude * 3.280839895));
                    }
                    else
                    {
                        lineConverted.Add("" + tempEuro.Cadence);
                        lineConverted.Add("" + (tempEuro.Altitude * 3.280839895));
                        //Console.WriteLine("We are meme 3.5134");
                    }
                    lineConverted.Add("" + tempEuro.Power);
                    lineConverted.Add("" + tempEuro.PbPedInd);
                    lineConverted.Add("" + tempEuro.AirPressure);
                    dataUS.Add(new HrDataSingle(lineConverted, version, smode, cadAlt));
                    //Console.WriteLine("We are meme 3.5135");
                    dataEuro.Add(tempEuro);
                    //Console.WriteLine("We are meme 3.5136");
                }
                //Console.WriteLine("We are meme 3.512");
            }
            else
            {
                foreach (string line in rawData)
                {
                    dataUS   = new List <HrDataSingle>();
                    dataEuro = new List <HrDataSingle>();

                    HrDataSingle tempUS = new HrDataSingle(line.Split('\t').ToList <string>(), version, smode, cadAlt);
                    //we need to convert form us to
                    List <string> lineConverted = new List <string>();
                    lineConverted.Add("" + tempUS.HeartRate);
                    lineConverted.Add("" + ((tempUS.Speed * 1.609344) * 10));
                    if (cadAlt == 0)
                    {
                        lineConverted.Add("" + tempUS.Cadence);
                    }
                    else if (cadAlt == 1)
                    {
                        lineConverted.Add("" + (tempUS.Altitude * 0.3048));
                    }
                    else
                    {
                        lineConverted.Add("" + tempUS.Cadence);
                        lineConverted.Add("" + (tempUS.Altitude * 0.3048));
                    }
                    lineConverted.Add("" + tempUS.Power);
                    lineConverted.Add("" + tempUS.PbPedInd);
                    lineConverted.Add("" + tempUS.AirPressure);
                    dataEuro.Add(new HrDataSingle(lineConverted, version, smode, cadAlt));
                    dataUS.Add(tempUS);
                }
            }
        }
示例#4
0
        /// <summary>
        /// Constructor for this calss
        /// </summary>
        /// <param name="data">list of the hr data to be used</param>
        /// <param name="version">version of the file</param>
        /// <param name="smode">SMODE of the current file</param>
        /// <param name="cadAlt">cad alt if provided, defaults to 46</param>
        /// <param name="pbPed">if not supplied set to null</param>
        public HrDataSingle(List <string> data, int version, Smode smode, int cadAlt = 46, string pbPed = null)
        {
            this.powerBalance = "";
            this.powerIndex   = "";

            this.smode = smode;
            heartRate  = cadence = altitude = power = airPressure = 0;
            pbPedInd   = "";
            speed      = 0.0;

            //depending upon which sensors are in use, means data will be pulled from a different position
            if (version == 105)
            {
                heartRate = (int)Convert.ToDouble(data.ElementAt(0));
                speed     = Convert.ToDouble(data.ElementAt(1)) / 10;
                if (cadAlt == 0)
                {
                    cadence = Convert.ToInt32(data.ElementAt(2));
                }
                else if (cadAlt == 1)
                {
                    altitude = (int)Convert.ToDouble(data.ElementAt(2));;
                }
            }
            else if (version == 106)
            {
                heartRate = Convert.ToInt32(data.ElementAt(0));


                if (smode.Speed)
                {
                    speed = Convert.ToDouble(data.ElementAt(1)) / 10;
                }

                if (smode.Cadence && smode.Speed)
                {
                    cadence = Convert.ToInt32(data.ElementAt(2));
                }
                else if (!smode.Speed)
                {
                    cadence = Convert.ToInt32(data.ElementAt(1));
                }

                if (smode.Altitude && smode.Cadence && smode.Speed)
                {
                    try
                    {
                        altitude = Convert.ToInt32(data.ElementAt(3).Split('.')[0]);
                    }
                    catch (Exception e)
                    {
                        smode.Altitude = false;
                    }
                }
                else if (!smode.Cadence && !smode.Speed && smode.Altitude)
                {
                    altitude = Convert.ToInt32(data.ElementAt(1).Split('.')[0]);
                }
                else if (!smode.Cadence && smode.Speed && smode.Altitude)
                {
                    altitude = Convert.ToInt32(data.ElementAt(2).Split('.')[0]);
                }
                else if (smode.Cadence && !smode.Speed && smode.Altitude)
                {
                    altitude = Convert.ToInt32(data.ElementAt(2).Split('.')[0]);
                }


                if (smode.Power && smode.Speed && smode.Altitude && smode.Cadence)
                {
                    try
                    {
                        power = Convert.ToInt32(data.ElementAt(4));
                    }
                    catch (Exception e)
                    {
                        smode.Power = false;
                        smode.PowerLeftRightBalance = false;
                        smode.PowerPedallingIndex   = false;
                    }
                }
                else if (smode.Power && !smode.Speed && !smode.Altitude && !smode.Cadence)
                {
                    power = Convert.ToInt32(data.ElementAt(1));
                }
                else if (smode.Power && smode.Speed && smode.Altitude && !smode.Cadence)
                {
                    power = Convert.ToInt32(data.ElementAt(3));
                }
                else if (smode.Power && smode.Speed && !smode.Altitude && smode.Cadence)
                {
                    power = Convert.ToInt32(data.ElementAt(3));
                }
                else if (smode.Power && !smode.Speed && smode.Altitude && !smode.Cadence)
                {
                    power = Convert.ToInt32(data.ElementAt(2));
                }
                else if (smode.Power && !smode.Speed && !smode.Altitude && smode.Cadence)
                {
                    power = Convert.ToInt32(data.ElementAt(2));
                }
                else if (smode.Power && !smode.Speed && smode.Altitude && smode.Cadence)
                {
                    power = Convert.ToInt32(data.ElementAt(3));
                }



                if (smode.PowerLeftRightBalance && smode.Power && smode.Speed && smode.Altitude && smode.Cadence)
                {
                    try
                    {
                        pbPedInd = data.ElementAt(5);
                        GetPBIndex();
                    }
                    catch (Exception e)
                    {
                        smode.PowerLeftRightBalance = false;
                        smode.PowerPedallingIndex   = false;
                    }
                }
                else if (smode.PowerLeftRightBalance && smode.Power && !smode.Speed && !smode.Altitude && !smode.Cadence)
                {
                    pbPedInd = data.ElementAt(2);
                    GetPBIndex();
                }
                else if (smode.PowerLeftRightBalance && smode.Power && smode.Speed && smode.Altitude && !smode.Cadence)
                {
                    pbPedInd = data.ElementAt(4);
                    GetPBIndex();
                }
                else if (smode.PowerLeftRightBalance && smode.Power && smode.Speed && !smode.Altitude && smode.Cadence)
                {
                    pbPedInd = data.ElementAt(4);
                    GetPBIndex();
                }
                else if (smode.PowerLeftRightBalance && smode.Power && !smode.Speed && smode.Altitude && !smode.Cadence)
                {
                    pbPedInd = data.ElementAt(4);
                    GetPBIndex();
                }
                else if (smode.PowerLeftRightBalance && smode.Power && !smode.Speed && !smode.Altitude && smode.Cadence)
                {
                    pbPedInd = data.ElementAt(4);
                    GetPBIndex();
                }
                else if (smode.PowerLeftRightBalance && smode.Power && !smode.Speed && smode.Altitude && smode.Cadence)
                {
                    pbPedInd = data.ElementAt(4);

                    GetPBIndex();
                }
            }
            else if (version == 107)
            {
                heartRate = Convert.ToInt32(data.ElementAt(0));


                if (smode.Speed)
                {
                    speed = Convert.ToDouble(data.ElementAt(1)) / 10;
                }

                if (smode.Cadence && smode.Speed)
                {
                    cadence = Convert.ToInt32(data.ElementAt(2));
                }
                else if (!smode.Speed)
                {
                    cadence = Convert.ToInt32(data.ElementAt(1));
                }

                if (smode.Altitude && smode.Cadence && smode.Speed)
                {
                    altitude = Convert.ToInt32(data.ElementAt(3).Split('.')[0]);
                }
                else if (!smode.Cadence && !smode.Speed && smode.Altitude)
                {
                    altitude = Convert.ToInt32(data.ElementAt(1).Split('.')[0]);
                }
                else if (!smode.Cadence && smode.Speed && smode.Altitude)
                {
                    altitude = Convert.ToInt32(data.ElementAt(2).Split('.')[0]);
                }
                else if (smode.Cadence && !smode.Speed && smode.Altitude)
                {
                    altitude = Convert.ToInt32(data.ElementAt(2).Split('.')[0]);
                }


                if (smode.Power && smode.Speed && smode.Altitude && smode.Cadence)
                {
                    power = Convert.ToInt32(data.ElementAt(4));
                }
                else if (smode.Power && !smode.Speed && !smode.Altitude && !smode.Cadence)
                {
                    power = Convert.ToInt32(data.ElementAt(1));
                }
                else if (smode.Power && smode.Speed && smode.Altitude && !smode.Cadence)
                {
                    power = Convert.ToInt32(data.ElementAt(3));
                }
                else if (smode.Power && smode.Speed && !smode.Altitude && smode.Cadence)
                {
                    power = Convert.ToInt32(data.ElementAt(3));
                }
                else if (smode.Power && !smode.Speed && smode.Altitude && !smode.Cadence)
                {
                    power = Convert.ToInt32(data.ElementAt(3));
                }
                else if (smode.Power && !smode.Speed && !smode.Altitude && smode.Cadence)
                {
                    power = Convert.ToInt32(data.ElementAt(3));
                }
                else if (smode.Power && !smode.Speed && smode.Altitude && smode.Cadence)
                {
                    power = Convert.ToInt32(data.ElementAt(3));
                }



                if (smode.PowerLeftRightBalance && smode.Power && smode.Speed && smode.Altitude && smode.Cadence)
                {
                    pbPedInd = data.ElementAt(5);
                    GetPBIndex();
                }
                else if (smode.PowerLeftRightBalance && smode.Power && !smode.Speed && !smode.Altitude && !smode.Cadence)
                {
                    pbPedInd = data.ElementAt(2);
                    GetPBIndex();
                }
                else if (smode.PowerLeftRightBalance && smode.Power && smode.Speed && smode.Altitude && !smode.Cadence)
                {
                    pbPedInd = data.ElementAt(4);
                    GetPBIndex();
                }
                else if (smode.PowerLeftRightBalance && smode.Power && smode.Speed && !smode.Altitude && smode.Cadence)
                {
                    pbPedInd = data.ElementAt(4);
                    GetPBIndex();
                }
                else if (smode.PowerLeftRightBalance && smode.Power && !smode.Speed && smode.Altitude && !smode.Cadence)
                {
                    pbPedInd = data.ElementAt(4);
                    GetPBIndex();
                }
                else if (smode.PowerLeftRightBalance && smode.Power && !smode.Speed && !smode.Altitude && smode.Cadence)
                {
                    pbPedInd = data.ElementAt(4);
                    GetPBIndex();
                }
                else if (smode.PowerLeftRightBalance && smode.Power && !smode.Speed && smode.Altitude && smode.Cadence)
                {
                    pbPedInd = data.ElementAt(4);
                    GetPBIndex();
                }



                airPressure = Convert.ToInt32(data.ElementAt(6));
            }
        }