From d249d45540b87bb079b361c0cf6331316c1b2c4d Mon Sep 17 00:00:00 2001 From: Mathieu DEHARBE Date: Wed, 4 Sep 2024 15:24:09 +0200 Subject: [PATCH] small refect on BatteryField Signed-off-by: Mathieu DEHARBE --- .../formula/equipmentfield/BatteryField.java | 38 +++++-------------- 1 file changed, 9 insertions(+), 29 deletions(-) diff --git a/src/main/java/org/gridsuite/modification/server/dto/formula/equipmentfield/BatteryField.java b/src/main/java/org/gridsuite/modification/server/dto/formula/equipmentfield/BatteryField.java index cf94bb81f..703d44066 100644 --- a/src/main/java/org/gridsuite/modification/server/dto/formula/equipmentfield/BatteryField.java +++ b/src/main/java/org/gridsuite/modification/server/dto/formula/equipmentfield/BatteryField.java @@ -43,47 +43,27 @@ public static Double getReferenceValue(Battery battery, String batteryField) { public static void setNewValue(Battery battery, String batteryField, Double newValue) { BatteryField field = BatteryField.valueOf(batteryField); + final AttributeModification modif = new AttributeModification<>(newValue, OperationType.SET); switch (field) { case MINIMUM_ACTIVE_POWER -> - modifyBatteryActiveLimitsAttributes( - null, - new AttributeModification<>(newValue, OperationType.SET), - battery, - null); + modifyBatteryActiveLimitsAttributes(null, modif, battery, null); case MAXIMUM_ACTIVE_POWER -> - modifyBatteryActiveLimitsAttributes( - new AttributeModification<>(newValue, OperationType.SET), - null, - battery, - null); + modifyBatteryActiveLimitsAttributes(modif, null, battery, null); case ACTIVE_POWER_SET_POINT -> { ModificationUtils.getInstance().checkActivePowerZeroOrBetweenMinAndMaxActivePower( - new AttributeModification<>(newValue, OperationType.SET), - null, - null, - battery.getMinP(), - battery.getMaxP(), - battery.getTargetP(), - MODIFY_GENERATOR_ERROR, - "Battery '" + battery.getId() + "' : " + modif, null, null, battery.getMinP(), + battery.getMaxP(), battery.getTargetP(), MODIFY_GENERATOR_ERROR, "Battery '" + battery.getId() + "' : " ); - modifyBatterySetpointsAttributes( - new AttributeModification<>(newValue, OperationType.SET), null, null, null, - battery, null); + modifyBatterySetpointsAttributes(modif, null, null, null, battery, null); } case REACTIVE_POWER_SET_POINT -> modifyBatterySetpointsAttributes( - null, new AttributeModification<>(newValue, OperationType.SET), null, null, - battery, null); + null, modif, null, null, battery, null); case DROOP -> { ActivePowerControl activePowerControl = battery.getExtension(ActivePowerControl.class); ActivePowerControlAdder activePowerControlAdder = battery.newExtension(ActivePowerControlAdder.class); ModificationUtils.getInstance().modifyActivePowerControlAttributes( - activePowerControl, - activePowerControlAdder, - null, - new AttributeModification<>(newValue.floatValue(), OperationType.SET), - null, - null); + activePowerControl, activePowerControlAdder, null, + new AttributeModification<>(newValue.floatValue(), OperationType.SET), null, null); } } }