summaryrefslogtreecommitdiff
path: root/opendc/opendc-core/src
diff options
context:
space:
mode:
authorGeorgios Andreadis <g.andreadis@student.tudelft.nl>2020-03-11 12:16:10 +0100
committerGeorgios Andreadis <g.andreadis@student.tudelft.nl>2020-03-11 12:16:10 +0100
commit1ccfcb28bb91c9dc456a1f324a0be6300086eb28 (patch)
treeb03bbf6dc69cc2d2c7fcfda1ad0b081c91443312 /opendc/opendc-core/src
parent2dd2bfe87bcbe368f46ce8e975ccccbfac2c0560 (diff)
parent1200816b7bf5c76b6bbb91b7e4555e9f04ea1af9 (diff)
Merge branch 'feat/2.x-power-model' into '2.x'
Implement basic power usage model See merge request opendc/opendc-simulator!36
Diffstat (limited to 'opendc/opendc-core/src')
-rw-r--r--opendc/opendc-core/src/main/kotlin/com/atlarge/opendc/core/power/PowerModel.kt32
-rw-r--r--opendc/opendc-core/src/main/kotlin/com/atlarge/opendc/core/power/Powerable.kt37
2 files changed, 69 insertions, 0 deletions
diff --git a/opendc/opendc-core/src/main/kotlin/com/atlarge/opendc/core/power/PowerModel.kt b/opendc/opendc-core/src/main/kotlin/com/atlarge/opendc/core/power/PowerModel.kt
new file mode 100644
index 00000000..51c9f379
--- /dev/null
+++ b/opendc/opendc-core/src/main/kotlin/com/atlarge/opendc/core/power/PowerModel.kt
@@ -0,0 +1,32 @@
+/*
+ * MIT License
+ *
+ * Copyright (c) 2020 atlarge-research
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+package com.atlarge.opendc.core.power
+
+import kotlinx.coroutines.flow.Flow
+
+/**
+ * A model for computing the power draw based on some value.
+ */
+public typealias PowerModel<T> = (T) -> Flow<Double>
diff --git a/opendc/opendc-core/src/main/kotlin/com/atlarge/opendc/core/power/Powerable.kt b/opendc/opendc-core/src/main/kotlin/com/atlarge/opendc/core/power/Powerable.kt
new file mode 100644
index 00000000..4473a571
--- /dev/null
+++ b/opendc/opendc-core/src/main/kotlin/com/atlarge/opendc/core/power/Powerable.kt
@@ -0,0 +1,37 @@
+/*
+ * MIT License
+ *
+ * Copyright (c) 2020 atlarge-research
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+package com.atlarge.opendc.core.power
+
+import kotlinx.coroutines.flow.Flow
+
+/**
+ * An entity that is uses power from some power source.
+ */
+public interface Powerable {
+ /**
+ * The power draw at the device's power supply in watts (W).w
+ */
+ val powerDraw: Flow<Double>
+}