36#include "observable.h"
38double PosPartsToDegrees(
float degrees,
float minutes,
float percent_of_minute);
40std::string DegreesToString(
double degrees);
42std::string TimeToString(
const time_t time);
46 enum class Type { NE, NW, SE, SW, Undef };
49 Position(
double _lat,
double _lon, Type t);
57 bool IsValid()
const {
return type != Type::Undef; }
74 std::string TypeToStr(
const Type t)
const;
77 Type LatLongToType(
double lat,
double lon);
80 double TypeToLat(Type t,
double lat);
83 double TypeToLong(Type t,
double lon);
91 : type(t), name(TypeToString(t)), source(
NavAddr()), prio(0) {};
96 virtual std::string
key()
const {
return "appmsg::" + name; }
101 std::string TypeToString(
const Type t)
const;
103 virtual std::string to_string()
const {
return "appmsg::" + name; }
106 const std::string name;
112 : type(tp), name(nm), source(src), prio(0) {};
115enum class AppMsg::Type {
132 std::vector<NavAddr> sources;
138 enum class Quality { none, gnss, differential };
140 GnssFix(
Position p, time_t t, Quality q = Quality::none,
int s_used = -1)
145 satellites_used(s_used) {};
147 std::string to_string()
const override {
148 std::stringstream buf;
149 buf << pos.
to_string() <<
" " << TimeToString(time);
160#define POS_UPDATE (int)(1)
161#define COG_UPDATE (int)(1 << 1)
162#define SOG_UPDATE (int)(1 << 2)
163#define VAR_UPDATE (int)(1 << 3)
164#define HDT_UPDATE (int)(1 << 4)
165#define POS_VALID (int)(1 << 5)
169 BasicNavDataMsg(
double lat,
double lon,
double SOG,
double COG,
double VAR,
170 double HDT,
int valid_flag, time_t t)
171 :
AppMsg(AppMsg::Type::BasicNavData,
"basic-nav-data",
NavAddr()),
181 :
AppMsg(AppMsg::Type::BasicNavData,
"basic-nav-data",
NavAddr()),
192 virtual std::string to_string()
const;
201 struct timespec set_time;
206 enum class WDSource { position, velocity, heading, var, sats };
209 :
AppMsg(AppMsg::Type::GPSWatchdog,
"gps-watchdog",
NavAddr()),
211 wd_source(_source) {};
215 const int gps_watchdog;
216 const WDSource wd_source;
222 std::string
key()
const override {
return "appmsg::aisdata"; }
223 std::string to_string()
const override;
232 std::string callsign;
245 CustomMsg(
const std::string s, std::shared_ptr<const void> ptr)
246 :
AppMsg(Type::CustomMsg,
"custom",
NavAddr()), id(s), payload(ptr) {}
248 std::string key()
const override {
return "appmsg::custom-" + id; }
250 const std::string id;
251 std::shared_ptr<const void> payload;
AIS data point for a vessel.
std::string key() const override
Return unique key used by Observable.
virtual std::string key() const
Return unique key used by Observable.
std::string GetKey() const
Alias for key().
A generic message containing a const pointer to basically anything, the pointer neds to be casted to ...
Issued when there are multiple sources providing 'what' with priority == 0.
Interface implemented by classes which listens.
Where messages are sent to or received from.
Position()
Construct a (0,0) position, type == Undef.
static Position ParseGGA(const std::string gga)
Parse a GGA string like "5800.588,N,01145.776,E" as present in GGA and other n0183 messages.
std::string to_string() const
Return utf string like 65°25,11N 21°12,01E.
Communication driver layer.