void CT_LbsClientPosTp2::CheckPositionCourseInfoL(TPositionCourseInfo& aCourseInfo) { CheckPositionInfoL(aCourseInfo); TCourse course; aCourseInfo.GetCourse(course); if (course.Heading() != KHeading || course.Speed() != KSpeed || course.SpeedAccuracy() != KSpeedAcc || course.HeadingAccuracy() != KHeadingAcc ) { _LIT(KErrCourse, "Course not correct"); LogErrorAndLeaveL(KErrCourse); } }
void CLcfPsyDummy3::GetPositionCourseInfoL(TPositionInfoBase& aPosInfo) { TPositionCourseInfo* courseInfo = static_cast<TPositionCourseInfo*>(&aPosInfo); TCourse course; // fill in course data course.SetHeading(DUMMY_HEADING); course.SetSpeed(DUMMY_SPEED); course.SetHeadingAccuracy(DUMMY_HEADING_ACCURACY); course.SetSpeedAccuracy(DUMMY_SPEED_ACCURACY); // store it in course info courseInfo->SetCourse(course); courseInfo->SetModuleId(ImplementationUid()); }
// --------------------------------------------------------- // CPosPSYClearPositionDataTest::CheckCourseInfoClearsL // // (other items were commented in a header). // --------------------------------------------------------- // void CPosPSYClearPositionDataTest::CheckCourseInfoClearsL( const TDesC& aPositionType) { TCourse course; TBool allIsCleared = ETrue; TPositionCourseInfo* courseInfo = static_cast<TPositionCourseInfo*> (iPosInfo); courseInfo->GetCourse(course); if (!Math::IsNaN(course.Speed())) { if (course.Speed() == KSpeed) { _LIT(KError, "Speed not cleared for "); AddMessageL(KError, aPositionType, EErrorMessage); allIsCleared = EFalse; } } if (!Math::IsNaN(course.Heading())) { if (course.Heading() == KHeading) { _LIT(KError, "Heading not cleared for "); AddMessageL(KError, aPositionType, EErrorMessage); allIsCleared = EFalse; } } if (!Math::IsNaN(course.SpeedAccuracy())) { if (course.SpeedAccuracy() == KSpeedAccuracy) { _LIT(KError, "Speed Accuracy not cleared for "); AddMessageL(KError, aPositionType, EErrorMessage); allIsCleared = EFalse; } } if (!Math::IsNaN(course.HeadingAccuracy())) { if (course.HeadingAccuracy() == KHeadingError) { _LIT(KError, "Heading Accuracy not cleared for "); AddMessageL(KError, aPositionType, EErrorMessage); allIsCleared = EFalse; } } if (allIsCleared) { _LIT(KInfo, "All TPositionCourseInfo fields were cleared for "); AddMessageL(KInfo, aPositionType, EInfoMessage); } }
//HBufC8* CAgentPosition::GetGPSBufferL(TPosition pos) // original MB HBufC8* CAgentPosition::GetGPSBufferL(TPositionSatelliteInfo satPos) { /* * If the number of satellites used to calculate the coordinates is < 4, we don't use * the fix */ if(satPos.NumSatellitesUsed() < 4 ) return HBufC8::NewL(0); CBufBase* buffer = CBufFlat::NewL(50); CleanupStack::PushL(buffer); TGPSInfo gpsInfo; // retrieve TPosition TPosition pos; satPos.GetPosition(pos); // insert filetime timestamp TTime now; now.UniversalTime(); //TInt64 filetime = GetFiletime(now); TInt64 filetime = TimeUtils::GetFiletime(now); gpsInfo.filetime.dwHighDateTime = (filetime >> 32); gpsInfo.filetime.dwLowDateTime = (filetime & 0xFFFFFFFF); gpsInfo.gps.FixType = GPS_FIX_3D; // we are sure at least 4 satellites have been used // insert lat-long-alt-time gpsInfo.gps.dblLatitude = pos.Latitude(); gpsInfo.gps.dblLongitude = pos.Longitude(); gpsInfo.gps.flAltitudeWRTSeaLevel = pos.Altitude(); gpsInfo.gps.stUTCTime = TSystemTime( pos.Time() ); gpsInfo.gps.dwValidFields = (GPS_VALID_UTC_TIME | GPS_VALID_LATITUDE | GPS_VALID_LONGITUDE | GPS_VALID_ALTITUDE_WRT_SEA_LEVEL); gpsInfo.gps.dwSatelliteCount = satPos.NumSatellitesUsed(); gpsInfo.gps.dwValidFields |= GPS_VALID_SATELLITE_COUNT; gpsInfo.gps.dwSatellitesInView = satPos.NumSatellitesInView(); gpsInfo.gps.dwValidFields |= GPS_VALID_SATELLITES_IN_VIEW; gpsInfo.gps.flHorizontalDilutionOfPrecision = satPos.HorizontalDoP(); gpsInfo.gps.dwValidFields |= GPS_VALID_HORIZONTAL_DILUTION_OF_PRECISION; gpsInfo.gps.flVerticalDilutionOfPrecision = satPos.VerticalDoP(); gpsInfo.gps.dwValidFields |= GPS_VALID_VERTICAL_DILUTION_OF_PRECISION; TCourse course; satPos.GetCourse(course); gpsInfo.gps.flSpeed = course.Speed(); gpsInfo.gps.dwValidFields |= GPS_VALID_SPEED; gpsInfo.gps.flHeading = course.Heading(); gpsInfo.gps.dwValidFields |= GPS_VALID_HEADING; /* * Additional data regarding the satellites can be obtained using the TSatelliteData structure. * Example: */ /* TInt numSat = satPos.NumSatellitesInView(); TInt err = KErrNone; for (int i=0; i<numSat; i++) { // Get satellite data TSatelliteData satData; err = satPos.GetSatelliteData(i,satData); if(err != KErrNone) { continue; } // Get info // See TSatelliteData definition for more methods. TReal32 azimuth = satData.Azimuth(); TInt satSignalStrength = satData.SignalStrength(); }*/ TUint32 type = TYPE_GPS; buffer->InsertL(0, &type, sizeof(TUint32)); buffer->InsertL(buffer->Size(), &gpsInfo, sizeof(TGPSInfo)); HBufC8* result = buffer->Ptr(0).AllocL(); CleanupStack::PopAndDestroy(buffer); return result; }
void XQLocationPrivate::DeliverPositionerResults(TPositionSatelliteInfo aPositionInfo) { TPosition pos; aPositionInfo.GetPosition(pos); // Handle speed reporting float speed = 0; if (speedAvailable) { // Positioning module is able to offer speed information TCourse course; aPositionInfo.GetCourse(course); speed = course.Speed(); if (isnan(speed)) { speed = 0; } } else { // Positioning module does not offer speed information // => Speed is calculated using position information & timestamps TTime posTime; TTimeIntervalSeconds interval; for (int i = iPositions.Count()-1 ; i >= 0; i--) { if (pos.Time().SecondsFrom(iPositions[i].Time(),interval) == KErrNone) { if (interval.Int() > 10) { pos.Speed(iPositions[i], speed); break; } } } while (iPositions.Count() > 0) { if (pos.Time().SecondsFrom(iPositions[0].Time(),interval) == KErrNone) { if (interval.Int() > 60) { iPositions.Remove(0); } else { break; } } } if (iPositions.Count() > 0) { if (pos.Time().SecondsFrom(iPositions[iPositions.Count()-1].Time(),interval) == KErrNone) { if (interval.Int() > 1) { iPositions.Append(pos); } } } else { iPositions.Append(pos); } // Accept speed from range 0.01 m/s (0.036 km/h) to 200 m/s (720 km/h) if (speed < 0.01 || speed > 200) { speed = 0; } } if (speed != iPreviousSpeed) { emit ipParent->speedChanged(speed); } iPreviousSpeed = speed; // Handle satellite information reporting if (satelliteInfoAvailable) { if (aPositionInfo.NumSatellitesInView() != iPreviousNumSatellitesInView) { emit ipParent->numberOfSatellitesInViewChanged(aPositionInfo.NumSatellitesInView()); } iPreviousNumSatellitesInView = aPositionInfo.NumSatellitesInView(); if (aPositionInfo.NumSatellitesUsed() != iPreviousNumSatellitesUsed) { emit ipParent->numberOfSatellitesUsedChanged(aPositionInfo.NumSatellitesUsed()); } iPreviousNumSatellitesUsed = aPositionInfo.NumSatellitesUsed(); } // Handle position information reporting if (iPreviousPosition.Latitude() != pos.Latitude() || iPreviousPosition.Longitude() != pos.Longitude() || iPreviousPosition.Altitude() != pos.Altitude()) { if (!isnan(pos.Latitude()) || !isnan(pos.Longitude()) || !isnan(pos.Altitude())) { emit ipParent->locationChanged(pos.Latitude(),pos.Longitude(),pos.Altitude(),speed); } if (iPreviousPosition.Latitude() != pos.Latitude()) { if (!isnan(pos.Latitude())) { emit ipParent->latitudeChanged(pos.Latitude(),pos.HorizontalAccuracy()); } } if (iPreviousPosition.Longitude() != pos.Longitude()) { if (!isnan(pos.Longitude())) { emit ipParent->longitudeChanged(pos.Longitude(),pos.HorizontalAccuracy()); } } if (iPreviousPosition.Altitude() != pos.Altitude()) { if (!isnan(pos.Altitude())) { emit ipParent->altitudeChanged(pos.Altitude(),pos.VerticalAccuracy()); } } } iPreviousPosition = pos; if (iSingleUpdate) { stopUpdates(); iSingleUpdate = EFalse; } }
void CNetworkGateway::ProcessNetworkLocationMessage(const TLbsNetLocMsgBase& aMessage) { LBSLOG(ELogP2, "CNetworkGateway::ProcessNetworkLocationMessage:"); LBSLOG2(ELogP3, "Type : %d", aMessage.Type()); switch (aMessage.Type()) { case TLbsNetLocMsgBase::ENetLocMsgNetworkLocationRequest: { TInt reason = KErrNone; const TLbsNetLocNetworkLocationRequestMsg& req = static_cast<const TLbsNetLocNetworkLocationRequestMsg&>(aMessage); iCurrentNetLocReqId = req.SessionId(); if (req.Quality().MaxFixTime() == 0)//answer req with incorrect session id { iCurrentNetLocReqId.SetSessionNum(999); TLbsNetLocNetworkLocationCompleteMsg msg(iCurrentNetLocReqId, reason); iNetworkLocationChannel->SendNetworkLocationMessage(msg); } else if (req.Quality().MaxFixTime() == 1)//answer req with unknown response type { TLbsNetLocNetworkLocationCancelMsg msg(iCurrentNetLocReqId, reason); iNetworkLocationChannel->SendNetworkLocationMessage(msg); } else { TLbsNetLocNetworkLocationCompleteMsg msg(iCurrentNetLocReqId, reason); iNetworkLocationChannel->SendNetworkLocationMessage(msg); } // for testing return a fixed test location TPositionCourseInfo posInfo; TPosition pos; pos.SetCoordinate(50, 80); posInfo.SetPosition(pos); TCourse course; course.SetSpeed(10.0); course.SetVerticalSpeed(20.0); course.SetHeading(30.0); course.SetSpeedAccuracy(1.0); course.SetVerticalSpeedAccuracy(2.0); course.SetHeadingAccuracy(3.0); course.SetCourse(40.0); course.SetCourseAccuracy(4.0); posInfo.SetCourse(course); iNetworkLocationChannel->SetReferencePosition(iCurrentNetLocReqId, posInfo); break; } case TLbsNetLocMsgBase::ENetLocMsgNetworkLocationCancel: { const TLbsNetLocNetworkLocationCancelMsg& cancel = static_cast<const TLbsNetLocNetworkLocationCancelMsg&>(aMessage); // for test netlocmanager, return the location info directly without sending request to network protocol iCurrentNetLocReqId = cancel.SessionId(); TInt reason = KErrNone; TLbsNetLocNetworkLocationCompleteMsg msg(iCurrentNetLocReqId, reason); iNetworkLocationChannel->SendNetworkLocationMessage(msg); break; } case TLbsNetLocMsgBase::ENetLocMsgNetworkLocationComplete: default: { break; } } }
TVerdict ClbsinternalapiTest3Step::doTestStepL() /** * @return - TVerdict code * Override of base class pure virtual * Our implementation only gets called if the base class doTestStepPreambleL() did * not leave. That being the case, the current test result value will be EPass. */ { if (TestStepResult()==EPass) { //Let's test! TPositionExtendedSatelliteInfo posSatInfo; RLbsPositionUpdates::InitializeL(posSatInfo); RLbsPositionUpdates posUpdates; //First Open, Close, re-Open to check for handle leaks etc. posUpdates.OpenL(KLbsGpsLocManagerUid); CleanupClosePushL(posUpdates); CleanupStack::PopAndDestroy(&posUpdates); posUpdates.OpenL(KLbsGpsLocManagerUid); CleanupClosePushL(posUpdates); //First, check the default data is OK. //Should be a default TPositionExtendedSatelliteInfo. TPositionExtendedSatelliteInfo satInfo; //Put some non-default data in it, then check we get the default data back. satInfo.SetSatelliteTime(TTime(500)); TInt error=1; TTime targetTime(100); TTime actualTime(200); TBool conflictControl; error = posUpdates.GetPositionInfo(conflictControl, &satInfo, sizeof(satInfo),targetTime, actualTime); //Now check we got deviuce not ready if(error!=KErrNotReady) User::Leave(KErrGeneral); //Now check that the same for TPositionInfo and TPositionCourseInfo TPositionInfo posInfo; posInfo.SetModuleId(KLbsGpsLocManagerUid); error = posUpdates.GetPositionInfo(conflictControl, &posInfo, sizeof(posInfo),targetTime, actualTime); if(error!=KErrNotReady) User::Leave(KErrGeneral); TPositionCourseInfo courseInfo; TCourse course; course.SetSpeed(TReal32(100)); courseInfo.SetCourse(course); error = posUpdates.GetPositionInfo(conflictControl, &courseInfo, sizeof(courseInfo),targetTime, actualTime); if(error!=KErrNotReady) User::Leave(KErrGeneral); //OK - we are now reasonably happy with Getting - it donsn't mash up the class size/type data //and it seems to be doing the data copying OK. //Next move onto the set method... //Choose some dummy values. error = KErrGeneral; targetTime = 1000; actualTime = 1001; satInfo.SetSatelliteTime(TTime(4020)); User::LeaveIfError(posUpdates.SetPositionInfo(error, EFalse, &satInfo, sizeof(satInfo),targetTime, actualTime)); error = posUpdates.GetPositionInfo(conflictControl, &satInfo, sizeof(satInfo),targetTime, actualTime); if(error!=KErrGeneral) User::Leave(KErrGeneral); if(conflictControl!=EFalse) User::Leave(KErrGeneral); if(targetTime!=1000) User::Leave(KErrGeneral); if(actualTime!=1001) User::Leave(KErrGeneral); if(satInfo.SatelliteTime()!=TTime(4020)) User::Leave(KErrGeneral); //Go on to check out notifications. //Open another handle. RLbsPositionUpdates posUpdates2; //First Open, Close, re-Open to check for handle leaks etc. posUpdates2.OpenL(KLbsGpsLocManagerUid); CleanupClosePushL(posUpdates2); TRequestStatus stat; posUpdates2.NotifyPositionUpdate(stat); User::LeaveIfError(posUpdates.SetPositionInfo(error, EFalse, &satInfo, sizeof(satInfo),targetTime, actualTime)); User::WaitForRequest(stat); if(stat.Int()!=KErrNone) User::Leave(KErrGeneral); //Now check the cancel. posUpdates2.NotifyPositionUpdate(stat); posUpdates2.CancelNotifyPositionUpdate(); User::WaitForRequest(stat); if(stat.Int()!=KErrCancel) User::Leave(KErrGeneral); CleanupStack::PopAndDestroy(2, &posUpdates); SetTestStepResult(EPass); } return TestStepResult(); }
void PsyUtils::TPositionInfo2QGeoPositionInfo(TPositionInfoBase &aPosInfoBase, QGeoPositionInfo& aQPosInfo) { if (aPosInfoBase.PositionClassType() & EPositionInfoClass || aPosInfoBase.PositionClassType() & EPositionSatelliteInfoClass) { TPositionInfo *posInfo = static_cast<TPositionInfo*>(&aPosInfoBase); TPosition pos; QGeoCoordinate coord; posInfo->GetPosition(pos); coord.setLatitude(pos.Latitude()); coord.setLongitude(pos.Longitude()); coord.setAltitude(pos.Altitude()); //store the QGeoCoordinate values aQPosInfo.setCoordinate(coord); TDateTime datetime = pos.Time().DateTime(); QDateTime dt(QDate(datetime.Year() , datetime.Month() + 1, datetime.Day() + 1), QTime(datetime.Hour() , datetime.Minute(), datetime.Second(), datetime.MicroSecond() / 1000), Qt::UTC); //store the time stamp aQPosInfo.setTimestamp(dt); //store the horizontal accuracy aQPosInfo.setAttribute(QGeoPositionInfo::HorizontalAccuracy, pos.HorizontalAccuracy()); //store the vertical accuracy aQPosInfo.setAttribute(QGeoPositionInfo::VerticalAccuracy, pos.VerticalAccuracy()); if (aPosInfoBase.PositionClassType() & EPositionSatelliteInfoClass) { TCourse course; TPositionSatelliteInfo *satInfo = static_cast<TPositionSatelliteInfo*>(&aPosInfoBase); satInfo->GetCourse(course); aQPosInfo.setAttribute(QGeoPositionInfo::Direction, course.Heading()); aQPosInfo.setAttribute(QGeoPositionInfo::GroundSpeed, course.Speed()); aQPosInfo.setAttribute(QGeoPositionInfo::VerticalSpeed, course.VerticalSpeed()); } } if (aPosInfoBase.PositionClassType() & EPositionGenericInfoClass) { HPositionGenericInfo *genInfo = static_cast<HPositionGenericInfo*>(&aPosInfoBase); float val; //check for the horizontal speed if (genInfo->IsFieldAvailable(EPositionFieldHorizontalSpeed)) { genInfo->GetValue(EPositionFieldHorizontalSpeed, val); aQPosInfo.setAttribute(QGeoPositionInfo::GroundSpeed, val); } //check for the vertcal speed if (genInfo->IsFieldAvailable(EPositionFieldVerticalSpeed)) { genInfo->GetValue(EPositionFieldVerticalSpeed, val); aQPosInfo.setAttribute(QGeoPositionInfo::VerticalSpeed, val); } //check for the magnetic variation if (genInfo->IsFieldAvailable(EPositionFieldMagneticCourseError)) { genInfo->GetValue(EPositionFieldMagneticCourseError, val); aQPosInfo.setAttribute(QGeoPositionInfo::MagneticVariation, val); } //check for the heading if (genInfo->IsFieldAvailable(EPositionFieldHeading)) { genInfo->GetValue(EPositionFieldHeading, val); aQPosInfo.setAttribute(QGeoPositionInfo::Direction, val); } } }