From 212182d9913b76716a40ec56e2ce4c629eb8f2f2 Mon Sep 17 00:00:00 2001 From: Peter Johnson Date: Sun, 12 Apr 2020 10:37:27 -0700 Subject: [PATCH] [wpilibj] Remove getSimObject (#2479) This approach to getting the simulation object doesn't work in C++ and creates coupling that doesn't need to be present. --- .../src/main/java/edu/wpi/first/wpilibj/AnalogInput.java | 7 +------ .../src/main/java/edu/wpi/first/wpilibj/AnalogOutput.java | 7 +------ .../java/edu/wpi/first/wpilibj/BuiltInAccelerometer.java | 7 +------ .../java/edu/wpi/first/wpilibj/sim/AnalogInputSimTest.java | 4 ++-- .../edu/wpi/first/wpilibj/sim/AnalogOutputSimTest.java | 4 ++-- 5 files changed, 7 insertions(+), 22 deletions(-) diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/AnalogInput.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/AnalogInput.java index 308be6b1b1..32980583e7 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/AnalogInput.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/AnalogInput.java @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2008-2019 FIRST. All Rights Reserved. */ +/* Copyright (c) 2008-2020 FIRST. All Rights Reserved. */ /* Open Source Software - may be modified and shared by FRC teams. The code */ /* must be accompanied by the FIRST BSD license file in the root directory of */ /* the project. */ @@ -12,7 +12,6 @@ import edu.wpi.first.hal.AnalogJNI; import edu.wpi.first.hal.FRCNetComm.tResourceType; import edu.wpi.first.hal.HAL; import edu.wpi.first.hal.SimDevice; -import edu.wpi.first.hal.sim.AnalogInSim; import edu.wpi.first.hal.util.AllocationException; import edu.wpi.first.wpilibj.smartdashboard.SendableBuilder; import edu.wpi.first.wpilibj.smartdashboard.SendableRegistry; @@ -360,8 +359,4 @@ public class AnalogInput implements PIDSource, Sendable, AutoCloseable { builder.setSmartDashboardType("Analog Input"); builder.addDoubleProperty("Value", this::getAverageVoltage, null); } - - public AnalogInSim getSimObject() { - return new AnalogInSim(m_channel); - } } diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/AnalogOutput.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/AnalogOutput.java index ae03463bf8..feb6e1e1b4 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/AnalogOutput.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/AnalogOutput.java @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2014-2019 FIRST. All Rights Reserved. */ +/* Copyright (c) 2014-2020 FIRST. All Rights Reserved. */ /* Open Source Software - may be modified and shared by FRC teams. The code */ /* must be accompanied by the FIRST BSD license file in the root directory of */ /* the project. */ @@ -10,7 +10,6 @@ package edu.wpi.first.wpilibj; import edu.wpi.first.hal.AnalogJNI; import edu.wpi.first.hal.FRCNetComm.tResourceType; import edu.wpi.first.hal.HAL; -import edu.wpi.first.hal.sim.AnalogOutSim; import edu.wpi.first.wpilibj.smartdashboard.SendableBuilder; import edu.wpi.first.wpilibj.smartdashboard.SendableRegistry; @@ -65,8 +64,4 @@ public class AnalogOutput implements Sendable, AutoCloseable { builder.setSmartDashboardType("Analog Output"); builder.addDoubleProperty("Value", this::getVoltage, this::setVoltage); } - - public AnalogOutSim getSimObject() { - return new AnalogOutSim(m_channel); - } } diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/BuiltInAccelerometer.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/BuiltInAccelerometer.java index f6811c0aff..e367756de3 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/BuiltInAccelerometer.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/BuiltInAccelerometer.java @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2014-2019 FIRST. All Rights Reserved. */ +/* Copyright (c) 2014-2020 FIRST. All Rights Reserved. */ /* Open Source Software - may be modified and shared by FRC teams. The code */ /* must be accompanied by the FIRST BSD license file in the root directory of */ /* the project. */ @@ -10,7 +10,6 @@ package edu.wpi.first.wpilibj; import edu.wpi.first.hal.AccelerometerJNI; import edu.wpi.first.hal.FRCNetComm.tResourceType; import edu.wpi.first.hal.HAL; -import edu.wpi.first.hal.sim.AccelerometerSim; import edu.wpi.first.wpilibj.interfaces.Accelerometer; import edu.wpi.first.wpilibj.smartdashboard.SendableBuilder; import edu.wpi.first.wpilibj.smartdashboard.SendableRegistry; @@ -104,8 +103,4 @@ public class BuiltInAccelerometer implements Accelerometer, Sendable, AutoClosea builder.addDoubleProperty("Y", this::getY, null); builder.addDoubleProperty("Z", this::getZ, null); } - - public AccelerometerSim getSimObject() { - return new AccelerometerSim(); - } } diff --git a/wpilibj/src/test/java/edu/wpi/first/wpilibj/sim/AnalogInputSimTest.java b/wpilibj/src/test/java/edu/wpi/first/wpilibj/sim/AnalogInputSimTest.java index 91210bc708..a9d9cd974d 100644 --- a/wpilibj/src/test/java/edu/wpi/first/wpilibj/sim/AnalogInputSimTest.java +++ b/wpilibj/src/test/java/edu/wpi/first/wpilibj/sim/AnalogInputSimTest.java @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2018-2019 FIRST. All Rights Reserved. */ +/* Copyright (c) 2018-2020 FIRST. All Rights Reserved. */ /* Open Source Software - may be modified and shared by FRC teams. The code */ /* must be accompanied by the FIRST BSD license file in the root directory of */ /* the project. */ @@ -27,7 +27,7 @@ class AnalogInputSimTest { HAL.initialize(500, 0); AnalogInput input = new AnalogInput(5); - AnalogInSim inputSim = input.getSimObject(); + AnalogInSim inputSim = new AnalogInSim(5); for (double i = 0; i < 5.0; i += 0.1) { inputSim.setVoltage(0); diff --git a/wpilibj/src/test/java/edu/wpi/first/wpilibj/sim/AnalogOutputSimTest.java b/wpilibj/src/test/java/edu/wpi/first/wpilibj/sim/AnalogOutputSimTest.java index 7771425872..a9848752f6 100644 --- a/wpilibj/src/test/java/edu/wpi/first/wpilibj/sim/AnalogOutputSimTest.java +++ b/wpilibj/src/test/java/edu/wpi/first/wpilibj/sim/AnalogOutputSimTest.java @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2018-2019 FIRST. All Rights Reserved. */ +/* Copyright (c) 2018-2020 FIRST. All Rights Reserved. */ /* Open Source Software - may be modified and shared by FRC teams. The code */ /* must be accompanied by the FIRST BSD license file in the root directory of */ /* the project. */ @@ -39,7 +39,7 @@ class AnalogOutputSimTest { AnalogOutput output = new AnalogOutput(0); output.setVoltage(0.5); - AnalogOutSim outputSim = output.getSimObject(); + AnalogOutSim outputSim = new AnalogOutSim(0); DoubleStore store = new DoubleStore();