Esempio n. 1
0
        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 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);
        }
Esempio n. 3
0
        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);
        }
Esempio n. 4
0
        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);
        }