You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is there a way motor positions (and UB matrices) of the two engines can be synchronized automatically?
classSync_UB_Matrix:
"""Copy the UB matrix from source to target diffractometers."""def__init__(self, source: Diffractometer, target: Diffractometer):
self.source=sourceself.target=targetself.source.UB.subscribe(self.sync_callback)
# initializeself.sync_callback(self.source.UB.get())
defcleanup(self, *args, **kwargs):
"""Remove all our subscriptions to ophyd objects."""self.source.UB.clear_sub(self.sync_callback)
defsync_callback(self, value=None, **kwargs):
ifvalueisNone:
raiseRuntimeError(f"sync_callback: {value=!r}{kwargs=!r}")
ub_source=valueprint(f"Copy UB={ub_source=} from {self.source.name} to {self.source.name}")
self.target.UB.put(ub_source)
foraxisinself.source.real_positioners._fields:
ptarget=getattr(self.target, axis)
ifisinstance(ptarget, SoftPositioner):
# If the target is a simulated motor, sync it with the source.psource=getattr(self.source, axis)
ptarget.move(psource.position)
print(f"Sync {self.target.name}.{axis}={ptarget.position}")
try:
sync_UB.cleanup()
exceptException:
passsync_UB=Sync_UB_Matrix(polar, polar_psi)
@strempfer - Thanks for the suggestion!
The text was updated successfully, but these errors were encountered: