From 279f2a3e54c5b25b58e187a7c89bbddabe5b2724 Mon Sep 17 00:00:00 2001 From: Dante Niewenhuis Date: Thu, 7 Nov 2024 20:05:54 +0100 Subject: Fixed power source bug (#265) * Fixed a small bug making the power source not update energy usage properly * small update to the test --- .../src/main/java/org/opendc/simulator/Multiplexer.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'opendc-simulator/opendc-simulator-flow/src/main/java/org') diff --git a/opendc-simulator/opendc-simulator-flow/src/main/java/org/opendc/simulator/Multiplexer.java b/opendc-simulator/opendc-simulator-flow/src/main/java/org/opendc/simulator/Multiplexer.java index a87ded8d..25dc564f 100644 --- a/opendc-simulator/opendc-simulator-flow/src/main/java/org/opendc/simulator/Multiplexer.java +++ b/opendc-simulator/opendc-simulator-flow/src/main/java/org/opendc/simulator/Multiplexer.java @@ -130,6 +130,8 @@ public class Multiplexer extends FlowNode implements FlowSupplier, FlowConsumer this.consumerEdges.add(consumerEdge); this.demands.add(0.0); this.supplies.add(0.0); + + this.invalidate(); } @Override @@ -137,6 +139,8 @@ public class Multiplexer extends FlowNode implements FlowSupplier, FlowConsumer this.supplierEdge = supplierEdge; this.capacity = supplierEdge.getCapacity(); this.totalSupply = 0; + + this.invalidate(); } @Override @@ -176,15 +180,12 @@ public class Multiplexer extends FlowNode implements FlowSupplier, FlowConsumer demands.set(idx, newDemand); this.totalDemand += (newDemand - prevDemand); + this.invalidate(); } @Override public void handleSupply(FlowEdge supplierEdge, double newSupply) { - if (newSupply == this.totalSupply) { - return; - } - - this.totalSupply = newSupply; + this.invalidate(); } @Override -- cgit v1.2.3