Skip to content
This repository was archived by the owner on Sep 14, 2019. It is now read-only.

Commit 6d823a3

Browse files
caengineerscaengineers
authored andcommitted
added standard err message to smartdashboard fails
1 parent 73e6ebc commit 6d823a3

3 files changed

Lines changed: 26 additions & 14 deletions

File tree

Robot2018/src/org/usfirst/frc/team199/Robot2018/OI.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,14 @@ public class OI {
3535
private JoystickButton updatePIDConstantsButton;
3636
private JoystickButton updateEncoderDPPButton;
3737
public Joystick manipulator;
38-
38+
3939
public int getButton(String key, int def) {
4040
if (!SmartDashboard.containsKey("Button/" + key)) {
41-
SmartDashboard.putNumber("Button/" + key, def);
42-
}
41+
if (!SmartDashboard.putNumber("Button/" + key, def)) {
42+
System.err.println("SmartDashboard Key" + "Button/" + key + "already taken by a different type");
43+
return def;
44+
}
45+
}
4346
return (int) SmartDashboard.getNumber("Button/" + key, def);
4447
}
4548

Robot2018/src/org/usfirst/frc/team199/Robot2018/Robot.java

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -57,21 +57,27 @@ public class Robot extends TimedRobot {
5757

5858
public static double getConst(String key, double def) {
5959
if (!SmartDashboard.containsKey("Const/" + key)) {
60-
SmartDashboard.putNumber("Const/" + key, def);
60+
if (!SmartDashboard.putNumber("Const/" + key, def)) {
61+
System.err.println("SmartDashboard Key" + "Const/" + key + "already taken by a different type");
62+
return def;
63+
}
6164
}
6265
return SmartDashboard.getNumber("Const/" + key, def);
6366
}
6467

6568
public static boolean getBool(String key, boolean def) {
6669
if (!SmartDashboard.containsKey("Bool/" + key)) {
67-
SmartDashboard.putBoolean("Bool/" + key, def);
70+
if (!SmartDashboard.putBoolean("Bool/" + key, def)) {
71+
System.err.println("SmartDashboard Key" + "Bool/" + key + "already taken by a different type");
72+
return def;
73+
}
6874
}
6975
return SmartDashboard.getBoolean("Bool/" + key, def);
7076
}
7177

7278
/**
73-
* This function is run when the robot is first started up and should be
74-
* used for any initialization code.
79+
* This function is run when the robot is first started up and should be used
80+
* for any initialization code.
7581
*/
7682
@Override
7783
public void robotInit() {
@@ -110,9 +116,9 @@ public void robotInit() {
110116
}
111117

112118
/**
113-
* This function is called once each time the robot enters Disabled mode.
114-
* You can use it to reset any subsystem information you want to clear when
115-
* the robot is disabled.
119+
* This function is called once each time the robot enters Disabled mode. You
120+
* can use it to reset any subsystem information you want to clear when the
121+
* robot is disabled.
116122
*/
117123
@Override
118124
public void disabledInit() {
@@ -125,9 +131,9 @@ public void disabledPeriodic() {
125131
}
126132

127133
/**
128-
* This function is called once during the start of autonomous in order to
129-
* grab values from SmartDashboard and the FMS and call the Autonomous
130-
* command with those values.
134+
* This function is called once during the start of autonomous in order to grab
135+
* values from SmartDashboard and the FMS and call the Autonomous command with
136+
* those values.
131137
*/
132138
@Override
133139
public void autonomousInit() {

Robot2018/src/org/usfirst/frc/team199/Robot2018/RobotMap.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,10 @@ public RobotMap() {
173173
*/
174174
public int getPort(String key, int def) {
175175
if (!SmartDashboard.containsKey("Port/" + key)) {
176-
SmartDashboard.putNumber("Port/" + key, def);
176+
if (!SmartDashboard.putNumber("Port/" + key, def)) {
177+
System.err.println("SmartDashboard Key" + "Port/" + key + "already taken by a different type");
178+
return def;
179+
}
177180
}
178181
return (int) SmartDashboard.getNumber("Port/" + key, def);
179182
}

0 commit comments

Comments
 (0)