diff --git a/src/zepben/ewb/model/cim/extensions/iec61970/base/protection/power_direction_kind.py b/src/zepben/ewb/model/cim/extensions/iec61970/base/protection/power_direction_kind.py index 1befce3b8..3761cf1f3 100644 --- a/src/zepben/ewb/model/cim/extensions/iec61970/base/protection/power_direction_kind.py +++ b/src/zepben/ewb/model/cim/extensions/iec61970/base/protection/power_direction_kind.py @@ -8,9 +8,11 @@ from enum import Enum from zepben.ewb.model.cim.extensions.zbex import zbex +from zepben.ewb.util import unique @zbex +@unique class PowerDirectionKind(Enum): """ [ZBEX] diff --git a/src/zepben/ewb/model/cim/extensions/iec61970/base/wires/battery_control_mode.py b/src/zepben/ewb/model/cim/extensions/iec61970/base/wires/battery_control_mode.py index 9f06ab8e5..55850071b 100644 --- a/src/zepben/ewb/model/cim/extensions/iec61970/base/wires/battery_control_mode.py +++ b/src/zepben/ewb/model/cim/extensions/iec61970/base/wires/battery_control_mode.py @@ -7,10 +7,12 @@ from enum import Enum +from zepben.ewb import unique from zepben.ewb.model.cim.extensions.zbex import zbex @zbex +@unique class BatteryControlMode(Enum): """ [ZBEX] diff --git a/src/zepben/ewb/model/cim/extensions/iec61970/base/wires/transformer_cooling_type.py b/src/zepben/ewb/model/cim/extensions/iec61970/base/wires/transformer_cooling_type.py index 02469abc9..55812bdd8 100644 --- a/src/zepben/ewb/model/cim/extensions/iec61970/base/wires/transformer_cooling_type.py +++ b/src/zepben/ewb/model/cim/extensions/iec61970/base/wires/transformer_cooling_type.py @@ -7,10 +7,12 @@ from enum import Enum +from zepben.ewb import unique from zepben.ewb.model.cim.extensions.zbex import zbex @zbex +@unique class TransformerCoolingType(Enum): """ [ZBEX] diff --git a/src/zepben/ewb/model/cim/extensions/iec61970/base/wires/vector_group.py b/src/zepben/ewb/model/cim/extensions/iec61970/base/wires/vector_group.py index 69d2fde18..70899d3f0 100644 --- a/src/zepben/ewb/model/cim/extensions/iec61970/base/wires/vector_group.py +++ b/src/zepben/ewb/model/cim/extensions/iec61970/base/wires/vector_group.py @@ -7,10 +7,12 @@ from enum import Enum +from zepben.ewb import unique from zepben.ewb.model.cim.extensions.zbex import zbex @zbex +@unique class VectorGroup(Enum): """ [ZBEX] diff --git a/src/zepben/ewb/model/cim/iec61968/assetinfo/wire_material_kind.py b/src/zepben/ewb/model/cim/iec61968/assetinfo/wire_material_kind.py index 74b7fb228..7752e1d95 100644 --- a/src/zepben/ewb/model/cim/iec61968/assetinfo/wire_material_kind.py +++ b/src/zepben/ewb/model/cim/iec61968/assetinfo/wire_material_kind.py @@ -7,7 +7,10 @@ from enum import Enum +from zepben.ewb import unique + +@unique class WireMaterialKind(Enum): """ Kind of wire material. diff --git a/src/zepben/ewb/model/cim/iec61968/customers/customer_kind.py b/src/zepben/ewb/model/cim/iec61968/customers/customer_kind.py index 40a56714d..8eb79fd92 100644 --- a/src/zepben/ewb/model/cim/iec61968/customers/customer_kind.py +++ b/src/zepben/ewb/model/cim/iec61968/customers/customer_kind.py @@ -7,7 +7,10 @@ from enum import Enum +from zepben.ewb import unique + +@unique class CustomerKind(Enum): """ Kind of customer. diff --git a/src/zepben/ewb/model/cim/iec61968/infiec61968/infassetinfo/transformer_construction_kind.py b/src/zepben/ewb/model/cim/iec61968/infiec61968/infassetinfo/transformer_construction_kind.py index 29df75a1b..170080802 100644 --- a/src/zepben/ewb/model/cim/iec61968/infiec61968/infassetinfo/transformer_construction_kind.py +++ b/src/zepben/ewb/model/cim/iec61968/infiec61968/infassetinfo/transformer_construction_kind.py @@ -7,7 +7,10 @@ from enum import Enum +from zepben.ewb import unique + +@unique class TransformerConstructionKind(Enum): """ Kind of transformer construction. diff --git a/src/zepben/ewb/model/cim/iec61968/infiec61968/infassetinfo/transformer_function_kind.py b/src/zepben/ewb/model/cim/iec61968/infiec61968/infassetinfo/transformer_function_kind.py index 7e2006bc5..94253671d 100644 --- a/src/zepben/ewb/model/cim/iec61968/infiec61968/infassetinfo/transformer_function_kind.py +++ b/src/zepben/ewb/model/cim/iec61968/infiec61968/infassetinfo/transformer_function_kind.py @@ -7,7 +7,10 @@ from enum import Enum +from zepben.ewb import unique + +@unique class TransformerFunctionKind(Enum): """ Function of a transformer. diff --git a/src/zepben/ewb/model/cim/iec61968/infiec61968/infassets/streetlight_lamp_kind.py b/src/zepben/ewb/model/cim/iec61968/infiec61968/infassets/streetlight_lamp_kind.py index 5fc554ea1..127a55348 100644 --- a/src/zepben/ewb/model/cim/iec61968/infiec61968/infassets/streetlight_lamp_kind.py +++ b/src/zepben/ewb/model/cim/iec61968/infiec61968/infassets/streetlight_lamp_kind.py @@ -7,7 +7,10 @@ from enum import Enum +from zepben.ewb import unique + +@unique class StreetlightLampKind(Enum): """ Kind of lamp for a `Streetlight` diff --git a/src/zepben/ewb/model/cim/iec61968/metering/controlled_appliance.py b/src/zepben/ewb/model/cim/iec61968/metering/controlled_appliance.py index d91920f0d..18e303421 100644 --- a/src/zepben/ewb/model/cim/iec61968/metering/controlled_appliance.py +++ b/src/zepben/ewb/model/cim/iec61968/metering/controlled_appliance.py @@ -11,7 +11,10 @@ from enum import Enum from typing import List, Union +from zepben.ewb import unique + +@unique class Appliance(Enum): """ The type of appliance. diff --git a/src/zepben/ewb/model/cim/iec61968/metering/end_device_function_kind.py b/src/zepben/ewb/model/cim/iec61968/metering/end_device_function_kind.py index 96b4168ef..6262e4992 100644 --- a/src/zepben/ewb/model/cim/iec61968/metering/end_device_function_kind.py +++ b/src/zepben/ewb/model/cim/iec61968/metering/end_device_function_kind.py @@ -7,7 +7,10 @@ from enum import Enum +from zepben.ewb import unique + +@unique class EndDeviceFunctionKind(Enum): """ Kind of end device function. diff --git a/src/zepben/ewb/model/cim/iec61970/base/auxiliaryequipment/potential_transformer_kind.py b/src/zepben/ewb/model/cim/iec61970/base/auxiliaryequipment/potential_transformer_kind.py index 5f5de866e..db707662b 100644 --- a/src/zepben/ewb/model/cim/iec61970/base/auxiliaryequipment/potential_transformer_kind.py +++ b/src/zepben/ewb/model/cim/iec61970/base/auxiliaryequipment/potential_transformer_kind.py @@ -7,7 +7,10 @@ from enum import Enum +from zepben.ewb import unique + +@unique class PotentialTransformerKind(Enum): """ The construction kind of the potential transformer. diff --git a/src/zepben/ewb/model/cim/iec61970/base/core/phase_code.py b/src/zepben/ewb/model/cim/iec61970/base/core/phase_code.py index 846ee9121..0471ac9db 100644 --- a/src/zepben/ewb/model/cim/iec61970/base/core/phase_code.py +++ b/src/zepben/ewb/model/cim/iec61970/base/core/phase_code.py @@ -8,6 +8,7 @@ from enum import Enum from typing import List, Set, Union +from zepben.ewb import unique from zepben.ewb.model.cim.iec61970.base.wires.single_phase_kind import SinglePhaseKind @@ -21,6 +22,7 @@ def phase_code_by_id(value: int): return _PHASE_CODE_VALUES[value] +@unique class PhaseCode(Enum): """ An unordered enumeration of phase identifiers. Allows designation of phases for both transmission and distribution equipment, diff --git a/src/zepben/ewb/model/cim/iec61970/base/diagramlayout/diagram_style.py b/src/zepben/ewb/model/cim/iec61970/base/diagramlayout/diagram_style.py index d658518ff..5847cfc46 100644 --- a/src/zepben/ewb/model/cim/iec61970/base/diagramlayout/diagram_style.py +++ b/src/zepben/ewb/model/cim/iec61970/base/diagramlayout/diagram_style.py @@ -7,7 +7,10 @@ from enum import Enum +from zepben.ewb import unique + +@unique class DiagramStyle(Enum): """ The diagram style refer to a style used by the originating system for a diagram. A diagram style describes diff --git a/src/zepben/ewb/model/cim/iec61970/base/diagramlayout/orientation_kind.py b/src/zepben/ewb/model/cim/iec61970/base/diagramlayout/orientation_kind.py index 2d1e461f2..3ab845378 100644 --- a/src/zepben/ewb/model/cim/iec61970/base/diagramlayout/orientation_kind.py +++ b/src/zepben/ewb/model/cim/iec61970/base/diagramlayout/orientation_kind.py @@ -7,7 +7,10 @@ from enum import Enum +from zepben.ewb import unique + +@unique class OrientationKind(Enum): """ The orientation of the coordinate system with respect to top, left, and the coordinate number system. diff --git a/src/zepben/ewb/model/cim/iec61970/base/domain/unit_symbol.py b/src/zepben/ewb/model/cim/iec61970/base/domain/unit_symbol.py index d1dfae5af..a663d2013 100644 --- a/src/zepben/ewb/model/cim/iec61970/base/domain/unit_symbol.py +++ b/src/zepben/ewb/model/cim/iec61970/base/domain/unit_symbol.py @@ -7,6 +7,8 @@ from enum import Enum +from zepben.ewb import unique + def unit_symbol_from_cim_name(value: str): return _unitsymbol_by_cim_name[value] @@ -16,6 +18,7 @@ def unit_symbol_from_id(value: int): return _unitsymbol_members_by_id[value] +# NOTE: We can't use `@unique` here, as there are duplicate unit strings. class UnitSymbol(Enum): """ The derived units defined for usage in the CIM. In some cases, the derived unit is equal to an SI unit. Whenever possible, the standard derived symbol is diff --git a/src/zepben/ewb/model/cim/iec61970/base/generation/production/battery_state_kind.py b/src/zepben/ewb/model/cim/iec61970/base/generation/production/battery_state_kind.py index 428dede8b..fb566446b 100644 --- a/src/zepben/ewb/model/cim/iec61970/base/generation/production/battery_state_kind.py +++ b/src/zepben/ewb/model/cim/iec61970/base/generation/production/battery_state_kind.py @@ -7,7 +7,10 @@ from enum import Enum +from zepben.ewb import unique + +@unique class BatteryStateKind(Enum): """ Battery state. diff --git a/src/zepben/ewb/model/cim/iec61970/base/wires/phase_shunt_connection_kind.py b/src/zepben/ewb/model/cim/iec61970/base/wires/phase_shunt_connection_kind.py index 3f7524b88..3149cd29c 100644 --- a/src/zepben/ewb/model/cim/iec61970/base/wires/phase_shunt_connection_kind.py +++ b/src/zepben/ewb/model/cim/iec61970/base/wires/phase_shunt_connection_kind.py @@ -7,7 +7,10 @@ from enum import Enum +from zepben.ewb.util import unique + +@unique class PhaseShuntConnectionKind(Enum): """ The configuration of phase connections for a single terminal device such as a load or capacitor. diff --git a/src/zepben/ewb/model/cim/iec61970/base/wires/regulating_control_mode_kind.py b/src/zepben/ewb/model/cim/iec61970/base/wires/regulating_control_mode_kind.py index 8beb389a3..a07449da9 100644 --- a/src/zepben/ewb/model/cim/iec61970/base/wires/regulating_control_mode_kind.py +++ b/src/zepben/ewb/model/cim/iec61970/base/wires/regulating_control_mode_kind.py @@ -7,7 +7,10 @@ from enum import Enum +from zepben.ewb import unique + +@unique class RegulatingControlModeKind(Enum): """ The kind of regulation model. For example regulating voltage, reactive power, active power, etc. diff --git a/src/zepben/ewb/model/cim/iec61970/base/wires/single_phase_kind.py b/src/zepben/ewb/model/cim/iec61970/base/wires/single_phase_kind.py index 73c20ef93..dc8519fe5 100644 --- a/src/zepben/ewb/model/cim/iec61970/base/wires/single_phase_kind.py +++ b/src/zepben/ewb/model/cim/iec61970/base/wires/single_phase_kind.py @@ -8,6 +8,8 @@ from enum import Enum from typing import Union +from zepben.ewb import unique + # # NOTE: The following import is actually at the bottom of this file to avoid cyclic imports. @@ -25,6 +27,7 @@ def single_phase_kind_by_id(value): return SINGLE_PHASE_KIND_VALUES[value] +@unique class SinglePhaseKind(Enum): """ Enumeration of single phase identifiers. Allows designation of single phases for both transmission and distribution equipment, circuits and loads. diff --git a/src/zepben/ewb/model/cim/iec61970/base/wires/svc_control_mode.py b/src/zepben/ewb/model/cim/iec61970/base/wires/svc_control_mode.py index 6dda61b1f..17c69f2f2 100644 --- a/src/zepben/ewb/model/cim/iec61970/base/wires/svc_control_mode.py +++ b/src/zepben/ewb/model/cim/iec61970/base/wires/svc_control_mode.py @@ -7,7 +7,10 @@ from enum import Enum +from zepben.ewb import unique + +@unique class SVCControlMode(Enum): """ Static VAr Compensator control mode. diff --git a/src/zepben/ewb/model/cim/iec61970/base/wires/synchronous_machine_kind.py b/src/zepben/ewb/model/cim/iec61970/base/wires/synchronous_machine_kind.py index 5ac8340e4..e150b3b68 100644 --- a/src/zepben/ewb/model/cim/iec61970/base/wires/synchronous_machine_kind.py +++ b/src/zepben/ewb/model/cim/iec61970/base/wires/synchronous_machine_kind.py @@ -7,7 +7,10 @@ from enum import Enum +from zepben.ewb import unique + +@unique class SynchronousMachineKind(Enum): """ Synchronous machine type. diff --git a/src/zepben/ewb/model/cim/iec61970/base/wires/winding_connection.py b/src/zepben/ewb/model/cim/iec61970/base/wires/winding_connection.py index 507ce70ad..290d82d5a 100644 --- a/src/zepben/ewb/model/cim/iec61970/base/wires/winding_connection.py +++ b/src/zepben/ewb/model/cim/iec61970/base/wires/winding_connection.py @@ -7,7 +7,10 @@ from enum import Enum +from zepben.ewb import unique + +@unique class WindingConnection(Enum): """ Winding connection type. diff --git a/src/zepben/ewb/services/network/network_state.py b/src/zepben/ewb/services/network/network_state.py index 3b8652f91..e651b71d0 100644 --- a/src/zepben/ewb/services/network/network_state.py +++ b/src/zepben/ewb/services/network/network_state.py @@ -7,7 +7,10 @@ from enum import Enum +from zepben.ewb import unique + +@unique class NetworkState(Enum): """ Indicates which state of the network an operation should be performed on. diff --git a/src/zepben/ewb/streaming/get/included_energized_containers.py b/src/zepben/ewb/streaming/get/included_energized_containers.py index 3e16d3a99..0abd370cd 100644 --- a/src/zepben/ewb/streaming/get/included_energized_containers.py +++ b/src/zepben/ewb/streaming/get/included_energized_containers.py @@ -7,7 +7,10 @@ from enum import Enum +from zepben.ewb import unique + +@unique class IncludedEnergizedContainers(Enum): """ Indicates which energized contains should be included when fetching a container. diff --git a/src/zepben/ewb/streaming/get/included_energizing_containers.py b/src/zepben/ewb/streaming/get/included_energizing_containers.py index 90027da51..5deefb0b1 100644 --- a/src/zepben/ewb/streaming/get/included_energizing_containers.py +++ b/src/zepben/ewb/streaming/get/included_energizing_containers.py @@ -7,7 +7,10 @@ from enum import Enum +from zepben.ewb.util import unique + +@unique class IncludedEnergizingContainers(Enum): """ Indicates which energizing contains should be included when fetching a container. diff --git a/src/zepben/ewb/util.py b/src/zepben/ewb/util.py index 6091ca997..979be8f18 100644 --- a/src/zepben/ewb/util.py +++ b/src/zepben/ewb/util.py @@ -19,12 +19,14 @@ "datetime_to_timestamp", "none", "classproperty", + "unique", ] import os import re from collections.abc import Sized from datetime import datetime +from enum import unique as enum_unique from typing import List, Optional, Iterable, Callable, Any, TypeVar, Generator, Dict, Collection from typing import TYPE_CHECKING from uuid import UUID @@ -187,3 +189,12 @@ def datetime_to_timestamp(date_time: datetime) -> PBTimestamp: timestamp = PBTimestamp() timestamp.FromDatetime(date_time) return timestamp + + +def unique(enumeration: T) -> T: + """ + A wrapper for the enum.unique() wrapper to preserve typing so that undefined members are correctly + flagged by the linter. + """ + enum_unique(enumeration) + return enumeration