Example #1
0
        private void LoadTCX(string in_strFileName)
        {
            if (in_strFileName == null) return;

            RunnerData data = new RunnerData();
            data.m_strFileName = in_strFileName;
            data.m_eType = RunnerData.eRunnerData.eFR305;
            data.m_dTime = DateTime.Today;
            data.m_dDistance = 0.0;
            data.m_dCalories = 0.0;
            data.m_dMaxHR = 0.0;
            data.m_dAvgHR = 0.0;
            data.m_dDate = DateTime.Today;

            try
            {
                StreamReader file = new StreamReader(data.m_strFileName);
                string strBuffer = file.ReadToEnd();
                file.Close();

                strBuffer = strBuffer.Replace(" xmlns=\"http://www.garmin.com/xmlschemas/TrainingCenterDatabase/v2\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.garmin.com/xmlschemas/TrainingCenterDatabase/v2 http://www.garmin.com/xmlschemas/TrainingCenterDatabasev2.xsd\"", "");
                strBuffer = strBuffer.Replace("xsi:", "");
                m_XmlDoc.LoadXml(strBuffer);

                string strPath = "//TrainingCenterDatabase/Activities/Activity/Lap";

                XmlNodeList xmlNodes = m_XmlDoc.DocumentElement.SelectNodes(strPath);
                if (xmlNodes == null) return;

                double dTime = 0.0;
                int nNodes = xmlNodes.Count;
                for (int iNode = 0; iNode < nNodes; iNode++)
                {
                    data.m_dDistance += ReadNodeToDouble(xmlNodes[iNode], "DistanceMeters") / 1000.0;
                    data.m_dCalories += ReadNodeToDouble(xmlNodes[iNode], "Calories");
                    double dMaxHR = ReadNodeToDouble(xmlNodes[iNode], "MaximumHeartRateBpm/Value");
                    if (dMaxHR > data.m_dMaxHR) data.m_dMaxHR = dMaxHR;
                    data.m_dAvgHR += ReadNodeToDouble(xmlNodes[iNode], "AverageHeartRateBpm/Value");
                    if (iNode == 0) data.m_dDate = ReadNodeToDateTime(xmlNodes[iNode], "@StartTime", "yyyy\\-MM\\-dd\\THH\\:mm\\:ss\\Z", true);
                    string strTime = ReadNode(xmlNodes[iNode], "TotalTimeSeconds");
                    dTime += ParseToDouble(strTime);
                }
                if (nNodes > 0) data.m_dAvgHR /= nNodes;
                data.m_dTime = data.m_dTime.AddSeconds(dTime);
                if (dTime != 0.0) data.m_dSpeed += data.m_dDistance * 3600.0 / dTime;
            }
            catch (Exception e)
            {
                Debug.WriteLine(e.ToString());
            }
            m_lstData.Add(data);
        }
Example #2
0
        private void LoadXML(string in_strFileName)
        {
            if (in_strFileName == null) return;

            RunnerData data = new RunnerData();
            data.m_strFileName = in_strFileName;
            data.m_eType = RunnerData.eRunnerData.eRS200;

            try
            {
                FileStream fs = new FileStream(data.m_strFileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
                m_XmlDoc.Load(fs);
                fs.Close();

                string strPath = "//rs200_session/session_data/";

                data.m_dDistance = ReadNodeToDouble(strPath + "summary/total_distance") / 1000.0;
                data.m_dAvgHR = ReadNodeToDouble(strPath + "summary/avg_hr");
                data.m_dMaxHR = ReadNodeToDouble(strPath + "summary/max_hr");
                data.m_dCalories = ReadNodeToDouble(strPath + "summary/calories");

                int iDay = ReadNodeToInt(strPath + "day");
                int iMonth = ReadNodeToInt(strPath + "month");
                int iYear = ReadNodeToInt(strPath + "year");
                int iHour = ReadNodeToInt(strPath + "start_hour");
                int iMinute = ReadNodeToInt(strPath + "start_minute");
                int iSecond = ReadNodeToInt(strPath + "start_second");

                data.m_dDate = new DateTime(iYear, iMonth, iDay, iHour, iMinute, iSecond);
                double dTime = ReadNodeToDouble(strPath + "summary/length");
                data.m_dTime = DateTime.Today.AddSeconds(dTime);

                if (dTime != 0.0) data.m_dSpeed = data.m_dDistance * 3600 / dTime;
            }
            catch (Exception e)
            {
                Debug.WriteLine(e.ToString());
            }
            m_lstData.Add(data);
        }
Example #3
0
        private void LoadGPX(string in_strFileName)
        {
            if (in_strFileName == null) return;

            RunnerData data = new RunnerData();
            data.m_strFileName = in_strFileName;
            data.m_eType = RunnerData.eRunnerData.eKM700;

            try
            {
                StreamReader file = new StreamReader(data.m_strFileName);
                string strBuffer = file.ReadToEnd();
                file.Close();

                strBuffer = strBuffer.Replace(" version=\"1.0\" creator=\"KeyMaze 500-700 PC Software\" xmlns:st=\"urn:uuid:D0EB2ED5-49B6-44e3-B13C-CF15BE7DD7DD\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns=\"http://www.topografix.com/GPX/1/0\" xsi:schemaLocation=\"http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd\"", "");
                strBuffer = strBuffer.Replace("st:", "");
                m_XmlDoc.LoadXml(strBuffer);

                string strPath = "//gpx/extensions/activity/";

                data.m_dDistance = ReadNodeToDouble(strPath + "@distanceEntered") / 1000.0;
                data.m_dCalories = ReadNodeToDouble(strPath + "@calories");
                data.m_dDate = ReadNodeToDateTime(strPath + "@startTime", "yyyy\\-MM\\-dd\\THH\\:mm\\:ss\\Z", true);
                data.m_dTime = ReadNodeToDateTime(strPath + "@timeEntered", "HH\\:mm\\:ss", false);
                double dTime = data.m_dTime.Hour * 3600 + data.m_dTime.Minute * 60 + data.m_dTime.Second;
                if (dTime != 0.0) data.m_dSpeed = data.m_dDistance * 3600 / dTime;

                data.m_dMaxHR = 0.0;
                data.m_dAvgHR = 0.0;

                string[] lstHR = ReadNodes(strPath + "heartRateTrack/heartRate/@bpm");
                if (lstHR != null)
                {
                    int nHR = lstHR.Length;
                    for (int iHR = 0; iHR < nHR; iHR++)
                    {
                        double dValue = ParseToDouble(lstHR[iHR]);
                        if (dValue > data.m_dMaxHR) data.m_dMaxHR = dValue;
                        data.m_dAvgHR += dValue;
                    }
                    if (nHR > 0) data.m_dAvgHR /= nHR;
                }
            }
            catch (Exception e)
            {
                Debug.WriteLine(e.ToString());
            }
            m_lstData.Add(data);
        }