jerrym | f157933 | 2013-02-07 01:56:28 +0000 | [diff] [blame] | 1 | /*----------------------------------------------------------------------------*/
|
| 2 | /* Copyright (c) FIRST 2011. All Rights Reserved. */
|
| 3 | /* Open Source Software - may be modified and shared by FRC teams. The code */
|
| 4 | /* must be accompanied by the FIRST BSD license file in $(WIND_BASE)/WPILib. */
|
| 5 | /*----------------------------------------------------------------------------*/
|
| 6 |
|
| 7 | #ifndef __SCHEDULER_H__
|
| 8 | #define __SCHEDULER_H__
|
| 9 |
|
| 10 | #include "Commands/Command.h"
|
| 11 | #include "ErrorBase.h"
|
| 12 | #include "SmartDashboard/NamedSendable.h"
|
| 13 | #include "networktables/NetworkTable.h"
|
| 14 | #include "networktables2/type/NumberArray.h"
|
| 15 | #include "networktables2/type/StringArray.h"
|
| 16 | #include "SmartDashboard/SmartDashboard.h"
|
| 17 | #include <list>
|
| 18 | #include <map>
|
| 19 | #include <set>
|
| 20 | #include <vector>
|
| 21 |
|
| 22 | class ButtonScheduler;
|
| 23 | class Subsystem;
|
| 24 |
|
| 25 | class Scheduler : public ErrorBase, public NamedSendable
|
| 26 | {
|
| 27 | public:
|
| 28 | static Scheduler *GetInstance();
|
| 29 |
|
| 30 | void AddCommand(Command* command);
|
| 31 | void AddButton(ButtonScheduler* button);
|
| 32 | void RegisterSubsystem(Subsystem *subsystem);
|
| 33 | void Run();
|
| 34 | void Remove(Command *command);
|
| 35 | void RemoveAll();
|
| 36 | void SetEnabled(bool enabled);
|
| 37 |
|
| 38 | void UpdateTable();
|
| 39 | std::string GetSmartDashboardType();
|
| 40 | void InitTable(ITable *subTable);
|
| 41 | ITable * GetTable();
|
| 42 | std::string GetName();
|
| 43 | std::string GetType();
|
| 44 |
|
| 45 | private:
|
| 46 | Scheduler();
|
| 47 | virtual ~Scheduler();
|
| 48 |
|
| 49 | void ProcessCommandAddition(Command *command);
|
| 50 |
|
| 51 | static Scheduler *_instance;
|
| 52 | Command::SubsystemSet m_subsystems;
|
| 53 | SEM_ID m_buttonsLock;
|
| 54 | typedef std::vector<ButtonScheduler *> ButtonVector;
|
| 55 | ButtonVector m_buttons;
|
| 56 | typedef std::vector<Command *> CommandVector;
|
| 57 | SEM_ID m_additionsLock;
|
| 58 | CommandVector m_additions;
|
| 59 | typedef std::set<Command *> CommandSet;
|
| 60 | CommandSet m_commands;
|
| 61 | bool m_adding;
|
| 62 | bool m_enabled;
|
| 63 | StringArray *commands;
|
| 64 | NumberArray *ids;
|
| 65 | NumberArray *toCancel;
|
| 66 | ITable *m_table;
|
jerrym | 42dedc0 | 2013-02-25 01:59:14 +0000 | [diff] [blame] | 67 | bool m_runningCommandsChanged;
|
jerrym | f157933 | 2013-02-07 01:56:28 +0000 | [diff] [blame] | 68 | };
|
| 69 | #endif
|
| 70 |
|