Multiple fixes to different moules

This commit is contained in:
Alexander Nozik 2017-11-13 16:56:34 +03:00
parent 94d538d858
commit 1b76b42d55
30 changed files with 210 additions and 142 deletions

View File

@ -26,8 +26,6 @@ dependencies {
compile "hep.dataforge:plots-jfc" // project(':dataforge-plots:plots-jfc') compile "hep.dataforge:plots-jfc" // project(':dataforge-plots:plots-jfc')
compile "hep.dataforge:dataforge-control" //project(':dataforge-control') compile "hep.dataforge:dataforge-control" //project(':dataforge-control')
compile "hep.dataforge:dataforge-gui" compile "hep.dataforge:dataforge-gui"
compile "org.jetbrains.kotlin:kotlin-stdlib-jre8:$kotlin_version"
} }
task installAll(type: Copy) { task installAll(type: Copy) {

View File

@ -10,7 +10,7 @@ if (!hasProperty('mainClass')) {
mainClassName = mainClass mainClassName = mainClass
version = "0.2.0" version = "0.3.0"
description = "The control room application for numass slow control" description = "The control room application for numass slow control"
@ -29,7 +29,6 @@ dependencies {
devices project(':numass-control:cryotemp') devices project(':numass-control:cryotemp')
devices project(':numass-control:msp') devices project(':numass-control:msp')
devices project(':numass-control:vac') devices project(':numass-control:vac')
compile "org.jetbrains.kotlin:kotlin-stdlib-jre8:$kotlin_version"
} }
shadowJar{ shadowJar{

View File

@ -3,110 +3,185 @@ package inr.numass.control
import hep.dataforge.context.Context import hep.dataforge.context.Context
import hep.dataforge.context.Global import hep.dataforge.context.Global
import hep.dataforge.control.DeviceManager import hep.dataforge.control.DeviceManager
import hep.dataforge.control.connections.Roles
import hep.dataforge.control.connections.StorageConnection
import hep.dataforge.meta.Meta import hep.dataforge.meta.Meta
import hep.dataforge.server.ServerManager import hep.dataforge.server.ServerManager
import hep.dataforge.storage.api.Storage import hep.dataforge.storage.commons.StorageConnection
import hep.dataforge.storage.commons.StorageFactory import hep.dataforge.storage.commons.StorageManager
import inr.numass.client.ClientUtils import inr.numass.client.ClientUtils
import inr.numass.server.NumassStorageServerObject import javafx.beans.binding.ListBinding
import javafx.application.Application
import javafx.application.Platform
import javafx.beans.property.SimpleObjectProperty import javafx.beans.property.SimpleObjectProperty
import javafx.collections.FXCollections import javafx.collections.FXCollections
import javafx.collections.ObservableList import javafx.collections.ObservableList
import tornadofx.* import tornadofx.*
import kotlin.streams.toList
/** /**
* Created by darksnake on 12-May-17. * Created by darksnake on 12-May-17.
*/ */
class BoardController() : Controller(), AutoCloseable { class BoardController() : Controller(), AutoCloseable {
val devices: ObservableList<DeviceDisplay<*>> = FXCollections.observableArrayList<DeviceDisplay<*>>();
val contextProperty = SimpleObjectProperty<Context>(Global.instance()) val contextProperty = SimpleObjectProperty<Context>(Global.instance())
var context: Context by contextProperty var context: Context by contextProperty
private set
val storageProperty = SimpleObjectProperty<Storage>() val metaProperty = SimpleObjectProperty<Meta>(Meta.empty())
var storage: Storage? by storageProperty var meta: Meta by metaProperty
private set
val serverManagerProperty = SimpleObjectProperty<ServerManager>()
var serverManager: ServerManager? by serverManagerProperty
private set
fun load(app: Application) {
runAsync {
getConfig(app).ifPresent {
val context = Context.build("NUMASS", Global.instance(), it)
load(context, it)
}
}
val storageManagerProperty = nonNullObjectBinding(contextProperty) {
context.pluginManager.getOrLoad(StorageManager::class.java)
} }
private fun load(context: Context, meta: Meta) { val storageProperty = nonNullObjectBinding(storageManagerProperty , metaProperty) {
this.context = context;
devices.clear();
meta.getMetaList("device").forEach {
try {
Platform.runLater { devices.add(buildDeviceView(context, it)) };
} catch (ex: Exception) {
context.logger.error("Can't build device view", ex);
}
}
if (meta.hasMeta("storage")) {
val st = buildStorage(context, meta);
val storageConnection = StorageConnection(storage);
devices.forEach {
if (it.device.acceptsRole(Roles.STORAGE_ROLE)) {
it.device.connect(storageConnection, Roles.STORAGE_ROLE);
}
}
Platform.runLater {
storage = st
meta.optMeta("server").ifPresent { serverMeta ->
val sm = context.pluginManager().getOrLoad(ServerManager::class.java);
sm.configure(serverMeta)
sm.bind(NumassStorageServerObject(serverManager, storage, "numass-storage"));
serverManager = sm
}
}
}
}
private fun buildDeviceView(context: Context, deviceMeta: Meta): DeviceDisplay<*> {
context.logger.info("Building device with meta: {}", deviceMeta)
val device = context.loadFeature("devices", DeviceManager::class.java).buildDevice(deviceMeta)
device.init();
return device.getDisplay();
}
private fun buildStorage(context: Context, meta: Meta): Storage {
val storageMeta = meta.getMeta("storage").builder val storageMeta = meta.getMeta("storage").builder
.putValue("readOnly", false) .putValue("readOnly", false)
.putValue("monitor", true) .putValue("monitor", true)
context.logger.info("Creating storage for server with meta {}", storageMeta) context.logger.info("Creating storage for server with meta {}", storageMeta)
var storage = StorageFactory.buildStorage(context, storageMeta); val rootStorage = value.buildStorage(storageMeta);
val numassRun = ClientUtils.getRunName(meta) val numassRun = ClientUtils.getRunName(meta)
if (!numassRun.isEmpty()) { if (!numassRun.isEmpty()) {
context.logger.info("Run information found. Selecting run {}", numassRun) context.logger.info("Run information found. Selecting run {}", numassRun)
storage = storage.buildShelf(numassRun, Meta.empty()); rootStorage.buildShelf(numassRun, Meta.empty());
} else {
rootStorage
}
}.apply {
onChange {
val connection = StorageConnection(value)
devices.map { it.device }.forEach { device ->
device.forEachConnection(StorageConnection::class.java) { device.disconnect(it) }//removing all ald storage connections
device.connect(connection)
}
}
}
val serverManagerProperty = objectBinding(contextProperty) {
context.optFeature(ServerManager::class.java).orElse(null)
}
val deviceManagerProperty = objectBinding(contextProperty) {
context.optFeature(DeviceManager::class.java).orElse(null)
}
val devices: ObservableList<DeviceDisplay<*>> = object : ListBinding<DeviceDisplay<*>>() {
init {
bind(deviceManagerProperty)
}
override fun computeValue(): ObservableList<DeviceDisplay<*>> {
val manager = deviceManagerProperty.value
return if (manager == null) {
FXCollections.emptyObservableList();
} else {
manager.deviceNames()
.filter { it.length == 1 } // select top level devices
.map { manager.optDevice(it) }
.filter { it.isPresent }
.map { it.get().getDisplay() }
.toList().observable()
}
}
}
fun configure(meta: Meta) {
val context = Context.build("NUMASS", Global.instance(), meta.getMeta("context", meta));
}
fun load(app: App) {
runAsync {
getConfig(app).ifPresent {
configure(it)
}
} }
return storage;
} }
override fun close() { override fun close() {
devices.forEach { context.close()
it.close()
}
context.close();
} }
// val devices: ObservableList<DeviceDisplay<*>> = FXCollections.observableArrayList<DeviceDisplay<*>>();
//
// val contextProperty = SimpleObjectProperty<Context>(Global.instance())
// var context: Context by contextProperty
// private set
//
// val storageProperty = SimpleObjectProperty<Storage>()
// var storage: Storage? by storageProperty
// private set
//
// val serverManagerProperty = SimpleObjectProperty<ServerManager>()
// var serverManager: ServerManager? by serverManagerProperty
// private set
//
// fun load(app: Application) {
// runAsync {
// getConfig(app).ifPresent {
// val context = Context.build("NUMASS", Global.instance(), it)
// load(context, it)
// }
// }
//
// }
//
// private fun load(context: Context, meta: Meta) {
// this.context = context;
// devices.clear();
// meta.getMetaList("device").forEach {
// try {
// Platform.runLater { devices.add(buildDeviceView(context, it)) };
// } catch (ex: Exception) {
// context.logger.error("Can't build device view", ex);
// }
// }
//
// if (meta.hasMeta("storage")) {
// val st = buildStorage(context, meta);
// val storageConnection = StorageConnection(storage);
// devices.forEach {
// if (it.device.acceptsRole(Roles.STORAGE_ROLE)) {
// it.device.connect(storageConnection, Roles.STORAGE_ROLE);
// }
// }
// Platform.runLater {
// storage = st
// meta.optMeta("server").ifPresent { serverMeta ->
// val sm = context.getPluginManager().getOrLoad(ServerManager::class.java);
// sm.configure(serverMeta)
//
// sm.bind(NumassStorageServerObject(serverManager, storage, "numass-storage"));
// serverManager = sm
// }
// }
// }
// }
//
// private fun buildDeviceView(context: Context, deviceMeta: Meta): DeviceDisplay<*> {
// context.logger.info("Building device with meta: {}", deviceMeta)
// val device = context.loadFeature("devices", DeviceManager::class.java).buildDevice(deviceMeta)
// device.init();
// return device.getDisplay();
// }
//
// private fun buildStorage(context: Context, meta: Meta): Storage {
// val storageMeta = meta.getMeta("storage").builder
// .putValue("readOnly", false)
// .putValue("monitor", true)
//
// context.logger.info("Creating storage for server with meta {}", storageMeta)
// var storage = StorageFactory.buildStorage(context, storageMeta);
//
// val numassRun = ClientUtils.getRunName(meta)
// if (!numassRun.isEmpty()) {
// context.logger.info("Run information found. Selecting run {}", numassRun)
// storage = storage.buildShelf(numassRun, Meta.empty());
// }
// return storage;
// }
//
// override fun close() {
// devices.forEach {
// it.close()
// }
// context.close();
// }
} }

View File

@ -1,9 +1,9 @@
package inr.numass.control package inr.numass.control
import hep.dataforge.fx.dfIcon
import hep.dataforge.storage.filestorage.FileStorage import hep.dataforge.storage.filestorage.FileStorage
import javafx.geometry.Orientation import javafx.geometry.Orientation
import javafx.geometry.Pos import javafx.geometry.Pos
import javafx.scene.control.Hyperlink
import javafx.scene.image.ImageView import javafx.scene.image.ImageView
import javafx.scene.layout.Priority import javafx.scene.layout.Priority
import tornadofx.* import tornadofx.*
@ -25,19 +25,16 @@ class BoardView : View("Numass control board", ImageView(dfIcon)) {
hbox { hbox {
alignment = Pos.CENTER_LEFT alignment = Pos.CENTER_LEFT
prefHeight = 40.0 prefHeight = 40.0
var serverLabel: Hyperlink by singleAssign();
togglebutton("Start") { togglebutton("Start") {
isSelected = false isSelected = false
disableProperty().bind(controller.serverManagerProperty.isNull) disableProperty().bind(controller.serverManagerProperty.booleanBinding { it == null })
action { action {
if (isSelected) { if (isSelected) {
text = "Stop" text = "Stop"
controller.serverManager?.startServer() controller.serverManagerProperty.value?.startServer()
serverLabel.text = controller.serverManager?.link;
} else { } else {
text = "Start" text = "Start"
controller.serverManager?.stopServer() controller.serverManagerProperty.value?.stopServer()
serverLabel.text = ""
} }
} }
} }
@ -45,13 +42,16 @@ class BoardView : View("Numass control board", ImageView(dfIcon)) {
paddingHorizontal = 5 paddingHorizontal = 5
} }
indicator { indicator {
bind(controller.serverManagerProperty.select { it.isStarted }) bind(controller.serverManagerProperty.select { it?.isStartedProperty ?: false.toProperty() })
} }
separator(Orientation.VERTICAL) separator(Orientation.VERTICAL)
text("Address: ") text("Address: ")
serverLabel = hyperlink { hyperlink {
textProperty().bind(controller.serverManagerProperty.stringBinding {
it?.link ?: ""
})
action { action {
hostServices.showDocument(controller.serverManager?.link); hostServices.showDocument(controller.serverManagerProperty.value?.link);
} }
} }
} }
@ -61,8 +61,7 @@ class BoardView : View("Numass control board", ImageView(dfIcon)) {
hbox { hbox {
alignment = Pos.CENTER_LEFT alignment = Pos.CENTER_LEFT
prefHeight = 40.0 prefHeight = 40.0
label(stringBinding(controller.storageProperty) { label(controller.storageProperty.stringBinding { storage ->
val storage = controller.storage
if (storage == null) { if (storage == null) {
"Storage not initialized" "Storage not initialized"
} else { } else {

View File

@ -20,7 +20,6 @@ import hep.dataforge.control.RoleDef
import hep.dataforge.control.RoleDefs import hep.dataforge.control.RoleDefs
import hep.dataforge.control.collectors.RegularPointCollector import hep.dataforge.control.collectors.RegularPointCollector
import hep.dataforge.control.connections.Roles import hep.dataforge.control.connections.Roles
import hep.dataforge.control.connections.StorageConnection
import hep.dataforge.control.devices.Device import hep.dataforge.control.devices.Device
import hep.dataforge.control.devices.PortSensor import hep.dataforge.control.devices.PortSensor
import hep.dataforge.control.devices.StateDef import hep.dataforge.control.devices.StateDef
@ -34,6 +33,7 @@ import hep.dataforge.exceptions.StorageException
import hep.dataforge.meta.Meta import hep.dataforge.meta.Meta
import hep.dataforge.storage.api.TableLoader import hep.dataforge.storage.api.TableLoader
import hep.dataforge.storage.commons.LoaderFactory import hep.dataforge.storage.commons.LoaderFactory
import hep.dataforge.storage.commons.StorageConnection
import hep.dataforge.tables.TableFormat import hep.dataforge.tables.TableFormat
import hep.dataforge.tables.TableFormatBuilder import hep.dataforge.tables.TableFormatBuilder
import hep.dataforge.utils.DateTimeUtils import hep.dataforge.utils.DateTimeUtils

View File

@ -21,7 +21,6 @@ import hep.dataforge.control.RoleDef
import hep.dataforge.control.RoleDefs import hep.dataforge.control.RoleDefs
import hep.dataforge.control.collectors.RegularPointCollector import hep.dataforge.control.collectors.RegularPointCollector
import hep.dataforge.control.connections.Roles import hep.dataforge.control.connections.Roles
import hep.dataforge.control.connections.StorageConnection
import hep.dataforge.control.devices.* import hep.dataforge.control.devices.*
import hep.dataforge.control.measurements.AbstractMeasurement import hep.dataforge.control.measurements.AbstractMeasurement
import hep.dataforge.control.ports.PortHandler import hep.dataforge.control.ports.PortHandler
@ -35,6 +34,7 @@ import hep.dataforge.exceptions.PortException
import hep.dataforge.meta.Meta import hep.dataforge.meta.Meta
import hep.dataforge.storage.api.TableLoader import hep.dataforge.storage.api.TableLoader
import hep.dataforge.storage.commons.LoaderFactory import hep.dataforge.storage.commons.LoaderFactory
import hep.dataforge.storage.commons.StorageConnection
import hep.dataforge.tables.TableFormatBuilder import hep.dataforge.tables.TableFormatBuilder
import hep.dataforge.utils.DateTimeUtils import hep.dataforge.utils.DateTimeUtils
import hep.dataforge.values.Value import hep.dataforge.values.Value

View File

@ -16,7 +16,7 @@ import java.util.function.Predicate
/** /**
* Created by darksnake on 14-May-17. * Created by darksnake on 14-May-17.
*/ */
abstract class NumassControlApplication<D : Device> : App() { abstract class NumassControlApplication<in D : Device> : App() {
private var device: D by singleAssign() private var device: D by singleAssign()
override fun start(stage: Stage) { override fun start(stage: Stage) {

View File

@ -3,17 +3,17 @@ package inr.numass.control
import hep.dataforge.context.Context import hep.dataforge.context.Context
import hep.dataforge.context.Global import hep.dataforge.context.Global
import hep.dataforge.control.connections.Roles import hep.dataforge.control.connections.Roles
import hep.dataforge.control.connections.StorageConnection
import hep.dataforge.control.devices.Device import hep.dataforge.control.devices.Device
import hep.dataforge.exceptions.StorageException import hep.dataforge.exceptions.StorageException
import hep.dataforge.fx.dfIcon
import hep.dataforge.io.MetaFileReader import hep.dataforge.io.MetaFileReader
import hep.dataforge.io.XMLMetaReader import hep.dataforge.io.XMLMetaReader
import hep.dataforge.meta.Meta import hep.dataforge.meta.Meta
import hep.dataforge.storage.commons.StorageConnection
import hep.dataforge.storage.commons.StorageFactory import hep.dataforge.storage.commons.StorageFactory
import hep.dataforge.storage.commons.StorageManager import hep.dataforge.storage.commons.StorageManager
import inr.numass.client.ClientUtils import inr.numass.client.ClientUtils
import javafx.application.Application import javafx.application.Application
import javafx.scene.image.Image
import javafx.stage.Stage import javafx.stage.Stage
import org.slf4j.LoggerFactory import org.slf4j.LoggerFactory
import java.io.IOException import java.io.IOException
@ -27,8 +27,8 @@ import java.util.function.Predicate
* Created by darksnake on 08-May-17. * Created by darksnake on 08-May-17.
*/ */
val DEFAULT_CONFIG_LOCATION = "./numass-control.xml" val DEFAULT_CONFIG_LOCATION = "./numass-control.xml"
val STORING_STATE = "storing" //val STORING_STATE = "storing"
val dfIcon: Image = Image(Global::class.java.getResourceAsStream("/img/df.png")) //val dfIcon: Image = Image(Global::class.java.getResourceAsStream("/img/df.png"))
/** /**
* Create a single or multiple storage connections for a device * Create a single or multiple storage connections for a device
@ -108,7 +108,7 @@ fun findDeviceMeta(config: Meta, criterion: Predicate<Meta>): Optional<Meta> {
fun setupContext(meta: Meta): Context { fun setupContext(meta: Meta): Context {
val ctx = Global.getContext("NUMASS-CONTROL") val ctx = Global.getContext("NUMASS-CONTROL")
ctx.pluginManager().getOrLoad(StorageManager::class.java) ctx.getPluginManager().getOrLoad(StorageManager::class.java)
return ctx return ctx
} }

View File

@ -1,8 +1,8 @@
package inr.numass.control package inr.numass.control
import hep.dataforge.control.connections.StorageConnection
import hep.dataforge.control.devices.AbstractDevice import hep.dataforge.control.devices.AbstractDevice
import hep.dataforge.storage.api.TableLoader import hep.dataforge.storage.api.TableLoader
import hep.dataforge.storage.commons.StorageConnection
import hep.dataforge.values.Values import hep.dataforge.values.Values
import java.util.* import java.util.*

View File

@ -10,7 +10,6 @@ import hep.dataforge.control.Connection
import hep.dataforge.control.RoleDef import hep.dataforge.control.RoleDef
import hep.dataforge.control.collectors.RegularPointCollector import hep.dataforge.control.collectors.RegularPointCollector
import hep.dataforge.control.connections.Roles import hep.dataforge.control.connections.Roles
import hep.dataforge.control.connections.StorageConnection
import hep.dataforge.control.devices.Device import hep.dataforge.control.devices.Device
import hep.dataforge.control.devices.DeviceHub import hep.dataforge.control.devices.DeviceHub
import hep.dataforge.control.devices.PortSensor.CONNECTED_STATE import hep.dataforge.control.devices.PortSensor.CONNECTED_STATE
@ -24,6 +23,7 @@ import hep.dataforge.meta.Meta
import hep.dataforge.names.Name import hep.dataforge.names.Name
import hep.dataforge.storage.api.TableLoader import hep.dataforge.storage.api.TableLoader
import hep.dataforge.storage.commons.LoaderFactory import hep.dataforge.storage.commons.LoaderFactory
import hep.dataforge.storage.commons.StorageConnection
import hep.dataforge.tables.TableFormatBuilder import hep.dataforge.tables.TableFormatBuilder
import hep.dataforge.tables.ValueMap import hep.dataforge.tables.ValueMap
import hep.dataforge.utils.DateTimeUtils import hep.dataforge.utils.DateTimeUtils

View File

@ -13,8 +13,8 @@ import static hep.dataforge.grind.Grind.buildMeta
import static hep.dataforge.grind.Grind.morph import static hep.dataforge.grind.Grind.morph
Context ctx = Global.instance() Context ctx = Global.instance()
ctx.pluginManager().load(FXPlotManager) ctx.getPluginManager().load(FXPlotManager)
ctx.pluginManager().load(NumassPlugin.class) ctx.getPluginManager().load(NumassPlugin.class)
GrindShell shell = new GrindShell(ctx) GrindShell shell = new GrindShell(ctx)

View File

@ -13,8 +13,8 @@ import inr.numass.models.FSS
import inr.numass.models.sterile.NumassBeta import inr.numass.models.sterile.NumassBeta
Context ctx = Global.instance() Context ctx = Global.instance()
ctx.pluginManager().load(FXPlotManager) ctx.getPluginManager().load(FXPlotManager)
ctx.pluginManager().load(NumassPlugin.class) ctx.getPluginManager().load(NumassPlugin.class)
new GrindShell(ctx).eval { new GrindShell(ctx).eval {

View File

@ -22,8 +22,8 @@ import inr.numass.data.storage.NumassStorageFactory
Context ctx = Global.instance() Context ctx = Global.instance()
ctx.pluginManager().load(PlotManager) ctx.getPluginManager().load(PlotManager)
ctx.pluginManager().load(NumassPlugin.class) ctx.getPluginManager().load(NumassPlugin.class)
new GrindShell(ctx).eval { new GrindShell(ctx).eval {
File rootDir = new File("D:\\Work\\Numass\\data\\2017_05\\Fill_3") File rootDir = new File("D:\\Work\\Numass\\data\\2017_05\\Fill_3")

View File

@ -13,8 +13,8 @@ import inr.numass.data.storage.NumassStorage
import inr.numass.data.storage.NumassStorageFactory import inr.numass.data.storage.NumassStorageFactory
Context ctx = Global.instance() Context ctx = Global.instance()
ctx.pluginManager().load(FXPlotManager) ctx.getPluginManager().load(FXPlotManager)
ctx.pluginManager().load(NumassPlugin) ctx.getPluginManager().load(NumassPlugin)
new GrindShell(ctx).eval { new GrindShell(ctx).eval {
File rootDir = new File("D:\\Work\\Numass\\data\\2017_05\\Fill_2") File rootDir = new File("D:\\Work\\Numass\\data\\2017_05\\Fill_2")

View File

@ -20,8 +20,8 @@ import inr.numass.data.storage.NumassStorageFactory
Context ctx = Global.instance() Context ctx = Global.instance()
ctx.pluginManager().load(FXPlotManager) ctx.getPluginManager().load(FXPlotManager)
ctx.pluginManager().load(NumassPlugin.class) ctx.getPluginManager().load(NumassPlugin.class)
new GrindShell(ctx).eval { new GrindShell(ctx).eval {
PlotHelper plot = plots PlotHelper plot = plots

View File

@ -19,8 +19,8 @@ import java.time.Instant
Context ctx = Global.instance() Context ctx = Global.instance()
ctx.pluginManager().load(PlotManager) ctx.getPluginManager().load(PlotManager)
ctx.pluginManager().load(NumassPlugin.class) ctx.getPluginManager().load(NumassPlugin.class)
new GrindShell(ctx).eval { new GrindShell(ctx).eval {

View File

@ -14,8 +14,8 @@ import inr.numass.data.storage.ProtoNumassPoint
import java.nio.file.Paths import java.nio.file.Paths
Context ctx = Global.instance() Context ctx = Global.instance()
ctx.pluginManager().load(FXPlotManager) ctx.getPluginManager().load(FXPlotManager)
ctx.pluginManager().load(NumassPlugin.class) ctx.getPluginManager().load(NumassPlugin.class)
new GrindShell(ctx).eval { new GrindShell(ctx).eval {
PlotHelper plot = plots PlotHelper plot = plots

View File

@ -15,9 +15,9 @@ import inr.numass.data.NumassDataUtils
import static hep.dataforge.grind.Grind.buildMeta import static hep.dataforge.grind.Grind.buildMeta
Context ctx = Global.instance() Context ctx = Global.instance()
ctx.pluginManager().load(FXPlotManager) ctx.getPluginManager().load(FXPlotManager)
ctx.pluginManager().load(NumassPlugin.class) ctx.getPluginManager().load(NumassPlugin.class)
ctx.pluginManager().load(CachePlugin.class) ctx.getPluginManager().load(CachePlugin.class)
Meta meta = buildMeta { Meta meta = buildMeta {
data(dir: "D:\\Work\\Numass\\data\\2017_05\\Fill_2", mask: "set_.{1,3}") data(dir: "D:\\Work\\Numass\\data\\2017_05\\Fill_2", mask: "set_.{1,3}")

View File

@ -29,9 +29,9 @@ import static inr.numass.data.api.NumassAnalyzer.CHANNEL_KEY
import static inr.numass.data.api.NumassAnalyzer.COUNT_RATE_KEY import static inr.numass.data.api.NumassAnalyzer.COUNT_RATE_KEY
Context ctx = Global.instance() Context ctx = Global.instance()
ctx.pluginManager().load(PlotManager) ctx.getPluginManager().load(PlotManager)
ctx.pluginManager().load(NumassPlugin) ctx.getPluginManager().load(NumassPlugin)
ctx.pluginManager().load(CachePlugin) ctx.getPluginManager().load(CachePlugin)
Meta meta = buildMeta { Meta meta = buildMeta {
data(dir: "D:\\Work\\Numass\\data\\2017_05\\Fill_2", mask: "set_.{1,3}") data(dir: "D:\\Work\\Numass\\data\\2017_05\\Fill_2", mask: "set_.{1,3}")

View File

@ -22,7 +22,6 @@ import hep.dataforge.data.FileDataFactory;
import hep.dataforge.io.IOManager; import hep.dataforge.io.IOManager;
import hep.dataforge.io.MetaFileReader; import hep.dataforge.io.MetaFileReader;
import hep.dataforge.meta.Meta; import hep.dataforge.meta.Meta;
import hep.dataforge.providers.Path;
import org.apache.commons.cli.*; import org.apache.commons.cli.*;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -89,7 +88,7 @@ public class Main {
return; return;
} }
java.nio.file.Path configFile = context.io().getFile(cfgPath); java.nio.file.Path configFile = context.getIo().getFile(cfgPath);
if (!Files.exists(configFile)) { if (!Files.exists(configFile)) {
throw new FileNotFoundException("Configuration file not found"); throw new FileNotFoundException("Configuration file not found");

View File

@ -66,6 +66,6 @@ public class Numass {
builder.text("***End of actions list***", "red"); builder.text("***End of actions list***", "red");
context.io().getMarkupRenderer().render(builder.build()); context.getIo().getMarkupRenderer().render(builder.build());
} }
} }

View File

@ -30,7 +30,7 @@ public class SubstractSpectrumAction extends OneToOneAction<Table, Table> {
protected Table execute(Context context, String name, Table input, Laminate inputMeta) { protected Table execute(Context context, String name, Table input, Laminate inputMeta) {
try { try {
String referencePath = inputMeta. getString("file", "empty.dat"); String referencePath = inputMeta. getString("file", "empty.dat");
Path referenceFile = context.io().getFile(referencePath); Path referenceFile = context.getIo().getFile(referencePath);
Table referenceTable = new ColumnedDataReader(referenceFile).toTable(); Table referenceTable = new ColumnedDataReader(referenceFile).toTable();
ListTable.Builder builder = new ListTable.Builder(input.getFormat()); ListTable.Builder builder = new ListTable.Builder(input.getFormat());
input.getRows().forEach(point -> { input.getRows().forEach(point -> {

View File

@ -18,8 +18,6 @@ package inr.numass.data;
import hep.dataforge.context.Global; import hep.dataforge.context.Global;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException; import java.io.IOException;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.Path; import java.nio.file.Path;
@ -41,7 +39,7 @@ public class MonitorCorrector {
private final List<MonitorPoint> list; private final List<MonitorPoint> list;
public MonitorCorrector(String path) throws ParseException, IOException { public MonitorCorrector(String path) throws ParseException, IOException {
this(Global.instance().io().getFile(path)); this(Global.instance().getIo().getFile(path));
} }
public MonitorCorrector(Path monitorFile) throws ParseException, IOException { public MonitorCorrector(Path monitorFile) throws ParseException, IOException {

View File

@ -40,7 +40,7 @@ public class TransmissionInterpolator implements UnivariateFunction {
public static TransmissionInterpolator fromFile(Context context, String path, String xName, String yName, int nSmooth, double w, double border) { public static TransmissionInterpolator fromFile(Context context, String path, String xName, String yName, int nSmooth, double w, double border) {
try { try {
Path dataFile = context.io().getFile(path); Path dataFile = context.getIo().getFile(path);
ColumnedDataReader reader = new ColumnedDataReader(Files.newInputStream(dataFile)); ColumnedDataReader reader = new ColumnedDataReader(Files.newInputStream(dataFile));
return new TransmissionInterpolator(reader, xName, yName, nSmooth, w, border); return new TransmissionInterpolator(reader, xName, yName, nSmooth, w, border);
} catch (IOException ex) { } catch (IOException ex) {

View File

@ -63,7 +63,7 @@ public class SterileNeutrinoSpectrum extends AbstractParametricFunction {
InputStream fssStream = configuration.optString("fssFile") InputStream fssStream = configuration.optString("fssFile")
.map(fssFile -> { .map(fssFile -> {
try { try {
return context.io().optBinary(fssFile) return context.getIo().optBinary(fssFile)
.orElseThrow(() -> new RuntimeException("Could not locate FSS file")) .orElseThrow(() -> new RuntimeException("Could not locate FSS file"))
.getStream(); .getStream();
} catch (IOException e) { } catch (IOException e) {

View File

@ -38,7 +38,7 @@ public class OldDataReader {
public static Table readConfig(String path) throws IOException { public static Table readConfig(String path) throws IOException {
String[] list = {"X", "time", "ushift"}; String[] list = {"X", "time", "ushift"};
ListTable.Builder res = new ListTable.Builder(list); ListTable.Builder res = new ListTable.Builder(list);
Path file = Global.instance().io().getFile(path); Path file = Global.instance().getIo().getFile(path);
Scanner sc = new Scanner(file); Scanner sc = new Scanner(file);
sc.nextLine(); sc.nextLine();
@ -60,7 +60,7 @@ public class OldDataReader {
public static Table readData(String path, double Elow) { public static Table readData(String path, double Elow) {
SpectrumDataAdapter factory = new SpectrumDataAdapter(); SpectrumDataAdapter factory = new SpectrumDataAdapter();
ListTable.Builder res = new ListTable.Builder(factory.getFormat()); ListTable.Builder res = new ListTable.Builder(factory.getFormat());
Path file = Global.instance().io().getFile(path); Path file = Global.instance().getIo().getFile(path);
double x; double x;
int count; int count;
int time; int time;
@ -112,7 +112,7 @@ public class OldDataReader {
public static Table readDataAsGun(String path, double Elow) { public static Table readDataAsGun(String path, double Elow) {
SpectrumDataAdapter factory = new SpectrumDataAdapter(); SpectrumDataAdapter factory = new SpectrumDataAdapter();
ListTable.Builder res = new ListTable.Builder(factory.getFormat()); ListTable.Builder res = new ListTable.Builder(factory.getFormat());
Path file = Global.instance().io().getFile(path); Path file = Global.instance().getIo().getFile(path);
double x; double x;
long count; long count;
int time; int time;
@ -145,7 +145,7 @@ public class OldDataReader {
public static Table readSpectrumData(String path) { public static Table readSpectrumData(String path) {
SpectrumDataAdapter factory = new SpectrumDataAdapter(); SpectrumDataAdapter factory = new SpectrumDataAdapter();
ListTable.Builder res = new ListTable.Builder(factory.getFormat()); ListTable.Builder res = new ListTable.Builder(factory.getFormat());
Path file = Global.instance().io().getFile(path); Path file = Global.instance().getIo().getFile(path);
double x; double x;
double count; double count;
double time; double time;

View File

@ -51,7 +51,7 @@ class NumassPlugin : BasicPlugin() {
override fun attach(context: Context) { override fun attach(context: Context) {
// StorageManager.buildFrom(context); // StorageManager.buildFrom(context);
super.attach(context) super.attach(context)
context.pluginManager().load(NumassIO()) context.getPluginManager().load(NumassIO())
loadModels(context.getFeature(ModelManager::class.java)) loadModels(context.getFeature(ModelManager::class.java))
loadMath(MathPlugin.buildFrom(context)) loadMath(MathPlugin.buildFrom(context))

View File

@ -84,14 +84,14 @@ val monitorTableTask = task("monitor") {
//add set markers //add set markers
addSetMarkers(frame, data.values) addSetMarkers(frame, data.values)
} }
context.io().out("numass.monitor", name, "dfp").use { context.getIo().out("numass.monitor", name, "dfp").use {
NumassUtils.writeEnvelope(it, PlotFrame.Wrapper().wrap(frame)) NumassUtils.writeEnvelope(it, PlotFrame.Wrapper().wrap(frame))
} }
} }
} }
} }
context.io().out("numass.monitor", name).use { context.getIo().out("numass.monitor", name).use {
NumassUtils.write(it, meta, res) NumassUtils.write(it, meta, res)
} }
@ -106,7 +106,7 @@ val analyzeTask = task("analyze") {
} }
pipe<NumassSet, Table> { set -> pipe<NumassSet, Table> { set ->
SmartAnalyzer().analyzeSet(set, meta).also { res -> SmartAnalyzer().analyzeSet(set, meta).also { res ->
context.io().out("numass.analyze", name).use { context.getIo().out("numass.analyze", name).use {
NumassUtils.write(it, meta, res) NumassUtils.write(it, meta, res)
} }
} }
@ -174,7 +174,7 @@ val subtractEmptyTask = task("dif") {
res.goal.onComplete { r, _ -> res.goal.onComplete { r, _ ->
if (r != null) { if (r != null) {
context.io().out("numass.merge", input.name + "_subtract").use { context.getIo().out("numass.merge", input.name + "_subtract").use {
NumassUtils.write(it, resMeta, r) NumassUtils.write(it, resMeta, r)
} }
} }
@ -227,7 +227,7 @@ val fitTask = task("fit") {
configure(meta.getMeta("fit")) configure(meta.getMeta("fit"))
} }
pipe<Table, FitResult> { data -> pipe<Table, FitResult> { data ->
context.io().out("numass.fit", name).use { out -> context.getIo().out("numass.fit", name).use { out ->
val writer = PrintWriter(out) val writer = PrintWriter(out)
writer.printf("%n*** META ***%n") writer.printf("%n*** META ***%n")
writer.println(meta.toString()) writer.println(meta.toString())

View File

@ -26,9 +26,9 @@ public class ServerRunner extends SimpleConfigurable implements AutoCloseable {
Context context = Global.getContext("NUMASS_SERVER"); Context context = Global.getContext("NUMASS_SERVER");
public ServerRunner() throws IOException, ParseException { public ServerRunner() throws IOException, ParseException {
// Global.instance().pluginManager().load(StorageManager.class); // Global.instance().getPluginManager().load(StorageManager.class);
Path configFile = context.io().getFile(SERVER_CONFIG_PATH); Path configFile = context.getIo().getFile(SERVER_CONFIG_PATH);
if (Files.exists(configFile)) { if (Files.exists(configFile)) {
context.getLogger().info("Trying to read server configuration from {}", SERVER_CONFIG_PATH); context.getLogger().info("Trying to read server configuration from {}", SERVER_CONFIG_PATH);
configure(MetaFileReader.read(configFile)); configure(MetaFileReader.read(configFile));

View File

@ -29,9 +29,9 @@ public class TestServer {
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
Context context = Global.getContext("NUMASS-SERVER"); Context context = Global.getContext("NUMASS-SERVER");
StorageManager storageManager = context.pluginManager().load(StorageManager.class); StorageManager storageManager = context.getPluginManager().load(StorageManager.class);
ServerManager serverManager = context.pluginManager().load(ServerManager.class); ServerManager serverManager = context.getPluginManager().load(ServerManager.class);
File path = new File("/D:/temp/test"); File path = new File("/D:/temp/test");
context.getLogger().info("Starting test numass storage servlet in '{}'", path); context.getLogger().info("Starting test numass storage servlet in '{}'", path);