OpenCPN Partial API docs
wiz_ui.h
1 /******************************************************************************
2  *
3  * Project: OpenCPN
4  * Purpose: Configuration wizard
5  * Author: David Register
6  *
7  ***************************************************************************
8  * Copyright (C) 2010-2024 by David S. Register *
9  * *
10  * This program is free software; you can redistribute it and/or modify *
11  * it under the terms of the GNU General Public License as published by *
12  * the Free Software Foundation; either version 2 of the License, or *
13  * (at your option) any later version. *
14  * *
15  * This program is distributed in the hope that it will be useful, *
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
18  * GNU General Public License for more details. *
19  * *
20  * You should have received a copy of the GNU General Public License *
21  * along with this program; if not, write to the *
22  * Free Software Foundation, Inc., *
23  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
24  ***************************************************************************
25  *
26  *
27  *
28  */
29 
30 #ifndef _WIZ_UI_H__
31 #define _WIZ_UI_H__
32 
33 #include "wiz_ui_proto.h"
34 #include "model/conn_params.h"
35 #include "navutil.h"
36 
37 #include <cstdint>
38 
39 struct USBDevice {
40  std::string name;
41  uint16_t vid;
42  uint16_t pid;
43  DataProtocol protocol;
44  int baudrate;
45 };
46 
47 enum class NMEA0183Flavor { CRC, NO_CRC, INVALID };
48 
49 const std::vector<uint32_t> Speeds = {4800, 9600, 19200, 38400,
50  57600, 115200, 230400, 460800};
51 
52 // Well known ports used by various NMEA to IP gateways
53 // 10110 - "Standard" for NMEA0183 over IP
54 // 2000 - Quark Elec default for both TCP and UDP
55 // 1456-1458 - YD (See https://www.yachtd.com/downloads/ydnr02.pdf)
56 // 39150/TCP - Vesper Cortex
57 const std::vector<uint16_t> UDPPorts = {10110, 2000, 1458};
58 const std::vector<uint16_t> TCPPorts = {10110, 2000, 1456, 1457, 39150};
59 
60 const std::vector<USBDevice> known_usb_devices = {
61  {"Actisense NGT-1", 0x0403, 0xd9aa, DataProtocol::PROTO_NMEA2000, 115200},
62  {"ShipModul MiniPlex", 0x0403, 0xfd4b, DataProtocol::PROTO_NMEA0183,
63  460800}};
64 
65 class FirstUseWizImpl : public FirstUseWiz {
66 public:
67  FirstUseWizImpl(wxWindow* parent, MyConfig *pConfig,
68  wxWindowID id = wxID_ANY,
69  const wxString& title = _("OpenCPN Initial Configuration"),
70  const wxBitmap& bitmap = wxNullBitmap,
71  const wxPoint& pos = wxDefaultPosition,
72  long style = wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER |
73  wxSTAY_ON_TOP);
74  ~FirstUseWizImpl();
75 
76  void OnWizardPageChanging(wxWizardEvent& event) { event.Skip(); }
77  void OnWizardPageChanged(wxWizardEvent& event) { event.Skip(); }
78  void OnWizardPageShown(wxWizardEvent& event);
79  void OnWizardCancel(wxWizardEvent& event) { event.Skip(); }
80  void OnWizardHelp(wxWizardEvent& event) { event.Skip(); }
81  void OnWizardFinished(wxWizardEvent& event);
82  void m_btnRescanSourcesOnButtonClick(wxCommandEvent& event) {
83  EnumerateDatasources();
84  }
85  void m_btnAddChartDirOnButtonClick(wxCommandEvent& event);
86 
87  bool Run() {
88  FitToPage(m_pages[m_pages.Count() - 1]);
89  return RunWizard(m_pages[0]);
90  }
91 
92  void EnumerateDatasources();
93  void EnumerateUSB();
94  void EnumerateUDP();
95  void EnumerateTCP();
96  void EnumerateCAN();
97  void EnumerateSignalK();
98  void EnumerateGPSD();
99 
100 private:
101  MyConfig *m_pConfig;
102  std::vector<ConnectionParams> m_detected_connections;
103  NMEA0183Flavor SeemsN0183(std::string& data);
104  bool SeemsN2000(std::string& data);
105 
106  inline void SetControlEnable(int id, bool state)
107  {
108  wxWindow *win = wxWindow::FindWindowById(id);
109  if(win) win->Enable(state);
110  }
111 };
112 
113 #endif //_WIZ_UI_H__
Class FirstUseWiz.
Definition: wiz_ui_proto.h:42