mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-07-04 03:11:43 +00:00
[copybara] Resync robotpy (#8585)
Project import generated by Copybara.
GitOrigin-RevId: fd000778e9b78c72cc7ca7b2ebe476129b78c6e0
This commit is contained in:
@@ -2,3 +2,5 @@ from . import _init__simulation
|
||||
from ._simulation import *
|
||||
|
||||
del _init__simulation
|
||||
|
||||
from .mockhooks import waitForProgramStart
|
||||
|
||||
24
hal/src/main/python/hal/simulation/mockhooks.py
Normal file
24
hal/src/main/python/hal/simulation/mockhooks.py
Normal file
@@ -0,0 +1,24 @@
|
||||
import time
|
||||
import typing as T
|
||||
|
||||
from ._simulation import getProgramStarted
|
||||
|
||||
|
||||
def waitForProgramStart(timeout: T.Optional[float] = None, delta: float = 0.001):
|
||||
"""
|
||||
Polls robot program and returns when it has reported that it started
|
||||
|
||||
:param timeout: Amount of time to wait
|
||||
:param delta: Amount of time to sleep between checks
|
||||
"""
|
||||
|
||||
# This is basically the same thing that the C version of this function
|
||||
# does. Implemented in python so that CTRL-C works.
|
||||
|
||||
until = None
|
||||
if timeout and timeout > 0:
|
||||
until = time.monotonic() + timeout
|
||||
while not getProgramStarted():
|
||||
if until is not None and time.monotonic() > until:
|
||||
raise TimeoutError("Program did not start")
|
||||
time.sleep(delta)
|
||||
@@ -1,7 +1,7 @@
|
||||
[build-system]
|
||||
build-backend = "hatchling.build"
|
||||
requires = [
|
||||
"semiwrap~=0.2.1",
|
||||
"semiwrap~=0.2.6",
|
||||
"hatch-meson~=0.1.0",
|
||||
"hatchling",
|
||||
"pyntcore==0.0.0",
|
||||
|
||||
@@ -8,6 +8,7 @@ strip_prefixes:
|
||||
functions:
|
||||
HALSIM_SetRuntimeType:
|
||||
HALSIM_WaitForProgramStart:
|
||||
ignore: true
|
||||
HALSIM_SetProgramStarted:
|
||||
HALSIM_GetProgramStarted:
|
||||
HALSIM_SetProgramState:
|
||||
|
||||
Reference in New Issue
Block a user