Exemple #1
0
    def serverTime(self, context, timestamp):
        end = globalClock.getRealTime()

        if context != self.thisContext:
            self.notify.debug(
                "Ignoring TimeManager response for old context %d" % context)
            return

        elapsed = end - self.start
        self.attemptCount += 1
        self.notify.debug("Clock sync roundtrip took %0.3f ms" %
                          (elapsed * 1000.0))

        average = (self.start + end) / 2.0 - self.extraSkew
        uncertainty = (end - self.start) / 2.0 + abs(self.extraSkew)

        globalClockDelta.resynchronize(average, timestamp, uncertainty)

        self.notify.debug("Local clock uncertainty +/- %.3f s" %
                          (globalClockDelta.getUncertainty()))

        if globalClockDelta.getUncertainty() > self.maxUncertainty:
            if self.attemptCount < self.maxAttempts:
                self.notify.debug("Uncertainty is too high, trying again.")
                self.start = globalClock.getRealTime()
                self.sendUpdate("requestServerTime", [self.thisContext])
                return
            self.notify.debug("Giving up on uncertainty requirement.")

        messenger.send("gotTimeSync", taskChain='default')
        messenger.send(self.cr.uniqueName("gotTimeSync"), taskChain='default')
Exemple #2
0
    def serverTime(self, context, timestamp):
        """serverTime(self, int8 context, int32 timestamp)



        This message is sent from the AI to the client in response to

        a previous requestServerTime.  It contains the time as

        observed by the AI.



        The client should use this, in conjunction with the time
        measurement taken before calling requestServerTime (above), to
        determine the clock delta between the AI and the client
        machines.
        """

        end = globalClock.getRealTime()

        if context != self.thisContext:
            self.notify.info(
                "Ignoring TimeManager response for old context %d" % (context))

            return

        elapsed = end - self.start

        self.attemptCount += 1

        self.notify.info("Clock sync roundtrip took %0.3f ms" %
                         (elapsed * 1000.0))

        average = (self.start + end) / 2.0 - self.extraSkew

        uncertainty = (end - self.start) / 2.0 + abs(self.extraSkew)

        globalClockDelta.resynchronize(average, timestamp, uncertainty)

        self.notify.info("Local clock uncertainty +/- %.3f s" %
                         (globalClockDelta.getUncertainty()))

        if globalClockDelta.getUncertainty() > self.maxUncertainty:
            if self.attemptCount < self.maxAttempts:
                self.notify.info("Uncertainty is too high, trying again.")

                self.start = globalClock.getRealTime()

                self.sendUpdate("requestServerTime", [self.thisContext])

                return

            self.notify.info("Giving up on uncertainty requirement.")

        messenger.send("gotTimeSync", taskChain='default')

        messenger.send(self.cr.uniqueName("gotTimeSync"), taskChain='default')
Exemple #3
0
    def serverTime(self, context, timestamp):
        """serverTime(self, int8 context, int32 timestamp)

        This message is sent from the AI to the client in response to
        a previous requestServerTime.  It contains the time as
        observed by the AI.

        The client should use this, in conjunction with the time
        measurement taken before calling requestServerTime (above), to
        determine the clock delta between the AI and the client
        machines.
        """
        end = globalClock.getRealTime()

        if context != self.thisContext:
            self.notify.info("Ignoring TimeManager response for old context %d" % (context))
            return

        elapsed = end - self.start
        self.attemptCount += 1
        self.notify.info("Clock sync roundtrip took %0.3f ms" % (elapsed * 1000.0))

        average = (self.start + end) / 2.0 - self.extraSkew
        uncertainty = (end - self.start) / 2.0 + abs(self.extraSkew)

        globalClockDelta.resynchronize(average, timestamp, uncertainty)

        self.notify.info("Local clock uncertainty +/- %.3f s" % (globalClockDelta.getUncertainty()))

        if globalClockDelta.getUncertainty() > self.maxUncertainty:
            if self.attemptCount < self.maxAttempts:
                self.notify.info("Uncertainty is too high, trying again.")
                self.start = globalClock.getRealTime()
                self.sendUpdate("requestServerTime", [self.thisContext])
                return
            self.notify.info("Giving up on uncertainty requirement.")

        messenger.send("gotTimeSync", taskChain = 'default')
        messenger.send(self.cr.uniqueName("gotTimeSync"), taskChain = 'default')