diff --git a/controls-core/src/commonMain/kotlin/space/kscience/controls/spec/DeviceBase.kt b/controls-core/src/commonMain/kotlin/space/kscience/controls/spec/DeviceBase.kt index 5e07880..38aa20a 100644 --- a/controls-core/src/commonMain/kotlin/space/kscience/controls/spec/DeviceBase.kt +++ b/controls-core/src/commonMain/kotlin/space/kscience/controls/spec/DeviceBase.kt @@ -3,6 +3,7 @@ package space.kscience.controls.spec import kotlinx.coroutines.CoroutineName import kotlinx.coroutines.Job import kotlinx.coroutines.SupervisorJob +import kotlinx.coroutines.channels.BufferOverflow import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.flow.SharedFlow import kotlinx.coroutines.newCoroutineContext @@ -13,6 +14,8 @@ import space.kscience.dataforge.context.Context import space.kscience.dataforge.context.debug import space.kscience.dataforge.context.logger import space.kscience.dataforge.meta.Meta +import space.kscience.dataforge.meta.get +import space.kscience.dataforge.meta.int import space.kscience.dataforge.misc.DFExperimental import kotlin.coroutines.CoroutineContext @@ -47,7 +50,7 @@ private suspend fun DeviceActionSpec.executeWithMeta */ public abstract class DeviceBase( final override val context: Context, - override val meta: Meta = Meta.EMPTY, + final override val meta: Meta = Meta.EMPTY, ) : Device { /** @@ -76,7 +79,10 @@ public abstract class DeviceBase( */ private val logicalState: HashMap = HashMap() - private val sharedMessageFlow: MutableSharedFlow = MutableSharedFlow() + private val sharedMessageFlow: MutableSharedFlow = MutableSharedFlow( + replay = meta["message.buffer"].int ?: 1000, + onBufferOverflow = BufferOverflow.DROP_OLDEST + ) public override val messageFlow: SharedFlow get() = sharedMessageFlow