Пример #1
0
def control_to_cim(pb: PBControl,
                   network_service: NetworkService) -> Optional[Control]:
    cim = Control(mrid=pb.mrid())
    network_service.resolve_or_defer_reference(resolver.remote_control(cim),
                                               pb.remoteControlMRID)
    iopoint_to_cim(pb.ip, cim, network_service)
    return cim if network_service.add(cim) else None
Пример #2
0
def pole_to_cim(pb: PBPole, network_service: NetworkService) -> Optional[Pole]:
    cim = Pole(mrid=pb.mrid(), classification=pb.classification)
    for mrid in pb.streetlightMRIDs:
        network_service.resolve_or_defer_reference(resolver.streetlights(cim),
                                                   mrid)
    structure_to_cim(pb.st, cim, network_service)
    return cim if network_service.add(cim) else None
Пример #3
0
def equipmentcontainer_to_cim(pb: PBEquipmentContainer,
                              cim: EquipmentContainer,
                              network_service: NetworkService):
    for mrid in pb.equipmentMRIDs:
        network_service.resolve_or_defer_reference(resolver.ec_equipment(cim),
                                                   mrid)
    connectivitynodecontainer_to_cim(pb.cnc, cim, network_service)
Пример #4
0
def asset_to_cim(pb: PBAsset, cim: Asset, network_service: NetworkService):
    network_service.resolve_or_defer_reference(resolver.at_location(cim),
                                               pb.locationMRID)
    for mrid in pb.organisationRoleMRIDs:
        network_service.resolve_or_defer_reference(
            resolver.organisation_roles(cim), mrid)
    identifiedobject_to_cim(pb.io, cim, network_service)
Пример #5
0
def remotesource_to_cim(
        pb: PBRemoteSource,
        network_service: NetworkService) -> Optional[RemoteSource]:
    cim = RemoteSource(mrid=pb.mrid())
    network_service.resolve_or_defer_reference(resolver.measurement(cim),
                                               pb.measurementMRID)
    remotepoint_to_cim(pb.rp, cim, network_service)
    return cim if network_service.add(cim) else None
Пример #6
0
def energysourcephase_to_cim(
        pb: PBEnergySourcePhase,
        network_service: NetworkService) -> Optional[EnergySourcePhase]:
    cim = EnergySourcePhase(mrid=pb.mrid(), phase=phasekind_by_id(pb.phase))
    network_service.resolve_or_defer_reference(resolver.energy_source(cim),
                                               pb.energySourceMRID)
    powersystemresource_to_cim(pb.psr, cim, network_service)
    return cim if network_service.add(cim) else None
Пример #7
0
def connectivitynode_to_cim(
        pb: PBConnectivityNode,
        network_service: NetworkService) -> Optional[ConnectivityNode]:
    cim = ConnectivityNode(mrid=pb.mrid())
    for mrid in pb.terminalMRIDs:
        network_service.resolve_or_defer_reference(resolver.cn_terminals(cim),
                                                   mrid)
    identifiedobject_to_cim(pb.io, cim, network_service)
    return cim if network_service.add(cim) else None
Пример #8
0
def conductingequipment_to_cim(pb: PBConductingEquipment,
                               cim: ConductingEquipment,
                               network_service: NetworkService):
    network_service.resolve_or_defer_reference(resolver.ce_base_voltage(cim),
                                               pb.baseVoltageMRID)
    for mrid in pb.terminalMRIDs:
        network_service.resolve_or_defer_reference(resolver.ce_terminals(cim),
                                                   mrid)
    equipment_to_cim(pb.eq, cim, network_service)
Пример #9
0
def operationalrestriction_to_cim(
        pb: PBOperationalRestriction,
        network_service: NetworkService) -> Optional[OperationalRestriction]:
    cim = OperationalRestriction(mrid=pb.mrid())
    for mrid in pb.equipmentMRIDs:
        network_service.resolve_or_defer_reference(resolver.or_equipment(cim),
                                                   mrid)
    document_to_cim(pb.doc, cim, network_service)
    return cim if network_service.add(cim) else None
Пример #10
0
def enddevice_to_cim(pb: PBEndDevice, cim: EndDevice,
                     network_service: NetworkService):
    for mrid in pb.usagePointMRIDs:
        network_service.resolve_or_defer_reference(
            resolver.ed_usage_points(cim), mrid)
    cim.customer_mrid = pb.customerMRID if pb.customerMRID else None
    network_service.resolve_or_defer_reference(resolver.service_location(cim),
                                               pb.serviceLocationMRID)
    assetcontainer_to_cim(pb.ac, cim, network_service)
Пример #11
0
def streetlight_to_cim(
        pb: PBStreetlight,
        network_service: NetworkService) -> Optional[Streetlight]:
    cim = Streetlight(mrid=pb.mrid(),
                      light_rating=pb.lightRating,
                      lamp_kind=StreetlightLampKind(pb.lampKind))
    network_service.resolve_or_defer_reference(resolver.pole(cim), pb.poleMRID)
    asset_to_cim(pb.at, cim, network_service)
    return cim if network_service.add(cim) else None
Пример #12
0
def geographicalregion_to_cim(
        pb: PBGeographicalRegion,
        network_service: NetworkService) -> Optional[GeographicalRegion]:
    cim = GeographicalRegion(mrid=pb.mrid())
    for mrid in pb.subGeographicalRegionMRIDs:
        network_service.resolve_or_defer_reference(
            resolver.sub_geographical_regions(cim), mrid)
    identifiedobject_to_cim(pb.io, cim, network_service)
    return cim if network_service.add(cim) else None
Пример #13
0
def measurement_to_cim(pb: PBMeasurement, cim: Measurement,
                       service: NetworkService):
    cim.power_system_resource_mrid = pb.powerSystemResourceMRID
    cim.terminal_mrid = pb.terminalMRID
    cim.phases = phasecode_by_id(pb.phases)
    cim.unitSymbol = unit_symbol_from_id(pb.unitSymbol)
    service.resolve_or_defer_reference(resolver.remote_source(cim),
                                       pb.remoteSourceMRID)
    identifiedobject_to_cim(pb.io, cim, service)
Пример #14
0
def aclinesegment_to_cim(
        pb: PBAcLineSegment,
        network_service: NetworkService) -> Optional[AcLineSegment]:
    cim = AcLineSegment(mrid=pb.mrid())
    network_service.resolve_or_defer_reference(
        resolver.per_length_sequence_impedance(cim),
        pb.perLengthSequenceImpedanceMRID)
    conductor_to_cim(pb.cd, cim, network_service)
    return cim if network_service.add(cim) else None
Пример #15
0
def circuit_to_cim(pb: PBCircuit,
                   network_service: NetworkService) -> Optional[Circuit]:
    cim = Circuit(mrid=pb.mrid())
    for mrid in pb.endTerminalMRIDs:
        network_service.resolve_or_defer_reference(resolver.end_terminal(cim),
                                                   mrid)
    for mrid in pb.endSubstationMRIDs:
        network_service.resolve_or_defer_reference(
            resolver.end_substation(cim), mrid)
    line_to_cim(pb.l, cim, network_service)
    return cim if network_service.add(cim) else None
Пример #16
0
def powertransformer_to_cim(
        pb: PBPowerTransformer,
        network_service: NetworkService) -> Optional[PowerTransformer]:
    cim = PowerTransformer(mrid=pb.mrid(),
                           vector_group=VectorGroup(pb.vectorGroup),
                           transformer_utilisation=pb.transformerUtilisation)
    for mrid in pb.powerTransformerEndMRIDs:
        network_service.resolve_or_defer_reference(resolver.ends(cim), mrid)
    network_service.resolve_or_defer_reference(
        resolver.power_transformer_info(cim), pb.asset_info_mrid())
    conductingequipment_to_cim(pb.ce, cim, network_service)
    return cim if network_service.add(cim) else None
    async def run(self, network: NetworkService):
        feeder_start_points = set()
        for feeder in network.objects(Feeder):
            if feeder.normal_head_terminal:
                if feeder.normal_head_terminal.conducting_equipment:
                    feeder_start_points.add(
                        feeder.normal_head_terminal.conducting_equipment)
        configure_stop_conditions(self.normal_traversal, feeder_start_points)
        configure_stop_conditions(self.current_traversal, feeder_start_points)

        for feeder in network.objects(Feeder):
            await self.assign_to_feeder(feeder)
Пример #18
0
def terminal_to_cim(pb: PBTerminal,
                    network_service: NetworkService) -> Optional[Terminal]:
    cim = Terminal(mrid=pb.mrid(),
                   phases=phasecode_by_id(pb.phases),
                   sequence_number=pb.sequenceNumber)
    network_service.resolve_or_defer_reference(
        resolver.conducting_equipment(cim), pb.conductingEquipmentMRID)
    cim.traced_phases._normal_status = pb.tracedPhases.normalStatus
    cim.traced_phases._current_status = pb.tracedPhases.currentStatus
    network_service.resolve_or_defer_reference(resolver.connectivity_node(cim),
                                               pb.connectivityNodeMRID)
    acdcterminal_to_cim(pb.ad, cim, network_service)
    return cim if network_service.add(cim) else None
Пример #19
0
def energyconsumerphase_to_cim(
        pb: PBEnergyConsumerPhase,
        network_service: NetworkService) -> Optional[EnergyConsumerPhase]:
    cim = EnergyConsumerPhase(mrid=pb.mrid(),
                              phase=phasekind_by_id(pb.phase),
                              p=pb.p,
                              p_fixed=pb.pFixed,
                              q=pb.q,
                              q_fixed=pb.qFixed)
    network_service.resolve_or_defer_reference(resolver.energy_consumer(cim),
                                               pb.energyConsumerMRID)
    powersystemresource_to_cim(pb.psr, cim, network_service)
    return cim if network_service.add(cim) else None
Пример #20
0
def basevoltage_to_cim(
        pb: PBBaseVoltage,
        network_service: NetworkService) -> Optional[BaseVoltage]:
    cim = BaseVoltage(mrid=pb.mrid())
    cim.nominal_voltage = pb.nominalVoltage
    identifiedobject_to_cim(pb.io, cim, network_service)
    return cim if network_service.add(cim) else None
Пример #21
0
def ratiotapchanger_to_cim(
        pb: PBRatioTapChanger,
        network_service: NetworkService) -> Optional[RatioTapChanger]:
    cim = RatioTapChanger(mrid=pb.mrid(),
                          step_voltage_increment=pb.stepVoltageIncrement)
    tapchanger_to_cim(pb.tc, cim, network_service)
    return cim if network_service.add(cim) else None
Пример #22
0
def energyconsumer_to_cim(
        pb: PBEnergyConsumer,
        network_service: NetworkService) -> Optional[EnergyConsumer]:
    cim = EnergyConsumer(mrid=pb.mrid(),
                         customer_count=pb.customerCount,
                         grounded=pb.grounded,
                         p=pb.p,
                         p_fixed=pb.pFixed,
                         q=pb.q,
                         q_fixed=pb.qFixed,
                         phase_connection=PhaseShuntConnectionKind(
                             pb.phaseConnection))
    for mrid in pb.energyConsumerPhasesMRIDs:
        network_service.resolve_or_defer_reference(resolver.ec_phases(cim),
                                                   mrid)
    energyconnection_to_cim(pb.ec, cim, network_service)
    return cim if network_service.add(cim) else None
Пример #23
0
def location_to_cim(pb: PBLocation,
                    network_service: NetworkService) -> Optional[Location]:
    cim = Location(mrid=pb.mrid(),
                   main_address=streetaddress_to_cim(pb.mainAddress)
                   if pb.HasField('mainAddress') else None)
    for point in pb.positionPoints:
        cim.add_point(positionpoint_to_cim(point))
    identifiedobject_to_cim(pb.io, cim, network_service)
    return cim if network_service.add(cim) else None
Пример #24
0
def linearshuntcompensator_to_cim(
        pb: PBLinearShuntCompensator,
        network_service: NetworkService) -> Optional[LinearShuntCompensator]:
    cim = LinearShuntCompensator(mrid=pb.mrid(),
                                 b0_per_section=pb.b0PerSection,
                                 b_per_section=pb.bPerSection,
                                 g0_per_section=pb.g0PerSection,
                                 g_per_section=pb.gPerSection)
    shuntcompensator_to_cim(pb.sc, cim, network_service)
    return cim if network_service.add(cim) else None
Пример #25
0
def powertransformerend_to_cim(
        pb: PBPowerTransformerEnd,
        network_service: NetworkService) -> Optional[PowerTransformerEnd]:
    cim = PowerTransformerEnd(mrid=pb.mrid(),
                              rated_s=pb.ratedS,
                              rated_u=pb.ratedU,
                              r=pb.r,
                              r0=pb.r0,
                              x=pb.x,
                              x0=pb.x0,
                              b=pb.b,
                              b0=pb.b0,
                              g=pb.g,
                              g0=pb.g0,
                              connection_kind=WindingConnection(
                                  pb.connectionKind),
                              phase_angle_clock=pb.phaseAngleClock)
    network_service.resolve_or_defer_reference(resolver.power_transformer(cim),
                                               pb.powerTransformerMRID)
    transformerend_to_cim(pb.te, cim, network_service)
    return cim if network_service.add(cim) else None
Пример #26
0
def energysource_to_cim(
        pb: PBEnergySource,
        network_service: NetworkService) -> Optional[EnergySource]:
    cim = EnergySource(mrid=pb.mrid(),
                       active_power=pb.activePower,
                       reactive_power=pb.reactivePower,
                       voltage_angle=pb.voltageAngle,
                       voltage_magnitude=pb.voltageMagnitude,
                       r=pb.r,
                       x=pb.x,
                       p_max=pb.pMax,
                       p_min=pb.pMin,
                       r0=pb.r0,
                       rn=pb.rn,
                       x0=pb.x0,
                       xn=pb.xn)
    for mrid in pb.energySourcePhasesMRIDs:
        network_service.resolve_or_defer_reference(resolver.es_phases(cim),
                                                   mrid)
    energyconnection_to_cim(pb.ec, cim, network_service)
    return cim if network_service.add(cim) else None
Пример #27
0
def perlengthsequenceimpedance_to_cim(
        pb: PBPerLengthSequenceImpedance, network_service: NetworkService
) -> Optional[PerLengthSequenceImpedance]:
    cim = PerLengthSequenceImpedance(mrid=pb.mrid(),
                                     r=pb.r,
                                     x=pb.x,
                                     r0=pb.r0,
                                     x0=pb.x0,
                                     bch=pb.bch,
                                     gch=pb.gch,
                                     b0ch=pb.b0ch,
                                     g0ch=pb.g0ch)
    perlengthimpedance_to_cim(pb.pli, cim, network_service)
    return cim if network_service.add(cim) else None
Пример #28
0
def loop_to_cim(pb: PBLoop, network_service: NetworkService) -> Optional[Loop]:
    cim = Loop(mrid=pb.mrid())
    for mrid in pb.circuitMRIDs:
        network_service.resolve_or_defer_reference(resolver.loop_circuits(cim),
                                                   mrid)
    for mrid in pb.substationMRIDs:
        network_service.resolve_or_defer_reference(
            resolver.loop_substations(cim), mrid)
    for mrid in pb.normalEnergizingSubstationMRIDs:
        network_service.resolve_or_defer_reference(
            resolver.loop_energizing_substations(cim), mrid)
    identifiedobject_to_cim(pb.io, cim, network_service)
    return cim if network_service.add(cim) else None
Пример #29
0
def usagepoint_to_cim(pb: PBUsagePoint,
                      network_service: NetworkService) -> Optional[UsagePoint]:
    cim = UsagePoint(mrid=pb.mrid())
    network_service.resolve_or_defer_reference(
        resolver.usage_point_location(cim), pb.usagePointLocationMRID)
    for mrid in pb.equipmentMRIDs:
        network_service.resolve_or_defer_reference(resolver.up_equipment(cim),
                                                   mrid)
    for mrid in pb.endDeviceMRIDs:
        network_service.resolve_or_defer_reference(resolver.end_devices(cim),
                                                   mrid)
    identifiedobject_to_cim(pb.io, cim, network_service)
    return cim if network_service.add(cim) else None
Пример #30
0
def feeder_to_cim(pb: PBFeeder,
                  network_service: NetworkService) -> Optional[Feeder]:
    cim = Feeder(mrid=pb.mrid())
    network_service.resolve_or_defer_reference(
        resolver.normal_head_terminal(cim), pb.normalHeadTerminalMRID)
    network_service.resolve_or_defer_reference(
        resolver.normal_energizing_substation(cim),
        pb.normalEnergizingSubstationMRID)
    for mrid in pb.currentEquipmentMRIDs:
        network_service.resolve_or_defer_reference(
            resolver.current_equipment(cim), mrid)
    equipmentcontainer_to_cim(pb.ec, cim, network_service)
    return cim if network_service.add(cim) else None