laymanshex-files/Sports/Concept2/PM5/pm5conv.bash

70 lines
1.4 KiB
Bash
Raw Normal View History

2020-04-28 22:44:24 +02:00
#!/bin/bash
cmd="laymanshex"
2020-04-28 22:44:24 +02:00
accTable="LogDataAccessTbl.bin"
storage="LogDataStorage.bin"
2020-04-30 16:30:26 +02:00
# uses evil eval
2020-04-30 16:07:19 +02:00
function printNonEmpty {
varname='$'"$1"
eval "val=$varname"
if [ "$val" != "" ]; then
echo "$1=$val"
fi
}
2020-04-30 16:07:19 +02:00
function printSplit {
outputSplit="$($cmd -nopadding -fvar=offset=$1,splitNo=$2 $storage-Workout$3.layhex $storage 2> /dev/null)"
status=$?
if [ $status -eq 0 ]; then
2020-04-30 16:30:26 +02:00
eval "$outputSplit"
2020-04-30 16:07:19 +02:00
echo
echo "Split $(($2+1))"
echo "----------"
printNonEmpty "SplitDuration"
printNonEmpty "SplitDistance"
printNonEmpty "SplitHeartRate"
printNonEmpty "SplitSPM"
fi
}
function printWorkout {
echo "Workout $1"
echo "============="
outputHeader="$($cmd -nopadding -fvar=offset=$2,splitNo=0 $storage-Workout$3.layhex $storage 2> /dev/null)"
status=$?
if [ $status -eq 0 ]; then
2020-04-30 16:30:26 +02:00
eval "$outputHeader"
printNonEmpty "TotalDuration"
printNonEmpty "TotalDistance"
printNonEmpty "SplitSize"
printNonEmpty "SPM"
2020-04-30 16:07:19 +02:00
j=0
while [ "$j" -lt "$NoSplits" ]; do
printSplit $2 $j $3
j=$((j+1))
done
echo
2020-04-28 22:44:24 +02:00
fi
2020-04-30 16:07:19 +02:00
}
function printAll {
i=0
while : ; do
offset=$(($i))
output="$($cmd -nopadding -fvar=offset=$offset $accTable.layhex $accTable 2>/dev/null)"
status=$?
if [ $status -ne 0 ]; then
break
else
2020-04-30 16:30:26 +02:00
eval "$output"
2020-04-30 16:07:19 +02:00
printWorkout $Index $Offset $WorkoutType
fi
i=$((i+1))
done
}
printAll