Skip to content

Commit b6d83d3

Browse files
committed
Clean code quality and rename syringe pump driver
1 parent 2a3d90d commit b6d83d3

42 files changed

Lines changed: 466 additions & 338 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

ARCHITECTURE.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ The droplet detection pipeline in `software/droplet-detection/` runs **alongside
141141
If you want to verify that "who owns what logic" is consistent in code, start with `software/main.py`. In broad strokes it:
142142

143143
- initializes Flask + Socket.IO
144-
- instantiates device controllers (`Camera`, `FlowWeb`, `heater_web`, `PumpController`) and (optionally) `DropletDetectorController`
144+
- instantiates device controllers (`Camera`, `FlowWeb`, `heater_web`, `SyringePumpController`) and (optionally) `DropletDetectorController`
145145
- instantiates remote adapters (if `RIO_REMOTE_MODULES` is set) to forward calls to API
146146
- instantiates web controllers (Socket.IO handlers under `software/rio-webapp/controllers/`)
147147
- registers HTTP routes and `/api/droplet/*` endpoints via `software/rio-webapp/routes.py`
@@ -150,7 +150,8 @@ If you want to verify that "who owns what logic" is consistent in code, start wi
150150
## Configuration (what decides which parts run)
151151

152152
Configuration is primarily driven by environment variables (`RIO_*`) plus a small number of config/constants in `software/config.py`.
153-
- **Hardware vs simulation**: routine dev/tests use `RIO_SIMULATION=true`; hardware runs use `RIO_SIMULATION=false`.
153+
- **Hardware vs simulation**: routine dev/tests use `RIO_SIMULATION=true`; hardware runs use `RIO_SIMULATION=false`. `rio-config.yaml` can optionally set `runtime.default_backend` and per-module overrides when `RIO_SIMULATION` is not explicitly set.
154+
- **Mixed backend (per-module)**: set `runtime.modules.syringe_pump: hardware` (or `RIO_MODULE_BACKENDS="syringe_pump=hardware"`) to run syringe pump hardware while keeping other modules in simulation.
154155
- **Feature toggles**: modules such as droplet analysis, flow, heater can be enabled/disabled via env vars (see `software/README.md`).
155156
- **Strobe pacing**: PIC-paced only (camera is triggered by the PIC; no multi-mode selection).
156157
- **ROI mode**: `RIO_ROI_MODE=software|hardware` (software default). Hardware ROI applies only on camera backends that support it; otherwise the app falls back to software ROI.

software/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Use these short READMEs to navigate the codebase. Detailed implementation lives
2727

2828
The main runtime entry point is **`software/main.py`**, which wires the layers together in a fairly direct way:
2929

30-
- **SPI/GPIO backend selection** happens inside `drivers/spi_handler.py` (simulation vs hardware is chosen via `RIO_SIMULATION=true|false`).
30+
- **SPI/GPIO backend selection** happens inside `drivers/spi_handler.py` (simulation vs hardware defaults to `RIO_SIMULATION=true|false`, but `runtime.default_backend` in `rio-config.yaml` can set this when `RIO_SIMULATION` is not explicitly set).
3131
- **Device controllers** are created in `main.py`:
3232
- `controllers/flow_web.py` (`FlowWeb`) wraps `drivers/flow.py` (`PiFlow`)
3333
- `controllers/heater_web.py` (`heater_web`) wraps `drivers/heater.py` (`PiHolder`)
@@ -169,7 +169,7 @@ bash ./scripts/dev/run-simulation.sh
169169

170170
```
171171

172-
Need custom parameters for simulation (frame size, ROI defaults, feature flags)? See `configurations/README.md` for the environment-variable profiles and examples you can export before running.
172+
Need custom parameters for simulation (frame size, ROI defaults, feature flags)? See `configurations/README.md` for the environment-variable profiles and examples you can export before running. Mixed backend selection (e.g., syringe pump hardware while other modules are simulated) is configured via the `runtime` block in `rio-config.yaml` or with `RIO_MODULE_BACKENDS`.
173173

174174
**Option 2: Manual setup**
175175
```bash
@@ -181,7 +181,7 @@ python main.py
181181

182182
The `scripts/dev/setup-simulation.sh` script creates a conda/mamba environment named **`rio-simulation`** and installs dependencies. The `scripts/dev/run-simulation.sh` script activates that environment and runs the app in simulation mode.
183183

184-
Note: `setup-simulation.sh` also creates a `rio-config.yaml` file for simulation settings, but **the main app currently selects simulation via `RIO_SIMULATION=true`**; `rio-config.yaml` is not a primary runtime configuration source for `main.py`.
184+
Note: `setup-simulation.sh` also creates a `rio-config.yaml` file for simulation settings. `software/main.py` now reads the `runtime` section from `rio-config.yaml` (or `RIO_CONFIG_FILE`) to choose the default backend and per-module overrides (currently used for the syringe pump).
185185

186186
This enables simulated SPI, GPIO, camera, and device controllers, allowing you to test the web interface and logic without physical hardware.
187187

0 commit comments

Comments
 (0)