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, see <https://www.gnu.org/licenses/>. *
16 ***************************************************************************/
17
24#ifndef _CONNECT_EDIT_H
25#define _CONNECT_EDIT_H
26
27#include <functional>
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 "observable/observable.h"
36
37#include "model/conn_params.h"
38
39#include "expand_icon.h"
40#include "options.h"
41#include "conn_params_panel.h"
42
47class ConnectionEditDialog : public wxPanel {
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
60 wxWindow *parent,
61 std::function<void(ConnectionParams *p, bool editing, bool ok_cancel)>
62 on_edit_click);
63
65
66 void Init(void);
67 void SetInitialSettings(void);
68 void PreloadControls(ConnectionParams *cp);
69 ConnectionParams *GetParamsFromControls();
70 void SetPropsLabel(wxString label);
71
72 void ApplySettings();
73 ConnectionParams *CreateConnectionParamsFromSelectedItem();
74 ConnectionParams *UpdateConnectionParamsFromControls(
75 ConnectionParams *pConnectionParams);
76 void SetSelectedConnectionPanel(ConnectionParamsPanel *panel);
77 void OnSelectDatasource(wxListEvent &event);
78 void OnAddDatasourceClick(wxCommandEvent &event);
79 void OnRemoveDatasourceClick(wxCommandEvent &event);
80
81 void OnTypeSerialSelected(wxCommandEvent &event);
82 void OnTypeNetSelected(wxCommandEvent &event);
83 void OnTypeGPSSelected(wxCommandEvent &event);
84 void OnTypeBTSelected(wxCommandEvent &event);
85 void OnTypeCANSelected(wxCommandEvent &event);
86
87 void OnNetProtocolSelected(wxCommandEvent &event);
88 void OnBaudrateChoice(wxCommandEvent &event) { OnConnValChange(event); }
89 void OnProtocolChoice(wxCommandEvent &event);
90 void OnRbAcceptInput(wxCommandEvent &event);
91 void OnRbIgnoreInput(wxCommandEvent &event);
92 void OnBtnIStcs(wxCommandEvent &event);
93 void OnCbInput(wxCommandEvent &event);
94 void OnCbOutput(wxCommandEvent &event);
95 void OnCbMultiCast(wxCommandEvent &event);
96 void OnCbAdvanced(wxCommandEvent &event);
97 void OnClickMore(wxMouseEvent &event);
98 void OnRbOutput(wxCommandEvent &event);
99 void OnBtnOStcs(wxCommandEvent &event);
100 void OnConnValChange(wxCommandEvent &event);
101 void OnValChange(wxCommandEvent &event);
102 void OnUploadFormatChange(wxCommandEvent &event);
103 void OnCollapsedToggle(bool collapsed);
104 void OnShowGpsWindowCheckboxClick(wxCommandEvent &event);
105 void EnableConnection(ConnectionParams *conn, bool value);
106 void OnDiscoverButton(wxCommandEvent &event);
107 void UpdateDiscoverStatus(wxString stat);
108 void OnPriorityDialog(wxCommandEvent &event);
109
110 void SetConnectionParams(ConnectionParams *cp);
111 void SetDefaultConnectionParams(void);
112 void SetDSFormRWStates();
113 void SetDSFormOptionVizStates();
114 void FillSourceList();
115 void UpdateSourceList(bool bResort);
116 bool SortSourceList(void);
117 void SetUDPNetAddressVisiblity(void);
118 bool IsAddressMultiCast(wxString ip);
119 bool IsAddressBroadcast(wxString ip);
120 bool IsDefaultPort(wxString address);
121
122 void ClearNMEAForm(void);
123 void SetNMEAFormToSerial(void);
124 void SetNMEAFormToNet(void);
125 void SetNMEAFormToGPS(void);
126 void SetNMEAFormToBT(void);
127 void SetNMEAFormToCAN(void);
128 void SetNMEAFormForSerialProtocol();
129 void SetNMEAFormForNetProtocol();
130
131 void ShowTypeCommon(bool visible = true);
132 void ShowNMEACommon(bool visible);
133 void ShowNMEASerial(bool visible);
134 void ShowNMEANet(bool visible);
135 void ShowNMEAGPS(bool visible);
136 void ShowNMEABT(bool visible);
137 void ShowNMEACAN(bool visible);
138
139 void OnScanBTClick(wxCommandEvent &event);
140 void onBTScanTimer(wxTimerEvent &event);
141 void StopBTScan(void);
142
143 void OnWheelChoice(wxMouseEvent &event);
144
145 void ShowInFilter(bool bshow = true);
146 void ShowOutFilter(bool bshow = true);
147 void LayoutDialog();
148
149 void CreateControls();
150 void ConnectControls();
151
152 void SetNewMode(bool mode) { new_mode = mode; }
153
154 void AddOKCancelButtons();
155 wxStdDialogButtonSizer *m_btnSizer;
156 wxBoxSizer *m_btnSizerBox;
157
158 wxButton *m_btnOK;
159 wxButton *m_btnCancel;
160 bool new_mode;
161
162 void OnOKClick();
163 void OnCancelClick();
164
165 // private:
166 wxWindow *m_parent;
167 // wxScrolledWindow *m_scrolledwin;
168
169 wxGridSizer *gSizerNetProps, *gSizerSerProps, *gSizerCanProps;
170 wxTextCtrl *m_tNetAddress, *m_tNetPort, *m_tFilterSec, *m_tcInputStc;
171 wxTextCtrl *m_tcOutputStc;
172 wxCheckBox *m_cbGarminHost, *m_cbGarminUploadHost, *m_cbCheckSKDiscover;
173 wxCheckBox *m_cbFurunoGP3X, *m_cbNMEADebug, *m_cbFilterSogCog, *m_cbInput;
174 wxCheckBox *m_cbMultiCast, *m_cbAdvanced;
175 wxCheckBox *m_cbOutput, *m_cbAPBMagnetic;
176 wxComboBox *m_comboPort;
177 wxStdDialogButtonSizer *m_sdbSizerDlgButtons;
178 wxButton *m_ButtonSKDiscover, *m_ButtonPriorityDialog;
179 wxStaticText *m_StaticTextSKServerStatus;
180
181 wxButton *m_buttonAdd, *m_buttonRemove, *m_buttonScanBT, *m_btnInputStcList;
182 wxButton *m_btnOutputStcList, *m_sdbSizerDlgButtonsOK;
183 wxButton *m_sdbSizerDlgButtonsApply, *m_sdbSizerDlgButtonsCancel;
184 wxStaticBoxSizer *sbSizerConnectionProps, *sbSizerInFilter;
185 wxStaticBoxSizer *sbSizerOutFilter;
186 wxRadioButton *m_rbTypeSerial, *m_rbTypeNet, *m_rbTypeInternalGPS;
187 wxRadioButton *m_rbTypeInternalBT, *m_rbNetProtoTCP, *m_rbNetProtoUDP;
188 wxRadioButton *m_rbNetProtoGPSD, *m_rbIAccept, *m_rbIIgnore, *m_rbOAccept;
189 wxRadioButton *m_rbNetProtoSignalK;
190 wxRadioButton *m_rbOIgnore, *m_rbTypeCAN;
191 wxStaticText *m_stBTPairs, *m_stNetProto, *m_stNetAddr, *m_stNetPort;
192 wxStaticText *m_stSerPort, *m_stSerBaudrate, *m_stSerProtocol;
193 wxStaticText *m_stFilterSec, *m_stPrecision;
194 wxStaticText *m_stTalkerIdText;
195 wxStaticText *m_stNetComment, *m_stSerialComment, *m_stCANSource,
196 *m_stAuthToken;
197 wxTextCtrl *m_tNetComment, *m_tSerialComment, *m_tAuthToken;
198 wxStaticBox *m_sbConnEdit;
199 wxChoice *m_choiceBTDataSources, *m_choiceBaudRate, *m_choiceSerialProtocol;
200 wxChoice *m_choicePriority, *m_choicePrecision, *m_choiceCANSource;
201 wxChoice *m_choiceNetDataProtocol;
202
203 wxBoxSizer *boxSizerConnections;
204 wxStaticText *m_stNetDataProtocol;
205
206 ConnectionParams *mSelectedConnection;
207
208#ifdef __ANDROID__
209 wxPanel *m_scrollWinConnections;
210#else
211 wxScrolledWindow *m_scrollWinConnections;
212#endif
213
214 bool connectionsaved;
215 bool m_advanced = false;
216 bool m_connection_enabled;
217 bool m_bNMEAParams_shown;
218 int m_btNoChangeCounter, m_btlastResultCount, m_BTscanning;
219 wxArrayString m_BTscan_results;
220 wxTimer m_BTScanTimer;
221 wxArrayString m_choice_CANSource_choices;
222
223 obs::Listener new_device_listener;
224 ConnectionParams *m_cp_original;
225
226 std::function<void(ConnectionParams *, bool, bool)> m_on_edit_click;
227
228protected:
229 wxSizer *m_collapse_box;
230};
231
232class SentenceListDlg : public wxDialog {
233public:
234 explicit SentenceListDlg(wxWindow *parent, FilterDirection dir, ListType type,
235 const wxArrayString &list);
236 wxString GetSentences(void);
237
238private:
239 void OnAddClick(wxCommandEvent &event);
240 void OnDeleteClick(wxCommandEvent &event);
241 void OnCLBSelect(wxCommandEvent &event);
242 void OnCheckAllClick(wxCommandEvent &event);
243 void OnClearAllClick(wxCommandEvent &event);
244
245 void Populate(const wxArrayString &list);
246 wxString GetBoxLabel(void) const;
247
248 wxCheckListBox *m_clbSentences;
249 wxButton *m_btnDel;
250
251 ListType m_type;
252 FilterDirection m_dir;
253 wxArrayString m_sentences;
254};
255
256#endif //_CONNECT_DIALOG_H
Dialog for editing connection parameters.
Panel for displaying and editing connection parameters.
Connection parameters.
Panel for editing a connection.
Options dialog.