⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 filegpsreceiver.cpp

📁 SYMBIAN GPS NMEA协议实现
💻 CPP
字号:
/************************************************************************/
/* Bluteooth Test           The.Berlin.Factor                 Juni 2003 */
/************************************************************************/

#include <E32Math.h>

#include "util/FileUtils.h"

#include "gps/impl/FileGpsReceiver.h"



#define PI 3.14145

#define INITIAL_DELAY 500000
#define INTERVAL 500000



CFileGpsReceiver * CFileGpsReceiver::NewL( ) {

	CFileGpsReceiver * self = new ( ELeave ) CFileGpsReceiver( );

	CleanupStack::PushL( self );
	self->ConstructL();
	CleanupStack::Pop( );

	return( self );

}



CFileGpsReceiver::~CFileGpsReceiver( ) {

	delete( iHeartBeat ); iHeartBeat = NULL;
	delete( iFileData ); iFileData = NULL;

}



CFileGpsReceiver::CFileGpsReceiver( ) {

}



void CFileGpsReceiver::ConstructL( ) {

	_LIT8( KDataFileName, "FileGpsReceiver.nmea" );
	iFileData = NFileUtils::LoadAppFileL( KDataFileName );

	TTimeIntervalMicroSeconds32 delay( INITIAL_DELAY );
	TTimeIntervalMicroSeconds32 interval( INTERVAL );
	TCallBack callBack( HeartBeat, this );

	iHeartBeat = CPeriodic::New( CActive::EPriorityStandard );
	iHeartBeat->Start( delay, interval, callBack );

}



void CFileGpsReceiver::AdvanceSimulation( ) {

	TBuf8< 256 > nmeaCommand;
	GetNextCommand( nmeaCommand );

	ProcessMessageL( nmeaCommand );

}



void CFileGpsReceiver::GetNextCommand( TDes8 & aNewCommand ) {

	TPtr8 data = iFileData->Des( );

	for ( TInt idx = 0; idx < aNewCommand.MaxLength( ); idx++ ) {

		TInt offset = iFileIndex + idx;

		if ( offset >= iFileData->Length( ) )
			offset -= iFileData->Length( );

		TChar nextChar = data[ offset ];

		aNewCommand.Append( nextChar );

		// Bei \r abbrechen
		if ( nextChar == 0x0a )
			break;
	}

	iFileIndex += aNewCommand.Length( );

	if ( iFileIndex >= iFileData->Length( ) )
		iFileIndex = 0;

}



TInt CFileGpsReceiver::HeartBeat( TAny * aPtr ) {

	CFileGpsReceiver * gpsReceiver = STATIC_CAST( CFileGpsReceiver *, aPtr );

	gpsReceiver->AdvanceSimulation( );

	return( 0 );

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -