Skip to content

Commit

Permalink
Upgrade resources to pydantic V2
Browse files Browse the repository at this point in the history
  • Loading branch information
guillaume-alliander committed Nov 15, 2023
1 parent f26d632 commit 5a928fc
Show file tree
Hide file tree
Showing 525 changed files with 18,462 additions and 12,051 deletions.
167 changes: 103 additions & 64 deletions pycgmes/resources/ACDCConverter.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,11 @@
from pydantic import Field
from pydantic.dataclasses import dataclass

from ..utils.dataclassconfig import DataclassConfig
from ..utils.profile import BaseProfile, Profile
from .ConductingEquipment import ConductingEquipment


@dataclass(config=DataclassConfig)
@dataclass
class ACDCConverter(ConductingEquipment):
"""
A unit with valves for three phases, together with unit control equipment, essential protective and switching
Expand Down Expand Up @@ -65,146 +64,186 @@ class ACDCConverter(ConductingEquipment):

baseS: float = Field(
default=0.0,
in_profiles=[
Profile.EQ,
],
json_schema_extra={
"in_profiles": [
Profile.EQ,
]
},
)

idleLoss: float = Field(
default=0.0,
in_profiles=[
Profile.EQ,
],
json_schema_extra={
"in_profiles": [
Profile.EQ,
]
},
)

maxUdc: float = Field(
default=0.0,
in_profiles=[
Profile.EQ,
],
json_schema_extra={
"in_profiles": [
Profile.EQ,
]
},
)

minUdc: float = Field(
default=0.0,
in_profiles=[
Profile.EQ,
],
json_schema_extra={
"in_profiles": [
Profile.EQ,
]
},
)

numberOfValves: int = Field(
default=0,
in_profiles=[
Profile.EQ,
],
json_schema_extra={
"in_profiles": [
Profile.EQ,
]
},
)

ratedUdc: float = Field(
default=0.0,
in_profiles=[
Profile.EQ,
],
json_schema_extra={
"in_profiles": [
Profile.EQ,
]
},
)

resistiveLoss: float = Field(
default=0.0,
in_profiles=[
Profile.EQ,
],
json_schema_extra={
"in_profiles": [
Profile.EQ,
]
},
)

switchingLoss: float = Field(
default=0.0,
in_profiles=[
Profile.EQ,
],
json_schema_extra={
"in_profiles": [
Profile.EQ,
]
},
)

valveU0: float = Field(
default=0.0,
in_profiles=[
Profile.EQ,
],
json_schema_extra={
"in_profiles": [
Profile.EQ,
]
},
)

maxP: float = Field(
default=0.0,
in_profiles=[
Profile.EQ,
],
json_schema_extra={
"in_profiles": [
Profile.EQ,
]
},
)

minP: float = Field(
default=0.0,
in_profiles=[
Profile.EQ,
],
json_schema_extra={
"in_profiles": [
Profile.EQ,
]
},
)

PccTerminal: Optional[str] = Field(
default=None,
in_profiles=[
Profile.EQ,
],
json_schema_extra={
"in_profiles": [
Profile.EQ,
]
},
)

# *Association not used*
# Type M:0..n in CIM # pylint: disable-next=line-too-long
# DCTerminals : list = Field(default_factory=list, in_profiles = [Profile.EQ, ])
# Type M:0..n in CIM
# DCTerminals : list = Field(default_factory=list, json_schema_extra={"in_profiles":[Profile.EQ, ]})

idc: float = Field(
default=0.0,
in_profiles=[
Profile.SV,
],
json_schema_extra={
"in_profiles": [
Profile.SV,
]
},
)

poleLossP: float = Field(
default=0.0,
in_profiles=[
Profile.SV,
],
json_schema_extra={
"in_profiles": [
Profile.SV,
]
},
)

uc: float = Field(
default=0.0,
in_profiles=[
Profile.SV,
],
json_schema_extra={
"in_profiles": [
Profile.SV,
]
},
)

udc: float = Field(
default=0.0,
in_profiles=[
Profile.SV,
],
json_schema_extra={
"in_profiles": [
Profile.SV,
]
},
)

p: float = Field(
default=0.0,
in_profiles=[
Profile.SSH,
],
json_schema_extra={
"in_profiles": [
Profile.SSH,
]
},
)

q: float = Field(
default=0.0,
in_profiles=[
Profile.SSH,
],
json_schema_extra={
"in_profiles": [
Profile.SSH,
]
},
)

targetPpcc: float = Field(
default=0.0,
in_profiles=[
Profile.SSH,
],
json_schema_extra={
"in_profiles": [
Profile.SSH,
]
},
)

targetUdc: float = Field(
default=0.0,
in_profiles=[
Profile.SSH,
],
json_schema_extra={
"in_profiles": [
Profile.SSH,
]
},
)

@cached_property
Expand Down
19 changes: 11 additions & 8 deletions pycgmes/resources/ACDCConverterDCTerminal.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,11 @@
from pydantic import Field
from pydantic.dataclasses import dataclass

from ..utils.dataclassconfig import DataclassConfig
from ..utils.profile import BaseProfile, Profile
from .DCBaseTerminal import DCBaseTerminal


@dataclass(config=DataclassConfig)
@dataclass
class ACDCConverterDCTerminal(DCBaseTerminal):
"""
A DC electrical connection point at the AC/DC converter. The AC/DC converter is electrically connected also to the
Expand All @@ -35,16 +34,20 @@ class ACDCConverterDCTerminal(DCBaseTerminal):

DCConductingEquipment: Optional[str] = Field(
default=None,
in_profiles=[
Profile.EQ,
],
json_schema_extra={
"in_profiles": [
Profile.EQ,
]
},
)

polarity: Optional[str] = Field(
default=None,
in_profiles=[
Profile.EQ,
],
json_schema_extra={
"in_profiles": [
Profile.EQ,
]
},
)

@cached_property
Expand Down
35 changes: 20 additions & 15 deletions pycgmes/resources/ACDCTerminal.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,11 @@
from pydantic import Field
from pydantic.dataclasses import dataclass

from ..utils.dataclassconfig import DataclassConfig
from ..utils.profile import BaseProfile, Profile
from .IdentifiedObject import IdentifiedObject


@dataclass(config=DataclassConfig)
@dataclass
class ACDCTerminal(IdentifiedObject):
"""
An electrical connection point (AC or DC) to a piece of conducting equipment. Terminals are connected at physical
Expand All @@ -43,32 +42,38 @@ class ACDCTerminal(IdentifiedObject):

sequenceNumber: int = Field(
default=0,
in_profiles=[
Profile.EQ,
],
json_schema_extra={
"in_profiles": [
Profile.EQ,
]
},
)

# *Association not used*
# Type M:0..n in CIM # pylint: disable-next=line-too-long
# OperationalLimitSet : list = Field(default_factory=list, in_profiles = [Profile.EQ, ])
# Type M:0..n in CIM
# OperationalLimitSet : list = Field(default_factory=list, json_schema_extra={"in_profiles":[Profile.EQ, ]}) # noqa: E501

BusNameMarker: Optional[str] = Field(
default=None,
in_profiles=[
Profile.EQ,
],
json_schema_extra={
"in_profiles": [
Profile.EQ,
]
},
)

connected: bool = Field(
default=False,
in_profiles=[
Profile.SSH,
],
json_schema_extra={
"in_profiles": [
Profile.SSH,
]
},
)

# *Association not used*
# Type M:0..n in CIM # pylint: disable-next=line-too-long
# Measurements : list = Field(default_factory=list, in_profiles = [Profile.OP, ])
# Type M:0..n in CIM
# Measurements : list = Field(default_factory=list, json_schema_extra={"in_profiles":[Profile.OP, ]})

@cached_property
def possible_profiles(self) -> set[BaseProfile]:
Expand Down
Loading

0 comments on commit 5a928fc

Please sign in to comment.