Skip to content

Commit

Permalink
meta model changes
Browse files Browse the repository at this point in the history
  • Loading branch information
dudanov committed Oct 22, 2024
1 parent 3296838 commit ba6c3c7
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 56 deletions.
3 changes: 2 additions & 1 deletion pyftms/models/realtime_data/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import io
from typing import Any, cast, override

from ...client.properties import MachineFeatures
from ...serializer import BaseModel, get_serializer, model_meta


Expand Down Expand Up @@ -52,7 +53,7 @@ class RealtimeSpeedData(RealtimeData):
default=None,
metadata=model_meta(
format="u2.01",
features_bit=0,
feature=MachineFeatures.AVERAGE_SPEED,
),
)
"""Average Speed"""
Expand Down
27 changes: 14 additions & 13 deletions pyftms/models/realtime_data/cross_trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
BaseModel,
EnergyData,
InclinationData,
MachineFeatures,
RealtimeSpeedData,
model_meta,
)
Expand Down Expand Up @@ -55,15 +56,15 @@ class CrossTrainerData(RealtimeSpeedData):
default=None,
metadata=model_meta(
format="u3",
features_bit=2,
feature=MachineFeatures.DISTANCE,
),
)
"""Total Distance"""

step_rate: StepRateData | None = dc.field(
default=None,
metadata=model_meta(
features_bit=6,
feature=MachineFeatures.STEP_COUNT,
),
)
"""Step Rate Data"""
Expand All @@ -72,23 +73,23 @@ class CrossTrainerData(RealtimeSpeedData):
default=None,
metadata=model_meta(
format="u2",
features_bit=8,
feature=MachineFeatures.STRIDE_COUNT,
),
)
"""Stride Count"""

elevation_gain: ElevationGainData | None = dc.field(
default=None,
metadata=model_meta(
features_bit=4,
feature=MachineFeatures.ELEVATION_GAIN,
),
)
"""Elevation Gain Data"""

inclination: InclinationData | None = dc.field(
default=None,
metadata=model_meta(
features_bit=3,
feature=MachineFeatures.INCLINATION,
),
)
"""Inclination and Ramp Angle Data"""
Expand All @@ -97,7 +98,7 @@ class CrossTrainerData(RealtimeSpeedData):
default=None,
metadata=model_meta(
format="s2.1",
features_bit=7,
feature=MachineFeatures.RESISTANCE,
),
)
"""Resistance Level"""
Expand All @@ -106,7 +107,7 @@ class CrossTrainerData(RealtimeSpeedData):
default=None,
metadata=model_meta(
format="s2",
features_bit=14,
feature=MachineFeatures.POWER_MEASUREMENT,
),
)
"""Instantaneous Power"""
Expand All @@ -115,15 +116,15 @@ class CrossTrainerData(RealtimeSpeedData):
default=None,
metadata=model_meta(
format="s2",
features_bit=14,
feature=MachineFeatures.POWER_MEASUREMENT,
),
)
"""Average Power"""

energy: EnergyData | None = dc.field(
default=None,
metadata=model_meta(
features_bit=9,
feature=MachineFeatures.EXPENDED_ENERGY,
),
)
"""Energy Data"""
Expand All @@ -132,7 +133,7 @@ class CrossTrainerData(RealtimeSpeedData):
default=None,
metadata=model_meta(
format="u1",
features_bit=10,
feature=MachineFeatures.HEART_RATE,
),
)
"""Heart Rate"""
Expand All @@ -141,7 +142,7 @@ class CrossTrainerData(RealtimeSpeedData):
default=None,
metadata=model_meta(
format="u1.1",
features_bit=11,
feature=MachineFeatures.METABOLIC_EQUIVALENT,
),
)
"""Metabolic Equivalent"""
Expand All @@ -150,7 +151,7 @@ class CrossTrainerData(RealtimeSpeedData):
default=None,
metadata=model_meta(
format="u2",
features_bit=12,
feature=MachineFeatures.ELAPSED_TIME,
),
)
"""Elapsed Time"""
Expand All @@ -159,7 +160,7 @@ class CrossTrainerData(RealtimeSpeedData):
default=None,
metadata=model_meta(
format="u2",
features_bit=13,
feature=MachineFeatures.REMAINING_TIME,
),
)
"""Remaining Time"""
Expand Down
24 changes: 12 additions & 12 deletions pyftms/models/realtime_data/indoor_bike.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import dataclasses as dc

from .common import EnergyData, RealtimeSpeedData, model_meta
from .common import EnergyData, MachineFeatures, RealtimeSpeedData, model_meta


@dc.dataclass(frozen=True)
Expand All @@ -12,7 +12,7 @@ class IndoorBikeData(RealtimeSpeedData):
default=None,
metadata=model_meta(
format="u2.5",
features_bit=1,
feature=MachineFeatures.CADENCE,
),
)
"""Instantaneous Cadence"""
Expand All @@ -21,7 +21,7 @@ class IndoorBikeData(RealtimeSpeedData):
default=None,
metadata=model_meta(
format="u2.5",
features_bit=1,
feature=MachineFeatures.CADENCE,
),
)
"""Average Cadence"""
Expand All @@ -30,7 +30,7 @@ class IndoorBikeData(RealtimeSpeedData):
default=None,
metadata=model_meta(
format="u3",
features_bit=2,
feature=MachineFeatures.DISTANCE,
),
)
"""Total Distance"""
Expand All @@ -39,7 +39,7 @@ class IndoorBikeData(RealtimeSpeedData):
default=None,
metadata=model_meta(
format="s2",
features_bit=7,
feature=MachineFeatures.RESISTANCE,
),
)
"""Resistance Level"""
Expand All @@ -48,7 +48,7 @@ class IndoorBikeData(RealtimeSpeedData):
default=None,
metadata=model_meta(
format="s2",
features_bit=14,
feature=MachineFeatures.POWER_MEASUREMENT,
),
)
"""Instantaneous Power"""
Expand All @@ -57,15 +57,15 @@ class IndoorBikeData(RealtimeSpeedData):
default=None,
metadata=model_meta(
format="s2",
features_bit=14,
feature=MachineFeatures.POWER_MEASUREMENT,
),
)
"""Average Power"""

energy: EnergyData | None = dc.field(
default=None,
metadata=model_meta(
features_bit=9,
feature=MachineFeatures.EXPENDED_ENERGY,
),
)
"""Energy Data"""
Expand All @@ -74,7 +74,7 @@ class IndoorBikeData(RealtimeSpeedData):
default=None,
metadata=model_meta(
format="u1",
features_bit=10,
feature=MachineFeatures.HEART_RATE,
),
)
"""Heart Rate"""
Expand All @@ -83,7 +83,7 @@ class IndoorBikeData(RealtimeSpeedData):
default=None,
metadata=model_meta(
format="u1.1",
features_bit=11,
feature=MachineFeatures.METABOLIC_EQUIVALENT,
),
)
"""Metabolic Equivalent"""
Expand All @@ -92,7 +92,7 @@ class IndoorBikeData(RealtimeSpeedData):
default=None,
metadata=model_meta(
format="u2",
features_bit=12,
feature=MachineFeatures.ELAPSED_TIME,
),
)
"""Elapsed Time"""
Expand All @@ -101,7 +101,7 @@ class IndoorBikeData(RealtimeSpeedData):
default=None,
metadata=model_meta(
format="u2",
features_bit=13,
feature=MachineFeatures.REMAINING_TIME,
),
)
"""Remaining Time"""
26 changes: 13 additions & 13 deletions pyftms/models/realtime_data/rower.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import dataclasses as dc

from .common import BaseModel, EnergyData, RealtimeData, model_meta
from .common import BaseModel, EnergyData, MachineFeatures, RealtimeData, model_meta


@dc.dataclass(frozen=True)
Expand Down Expand Up @@ -35,7 +35,7 @@ class RowerData(RealtimeData):
default=None,
metadata=model_meta(
format="u1.5",
features_bit=1,
feature=MachineFeatures.CADENCE,
),
)
"""Average Stroke Rate"""
Expand All @@ -44,7 +44,7 @@ class RowerData(RealtimeData):
default=None,
metadata=model_meta(
format="u3",
features_bit=2,
feature=MachineFeatures.DISTANCE,
),
)
"""Total Distance"""
Expand All @@ -53,7 +53,7 @@ class RowerData(RealtimeData):
default=None,
metadata=model_meta(
format="u2",
features_bit=5,
feature=MachineFeatures.PACE,
),
)
"""Instantaneous Split Time"""
Expand All @@ -62,7 +62,7 @@ class RowerData(RealtimeData):
default=None,
metadata=model_meta(
format="u2",
features_bit=5,
feature=MachineFeatures.PACE,
),
)
"""Average Split Time"""
Expand All @@ -71,7 +71,7 @@ class RowerData(RealtimeData):
default=None,
metadata=model_meta(
format="s2",
features_bit=14,
feature=MachineFeatures.POWER_MEASUREMENT,
),
)
"""Instantaneous Power"""
Expand All @@ -80,7 +80,7 @@ class RowerData(RealtimeData):
default=None,
metadata=model_meta(
format="s2",
features_bit=14,
feature=MachineFeatures.POWER_MEASUREMENT,
),
)
"""Average Power"""
Expand All @@ -89,15 +89,15 @@ class RowerData(RealtimeData):
default=None,
metadata=model_meta(
format="s2",
features_bit=7,
feature=MachineFeatures.RESISTANCE,
),
)
"""Resistance Level"""

energy: EnergyData | None = dc.field(
default=None,
metadata=model_meta(
features_bit=9,
feature=MachineFeatures.EXPENDED_ENERGY,
),
)
"""Energy Data"""
Expand All @@ -106,7 +106,7 @@ class RowerData(RealtimeData):
default=None,
metadata=model_meta(
format="u1",
features_bit=10,
feature=MachineFeatures.HEART_RATE,
),
)
"""Heart Rate"""
Expand All @@ -115,7 +115,7 @@ class RowerData(RealtimeData):
default=None,
metadata=model_meta(
format="u1.1",
features_bit=11,
feature=MachineFeatures.METABOLIC_EQUIVALENT,
),
)
"""Metabolic Equivalent"""
Expand All @@ -124,7 +124,7 @@ class RowerData(RealtimeData):
default=None,
metadata=model_meta(
format="u2",
features_bit=12,
feature=MachineFeatures.ELAPSED_TIME,
),
)
"""Elapsed Time"""
Expand All @@ -133,7 +133,7 @@ class RowerData(RealtimeData):
default=None,
metadata=model_meta(
format="u2",
features_bit=13,
feature=MachineFeatures.REMAINING_TIME,
),
)
"""Remaining Time"""
Loading

0 comments on commit ba6c3c7

Please sign in to comment.