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 <vector>
30
31#include <wx/string.h>
32#include <wx/datetime.h>
33#include <unordered_map>
34#include <memory>
35
36#define SHIP_NAME_LEN 35
37#define DESTINATION_LEN 21
38#define CALL_SIGN_LEN 8
39#define EURO_VIN_LEN 9
40
41#define AIS_TARGETDATA_MAX_CANVAS 6
42
43void make_hash_ERI(int key, const wxString& description);
44void clear_hash_ERI(void);
45
46typedef enum ais_nav_status {
47 UNDERWAY_USING_ENGINE = 0,
48 AT_ANCHOR,
49 NOT_UNDER_COMMAND,
50 RESTRICTED_MANOEUVRABILITY,
51 CONSTRAINED_BY_DRAFT,
52 MOORED,
53 AGROUND,
54 FISHING,
55 UNDERWAY_SAILING,
56 HSC,
57 WIG,
58 RESERVED_11,
59 RESERVED_12,
60 RESERVED_13,
61 RESERVED_14,
62 UNDEFINED,
63 ATON_VIRTUAL,
64 ATON_VIRTUAL_ONPOSITION,
65 ATON_VIRTUAL_OFFPOSITION,
66 ATON_REAL,
67 ATON_REAL_ONPOSITION,
68 ATON_REAL_OFFPOSITION
69
70} _ais_nav_status;
71
72
73// Describe Transponder Class
74typedef enum ais_transponder_class {
75 AIS_CLASS_A = 0,
76 AIS_CLASS_B,
77 AIS_ATON, // Aid to Navigation pjotrc 2010/02/01
78 AIS_BASE, // Base station
79 AIS_GPSG_BUDDY, // GpsGate Buddy object
80 AIS_DSC, // DSC target
81 AIS_SART, // SART
82 AIS_ARPA, // ARPA radar target
83 AIS_APRS // APRS position report
84} _ais_transponder_class;
85
86
87// Describe AIS Alert state
88typedef enum ais_alert_type {
89 AIS_NO_ALERT = 0,
90 AIS_ALERT_SET,
91 AIS_ALERT_NO_DIALOG_SET
92
93} _ais_alarm_type;
94
96public:
97 double m_lat;
98 double m_lon;
99 time_t m_time;
100};
101
102enum Ais8_001_22_AreaShapeEnum {
103 AIS8_001_22_SHAPE_ERROR = -1,
104 AIS8_001_22_SHAPE_CIRCLE = 0, // OR Point
105 AIS8_001_22_SHAPE_RECT = 1,
106 AIS8_001_22_SHAPE_SECTOR = 2,
107 AIS8_001_22_SHAPE_POLYLINE = 3,
108 AIS8_001_22_SHAPE_POLYGON = 4,
109 AIS8_001_22_SHAPE_TEXT = 5,
110 AIS8_001_22_SHAPE_RESERVED_6 = 6,
111 AIS8_001_22_SHAPE_RESERVED_7 = 7
112};
113
115 int shape;
116 float longitude, latitude;
117 int radius_m;
118 int e_dim_m; // East dimension in meters
119 int n_dim_m;
120 int orient_deg; // Orientation in degrees from true north
121 int left_bound_deg;
122 int right_bound_deg;
123 float angles[4];
124 float dists_m[4];
125 wxString text;
126};
127
128typedef std::vector<Ais8_001_22_SubArea> Ais8_001_22_SubAreaList;
129
131 int link_id; // 10 bit id to match up text blocks
132 int notice_type; // area_type / Notice Description
133 int month; // These are in UTC
134 int day; // UTC!
135 int hour; // UTC!
136 int minute;
137 int duration_minutes; // Time from the start until the notice expires
138 wxDateTime start_time;
139 wxDateTime expiry_time;
140 Ais8_001_22_SubAreaList sub_areas;
141};
142
144 std::function<double(double)> get_mag;
145 AisTargetCallbacks(): get_mag([](double a) { return 1.0; }) {}
146};
147
148
150friend class AisTargetDataMaker;
151
152public:
155
156 wxString BuildQueryResult(void);
157 wxString GetRolloverString(void);
158 wxString Get_vessel_type_string(bool b_short = false);
159 wxString Get_class_string(bool b_short = false);
160 wxString GetFullName(void);
161 wxString GetCountryCode(bool b_CntryLongStr);
162 wxString GetNatureofDistress(int dscnature);
163 void Toggle_AIS_CPA(void);
164 void ToggleShowTrack(void);
165 void CloneFrom(AisTargetData* q);
166
167 int MID;
168 int MMSI;
169 ais_transponder_class Class;
170 int NavStatus;
171 int SyncState;
172 int SlotTO;
173 double SOG;
174 double COG;
175 double HDG;
176 double Lon;
177 double Lat;
178 int ROTAIS;
179 int ROTIND;
180 char CallSign[CALL_SIGN_LEN]; // includes terminator
181 char ShipName[SHIP_NAME_LEN];
182 char ShipNameExtension[15];
183 unsigned char ShipType;
184 int IMO;
185
186 int DimA;
187 int DimB;
188 int DimC;
189 int DimD;
190
191 double Euro_Length; // Extensions for European Inland AIS
192 double Euro_Beam;
193 double Euro_Draft;
194 char Euro_VIN[EURO_VIN_LEN]; // includes terminator
195 int UN_shiptype;
196 bool b_isEuroInland;
197 bool b_hasInlandDac; // intermediate storage for EU Inland. SignalK
198 bool b_blue_paddle;
199 int blue_paddle;
200
201 int ETA_Mo;
202 int ETA_Day;
203 int ETA_Hr;
204 int ETA_Min;
205
206 double Draft;
207
208 char Destination[DESTINATION_LEN];
209
210 time_t PositionReportTicks;
211 time_t StaticReportTicks;
212
213 int RecentPeriod;
214 bool b_active;
215 bool b_lost;
216 bool b_removed;
217 ais_alert_type n_alert_state;
218 bool b_suppress_audio;
219 bool b_positionDoubtful;
220 bool b_positionOnceValid;
221 bool b_nameValid;
222 bool b_isFollower;
223 bool b_isDSCtarget; // DSC flag to a possible simultaneous AIS target
224 int m_dscNature;
225 int m_dscTXmmsi; // MMSI for the DSC relay issuer
226
227 // MMSI Properties
228 bool b_NoTrack;
229 bool b_OwnShip;
230 bool b_PersistTrack; // For AIS target query
231 bool b_mPropPersistTrack; // For mmsi_prop
232
233 int m_utc_hour;
234 int m_utc_min;
235 int m_utc_sec;
236 wxString m_date_string;
237
238 wxDateTime m_ack_time;
239 bool b_in_ack_timeout;
240
241 double Range_NM;
242 double Brg;
243
244 wxString MSG_14_text;
245
246 // Per target collision parameters
247 bool bCPA_Valid;
248 double TCPA; // Minutes
249 double CPA; // Nautical Miles
250
251 bool b_show_AIS_CPA; // TR 2012.06.28: Show AIS-CPA
252
253 bool b_show_track;
254
255 std::vector<AISTargetTrackPoint> m_ptrack;
256
257 std::unordered_map<int, Ais8_001_22> area_notices;
258 bool b_SarAircraftPosnReport;
259 int altitude; // Metres, from special position report(9)
260 bool b_nameFromCache;
261 float importance;
262 short last_scale[AIS_TARGETDATA_MAX_CANVAS]; // where
263 // AIS_TARGETDATA_MAX_CANVAS is
264 // the max number of chartcanvas
265 long dsc_NatureOfDistress;
266
267private:
268 AisTargetCallbacks m_callbacks;
269};
270
277public:
278 static AisTargetDataMaker& GetInstance() {
279 static AisTargetDataMaker instance;
280 return instance;
281 }
282
283 AisTargetDataMaker(const AisTargetDataMaker&) = delete;
284 AisTargetDataMaker& operator=(const AisTargetDataMaker&) = delete;
285
286
287 std::shared_ptr<AisTargetData> GetTargetData() { return std::make_shared<AisTargetData>(m_callbacks); }
288 void SetCallbacks(AisTargetCallbacks callbacks) { m_callbacks = callbacks; }
289
290private:
291 AisTargetDataMaker() : m_callbacks(AisTargetCallbacks()) {}
292 AisTargetCallbacks m_callbacks;
293};
294
295
296wxString trimAISField(char *data);
297wxString ais_get_status(int index);
298
299wxString ais_get_type(int index);
300wxString ais_get_short_type(int index);
301
302#endif
Singleton factory.