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