Added slow control viewer to NumassViewer

This commit is contained in:
darksnake 2017-06-18 20:50:40 +03:00
parent fb9f55c633
commit 02a7f66a35
3 changed files with 92 additions and 17 deletions

View File

@ -1,5 +1,5 @@
plugins{
id "org.jetbrains.kotlin.jvm" version '1.1.2-2'
id "org.jetbrains.kotlin.jvm" version '1.1.2-5'
id "application"
}
@ -23,12 +23,11 @@ compileKotlin.kotlinOptions.jvmTarget = "1.8"
dependencies {
compile project(':numass-core')
compile "hep.dataforge:plots-jfc" //project(':dataforge-plots:plots-jfc')
compile "hep.dataforge:kodex"
compile 'com.jcraft:jsch:0.1.54'
compile 'org.controlsfx:controlsfx:8.40.12'
compile "org.jetbrains.kotlin:kotlin-stdlib-jre8"
compile "no.tornado:tornadofx:1.7.4"
compile "no.tornado:tornadofx:1.7.5"
}
apply plugin: 'kotlin'

View File

@ -11,6 +11,7 @@ import hep.dataforge.fx.work.WorkManagerFragment
import hep.dataforge.meta.Metoid
import hep.dataforge.names.AlphanumComparator
import hep.dataforge.names.Named
import hep.dataforge.storage.api.PointLoader
import hep.dataforge.storage.api.Storage
import hep.dataforge.storage.filestorage.FileStorageFactory
import inr.numass.NumassProperties
@ -35,10 +36,11 @@ import java.util.logging.Level
/**
* Created by darksnake on 14-Apr-17.
*/
class MainView : View() {
class MainView : View("Numass data viewer") {
override val root: AnchorPane by fxml("/fxml/MainView.fxml");
private val numassLoaderView: NumassLoaderView by inject()
private val slowControlView: SlowControlView by inject()
private val consoleButton: ToggleButton by fxid()
private val processManagerButton: ToggleButton by fxid()
@ -50,6 +52,16 @@ class MainView : View() {
private val treePane: BorderPane by fxid()
private val statusBar: StatusBar by fxid()
private val logFragment = FragmentWindow.build(consoleButton) {
LogFragment().apply {
addRootLogHandler()
}
}
private val processFragment = FragmentWindow.build(processManagerButton) {
WorkManagerFragment(getWorkManager())
}
private val storageProperty = SimpleObjectProperty<Storage>();
init {
@ -87,9 +99,15 @@ class MainView : View() {
addEventHandler(MouseEvent.MOUSE_CLICKED) { e: MouseEvent ->
if (e.clickCount == 2) {
val value = focusModel.focusedCell.treeItem.value
if (value.content is NumassData) {
numassLoaderView.loadData(value.content)
loaderPane.center = numassLoaderView.root
when (value.content) {
is NumassData -> {
numassLoaderView.loadData(value.content)
loaderPane.center = numassLoaderView.root
}
is PointLoader -> {
slowControlView.load(value.content)
loaderPane.center = slowControlView.root
}
}
}
}
@ -122,11 +140,7 @@ class MainView : View() {
}
}
val logFragment = LogFragment()
logFragment.addRootLogHandler()
//logFragment.hookStd();
FragmentWindow(logFragment).bindTo(consoleButton)
FragmentWindow(WorkManagerFragment(getWorkManager())).bindTo(processManagerButton)
}
private fun loadDirectory(path: String) {
@ -135,7 +149,7 @@ class MainView : View() {
work.progress = -1.0
work.status = "Building numass storage tree..."
try {
val root = NumassStorage(context,FileStorageFactory.buildStorageMeta(path,true, true));
val root = NumassStorage(context, FileStorageFactory.buildStorageMeta(path, true, true));
setRootStorage(root)
Platform.runLater { storagePathLabel.text = "Storage: " + path }
} catch (ex: Exception) {
@ -224,9 +238,9 @@ class MainView : View() {
}
}
class Item(val content: Named): Comparable<Item> {
class Item(val content: Named) : Comparable<Item> {
override fun compareTo(other: Item): Int {
return AlphanumComparator.INSTANCE.compare(this.getName(),other.getName())
return AlphanumComparator.INSTANCE.compare(this.getName(), other.getName())
}
fun getName(): String {
@ -235,7 +249,7 @@ class MainView : View() {
fun getTime(): String {
if (content is NumassData) {
if(content.startTime() == null){
if (content.startTime() == null) {
return ""
} else {
return content.startTime().toString()

View File

@ -0,0 +1,62 @@
package inr.numass.viewer
import hep.dataforge.kodex.buildMeta
import hep.dataforge.meta.Meta
import hep.dataforge.plots.Plottable
import hep.dataforge.plots.data.PlottableData
import hep.dataforge.plots.fx.PlotContainer
import hep.dataforge.plots.jfreechart.JFreeChartFrame
import hep.dataforge.storage.api.PointLoader
import hep.dataforge.storage.api.ValueIndex
import hep.dataforge.tables.DataPoint
import hep.dataforge.tables.ListTable
import hep.dataforge.tables.Table
import hep.dataforge.tables.XYAdapter
import tornadofx.*
/**
* Created by darksnake on 18.06.2017.
*/
class SlowControlView : View("My View") {
private val plotMeta = buildMeta("plot") {
}
val plot = JFreeChartFrame(plotMeta)
override val root = borderpane {
PlotContainer.centerIn(this).plot = plot
}
fun load(loader: PointLoader) {
runAsync {
val data = getData(loader)
ArrayList<Plottable>().apply {
loader.format.columns.filter { it.name != "timestamp" }.forEach {
val adapter = XYAdapter("timestamp", it.name);
this += PlottableData.plot("data", adapter, data);
}
}
} ui {
plot.setAll(it)
}
}
private fun getData(loader: PointLoader, query: Meta = Meta.empty()): Table {
val index: ValueIndex<DataPoint>
//use custom index if needed
if (query.hasValue("index")) {
index = loader.getIndex(query.getString("index", ""))
} else {
//use loader default one otherwise
index = loader.index
}
try {
return ListTable(loader.format, index.query(query))
} catch (e: Exception) {
throw RuntimeException(e)
}
}
}