diff --git a/controls-xodus/src/main/kotlin/ru/mipt/npm/controls/xodus/converters.kt b/controls-xodus/src/main/kotlin/ru/mipt/npm/controls/xodus/converters.kt index bc7deb6..f7bbd87 100644 --- a/controls-xodus/src/main/kotlin/ru/mipt/npm/controls/xodus/converters.kt +++ b/controls-xodus/src/main/kotlin/ru/mipt/npm/controls/xodus/converters.kt @@ -13,7 +13,7 @@ import space.kscience.dataforge.names.Name import space.kscience.dataforge.values.Value import space.kscience.dataforge.values.ValueType -public fun PropertyChangedMessage.toEntity(transaction: StoreTransaction): Entity { +internal fun PropertyChangedMessage.toEntity(transaction: StoreTransaction): Entity { val entity = transaction.newEntity("PropertyChangedMessage") entity.setProperty("property", property) entity.setProperty("value", value.toString()) @@ -24,7 +24,7 @@ public fun PropertyChangedMessage.toEntity(transaction: StoreTransaction): Entit return entity } -public fun Entity.toPropertyChangedMessage(): PropertyChangedMessage? { +internal fun Entity.toPropertyChangedMessage(): PropertyChangedMessage? { if (getProperty("property") == null || getProperty("value") == null || getProperty("sourceDevice") == null) { return null } @@ -39,7 +39,7 @@ public fun Entity.toPropertyChangedMessage(): PropertyChangedMessage? { ) } -public fun MagixMessage.toEntity(transaction: StoreTransaction): Entity { +internal fun MagixMessage.toEntity(transaction: StoreTransaction): Entity { val entity = transaction.newEntity("MagixMessage") entity.setProperty("format", format) entity.setProperty("origin", origin) @@ -54,7 +54,7 @@ public fun MagixMessage.toEntity(transaction: StoreTransaction): Entity { return entity } -public fun Entity.toMagixMessage(): MagixMessage? { +internal fun Entity.toMagixMessage(): MagixMessage? { if (getProperty("format") == null || getProperty("origin") == null) { return null } diff --git a/controls-xodus/src/main/kotlin/ru/mipt/npm/controls/xodus/util/queries.kt b/controls-xodus/src/main/kotlin/ru/mipt/npm/controls/xodus/util/queries.kt index f547e05..ee9361f 100644 --- a/controls-xodus/src/main/kotlin/ru/mipt/npm/controls/xodus/util/queries.kt +++ b/controls-xodus/src/main/kotlin/ru/mipt/npm/controls/xodus/util/queries.kt @@ -5,11 +5,8 @@ import kotlinx.datetime.Instant import ru.mipt.npm.controls.api.PropertyChangedMessage import ru.mipt.npm.controls.xodus.toPropertyChangedMessage -//selectDeviceMessagesInRange -public fun StoreTransaction.fromTo( - range: ClosedRange, -// from: Instant, -// to: Instant, +public fun StoreTransaction.selectPropertyChangedMessagesFromRange( + range: ClosedRange ): List = find( "PropertyChangedMessage", "time", diff --git a/controls-xodus/src/test/kotlin/ru/mipt/npm/controls/xodus/util/QueriesTest.kt b/controls-xodus/src/test/kotlin/ru/mipt/npm/controls/xodus/util/QueriesTest.kt index 73d915b..b09ae2e 100644 --- a/controls-xodus/src/test/kotlin/ru/mipt/npm/controls/xodus/util/QueriesTest.kt +++ b/controls-xodus/src/test/kotlin/ru/mipt/npm/controls/xodus/util/QueriesTest.kt @@ -55,7 +55,7 @@ internal class QueriesTest { @Test fun testFromTo() { assertEquals(propertyChangedMessages.subList(0, 2).toSet(), entityStore.computeInReadonlyTransaction { - it.fromTo( Instant.fromEpochMilliseconds(1000)..Instant.fromEpochMilliseconds(1500)) + it.selectPropertyChangedMessagesFromRange( Instant.fromEpochMilliseconds(1000)..Instant.fromEpochMilliseconds(1500)) }.toSet()) } diff --git a/demo/car/src/main/kotlin/ru/mipt/npm/controls/demo/car/VirtualCarController.kt b/demo/car/src/main/kotlin/ru/mipt/npm/controls/demo/car/VirtualCarController.kt index 8a652bb..31f315c 100644 --- a/demo/car/src/main/kotlin/ru/mipt/npm/controls/demo/car/VirtualCarController.kt +++ b/demo/car/src/main/kotlin/ru/mipt/npm/controls/demo/car/VirtualCarController.kt @@ -26,6 +26,7 @@ import ru.mipt.npm.magix.server.startMagixServer import space.kscience.dataforge.context.* import space.kscience.dataforge.meta.Meta import tornadofx.* +import java.nio.file.Paths class VirtualCarController : Controller(), ContextAware { @@ -49,12 +50,12 @@ class VirtualCarController : Controller(), ContextAware { virtualCar = deviceManager.install("virtual-car", VirtualCar) //starting magix event loop and connect it to entity store - magixEntityStore = PersistentEntityStores.newInstance("/home/marvel1337/2021/SCADA/.server_messages") + magixEntityStore = PersistentEntityStores.newInstance(Paths.get(".server_messages").toFile()) magixServer = startMagixServer(enableRawRSocket = true, enableZmq = true) { flow -> flow.storeInXodus(magixEntityStore as PersistentEntityStore) } magixVirtualCar = deviceManager.install("magix-virtual-car", MagixVirtualCar) - deviceEntityStore = PersistentEntityStores.newInstance("/home/marvel1337/2021/SCADA/.messages") + deviceEntityStore = PersistentEntityStores.newInstance(Paths.get(".messages").toFile()) //connect to device entity store xodusStorageJob = deviceManager.connectXodus(deviceEntityStore as PersistentEntityStore) //Create mongo client and connect to MongoDB