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