void CNetworkPsy2::ConfigPsyL(const HPositionGenericInfo& aGenInfo) { TInt32 configUid; User::LeaveIfError(aGenInfo.GetValue(KIntGpsPsy1ConfigPsyUid, configUid)); if(configUid!=iUid.iUid) { User::Leave(KErrNotSupported); } iPsyConfigArray.Reset(); iCurrentIndex = 0; TInt32 numOfItem; User::LeaveIfError(aGenInfo.GetValue(KIntGpsPsy1ConfigItemsNumber, numOfItem)); for(TInt i=0; i<numOfItem; i++) { TPsyConfig psyConfig; TPckg<TPsyConfig> configBuf(psyConfig); User::LeaveIfError(aGenInfo.GetValue(KIntGpsPsy1ConfigItemsNumber+i+1, configBuf)); User::LeaveIfError(iPsyConfigArray.Append(psyConfig)); } }
// ----------------------------------------------------------------------------- // PosGenericInfoUser::CopyData // ----------------------------------------------------------------------------- // template < class T > TInt PosGenericInfoUser::CopyData( const HPositionGenericInfo& aSrc, HPositionGenericInfo& aDes, TInt aFieldId ) { T data; TInt err( KErrNone ); err = aSrc.GetValue( aFieldId, data ); if ( err != KErrNone ) { return err; } return aDes.SetValue( aFieldId, data ); }
// ----------------------------------------------------------------------------- // PosGenericInfoUser::CopyField // ----------------------------------------------------------------------------- // TInt PosGenericInfoUser::CopyField( const HPositionGenericInfo& aSrc, HPositionGenericInfo& aDes, TInt aFieldId ) { //Get field data type TInt dataType; TBool isList; TInt err( KErrNone ); err = FieldDataType( aFieldId, dataType, isList ); if ( err != KErrNone ) { return err; } if ( isList ) { //copy list TUint8 count; //length of the list err = aSrc.GetValue( aFieldId, count ); if ( err != KErrNone ) { return err; } for ( TInt i = 0; i < count; i++ ) { err = CopyDataByType( aSrc, aDes, aFieldId + 1 + i, dataType ); if ( err != KErrNone ) { return err; } } err = aDes.SetValue( aFieldId, count ); } else { err = CopyDataByType( aSrc, aDes, aFieldId, dataType ); } return err; }
// --------------------------------------------------------- // CPosPSYClearPositionDataTest::CheckGenericInfoClearsL // // (other items were commented in a header). // --------------------------------------------------------- // void CPosPSYClearPositionDataTest::CheckGenericInfoClearsL() { TBuf<KClearPositionDataBufSize> buf; TReal32 real32Num(0); TInt8 shortNum(0); TTime time(0); TUint8 unsignedShortNum(0); HPositionGenericInfo* genInfo = static_cast<HPositionGenericInfo*> (iPosInfo); if (genInfo->GetValue(EPositionFieldCountry, buf) != KErrNotFound && genInfo->GetValue(EPositionFieldCountryCode, buf) != KErrNotFound && genInfo->GetValue(EPositionFieldState, buf) != KErrNotFound && genInfo->GetValue(EPositionFieldCity, buf) != KErrNotFound && genInfo->GetValue(EPositionFieldDistrict, buf) != KErrNotFound && genInfo->GetValue(EPositionFieldStreet, buf) != KErrNotFound && genInfo->GetValue(EPositionFieldStreetExtension, buf) != KErrNotFound && genInfo->GetValue(EPositionFieldLocationName, buf) != KErrNotFound && genInfo->GetValue(EPositionFieldPostalCode, buf) != KErrNotFound && genInfo->GetValue(EPositionFieldLocality, buf) != KErrNotFound && genInfo->GetValue(EPositionFieldCrossing1, buf) != KErrNotFound && genInfo->GetValue(EPositionFieldCrossing2, buf) != KErrNotFound && genInfo->GetValue(EPositionFieldHorizontalSpeed, real32Num) != KErrNotFound && genInfo->GetValue(EPositionFieldHorizontalSpeedError, real32Num) != KErrNotFound && genInfo->GetValue(EPositionFieldVerticalSpeedError, real32Num) != KErrNotFound && genInfo->GetValue(EPositionFieldVerticalSpeed, real32Num) != KErrNotFound && genInfo->GetValue(EPositionFieldHeading, real32Num) != KErrNotFound && genInfo->GetValue(EPositionFieldHeadingError, real32Num) != KErrNotFound && genInfo->GetValue(EPositionFieldTrueCourse, real32Num) != KErrNotFound && genInfo->GetValue(EPositionFieldTrueCourseError, real32Num) != KErrNotFound && genInfo->GetValue(EPositionFieldMagneticCourse, real32Num) != KErrNotFound && genInfo->GetValue(EPositionFieldBuildingName, buf) != KErrNotFound && genInfo->GetValue(EPositionFieldBuildingFloor, buf) != KErrNotFound && genInfo->GetValue(EPositionFieldBuildingRoom, buf) != KErrNotFound && genInfo->GetValue(EPositionFieldBuildingZone, buf) != KErrNotFound && genInfo->GetValue(EPositionFieldBuildingTelephone, buf) != KErrNotFound && genInfo->GetValue(EPositionFieldNMEASentences, unsignedShortNum) != KErrNotFound && genInfo->GetValue(EPositionFieldNMEASentencesStart, buf) != KErrNotFound && genInfo->GetValue(EPositionFieldSatelliteNumInView, shortNum) != KErrNotFound && genInfo->GetValue(EPositionFieldSatelliteNumUsed, shortNum) != KErrNotFound && genInfo->GetValue(EPositionFieldSatelliteTime, time) != KErrNotFound && genInfo->GetValue(EPositionFieldSatelliteHorizontalDoP, real32Num) != KErrNotFound && genInfo->GetValue(EPositionFieldSatelliteVerticalDoP, real32Num) != KErrNotFound && genInfo->GetValue(EPositionFieldSatelliteTimeDoP, real32Num) != KErrNotFound && genInfo->GetValue(EPositionFieldSatellitePositionDoP, real32Num) != KErrNotFound && genInfo->GetValue(EPositionFieldSatelliteSeaLevelAltitude, real32Num) != KErrNotFound && genInfo->GetValue(EPositionFieldSatelliteGeoidalSeparation, real32Num) != KErrNotFound && genInfo->GetValue(EPositionFieldMediaLinks, unsignedShortNum) != KErrNotFound && genInfo->GetValue(EPositionFieldMediaLinksStart, buf) != KErrNotFound) { _LIT(KError, "All HPositionGenericInfo fields were not cleared for HPositionGenericInfo."); AddTestResultL(KError, EErrorMessage); } else { _LIT(KInfo, "All HPositionGenericInfo fields were cleared for HPositionGenericInfo."); AddTestResultL(KInfo, EInfoMessage); } }
TVerdict CTrackingSessionStep::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. */ { StandardPrepareL(); const TInt KInterval = 1 * KSecondsToMicro; const TTimeIntervalMicroSeconds KFirstRequestDelay = 200 * 1000; // 0.2 sec const TTimeIntervalMicroSeconds KNormalRequestDelay = 200 * 1000; // 0.2 sec const TInt KDiff = 200 * 1000; // 0.2 sec const TInt KIntervalError = 100 * 1000; // 0.1 sec TRequestStatus status; TWatch watch; TTime secondRequest, stopTracking; TInt interval; HPositionGenericInfo* genInfo = HPositionGenericInfo::NewLC(); // setup : only PSY6 ToggleModuleL(KUidLcfPsy1, EFalse); ToggleModuleL(KUidLcfPsy3, EFalse); User::After(KSecond * 7); InitPsyListInDefaultProxyL(); // make one request to allow default proxy rebuild its database // this will guarantee that first request will be as fast as possible TPositionCourseInfo courseInfo; PositionRequestWithCheck(courseInfo, KErrArgument, KNullUid); // setup tracking session TPositionUpdateOptions updateOptions; updateOptions.SetUpdateInterval(KInterval); iPositioner.SetUpdateOptions(updateOptions); // 1st request // first request must be quick watch.Tick(); PositionRequestWithCheck(*genInfo, KErrNone, KUidLcfPsy6); if(watch.ElapsedFromTick() > KFirstRequestDelay) { ERR_PRINTF1(KFirstDelayTooLong); SetTestStepResult(EFail); } // drop delay and make 2nd and 3rd requests genInfo->ClearRequestedFields(); { watch.Tick(); PositionRequestWithCheck(*genInfo, KErrNone, KUidLcfPsy6); secondRequest.UniversalTime(); interval = (TInt) watch.ElapsedFromTick().Int64(); if(Abs(interval - KInterval) > KIntervalError) { ERR_PRINTF1(KSecondDelayOutOfRange); SetTestStepResult(EFail); } watch.Tick(); PositionRequestWithCheck(*genInfo, KErrNone, KUidLcfPsy6); interval = watch.ElapsedFromTick().Int64(); if(Abs(interval - KInterval) > KIntervalError) { ERR_PRINTF1(KThirdDelayOutOfRange); SetTestStepResult(EFail); } } // stop tracking updateOptions.SetUpdateInterval(TTimeIntervalMicroSeconds(0)); iPositioner.SetUpdateOptions(updateOptions); stopTracking.UniversalTime(); // psy6 must return event log genInfo->SetRequestedField(KPSY6FieldEventLog); watch.Tick(); PositionRequestWithCheck(*genInfo, KErrNone, KUidLcfPsy6); if(watch.ElapsedFromTick() > KNormalRequestDelay) { ERR_PRINTF1(KNormalDelayTooBig); SetTestStepResult(EFail); } // Analyze event log from PSY6 TQueryEvent* eventArray = GetPsy6EventLogL(*genInfo); TInt32 logSize; if(KErrNone != genInfo->GetValue(KPSY6FieldEventLogSize, logSize)) { ERR_PRINTF1(KFailedReadLogsize); SetTestStepResult(EFail); return TestStepResult(); } TUint expectedEvents[] = {EUpdate, ETrackingStart, EUpdate, EUpdate, ETrackingStop, EUpdate}; TUint numExpectedEvents = sizeof(expectedEvents) / sizeof(TUint); CheckExpectedResult(logSize, numExpectedEvents, KWrongEventNumberPSY6); // check event types for (TInt32 index = 0; index < Min(logSize, numExpectedEvents); index++) { TQueryEvent& event = *(eventArray + index); CheckExpectedResult(event.iEventType, expectedEvents[index], KUnexpectedEvent); } // check event times if(logSize != numExpectedEvents) { ERR_PRINTF1(KCannotCheckEventTimes); SetTestStepResult(EFail); return TestStepResult(); } // ( ETrackingStart should have happenned right after first // request was completed ) // Harley: Because of intelligent Default Proxy change, the tracking start // shall happen just before the second location request is issued to the PSY. TQueryEvent& event = *(eventArray + 1); if(Abs(secondRequest.MicroSecondsFrom(event.iTime).Int64()) > KDiff) { ERR_PRINTF1(KStartEventBeyondExpectendRange); SetTestStepResult(EFail); } // ETrackingStop should have happenned right after second // SetUpdateOptions event = *(eventArray + 4); if(Abs(stopTracking.MicroSecondsFrom(event.iTime).Int64()) > KDiff) { ERR_PRINTF1(KStopEventBeyondExpectendRange); SetTestStepResult(EFail); } // cleanup CleanupStack::PopAndDestroy(genInfo); StandardCleanup(); 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); } } }