Squashed 'third_party/allwpilib_2016/' content from commit 7f61816
Change-Id: If9d9245880859cdf580f5d7f77045135d0521ce7
git-subtree-dir: third_party/allwpilib_2016
git-subtree-split: 7f618166ed253a24629934fcf89c3decb0528a3b
diff --git a/wpilibc/shared/include/LiveWindow/LiveWindow.h b/wpilibc/shared/include/LiveWindow/LiveWindow.h
new file mode 100644
index 0000000..7b40f67
--- /dev/null
+++ b/wpilibc/shared/include/LiveWindow/LiveWindow.h
@@ -0,0 +1,78 @@
+#ifndef _LIVE_WINDOW_H
+#define _LIVE_WINDOW_H
+
+#include "LiveWindow/LiveWindowSendable.h"
+#include "tables/ITable.h"
+#include "Commands/Scheduler.h"
+#include <vector>
+#include <map>
+#include <memory>
+
+struct LiveWindowComponent {
+ std::string subsystem;
+ std::string name;
+ bool isSensor = false;
+
+ LiveWindowComponent() = default;
+ LiveWindowComponent(std::string subsystem, std::string name, bool isSensor) {
+ this->subsystem = subsystem;
+ this->name = name;
+ this->isSensor = isSensor;
+ }
+};
+
+/**
+ * The LiveWindow class is the public interface for putting sensors and
+ * actuators
+ * on the LiveWindow.
+ *
+ * @author Brad Miller
+ */
+class LiveWindow {
+ public:
+ static LiveWindow *GetInstance();
+ void Run();
+ void AddSensor(const std::string &subsystem, const std::string &name,
+ LiveWindowSendable *component);
+ void AddSensor(const std::string &subsystem, const std::string &name,
+ LiveWindowSendable &component);
+ void AddSensor(const std::string &subsystem, const std::string &name,
+ std::shared_ptr<LiveWindowSendable> component);
+ void AddActuator(const std::string &subsystem, const std::string &name,
+ LiveWindowSendable *component);
+ void AddActuator(const std::string &subsystem, const std::string &name,
+ LiveWindowSendable &component);
+ void AddActuator(const std::string &subsystem, const std::string &name,
+ std::shared_ptr<LiveWindowSendable> component);
+
+ void AddSensor(std::string type, int channel, LiveWindowSendable *component);
+ void AddActuator(std::string type, int channel,
+ LiveWindowSendable *component);
+ void AddActuator(std::string type, int module, int channel,
+ LiveWindowSendable *component);
+
+ bool IsEnabled() const { return m_enabled; }
+ void SetEnabled(bool enabled);
+
+ protected:
+ LiveWindow();
+ virtual ~LiveWindow() = default;
+
+ private:
+ void UpdateValues();
+ void Initialize();
+ void InitializeLiveWindowComponents();
+
+ std::vector<std::shared_ptr<LiveWindowSendable>> m_sensors;
+ std::map<std::shared_ptr<LiveWindowSendable>, LiveWindowComponent> m_components;
+
+ std::shared_ptr<ITable> m_liveWindowTable;
+ std::shared_ptr<ITable> m_statusTable;
+
+ Scheduler *m_scheduler;
+
+ bool m_enabled = false;
+ bool m_firstTime = true;
+};
+
+#endif
diff --git a/wpilibc/shared/include/LiveWindow/LiveWindowSendable.h b/wpilibc/shared/include/LiveWindow/LiveWindowSendable.h
new file mode 100644
index 0000000..4f2023a
--- /dev/null
+++ b/wpilibc/shared/include/LiveWindow/LiveWindowSendable.h
@@ -0,0 +1,38 @@
+/*----------------------------------------------------------------------------*/
+/* Copyright (c) Patrick Plenefisch 2012. 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 LIVEWINDOWSENDABLE_H_
+#define LIVEWINDOWSENDABLE_H_
+
+#include "SmartDashboard/Sendable.h"
+
+/**
+ * Live Window Sendable is a special type of object sendable to the live window.
+ *
+ * @author Patrick Plenefisch
+ */
+class LiveWindowSendable : public Sendable {
+ public:
+ /**
+ * Update the table for this sendable object with the latest
+ * values.
+ */
+ virtual void UpdateTable() = 0;
+
+ /**
+ * Start having this sendable object automatically respond to
+ * value changes reflect the value on the table.
+ */
+ virtual void StartLiveWindowMode() = 0;
+
+ /**
+ * Stop having this sendable object automatically respond to value
+ * changes.
+ */
+ virtual void StopLiveWindowMode() = 0;
+};
+
+#endif /* LIVEWINDOWSENDABLE_H_ */
diff --git a/wpilibc/shared/include/LiveWindow/LiveWindowStatusListener.h b/wpilibc/shared/include/LiveWindow/LiveWindowStatusListener.h
new file mode 100644
index 0000000..4fa3eb7
--- /dev/null
+++ b/wpilibc/shared/include/LiveWindow/LiveWindowStatusListener.h
@@ -0,0 +1,13 @@
+#ifndef _LIVE_WINDOW_STATUS_LISTENER_H
+#define _LIVE_WINDOW_STATUS_LISTENER_H
+
+#include "tables/ITable.h"
+#include "tables/ITableListener.h"
+
+class LiveWindowStatusListener : public ITableListener {
+ public:
+ virtual void ValueChanged(ITable* source, llvm::StringRef key,
+ std::shared_ptr<nt::Value> value, bool isNew);
+};
+
+#endif