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
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
147 std::function<double(double)> get_mag;
148 AisTargetCallbacks() : get_mag([](double a) { return toMagnetic(a); }) {}
149};
150
152 friend class AisTargetDataMaker;
153
154public:
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 int ROTAIS;
182 int ROTIND;
183 char CallSign[CALL_SIGN_LEN]; // includes terminator
184 char ShipName[SHIP_NAME_LEN];
185 char ShipNameExtension[15];
186 unsigned char ShipType;
187 int IMO;
188
189 int DimA;
190 int DimB;
191 int DimC;
192 int DimD;
193
194 double Euro_Length; // Extensions for European Inland AIS
195 double Euro_Beam;
196 double Euro_Draft;
197 char Euro_VIN[EURO_VIN_LEN]; // includes terminator
198 int UN_shiptype;
199 bool b_isEuroInland;
200 bool b_hasInlandDac; // intermediate storage for EU Inland. SignalK
201 bool b_blue_paddle;
202 int blue_paddle;
203
204 int ETA_Mo;
205 int ETA_Day;
206 int ETA_Hr;
207 int ETA_Min;
208
209 double Draft;
210
211 char Destination[DESTINATION_LEN];
212
213 time_t PositionReportTicks;
214 time_t LastPositionReportTicks;
215 time_t StaticReportTicks;
216
217 int RecentPeriod;
218 bool b_active;
219 bool b_lost;
220 bool b_removed;
221 ais_alert_type n_alert_state;
222 bool b_suppress_audio;
223 bool b_positionDoubtful;
224 bool b_positionOnceValid;
225 bool b_nameValid;
226 bool b_isFollower;
227 bool b_isDSCtarget; // DSC flag to a possible simultaneous AIS target
228 int m_dscNature;
229 int m_dscTXmmsi; // MMSI for the DSC relay issuer
230 long dsc_NatureOfDistress;
231
232 // MMSI Properties
233 bool b_NoTrack;
234 bool b_OwnShip;
235 bool b_PersistTrack; // For AIS target query
236 bool b_mPropPersistTrack; // For mmsi_prop
237
238 int m_utc_hour;
239 int m_utc_min;
240 int m_utc_sec;
241 wxString m_date_string;
242
243 wxDateTime m_ack_time;
244 bool b_in_ack_timeout;
245
246 double Range_NM;
247 double Brg;
248
249 wxString MSG_14_text;
250
251 // Per target collision parameters
252 bool bCPA_Valid;
253 double TCPA; // Minutes
254 double CPA; // Nautical Miles
255 bool b_show_AIS_CPA; // TR 2012.06.28: Show AIS-CPA
256 bool b_show_track;
257 bool b_show_track_old; // Previous state of b_show_track
258
259 AisMeteoData met_data;
260 std::vector<AISTargetTrackPoint> m_ptrack;
261
262 std::unordered_map<int, Ais8_001_22> area_notices;
263 bool b_SarAircraftPosnReport;
264 int altitude; // Metres, from special position report(9)
265 bool b_nameFromCache;
266 float importance;
267 short last_scale[AIS_TARGETDATA_MAX_CANVAS]; // where
268 // AIS_TARGETDATA_MAX_CANVAS is
269 // the max number of chartcanvas
270
271private:
272 AisTargetCallbacks m_callbacks;
273};
274
281public:
282 static AisTargetDataMaker& GetInstance() {
283 static AisTargetDataMaker instance;
284 return instance;
285 }
286
287 AisTargetDataMaker(const AisTargetDataMaker&) = delete;
288 AisTargetDataMaker& operator=(const AisTargetDataMaker&) = delete;
289
290 std::shared_ptr<AisTargetData> GetTargetData() {
291 return std::make_shared<AisTargetData>(m_callbacks);
292 }
293 void SetCallbacks(AisTargetCallbacks callbacks) { m_callbacks = callbacks; }
294
295private:
296 AisTargetDataMaker() : m_callbacks(AisTargetCallbacks()) {}
297 AisTargetCallbacks m_callbacks;
298};
299
300wxString trimAISField(char* data);
301wxString ais_get_status(int index);
302
303wxString ais_get_type(int index);
304wxString ais_get_short_type(int index);
305
306#endif
Singleton factory.
Meteo points are Meteorological and Hydrographic data received by NMEA0183 (AIS) VDM message 8 dac:00...
Navigation Utility Functions without GUI dependencies.