feat(domain): implement RelayController trait and error handling
Add RelayController async trait (T030) defining interface for Modbus relay operations with methods for read/write state, bulk operations, connection checks, and firmware queries. Implement ControllerError enum (T031) with variants for connection failures, timeouts, Modbus exceptions, and invalid relay IDs. Provide MockRelayController (T029) in-memory implementation using Arc<Mutex<HashMap>> for thread-safe state storage with timeout simulation for error handling tests. Add RelayLabelRepository trait abstraction. Ref: T029 T030 T031 (specs/001-modbus-relay-control/tasks.md)
This commit is contained in:
@@ -293,13 +293,13 @@
|
||||
- **File**: src/infrastructure/modbus/mock_controller.rs
|
||||
- **Complexity**: Low | **Uncertainty**: Low
|
||||
|
||||
- [ ] **T029** [P] [US1] [TDD] Implement MockRelayController
|
||||
- [x] **T029** [P] [US1] [TDD] Implement MockRelayController
|
||||
- Struct with Arc<Mutex<HashMap<RelayId, RelayState>>>
|
||||
- Implement RelayController trait with in-memory state
|
||||
- **File**: src/infrastructure/modbus/mock_controller.rs
|
||||
- **Complexity**: Low | **Uncertainty**: Low
|
||||
|
||||
- [ ] **T030** [US1] [TDD] Define RelayController trait
|
||||
- [x] **T030** [US1] [TDD] Define RelayController trait
|
||||
- async fn read_state(&self, id: RelayId) → Result<RelayState, ControllerError>
|
||||
- async fn write_state(&self, id: RelayId, state: RelayState) → Result<(), ControllerError>
|
||||
- async fn read_all(&self) → Result<Vec<(RelayId, RelayState)>, ControllerError>
|
||||
@@ -307,7 +307,7 @@
|
||||
- **File**: src/infrastructure/modbus/controller.rs
|
||||
- **Complexity**: Low | **Uncertainty**: Low
|
||||
|
||||
- [ ] **T031** [P] [US1] [TDD] Define ControllerError enum
|
||||
- [x] **T031** [P] [US1] [TDD] Define ControllerError enum
|
||||
- Variants: ConnectionError(String), Timeout(u64), ModbusException(String), InvalidRelayId(u8)
|
||||
- Implement std::error::Error, Display, Debug
|
||||
- Use thiserror derive macros
|
||||
|
||||
Reference in New Issue
Block a user