72 lines
1.8 KiB
Python
72 lines
1.8 KiB
Python
from __future__ import annotations
|
|
|
|
from dataclasses import dataclass, asdict
|
|
from typing import Any, Dict, Optional
|
|
|
|
|
|
@dataclass
|
|
class LocalProblem:
|
|
site_id: str
|
|
description: str
|
|
variables: Dict[str, Any]
|
|
|
|
def to_dict(self) -> Dict[str, Any]:
|
|
return asdict(self)
|
|
|
|
@staticmethod
|
|
def from_dict(d: Dict[str, Any]) -> "LocalProblem":
|
|
return LocalProblem(site_id=d["site_id"], description=d["description"], variables=d.get("variables", {}))
|
|
|
|
|
|
@dataclass
|
|
class SharedVariables:
|
|
signals: Dict[str, Any]
|
|
version: int = 0
|
|
|
|
def to_dict(self) -> Dict[str, Any]:
|
|
return asdict(self)
|
|
|
|
@staticmethod
|
|
def from_dict(d: Dict[str, Any]) -> "SharedVariables":
|
|
return SharedVariables(signals=d.get("signals", {}), version=d.get("version", 0))
|
|
|
|
|
|
@dataclass
|
|
class PlanDelta:
|
|
delta_id: str
|
|
changes: Dict[str, Any]
|
|
timestamp: float
|
|
|
|
def to_dict(self) -> Dict[str, Any]:
|
|
return asdict(self)
|
|
|
|
@staticmethod
|
|
def from_dict(d: Dict[str, Any]) -> "PlanDelta":
|
|
return PlanDelta(delta_id=d["delta_id"], changes=d.get("changes", {}), timestamp=d.get("timestamp", 0.0))
|
|
|
|
|
|
@dataclass
|
|
class ConstraintSet:
|
|
constraints: Dict[str, Any]
|
|
|
|
def to_dict(self) -> Dict[str, Any]:
|
|
return asdict(self)
|
|
|
|
@staticmethod
|
|
def from_dict(d: Dict[str, Any]) -> "ConstraintSet":
|
|
return ConstraintSet(constraints=d.get("constraints", {}))
|
|
|
|
|
|
@dataclass
|
|
class DeviceInfo:
|
|
device_id: str
|
|
device_type: str
|
|
capabilities: Dict[str, Any]
|
|
|
|
def to_dict(self) -> Dict[str, Any]:
|
|
return asdict(self)
|
|
|
|
@staticmethod
|
|
def from_dict(d: Dict[str, Any]) -> "DeviceInfo":
|
|
return DeviceInfo(device_id=d["device_id"], device_type=d["device_type"], capabilities=d.get("capabilities", {}))
|