feat: finish lut resolver
This commit is contained in:
160
legacy/common.py
160
legacy/common.py
@@ -76,7 +76,8 @@ class SubCircuit:
|
||||
case JointKind.PARALLEL:
|
||||
return (self.__device_value * value) / (self.__device_value + value)
|
||||
|
||||
def get_device_value(self) -> float:
|
||||
@property
|
||||
def device_value(self) -> float:
|
||||
"""
|
||||
Get the device value
|
||||
|
||||
@@ -84,7 +85,8 @@ class SubCircuit:
|
||||
"""
|
||||
return self.__device_value
|
||||
|
||||
def get_joint_kind(self) -> JointKind:
|
||||
@property
|
||||
def joint_kind(self) -> JointKind:
|
||||
"""
|
||||
Get the joint kind
|
||||
|
||||
@@ -93,8 +95,8 @@ class SubCircuit:
|
||||
return self.__joint_kind
|
||||
|
||||
|
||||
class CircuitDeviceCount(enum.IntEnum):
|
||||
"""The number of devices in the circuit"""
|
||||
class CircuitDeviceScale(enum.IntEnum):
|
||||
"""The scale of devices in the circuit"""
|
||||
|
||||
ONE = enum.auto()
|
||||
"""One device"""
|
||||
@@ -104,12 +106,17 @@ class CircuitDeviceCount(enum.IntEnum):
|
||||
"""Three devices"""
|
||||
|
||||
def to_device_count(self) -> int:
|
||||
"""
|
||||
Convert circuit device scale to device count
|
||||
|
||||
:return: The device count
|
||||
"""
|
||||
match self:
|
||||
case CircuitDeviceCount.ONE:
|
||||
case CircuitDeviceScale.ONE:
|
||||
return 1
|
||||
case CircuitDeviceCount.TWO:
|
||||
case CircuitDeviceScale.TWO:
|
||||
return 2
|
||||
case CircuitDeviceCount.THREE:
|
||||
case CircuitDeviceScale.THREE:
|
||||
return 3
|
||||
|
||||
|
||||
@@ -167,70 +174,6 @@ class Circuit:
|
||||
SubCircuit(device3_value, device3_joint),
|
||||
)
|
||||
|
||||
def get_device_count(self) -> CircuitDeviceCount:
|
||||
if self.__third_device_subckt is not None:
|
||||
return CircuitDeviceCount.THREE
|
||||
elif self.__second_device_subckt is not None:
|
||||
return CircuitDeviceCount.TWO
|
||||
else:
|
||||
return CircuitDeviceCount.ONE
|
||||
|
||||
def get_first_device_value(self) -> float:
|
||||
"""
|
||||
Get the value of the first device
|
||||
|
||||
:return: The value of the first device
|
||||
"""
|
||||
return self.__first_device_value
|
||||
|
||||
def get_second_device_joint(self) -> JointKind:
|
||||
"""
|
||||
Get the joint kind of the second device
|
||||
|
||||
:return: The joint kind of the second device
|
||||
:raises LcrConnException: If there is no second device
|
||||
"""
|
||||
if self.__second_device_subckt is not None:
|
||||
return self.__second_device_subckt.get_joint_kind()
|
||||
else:
|
||||
raise LcrConnException("No second device")
|
||||
|
||||
def get_second_device_value(self) -> float:
|
||||
"""
|
||||
Get the value of the second device
|
||||
|
||||
:return: The value of the second device
|
||||
:raises LcrConnException: If there is no second device
|
||||
"""
|
||||
if self.__second_device_subckt is not None:
|
||||
return self.__second_device_subckt.get_device_value()
|
||||
else:
|
||||
raise LcrConnException("No second device")
|
||||
|
||||
def get_third_device_joint(self) -> JointKind:
|
||||
"""
|
||||
Get the joint kind of the third device
|
||||
|
||||
:return: The joint kind of the third device
|
||||
:raises LcrConnException: If there is no third device
|
||||
"""
|
||||
if self.__third_device_subckt is not None:
|
||||
return self.__third_device_subckt.get_joint_kind()
|
||||
else:
|
||||
raise LcrConnException("No third device")
|
||||
|
||||
def get_third_device_value(self) -> float:
|
||||
"""
|
||||
Get the value of the third device
|
||||
|
||||
:return: The value of the third device
|
||||
:raises LcrConnException: If there is no third device
|
||||
"""
|
||||
if self.__third_device_subckt is not None:
|
||||
return self.__third_device_subckt.get_device_value()
|
||||
else:
|
||||
raise LcrConnException("No third device")
|
||||
|
||||
def compute(self, device_kind: DeviceKind) -> float:
|
||||
"""
|
||||
Compute the circuit value
|
||||
@@ -249,3 +192,78 @@ class Circuit:
|
||||
return value
|
||||
value = self.__third_device_subckt.compute(value, device_kind)
|
||||
return value
|
||||
|
||||
@property
|
||||
def device_scale(self) -> CircuitDeviceScale:
|
||||
"""
|
||||
Get the device scale
|
||||
|
||||
:return: The device scale
|
||||
"""
|
||||
if self.__third_device_subckt is not None:
|
||||
return CircuitDeviceScale.THREE
|
||||
elif self.__second_device_subckt is not None:
|
||||
return CircuitDeviceScale.TWO
|
||||
else:
|
||||
return CircuitDeviceScale.ONE
|
||||
|
||||
@property
|
||||
def first_device_value(self) -> float:
|
||||
"""
|
||||
Get the value of the first device
|
||||
|
||||
:return: The value of the first device
|
||||
"""
|
||||
return self.__first_device_value
|
||||
|
||||
@property
|
||||
def second_device_joint(self) -> JointKind:
|
||||
"""
|
||||
Get the joint kind of the second device
|
||||
|
||||
:return: The joint kind of the second device
|
||||
:raises LcrConnException: If there is no second device
|
||||
"""
|
||||
if self.__second_device_subckt is not None:
|
||||
return self.__second_device_subckt.joint_kind
|
||||
else:
|
||||
raise LcrConnException("No second device")
|
||||
|
||||
@property
|
||||
def second_device_value(self) -> float:
|
||||
"""
|
||||
Get the value of the second device
|
||||
|
||||
:return: The value of the second device
|
||||
:raises LcrConnException: If there is no second device
|
||||
"""
|
||||
if self.__second_device_subckt is not None:
|
||||
return self.__second_device_subckt.device_value
|
||||
else:
|
||||
raise LcrConnException("No second device")
|
||||
|
||||
@property
|
||||
def third_device_joint(self) -> JointKind:
|
||||
"""
|
||||
Get the joint kind of the third device
|
||||
|
||||
:return: The joint kind of the third device
|
||||
:raises LcrConnException: If there is no third device
|
||||
"""
|
||||
if self.__third_device_subckt is not None:
|
||||
return self.__third_device_subckt.joint_kind
|
||||
else:
|
||||
raise LcrConnException("No third device")
|
||||
|
||||
@property
|
||||
def third_device_value(self) -> float:
|
||||
"""
|
||||
Get the value of the third device
|
||||
|
||||
:return: The value of the third device
|
||||
:raises LcrConnException: If there is no third device
|
||||
"""
|
||||
if self.__third_device_subckt is not None:
|
||||
return self.__third_device_subckt.device_value
|
||||
else:
|
||||
raise LcrConnException("No third device")
|
||||
|
||||
Reference in New Issue
Block a user