[robotpy] Mirror most other subprojects (#8208)

GitOrigin-RevId: ac60fd3cf4a24023184376687da28373d14b781a

This mirrors the robotpy files for the following projects:
- apriltag
- datalog
- hal
- ntcore
- romiVendordep
- wpilibc
- wpimath
- xrpVendordep

This excludes cscore and the halsim wrappers for at this time.

NOTE: This does not hook these projects up to the build system, just simply mirrors the files. The building will take place in a follow up PR to make it easier to review the changes necessary to build.
This commit is contained in:
PJ Reiniger
2025-10-24 01:28:04 -04:00
committed by GitHub
parent 8992dcdc99
commit 44b9cc1398
545 changed files with 27293 additions and 38 deletions

View File

@@ -0,0 +1,41 @@
import hal
import hal.simulation
import typing
def test_value_changed_callback():
recv: typing.Optional[typing.Tuple[bool, str, int]] = None
def created_cb(
name: str, handle: int, direction: hal.SimValueDirection, value: hal.Value
):
nonlocal recv
recv = (True, name, value.value)
def cb(name: str, handle: int, direction: hal.SimValueDirection, value: hal.Value):
nonlocal recv
recv = (False, name, value.value)
dev = hal.SimDevice("simd")
# Must keep the returned value alive or the callback will be unregistered
devunused = hal.simulation.registerSimValueCreatedCallback(dev, created_cb, True)
assert recv is None
val = dev.createInt("answer", 0, 42)
assert recv == (True, "answer", 42)
recv = None
# Must keep the returned value alive or the callback will be unregistered
unused = hal.simulation.registerSimValueChangedCallback(val, cb, True)
assert recv == (False, "answer", 42)
recv = None
val.set(84)
assert recv == (False, "answer", 84)
recv = None