本文整理汇总了C++中NMEAParser类的典型用法代码示例。如果您正苦于以下问题:C++ NMEAParser类的具体用法?C++ NMEAParser怎么用?C++ NMEAParser使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了NMEAParser类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TestTasman
static void
TestTasman()
{
NMEAParser parser;
NMEAInfo nmea_info;
nmea_info.Reset();
nmea_info.clock = fixed(1);
ok1(parser.ParseLine("$PTAS1,200,200,02426,000*25", nmea_info));
ok1(nmea_info.total_energy_vario_available);
ok1(equals(nmea_info.total_energy_vario, fixed(0)));
ok1(nmea_info.pressure_altitude_available);
ok1(equals(nmea_info.pressure_altitude, Units::ToSysUnit(fixed(426), Unit::FEET)));
ok1(nmea_info.airspeed_available);
ok1(equals(nmea_info.true_airspeed, fixed(0)));
ok1(parser.ParseLine("$PTAS1,234,000,00426,062*26", nmea_info));
ok1(nmea_info.total_energy_vario_available);
ok1(equals(nmea_info.total_energy_vario, Units::ToSysUnit(fixed(3.4), Unit::KNOTS)));
ok1(nmea_info.pressure_altitude_available);
ok1(equals(nmea_info.pressure_altitude, Units::ToSysUnit(fixed(-1574), Unit::FEET)));
ok1(nmea_info.airspeed_available);
ok1(equals(nmea_info.true_airspeed, Units::ToSysUnit(fixed(62), Unit::KNOTS)));
}
示例2: ParseNMEAString
/**
* Redirects parsing of the String into GPS_INFO to the right device parser
* @param device 0 or 1, depending on the port used
* @param String NMEA string
* @param GPS_INFO GPS_INFO struct that will be updated
* @return Parsing success
*/
bool NMEAParser::ParseNMEAString(int device, const TCHAR *String,
NMEA_INFO *GPS_INFO) {
switch (device) {
case 0:
return nmeaParser1.ParseNMEAString_Internal(String, GPS_INFO);
case 1:
return nmeaParser2.ParseNMEAString_Internal(String, GPS_INFO);
};
return false;
}
示例3: Reset
void NMEAParser::Reset(void) {
// clear status
nmeaParser1._Reset();
nmeaParser2._Reset();
// trigger updates
TriggerGPSUpdate();
TriggerVarioUpdate();
}
示例4: ParseNMEAString
BOOL NMEAParser::ParseNMEAString(int device,
TCHAR *String, NMEA_INFO *GPS_INFO)
{
switch (device) {
case 0:
return nmeaParser1.ParseNMEAString_Internal(String, GPS_INFO);
case 1:
return nmeaParser2.ParseNMEAString_Internal(String, GPS_INFO);
};
return FALSE;
}
示例5: ParseGPS_POSITION
BOOL NMEAParser::ParseGPS_POSITION(int Idx, const GPS_POSITION& loc, NMEA_INFO& GPSData) {
LKASSERT(!ReplayLogger::IsEnabled());
switch (Idx) {
case 0:
ComPortHB[0]=LKHearthBeats;
return nmeaParser1.ParseGPS_POSITION_internal(loc, GPSData);
case 1:
ComPortHB[1]=LKHearthBeats;
return nmeaParser2.ParseGPS_POSITION_internal(loc, GPSData);
};
return FALSE;
}
示例6: ParseNMEAString
BOOL NMEAParser::ParseNMEAString(int device,
TCHAR *String, NMEA_INFO *pGPS)
{
LKASSERT(!ReplayLogger::IsEnabled());
switch (device) {
case 0:
return nmeaParser1.ParseNMEAString_Internal(String, pGPS);
case 1:
return nmeaParser2.ParseNMEAString_Internal(String, pGPS);
};
return FALSE;
}
示例7: sprintf
/**
* This function creates some simulated traffic for FLARM debugging
* @param GPS_INFO Pointer to the NMEA_INFO struct
*/
void
Simulator::GenerateFLARMTraffic(NMEAInfo &basic)
{
static int i = 90;
i++;
if (i > 255)
i = 0;
if (i > 80)
return;
const Angle angle = Angle::degrees(fixed((i * 360) / 255)).as_bearing();
Angle dangle = (angle + Angle::degrees(fixed(120))).as_bearing();
Angle hangle = dangle.flipped().as_bearing();
int alt = (angle.ifastsine()) / 7;
int north = (angle.ifastsine()) / 2 - 200;
int east = (angle.ifastcosine()) / 1.5;
int track = -angle.as_bearing().value_degrees();
unsigned alarm_level = (i % 30 > 13 ? 0 : (i % 30 > 5 ? 2 : 1));
NMEAParser parser;
char buffer[50];
// PFLAA,<AlarmLevel>,<RelativeNorth>,<RelativeEast>,<RelativeVertical>,
// <IDType>,<ID>,<Track>,<TurnRate>,<GroundSpeed>,<ClimbRate>,<AcftType>
sprintf(buffer, "$PFLAA,%d,%d,%d,%d,2,DDA85C,%d,0,35,0,1",
alarm_level, north, east, alt, track);
AppendNMEAChecksum(buffer);
parser.ParseNMEAString_Internal(buffer, basic);
alt = (angle.ifastcosine()) / 10;
north = (dangle.ifastsine()) / 1.20 + 300;
east = (dangle.ifastcosine()) + 500;
track = hangle.value_degrees();
// PFLAA,<AlarmLevel>,<RelativeNorth>,<RelativeEast>,<RelativeVertical>,
// <IDType>,<ID>,<Track>,<TurnRate>,<GroundSpeed>,<ClimbRate>,<AcftType>
sprintf(buffer, "$PFLAA,0,%d,%d,%d,2,AA9146,,,,,1",
north, east, alt);
AppendNMEAChecksum(buffer);
parser.ParseNMEAString_Internal(buffer, basic);
// PFLAU,<RX>,<TX>,<GPS>,<Power>,<AlarmLevel>,<RelativeBearing>,<AlarmType>,
// <RelativeVertical>,<RelativeDistance>(,<ID>)
sprintf(buffer, "$PFLAU,2,1,2,1,%d", alarm_level);
AppendNMEAChecksum(buffer);
parser.ParseNMEAString_Internal(buffer, basic);
}
示例8: main
int main(int argc, char **argv)
{
NarrowString<1024> usage;
usage = "DRIVER\n\n"
"Where DRIVER is one of:";
{
const DeviceRegister *driver;
for (unsigned i = 0; (driver = GetDriverByIndex(i)) != nullptr; ++i) {
WideToUTF8Converter driver_name(driver->name);
usage.AppendFormat("\n\t%s", (const char *)driver_name);
}
}
Args args(argc, argv, usage);
tstring driver_name = args.ExpectNextT();
args.ExpectEnd();
driver = FindDriverByName(driver_name.c_str());
if (driver == nullptr) {
_ftprintf(stderr, _T("No such driver: %s\n"), driver_name.c_str());
return 1;
}
DeviceConfig config;
config.Clear();
NullPort port;
Device *device = driver->CreateOnPort != nullptr
? driver->CreateOnPort(config, port)
: nullptr;
NMEAParser parser;
NMEAInfo data;
data.Reset();
char buffer[1024];
while (fgets(buffer, sizeof(buffer), stdin) != nullptr) {
StripRight(buffer);
if (device == nullptr || !device->ParseNMEA(buffer, data))
parser.ParseLine(buffer, data);
}
Dump(data);
return EXIT_SUCCESS;
}
示例9: TestVega
static void
TestVega()
{
NullPort null;
Device *device = vega_driver.CreateOnPort(dummy_config, null);
ok1(device != NULL);
NMEAInfo nmea_info;
nmea_info.Reset();
nmea_info.clock = fixed(1);
/* enable FLARM mode (switches the $PGRMZ parser to pressure
altitude) */
NMEAParser parser;
ok1(parser.ParseLine("$PFLAU,0,0,0,1,0,,0,,*63", nmea_info));
ok1(parser.ParseLine("$PGRMZ,2447,F,2*0F", nmea_info));
ok1(nmea_info.pressure_altitude_available);
ok1(equals(nmea_info.pressure_altitude, 745.845));
ok1(device->ParseNMEA("$PDSWC,0,1002000,100,115*54", nmea_info));
ok1(nmea_info.settings.mac_cready_available);
ok1(equals(nmea_info.settings.mac_cready, 0));
ok1(nmea_info.voltage_available);
ok1(equals(nmea_info.voltage, 11.5));
ok1(device->ParseNMEA("$PDVDV,1,0,1062,762,9252,0*5B", nmea_info));
ok1(nmea_info.total_energy_vario_available);
ok1(equals(nmea_info.total_energy_vario, 0.1));
ok1(nmea_info.airspeed_available);
ok1(equals(nmea_info.true_airspeed, 0));
ok1(equals(nmea_info.indicated_airspeed, 0));
ok1(!nmea_info.static_pressure_available);
ok1(!nmea_info.baro_altitude_available);
ok1(nmea_info.pressure_altitude_available);
ok1(equals(nmea_info.pressure_altitude, 762));
/* parse $PGRMZ again, it should be ignored */
ok1(parser.ParseLine("$PGRMZ,2447,F,2*0F", nmea_info));
ok1(nmea_info.pressure_altitude_available);
ok1(equals(nmea_info.pressure_altitude, 762));
delete device;
}
示例10: TestGeneric
static void
TestGeneric()
{
NMEAParser parser;
NMEAInfo nmea_info;
nmea_info.Reset();
nmea_info.clock = fixed(1);
nmea_info.alive.Update(nmea_info.clock);
/* no GPS reception */
ok1(parser.ParseLine("$GPRMC,082310,V,,,,,230610*3f",
nmea_info));
ok1(nmea_info.alive);
ok1(!nmea_info.location_available);
ok1(nmea_info.date_time_utc.year == 2010);
ok1(nmea_info.date_time_utc.month == 6);
ok1(nmea_info.date_time_utc.day == 23);
ok1(nmea_info.date_time_utc.hour == 8);
ok1(nmea_info.date_time_utc.minute == 23);
ok1(nmea_info.date_time_utc.second == 10);
/* got a GPS fix */
ok1(parser.ParseLine("$GPRMC,082311,A,5103.5403,N,00741.5742,E,055.3,022.4,230610,000.3,W*6C",
nmea_info));
ok1(nmea_info.alive);
ok1(nmea_info.location_available);
ok1(nmea_info.date_time_utc.hour == 8);
ok1(nmea_info.date_time_utc.minute == 23);
ok1(nmea_info.date_time_utc.second == 11);
ok1(equals(nmea_info.location.longitude, 7.693));
ok1(equals(nmea_info.location.latitude, 51.059));
ok1(!nmea_info.baro_altitude_available);
/* baro altitude (proprietary Garmin sentence) */
ok1(parser.ParseLine("$PGRMZ,100,m,3*11", nmea_info));
ok1(nmea_info.baro_altitude_available);
ok1(equals(nmea_info.baro_altitude, 100));
}
示例11: TestRoutine
void NMEAParser::TestRoutine(NMEA_INFO *GPS_INFO) {
// QUESTION TB: should be moved to test folder!?
#ifndef NDEBUG
#ifndef GNAV
static int i=90;
static TCHAR t1[] = TEXT("1,1,1,1");
static TCHAR t2[] = TEXT("1,300,500,220,2,DD927B,0,-4.5,30,-1.4,1");
static TCHAR t3[] = TEXT("0,0,1200,50,2,DD9146,270,-4.5,30,-1.4,1");
// static TCHAR b50[] = TEXT("0,.1,.0,0,0,1.06,0,-222");
// static TCHAR t4[] = TEXT("-3,500,1024,50");
// nmeaParser1.ParseNMEAString_Internal(TEXT("$PTAS1,201,200,02583,000*2A"), GPS_INFO);
// nmeaParser1.ParseNMEAString_Internal(TEXT("$GPRMC,082430.00,A,3744.09096,S,14426.16069,E,0.520294.90,301207,,,A*77"), GPS_INFO);
// nmeaParser1.ParseNMEAString_Internal(TEXT("$GPGGA,082430.00,3744.09096,S,1426.16069,E,1,08,1.37,157.6,M,-4.9,M,,*5B"), GPS_INFO);
QNH=1013.25;
double h;
double altraw= 5.0;
h = AltitudeToQNHAltitude(altraw);
QNH = FindQNH(altraw, 50.0);
h = AltitudeToQNHAltitude(altraw);
i++;
if (i>100) {
i=0;
}
if (i<50) {
GPS_INFO->FLARM_Available = true;
TCHAR ctemp[MAX_NMEA_LEN];
const TCHAR *params[MAX_NMEA_PARAMS];
size_t nr;
nr = nmeaParser1.ExtractParameters(t1, ctemp, params, MAX_NMEA_PARAMS);
nmeaParser1.PFLAU(t1, params, nr, GPS_INFO);
nr = nmeaParser1.ExtractParameters(t2, ctemp, params, MAX_NMEA_PARAMS);
nmeaParser1.PFLAA(t2, params, nr, GPS_INFO);
nr = nmeaParser1.ExtractParameters(t3, ctemp, params, MAX_NMEA_PARAMS);
nmeaParser1.PFLAA(t3, params, nr, GPS_INFO);
}
#endif
#endif
}
示例12: TestFLARM
static void
TestFLARM()
{
NMEAParser parser;
NMEAInfo nmea_info;
nmea_info.Reset();
nmea_info.clock = fixed(1);
ok1(parser.ParseLine("$PFLAU,3,1,1,1,0*50",
nmea_info));
ok1(nmea_info.flarm.status.rx == 3);
ok1(nmea_info.flarm.status.tx);
ok1(nmea_info.flarm.status.gps == FlarmStatus::GPSStatus::GPS_2D);
ok1(nmea_info.flarm.status.alarm_level == FlarmTraffic::AlarmType::NONE);
ok1(nmea_info.flarm.traffic.GetActiveTrafficCount() == 0);
ok1(!nmea_info.flarm.traffic.new_traffic);
ok1(parser.ParseLine("$PFLAA,0,100,-150,10,2,DDA85C,123,13,24,1.4,2*7f",
nmea_info));
ok1(nmea_info.flarm.traffic.new_traffic);
ok1(nmea_info.flarm.traffic.GetActiveTrafficCount() == 1);
FlarmId id = FlarmId::Parse("DDA85C", NULL);
FlarmTraffic *traffic = nmea_info.flarm.traffic.FindTraffic(id);
if (ok1(traffic != NULL)) {
ok1(traffic->valid);
ok1(traffic->alarm_level == FlarmTraffic::AlarmType::NONE);
ok1(equals(traffic->relative_north, 100));
ok1(equals(traffic->relative_east, -150));
ok1(equals(traffic->relative_altitude, 10));
ok1(equals(traffic->track, 123));
ok1(traffic->track_received);
ok1(equals(traffic->turn_rate, 13));
ok1(traffic->turn_rate_received);
ok1(equals(traffic->speed, 24));
ok1(traffic->speed_received);
ok1(equals(traffic->climb_rate, 1.4));
ok1(traffic->climb_rate_received);
ok1(traffic->type == FlarmTraffic::AircraftType::TOW_PLANE);
ok1(!traffic->stealth);
} else {
skip(16, 0, "traffic == NULL");
}
ok1(parser.ParseLine("$PFLAA,2,20,10,24,2,DEADFF,,,,,1*46",
nmea_info));
ok1(nmea_info.flarm.traffic.GetActiveTrafficCount() == 2);
id = FlarmId::Parse("DEADFF", NULL);
traffic = nmea_info.flarm.traffic.FindTraffic(id);
if (ok1(traffic != NULL)) {
ok1(traffic->valid);
ok1(traffic->alarm_level == FlarmTraffic::AlarmType::IMPORTANT);
ok1(equals(traffic->relative_north, 20));
ok1(equals(traffic->relative_east, 10));
ok1(equals(traffic->relative_altitude, 24));
ok1(!traffic->track_received);
ok1(!traffic->turn_rate_received);
ok1(!traffic->speed_received);
ok1(!traffic->climb_rate_received);
ok1(traffic->type == FlarmTraffic::AircraftType::GLIDER);
ok1(traffic->stealth);
} else {
skip(12, 0, "traffic == NULL");
}
ok1(parser.ParseLine("$PFLAA,0,1206,574,21,2,DDAED5,196,,32,1.0,1*10",
nmea_info));
ok1(nmea_info.flarm.traffic.GetActiveTrafficCount() == 3);
id = FlarmId::Parse("DDAED5", NULL);
traffic = nmea_info.flarm.traffic.FindTraffic(id);
if (ok1(traffic != NULL)) {
ok1(traffic->valid);
ok1(traffic->alarm_level == FlarmTraffic::AlarmType::NONE);
ok1(equals(traffic->relative_north, 1206));
ok1(equals(traffic->relative_east, 574));
ok1(equals(traffic->relative_altitude, 21));
ok1(equals(traffic->track, 196));
ok1(traffic->track_received);
ok1(!traffic->turn_rate_received);
ok1(equals(traffic->speed, 32));
ok1(traffic->speed_received);
ok1(equals(traffic->climb_rate, 1.0));
ok1(traffic->climb_rate_received);
ok1(traffic->type == FlarmTraffic::AircraftType::GLIDER);
ok1(!traffic->stealth);
} else {
skip(15, 0, "traffic == NULL");
}
}
示例13: UpdateMonitor
//
// Run every 5 seconds, approx.
// This is the hearth of LK. Questions? Ask Paolo..
// THIS IS RUNNING WITH LockComm from ConnectionProcessTimer .
//
void NMEAParser::UpdateMonitor(void)
{
short active=0; // active port number for gps
static short lastactive=0;
static bool lastvalidBaro=false;
static bool wasSilent[2]={false,false};
short invalidGps=0;
short invalidBaro=0;
short validBaro=0;
// does anyone have GPS?
if (nmeaParser1.gpsValid || nmeaParser2.gpsValid) {
if (nmeaParser1.gpsValid && nmeaParser2.gpsValid) {
// both valid, just use first
nmeaParser2.activeGPS = false;
nmeaParser1.activeGPS = true;
active=1;
} else {
// only one valid, pick it up
nmeaParser1.activeGPS = nmeaParser1.gpsValid;
nmeaParser2.activeGPS = nmeaParser2.gpsValid;
active= nmeaParser1.activeGPS ? 1 : 2;
}
} else {
// No valid fix on any port. We use the first port with at least some data going through!
// This will keep probably at least the time updated since the gps may still be receiving a
// valid time, good for us.
if ( (LKHearthBeats-ComPortHB[0])<10 ) {
// It is not granted that devA is really a GPS source.
// Very unlikely, but possible..
if (devIsGPSSource(devA())) active=1;
} else {
if ( (LKHearthBeats-ComPortHB[1])<10 ) {
// portB is really active, although there is no valid fix on it.
// Before electing it to gps, lets be sure it really has one!
// LKEXT1 and other instruments do not provide GPS source in fact.
if (devIsGPSSource(devB())) active=2;
} else {
// nothing coming in from any port, recently.
if (devIsGPSSource(devA())) active=1; // lets keep waiting for the first port
}
}
switch(active) {
case 0:
nmeaParser1.activeGPS = false;
nmeaParser2.activeGPS = false;
break;
case 1:
nmeaParser1.activeGPS = true;
nmeaParser2.activeGPS = false;
break;
case 2:
nmeaParser1.activeGPS = false;
nmeaParser2.activeGPS = true;
break;
default:
nmeaParser1.activeGPS = false;
nmeaParser2.activeGPS = false;
LKASSERT(0);
break;
}
}
if (nmeaParser2.activeGPS==true && active==1) {
StartupStore(_T(".... GPS Update error: port 1 and 2 are active! %s%s"),WhatTimeIsIt(),NEWLINE);
nmeaParser2.activeGPS=false; // force it off
active=1;
}
// wait for some seconds before monitoring, after startup
if (LKHearthBeats<20) return;
/* check if Flarm disappeared after 30 seconds no activity */
if (GPS_INFO.FLARM_Available && ((GPS_INFO.Time -LastFlarmCommandTime)> 30) )
{
static unsigned short MessageCnt =0;
if(MessageCnt <10)
{
MessageCnt++;
StartupStore(_T(". FLARM lost! Disable FLARM functions !%s"),NEWLINE);
DoStatusMessage(gettext(TEXT("[email protected]_"))); // [email protected]_ "FLARM SIGNAL LOST"
}
GPS_INFO.FLARM_Available = false;
GPS_INFO.FLARM_HW_Version =0.0;
GPS_INFO.FLARM_SW_Version =0.0;
}
// Check Port 1 with no serial activity in last seconds
if ( (LKHearthBeats-ComPortHB[0])>10 ) {
#ifdef DEBUGNPM
StartupStore(_T("... GPS Port 1 : no activity LKHB=%u CBHB=%u %s"),LKHearthBeats, ComPortHB[0],NEWLINE);
#endif
// if this is active and supposed to have a valid fix.., but no HB..
//.........这里部分代码省略.........
示例14: Reset
/**
* Resets both NMEAParsers (Port1 + Port2)
*/
void NMEAParser::Reset(void) {
// clear status
nmeaParser1._Reset();
nmeaParser2._Reset();
}