com.powsybl.iidm.network.extensions.util.MeasurementValidationUtil Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of powsybl-iidm-extensions Show documentation
Show all versions of powsybl-iidm-extensions Show documentation
A set of IIDM common extensions
/**
* Copyright (c) 2021, 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/.
*/
package com.powsybl.iidm.network.extensions.util;
import com.powsybl.commons.PowsyblException;
import com.powsybl.iidm.network.Connectable;
import com.powsybl.iidm.network.Injection;
import com.powsybl.iidm.network.extensions.Measurement;
import com.powsybl.iidm.network.extensions.Measurements;
import static com.powsybl.iidm.network.extensions.Measurement.Type.OTHER;
/**
* @author Miora Ralambotiana
*/
public final class MeasurementValidationUtil {
public static > void checkId(String id, Measurements measurements) {
if (id != null && measurements.getMeasurement(id) != null) {
throw new PowsyblException(String.format("There is already a measurement with ID %s", id));
}
}
public static void checkValue(double value, boolean valid) {
if (Double.isNaN(value) && valid) {
throw new PowsyblException("Valid measurement can not have an undefined value");
}
}
public static > void checkSide(Measurement.Type type, Measurement.Side side, Connectable c) {
if (side != null && c instanceof Injection) {
throw new PowsyblException("Inconsistent side for measurement of injection");
} else if (side == null && type != OTHER && !(c instanceof Injection)) {
throw new PowsyblException("Inconsistent null side for measurement of branch or three windings transformer");
}
}
private MeasurementValidationUtil() {
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy