From 10575a6a72d24bc4e575c4a6410b6645f0cfe8a7 Mon Sep 17 00:00:00 2001 From: Geoffroy Jamgotchian Date: Mon, 28 Nov 2016 13:36:37 +0100 Subject: [PATCH] Add convenient method to get temporary limit value --- .../eu/itesla_project/iidm/network/CurrentLimits.java | 8 ++++++++ .../iidm/network/impl/CurrentLimitsImpl.java | 6 ++++++ 2 files changed, 14 insertions(+) diff --git a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/CurrentLimits.java b/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/CurrentLimits.java index c6699ed9..7580083c 100644 --- a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/CurrentLimits.java +++ b/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/CurrentLimits.java @@ -82,4 +82,12 @@ interface TemporaryLimit { * @return the temporary limit */ TemporaryLimit getTemporaryLimit(int acceptableDuration); + + /** + * Get a temporary limit value from its acceptable duration. Return NaN if there is non temporay limit with this + * acceptable duration. + * @param acceptableDuration acceptable duration in second + * @return the temporary limit value or NaN if there is no temporary limit for this acceptable duration + */ + float getTemporaryLimitValue(int acceptableDuration); } diff --git a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/CurrentLimitsImpl.java b/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/CurrentLimitsImpl.java index 66aeb904..7d034f97 100644 --- a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/CurrentLimitsImpl.java +++ b/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/CurrentLimitsImpl.java @@ -78,4 +78,10 @@ public Collection getTemporaryLimits() { public TemporaryLimit getTemporaryLimit(int acceptableDuration) { return temporaryLimits.get(acceptableDuration); } + + @Override + public float getTemporaryLimitValue(int acceptableDuration) { + TemporaryLimit tl = getTemporaryLimit(acceptableDuration); + return tl != null ? tl.getValue() : Float.NaN; + } }