Пример #1
0
    def __init__(self, run: callable) -> None:
        #: The lock for the process information.
        self._processLock = threading.RLock()

        # Notifier handle
        self._notifier = hal.initializeNotifier()

        #: The time, in microseconds, at which the corresponding handler should be
        #: called. Has the same zero as Timer.getFPGATime().
        self._expirationTime = 0

        #: The handler passed in by the user which should be called at the
        #: appropriate interval.
        self._handler = run

        # Whether we are calling the handler just once or periodically.
        self._periodic = False

        #: If periodic, the period of the calling; if just once, stores how long it
        #: is until we call the handler.
        self._period = 0

        #: The thread waiting on the HAL alarm
        self._thread = threading.Thread(target=self._run, daemon=True)
        self._thread.start()

        # python-specific
        Resource._add_global_resource(self)
Пример #2
0
    def __init__(self, run: callable) -> None:
        """
        Create a Notifier for timer event notification.

        :param run: The handler that is called at the notification time which is
                    set using :meth:`.startSingle` or :meth:`.startPeriodic`.
        """
        #: The lock for the process information.
        self._processLock = threading.RLock()

        # Notifier handle
        self._notifier = hal.initializeNotifier()

        #: The time, in microseconds, at which the corresponding handler should be
        #: called. Has the same zero as Timer.getFPGATime().
        self._expirationTime = 0

        #: The handler passed in by the user which should be called at the
        #: appropriate interval.
        self._handler = run

        # Whether we are calling the handler just once or periodically.
        self._periodic = False

        #: If periodic, the period of the calling; if just once, stores how long it
        #: is until we call the handler.
        self._period = 0

        #: The thread waiting on the HAL alarm
        self._thread = threading.Thread(target=self._run, name="Notifier", daemon=True)
        self._thread.start()

        # python-specific
        Resource._add_global_resource(self)
Пример #3
0
    def __init__(self):
        RobotBase.__init__(self)
        self.iterator = None
        self.earlyStop = False

        hal.report(hal.tResourceType.kResourceType_Framework,
                   hal.tInstances.kFramework_Timed)

        self._expirationTime = 0
        self._notifier = hal.initializeNotifier()
    def __init__(self, delay_period: float) -> None:
        """:param delay_period: The period's amount of time (in seconds)."""
        if delay_period < 0.001:
            raise ValueError("You probably don't want to delay less than 1ms!")

        # Convert the delay period to microseconds, as FPGA timestamps are microseconds
        self.delay_period = int(delay_period * 1e6)
        self._notifier = hal.initializeNotifier()
        self._expiry_time = wpilib.RobotController.getFPGATime() + self.delay_period
        self._update_alarm()

        wpilib.Resource._add_global_resource(self)
Пример #5
0
    def __init__(self):
        super().__init__()
        hal.report(hal.UsageReporting.kResourceType_Framework, hal.UsageReporting.kFramework_Iterative)

        self.period = TimedRobot.DEFAULT_PERIOD
        # Prevents loop from starting if user calls setPeriod() in robotInit()
        self.startLoop = False
        
        self._expirationTime = 0
        self._notifier = hal.initializeNotifier()
        
        Resource._add_global_resource(self)
Пример #6
0
    def __init__(self, delay_period: float) -> None:
        """:param delay_period: The period's amount of time (in seconds)."""
        if delay_period < 0.001:
            raise ValueError("You probably don't want to delay less than 1ms!")

        # Convert the delay period to microseconds, as FPGA timestamps are microseconds
        self.delay_period = int(delay_period * 1e6)
        self._notifier = hal.initializeNotifier()
        self._expiry_time = wpilib.RobotController.getFPGATime(
        ) + self.delay_period
        self._update_alarm()

        wpilib.Resource._add_global_resource(self)
Пример #7
0
    def __init__(self, period: Optional[float] = None) -> None:
        if period is None:
            period = TimedRobot.kDefaultPeriod
        super().__init__(period)
        hal.report(
            hal.UsageReporting.kResourceType_Framework,
            hal.UsageReporting.kFramework_Timed,
        )

        self._expirationTime = 0
        self._notifier = hal.initializeNotifier()

        Resource._add_global_resource(self)
Пример #8
0
    def __init__(self):
        super().__init__()
        hal.report(hal.UsageReporting.kResourceType_Framework,
                   hal.UsageReporting.kFramework_Iterative)

        self.period = AsyncRobot.DEFAULT_PERIOD
        # Prevents loop from starting if user calls setPeriod() in robotInit()
        self.startLoop = False

        self._expirationTime = 0
        self._loop = asyncio.get_event_loop()
        self._interrupted = asyncio.Event()

        self._notifier = hal.initializeNotifier()

        self._active_commands = []

        Resource._add_global_resource(self)