コード例 #1
0
ファイル: multiplexer.cpp プロジェクト: doublespy/OpenCPN
void Multiplexer::SendNMEAMessage( wxString &msg )
{
    //Send to all the outputs
    for (size_t i = 0; i < m_pdatastreams->Count(); i++)
    {
        DataStream* s = m_pdatastreams->Item(i);
        if ( s->IsOk() && (s->GetIoSelect() == DS_TYPE_INPUT_OUTPUT || s->GetIoSelect() == DS_TYPE_OUTPUT) ) {
            bool bout_filter = true;

            bool bxmit_ok = true;
            if(s->SentencePassesFilter( msg, FILTER_OUTPUT ) ) {
                bxmit_ok = s->SendSentence(msg);
                bout_filter = false;
            }    
            //Send to the Debug Window, if open
            if( !bout_filter ) {
                if( bxmit_ok )
                    LogOutputMessageColor( msg, s->GetPort(), _T("<BLUE>") );
                else
                    LogOutputMessageColor( msg, s->GetPort(), _T("<RED>") );
            }
            else
                LogOutputMessageColor( msg, s->GetPort(), _T("<AMBER>") );
        }
        
    }
    //Send to plugins
    if ( g_pi_manager )
        g_pi_manager->SendNMEASentenceToAllPlugIns( msg );
}
コード例 #2
0
ファイル: multiplexer.cpp プロジェクト: JesperWe/OpenCPN
void Multiplexer::SendNMEAMessage( wxString &msg )
{
    //Send to all the outputs
    for (size_t i = 0; i < m_pdatastreams->Count(); i++)
    {
        DataStream* s = m_pdatastreams->Item(i);
        if ( s->IsOk() && (s->GetIoSelect() == DS_TYPE_INPUT_OUTPUT || s->GetIoSelect() == DS_TYPE_OUTPUT) ) {
            bool bout_filter = true;
            
            if(s->SentencePassesFilter( msg, FILTER_OUTPUT ) ) {
                s->SendSentence(msg);
                bout_filter = false;
            }    
            //Send to the Debug Window, if open
            if( g_NMEALogWindow) {
                wxDateTime now = wxDateTime::Now();
                wxString ss = now.FormatISOTime();
                ss.Prepend(_T("--> "));
                ss.Append( _T(" (") );
                ss.Append( s->GetPort() );
                ss.Append( _T(") ") );
                ss.Append( msg );
                if(bout_filter)
                    ss.Prepend( _T("<AMBER>") );
                else
                    ss.Prepend( _T("<BLUE>") );
                
                g_NMEALogWindow->Add( ss );
                g_NMEALogWindow->Refresh( false );
            }
            
        }
        
    }
    //Send to plugins
    if ( g_pi_manager )
        g_pi_manager->SendNMEASentenceToAllPlugIns( msg );
}
コード例 #3
0
ファイル: multiplexer.cpp プロジェクト: iplaydu/OpenCPN
void Multiplexer::OnEvtStream(OCPN_DataStreamEvent& event)
{
    wxString message = wxString(event.GetNMEAString().c_str(), wxConvUTF8);
    wxString port = wxString(event.GetStreamName().c_str(), wxConvUTF8);
    DataStream *stream = FindStream(port);
    if( !message.IsEmpty() )
    {
        //Send to core consumers
        //if it passes the source's input filter
        //  If there is no datastream, as for PlugIns, then pass everything
        bool bpass = true;
        if( stream )
            bpass = stream->SentencePassesFilter( message, FILTER_INPUT );
            
        if( bpass ) {
            if( message.Mid(3,3).IsSameAs(_T("VDM")) ||
                message.Mid(1,5).IsSameAs(_T("FRPOS")) ||
                message.Mid(1,2).IsSameAs(_T("CD")) )
            {
                if( m_aisconsumer )
                    m_aisconsumer->AddPendingEvent(event);
            }
            else
            {
                if( m_gpsconsumer )
                    m_gpsconsumer->AddPendingEvent(event);
            }

            //  Handle AIVDO messages from transponder....
            if( message.Mid(3,3).IsSameAs(_T("VDO")) ) {
                if( m_gpsconsumer )
                    m_gpsconsumer->AddPendingEvent(event);
            }
        }

            //Send to the Debug Window, if open
        LogInputMessage( message, port, !bpass );
            
        //Send to plugins
        if ( g_pi_manager )
            g_pi_manager->SendNMEASentenceToAllPlugIns( message );
            
       //Send to all the other outputs
        for (size_t i = 0; i < m_pdatastreams->Count(); i++)
        {
            DataStream* s = m_pdatastreams->Item(i);
            if ( s->IsOk() ) {
                if((s->GetConnectionType() == SERIAL)  || (s->GetPort() != port)) {
                    if ( s->GetIoSelect() == DS_TYPE_INPUT_OUTPUT || s->GetIoSelect() == DS_TYPE_OUTPUT ) {
                        bool bout_filter = true;
                       
                        if(s->SentencePassesFilter( message, FILTER_OUTPUT ) ) {
                            s->SendSentence(message);
                            bout_filter = false;
                        }    
                            //Send to the Debug Window, if open
                        LogOutputMessage( message, port, bout_filter );
                    }
                }
            }
        }
    }
}
コード例 #4
0
ファイル: multiplexer.cpp プロジェクト: JesperWe/OpenCPN
void Multiplexer::OnEvtStream(OCPN_DataStreamEvent& event)
{
    wxString message = event.GetNMEAString();
    wxString ds = event.GetDataSource();
    DataStream *stream = event.GetDataStream();
 
    
    if( !message.IsEmpty() )
    {
        //Send to all the other outputs
        for (size_t i = 0; i < m_pdatastreams->Count(); i++)
        {
            DataStream* s = m_pdatastreams->Item(i);
            if ( ds != s->GetPort() ) {
                if ( s->IsOk() )
                    if ( s->GetIoSelect() == DS_TYPE_INPUT_OUTPUT || s->GetIoSelect() == DS_TYPE_OUTPUT ) {
                        bool bout_filter = true;
                        
                        if(s->SentencePassesFilter( message, FILTER_OUTPUT ) ) {
                            s->SendSentence(message);
                            bout_filter = false;
                        }    
                            //Send to the Debug Window, if open
                        if( g_NMEALogWindow) {
                            wxDateTime now = wxDateTime::Now();
                            wxString ss = now.FormatISOTime();
                            ss.Prepend(_T("--> "));
                            ss.Append( _T(" (") );
                            ss.Append( s->GetPort() );
                            ss.Append( _T(") ") );
                            ss.Append( message );
                            if(bout_filter)
                                ss.Prepend( _T("<AMBER>") );
                            else
                                ss.Prepend( _T("<BLUE>") );
                                
                            g_NMEALogWindow->Add( ss );
                            g_NMEALogWindow->Refresh( false );
                        }
                            
                        
                    }
            }
        }
        //Send to core consumers
        //if it passes the source's input filter
        bool bfilter = true;
        if(stream->SentencePassesFilter( message, FILTER_INPUT ) ) {
            bfilter = false;
            if( message.Mid(3,3).IsSameAs(_T("VDM")) ||
                message.Mid(3,3).IsSameAs(_T("VDO")) ||
                message.Mid(1,5).IsSameAs(_T("FRPOS")) ||
                message.Mid(1,2).IsSameAs(_T("CD")) )
            {
                if( m_aisconsumer )
                    m_aisconsumer->AddPendingEvent(event);
            }
            else
            {
                if( m_gpsconsumer )
                    m_gpsconsumer->AddPendingEvent(event);
            }
        //Send to plugins
            if ( g_pi_manager )
                g_pi_manager->SendNMEASentenceToAllPlugIns( message );
        }
        
        //Send to the Debug Window, if open
        if( g_NMEALogWindow) {
            wxDateTime now = wxDateTime::Now();
            wxString ss = now.FormatISOTime();
            ss.Append( _T(" (") );
            ss.Append( event.GetDataSource() );
            ss.Append( _T(") ") );
            ss.Append( message );
            if(bfilter)
                ss.Prepend( _T("<AMBER>") );
            else
                ss.Prepend( _T("<GREEN>") );
            
            g_NMEALogWindow->Add( ss );
            g_NMEALogWindow->Refresh( false );
        }
        
    }
}
コード例 #5
0
ファイル: multiplexer.cpp プロジェクト: vipserv/OpenCPN
void Multiplexer::OnEvtStream(OCPN_DataStreamEvent& event)
{
    wxString message = wxString(event.GetNMEAString().c_str(), wxConvUTF8);

    DataStream *stream = event.GetStream();
    wxString port(_T("Virtual:"));
    if( stream )
        port = wxString(stream->GetPort());

    if( !message.IsEmpty() )
    {
        //Send to core consumers
        //if it passes the source's input filter
        //  If there is no datastream, as for PlugIns, then pass everything
        bool bpass = true;
        if( stream )
            bpass = stream->SentencePassesFilter( message, FILTER_INPUT );

        if( bpass ) {
            if( message.Mid(3,3).IsSameAs(_T("VDM")) ||
                message.Mid(1,5).IsSameAs(_T("FRPOS")) ||
                message.Mid(1,2).IsSameAs(_T("CD")) ||
                message.Mid(3,3).IsSameAs(_T("TLL")) ||
                message.Mid(3,3).IsSameAs(_T("TTM")) ||
                message.Mid(3,3).IsSameAs(_T("OSD")) ||
                ( g_bWplIsAprsPosition && message.Mid(3,3).IsSameAs(_T("WPL")) ) )
            {
                if( m_aisconsumer )
                    m_aisconsumer->AddPendingEvent(event);
            }
            else
            {
                if( m_gpsconsumer )
                    m_gpsconsumer->AddPendingEvent(event);
            }
        }

        if ((g_b_legacy_input_filter_behaviour && !bpass) || bpass) {

            //Send to plugins
            if ( g_pi_manager ){
                if(stream){                     // Is this a real or a virtual stream?
                    if( stream->ChecksumOK(event.GetNMEAString()) )
                        g_pi_manager->SendNMEASentenceToAllPlugIns( message );
                }
                else{
                    if( CheckSumCheck(event.GetNMEAString()) )
                        g_pi_manager->SendNMEASentenceToAllPlugIns( message );
                }
                    
            }

           //Send to all the other outputs
            for (size_t i = 0; i < m_pdatastreams->Count(); i++)
            {
                DataStream* s = m_pdatastreams->Item(i);
                if ( s->IsOk() ) {
                    if((s->GetConnectionType() == SERIAL)  || (s->GetPort() != port)) {
                        if ( s->GetIoSelect() == DS_TYPE_INPUT_OUTPUT || s->GetIoSelect() == DS_TYPE_OUTPUT ) {
                            bool bout_filter = true;

                            bool bxmit_ok = true;
                            if(s->SentencePassesFilter( message, FILTER_OUTPUT ) ) {
                                bxmit_ok = s->SendSentence(message);
                                bout_filter = false;
                            }

                            //Send to the Debug Window, if open
                            if( !bout_filter ) {
                                if( bxmit_ok )
                                    LogOutputMessageColor( message, s->GetPort(), _T("<BLUE>") );
                                else
                                    LogOutputMessageColor( message, s->GetPort(), _T("<RED>") );
                            }
                            else
                                LogOutputMessageColor( message, s->GetPort(), _T("<CORAL>") );
                        }
                    }
                }
            }
        }

            //Send to the Debug Window, if open
            //  Special formatting for non-printable characters helps debugging NMEA problems
        if (NMEALogWindow::Get().Active()) {
            std::string str= event.GetNMEAString();    
            wxString fmsg;
            
            bool b_error = false;
            for ( std::string::iterator it=str.begin(); it!=str.end(); ++it){
                if(isprint(*it))
                    fmsg += *it;
                else{
                    wxString bin_print;
                    bin_print.Printf(_T("<0x%02X>"), *it);
                    fmsg += bin_print;
                    if((*it != 0x0a) && (*it != 0x0d))
                        b_error = true;
                }
                
            }
            LogInputMessage( fmsg, port, !bpass, b_error );
        }
    }
}