OpenCPN Partial API docs
conn_params.h
1 /***************************************************************************
2  *
3  * Project: OpenCPN
4  *
5  ***************************************************************************
6  * Copyright (C) 2013 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 #ifndef _CONNECTIONPARAMS_H__
25 #define _CONNECTIONPARAMS_H__
26 
27 #include <wx/wxprec.h>
28 
29 #ifndef __DSPORTTYPE_H__
30 #include "model/ds_porttype.h"
31 #endif
32 
33 
34 #ifndef WX_PRECOMP
35 #include <wx/arrstr.h>
36 #include <wx/dynarray.h>
37 #include <wx/string.h>
38 #endif // precompiled headers
39 
40 #include "model/comm_navmsg.h"
41 
42 class ConnectionParams;
43 class ConnectionsDialog;
44 
45 typedef enum {
46  SERIAL = 0,
47  NETWORK = 1,
48  INTERNAL_GPS = 2,
49  INTERNAL_BT = 3,
50  SOCKETCAN = 4,
51  UNKNOWN = 5
52 } ConnectionType;
53 
54 typedef enum {
55  TCP = 0,
56  UDP = 1,
57  GPSD = 2,
58  SIGNALK = 3,
59  PROTO_UNDEFINED = 4
60 } NetworkProtocol;
61 
62 typedef enum { WHITELIST = 0, BLACKLIST = 1 } ListType;
63 
64 typedef enum { FILTER_INPUT = 0, FILTER_OUTPUT = 1 } FilterDirection;
65 
66 typedef enum {
67  PROTO_NMEA0183 = 0,
68  PROTO_NMEA2000 = 1,
69  PROTO_SIGNALK = 2
70 } DataProtocol;
71 
72 #define CONN_ENABLE_ID 47621
73 
74 
76 
78 public:
81  ConnectionParams(const wxString &configStr);
82 
83  ConnectionType Type;
84  NetworkProtocol NetProtocol;
85  wxString NetworkAddress;
86  int NetworkPort;
87 
88  wxString LastNetworkAddress;
89  int LastNetworkPort;
90  NetworkProtocol LastNetProtocol;
91  DataProtocol LastDataProtocol;
92 
93  DataProtocol Protocol;
94  wxString Port;
95  wxString socketCAN_port;
96  int Baudrate;
97  bool NoDataReconnect;
98  bool DisableEcho;
99  bool ChecksumCheck;
100  bool Garmin;
101  bool GarminUpload;
102  bool FurunoGP3X;
103  bool AutoSKDiscover;
104  dsPortType IOSelect;
105  ListType InputSentenceListType;
106  wxArrayString InputSentenceList;
107  ListType OutputSentenceListType;
108  wxArrayString OutputSentenceList;
109  int Priority;
110  bool bEnabled;
111  wxString UserComment;
112  wxString AuthToken;
113 
114  wxString Serialize() const;
115  void Deserialize(const wxString &configStr);
116 
117  wxString GetSourceTypeStr() const;
118  wxString GetAddressStr() const;
119  wxString GetParametersStr() const;
120  wxString GetIOTypeValueStr() const;
121  wxString GetFiltersStr() const;
122  wxString GetDSPort() const;
123  std::string GetLastDSPort() const;
124  NavAddr::Bus GetLastCommProtocol();
125  wxString GetPortStr() const { return Port; }
126  void SetPortStr(wxString str) { Port = str; }
127  std::string GetStrippedDSPort();
128  NavAddr::Bus GetCommProtocol();
129 
130  bool SentencePassesFilter(const wxString& sentence, FilterDirection direction);
131 
132  bool Valid;
133  bool b_IsSetup;
134  ConnectionParamsPanel *m_optionsPanel;
135 
136 private:
137  wxString FilterTypeToStr(ListType type, FilterDirection dir) const;
138 };
139 
140 WX_DEFINE_ARRAY(ConnectionParams *, wxArrayOfConnPrm);
141 
142 wxArrayOfConnPrm* TheConnectionParams();
143 
144 #endif