Files
allwpilib/wpilibc/wpilibC++/include/Commands/Scheduler.h
Tyler Veness 368ad30d37 artf4107: Uniform initialization syntax introduced
Change-Id: I452b4794d757a0817589ec62b75eda7fbdd74904
2015-07-02 21:50:39 -07:00

72 lines
2.0 KiB
C++

/*----------------------------------------------------------------------------*/
/* Copyright (c) FIRST 2011. All Rights Reserved.
*/
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in $(WIND_BASE)/WPILib. */
/*----------------------------------------------------------------------------*/
#ifndef __SCHEDULER_H__
#define __SCHEDULER_H__
#include "Commands/Command.h"
#include "ErrorBase.h"
#include "SmartDashboard/NamedSendable.h"
#include "networktables/NetworkTable.h"
#include "networktables2/type/NumberArray.h"
#include "networktables2/type/StringArray.h"
#include "SmartDashboard/SmartDashboard.h"
#include "HAL/Semaphore.hpp"
#include <list>
#include <map>
#include <set>
#include <vector>
class ButtonScheduler;
class Subsystem;
class Scheduler : public ErrorBase, public NamedSendable {
public:
static Scheduler *GetInstance();
void AddCommand(Command *command);
void AddButton(ButtonScheduler *button);
void RegisterSubsystem(Subsystem *subsystem);
void Run();
void Remove(Command *command);
void RemoveAll();
void ResetAll();
void SetEnabled(bool enabled);
void UpdateTable();
std::string GetSmartDashboardType() const;
void InitTable(ITable *subTable);
ITable *GetTable() const;
std::string GetName();
std::string GetType() const;
private:
Scheduler();
virtual ~Scheduler();
void ProcessCommandAddition(Command *command);
static Scheduler *_instance;
Command::SubsystemSet m_subsystems;
MUTEX_ID m_buttonsLock = nullptr;
typedef std::vector<ButtonScheduler *> ButtonVector;
ButtonVector m_buttons;
typedef std::vector<Command *> CommandVector;
MUTEX_ID m_additionsLock = nullptr;
CommandVector m_additions;
typedef std::set<Command *> CommandSet;
CommandSet m_commands;
bool m_adding = false;
bool m_enabled = true;
StringArray *commands = nullptr;
NumberArray *ids = nullptr;
NumberArray *toCancel = nullptr;
ITable *m_table = nullptr;
bool m_runningCommandsChanged = false;
};
#endif