diff options
| author | Fabian Mastenbroek <mail.fabianm@gmail.com> | 2020-03-10 23:36:25 +0100 |
|---|---|---|
| committer | Fabian Mastenbroek <mail.fabianm@gmail.com> | 2020-03-10 23:36:25 +0100 |
| commit | 4e127b7cef0bbc186766af9631f538992ff7dfaf (patch) | |
| tree | 2484d70223c6135cd1be41dafd65ed6971134658 /opendc/opendc-core/src/main | |
| parent | ea601024d9ec1f03e9bc081de91874b11181548d (diff) | |
feat: Implement basic power model
Diffstat (limited to 'opendc/opendc-core/src/main')
| -rw-r--r-- | opendc/opendc-core/src/main/kotlin/com/atlarge/opendc/core/power/PowerModel.kt | 32 | ||||
| -rw-r--r-- | opendc/opendc-core/src/main/kotlin/com/atlarge/opendc/core/power/Powerable.kt | 37 |
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..203bf520 --- /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 of the device. + */ + val powerDraw: Flow<Double> +} |
