1 /***************************************************************************
2  *
3  * Project:  OpenCPN
4  *
5  ***************************************************************************
6  *   Copyright (C) 2013 by David S. Register                               *
7  *                                                                         *
8  *   This program is free software; you can redistribute it and/or modify  *
9  *   it under the terms of the GNU General Public License as published by  *
10  *   the Free Software Foundation; either version 2 of the License, or     *
11  *   (at your option) any later version.                                   *
12  *                                                                         *
13  *   This program is distributed in the hope that it will be useful,       *
14  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
15  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
16  *   GNU General Public License for more details.                          *
17  *                                                                         *
18  *   You should have received a copy of the GNU General Public License     *
19  *   along with this program; if not, write to the                         *
20  *   Free Software Foundation, Inc.,                                       *
21  *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,  USA.         *
22  **************************************************************************/
23 
24 #ifndef __DSPORTTYPE_H__
25 #include <dsPortType.h>
26 #endif
27 
28 #ifndef __CONNECTIONPARAMS_H__
29 #define __CONNECTIONPARAMS_H__
30 
31 #include "wx/wxprec.h"
32 
33 #ifndef  WX_PRECOMP
34   #include "wx/wx.h"
35 #endif //precompiled headers
36 
37 class ConnectionParams;
38 class options;
39 
40 typedef enum
41 {
42     SERIAL = 0,
43     NETWORK = 1,
44     INTERNAL_GPS = 2,
45     INTERNAL_BT = 3
46 } ConnectionType;
47 
48 typedef enum
49 {
50     TCP = 0,
51     UDP = 1,
52     GPSD = 2,
53     SIGNALK = 3,
54     PROTO_UNDEFINED = 4
55 } NetworkProtocol;
56 
57 typedef enum
58 {
59     WHITELIST = 0,
60     BLACKLIST = 1
61 } ListType;
62 
63 typedef enum
64 {
65     FILTER_INPUT = 0,
66     FILTER_OUTPUT = 1
67 } FilterDirection;
68 
69 typedef enum
70 {
71     PROTO_NMEA0183 = 0,
72     PROTO_SEATALK = 1,
73     PROTO_NMEA2000 = 2
74 } DataProtocol;
75 
76 #define CONN_ENABLE_ID 47621
77 
78 class ConnectionParamsPanel: public wxPanel
79 {
80 public:
81     ConnectionParamsPanel( wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size,
82                            ConnectionParams *p_itemConnectionParams, options *pContainer );
83     ~ConnectionParamsPanel();
84 
85     void OnSelected( wxMouseEvent &event );
86     void SetSelected( bool selected );
87     void OnPaint( wxPaintEvent &event );
88     void OnEraseBackground( wxEraseEvent &event );
89     void CreateControls( void );
90     void OnEnableCBClick(wxCommandEvent &event);
91     void Update( ConnectionParams *ConnectionParams);
92 
GetSelected()93     bool GetSelected(){ return m_bSelected; }
GetUnselectedHeight()94     int GetUnselectedHeight(){ return m_unselectedHeight; }
95     ConnectionParams *m_pConnectionParams;
96 
97 private:
98     options *m_pContainer;
99     bool m_bSelected;
100     wxStaticText *m_pName;
101     wxColour m_boxColour;
102     int m_unselectedHeight;
103     wxCheckBox *m_cbEnable;
104     wxStaticText *t2;
105     wxStaticText *t4;
106     wxStaticText *t6;
107     wxStaticText *t12;
108     wxStaticText *t14;
109     wxStaticText *t16;
110     wxStaticText *t18;
111 
112     wxStaticText *t21;
113 
114 
115     DECLARE_EVENT_TABLE()
116 };
117 
118 
119 
120 
121 class ConnectionParams
122 {
123 public:
124     ConnectionParams();
125     ~ConnectionParams();
126     ConnectionParams(const wxString &configStr);
127 
128     ConnectionType  Type;
129     NetworkProtocol NetProtocol;
130     wxString        NetworkAddress;
131     int             NetworkPort;
132 
133     wxString        LastNetworkAddress;
134     int             LastNetworkPort;
135     NetworkProtocol LastNetProtocol;
136 
137     DataProtocol    Protocol;
138     wxString        Port;
139     int             Baudrate;
140     bool            ChecksumCheck;
141     bool            Garmin;
142     bool            GarminUpload;
143     bool            FurunoGP3X;
144     bool            AutoSKDiscover;
145     dsPortType      IOSelect;
146     ListType        InputSentenceListType;
147     wxArrayString   InputSentenceList;
148     ListType        OutputSentenceListType;
149     wxArrayString   OutputSentenceList;
150     int             Priority;
151     bool            bEnabled;
152     wxString        UserComment;
153 
154     wxString        Serialize() const;
155     void            Deserialize(const wxString &configStr);
156 
157     wxString GetSourceTypeStr() const;
158     wxString GetAddressStr() const;
159     wxString GetParametersStr() const;
160     wxString GetIOTypeValueStr() const;
161     wxString GetFiltersStr() const;
162     wxString GetDSPort() const;
163     wxString GetLastDSPort() const;
GetPortStr()164     wxString GetPortStr() const { return Port; }
SetPortStr(wxString str)165     void SetPortStr( wxString str ){ Port = str; }
166 
167 
168     bool            Valid;
169     bool            b_IsSetup;
170     ConnectionParamsPanel *m_optionsPanel;
171 private:
172     wxString FilterTypeToStr(ListType type, FilterDirection dir) const;
173 
174 };
175 
176 WX_DEFINE_ARRAY(ConnectionParams *, wxArrayOfConnPrm);
177 
178 #endif
179