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 wxDialog {
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
60 ConnectionEditDialog(wxWindow *parent);
61
63
64 void Init(void);
65 void SetInitialSettings(void);
66 void PreloadControls(ConnectionParams *cp);
67 ConnectionParams *GetParamsFromControls();
68 void SetPropsLabel(wxString label);
69
70 void ApplySettings();
71 ConnectionParams *CreateConnectionParamsFromSelectedItem();
72 ConnectionParams *UpdateConnectionParamsFromControls(
73 ConnectionParams *pConnectionParams);
74 void SetSelectedConnectionPanel(ConnectionParamsPanel *panel);
75 void OnSelectDatasource(wxListEvent &event);
76 void OnAddDatasourceClick(wxCommandEvent &event);
77 void OnRemoveDatasourceClick(wxCommandEvent &event);
78
79 void OnTypeSerialSelected(wxCommandEvent &event);
80 void OnTypeNetSelected(wxCommandEvent &event);
81 void OnTypeGPSSelected(wxCommandEvent &event);
82 void OnTypeBTSelected(wxCommandEvent &event);
83 void OnTypeCANSelected(wxCommandEvent &event);
84
85 void OnNetProtocolSelected(wxCommandEvent &event);
86 void OnBaudrateChoice(wxCommandEvent &event) { OnConnValChange(event); }
87 void OnProtocolChoice(wxCommandEvent &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 OnCollapsedToggle(bool collapsed);
102 void OnShowGpsWindowCheckboxClick(wxCommandEvent &event);
103 void EnableConnection(ConnectionParams *conn, bool value);
104 void OnDiscoverButton(wxCommandEvent &event);
105 void UpdateDiscoverStatus(wxString stat);
106 void OnPriorityDialog(wxCommandEvent &event);
107
108 void SetConnectionParams(ConnectionParams *cp);
109 void SetDefaultConnectionParams(void);
110 void SetDSFormRWStates();
111 void SetDSFormOptionVizStates();
112 void FillSourceList();
113 void UpdateSourceList(bool bResort);
114 bool SortSourceList(void);
115 void SetUDPNetAddressVisiblity(void);
116 bool IsAddressMultiCast(wxString ip);
117 bool IsAddressBroadcast(wxString ip);
118 bool IsDefaultPort(wxString address);
119
120 void ClearNMEAForm(void);
121 void SetNMEAFormToSerial(void);
122 void SetNMEAFormToNet(void);
123 void SetNMEAFormToGPS(void);
124 void SetNMEAFormToBT(void);
125 void SetNMEAFormToCAN(void);
126 void SetNMEAFormForSerialProtocol();
127 void SetNMEAFormForNetProtocol();
128
129 void ShowTypeCommon(bool visible = true);
130 void ShowNMEACommon(bool visible);
131 void ShowNMEASerial(bool visible);
132 void ShowNMEANet(bool visible);
133 void ShowNMEAGPS(bool visible);
134 void ShowNMEABT(bool visible);
135 void ShowNMEACAN(bool visible);
136
137 void OnScanBTClick(wxCommandEvent &event);
138 void onBTScanTimer(wxTimerEvent &event);
139 void StopBTScan(void);
140
141 void OnWheelChoice(wxMouseEvent &event);
142
143 void ShowInFilter(bool bshow = true);
144 void ShowOutFilter(bool bshow = true);
145 void LayoutDialog();
146
147 void CreateControls();
148 void ConnectControls();
149
150 // private:
151 wxWindow *m_parent;
152 wxScrolledWindow *m_scrolledwin;
153
154 wxGridSizer *gSizerNetProps, *gSizerSerProps, *gSizerCanProps;
155 wxTextCtrl *m_tNetAddress, *m_tNetPort, *m_tFilterSec, *m_tcInputStc;
156 wxTextCtrl *m_tcOutputStc;
157 wxCheckBox *m_cbGarminHost, *m_cbGarminUploadHost, *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 ExpandableIcon m_expandable_icon;
213 wxSizer *m_collapse_box;
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.
Simple panel showing either an "expand" or "collapse" icon, state switches when clicked.
Definition expand_icon.h:35
Define an action to be performed when a KeyProvider is notified.
Definition observable.h:228