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>
|
2019-01-13 23:44:59 +00:00
|
|
|
#include <vector>
|
2018-12-12 04:04:00 +00:00
|
|
|
|
2019-01-13 23:44:59 +00:00
|
|
|
#include <cscore.h>
|
2018-12-15 00:36:56 +00:00
|
|
|
#include <wpi/Signal.h>
|
|
|
|
#include <wpi/StringRef.h>
|
2018-12-17 08:54:25 +00:00
|
|
|
#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;
|
|
|
|
|
2019-01-13 23:44:59 +00:00
|
|
|
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);
|
2019-01-13 23:44:59 +00:00
|
|
|
void UpdateCameraList();
|
2018-12-12 04:04:00 +00:00
|
|
|
|
|
|
|
wpi::sig::Signal<const wpi::json&> update;
|
|
|
|
wpi::sig::Signal<const wpi::json&> log;
|
2019-01-13 23:44:59 +00:00
|
|
|
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);
|
2019-01-13 23:44:59 +00:00
|
|
|
void RefreshCameraList();
|
2018-12-12 04:04:00 +00:00
|
|
|
|
|
|
|
std::shared_ptr<wpi::uv::Loop> m_loop;
|
2019-01-13 23:44:59 +00:00
|
|
|
|
|
|
|
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_
|