mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-23 01:21:42 +00:00
Add ability to associate other devices with a SimDevice
Implemented only for AnalogInput, DIO, and Encoder.
This commit is contained in:
@@ -11,6 +11,7 @@ import edu.wpi.first.hal.AccumulatorResult;
|
||||
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;
|
||||
@@ -344,6 +345,15 @@ public class AnalogInput implements PIDSource, Sendable, AutoCloseable {
|
||||
return getAverageVoltage();
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates this input is used by a simulated device.
|
||||
*
|
||||
* @param device simulated device handle
|
||||
*/
|
||||
public void setSimDevice(SimDevice device) {
|
||||
AnalogJNI.setAnalogInputSimDevice(m_port, device.getNativeHandle());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initSendable(SendableBuilder builder) {
|
||||
builder.setSmartDashboardType("Analog Input");
|
||||
|
||||
@@ -10,6 +10,7 @@ package edu.wpi.first.wpilibj;
|
||||
import edu.wpi.first.hal.DIOJNI;
|
||||
import edu.wpi.first.hal.FRCNetComm.tResourceType;
|
||||
import edu.wpi.first.hal.HAL;
|
||||
import edu.wpi.first.hal.SimDevice;
|
||||
import edu.wpi.first.wpilibj.smartdashboard.SendableBuilder;
|
||||
import edu.wpi.first.wpilibj.smartdashboard.SendableRegistry;
|
||||
|
||||
@@ -98,6 +99,15 @@ public class DigitalInput extends DigitalSource implements Sendable, AutoCloseab
|
||||
return m_handle;
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates this input is used by a simulated device.
|
||||
*
|
||||
* @param device simulated device handle
|
||||
*/
|
||||
public void setSimDevice(SimDevice device) {
|
||||
DIOJNI.setDIOSimDevice(m_handle, device.getNativeHandle());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initSendable(SendableBuilder builder) {
|
||||
builder.setSmartDashboardType("Digital Input");
|
||||
|
||||
@@ -10,6 +10,7 @@ package edu.wpi.first.wpilibj;
|
||||
import edu.wpi.first.hal.DIOJNI;
|
||||
import edu.wpi.first.hal.FRCNetComm.tResourceType;
|
||||
import edu.wpi.first.hal.HAL;
|
||||
import edu.wpi.first.hal.SimDevice;
|
||||
import edu.wpi.first.wpilibj.smartdashboard.SendableBuilder;
|
||||
import edu.wpi.first.wpilibj.smartdashboard.SendableRegistry;
|
||||
|
||||
@@ -161,6 +162,15 @@ public class DigitalOutput implements Sendable, AutoCloseable {
|
||||
DIOJNI.setDigitalPWMDutyCycle(m_pwmGenerator, dutyCycle);
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates this input is used by a simulated device.
|
||||
*
|
||||
* @param device simulated device handle
|
||||
*/
|
||||
public void setSimDevice(SimDevice device) {
|
||||
DIOJNI.setDIOSimDevice(m_handle, device.getNativeHandle());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initSendable(SendableBuilder builder) {
|
||||
builder.setSmartDashboardType("Digital Output");
|
||||
|
||||
@@ -10,6 +10,7 @@ package edu.wpi.first.wpilibj;
|
||||
import edu.wpi.first.hal.EncoderJNI;
|
||||
import edu.wpi.first.hal.FRCNetComm.tResourceType;
|
||||
import edu.wpi.first.hal.HAL;
|
||||
import edu.wpi.first.hal.SimDevice;
|
||||
import edu.wpi.first.hal.util.AllocationException;
|
||||
import edu.wpi.first.wpilibj.smartdashboard.SendableBuilder;
|
||||
import edu.wpi.first.wpilibj.smartdashboard.SendableRegistry;
|
||||
@@ -560,6 +561,15 @@ public class Encoder implements CounterBase, PIDSource, Sendable, AutoCloseable
|
||||
source.getAnalogTriggerTypeForRouting(), type.value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates this input is used by a simulated device.
|
||||
*
|
||||
* @param device simulated device handle
|
||||
*/
|
||||
public void setSimDevice(SimDevice device) {
|
||||
EncoderJNI.setEncoderSimDevice(m_encoder, device.getNativeHandle());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initSendable(SendableBuilder builder) {
|
||||
if (EncoderJNI.getEncoderEncodingType(m_encoder) == EncodingType.k4X.value) {
|
||||
|
||||
Reference in New Issue
Block a user