本文整理汇总了C++中DataStream::SendSentence方法的典型用法代码示例。如果您正苦于以下问题:C++ DataStream::SendSentence方法的具体用法?C++ DataStream::SendSentence怎么用?C++ DataStream::SendSentence使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataStream
的用法示例。
在下文中一共展示了DataStream::SendSentence方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SendNMEAMessage
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: SendNMEAMessage
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: 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;
}
示例4: SendRouteToGPS
//.........这里部分代码省略.........
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 ( pProgress )
{
pProgress->SetValue ( ( ip * 100 ) / nProg );
pProgress->Refresh();
pProgress->Update();
}
wxMilliSleep ( progress_stall );
node = node->GetNext();
ip++;
}
}
// Create the NMEA Rte sentence
oNMEA0183.Rte.Empty();
oNMEA0183.Rte.TypeOfRoute = CompleteRoute;
if ( pr->m_RouteNameString.IsEmpty() )
oNMEA0183.Rte.RouteName = _T ( "1" );
else
示例5: OnEvtStream
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 );
}
}
}
}
}
}
示例6: OnEvtStream
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 );
}
}
}
示例7: SendRouteToGPS
//.........这里部分代码省略.........
}
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" ) );
wxString name = prp->GetName();
name += _T("000000");
name.Truncate( 6 );
oNMEA0183.GPwpl.To = name;
oNMEA0183.GPwpl.Write ( snt );
}
wxString payload = snt.Sentence;
// for some gps, like some garmin models, they assume the first waypoint
// in the route is the boat location, therefore it is dropped.
// These gps also can only accept a maximum of up to 20 waypoints at a time before
// a delay is needed and a new string of waypoints may be sent.
// To ensure all waypoints will arrive, we can simply send each one twice.
// This ensures that the gps will get the waypoint and also allows us to send as many as we like
payload += _T("\r\n") + payload;
if( dstr->SendSentence( payload ) )
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 ( pProgress )
{
pProgress->SetValue ( ( ip * 100 ) / nProg );
pProgress->Refresh();
pProgress->Update();
}
wxMilliSleep ( progress_stall );
node = node->GetNext();
ip++;
}
}
// Create the NMEA Rte sentence
// Try to create a single sentence, and then check the length to see if too long
unsigned int max_length = 76;
unsigned int max_wp = 2; // seems to be required for garmin...
// Furuno GPS can only accept 5 (five) waypoint linkage sentences....
// So, we need to compact a few more points into each link sentence.
if(g_GPS_Ident == _T("FurunoGP3X")){
示例8: OnEvtStream
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;
}
//.........这里部分代码省略.........