Skip to content

Commit

Permalink
Feature/G9_Driver (#16)
Browse files Browse the repository at this point in the history
* seeing if i can get the same widget sizes to work

* working on understanding how the tkinter library works

* works

* added comments and got rid of old code

* push1

* rough write up for G9 Driver

* more edits

* commiting before leaving

* made a few chnages to g9_driver.py

* made a few changes

* looking into what will be needed for the frontend to work

* adding another indicator cause i think red is more clear on what it means

* made some small changes to interlocks.py

* added alot of functions to parse and form input/output

* fixed indice values

* getting SITDF, OCTD, and SODTF

* raise error for OCTD case

* Retrieved SOTDF readings

* minor edits

* small changes

* small change

* clarified acronyms

* resolved optional and reserved data

* added test file

* g9_backend handle_errors

* error handling, highlighted frames

* added logger

* added logger

* testing functions in g9 driver

* committing

* temp changes

* minor change

* updating tests

* working to see if the driver file works

* updated g9_driver

* commiting to switch branch

* some how there was not a gitignore on this branched, had to fix to make sure the venv would not be tracked

* removed duplicate functions, driver is looking to be close to being finished

* removed print statements

* updated the g9driver test file was uptodate

* while updating the gitignore, removed the panel_config.py on accident

* add Interlock's COM port to be defined in main.py

* update .gitignore and remove .pyc files

* working on resolving merge request errors

* commiting to work on other laptop

* was working on adding the changes to the driver and also working with some of the flag sections and error sections to exclude the reserver data being processed

* added update method and todo comments

* working on backend

* working on interlocks.py

* commiting changes

* set driver com port to none to test

* error hierarchy

* testing

* modified calculate_checksum() to send both high and low byte

* temp

* corrected check_flags_13

* correction

* Addressed data indexing to access a single byte by slicing

* removed duplicate file

* fixed type line 99

* small change

* working on tester

* modified msg for test1

* push

* pushing

* modified msg

* fixed typo line 99 to return byte object instead of str

* finishing up the test

* pushing for tests

* error fixed

* added responseTestCreator.py

* small changes

* added comments to tests

* added comments

* actually added the comments this time

* starting to work on forming the front end

* it was bothering me that the water indicator was not centered

* is_connected function in g9driver

* working on adding the global vars

* forgot to save lol

* added comments to the driver file and rearranged some things

* removed one of the tests because that functionality is not longer needed at this time

* crazy changes, made a square indicator method

* added the g9 output and hvolt indicatator to the dictionary

* i think css is easier to visualize, more frontend changes

* made sure that com port was being passed to the interlocks.py

* ensured g9 specific constants were placed within the class itself and called appropriately. Still need to update a few more constants to replace them with appropriately named variables

* made all changes except check_sum

* checksum calculation added in response

* updated all changes according to suggestions

* Further clarified on constants and usage

* minor fixes from merging process

* gui chnages

* spaced out the HV Status frame

* changes to frontend

* Added another indicator for the E-STOP

* shifted the interlocks frame to the top of gui to chreate space

* small change

* remove unused imports

* fix serial connection check

* simplify checksum. rework message construction in send_command

* worked on the frontend how everything is adjusted to just be at the top of the screen

* the checksum function is making all the tests fail, will revisit this

* i think there is a better way to store and arrange the interlock data but im not sure yet

* working on the backend in interlock.py

* working on backend still

* changes to integrate backend to access binary

* rework checksum and read_response

* testing the interlocks.py to reflect status flag changes on the dashboard

* modified mock_data()

* ensured update_data is constantly called every 5 seconds and scrapped mock_data test changes

* Force remove .venv and .vscode dirs

* add .venv to gitignore

* moved a test file to scripts\G9Drivertest

* debugged g9driver.py and interlocks.py to correctly update interlocks

* moving files around

* added the functionality for the all interlocks

* bug related to all interlocks fix

* added logger status for change in interlocks

* fixed bug in the interlock logger updating

* fixed error being thrown when g9driver is not defined or the com port is not defined

* overhaul G9 data access and comm handling

* enforce error rate limiting when no COM port available

* fix SITEC/SOTEC labels

* update G9 unit test file

* first draft of readme

* i should've checked my grammar first

* typo in readme

* worked on comments in the G9driver file

* improved input checking for methods and added more detail to the function comments

* restructure the git repo with subsystem/instrumentctl READMEs

* working on sanitizing inputs for methods

* added log function and made it the same as other functions

* fixed the file organization problem

* working on G9 readme

* still working on the code flow diagram

* worked on the flow chart

* fixed missing return labels

* reverted changes made to the structure of the subsystem directory

* make the set up gui function a little simpler by breaking it up into smaller methods

* undid the changes i made to make the earlier dir changes to compile and run

* i forgot to push from the lab labtop yesterday, current bugs: calculate checksum and the bits that are being returned for sitsf and sitdf

* added new function for the pulling the correct flags from the data

* tests are not passing, but will test with g9 later today or tomorrow

* individual interlocks are all reporting correctly, just need all interlocks and G9 active

* All interlocks is now working, just need to get G9 active to work

* unit status no longer raises errors, that would lead to full message not being parsed; now only reports to the log; will need to rewrite some of the tests to reflex these changes

* uncommented code that was throwing errors, G9 Active indicator is reflecting the what the G9 is outputing; currently unit state is not dowing what it should

* typo correction

* commiting from lab laptop

* revert unrelated changes to power_supply_9104.py

* fix misplaced log statement

* avoid attributeError

* offload serial comms to background thread. fix inconsistent update scheduling

* No longer enqueuing None for incomplete/failed response reads

* clean rogue prints

* only schedule updates if driver exists

* break on line 116 is making it so no data is put into the Q

* fixed the bugs related to the threading issues

* reverted the changes made to the sleeps

* pushing changes for testing; threading when not receiving communications does not set all indicators to red

* removed stuff needed for testing, this did fix the issue

* remove log files from repo. should only be posting these to PR's

* removing another committed logfile

---------

Co-authored-by: Mark Ruzicka <[email protected]>
Co-authored-by: A Permalla <[email protected]>
Co-authored-by: Arundhati Singh <[email protected]>
Co-authored-by: Experiment <[email protected]>
  • Loading branch information
5 people authored Nov 18, 2024
1 parent ff2935a commit b78c601
Show file tree
Hide file tree
Showing 21 changed files with 2,393 additions and 67 deletions.
56 changes: 36 additions & 20 deletions dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,19 @@


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:
Expand All @@ -33,6 +33,10 @@ def __init__(self, root, com_ports):
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():
self.load_saved_pane_state()
Expand Down Expand Up @@ -65,6 +69,7 @@ def setup_main_pane(self):
def create_frames(self):
"""Create frames for different systems and controls within the dashboard."""
global frames_config
global frames_config

for title, row, width, height in frames_config:
if width and height and title:
Expand All @@ -73,7 +78,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 @@ -145,14 +151,22 @@ def add_title(self, frame, title):
label = tk.Label(frame, text=title, font=("Helvetica", 10, "bold"))
label.pack(pady=0, fill=tk.X)

# saves data to file when button is pressed
# saves data to file when button is pressed
def save_current_pane_state(self):
save_pane_states(frames_config, self.frames, self.main_pane)
save_pane_states(frames_config, self.frames, self.main_pane)

# gets data in save config file (as dict) and updates the global var of frames_config
# gets data in save config file (as dict) and updates the global var of frames_config
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 +205,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,8 +223,8 @@ 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):
Expand All @@ -225,7 +241,7 @@ def create_com_port_frame(self, parent_frame):
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 Down
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

0 comments on commit b78c601

Please sign in to comment.