summaryrefslogtreecommitdiff
path: root/opendc-simulator/opendc-simulator-power/src
diff options
context:
space:
mode:
authorFabian Mastenbroek <mail.fabianm@gmail.com>2021-10-01 22:04:35 +0200
committerFabian Mastenbroek <mail.fabianm@gmail.com>2021-10-03 17:17:41 +0200
commit081221684fb826ab5a00c1d8cc5a9886b9e2203c (patch)
tree7f2202429256b4cb96812f96b682a021f8236180 /opendc-simulator/opendc-simulator-power/src
parent6e424e9b44687d01e618e7bc38afc427610cd845 (diff)
feat(simulator): Expose CPU time counters directly on hypervisor
This change adds a new interface to the SimHypervisor interface that exposes the CPU time counters directly. These are derived from the flow counters and will be used by SimHost to expose them via telemetry.
Diffstat (limited to 'opendc-simulator/opendc-simulator-power/src')
-rw-r--r--opendc-simulator/opendc-simulator-power/src/main/kotlin/org/opendc/simulator/power/SimPdu.kt8
-rw-r--r--opendc-simulator/opendc-simulator-power/src/main/kotlin/org/opendc/simulator/power/SimUps.kt6
2 files changed, 5 insertions, 9 deletions
diff --git a/opendc-simulator/opendc-simulator-power/src/main/kotlin/org/opendc/simulator/power/SimPdu.kt b/opendc-simulator/opendc-simulator-power/src/main/kotlin/org/opendc/simulator/power/SimPdu.kt
index d536f22d..9f88fecc 100644
--- a/opendc-simulator/opendc-simulator-power/src/main/kotlin/org/opendc/simulator/power/SimPdu.kt
+++ b/opendc-simulator/opendc-simulator-power/src/main/kotlin/org/opendc/simulator/power/SimPdu.kt
@@ -46,18 +46,14 @@ public class SimPdu(
/**
* The [FlowForwarder] that represents the input of the PDU.
*/
- private val forwarder = FlowForwarder(engine)
+ private val output = mux.newOutput()
/**
* Create a new PDU outlet.
*/
public fun newOutlet(): Outlet = Outlet(mux, mux.newInput())
- init {
- mux.addOutput(forwarder)
- }
-
- override fun createSource(): FlowSource = FlowMapper(forwarder) { _, rate ->
+ override fun createSource(): FlowSource = FlowMapper(output) { _, rate ->
val loss = computePowerLoss(rate)
rate + loss
}
diff --git a/opendc-simulator/opendc-simulator-power/src/main/kotlin/org/opendc/simulator/power/SimUps.kt b/opendc-simulator/opendc-simulator-power/src/main/kotlin/org/opendc/simulator/power/SimUps.kt
index 312f1d0f..46d659f8 100644
--- a/opendc-simulator/opendc-simulator-power/src/main/kotlin/org/opendc/simulator/power/SimUps.kt
+++ b/opendc-simulator/opendc-simulator-power/src/main/kotlin/org/opendc/simulator/power/SimUps.kt
@@ -42,19 +42,19 @@ public class SimUps(
/**
* The resource aggregator used to combine the input sources.
*/
- private val switch = MaxMinFlowMultiplexer(engine)
+ private val mux = MaxMinFlowMultiplexer(engine)
/**
* The [FlowConsumer] that represents the output of the UPS.
*/
- private val provider = switch.newInput()
+ private val provider = mux.newInput()
/**
* Create a new UPS outlet.
*/
public fun newInlet(): SimPowerInlet {
val forward = FlowForwarder(engine, isCoupled = true)
- switch.addOutput(forward)
+ forward.startConsumer(mux.newOutput())
return Inlet(forward)
}