def get_status(self, pretty=False): """ Returns the status of the erg """ status = {} status['status'] = STATUS status = get_pretty(status, pretty) return status
def get_forceplot(self, pretty=False): """ Returns force plot data and stroke state """ forceplot = {} forceplot['forceplot'] = [1] * 32 forceplot['strokestate'] = 4 forceplot['status'] = STATUS forceplot = get_pretty(forceplot, pretty) return forceplot
def get_workout(self, pretty=False): """ Returns overall workout data """ workoutdata = {} workoutdata['userid'] = 0 workoutdata['type'] = 0 workoutdata['state'] = 1 workoutdata['inttype'] = 1 workoutdata['intcount'] = 0 workoutdata['status'] = STATUS workoutdata = get_pretty(workoutdata, pretty) return workoutdata
def get_monitor(self, forceplot=False, pretty=False): """ Returns values from the monitor that relate to the current workout, optionally returns force plot data and stroke state. (* required) time: time in seconds distance: distance in meters spm: strokes per minute power: power in watts pace: seconds/500m calhr: calories burned per hour calories: calories burned heartrate: heartrate status if heartrate: forceplot: force plot data strokestate """ SPM = 30 POWER = 150 CAL_TO_TIME = 1 VEL = lambda x: 4 + np.sin(np.pi * x) + 0.5 * np.cos( np.pi * x / 480) + 0.5 * np.exp(-x / 120) - 5 * np.exp(-x / 4) VELOCITY = 5 DIST = lambda x: 40.3 + 4 * x - 60 * np.exp(-x / 120) + 20 * np.exp( -x / 4) + 80 * np.sin(np.pi * x / 480) - 0.3 * np.cos(np.pi * x) elapsed_time = round(time.time() - self._start_time, 2) monitor = {} monitor['time'] = round(elapsed_time, 2) monitor['distance'] = int(round(self._factor * DIST(elapsed_time))) monitor['spm'] = SPM #Rowing machine always returns power as Watts monitor['power'] = POWER if monitor['power']: monitor['pace'] = ((2.8 / POWER)**(1. / 3)) * 500 monitor['calhr'] = POWER * (4.0 * 0.8604) + 300. else: monitor['pace'], monitor['calhr'] = 0, 0 monitor['calories'] = round(CAL_TO_TIME * elapsed_time) monitor['heartrate'] = 100 if forceplot: monitor['forceplot'] = [1] * 32 monitor['strokestate'] = 4 # 1 or 5 monitor['status'] = STATUS monitor = get_pretty(monitor, pretty) return monitor
def get_erg(self, pretty=False): """ Returns all erg data that is not related to the workout """ ergdata = {} #Get data from csafe get version command ergdata['mfgid'] = 0 ergdata['cid'] = 0 ergdata['model'] = 0 ergdata['hwversion'] = 0 ergdata['swversion'] = 0 #Get data from csafe get serial command ergdata['serial'] = 0 #Get data from csafe get capabilities command ergdata['maxrx'] = 0 ergdata['maxtx'] = 0 ergdata['mininterframe'] = 0 ergdata['status'] = STATUS ergdata = get_pretty(ergdata, pretty) return ergdata