Ejemplo n.º 1
0
    def get_data(self):
        
        s = self.running_table.join(self.file_table).\
        select().where(self.file_table.c.file_hash==self._metadata.file_hash)

        cadence    = TimeSeriesData(name="cadence"   ,labels=[],data=[],unit='rpm')
        distance   = TimeSeriesData(name="distance"  ,labels=[],data=[],unit='m')
        heart_rate = TimeSeriesData(name="heart_rate",labels=[],data=[],unit="bpm")
        speed      = TimeSeriesData(name="speed"     ,labels=[],data=[],unit="m/s")
        
        rows = 0
        abs_len = 0
        last_ts = 0

        row = None
               
        for row in self._alchemy_logbook.execute(s):
            if row.cadence and row.distance and row.enhanced_speed and row.heart_rate:
                rows = rows + 1
                
                if last_ts == 0:
                    last_ts = row.timestamp

                ts =  ((row.timestamp-last_ts).seconds/60)

                
                cadence.data.append(row.cadence)
                cadence.labels.append(ts)
                
                distance.data.append(row.distance-abs_len)
                abs_len = row.distance
                distance.labels.append(ts)
                
                heart_rate.data.append(row.heart_rate)
                heart_rate.labels.append(ts)
                
                speed.data.append(row.enhanced_speed)
                speed.labels.append(ts)
            
        if row:
            self._data = [cadence,distance,heart_rate,speed]
    
            self._formdata = []
    
            self._formdata.append(TimeSeriesMetaData("Total Length",row.distance,"m"))
            self._formdata.append(TimeSeriesMetaData("Time per 100m","%.1f" %1,"s"))
            self._formdata.append(TimeSeriesMetaData("average speed","%.1f" %(1/1),"m/s"))
            self._formdata.append(TimeSeriesMetaData("Total calories",1,"kcal"))
            self._formdata.append(TimeSeriesMetaData("Event duration","%.1f" %(1),"min"))
Ejemplo n.º 2
0
    def get_data(self):

        s = self.swim_table.join(self.file_table).\
        select().where(self.file_table.c.file_hash==self._metadata.file_hash)

        strokes_data = TimeSeriesData(name="strokes",
                                      labels=[],
                                      data=[],
                                      unit=None)
        avg_strokes = TimeSeriesData(name="avg strokes",
                                     labels=[],
                                     data=[],
                                     unit="Strokes/lap")
        calories_data = TimeSeriesData(name="calories",
                                       labels=[],
                                       data=[],
                                       unit=None)
        speed_data = TimeSeriesData(name="speed",
                                    labels=[],
                                    data=[],
                                    unit="min/100m")

        rows = 0
        total_calories = 0
        event_duration = 0

        strokes_data.data.append(0)
        strokes_data.labels.append(0)

        avg_strokes.data.append(0)
        avg_strokes.labels.append(0)

        calories_data.data.append(0)
        calories_data.labels.append(0)

        speed_data.data.append(0)
        speed_data.labels.append(0)

        stro = 0

        row = None

        for row in self._alchemy_logbook.execute(s):
            if row.total_strokes and row.distance and row.total_calories and row.total_elapsed_time:
                rows = rows + 1
                strokes_data.data.append(row.total_strokes)
                strokes_data.labels.append(row.distance)

                stro = stro + row.total_strokes

                avg_strokes.data.append((stro / row.distance) * 50)
                avg_strokes.labels.append(row.distance)

                calories_data.data.append(row.total_calories)
                calories_data.labels.append(row.distance)

                speed_data.data.append(
                    ((row.total_elapsed_time / 50) * 100) / 60)  #FIXME
                speed_data.labels.append(row.distance)

                total_calories = total_calories + row.total_calories
                event_duration = event_duration + row.total_elapsed_time

        if row:
            lap_distance = int(row.distance / rows)
            total_length = row.distance
            total_time = row.start_time

            self._data = [strokes_data, calories_data, speed_data, avg_strokes]

            time_per_hundred = (100 / lap_distance) * (event_duration /
                                                       lap_distance)

            self._formdata = []

            self._formdata.append(
                TimeSeriesMetaData("Lap length", lap_distance, "m"))
            self._formdata.append(
                TimeSeriesMetaData("Total Length", total_length, "m"))
            self._formdata.append(
                TimeSeriesMetaData("Time per 100m", "%.1f" % time_per_hundred,
                                   "s"))
            self._formdata.append(
                TimeSeriesMetaData("average speed",
                                   "%.1f" % (total_length / event_duration),
                                   "m/s"))
            #            self._formdata.append(TimeSeriesMetaData("Total time",total_time,"s"))
            self._formdata.append(
                TimeSeriesMetaData("Total calories", total_calories, "kcal"))
            self._formdata.append(
                TimeSeriesMetaData("Event duration",
                                   "%.1f" % (event_duration / 60), "min"))
Ejemplo n.º 3
0
 def get_data(self,event):
     self._data = [TimeSeriesData(name="dummy" ,labels=[],data=[],unit=None)]
Ejemplo n.º 4
0
    def get_data(self, filehash):

        s = self.cycling_table.join(self.file_table).\
        select().where(self.file_table.c.file_hash==filehash)

        distance = TimeSeriesData(name="distance",
                                  labels=[],
                                  data=[],
                                  unit='m',
                                  xlabel="duration(min)")
        enhanced_altitude = TimeSeriesData(name="enhanced_altitude",
                                           labels=[],
                                           data=[],
                                           unit='m',
                                           xlabel="duration(min)")
        heart_rate = TimeSeriesData(name="heart_rate",
                                    labels=[],
                                    data=[],
                                    unit="bpm",
                                    xlabel="duration(min)")
        #        speed             = TimeSeriesData(name="speed"            ,labels=[],data=[],unit="m/s",xlabel="duration(min)")

        rows = 0
        abs_len = 0
        last_ts = 0

        row = None

        for row in self._alchemy_logbook.execute(s):
            rows = rows + 1

            if last_ts == 0:
                last_ts = row.timestamp

            ts = ((row.timestamp - last_ts).seconds / 60)

            enhanced_altitude.data.append(row.enhanced_altitude)
            enhanced_altitude.labels.append(ts)

            distance.data.append(row.distance - abs_len)
            abs_len = row.distance
            distance.labels.append(ts)

            heart_rate.data.append(row.heart_rate)
            heart_rate.labels.append(ts)

        if row:
            data = [enhanced_altitude, distance, heart_rate]
            formdata = []

            formdata.append(
                TimeSeriesMetaData("Total Length", row.distance, "m"))
            formdata.append(
                TimeSeriesMetaData("Time per 100m", "%.1f" % 1, "s"))
            formdata.append(
                TimeSeriesMetaData("average speed", "%.1f" % (1 / 1), "m/s"))
            formdata.append(TimeSeriesMetaData("Total calories", 1, "kcal"))
            formdata.append(
                TimeSeriesMetaData("Event duration", "%.1f" % (1), "min"))

        return TimeSeries(data=data, metadata=formdata)