summaryrefslogtreecommitdiff
path: root/opendc-simulator/opendc-simulator-flow/src/main/java
diff options
context:
space:
mode:
authorDante Niewenhuis <d.niewenhuis@hotmail.com>2024-11-07 20:05:54 +0100
committerGitHub <noreply@github.com>2024-11-07 20:05:54 +0100
commit279f2a3e54c5b25b58e187a7c89bbddabe5b2724 (patch)
treecd149bca6a6db40c750d6add5a4973a1c18eb184 /opendc-simulator/opendc-simulator-flow/src/main/java
parent4e8ca5d246d72e16a8adaf02ccf4ac02f23977c8 (diff)
Fixed power source bug (#265)
* Fixed a small bug making the power source not update energy usage properly * small update to the test
Diffstat (limited to 'opendc-simulator/opendc-simulator-flow/src/main/java')
-rw-r--r--opendc-simulator/opendc-simulator-flow/src/main/java/org/opendc/simulator/Multiplexer.java11
1 files changed, 6 insertions, 5 deletions
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