public StandardUserSystemClockCore(StandardLocalSystemClockCore localSystemClockCore, StandardNetworkSystemClockCore networkSystemClockCore) : base(localSystemClockCore.GetSteadyClockCore()) { _localSystemClockCore = localSystemClockCore; _networkSystemClockCore = networkSystemClockCore; _autoCorrectionEnabled = false; _autoCorrectionTime = SteadyClockTimePoint.GetRandom(); _autoCorrectionEvent = null; }
public SteadyClockTimePoint GetCurrentTimePoint(ITickSource tickSource) { SteadyClockTimePoint result = GetTimePoint(tickSource); result.TimePoint += GetTestOffset().ToSeconds(); result.TimePoint += GetInternalOffset().ToSeconds(); return(result); }
public SteadyClockTimePoint GetCurrentTimePoint(KThread thread) { SteadyClockTimePoint result = GetTimePoint(thread); result.TimePoint += GetTestOffset().ToSeconds(); result.TimePoint += GetInternalOffset().ToSeconds(); return(result); }
public override SteadyClockTimePoint GetTimePoint(ITickSource tickSource) { SteadyClockTimePoint result = new SteadyClockTimePoint { TimePoint = GetCurrentRawTimePoint(tickSource).ToSeconds(), ClockSourceId = GetClockSourceId() }; return(result); }
public bool IsClockSetup(ITickSource tickSource) { ResultCode result = GetClockContext(tickSource, out SystemClockContext context); if (result == ResultCode.Success) { SteadyClockTimePoint steadyClockTimePoint = _steadyClockCore.GetCurrentTimePoint(tickSource); return(steadyClockTimePoint.ClockSourceId == context.SteadyTimePoint.ClockSourceId); } return(false); }
public static ResultCode GetCurrentTime(out long currentTime, SteadyClockTimePoint steadyClockTimePoint, SystemClockContext context) { currentTime = 0; if (steadyClockTimePoint.ClockSourceId == context.SteadyTimePoint.ClockSourceId) { currentTime = steadyClockTimePoint.TimePoint + context.Offset; return(ResultCode.Success); } return(ResultCode.TimeMismatch); }
public override SteadyClockTimePoint GetTimePoint(ITickSource tickSource) { SteadyClockTimePoint result = new SteadyClockTimePoint { TimePoint = 0, ClockSourceId = GetClockSourceId() }; TimeSpanType ticksTimeSpan = TimeSpanType.FromTicks(tickSource.Counter, tickSource.Frequency); result.TimePoint = ticksTimeSpan.ToSeconds(); return(result); }
public override SteadyClockTimePoint GetTimePoint(KThread thread) { SteadyClockTimePoint result = new SteadyClockTimePoint { TimePoint = 0, ClockSourceId = GetClockSourceId() }; TimeSpanType ticksTimeSpan = TimeSpanType.FromTicks(thread.Context.CntpctEl0, thread.Context.CntfrqEl0); result.TimePoint = _setupValue + ticksTimeSpan.ToSeconds(); return(result); }
public bool IsStandardNetworkSystemClockAccuracySufficient(KThread thread) { SteadyClockCore steadyClockCore = GetSteadyClockCore(); SteadyClockTimePoint currentTimePoint = steadyClockCore.GetCurrentTimePoint(thread); bool isStandardNetworkClockSufficientAccuracy = false; if (_context.SteadyTimePoint.GetSpanBetween(currentTimePoint, out long outSpan) == ResultCode.Success) { isStandardNetworkClockSufficientAccuracy = outSpan * 1000000000 < _standardNetworkClockSufficientAccuracy.NanoSeconds; } return(isStandardNetworkClockSufficientAccuracy); }
public bool IsClockSetup(KThread thread) { ResultCode result = GetSystemClockContext(thread, out SystemClockContext context); if (result == ResultCode.Success) { SteadyClockCore steadyClockCore = GetSteadyClockCore(); SteadyClockTimePoint steadyClockTimePoint = steadyClockCore.GetCurrentTimePoint(thread); return(steadyClockTimePoint.ClockSourceId == context.SteadyTimePoint.ClockSourceId); } return(false); }
public bool IsStandardNetworkSystemClockAccuracySufficient(ITickSource tickSource) { SteadyClockCore steadyClockCore = GetSteadyClockCore(); SteadyClockTimePoint currentTimePoint = steadyClockCore.GetCurrentTimePoint(tickSource); bool isStandardNetworkClockSufficientAccuracy = false; ResultCode result = GetClockContext(tickSource, out SystemClockContext context); if (result == ResultCode.Success && context.SteadyTimePoint.GetSpanBetween(currentTimePoint, out long outSpan) == ResultCode.Success) { isStandardNetworkClockSufficientAccuracy = outSpan * 1000000000 < _standardNetworkClockSufficientAccuracy.NanoSeconds; } return(isStandardNetworkClockSufficientAccuracy); }
public ResultCode SetCurrentTime(ITickSource tickSource, long posixTime) { SteadyClockTimePoint currentTimePoint = _steadyClockCore.GetCurrentTimePoint(tickSource); SystemClockContext clockContext = new SystemClockContext() { Offset = posixTime - currentTimePoint.TimePoint, SteadyTimePoint = currentTimePoint }; ResultCode result = SetClockContext(clockContext); if (result == ResultCode.Success) { result = Flush(clockContext); } return(result); }
public ResultCode GetSpanBetween(SteadyClockTimePoint other, out long outSpan) { outSpan = 0; if (ClockSourceId == other.ClockSourceId) { try { outSpan = checked (other.TimePoint - TimePoint); return(ResultCode.Success); } catch (OverflowException) { return(ResultCode.Overflow); } } return(ResultCode.Overflow); }
public ResultCode GetCurrentTime(ITickSource tickSource, out long posixTime) { posixTime = 0; SteadyClockTimePoint currentTimePoint = _steadyClockCore.GetCurrentTimePoint(tickSource); ResultCode result = GetClockContext(tickSource, out SystemClockContext clockContext); if (result == ResultCode.Success) { result = ResultCode.TimeMismatch; if (currentTimePoint.ClockSourceId == clockContext.SteadyTimePoint.ClockSourceId) { posixTime = clockContext.Offset + currentTimePoint.TimePoint; result = 0; } } return(result); }
public override SteadyClockTimePoint GetTimePoint(KThread thread) { SteadyClockTimePoint result = new SteadyClockTimePoint { TimePoint = 0, ClockSourceId = GetClockSourceId() }; TimeSpanType ticksTimeSpan; // As this may be called before the guest code, we support passing a null thread to make this api usable. if (thread == null) { ticksTimeSpan = TimeSpanType.FromSeconds(0); } else { ticksTimeSpan = TimeSpanType.FromTicks(thread.Context.CntpctEl0, thread.Context.CntfrqEl0); } result.TimePoint = ticksTimeSpan.ToSeconds(); return(result); }
public virtual TimeSpanType GetCurrentRawTimePoint(KThread thread) { SteadyClockTimePoint timePoint = GetTimePoint(thread); return(TimeSpanType.FromSeconds(timePoint.TimePoint)); }
public void SetAutomaticCorrectionUpdatedTime(SteadyClockTimePoint steadyClockTimePoint) { _autoCorrectionTime = steadyClockTimePoint; }
public virtual TimeSpanType GetCurrentRawTimePoint(ITickSource tickSource) { SteadyClockTimePoint timePoint = GetTimePoint(tickSource); return(TimeSpanType.FromSeconds(timePoint.TimePoint)); }