85 lines
2.0 KiB
Python
85 lines
2.0 KiB
Python
from aarecommon.models.aerotech import (
|
|
AerotechAxisStatus,
|
|
AerotechRotationScanRequest,
|
|
AerotechRunEnum,
|
|
AerotechStatus,
|
|
AerotechTarget,
|
|
AxisEnum,
|
|
TaskEnum,
|
|
VariableTypeEnum,
|
|
)
|
|
|
|
|
|
def test_enums():
|
|
assert TaskEnum.TASK_0.value == 0
|
|
assert AxisEnum.X.value == "x"
|
|
assert AerotechRunEnum.START.value == 1
|
|
assert VariableTypeEnum.REAL.value == 1
|
|
|
|
|
|
def test_aerotech_axis_status():
|
|
status = AerotechAxisStatus(
|
|
enabled=True,
|
|
fault=0,
|
|
homed=True,
|
|
is_fault=False,
|
|
moving=False,
|
|
position=10.0,
|
|
status=1,
|
|
velocity=0.0,
|
|
)
|
|
assert status.position == 10.0
|
|
assert status.enabled is True
|
|
|
|
|
|
def test_aerotech_status_strings():
|
|
axis_status = AerotechAxisStatus(
|
|
enabled=True,
|
|
fault=0,
|
|
homed=True,
|
|
is_fault=False,
|
|
moving=False,
|
|
position=1.234567,
|
|
status=1,
|
|
velocity=0.1,
|
|
)
|
|
status = AerotechStatus(state="READY", x=axis_status)
|
|
|
|
pretty = status.to_pretty_string()
|
|
assert "STATE: READY" in pretty
|
|
assert " X | pos= 1.234567" in pretty
|
|
assert "Y: unavailable" in pretty
|
|
|
|
compact = status.to_compact_string()
|
|
assert "state=READY" in compact
|
|
assert "x=1.2346 (H, -)" in compact
|
|
|
|
colored = status.to_colored_string()
|
|
assert "STATE:" in colored
|
|
assert "READY" in colored
|
|
assert "pos=" in colored
|
|
|
|
assert str(status) == pretty
|
|
|
|
|
|
def test_aerotech_target():
|
|
target = AerotechTarget(x=10.0, y=20.0)
|
|
payload = target.to_payload()
|
|
assert payload == {"x": 10.0, "y": 20.0}
|
|
assert "z" not in payload
|
|
|
|
|
|
def test_aerotech_rotation_scan_request():
|
|
request = AerotechRotationScanRequest(
|
|
rotation_deg=360.0,
|
|
time_sec=10.0,
|
|
start_pos_deg=0.0,
|
|
async_move=True,
|
|
exp_time_s=0.1,
|
|
incr_omega_deg=1.0,
|
|
steps=360,
|
|
)
|
|
payload = request.to_payload()
|
|
assert payload["rotation_deg"] == 360.0
|
|
assert payload["async"] is True
|