mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-30 02:31:44 +00:00
Add ability to associate other devices with a SimDevice
Implemented only for AnalogInput, DIO, and Encoder.
This commit is contained in:
@@ -224,6 +224,10 @@ double AnalogInput::PIDGet() {
|
||||
return GetAverageVoltage();
|
||||
}
|
||||
|
||||
void AnalogInput::SetSimDevice(HAL_SimDeviceHandle device) {
|
||||
HAL_SetAnalogInputSimDevice(m_port, device);
|
||||
}
|
||||
|
||||
void AnalogInput::InitSendable(SendableBuilder& builder) {
|
||||
builder.SetSmartDashboardType("Analog Input");
|
||||
builder.AddDoubleProperty("Value", [=]() { return GetAverageVoltage(); },
|
||||
|
||||
@@ -65,6 +65,10 @@ AnalogTriggerType DigitalInput::GetAnalogTriggerTypeForRouting() const {
|
||||
|
||||
bool DigitalInput::IsAnalogTrigger() const { return false; }
|
||||
|
||||
void DigitalInput::SetSimDevice(HAL_SimDeviceHandle device) {
|
||||
HAL_SetDIOSimDevice(m_handle, device);
|
||||
}
|
||||
|
||||
int DigitalInput::GetChannel() const { return m_channel; }
|
||||
|
||||
void DigitalInput::InitSendable(SendableBuilder& builder) {
|
||||
|
||||
@@ -140,6 +140,10 @@ void DigitalOutput::UpdateDutyCycle(double dutyCycle) {
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
|
||||
void DigitalOutput::SetSimDevice(HAL_SimDeviceHandle device) {
|
||||
HAL_SetDIOSimDevice(m_handle, device);
|
||||
}
|
||||
|
||||
void DigitalOutput::InitSendable(SendableBuilder& builder) {
|
||||
builder.SetSmartDashboardType("Digital Output");
|
||||
builder.AddBooleanProperty("Value", [=]() { return Get(); },
|
||||
|
||||
@@ -217,6 +217,10 @@ void Encoder::SetIndexSource(const DigitalSource& source,
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
|
||||
void Encoder::SetSimDevice(HAL_SimDeviceHandle device) {
|
||||
HAL_SetEncoderSimDevice(m_encoder, device);
|
||||
}
|
||||
|
||||
int Encoder::GetFPGAIndex() const {
|
||||
int32_t status = 0;
|
||||
int val = HAL_GetEncoderFPGAIndex(m_encoder, &status);
|
||||
|
||||
@@ -286,6 +286,13 @@ class AnalogInput : public ErrorBase,
|
||||
*/
|
||||
double PIDGet() override;
|
||||
|
||||
/**
|
||||
* Indicates this input is used by a simulated device.
|
||||
*
|
||||
* @param device simulated device handle
|
||||
*/
|
||||
void SetSimDevice(HAL_SimDeviceHandle device);
|
||||
|
||||
void InitSendable(SendableBuilder& builder) override;
|
||||
|
||||
private:
|
||||
|
||||
@@ -71,6 +71,13 @@ class DigitalInput : public DigitalSource,
|
||||
*/
|
||||
int GetChannel() const override;
|
||||
|
||||
/**
|
||||
* Indicates this input is used by a simulated device.
|
||||
*
|
||||
* @param device simulated device handle
|
||||
*/
|
||||
void SetSimDevice(HAL_SimDeviceHandle device);
|
||||
|
||||
void InitSendable(SendableBuilder& builder) override;
|
||||
|
||||
private:
|
||||
|
||||
@@ -125,6 +125,13 @@ class DigitalOutput : public ErrorBase,
|
||||
*/
|
||||
void UpdateDutyCycle(double dutyCycle);
|
||||
|
||||
/**
|
||||
* Indicates this output is used by a simulated device.
|
||||
*
|
||||
* @param device simulated device handle
|
||||
*/
|
||||
void SetSimDevice(HAL_SimDeviceHandle device);
|
||||
|
||||
void InitSendable(SendableBuilder& builder) override;
|
||||
|
||||
private:
|
||||
|
||||
@@ -332,6 +332,13 @@ class Encoder : public ErrorBase,
|
||||
void SetIndexSource(const DigitalSource& source,
|
||||
IndexingType type = kResetOnRisingEdge);
|
||||
|
||||
/**
|
||||
* Indicates this encoder is used by a simulated device.
|
||||
*
|
||||
* @param device simulated device handle
|
||||
*/
|
||||
void SetSimDevice(HAL_SimDeviceHandle device);
|
||||
|
||||
int GetFPGAIndex() const;
|
||||
|
||||
void InitSendable(SendableBuilder& builder) override;
|
||||
|
||||
Reference in New Issue
Block a user