summaryrefslogtreecommitdiff
path: root/opendc-simulator/opendc-simulator-compute/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-compute/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-compute/src/main/java')
-rw-r--r--opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/cpu/SimCpu.java6
-rw-r--r--opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/machine/VirtualMachine.java6
-rw-r--r--opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/power/SimPowerSource.java6
-rw-r--r--opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/power/SimPsu.java6
4 files changed, 1 insertions, 23 deletions
diff --git a/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/cpu/SimCpu.java b/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/cpu/SimCpu.java
index ac3bff74..24627a9c 100644
--- a/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/cpu/SimCpu.java
+++ b/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/cpu/SimCpu.java
@@ -124,7 +124,7 @@ public final class SimCpu extends FlowNode implements FlowSupplier, FlowConsumer
// Calculate Power Demand and send to PSU
// TODO: look at the double / double thing
- double powerDemand = (double) this.cpuPowerModel.computePower((double) this.currentCpuUtilization);
+ double powerDemand = this.cpuPowerModel.computePower(this.currentCpuUtilization);
if (powerDemand != this.currentPowerDemand) {
this.pushDemand(this.psuEdge, powerDemand);
@@ -201,10 +201,6 @@ public final class SimCpu extends FlowNode implements FlowSupplier, FlowConsumer
*/
@Override
public void handleDemand(FlowEdge consumerEdge, double newCpuDemand) {
- if (newCpuDemand == this.currentCpuDemand) {
- return;
- }
-
updateCounters();
this.currentCpuDemand = newCpuDemand;
this.currentCpuUtilization = this.currentCpuDemand / this.maxCapacity;
diff --git a/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/machine/VirtualMachine.java b/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/machine/VirtualMachine.java
index 21f59cf6..0557165b 100644
--- a/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/machine/VirtualMachine.java
+++ b/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/machine/VirtualMachine.java
@@ -202,9 +202,6 @@ public class VirtualMachine extends FlowNode implements FlowConsumer, FlowSuppli
**/
@Override
public void handleDemand(FlowEdge consumerEdge, double newDemand) {
- if (this.cpuDemand == newDemand) {
- return;
- }
updateCounters(this.clock.millis());
this.cpuDemand = newDemand;
@@ -217,9 +214,6 @@ public class VirtualMachine extends FlowNode implements FlowConsumer, FlowSuppli
**/
@Override
public void handleSupply(FlowEdge supplierEdge, double newCpuSupply) {
- if (newCpuSupply == this.cpuSupply) {
- return;
- }
updateCounters(this.clock.millis());
this.cpuSupply = newCpuSupply;
diff --git a/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/power/SimPowerSource.java b/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/power/SimPowerSource.java
index 2c953d06..a219d4e6 100644
--- a/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/power/SimPowerSource.java
+++ b/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/power/SimPowerSource.java
@@ -163,9 +163,6 @@ public final class SimPowerSource extends FlowNode implements FlowSupplier {
@Override
public void handleDemand(FlowEdge consumerEdge, double newPowerDemand) {
- if (newPowerDemand == this.powerDemand) {
- return;
- }
this.powerDemand = newPowerDemand;
this.invalidate();
@@ -173,9 +170,6 @@ public final class SimPowerSource extends FlowNode implements FlowSupplier {
@Override
public void pushSupply(FlowEdge consumerEdge, double newSupply) {
- if (newSupply == this.powerSupplied) {
- return;
- }
this.powerSupplied = newSupply;
consumerEdge.pushSupply(newSupply);
diff --git a/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/power/SimPsu.java b/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/power/SimPsu.java
index 436c5c12..709d3e15 100644
--- a/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/power/SimPsu.java
+++ b/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/power/SimPsu.java
@@ -148,9 +148,6 @@ public final class SimPsu extends FlowNode implements FlowSupplier, FlowConsumer
@Override
public void handleDemand(FlowEdge consumerEdge, double newPowerDemand) {
- if (newPowerDemand == this.powerDemand) {
- return;
- }
updateCounters();
this.powerDemand = newPowerDemand;
@@ -160,9 +157,6 @@ public final class SimPsu extends FlowNode implements FlowSupplier, FlowConsumer
@Override
public void handleSupply(FlowEdge supplierEdge, double newPowerSupply) {
- if (newPowerSupply == this.powerSupplied) {
- return;
- }
updateCounters();
this.powerSupplied = newPowerSupply;