burrow-pi-img/deps/tools/configServer/src/VisionStatus.h

67 lines
1.9 KiB
C
Raw Normal View History

2018-12-12 04:04:00 +00:00
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 FIRST. 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 the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
2018-12-15 00:36:56 +00:00
#ifndef RPICONFIGSERVER_VISIONSTATUS_H_
#define RPICONFIGSERVER_VISIONSTATUS_H_
2018-12-12 04:04:00 +00:00
#include <functional>
#include <memory>
#include <vector>
2018-12-12 04:04:00 +00:00
#include <cscore.h>
2018-12-15 00:36:56 +00:00
#include <wpi/Signal.h>
#include <wpi/StringRef.h>
#include <wpi/uv/Loop.h>
2018-12-12 04:04:00 +00:00
namespace wpi {
class json;
namespace uv {
class Buffer;
} // namespace uv
} // namespace wpi
class VisionStatus {
struct private_init {};
public:
explicit VisionStatus(const private_init&) {}
VisionStatus(const VisionStatus&) = delete;
VisionStatus& operator=(const VisionStatus&) = delete;
void SetLoop(std::shared_ptr<wpi::uv::Loop> loop);
2018-12-12 04:04:00 +00:00
void Up(std::function<void(wpi::StringRef)> onFail);
void Down(std::function<void(wpi::StringRef)> onFail);
void Terminate(std::function<void(wpi::StringRef)> onFail);
void Kill(std::function<void(wpi::StringRef)> onFail);
void UpdateStatus();
void ConsoleLog(wpi::uv::Buffer& buf, size_t len);
void UpdateCameraList();
2018-12-12 04:04:00 +00:00
wpi::sig::Signal<const wpi::json&> update;
wpi::sig::Signal<const wpi::json&> log;
wpi::sig::Signal<const wpi::json&> cameraList;
2018-12-12 04:04:00 +00:00
static std::shared_ptr<VisionStatus> GetInstance();
private:
void RunSvc(const char* cmd, std::function<void(wpi::StringRef)> onFail);
void RefreshCameraList();
2018-12-12 04:04:00 +00:00
std::shared_ptr<wpi::uv::Loop> m_loop;
struct CameraInfo {
cs::UsbCameraInfo info;
std::vector<cs::VideoMode> modes;
};
std::vector<CameraInfo> m_cameraInfo;
2018-12-12 04:04:00 +00:00
};
2018-12-15 00:36:56 +00:00
#endif // RPICONFIGSERVER_VISIONSTATUS_H_