fix plot extensions
This commit is contained in:
parent
53cc4dc0df
commit
70ab60f98c
@ -54,7 +54,7 @@ public abstract class DeviceConstructor(
|
|||||||
/**
|
/**
|
||||||
* Register a property and provide a direct reader for it
|
* 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,
|
state: S,
|
||||||
descriptorBuilder: PropertyDescriptor.() -> Unit = {},
|
descriptorBuilder: PropertyDescriptor.() -> Unit = {},
|
||||||
nameOverride: String? = null,
|
nameOverride: String? = null,
|
||||||
@ -104,7 +104,7 @@ public abstract class DeviceConstructor(
|
|||||||
/**
|
/**
|
||||||
* Create and register a virtual mutable property with optional [callback]
|
* Create and register a virtual mutable property with optional [callback]
|
||||||
*/
|
*/
|
||||||
public fun <T : Any> virtualProperty(
|
public fun <T> virtualProperty(
|
||||||
metaConverter: MetaConverter<T>,
|
metaConverter: MetaConverter<T>,
|
||||||
initialState: T,
|
initialState: T,
|
||||||
descriptorBuilder: PropertyDescriptor.() -> Unit = {},
|
descriptorBuilder: PropertyDescriptor.() -> Unit = {},
|
||||||
|
@ -28,7 +28,7 @@ public open class DeviceGroup(
|
|||||||
) : DeviceHub, CachingDevice {
|
) : DeviceHub, CachingDevice {
|
||||||
|
|
||||||
internal class Property(
|
internal class Property(
|
||||||
val state: DeviceState<out Any>,
|
val state: DeviceState<*>,
|
||||||
val descriptor: PropertyDescriptor,
|
val descriptor: PropertyDescriptor,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -82,7 +82,7 @@ public open class DeviceGroup(
|
|||||||
/**
|
/**
|
||||||
* Register a new property based on [DeviceState]. Properties could be modified dynamically
|
* 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()
|
val name = descriptor.name.parseAsName()
|
||||||
require(properties[name] == null) { "Can't add property with name $name. It already exists." }
|
require(properties[name] == null) { "Can't add property with name $name. It already exists." }
|
||||||
properties[name] = Property(state, descriptor)
|
properties[name] = Property(state, descriptor)
|
||||||
|
@ -50,7 +50,7 @@ public operator fun <T> MutableDeviceState<T>.setValue(thisRef: Any?, property:
|
|||||||
this.value = value
|
this.value = value
|
||||||
}
|
}
|
||||||
|
|
||||||
public var <T : Any> MutableDeviceState<T>.valueAsMeta: Meta
|
public var <T> MutableDeviceState<T>.valueAsMeta: Meta
|
||||||
get() = converter.convert(value)
|
get() = converter.convert(value)
|
||||||
set(arg) {
|
set(arg) {
|
||||||
value = converter.read(arg)
|
value = converter.read(arg)
|
||||||
|
@ -184,7 +184,6 @@ public fun Plot.plotBooleanState(
|
|||||||
private fun <T> Flow<T>.chunkedByPeriod(duration: Duration): Flow<List<T>> {
|
private fun <T> Flow<T>.chunkedByPeriod(duration: Duration): Flow<List<T>> {
|
||||||
val collector: ArrayDeque<T> = ArrayDeque<T>()
|
val collector: ArrayDeque<T> = ArrayDeque<T>()
|
||||||
return channelFlow {
|
return channelFlow {
|
||||||
coroutineScope {
|
|
||||||
launch {
|
launch {
|
||||||
while (isActive) {
|
while (isActive) {
|
||||||
delay(duration)
|
delay(duration)
|
||||||
@ -197,7 +196,6 @@ private fun <T> Flow<T>.chunkedByPeriod(duration: Duration): Flow<List<T>> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private fun List<Instant>.averageTime(): Instant {
|
private fun List<Instant>.averageTime(): Instant {
|
||||||
val min = min()
|
val min = min()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user