Skip to content

Feature/beam energy#92

Merged
bwalkerMIR merged 82 commits intodevelopfrom
feature/beam-energy
May 1, 2026
Merged

Feature/beam energy#92
bwalkerMIR merged 82 commits intodevelopfrom
feature/beam-energy

Conversation

@danielegelhoff13
Copy link
Copy Markdown

@danielegelhoff13 danielegelhoff13 commented Mar 13, 2026

Description

This PR introduces the Beam Energy subsystem for the EBEAM Dashboard, including the new Beam Energy subpanel UI, Modbus communication with the Knob Box, and logging of errors in the Knob Box operation.

Beam Energy Subpanel

During Operation
{098DA5F6-43D9-4709-AE93-5BA70F894251}

Not Connected to Knob Box
{E6C745D4-71A6-47E8-B908-FD0C9AA918BB}

Scope of Changes Made

UI: Beam Energy dashboard panel, beam_energy.py

  • Voltage and current displays, indicator lights, and switch states reflect the Knob Box state of operation.
  • Communication status indicators verify if connection is functioning.

Modbus Communication: knob_box_modbus.py

  • Modbus register reads of the 4 Monitoring Arduinos in the Knob Box.
  • Each unit is polled in order with 3 possible read attempts per unit.
  • Connection attempts to the Knob Box are controlled by exponentially backing off to avoid slowing down the Dashboard.
  • COM ports are configured for the Knob Box to Dashboard connection.

dashboard.py and main.py were modified to create the Beam Energy subsystem and Knob Box instrument control objects.

Tests Run

A full Knob Box BTest was run to test both the hardware and software functionality together and is documented here:

https://docs.google.com/document/d/1PGchj_ZEUTGBbvStswzUiM31VCPpr_ZamW7ts0TJBkY/edit?tab=t.0#heading=h.g681r5xzzqq7

With corresponding images from the test here:

https://docs.google.com/presentation/d/1L03H2zA92JuW7442mnP7uVDj44vJ63D-VFfa9U56O-w/edit?slide=id.g2b5328b7f44_0_0#slide=id.g2b5328b7f44_0_0

@bwalkerMIR
Copy link
Copy Markdown
Collaborator

@danielegelhoff13 what is the status of this PR and branch?

@bwalkerMIR
Copy link
Copy Markdown
Collaborator

bwalkerMIR commented Mar 24, 2026

@chott24 has made changes to the firmware that need to be updated in this branch. @BaiTian6641 is going to branch off this feature/beam-energy branch to try to incorporate Chase's changes and get this tested and working in parallel. Ideally please work together on this. If one branch is shown to work and be tested and ready for a PR we will use that one and either merge the other or discard.

Chase said: FYI the modbus frames have been completely redone. I'll update the dev spec with a more thorough description once I've got the code done.

For now, this README is up to date for the firmware changes (as of 2026-03-24)
https://github.com/uw-loci/knob-box/tree/bugfix/latch-modbus-flag-registers/monitor-arduino#modbus-register-map

@danielegelhoff13
Copy link
Copy Markdown
Author

@codex review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: cd636d2eaa

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread dashboard.py Outdated
Comment on lines +437 to +438
elif subsystem_name == 'Beam Energy':
subsystem.update_com_ports(new_com_ports)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Invoke Beam Energy COM-port updater

The new Beam Energy branch is currently unreachable because it sits under if hasattr(subsystem, 'update_com_port'), but BeamEnergySubsystem defines update_com_ports (plural) instead. In practice, changing the KnobBox port from the config UI will not reconfigure Beam Energy, so it keeps using the stale serial port until restart. Please either check for update_com_ports here or move the Beam Energy case outside this guard.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Fixed with commit 36051ba.

Note: this issue needs further attention for other subsystems. See Asana task: https://app.asana.com/1/492353873344076/project/1208196184307227/task/1213974761625776?focus=true

return self.ps_connected

def handle_disconnect(self, msg=''):
self.log(f"Disconnect: {msg}", err=True)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Pass a supported argument to log()

handle_disconnect calls self.log(..., err=True), but log only accepts (message, level). If a disconnect occurs, this raises TypeError before the disconnect cleanup runs, so the serial handle/state reset path is skipped exactly when it is needed most. Use a LogLevel value (for example LogLevel.ERROR) instead of the unsupported err kwarg.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

This is an error in glassman.py, which should have been deleted before codex reviewed the PR. The most recent commit 1b27b5d deletes glassman.py and knob_box.py, which are both unused, old serial drivers.

@danielegelhoff13
Copy link
Copy Markdown
Author

@codex review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1b27b5d603

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread subsystem/beam_energy/beam_energy.py Outdated
Comment thread instrumentctl/knob_box/pymodbus_tester.py Outdated
@danielegelhoff13
Copy link
Copy Markdown
Author

@codex review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e26d330f3f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread subsystem/beam_energy/beam_energy.py
Comment thread subsystem/beam_energy/beam_energy.py Outdated
@danielegelhoff13
Copy link
Copy Markdown
Author

@codex review

@chatgpt-codex-connector
Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@danielegelhoff13 danielegelhoff13 marked this pull request as ready for review April 8, 2026 17:29
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7ae4e5d8ab

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread subsystem/beam_energy/beam_energy.py Outdated
Comment thread subsystem/beam_energy/beam_energy.py
@uw-loci uw-loci deleted a comment from chatgpt-codex-connector Bot Apr 9, 2026
@uw-loci uw-loci deleted a comment from chatgpt-codex-connector Bot Apr 9, 2026
@bwalkerMIR
Copy link
Copy Markdown
Collaborator

@codex review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 91b8f72afd

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread subsystem/beam_energy/beam_energy.py
Comment thread instrumentctl/knob_box/knob_box_modbus.py Outdated
@danielegelhoff13
Copy link
Copy Markdown
Author

danielegelhoff13 commented Apr 9, 2026

Commit e703087 fixes another reconnection behavior bug (found by Codex):

Problem: Backoff is checked in initialize_knob_box_modbus (_next_connect_time), but reconnect workers are still spawned frequently (every poll/update cycle), then immediately return when backoff hasn’t elapsed. That causes repeated thread creation and scheduling churn even during intentional backoff windows.

Why it matters: This can still create unnecessary CPU/thread overhead and queue pressure during outages—the same failure mode this series intends to reduce.

Fix: Check backoff time remaining before creating a reconnection worker thread.

@danielegelhoff13
Copy link
Copy Markdown
Author

@bwalkerMIR could you ask codex to do another review when you get a chance?

@bwalkerMIR
Copy link
Copy Markdown
Collaborator

@codex review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: be3a4341ef

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread subsystem/beam_energy/beam_energy.py
Comment thread subsystem/beam_energy/beam_energy.py
@uw-loci uw-loci deleted a comment from chatgpt-codex-connector Bot Apr 14, 2026
@danielegelhoff13
Copy link
Copy Markdown
Author

@bwalkerMIR This PR is ready for review and merge.

Copilot AI pushed a commit that referenced this pull request Apr 28, 2026
…ignal edges that do not consititue an error (e.g. Arm Beams signal).
…on is called from both close() AND update_com_ports() paths.
…y conection attempt to avoid losing backoff data and spamming log with connection attempts.
… the 3kV enable switch will now be logged correctly.
…time to expire to spawn. Previously, they would spawn then immediately return very frequently, not respecting backoff.
…eduling a reconnection attempt. Deasserts controller's connected field when polling error.
… message when all these attempts fail in a row.
@bwalkerMIR
Copy link
Copy Markdown
Collaborator

@codex review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c68c66562e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread subsystem/beam_energy/beam_energy.py
@bwalkerMIR
Copy link
Copy Markdown
Collaborator

@codex review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f8d5608b32

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread subsystem/beam_energy/beam_energy.py
Comment thread subsystem/beam_energy/beam_energy.py
Copy link
Copy Markdown
Collaborator

@bwalkerMIR bwalkerMIR left a comment

Choose a reason for hiding this comment

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

This is a much needed addition of the Knob Box / Beam Energy subsystem into the dashboard and the code looks good. Codex has reviewed many times and @danielegelhoff13 has patched anything worth patching so far, and we have been left with P2 or lower priority issues. The code has been well tested by @chott24 and @danielegelhoff13 in

https://docs.google.com/document/d/1PGchj_ZEUTGBbvStswzUiM31VCPpr_ZamW7ts0TJBkY/edit?tab=t.0#heading=h.g681r5xzzqq7

With corresponding images from the test here:

https://docs.google.com/presentation/d/1L03H2zA92JuW7442mnP7uVDj44vJ63D-VFfa9U56O-w/edit?slide=id.g2b5328b7f44_0_0#slide=id.g2b5328b7f44_0_0

Approved.

@bwalkerMIR bwalkerMIR merged commit 88dc9db into develop May 1, 2026
1 check passed
@bwalkerMIR bwalkerMIR deleted the feature/beam-energy branch May 1, 2026 23:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants