mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-24 01:31:46 +00:00
[sim] Add WPILib-class-taking constructors (#2538)
When not direct mapped, make index constructors private and add factory functions for channel and index. Co-authored-by: GabrielDeml <gabrielddeml@gmail.com>
This commit is contained in:
@@ -13,12 +13,37 @@
|
||||
#include <hal/simulation/DIOData.h>
|
||||
|
||||
#include "CallbackStore.h"
|
||||
#include "frc/DigitalInput.h"
|
||||
#include "frc/DigitalOutput.h"
|
||||
|
||||
namespace frc {
|
||||
namespace sim {
|
||||
|
||||
/**
|
||||
* Class to control a simulated digital input or output.
|
||||
*/
|
||||
class DIOSim {
|
||||
public:
|
||||
explicit DIOSim(int index) { m_index = index; }
|
||||
/**
|
||||
* Constructs from a DigitalInput object.
|
||||
*
|
||||
* @param input DigitalInput to simulate
|
||||
*/
|
||||
explicit DIOSim(const DigitalInput& input) : m_index{input.GetChannel()} {}
|
||||
|
||||
/**
|
||||
* Constructs from a DigitalOutput object.
|
||||
*
|
||||
* @param output DigitalOutput to simulate
|
||||
*/
|
||||
explicit DIOSim(const DigitalOutput& output) : m_index{output.GetChannel()} {}
|
||||
|
||||
/**
|
||||
* Constructs from an digital I/O channel number.
|
||||
*
|
||||
* @param channel Channel number
|
||||
*/
|
||||
explicit DIOSim(int channel) : m_index{channel} {}
|
||||
|
||||
std::unique_ptr<CallbackStore> RegisterInitializedCallback(
|
||||
NotifyCallback callback, bool initialNotify) {
|
||||
|
||||
Reference in New Issue
Block a user