OpenCPN Partial API docs
Loading...
Searching...
No Matches
connection_edit.h
Go to the documentation of this file.
1/**************************************************************************
2 * Copyright (C) 2022 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, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
18 ***************************************************************************
19 */
20
26#ifndef _CONNECT_EDIT_H
27#define _CONNECT_EDIT_H
28
29#include <wx/checkbox.h>
30#include <wx/listctrl.h>
31#include <wx/radiobut.h>
32#include <wx/stattext.h>
33#include <wx/timer.h>
34
35#include "model/conn_params.h"
36#include "model/comm_util.h"
37
38#include "observable.h"
39
40class options;
42
47class ConnectionEditDialog : public wxDialog {
48public:
49 const wxString DEFAULT_TCP_PORT = "10110";
50 const wxString DEFAULT_UDP_PORT = "10110";
51 const wxString DEFAULT_GPSD_PORT = "2947";
52 const wxString DEFAULT_SIGNALK_PORT = "3000";
53 const wxString DEFAULT_IP_ADDRESS = "localhost";
54 // "LIMITED BROADCAST" address
55 // Deprecated, but still useful on simple mobile networks.
56 const wxString DEFAULT_UDP_OUT_ADDRESS = "255.255.255.255";
57
59 ConnectionEditDialog(wxWindow *parent);
60
62
63 void Init(void);
64 void SetInitialSettings(void);
65 void PreloadControls(ConnectionParams *cp);
66 ConnectionParams *GetParamsFromControls();
67 void SetPropsLabel(wxString label);
68
69 void ApplySettings();
70 ConnectionParams *CreateConnectionParamsFromSelectedItem();
71 ConnectionParams *UpdateConnectionParamsFromControls(
72 ConnectionParams *pConnectionParams);
73 void SetSelectedConnectionPanel(ConnectionParamsPanel *panel);
74 void OnSelectDatasource(wxListEvent &event);
75 void OnAddDatasourceClick(wxCommandEvent &event);
76 void OnRemoveDatasourceClick(wxCommandEvent &event);
77
78 void OnTypeSerialSelected(wxCommandEvent &event);
79 void OnTypeNetSelected(wxCommandEvent &event);
80 void OnTypeGPSSelected(wxCommandEvent &event);
81 void OnTypeBTSelected(wxCommandEvent &event);
82 void OnTypeCANSelected(wxCommandEvent &event);
83
84 void OnNetProtocolSelected(wxCommandEvent &event);
85 void OnBaudrateChoice(wxCommandEvent &event) { OnConnValChange(event); }
86 void OnProtocolChoice(wxCommandEvent &event);
87 void OnCrcCheck(wxCommandEvent &event) { OnConnValChange(event); }
88 void OnRbAcceptInput(wxCommandEvent &event);
89 void OnRbIgnoreInput(wxCommandEvent &event);
90 void OnBtnIStcs(wxCommandEvent &event);
91 void OnCbInput(wxCommandEvent &event);
92 void OnCbOutput(wxCommandEvent &event);
93 void OnCbMultiCast(wxCommandEvent &event);
94 void OnCbAdvanced(wxCommandEvent &event);
95 void OnClickMore(wxMouseEvent &event);
96 void OnRbOutput(wxCommandEvent &event);
97 void OnBtnOStcs(wxCommandEvent &event);
98 void OnConnValChange(wxCommandEvent &event);
99 void OnValChange(wxCommandEvent &event);
100 void OnUploadFormatChange(wxCommandEvent &event);
101 void OnShowGpsWindowCheckboxClick(wxCommandEvent &event);
102 void EnableConnection(ConnectionParams *conn, bool value);
103 void OnDiscoverButton(wxCommandEvent &event);
104 void UpdateDiscoverStatus(wxString stat);
105 void OnPriorityDialog(wxCommandEvent &event);
106
107 void SetConnectionParams(ConnectionParams *cp);
108 void SetDefaultConnectionParams(void);
109 void SetDSFormRWStates();
110 void SetDSFormOptionVizStates();
111 void FillSourceList();
112 void UpdateSourceList(bool bResort);
113 bool SortSourceList(void);
114 void SetUDPNetAddressVisiblity(void);
115 bool IsAddressMultiCast(wxString ip);
116 bool IsAddressBroadcast(wxString ip);
117 bool IsDefaultPort(wxString address);
118
119 void ClearNMEAForm(void);
120 void SetNMEAFormToSerial(void);
121 void SetNMEAFormToNet(void);
122 void SetNMEAFormToGPS(void);
123 void SetNMEAFormToBT(void);
124 void SetNMEAFormToCAN(void);
125 void SetNMEAFormForSerialProtocol();
126 void SetNMEAFormForNetProtocol();
127
128 void ShowTypeCommon(bool visible = true);
129 void ShowNMEACommon(bool visible);
130 void ShowNMEASerial(bool visible);
131 void ShowNMEANet(bool visible);
132 void ShowNMEAGPS(bool visible);
133 void ShowNMEABT(bool visible);
134 void ShowNMEACAN(bool visible);
135
136 void OnScanBTClick(wxCommandEvent &event);
137 void onBTScanTimer(wxTimerEvent &event);
138 void StopBTScan(void);
139
140 void OnWheelChoice(wxMouseEvent &event);
141
142 void ShowInFilter(bool bshow = true);
143 void ShowOutFilter(bool bshow = true);
144 void LayoutDialog();
145
146 void CreateControls();
147 void ConnectControls();
148
149 // private:
150 wxWindow *m_parent;
151 wxScrolledWindow *m_scrolledwin;
152
153 wxGridSizer *gSizerNetProps, *gSizerSerProps, *gSizerCanProps;
154 wxTextCtrl *m_tNetAddress, *m_tNetPort, *m_tFilterSec, *m_tcInputStc;
155 wxTextCtrl *m_tcOutputStc;
156 wxCheckBox *m_cbCheckCRC, *m_cbGarminHost, *m_cbGarminUploadHost,
157 *m_cbCheckSKDiscover;
158 wxCheckBox *m_cbFurunoGP3X, *m_cbNMEADebug, *m_cbFilterSogCog, *m_cbInput;
159 wxCheckBox *m_cbMultiCast, *m_cbAdvanced;
160 wxCheckBox *m_cbOutput, *m_cbAPBMagnetic;
161 wxComboBox *m_comboPort;
162 wxStdDialogButtonSizer *m_sdbSizerDlgButtons;
163 wxButton *m_ButtonSKDiscover, *m_ButtonPriorityDialog;
164 wxStaticText *m_StaticTextSKServerStatus;
165
166 wxButton *m_buttonAdd, *m_buttonRemove, *m_buttonScanBT, *m_btnInputStcList;
167 wxButton *m_btnOutputStcList, *m_sdbSizerDlgButtonsOK;
168 wxButton *m_sdbSizerDlgButtonsApply, *m_sdbSizerDlgButtonsCancel;
169 wxStaticBoxSizer *sbSizerConnectionProps, *sbSizerInFilter;
170 wxStaticBoxSizer *sbSizerOutFilter;
171 wxRadioButton *m_rbTypeSerial, *m_rbTypeNet, *m_rbTypeInternalGPS;
172 wxRadioButton *m_rbTypeInternalBT, *m_rbNetProtoTCP, *m_rbNetProtoUDP;
173 wxRadioButton *m_rbNetProtoGPSD, *m_rbIAccept, *m_rbIIgnore, *m_rbOAccept;
174 wxRadioButton *m_rbNetProtoSignalK;
175 wxRadioButton *m_rbOIgnore, *m_rbTypeCAN;
176 wxStaticText *m_stBTPairs, *m_stNetProto, *m_stNetAddr, *m_stNetPort;
177 wxStaticText *m_stSerPort, *m_stSerBaudrate, *m_stSerProtocol;
178 wxStaticText *m_stFilterSec, *m_stPrecision;
179 wxStaticText *m_stTalkerIdText;
180 wxStaticText *m_stNetComment, *m_stSerialComment, *m_stCANSource,
181 *m_stAuthToken;
182 wxTextCtrl *m_tNetComment, *m_tSerialComment, *m_tAuthToken;
183 wxStaticBox *m_sbConnEdit;
184 wxChoice *m_choiceBTDataSources, *m_choiceBaudRate, *m_choiceSerialProtocol;
185 wxChoice *m_choicePriority, *m_choicePrecision, *m_choiceCANSource;
186 wxChoice *m_choiceNetDataProtocol;
187
188 wxBoxSizer *boxSizerConnections;
189 wxStaticText *m_stNetDataProtocol;
190
191 ConnectionParams *mSelectedConnection;
192
193#ifdef __ANDROID__
194 wxPanel *m_scrollWinConnections;
195#else
196 wxScrolledWindow *m_scrollWinConnections;
197#endif
198
199 bool connectionsaved;
200 bool m_advanced = false;
201 bool m_connection_enabled;
202 bool m_bNMEAParams_shown;
203 int m_btNoChangeCounter, m_btlastResultCount, m_BTscanning;
204 wxArrayString m_BTscan_results;
205 wxTimer m_BTScanTimer;
206 wxArrayString m_choice_CANSource_choices;
207
208 ObsListener new_device_listener;
209
210 // DECLARE_EVENT_TABLE()
211protected:
212 wxString MORE, LESS;
213 wxStaticText *m_more;
214};
215
216class SentenceListDlg : public wxDialog {
217public:
218 explicit SentenceListDlg(wxWindow *parent, FilterDirection dir, ListType type,
219 const wxArrayString &list);
220 wxString GetSentences(void);
221
222private:
223 void OnAddClick(wxCommandEvent &event);
224 void OnDeleteClick(wxCommandEvent &event);
225 void OnCLBSelect(wxCommandEvent &event);
226 void OnCheckAllClick(wxCommandEvent &event);
227 void OnClearAllClick(wxCommandEvent &event);
228
229 void Populate(const wxArrayString &list);
230 wxString GetBoxLabel(void) const;
231
232 wxCheckListBox *m_clbSentences;
233 wxButton *m_btnDel;
234
235 ListType m_type;
236 FilterDirection m_dir;
237 wxArrayString m_sentences;
238};
239
240#endif //_CONNECT_DIALOG_H
Dialog for editing connection parameters.
Panel for displaying and editing connection parameters.
Define an action to be performed when a KeyProvider is notified.
Definition observable.h:228