// Copyright (c) FIRST and other WPILib contributors. // Open Source Software; you can modify and/or share it under the terms of // the WPILib BSD license file in the root directory of this project. #pragma once #include #include "frc/simulation/CallbackStore.h" namespace frc { class DigitalInput; class DigitalOutput; namespace sim { /** * Class to control a simulated digital input or output. */ class DIOSim { public: /** * Constructs from a DigitalInput object. * * @param input DigitalInput to simulate */ explicit DIOSim(const DigitalInput& input); /** * Constructs from a DigitalOutput object. * * @param output DigitalOutput to simulate */ explicit DIOSim(const DigitalOutput& output); /** * Constructs from an digital I/O channel number. * * @param channel Channel number */ explicit DIOSim(int channel); std::unique_ptr RegisterInitializedCallback( NotifyCallback callback, bool initialNotify); bool GetInitialized() const; void SetInitialized(bool initialized); std::unique_ptr RegisterValueCallback(NotifyCallback callback, bool initialNotify); bool GetValue() const; void SetValue(bool value); std::unique_ptr RegisterPulseLengthCallback( NotifyCallback callback, bool initialNotify); double GetPulseLength() const; void SetPulseLength(double pulseLength); std::unique_ptr RegisterIsInputCallback( NotifyCallback callback, bool initialNotify); bool GetIsInput() const; void SetIsInput(bool isInput); std::unique_ptr RegisterFilterIndexCallback( NotifyCallback callback, bool initialNotify); int GetFilterIndex() const; void SetFilterIndex(int filterIndex); void ResetData(); private: int m_index; }; } // namespace sim } // namespace frc