OpenCPN Partial API docs
Loading...
Searching...
No Matches
comm_decoder.h
1/***************************************************************************
2 *
3 * Project: OpenCPN
4 * Purpose:
5 *
6 * Author: David Register, Alec Leamas
7 *
8 ***************************************************************************
9 * Copyright (C) 2022 by David Register, Alec Leamas *
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 * This program is distributed in the hope that it will be useful, *
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
19 * GNU General Public License for more details. *
20 * *
21 * You should have received a copy of the GNU General Public License *
22 * along with this program; if not, write to the *
23 * Free Software Foundation, Inc., *
24 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
25 **************************************************************************/
26
27#ifndef _COMM_DECODER_H
28#define _COMM_DECODER_H
29
30#include <memory>
31#include <string>
32
33#include "rapidjson/fwd.h"
34#include <wx/string.h>
35
36#include "model/comm_appmsg.h"
37#include "model/config_vars.h"
38#include "model/nmea_ctx_factory.h"
39
40#include "nmea0183.h"
41#include "N2KParser.h"
42
43typedef struct {
44 double gLat;
45 double gLon;
46 double gSog;
47 double gCog;
48 double gHdt;
49 double gHdm;
50 double gVar;
51 int n_satellites;
52 int SID;
53} NavData;
54
56public:
57 CommDecoder() : m_NMEA0183(NmeaCtxFactory()) {};
58 ~CommDecoder() {};
59
60 // NMEA0183 decoding, by sentence.
61 bool DecodeRMC(std::string s, NavData& temp_data);
62 bool DecodeHDM(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