Skip to content
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

Feature/comportdetection #26

Open
wants to merge 202 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 195 commits
Commits
Show all changes
202 commits
Select commit Hold shift + click to select a range
32b18e5
seeing if i can get the same widget sizes to work
mark11778 Sep 7, 2024
7997e58
working on understanding how the tkinter library works
mark11778 Sep 7, 2024
002b5d6
works
mark11778 Sep 8, 2024
561bbe2
added comments and got rid of old code
mark11778 Sep 8, 2024
f3daf3a
pulled and handled merge conflict on develop
mark11778 Sep 8, 2024
8fa29be
push1
Sep 13, 2024
c9f3b4d
rough write up for G9 Driver
mark11778 Sep 13, 2024
aa49717
more edits
mark11778 Sep 13, 2024
452afc0
commiting before leaving
mark11778 Sep 13, 2024
bb37644
made a few chnages to g9_driver.py
arundhatisingh17 Sep 20, 2024
49d6064
made a few changes
arundhatisingh17 Sep 20, 2024
3771c35
looking into what will be needed for the frontend to work
mark11778 Sep 21, 2024
fa44fb7
adding another indicator cause i think red is more clear on what it …
mark11778 Sep 21, 2024
97fab6b
Merge branch 'feature/G9Driversim' into feature/interlocks_frontend
mark11778 Sep 21, 2024
c1c28d8
made some small changes to interlocks.py
mark11778 Sep 21, 2024
7646f86
added alot of functions to parse and form input/output
mark11778 Oct 1, 2024
e7bfd1a
fixed indice values
Oct 2, 2024
de20435
getting SITDF, OCTD, and SODTF
Oct 2, 2024
91691d9
raise error for OCTD case
Oct 2, 2024
d0b11a2
Retrieved SOTDF readings
Oct 4, 2024
6fb21c9
minor edits
Oct 4, 2024
02fc2d4
small changes
arundhatisingh17 Oct 5, 2024
ab4d7ee
small change
arundhatisingh17 Oct 6, 2024
fa7b253
clarified acronyms
Oct 8, 2024
2fbf13b
resolved optional and reserved data
Oct 8, 2024
f3014a0
added test file
Oct 9, 2024
044a023
g9_backend handle_errors
arundhatisingh17 Oct 11, 2024
c211c92
error handling, highlighted frames
arundhatisingh17 Oct 11, 2024
8cafe31
added logger
arundhatisingh17 Oct 11, 2024
1014f21
added logger
arundhatisingh17 Oct 11, 2024
eebcf19
testing functions in g9 driver
mark11778 Oct 11, 2024
2ca5cdc
committing
mark11778 Oct 11, 2024
b5e8b2b
temp changes
arundhatisingh17 Oct 11, 2024
f90e899
minor change
arundhatisingh17 Oct 11, 2024
68096dd
updating tests
mark11778 Oct 11, 2024
afc011a
working to see if the driver file works
mark11778 Oct 12, 2024
44057e9
updated g9_driver
mark11778 Oct 13, 2024
dbe6672
commiting to switch branch
mark11778 Oct 13, 2024
72fe1c6
some how there was not a gitignore on this branched, had to fix to ma…
mark11778 Oct 13, 2024
cefa251
merged in frontend features, along with removing the usr dir from bei…
mark11778 Oct 13, 2024
c0b0bbe
removed duplicate functions, driver is looking to be close to being f…
mark11778 Oct 13, 2024
6093bdc
removed print statements
mark11778 Oct 13, 2024
7469590
updated the g9driver test file was uptodate
mark11778 Oct 13, 2024
ae82e55
while updating the gitignore, removed the panel_config.py on accident
mark11778 Oct 13, 2024
eed749e
add Interlock's COM port to be defined in main.py
mark11778 Oct 13, 2024
b99ae98
update .gitignore and remove .pyc files
mslaffin Oct 13, 2024
7b91844
working on resolving merge request errors
mark11778 Oct 14, 2024
049f90f
commiting to work on other laptop
Oct 14, 2024
a70b634
was working on adding the changes to the driver and also working with…
mark11778 Oct 14, 2024
7e55d58
added update method and todo comments
mark11778 Oct 14, 2024
e88d6a7
working on backend
mark11778 Oct 14, 2024
fa56cc3
working on interlocks.py
mark11778 Oct 14, 2024
1059c47
commiting changes
mark11778 Oct 14, 2024
ddb2950
set driver com port to none to test
mark11778 Oct 14, 2024
db9f5df
error hierarchy
arundhatisingh17 Oct 14, 2024
3a4baff
testing
arundhatisingh17 Oct 14, 2024
9df474d
modified calculate_checksum() to send both high and low byte
Oct 16, 2024
72d95c9
temp
arundhatisingh17 Oct 16, 2024
84e6033
corrected check_flags_13
arundhatisingh17 Oct 16, 2024
e0dea7c
correction
arundhatisingh17 Oct 16, 2024
81868c0
Addressed data indexing to access a single byte by slicing
Oct 16, 2024
eb166b8
removed duplicate file
mark11778 Oct 18, 2024
0364155
fixed type line 99
Oct 18, 2024
d8cab93
small change
arundhatisingh17 Oct 18, 2024
3314e9e
working on tester
mark11778 Oct 18, 2024
d38b56d
modified msg for test1
Oct 18, 2024
9b76836
push
mark11778 Oct 18, 2024
55149d3
pushing
mark11778 Oct 18, 2024
8de1851
modified msg
Oct 18, 2024
02ef996
fixed typo line 99 to return byte object instead of str
Oct 18, 2024
c5fa1bc
finishing up the test
mark11778 Oct 18, 2024
c6b7bef
pushing for tests
mark11778 Oct 18, 2024
c0faf7d
error fixed
arundhatisingh17 Oct 18, 2024
7ec3a83
added responseTestCreator.py
Oct 18, 2024
13a1f2e
Merge branch 'feature/G9Driversim' of https://github.com/uw-loci/EBEA…
Oct 18, 2024
094eb62
small changes
mark11778 Oct 18, 2024
0fb19ae
added comments to tests
mark11778 Oct 18, 2024
5abd56d
added comments
Oct 18, 2024
63aa96e
actually added the comments this time
mark11778 Oct 18, 2024
6d11673
starting to work on forming the front end
mark11778 Oct 19, 2024
750869e
it was bothering me that the water indicator was not centered
mark11778 Oct 19, 2024
34bee01
is_connected function in g9driver
mark11778 Oct 19, 2024
6d51add
working on adding the global vars
mark11778 Oct 20, 2024
b1f354b
forgot to save lol
mark11778 Oct 20, 2024
50a568d
added comments to the driver file and rearranged some things
mark11778 Oct 20, 2024
f6750a8
removed one of the tests because that functionality is not longer nee…
mark11778 Oct 20, 2024
a596306
crazy changes, made a square indicator method
mark11778 Oct 20, 2024
38c3768
added the g9 output and hvolt indicatator to the dictionary
mark11778 Oct 20, 2024
f44e8d7
i think css is easier to visualize, more frontend changes
mark11778 Oct 20, 2024
e6c8567
made sure that com port was being passed to the interlocks.py
mark11778 Oct 20, 2024
6a995fb
ensured g9 specific constants were placed within the class itself and…
Oct 21, 2024
eb72795
made all changes except check_sum
arundhatisingh17 Oct 21, 2024
1d7a44f
checksum calculation added in response
Oct 21, 2024
25e7fb0
Merge branch 'feature/G9Driversim' of https://github.com/uw-loci/EBEA…
Oct 21, 2024
b42d35a
updated all changes according to suggestions
arundhatisingh17 Oct 21, 2024
7361420
Further clarified on constants and usage
Oct 21, 2024
1315ec1
Merge branch 'feature/G9Driversim' of https://github.com/uw-loci/EBEA…
Oct 21, 2024
29c82f6
minor fixes from merging process
Oct 21, 2024
e4e028c
gui chnages
arundhatisingh17 Oct 21, 2024
1b0d048
spaced out the HV Status frame
arundhatisingh17 Oct 21, 2024
af37288
changes to frontend
arundhatisingh17 Oct 21, 2024
b447ae2
Added another indicator for the E-STOP
Oct 21, 2024
9ed450a
aligned text better with indicators/shapes
Oct 21, 2024
a5b9883
shifted the interlocks frame to the top of gui to chreate space
arundhatisingh17 Oct 23, 2024
48a87b2
small change
arundhatisingh17 Oct 23, 2024
2b528d5
remove unused imports
mslaffin Oct 23, 2024
cef3b1a
fix serial connection check
mslaffin Oct 23, 2024
bcf50b1
simplify checksum. rework message construction in send_command
mslaffin Oct 23, 2024
66e533d
worked on the frontend how everything is adjusted to just be at the t…
mark11778 Oct 27, 2024
325224d
the checksum function is making all the tests fail, will revisit this
mark11778 Oct 27, 2024
2fa2dc0
i think there is a better way to store and arrange the interlock data…
mark11778 Oct 27, 2024
1ab6b95
working on the backend in interlock.py
mark11778 Oct 28, 2024
b5eae55
working on backend still
mark11778 Oct 28, 2024
1d2d6c2
changes to integrate backend to access binary
mark11778 Oct 28, 2024
84fc850
Merge branch 'feature/G9Driversim' of https://github.com/uw-loci/EBEA…
mslaffin Oct 28, 2024
56dae32
rework checksum and read_response
mslaffin Oct 29, 2024
e701150
testing the interlocks.py to reflect status flag changes on the dashb…
Oct 30, 2024
6b5ba13
Merge branch 'feature/G9Driversim' of https://github.com/uw-loci/EBEA…
Oct 30, 2024
c27bd56
modified mock_data()
Oct 30, 2024
7ac38ff
ensured update_data is constantly called every 5 seconds and scrapped…
Oct 30, 2024
1380f18
Force remove .venv and .vscode dirs
mslaffin Oct 30, 2024
8e3741a
add .venv to gitignore
mslaffin Oct 30, 2024
55cc9a2
moved a test file to scripts\G9Drivertest
Nov 1, 2024
c1361cd
debugged g9driver.py and interlocks.py to correctly update interlocks
Nov 1, 2024
c0dfa8b
moving files around
mark11778 Nov 1, 2024
20e56fd
added the functionality for the all interlocks
mark11778 Nov 1, 2024
9419dde
bug related to all interlocks fix
mark11778 Nov 1, 2024
7745aa8
added logger status for change in interlocks
mark11778 Nov 1, 2024
5da8eec
fixed bug in the interlock logger updating
mark11778 Nov 1, 2024
4f6af6d
fixed error being thrown when g9driver is not defined or the com port…
mark11778 Nov 2, 2024
1bd5e38
overhaul G9 data access and comm handling
mslaffin Nov 2, 2024
768e5fb
enforce error rate limiting when no COM port available
mslaffin Nov 2, 2024
7fdaa42
fix SITEC/SOTEC labels
mslaffin Nov 2, 2024
6de8e93
update G9 unit test file
mslaffin Nov 2, 2024
f184881
first draft of readme
mark11778 Nov 4, 2024
14b1e5c
i should've checked my grammar first
mark11778 Nov 4, 2024
aaf6164
typo in readme
mark11778 Nov 4, 2024
de252a4
merged main into branch and handled all conflicts, all tests are pass…
mark11778 Nov 4, 2024
0178e91
worked on comments in the G9driver file
mark11778 Nov 4, 2024
7b2f375
improved input checking for methods and added more detail to the func…
mark11778 Nov 4, 2024
2d87614
restructure the git repo with subsystem/instrumentctl READMEs
arundhatisingh17 Nov 4, 2024
51e27ac
working on sanitizing inputs for methods
mark11778 Nov 4, 2024
b12b0bc
added log function and made it the same as other functions
mark11778 Nov 4, 2024
ea9f258
fixed the file organization problem
mark11778 Nov 4, 2024
da2c1aa
working on G9 readme
mark11778 Nov 5, 2024
fc48876
Merge branch 'feature/G9Driversim' of https://github.com/uw-loci/EBEA…
mark11778 Nov 5, 2024
7e91654
still working on the code flow diagram
mark11778 Nov 5, 2024
15613a8
worked on the flow chart
mark11778 Nov 5, 2024
23a7e1f
fixed missing return labels
mark11778 Nov 5, 2024
f2a16be
reverted changes made to the structure of the subsystem directory
arundhatisingh17 Nov 6, 2024
1c5ec42
make the set up gui function a little simpler by breaking it up into …
mark11778 Nov 7, 2024
61031d8
undid the changes i made to make the earlier dir changes to compile a…
mark11778 Nov 7, 2024
771fd01
i forgot to push from the lab labtop yesterday, current bugs: calcula…
Nov 9, 2024
7e56abf
added new function for the pulling the correct flags from the data
mark11778 Nov 9, 2024
4620b17
tests are not passing, but will test with g9 later today or tomorrow
mark11778 Nov 9, 2024
b1b9c5e
individual interlocks are all reporting correctly, just need all inte…
Nov 9, 2024
f80c18f
All interlocks is now working, just need to get G9 active to work
Nov 9, 2024
07abf06
unit status no longer raises errors, that would lead to full message …
mark11778 Nov 10, 2024
8f3f4d3
uncommented code that was throwing errors, G9 Active indicator is ref…
Nov 10, 2024
ec0a445
typo correction
Nov 11, 2024
8d438d2
made the save comport function for dummy ports only save the ones not…
mark11778 Nov 12, 2024
0dbb5d2
fixed an error with the data being saved, making sure that it would a…
mark11778 Nov 12, 2024
0a87c86
commiting from lab laptop
Nov 12, 2024
4fff581
Merge branch 'feature/G9Driversim' of https://github.com/uw-loci/EBEA…
Nov 12, 2024
4c1a069
adding file to so i can work on this during lecture
Nov 12, 2024
e4fd33d
added a function to detect and update comport changes; will need to t…
mark11778 Nov 12, 2024
17a5a46
revert unrelated changes to power_supply_9104.py
mslaffin Nov 12, 2024
d0c8a9c
Merge branch 'develop' into feature/G9Driversim
mslaffin Nov 12, 2024
14da511
Merge branch 'feature/G9Driversim' of https://github.com/uw-loci/EBEA…
Nov 13, 2024
4e9d1d1
small changes getting there
Nov 13, 2024
0d75c03
fix misplaced log statement
mslaffin Nov 13, 2024
e298cf7
avoid attributeError
mslaffin Nov 13, 2024
eacf94d
made some small adjustments to for the comport dection function; will…
mark11778 Nov 13, 2024
3ba4b0a
offload serial comms to background thread. fix inconsistent update sc…
mslaffin Nov 13, 2024
1e1e21a
disconnect and reconnect are working for the comport detection
Nov 15, 2024
dd8573f
Decreased time for comport change
Nov 15, 2024
19893e7
removed comment
Nov 15, 2024
c4516de
handled merge
Nov 15, 2024
6136538
No longer enqueuing None for incomplete/failed response reads
mslaffin Nov 16, 2024
76844bd
clean rogue prints
mslaffin Nov 16, 2024
074afe0
added comments and removed some functions
mark11778 Nov 16, 2024
803673d
only schedule updates if driver exists
mslaffin Nov 16, 2024
cbe69c0
Merge branch 'feature/comportdetection' of https://github.com/uw-loci…
Nov 17, 2024
407f13d
have found that this the connect/disconnect should work whenever the …
Nov 17, 2024
2d68172
merged in develop
mark11778 Nov 17, 2024
fe3da5f
one more test
Nov 17, 2024
f16cd0c
handled merge conflict
Nov 17, 2024
9e1f6e5
break on line 116 is making it so no data is put into the Q
Nov 17, 2024
eeecb19
fixed the bugs related to the threading issues
Nov 17, 2024
f07b3f5
reverted the changes made to the sleeps
mark11778 Nov 17, 2024
4db402a
pushing changes for testing; threading when not receiving communicati…
mark11778 Nov 18, 2024
e5c2796
removed stuff needed for testing, this did fix the issue
mark11778 Nov 18, 2024
5e2e564
Merge branch 'feature/G9Driversim' into feature/comportdetection
mark11778 Nov 18, 2024
672e06c
merged G9 branch with threading into comportdection to make sure that…
mark11778 Nov 18, 2024
9e53ed7
waiting to be able to test this for check to see if comport dectectio…
mark11778 Nov 18, 2024
784cfee
got the threading to work with the comport dectection
Nov 18, 2024
1a4b49b
commiting from laptop
Nov 18, 2024
4b5d7e0
found small bug in for loop indices and also setting the G9 Active in…
Nov 18, 2024
295fc13
cherry picked changes
mslaffin Nov 20, 2024
d705be7
handling merge conflicts
Nov 25, 2024
c054e12
am i just bad at merge conflicts? i feel like vscode did not do the t…
Nov 25, 2024
c52557d
adding all current serial port specs
mark11778 Dec 20, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
[16:27:18] - ERROR: Error opening serial port DUMMY_COM1: could not open port 'DUMMY_COM1': FileNotFoundError(2, 'The system cannot find the file specified.', None, 2)
[16:27:19] - ERROR: Failed to open serial port COM11: could not open port 'COM11': FileNotFoundError(2, 'The system cannot find the file specified.', None, 2)
[16:27:19] - INFO: G9 driver initialized
[16:27:20] - ERROR: Exception while initializing temperature controllers at DUMMY_COM5: 'ModbusSerialClient' object has no attribute 'port'
[16:27:20] - ERROR: Error opening serial port DUMMY_COM2: could not open port 'DUMMY_COM2': FileNotFoundError(2, 'The system cannot find the file specified.', None, 2)
[16:27:20] - DEBUG: Raw command sent: SABC3
[16:27:20] - ERROR: Failed to initialize CathodeA PS on port DUMMY_COM2: 'NoneType' object has no attribute 'write'
[16:27:20] - ERROR: Error opening serial port DUMMY_COM3: could not open port 'DUMMY_COM3': FileNotFoundError(2, 'The system cannot find the file specified.', None, 2)
[16:27:20] - DEBUG: Raw command sent: SABC3
[16:27:20] - ERROR: Failed to initialize CathodeB PS on port DUMMY_COM3: 'NoneType' object has no attribute 'write'
[16:27:20] - ERROR: Error opening serial port DUMMY_COM4: could not open port 'DUMMY_COM4': FileNotFoundError(2, 'The system cannot find the file specified.', None, 2)
[16:27:20] - DEBUG: Raw command sent: SABC3
[16:27:20] - ERROR: Failed to initialize CathodeC PS on port DUMMY_COM4: 'NoneType' object has no attribute 'write'
[16:27:20] - DEBUG: Power supply 1 not initialized. Button disabled.
[16:27:20] - DEBUG: Power supply 2 not initialized. Button disabled.
[16:27:20] - DEBUG: Power supply 3 not initialized. Button disabled.
[16:27:20] - DEBUG: No power supplies were initialized properly.
[16:27:20] - DEBUG: No connection to CCS temperature controller 1
[16:27:20] - DEBUG: No connection to CCS temperature controller 2
[16:27:20] - DEBUG: No connection to CCS temperature controller 3
[16:27:20] - WARNING: G9 driver not connected
[16:27:21] - WARNING: G9 driver not connected
[16:27:22] - WARNING: G9 driver not connected
[16:27:23] - WARNING: G9 driver not connected
[16:27:26] - WARNING: G9 driver not connected
[16:27:26] - WARNING: G9 Connection issue. Update interval: 2530ms
[16:27:29] - WARNING: G9 driver not connected
[16:27:30] - DEBUG: No connection to CCS temperature controller 1
[16:27:30] - DEBUG: No connection to CCS temperature controller 2
[16:27:30] - DEBUG: No connection to CCS temperature controller 3
[16:27:31] - WARNING: G9 driver not connected

1,007 changes: 1,007 additions & 0 deletions EBEAM-Dashboard-Logs/usb_disconnect_log.txt

Large diffs are not rendered by default.

25 changes: 25 additions & 0 deletions com_ports.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"VTRXSubsystem": {
"com_port": "DUMMY_COM1"
},
"CathodeA PS": {
"com_port": "DUMMY_COM2"
},
"CathodeB PS": {
"com_port": "DUMMY_COM3"
},
"CathodeC PS": {
"com_port": "DUMMY_COM4"
},
"TempControllers": {
"com_port": "DUMMY_COM5"
},
"Interlocks": {
"com_port": "COM11",
"vid": 1027,
"pid": 24577,
"serial_number": "AD0K0ZIEA",
"manufacturer": "FTDI",
"description": "USB Serial Port (COM11)"
}
}
150 changes: 86 additions & 64 deletions dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,38 @@
from usr.panel_config import save_pane_states, load_pane_states, saveFileExists
import serial.tools.list_ports


# Only have the interlocks at the top of the display
# title, row, width, height
frames_config = [
("Oil System", 0, 50, 150),
("Visualization Gas Control", 0, 50, 150),
("System Checks", 0, None, None),
("Beam Extraction", 0, None, None),
("Vacuum System", 1, 150, 300),
("Deflection Monitor", 1, None, None),
("Beam Pulse", 1, None, None),
("Main Control", 1, 50, 300),
("Setup Script", 2, None, 25),
("Interlocks", 2, None, 25),
("High Voltage Warning", 2, None, 25),
("Environmental", 3, 150, 450),
("Cathode Heating", 3, 960, 450),
("Interlocks", 0, None, 2), # Moved to the top row
("Oil System", 1, 50, 150),
("Visualization Gas Control", 2, 50, 150),
("System Checks", 1, None, None),
("Beam Extraction", 1, None, None),
("Vacuum System", 2, 150, 300),
("Deflection Monitor", 2, None, None),
("Beam Pulse", 2, None, None),
("Main Control", 2, 50, 300),
("Setup Script", 3, None, 25),
("High Voltage Warning", 3, None, 25),
("Environmental", 4, 150, 450),
("Cathode Heating", 4, 960, 450),
]

class EBEAMSystemDashboard:
PORT_INFO = {
"AD0K0ZIEA" : "Interlocks"
}
def __init__(self, root, com_ports):
self.root = root
self.com_ports = com_ports
self.set_com_ports = set(serial.tools.list_ports.comports())

self.root.title("EBEAM Control System Dashboard")

# if save file exists call it and open it
if saveFileExists():
self.load_saved_pane_state()

# if save file exists call it and open it
if saveFileExists():
Expand All @@ -52,6 +61,9 @@ def __init__(self, root, com_ports):
# Set up different subsystems within their respective frames
self.create_subsystems()

# starts the constant check for the avavilbe com ports
self._check_for_port_changes()

def setup_main_pane(self):
"""Initialize the main layout pane and its rows."""
self.main_pane = tk.PanedWindow(self.root, orient='vertical', sashrelief=tk.RAISED)
Expand All @@ -73,7 +85,8 @@ def create_frames(self):
else:
frame = tk.Frame(borderwidth=1, relief="solid")
self.rows[row].add(frame, stretch='always')
self.add_title(frame, title)
if title != "Interlocks":
self.add_title(frame, title)
self.frames[title] = frame
if title == "Setup Script":
SetupScripts(frame)
Expand Down Expand Up @@ -153,6 +166,11 @@ def save_current_pane_state(self):
def load_saved_pane_state(self):
savedData = load_pane_states()

for i in range(len(frames_config)):
if frames_config[i][0] in savedData:
frames_config[i] = (frames_config[i][0], frames_config[i][1], savedData[frames_config[i][0]][0],savedData[frames_config[i][0]][1])
savedData = load_pane_states()

for i in range(len(frames_config)):
if frames_config[i][0] in savedData:
frames_config[i] = (frames_config[i][0], frames_config[i][1], savedData[frames_config[i][0]][0],savedData[frames_config[i][0]][1])
Expand Down Expand Up @@ -191,11 +209,13 @@ def create_subsystems(self):
logger=self.logger
),
'Interlocks': subsystem.InterlocksSubsystem(
self.frames['Interlocks'],
logger=self.logger
self.frames['Interlocks'],
com_ports = self.com_ports['Interlocks'],
logger=self.logger,
frames = self.frames
),
'Oil System': subsystem.OilSubsystem(
self.frames['Oil System'],
self.frames['Oil System'],
logger=self.logger
),
'Cathode Heating': subsystem.CathodeHeatingSubsystem(
Expand All @@ -207,25 +227,22 @@ def create_subsystems(self):

def create_messages_frame(self):
"""Create a frame for displaying messages and errors."""
self.messages_frame = MessagesFrame(self.rows[3])
self.rows[3].add(self.messages_frame.frame, stretch='always')
self.messages_frame = MessagesFrame(self.rows[4])
self.rows[4].add(self.messages_frame.frame, stretch='always')
self.logger = self.messages_frame.logger

def create_com_port_frame(self, parent_frame):
self.com_port_frame = ttk.Frame(parent_frame)
self.com_port_frame.pack(side=tk.TOP, fill=tk.X, padx=5, pady=5)

self.com_port_button = ttk.Button(self.com_port_frame, text="Configure COM Ports", command=self.toggle_com_port_menu)
self.com_port_button.pack(side=tk.TOP, anchor='w')

self.com_port_menu = ttk.Frame(self.com_port_frame)
self.com_port_menu.pack(side=tk.TOP, fill=tk.X, expand=True)
self.com_port_menu.pack_forget() # Initially hidden

self.port_selections = {}
self.port_dropdowns = {}

for subsystem in ['VTRXSubsystem', 'CathodeA PS', 'CathodeB PS', 'CathodeC PS', 'TempControllers']:
for subsystem in ['VTRXSubsystem', 'CathodeA PS', 'CathodeB PS', 'CathodeC PS', 'TempControllers', 'Interlocks']:
frame = ttk.Frame(self.com_port_menu)
frame.pack(fill=tk.X, padx=5, pady=2)
ttk.Label(frame, text=f"{subsystem}:").pack(side=tk.LEFT)
Expand All @@ -235,44 +252,49 @@ def create_com_port_frame(self, parent_frame):
dropdown.pack(side=tk.RIGHT)
self.port_dropdowns[subsystem] = dropdown

ttk.Button(self.com_port_menu, text="Apply", command=self.apply_com_port_changes).pack(pady=5)

def toggle_com_port_menu(self):
if self.com_port_menu.winfo_viewable():
self.com_port_menu.pack_forget()
self.com_port_button.config(text="Configure COM Ports")
else:
self.update_available_ports()
self.com_port_menu.pack(after=self.com_port_button, fill=tk.X, expand=True)
self.com_port_button.config(text="Hide COM Port Configuration")

def update_available_ports(self):
available_ports = [port.device for port in serial.tools.list_ports.comports()]
for dropdown in self.port_dropdowns.values():
current_value = dropdown.get()
dropdown['values'] = available_ports
if current_value in available_ports:
dropdown.set(current_value)
elif available_ports:
dropdown.set(available_ports[0])
else:
dropdown.set('')

def apply_com_port_changes(self):
new_com_ports = {subsystem: var.get() for subsystem, var in self.port_selections.items()}
self.update_com_ports(new_com_ports)
self.toggle_com_port_menu()

def update_com_ports(self, new_com_ports):
self.com_ports = new_com_ports
# TODO: update the COM ports for each subsystem

for subsystem_name, subsystem in self.subsystems.items():
if hasattr(subsystem, 'update_com_port'):
if subsystem_name == 'Vacuum System':
subsystem.update_com_port(new_com_ports.get('VTRXSubsystem'))
elif subsystem_name == 'Cathode Heating':
subsystem.update_com_ports(new_com_ports)
else:
self.logger.warning(f"Subsystem {subsystem_name} does not have an update_com_port method")

def _check_for_port_changes(self):
"""
Compares the current available comports to the last set

Finally:
Calls itself to be cheack again
"""
nowPorts = set(serial.tools.list_ports.comports())

dif = self.set_com_ports - nowPorts
added_ports = nowPorts - self.set_com_ports

try:
# Process removed ports
for port in dif:
if port.serial_number in self.PORT_INFO:
self.logger.warning(f"Lost connection to {self.PORT_INFO[port.serial_number]} on {port}")
self._update_com_ports(self.PORT_INFO[port.serial_number], None)

# Process added ports
for port in added_ports:
if port.serial_number in self.PORT_INFO:
self.logger.info(f"Attempting to connect {self.PORT_INFO[port.serial_number]} to {port}")
self._update_com_ports(self.PORT_INFO[port.serial_number], port)
except Exception as e:
self.logger.warning(f"Error was thrown when either removing or adding a comport: {e}")

finally:
self.set_com_ports = nowPorts
self.root.after(500, self._check_for_port_changes)

def _update_com_ports(self, subsystem, port):
"""
Calls to update subsystems with change in comport
"""
if subsystem == None:
raise ValueError("_update_com_ports was called with invalid args")
strPort = port.device if port != None else None
if subsystem in self.subsystems.keys():
if subsystem == "Interlocks":
self.subsystems[subsystem].update_com_port(strPort)
#TODO: Need to add Vacuum system and Cathode Heating

self.logger.info(f"COM ports updated: {self.com_ports}")

Binary file added instrumentctl/G9DriverFlowChart.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading