13 #include "HAL/Types.h"
14 #include "LiveWindow/LiveWindowSendable.h"
15 #include "MotorSafety.h"
16 #include "SensorBase.h"
17 #include "llvm/raw_ostream.h"
18 #include "tables/ITable.h"
19 #include "tables/ITableListener.h"
41 enum Value { kOff, kOn, kForward, kReverse };
42 enum Direction { kBothDirections, kForwardOnly, kReverseOnly };
44 explicit Relay(
int channel, Direction direction = kBothDirections);
47 void Set(Value value);
49 int GetChannel()
const;
57 void GetDescription(llvm::raw_ostream& desc)
const override;
59 void ValueChanged(
ITable* source, llvm::StringRef key,
60 std::shared_ptr<nt::Value> value,
bool isNew)
override;
65 void InitTable(std::shared_ptr<ITable> subTable)
override;
66 std::shared_ptr<ITable>
GetTable()
const override;
68 std::shared_ptr<ITable> m_table;
72 Direction m_direction;
74 HAL_RelayHandle m_forwardHandle = HAL_kInvalidHandle;
75 HAL_RelayHandle m_reverseHandle = HAL_kInvalidHandle;
77 std::unique_ptr<MotorSafetyHelper> m_safetyHelper;
Value Get() const
Get the Relay State.
Definition: Relay.cpp:185
A table whose values can be read and written to.
Definition: ITable.h:22
Live Window Sendable is a special type of object sendable to the live window.
Definition: LiveWindowSendable.h:17
Base class for all sensors.
Definition: SensorBase.h:22
void Set(Value value)
Set the relay state.
Definition: Relay.cpp:124
Class for Spike style relay outputs.
Definition: Relay.h:36
void SetExpiration(double timeout) override
Set the expiration time for the Relay object.
Definition: Relay.cpp:225
void StartLiveWindowMode() override
Start having this sendable object automatically respond to value changes reflect the value on the tab...
Definition: Relay.cpp:302
std::shared_ptr< ITable > GetTable() const override
Definition: Relay.cpp:321
Definition: MotorSafety.h:16
Definition: MotorSafetyHelper.h:19
void StopLiveWindowMode() override
Stop having this sendable object automatically respond to value changes.
Definition: Relay.cpp:308
void SetSafetyEnabled(bool enabled) override
Enable/disable motor safety for this device.
Definition: Relay.cpp:258
Relay(int channel, Direction direction=kBothDirections)
Relay constructor given a channel.
Definition: Relay.cpp:29
double GetExpiration() const override
Return the expiration time for the relay object.
Definition: Relay.cpp:233
void InitTable(std::shared_ptr< ITable > subTable) override
Initializes a table for this sendable object.
Definition: Relay.cpp:316
std::string GetSmartDashboardType() const override
Definition: Relay.cpp:314
void StopMotor() override
Stop the motor associated with this PWM object.
Definition: Relay.cpp:249
A listener that listens to changes in values in a ITable.
Definition: ITableListener.h:18
bool IsSafetyEnabled() const override
Check if motor safety is enabled for this object.
Definition: Relay.cpp:267
virtual ~Relay()
Free the resource associated with a relay.
Definition: Relay.cpp:98
void UpdateTable() override
Update the table for this sendable object with the latest values.
Definition: Relay.cpp:288
bool IsAlive() const override
Check if the relay object is currently alive or stopped due to a timeout.
Definition: Relay.cpp:241