Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,16 @@ def reclose_delays(self) -> Generator[float, None, None]:
"""
return ngen(self._reclose_delays)

def set_delays(self, delays: List[float]) -> RelayInfo:
"""
Set the reclose delays for this :class:`RelayInfo`.

:param delays: The delays to set. The provided list will be copied.
:return: A reference to this :class:`RelayInfo` to allow fluent use.
"""
self._reclose_delays = delays.copy()
return self

def num_delays(self) -> int:
"""
Get the number of reclose delays for this :class:`RelayInfo`
Expand Down Expand Up @@ -86,16 +96,6 @@ def add_delay(self, delay: float, index: int = None) -> RelayInfo:
self._reclose_delays.insert(index, delay)
return self

def set_delays(self, delays: List[float]) -> RelayInfo:
"""
Set the reclose delays for this :class:`RelayInfo`.

:param delays: The delays to set. The provided list will be copied.
:return: A reference to this :class:`RelayInfo` to allow fluent use.
"""
self._reclose_delays = delays.copy()
return self

def remove_delay(self, delay: float) -> RelayInfo:
"""
Remove a delay from the list.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,31 @@ def phone_numbers(self) -> Generator[TelephoneNumber, None, None]:
"""[ZBEX] Phone numbers."""
return ngen(self._phone_numbers)

@zbex
@property
def electronic_addresses(self) -> Generator[ElectronicAddress, None, None]:
"""[ZBEX] Electronic addresses."""
return ngen(self._electronic_addresses)

def __eq__(self, other: Any) -> bool:
#
# NOTE: We implement the equals to allow us to compare the entire ``ContactDetails`` as a value. We do this since it isnt an
# ``IdentifiedObject``, so our other helpers don't support it.
if not isinstance(other, ContactDetails):
return False
return all((
self.is_primary == other.is_primary,
self.mrid == other.mrid,
self.contact_address == other.contact_address,
self.contact_type == other.contact_type,
self.first_name == other.first_name,
self.last_name == other.last_name,
self.preferred_contact_method == other.preferred_contact_method,
self.business_name == other.business_name,
self._phone_numbers == other._phone_numbers,
self._electronic_addresses == other._electronic_addresses,
))

def num_phone_numbers(self) -> int:
"""Get the number of entries in the ``TelephoneNumber`` collection."""
return nlen(self._phone_numbers)
Expand Down Expand Up @@ -131,12 +156,6 @@ def clear_phone_numbers(self) -> "ContactDetails":
self._phone_numbers = None
return self

@zbex
@property
def electronic_addresses(self) -> Generator[ElectronicAddress, None, None]:
"""[ZBEX] Electronic addresses."""
return ngen(self._electronic_addresses)

def num_electronic_addresses(self) -> int:
"""Get the number of entries in the [ElectronicAddress] collection."""
return nlen(self._electronic_addresses)
Expand Down Expand Up @@ -175,22 +194,3 @@ def clear_electronic_addresses(self) -> "ContactDetails":
"""
self._electronic_addresses = None
return self

def __eq__(self, other: Any) -> bool:
#
# NOTE: We implement the equals to allow us to compare the entire ``ContactDetails`` as a value. We do this since it isnt an
# ``IdentifiedObject``, so our other helpers don't support it.
if not isinstance(other, ContactDetails):
return False
return all((
self.is_primary == other.is_primary,
self.mrid == other.mrid,
self.contact_address == other.contact_address,
self.contact_type == other.contact_type,
self.first_name == other.first_name,
self.last_name == other.last_name,
self.preferred_contact_method == other.preferred_contact_method,
self.business_name == other.business_name,
self._phone_numbers == other._phone_numbers,
self._electronic_addresses == other._electronic_addresses,
))
136 changes: 68 additions & 68 deletions src/zepben/ewb/model/cim/extensions/iec61970/base/feeder/lv_feeder.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,74 @@ def normal_energizing_feeders(self) -> Generator[Feeder, None, None]:
"""
return ngen(self._normal_energizing_feeders)

@property
def current_energizing_feeders(self) -> Generator[Feeder, None, None]:
"""
[ZBEX] The HV/MV feeders that currently energize this LV feeder.
"""
return ngen(self._current_energizing_feeders)

@property
def current_equipment(self) -> Generator[Equipment, None, None]:
"""
Contained `Equipment` using the current state of the network.
"""
return ngen(self._current_equipment)

def num_current_equipment(self):
"""
Returns The number of `Equipment` associated with this `LvFeeder` in the current state of the network.
"""
return nlen(self._current_equipment)

def get_current_equipment(self, mrid: str) -> Equipment:
"""
Get the `Equipment` contained in this `LvFeeder` in the current state of the network, identified by `mrid`

`mrid` The mRID of the required `Equipment`
Returns The `Equipment` with the specified `mrid` if it exists
Raises `KeyError` if `mrid` wasn't present.
"""
if not self._current_equipment:
raise KeyError(mrid)
try:
return self._current_equipment[mrid]
except AttributeError:
raise KeyError(mrid)

def add_current_equipment(self, equipment: Equipment) -> LvFeeder:
"""
Associate `equipment` with this `LvFeeder` in the current state of the network.

`equipment` the `Equipment` to associate with this `LvFeeder` in the current state of the network.
Returns A reference to this `LvFeeder` to allow fluent use.
Raises `ValueError` if another `Equipment` with the same `mrid` already exists for this `LvFeeder`.
"""
if self._validate_reference(equipment, self.get_current_equipment, "An Equipment"):
return self
self._current_equipment = dict() if self._current_equipment is None else self._current_equipment
self._current_equipment[equipment.mrid] = equipment
return self

def remove_current_equipment(self, equipment: Equipment) -> LvFeeder:
"""
Disassociate `equipment` from this `LvFeeder` in the current state of the network.

`equipment` The `Equipment` to disassociate from this `LvFeeder` in the current state of the network.
Returns A reference to this `LvFeeder` to allow fluent use.
Raises `KeyError` if `equipment` was not associated with this `LvFeeder`.
"""
self._current_equipment = safe_remove_by_id(self._current_equipment, equipment)
return self

def clear_current_equipment(self) -> LvFeeder:
"""
Clear all `Equipment` from this `LvFeeder` in the current state of the network.
Returns A reference to this `LvFeeder` to allow fluent use.
"""
self._current_equipment = None
return self

def num_normal_energizing_feeders(self) -> int:
"""
Get the number of HV/MV feeders that normally energize this LV feeder.
Expand Down Expand Up @@ -149,13 +217,6 @@ def clear_normal_energizing_feeders(self) -> LvFeeder:
self._normal_energizing_feeders = None
return self

@property
def current_energizing_feeders(self) -> Generator[Feeder, None, None]:
"""
[ZBEX] The HV/MV feeders that currently energize this LV feeder.
"""
return ngen(self._current_energizing_feeders)

def num_current_energizing_feeders(self) -> int:
"""
Get the number of HV/MV feeders that currently energize this LV feeder.
Expand Down Expand Up @@ -209,64 +270,3 @@ def clear_current_energizing_feeders(self) -> LvFeeder:
"""
self._current_energizing_feeders = None
return self

@property
def current_equipment(self) -> Generator[Equipment, None, None]:
"""
Contained `Equipment` using the current state of the network.
"""
return ngen(self._current_equipment)

def num_current_equipment(self):
"""
Returns The number of `Equipment` associated with this `LvFeeder` in the current state of the network.
"""
return nlen(self._current_equipment)

def get_current_equipment(self, mrid: str) -> Equipment:
"""
Get the `Equipment` contained in this `LvFeeder` in the current state of the network, identified by `mrid`

`mrid` The mRID of the required `Equipment`
Returns The `Equipment` with the specified `mrid` if it exists
Raises `KeyError` if `mrid` wasn't present.
"""
if not self._current_equipment:
raise KeyError(mrid)
try:
return self._current_equipment[mrid]
except AttributeError:
raise KeyError(mrid)

def add_current_equipment(self, equipment: Equipment) -> LvFeeder:
"""
Associate `equipment` with this `LvFeeder` in the current state of the network.

`equipment` the `Equipment` to associate with this `LvFeeder` in the current state of the network.
Returns A reference to this `LvFeeder` to allow fluent use.
Raises `ValueError` if another `Equipment` with the same `mrid` already exists for this `LvFeeder`.
"""
if self._validate_reference(equipment, self.get_current_equipment, "An Equipment"):
return self
self._current_equipment = dict() if self._current_equipment is None else self._current_equipment
self._current_equipment[equipment.mrid] = equipment
return self

def remove_current_equipment(self, equipment: Equipment) -> LvFeeder:
"""
Disassociate `equipment` from this `LvFeeder` in the current state of the network.

`equipment` The `Equipment` to disassociate from this `LvFeeder` in the current state of the network.
Returns A reference to this `LvFeeder` to allow fluent use.
Raises `KeyError` if `equipment` was not associated with this `LvFeeder`.
"""
self._current_equipment = safe_remove_by_id(self._current_equipment, equipment)
return self

def clear_current_equipment(self) -> LvFeeder:
"""
Clear all `Equipment` from this `LvFeeder` in the current state of the network.
Returns A reference to this `LvFeeder` to allow fluent use.
"""
self._current_equipment = None
return self
Loading
Loading