Files
allwpilib/wpilibc/src/main/native/include/frc/simulation/AnalogTriggerSim.h
Peter Johnson 8f1f64ffb6 Remove year from file copyright message (NFC) (#2972)
Also update copyright to include "and other WPILib contributors" and clarify
license referral language to not be restricted to FIRST teams.
2020-12-26 14:12:05 -08:00

78 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 AnalogTrigger;
namespace sim {
/**
* Class to control a simulated analog trigger.
*/
class AnalogTriggerSim {
public:
/**
* Constructs from an AnalogTrigger object.
*
* @param analogTrigger AnalogTrigger to simulate
*/
explicit AnalogTriggerSim(const AnalogTrigger& analogTrigger);
/**
* Creates an AnalogTriggerSim for an analog input channel.
*
* @param channel analog input channel
* @return Simulated object
* @throws std::out_of_range if no AnalogTrigger is configured for that
* channel
*/
static AnalogTriggerSim CreateForChannel(int channel);
/**
* Creates an AnalogTriggerSim for a simulated index.
* The index is incremented for each simulated AnalogTrigger.
*
* @param index simulator index
* @return Simulated object
*/
static AnalogTriggerSim CreateForIndex(int index);
std::unique_ptr<CallbackStore> RegisterInitializedCallback(
NotifyCallback callback, bool initialNotify);
bool GetInitialized() const;
void SetInitialized(bool initialized);
std::unique_ptr<CallbackStore> RegisterTriggerLowerBoundCallback(
NotifyCallback callback, bool initialNotify);
double GetTriggerLowerBound() const;
void SetTriggerLowerBound(double triggerLowerBound);
std::unique_ptr<CallbackStore> RegisterTriggerUpperBoundCallback(
NotifyCallback callback, bool initialNotify);
double GetTriggerUpperBound() const;
void SetTriggerUpperBound(double triggerUpperBound);
void ResetData();
private:
explicit AnalogTriggerSim(int index) : m_index{index} {}
int m_index;
};
} // namespace sim
} // namespace frc