OpenCPN Partial API docs
Loading...
Searching...
No Matches
ais_target_data.h
Go to the documentation of this file.
1/***************************************************************************
2 * Copyright (C) 2010 by David S. Register *
3 * *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
8 * *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
13 * *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, see <https://www.gnu.org/licenses/>. *
16 **************************************************************************/
17
23
24#ifndef AIS_TARGET_DATA_H_
25#define AIS_TARGET_DATA_H_
26
27#include <functional>
28#include <memory>
29#include <vector>
30#include <unordered_map>
31
32#include <wx/datetime.h>
33#include <wx/intl.h>
34#include <wx/string.h>
35
36#include "model/meteo_points.h"
37#include "model/navutil_base.h"
38
39#define SHIP_NAME_LEN 35
40#define DESTINATION_LEN 21
41#define CALL_SIGN_LEN 8
42#define EURO_VIN_LEN 9
43
44#define AIS_TARGETDATA_MAX_CANVAS 6
45
46void make_hash_ERI(int key, const wxString& description);
47void clear_hash_ERI(void);
48
49typedef enum ais_nav_status {
50 UNDERWAY_USING_ENGINE = 0,
51 AT_ANCHOR,
52 NOT_UNDER_COMMAND,
53 RESTRICTED_MANOEUVRABILITY,
54 CONSTRAINED_BY_DRAFT,
55 MOORED,
56 AGROUND,
57 FISHING,
58 UNDERWAY_SAILING,
59 HSC,
60 WIG,
61 RESERVED_11,
62 RESERVED_12,
63 RESERVED_13,
64 RESERVED_14,
65 UNDEFINED,
66 ATON_VIRTUAL,
67 ATON_VIRTUAL_ONPOSITION,
68 ATON_VIRTUAL_OFFPOSITION,
69 ATON_REAL,
70 ATON_REAL_ONPOSITION,
71 ATON_REAL_OFFPOSITION
72
73} _ais_nav_status;
74
75// Describe Transponder Class
76typedef enum ais_transponder_class {
77 AIS_CLASS_A = 0,
78 AIS_CLASS_B,
79 AIS_ATON, // Aid to Navigation pjotrc 2010/02/01
80 AIS_BASE, // Base station
81 AIS_GPSG_BUDDY, // GpsGate Buddy object
82 AIS_DSC, // DSC target
83 AIS_SART, // SART
84 AIS_ARPA, // ARPA radar target
85 AIS_APRS, // APRS position report
86 AIS_METEO, // Meteorological and Hydrographic data
87 AIS_BUOY // Buoy or a similar non standard target
88} _ais_transponder_class;
89
90// Describe AIS Alert state
91typedef enum ais_alert_type {
92 AIS_NO_ALERT = 0,
93 AIS_ALERT_SET,
94 AIS_ALERT_NO_DIALOG_SET
95
96} _ais_alarm_type;
97
99public:
100 double m_lat;
101 double m_lon;
102 time_t m_time;
103};
104
105enum Ais8_001_22_AreaShapeEnum {
106 AIS8_001_22_SHAPE_ERROR = -1,
107 AIS8_001_22_SHAPE_CIRCLE = 0, // OR Point
108 AIS8_001_22_SHAPE_RECT = 1,
109 AIS8_001_22_SHAPE_SECTOR = 2,
110 AIS8_001_22_SHAPE_POLYLINE = 3,
111 AIS8_001_22_SHAPE_POLYGON = 4,
112 AIS8_001_22_SHAPE_TEXT = 5,
113 AIS8_001_22_SHAPE_RESERVED_6 = 6,
114 AIS8_001_22_SHAPE_RESERVED_7 = 7
115};
116
118 int shape;
119 float longitude, latitude;
120 int radius_m;
121 int e_dim_m; // East dimension in meters
122 int n_dim_m;
123 int orient_deg; // Orientation in degrees from true north
124 int left_bound_deg;
125 int right_bound_deg;
126 float angles[4];
127 float dists_m[4];
128 wxString text;
129};
130
131typedef std::vector<Ais8_001_22_SubArea> Ais8_001_22_SubAreaList;
132
134 int link_id; // 10 bit id to match up text blocks
135 int notice_type; // area_type / Notice Description
136 int month; // These are in UTC
137 int day; // UTC!
138 int hour; // UTC!
139 int minute;
140 int duration_minutes; // Time from the start until the notice expires
141 wxDateTime start_time;
142 wxDateTime expiry_time;
143 Ais8_001_22_SubAreaList sub_areas;
144};
145
146struct AisTargetCallbacks {
147 std::function<double(double)> get_mag;
148 AisTargetCallbacks() : get_mag([](double a) { return toMagnetic(a); }) {}
149};
150
151class AisTargetData {
152 friend class AisTargetDataMaker;
153
154public:
155 AisTargetData(AisTargetCallbacks callbacks);
156 ~AisTargetData();
157
158 wxString BuildQueryResult(void);
159 wxString GetRolloverString(void);
160 wxString Get_vessel_type_string(bool b_short = false);
161 wxString Get_class_string(bool b_short = false);
162 wxString GetFullName(void);
163 wxString GetCountryCode(bool b_CntryLongStr);
164 wxString GetNatureofDistress(int dscnature);
165 void Toggle_AIS_CPA(void);
166 void ToggleShowTrack(void);
167 void CloneFrom(AisTargetData* q);
168 bool IsValidMID(int);
169
170 int MID;
171 int MMSI;
172 ais_transponder_class Class;
173 int NavStatus;
174 int SyncState;
175 int SlotTO;
176 double SOG;
177 double COG;
178 double HDG;
179 double Lon;
180 double Lat;
181 double Lat_projected;
182 double Lon_projected;
183 int ROTAIS;
184 int ROTIND;
185 char CallSign[CALL_SIGN_LEN]; // includes terminator
186 char ShipName[SHIP_NAME_LEN];
187 char ShipNameExtension[15];
188 unsigned char ShipType;
189 int IMO;
190
191 int DimA;
192 int DimB;
193 int DimC;
194 int DimD;
195
196 double Euro_Length; // Extensions for European Inland AIS
197 double Euro_Beam;
198 double Euro_Draft;
199 char Euro_VIN[EURO_VIN_LEN]; // includes terminator
200 int UN_shiptype;
201 bool b_isEuroInland;
202 bool b_hasInlandDac; // intermediate storage for EU Inland. SignalK
203 bool b_blue_paddle;
204 int blue_paddle;
205
206 int ETA_Mo;
207 int ETA_Day;
208 int ETA_Hr;
209 int ETA_Min;
210
211 double Draft;
212
213 char Destination[DESTINATION_LEN];
214
215 time_t PositionReportTicks;
216 time_t LastPositionReportTicks;
217 time_t StaticReportTicks;
218 bool b_VDM_secure_Pos; // Prevent VDM msg 27 if we have got a proper position
219
220 int RecentPeriod;
221 bool b_active;
222 bool b_lost;
223 bool b_removed;
224 ais_alert_type n_alert_state;
225 bool b_suppress_audio;
226 bool b_positionDoubtful;
227 bool b_positionOnceValid;
228 bool b_nameValid;
229 bool b_isFollower;
230 bool b_isDSCtarget; // DSC flag to a possible simultaneous AIS target
231 int m_dscNature;
232 int m_dscTXmmsi; // MMSI for the DSC relay issuer
233 long dsc_NatureOfDistress;
234
235 // MMSI Properties
236 bool b_NoTrack;
237 bool b_OwnShip;
238 bool b_PersistTrack; // For AIS target query
239 bool b_mPropPersistTrack; // For mmsi_prop
240
241 int m_utc_hour;
242 int m_utc_min;
243 int m_utc_sec;
244 wxString m_date_string;
245
246 wxDateTime m_ack_time;
247 bool b_in_ack_timeout;
248
249 double Range_NM;
250 double Brg;
251
252 wxString MSG_14_text;
253
254 // Per target collision parameters
255 bool bCPA_Valid;
256 double TCPA; // Minutes
257 double CPA; // Nautical Miles
258 bool b_show_AIS_CPA; // TR 2012.06.28: Show AIS-CPA
259 bool b_show_track;
260 bool b_show_track_old; // Previous state of b_show_track
261
262 AisMeteoData met_data;
263 std::vector<AISTargetTrackPoint> m_ptrack;
264
265 std::unordered_map<int, Ais8_001_22> area_notices;
266 bool b_SarAircraftPosnReport;
267 int altitude; // Metres, from special position report(9)
268 bool b_nameFromCache;
269 float importance;
270 short last_scale[AIS_TARGETDATA_MAX_CANVAS]; // where
271 // AIS_TARGETDATA_MAX_CANVAS is
272 // the max number of chartcanvas
273
274private:
275 AisTargetCallbacks m_callbacks;
276};
277
282
283class AisTargetDataMaker {
284public:
285 static AisTargetDataMaker& GetInstance() {
286 static AisTargetDataMaker instance;
287 return instance;
288 }
289
290 AisTargetDataMaker(const AisTargetDataMaker&) = delete;
291 AisTargetDataMaker& operator=(const AisTargetDataMaker&) = delete;
292
293 std::shared_ptr<AisTargetData> GetTargetData() {
294 return std::make_shared<AisTargetData>(m_callbacks);
295 }
296 void SetCallbacks(AisTargetCallbacks callbacks) { m_callbacks = callbacks; }
297
298private:
299 AisTargetDataMaker() : m_callbacks(AisTargetCallbacks()) {}
300 AisTargetCallbacks m_callbacks;
301};
302
303wxString trimAISField(char* data);
304wxString ais_get_status(int index);
305
306wxString ais_get_type(int index);
307wxString ais_get_short_type(int index);
308
309#endif
Meteo points are Meteorological and Hydrographic data received by NMEA0183 (AIS) VDM message 8 dac:00...
Navigation Utility Functions without GUI dependencies.