diff --git a/controls-core/src/commonMain/kotlin/space/kscience/controls/misc/PropertyHistory.kt b/controls-core/src/commonMain/kotlin/space/kscience/controls/misc/PropertyHistory.kt index 96bd8d5..092d9bb 100644 --- a/controls-core/src/commonMain/kotlin/space/kscience/controls/misc/PropertyHistory.kt +++ b/controls-core/src/commonMain/kotlin/space/kscience/controls/misc/PropertyHistory.kt @@ -10,6 +10,7 @@ import space.kscience.controls.api.PropertyChangedMessage import space.kscience.controls.spec.DevicePropertySpec import space.kscience.controls.spec.name import space.kscience.dataforge.meta.MetaConverter +import space.kscience.dataforge.names.Name /** * An interface for device property history. @@ -34,6 +35,7 @@ public interface PropertyHistory { public class CollectedPropertyHistory( public val scope: CoroutineScope, eventFlow: Flow, + public val deviceName: Name, public val propertyName: String, public val converter: MetaConverter, maxSize: Int = 1000, @@ -41,7 +43,7 @@ public class CollectedPropertyHistory( private val store: SharedFlow> = eventFlow .filterIsInstance() - .filter { it.property == propertyName } + .filter { it.sourceDevice == deviceName && it.property == propertyName } .map { ValueWithTime(converter.read(it.value), it.time) } .shareIn(scope, started = SharingStarted.Eagerly, replay = maxSize) @@ -54,13 +56,15 @@ public class CollectedPropertyHistory( */ public fun Device.collectPropertyHistory( scope: CoroutineScope = this, + deviceName: Name, propertyName: String, converter: MetaConverter, maxSize: Int = 1000, -): PropertyHistory = CollectedPropertyHistory(scope, messageFlow, propertyName, converter, maxSize) +): PropertyHistory = CollectedPropertyHistory(scope, messageFlow, deviceName, propertyName, converter, maxSize) public fun D.collectPropertyHistory( scope: CoroutineScope = this, + deviceName: Name, spec: DevicePropertySpec, maxSize: Int = 1000, -): PropertyHistory = collectPropertyHistory(scope, spec.name, spec.converter, maxSize) \ No newline at end of file +): PropertyHistory = collectPropertyHistory(scope, deviceName, spec.name, spec.converter, maxSize) \ No newline at end of file