2013-12-15 18:30:16 -05:00
|
|
|
/*----------------------------------------------------------------------------*/
|
2018-01-02 09:20:21 -08:00
|
|
|
/* Copyright (c) 2011-2018 FIRST. All Rights Reserved. */
|
2013-12-15 18:30:16 -05:00
|
|
|
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
2016-01-02 03:02:34 -08:00
|
|
|
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
|
|
|
|
/* the project. */
|
2013-12-15 18:30:16 -05:00
|
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
|
|
2016-05-25 22:40:15 -07:00
|
|
|
#pragma once
|
2013-12-15 18:30:16 -05:00
|
|
|
|
2016-05-20 17:30:37 -07:00
|
|
|
#include <memory>
|
2017-12-04 23:28:33 -08:00
|
|
|
|
2018-04-29 23:33:19 -07:00
|
|
|
#include <wpi/StringRef.h>
|
|
|
|
|
#include <wpi/Twine.h>
|
2016-09-25 16:50:13 -07:00
|
|
|
|
2013-12-15 18:30:16 -05:00
|
|
|
#include "ErrorBase.h"
|
2017-12-04 23:28:33 -08:00
|
|
|
#include "SmartDashboard/Sendable.h"
|
|
|
|
|
#include "SmartDashboard/SendableBase.h"
|
2013-12-15 18:30:16 -05:00
|
|
|
|
2016-11-01 22:33:12 -07:00
|
|
|
namespace frc {
|
|
|
|
|
|
2013-12-15 18:30:16 -05:00
|
|
|
class Command;
|
|
|
|
|
|
2017-12-04 23:28:33 -08:00
|
|
|
class Subsystem : public ErrorBase, public SendableBase {
|
2015-06-25 15:07:55 -04:00
|
|
|
friend class Scheduler;
|
|
|
|
|
|
|
|
|
|
public:
|
2018-04-29 23:33:19 -07:00
|
|
|
explicit Subsystem(const wpi::Twine& name);
|
2015-06-25 15:07:55 -04:00
|
|
|
|
2016-05-20 17:30:37 -07:00
|
|
|
void SetDefaultCommand(Command* command);
|
|
|
|
|
Command* GetDefaultCommand();
|
2018-04-29 23:33:19 -07:00
|
|
|
wpi::StringRef GetDefaultCommandName();
|
2016-05-20 17:30:37 -07:00
|
|
|
void SetCurrentCommand(Command* command);
|
|
|
|
|
Command* GetCurrentCommand() const;
|
2018-04-29 23:33:19 -07:00
|
|
|
wpi::StringRef GetCurrentCommandName() const;
|
2017-07-02 23:02:41 -07:00
|
|
|
virtual void Periodic();
|
2015-06-25 15:07:55 -04:00
|
|
|
virtual void InitDefaultCommand();
|
|
|
|
|
|
2018-04-29 23:33:19 -07:00
|
|
|
void AddChild(const wpi::Twine& name, std::shared_ptr<Sendable> child);
|
|
|
|
|
void AddChild(const wpi::Twine& name, Sendable* child);
|
|
|
|
|
void AddChild(const wpi::Twine& name, Sendable& child);
|
2017-12-04 23:28:33 -08:00
|
|
|
void AddChild(std::shared_ptr<Sendable> child);
|
|
|
|
|
void AddChild(Sendable* child);
|
|
|
|
|
void AddChild(Sendable& child);
|
|
|
|
|
|
2015-06-25 15:07:55 -04:00
|
|
|
private:
|
|
|
|
|
void ConfirmCommand();
|
|
|
|
|
|
2016-05-20 17:30:37 -07:00
|
|
|
Command* m_currentCommand = nullptr;
|
2015-06-24 01:06:29 -07:00
|
|
|
bool m_currentCommandChanged = true;
|
2016-05-20 17:30:37 -07:00
|
|
|
Command* m_defaultCommand = nullptr;
|
2015-06-24 01:06:29 -07:00
|
|
|
bool m_initializedDefaultCommand = false;
|
2015-06-25 15:07:55 -04:00
|
|
|
|
|
|
|
|
public:
|
2017-12-04 23:28:33 -08:00
|
|
|
void InitSendable(SendableBuilder& builder) override;
|
2013-12-15 18:30:16 -05:00
|
|
|
};
|
2016-11-01 22:33:12 -07:00
|
|
|
|
|
|
|
|
} // namespace frc
|