Add details for device description message.

Update build plugin and kotlin.
This commit is contained in:
Alexander Nozik 2021-12-24 20:52:04 +03:00
parent df6defd637
commit 29c0291fa3
No known key found for this signature in database
GPG Key ID: F7FCF2DD25C71357
7 changed files with 14 additions and 25 deletions

View File

@ -113,6 +113,8 @@ public data class GetDescriptionMessage(
@SerialName("description")
public data class DescriptionMessage(
val description: Meta,
val properties: Collection<PropertyDescriptor>,
val actions: Collection<ActionDescriptor>,
override val sourceDevice: Name,
override val targetDevice: Name? = null,
override val comment: String? = null,

View File

@ -5,11 +5,7 @@ import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.MutableSharedFlow
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
import kotlinx.serialization.json.Json
import kotlinx.serialization.json.encodeToJsonElement
import ru.mipt.npm.controls.api.*
import space.kscience.dataforge.meta.Meta
import space.kscience.dataforge.meta.toMeta
import space.kscience.dataforge.names.Name
import space.kscience.dataforge.names.plus
@ -48,21 +44,10 @@ public suspend fun Device.respondMessage(deviceTarget: Name, request: DeviceMess
}
is GetDescriptionMessage -> {
val descriptionMeta = Meta {
"properties" put {
propertyDescriptors.map { descriptor ->
descriptor.name put Json.encodeToJsonElement(descriptor).toMeta()
}
}
"actions" put {
actionDescriptors.map { descriptor ->
descriptor.name put Json.encodeToJsonElement(descriptor).toMeta()
}
}
}
DescriptionMessage(
description = descriptionMeta,
description = meta,
properties = propertyDescriptors,
actions = actionDescriptors,
sourceDevice = deviceTarget,
targetDevice = request.sourceDevice
)

View File

@ -17,6 +17,7 @@ import space.kscience.dataforge.meta.get
import space.kscience.dataforge.meta.transformations.MetaConverter
import kotlin.math.pow
import kotlin.time.Duration
import kotlin.time.Duration.Companion.milliseconds
import kotlin.time.ExperimentalTime
data class Vector2D(var x: Double = 0.0, var y: Double = 0.0) : MetaRepr {
@ -103,7 +104,7 @@ open class VirtualCar(context: Context, meta: Meta) : DeviceBySpec<VirtualCar>(I
//initializing the clock
timeState = Clock.System.now()
//starting regular updates
doRecurring(Duration.milliseconds(100)) {
doRecurring(100.milliseconds) {
update()
}
}

View File

@ -10,7 +10,7 @@ import space.kscience.dataforge.meta.descriptors.value
import space.kscience.dataforge.meta.transformations.MetaConverter
import space.kscience.dataforge.values.ValueType
import java.time.Instant
import kotlin.time.Duration
import kotlin.time.Duration.Companion.milliseconds
import kotlin.time.ExperimentalTime
@ -27,7 +27,7 @@ class DemoDevice(context: Context, meta: Meta) : DeviceBySpec<DemoDevice>(DemoDe
cosScale.read()
timeScale.read()
}
doRecurring(Duration.milliseconds(50)) {
doRecurring(50.milliseconds) {
coordinates.read()
}
}

View File

@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

View File

@ -25,6 +25,7 @@ import space.kscience.dataforge.values.asValue
import kotlin.collections.component1
import kotlin.collections.component2
import kotlin.time.Duration
import kotlin.time.Duration.Companion.milliseconds
class PiMotionMasterDevice(
context: Context,
@ -42,7 +43,7 @@ class PiMotionMasterDevice(
}
}
var timeoutValue: Duration = Duration.microseconds(200)
var timeoutValue: Duration = 200.milliseconds
/**
* Name-friendly accessor for axis

View File

@ -5,7 +5,7 @@ enableFeaturePreview("VERSION_CATALOGS")
pluginManagement {
val toolsVersion = "0.10.5"
val toolsVersion = "0.10.7"
repositories {
maven("https://repo.kotlin.link")
@ -29,7 +29,7 @@ dependencyResolutionManagement {
versionCatalogs {
create("npm") {
from("ru.mipt.npm:version-catalog:0.10.5")
from("ru.mipt.npm:version-catalog:0.10.7")
}
}
}