[sim] Move Sim classes from HAL to wpilibc/j (#2549)

Also move some things in HAL for consistency.

WAS:
C++:
- C APIs: #include "mockdata/AccelerometerData.h"
- User side class: #include "simulation/AccelerometerSim.h"
Java:
- JNI APIs: hal.sim.mockdata.AccelerometerData (and a few classes in hal.sim)
- User side classes: hal.sim.AccelerometerSim

IS:
C++:
- C APIs: #include "hal/simulation/AccelerometerData.h"
- C++ class: #include "frc/simulation/AccelerometerSim.h"
Java:
- JNI APIs: hal.simulation.AccelerometerData
- User side class: wpilibj.simulation.AccelerometerSim
This commit is contained in:
Peter Johnson
2020-06-27 22:11:24 -07:00
committed by GitHub
parent 22c0e2813a
commit ce3bc91946
207 changed files with 1420 additions and 1415 deletions

View File

@@ -0,0 +1,78 @@
/*----------------------------------------------------------------------------*/
/* 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. */
/*----------------------------------------------------------------------------*/
package edu.wpi.first.wpilibj.simulation;
import edu.wpi.first.hal.simulation.AccelerometerDataJNI;
import edu.wpi.first.hal.simulation.NotifyCallback;
public class AccelerometerSim {
private final int m_index;
public AccelerometerSim() {
m_index = 0;
}
public CallbackStore registerActiveCallback(NotifyCallback callback, boolean initialNotify) {
int uid = AccelerometerDataJNI.registerActiveCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, AccelerometerDataJNI::cancelActiveCallback);
}
public boolean getActive() {
return AccelerometerDataJNI.getActive(m_index);
}
public void setActive(boolean active) {
AccelerometerDataJNI.setActive(m_index, active);
}
public CallbackStore registerRangeCallback(NotifyCallback callback, boolean initialNotify) {
int uid = AccelerometerDataJNI.registerRangeCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, AccelerometerDataJNI::cancelRangeCallback);
}
public int getRange() {
return AccelerometerDataJNI.getRange(m_index);
}
public void setRange(int range) {
AccelerometerDataJNI.setRange(m_index, range);
}
public CallbackStore registerXCallback(NotifyCallback callback, boolean initialNotify) {
int uid = AccelerometerDataJNI.registerXCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, AccelerometerDataJNI::cancelXCallback);
}
public double getX() {
return AccelerometerDataJNI.getX(m_index);
}
public void setX(double x) {
AccelerometerDataJNI.setX(m_index, x);
}
public CallbackStore registerYCallback(NotifyCallback callback, boolean initialNotify) {
int uid = AccelerometerDataJNI.registerYCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, AccelerometerDataJNI::cancelYCallback);
}
public double getY() {
return AccelerometerDataJNI.getY(m_index);
}
public void setY(double y) {
AccelerometerDataJNI.setY(m_index, y);
}
public CallbackStore registerZCallback(NotifyCallback callback, boolean initialNotify) {
int uid = AccelerometerDataJNI.registerZCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, AccelerometerDataJNI::cancelZCallback);
}
public double getZ() {
return AccelerometerDataJNI.getZ(m_index);
}
public void setZ(double z) {
AccelerometerDataJNI.setZ(m_index, z);
}
public void resetData() {
AccelerometerDataJNI.resetData(m_index);
}
}

View File

@@ -0,0 +1,79 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2019-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. */
/*----------------------------------------------------------------------------*/
package edu.wpi.first.wpilibj.simulation;
import edu.wpi.first.hal.simulation.AddressableLEDDataJNI;
import edu.wpi.first.hal.simulation.ConstBufferCallback;
import edu.wpi.first.hal.simulation.NotifyCallback;
public class AddressableLEDSim {
private final int m_index;
public AddressableLEDSim(int index) {
m_index = index;
}
public CallbackStore registerInitializedCallback(NotifyCallback callback, boolean initialNotify) {
int uid = AddressableLEDDataJNI.registerInitializedCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, AddressableLEDDataJNI::cancelInitializedCallback);
}
public boolean getInitialized() {
return AddressableLEDDataJNI.getInitialized(m_index);
}
public void setInitialized(boolean initialized) {
AddressableLEDDataJNI.setInitialized(m_index, initialized);
}
public CallbackStore registerOutputPortCallback(NotifyCallback callback, boolean initialNotify) {
int uid = AddressableLEDDataJNI.registerOutputPortCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, AddressableLEDDataJNI::cancelOutputPortCallback);
}
public int getOutputPort() {
return AddressableLEDDataJNI.getOutputPort(m_index);
}
public void setOutputPort(int outputPort) {
AddressableLEDDataJNI.setOutputPort(m_index, outputPort);
}
public CallbackStore registerLengthCallback(NotifyCallback callback, boolean initialNotify) {
int uid = AddressableLEDDataJNI.registerLengthCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, AddressableLEDDataJNI::cancelLengthCallback);
}
public int getLength() {
return AddressableLEDDataJNI.getLength(m_index);
}
public void setLength(int length) {
AddressableLEDDataJNI.setLength(m_index, length);
}
public CallbackStore registerRunningCallback(NotifyCallback callback, boolean initialNotify) {
int uid = AddressableLEDDataJNI.registerRunningCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, AddressableLEDDataJNI::cancelRunningCallback);
}
public boolean getRunning() {
return AddressableLEDDataJNI.getRunning(m_index);
}
public void setRunning(boolean running) {
AddressableLEDDataJNI.setRunning(m_index, running);
}
public CallbackStore registerDataCallback(ConstBufferCallback callback) {
int uid = AddressableLEDDataJNI.registerDataCallback(m_index, callback);
return new CallbackStore(m_index, uid, AddressableLEDDataJNI::cancelDataCallback);
}
public byte[] getData() {
return AddressableLEDDataJNI.getData(m_index);
}
public void setData(byte[] data) {
AddressableLEDDataJNI.setData(m_index, data);
}
public void resetData() {
AddressableLEDDataJNI.resetData(m_index);
}
}

View File

@@ -0,0 +1,56 @@
/*----------------------------------------------------------------------------*/
/* 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. */
/*----------------------------------------------------------------------------*/
package edu.wpi.first.wpilibj.simulation;
import edu.wpi.first.hal.simulation.AnalogGyroDataJNI;
import edu.wpi.first.hal.simulation.NotifyCallback;
public class AnalogGyroSim {
private final int m_index;
public AnalogGyroSim(int index) {
m_index = index;
}
public CallbackStore registerAngleCallback(NotifyCallback callback, boolean initialNotify) {
int uid = AnalogGyroDataJNI.registerAngleCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, AnalogGyroDataJNI::cancelAngleCallback);
}
public double getAngle() {
return AnalogGyroDataJNI.getAngle(m_index);
}
public void setAngle(double angle) {
AnalogGyroDataJNI.setAngle(m_index, angle);
}
public CallbackStore registerRateCallback(NotifyCallback callback, boolean initialNotify) {
int uid = AnalogGyroDataJNI.registerRateCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, AnalogGyroDataJNI::cancelRateCallback);
}
public double getRate() {
return AnalogGyroDataJNI.getRate(m_index);
}
public void setRate(double rate) {
AnalogGyroDataJNI.setRate(m_index, rate);
}
public CallbackStore registerInitializedCallback(NotifyCallback callback, boolean initialNotify) {
int uid = AnalogGyroDataJNI.registerInitializedCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, AnalogGyroDataJNI::cancelInitializedCallback);
}
public boolean getInitialized() {
return AnalogGyroDataJNI.getInitialized(m_index);
}
public void setInitialized(boolean initialized) {
AnalogGyroDataJNI.setInitialized(m_index, initialized);
}
public void resetData() {
AnalogGyroDataJNI.resetData(m_index);
}
}

View File

@@ -0,0 +1,122 @@
/*----------------------------------------------------------------------------*/
/* 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. */
/*----------------------------------------------------------------------------*/
package edu.wpi.first.wpilibj.simulation;
import edu.wpi.first.hal.simulation.AnalogInDataJNI;
import edu.wpi.first.hal.simulation.NotifyCallback;
public class AnalogInSim {
private final int m_index;
public AnalogInSim(int index) {
m_index = index;
}
public CallbackStore registerInitializedCallback(NotifyCallback callback, boolean initialNotify) {
int uid = AnalogInDataJNI.registerInitializedCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, AnalogInDataJNI::cancelInitializedCallback);
}
public boolean getInitialized() {
return AnalogInDataJNI.getInitialized(m_index);
}
public void setInitialized(boolean initialized) {
AnalogInDataJNI.setInitialized(m_index, initialized);
}
public CallbackStore registerAverageBitsCallback(NotifyCallback callback, boolean initialNotify) {
int uid = AnalogInDataJNI.registerAverageBitsCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, AnalogInDataJNI::cancelAverageBitsCallback);
}
public int getAverageBits() {
return AnalogInDataJNI.getAverageBits(m_index);
}
public void setAverageBits(int averageBits) {
AnalogInDataJNI.setAverageBits(m_index, averageBits);
}
public CallbackStore registerOversampleBitsCallback(NotifyCallback callback, boolean initialNotify) {
int uid = AnalogInDataJNI.registerOversampleBitsCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, AnalogInDataJNI::cancelOversampleBitsCallback);
}
public int getOversampleBits() {
return AnalogInDataJNI.getOversampleBits(m_index);
}
public void setOversampleBits(int oversampleBits) {
AnalogInDataJNI.setOversampleBits(m_index, oversampleBits);
}
public CallbackStore registerVoltageCallback(NotifyCallback callback, boolean initialNotify) {
int uid = AnalogInDataJNI.registerVoltageCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, AnalogInDataJNI::cancelVoltageCallback);
}
public double getVoltage() {
return AnalogInDataJNI.getVoltage(m_index);
}
public void setVoltage(double voltage) {
AnalogInDataJNI.setVoltage(m_index, voltage);
}
public CallbackStore registerAccumulatorInitializedCallback(NotifyCallback callback, boolean initialNotify) {
int uid = AnalogInDataJNI.registerAccumulatorInitializedCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, AnalogInDataJNI::cancelAccumulatorInitializedCallback);
}
public boolean getAccumulatorInitialized() {
return AnalogInDataJNI.getAccumulatorInitialized(m_index);
}
public void setAccumulatorInitialized(boolean accumulatorInitialized) {
AnalogInDataJNI.setAccumulatorInitialized(m_index, accumulatorInitialized);
}
public CallbackStore registerAccumulatorValueCallback(NotifyCallback callback, boolean initialNotify) {
int uid = AnalogInDataJNI.registerAccumulatorValueCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, AnalogInDataJNI::cancelAccumulatorValueCallback);
}
public long getAccumulatorValue() {
return AnalogInDataJNI.getAccumulatorValue(m_index);
}
public void setAccumulatorValue(long accumulatorValue) {
AnalogInDataJNI.setAccumulatorValue(m_index, accumulatorValue);
}
public CallbackStore registerAccumulatorCountCallback(NotifyCallback callback, boolean initialNotify) {
int uid = AnalogInDataJNI.registerAccumulatorCountCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, AnalogInDataJNI::cancelAccumulatorCountCallback);
}
public long getAccumulatorCount() {
return AnalogInDataJNI.getAccumulatorCount(m_index);
}
public void setAccumulatorCount(long accumulatorCount) {
AnalogInDataJNI.setAccumulatorCount(m_index, accumulatorCount);
}
public CallbackStore registerAccumulatorCenterCallback(NotifyCallback callback, boolean initialNotify) {
int uid = AnalogInDataJNI.registerAccumulatorCenterCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, AnalogInDataJNI::cancelAccumulatorCenterCallback);
}
public int getAccumulatorCenter() {
return AnalogInDataJNI.getAccumulatorCenter(m_index);
}
public void setAccumulatorCenter(int accumulatorCenter) {
AnalogInDataJNI.setAccumulatorCenter(m_index, accumulatorCenter);
}
public CallbackStore registerAccumulatorDeadbandCallback(NotifyCallback callback, boolean initialNotify) {
int uid = AnalogInDataJNI.registerAccumulatorDeadbandCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, AnalogInDataJNI::cancelAccumulatorDeadbandCallback);
}
public int getAccumulatorDeadband() {
return AnalogInDataJNI.getAccumulatorDeadband(m_index);
}
public void setAccumulatorDeadband(int accumulatorDeadband) {
AnalogInDataJNI.setAccumulatorDeadband(m_index, accumulatorDeadband);
}
public void resetData() {
AnalogInDataJNI.resetData(m_index);
}
}

View File

@@ -0,0 +1,45 @@
/*----------------------------------------------------------------------------*/
/* 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. */
/*----------------------------------------------------------------------------*/
package edu.wpi.first.wpilibj.simulation;
import edu.wpi.first.hal.simulation.AnalogOutDataJNI;
import edu.wpi.first.hal.simulation.NotifyCallback;
public class AnalogOutSim {
private final int m_index;
public AnalogOutSim(int index) {
m_index = index;
}
public CallbackStore registerVoltageCallback(NotifyCallback callback, boolean initialNotify) {
int uid = AnalogOutDataJNI.registerVoltageCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, AnalogOutDataJNI::cancelVoltageCallback);
}
public double getVoltage() {
return AnalogOutDataJNI.getVoltage(m_index);
}
public void setVoltage(double voltage) {
AnalogOutDataJNI.setVoltage(m_index, voltage);
}
public CallbackStore registerInitializedCallback(NotifyCallback callback, boolean initialNotify) {
int uid = AnalogOutDataJNI.registerInitializedCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, AnalogOutDataJNI::cancelInitializedCallback);
}
public boolean getInitialized() {
return AnalogOutDataJNI.getInitialized(m_index);
}
public void setInitialized(boolean initialized) {
AnalogOutDataJNI.setInitialized(m_index, initialized);
}
public void resetData() {
AnalogOutDataJNI.resetData(m_index);
}
}

View File

@@ -0,0 +1,56 @@
/*----------------------------------------------------------------------------*/
/* 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. */
/*----------------------------------------------------------------------------*/
package edu.wpi.first.wpilibj.simulation;
import edu.wpi.first.hal.simulation.AnalogTriggerDataJNI;
import edu.wpi.first.hal.simulation.NotifyCallback;
public class AnalogTriggerSim {
private final int m_index;
public AnalogTriggerSim(int index) {
m_index = index;
}
public CallbackStore registerInitializedCallback(NotifyCallback callback, boolean initialNotify) {
int uid = AnalogTriggerDataJNI.registerInitializedCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, AnalogTriggerDataJNI::cancelInitializedCallback);
}
public boolean getInitialized() {
return AnalogTriggerDataJNI.getInitialized(m_index);
}
public void setInitialized(boolean initialized) {
AnalogTriggerDataJNI.setInitialized(m_index, initialized);
}
public CallbackStore registerTriggerLowerBoundCallback(NotifyCallback callback, boolean initialNotify) {
int uid = AnalogTriggerDataJNI.registerTriggerLowerBoundCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, AnalogTriggerDataJNI::cancelTriggerLowerBoundCallback);
}
public double getTriggerLowerBound() {
return AnalogTriggerDataJNI.getTriggerLowerBound(m_index);
}
public void setTriggerLowerBound(double triggerLowerBound) {
AnalogTriggerDataJNI.setTriggerLowerBound(m_index, triggerLowerBound);
}
public CallbackStore registerTriggerUpperBoundCallback(NotifyCallback callback, boolean initialNotify) {
int uid = AnalogTriggerDataJNI.registerTriggerUpperBoundCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, AnalogTriggerDataJNI::cancelTriggerUpperBoundCallback);
}
public double getTriggerUpperBound() {
return AnalogTriggerDataJNI.getTriggerUpperBound(m_index);
}
public void setTriggerUpperBound(double triggerUpperBound) {
AnalogTriggerDataJNI.setTriggerUpperBound(m_index, triggerUpperBound);
}
public void resetData() {
AnalogTriggerDataJNI.resetData(m_index);
}
}

View File

@@ -0,0 +1,84 @@
/*----------------------------------------------------------------------------*/
/* 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. */
/*----------------------------------------------------------------------------*/
package edu.wpi.first.wpilibj.simulation;
public class CallbackStore implements AutoCloseable {
interface CancelCallbackFunc {
void cancel(int index, int uid);
}
interface CancelCallbackChannelFunc {
void cancel(int index, int channel, int uid);
}
interface CancelCallbackNoIndexFunc {
void cancel(int uid);
}
public CallbackStore(int index, int uid, CancelCallbackFunc ccf) {
this.m_cancelType = kNormalCancel;
this.m_index = index;
this.m_uid = uid;
this.m_cancelCallback = ccf;
}
public CallbackStore(int index, int channel, int uid, CancelCallbackChannelFunc ccf) {
this.m_cancelType = kChannelCancel;
this.m_index = index;
this.m_uid = uid;
this.m_channel = channel;
this.m_cancelCallbackChannel = ccf;
}
public CallbackStore(int uid, CancelCallbackNoIndexFunc ccf) {
this.m_cancelType = kNoIndexCancel;
this.m_uid = uid;
this.m_cancelCallbackNoIndex = ccf;
}
private int m_index;
private int m_channel;
private final int m_uid;
private CancelCallbackFunc m_cancelCallback;
private CancelCallbackChannelFunc m_cancelCallbackChannel;
private CancelCallbackNoIndexFunc m_cancelCallbackNoIndex;
private static final int kNormalCancel = 0;
private static final int kChannelCancel = 1;
private static final int kNoIndexCancel = 2;
private int m_cancelType;
@Override
public void close() {
switch (m_cancelType) {
case kNormalCancel:
m_cancelCallback.cancel(m_index, m_uid);
break;
case kChannelCancel:
m_cancelCallbackChannel.cancel(m_index, m_channel, m_uid);
break;
case kNoIndexCancel:
m_cancelCallbackNoIndex.cancel(m_uid);
break;
default:
assert false;
break;
}
m_cancelType = -1;
}
@Override
protected void finalize() throws Throwable {
try {
if (m_cancelType >= 0) {
close(); // close open files
}
} finally {
super.finalize();
}
}
}

View File

@@ -0,0 +1,78 @@
/*----------------------------------------------------------------------------*/
/* 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. */
/*----------------------------------------------------------------------------*/
package edu.wpi.first.wpilibj.simulation;
import edu.wpi.first.hal.simulation.DIODataJNI;
import edu.wpi.first.hal.simulation.NotifyCallback;
public class DIOSim {
private final int m_index;
public DIOSim(int index) {
m_index = index;
}
public CallbackStore registerInitializedCallback(NotifyCallback callback, boolean initialNotify) {
int uid = DIODataJNI.registerInitializedCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, DIODataJNI::cancelInitializedCallback);
}
public boolean getInitialized() {
return DIODataJNI.getInitialized(m_index);
}
public void setInitialized(boolean initialized) {
DIODataJNI.setInitialized(m_index, initialized);
}
public CallbackStore registerValueCallback(NotifyCallback callback, boolean initialNotify) {
int uid = DIODataJNI.registerValueCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, DIODataJNI::cancelValueCallback);
}
public boolean getValue() {
return DIODataJNI.getValue(m_index);
}
public void setValue(boolean value) {
DIODataJNI.setValue(m_index, value);
}
public CallbackStore registerPulseLengthCallback(NotifyCallback callback, boolean initialNotify) {
int uid = DIODataJNI.registerPulseLengthCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, DIODataJNI::cancelPulseLengthCallback);
}
public double getPulseLength() {
return DIODataJNI.getPulseLength(m_index);
}
public void setPulseLength(double pulseLength) {
DIODataJNI.setPulseLength(m_index, pulseLength);
}
public CallbackStore registerIsInputCallback(NotifyCallback callback, boolean initialNotify) {
int uid = DIODataJNI.registerIsInputCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, DIODataJNI::cancelIsInputCallback);
}
public boolean getIsInput() {
return DIODataJNI.getIsInput(m_index);
}
public void setIsInput(boolean isInput) {
DIODataJNI.setIsInput(m_index, isInput);
}
public CallbackStore registerFilterIndexCallback(NotifyCallback callback, boolean initialNotify) {
int uid = DIODataJNI.registerFilterIndexCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, DIODataJNI::cancelFilterIndexCallback);
}
public int getFilterIndex() {
return DIODataJNI.getFilterIndex(m_index);
}
public void setFilterIndex(int filterIndex) {
DIODataJNI.setFilterIndex(m_index, filterIndex);
}
public void resetData() {
DIODataJNI.resetData(m_index);
}
}

View File

@@ -0,0 +1,56 @@
/*----------------------------------------------------------------------------*/
/* 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. */
/*----------------------------------------------------------------------------*/
package edu.wpi.first.wpilibj.simulation;
import edu.wpi.first.hal.simulation.DigitalPWMDataJNI;
import edu.wpi.first.hal.simulation.NotifyCallback;
public class DigitalPWMSim {
private final int m_index;
public DigitalPWMSim(int index) {
m_index = index;
}
public CallbackStore registerInitializedCallback(NotifyCallback callback, boolean initialNotify) {
int uid = DigitalPWMDataJNI.registerInitializedCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, DigitalPWMDataJNI::cancelInitializedCallback);
}
public boolean getInitialized() {
return DigitalPWMDataJNI.getInitialized(m_index);
}
public void setInitialized(boolean initialized) {
DigitalPWMDataJNI.setInitialized(m_index, initialized);
}
public CallbackStore registerDutyCycleCallback(NotifyCallback callback, boolean initialNotify) {
int uid = DigitalPWMDataJNI.registerDutyCycleCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, DigitalPWMDataJNI::cancelDutyCycleCallback);
}
public double getDutyCycle() {
return DigitalPWMDataJNI.getDutyCycle(m_index);
}
public void setDutyCycle(double dutyCycle) {
DigitalPWMDataJNI.setDutyCycle(m_index, dutyCycle);
}
public CallbackStore registerPinCallback(NotifyCallback callback, boolean initialNotify) {
int uid = DigitalPWMDataJNI.registerPinCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, DigitalPWMDataJNI::cancelPinCallback);
}
public int getPin() {
return DigitalPWMDataJNI.getPin(m_index);
}
public void setPin(int pin) {
DigitalPWMDataJNI.setPin(m_index, pin);
}
public void resetData() {
DigitalPWMDataJNI.resetData(m_index);
}
}

View File

@@ -0,0 +1,95 @@
/*----------------------------------------------------------------------------*/
/* 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. */
/*----------------------------------------------------------------------------*/
package edu.wpi.first.wpilibj.simulation;
import edu.wpi.first.hal.simulation.DriverStationDataJNI;
import edu.wpi.first.hal.simulation.NotifyCallback;
public class DriverStationSim {
public CallbackStore registerEnabledCallback(NotifyCallback callback, boolean initialNotify) {
int uid = DriverStationDataJNI.registerEnabledCallback(callback, initialNotify);
return new CallbackStore(uid, DriverStationDataJNI::cancelEnabledCallback);
}
public boolean getEnabled() {
return DriverStationDataJNI.getEnabled();
}
public void setEnabled(boolean enabled) {
DriverStationDataJNI.setEnabled(enabled);
}
public CallbackStore registerAutonomousCallback(NotifyCallback callback, boolean initialNotify) {
int uid = DriverStationDataJNI.registerAutonomousCallback(callback, initialNotify);
return new CallbackStore(uid, DriverStationDataJNI::cancelAutonomousCallback);
}
public boolean getAutonomous() {
return DriverStationDataJNI.getAutonomous();
}
public void setAutonomous(boolean autonomous) {
DriverStationDataJNI.setAutonomous(autonomous);
}
public CallbackStore registerTestCallback(NotifyCallback callback, boolean initialNotify) {
int uid = DriverStationDataJNI.registerTestCallback(callback, initialNotify);
return new CallbackStore(uid, DriverStationDataJNI::cancelTestCallback);
}
public boolean getTest() {
return DriverStationDataJNI.getTest();
}
public void setTest(boolean test) {
DriverStationDataJNI.setTest(test);
}
public CallbackStore registerEStopCallback(NotifyCallback callback, boolean initialNotify) {
int uid = DriverStationDataJNI.registerEStopCallback(callback, initialNotify);
return new CallbackStore(uid, DriverStationDataJNI::cancelEStopCallback);
}
public boolean getEStop() {
return DriverStationDataJNI.getEStop();
}
public void setEStop(boolean eStop) {
DriverStationDataJNI.setEStop(eStop);
}
public CallbackStore registerFmsAttachedCallback(NotifyCallback callback, boolean initialNotify) {
int uid = DriverStationDataJNI.registerFmsAttachedCallback(callback, initialNotify);
return new CallbackStore(uid, DriverStationDataJNI::cancelFmsAttachedCallback);
}
public boolean getFmsAttached() {
return DriverStationDataJNI.getFmsAttached();
}
public void setFmsAttached(boolean fmsAttached) {
DriverStationDataJNI.setFmsAttached(fmsAttached);
}
public CallbackStore registerDsAttachedCallback(NotifyCallback callback, boolean initialNotify) {
int uid = DriverStationDataJNI.registerDsAttachedCallback(callback, initialNotify);
return new CallbackStore(uid, DriverStationDataJNI::cancelDsAttachedCallback);
}
public boolean getDsAttached() {
return DriverStationDataJNI.getDsAttached();
}
public void setDsAttached(boolean dsAttached) {
DriverStationDataJNI.setDsAttached(dsAttached);
}
public void notifyNewData() {
DriverStationDataJNI.notifyNewData();
}
/**
* Toggles suppression of DriverStation.reportError and reportWarning messages.
*
* @param shouldSend If false then messages will will be suppressed.
*/
public void setSendError(boolean shouldSend) {
DriverStationDataJNI.setSendError(shouldSend);
}
public void resetData() {
DriverStationDataJNI.resetData();
}
}

View File

@@ -0,0 +1,52 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2019-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. */
/*----------------------------------------------------------------------------*/
package edu.wpi.first.wpilibj.simulation;
import edu.wpi.first.hal.simulation.DutyCycleDataJNI;
import edu.wpi.first.hal.simulation.NotifyCallback;
public class DutyCycleSim {
private final int m_index;
public DutyCycleSim(int index) {
m_index = index;
}
public CallbackStore registerInitializedCallback(NotifyCallback callback, boolean initialNotify) {
int uid = DutyCycleDataJNI.registerInitializedCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, DutyCycleDataJNI::cancelInitializedCallback);
}
public boolean getInitialized() {
return DutyCycleDataJNI.getInitialized(m_index);
}
public void setInitialized(boolean initialized) {
DutyCycleDataJNI.setInitialized(m_index, initialized);
}
public CallbackStore registerFrequencyCallback(NotifyCallback callback, boolean initialNotify) {
int uid = DutyCycleDataJNI.registerFrequencyCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, DutyCycleDataJNI::cancelFrequencyCallback);
}
public int getFrequency() {
return DutyCycleDataJNI.getFrequency(m_index);
}
public void setFrequency(int frequency) {
DutyCycleDataJNI.setFrequency(m_index, frequency);
}
public CallbackStore registerOutputCallback(NotifyCallback callback, boolean initialNotify) {
int uid = DutyCycleDataJNI.registerOutputCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, DutyCycleDataJNI::cancelOutputCallback);
}
public double getOutput() {
return DutyCycleDataJNI.getOutput(m_index);
}
public void setOutput(double output) {
DutyCycleDataJNI.setOutput(m_index, output);
}
}

View File

@@ -0,0 +1,127 @@
/*----------------------------------------------------------------------------*/
/* 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. */
/*----------------------------------------------------------------------------*/
package edu.wpi.first.wpilibj.simulation;
import edu.wpi.first.hal.simulation.EncoderDataJNI;
import edu.wpi.first.hal.simulation.NotifyCallback;
public class EncoderSim {
private final int m_index;
public EncoderSim(int index) {
m_index = index;
}
public CallbackStore registerInitializedCallback(NotifyCallback callback, boolean initialNotify) {
int uid = EncoderDataJNI.registerInitializedCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, EncoderDataJNI::cancelInitializedCallback);
}
public boolean getInitialized() {
return EncoderDataJNI.getInitialized(m_index);
}
public void setInitialized(boolean initialized) {
EncoderDataJNI.setInitialized(m_index, initialized);
}
public CallbackStore registerCountCallback(NotifyCallback callback, boolean initialNotify) {
int uid = EncoderDataJNI.registerCountCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, EncoderDataJNI::cancelCountCallback);
}
public int getCount() {
return EncoderDataJNI.getCount(m_index);
}
public void setCount(int count) {
EncoderDataJNI.setCount(m_index, count);
}
public CallbackStore registerPeriodCallback(NotifyCallback callback, boolean initialNotify) {
int uid = EncoderDataJNI.registerPeriodCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, EncoderDataJNI::cancelPeriodCallback);
}
public double getPeriod() {
return EncoderDataJNI.getPeriod(m_index);
}
public void setPeriod(double period) {
EncoderDataJNI.setPeriod(m_index, period);
}
public CallbackStore registerResetCallback(NotifyCallback callback, boolean initialNotify) {
int uid = EncoderDataJNI.registerResetCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, EncoderDataJNI::cancelResetCallback);
}
public boolean getReset() {
return EncoderDataJNI.getReset(m_index);
}
public void setReset(boolean reset) {
EncoderDataJNI.setReset(m_index, reset);
}
public CallbackStore registerMaxPeriodCallback(NotifyCallback callback, boolean initialNotify) {
int uid = EncoderDataJNI.registerMaxPeriodCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, EncoderDataJNI::cancelMaxPeriodCallback);
}
public double getMaxPeriod() {
return EncoderDataJNI.getMaxPeriod(m_index);
}
public void setMaxPeriod(double maxPeriod) {
EncoderDataJNI.setMaxPeriod(m_index, maxPeriod);
}
public CallbackStore registerDirectionCallback(NotifyCallback callback, boolean initialNotify) {
int uid = EncoderDataJNI.registerDirectionCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, EncoderDataJNI::cancelDirectionCallback);
}
public boolean getDirection() {
return EncoderDataJNI.getDirection(m_index);
}
public void setDirection(boolean direction) {
EncoderDataJNI.setDirection(m_index, direction);
}
public CallbackStore registerReverseDirectionCallback(NotifyCallback callback, boolean initialNotify) {
int uid = EncoderDataJNI.registerReverseDirectionCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, EncoderDataJNI::cancelReverseDirectionCallback);
}
public boolean getReverseDirection() {
return EncoderDataJNI.getReverseDirection(m_index);
}
public void setReverseDirection(boolean reverseDirection) {
EncoderDataJNI.setReverseDirection(m_index, reverseDirection);
}
public CallbackStore registerSamplesToAverageCallback(NotifyCallback callback, boolean initialNotify) {
int uid = EncoderDataJNI.registerSamplesToAverageCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, EncoderDataJNI::cancelSamplesToAverageCallback);
}
public int getSamplesToAverage() {
return EncoderDataJNI.getSamplesToAverage(m_index);
}
public void setSamplesToAverage(int samplesToAverage) {
EncoderDataJNI.setSamplesToAverage(m_index, samplesToAverage);
}
public void setDistance(double distance) {
EncoderDataJNI.setDistance(m_index, distance);
}
public double getDistance() {
return EncoderDataJNI.getDistance(m_index);
}
public void setRate(double rate) {
EncoderDataJNI.setRate(m_index, rate);
}
public double getRate() {
return EncoderDataJNI.getRate(m_index);
}
public void resetData() {
EncoderDataJNI.resetData(m_index);
}
}

View File

@@ -0,0 +1,46 @@
/*----------------------------------------------------------------------------*/
/* 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. */
/*----------------------------------------------------------------------------*/
package edu.wpi.first.wpilibj.simulation;
import edu.wpi.first.hal.simulation.BufferCallback;
import edu.wpi.first.hal.simulation.ConstBufferCallback;
import edu.wpi.first.hal.simulation.I2CDataJNI;
import edu.wpi.first.hal.simulation.NotifyCallback;
public class I2CSim {
private final int m_index;
public I2CSim(int index) {
m_index = index;
}
public CallbackStore registerInitializedCallback(NotifyCallback callback, boolean initialNotify) {
int uid = I2CDataJNI.registerInitializedCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, I2CDataJNI::cancelInitializedCallback);
}
public boolean getInitialized() {
return I2CDataJNI.getInitialized(m_index);
}
public void setInitialized(boolean initialized) {
I2CDataJNI.setInitialized(m_index, initialized);
}
public CallbackStore registerReadCallback(BufferCallback callback) {
int uid = I2CDataJNI.registerReadCallback(m_index, callback);
return new CallbackStore(m_index, uid, I2CDataJNI::cancelReadCallback);
}
public CallbackStore registerWriteCallback(ConstBufferCallback callback) {
int uid = I2CDataJNI.registerWriteCallback(m_index, callback);
return new CallbackStore(m_index, uid, I2CDataJNI::cancelWriteCallback);
}
public void resetData() {
I2CDataJNI.resetData(m_index);
}
}

View File

@@ -0,0 +1,23 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2019-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. */
/*----------------------------------------------------------------------------*/
package edu.wpi.first.wpilibj.simulation;
import edu.wpi.first.hal.simulation.NotifierDataJNI;
public final class NotifierSim {
private NotifierSim() {
}
public static long getNextTimeout() {
return NotifierDataJNI.getNextTimeout();
}
public static int getNumNotifiers() {
return NotifierDataJNI.getNumNotifiers();
}
}

View File

@@ -0,0 +1,100 @@
/*----------------------------------------------------------------------------*/
/* 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. */
/*----------------------------------------------------------------------------*/
package edu.wpi.first.wpilibj.simulation;
import edu.wpi.first.hal.simulation.NotifyCallback;
import edu.wpi.first.hal.simulation.PCMDataJNI;
public class PCMSim {
private final int m_index;
public PCMSim(int index) {
m_index = index;
}
public CallbackStore registerSolenoidInitializedCallback(int channel, NotifyCallback callback, boolean initialNotify) {
int uid = PCMDataJNI.registerSolenoidInitializedCallback(m_index, channel, callback, initialNotify);
return new CallbackStore(m_index, channel, uid, PCMDataJNI::cancelSolenoidInitializedCallback);
}
public boolean getSolenoidInitialized(int channel) {
return PCMDataJNI.getSolenoidInitialized(m_index, channel);
}
public void setSolenoidInitialized(int channel, boolean solenoidInitialized) {
PCMDataJNI.setSolenoidInitialized(m_index, channel, solenoidInitialized);
}
public CallbackStore registerSolenoidOutputCallback(int channel, NotifyCallback callback, boolean initialNotify) {
int uid = PCMDataJNI.registerSolenoidOutputCallback(m_index, channel, callback, initialNotify);
return new CallbackStore(m_index, channel, uid, PCMDataJNI::cancelSolenoidOutputCallback);
}
public boolean getSolenoidOutput(int channel) {
return PCMDataJNI.getSolenoidOutput(m_index, channel);
}
public void setSolenoidOutput(int channel, boolean solenoidOutput) {
PCMDataJNI.setSolenoidOutput(m_index, channel, solenoidOutput);
}
public CallbackStore registerCompressorInitializedCallback(NotifyCallback callback, boolean initialNotify) {
int uid = PCMDataJNI.registerCompressorInitializedCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, PCMDataJNI::cancelCompressorInitializedCallback);
}
public boolean getCompressorInitialized() {
return PCMDataJNI.getCompressorInitialized(m_index);
}
public void setCompressorInitialized(boolean compressorInitialized) {
PCMDataJNI.setCompressorInitialized(m_index, compressorInitialized);
}
public CallbackStore registerCompressorOnCallback(NotifyCallback callback, boolean initialNotify) {
int uid = PCMDataJNI.registerCompressorOnCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, PCMDataJNI::cancelCompressorOnCallback);
}
public boolean getCompressorOn() {
return PCMDataJNI.getCompressorOn(m_index);
}
public void setCompressorOn(boolean compressorOn) {
PCMDataJNI.setCompressorOn(m_index, compressorOn);
}
public CallbackStore registerClosedLoopEnabledCallback(NotifyCallback callback, boolean initialNotify) {
int uid = PCMDataJNI.registerClosedLoopEnabledCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, PCMDataJNI::cancelClosedLoopEnabledCallback);
}
public boolean getClosedLoopEnabled() {
return PCMDataJNI.getClosedLoopEnabled(m_index);
}
public void setClosedLoopEnabled(boolean closedLoopEnabled) {
PCMDataJNI.setClosedLoopEnabled(m_index, closedLoopEnabled);
}
public CallbackStore registerPressureSwitchCallback(NotifyCallback callback, boolean initialNotify) {
int uid = PCMDataJNI.registerPressureSwitchCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, PCMDataJNI::cancelPressureSwitchCallback);
}
public boolean getPressureSwitch() {
return PCMDataJNI.getPressureSwitch(m_index);
}
public void setPressureSwitch(boolean pressureSwitch) {
PCMDataJNI.setPressureSwitch(m_index, pressureSwitch);
}
public CallbackStore registerCompressorCurrentCallback(NotifyCallback callback, boolean initialNotify) {
int uid = PCMDataJNI.registerCompressorCurrentCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, PCMDataJNI::cancelCompressorCurrentCallback);
}
public double getCompressorCurrent() {
return PCMDataJNI.getCompressorCurrent(m_index);
}
public void setCompressorCurrent(double compressorCurrent) {
PCMDataJNI.setCompressorCurrent(m_index, compressorCurrent);
}
public void resetData() {
PCMDataJNI.resetData(m_index);
}
}

View File

@@ -0,0 +1,67 @@
/*----------------------------------------------------------------------------*/
/* 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. */
/*----------------------------------------------------------------------------*/
package edu.wpi.first.wpilibj.simulation;
import edu.wpi.first.hal.simulation.NotifyCallback;
import edu.wpi.first.hal.simulation.PDPDataJNI;
public class PDPSim {
private final int m_index;
public PDPSim(int index) {
m_index = index;
}
public CallbackStore registerInitializedCallback(NotifyCallback callback, boolean initialNotify) {
int uid = PDPDataJNI.registerInitializedCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, PDPDataJNI::cancelInitializedCallback);
}
public boolean getInitialized() {
return PDPDataJNI.getInitialized(m_index);
}
public void setInitialized(boolean initialized) {
PDPDataJNI.setInitialized(m_index, initialized);
}
public CallbackStore registerTemperatureCallback(NotifyCallback callback, boolean initialNotify) {
int uid = PDPDataJNI.registerTemperatureCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, PDPDataJNI::cancelTemperatureCallback);
}
public double getTemperature() {
return PDPDataJNI.getTemperature(m_index);
}
public void setTemperature(double temperature) {
PDPDataJNI.setTemperature(m_index, temperature);
}
public CallbackStore registerVoltageCallback(NotifyCallback callback, boolean initialNotify) {
int uid = PDPDataJNI.registerVoltageCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, PDPDataJNI::cancelVoltageCallback);
}
public double getVoltage() {
return PDPDataJNI.getVoltage(m_index);
}
public void setVoltage(double voltage) {
PDPDataJNI.setVoltage(m_index, voltage);
}
public CallbackStore registerCurrentCallback(int channel, NotifyCallback callback, boolean initialNotify) {
int uid = PDPDataJNI.registerCurrentCallback(m_index, channel, callback, initialNotify);
return new CallbackStore(m_index, channel, uid, PDPDataJNI::cancelCurrentCallback);
}
public double getCurrent(int channel) {
return PDPDataJNI.getCurrent(m_index, channel);
}
public void setCurrent(int channel, double current) {
PDPDataJNI.setCurrent(m_index, channel, current);
}
public void resetData() {
PDPDataJNI.resetData(m_index);
}
}

View File

@@ -0,0 +1,89 @@
/*----------------------------------------------------------------------------*/
/* 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. */
/*----------------------------------------------------------------------------*/
package edu.wpi.first.wpilibj.simulation;
import edu.wpi.first.hal.simulation.NotifyCallback;
import edu.wpi.first.hal.simulation.PWMDataJNI;
public class PWMSim {
private final int m_index;
public PWMSim(int index) {
m_index = index;
}
public CallbackStore registerInitializedCallback(NotifyCallback callback, boolean initialNotify) {
int uid = PWMDataJNI.registerInitializedCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, PWMDataJNI::cancelInitializedCallback);
}
public boolean getInitialized() {
return PWMDataJNI.getInitialized(m_index);
}
public void setInitialized(boolean initialized) {
PWMDataJNI.setInitialized(m_index, initialized);
}
public CallbackStore registerRawValueCallback(NotifyCallback callback, boolean initialNotify) {
int uid = PWMDataJNI.registerRawValueCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, PWMDataJNI::cancelRawValueCallback);
}
public int getRawValue() {
return PWMDataJNI.getRawValue(m_index);
}
public void setRawValue(int rawValue) {
PWMDataJNI.setRawValue(m_index, rawValue);
}
public CallbackStore registerSpeedCallback(NotifyCallback callback, boolean initialNotify) {
int uid = PWMDataJNI.registerSpeedCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, PWMDataJNI::cancelSpeedCallback);
}
public double getSpeed() {
return PWMDataJNI.getSpeed(m_index);
}
public void setSpeed(double speed) {
PWMDataJNI.setSpeed(m_index, speed);
}
public CallbackStore registerPositionCallback(NotifyCallback callback, boolean initialNotify) {
int uid = PWMDataJNI.registerPositionCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, PWMDataJNI::cancelPositionCallback);
}
public double getPosition() {
return PWMDataJNI.getPosition(m_index);
}
public void setPosition(double position) {
PWMDataJNI.setPosition(m_index, position);
}
public CallbackStore registerPeriodScaleCallback(NotifyCallback callback, boolean initialNotify) {
int uid = PWMDataJNI.registerPeriodScaleCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, PWMDataJNI::cancelPeriodScaleCallback);
}
public int getPeriodScale() {
return PWMDataJNI.getPeriodScale(m_index);
}
public void setPeriodScale(int periodScale) {
PWMDataJNI.setPeriodScale(m_index, periodScale);
}
public CallbackStore registerZeroLatchCallback(NotifyCallback callback, boolean initialNotify) {
int uid = PWMDataJNI.registerZeroLatchCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, PWMDataJNI::cancelZeroLatchCallback);
}
public boolean getZeroLatch() {
return PWMDataJNI.getZeroLatch(m_index);
}
public void setZeroLatch(boolean zeroLatch) {
PWMDataJNI.setZeroLatch(m_index, zeroLatch);
}
public void resetData() {
PWMDataJNI.resetData(m_index);
}
}

View File

@@ -0,0 +1,67 @@
/*----------------------------------------------------------------------------*/
/* 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. */
/*----------------------------------------------------------------------------*/
package edu.wpi.first.wpilibj.simulation;
import edu.wpi.first.hal.simulation.NotifyCallback;
import edu.wpi.first.hal.simulation.RelayDataJNI;
public class RelaySim {
private final int m_index;
public RelaySim(int index) {
m_index = index;
}
public CallbackStore registerInitializedForwardCallback(NotifyCallback callback, boolean initialNotify) {
int uid = RelayDataJNI.registerInitializedForwardCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, RelayDataJNI::cancelInitializedForwardCallback);
}
public boolean getInitializedForward() {
return RelayDataJNI.getInitializedForward(m_index);
}
public void setInitializedForward(boolean initializedForward) {
RelayDataJNI.setInitializedForward(m_index, initializedForward);
}
public CallbackStore registerInitializedReverseCallback(NotifyCallback callback, boolean initialNotify) {
int uid = RelayDataJNI.registerInitializedReverseCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, RelayDataJNI::cancelInitializedReverseCallback);
}
public boolean getInitializedReverse() {
return RelayDataJNI.getInitializedReverse(m_index);
}
public void setInitializedReverse(boolean initializedReverse) {
RelayDataJNI.setInitializedReverse(m_index, initializedReverse);
}
public CallbackStore registerForwardCallback(NotifyCallback callback, boolean initialNotify) {
int uid = RelayDataJNI.registerForwardCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, RelayDataJNI::cancelForwardCallback);
}
public boolean getForward() {
return RelayDataJNI.getForward(m_index);
}
public void setForward(boolean forward) {
RelayDataJNI.setForward(m_index, forward);
}
public CallbackStore registerReverseCallback(NotifyCallback callback, boolean initialNotify) {
int uid = RelayDataJNI.registerReverseCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, RelayDataJNI::cancelReverseCallback);
}
public boolean getReverse() {
return RelayDataJNI.getReverse(m_index);
}
public void setReverse(boolean reverse) {
RelayDataJNI.setReverse(m_index, reverse);
}
public void resetData() {
RelayDataJNI.resetData(m_index);
}
}

View File

@@ -0,0 +1,189 @@
/*----------------------------------------------------------------------------*/
/* 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. */
/*----------------------------------------------------------------------------*/
package edu.wpi.first.wpilibj.simulation;
import edu.wpi.first.hal.simulation.NotifyCallback;
import edu.wpi.first.hal.simulation.RoboRioDataJNI;
@SuppressWarnings({"PMD.ExcessivePublicCount", "PMD.TooManyMethods"})
public class RoboRioSim {
private final int m_index;
public RoboRioSim(int index) {
m_index = index;
}
public CallbackStore registerFPGAButtonCallback(NotifyCallback callback, boolean initialNotify) {
int uid = RoboRioDataJNI.registerFPGAButtonCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, RoboRioDataJNI::cancelFPGAButtonCallback);
}
public boolean getFPGAButton() {
return RoboRioDataJNI.getFPGAButton(m_index);
}
public void setFPGAButton(boolean fPGAButton) {
RoboRioDataJNI.setFPGAButton(m_index, fPGAButton);
}
public CallbackStore registerVInVoltageCallback(NotifyCallback callback, boolean initialNotify) {
int uid = RoboRioDataJNI.registerVInVoltageCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, RoboRioDataJNI::cancelVInVoltageCallback);
}
public double getVInVoltage() {
return RoboRioDataJNI.getVInVoltage(m_index);
}
public void setVInVoltage(double vInVoltage) {
RoboRioDataJNI.setVInVoltage(m_index, vInVoltage);
}
public CallbackStore registerVInCurrentCallback(NotifyCallback callback, boolean initialNotify) {
int uid = RoboRioDataJNI.registerVInCurrentCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, RoboRioDataJNI::cancelVInCurrentCallback);
}
public double getVInCurrent() {
return RoboRioDataJNI.getVInCurrent(m_index);
}
public void setVInCurrent(double vInCurrent) {
RoboRioDataJNI.setVInCurrent(m_index, vInCurrent);
}
public CallbackStore registerUserVoltage6VCallback(NotifyCallback callback, boolean initialNotify) {
int uid = RoboRioDataJNI.registerUserVoltage6VCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, RoboRioDataJNI::cancelUserVoltage6VCallback);
}
public double getUserVoltage6V() {
return RoboRioDataJNI.getUserVoltage6V(m_index);
}
public void setUserVoltage6V(double userVoltage6V) {
RoboRioDataJNI.setUserVoltage6V(m_index, userVoltage6V);
}
public CallbackStore registerUserCurrent6VCallback(NotifyCallback callback, boolean initialNotify) {
int uid = RoboRioDataJNI.registerUserCurrent6VCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, RoboRioDataJNI::cancelUserCurrent6VCallback);
}
public double getUserCurrent6V() {
return RoboRioDataJNI.getUserCurrent6V(m_index);
}
public void setUserCurrent6V(double userCurrent6V) {
RoboRioDataJNI.setUserCurrent6V(m_index, userCurrent6V);
}
public CallbackStore registerUserActive6VCallback(NotifyCallback callback, boolean initialNotify) {
int uid = RoboRioDataJNI.registerUserActive6VCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, RoboRioDataJNI::cancelUserActive6VCallback);
}
public boolean getUserActive6V() {
return RoboRioDataJNI.getUserActive6V(m_index);
}
public void setUserActive6V(boolean userActive6V) {
RoboRioDataJNI.setUserActive6V(m_index, userActive6V);
}
public CallbackStore registerUserVoltage5VCallback(NotifyCallback callback, boolean initialNotify) {
int uid = RoboRioDataJNI.registerUserVoltage5VCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, RoboRioDataJNI::cancelUserVoltage5VCallback);
}
public double getUserVoltage5V() {
return RoboRioDataJNI.getUserVoltage5V(m_index);
}
public void setUserVoltage5V(double userVoltage5V) {
RoboRioDataJNI.setUserVoltage5V(m_index, userVoltage5V);
}
public CallbackStore registerUserCurrent5VCallback(NotifyCallback callback, boolean initialNotify) {
int uid = RoboRioDataJNI.registerUserCurrent5VCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, RoboRioDataJNI::cancelUserCurrent5VCallback);
}
public double getUserCurrent5V() {
return RoboRioDataJNI.getUserCurrent5V(m_index);
}
public void setUserCurrent5V(double userCurrent5V) {
RoboRioDataJNI.setUserCurrent5V(m_index, userCurrent5V);
}
public CallbackStore registerUserActive5VCallback(NotifyCallback callback, boolean initialNotify) {
int uid = RoboRioDataJNI.registerUserActive5VCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, RoboRioDataJNI::cancelUserActive5VCallback);
}
public boolean getUserActive5V() {
return RoboRioDataJNI.getUserActive5V(m_index);
}
public void setUserActive5V(boolean userActive5V) {
RoboRioDataJNI.setUserActive5V(m_index, userActive5V);
}
public CallbackStore registerUserVoltage3V3Callback(NotifyCallback callback, boolean initialNotify) {
int uid = RoboRioDataJNI.registerUserVoltage3V3Callback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, RoboRioDataJNI::cancelUserVoltage3V3Callback);
}
public double getUserVoltage3V3() {
return RoboRioDataJNI.getUserVoltage3V3(m_index);
}
public void setUserVoltage3V3(double userVoltage3V3) {
RoboRioDataJNI.setUserVoltage3V3(m_index, userVoltage3V3);
}
public CallbackStore registerUserCurrent3V3Callback(NotifyCallback callback, boolean initialNotify) {
int uid = RoboRioDataJNI.registerUserCurrent3V3Callback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, RoboRioDataJNI::cancelUserCurrent3V3Callback);
}
public double getUserCurrent3V3() {
return RoboRioDataJNI.getUserCurrent3V3(m_index);
}
public void setUserCurrent3V3(double userCurrent3V3) {
RoboRioDataJNI.setUserCurrent3V3(m_index, userCurrent3V3);
}
public CallbackStore registerUserActive3V3Callback(NotifyCallback callback, boolean initialNotify) {
int uid = RoboRioDataJNI.registerUserActive3V3Callback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, RoboRioDataJNI::cancelUserActive3V3Callback);
}
public boolean getUserActive3V3() {
return RoboRioDataJNI.getUserActive3V3(m_index);
}
public void setUserActive3V3(boolean userActive3V3) {
RoboRioDataJNI.setUserActive3V3(m_index, userActive3V3);
}
public CallbackStore registerUserFaults6VCallback(NotifyCallback callback, boolean initialNotify) {
int uid = RoboRioDataJNI.registerUserFaults6VCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, RoboRioDataJNI::cancelUserFaults6VCallback);
}
public int getUserFaults6V() {
return RoboRioDataJNI.getUserFaults6V(m_index);
}
public void setUserFaults6V(int userFaults6V) {
RoboRioDataJNI.setUserFaults6V(m_index, userFaults6V);
}
public CallbackStore registerUserFaults5VCallback(NotifyCallback callback, boolean initialNotify) {
int uid = RoboRioDataJNI.registerUserFaults5VCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, RoboRioDataJNI::cancelUserFaults5VCallback);
}
public int getUserFaults5V() {
return RoboRioDataJNI.getUserFaults5V(m_index);
}
public void setUserFaults5V(int userFaults5V) {
RoboRioDataJNI.setUserFaults5V(m_index, userFaults5V);
}
public CallbackStore registerUserFaults3V3Callback(NotifyCallback callback, boolean initialNotify) {
int uid = RoboRioDataJNI.registerUserFaults3V3Callback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, RoboRioDataJNI::cancelUserFaults3V3Callback);
}
public int getUserFaults3V3() {
return RoboRioDataJNI.getUserFaults3V3(m_index);
}
public void setUserFaults3V3(int userFaults3V3) {
RoboRioDataJNI.setUserFaults3V3(m_index, userFaults3V3);
}
public void resetData() {
RoboRioDataJNI.resetData(m_index);
}
}

View File

@@ -0,0 +1,78 @@
/*----------------------------------------------------------------------------*/
/* 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. */
/*----------------------------------------------------------------------------*/
package edu.wpi.first.wpilibj.simulation;
import edu.wpi.first.hal.simulation.NotifyCallback;
import edu.wpi.first.hal.simulation.SPIAccelerometerDataJNI;
public class SPIAccelerometerSim {
private final int m_index;
public SPIAccelerometerSim(int index) {
m_index = index;
}
public CallbackStore registerActiveCallback(NotifyCallback callback, boolean initialNotify) {
int uid = SPIAccelerometerDataJNI.registerActiveCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, SPIAccelerometerDataJNI::cancelActiveCallback);
}
public boolean getActive() {
return SPIAccelerometerDataJNI.getActive(m_index);
}
public void setActive(boolean active) {
SPIAccelerometerDataJNI.setActive(m_index, active);
}
public CallbackStore registerRangeCallback(NotifyCallback callback, boolean initialNotify) {
int uid = SPIAccelerometerDataJNI.registerRangeCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, SPIAccelerometerDataJNI::cancelRangeCallback);
}
public int getRange() {
return SPIAccelerometerDataJNI.getRange(m_index);
}
public void setRange(int range) {
SPIAccelerometerDataJNI.setRange(m_index, range);
}
public CallbackStore registerXCallback(NotifyCallback callback, boolean initialNotify) {
int uid = SPIAccelerometerDataJNI.registerXCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, SPIAccelerometerDataJNI::cancelXCallback);
}
public double getX() {
return SPIAccelerometerDataJNI.getX(m_index);
}
public void setX(double x) {
SPIAccelerometerDataJNI.setX(m_index, x);
}
public CallbackStore registerYCallback(NotifyCallback callback, boolean initialNotify) {
int uid = SPIAccelerometerDataJNI.registerYCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, SPIAccelerometerDataJNI::cancelYCallback);
}
public double getY() {
return SPIAccelerometerDataJNI.getY(m_index);
}
public void setY(double y) {
SPIAccelerometerDataJNI.setY(m_index, y);
}
public CallbackStore registerZCallback(NotifyCallback callback, boolean initialNotify) {
int uid = SPIAccelerometerDataJNI.registerZCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, SPIAccelerometerDataJNI::cancelZCallback);
}
public double getZ() {
return SPIAccelerometerDataJNI.getZ(m_index);
}
public void setZ(double z) {
SPIAccelerometerDataJNI.setZ(m_index, z);
}
public void resetData() {
SPIAccelerometerDataJNI.resetData(m_index);
}
}

View File

@@ -0,0 +1,52 @@
/*----------------------------------------------------------------------------*/
/* 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. */
/*----------------------------------------------------------------------------*/
package edu.wpi.first.wpilibj.simulation;
import edu.wpi.first.hal.simulation.BufferCallback;
import edu.wpi.first.hal.simulation.ConstBufferCallback;
import edu.wpi.first.hal.simulation.NotifyCallback;
import edu.wpi.first.hal.simulation.SPIDataJNI;
import edu.wpi.first.hal.simulation.SpiReadAutoReceiveBufferCallback;
public class SPISim {
private final int m_index;
public SPISim(int index) {
m_index = index;
}
public CallbackStore registerInitializedCallback(NotifyCallback callback, boolean initialNotify) {
int uid = SPIDataJNI.registerInitializedCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, SPIDataJNI::cancelInitializedCallback);
}
public boolean getInitialized() {
return SPIDataJNI.getInitialized(m_index);
}
public void setInitialized(boolean initialized) {
SPIDataJNI.setInitialized(m_index, initialized);
}
public CallbackStore registerReadCallback(BufferCallback callback) {
int uid = SPIDataJNI.registerReadCallback(m_index, callback);
return new CallbackStore(m_index, uid, SPIDataJNI::cancelReadCallback);
}
public CallbackStore registerWriteCallback(ConstBufferCallback callback) {
int uid = SPIDataJNI.registerWriteCallback(m_index, callback);
return new CallbackStore(m_index, uid, SPIDataJNI::cancelWriteCallback);
}
public CallbackStore registerReadAutoReceiveBufferCallback(SpiReadAutoReceiveBufferCallback callback) {
int uid = SPIDataJNI.registerReadAutoReceiveBufferCallback(m_index, callback);
return new CallbackStore(m_index, uid, SPIDataJNI::cancelReadAutoReceiveBufferCallback);
}
public void resetData() {
SPIDataJNI.resetData(m_index);
}
}

View File

@@ -0,0 +1,96 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2019-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. */
/*----------------------------------------------------------------------------*/
package edu.wpi.first.wpilibj.simulation;
import edu.wpi.first.hal.SimBoolean;
import edu.wpi.first.hal.SimDouble;
import edu.wpi.first.hal.SimEnum;
import edu.wpi.first.hal.SimValue;
import edu.wpi.first.hal.simulation.SimDeviceCallback;
import edu.wpi.first.hal.simulation.SimDeviceDataJNI;
import edu.wpi.first.hal.simulation.SimValueCallback;
public class SimDeviceSim {
private final int m_handle;
public SimDeviceSim(String name) {
m_handle = SimDeviceDataJNI.getSimDeviceHandle(name);
}
public SimValue getValue(String name) {
int handle = SimDeviceDataJNI.getSimValueHandle(m_handle, name);
if (handle <= 0) {
return null;
}
return new SimValue(handle);
}
public SimDouble getDouble(String name) {
int handle = SimDeviceDataJNI.getSimValueHandle(m_handle, name);
if (handle <= 0) {
return null;
}
return new SimDouble(handle);
}
public SimEnum getEnum(String name) {
int handle = SimDeviceDataJNI.getSimValueHandle(m_handle, name);
if (handle <= 0) {
return null;
}
return new SimEnum(handle);
}
public SimBoolean getBoolean(String name) {
int handle = SimDeviceDataJNI.getSimValueHandle(m_handle, name);
if (handle <= 0) {
return null;
}
return new SimBoolean(handle);
}
public static String[] getEnumOptions(SimEnum val) {
return SimDeviceDataJNI.getSimValueEnumOptions(val.getNativeHandle());
}
public SimDeviceDataJNI.SimValueInfo[] enumerateValues() {
return SimDeviceDataJNI.enumerateSimValues(m_handle);
}
public int getNativeHandle() {
return m_handle;
}
public CallbackStore registerValueCreatedCallback(SimValueCallback callback, boolean initialNotify) {
int uid = SimDeviceDataJNI.registerSimValueCreatedCallback(m_handle, callback, initialNotify);
return new CallbackStore(uid, SimDeviceDataJNI::cancelSimValueCreatedCallback);
}
public CallbackStore registerValueChangedCallback(SimValueCallback callback, boolean initialNotify) {
int uid = SimDeviceDataJNI.registerSimValueChangedCallback(m_handle, callback, initialNotify);
return new CallbackStore(uid, SimDeviceDataJNI::cancelSimValueChangedCallback);
}
public static SimDeviceDataJNI.SimDeviceInfo[] enumerateDevices(String prefix) {
return SimDeviceDataJNI.enumerateSimDevices(prefix);
}
public CallbackStore registerDeviceCreatedCallback(String prefix, SimDeviceCallback callback, boolean initialNotify) {
int uid = SimDeviceDataJNI.registerSimDeviceCreatedCallback(prefix, callback, initialNotify);
return new CallbackStore(uid, SimDeviceDataJNI::cancelSimDeviceCreatedCallback);
}
public CallbackStore registerDeviceFreedCallback(String prefix, SimDeviceCallback callback) {
int uid = SimDeviceDataJNI.registerSimDeviceFreedCallback(prefix, callback);
return new CallbackStore(uid, SimDeviceDataJNI::cancelSimDeviceFreedCallback);
}
public static void resetData() {
SimDeviceDataJNI.resetSimDeviceData();
}
}