Multiple fixes to different moules
This commit is contained in:
parent
94d538d858
commit
1b76b42d55
@ -26,8 +26,6 @@ dependencies {
|
||||
compile "hep.dataforge:plots-jfc" // project(':dataforge-plots:plots-jfc')
|
||||
compile "hep.dataforge:dataforge-control" //project(':dataforge-control')
|
||||
compile "hep.dataforge:dataforge-gui"
|
||||
compile "org.jetbrains.kotlin:kotlin-stdlib-jre8:$kotlin_version"
|
||||
|
||||
}
|
||||
|
||||
task installAll(type: Copy) {
|
||||
|
@ -10,7 +10,7 @@ if (!hasProperty('mainClass')) {
|
||||
|
||||
mainClassName = mainClass
|
||||
|
||||
version = "0.2.0"
|
||||
version = "0.3.0"
|
||||
|
||||
description = "The control room application for numass slow control"
|
||||
|
||||
@ -29,7 +29,6 @@ dependencies {
|
||||
devices project(':numass-control:cryotemp')
|
||||
devices project(':numass-control:msp')
|
||||
devices project(':numass-control:vac')
|
||||
compile "org.jetbrains.kotlin:kotlin-stdlib-jre8:$kotlin_version"
|
||||
}
|
||||
|
||||
shadowJar{
|
||||
|
@ -3,110 +3,185 @@ package inr.numass.control
|
||||
import hep.dataforge.context.Context
|
||||
import hep.dataforge.context.Global
|
||||
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.server.ServerManager
|
||||
import hep.dataforge.storage.api.Storage
|
||||
import hep.dataforge.storage.commons.StorageFactory
|
||||
import hep.dataforge.storage.commons.StorageConnection
|
||||
import hep.dataforge.storage.commons.StorageManager
|
||||
import inr.numass.client.ClientUtils
|
||||
import inr.numass.server.NumassStorageServerObject
|
||||
import javafx.application.Application
|
||||
import javafx.application.Platform
|
||||
import javafx.beans.binding.ListBinding
|
||||
import javafx.beans.property.SimpleObjectProperty
|
||||
import javafx.collections.FXCollections
|
||||
import javafx.collections.ObservableList
|
||||
import tornadofx.*
|
||||
import kotlin.streams.toList
|
||||
|
||||
/**
|
||||
* Created by darksnake on 12-May-17.
|
||||
*/
|
||||
class BoardController() : Controller(), AutoCloseable {
|
||||
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)
|
||||
}
|
||||
}
|
||||
val metaProperty = SimpleObjectProperty<Meta>(Meta.empty())
|
||||
var meta: Meta by metaProperty
|
||||
|
||||
val storageManagerProperty = nonNullObjectBinding(contextProperty) {
|
||||
context.pluginManager.getOrLoad(StorageManager::class.java)
|
||||
}
|
||||
|
||||
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.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 storageProperty = nonNullObjectBinding(storageManagerProperty , metaProperty) {
|
||||
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 rootStorage = value.buildStorage(storageMeta);
|
||||
|
||||
val numassRun = ClientUtils.getRunName(meta)
|
||||
if (!numassRun.isEmpty()) {
|
||||
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() {
|
||||
devices.forEach {
|
||||
it.close()
|
||||
}
|
||||
context.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();
|
||||
// }
|
||||
}
|
@ -1,9 +1,9 @@
|
||||
package inr.numass.control
|
||||
|
||||
import hep.dataforge.fx.dfIcon
|
||||
import hep.dataforge.storage.filestorage.FileStorage
|
||||
import javafx.geometry.Orientation
|
||||
import javafx.geometry.Pos
|
||||
import javafx.scene.control.Hyperlink
|
||||
import javafx.scene.image.ImageView
|
||||
import javafx.scene.layout.Priority
|
||||
import tornadofx.*
|
||||
@ -25,19 +25,16 @@ class BoardView : View("Numass control board", ImageView(dfIcon)) {
|
||||
hbox {
|
||||
alignment = Pos.CENTER_LEFT
|
||||
prefHeight = 40.0
|
||||
var serverLabel: Hyperlink by singleAssign();
|
||||
togglebutton("Start") {
|
||||
isSelected = false
|
||||
disableProperty().bind(controller.serverManagerProperty.isNull)
|
||||
disableProperty().bind(controller.serverManagerProperty.booleanBinding { it == null })
|
||||
action {
|
||||
if (isSelected) {
|
||||
text = "Stop"
|
||||
controller.serverManager?.startServer()
|
||||
serverLabel.text = controller.serverManager?.link;
|
||||
controller.serverManagerProperty.value?.startServer()
|
||||
} else {
|
||||
text = "Start"
|
||||
controller.serverManager?.stopServer()
|
||||
serverLabel.text = ""
|
||||
controller.serverManagerProperty.value?.stopServer()
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -45,13 +42,16 @@ class BoardView : View("Numass control board", ImageView(dfIcon)) {
|
||||
paddingHorizontal = 5
|
||||
}
|
||||
indicator {
|
||||
bind(controller.serverManagerProperty.select { it.isStarted })
|
||||
bind(controller.serverManagerProperty.select { it?.isStartedProperty ?: false.toProperty() })
|
||||
}
|
||||
separator(Orientation.VERTICAL)
|
||||
text("Address: ")
|
||||
serverLabel = hyperlink {
|
||||
hyperlink {
|
||||
textProperty().bind(controller.serverManagerProperty.stringBinding {
|
||||
it?.link ?: ""
|
||||
})
|
||||
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 {
|
||||
alignment = Pos.CENTER_LEFT
|
||||
prefHeight = 40.0
|
||||
label(stringBinding(controller.storageProperty) {
|
||||
val storage = controller.storage
|
||||
label(controller.storageProperty.stringBinding { storage ->
|
||||
if (storage == null) {
|
||||
"Storage not initialized"
|
||||
} else {
|
||||
|
@ -20,7 +20,6 @@ import hep.dataforge.control.RoleDef
|
||||
import hep.dataforge.control.RoleDefs
|
||||
import hep.dataforge.control.collectors.RegularPointCollector
|
||||
import hep.dataforge.control.connections.Roles
|
||||
import hep.dataforge.control.connections.StorageConnection
|
||||
import hep.dataforge.control.devices.Device
|
||||
import hep.dataforge.control.devices.PortSensor
|
||||
import hep.dataforge.control.devices.StateDef
|
||||
@ -34,6 +33,7 @@ import hep.dataforge.exceptions.StorageException
|
||||
import hep.dataforge.meta.Meta
|
||||
import hep.dataforge.storage.api.TableLoader
|
||||
import hep.dataforge.storage.commons.LoaderFactory
|
||||
import hep.dataforge.storage.commons.StorageConnection
|
||||
import hep.dataforge.tables.TableFormat
|
||||
import hep.dataforge.tables.TableFormatBuilder
|
||||
import hep.dataforge.utils.DateTimeUtils
|
||||
|
@ -21,7 +21,6 @@ import hep.dataforge.control.RoleDef
|
||||
import hep.dataforge.control.RoleDefs
|
||||
import hep.dataforge.control.collectors.RegularPointCollector
|
||||
import hep.dataforge.control.connections.Roles
|
||||
import hep.dataforge.control.connections.StorageConnection
|
||||
import hep.dataforge.control.devices.*
|
||||
import hep.dataforge.control.measurements.AbstractMeasurement
|
||||
import hep.dataforge.control.ports.PortHandler
|
||||
@ -35,6 +34,7 @@ import hep.dataforge.exceptions.PortException
|
||||
import hep.dataforge.meta.Meta
|
||||
import hep.dataforge.storage.api.TableLoader
|
||||
import hep.dataforge.storage.commons.LoaderFactory
|
||||
import hep.dataforge.storage.commons.StorageConnection
|
||||
import hep.dataforge.tables.TableFormatBuilder
|
||||
import hep.dataforge.utils.DateTimeUtils
|
||||
import hep.dataforge.values.Value
|
||||
|
@ -16,7 +16,7 @@ import java.util.function.Predicate
|
||||
/**
|
||||
* 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()
|
||||
|
||||
override fun start(stage: Stage) {
|
||||
|
@ -3,17 +3,17 @@ package inr.numass.control
|
||||
import hep.dataforge.context.Context
|
||||
import hep.dataforge.context.Global
|
||||
import hep.dataforge.control.connections.Roles
|
||||
import hep.dataforge.control.connections.StorageConnection
|
||||
import hep.dataforge.control.devices.Device
|
||||
import hep.dataforge.exceptions.StorageException
|
||||
import hep.dataforge.fx.dfIcon
|
||||
import hep.dataforge.io.MetaFileReader
|
||||
import hep.dataforge.io.XMLMetaReader
|
||||
import hep.dataforge.meta.Meta
|
||||
import hep.dataforge.storage.commons.StorageConnection
|
||||
import hep.dataforge.storage.commons.StorageFactory
|
||||
import hep.dataforge.storage.commons.StorageManager
|
||||
import inr.numass.client.ClientUtils
|
||||
import javafx.application.Application
|
||||
import javafx.scene.image.Image
|
||||
import javafx.stage.Stage
|
||||
import org.slf4j.LoggerFactory
|
||||
import java.io.IOException
|
||||
@ -27,8 +27,8 @@ import java.util.function.Predicate
|
||||
* Created by darksnake on 08-May-17.
|
||||
*/
|
||||
val DEFAULT_CONFIG_LOCATION = "./numass-control.xml"
|
||||
val STORING_STATE = "storing"
|
||||
val dfIcon: Image = Image(Global::class.java.getResourceAsStream("/img/df.png"))
|
||||
//val STORING_STATE = "storing"
|
||||
//val dfIcon: Image = Image(Global::class.java.getResourceAsStream("/img/df.png"))
|
||||
|
||||
/**
|
||||
* 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 {
|
||||
val ctx = Global.getContext("NUMASS-CONTROL")
|
||||
ctx.pluginManager().getOrLoad(StorageManager::class.java)
|
||||
ctx.getPluginManager().getOrLoad(StorageManager::class.java)
|
||||
return ctx
|
||||
}
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
package inr.numass.control
|
||||
|
||||
import hep.dataforge.control.connections.StorageConnection
|
||||
import hep.dataforge.control.devices.AbstractDevice
|
||||
import hep.dataforge.storage.api.TableLoader
|
||||
import hep.dataforge.storage.commons.StorageConnection
|
||||
import hep.dataforge.values.Values
|
||||
import java.util.*
|
||||
|
||||
|
@ -10,7 +10,6 @@ import hep.dataforge.control.Connection
|
||||
import hep.dataforge.control.RoleDef
|
||||
import hep.dataforge.control.collectors.RegularPointCollector
|
||||
import hep.dataforge.control.connections.Roles
|
||||
import hep.dataforge.control.connections.StorageConnection
|
||||
import hep.dataforge.control.devices.Device
|
||||
import hep.dataforge.control.devices.DeviceHub
|
||||
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.storage.api.TableLoader
|
||||
import hep.dataforge.storage.commons.LoaderFactory
|
||||
import hep.dataforge.storage.commons.StorageConnection
|
||||
import hep.dataforge.tables.TableFormatBuilder
|
||||
import hep.dataforge.tables.ValueMap
|
||||
import hep.dataforge.utils.DateTimeUtils
|
||||
|
@ -13,8 +13,8 @@ import static hep.dataforge.grind.Grind.buildMeta
|
||||
import static hep.dataforge.grind.Grind.morph
|
||||
|
||||
Context ctx = Global.instance()
|
||||
ctx.pluginManager().load(FXPlotManager)
|
||||
ctx.pluginManager().load(NumassPlugin.class)
|
||||
ctx.getPluginManager().load(FXPlotManager)
|
||||
ctx.getPluginManager().load(NumassPlugin.class)
|
||||
|
||||
GrindShell shell = new GrindShell(ctx)
|
||||
|
||||
|
@ -13,8 +13,8 @@ import inr.numass.models.FSS
|
||||
import inr.numass.models.sterile.NumassBeta
|
||||
|
||||
Context ctx = Global.instance()
|
||||
ctx.pluginManager().load(FXPlotManager)
|
||||
ctx.pluginManager().load(NumassPlugin.class)
|
||||
ctx.getPluginManager().load(FXPlotManager)
|
||||
ctx.getPluginManager().load(NumassPlugin.class)
|
||||
|
||||
|
||||
new GrindShell(ctx).eval {
|
||||
|
@ -22,8 +22,8 @@ import inr.numass.data.storage.NumassStorageFactory
|
||||
|
||||
|
||||
Context ctx = Global.instance()
|
||||
ctx.pluginManager().load(PlotManager)
|
||||
ctx.pluginManager().load(NumassPlugin.class)
|
||||
ctx.getPluginManager().load(PlotManager)
|
||||
ctx.getPluginManager().load(NumassPlugin.class)
|
||||
|
||||
new GrindShell(ctx).eval {
|
||||
File rootDir = new File("D:\\Work\\Numass\\data\\2017_05\\Fill_3")
|
||||
|
@ -13,8 +13,8 @@ import inr.numass.data.storage.NumassStorage
|
||||
import inr.numass.data.storage.NumassStorageFactory
|
||||
|
||||
Context ctx = Global.instance()
|
||||
ctx.pluginManager().load(FXPlotManager)
|
||||
ctx.pluginManager().load(NumassPlugin)
|
||||
ctx.getPluginManager().load(FXPlotManager)
|
||||
ctx.getPluginManager().load(NumassPlugin)
|
||||
|
||||
new GrindShell(ctx).eval {
|
||||
File rootDir = new File("D:\\Work\\Numass\\data\\2017_05\\Fill_2")
|
||||
|
@ -20,8 +20,8 @@ import inr.numass.data.storage.NumassStorageFactory
|
||||
|
||||
|
||||
Context ctx = Global.instance()
|
||||
ctx.pluginManager().load(FXPlotManager)
|
||||
ctx.pluginManager().load(NumassPlugin.class)
|
||||
ctx.getPluginManager().load(FXPlotManager)
|
||||
ctx.getPluginManager().load(NumassPlugin.class)
|
||||
|
||||
new GrindShell(ctx).eval {
|
||||
PlotHelper plot = plots
|
||||
|
@ -19,8 +19,8 @@ import java.time.Instant
|
||||
|
||||
|
||||
Context ctx = Global.instance()
|
||||
ctx.pluginManager().load(PlotManager)
|
||||
ctx.pluginManager().load(NumassPlugin.class)
|
||||
ctx.getPluginManager().load(PlotManager)
|
||||
ctx.getPluginManager().load(NumassPlugin.class)
|
||||
|
||||
new GrindShell(ctx).eval {
|
||||
|
||||
|
@ -14,8 +14,8 @@ import inr.numass.data.storage.ProtoNumassPoint
|
||||
import java.nio.file.Paths
|
||||
|
||||
Context ctx = Global.instance()
|
||||
ctx.pluginManager().load(FXPlotManager)
|
||||
ctx.pluginManager().load(NumassPlugin.class)
|
||||
ctx.getPluginManager().load(FXPlotManager)
|
||||
ctx.getPluginManager().load(NumassPlugin.class)
|
||||
|
||||
new GrindShell(ctx).eval {
|
||||
PlotHelper plot = plots
|
||||
|
@ -15,9 +15,9 @@ import inr.numass.data.NumassDataUtils
|
||||
import static hep.dataforge.grind.Grind.buildMeta
|
||||
|
||||
Context ctx = Global.instance()
|
||||
ctx.pluginManager().load(FXPlotManager)
|
||||
ctx.pluginManager().load(NumassPlugin.class)
|
||||
ctx.pluginManager().load(CachePlugin.class)
|
||||
ctx.getPluginManager().load(FXPlotManager)
|
||||
ctx.getPluginManager().load(NumassPlugin.class)
|
||||
ctx.getPluginManager().load(CachePlugin.class)
|
||||
|
||||
Meta meta = buildMeta {
|
||||
data(dir: "D:\\Work\\Numass\\data\\2017_05\\Fill_2", mask: "set_.{1,3}")
|
||||
|
@ -29,9 +29,9 @@ import static inr.numass.data.api.NumassAnalyzer.CHANNEL_KEY
|
||||
import static inr.numass.data.api.NumassAnalyzer.COUNT_RATE_KEY
|
||||
|
||||
Context ctx = Global.instance()
|
||||
ctx.pluginManager().load(PlotManager)
|
||||
ctx.pluginManager().load(NumassPlugin)
|
||||
ctx.pluginManager().load(CachePlugin)
|
||||
ctx.getPluginManager().load(PlotManager)
|
||||
ctx.getPluginManager().load(NumassPlugin)
|
||||
ctx.getPluginManager().load(CachePlugin)
|
||||
|
||||
Meta meta = buildMeta {
|
||||
data(dir: "D:\\Work\\Numass\\data\\2017_05\\Fill_2", mask: "set_.{1,3}")
|
||||
|
@ -22,7 +22,6 @@ import hep.dataforge.data.FileDataFactory;
|
||||
import hep.dataforge.io.IOManager;
|
||||
import hep.dataforge.io.MetaFileReader;
|
||||
import hep.dataforge.meta.Meta;
|
||||
import hep.dataforge.providers.Path;
|
||||
import org.apache.commons.cli.*;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@ -89,7 +88,7 @@ public class Main {
|
||||
return;
|
||||
}
|
||||
|
||||
java.nio.file.Path configFile = context.io().getFile(cfgPath);
|
||||
java.nio.file.Path configFile = context.getIo().getFile(cfgPath);
|
||||
|
||||
if (!Files.exists(configFile)) {
|
||||
throw new FileNotFoundException("Configuration file not found");
|
||||
|
@ -66,6 +66,6 @@ public class Numass {
|
||||
builder.text("***End of actions list***", "red");
|
||||
|
||||
|
||||
context.io().getMarkupRenderer().render(builder.build());
|
||||
context.getIo().getMarkupRenderer().render(builder.build());
|
||||
}
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ public class SubstractSpectrumAction extends OneToOneAction<Table, Table> {
|
||||
protected Table execute(Context context, String name, Table input, Laminate inputMeta) {
|
||||
try {
|
||||
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();
|
||||
ListTable.Builder builder = new ListTable.Builder(input.getFormat());
|
||||
input.getRows().forEach(point -> {
|
||||
|
@ -18,8 +18,6 @@ package inr.numass.data;
|
||||
import hep.dataforge.context.Global;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
@ -41,7 +39,7 @@ public class MonitorCorrector {
|
||||
private final List<MonitorPoint> list;
|
||||
|
||||
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 {
|
||||
|
@ -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) {
|
||||
try {
|
||||
Path dataFile = context.io().getFile(path);
|
||||
Path dataFile = context.getIo().getFile(path);
|
||||
ColumnedDataReader reader = new ColumnedDataReader(Files.newInputStream(dataFile));
|
||||
return new TransmissionInterpolator(reader, xName, yName, nSmooth, w, border);
|
||||
} catch (IOException ex) {
|
||||
|
@ -63,7 +63,7 @@ public class SterileNeutrinoSpectrum extends AbstractParametricFunction {
|
||||
InputStream fssStream = configuration.optString("fssFile")
|
||||
.map(fssFile -> {
|
||||
try {
|
||||
return context.io().optBinary(fssFile)
|
||||
return context.getIo().optBinary(fssFile)
|
||||
.orElseThrow(() -> new RuntimeException("Could not locate FSS file"))
|
||||
.getStream();
|
||||
} catch (IOException e) {
|
||||
|
@ -38,7 +38,7 @@ public class OldDataReader {
|
||||
public static Table readConfig(String path) throws IOException {
|
||||
String[] list = {"X", "time", "ushift"};
|
||||
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);
|
||||
sc.nextLine();
|
||||
|
||||
@ -60,7 +60,7 @@ public class OldDataReader {
|
||||
public static Table readData(String path, double Elow) {
|
||||
SpectrumDataAdapter factory = new SpectrumDataAdapter();
|
||||
ListTable.Builder res = new ListTable.Builder(factory.getFormat());
|
||||
Path file = Global.instance().io().getFile(path);
|
||||
Path file = Global.instance().getIo().getFile(path);
|
||||
double x;
|
||||
int count;
|
||||
int time;
|
||||
@ -112,7 +112,7 @@ public class OldDataReader {
|
||||
public static Table readDataAsGun(String path, double Elow) {
|
||||
SpectrumDataAdapter factory = new SpectrumDataAdapter();
|
||||
ListTable.Builder res = new ListTable.Builder(factory.getFormat());
|
||||
Path file = Global.instance().io().getFile(path);
|
||||
Path file = Global.instance().getIo().getFile(path);
|
||||
double x;
|
||||
long count;
|
||||
int time;
|
||||
@ -145,7 +145,7 @@ public class OldDataReader {
|
||||
public static Table readSpectrumData(String path) {
|
||||
SpectrumDataAdapter factory = new SpectrumDataAdapter();
|
||||
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 count;
|
||||
double time;
|
||||
|
@ -51,7 +51,7 @@ class NumassPlugin : BasicPlugin() {
|
||||
override fun attach(context: Context) {
|
||||
// StorageManager.buildFrom(context);
|
||||
super.attach(context)
|
||||
context.pluginManager().load(NumassIO())
|
||||
context.getPluginManager().load(NumassIO())
|
||||
loadModels(context.getFeature(ModelManager::class.java))
|
||||
loadMath(MathPlugin.buildFrom(context))
|
||||
|
||||
|
@ -84,14 +84,14 @@ val monitorTableTask = task("monitor") {
|
||||
//add set markers
|
||||
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))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
context.io().out("numass.monitor", name).use {
|
||||
context.getIo().out("numass.monitor", name).use {
|
||||
NumassUtils.write(it, meta, res)
|
||||
}
|
||||
|
||||
@ -106,7 +106,7 @@ val analyzeTask = task("analyze") {
|
||||
}
|
||||
pipe<NumassSet, Table> { set ->
|
||||
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)
|
||||
}
|
||||
}
|
||||
@ -174,7 +174,7 @@ val subtractEmptyTask = task("dif") {
|
||||
|
||||
res.goal.onComplete { r, _ ->
|
||||
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)
|
||||
}
|
||||
}
|
||||
@ -227,7 +227,7 @@ val fitTask = task("fit") {
|
||||
configure(meta.getMeta("fit"))
|
||||
}
|
||||
pipe<Table, FitResult> { data ->
|
||||
context.io().out("numass.fit", name).use { out ->
|
||||
context.getIo().out("numass.fit", name).use { out ->
|
||||
val writer = PrintWriter(out)
|
||||
writer.printf("%n*** META ***%n")
|
||||
writer.println(meta.toString())
|
||||
|
@ -26,9 +26,9 @@ public class ServerRunner extends SimpleConfigurable implements AutoCloseable {
|
||||
Context context = Global.getContext("NUMASS_SERVER");
|
||||
|
||||
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)) {
|
||||
context.getLogger().info("Trying to read server configuration from {}", SERVER_CONFIG_PATH);
|
||||
configure(MetaFileReader.read(configFile));
|
||||
|
@ -29,9 +29,9 @@ public class TestServer {
|
||||
public static void main(String[] args) throws Exception {
|
||||
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");
|
||||
context.getLogger().info("Starting test numass storage servlet in '{}'", path);
|
||||
|
Loading…
Reference in New Issue
Block a user