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} DataProtocol;
70
72
76class ConnectionParams {
77public:
78 ConnectionParams();
79 explicit ConnectionParams(const wxString &config_str);
80 ~ConnectionParams();
81
82 ConnectionType type;
83 NetworkProtocol net_protocol;
84 DataProtocol data_protocol;
85 wxString network_address;
86 int network_port;
87 wxString serial_port;
88 wxString socket_can_port;
89 PortDirection direction;
90 DataProtocol last_data_protocol;
91 NetworkProtocol last_net_protocol;
92
93 bool auto_sk_discover;
94 bool checksum_check;
95 bool disable_echo;
96 bool FurunoGP3X; // Unused placeholder?
97 bool GarminUpload; // Unused placeholder?
98 bool is_enabled;
99 bool is_garmin;
100 bool is_server;
101 bool is_setup;
102 bool is_valid;
103 bool no_data_reconnect;
104 int baudrate;
105 int last_network_port;
106 ListType input_sentence_list_type;
107 ListType output_sentence_list_type;
108 wxArrayString input_sentence_list;
109 wxArrayString output_sentence_list;
110 wxString auth_token;
111 wxString last_network_address;
112 wxString user_comment;
113
114 ConnectionParamsPanel *options_panel;
115
117 [[nodiscard]] std::string GetKey() const;
118
119 [[nodiscard]] wxString Serialize() const;
120 void Deserialize(const wxString &config_str);
121
123 [[nodiscard]] wxString GetPortDirectionValueStr() const;
124
129 [[nodiscard]] wxString GetDSPort() const;
130
132 [[nodiscard]] bool IsPortValid() const;
133
138 [[nodiscard]] std::string GetLastDSPort() const;
139
144 [[nodiscard]] NavAddr::Bus GetCommProtocol() const;
145
150 [[nodiscard]] NavAddr::Bus GetLastCommProtocol() const;
151
156 [[nodiscard]] std::string GetStrippedDSPort() const;
157
159 [[nodiscard]] bool SentencePassesFilter(const wxString &sentence,
160 FilterDirection direction) const;
161};
162
164std::vector<ConnectionParams *> &TheConnectionParams();
165
166#endif
Panel for displaying and editing connection parameters.
Connection data container close to a POD struct.
Definition conn_params.h:76
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.