def feeder_to_pb(cim: Feeder) -> PBFeeder: return PBFeeder( ec=equipmentcontainer_to_pb(cim), normalHeadTerminalMRID=mrid_or_empty(cim.normal_head_terminal), normalEnergizingSubstationMRID=mrid_or_empty( cim.normal_energizing_substation), currentEquipmentMRIDs=[str(io.mrid) for io in cim.current_equipment])
def terminal_to_pb(cim: Terminal) -> PBTerminal: return PBTerminal( ad=acdcterminal_to_pb(cim), conductingEquipmentMRID=mrid_or_empty(cim.conducting_equipment), connectivityNodeMRID=mrid_or_empty(cim.connectivity_node), tracedPhases=get_or_none(tracedphases_to_pb, cim.traced_phases), phases=PBPhaseCode.Value(cim.phases.short_name), sequenceNumber=cim.sequence_number)
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 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 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 substation_to_pb(cim: Substation) -> PBSubstation: return PBSubstation( ec=equipmentcontainer_to_pb(cim), subGeographicalRegionMRID=mrid_or_empty(cim.sub_geographical_region), normalEnergizedFeederMRIDs=[str(io.mrid) for io in cim.feeders], loopMRIDs=[str(io.mrid) for io in cim.loops], normalEnergizedLoopMRIDs=[str(io.mrid) for io in cim.energized_loops], circuitMRIDs=[str(io.mrid) for io in cim.circuits])
def energyconsumerphase_to_pb( cim: EnergyConsumerPhase) -> PBEnergyConsumerPhase: return PBEnergyConsumerPhase( psr=powersystemresource_to_pb(cim), energyConsumerMRID=mrid_or_empty(cim.energy_consumer), phase=PBSinglePhaseKind.Value(cim.phase.short_name), p=cim.p, pFixed=cim.p_fixed, q=cim.q, qFixed=cim.q_fixed)
def powertransformerend_to_pb( cim: PowerTransformerEnd) -> PBPowerTransformerEnd: return PBPowerTransformerEnd(te=transformerend_to_pb(cim), powerTransformerMRID=mrid_or_empty( cim.power_transformer), ratedS=cim.rated_s, ratedU=cim.rated_u, r=cim.r, r0=cim.r0, x=cim.x, x0=cim.x0, connectionKind=PBWindingConnection.Value( cim.connection_kind.short_name), b=cim.b, b0=cim.b0, g=cim.g, g0=cim.g0, phaseAngleClock=cim.phase_angle_clock)
def customeragreement_to_pb(cim: CustomerAgreement) -> PBCustomerAgreement: return PBCustomerAgreement(agr=agreement_to_pb(cim), customerMRID=mrid_or_empty(cim.customer), pricingStructureMRIDs=[str(io.mrid) for io in cim.pricing_structures])
def remotesource_to_pb(cim: RemoteSource) -> PBRemoteSource: return PBRemoteSource(rp=remotepoint_to_pb(cim), measurementMRID=mrid_or_empty(cim.measurement))
def remotecontrol_to_pb(cim: RemoteControl) -> PBRemoteControl: return PBRemoteControl(rp=remotepoint_to_pb(cim), controlMRID=mrid_or_empty(cim.control))
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 control_to_pb(cim: Control) -> PBControl: return PBControl(ip=iopoint_to_pb(cim), remoteControlMRID=mrid_or_empty(cim.remote_control), powerSystemResourceMRID=cim.power_system_resource_mrid)
def circuit_to_pb(cim: Circuit) -> PBCircuit: return PBCircuit( l=line_to_pb(cim), loopMRID=mrid_or_empty(cim.loop.mrid), endTerminalMRIDs=[str(io.mrid) for io in cim.end_terminals], endSubstationMRIDs=[str(io.mrid) for io in cim.end_substations])
def auxiliaryequipment_to_pb(cim: AuxiliaryEquipment) -> PBAuxiliaryEquipment: return PBAuxiliaryEquipment(eq=equipment_to_pb(cim), terminalMRID=mrid_or_empty(cim.terminal))
def ratiotapchanger_to_pb(cim: RatioTapChanger) -> PBRatioTapChanger: return PBRatioTapChanger(tc=tapchanger_to_pb(cim), transformerEndMRID=mrid_or_empty( cim.transformer_end), stepVoltageIncrement=cim.step_voltage_increment)
def energysourcephase_to_pb(cim: EnergySourcePhase) -> PBEnergySourcePhase: return PBEnergySourcePhase( psr=powersystemresource_to_pb(cim), energySourceMRID=mrid_or_empty(cim.energy_source), phase=PBSinglePhaseKind.Value(cim.phase.short_name))
def enddevice_to_pb(cim: EndDevice) -> PBEndDevice: return PBEndDevice( ac=assetcontainer_to_pb(cim), usagePointMRIDs=[str(io.mrid) for io in cim.usage_points], customerMRID=cim.customer_mrid, serviceLocationMRID=mrid_or_empty(cim.service_location))
def aclinesegment_to_pb(cim: AcLineSegment) -> PBAcLineSegment: return PBAcLineSegment(cd=conductor_to_pb(cim), perLengthSequenceImpedanceMRID=mrid_or_empty( cim.per_length_sequence_impedance))
def conductingequipment_to_pb( cim: ConductingEquipment) -> PBConductingEquipment: return PBConductingEquipment( eq=equipment_to_pb(cim), baseVoltageMRID=mrid_or_empty(cim.base_voltage), terminalMRIDs=[str(io.mrid) for io in cim.terminals])
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 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])