-
Notifications
You must be signed in to change notification settings - Fork 21
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
Draft: Add check_ref_clock-functions for SHF*, and HDAWG #281
base: main
Are you sure you want to change the base?
Conversation
072d4ed
to
3ba289a
Compare
Introduce SHF class for SHF* functionality, such as the above mentioned function
3ba289a
to
c13344b
Compare
if ref_clock_status() == 1 and ref_clock_actual() != ref_clock(): | ||
ref_clock("internal", deep=True) | ||
logger.error( | ||
f"There was an error locking the device({self.serial}) " | ||
f"onto reference clock signal. Automatically switching to internal " | ||
f"reference clock. Please try again." | ||
) | ||
return False |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question: Wouldn't it make more sense to return code and raise an error if its not or an error occurred?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Andrea and I agree that raising an error probably makes sense.
We don't understand what you mean by "return code" however.
In any case this was taken over from an existing pqsc function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Feel free to add a proposal. Thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
something like this. #281 (comment)
... The "return code" was just a mixup in my head ... I meant return None and rais an error
shfsg.check_ref_clock() | ||
shfqa.check_ref_clock() | ||
|
||
# Verify if the ZSync connection is successful | ||
pqsc.check_zsync_connection([shfqa, shfsg]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shfsg.check_ref_clock() | |
shfqa.check_ref_clock() | |
# Verify if the ZSync connection is successful | |
pqsc.check_zsync_connection([shfqa, shfsg]) | |
# Verify if the ZSync connection is successful | |
shfsg.check_ref_clock() | |
shfqa.check_ref_clock() | |
pqsc.check_zsync_connection([shfqa, shfsg]) |
def check_ref_clock( | ||
self, *, timeout: float = 30.0, sleep_time: float = 1.0 | ||
) -> bool: | ||
"""Check if reference clock is locked successfully. | ||
|
||
Args: | ||
timeout: Maximum time in seconds the program waits | ||
(default: 30.0). | ||
sleep_time: Time in seconds to wait between | ||
requesting the reference clock status (default: 1) | ||
|
||
Raises: | ||
TimeoutError: If the process of locking to the reference clock | ||
exceeds the specified timeout. | ||
""" | ||
ref_clock_status = self.system.clocks.referenceclock.in_.status | ||
ref_clock = self.system.clocks.referenceclock.in_.source | ||
ref_clock_actual = self.system.clocks.referenceclock.in_.sourceactual | ||
try: | ||
ref_clock_status.wait_for_state_change( | ||
2, invert=True, timeout=timeout, sleep_time=sleep_time | ||
) | ||
except TimeoutError as error: | ||
raise TimeoutError( | ||
"Timeout during locking to reference clock signal" | ||
) from error | ||
if ref_clock_status() == 0: | ||
return True | ||
if ref_clock_status() == 1 and ref_clock_actual() != ref_clock(): | ||
ref_clock("internal", deep=True) | ||
logger.error( | ||
f"There was an error locking the device({self.serial}) " | ||
f"onto reference clock signal. Automatically switching to internal " | ||
f"reference clock. Please try again." | ||
) | ||
return False |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def check_ref_clock( | |
self, *, timeout: float = 30.0, sleep_time: float = 1.0 | |
) -> bool: | |
"""Check if reference clock is locked successfully. | |
Args: | |
timeout: Maximum time in seconds the program waits | |
(default: 30.0). | |
sleep_time: Time in seconds to wait between | |
requesting the reference clock status (default: 1) | |
Raises: | |
TimeoutError: If the process of locking to the reference clock | |
exceeds the specified timeout. | |
""" | |
ref_clock_status = self.system.clocks.referenceclock.in_.status | |
ref_clock = self.system.clocks.referenceclock.in_.source | |
ref_clock_actual = self.system.clocks.referenceclock.in_.sourceactual | |
try: | |
ref_clock_status.wait_for_state_change( | |
2, invert=True, timeout=timeout, sleep_time=sleep_time | |
) | |
except TimeoutError as error: | |
raise TimeoutError( | |
"Timeout during locking to reference clock signal" | |
) from error | |
if ref_clock_status() == 0: | |
return True | |
if ref_clock_status() == 1 and ref_clock_actual() != ref_clock(): | |
ref_clock("internal", deep=True) | |
logger.error( | |
f"There was an error locking the device({self.serial}) " | |
f"onto reference clock signal. Automatically switching to internal " | |
f"reference clock. Please try again." | |
) | |
return False | |
def check_ref_clock( | |
self, *, timeout: float = 30.0, sleep_time: float = 1.0 | |
) -> None: | |
"""Check if reference clock is locked successfully. | |
Args: | |
timeout: Maximum time in seconds the program waits | |
(default: 30.0). | |
sleep_time: Time in seconds to wait between | |
requesting the reference clock status (default: 1) | |
Raises: | |
ToolkitError: It the reference clock is not locked successfully or | |
there was an error. | |
TimeoutError: If the process of locking to the reference clock | |
exceeds the specified timeout. | |
""" | |
ref_clock_status = self.system.clocks.referenceclock.in_.status | |
ref_clock = self.system.clocks.referenceclock.in_.source | |
ref_clock_actual = self.system.clocks.referenceclock.in_.sourceactual | |
try: | |
ref_clock_status.wait_for_state_change( | |
2, invert=True, timeout=timeout, sleep_time=sleep_time | |
) | |
except TimeoutError as error: | |
raise TimeoutError( | |
"Timeout during locking to reference clock signal" | |
) from error | |
if ref_clock_status() == 0: | |
return | |
if ref_clock_status() == 1 and ref_clock_actual() != ref_clock(): | |
ref_clock("internal", deep=True) | |
msg = ( | |
f"There was an error locking the device({self.serial}) " | |
f"onto reference clock signal. Automatically switching to internal " | |
f"reference clock. Please try again." | |
) | |
raise ToolkitError(msg) | |
msg = "Reference clock is not locked sucessfully." | |
raise ToolkitError(msg) |
Description:
Fixes issue: #
Checklist: