OpenCPN Partial API docs
Loading...
Searching...
No Matches
conn_params.h
Go to the documentation of this file.
1/***************************************************************************
2 * Copyright (C) 2013 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 CONNECTIONPARAMS_H_
25#define CONNECTIONPARAMS_H_
26
27#ifndef WX_PRECOMP
28#include <wx/arrstr.h>
29#include <wx/string.h>
30#endif
31
32#include "model/comm_navmsg.h"
33
34#ifndef __DSPORTTYPE_H__
35#include "model/ds_porttype.h"
36#endif
37
38#define CONN_ENABLE_ID 47621
39
40class ConnectionParams; // forward
41class ConnectionsDialog; // Indirectly unused FIXME (leamas) remove
42
43typedef enum {
44 SERIAL = 0,
45 NETWORK = 1,
46 INTERNAL_GPS = 2,
47 INTERNAL_BT = 3,
48 SOCKETCAN = 4,
49 UNKNOWN = 5,
50 CANABLE = 6
51} ConnectionType;
52
53typedef enum {
54 TCP = 0,
55 UDP = 1,
56 GPSD = 2,
57 SIGNALK = 3,
58 PROTO_UNDEFINED = 4
59} NetworkProtocol;
60
61typedef enum { WHITELIST = 0, BLACKLIST = 1 } ListType;
62
63typedef enum { FILTER_INPUT = 0, FILTER_OUTPUT = 1 } FilterDirection;
64
65typedef enum {
66 PROTO_NMEA0183 = 0,
67 PROTO_NMEA2000 = 1,
68 PROTO_SIGNALK = 2,
69 PROTO_GPSD = 3
70} DataProtocol;
71
73
77class ConnectionParams {
78public:
79 ConnectionParams();
80 explicit ConnectionParams(const wxString &config_str);
81 ~ConnectionParams();
82
83 ConnectionType type;
84 NetworkProtocol net_protocol;
85 DataProtocol data_protocol;
86 wxString network_address;
87 int network_port;
88 wxString serial_port;
89 wxString socket_can_port;
90 PortDirection direction;
91 DataProtocol last_data_protocol;
92 NetworkProtocol last_net_protocol;
93
94 bool auto_sk_discover;
95 bool checksum_check;
96 bool disable_echo;
97 bool FurunoGP3X; // Unused placeholder?
98 bool GarminUpload; // Unused placeholder?
99 bool is_enabled;
100 bool is_garmin;
101 bool is_server;
102 bool is_setup;
103 bool is_valid;
104 bool no_data_reconnect;
105 int baudrate;
106 int last_network_port;
107 ListType input_sentence_list_type;
108 ListType output_sentence_list_type;
109 wxArrayString input_sentence_list;
110 wxArrayString output_sentence_list;
111 wxString auth_token;
112 wxString last_network_address;
113 wxString user_comment;
114
115 ConnectionParamsPanel *options_panel;
116
118 [[nodiscard]] std::string GetKey() const;
119
120 [[nodiscard]] wxString Serialize() const;
121 void Deserialize(const wxString &config_str);
122
124 [[nodiscard]] wxString GetPortDirectionValueStr() const;
125
130 [[nodiscard]] wxString GetDSPort() const;
131
133 [[nodiscard]] bool IsPortValid() const;
134
139 [[nodiscard]] std::string GetLastDSPort() const;
140
145 [[nodiscard]] NavAddr::Bus GetCommProtocol() const;
146
151 [[nodiscard]] NavAddr::Bus GetLastCommProtocol() const;
152
157 [[nodiscard]] std::string GetStrippedDSPort() const;
158
160 [[nodiscard]] bool SentencePassesFilter(const wxString &sentence,
161 FilterDirection direction) const;
162};
163
165std::vector<ConnectionParams *> &TheConnectionParams();
166
167#endif
Panel for displaying and editing connection parameters.
Connection data container close to a POD struct.
Definition conn_params.h:77
bool IsPortValid() const
Return true if port data like com port or network address are sane.
bool SentencePassesFilter(const wxString &sentence, FilterDirection direction) const
Return true if given sentence and direction passes connection filters.
std::string GetStrippedDSPort() const
Return port string with possible windows extra data removed, in some cases empty.
std::string GetKey() const
Return string unique for each instance.
NavAddr::Bus GetLastCommProtocol() const
Return NavAddr::Bus corresponding to last known network address/port or serial parameters.
std::string GetLastDSPort() const
Return Last known network "address:protocol:port" for network connections, else "Serial: <port>".
wxString GetDSPort() const
Return port description including for example serial port or network address/port,...
wxString GetPortDirectionValueStr() const
Return translated name for direction, like _("Input").
NavAddr::Bus GetCommProtocol() const
Return NavAddr::Bus corresponding to network address/port or serial parameters.
Raw, undecoded messages definitions.
std::vector< ConnectionParams * > & TheConnectionParams()
Return global list of connections.
Port type definition and support.