Dispatch Engine
TheDispatchEngine is the core bridge between Layer 3’s optimization output and Layer 4’s command execution. It reads schedule DataFrames and produces a queue of timed Command objects, then manages their lifecycle through dispatch, response handling, retries, and timeout detection.
Schedule-to-Command Conversion
The dispatch engine parses Layer 3 schedule DataFrame columns using naming conventions:| Column Pattern | Command Type | Asset Type |
|---|---|---|
ev_{vehicle_id}_kw | SET_CHARGE_RATE | EV Charger |
battery_charge_kw | SET_CHARGE_RATE | Battery |
battery_discharge_kw | SET_DISCHARGE_RATE | Battery |
Change Detection
The engine only emits commands when power values change between consecutive time slots. This avoids flooding assets with redundant setpoints:Command Lifecycle
Dispatching Commands
Handling Responses
Timeout Detection
Command Object
Command Types
| Type | Description | Typical Target |
|---|---|---|
SET_CHARGE_RATE | Set charging power | EV charger, battery |
SET_DISCHARGE_RATE | Set discharging power | Battery |
SET_POWER_LIMIT | Set power limit | Any |
START_CHARGING | Begin charging session | EV charger |
STOP_CHARGING | End charging session | EV charger |
CHANGE_AVAILABILITY | Enable/disable asset | EV charger |
SET_SOC_TARGET | Set target SOC | Battery |
Event Publishing
The dispatch engine publishes events at each lifecycle transition:| Action | Event Type |
|---|---|
| Commands generated | SCHEDULE_RECEIVED |
| Command sent | COMMAND_DISPATCHED |
| Command succeeded | COMMAND_COMPLETED |
| Command failed | COMMAND_FAILED |
| Command timed out | COMMAND_TIMED_OUT |