<meta name='google-adsense-platform-account' content='ca-host-pub-1556223355139109'/> <meta name='google-adsense-platform-domain' content='blogspot.com'/> <!-- data-ad-client=ca-pub-4320963827702032 --> <!-- --><style type="text/css">@import url(https://www.blogger.com/static/v1/v-css/navbar/3334278262-classic.css); div.b-mobile {display:none;} </style> </head><body><script type="text/javascript"> function setAttributeOnload(object, attribute, val) { if(window.addEventListener) { window.addEventListener('load', function(){ object[attribute] = val; }, false); } else { window.attachEvent('onload', function(){ object[attribute] = val; }); } } </script> <div id="navbar-iframe-container"></div> <script type="text/javascript" src="https://apis.google.com/js/platform.js"></script> <script type="text/javascript"> gapi.load("gapi.iframes:gapi.iframes.style.bubble", function() { if (gapi.iframes && gapi.iframes.getContext) { gapi.iframes.getContext().openChild({ url: 'https://www.blogger.com/navbar.g?targetBlogID\x3d7256432\x26blogName\x3dThe+Frustrated+Programmer\x26publishMode\x3dPUBLISH_MODE_BLOGSPOT\x26navbarType\x3dBLACK\x26layoutType\x3dCLASSIC\x26searchRoot\x3dhttps://frustratedprogrammer.blogspot.com/search\x26blogLocale\x3den_US\x26v\x3d2\x26homepageUrl\x3dhttp://frustratedprogrammer.blogspot.com/\x26vt\x3d4213664491834773269', where: document.getElementById("navbar-iframe-container"), id: "navbar-iframe", messageHandlersFilter: gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER, messageHandlers: { 'blogger-ping': function() {} } }); } }); </script>
| Sunday, January 29, 2012

I like to keep the data around from my Swimmovate PoolMate and entering the details into TrainingPeaks is very cumbersome. So I wrote a quick script to generate TCX files that can be uploaded. Its very simple:





#!/bin/bash

function do_lap() {
LAP_TIME=`expr $LAP_MINUTES \* 60`
LAP_TIME=`expr $LAP_TIME + $LAP_SECONDS`
echo " <Lap StartTime=\"$LAP_START\">" >> $START_DATE.tcx
echo " <TotalTimeSeconds>$LAP_TIME</TotalTimeSeconds>" >> $START_DATE.tcx
echo " <DistanceMeters>$LAP_DISTANCE</DistanceMeters>" >> $START_DATE.tcx
echo " <Intensity>$1</Intensity>" >> $START_DATE.tcx
echo " <TriggerMethod>Manual</TriggerMethod>" >> $START_DATE.tcx
echo " </Lap>" >> $START_DATE.tcx
MINUTE_OFFSET=`expr $MINUTE_OFFSET + $LAP_MINUTES`
SECOND_OFFSET=`expr $SECOND_OFFSET + $LAP_SECONDS`
}

START_DATE=`date +%Y-%m-%dT%H:%M:%S.000Z`
cat header.tcx > $START_DATE.tcx
echo " <Id>"$START_DATE"</Id>" >> $START_DATE.tcx
echo -n "Yards or Meters (y/m): "
read YARDS
echo -n "Number of sets: "
read SETS
CURRENT_SET=0
MINUTE_OFFSET=0
SECOND_OFFSET=0
while [ $CURRENT_SET -ne $SETS ]; do
echo -n "Set $CURRENT_SET Distance: "
read LAP_DISTANCE
if [ "$YARDS" = "y" ]; then
LAP_DISTANCE=`echo $LAP_DISTANCE \* 0.9144 | bc`
fi
echo -n "Set $CURRENT_SET Time (Min Sec): "
read LAP_MINUTES LAP_SECONDS
LAP_START=`date -v +${MINUTE_OFFSET}M -v +${SECOND_OFFSET}S +%Y-%m-%dT%H:%M:%S.000Z`
do_lap "Active"

#Default to 60 second reset between sets
LAP_MINUTES=0
LAP_SECONDS=60
LAP_DISTANCE=0
do_lap "Resting"

CURRENT_SET=`expr $CURRENT_SET + 1`
done
cat trailer.tcx >> $START_DATE.tcx



Here is header.tcx

<?xml version="1.0" encoding="UTF-8"?>
<TrainingCenterDatabase
xsi:schemaLocation="http://www.garmin.com/xmlschemas/TrainingCenterDatabase/v2 http://www.garmin.com/xmlschemas/TrainingCenterDatabasev2.xsd"
xmlns:ns5="http://www.garmin.com/xmlschemas/ActivityGoals/v1"
xmlns:ns3="http://www.garmin.com/xmlschemas/ActivityExtension/v2"
xmlns:ns2="http://www.garmin.com/xmlschemas/UserProfile/v2"
xmlns="http://www.garmin.com/xmlschemas/TrainingCenterDatabase/v2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns4="http://www.garmin.com/xmlschemas/ProfileExtension/v1">
<Activities>
<Activity Sport="Other">


And trailer.tcx

</Activity>
</Activities>
</TrainingCenterDatabase>