mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-22 01:11:42 +00:00
Also update copyright to include "and other WPILib contributors" and clarify license referral language to not be restricted to FIRST teams.
86 lines
1.9 KiB
C++
86 lines
1.9 KiB
C++
// 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 <memory>
|
|
|
|
#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<CallbackStore> RegisterInitializedCallback(
|
|
NotifyCallback callback, bool initialNotify);
|
|
|
|
bool GetInitialized() const;
|
|
|
|
void SetInitialized(bool initialized);
|
|
|
|
std::unique_ptr<CallbackStore> RegisterValueCallback(NotifyCallback callback,
|
|
bool initialNotify);
|
|
|
|
bool GetValue() const;
|
|
|
|
void SetValue(bool value);
|
|
|
|
std::unique_ptr<CallbackStore> RegisterPulseLengthCallback(
|
|
NotifyCallback callback, bool initialNotify);
|
|
|
|
double GetPulseLength() const;
|
|
|
|
void SetPulseLength(double pulseLength);
|
|
|
|
std::unique_ptr<CallbackStore> RegisterIsInputCallback(
|
|
NotifyCallback callback, bool initialNotify);
|
|
|
|
bool GetIsInput() const;
|
|
|
|
void SetIsInput(bool isInput);
|
|
|
|
std::unique_ptr<CallbackStore> RegisterFilterIndexCallback(
|
|
NotifyCallback callback, bool initialNotify);
|
|
|
|
int GetFilterIndex() const;
|
|
|
|
void SetFilterIndex(int filterIndex);
|
|
|
|
void ResetData();
|
|
|
|
private:
|
|
int m_index;
|
|
};
|
|
} // namespace sim
|
|
} // namespace frc
|