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 DecodeTHS(std::string s, NavData& temp_data);
64 bool DecodeHDT(std::string s, NavData& temp_data);
65 bool DecodeHDG(std::string s, NavData& temp_data);
66 bool DecodeVTG(std::string s, NavData& temp_data);
67 bool DecodeGSV(std::string s, NavData& temp_data);
68 bool DecodeGGA(std::string s, NavData& temp_data);
69 bool DecodeGLL(std::string s, NavData& temp_data);
70
71 bool ParsePosition(const LATLONG& Position, double& lat, double& lon);
72
73 NMEA0183 m_NMEA0183; // Used to parse messages from NMEA threads
74
75 // NMEA2000 decoding, by PGN
76 bool DecodePGN129025(std::vector<unsigned char> v, NavData& temp_data);
77 bool DecodePGN129026(std::vector<unsigned char> v, NavData& temp_data);
78 bool DecodePGN129029(std::vector<unsigned char> v, NavData& temp_data);
79 bool DecodePGN127250(std::vector<unsigned char> v, NavData& temp_data);
80 bool DecodePGN129540(std::vector<unsigned char> v, NavData& temp_data);
81
82 // SignalK
83 bool DecodeSignalK(std::string s, NavData& temp_data);
84 void handleUpdate(const rapidjson::Value& update, NavData& temp_data);
85 void updateItem(const rapidjson::Value& item, wxString& sfixtime,
86 NavData& temp_data);
87 bool updateNavigationPosition(const rapidjson::Value& value,
88 const wxString& sfixtime, NavData& temp_data);
89 void updateNavigationSpeedOverGround(const rapidjson::Value& value,
90 const wxString& sfixtime,
91 NavData& temp_data);
92 void updateNavigationCourseOverGround(const rapidjson::Value& value,
93 const wxString& sfixtime,
94 NavData& temp_data);
95 void updateGnssSatellites(const rapidjson::Value& value,
96 const wxString& sfixtime, NavData& temp_data);
97 void updateHeadingTrue(const rapidjson::Value& value,
98 const wxString& sfixtime, NavData& temp_data);
99 void updateHeadingMagnetic(const rapidjson::Value& value,
100 const wxString& sfixtime, NavData& temp_data);
101 void updateMagneticVariance(const rapidjson::Value& value,
102 const wxString& sfixtime, NavData& temp_data);
103
104 std::string src_string;
105 std::unordered_map<std::string, int> GNSS_quality_map;
106};
107
108#endif // _COMM_DECODER_H
Global variables stored in configuration file.