fix plot extensions

This commit is contained in:
Alexander Nozik 2024-03-18 17:15:39 +03:00
parent 53cc4dc0df
commit 70ab60f98c
4 changed files with 14 additions and 16 deletions

View File

@ -54,7 +54,7 @@ public abstract class DeviceConstructor(
/**
* Register a property and provide a direct reader for it
*/
public fun <T : Any, S: DeviceState<T>> property(
public fun <T, S: DeviceState<T>> property(
state: S,
descriptorBuilder: PropertyDescriptor.() -> Unit = {},
nameOverride: String? = null,
@ -104,7 +104,7 @@ public abstract class DeviceConstructor(
/**
* Create and register a virtual mutable property with optional [callback]
*/
public fun <T : Any> virtualProperty(
public fun <T> virtualProperty(
metaConverter: MetaConverter<T>,
initialState: T,
descriptorBuilder: PropertyDescriptor.() -> Unit = {},

View File

@ -28,7 +28,7 @@ public open class DeviceGroup(
) : DeviceHub, CachingDevice {
internal class Property(
val state: DeviceState<out Any>,
val state: DeviceState<*>,
val descriptor: PropertyDescriptor,
)
@ -82,7 +82,7 @@ public open class DeviceGroup(
/**
* Register a new property based on [DeviceState]. Properties could be modified dynamically
*/
public fun registerProperty(descriptor: PropertyDescriptor, state: DeviceState<out Any>) {
public fun registerProperty(descriptor: PropertyDescriptor, state: DeviceState<*>) {
val name = descriptor.name.parseAsName()
require(properties[name] == null) { "Can't add property with name $name. It already exists." }
properties[name] = Property(state, descriptor)

View File

@ -50,7 +50,7 @@ public operator fun <T> MutableDeviceState<T>.setValue(thisRef: Any?, property:
this.value = value
}
public var <T : Any> MutableDeviceState<T>.valueAsMeta: Meta
public var <T> MutableDeviceState<T>.valueAsMeta: Meta
get() = converter.convert(value)
set(arg) {
value = converter.read(arg)

View File

@ -184,7 +184,6 @@ public fun Plot.plotBooleanState(
private fun <T> Flow<T>.chunkedByPeriod(duration: Duration): Flow<List<T>> {
val collector: ArrayDeque<T> = ArrayDeque<T>()
return channelFlow {
coroutineScope {
launch {
while (isActive) {
delay(duration)
@ -197,7 +196,6 @@ private fun <T> Flow<T>.chunkedByPeriod(duration: Duration): Flow<List<T>> {
}
}
}
}
private fun List<Instant>.averageTime(): Instant {
val min = min()