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

com.powsybl.metrix.integration.ProbabilityContingencyDslExtension.groovy Maven / Gradle / Ivy

The newest version!
/*
 * Copyright (c) 2020, RTE (http://www.rte-france.com)
 * 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 http://mozilla.org/MPL/2.0/.
 * SPDX-License-Identifier: MPL-2.0
 */
package com.powsybl.metrix.integration

import com.google.auto.service.AutoService
import com.powsybl.commons.extensions.Extension
import com.powsybl.contingency.Contingency
import com.powsybl.contingency.dsl.ContingencyDslExtension
import com.powsybl.metrix.integration.contingency.Probability

/**
 * @author Paul Bui-Quang {@literal }
 */
@AutoService(ContingencyDslExtension.class)
class ProbabilityContingencyDslExtension implements ContingencyDslExtension {
    @Override
    Class getExtendableClass() {
        return Contingency.class
    }

    @Override
    void addToSpec(MetaClass extSpecMetaClass, List> contingencyExtensions, Binding binding) {
        extSpecMetaClass.probability = { Closure closure ->
            def cloned = closure.clone()
            ProbabilitySpec spec = new ProbabilitySpec()
            cloned.delegate = spec
            cloned()

            contingencyExtensions.add(new Probability(spec.base, spec.tsName))
        }
    }

    static class ProbabilitySpec {
        Double base
        String tsName

        void base(Double base) {
            this.base = base
        }

        void tsName(String tsName) {
            this.tsName = tsName
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy