Skip to content

Hla 1113 implement stop and pause buttons#90

Open
ptsOSL wants to merge 16 commits into
mainfrom
hla-1113-stop-button
Open

Hla 1113 implement stop and pause buttons#90
ptsOSL wants to merge 16 commits into
mainfrom
hla-1113-stop-button

Conversation

@ptsOSL

@ptsOSL ptsOSL commented Jul 16, 2026

Copy link
Copy Markdown
Collaborator
  • Added stop and pause button functionality.
  • The stop button makes the "run" function of the algorithm return early after the current set of setpoints have been set. This should take less than a second. It cleans up ready for the next run and does not save any results.
  • The pause button pauses the "run" function of the algorithm after the current set of setpoints have been set. This should take less than a second. A subsequent press of the same button unpauses the "run" function.
  • I made the worker.start() function run much faster (saving ~10 seconds with the Virtac by streamlining how the zero_offsets functions does cagets)
  • Improved a few function names and deleted unused functions.
  • Added basic tests for pausing/stopping an algorithm. More tests should be added later.

@ptsOSL
ptsOSL requested review from MJGaughran and removed request for MJGaughran July 16, 2026 15:14
@codecov

codecov Bot commented Jul 16, 2026

Copy link
Copy Markdown

Welcome to Codecov 🎉

Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests.

Thanks for integrating Codecov - We've got you covered ☂️

ptsOSL added 3 commits July 16, 2026 16:35
We now send the stop signal and then send the unpause signal (if
paused). This stops an unnecessary algorithm run cycle from happening.
@ptsOSL ptsOSL changed the title Draft: Hla 1113 stop button Draft: Hla 1113 implement stop and pause buttons Jul 16, 2026
@ptsOSL
ptsOSL requested review from MJGaughran, MichaelStubbings and T-Nicholls and removed request for MichaelStubbings July 16, 2026 17:19
ptsOSL added 5 commits July 17, 2026 10:25
This is to prevent us stopping in a place which leaves a quadrupole
away from its original setpoint
If checks the bool'ness of a value automatically so we do not
need to do this explicitly
Both names are true, but ticker was deemed more the more immediate action

@MJGaughran MJGaughran 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.

I think the general approach is fine, feel free to continue with it.

Comment thread src/dls_bba/gui.py Outdated
Comment on lines +390 to +391

def stop_worker(self, manual_stop: bool = False) -> None:

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.

This is still called stop_worker

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Fixed

Comment thread src/dls_bba/machine.py
log.info("Zeroing BCD and Golden Offsets")
golden_offsets = {}
pv_names = []
bcd_names = []

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.

Did you leave these lines in by mistake?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

No, these are supposed to be here. One of the commits changed this a little to speed up startup

Comment thread src/dls_bba/worker.py Outdated
"""The process is resumed."""
log.debug("Resumed")
Args:
stop_event: Cothread event which is triggered when the GUI stop button

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.

This is outdated

Comment thread src/dls_bba/worker.py Outdated
def work(self) -> float:
"""Complete an iteration of the BBA process.

Args:

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.

Outdated

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Fixed

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Fixed

Comment thread src/dls_bba/gui.py
def stop_ticker(self, manual_stop: bool = False) -> None:
"""Stop the ticker."""
self.__action.Signal(("stop", None))
if self.__worker is None:

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.

Nitpick:

The whitespace is inconsistent. At the top of the method, there's no newline on stop_ticker, __do_tick has a newline, and __ticker has a newline immediately after the docstring.

Keep it consistent, I recommend following __do_tick. Guard clauses (e.g. if val is None: return/raise) are often separated from the main code, as in __do_tick.

@ptsOSL ptsOSL Jul 20, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Standardised functions in this file to look like __do_tick

@ptsOSL ptsOSL changed the title Draft: Hla 1113 implement stop and pause buttons Hla 1113 implement stop and pause buttons Jul 20, 2026
@ptsOSL
ptsOSL requested a review from MJGaughran July 20, 2026 13:13
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