-
Notifications
You must be signed in to change notification settings - Fork 36
/
statshow.py
executable file
·45 lines (36 loc) · 1.67 KB
/
statshow.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import pyrow
import time
if __name__ == '__main__':
#Connecting to erg
ergs = list(pyrow.find())
if len(ergs) == 0:
exit("No ergs found.")
erg = pyrow.pyrow(ergs[0])
print "Connected to erg."
#Create a dictionary of the different status states
state = ['Error', 'Ready', 'Idle', 'Have ID', 'N/A', 'In Use',
'Pause', 'Finished', 'Manual', 'Offline']
stroke = ['Wait for min speed', 'Wait for acceleration', 'Drive', 'Dwelling', 'Recovery']
workout = ['Waiting begin', 'Workout row', 'Countdown pause', 'Interval rest',
'Work time inverval', 'Work distance interval', 'Rest end time', 'Rest end distance',
'Time end rest', 'Distance end rest', 'Workout end', 'Workout terminate',
'Workout logged', 'Workout rearm']
command = ['CSAFE_GETSTATUS_CMD', 'CSAFE_PM_GET_STROKESTATE', 'CSAFE_PM_GET_WORKOUTSTATE']
#prime status number
cstate = -1
cstroke = -1
cworkout = -1
erg.set_workout(distance=2000, split=100, pace=120)
#Inf loop
while 1:
results = erg.send(command)
if cstate != (results['CSAFE_GETSTATUS_CMD'][0] & 0xF):
cstate = results['CSAFE_GETSTATUS_CMD'][0] & 0xF
print "State " + str(cstate) + ": " + state[cstate]
if cstroke != results['CSAFE_PM_GET_STROKESTATE'][0]:
cstroke = results['CSAFE_PM_GET_STROKESTATE'][0]
print "Stroke " + str(cstroke) + ": " + stroke[cstroke]
if cworkout != results['CSAFE_PM_GET_WORKOUTSTATE'][0]:
cworkout = results['CSAFE_PM_GET_WORKOUTSTATE'][0]
print "Workout " + str(cworkout) + ": " + workout[cworkout]
time.sleep(1)