104 return m_astr.
IsEmpty() ? _T(
"") : m_astr[0];
115 return m_astr.
IsInRange(index) ? m_astr[index] : _T(
"");
126 return m_astr.
IsInRange(index) ? m_astr[index].ToInt() : 0;
137 return m_astr.
IsInRange(index) ? m_astr[index].ToDouble() : 0.0;
270 m_inner.m_pListener = pListener;
287 if ( ::SystemTimeToFileTime(&m_inner.m_gpZda, &ft1) && ::FileTimeToLocalFileTime(&ft1, &ft2) )
289 ::FileTimeToSystemTime(&ft2, &_tm);
290 DWORD r = ::GetTickCount() - m_inner.m_tickZda;
309 _gga = m_inner.m_gpGga;
310 DWORD r = ::GetTickCount() - m_inner.m_tickGga;
328 _gsvs = m_inner.m_gpGsvs;
329 DWORD r = ::GetTickCount() - m_inner.m_tickGsv;
335 TRACE2(
"Nmea;GSV[%d] 衛星No=%d, ", i + 1, _gsvs[i].satelliteNumber);
336 TRACE3(
"仰角=%d, 方位=%d, SNR=%d\n", _gsvs[i].angleOfElevation, _gsvs[i].direction, _gsvs[i].snr);
357 _rmc = m_inner.m_gpRmc;
358 DWORD r = ::GetTickCount() - m_inner.m_tickRmc;
383 DEFPARENTLISTENER(
CNmea0183, IParentListener);
385 IParentListener* m_pListener;
403 TInner(
void) : m_isAnalying(false), m_pListener(NULL)
405 DWORD w = ::GetTickCount();
412 void NotifyNmeaReceivedLine(
const CLineInfo& li)
418 sm.
wYear =
static_cast<WORD
>(li.GetInt(4));
419 sm.
wMonth =
static_cast<WORD
>(li.GetInt(2));
420 sm.
wDay =
static_cast<WORD
>(li.GetInt(3));
422 double tm = li.GetDouble(1);
423 sm.
wHour =
static_cast<WORD
>(int(tm / 10000) % 100);
424 sm.
wMinute =
static_cast<WORD
>(int(tm / 100) % 100);
425 sm.
wSecond =
static_cast<WORD
>(int(tm) % 100);
428 m_tickZda = ::GetTickCount();
436 double tm = li.GetDouble(1);
437 g.utc.
wHour =
static_cast<WORD
>(int(tm / 10000) % 100);
438 g.utc.wMinute =
static_cast<WORD
>(int(tm / 100) % 100);
439 g.utc.wSecond =
static_cast<WORD
>(int(tm) % 100);
440 g.utc.wMilliseconds =
static_cast<WORD
>(int(tm * 1000) % 1000);
442 g.isValid = (li.GetString(2)[0] ==
'A');
444 g.latitude = li.GetDouble(3);
445 g.isNorth = (li.GetString(4)[0] ==
'N');
447 g.longitude = li.GetDouble(5);
448 g.isEast = (li.GetString(6)[0] ==
'E');
450 g.speed = li.GetDouble(7);
452 g.degree = li.GetDouble(8);
454 int sm = li.GetInt(9);
456 g.utc.
wYear =
static_cast<WORD
>(y + ((y < 50) ? 2000 : 1900));
457 g.utc.wMonth =
static_cast<WORD
>((sm / 100) % 100);
458 g.utc.wDay =
static_cast<WORD
>((sm / 10000) % 100);
459 g.utc.wDayOfWeek = 0;
462 m_tickRmc = ::GetTickCount();
470 double tm = li.GetDouble(1);
471 g.hour =
static_cast<WORD
>(int(tm / 10000) % 100);
472 g.minute =
static_cast<WORD
>(int(tm / 100) % 100);
473 g.second =
static_cast<WORD
>(int(tm) % 100);
474 g.ms =
static_cast<WORD
>(int(tm * 1000) % 1000);
476 g.latitude = li.GetDouble(2);
477 g.isNorth = (li.GetString(3)[0] ==
'N');
479 g.longitude = li.GetDouble(4);
480 g.isEast = (li.GetString(5)[0] ==
'E');
482 g.gpsQuality =
static_cast<WORD
>(li.GetInt(6));
483 g.satelliteNumber =
static_cast<WORD
>(li.GetInt(7));
484 g.hdop = li.GetDouble(8);
485 g.height = li.GetDouble(9);
486 if ( li.GetString(10)[0] ==
'f' )
491 g.altitudeDifference = li.GetDouble(11);
492 if ( li.GetString(12)[0] ==
'f' )
495 g.altitudeDifference *= 0.3048;
497 g.dgpsData = li.GetDouble(13);
498 g.dgpsId =
static_cast<WORD
>(li.GetInt(14));
501 m_tickGga = ::GetTickCount();
507 int all = li.GetInt(1);
508 int no = li.GetInt(2);
518 if ( li.GetSize() <= j + 3 )
523 g.satelliteNumber =
static_cast<WORD
>(li.GetInt(j));
524 g.angleOfElevation =
static_cast<WORD
>(li.GetInt(j + 1));
525 g.direction =
static_cast<WORD
>(li.GetInt(j + 2));
526 g.snr =
static_cast<WORD
>(li.GetInt(j + 3));
533 m_tickGsv = ::GetTickCount();
534 m_gpGsvs = m_gpGsvsTmp;
537 if ( m_pListener != NULL )
539 m_pListener->OnNmeaReceivedLine(li);
543 void NotifyNmeaError(
EErrorCode e, LPARAM lParam)
545 if ( m_pListener != NULL )
547 m_pListener->OnNmeaError(e, lParam);
568 NotifyNmeaError(
EC_End, 0);
582 if ( ! m_isAnalying )
588 if ( b ==
'\n' || b ==
'\r' || b == 0 )
595 for (
size_t i = 1; i < len; i++ )
597 if ( c.
At(i) ==
'$' )
599 TRACE1(
"Nmea;skip %d\n", i);
604 TRACE1(
"Nmea;skip %d\n", len);
609 if ( len < 1 + 1 + 3 )
617 TRACE0(
"Nmea;found header'$'\n");
624 if ( b ==
'\n' || b ==
'$' || b == 0 )
627 TRACE0(
"Nmea;found known char\n");
628 m_isAnalying =
false;
632 else if ( b ==
'*' && (len - i) < 3 )
636 else if ( b ==
',' || b ==
'*' )
643 m_checkSum ^= c.
At(j);
646 TRACE2(
"(%d) %s\n", m_queStr.
GetSize(), s);
660 if ( h < 0 || l < 0 )
662 TRACE1(
"Nmea;invalid checksum char skip %d\n", m_checkSize + 1);
664 m_isAnalying =
false;
667 BYTE sum =
static_cast<BYTE
>(h << 4 | l);
668 if ( m_checkSum == sum )
671 TRACE0(
"Nmea;found valid line!!\n");
672 CLineInfo li(m_queStr);
673 NotifyNmeaReceivedLine(li);
677 TRACE1(
"Nmea;checksum error!! skip %d\n", m_checkSize + 3);
678 if ( m_pListener != NULL )
683 m_isAnalying =
false;
696 friend class CNmea0183Test;
#define loop(VAR, CNT)
loop構文.
size_t GetSize(void) const
[取得] パラメータ数取得.
double GetDouble(INDEX index) const
[取得] double型取得.
LPCTSTR GetString(INDEX index) const
[取得] 文字型取得.
LPCTSTR GetName(void) const
[取得] 名前取得.
CStr MakeLineString(bool withCheckSum=true) const
[作成] 一行文字列作成
CLineInfo(const CStrVector &vs)
コンストラクタ
int GetInt(INDEX index) const
[取得] int型取得.
virtual bool ExistGps(void) const
[確認] GPS確認.
bool GetZdaData(SYSTEMTIME &_tm, DWORD tick=2000) const
[取得] ZDAデータ取得.
bool GetGsvData(CVectorT< TGpGsv > &_gsvs, DWORD tick=2000) const
[取得] GSVデータ取得.
bool GetRmcData(TGpRmc &_rmc, DWORD tick=2000) const
[取得] RMCデータ取得.
bool GetGgaData(TGpGga &_gga, DWORD tick=2000) const
[取得] GGAデータ取得.
void SetEnvironment(IReport *pReport, IListener *pListener=NULL)
[設定] 環境設定.
@ EC_End
終了。クローズされた。lParam は0。
@ EC_UnknownDatas
不明なデータ(SkipData)。lParamは長さ。
@ EC_CheckSumError
チェックサムエラー。HIWORD(lParam)は受信SUM、LOWORD(lParam) は計算SUM。
@ EC_Disconnect
切断。lParam は0。
@ EC_Connect
接続。lParam は0。
void SetEnvironment(IReport *pReport, IListener *pListener)
[設定] 環境設定
bool IsAlive(void) const
[確認] Aliveチェック.
bool IsConnect(void) const
[確認] 接続チェック
bool HasEvent(void) const
[確認] Event(Error)を持っている
EReportEvent GetEvent(void) const
[取得] イベントコード取得
size_t GetLength(void) const
[取得] 文字列長
static CStrT Fmt(const TCHAR *lpszFormat,...)
[作成] 書式付き文字列作成
virtual size_t GetSize(void) const
[取得] サイズ取得
virtual bool RemoveAll(void)
[削除] 空化
virtual INDEX Add(const TYP &t)
[追加] 要素一つ追加.
int Compare(LPCSTR P1, LPCSTR P2, INT_PTR len=-1, DWORD dwCmpFlags=0)
[比較] 文字列比較(ASCII/SJIS用)
int HexCharToInt(int c)
[変換] HEX文字数値変換
#define EXCLUSIVE(CLS)
簡易排他制御マクロ.
@ ReportEvent_Disconnect
切断.
virtual ~IListener(void)
デストラクタ
virtual void OnNmeaError(EErrorCode e, LPARAM lParam)=0
[通知] エラー通知.
virtual void OnNmeaReceivedLine(const CLineInfo &li)=0
[通知] 正常ライン取得通知.
Global Positioning System Fix Data
double dgpsData
DGPSデータのエイジ(秒)
double height
平均海水面からのアンテナ高度(m)
WORD gpsQuality
GPSクオリティ 0=受信不能 1=単独測位 2=DGPS
double altitudeDifference
平均高度差
WORD satelliteNumber
受信衛星数
Recommended Minimum Specific GNSS Data
bool IsEmpty(void) const
[確認] 要素の有無確認.
virtual const TYP & At(INDEX index) const =0
[取得] 要素の参照取得.
bool IsInRange(INDEX index) const
[確認] INDEXの有効確認.
virtual size_t GetSize(void) const =0
[取得] 要素数取得.