Add JVM application for constructor demo
This commit is contained in:
parent
1414cf5a2f
commit
984e7f12ef
@ -4,11 +4,11 @@ import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.flow.launchIn
|
||||
import kotlinx.coroutines.flow.onEach
|
||||
import kotlinx.datetime.Clock
|
||||
import space.kscience.controls.api.Device
|
||||
import space.kscience.controls.api.propertyMessageFlow
|
||||
import space.kscience.controls.constructor.DeviceState
|
||||
import space.kscience.controls.manager.clock
|
||||
import space.kscience.dataforge.context.Context
|
||||
import space.kscience.dataforge.meta.ListValue
|
||||
import space.kscience.dataforge.meta.Meta
|
||||
import space.kscience.dataforge.meta.Null
|
||||
@ -44,13 +44,14 @@ public fun Plot.plotDeviceProperty(
|
||||
}
|
||||
|
||||
public fun Plot.plotDeviceState(
|
||||
scope: CoroutineScope,
|
||||
context: Context,
|
||||
state: DeviceState<out Number>,
|
||||
pointsNumber: Int = 400,
|
||||
configuration: Scatter.() -> Unit = {},
|
||||
): Job = scatter(configuration).run {
|
||||
val clock = context.clock
|
||||
state.valueFlow.onEach {
|
||||
x.strings = (x.strings + Clock.System.now().toString()).takeLast(pointsNumber)
|
||||
x.strings = (x.strings + clock.now().toString()).takeLast(pointsNumber)
|
||||
y.numbers = (y.numbers + it).takeLast(pointsNumber)
|
||||
}.launchIn(scope)
|
||||
}.launchIn(context)
|
||||
}
|
@ -4,7 +4,7 @@ plugins {
|
||||
}
|
||||
|
||||
kscience {
|
||||
fullStack("js/constructor.js")
|
||||
fullStack("js/constructor.js", jvmConfig = {withJava()})
|
||||
useKtor()
|
||||
dependencies {
|
||||
api(projects.controlsVision)
|
||||
|
@ -79,7 +79,7 @@ public fun main() {
|
||||
) {
|
||||
vision {
|
||||
plotly {
|
||||
plotDeviceState(this@embeddedServer, state){
|
||||
plotDeviceState(context, state){
|
||||
name = "value"
|
||||
}
|
||||
plotDeviceProperty(device["pid"], Regulator.target.name){
|
Loading…
Reference in New Issue
Block a user