fwt_software/include/fgc/IControlChannel.h

59 lines
2.2 KiB
C++

#pragma once
#include <string>
namespace fgc {
// Remote control input (was struct mqtt_sub_data). The *_available flags mark
// whether a fresh value arrived since the last poll().
struct ControlCommand {
bool control_code_available = false;
int control_code = 0; // 0 = automatic sweep, 1 = directed to target heading
bool heading_available = false;
std::string target_heading; // kept as string; the yaw target in degrees
};
// Notification published after an image is captured and saved.
struct CamEvent {
std::string tower; // tower / FWT name
std::string camera; // "RGB" / "ACR" / "NIR"
int heading_decideg = 0; // yaw heading * 10 (one decimal as integer)
int pitch_decideg = 0; // pitch elevation * 10 (one decimal as integer)
long long timestamp_ms = 0; // Unix epoch ms; matches the image filename
// True when the quality gate ran out of attempts and this is its best effort
// rather than a frame that passed. Published so consumers can weight or skip
// degraded images instead of silently treating them as good.
bool degraded = false;
};
// Ambient temperature/humidity reading published once per fresh sensor sample.
struct EnvEvent {
std::string tower;
float temp_c = 0.0f;
float humidity_pct = 0.0f;
long long timestamp_ms = 0;
};
// Abstraction over the remote control/telemetry channel. Implemented by
// MqttControlChannel (Eclipse Paho) and NullControlChannel (no broker; used
// for development - publishes are dropped and poll() yields a default).
class IControlChannel {
public:
virtual ~IControlChannel() = default;
// Returns true once usable. NullControlChannel always succeeds.
virtual bool connect() = 0;
virtual void disconnect() = 0;
virtual bool connected() const = 0;
virtual void publishStatus(int code) = 0;
virtual void publishCamEvent(const CamEvent& event) = 0;
virtual void publishEnv(const EnvEvent& event) = 0;
// Latest control input; clears the *_available flags so each update is
// acted on once.
virtual ControlCommand poll() = 0;
};
} // namespace fgc