|
7 | 7 | import java.time.ZonedDateTime;
|
8 | 8 | import java.time.temporal.ChronoUnit;
|
9 | 9 | import java.util.ArrayList;
|
10 |
| -import java.util.Arrays; |
11 | 10 | import java.util.Dictionary;
|
12 | 11 | import java.util.HashSet;
|
13 | 12 | import java.util.Hashtable;
|
|
43 | 42 | import io.openems.common.exceptions.OpenemsException;
|
44 | 43 | import io.openems.common.jsonrpc.request.CreateComponentConfigRequest;
|
45 | 44 | import io.openems.common.jsonrpc.request.DeleteComponentConfigRequest;
|
46 |
| -import io.openems.common.jsonrpc.request.UpdateComponentConfigRequest.Property; |
47 | 45 | import io.openems.common.session.Role;
|
48 | 46 | import io.openems.common.test.TimeLeapClock;
|
49 | 47 | import io.openems.common.timedata.Resolution;
|
@@ -182,8 +180,7 @@ private synchronized CompletableFuture<ExecuteSimulationResponse> handleExecuteS
|
182 | 180 | this.setCycleTime(AbstractWorker.ALWAYS_WAIT_FOR_TRIGGER_NEXT_RUN);
|
183 | 181 |
|
184 | 182 | // Create Ess.Power with disabled PID filter
|
185 |
| - this.componentManager.handleCreateComponentConfigRequest(user, |
186 |
| - new CreateComponentConfigRequest("Ess.Power", Arrays.asList(new Property("enablePid", false)))); |
| 183 | + this.updateEssPower(); |
187 | 184 |
|
188 | 185 | // Create Components
|
189 | 186 | Set<String> simulatorComponentIds = new HashSet<>();
|
@@ -328,7 +325,11 @@ private void deleteAllConfigurations(User user) throws OpenemsNamedException {
|
328 | 325 | }
|
329 | 326 | if (factoryPid.startsWith("Core.") //
|
330 | 327 | || factoryPid.startsWith("Controller.Api.") //
|
331 |
| - || factoryPid.startsWith("Predictor.")) { |
| 328 | + || factoryPid.startsWith("Predictor.") // |
| 329 | + // Ess.Power exists by default. We don't delete it, but will overwrite the |
| 330 | + // configuration later. Delete request for this component does not work for some |
| 331 | + // unknown reason. |
| 332 | + || factoryPid.equals("Ess.Power")) { |
332 | 333 | continue;
|
333 | 334 | }
|
334 | 335 | switch (factoryPid) {
|
@@ -401,6 +402,22 @@ private void setCycleTime(int cycleTime) {
|
401 | 402 | }
|
402 | 403 | }
|
403 | 404 |
|
| 405 | + /** |
| 406 | + * Sets the Ess.Power to the default settings for a simulation. |
| 407 | + * |
| 408 | + */ |
| 409 | + private void updateEssPower() { |
| 410 | + try { |
| 411 | + var config = this.cm.getConfiguration("Ess.Power", null); |
| 412 | + Dictionary<String, Object> properties = new Hashtable<>(); |
| 413 | + properties.put("enablePid", false); |
| 414 | + config.update(properties); |
| 415 | + } catch (IOException e) { |
| 416 | + this.logError(this.log, |
| 417 | + "Unable to configure Ess.Power enabledPid. " + e.getClass() + ": " + e.getMessage()); |
| 418 | + } |
| 419 | + } |
| 420 | + |
404 | 421 | private void waitForComponentsToActivate(Set<String> simulatorComponentIds) throws OpenemsException {
|
405 | 422 | // Wait for Components to appear
|
406 | 423 | for (var i = 0; i < 100; i++) {
|
|
0 commit comments