2018-05-11 12:38:23 -07:00
|
|
|
/*----------------------------------------------------------------------------*/
|
2020-06-27 22:11:24 -07:00
|
|
|
/* Copyright (c) 2018-2020 FIRST. All Rights Reserved. */
|
2018-05-11 12:38:23 -07:00
|
|
|
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
|
|
|
|
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
|
|
|
|
/* the project. */
|
|
|
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
|
|
#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 AnalogGyro;
|
|
|
|
|
|
2018-05-11 12:38:23 -07:00
|
|
|
namespace sim {
|
2020-07-04 10:10:43 -07:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Class to control a simulated analog gyro.
|
|
|
|
|
*/
|
2018-05-11 12:38:23 -07:00
|
|
|
class AnalogGyroSim {
|
|
|
|
|
public:
|
2020-07-04 10:10:43 -07:00
|
|
|
/**
|
|
|
|
|
* Constructs from an AnalogGyro object.
|
|
|
|
|
*
|
|
|
|
|
* @param gyro AnalogGyro to simulate
|
|
|
|
|
*/
|
2020-07-15 23:48:09 -07:00
|
|
|
explicit AnalogGyroSim(const AnalogGyro& gyro);
|
2020-07-04 10:10:43 -07:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Constructs from an analog input channel number.
|
|
|
|
|
*
|
|
|
|
|
* @param channel Channel number
|
|
|
|
|
*/
|
2020-07-15 23:48:09 -07:00
|
|
|
explicit AnalogGyroSim(int channel);
|
2018-05-11 12:38:23 -07:00
|
|
|
|
|
|
|
|
std::unique_ptr<CallbackStore> RegisterAngleCallback(NotifyCallback callback,
|
2020-07-15 23:48:09 -07:00
|
|
|
bool initialNotify);
|
2018-08-16 01:17:59 -04:00
|
|
|
|
2020-07-15 23:48:09 -07:00
|
|
|
double GetAngle() const;
|
2018-08-16 01:17:59 -04:00
|
|
|
|
2020-07-15 23:48:09 -07:00
|
|
|
void SetAngle(double angle);
|
2018-05-11 12:38:23 -07:00
|
|
|
|
|
|
|
|
std::unique_ptr<CallbackStore> RegisterRateCallback(NotifyCallback callback,
|
2020-07-15 23:48:09 -07:00
|
|
|
bool initialNotify);
|
2018-08-16 01:17:59 -04:00
|
|
|
|
2020-07-15 23:48:09 -07:00
|
|
|
double GetRate() const;
|
2018-08-16 01:17:59 -04:00
|
|
|
|
2020-07-15 23:48:09 -07:00
|
|
|
void SetRate(double rate);
|
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);
|
|
|
|
|
|
|
|
|
|
void ResetData();
|
2018-05-11 12:38:23 -07:00
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
int m_index;
|
|
|
|
|
};
|
|
|
|
|
} // namespace sim
|
|
|
|
|
} // namespace frc
|