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
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} ConnectionType;
51
52typedef enum {
53 TCP = 0,
54 UDP = 1,
55 GPSD = 2,
56 SIGNALK = 3,
57 PROTO_UNDEFINED = 4
58} NetworkProtocol;
59
60typedef enum { WHITELIST = 0, BLACKLIST = 1 } ListType;
61
62typedef enum { FILTER_INPUT = 0, FILTER_OUTPUT = 1 } FilterDirection;
63
64typedef enum {
65 PROTO_NMEA0183 = 0,
66 PROTO_NMEA2000 = 1,
67 PROTO_SIGNALK = 2
68} DataProtocol;
69
71
76public:
78 explicit ConnectionParams(const wxString &config_str);
80
81 ConnectionType type;
82 NetworkProtocol net_protocol;
83 DataProtocol data_protocol;
84 wxString network_address;
85 int network_port;
86 wxString serial_port;
87 wxString socket_can_port;
88 PortDirection direction;
89 DataProtocol last_data_protocol;
90 NetworkProtocol last_net_protocol;
91
92 bool auto_sk_discover;
93 bool checksum_check;
94 bool disable_echo;
95 bool FurunoGP3X; // Unused placeholder?
96 bool GarminUpload; // Unused placeholder?
97 bool is_enabled;
98 bool is_garmin;
99 bool is_server;
100 bool is_setup;
101 bool is_valid;
102 bool no_data_reconnect;
103 int baudrate;
104 int last_network_port;
105 ListType input_sentence_list_type;
106 ListType output_sentence_list_type;
107 wxArrayString input_sentence_list;
108 wxArrayString output_sentence_list;
109 wxString auth_token;
110 wxString last_network_address;
111 wxString user_comment;
112
113 ConnectionParamsPanel *options_panel;
114
116 [[nodiscard]] std::string GetKey() const;
117
118 [[nodiscard]] wxString Serialize() const;
119 void Deserialize(const wxString &config_str);
120
122 [[nodiscard]] wxString GetPortDirectionValueStr() const;
123
128 [[nodiscard]] wxString GetDSPort() const;
129
131 [[nodiscard]] bool IsPortValid() const;
132
137 [[nodiscard]] std::string GetLastDSPort() const;
138
143 [[nodiscard]] NavAddr::Bus GetCommProtocol() const;
144
149 [[nodiscard]] NavAddr::Bus GetLastCommProtocol() const;
150
155 [[nodiscard]] std::string GetStrippedDSPort() const;
156
158 [[nodiscard]] bool SentencePassesFilter(const wxString &sentence,
159 FilterDirection direction) const;
160};
161
163std::vector<ConnectionParams *> &TheConnectionParams();
164
165#endif
Panel for displaying and editing connection parameters.
Connection data container close to a POD struct.
Definition conn_params.h:75
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.