25#ifndef _AIS_DECODER_H__
26#define _AIS_DECODER_H__
29#include <unordered_map>
32#include <wx/datetime.h>
33#include "rapidjson/fwd.h"
37#include "ais_bitstring.h"
39#include "ais_target_data.h"
40#include "comm_navmsg.h"
41#include "observable_evtvar.h"
42#include "ocpn_types.h"
46enum AISAudioSoundType {
73 bool m_bPersistentTrack;
80 std::function<bool()> confirm_stop_track;
90 AisError DecodeN0183(
const wxString &str);
91 std::unordered_map<int, std::shared_ptr <AisTargetData>> &GetTargetList(
void) {
94 std::unordered_map<int, std::shared_ptr <AisTargetData>> &GetAreaNoticeSourcesList(
void) {
95 return AIS_AreaNotice_Sources;
97 std::shared_ptr<AisTargetData> Get_Target_Data_From_MMSI(
int mmsi);
98 int GetNumTargets(
void) {
return m_n_targets; }
99 bool IsAISSuppressed(
void) {
return m_bSuppressed; }
100 bool IsAISAlertGeneral(
void) {
return m_bGeneralAlert; }
103 void DeletePersistentTrack(
Track *track);
104 std::map<int, Track *> m_persistent_tracks;
105 bool AIS_AlertPlaying(
void) {
return m_bAIS_AlertPlaying; };
129 void OnActivate(wxActivateEvent &event);
130 void OnTimerAIS(wxTimerEvent &event);
131 void OnTimerDSC(wxTimerEvent &event);
133 bool NMEACheckSumOK(
const wxString &str);
134 bool Parse_VDXBitstring(
AisBitstring *bstr, std::shared_ptr<AisTargetData> ptd);
135 void UpdateAllCPA(
void);
137 void UpdateAllAlarms(
void);
138 void UpdateAllTracks(
void);
140 void BuildERIShipTypeHash(
void);
141 std::shared_ptr<AisTargetData> ProcessDSx(
const wxString &str,
bool b_take_dsc =
false);
143 wxString DecodeDSEExpansionCharacters(wxString dseData);
144 void getAISTarget(
long mmsi, std::shared_ptr<AisTargetData> &pTargetData,
145 std::shared_ptr<AisTargetData> &pStaleTarget,
bool &bnewtarget,
146 int &last_report_ticks, wxDateTime &now);
147 void getMmsiProperties(std::shared_ptr<AisTargetData> &pTargetData);
148 void handleUpdate(std::shared_ptr<AisTargetData> pTargetData,
bool bnewtarget,
149 const rapidjson::Value &update);
150 void updateItem(std::shared_ptr<AisTargetData> pTargetData,
bool bnewtarget,
151 const rapidjson::Value &item, wxString &sfixtime)
const;
152 void CommitAISTarget( std::shared_ptr<AisTargetData> pTargetData,
153 const wxString &str,
bool message_valid,
155 void InitCommListeners(
void);
156 bool HandleN0183_AIS( std::shared_ptr <const Nmea0183Msg> n0183_msg );
157 void HandleSignalK(std::shared_ptr<const SignalkMsg> sK_msg);
159 bool HandleN2K_129038( std::shared_ptr<const Nmea2000Msg> n2k_msg );
160 bool HandleN2K_129039( std::shared_ptr<const Nmea2000Msg> n2k_msg );
161 bool HandleN2K_129041( std::shared_ptr<const Nmea2000Msg> n2k_msg );
162 bool HandleN2K_129794( std::shared_ptr<const Nmea2000Msg> n2k_msg );
163 bool HandleN2K_129809( std::shared_ptr<const Nmea2000Msg> n2k_msg );
164 bool HandleN2K_129810( std::shared_ptr<const Nmea2000Msg> n2k_msg );
165 bool HandleN2K_129793( std::shared_ptr<const Nmea2000Msg> n2k_msg );
167 wxString m_signalk_selfid;
168 std::unordered_map<int, std::shared_ptr<AisTargetData>> AISTargetList;
169 std::unordered_map<int, std::shared_ptr<AisTargetData>> AIS_AreaNotice_Sources;
170 AIS_Target_Name_Hash *AISTargetNamesC;
171 AIS_Target_Name_Hash *AISTargetNamesNC;
192 wxFrame *m_parent_frame;
197 wxString sentence_accumulator;
200 std::shared_ptr<AisTargetData> m_pLatestTargetData;
202 bool m_bAIS_Audio_Alert_On;
203 wxTimer m_AIS_Audio_Alert_Timer;
206 bool m_bGeneralAlert;
207 std::shared_ptr<AisTargetData> m_ptentative_dsctarget;
209 wxString m_dsc_last_string;
210 std::vector<int> m_MMSI_MismatchVec;
212 bool m_bAIS_AlertPlaying;
213 DECLARE_EVENT_TABLE()
EventVar plugin_msg
A JSON message should be sent.
EventVar new_track
Notified on new track creation.
EventVar new_ais_wp
Notified when new AIS wp is created.
EventVar info_update
Notified when AIS user dialogs should update.
EventVar delete_track
Notified when about to delete track.
EventVar touch_state
Notified when gFrame->TouchAISActive() should be invoked.
Generic event handling between between two parties like MVC Model and Controller using a shared Event...
Keeps listening over it's lifespan, removes itself on destruction.