-
Notifications
You must be signed in to change notification settings - Fork 7
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
Multiple Device Integration #265
base: main
Are you sure you want to change the base?
Conversation
We may have to switch gears on this work and put it towards a dedicated issue for the serial port device test feature. My only concern is pushing code to main before we get a chance to test with multiple serial devices ourselves. Let me know your thoughts on this. Many smaller commits are preferred while you are working to help with code readability (small commits help devs too as commit messages will show alongside the line in code editors). It is essential for debugging, especially with Pylint. |
The code runs on my machine and the test screen looks good. Excited to test these changes out with hardware tomorrow. I noticed it is very annoying to test around with these features once you activate the listener with no hardware (like on a laptop or home pc). A keyboard quit command (something like CTRL+C or CTRL+Q) in terminal to stop the listener would be so useful. edit: There is also no way to return to the home screen (where you see New Experiment and your new test screen) once an experiment is opened 🤣 . This is an immediate new issue. |
data_thread.start() | ||
|
||
# Automated handling of data input | ||
def check_for_data(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We use
# Main loop or functionality can go here
while True:
print("Main thread is running. Most recent data:", data_handler.get_stored_data())
time.sleep(1)
except KeyboardInterrupt:
print("Stopping serial reader...")
finally:
data_handler.stop()
data_thread.join()
print("Serial reader stopped.")
in serial_handler.py. Try wrapping this logic in a try except with KeyboardInterrupt.
This issue isn't fully done yet (thanks for calling out the back to menu, I'll add that soon. I still need to test once the adapter is here and then restructure accordingly, and then it'll hopefully be done Edit: Logic-wise it should fully work. The idea of doing multiple measurement devices was my original idea, but it is incredibly complex to configure that, can be done, but this sprint definitely opened the door for that to happen in a later sprint. This test screen is only to help me integrate it in the data collection page in the next sprint for issue #263 (hopefully). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
overall, this looks good. The changes work, but I cannot fully test everything without the actual serial devices myself.
@@ -16,6 +16,7 @@ | |||
from experiment_pages.experiment.experiment_menu_ui import ExperimentMenuUI | |||
from experiment_pages.create_experiment.new_experiment_ui import NewExperimentUI | |||
from experiment_pages.experiment.select_experiment_ui import ExperimentsUI | |||
from experiment_pages.experiment.test_screen import TestScreen |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good importing, ensuring no excess is brought in.
@@ -116,6 +117,10 @@ def create_file(): | |||
page = NewExperimentUI(root, experiments_frame) | |||
page.raise_frame() | |||
|
|||
def open_test(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will this be needed in final release?
with open(config_path, "r") as file: | ||
device_name = file.readline().strip() | ||
|
||
elif os.path.exists(rfid_path): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good to understand if the device is not the RFID device.
self.settings = self.port_controller.retrieve_setting("serial_port_preference.csv") | ||
self.device_file = self.find_device_config(port) | ||
if not self.device_file: | ||
print(f"ERROR: No configuration file found for {port}.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good for ensuring the device is set up properly.
print(f"ERROR: preferred_config.txt missing for {port}.") | ||
return None | ||
except Exception as e: | ||
print(f"Error reading device config: {e}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be a catch instead of an except?
Fixes #260
What was changed?
The application can now handle more than one (two) serial devices at a time. Created a test screen that can detect and test both RFID devices.
Why was it changed?
In order for our clients to be able to scan mice into the system AND take in measurements, they must be able to use RFID readers and measurement devices at the same time. This is a very important feature to the integrity of the deployment of this program.
How was it changed?
Rather than having one preference folder that finds the desired device settings, I split it into "Device" and "RFID" folders and did a bunch of changes to how objects like the serial controller, handler, and listener are instantiated in order to effectively maneuver which device is which. I haven't been able to test the true functionality of this just yet, but based on tests that I set throughout the code, it should work flawlessly.
I added a button to the device configuration screen that can set devices to their respective categories (i.e. caliper settings would go to measurement device, reader would go to RFID device.
On top of that, I added a button to the main screen that can take you to a device testing screen to make sure that these devices are properly configured and working. This screen is hopefully a nice feature that the lab techs can use in order to ensure correct configuration before testing.
Screenshots that show the changes (if applicable):