Skip to content

Commit c3ae823

Browse files
authored
Re-add gripper metrics to the list of metrics (#238)
1 parent ce1e1c6 commit c3ae823

File tree

2 files changed

+47
-36
lines changed

2 files changed

+47
-36
lines changed

lib/src/models/rover/metrics.dart

Lines changed: 46 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import "package:rover_dashboard/models.dart";
44

55
/// A data model that listens for updated data and provides [Metrics] to the UI.
66
class RoverMetrics extends Model {
7-
/// Data from the science subsystem.
8-
final science = ScienceMetrics();
7+
/// Data from the science subsystem.
8+
final science = ScienceMetrics();
99

1010
/// Data from the GPS.
1111
final position = PositionMetrics();
@@ -21,7 +21,7 @@ class RoverMetrics extends Model {
2121

2222
/// Vitals data from the rover.
2323
final vitals = VitalsMetrics();
24-
24+
2525
/// Subsystems status from the rover
2626
final subsystems = SubsystemsMetrics();
2727

@@ -34,11 +34,22 @@ class RoverMetrics extends Model {
3434
/// Data from the Base Station
3535
final baseStation = BaseStationMetrics();
3636

37-
/// A list of all the metrics to iterate over.
38-
///
39-
/// NOTE: Keep this as a getter, NOT a field. If this is made a field, then it won't update
40-
/// when new data is received. As a getter, every time it is called it will use new data.
41-
List<Metrics> get allMetrics => [vitals, position, drive, science, arm, subsystems, relays, vision, baseStation];
37+
/// A list of all the metrics to iterate over.
38+
///
39+
/// NOTE: Keep this as a getter, NOT a field. If this is made a field, then it won't update
40+
/// when new data is received. As a getter, every time it is called it will use new data.
41+
List<Metrics> get allMetrics => [
42+
vitals,
43+
position,
44+
drive,
45+
science,
46+
arm,
47+
gripper,
48+
subsystems,
49+
relays,
50+
vision,
51+
baseStation,
52+
];
4253

4354
/// Whether the given command is supported by the rover.
4455
bool isSupportedVersion(Message command) {
@@ -56,33 +67,33 @@ class RoverMetrics extends Model {
5667
BaseStationCommand().messageName: baseStation,
5768
};
5869

59-
@override
60-
Future<void> init() async {
61-
models.messages.stream.onMessage(
62-
name: DriveData().messageName,
63-
constructor: DriveData.fromBuffer,
64-
callback: drive.update,
65-
);
66-
models.messages.stream.onMessage(
67-
name: ScienceData().messageName,
68-
constructor: ScienceData.fromBuffer,
69-
callback: science.update,
70-
);
70+
@override
71+
Future<void> init() async {
72+
models.messages.stream.onMessage(
73+
name: DriveData().messageName,
74+
constructor: DriveData.fromBuffer,
75+
callback: drive.update,
76+
);
7177
models.messages.stream.onMessage(
72-
name: RoverPosition().messageName,
73-
constructor: RoverPosition.fromBuffer,
74-
callback: position.update,
75-
);
76-
models.messages.stream.onMessage(
77-
name: ArmData().messageName,
78-
constructor: ArmData.fromBuffer,
79-
callback: arm.update,
80-
);
81-
models.messages.stream.onMessage(
82-
name: GripperData().messageName,
83-
constructor: GripperData.fromBuffer,
84-
callback: gripper.update,
85-
);
78+
name: ScienceData().messageName,
79+
constructor: ScienceData.fromBuffer,
80+
callback: science.update,
81+
);
82+
models.messages.stream.onMessage(
83+
name: RoverPosition().messageName,
84+
constructor: RoverPosition.fromBuffer,
85+
callback: position.update,
86+
);
87+
models.messages.stream.onMessage(
88+
name: ArmData().messageName,
89+
constructor: ArmData.fromBuffer,
90+
callback: arm.update,
91+
);
92+
models.messages.stream.onMessage(
93+
name: GripperData().messageName,
94+
constructor: GripperData.fromBuffer,
95+
callback: gripper.update,
96+
);
8697
models.messages.stream.onMessage(
8798
name: RelaysData().messageName,
8899
constructor: RelaysData.fromBuffer,
@@ -110,7 +121,7 @@ class RoverMetrics extends Model {
110121
);
111122
drive.addListener(vitals.notify);
112123
// versionTimer = Timer.periodic(versionInterval, _sendVersions);
113-
}
124+
}
114125

115126
// /// A timer to broadcast the supported Protobuf version every [versionInterval] seconds.
116127
// Timer? versionTimer;

lib/src/pages/arm.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ class ArmPage extends ReactiveWidget<ArmModel> {
239239
const Text("Laser Light"),
240240
const SizedBox(width: 5),
241241
Switch(
242-
activeColor: Colors.red,
242+
activeThumbColor: Colors.red,
243243
value: model.desiredLaserState,
244244
onChanged: (value) => model.setLaser(laser: value),
245245
),

0 commit comments

Comments
 (0)