From c9531df8de460f80919a37c24fd9c5f7e870d998 Mon Sep 17 00:00:00 2001 From: Stefan Feilmeier Date: Sat, 19 Oct 2024 23:01:22 +0200 Subject: [PATCH 1/3] Change `JavadocParagraph` to `allowNewlineParagraph` --- cnf/checkstyle.xml | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/cnf/checkstyle.xml b/cnf/checkstyle.xml index ad22318becf..6ed4ad0febb 100644 --- a/cnf/checkstyle.xml +++ b/cnf/checkstyle.xml @@ -23,8 +23,8 @@ - + @@ -47,9 +47,9 @@ + - @@ -107,8 +107,8 @@ - + @@ -144,9 +144,9 @@ + - @@ -179,12 +179,10 @@ - - - + - + @@ -206,15 +204,15 @@ - + - + From c1a016cb1f1c597fa325043a6edbedfc063f0064 Mon Sep 17 00:00:00 2001 From: Stefan Feilmeier Date: Sat, 19 Oct 2024 23:03:21 +0200 Subject: [PATCH 2/3] Fix ControllerEssGridOptimizedChargeImplTest Fixes Checstyle `Checks that overloaded methods are grouped together. Overloaded methods have the samename but different signatures where the signature can differ by the number ofinput parameters or type of input parameters or both. ` --- ...trollerEssGridOptimizedChargeImplTest.java | 148 +++++++++--------- 1 file changed, 74 insertions(+), 74 deletions(-) diff --git a/io.openems.edge.controller.ess.gridoptimizedcharge/test/io/openems/edge/controller/ess/gridoptimizedcharge/ControllerEssGridOptimizedChargeImplTest.java b/io.openems.edge.controller.ess.gridoptimizedcharge/test/io/openems/edge/controller/ess/gridoptimizedcharge/ControllerEssGridOptimizedChargeImplTest.java index 7ac9440a6ba..862b0955d56 100644 --- a/io.openems.edge.controller.ess.gridoptimizedcharge/test/io/openems/edge/controller/ess/gridoptimizedcharge/ControllerEssGridOptimizedChargeImplTest.java +++ b/io.openems.edge.controller.ess.gridoptimizedcharge/test/io/openems/edge/controller/ess/gridoptimizedcharge/ControllerEssGridOptimizedChargeImplTest.java @@ -1444,80 +1444,6 @@ private void testLogic(String description, Integer[] productionPrediction, Integ }); } - private DelayChargeResultState testOneDay(String testDescription, Integer[] productionPrediction, - Integer[] consumptionPrediction, int soc, Optional targetMinuteOpt, int capacity, - int maxApparentPower, int allowedChargePower, DelayChargeRiskLevel riskLevel, Integer[] productionActual, - Integer[] consumptionActual, float resultBuffer) { - DelayChargeResultState resultState; - DelayChargeResult newLogic = ControllerEssGridOptimizedChargeImplTest.testOneDay(testDescription, - productionPrediction, consumptionPrediction, soc, targetMinuteOpt, capacity, maxApparentPower, - allowedChargePower, riskLevel, productionActual, consumptionActual, false); - - DelayChargeResult oldLogic = ControllerEssGridOptimizedChargeImplTest.testOneDay(testDescription, - productionPrediction, consumptionPrediction, soc, targetMinuteOpt, capacity, maxApparentPower, - allowedChargePower, riskLevel, productionActual, consumptionActual, true); - - if (newLogic.getFinalSoc() + resultBuffer < oldLogic.getFinalSoc()) { - resultState = DelayChargeResultState.WARNING; - } else if (newLogic.getFinalSoc() - resultBuffer > oldLogic.getFinalSoc()) { - resultState = DelayChargeResultState.PERFECT; - } else { - resultState = DelayChargeResultState.OK; - } - - float unefficientEnergy = Math - .round(newLogic.getChargedEnergyWithLowPower() / newLogic.getChargedEnergy() * 1000) / 10.0f; - float unefficientEnergyOld = Math - .round(oldLogic.getChargedEnergyWithLowPower() / oldLogic.getChargedEnergy() * 1000) / 10.0f; - System.out.println(resultState.text + "\t" + testDescription + " \t(New: " - + Math.round(newLogic.getFinalSoc() * 100) / 100.0 + " | Old: " - + Math.round(oldLogic.getFinalSoc() * 100) / 100.0 + ") \t Energy: (New: " - + newLogic.getChargedEnergy() + "[" + newLogic.getChargedEnergyWithLowPower() + " -> " - + unefficientEnergy + "%] | Old: " + oldLogic.getChargedEnergy() + "[" - + oldLogic.getChargedEnergyWithLowPower() + " -> " + unefficientEnergyOld + "%])"); - - // fail("New logic results in a lower SoC (New: " + newLogic.getFinalSoc() + " | - // Old: "+ oldLogic.getFinalSoc() + ") - " + testDescription); - return resultState; - } - - private static class DelayChargeResult { - - private float finalSoc; - private float chargedEnergy; - private float chargedEnergyWithLowPower; - - public DelayChargeResult(float finalSoc, float chargedEnergy, float chargedEnergyWithLowPower) { - this.finalSoc = finalSoc; - this.chargedEnergy = chargedEnergy; - this.chargedEnergyWithLowPower = chargedEnergyWithLowPower; - } - - public float getFinalSoc() { - return this.finalSoc; - } - - public float getChargedEnergy() { - return this.chargedEnergy; - } - - public float getChargedEnergyWithLowPower() { - return this.chargedEnergyWithLowPower; - } - } - - private static enum DelayChargeResultState { - OK("OK - SoC as bevore"), // - WARNING("WARNING - Lower SoC"), // - PERFECT("PERFECT - Higher SoC"); - - private String text; - - DelayChargeResultState(String text) { - this.text = text; - } - } - @SuppressWarnings("deprecation") private static DelayChargeResult testOneDay(String testDescription, Integer[] productionPrediction, Integer[] consumptionPrediction, int soc, Optional targetMinuteOpt, int capacity, @@ -1658,6 +1584,80 @@ private static DelayChargeResult testOneDay(String testDescription, Integer[] pr return new DelayChargeResult(socFloat, totoalActivePower * 0.25f, totoalActivePowerLessEfficiency * 0.25f); } + private DelayChargeResultState testOneDay(String testDescription, Integer[] productionPrediction, + Integer[] consumptionPrediction, int soc, Optional targetMinuteOpt, int capacity, + int maxApparentPower, int allowedChargePower, DelayChargeRiskLevel riskLevel, Integer[] productionActual, + Integer[] consumptionActual, float resultBuffer) { + DelayChargeResultState resultState; + DelayChargeResult newLogic = ControllerEssGridOptimizedChargeImplTest.testOneDay(testDescription, + productionPrediction, consumptionPrediction, soc, targetMinuteOpt, capacity, maxApparentPower, + allowedChargePower, riskLevel, productionActual, consumptionActual, false); + + DelayChargeResult oldLogic = ControllerEssGridOptimizedChargeImplTest.testOneDay(testDescription, + productionPrediction, consumptionPrediction, soc, targetMinuteOpt, capacity, maxApparentPower, + allowedChargePower, riskLevel, productionActual, consumptionActual, true); + + if (newLogic.getFinalSoc() + resultBuffer < oldLogic.getFinalSoc()) { + resultState = DelayChargeResultState.WARNING; + } else if (newLogic.getFinalSoc() - resultBuffer > oldLogic.getFinalSoc()) { + resultState = DelayChargeResultState.PERFECT; + } else { + resultState = DelayChargeResultState.OK; + } + + float unefficientEnergy = Math + .round(newLogic.getChargedEnergyWithLowPower() / newLogic.getChargedEnergy() * 1000) / 10.0f; + float unefficientEnergyOld = Math + .round(oldLogic.getChargedEnergyWithLowPower() / oldLogic.getChargedEnergy() * 1000) / 10.0f; + System.out.println(resultState.text + "\t" + testDescription + " \t(New: " + + Math.round(newLogic.getFinalSoc() * 100) / 100.0 + " | Old: " + + Math.round(oldLogic.getFinalSoc() * 100) / 100.0 + ") \t Energy: (New: " + + newLogic.getChargedEnergy() + "[" + newLogic.getChargedEnergyWithLowPower() + " -> " + + unefficientEnergy + "%] | Old: " + oldLogic.getChargedEnergy() + "[" + + oldLogic.getChargedEnergyWithLowPower() + " -> " + unefficientEnergyOld + "%])"); + + // fail("New logic results in a lower SoC (New: " + newLogic.getFinalSoc() + " | + // Old: "+ oldLogic.getFinalSoc() + ") - " + testDescription); + return resultState; + } + + private static class DelayChargeResult { + + private float finalSoc; + private float chargedEnergy; + private float chargedEnergyWithLowPower; + + public DelayChargeResult(float finalSoc, float chargedEnergy, float chargedEnergyWithLowPower) { + this.finalSoc = finalSoc; + this.chargedEnergy = chargedEnergy; + this.chargedEnergyWithLowPower = chargedEnergyWithLowPower; + } + + public float getFinalSoc() { + return this.finalSoc; + } + + public float getChargedEnergy() { + return this.chargedEnergy; + } + + public float getChargedEnergyWithLowPower() { + return this.chargedEnergyWithLowPower; + } + } + + private static enum DelayChargeResultState { + OK("OK - SoC as bevore"), // + WARNING("WARNING - Lower SoC"), // + PERFECT("PERFECT - Higher SoC"); + + private String text; + + DelayChargeResultState(String text) { + this.text = text; + } + } + @Test public void calculateAvailEnergy_test() throws Exception { final var clock = new TimeLeapClock(Instant.parse("2020-01-01T08:00:00.00Z"), ZoneOffset.UTC); From 4ed83b4b420cf63bb32a445a25fe1d4ade84983d Mon Sep 17 00:00:00 2001 From: Stefan Feilmeier Date: Sat, 19 Oct 2024 23:08:11 +0200 Subject: [PATCH 3/3] Update checkstyle to 10.18.2 --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 82249fb14f2..ad224209fd9 100644 --- a/build.gradle +++ b/build.gradle @@ -68,7 +68,7 @@ subprojects { } checkstyle { - toolVersion = '10.11.0' + toolVersion = '10.18.2' configFile = file("${rootDir}/cnf/checkstyle.xml") maxWarnings = 0 ignoreFailures = false