Skip to content

Ticket 5220 #70

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions tests/motor_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,43 @@ def check_nonzero_delay(controller, motor) -> str | None:
result = fut.result()
with self.subTest():
self.assertIsNone(result)

def test_galils_have_nonzero_encoder_sync_tolerance(self) -> None:
"""
Closed-loop galil axes must have a non-zero motor-encoder sync tolerance set.

This only applies to closed-loop axes; it is not meaningful for open-loop axes.

Generally an appropriate _MOT_ENC_SYNC_TOL_SP is ~ERES, this will cause motor and encoder
to resync before a move if they differ by more than one encoder step.

This test ensures that ._MOT_ENC_SYNC_TOL_SP is not set to zero
for any closed-loop galil axes.
"""

def check_nonzero_mot_enc_sync_tol(controller, motor) -> str | None:
prefix = f"MOT:MTR{controller:02d}{motor:02d}"
controller_type = self.ca.get_value(f"{prefix}_IOCNAME", timeout=30)

if isinstance(controller_type, str) and controller_type.startswith("GALIL_"):
mot_enc_sync_tol = self.ca.get_value(f"{prefix}_MOT_ENC_SYNC_TOL_SP", timeout=30)
ueip = self.ca.get_value(f"{prefix}.UEIP", timeout=30)
if ueip and mot_enc_sync_tol == 0:
return f"Motor-encoder sync tolerance is zero on closed-loop axis {self.ca.pv_prefix}{prefix}"

return None

with concurrent.futures.ThreadPoolExecutor(
max_workers=MAX_MOTOR * MAX_CONTROLLER
) as executor:
futures = []
for controller in range(1, MAX_CONTROLLER + 1):
for motor in range(1, MAX_MOTOR + 1):
futures.append(
executor.submit(check_nonzero_mot_enc_sync_tol, controller, motor)
)

for fut in concurrent.futures.as_completed(futures):
result = fut.result()
with self.subTest():
self.assertIsNone(result)
Loading