mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-25 01:41:43 +00:00
verified to work on real robots adds sim eclipse plugins, fixed JavaGazebo, made wpilibC++Sim build on windows - Java and C++ simulation robot programs run on windows - simulation eclipse plugin delivers models and gazebo plugins - Java Gazebo now respects GAZEBO_IP variables and can work across networks - hal and network tables win32 hacked to work on windows - smart dashboard broken on windows due to network tables hacks - wpilibC++Sim, gz_msgs, and frcsim_gazebo_plugins build with CMake - removed constexpr for cross platform compatibility - msgs generated using .protos as a part of build process - some spare and unused cmake/pom files deleted - simulation ubuntu debians removed entirely - refactored CMake project flags and macros - updated to match non-sim C++ API - fixed and updated documentation - servo added to simulation Change-Id: Ia702ff0f1fee10d77f543810ad88f56696443b05
95 lines
2.8 KiB
C++
95 lines
2.8 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]]
|
|
#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
|