Files
allwpilib/wpilibc/wpilibC++/include/LiveWindow/LiveWindow.h
peter mitrano 4514e4489a refactored HAL library
builds two libraries, Athena  and Desktop.
Simulation should use Desktop, Robots should use Athena

Also:
 - copied Driverstation and Joystick from Devices into Sim
 - Descreased dependency of pthreads in JNI.
 - removed Simulation ifdef from non simulation
 - added missing decprecated attribute for msvc
 - removed usage reporting from sim
 - removed unused pom.xml and constexpr

Change-Id: If8eb540f9434dce17c77a245fda6985713e80b2d
2015-08-20 11:22:42 -04:00

100 lines
3.0 KiB
C++

#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;
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();
#if !defined(_MSC_VER)
[[deprecated(
"Raw pointers are deprecated; pass the component using shared_ptr "
"instead.")]]
#else
__declspec(deprecated("**Raw pointers are deprecated; pass the component using shared_ptr instead**"))
#endif
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);
#if !defined(_MSC_VER)
[[deprecated(
"Raw pointers are deprecated; pass the component using shared_ptr "
"instead.")]]
#else
__declspec(deprecated("**Raw pointers are deprecated; pass the component using shared_ptr instead**"))
#endif
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);
#if !defined(_MSC_VER)
[[deprecated(
"Raw pointers are deprecated; pass the component using shared_ptr "
"instead.")]]
#else
__declspec(deprecated("**Raw pointers are deprecated; pass the component using shared_ptr instead**"))
#endif
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