当前位置: 首页>>代码示例>>C++>>正文


C++ DataStream::Close方法代码示例

本文整理汇总了C++中DataStream::Close方法的典型用法代码示例。如果您正苦于以下问题:C++ DataStream::Close方法的具体用法?C++ DataStream::Close怎么用?C++ DataStream::Close使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DataStream的用法示例。


在下文中一共展示了DataStream::Close方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: SendRouteToGPS


//.........这里部分代码省略.........
                        oNMEA0183.Rte.total_number_of_messages = final_total;
                        oNMEA0183.Rte.message_number = n_run;
                        snt.Sentence.Clear();

                        oNMEA0183.Rte.AddWaypoint ( name );
                        node = node->GetNext();
                    }
                    else
                    {
                        if(sent_len + name_len > max_length)
                        {
                            n_run ++;
                            bnew_sentence = true;

                            oNMEA0183.Rte.Write ( snt );
                    // printf("%s", snt.Sentence.mb_str());

                            sentence_array.Add(snt.Sentence);
                        }
                        else
                        {
                            sent_len += name_len;
                            oNMEA0183.Rte.AddWaypoint ( name );
                            node = node->GetNext();
                        }
                    }
                }

                oNMEA0183.Rte.Write ( snt ); //last one...
                if(snt.Sentence.Len() > tare_length)
                      sentence_array.Add(snt.Sentence);

                for(unsigned int ii=0 ; ii < sentence_array.GetCount(); ii++)
                {
                    if(dstr->SendSentence( sentence_array.Item(ii) ) )
                        LogOutputMessage( sentence_array.Item(ii), dstr->GetPort(), false );
                    
                    wxString msg(_T("-->GPS Port:"));
                    msg += com_name;
                    msg += _T(" Sentence: ");
                    msg += sentence_array.Item(ii);
                    msg.Trim();
                    wxLogMessage(msg);

                    wxMilliSleep ( 500 );
                }

            }
            else
            {
                if( dstr->SendSentence( snt.Sentence ) )
                    LogOutputMessage( snt.Sentence, dstr->GetPort(), false );
                
                wxString msg(_T("-->GPS Port:"));
                msg += com_name;
                msg += _T(" Sentence: ");
                msg += snt.Sentence;
                msg.Trim();
                wxLogMessage(msg);
            }

            if(g_GPS_Ident == _T("FurunoGP3X"))
            {
                wxString term;
                term.Printf(_T("$PFEC,GPxfr,CTL,E%c%c"), 0x0d, 0x0a);

                if( dstr->SendSentence( term ) )
                    LogOutputMessage( term, dstr->GetPort(), false );
                
                wxString msg(_T("-->GPS Port:"));
                msg += com_name;
                msg += _T(" Sentence: ");
                msg += term;
                msg.Trim();
                wxLogMessage(msg);
            }

            if ( pProgress )
            {
                pProgress->SetValue ( 100 );
                pProgress->Refresh();
                pProgress->Update();
            }

            wxMilliSleep ( 500 );

            ret_bool = true;
            
            //  All finished with the temp port
            dstr->Close();
        }
    }

ret_point_1:

    if( old_stream )
        CreateAndRestoreSavedStreamProperties();
    
    return ret_bool;
}
开发者ID:iplaydu,项目名称:OpenCPN,代码行数:101,代码来源:multiplexer.cpp

示例2: SendWaypointToGPS


//.........这里部分代码省略.........
    
    DataStream *dstr = new DataStream( this,
                                       com_name,
                                       baud,
                                       DS_TYPE_INPUT_OUTPUT,
                                       0 );
    
        SENTENCE snt;
        NMEA0183 oNMEA0183;
        oNMEA0183.TalkerID = _T ( "EC" );

        if ( pProgress )
            pProgress->SetRange ( 100 );

        if(g_GPS_Ident == _T("Generic"))
        {
            if ( prp->m_lat < 0. )
                oNMEA0183.Wpl.Position.Latitude.Set ( -prp->m_lat, _T ( "S" ) );
            else
                oNMEA0183.Wpl.Position.Latitude.Set ( prp->m_lat, _T ( "N" ) );

            if ( prp->m_lon < 0. )
                oNMEA0183.Wpl.Position.Longitude.Set ( -prp->m_lon, _T ( "W" ) );
            else
                oNMEA0183.Wpl.Position.Longitude.Set ( prp->m_lon, _T ( "E" ) );

            oNMEA0183.Wpl.To = prp->GetName().Truncate ( 6 );

            oNMEA0183.Wpl.Write ( snt );
        }
        else if(g_GPS_Ident == _T("FurunoGP3X"))
        {
            oNMEA0183.TalkerID = _T ( "PFEC," );

            if ( prp->m_lat < 0. )
                oNMEA0183.GPwpl.Position.Latitude.Set ( -prp->m_lat, _T ( "S" ) );
            else
                oNMEA0183.GPwpl.Position.Latitude.Set ( prp->m_lat, _T ( "N" ) );

            if ( prp->m_lon < 0. )
                oNMEA0183.GPwpl.Position.Longitude.Set ( -prp->m_lon, _T ( "W" ) );
            else
                oNMEA0183.GPwpl.Position.Longitude.Set ( prp->m_lon, _T ( "E" ) );


            oNMEA0183.GPwpl.To = prp->GetName().Truncate ( 8 );

            oNMEA0183.GPwpl.Write ( snt );
        }

        if( dstr->SendSentence( snt.Sentence ) )
            LogOutputMessage( snt.Sentence, dstr->GetPort(), false );
        
        wxString msg(_T("-->GPS Port:"));
        msg += com_name;
        msg += _T(" Sentence: ");
        msg += snt.Sentence;
        msg.Trim();
        wxLogMessage(msg);

        if(g_GPS_Ident == _T("FurunoGP3X"))
        {
            wxString term;
            term.Printf(_T("$PFEC,GPxfr,CTL,E%c%c"), 0x0d, 0x0a);

            if( dstr->SendSentence( term ) )
                LogOutputMessage( term, dstr->GetPort(), false );
            
            wxString msg(_T("-->GPS Port:"));
            msg += com_name;
            msg += _T(" Sentence: ");
            msg += term;
            msg.Trim();
            wxLogMessage(msg);
        }

        if ( pProgress )
        {
            pProgress->SetValue ( 100 );
            pProgress->Refresh();
            pProgress->Update();
        }

        wxMilliSleep ( 500 );

        //  All finished with the temp port
        dstr->Close();
        
        ret_bool = true;
    }

ret_point:
    
    if( old_stream )
        CreateAndRestoreSavedStreamProperties();
    
    
    return ret_bool;
    
}
开发者ID:iplaydu,项目名称:OpenCPN,代码行数:101,代码来源:multiplexer.cpp

示例3: SendRouteToGPS


//.........这里部分代码省略.........
        { // Standard NMEA mode

            //  If the port was temporarily closed, reopen as I/O type
            //  Otherwise, open another port using default properties
            wxString baud;

            if( old_stream ) {
                baud = baud_rate_save;
            }
            else {
                baud = _T("4800");
            }

            DataStream *dstr = new DataStream( this,
                                               SERIAL,
                                               com_name,
                                               baud,
                                               DS_TYPE_INPUT_OUTPUT,
                                               0 );

            //  Wait up to 5 seconds for Datastream secondary thread to come up
            int timeout = 0;
            while( !dstr-> IsSecThreadActive()  && (timeout < 50)) {
                wxMilliSleep(100);
                timeout++;
            }

            if( !dstr-> IsSecThreadActive() ){
                wxString msg(_T("-->GPS Port:"));
                msg += com_name;
                msg += _T(" ...Could not be opened for writing");
                wxLogMessage(msg);

                dstr->Close();
                goto ret_point_1;
            }

            SENTENCE snt;
            NMEA0183 oNMEA0183;
            oNMEA0183.TalkerID = _T ( "EC" );

            int nProg = pr->pRoutePointList->GetCount() + 1;
            if ( pProgress )
                pProgress->SetRange ( 100 );

            int progress_stall = 500;
            if(pr->pRoutePointList->GetCount() > 10)
                progress_stall = 200;

            if(!pProgress)
                progress_stall = 200;   // 80 chars at 4800 baud is ~160 msec

            // Send out the waypoints, in order
            if ( bsend_waypoints )
            {
                wxRoutePointListNode *node = pr->pRoutePointList->GetFirst();

                int ip = 1;
                while ( node )
                {
                    RoutePoint *prp = node->GetData();

                    if(g_GPS_Ident == _T("Generic"))
                    {
                        if ( prp->m_lat < 0. )
                            oNMEA0183.Wpl.Position.Latitude.Set ( -prp->m_lat, _T ( "S" ) );
开发者ID:vipserv,项目名称:OpenCPN,代码行数:67,代码来源:multiplexer.cpp


注:本文中的DataStream::Close方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。