50 lines
1.4 KiB
Python
50 lines
1.4 KiB
Python
from typing import Dict, Any
|
|
from .models import LocalProblem
|
|
|
|
|
|
class BaseAdapter:
|
|
def to_shared(self, lp: LocalProblem) -> Dict[str, Any]:
|
|
raise NotImplementedError
|
|
|
|
|
|
class DERAdapter(BaseAdapter):
|
|
def to_shared(self, lp: LocalProblem) -> Dict[str, Any]:
|
|
return {
|
|
"type": "DER",
|
|
"neighborhood_id": lp.neighborhood_id,
|
|
"pv_kw": lp.pv_kw,
|
|
"demand_kw": lp.demand_kw,
|
|
}
|
|
|
|
|
|
class BatteryAdapter(BaseAdapter):
|
|
def to_shared(self, lp: LocalProblem) -> Dict[str, Any]:
|
|
return {
|
|
"type": "Battery",
|
|
"neighborhood_id": lp.neighborhood_id,
|
|
"storage_kwh": lp.storage_kwh,
|
|
"evs": lp.evs,
|
|
}
|
|
|
|
|
|
class InverterControllerAdapter(BaseAdapter):
|
|
def to_shared(self, lp: LocalProblem) -> Dict[str, Any]:
|
|
# Starter adapter mapping LocalProblem to an inverter-controller style payload
|
|
return {
|
|
"type": "InverterController",
|
|
"neighborhood_id": lp.neighborhood_id,
|
|
"pv_kw": lp.pv_kw,
|
|
"demand_kw": lp.demand_kw,
|
|
}
|
|
|
|
|
|
class NeighborhoodBatteryAdapter(BaseAdapter):
|
|
def to_shared(self, lp: LocalProblem) -> Dict[str, Any]:
|
|
# Starter adapter for a neighborhood-level battery manager
|
|
return {
|
|
"type": "NeighborhoodBattery",
|
|
"neighborhood_id": lp.neighborhood_id,
|
|
"storage_kwh": lp.storage_kwh,
|
|
"evs": lp.evs,
|
|
}
|