Skip to content

Commit 574a06f

Browse files
committed
wip
1 parent dab207f commit 574a06f

2 files changed

Lines changed: 45 additions & 0 deletions

File tree

edg/electronics_interfaces/GroundDummy.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import warnings
2+
from typing import Any
3+
14
from ..electronics_model import *
25
from .DummyDevices import BaseDummyBlock
36
from .GroundPort import Ground, Common, GroundLink
@@ -7,3 +10,16 @@ class DummyGround(BaseDummyBlock[GroundLink]):
710
def __init__(self) -> None:
811
super().__init__()
912
self.io = self.Port(Ground(), [Common, InOut])
13+
14+
def __getattr__(self, item: str) -> Any:
15+
if item == "gnd":
16+
warnings.warn(
17+
f"Use .io instead.",
18+
DeprecationWarning,
19+
stacklevel=2,
20+
)
21+
return self.io
22+
else:
23+
raise AttributeError(
24+
item
25+
) # ideally we'd use super().__getattr__(...), but that's not defined in base classes

edg/electronics_interfaces/VoltageDummy.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import warnings
2+
from typing import Any
3+
14
from ..electronics_model import *
25
from .DummyDevices import BaseDummyBlock
36
from .VoltagePorts import VoltageSource, VoltageSink, Power, VoltageLink
@@ -27,6 +30,19 @@ def __init__(
2730
self.voltage_limits = self.Parameter(RangeExpr(self.io.link().voltage_limits))
2831
self.reverse_voltage = self.Parameter(RangeExpr(self.io.link().reverse_voltage))
2932

33+
def __getattr__(self, item: str) -> Any:
34+
if item == "pwr":
35+
warnings.warn(
36+
f"Use .io instead.",
37+
DeprecationWarning,
38+
stacklevel=2,
39+
)
40+
return self.io
41+
else:
42+
raise AttributeError(
43+
item
44+
) # ideally we'd use super().__getattr__(...), but that's not defined in base classes
45+
3046

3147
class DummyVoltageSink(BaseDummyBlock[VoltageLink]):
3248

@@ -51,3 +67,16 @@ def __init__(
5167

5268
self.voltage = self.Parameter(RangeExpr(self.io.link().voltage))
5369
self.current_limits = self.Parameter(RangeExpr(self.io.link().current_limits))
70+
71+
def __getattr__(self, item: str) -> Any:
72+
if item == "pwr":
73+
warnings.warn(
74+
f"Use .io instead.",
75+
DeprecationWarning,
76+
stacklevel=2,
77+
)
78+
return self.io
79+
else:
80+
raise AttributeError(
81+
item
82+
) # ideally we'd use super().__getattr__(...), but that's not defined in base classes

0 commit comments

Comments
 (0)