2020-12-26 14:12:05 -08:00
|
|
|
// 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.
|
2018-05-11 12:38:23 -07:00
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <memory>
|
|
|
|
|
|
2020-07-15 23:48:09 -07:00
|
|
|
#include "frc/simulation/CallbackStore.h"
|
2018-05-11 12:38:23 -07:00
|
|
|
|
|
|
|
|
namespace frc {
|
2020-07-15 23:48:09 -07:00
|
|
|
|
|
|
|
|
class AnalogTrigger;
|
|
|
|
|
|
2018-05-11 12:38:23 -07:00
|
|
|
namespace sim {
|
2020-07-04 10:10:43 -07:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Class to control a simulated analog trigger.
|
|
|
|
|
*/
|
2018-05-11 12:38:23 -07:00
|
|
|
class AnalogTriggerSim {
|
|
|
|
|
public:
|
2020-07-04 10:10:43 -07:00
|
|
|
/**
|
|
|
|
|
* Constructs from an AnalogTrigger object.
|
|
|
|
|
*
|
|
|
|
|
* @param analogTrigger AnalogTrigger to simulate
|
|
|
|
|
*/
|
2020-07-15 23:48:09 -07:00
|
|
|
explicit AnalogTriggerSim(const AnalogTrigger& analogTrigger);
|
2020-07-04 10:10:43 -07:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 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
|
|
|
|
|
*/
|
2020-07-15 23:48:09 -07:00
|
|
|
static AnalogTriggerSim CreateForChannel(int channel);
|
2020-07-04 10:10:43 -07:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Creates an AnalogTriggerSim for a simulated index.
|
|
|
|
|
* The index is incremented for each simulated AnalogTrigger.
|
|
|
|
|
*
|
|
|
|
|
* @param index simulator index
|
|
|
|
|
* @return Simulated object
|
|
|
|
|
*/
|
2020-07-15 23:48:09 -07:00
|
|
|
static AnalogTriggerSim CreateForIndex(int index);
|
2018-05-11 12:38:23 -07:00
|
|
|
|
|
|
|
|
std::unique_ptr<CallbackStore> RegisterInitializedCallback(
|
2020-07-15 23:48:09 -07:00
|
|
|
NotifyCallback callback, bool initialNotify);
|
|
|
|
|
|
|
|
|
|
bool GetInitialized() const;
|
|
|
|
|
|
|
|
|
|
void SetInitialized(bool initialized);
|
2018-05-11 12:38:23 -07:00
|
|
|
|
|
|
|
|
std::unique_ptr<CallbackStore> RegisterTriggerLowerBoundCallback(
|
2020-07-15 23:48:09 -07:00
|
|
|
NotifyCallback callback, bool initialNotify);
|
|
|
|
|
|
|
|
|
|
double GetTriggerLowerBound() const;
|
|
|
|
|
|
|
|
|
|
void SetTriggerLowerBound(double triggerLowerBound);
|
2018-05-11 12:38:23 -07:00
|
|
|
|
|
|
|
|
std::unique_ptr<CallbackStore> RegisterTriggerUpperBoundCallback(
|
2020-07-15 23:48:09 -07:00
|
|
|
NotifyCallback callback, bool initialNotify);
|
|
|
|
|
|
|
|
|
|
double GetTriggerUpperBound() const;
|
|
|
|
|
|
|
|
|
|
void SetTriggerUpperBound(double triggerUpperBound);
|
|
|
|
|
|
|
|
|
|
void ResetData();
|
2018-05-11 12:38:23 -07:00
|
|
|
|
|
|
|
|
private:
|
2020-07-04 10:10:43 -07:00
|
|
|
explicit AnalogTriggerSim(int index) : m_index{index} {}
|
|
|
|
|
|
2018-05-11 12:38:23 -07:00
|
|
|
int m_index;
|
|
|
|
|
};
|
|
|
|
|
} // namespace sim
|
|
|
|
|
} // namespace frc
|