Skip to content

Commit 1777db6

Browse files
committed
A bunch of fixes
Signed-off-by: Kurt Greaves <kurt.greaves@zepben.com>
1 parent dd82567 commit 1777db6

7 files changed

Lines changed: 24 additions & 28 deletions

File tree

src/zepben/ewb/model/cim/iec61968/common/street_detail.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class StreetDetail(object):
1515
Street details, in the context of address.
1616
"""
1717

18-
building_name: str = None
18+
building_name: Optional[str] = None
1919
"""
2020
(if applicable) In certain cases the physical location of the place of interest does not have a direct point of entry from the street,
2121
but may be located inside a larger structure such as a building, complex, office block, apartment, etc.

src/zepben/ewb/model/cim/iec61968/metering/meter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def company_meter_id(self) -> Optional[str]:
2121
return self.name
2222

2323
@company_meter_id.setter
24-
def company_meter_id(self, meter_id: str):
24+
def company_meter_id(self, meter_id: Optional[str]):
2525
"""
2626
`meter_id` The ID to set for this Meter. Will use `IdentifiedObject.name` as a backing field.
2727
"""

src/zepben/ewb/model/cim/iec61970/base/core/identified_object.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,10 @@ def __init__(self, names: Optional[List[Name]] = None, **kwargs):
5151
self.add_name(name.type, name.name)
5252

5353
def __str__(self):
54-
str = f'{self.__class__.__name__}'
54+
class_name = f'{self.__class__.__name__}'
5555
if self.name:
56-
return f'{str}{{{self.mrid}|{self.name}}}'
57-
return f'{str}{{{self.mrid}}}'
58-
return f'{self.__class__.__name__}{{{self.mrid}{f"|{self.name}" if self.name else ""}}}'
56+
return f'{class_name}{{{self.mrid}|{self.name}}}'
57+
return f'{class_name}{{{self.mrid}}}'
5958

6059
@property
6160
def names(self) -> Generator[Name, None, None]:

src/zepben/ewb/model/cim/iec61970/base/wires/transformer_star_impedance.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,16 @@ class TransformerStarImpedance(IdentifiedObject):
2121
For transmission networks use PowerTransformerEnd impedances (r, r0, x, x0, b, b0, g and g0).
2222
"""
2323

24-
r: Optional[float] = 0.0
24+
r: Optional[float] = None
2525
""" r : Resistance of the transformer end. Unit: Ohms """
2626

27-
r0: Optional[float] = 0.0
27+
r0: Optional[float] = None
2828
""" r0 : Zero sequence series resistance of the transformer end. Unit: Ohms"""
2929

30-
x: Optional[float] = 0.0
30+
x: Optional[float] = None
3131
""" x : Positive sequence series reactance of the transformer end. Unit: Ohms"""
3232

33-
x0: Optional[float] = 0.0
33+
x0: Optional[float] = None
3434
""" x0 : Zero sequence series reactance of the transformer end. Unit: Ohms"""
3535

3636
transformer_end_info: Optional['TransformerEndInfo'] = None

src/zepben/ewb/services/common/translator/base_cim2proto.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,6 @@ def bind_to_pb(func: Callable[P, R]) -> Callable[P, R]:
4141

4242

4343
def set_or_null(**kwargs):
44-
if 'invWattRespPAtV1' in kwargs.keys():
45-
print('yo')
4644
return {f'{k}{"Null" if v is None else "Set"}': v if v is not None else NullValue.NULL_VALUE for k, v in kwargs.items()}
4745

4846

src/zepben/ewb/services/network/translator/network_cim2proto.py

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -595,7 +595,7 @@ def transformer_end_info_to_pb(cim: TransformerEndInfo) -> PBTransformerEndInfo:
595595
return PBTransformerEndInfo(
596596
ai=asset_info_to_pb(cim),
597597
connectionKind=_map_winding_connection.to_pb(cim.connection_kind),
598-
endNumber=from_nullable_int(cim.end_number),
598+
endNumber=cim.end_number,
599599
transformerTankInfoMRID=mrid_or_empty(cim.transformer_tank_info),
600600
transformerStarImpedanceMRID=mrid_or_empty(cim.transformer_star_impedance),
601601
energisedEndNoLoadTestsMRID=mrid_or_empty(cim.energised_end_no_load_tests),
@@ -966,12 +966,13 @@ def curve_to_pb(cim: Curve) -> PBCurve:
966966

967967

968968
def curve_data_to_pb(cim: CurveData) -> PBCurveData:
969-
return PBCurveData(**set_or_null(
969+
return PBCurveData(
970970
xValue=cim.x_value,
971971
y1Value=cim.y1_value,
972-
y2Value=from_nullable_float(cim.y2_value),
973-
y3Value=from_nullable_float(cim.y3_value)
974-
)
972+
**set_or_null(
973+
y2Value=from_nullable_float(cim.y2_value),
974+
y3Value=from_nullable_float(cim.y3_value)
975+
)
975976
)
976977

977978

@@ -1832,10 +1833,8 @@ def transformer_end_to_pb(cim: TransformerEnd) -> PBTransformerEnd:
18321833

18331834
def transformer_end_rated_s_to_pb(cim: TransformerEndRatedS) -> PBTransformerEndRatedS:
18341835
return PBTransformerEndRatedS(
1835-
coolingType=_map_transformer_cooling_type.to_pb(cim.cooling_type)
1836-
**set_or_null(
1837-
ratedS=cim.rated_s,
1838-
)
1836+
coolingType=_map_transformer_cooling_type.to_pb(cim.cooling_type),
1837+
ratedS=cim.rated_s,
18391838
)
18401839

18411840

@@ -1845,10 +1844,10 @@ def transformer_star_impedance_to_pb(cim: TransformerStarImpedance) -> PBTransfo
18451844
io=identified_object_to_pb(cim),
18461845
transformerEndInfoMRID=mrid_or_empty(cim.transformer_end_info),
18471846
**set_or_null(
1848-
r=cim.r if cim.r else 0.0,
1849-
r0=cim.r0 if cim.r0 else 0.0,
1850-
x=cim.x if cim.x else 0.0,
1851-
x0=cim.x0 if cim.x0 else 0.0,
1847+
r=cim.r,
1848+
r0=cim.r0,
1849+
x=cim.x,
1850+
x0=cim.x0
18521851
)
18531852
)
18541853

src/zepben/ewb/services/network/translator/network_proto2cim.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1119,8 +1119,8 @@ def curve_to_cim(pb: PBCurve, cim: Curve, network_service: NetworkService):
11191119

11201120
def curve_data_to_cim(pb: PBCurveData) -> Optional[CurveData]:
11211121
return CurveData(
1122-
get_nullable(pb, 'xValue'),
1123-
get_nullable(pb, 'y1Value'),
1122+
pb.xValue,
1123+
pb.y1Value,
11241124
get_nullable(pb, 'y2Value'),
11251125
get_nullable(pb, 'y3Value'),
11261126
)
@@ -2160,7 +2160,7 @@ def transformer_end_to_cim(pb: PBTransformerEnd, cim: TransformerEnd, network_se
21602160

21612161

21622162
def transformer_end_rated_s_to_cim(pb: PBTransformerEndRatedS) -> Optional[TransformerEndRatedS]:
2163-
return TransformerEndRatedS(cooling_type=TransformerCoolingType(pb.coolingType), rated_s=get_nullable(pb, 'ratedS'))
2163+
return TransformerEndRatedS(cooling_type=TransformerCoolingType(pb.coolingType), rated_s=pb.ratedS)
21642164

21652165

21662166
@bind_to_cim

0 commit comments

Comments
 (0)