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 OnCrcCheck(wxCommandEvent &event) { OnConnValChange(event); }
89 void OnRbAcceptInput(wxCommandEvent &event);
90 void OnRbIgnoreInput(wxCommandEvent &event);
91 void OnBtnIStcs(wxCommandEvent &event);
92 void OnCbInput(wxCommandEvent &event);
93 void OnCbOutput(wxCommandEvent &event);
94 void OnCbMultiCast(wxCommandEvent &event);
95 void OnCbAdvanced(wxCommandEvent &event);
96 void OnClickMore(wxMouseEvent &event);
97 void OnRbOutput(wxCommandEvent &event);
98 void OnBtnOStcs(wxCommandEvent &event);
99 void OnConnValChange(wxCommandEvent &event);
100 void OnValChange(wxCommandEvent &event);
101 void OnUploadFormatChange(wxCommandEvent &event);
102 void OnCollapsedToggle(bool collapsed);
103 void OnShowGpsWindowCheckboxClick(wxCommandEvent &event);
104 void EnableConnection(ConnectionParams *conn, bool value);
105 void OnDiscoverButton(wxCommandEvent &event);
106 void UpdateDiscoverStatus(wxString stat);
107 void OnPriorityDialog(wxCommandEvent &event);
108
109 void SetConnectionParams(ConnectionParams *cp);
110 void SetDefaultConnectionParams(void);
111 void SetDSFormRWStates();
112 void SetDSFormOptionVizStates();
113 void FillSourceList();
114 void UpdateSourceList(bool bResort);
115 bool SortSourceList(void);
116 void SetUDPNetAddressVisiblity(void);
117 bool IsAddressMultiCast(wxString ip);
118 bool IsAddressBroadcast(wxString ip);
119 bool IsDefaultPort(wxString address);
120
121 void ClearNMEAForm(void);
122 void SetNMEAFormToSerial(void);
123 void SetNMEAFormToNet(void);
124 void SetNMEAFormToGPS(void);
125 void SetNMEAFormToBT(void);
126 void SetNMEAFormToCAN(void);
127 void SetNMEAFormForSerialProtocol();
128 void SetNMEAFormForNetProtocol();
129
130 void ShowTypeCommon(bool visible = true);
131 void ShowNMEACommon(bool visible);
132 void ShowNMEASerial(bool visible);
133 void ShowNMEANet(bool visible);
134 void ShowNMEAGPS(bool visible);
135 void ShowNMEABT(bool visible);
136 void ShowNMEACAN(bool visible);
137
138 void OnScanBTClick(wxCommandEvent &event);
139 void onBTScanTimer(wxTimerEvent &event);
140 void StopBTScan(void);
141
142 void OnWheelChoice(wxMouseEvent &event);
143
144 void ShowInFilter(bool bshow = true);
145 void ShowOutFilter(bool bshow = true);
146 void LayoutDialog();
147
148 void CreateControls();
149 void ConnectControls();
150
151 // private:
152 wxWindow *m_parent;
153 wxScrolledWindow *m_scrolledwin;
154
155 wxGridSizer *gSizerNetProps, *gSizerSerProps, *gSizerCanProps;
156 wxTextCtrl *m_tNetAddress, *m_tNetPort, *m_tFilterSec, *m_tcInputStc;
157 wxTextCtrl *m_tcOutputStc;
158 wxCheckBox *m_cbCheckCRC, *m_cbGarminHost, *m_cbGarminUploadHost,
159 *m_cbCheckSKDiscover;
160 wxCheckBox *m_cbFurunoGP3X, *m_cbNMEADebug, *m_cbFilterSogCog, *m_cbInput;
161 wxCheckBox *m_cbMultiCast, *m_cbAdvanced;
162 wxCheckBox *m_cbOutput, *m_cbAPBMagnetic;
163 wxComboBox *m_comboPort;
164 wxStdDialogButtonSizer *m_sdbSizerDlgButtons;
165 wxButton *m_ButtonSKDiscover, *m_ButtonPriorityDialog;
166 wxStaticText *m_StaticTextSKServerStatus;
167
168 wxButton *m_buttonAdd, *m_buttonRemove, *m_buttonScanBT, *m_btnInputStcList;
169 wxButton *m_btnOutputStcList, *m_sdbSizerDlgButtonsOK;
170 wxButton *m_sdbSizerDlgButtonsApply, *m_sdbSizerDlgButtonsCancel;
171 wxStaticBoxSizer *sbSizerConnectionProps, *sbSizerInFilter;
172 wxStaticBoxSizer *sbSizerOutFilter;
173 wxRadioButton *m_rbTypeSerial, *m_rbTypeNet, *m_rbTypeInternalGPS;
174 wxRadioButton *m_rbTypeInternalBT, *m_rbNetProtoTCP, *m_rbNetProtoUDP;
175 wxRadioButton *m_rbNetProtoGPSD, *m_rbIAccept, *m_rbIIgnore, *m_rbOAccept;
176 wxRadioButton *m_rbNetProtoSignalK;
177 wxRadioButton *m_rbOIgnore, *m_rbTypeCAN;
178 wxStaticText *m_stBTPairs, *m_stNetProto, *m_stNetAddr, *m_stNetPort;
179 wxStaticText *m_stSerPort, *m_stSerBaudrate, *m_stSerProtocol;
180 wxStaticText *m_stFilterSec, *m_stPrecision;
181 wxStaticText *m_stTalkerIdText;
182 wxStaticText *m_stNetComment, *m_stSerialComment, *m_stCANSource,
183 *m_stAuthToken;
184 wxTextCtrl *m_tNetComment, *m_tSerialComment, *m_tAuthToken;
185 wxStaticBox *m_sbConnEdit;
186 wxChoice *m_choiceBTDataSources, *m_choiceBaudRate, *m_choiceSerialProtocol;
187 wxChoice *m_choicePriority, *m_choicePrecision, *m_choiceCANSource;
188 wxChoice *m_choiceNetDataProtocol;
189
190 wxBoxSizer *boxSizerConnections;
191 wxStaticText *m_stNetDataProtocol;
192
193 ConnectionParams *mSelectedConnection;
194
195#ifdef __ANDROID__
196 wxPanel *m_scrollWinConnections;
197#else
198 wxScrolledWindow *m_scrollWinConnections;
199#endif
200
201 bool connectionsaved;
202 bool m_advanced = false;
203 bool m_connection_enabled;
204 bool m_bNMEAParams_shown;
205 int m_btNoChangeCounter, m_btlastResultCount, m_BTscanning;
206 wxArrayString m_BTscan_results;
207 wxTimer m_BTScanTimer;
208 wxArrayString m_choice_CANSource_choices;
209
210 ObsListener new_device_listener;
211
212 // DECLARE_EVENT_TABLE()
213protected:
214 ExpandableIcon m_expandable_icon;
215 wxSizer *m_collapse_box;
216};
217
218class SentenceListDlg : public wxDialog {
219public:
220 explicit SentenceListDlg(wxWindow *parent, FilterDirection dir, ListType type,
221 const wxArrayString &list);
222 wxString GetSentences(void);
223
224private:
225 void OnAddClick(wxCommandEvent &event);
226 void OnDeleteClick(wxCommandEvent &event);
227 void OnCLBSelect(wxCommandEvent &event);
228 void OnCheckAllClick(wxCommandEvent &event);
229 void OnClearAllClick(wxCommandEvent &event);
230
231 void Populate(const wxArrayString &list);
232 wxString GetBoxLabel(void) const;
233
234 wxCheckListBox *m_clbSentences;
235 wxButton *m_btnDel;
236
237 ListType m_type;
238 FilterDirection m_dir;
239 wxArrayString m_sentences;
240};
241
242#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