Example #1
0
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])
Example #2
0
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
                  ])
Example #3
0
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))
Example #4
0
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)
Example #5
0
def remotepoint_to_pb(cim: RemotePoint) -> PBRemotePoint:
    return PBRemotePoint(io=identifiedobject_to_pb(cim))
Example #6
0
def iopoint_to_pb(cim: IoPoint) -> PBIoPoint:
    return PBIoPoint(io=identifiedobject_to_pb(cim))
Example #7
0
def perlengthlineparameter_to_pb(
        cim: PerLengthLineParameter) -> PBPerLengthLineParameter:
    return PBPerLengthLineParameter(io=identifiedobject_to_pb(cim))
Example #8
0
def assetinfo_to_pb(cim: AssetInfo) -> PBAssetInfo:
    return PBAssetInfo(io=identifiedobject_to_pb(cim))
Example #9
0
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))
Example #10
0
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
                                ])
Example #11
0
def connectivitynode_to_pb(cim: ConnectivityNode) -> PBConnectivityNode:
    return PBConnectivityNode(
        io=identifiedobject_to_pb(cim),
        terminalMRIDs=[str(io.mrid) for io in cim.terminals])
Example #12
0
def basevoltage_to_pb(cim: BaseVoltage) -> PBBaseVoltage:
    return PBBaseVoltage(io=identifiedobject_to_pb(cim),
                         nominalVoltage=cim.nominal_voltage)
Example #13
0
def acdcterminal_to_pb(cim: AcDcTerminal) -> PBAcDcTerminal:
    return PBAcDcTerminal(io=identifiedobject_to_pb(cim))
Example #14
0
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])
Example #15
0
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])
Example #16
0
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])
Example #17
0
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])
Example #18
0
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])