Update server to working condition

This commit is contained in:
Alexander Nozik 2022-11-23 14:19:30 +03:00
parent bdc649fde6
commit 7efb952163
No known key found for this signature in database
GPG Key ID: F7FCF2DD25C71357
4 changed files with 14 additions and 7 deletions

View File

@ -1,6 +1,5 @@
package ru.inr.mass.data.proto
import kotlinx.coroutines.launch
import ru.inr.mass.data.api.NumassPoint
import space.kscience.dataforge.context.AbstractPlugin
import space.kscience.dataforge.context.Context
@ -64,15 +63,14 @@ public suspend fun NumassProtoPlugin.readRepository(path: Path): DataTree<Numass
NameToken(segment.fileName.toString())
})
val value = readNumassDirectory(childPath)
launch {
static(name, value, value.meta)
}
static(name, value, value.meta)
}
//TODO add file watcher
}
public suspend fun NumassProtoPlugin.readRepository(path: String): DataTree<NumassDirectorySet> = readRepository(Path.of(path))
public suspend fun NumassProtoPlugin.readRepository(path: String): DataTree<NumassDirectorySet> =
readRepository(Path.of(path))
public fun NumassProtoPlugin.readPoint(path: String): NumassPoint = readNumassPointFile(path)
?: error("Can't read numass point at $path")

View File

@ -27,6 +27,7 @@ public class NumassCommonPlugin(meta: Meta = Meta.EMPTY) : VisionPlugin(meta) {
subclass(VisionOfNumassHv.serializer())
subclass(VisionOfNumassPoint.serializer())
subclass(VisionOfNumassSet.serializer())
subclass(VisionOfNumassSetRef.serializer())
subclass(VisionOfNumassRepository.serializer())
}
}

View File

@ -4,10 +4,11 @@ import kotlinx.serialization.Serializable
import ru.inr.mass.data.api.NumassSet
import space.kscience.dataforge.data.DataTree
import space.kscience.dataforge.data.DataTreeItem
import space.kscience.dataforge.data.await
import space.kscience.dataforge.misc.Named
import space.kscience.dataforge.names.Name
import space.kscience.dataforge.names.NameToken
import space.kscience.dataforge.names.plus
import space.kscience.visionforge.AbstractVision
import space.kscience.visionforge.AbstractVisionGroup
@Serializable
@ -15,13 +16,18 @@ public class VisionOfNumassRepository : AbstractVisionGroup() {
override fun createGroup(): VisionOfNumassRepository = VisionOfNumassRepository()
}
@Serializable
public class VisionOfNumassSetRef(
override val name: Name,
) : Named, AbstractVision()
public suspend fun VisionOfNumassRepository(
repoName: Name,
tree: DataTree<NumassSet>,
): VisionOfNumassRepository = VisionOfNumassRepository().apply {
tree.items.forEach { (key: NameToken, value) ->
children[key] = when (value) {
is DataTreeItem.Leaf -> VisionOfNumassSet(repoName + key, value.data.await())
is DataTreeItem.Leaf -> VisionOfNumassSetRef(repoName + key)
is DataTreeItem.Node -> VisionOfNumassRepository(repoName + key, value.tree)
}
}

View File

@ -19,11 +19,13 @@ public data class PointRef(
@Serializable
public class VisionOfNumassSet(
public val meta: Meta,
public val points: List<PointRef>,
public val hvData: HVData? = null,
) : AbstractVision()
public fun VisionOfNumassSet(setName: Name, set: NumassSet): VisionOfNumassSet = VisionOfNumassSet(
set.meta,
set.points.map { point ->
PointRef(
setName + point.index.toString(),