aboutsummaryrefslogtreecommitdiff
path: root/new_plan.md
blob: 6c7186e691b1c827694f76e8475a158f542964e1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
             Design

The application will be a single-window GUI built with PyQt5. It will be composed of three main components: a main
window, a refactored plotter widget, and a background worker for data acquisition.

 1 PicoStreamMainWindow (QMainWindow): This will be the application's central component, serving as the main entry point.
    • Layout: It will feature a two-panel layout. The left panel will contain all user-configurable settings for the
      acquisition (e.g., sample rate, voltage range, output file). The right panel will contain the embedded live plot.
    • Control: It will have "Start" and "Stop" buttons to manage the acquisition lifecycle. It will manage the
      application's state (e.g., idle, acquiring, error).
    • Persistence: It will use QSettings to automatically save user-entered settings on exit and load them on startup.
    • Lifecycle: It will be responsible for creating and managing the background worker thread and ensuring a graceful
      shutdown.
 2 HDF5LivePlotter (QWidget): The existing plotter will be refactored from a QMainWindow into a QWidget.
    • Responsibility: Its sole responsibility will be to monitor the HDF5 file and display the live data. It will no
      longer be a top-level window or control the application's lifecycle.
    • Integration: An instance of this widget will be created and embedded directly into the right-hand panel of the
      PicoStreamMainWindow.
 3 StreamerWorker (QObject): This class will manage the acquisition task in a background thread to keep the GUI
   responsive.
    • Execution: It will be moved to a QThread. Its primary method will instantiate the Streamer class with parameters
      from the GUI and call the blocking Streamer.run() method.
    • Communication: It will use Qt signals to report its status (e.g., finished, error) back to the PicoStreamMainWindow
      in a thread-safe manner. The main window will connect to these signals to update the UI, for example, by
      re-enabling the "Start" button upon completion.

                                               Phased Implementation Plan

This plan breaks the work into five distinct, sequential phases.

Phase 1: Project Restructuring and GUI Shell The goal is to set up the new file structure and a basic, non-functional GUI
window.

 1 Rename picostream/main.py to picostream/cli.py.
 2 Create a new, empty picostream/main.py to serve as the GUI entry point.
 3 In the new main.py, create a PicoStreamMainWindow class with a simple layout containing placeholders for the settings
   panel and the plot.
 4 Update the justfile with a new target to run the GUI application.

Phase 2: Background Worker Implementation The goal is to run the data acquisition in a background thread, controlled by
the GUI.

 1 In picostream/main.py, create the StreamerWorker class inheriting from QObject.
 2 Implement the QThread worker pattern in PicoStreamMainWindow to start the acquisition when a "Start" button is clicked
   and to signal a stop using the existing shutdown_event.
 3 Connect the worker's finished and error signals to GUI methods that update the UI state (e.g., re-enable buttons).

Phase 3: GUI Controls and Settings Persistence The goal is to make the acquisition configurable through the GUI and to
remember settings.

 1 Populate the settings panel in PicoStreamMainWindow with input widgets for all acquisition parameters.
 2 Pass the values from these widgets to the StreamerWorker when starting an acquisition.
 3 Implement load_settings and save_settings methods using QSettings.

Phase 4: Plotter Integration The goal is to embed the live plot directly into the main window.

 1 In picostream/dfplot.py, refactor the HDF5LivePlotter class to inherit from QWidget instead of QMainWindow. Remove its
   window-management logic.
 2 In PicoStreamMainWindow, replace the plot placeholder with an instance of the refactored HDF5LivePlotter widget.

Phase 5: Packaging The goal is to create a standalone, distributable executable.

 1 Add a new build target to the justfile that uses PyInstaller to bundle the application.
 2 Configure the build to handle dependencies, particularly creating a hook for Numba if necessary.
 3 Test the final executable.