Skip to content

Implement OpenEMS Layer 2 Dispatch Controller #8

@3shn

Description

@3shn

Implementation Plan - Layer 2 Dispatch Controller

Goal: Implement io.openems.edge.controller.microgrid.dispatcher to manage power flows in the microgrid based on the state provided by the Supervisor.

[Goal Description]

Develop a rule-based dispatch controller that optimizes energy usage and ensures stability in both Grid-Connected (SS1) and Islanded (SS2) modes. It will actively control:

  • BESS (Battery Energy Storage System)
  • Genset (Diesel Generator)
  • PV Inverter (Curtailment)

User Review Required

  • Genset Interface: Identifying the correct channel for "Genset Status" and "Start/Stop" control. We verify if io.openems.edge.controller.chp.soc or a simple DigitalOutput + Meter is used.
  • Microgrid State: Reading the State channel from io.openems.edge.controller.microgrid.

Proposed Changes

[NEW] Bundle: io.openems.edge.controller.microgrid.dispatcher

Config.java

  • ess_id (String)
  • meter_id (String) - Grid Meter
  • genset_id (String) - Genset Component ID
  • pv_id (String) - PV Inverter Component ID
  • grid_limit (int) - Peak Shaving Limit [W]
  • genset_start_soc (int) - Default 20%
  • genset_stop_soc (int) - Default 80%
  • genset_capacity (int) - Genset Capacity [W]

MicrogridDispatcherImpl.java

  • Components:

    • @Reference ComponentManager
    • @Reference SymmetricEss
    • @Reference ElectricityMeter (Grid)
    • @Reference ManagedSymmetricPvInverter
    • @Reference MicrogridSupervisor (or access via ComponentManager)
  • Loop (run()):

    1. Read Inputs:
      • MicrogridState from Supervisor.
      • Ess.SoC
      • GridMeter.ActivePower
      • Genset.Status (if available) or Genset.ActivePower
    2. Switch/Case on State:
      • SS1 (Grid Connected):
        • Peak Shaving: Calculate Grid - GridLimit. If positive, Ess.SetActivePowerEquals(Discharge).
        • Genset: Send Stop command (via Channel Start=false or similar).
      • SS2 (Islanded):
        • Genset Control:
          • SoC < StartSoC -> Start Genset.
          • SoC > StopSoC -> Stop Genset.
        • Genset Loading:
          • If Genset ON: TargetLoad = GensetCapacity * 0.40.
          • If SiteLoad < TargetLoad, Ess.SetActivePowerEquals(Charge = TargetLoad - SiteLoad).
        • PV Curtailment:
          • If SoC > 95% AND Ess.MaxChargePower ~ 0:
            • limit = Load.
            • Pv.setActivePowerLimit(limit).

Verification Plan

Automated Tests

  • Unit Test: MicrogridDispatcherTest
    • Mock Components (Ess, Meter, Genset, PV).
    • Simulate States (SS1, SS2).
    • Verify Output Channels (SetActivePowerEquals, SetGridMode, etc. wait, Dispatcher doesn't set GridMode).
    • Verify Logic:
      • Test Peak Shaving triggers.
      • Test Genset Start/Stop hysteresis.
      • Test PV Curtailment.

Delegation to Jules

  • Create GitHub Issue with this plan.
  • Label: jules

Metadata

Metadata

Assignees

No one assigned

    Labels

    julesTasks for Jules agent

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions