Skip to content

fix cryomagnetics4g driver bug. #7114

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 3 commits into
base: main
Choose a base branch
from

Conversation

liuyichao82
Copy link

I am trying to fix several bugs in cryomagnetics4g:

  1. In the write_raw function of the code, when VisaIOError occurs in the first communication, the code will use self._RETRY_WRITE_ASK to determine whether to re-communicate, but I did not see the definition of self._RETRY_WRITE_ASK in the code, so I added
self._RETRY_WRITE_ASK = True
self._RETRY_TIME = 1 
  1. This magnet power supply has three states: Standby, Holding, and Ramping. In the original code, each time the set_field function is executed, it will determine whether the magnetic field setting is normal by judging whether the final state is the Holding state. However, he forgot one situation——when the magnetic field is set to 0T, the magnet power supply will enter the Standby state instead of Holding, so I added a judgment to fix this problem.
  2. This program waits for the excitation to end by checking the status code status_byte = int(self.ask("*STB?")), when the magnet state is not ramping, it means that the excitation is complete. However, there is a problem with this magnet power supply——even if the magnetic field has been added to the specified value, the state is still ramping and will not change! So I changed to ask the current magnetic field value self._get_field() to determine whether the excitation is complete

@liuyichao82 liuyichao82 requested a review from a team as a code owner April 30, 2025 14:33
@@ -0,0 +1,3 @@
1. Fixed the problem that there is no specific initialization variable in self._RETRY_WRITE_ASK.
2. Fix the instrument status recognition problem in self.set_field.
3. Fixed the ramping state recognition issue in wait_while_ramping.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you reword this so it's clear which driver this refers to

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry about that! I've updated the code in a new commit following your suggestion.

if not exit_state.holding:
msg = "_set_field({}) failed with state: {}"
raise Cryomagnetics4GException(msg.format(field_setpoint, exit_state))
if not exit_state.standby:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if not exit_state.standby:
if not exit_state.standby and not exit_state.holding:

Writing this on one line will make the logic clearer.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes! I've updated the code accordingly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants