File: multiplexer.h

package info (click to toggle)
opencpn 5.2.4%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 101,540 kB
  • sloc: ansic: 414,598; cpp: 253,008; xml: 83,748; sh: 409; python: 353; makefile: 110; javascript: 87; perl: 83
file content (87 lines) | stat: -rw-r--r-- 3,558 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
/***************************************************************************
 *
 * Project:  OpenCPN
 * Purpose:  NMEA Data Multiplexer Object
 * Author:   David Register
 *
 ***************************************************************************
 *   Copyright (C) 2010 by David S. Register                               *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,  USA.         *
 **************************************************************************/

#ifndef __MULTIPLEXER_H__
#define __MULTIPLEXER_H__

#include "wx/wxprec.h"

#ifndef  WX_PRECOMP
#include "wx/wx.h"
#endif //precompiled headers

#include "pluginmanager.h"  // for PlugInManager
#include "datastream.h"

class RoutePoint;
class Route;

WX_DEFINE_ARRAY(DataStream *, wxArrayOfDataStreams);

//      Garmin interface private error codes
#define ERR_GARMIN_INITIALIZE           -1
#define ERR_GARMIN_GENERAL              -2

class Multiplexer : public wxEvtHandler
{
    public:
        Multiplexer();
        ~Multiplexer();
        void AddStream(DataStream *stream);
        void StopAllStreams();
        void ClearStreams();
        void StartAllStreams();
        
        DataStream *FindStream(const wxString & port);
        void StopAndRemoveStream( DataStream *stream );
        void SaveStreamProperties( DataStream *stream );
        bool CreateAndRestoreSavedStreamProperties();

        void SendNMEAMessage(const wxString &msg);
        void SetAISHandler(wxEvtHandler *handler);
        void SetGPSHandler(wxEvtHandler *handler);

        int SendRouteToGPS(Route *pr, const wxString &com_name, bool bsend_waypoints, wxGauge *pProgress);
        int SendWaypointToGPS(RoutePoint *prp, const wxString &com_name, wxGauge *pProgress);

        void OnEvtStream(OCPN_DataStreamEvent& event);
        void OnEvtSignalK(OCPN_SignalKEvent& event);
        
        void LogOutputMessage(const wxString &msg, wxString stream_name, bool b_filter);
        void LogOutputMessageColor(const wxString &msg, const wxString & stream_name, const wxString & color);
        void LogInputMessage(const wxString &msg, const wxString & stream_name, bool b_filter, bool b_error = false);

    private:
        wxArrayOfDataStreams *m_pdatastreams;

        wxEvtHandler        *m_aisconsumer;
        wxEvtHandler        *m_gpsconsumer;

        //      A set of temporarily saved parameters for a DataStream
        const ConnectionParams* params_save;

};
#endif // __MULTIPLEXER_H__