OpenCPN Partial API docs
Loading...
Searching...
No Matches
comm_decoder.h
Go to the documentation of this file.
1/***************************************************************************
2 * Copyright (C) 2022 by David Register *
3 * Copyright (C) 2022 Alec Leamas *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, see <https://www.gnu.org/licenses/>. *
17 **************************************************************************/
18
25#ifndef _COMM_DECODER_H
26#define _COMM_DECODER_H
27
28#include <memory>
29#include <string>
30
31#include "rapidjson/fwd.h" // Must be early, rapidjson known bug
32
33#include <wx/string.h>
34
35#include "model/comm_appmsg.h"
36#include "model/config_vars.h"
38
39#include "nmea0183.h"
40#include "N2KParser.h"
41
42typedef struct {
43 double gLat;
44 double gLon;
45 double gSog;
46 double gCog;
47 double gHdt;
48 double gHdm;
49 double gVar;
50 int n_satellites;
51 int SID;
52} NavData;
53
55public:
56 CommDecoder() : m_NMEA0183(NmeaCtxFactory()) {};
57 ~CommDecoder() {};
58
59 // NMEA0183 decoding, by sentence.
60 bool DecodeRMC(std::string s, NavData& temp_data);
61 bool DecodeHDM(std::string s, NavData& temp_data);
62 bool DecodeTHS(std::string s, NavData& temp_data);
63 bool DecodeHDT(std::string s, NavData& temp_data);
64 bool DecodeHDG(std::string s, NavData& temp_data);
65 bool DecodeVTG(std::string s, NavData& temp_data);
66 bool DecodeGSV(std::string s, NavData& temp_data);
67 bool DecodeGGA(std::string s, NavData& temp_data);
68 bool DecodeGLL(std::string s, NavData& temp_data);
69
70 bool ParsePosition(const LATLONG& Position, double& lat, double& lon);
71
72 NMEA0183 m_NMEA0183; // Used to parse messages from NMEA threads
73
74 // NMEA2000 decoding, by PGN
75 bool DecodePGN129025(std::vector<unsigned char> v, NavData& temp_data);
76 bool DecodePGN129026(std::vector<unsigned char> v, NavData& temp_data);
77 bool DecodePGN129029(std::vector<unsigned char> v, NavData& temp_data);
78 bool DecodePGN127250(std::vector<unsigned char> v, NavData& temp_data);
79 bool DecodePGN129540(std::vector<unsigned char> v, NavData& temp_data);
80
81 // SignalK
82 bool DecodeSignalK(std::string s, NavData& temp_data);
83 void handleUpdate(const rapidjson::Value& update, NavData& temp_data);
84 void updateItem(const rapidjson::Value& item, wxString& sfixtime,
85 NavData& temp_data);
86 bool updateNavigationPosition(const rapidjson::Value& value,
87 const wxString& sfixtime, NavData& temp_data);
88 void updateNavigationSpeedOverGround(const rapidjson::Value& value,
89 const wxString& sfixtime,
90 NavData& temp_data);
91 void updateNavigationCourseOverGround(const rapidjson::Value& value,
92 const wxString& sfixtime,
93 NavData& temp_data);
94 void updateGnssSatellites(const rapidjson::Value& value,
95 const wxString& sfixtime, NavData& temp_data);
96 void updateHeadingTrue(const rapidjson::Value& value,
97 const wxString& sfixtime, NavData& temp_data);
98 void updateHeadingMagnetic(const rapidjson::Value& value,
99 const wxString& sfixtime, NavData& temp_data);
100 void updateMagneticVariance(const rapidjson::Value& value,
101 const wxString& sfixtime, NavData& temp_data);
102
103 std::string src_string;
104 std::unordered_map<std::string, int> GNSS_quality_map;
105};
106
107#endif // _COMM_DECODER_H
Decoded messages definitions.
Global variables stored in configuration file.
Wrapper for creating an NmeaContext based on global vars.
double gHdm
Magnetic heading in degrees (0-359.99).
Definition own_ship.cpp:31
double gVar
Magnetic variation in degrees.
Definition own_ship.cpp:32
double gHdt
True heading in degrees (0-359.99).
Definition own_ship.cpp:30
double gLat
Vessel's current latitude in decimal degrees.
Definition own_ship.cpp:26
double gCog
Course over ground in degrees (0-359.99).
Definition own_ship.cpp:28
double gSog
Speed over ground in knots.
Definition own_ship.cpp:29
double gLon
Vessel's current longitude in decimal degrees.
Definition own_ship.cpp:27