1 #include "LiveWindow/LiveWindow.h"
2 #include "networktables/NetworkTable.h"
15 if (m_instance == NULL)
30 m_statusTable = m_liveWindowTable->
GetSubTable(
"~STATUS~");
40 if (m_enabled == enabled)
44 printf(
"Starting live window mode\n");
47 InitializeLiveWindowComponents();
50 m_scheduler->SetEnabled(
false);
51 m_scheduler->RemoveAll();
52 for (std::map<LiveWindowSendable *, LiveWindowComponent>::iterator it =
53 m_components.begin(); it != m_components.end(); ++it)
55 it->first->StartLiveWindowMode();
60 printf(
"Ending LiveWindow mode\n");
61 for (std::map<LiveWindowSendable *, LiveWindowComponent>::iterator it =
62 m_components.begin(); it != m_components.end(); ++it)
64 it->first->StopLiveWindowMode();
66 m_scheduler->SetEnabled(
true);
69 m_statusTable->
PutBoolean(
"LW Enabled", m_enabled);
72 LiveWindow::~LiveWindow()
85 m_components[component].subsystem = subsystem;
86 m_components[component].name = name;
87 m_components[component].isSensor =
true;
99 m_components[component].subsystem = subsystem;
100 m_components[component].name = name;
101 m_components[component].isSensor =
false;
109 std::ostringstream oss;
110 oss << type <<
"[" << module <<
"," << channel <<
"]";
111 std::string types(oss.str());
112 char* cc =
new char[types.size() + 1];
113 types.copy(cc, types.size());
114 cc[types.size()]=
'\0';
116 if (std::find(m_sensors.begin(), m_sensors.end(), component) == m_sensors.end())
117 m_sensors.push_back(component);
125 std::ostringstream oss;
126 oss << type <<
"[" << module <<
"," << channel <<
"]";
127 std::string types(oss.str());
128 char* cc =
new char[types.size() + 1];
129 types.copy(cc, types.size());
130 cc[types.size()]=
'\0';
139 void LiveWindow::UpdateValues()
141 for (
unsigned int i = 0; i < m_sensors.size(); i++)
143 m_sensors[i]->UpdateTable();
166 void LiveWindow::InitializeLiveWindowComponents()
168 for (std::map<LiveWindowSendable *, LiveWindowComponent>::iterator it =
169 m_components.begin(); it != m_components.end(); ++it)
173 std::string subsystem = c.subsystem;
174 std::string name = c.name;
181 table->
PutString(
"Subsystem", subsystem);
185 m_sensors.push_back(component);
void AddActuator(const char *subsystem, const char *name, LiveWindowSendable *component)
void SetEnabled(bool enabled)
static NetworkTable * GetTable(std::string key)
virtual ITable * GetSubTable(std::string key)=0
void AddSensor(const char *subsystem, const char *name, LiveWindowSendable *component)
virtual void InitTable(ITable *subtable)=0
virtual void PutBoolean(std::string key, bool value)=0
static LiveWindow * GetInstance()
virtual std::string GetSmartDashboardType()=0
static Scheduler * GetInstance()
virtual void PutString(std::string key, std::string value)=0