25 #ifndef _AIS_DECODER_H__
26 #define _AIS_DECODER_H__
29 #include <unordered_map>
33 #include <wx/datetime.h>
35 #include <wx/string.h>
37 #include "rapidjson/fwd.h"
38 #include "model/ais_bitstring.h"
39 #include "model/ais_defs.h"
40 #include "model/ais_target_data.h"
41 #include "model/comm_navmsg.h"
42 #include "model/ocpn_types.h"
43 #include "model/select.h"
44 #include "model/track.h"
45 #include "observable_evtvar.h"
48 class ArrayOfMmsiProperties;
51 extern wxEvtHandler* g_pais_alert_dialog_active;
54 extern wxString AISTargetNameFileName;
56 extern ArrayOfMmsiProperties g_MMSI_Props_Array;
58 enum AISAudioSoundType {
85 bool m_bPersistentTrack;
93 std::function<bool()> confirm_stop_track;
94 std::function<int()> get_target_mmsi;
96 : confirm_stop_track([]() {
return true; } ),
97 get_target_mmsi([]() {
return 0; }) {}
106 AisError DecodeN0183(
const wxString &str);
107 std::unordered_map<int, std::shared_ptr <AisTargetData>> &GetTargetList(
void) {
108 return AISTargetList;
110 std::unordered_map<int, std::shared_ptr <AisTargetData>> &GetAreaNoticeSourcesList(
void) {
111 return AIS_AreaNotice_Sources;
113 std::shared_ptr<AisTargetData> Get_Target_Data_From_MMSI(
int mmsi);
114 int GetNumTargets(
void) {
return m_n_targets; }
115 bool IsAISSuppressed(
void) {
return m_bSuppressed; }
116 bool IsAISAlertGeneral(
void) {
return m_bGeneralAlert; }
119 void DeletePersistentTrack(
Track *track);
120 std::map<int, Track *> m_persistent_tracks;
121 bool AIS_AlertPlaying(
void) {
return m_bAIS_AlertPlaying; };
145 void OnActivate(wxActivateEvent &event);
146 void OnTimerAIS(wxTimerEvent &event);
147 void OnTimerDSC(wxTimerEvent &event);
149 bool NMEACheckSumOK(
const wxString &str);
150 bool Parse_VDXBitstring(
AisBitstring *bstr, std::shared_ptr<AisTargetData> ptd);
151 void UpdateAllCPA(
void);
153 void UpdateAllAlarms(
void);
154 void UpdateAllTracks(
void);
156 void BuildERIShipTypeHash(
void);
157 std::shared_ptr<AisTargetData> ProcessDSx(
const wxString &str,
bool b_take_dsc =
false);
159 wxString DecodeDSEExpansionCharacters(wxString dseData);
160 void getAISTarget(
long mmsi, std::shared_ptr<AisTargetData> &pTargetData,
161 std::shared_ptr<AisTargetData> &pStaleTarget,
bool &bnewtarget,
162 int &last_report_ticks, wxDateTime &now);
163 void getMmsiProperties(std::shared_ptr<AisTargetData> &pTargetData);
164 void handleUpdate(std::shared_ptr<AisTargetData> pTargetData,
bool bnewtarget,
165 const rapidjson::Value &update);
166 void updateItem(std::shared_ptr<AisTargetData> pTargetData,
bool bnewtarget,
167 const rapidjson::Value &item, wxString &sfixtime)
const;
168 void CommitAISTarget( std::shared_ptr<AisTargetData> pTargetData,
169 const wxString &str,
bool message_valid,
171 void InitCommListeners(
void);
172 bool HandleN0183_AIS( std::shared_ptr <const Nmea0183Msg> n0183_msg );
173 void HandleSignalK(std::shared_ptr<const SignalkMsg> sK_msg);
175 bool HandleN2K_129038( std::shared_ptr<const Nmea2000Msg> n2k_msg );
176 bool HandleN2K_129039( std::shared_ptr<const Nmea2000Msg> n2k_msg );
177 bool HandleN2K_129041( std::shared_ptr<const Nmea2000Msg> n2k_msg );
178 bool HandleN2K_129794( std::shared_ptr<const Nmea2000Msg> n2k_msg );
179 bool HandleN2K_129809( std::shared_ptr<const Nmea2000Msg> n2k_msg );
180 bool HandleN2K_129810( std::shared_ptr<const Nmea2000Msg> n2k_msg );
181 bool HandleN2K_129793( std::shared_ptr<const Nmea2000Msg> n2k_msg );
183 wxString m_signalk_selfid;
184 std::unordered_map<int, std::shared_ptr<AisTargetData>> AISTargetList;
185 std::unordered_map<int, std::shared_ptr<AisTargetData>> AIS_AreaNotice_Sources;
186 AIS_Target_Name_Hash *AISTargetNamesC;
187 AIS_Target_Name_Hash *AISTargetNamesNC;
209 wxFrame *m_parent_frame;
214 wxString sentence_accumulator;
217 std::shared_ptr<AisTargetData> m_pLatestTargetData;
219 bool m_bAIS_Audio_Alert_On;
220 wxTimer m_AIS_Audio_Alert_Timer;
223 bool m_bGeneralAlert;
224 std::shared_ptr<AisTargetData> m_ptentative_dsctarget;
226 wxString m_dsc_last_string;
227 std::vector<int> m_MMSI_MismatchVec;
229 bool m_bAIS_AlertPlaying;
230 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 MVC Model and Controller based on a shared EventVar variable.
Keeps listening over it's lifespan, removes itself on destruction.