Skip to content

Commit

Permalink
Call super.resetSubscription() method after changing topics
Browse files Browse the repository at this point in the history
  • Loading branch information
Gold872 committed Dec 3, 2023
1 parent 58b5518 commit 096ee73
Show file tree
Hide file tree
Showing 15 changed files with 30 additions and 28 deletions.
4 changes: 2 additions & 2 deletions lib/widgets/nt4_widgets/multi-topic/combo_box_chooser.dart
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,14 @@ class ComboBoxChooser extends StatelessWidget with NT4Widget {

@override
void resetSubscription() {
super.resetSubscription();

optionsTopicName = '$topic/options';
selectedTopicName = '$topic/selected';
activeTopicName = '$topic/active';
defaultTopicName = '$topic/default';

selectedTopic = null;

super.resetSubscription();
}

void publishSelectedValue(String? selected) {
Expand Down
4 changes: 2 additions & 2 deletions lib/widgets/nt4_widgets/multi-topic/command_scheduler.dart
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ class CommandSchedulerWidget extends StatelessWidget with NT4Widget {

@override
void resetSubscription() {
super.resetSubscription();

namesTopicName = '$topic/Names';
idsTopicName = '$topic/Ids';
cancelTopicName = '$topic/Cancel';

cancelTopic = null;

super.resetSubscription();
}

void cancelCommand(int id) {
Expand Down
4 changes: 2 additions & 2 deletions lib/widgets/nt4_widgets/multi-topic/command_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ class CommandWidget extends StatelessWidget with NT4Widget {

@override
void resetSubscription() {
super.resetSubscription();

runningTopicName = '$topic/running';
nameTopicName = '$topic/.name';

runningTopic = null;

super.resetSubscription();
}

@override
Expand Down
4 changes: 2 additions & 2 deletions lib/widgets/nt4_widgets/multi-topic/differential_drive.dart
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@ class DifferentialDrive extends StatelessWidget with NT4Widget {

@override
void resetSubscription() {
super.resetSubscription();

leftSpeedTopicName = '$topic/Left Motor Speed';
rightSpeedTopicName = '$topic/Right Motor Speed';

Expand All @@ -67,6 +65,8 @@ class DifferentialDrive extends StatelessWidget with NT4Widget {

rightSpeedPreviousValue = 0.0;
rightSpeedCurrentValue = 0.0;

super.resetSubscription();
}

@override
Expand Down
4 changes: 2 additions & 2 deletions lib/widgets/nt4_widgets/multi-topic/encoder_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ class EncoderWidget extends StatelessWidget with NT4Widget {

@override
void resetSubscription() {
super.resetSubscription();

distanceTopic = '$topic/Distance';
speedTopic = '$topic/Speed';

super.resetSubscription();
}

@override
Expand Down
4 changes: 2 additions & 2 deletions lib/widgets/nt4_widgets/multi-topic/field_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,10 @@ class FieldWidget extends StatelessWidget with NT4Widget {

@override
void resetSubscription() {
super.resetSubscription();

robotTopicName = '$topic/Robot';
otherObjectTopics.clear();

super.resetSubscription();
}

@override
Expand Down
4 changes: 2 additions & 2 deletions lib/widgets/nt4_widgets/multi-topic/fms_info.dart
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,15 @@ class FMSInfo extends StatelessWidget with NT4Widget {

@override
void resetSubscription() {
super.resetSubscription();

eventNameTopic = '$topic/EventName';
controlDataTopic = '$topic/FMSControlData';
allianceTopic = '$topic/IsRedAlliance';
matchNumberTopic = '$topic/MatchNumber';
matchTypeTopic = '$topic/MatchType';
replayNumberTopic = '$topic/ReplayNumber';
stationNumberTopic = '$topic/StationNumber';

super.resetSubscription();
}

String _getMatchTypeString(int matchType) {
Expand Down
4 changes: 2 additions & 2 deletions lib/widgets/nt4_widgets/multi-topic/network_alerts.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ class NetworkAlerts extends StatelessWidget with NT4Widget {

@override
void resetSubscription() {
super.resetSubscription();

errorsTopicName = '$topic/errors';
warningsTopicName = '$topic/warnings';
infosTopicName = '$topic/infos';

super.resetSubscription();
}

@override
Expand Down
4 changes: 2 additions & 2 deletions lib/widgets/nt4_widgets/multi-topic/pid_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,6 @@ class PIDControllerWidget extends StatelessWidget with NT4Widget {

@override
void resetSubscription() {
super.resetSubscription();

kpTopicName = '$topic/p';
kiTopicName = '$topic/i';
kdTopicName = '$topic/d';
Expand All @@ -77,6 +75,8 @@ class PIDControllerWidget extends StatelessWidget with NT4Widget {
kiTopic = null;
kdTopic = null;
setpointTopic = null;

super.resetSubscription();
}

@override
Expand Down
4 changes: 2 additions & 2 deletions lib/widgets/nt4_widgets/multi-topic/power_distribution.dart
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ class PowerDistribution extends StatelessWidget with NT4Widget {

@override
void resetSubscription() {
super.resetSubscription();

channelTopics.clear();

for (int channel = 0; channel <= numberOfChannels; channel++) {
Expand All @@ -56,6 +54,8 @@ class PowerDistribution extends StatelessWidget with NT4Widget {

voltageTopic = '$topic/Voltage';
currentTopic = '$topic/TotalCurrent';

super.resetSubscription();
}

Widget _getChannelsColumn(BuildContext context, int start, int end) {
Expand Down
4 changes: 2 additions & 2 deletions lib/widgets/nt4_widgets/multi-topic/split_button_chooser.dart
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,14 @@ class SplitButtonChooser extends StatelessWidget with NT4Widget {

@override
void resetSubscription() {
super.resetSubscription();

optionsTopicName = '$topic/options';
selectedTopicName = '$topic/selected';
activeTopicName = '$topic/active';
defaultTopicName = '$topic/default';

selectedTopic = null;

super.resetSubscription();
}

void publishSelectedValue(String? selected) {
Expand Down
4 changes: 2 additions & 2 deletions lib/widgets/nt4_widgets/multi-topic/subsystem_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ class SubsystemWidget extends StatelessWidget with NT4Widget {

@override
void resetSubscription() {
super.resetSubscription();

defaultCommandTopic = '$topic/.default';
currentCommandTopic = '$topic/.command';

super.resetSubscription();
}

@override
Expand Down
4 changes: 2 additions & 2 deletions lib/widgets/nt4_widgets/multi-topic/swerve_drive.dart
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,6 @@ class SwerveDriveWidget extends StatelessWidget with NT4Widget {

@override
void resetSubscription() {
super.resetSubscription();

frontLeftAngleTopic = '$topic/Front Left Angle';
frontLeftVelocityTopic = '$topic/Front Left Velocity';

Expand All @@ -86,6 +84,8 @@ class SwerveDriveWidget extends StatelessWidget with NT4Widget {
backRightVelocityTopic = '$topic/Back Right Velocity';

robotAngleTopic = '$topic/Robot Angle';

super.resetSubscription();
}

@override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ class ThreeAxisAccelerometer extends StatelessWidget with NT4Widget {

@override
void resetSubscription() {
super.resetSubscription();

xTopic = '$topic/X';
yTopic = '$topic/Y';
zTopic = '$topic/Z';

super.resetSubscription();
}

@override
Expand Down
2 changes: 2 additions & 0 deletions lib/widgets/nt4_widgets/nt4_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ mixin NT4Widget on StatelessWidget {
subscription = nt4Connection.subscribe(topic, period);

nt4Topic = null;

refresh();
return;
}

Expand Down

0 comments on commit 096ee73

Please sign in to comment.