Private
Public Access
1
0

incomplete version of garmin training payload

This commit is contained in:
Sander Roosendaal
2021-03-01 21:31:25 +01:00
parent f2ec2585cc
commit f1379bfcf5
2 changed files with 172 additions and 1 deletions

View File

@@ -638,6 +638,56 @@ def step_to_time_dist(step,avgspeed = 3.7):
return seconds,distance
def get_step_type(step):
t = 'WorkoutStep'
if step['durationType'] in ['RepeatUntilStepsCmplt','RepeatUntilHrLessThan','RepeatUntilHrGreaterThan']:
t = 'WorkoutRepeatStep'
return t
def peel(l):
if len(l)==0:
return None,None
if len(l)==1:
return l[0],None
first = l[0]
rest = l[1:]
if first['type'] == 'Step':
return first, rest
# repeatstep
theID = -1
lijst = []
while theID != first['repeatID']:
f, rest = peel(rest)
lijst.append(f)
theID = f['stepID']
first['steps'] = list(reversed(lijst))
return first,rest
def ps_dict_order_dict(d):
steps = d['steps']
sdicts = []
for step in steps:
sstring, type, stepID, repeatID, repeatValue = step_to_string(step)
seconds, meters = step_to_time_dist(step)
sdict = {
'type':type,
'stepID': stepID,
'repeatID': repeatID,
'repeatValue': repeatValue,
'dict': step,
}
sdicts.append(sdict)
sdict2 = list(reversed(sdicts))
return sdict2
def ps_dict_order(d):
sdict = collections.OrderedDict({})
@@ -659,6 +709,22 @@ def ps_dict_order(d):
sdict2 = collections.OrderedDict(reversed(list(sdict.items())))
for step in steps:
sstring, type, stepID, repeatID, repeatValue = step_to_string(step)
seconds, meters = step_to_time_dist(step)
sdict[stepID] = {
'string':sstring,
'type':type,
'stepID': stepID,
'repeatID': repeatID,
'repeatValue': repeatValue,
'seconds': seconds,
'meters': meters,
}
sdict2 = collections.OrderedDict(reversed(list(sdict.items())))
sdict3 = []
hold = []
multiplier = []