Fix some issues
This commit is contained in:
parent
cfd7bce2f3
commit
b79ad40a9b
@ -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 <T> MagixMessage<T>.toEntity(transaction: StoreTransaction): Entity {
|
||||
internal fun <T> MagixMessage<T>.toEntity(transaction: StoreTransaction): Entity {
|
||||
val entity = transaction.newEntity("MagixMessage")
|
||||
entity.setProperty("format", format)
|
||||
entity.setProperty("origin", origin)
|
||||
@ -54,7 +54,7 @@ public fun <T> MagixMessage<T>.toEntity(transaction: StoreTransaction): Entity {
|
||||
return entity
|
||||
}
|
||||
|
||||
public fun Entity.toMagixMessage(): MagixMessage<PropertyChangedMessage>? {
|
||||
internal fun Entity.toMagixMessage(): MagixMessage<PropertyChangedMessage>? {
|
||||
if (getProperty("format") == null || getProperty("origin") == null) {
|
||||
return null
|
||||
}
|
||||
|
@ -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<Instant>,
|
||||
// from: Instant,
|
||||
// to: Instant,
|
||||
public fun StoreTransaction.selectPropertyChangedMessagesFromRange(
|
||||
range: ClosedRange<Instant>
|
||||
): List<PropertyChangedMessage> = find(
|
||||
"PropertyChangedMessage",
|
||||
"time",
|
||||
|
@ -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())
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user