本文整理汇总了C++中TPosition::SetTime方法的典型用法代码示例。如果您正苦于以下问题:C++ TPosition::SetTime方法的具体用法?C++ TPosition::SetTime怎么用?C++ TPosition::SetTime使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TPosition
的用法示例。
在下文中一共展示了TPosition::SetTime方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
// ---------------------------------------------------------
// CT_LbsInstallPsyTp273::NotifyPositionUpdate
//
// (other items were commented in a header).
// ---------------------------------------------------------
//
void CT_LbsInstallPsyTp273::NotifyPositionUpdate(
TPositionInfoBase& aPosInfo,
TRequestStatus& aStatus)
{
TInt err = KErrNone;
TTime tt;
tt.UniversalTime();
//Request ID must be unique, use universalime as seed
// to give a random number
TInt64 seed = tt.Int64();
TReal lat = 90 * Math::FRand(seed);
TReal lon = 90 * Math::FRand(seed);
TReal32 alt = (TReal32)(90 * Math::FRand(seed));
TPositionInfo* position = static_cast<TPositionInfo*> (&aPosInfo);
TUid implUid = { KPosImplementationUid };
position->SetModuleId(implUid);
TTime now;
now.UniversalTime();
TPosition posse;
posse.SetCoordinate(lat, lon, alt);
posse.SetTime(now);
position->SetPosition(posse);
TRequestStatus* status = &aStatus;
User::RequestComplete(status, err);
}
示例2: LocationUpdate
/** Adjusts system time if required. The decision whether the adjustment is needed or not
is based on the following criterias:
- satellite time must be present in the location update
- time threshold must be exceeded
- time from a last adjustment is greater than a defined interval.
@param aStatus An error code.
@param TPositionSatelliteInfo Position and time information.
If clock adjustment takes place the TPosition::iTime is
re-set to the satellite time.
@see CLbsAdmin
@see TPositionSatelliteInfo
*/
void CAutoClockAdjust::LocationUpdate(TInt aStatus, TPositionSatelliteInfo& aPosInfo)
{
LBSLOG(ELogP1, "CAutoClockAdjust::LocationUpdate()\n");
TTimeIntervalMicroSeconds timeCorr;
TTime sysTime;
TInt err;
// If adjustment on, no error, and satellite information present
if ((iClockAdjustSetting == CLbsAdmin::EClockAdjustOn) && (aStatus == KErrNone) &&
((aPosInfo.PositionClassType() & EPositionSatelliteInfoClass) == EPositionSatelliteInfoClass))
{
// Is is time do do another time adjustment?
sysTime.UniversalTime();
if (Abs(sysTime.MicroSecondsFrom(iLastAdjustment).Int64()) > (1000*iAdjustInterval))
{
const TPositionSatelliteInfo& satInfo = static_cast<const TPositionSatelliteInfo&>(aPosInfo);
err = CalculateTimeCorrection(satInfo, timeCorr);
if (err == KErrNone)
{
// Is threshold exceeded?
if (Abs(timeCorr.Int64()) > (1000*iAdjustThreshold))
{
sysTime.UniversalTime();
sysTime += timeCorr;
LBSLOG(ELogP9, "->S CGpsSetClockBase::SetUTCTime() ClockModule\n");
LBSLOG5(ELogP9, " > TTime sysTime = %02d:%02d:%02d.%06d\n", sysTime.DateTime().Hour(),
sysTime.DateTime().Minute(),
sysTime.DateTime().Second(),
sysTime.DateTime().MicroSecond());
err = iSetClockImpl->SetUTCTime(sysTime);
LBSLOG2(ELogP9, " Return = %d\n", err);
if (err == KErrNone)
{
// Sync the position time with the satellite time
// to avoid re-adjusting the system time by the manual clock adjustment component.
TPosition pos;
aPosInfo.GetPosition(pos);
pos.SetTime(aPosInfo.SatelliteTime());
aPosInfo.SetPosition(pos);
LBSLOG2(ELogP2, "ACTION: Clock Adjusted by %ld\n", timeCorr.Int64());
}
}
if (err == KErrNone)
{
// Remember the current time even if threshold not exceeded
iLastAdjustment = sysTime;
}
else
{
LBSLOG_WARN2(ELogP3, "Clock Adjustment failed. Error: %d\n", err);
}
}
}
}
}