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
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* `MeasurementValue.time_stamp`
* `RelayInfo.curve_setting`
* `RelayInfo.reclose_fast`
* Removed `TracedPhases`. `Terminal.normalPhases` and `Terminal.currentPhases` should be used instead of `Terminal.tracedPhases` going forward. (missed in 0.48.0)

### New Features
* Added the following new CIM classes:
Expand Down
1 change: 0 additions & 1 deletion src/zepben/ewb/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,6 @@
# END CIM MODEL #
#################

from zepben.ewb.model.phases import *
from zepben.ewb.model.resistance_reactance import *

from zepben.ewb.services.network.tracing.util import *
Expand Down
36 changes: 20 additions & 16 deletions src/zepben/ewb/model/cim/iec61970/base/core/terminal.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
# Copyright 2024 Zeppelin Bend Pty Ltd
# Copyright 2026 Zeppelin Bend Pty Ltd
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at https://mozilla.org/MPL/2.0/.

from __future__ import annotations

__all__ = ["Terminal"]

from typing import Optional, Generator
from typing import TYPE_CHECKING
from weakref import ref, ReferenceType
Expand All @@ -13,16 +15,13 @@
from zepben.ewb.model.cim.iec61970.base.core.feeder import Feeder
from zepben.ewb.model.cim.iec61970.base.core.phase_code import PhaseCode
from zepben.ewb.model.cim.iec61970.base.wires.busbar_section import BusbarSection
from zepben.ewb.model.phases import TracedPhases
from zepben.ewb.services.network.tracing.feeder.feeder_direction import FeederDirection
from zepben.ewb.services.network.tracing.phases.phase_status import PhaseStatus, NormalPhases, CurrentPhases
from zepben.ewb.services.network.tracing.phases.phase_status import PhaseStatus

if TYPE_CHECKING:
from zepben.ewb.model.cim.iec61970.base.core.conducting_equipment import ConductingEquipment
from zepben.ewb.model.cim.iec61970.base.core.connectivity_node import ConnectivityNode

__all__ = ["Terminal"]


class Terminal(AcDcTerminal):
"""
Expand All @@ -36,10 +35,6 @@ class Terminal(AcDcTerminal):
phases: PhaseCode = PhaseCode.ABC
"""Represents the normal network phasing condition. If the attribute is missing three phases (ABC) shall be assumed."""

traced_phases: TracedPhases = TracedPhases()
"""the phase object representing the traced phases in both the normal and current network. If properly configured you would expect the normal state phases
to match those in `phases`"""

sequence_number: int = 0
"""The orientation of the terminal connections for a multiple terminal conducting equipment. The sequence numbering starts with 1 and additional
terminals should follow in increasing order. The first terminal is the "starting point" for a two terminal branch."""
Expand All @@ -56,8 +51,16 @@ class Terminal(AcDcTerminal):
"""This is a weak reference to the connectivity node so if a Network object goes out of scope, holding a single conducting equipment
reference does not cause everything connected to it in the network to stay in memory."""

_normal_phases: PhaseStatus = None
_current_phases: PhaseStatus = None

def __init__(self, conducting_equipment: ConductingEquipment = None, connectivity_node: ConnectivityNode = None, **kwargs):
super(Terminal, self).__init__(**kwargs)

self._normal_phases = PhaseStatus(self)

self._current_phases = PhaseStatus(self)

if conducting_equipment:
self.conducting_equipment = conducting_equipment

Expand All @@ -69,13 +72,13 @@ def __init__(self, conducting_equipment: ConductingEquipment = None, connectivit

@property
def normal_phases(self) -> PhaseStatus:
""" Convenience method for accessing the normal phases"""
return NormalPhases(self)
"""The status of phases as traced for the normal state of the network."""
return self._normal_phases

@property
def current_phases(self) -> PhaseStatus:
""" Convenience method for accessing the current phases"""
return CurrentPhases(self)
"""The status of phases as traced for the current state of the network.gi"""
return self._current_phases

@property
def conducting_equipment(self):
Expand Down Expand Up @@ -146,9 +149,10 @@ def other_terminals(self) -> Generator[Terminal]:
*
:return: A `Generator` of terminals that share the same `ConductingEquipment` as this `Terminal`.
"""
for t in self.conducting_equipment.terminals:
if t is not self:
yield t
if self.conducting_equipment is not None:
for t in self.conducting_equipment.terminals:
if t is not self:
yield t

def connect(self, connectivity_node: ConnectivityNode):
self.connectivity_node = connectivity_node
Expand Down
168 changes: 0 additions & 168 deletions src/zepben/ewb/model/phases.py

This file was deleted.

4 changes: 2 additions & 2 deletions src/zepben/ewb/services/common/base_service_comparator.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ def _add_if_different(diff: ObjectDifference, name: str, difference: Optional[Di
diff.differences[name] = difference

@staticmethod
def _calculate_values_diff(prop: Union[MemberDescriptorType, property], diff: ObjectDifference) -> Optional[ValueDifference]:
def _calculate_values_diff(prop: Union[MemberDescriptorType, property], diff: ObjectDifference, to_comparable: Callable[[property], Any] = (lambda it: it)) -> Optional[ValueDifference]:
if isinstance(prop, property):
s_val = getattr(diff.source, prop.fget.__name__) if diff.source else None
t_val = getattr(diff.target, prop.fget.__name__) if diff.target else None
Expand All @@ -230,7 +230,7 @@ def _calculate_values_diff(prop: Union[MemberDescriptorType, property], diff: Ob
if (type(s_val) == float) or (type(t_val) == float):
raise TypeError(f"Using wrong comparator for {prop}, use _calculate_float_diff instead.")

if s_val == t_val:
if to_comparable(s_val) == to_comparable(t_val):
return None
else:
return ValueDifference(s_val, t_val)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -764,8 +764,9 @@ def _compare_terminal(self, source: Terminal, target: Terminal) -> ObjectDiffere
Terminal.sequence_number,
Terminal.normal_feeder_direction,
Terminal.current_feeder_direction,
Terminal.phases
)
self._add_if_different(diff, Terminal.normal_phases.fget.__name__, self._calculate_values_diff(Terminal.normal_phases, diff, to_comparable=lambda it: it._phase_status_internal))
self._add_if_different(diff, Terminal.current_phases.fget.__name__, self._calculate_values_diff(Terminal.current_phases, diff, to_comparable=lambda it: it._phase_status_internal))

return self._compare_ac_dc_terminal(diff)

Expand Down
Loading