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 Relay;
|
|
|
|
|
|
2018-05-11 12:38:23 -07:00
|
|
|
namespace sim {
|
2020-07-04 10:10:43 -07:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Class to control a simulated relay.
|
|
|
|
|
*/
|
2018-05-11 12:38:23 -07:00
|
|
|
class RelaySim {
|
|
|
|
|
public:
|
2020-07-04 10:10:43 -07:00
|
|
|
/**
|
|
|
|
|
* Constructs from a Relay object.
|
|
|
|
|
*
|
|
|
|
|
* @param relay Relay to simulate
|
|
|
|
|
*/
|
2020-07-15 23:48:09 -07:00
|
|
|
explicit RelaySim(const Relay& relay);
|
2020-07-04 10:10:43 -07:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Constructs from a relay channel number.
|
|
|
|
|
*
|
|
|
|
|
* @param channel Channel number
|
|
|
|
|
*/
|
2020-07-15 23:48:09 -07:00
|
|
|
explicit RelaySim(int channel);
|
2018-05-11 12:38:23 -07:00
|
|
|
|
|
|
|
|
std::unique_ptr<CallbackStore> RegisterInitializedForwardCallback(
|
2020-07-15 23:48:09 -07:00
|
|
|
NotifyCallback callback, bool initialNotify);
|
|
|
|
|
|
|
|
|
|
bool GetInitializedForward() const;
|
|
|
|
|
|
|
|
|
|
void SetInitializedForward(bool initializedForward);
|
2018-05-11 12:38:23 -07:00
|
|
|
|
|
|
|
|
std::unique_ptr<CallbackStore> RegisterInitializedReverseCallback(
|
2020-07-15 23:48:09 -07:00
|
|
|
NotifyCallback callback, bool initialNotify);
|
|
|
|
|
|
|
|
|
|
bool GetInitializedReverse() const;
|
|
|
|
|
|
|
|
|
|
void SetInitializedReverse(bool initializedReverse);
|
2018-05-11 12:38:23 -07:00
|
|
|
|
|
|
|
|
std::unique_ptr<CallbackStore> RegisterForwardCallback(
|
2020-07-15 23:48:09 -07:00
|
|
|
NotifyCallback callback, bool initialNotify);
|
2018-08-16 01:17:59 -04:00
|
|
|
|
2020-07-15 23:48:09 -07:00
|
|
|
bool GetForward() const;
|
2018-08-16 01:17:59 -04:00
|
|
|
|
2020-07-15 23:48:09 -07:00
|
|
|
void SetForward(bool forward);
|
2018-05-11 12:38:23 -07:00
|
|
|
|
|
|
|
|
std::unique_ptr<CallbackStore> RegisterReverseCallback(
|
2020-07-15 23:48:09 -07:00
|
|
|
NotifyCallback callback, bool initialNotify);
|
2018-08-16 01:17:59 -04:00
|
|
|
|
2020-07-15 23:48:09 -07:00
|
|
|
bool GetReverse() const;
|
2018-08-16 01:17:59 -04:00
|
|
|
|
2020-07-15 23:48:09 -07:00
|
|
|
void SetReverse(bool reverse);
|
2018-05-11 12:38:23 -07:00
|
|
|
|
2020-07-15 23:48:09 -07:00
|
|
|
void ResetData();
|
2018-05-11 12:38:23 -07:00
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
int m_index;
|
|
|
|
|
};
|
|
|
|
|
} // namespace sim
|
|
|
|
|
} // namespace frc
|