Exemplo n.º 1
0
    def getFPGATime():
        """Read the microsecond timer from the FPGA.

        :returns: The current time in microseconds according to the FPGA.
        :rtype: int
        """
        return hal.getFPGATime()
Exemplo n.º 2
0
 def printEpochs(self) -> None:
     """Prints list of epochs added so far and their times."""
     now = hal.getFPGATime()
     if now - self._lastEpochsPrintTime > self.kMinPrintPeriod:
         self._lastEpochsPrintTime = now
         for key, value in self._epochs.items():
             logger.info("\t%s: %.6fs", key, value / 1e6)
Exemplo n.º 3
0
    def getFPGATimestamp() -> float:
        """Return the system clock time in seconds. Return the time from the
        FPGA hardware clock in seconds since the FPGA started.

        :returns: Robot running time in seconds.
        """
        return hal.getFPGATime() / 1000000.0
Exemplo n.º 4
0
    def getFPGATime():
        """Read the microsecond timer from the FPGA.

        :returns: The current time in microseconds according to the FPGA.
        :rtype: int
        """
        return hal.getFPGATime()
Exemplo n.º 5
0
    def getFPGATimestamp() -> float:
        """Return the system clock time in seconds. Return the time from the
        FPGA hardware clock in seconds since the FPGA started.

        :returns: Robot running time in seconds.
        """
        return hal.getFPGATime() / 1000000.0
Exemplo n.º 6
0
    def setTimeout(self, timeout: float) -> None:
        """Sets the watchdog's timeout.

        :param timeout: The watchdog's timeout in seconds with microsecond
                        resolution.
        """
        self._startTime = hal.getFPGATime()
        self._epochs.clear()
        timeout = int(timeout * 1e6)  # us

        with self._queueMutex:
            self._timeout = timeout
            self._isExpired = False

            watchdogs = self._watchdogs
            try:
                watchdogs.remove(self)
            except ValueError:
                pass
            else:
                heapq.heapify(watchdogs)

            self._expirationTime = self._startTime + timeout
            heapq.heappush(watchdogs, self)
            self._schedulerWaiter.notify_all()
Exemplo n.º 7
0
    def setTimeout(self, timeout: float) -> None:
        """Sets the watchdog's timeout.

        :param timeout: The watchdog's timeout in seconds with microsecond
                        resolution.
        """
        self._startTime = hal.getFPGATime()
        self._epochs.clear()
        timeout = int(timeout * 1e6)  # us

        with self._queueMutex:
            self._timeout = timeout
            self._isExpired = False

            watchdogs = self._watchdogs
            try:
                watchdogs.remove(self)
            except ValueError:
                pass
            else:
                heapq.heapify(watchdogs)

            self._expirationTime = self._startTime + timeout
            heapq.heappush(watchdogs, self)
            self._schedulerWaiter.notify_all()
Exemplo n.º 8
0
 def printEpochs(self) -> None:
     """Prints list of epochs added so far and their times."""
     now = hal.getFPGATime()
     if now - self._lastEpochsPrintTime > self.kMinPrintPeriod:
         self._lastEpochsPrintTime = now
         log = logger.info
         for key, value in self._epochs.items():
             log("\t%s: %.6fs", key, value / 1e6)
Exemplo n.º 9
0
    def getFPGATime() -> int:
        """Read the microsecond timer from the FPGA.

        .. deprecated:: 2018.0.0
            Use :meth:`.RobotController.getFPGATime` instead

        :returns: The current time in microseconds according to the FPGA.
        """
        return hal.getFPGATime()
Exemplo n.º 10
0
    def getFPGATime() -> int:
        """Read the microsecond timer from the FPGA.

        .. deprecated:: 2018.0.0
            Use :meth:`.RobotController.getFPGATime` instead

        :returns: The current time in microseconds according to the FPGA.
        """
        return hal.getFPGATime()
Exemplo n.º 11
0
    def _updateControlWord(self, force):
        """Updates the data in the control word cache. Updates if the force parameter is set, or if
        50ms have passed since the last update.

        :param force: True to force an update to the cache, otherwise update if 50ms have passed.
        """
        now = hal.getFPGATime()
        with self.controlWordMutex:
            if now - self.lastControlWordUpdate > 50 or force:
                hal.getControlWord(self.controlWordCache)
                self.lastControlWordUpdate = now
 def _updateControlWord(self, force):
     """Updates the data in the control word cache. Updates if the force parameter is set, or if
     50ms have passed since the last update.
     
     :param force: True to force an update to the cache, otherwise update if 50ms have passed.
     """
     now = hal.getFPGATime()
     with self.controlWordMutex:
         if now - self.lastControlWordUpdate > 50 or force:
             hal.getControlWord(self.controlWordCache)
             self.lastControlWordUpdate = now
Exemplo n.º 13
0
    def addEpoch(self, epochName: str) -> None:
        """
        Adds time since last epoch to the list printed by printEpochs().

        Epochs are a way to partition the time elapsed so that when
        overruns occur, one can determine which parts of an operation
        consumed the most time.

        :param epochName: The name to associate with the epoch.
        """
        currentTime = hal.getFPGATime()
        self._epochs[epochName] = currentTime - self._startTime
        self._startTime = currentTime
Exemplo n.º 14
0
    def addEpoch(self, epochName: str) -> None:
        """
        Adds time since last epoch to the list printed by printEpochs().

        Epochs are a way to partition the time elapsed so that when
        overruns occur, one can determine which parts of an operation
        consumed the most time.

        :param epochName: The name to associate with the epoch.
        """
        currentTime = hal.getFPGATime()
        self._epochs[epochName] = currentTime - self._startTime
        self._startTime = currentTime
Exemplo n.º 15
0
    def enable(self) -> None:
        """Enables the watchdog timer."""
        self._startTime = hal.getFPGATime()
        self._epochs.clear()

        with self._queueMutex:
            self._isExpired = False

            watchdogs = self._watchdogs
            try:
                watchdogs.remove(self)
            except ValueError:
                pass
            else:
                heapq.heapify(watchdogs)

            self._expirationTime = self._startTime + self._timeout
            heapq.heappush(watchdogs, self)
            self._schedulerWaiter.notify_all()
Exemplo n.º 16
0
    def enable(self) -> None:
        """Enables the watchdog timer."""
        self._startTime = hal.getFPGATime()
        self._epochs.clear()

        with self._queueMutex:
            self._isExpired = False

            watchdogs = self._watchdogs
            try:
                watchdogs.remove(self)
            except ValueError:
                pass
            else:
                heapq.heapify(watchdogs)

            self._expirationTime = self._startTime + self._timeout
            heapq.heappush(watchdogs, self)
            self._schedulerWaiter.notify_all()
Exemplo n.º 17
0
 def getMsClock(self):
     """
         :returns: the system clock time in milliseconds.
         :rtype: int
     """
     return hal.getFPGATime() / 1000
Exemplo n.º 18
0
 def getMsClock(self) -> int:
     """
         :returns: the system clock time in milliseconds.
     """
     return hal.getFPGATime() / 1000
Exemplo n.º 19
0
 def getMsClock(self) -> int:
     """
         :returns: the system clock time in milliseconds.
     """
     return hal.getFPGATime() / 1000
Exemplo n.º 20
0
 def getTime(self) -> float:
     """Returns the time in seconds since the watchdog was last fed."""
     return (hal.getFPGATime() - self._startTime) / 1e6
Exemplo n.º 21
0
 def getTime(self) -> float:
     """Returns the time in seconds since the watchdog was last fed."""
     return (hal.getFPGATime() - self._startTime) / 1e6