Skip to content

Set BDES with validation - #20

Merged
shamin-slac merged 9 commits into
slaclab:mainfrom
shamin-slac:main
Jun 18, 2026
Merged

Set BDES with validation#20
shamin-slac merged 9 commits into
slaclab:mainfrom
shamin-slac:main

Conversation

@shamin-slac

Copy link
Copy Markdown
Collaborator

This PR adds in the set_bdes_with_validation function for the Magnet class. This sets the BDES, trims the magnet and waits for the BACT to settle within a tolerance of 0.005.

Comment thread slac_devices/magnet.py Outdated
return self.metadata.read_tolerance

def is_bact_settled(self, b_tolerance: Optional[float] = 0.0) -> bool:
def is_bact_settled(self, b_tolerance: Optional[float] = 0.005) -> bool:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Use Magnet tolerance PV and/or metadata here instead of 0.005 static value

Comment thread slac_devices/magnet.py Outdated

def is_bact_settled(self, b_tolerance: Optional[float] = 0.0) -> bool:
def is_bact_settled(self, b_tolerance: Optional[float] = 0.005) -> bool:
return abs(self.bdes) - abs(self.bact) < b_tolerance

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Should be absolute of differences, not difference of absolutes

Comment thread slac_devices/magnet.py
Comment on lines 218 to 220
def trim(self) -> None:
"""Issue trim command"""
self.controls_information.PVs.ctrl.put(self.ctrl_options["TRIM"])

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
def trim(self, **kwargs) -> None:
"""Issue trim command"""
self.controls_information.PVs.ctrl.put(self.ctrl_options["TRIM"], **kwargs)

Comment thread slac_devices/magnet.py Outdated
self.bdes = bval
self.trim()
time_when_trim_started = datetime.now()
while not self.is_bact_settled():

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Compare to bval instead of self.bdes per conversation in tools meeting

@eloise-nebula
eloise-nebula requested a review from kabanaty June 3, 2026 22:04

@eloise-nebula eloise-nebula left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for the changes. Dunno if you wanna wait to merge until after tonight's MD or not, but I'll approve now.

@shamin-slac
shamin-slac merged commit 26f1307 into slaclab:main Jun 18, 2026
3 checks passed
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.

3 participants