def diagramobject_to_pb(cim: DiagramObject) -> PBDiagramObject: return PBDiagramObject(io=identifiedobject_to_pb(cim), diagramMRID=mrid_or_empty(cim.diagram), identifiedObjectMRID=cim.identified_object_mrid, diagramObjectStyle=PBDiagramObjectStyle.Value(cim.style.short_name), rotation=cim.rotation, diagramObjectPoints=[diagramobjectpoint_to_pb(io) for io in cim.points])
def loop_to_pb(cim: Loop) -> PBLoop: return PBLoop(io=identifiedobject_to_pb(cim), circuitMRIDs=[str(io.mrid) for io in cim.circuits], substationMRIDs=[str(io.mrid) for io in cim.substations], normalEnergizingSubstationMRIDs=[ str(io.mrid) for io in cim.energizing_substations ])
def measurement_to_pb(cim: Measurement) -> PBMeasurement: return PBMeasurement( io=identifiedobject_to_pb(cim), remoteSourceMRID=mrid_or_empty(cim.remote_source), powerSystemResourceMRID=cim.power_system_resource_mrid, terminalMRID=cim.terminal_mrid, phases=PBPhaseCode.Value(cim.phases.short_name), unitSymbol=PBUnitSymbol.Value(cim.unitSymbol.short_name))
def transformerend_to_pb(cim: TransformerEnd) -> PBTransformerEnd: return PBTransformerEnd(io=identifiedobject_to_pb(cim), terminalMRID=mrid_or_empty(cim.terminal), baseVoltageMRID=mrid_or_empty(cim.base_voltage), ratioTapChangerMRID=mrid_or_empty( cim.ratio_tap_changer), endNumber=cim.end_number, grounded=cim.grounded, rGround=cim.r_ground, xGround=cim.x_ground)
def remotepoint_to_pb(cim: RemotePoint) -> PBRemotePoint: return PBRemotePoint(io=identifiedobject_to_pb(cim))
def iopoint_to_pb(cim: IoPoint) -> PBIoPoint: return PBIoPoint(io=identifiedobject_to_pb(cim))
def perlengthlineparameter_to_pb( cim: PerLengthLineParameter) -> PBPerLengthLineParameter: return PBPerLengthLineParameter(io=identifiedobject_to_pb(cim))
def assetinfo_to_pb(cim: AssetInfo) -> PBAssetInfo: return PBAssetInfo(io=identifiedobject_to_pb(cim))
def powersystemresource_to_pb( cim: PowerSystemResource) -> PBPowerSystemResource: return PBPowerSystemResource(io=identifiedobject_to_pb(cim), assetInfoMRID=mrid_or_empty(cim.asset_info), locationMRID=mrid_or_empty(cim.location))
def geographicalregion_to_pb(cim: GeographicalRegion) -> PBGeographicalRegion: return PBGeographicalRegion(io=identifiedobject_to_pb(cim), subGeographicalRegionMRIDs=[ str(io.mrid) for io in cim.sub_geographical_regions ])
def connectivitynode_to_pb(cim: ConnectivityNode) -> PBConnectivityNode: return PBConnectivityNode( io=identifiedobject_to_pb(cim), terminalMRIDs=[str(io.mrid) for io in cim.terminals])
def basevoltage_to_pb(cim: BaseVoltage) -> PBBaseVoltage: return PBBaseVoltage(io=identifiedobject_to_pb(cim), nominalVoltage=cim.nominal_voltage)
def acdcterminal_to_pb(cim: AcDcTerminal) -> PBAcDcTerminal: return PBAcDcTerminal(io=identifiedobject_to_pb(cim))
def usagepoint_to_pb(cim: UsagePoint) -> PBUsagePoint: return PBUsagePoint( io=identifiedobject_to_pb(cim), usagePointLocationMRID=mrid_or_empty(cim.usage_point_location), equipmentMRIDs=[str(io.mrid) for io in cim.equipment], endDeviceMRIDs=[str(io.mrid) for io in cim.end_devices])
def location_to_pb(cim: Location) -> PBLocation: return PBLocation( io=identifiedobject_to_pb(cim), mainAddress=get_or_none(streetaddress_to_pb, cim.main_address), positionPoints=[positionpoint_to_pb(point) for _, point in cim.points])
def diagram_to_pb(cim: Diagram) -> PBDiagram: return PBDiagram(io=identifiedobject_to_pb(cim), diagramStyle=PBDiagramStyle.Value(cim.diagram_style.short_name), orientationKind=PBOrientationKind.Value(cim.orientation_kind.short_name), diagramObjectMRIDs=[str(io.mrid) for io in cim.diagram_objects])
def subgeographicalregion_to_pb( cim: SubGeographicalRegion) -> PBSubGeographicalRegion: return PBSubGeographicalRegion( io=identifiedobject_to_pb(cim), geographicalRegionMRID=mrid_or_empty(cim.geographical_region), substationMRIDs=[str(io.mrid) for io in cim.substations])
def asset_to_pb(cim: Asset) -> PBAsset: return PBAsset( io=identifiedobject_to_pb(cim), locationMRID=cim.location.mrid if cim.location else None, organisationRoleMRIDs=[str(io.mrid) for io in cim.organisation_roles])