Restructure package for domain-driven design

Reorganise package structure to improve separation of concerns:
- instruments/ - SCPI, transport, drivers, interfaces, factory
- simulation/ - physics engine, virtual instruments, server
- framework/ - test runner, logger, limits, context
- tests/ - thermal/, electrical/ (DVT test implementations)
- data/ - repository, models
- reporting/ - generator, templates
- app/ - CLI, config, dashboard

This structure enables:
- Reusable instruments package for other test suites
- Clear separation of simulation (dev) vs production code
- Domain-focused package organisation

Updated documentation to reflect new paths.
This commit is contained in:
2025-02-10 12:06:22 +00:00
parent 700991e9a3
commit 85a0122e19
29 changed files with 332 additions and 361 deletions

View File

@@ -38,7 +38,7 @@ Each sprint is ~1-2 days of work, producing demonstrable progress.
**Vertical Slice Strategy:**
- Sprints 1-3: Foundation + Physics Engine (the core simulation)
- Sprint 4: Dashboard (see the physics working!)
- Sprints 5-11: Infrastructure/Plumbing (SCPI, TCP, HAL)
- Sprints 5-11: Infrastructure/Plumbing (SCPI, TCP, Instruments)
- Sprints 12-17: Test Framework, CLI, Polish
---
@@ -79,20 +79,18 @@ Each sprint is ~1-2 days of work, producing demonstrable progress.
**Goal:** Define physics interfaces and data structures.
### Task 2.1: Define thermal state dataclasses
- Create src/py_dvt_ate/physics/__init__.py
- Create src/py_dvt_ate/physics/models.py
- Create src/py_dvt_ate/simulation/physics/models.py
- Define ThermalState (frozen dataclass)
- Define ElectricalState (frozen dataclass)
- **Commit:** "Add physics state dataclasses"
### Task 2.2: Define DUT base protocol
- Create src/py_dvt_ate/physics/dut/__init__.py
- Create src/py_dvt_ate/physics/dut/base.py
- Create src/py_dvt_ate/simulation/physics/models/base.py
- Define DUTModel Protocol with method signatures
- **Commit:** "Add DUT model protocol"
### Task 2.3: Create physics engine stub
- Create src/py_dvt_ate/physics/engine.py
- Create src/py_dvt_ate/simulation/physics/engine.py
- Define PhysicsEngine class with stub methods
- Methods return placeholder values
- **Commit:** "Add physics engine stub"
@@ -109,13 +107,13 @@ Each sprint is ~1-2 days of work, producing demonstrable progress.
**Goal:** Implement working physics simulation.
### Task 3.1: Implement thermal calculations
- Create src/py_dvt_ate/physics/thermal.py
- Create src/py_dvt_ate/simulation/physics/thermal.py
- Implement first-order thermal response calculations
- Pure functions, no state
- **Commit:** "Implement thermal calculation functions"
### Task 3.2: Implement LDO DUT model
- Create src/py_dvt_ate/physics/dut/ldo.py
- Create src/py_dvt_ate/simulation/physics/models/ldo.py
- Implement LDOModel class
- Temperature-dependent Vout, Iq calculations
- Power dissipation calculation
@@ -140,8 +138,8 @@ Each sprint is ~1-2 days of work, producing demonstrable progress.
**Goal:** Visualise physics engine directly - see something working!
### Task 4.1: Create dashboard app skeleton
- Create src/py_dvt_ate/dashboard/__init__.py
- Create src/py_dvt_ate/dashboard/app.py
- Create src/py_dvt_ate/app/dashboard/__init__.py
- Create src/py_dvt_ate/app/dashboard/app.py
- Basic Streamlit page with title
- **Commit:** "Add Streamlit dashboard skeleton"
@@ -173,7 +171,7 @@ Each sprint is ~1-2 days of work, producing demonstrable progress.
### Task 5.1: Define SCPI command dataclass
- Create src/py_dvt_ate/instruments/__init__.py
- Create src/py_dvt_ate/instruments/scpi_parser.py
- Create src/py_dvt_ate/instruments/scpi.py
- Define SCPICommand dataclass
- **Commit:** "Add SCPI command dataclass"
@@ -196,13 +194,13 @@ Each sprint is ~1-2 days of work, producing demonstrable progress.
**Goal:** Create first virtual instrument.
### Task 6.1: Define instrument base class
- Create src/py_dvt_ate/instruments/base.py
- Create src/py_dvt_ate/simulation/virtual/base.py
- Define BaseInstrument with common functionality
- Command dispatch mechanism
- **Commit:** "Add base instrument class"
### Task 6.2: Create thermal chamber simulator stub
- Create src/py_dvt_ate/instruments/thermal_chamber.py
- Create src/py_dvt_ate/simulation/virtual/chamber.py
- Define ThermalChamberSim class
- Stub SCPI command handlers
- **Commit:** "Add thermal chamber simulator stub"
@@ -224,7 +222,7 @@ Each sprint is ~1-2 days of work, producing demonstrable progress.
**Goal:** Complete instrument simulators.
### Task 7.1: Create power supply simulator
- Create src/py_dvt_ate/instruments/power_supply.py
- Create src/py_dvt_ate/simulation/virtual/power_supply.py
- Implement PSU SCPI commands
- VOLT, CURR, OUTP, MEAS commands
- **Commit:** "Add power supply simulator"
@@ -234,7 +232,7 @@ Each sprint is ~1-2 days of work, producing demonstrable progress.
- **Commit:** "Add power supply simulator tests"
### Task 7.3: Create DMM simulator
- Create src/py_dvt_ate/instruments/multimeter.py
- Create src/py_dvt_ate/simulation/virtual/multimeter.py
- Implement DMM SCPI commands
- MEAS:VOLT:DC?, CONF commands
- **Commit:** "Add multimeter simulator"
@@ -250,8 +248,8 @@ Each sprint is ~1-2 days of work, producing demonstrable progress.
**Goal:** Expose instruments over network.
### Task 8.1: Create async TCP server foundation
- Create src/py_dvt_ate/server/__init__.py
- Create src/py_dvt_ate/server/tcp_server.py
- Create src/py_dvt_ate/simulation/__init__.py
- Create src/py_dvt_ate/simulation/tcp_server.py
- Define InstrumentServer class with asyncio
- **Commit:** "Add async TCP server foundation"
@@ -261,7 +259,7 @@ Each sprint is ~1-2 days of work, producing demonstrable progress.
- **Commit:** "Implement TCP client handling"
### Task 8.3: Create server main entry point
- Create src/py_dvt_ate/server/main.py
- Create src/py_dvt_ate/simulation/server.py
- Wire up physics engine and instruments
- Add CLI command to start server
- **Commit:** "Add simulation server entry point"
@@ -278,13 +276,13 @@ Each sprint is ~1-2 days of work, producing demonstrable progress.
**Goal:** Create client-side communication.
### Task 9.1: Define transport protocol
- Create src/py_dvt_ate/transport/__init__.py
- Create src/py_dvt_ate/transport/base.py
- Create src/py_dvt_ate/instruments/transport/__init__.py
- Create src/py_dvt_ate/instruments/transport/base.py
- Define Transport Protocol class
- **Commit:** "Add transport protocol definition"
### Task 9.2: Implement TCP transport
- Create src/py_dvt_ate/transport/tcp.py
- Create src/py_dvt_ate/instruments/transport/tcp.py
- Implement TCPTransport class
- connect(), write(), read(), query() methods
- **Commit:** "Implement TCP transport"
@@ -301,19 +299,19 @@ Each sprint is ~1-2 days of work, producing demonstrable progress.
**Goal:** Create instrument drivers using transport.
### Task 10.1: Define driver base class
- Create src/py_dvt_ate/drivers/__init__.py
- Create src/py_dvt_ate/drivers/base.py
- Create src/py_dvt_ate/instruments/drivers/__init__.py
- Create src/py_dvt_ate/instruments/drivers/base.py
- Define BaseDriver with transport dependency
- **Commit:** "Add driver base class"
### Task 10.2: Implement thermal chamber driver
- Create src/py_dvt_ate/drivers/thermal_chamber.py
- Create src/py_dvt_ate/instruments/drivers/chamber.py
- Methods map to SCPI commands
- **Commit:** "Add thermal chamber driver"
### Task 10.3: Implement PSU and DMM drivers
- Create src/py_dvt_ate/drivers/power_supply.py
- Create src/py_dvt_ate/drivers/multimeter.py
- Create src/py_dvt_ate/instruments/drivers/power_supply.py
- Create src/py_dvt_ate/instruments/drivers/multimeter.py
- **Commit:** "Add PSU and DMM drivers"
### Task 10.4: Add driver tests
@@ -323,32 +321,30 @@ Each sprint is ~1-2 days of work, producing demonstrable progress.
---
## Sprint 11: Hardware Abstraction Layer
## Sprint 11: Instrument Interfaces
**Goal:** Create HAL interfaces and implementations.
**Goal:** Create instrument protocol interfaces and factory.
### Task 11.1: Define HAL protocols
- Create src/py_dvt_ate/hal/__init__.py
- Create src/py_dvt_ate/hal/interfaces.py
- Define IThermalChamber, IPowerSupply, IMultimeter
- **Commit:** "Add HAL protocol definitions"
### Task 11.1: Define instrument interface protocols
- Create src/py_dvt_ate/instruments/interfaces.py
- Define IThermalChamber, IPowerSupply, IMultimeter protocols
- **Commit:** "Add instrument interface protocols"
### Task 11.2: Implement HAL wrappers
- Create src/py_dvt_ate/hal/impl/__init__.py
- Create HAL implementation classes
- Wrap drivers with HAL interface
- **Commit:** "Add HAL implementations"
### Task 11.2: Ensure drivers implement interfaces
- Update drivers to satisfy Protocol interfaces
- Add type hints for interface compliance
- **Commit:** "Implement instrument interfaces in drivers"
### Task 11.3: Create instrument factory
- Create src/py_dvt_ate/hal/factory.py
- Create src/py_dvt_ate/instruments/factory.py
- InstrumentSet dataclass
- InstrumentFactory.create() method
- **Commit:** "Add instrument factory"
### Task 11.4: Add HAL tests
- Create tests/unit/test_hal.py
### Task 11.4: Add instrument interface tests
- Create tests/unit/test_instruments.py
- Test factory creates correct types
- **Commit:** "Add HAL unit tests"
- **Commit:** "Add instrument interface tests"
---
@@ -357,13 +353,12 @@ Each sprint is ~1-2 days of work, producing demonstrable progress.
**Goal:** YAML-based configuration.
### Task 12.1: Define config models
- Create src/py_dvt_ate/config/__init__.py
- Create src/py_dvt_ate/config/models.py
- Pydantic models for all config sections
- Create src/py_dvt_ate/app/config.py
- Define Pydantic models for all config sections
- **Commit:** "Add configuration Pydantic models"
### Task 12.2: Implement config loader
- Create src/py_dvt_ate/config/loader.py
- Add load_config() function to src/py_dvt_ate/app/config.py
- Load YAML, validate with Pydantic
- Environment variable overrides
- **Commit:** "Implement configuration loader"
@@ -410,25 +405,25 @@ Each sprint is ~1-2 days of work, producing demonstrable progress.
**Goal:** Test execution orchestration.
### Task 14.1: Define test interface and models
- Create src/py_dvt_ate/executive/__init__.py
- Create src/py_dvt_ate/executive/models.py
- Create src/py_dvt_ate/framework/__init__.py
- Create src/py_dvt_ate/framework/context.py
- TestStatus enum, TestContext, ITest protocol
- **Commit:** "Add test executive models"
- **Commit:** "Add test framework models"
### Task 14.2: Implement test logger
- Create src/py_dvt_ate/executive/logger.py
- Create src/py_dvt_ate/framework/logger.py
- Log measurements and events
- **Commit:** "Implement test logger"
### Task 14.3: Implement limit checker
- Create src/py_dvt_ate/executive/limits.py
- Create src/py_dvt_ate/framework/limits.py
- Evaluate pass/fail against limits
- **Commit:** "Implement limit checker"
### Task 14.4: Implement test sequencer
- Create src/py_dvt_ate/executive/sequencer.py
### Task 14.4: Implement test runner
- Create src/py_dvt_ate/framework/runner.py
- Run tests, collect results
- **Commit:** "Implement test sequencer"
- **Commit:** "Implement test runner"
---
@@ -443,7 +438,7 @@ Each sprint is ~1-2 days of work, producing demonstrable progress.
- **Commit:** "Add DVT test base class"
### Task 15.2: Implement TempCo test
- Create src/py_dvt_ate/tests/tempco.py
- Create src/py_dvt_ate/tests/thermal/tempco.py
- Temperature sweep logic
- Vout measurement at each temperature
- TempCo calculation
@@ -517,40 +512,38 @@ Each sprint is ~1-2 days of work, producing demonstrable progress.
## File Dependencies Map
```
physics/models.py → (none)
physics/dut/base.py → models.py
physics/dut/ldo.py → base.py, models.py
physics/thermal.py → models.py
physics/engine.py → models.py, thermal.py, dut/base.py
simulation/physics/models.py → (none)
simulation/physics/models/base.py → models.py
simulation/physics/models/ldo.py → base.py, models.py
simulation/physics/thermal.py → models.py
simulation/physics/engine.py → models.py, thermal.py, models/base.py
dashboard/app.py physics/engine.py (Sprint 4, direct connection)
app/dashboard/app.py → simulation/physics/engine.py (Sprint 4)
instruments/scpi_parser.py → (none)
instruments/base.py → scpi_parser.py
instruments/*_sim.py → base.py, physics/engine.py
instruments/scpi.py → (none)
simulation/virtual/base.py → instruments/scpi.py
simulation/virtual/*.py → base.py, simulation/physics/engine.py
transport/base.py → (none)
transport/tcp.py → base.py
instruments/transport/base.py → (none)
instruments/transport/tcp.py → base.py
drivers/base.py → transport/base.py
drivers/*.py → base.py
instruments/drivers/base.py → instruments/transport/base.py
instruments/drivers/*.py → base.py
hal/interfaces.py → (none)
hal/impl/*.py → interfaces.py, drivers/*.py
hal/factory.py → interfaces.py, impl/*.py
instruments/interfaces.py → (none)
instruments/factory.py → interfaces.py, drivers/*.py
config/models.py → (none)
config/loader.py → models.py
app/config.py → (none)
data/models.py → (none)
data/repository.py → models.py
data/models.py → (none)
data/repository.py → models.py
executive/models.py → hal/interfaces.py
executive/*.py → models.py, data/repository.py
framework/context.py → instruments/interfaces.py
framework/*.py → context.py, data/repository.py
tests/*.py → executive/models.py, hal/interfaces.py
tests/*.py → framework/context.py, instruments/interfaces.py
dashboard/app.py → hal/factory.py (Sprint 17, upgraded)
app/dashboard/app.py → instruments/factory.py (Sprint 17, upgraded)
```
---
@@ -578,7 +571,7 @@ MAJOR.MINOR.PATCH[-PRERELEASE]
| 3 | `v0.1.0-alpha.1` | Physics engine working | Pre-release |
| 4 | `v0.1.0-alpha.2` | Visual demo (dashboard) | Pre-release |
| 8 | `v0.1.0-alpha.3` | Network ready (TCP server) | Pre-release |
| 11 | `v0.1.0-beta.1` | HAL complete | Pre-release |
| 11 | `v0.1.0-beta.1` | Interfaces complete | Pre-release |
| 15 | `v0.1.0-beta.2` | First DVT test runs | Pre-release |
| 17 | `v0.1.0` | **MVP Complete** | Release |
@@ -644,7 +637,7 @@ Maintain `CHANGELOG.md` following [Keep a Changelog](https://keepachangelog.com/
| 4 | `v0.1.0-alpha.2` | **Visual Demo!** | Interactive Streamlit showing physics |
| 7 | - | Instruments Done | SCPI simulators respond to commands |
| 8 | `v0.1.0-alpha.3` | Network Ready | TCP server accepts connections |
| 11 | `v0.1.0-beta.1` | HAL Complete | Abstraction layer swappable |
| 11 | `v0.1.0-beta.1` | Interfaces Complete | Instrument layer swappable |
| 15 | `v0.1.0-beta.2` | First Test | TempCo characterisation runs |
| 17 | `v0.1.0` | **MVP Complete** | Full end-to-end workflow |