All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.zepben.evolve.services.common.ReferenceResolvers.kt Maven / Gradle / Ivy

There is a newer version: 0.24.0rc1
Show newest version
/*
 * Copyright 2020 Zeppelin Bend Pty Ltd
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at https://mozilla.org/MPL/2.0/.
 */

package com.zepben.evolve.services.common

import com.zepben.evolve.cim.iec61968.assetinfo.*
import com.zepben.evolve.cim.iec61968.assets.Asset
import com.zepben.evolve.cim.iec61968.assets.AssetOrganisationRole
import com.zepben.evolve.cim.iec61968.assets.Pole
import com.zepben.evolve.cim.iec61968.assets.Streetlight
import com.zepben.evolve.cim.iec61968.common.Location
import com.zepben.evolve.cim.iec61968.common.Organisation
import com.zepben.evolve.cim.iec61968.common.OrganisationRole
import com.zepben.evolve.cim.iec61968.customers.Customer
import com.zepben.evolve.cim.iec61968.customers.CustomerAgreement
import com.zepben.evolve.cim.iec61968.customers.PricingStructure
import com.zepben.evolve.cim.iec61968.customers.Tariff
import com.zepben.evolve.cim.iec61968.infiec61968.infassetinfo.CurrentTransformerInfo
import com.zepben.evolve.cim.iec61968.infiec61968.infassetinfo.PotentialTransformerInfo
import com.zepben.evolve.cim.iec61968.infiec61968.infassetinfo.RelayInfo
import com.zepben.evolve.cim.iec61968.metering.EndDevice
import com.zepben.evolve.cim.iec61968.metering.UsagePoint
import com.zepben.evolve.cim.iec61968.operations.OperationalRestriction
import com.zepben.evolve.cim.iec61970.base.auxiliaryequipment.AuxiliaryEquipment
import com.zepben.evolve.cim.iec61970.base.auxiliaryequipment.CurrentTransformer
import com.zepben.evolve.cim.iec61970.base.auxiliaryequipment.PotentialTransformer
import com.zepben.evolve.cim.iec61970.base.auxiliaryequipment.Sensor
import com.zepben.evolve.cim.iec61970.base.core.*
import com.zepben.evolve.cim.iec61970.base.diagramlayout.Diagram
import com.zepben.evolve.cim.iec61970.base.diagramlayout.DiagramObject
import com.zepben.evolve.cim.iec61970.base.meas.Control
import com.zepben.evolve.cim.iec61970.base.meas.Measurement
import com.zepben.evolve.cim.iec61970.base.protection.ProtectionRelayFunction
import com.zepben.evolve.cim.iec61970.base.protection.ProtectionRelayScheme
import com.zepben.evolve.cim.iec61970.base.protection.ProtectionRelaySystem
import com.zepben.evolve.cim.iec61970.base.scada.RemoteControl
import com.zepben.evolve.cim.iec61970.base.scada.RemoteSource
import com.zepben.evolve.cim.iec61970.base.wires.*
import com.zepben.evolve.cim.iec61970.base.wires.generation.production.PowerElectronicsUnit
import com.zepben.evolve.cim.iec61970.infiec61970.feeder.Circuit
import com.zepben.evolve.cim.iec61970.infiec61970.feeder.Loop
import com.zepben.evolve.cim.iec61970.infiec61970.feeder.LvFeeder
import kotlin.reflect.KClass


internal object AcLineSegmentToPerLengthSequenceImpedanceResolver : ReferenceResolver by KReferenceResolver(
    AcLineSegment::class, PerLengthSequenceImpedance::class, AcLineSegment::perLengthSequenceImpedance.setter
)

internal object AssetToAssetOrganisationRoleResolver : ReferenceResolver by KReferenceResolver(
    Asset::class, AssetOrganisationRole::class, Asset::addOrganisationRole
)

internal object AssetToLocationResolver : ReferenceResolver by KReferenceResolver(
    Asset::class, Location::class, Asset::location.setter
)

internal object PoleToStreetlightResolver : ReferenceResolver by KReferenceResolver(
    Pole::class, Streetlight::class, Pole::addStreetlight
)

internal object StreetlightToPoleResolver : ReferenceResolver by KReferenceResolver(
    Streetlight::class, Pole::class, Streetlight::pole.setter
)

internal object AuxiliaryEquipmentToTerminalResolver : ReferenceResolver by KReferenceResolver(
    AuxiliaryEquipment::class, Terminal::class, AuxiliaryEquipment::terminal.setter
)

internal object ConductingEquipmentToBaseVoltageResolver : ReferenceResolver by KReferenceResolver(
    ConductingEquipment::class, BaseVoltage::class, ConductingEquipment::baseVoltage.setter
)

internal object ConductingEquipmentToTerminalsResolver : ReferenceResolver by KReferenceResolver(
    ConductingEquipment::class,
    Terminal::class,
    { ce, t ->
        t.conductingEquipment = ce
        ce.addTerminal(t)
    })

internal object ConductorToWireInfoResolver : ReferenceResolver by KReferenceResolver(
    Conductor::class, WireInfo::class, Conductor::assetInfo.setter
)

internal object CurrentTransformerToCurrentTransformerInfoResolver : ReferenceResolver by KReferenceResolver(
    CurrentTransformer::class, CurrentTransformerInfo::class, CurrentTransformer::assetInfo.setter
)

internal object PotentialTransformerToPotentialTransformerInfoResolver :
    ReferenceResolver by KReferenceResolver(
        PotentialTransformer::class, PotentialTransformerInfo::class, PotentialTransformer::assetInfo.setter
    )

internal object PowerTransformerToPowerTransformerInfoResolver : ReferenceResolver by KReferenceResolver(
    PowerTransformer::class, PowerTransformerInfo::class, PowerTransformer::assetInfo.setter
)

internal object ShuntCompensatorToShuntCompensatorInfoResolver : ReferenceResolver by KReferenceResolver(
    ShuntCompensator::class, ShuntCompensatorInfo::class, ShuntCompensator::assetInfo.setter
)

internal object SwitchToSwitchInfoResolver : ReferenceResolver by KReferenceResolver(
    Switch::class, SwitchInfo::class, Switch::assetInfo.setter
)

internal object ConnectivityNodeToTerminalResolver : ReferenceResolver by KReferenceResolver(
    ConnectivityNode::class, Terminal::class, ConnectivityNode::addTerminal
)

internal object ControlToRemoteControlResolver : ReferenceResolver by KReferenceResolver(
    Control::class, RemoteControl::class, Control::remoteControl.setter
)

internal object CustomerToCustomerAgreementResolver : ReferenceResolver by KReferenceResolver(
    Customer::class, CustomerAgreement::class, Customer::addAgreement
)

internal object CustomerAgreementToCustomerResolver : ReferenceResolver by KReferenceResolver(
    CustomerAgreement::class, Customer::class, CustomerAgreement::customer.setter
)

internal object CustomerAgreementToPricingStructureResolver : ReferenceResolver by KReferenceResolver(
    CustomerAgreement::class, PricingStructure::class, CustomerAgreement::addPricingStructure
)

internal object DiagramToDiagramObjectResolver : ReferenceResolver by KReferenceResolver(
    Diagram::class, DiagramObject::class,
    { diagram, diagramObject ->
        diagramObject.diagram = diagram
        diagram.addDiagramObject(diagramObject)
    })

internal object DiagramObjectToDiagramResolver : ReferenceResolver by KReferenceResolver(
    DiagramObject::class, Diagram::class, DiagramObject::diagram.setter
)

internal object EndDeviceToUsagePointResolver : ReferenceResolver by KReferenceResolver(
    EndDevice::class, UsagePoint::class, EndDevice::addUsagePoint
)

internal object EndDeviceToServiceLocationResolver : ReferenceResolver by KReferenceResolver(
    EndDevice::class, Location::class, EndDevice::serviceLocation.setter
)

internal object EnergyConsumerToEnergyConsumerPhaseResolver : ReferenceResolver by KReferenceResolver(
    EnergyConsumer::class, EnergyConsumerPhase::class, EnergyConsumer::addPhase
)

internal object EnergyConsumerPhaseToEnergyConsumerResolver : ReferenceResolver by KReferenceResolver(
    EnergyConsumerPhase::class, EnergyConsumer::class, EnergyConsumerPhase::energyConsumer.setter
)

internal object EnergySourceToEnergySourcePhaseResolver : ReferenceResolver by KReferenceResolver(
    EnergySource::class, EnergySourcePhase::class, EnergySource::addPhase
)

internal object EnergySourcePhaseToEnergySourceResolver : ReferenceResolver by KReferenceResolver(
    EnergySourcePhase::class, EnergySource::class, EnergySourcePhase::energySource.setter
)

internal object EquipmentToCurrentContainersResolver : ReferenceResolver by KReferenceResolver(
    Equipment::class, EquipmentContainer::class, Equipment::addCurrentContainer
)

internal object EquipmentToEquipmentContainerResolver : ReferenceResolver by KReferenceResolver(
    Equipment::class, EquipmentContainer::class, Equipment::addContainer
)

internal object EquipmentToOperationalRestrictionResolver : ReferenceResolver by KReferenceResolver(
    Equipment::class, OperationalRestriction::class, Equipment::addOperationalRestriction
)

internal object EquipmentToUsagePointResolver : ReferenceResolver by KReferenceResolver(
    Equipment::class, UsagePoint::class, Equipment::addUsagePoint
)

internal object EquipmentContainerToEquipmentResolver : ReferenceResolver by KReferenceResolver(
    EquipmentContainer::class, Equipment::class, EquipmentContainer::addEquipment
)

internal object EquipmentContainerToCurrentEquipmentResolver : ReferenceResolver by KReferenceResolver(
    EquipmentContainer::class, Equipment::class, EquipmentContainer::addCurrentEquipment
)

internal object FeederToNormalEnergizingSubstationResolver : ReferenceResolver by KReferenceResolver(
    Feeder::class, Substation::class, Feeder::normalEnergizingSubstation.setter
)

internal object FeederToNormalHeadTerminalResolver : ReferenceResolver by KReferenceResolver(
    Feeder::class, Terminal::class, Feeder::normalHeadTerminal.setter
)

internal object FeederToNormalEnergizedLvFeedersResolver : ReferenceResolver by KReferenceResolver(
    Feeder::class, LvFeeder::class, Feeder::addNormalEnergizedLvFeeder
)

internal object GeographicalRegionToSubGeographicalRegionResolver : ReferenceResolver by KReferenceResolver(
    GeographicalRegion::class, SubGeographicalRegion::class, GeographicalRegion::addSubGeographicalRegion
)

internal object MeasurementToRemoteSourceResolver : ReferenceResolver by KReferenceResolver(
    Measurement::class, RemoteSource::class, Measurement::remoteSource.setter
)

internal object OperationalRestrictionToEquipmentResolver : ReferenceResolver by KReferenceResolver(
    OperationalRestriction::class, Equipment::class, OperationalRestriction::addEquipment
)

internal object OrganisationRoleToOrganisationResolver : ReferenceResolver by KReferenceResolver(
    OrganisationRole::class, Organisation::class, OrganisationRole::organisation.setter
)

internal object PowerSystemResourceToLocationResolver : ReferenceResolver by KReferenceResolver(
    PowerSystemResource::class, Location::class, PowerSystemResource::location.setter
)

internal object PowerTransformerToPowerTransformerEndResolver : ReferenceResolver by KReferenceResolver(
    PowerTransformer::class,
    PowerTransformerEnd::class,
    { pt, pte ->
        pte.powerTransformer = pt
        pt.addEnd(pte)
    })

internal object PowerTransformerEndToPowerTransformerResolver : ReferenceResolver by KReferenceResolver(
    PowerTransformerEnd::class, PowerTransformer::class, PowerTransformerEnd::powerTransformer.setter
)

internal object PricingStructureToTariffResolver : ReferenceResolver by KReferenceResolver(
    PricingStructure::class, Tariff::class, PricingStructure::addTariff
)

internal object RatioTapChangerToTransformerEndResolver : ReferenceResolver by KReferenceResolver(
    RatioTapChanger::class, TransformerEnd::class, RatioTapChanger::transformerEnd.setter
)

internal object RegulatingCondEqToRegulatingControlResolver : ReferenceResolver by KReferenceResolver(
    RegulatingCondEq::class, RegulatingControl::class, RegulatingCondEq::regulatingControl.setter
)

internal object RegulatingControlToTerminalResolver : ReferenceResolver by KReferenceResolver(
    RegulatingControl::class, Terminal::class, RegulatingControl::terminal.setter
)

internal object RegulatingControlToRegulatingCondEqResolver : ReferenceResolver by KReferenceResolver(
    RegulatingControl::class, RegulatingCondEq::class, RegulatingControl::addRegulatingCondEq
)

internal object RemoteControlToControlResolver : ReferenceResolver by KReferenceResolver(
    RemoteControl::class, Control::class, RemoteControl::control.setter
)

internal object RemoteSourceToMeasurementResolver : ReferenceResolver by KReferenceResolver(
    RemoteSource::class, Measurement::class, RemoteSource::measurement.setter
)

internal object SubGeographicalRegionToGeographicalRegionResolver : ReferenceResolver by KReferenceResolver(
    SubGeographicalRegion::class, GeographicalRegion::class, SubGeographicalRegion::geographicalRegion.setter
)

internal object SubGeographicalRegionToSubstationResolver : ReferenceResolver by KReferenceResolver(
    SubGeographicalRegion::class, Substation::class, SubGeographicalRegion::addSubstation
)

internal object SubstationToNormalEnergizedFeedersResolver : ReferenceResolver by KReferenceResolver(
    Substation::class, Feeder::class, Substation::addFeeder
)

internal object SubstationToSubGeographicalRegionResolver : ReferenceResolver by KReferenceResolver(
    Substation::class, SubGeographicalRegion::class, Substation::subGeographicalRegion.setter
)

internal object SubstationToCircuitResolver : ReferenceResolver by KReferenceResolver(
    Substation::class, Circuit::class, Substation::addCircuit
)

internal object SubstationToLoopResolver : ReferenceResolver by KReferenceResolver(
    Substation::class, Loop::class, Substation::addLoop
)

internal object SubstationToEnergizedLoopResolver : ReferenceResolver by KReferenceResolver(
    Substation::class, Loop::class, Substation::addEnergizedLoop
)

internal object TerminalToConductingEquipmentResolver : ReferenceResolver by KReferenceResolver(
    Terminal::class, ConductingEquipment::class, Terminal::conductingEquipment.setter
)

internal object TerminalToConnectivityNodeResolver : ReferenceResolver by KReferenceResolver(
    Terminal::class, ConnectivityNode::class, Terminal::connectivityNode.setter
)

internal object TransformerEndToTerminalResolver : ReferenceResolver by KReferenceResolver(
    TransformerEnd::class, Terminal::class, TransformerEnd::terminal.setter
)

internal object TransformerEndToBaseVoltageResolver : ReferenceResolver by KReferenceResolver(
    TransformerEnd::class, BaseVoltage::class, TransformerEnd::baseVoltage.setter
)

internal object TransformerEndToRatioTapChangerResolver : ReferenceResolver by KReferenceResolver(
    TransformerEnd::class, RatioTapChanger::class, TransformerEnd::ratioTapChanger.setter
)

internal object UsagePointToEndDeviceResolver : ReferenceResolver by KReferenceResolver(
    UsagePoint::class, EndDevice::class, UsagePoint::addEndDevice
)

internal object UsagePointToEquipmentResolver : ReferenceResolver by KReferenceResolver(
    UsagePoint::class, Equipment::class, UsagePoint::addEquipment
)

internal object UsagePointToLocationResolver : ReferenceResolver by KReferenceResolver(
    UsagePoint::class, Location::class, UsagePoint::usagePointLocation.setter
)

internal object CircuitToTerminalResolver : ReferenceResolver by KReferenceResolver(
    Circuit::class, Terminal::class, Circuit::addEndTerminal
)

internal object CircuitToLoopResolver : ReferenceResolver by KReferenceResolver(
    Circuit::class, Loop::class, Circuit::loop.setter
)

internal object CircuitToSubstationResolver : ReferenceResolver by KReferenceResolver(
    Circuit::class, Substation::class, Circuit::addEndSubstation
)

internal object LoopToCircuitResolver : ReferenceResolver by KReferenceResolver(
    Loop::class, Circuit::class, Loop::addCircuit
)

internal object LoopToSubstationResolver : ReferenceResolver by KReferenceResolver(
    Loop::class, Substation::class, Loop::addSubstation
)

internal object LoopToEnergizingSubstationResolver : ReferenceResolver by KReferenceResolver(
    Loop::class, Substation::class, Loop::addEnergizingSubstation
)

internal object LvFeederToNormalHeadTerminalResolver : ReferenceResolver by KReferenceResolver(
    LvFeeder::class, Terminal::class, LvFeeder::normalHeadTerminal.setter
)

internal object LvFeederToNormalEnergizingFeedersResolver : ReferenceResolver by KReferenceResolver(
    LvFeeder::class, Feeder::class, LvFeeder::addNormalEnergizingFeeder
)

internal object PowerElectronicsConnectionToPowerElectronicsConnectionPhaseResolver :
    ReferenceResolver by KReferenceResolver(
        PowerElectronicsConnection::class, PowerElectronicsConnectionPhase::class, PowerElectronicsConnection::addPhase
    )

internal object PowerElectronicsConnectionPhaseToPowerElectronicsConnectionResolver :
    ReferenceResolver by KReferenceResolver(
        PowerElectronicsConnectionPhase::class, PowerElectronicsConnection::class, PowerElectronicsConnectionPhase::powerElectronicsConnection.setter
    )

internal object PowerElectronicsConnectionToPowerElectronicsUnitResolver :
    ReferenceResolver by KReferenceResolver(
        PowerElectronicsConnection::class, PowerElectronicsUnit::class, PowerElectronicsConnection::addUnit
    )

internal object PowerElectronicsUnitToPowerElectronicsConnectionResolver :
    ReferenceResolver by KReferenceResolver(
        PowerElectronicsUnit::class, PowerElectronicsConnection::class, PowerElectronicsUnit::powerElectronicsConnection.setter
    )

internal object TapChangerToTapChangerControlResolver : ReferenceResolver by KReferenceResolver(
    TapChanger::class, TapChangerControl::class, TapChanger::tapChangerControl.setter
)

internal object TransformerEndToTransformerStarImpedanceResolver : ReferenceResolver by KReferenceResolver(
    TransformerEnd::class, TransformerStarImpedance::class, TransformerEnd::starImpedance.setter
)

internal object PowerTransformerInfoToTransformerTankInfoResolver : ReferenceResolver by KReferenceResolver(
    PowerTransformerInfo::class, TransformerTankInfo::class, PowerTransformerInfo::addTransformerTankInfo
)

internal object TransformerTankInfoToPowerTransformerInfoResolver : ReferenceResolver by KReferenceResolver(
    TransformerTankInfo::class, PowerTransformerInfo::class, TransformerTankInfo::powerTransformerInfo.setter
)

internal object TransformerTankInfoToTransformerEndInfoResolver : ReferenceResolver by KReferenceResolver(
    TransformerTankInfo::class, TransformerEndInfo::class, TransformerTankInfo::addTransformerEndInfo
)

internal object TransformerEndInfoToTransformerTankInfoResolver : ReferenceResolver by KReferenceResolver(
    TransformerEndInfo::class, TransformerTankInfo::class, TransformerEndInfo::transformerTankInfo.setter
)

internal object TransformerEndInfoToTransformerStarImpedanceResolver : ReferenceResolver by KReferenceResolver(
    TransformerEndInfo::class, TransformerStarImpedance::class, TransformerEndInfo::transformerStarImpedance.setter
)

internal object TransformerStarImpedanceToTransformerEndInfoResolver : ReferenceResolver by KReferenceResolver(
    TransformerStarImpedance::class, TransformerEndInfo::class, TransformerStarImpedance::transformerEndInfo.setter
)

internal object TransformerEndInfoToNoLoadTestResolver : ReferenceResolver by KReferenceResolver(
    TransformerEndInfo::class, NoLoadTest::class, TransformerEndInfo::energisedEndNoLoadTests.setter
)

internal object TransformerEndInfoToEnergisedEndShortCircuitTestResolver : ReferenceResolver by KReferenceResolver(
    TransformerEndInfo::class, ShortCircuitTest::class, TransformerEndInfo::energisedEndShortCircuitTests.setter
)

internal object TransformerEndInfoToGroundedEndShortCircuitTestResolver : ReferenceResolver by KReferenceResolver(
    TransformerEndInfo::class, ShortCircuitTest::class, TransformerEndInfo::groundedEndShortCircuitTests.setter
)

internal object TransformerEndInfoToOpenEndOpenCircuitTestResolver : ReferenceResolver by KReferenceResolver(
    TransformerEndInfo::class, OpenCircuitTest::class, TransformerEndInfo::openEndOpenCircuitTests.setter
)

internal object TransformerEndInfoToEnergisedEndOpenCircuitTestResolver : ReferenceResolver by KReferenceResolver(
    TransformerEndInfo::class, OpenCircuitTest::class, TransformerEndInfo::energisedEndOpenCircuitTests.setter
)

internal object ProtectionRelayFunctionToProtectedSwitchResolver : ReferenceResolver by KReferenceResolver(
    ProtectionRelayFunction::class, ProtectedSwitch::class, ProtectionRelayFunction::addProtectedSwitch
)

internal object ProtectedSwitchToProtectionRelayFunctionResolver : ReferenceResolver by KReferenceResolver(
    ProtectedSwitch::class, ProtectionRelayFunction::class, ProtectedSwitch::addRelayFunction
)

internal object ProtectionRelayFunctionToSensorResolver : ReferenceResolver by KReferenceResolver(
    ProtectionRelayFunction::class, Sensor::class, ProtectionRelayFunction::addSensor
)

internal object SensorToProtectionRelayFunctionResolver : ReferenceResolver by KReferenceResolver(
    Sensor::class, ProtectionRelayFunction::class, Sensor::addRelayFunction
)

internal object ProtectionRelayFunctionToProtectionRelaySchemeResolver : ReferenceResolver by KReferenceResolver(
    ProtectionRelayFunction::class, ProtectionRelayScheme::class, ProtectionRelayFunction::addScheme
)

internal object ProtectionRelaySchemeToProtectionRelayFunctionResolver : ReferenceResolver by KReferenceResolver(
    ProtectionRelayScheme::class, ProtectionRelayFunction::class, ProtectionRelayScheme::addFunction
)

internal object ProtectionRelaySchemeToProtectionRelaySystemResolver : ReferenceResolver by KReferenceResolver(
    ProtectionRelayScheme::class, ProtectionRelaySystem::class, ProtectionRelayScheme::system.setter
)

internal object ProtectionRelaySystemToProtectionRelaySchemeResolver : ReferenceResolver by KReferenceResolver(
    ProtectionRelaySystem::class, ProtectionRelayScheme::class, ProtectionRelaySystem::addScheme
)

internal object FuseToProtectionRelayFunctionResolver : ReferenceResolver by KReferenceResolver(
    Fuse::class, ProtectionRelayFunction::class, Fuse::function.setter
)

internal object ProtectionRelayFunctionToRelayInfoResolver : ReferenceResolver by KReferenceResolver(
    ProtectionRelayFunction::class, RelayInfo::class, ProtectionRelayFunction::assetInfo.setter
)

internal object SynchronousMachineToReactiveCapabilityCurveResolver : ReferenceResolver by KReferenceResolver(
    SynchronousMachine::class, ReactiveCapabilityCurve::class, SynchronousMachine::addCurve
)

//-------------------------------------------//

class KReferenceResolver(
    private val fromKClass: KClass,
    private val toKClass: KClass,
    private val resolveFun: (T, R) -> Unit
) : ReferenceResolver {

    override val fromClass: Class get() = fromKClass.java
    override val toClass: Class get() = toKClass.java

    override fun resolve(from: T, to: R) {
        resolveFun(from, to)
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy