Class AbstractLimitsComputerWithCache<P,L>
- All Implemented Interfaces:
LimitsComputer<P,
L>
- Direct Known Subclasses:
AbstractLimitReductionsApplier
,LimitsComputer.NoModificationsImpl
Abstract class responsible for computing limits (potentially altered from the ones declared on the network element).
Already computed altered limits are stored in an internal cache to avoid unnecessary computations.
This cache should be cleared with clearCache()
when the reductions to apply are changed.
- Author:
- Olivier Perrin <olivier.perrin at rte-france.com>
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.powsybl.iidm.network.limitmodification.LimitsComputer
LimitsComputer.NoModificationsImpl
-
Field Summary
Fields inherited from interface com.powsybl.iidm.network.limitmodification.LimitsComputer
NO_MODIFICATIONS
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Clear the cache containing the already computed limits.computeLimits
(P processable, LimitType limitType, ThreeSides side, boolean monitoringOnly) Retrieve the limits ofprocessable
corresponding to the given limits type and side, then apply on them the modifications configured in the currentLimitsComputer
.protected abstract Optional<LimitsContainer<L>>
computeUncachedLimits
(P processable, LimitType limitType, ThreeSides side, boolean monitoringOnly) Retrieve the limits onprocessable
then apply modifications on them.protected void
putInCache
(P processable, LimitType limitType, ThreeSides side, boolean monitoringOnly, LimitsContainer<L> limitsContainer)
-
Constructor Details
-
AbstractLimitsComputerWithCache
protected AbstractLimitsComputerWithCache()
-
-
Method Details
-
computeLimits
public Optional<LimitsContainer<L>> computeLimits(P processable, LimitType limitType, ThreeSides side, boolean monitoringOnly) Retrieve the limits of
processable
corresponding to the given limits type and side, then apply on them the modifications configured in the currentLimitsComputer
.The result of this method contains both originals and altered limits.
Resulting limits are stored in an internal cache, by (identifier's ID, limit type, side), in order to avoid unnecessary re-computation. If needed, this cache can be cleared using
clearCache()
.- Specified by:
computeLimits
in interfaceLimitsComputer<P,
L> - Parameters:
processable
- The network element for which the reduced limits must be computedlimitType
- The type of the limits to processside
- The side ofprocessable
on which the limits should be retrievedmonitoringOnly
- Iftrue
, compute the limits to use for a monitoring only use case. Iffalse
, compute the limits to use for a monitoring + action use case.- Returns:
- an object containing the original limits and the altered ones
-
computeUncachedLimits
protected abstract Optional<LimitsContainer<L>> computeUncachedLimits(P processable, LimitType limitType, ThreeSides side, boolean monitoringOnly) Retrieve the limits on
processable
then apply modifications on them.If no modifications applies on the resulting
LimitsContainer
must contains the same object for the original and the reduced limits.This function is called when the corresponding limits were not found in the cache.
This function is responsible for the addition of the computed limit in the cache (via the
putInCache(P, com.powsybl.iidm.network.LimitType, com.powsybl.iidm.network.ThreeSides, boolean, com.powsybl.iidm.network.limitmodification.result.LimitsContainer<L>)
method).- Parameters:
processable
- the network element for which the limits must be retrieved and modifiedlimitType
- the type of limits to processside
- the side of the network element where to retrieve the original limitsmonitoringOnly
- Iftrue
, compute the limits to use for a monitoring only use case. Iffalse
, compute the limits to use for a monitoring + action use case.- Returns:
- an object containing both the original and the modified limits.
-
putInCache
protected void putInCache(P processable, LimitType limitType, ThreeSides side, boolean monitoringOnly, LimitsContainer<L> limitsContainer) -
clearCache
public void clearCache()Clear the cache containing the already computed limits.
This method must be called when the modifications to apply on the original limits of a network element are changed.
-