Killed WorkManager because it was ugly.
This commit is contained in:
parent
7de7187f08
commit
e218a17f09
@ -5,9 +5,6 @@ import hep.dataforge.context.Global
|
|||||||
import hep.dataforge.exceptions.StorageException
|
import hep.dataforge.exceptions.StorageException
|
||||||
import hep.dataforge.fx.fragments.FragmentWindow
|
import hep.dataforge.fx.fragments.FragmentWindow
|
||||||
import hep.dataforge.fx.fragments.LogFragment
|
import hep.dataforge.fx.fragments.LogFragment
|
||||||
import hep.dataforge.fx.work.Work
|
|
||||||
import hep.dataforge.fx.work.WorkManager
|
|
||||||
import hep.dataforge.fx.work.WorkManagerFragment
|
|
||||||
import hep.dataforge.meta.Metoid
|
import hep.dataforge.meta.Metoid
|
||||||
import hep.dataforge.names.AlphanumComparator
|
import hep.dataforge.names.AlphanumComparator
|
||||||
import hep.dataforge.names.Named
|
import hep.dataforge.names.Named
|
||||||
@ -59,9 +56,9 @@ class MainView : View("Numass data viewer") {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private val processFragment = FragmentWindow.build(processManagerButton) {
|
// private val processFragment = FragmentWindow.build(processManagerButton) {
|
||||||
WorkManagerFragment(getWorkManager())
|
// WorkManagerFragment(getWorkManager())
|
||||||
}
|
// }
|
||||||
|
|
||||||
private val storageProperty = SimpleObjectProperty<Storage>();
|
private val storageProperty = SimpleObjectProperty<Storage>();
|
||||||
|
|
||||||
@ -76,7 +73,7 @@ class MainView : View("Numass data viewer") {
|
|||||||
} else {
|
} else {
|
||||||
chooser.initialDirectory = File(storageRoot)
|
chooser.initialDirectory = File(storageRoot)
|
||||||
}
|
}
|
||||||
} catch (ex: Exception){
|
} catch (ex: Exception) {
|
||||||
NumassProperties.setNumassProperty("numass.storage.root", null)
|
NumassProperties.setNumassProperty("numass.storage.root", null)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -150,38 +147,28 @@ class MainView : View("Numass data viewer") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun loadDirectory(path: URI) {
|
private fun loadDirectory(path: URI) {
|
||||||
getWorkManager().startWork("viewer.loadDirectory") { work: Work ->
|
runAsync {
|
||||||
work.title = "Load storage ($path)"
|
updateTitle("Load storage ($path)")
|
||||||
work.progress = -1.0
|
updateProgress(-1.0, -1.0);
|
||||||
work.status = "Building numass storage tree..."
|
updateMessage("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)
|
||||||
setRootStorage(root)
|
Platform.runLater { storagePathLabel.text = "Storage: " + path }
|
||||||
Platform.runLater { storagePathLabel.text = "Storage: " + path }
|
updateProgress(1.0, 1.0)
|
||||||
} catch (ex: Exception) {
|
|
||||||
work.progress = 0.0
|
|
||||||
work.status = "Failed to load storage " + path
|
|
||||||
log.log(Level.SEVERE, null, ex)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private val context: Context
|
private val context: Context
|
||||||
get() = Global.instance()
|
get() = Global.instance()
|
||||||
|
|
||||||
@Synchronized private fun getWorkManager(): WorkManager {
|
|
||||||
return Global.instance().getFeature(WorkManager::class.java);
|
|
||||||
}
|
|
||||||
|
|
||||||
fun setRootStorage(root: NumassStorage) {
|
fun setRootStorage(root: NumassStorage) {
|
||||||
|
|
||||||
getWorkManager().cleanup()
|
runAsync {
|
||||||
getWorkManager().startWork("viewer.storage.load") { callback: Work ->
|
updateTitle("Fill data to UI (" + root.name + ")")
|
||||||
callback.title = "Fill data to UI (" + root.name + ")"
|
updateProgress(-1.0, 1.0)
|
||||||
callback.progress = -1.0
|
|
||||||
Platform.runLater { statusBar.progress = -1.0 }
|
Platform.runLater { statusBar.progress = -1.0 }
|
||||||
|
|
||||||
callback.status = "Loading numass storage tree..."
|
updateMessage("Loading numass storage tree...")
|
||||||
|
|
||||||
try {
|
try {
|
||||||
storageProperty.set(root)
|
storageProperty.set(root)
|
||||||
@ -191,8 +178,8 @@ class MainView : View("Numass data viewer") {
|
|||||||
|
|
||||||
// callback.setProgress(1, 1);
|
// callback.setProgress(1, 1);
|
||||||
Platform.runLater { statusBar.progress = 0.0 }
|
Platform.runLater { statusBar.progress = 0.0 }
|
||||||
callback.status = "Numass storage tree loaded."
|
updateMessage("Numass storage tree loaded.")
|
||||||
callback.setProgressToMax()
|
updateProgress(1.0, 1.0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,7 +2,6 @@ package inr.numass.viewer
|
|||||||
|
|
||||||
import hep.dataforge.context.Context
|
import hep.dataforge.context.Context
|
||||||
import hep.dataforge.context.Global
|
import hep.dataforge.context.Global
|
||||||
import hep.dataforge.fx.work.WorkManager
|
|
||||||
import hep.dataforge.io.ColumnedDataWriter
|
import hep.dataforge.io.ColumnedDataWriter
|
||||||
import hep.dataforge.kodex.buildMeta
|
import hep.dataforge.kodex.buildMeta
|
||||||
import hep.dataforge.meta.Meta
|
import hep.dataforge.meta.Meta
|
||||||
@ -69,7 +68,7 @@ class NumassLoaderView : View() {
|
|||||||
private val spectrumPlot: PlotContainer = PlotContainer.centerIn(spectrumPlotPane)
|
private val spectrumPlot: PlotContainer = PlotContainer.centerIn(spectrumPlotPane)
|
||||||
private val hvPlot: PlotContainer = PlotContainer.centerIn(hvPane)
|
private val hvPlot: PlotContainer = PlotContainer.centerIn(hvPane)
|
||||||
private val detectorBinningSelector: ChoiceBox<Int> = ChoiceBox(FXCollections.observableArrayList(1, 2, 5, 10, 20, 50))
|
private val detectorBinningSelector: ChoiceBox<Int> = ChoiceBox(FXCollections.observableArrayList(1, 2, 5, 10, 20, 50))
|
||||||
private val detectorNormalizeSwitch: CheckBox = CheckBox("Normailize")
|
private val detectorNormalizeSwitch: CheckBox = CheckBox("Normalize")
|
||||||
private val detectorDataExportButton: Button = Button("Export")
|
private val detectorDataExportButton: Button = Button("Export")
|
||||||
|
|
||||||
val dataProperty = SimpleObjectProperty<NumassSet>()
|
val dataProperty = SimpleObjectProperty<NumassSet>()
|
||||||
@ -202,8 +201,8 @@ class NumassLoaderView : View() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (newData != null) {
|
if (newData != null) {
|
||||||
getWorkManager().startWork("viewer.numass.load") { work ->
|
runAsync {
|
||||||
work.title = "Load numass data (" + newData.name + ")"
|
updateTitle("Load numass data (" + newData.name + ")")
|
||||||
|
|
||||||
//setup info
|
//setup info
|
||||||
updateInfo(newData)
|
updateInfo(newData)
|
||||||
@ -228,9 +227,6 @@ class NumassLoaderView : View() {
|
|||||||
return Global.getDefaultContext();
|
return Global.getDefaultContext();
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getWorkManager(): WorkManager {
|
|
||||||
return getContext().getFeature(WorkManager::class.java);
|
|
||||||
}
|
|
||||||
|
|
||||||
fun loadData(data: NumassSet?) {
|
fun loadData(data: NumassSet?) {
|
||||||
this.data = data;
|
this.data = data;
|
||||||
@ -311,10 +307,6 @@ class NumassLoaderView : View() {
|
|||||||
private fun updateDetectorPane(data: NumassSet) {
|
private fun updateDetectorPane(data: NumassSet) {
|
||||||
Platform.runLater { detectorPlotFrame.clear() }
|
Platform.runLater { detectorPlotFrame.clear() }
|
||||||
|
|
||||||
val work = getWorkManager().getWork("viewer.numass.load.detector")
|
|
||||||
work.maxProgress = data.points.count().toDouble();
|
|
||||||
work.progress = 0.0
|
|
||||||
|
|
||||||
val binning = detectorBinningSelector.value
|
val binning = detectorBinningSelector.value
|
||||||
|
|
||||||
val valueAxis = if (detectorNormalizeSwitch.isSelected) {
|
val valueAxis = if (detectorNormalizeSwitch.isSelected) {
|
||||||
@ -323,8 +315,9 @@ class NumassLoaderView : View() {
|
|||||||
NumassAnalyzer.COUNT_KEY
|
NumassAnalyzer.COUNT_KEY
|
||||||
}
|
}
|
||||||
|
|
||||||
/// detectorPlot.plot = detectorPlotFrame
|
|
||||||
runAsync {
|
runAsync {
|
||||||
|
detectorPlot.progressProperty().bind(progressProperty());
|
||||||
|
val totalCount = data.points.count();
|
||||||
val index = AtomicInteger(0);
|
val index = AtomicInteger(0);
|
||||||
data.points.map { point ->
|
data.points.map { point ->
|
||||||
val seriesName = String.format("%d: %.2f", index.incrementAndGet(), point.voltage)
|
val seriesName = String.format("%d: %.2f", index.incrementAndGet(), point.voltage)
|
||||||
@ -335,14 +328,11 @@ class NumassLoaderView : View() {
|
|||||||
).apply {
|
).apply {
|
||||||
configure(plottableConfig)
|
configure(plottableConfig)
|
||||||
}.also {
|
}.also {
|
||||||
work.increaseProgress(1.0)
|
updateProgress(index.get() as Long, totalCount);
|
||||||
detectorPlot.setProgress(work.progress/work.maxProgress)
|
|
||||||
}
|
}
|
||||||
}.collect(Collectors.toList())
|
}.collect(Collectors.toList())
|
||||||
} ui { plots ->
|
} ui { plots ->
|
||||||
detectorPlotFrame.setAll(plots)
|
detectorPlotFrame.setAll(plots)
|
||||||
work.setProgressToMax()
|
|
||||||
detectorPlot.setProgress(1.0)
|
|
||||||
detectorDataExportButton.isDisable = false
|
detectorDataExportButton.isDisable = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,6 @@ package inr.numass.viewer
|
|||||||
import ch.qos.logback.classic.Level
|
import ch.qos.logback.classic.Level
|
||||||
import ch.qos.logback.classic.Logger
|
import ch.qos.logback.classic.Logger
|
||||||
import hep.dataforge.context.Global
|
import hep.dataforge.context.Global
|
||||||
import hep.dataforge.fx.work.WorkManager
|
|
||||||
import hep.dataforge.storage.commons.StorageManager
|
import hep.dataforge.storage.commons.StorageManager
|
||||||
import javafx.scene.image.Image
|
import javafx.scene.image.Image
|
||||||
import javafx.stage.Stage
|
import javafx.stage.Stage
|
||||||
@ -20,7 +19,6 @@ class Viewer : App(MainView::class) {
|
|||||||
(LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME) as Logger).level = Level.INFO
|
(LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME) as Logger).level = Level.INFO
|
||||||
Global.setDefaultContext(Global.instance())
|
Global.setDefaultContext(Global.instance())
|
||||||
StorageManager().startGlobal()
|
StorageManager().startGlobal()
|
||||||
WorkManager().startGlobal()
|
|
||||||
super.start(stage)
|
super.start(stage)
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,7 +1,6 @@
|
|||||||
package inr.numass.viewer.test
|
package inr.numass.viewer.test
|
||||||
|
|
||||||
import hep.dataforge.context.Global
|
import hep.dataforge.context.Global
|
||||||
import hep.dataforge.fx.work.WorkManager
|
|
||||||
import inr.numass.data.api.NumassSet
|
import inr.numass.data.api.NumassSet
|
||||||
import inr.numass.data.storage.NumassStorageFactory
|
import inr.numass.data.storage.NumassStorageFactory
|
||||||
import inr.numass.viewer.NumassLoaderView
|
import inr.numass.viewer.NumassLoaderView
|
||||||
@ -18,7 +17,6 @@ class NumassTest : App(NumassLoaderView::class) {
|
|||||||
super.start(stage)
|
super.start(stage)
|
||||||
val storage = NumassStorageFactory.buildLocal(File("D:\\Work\\Numass\\data\\2017_05\\"))
|
val storage = NumassStorageFactory.buildLocal(File("D:\\Work\\Numass\\data\\2017_05\\"))
|
||||||
Global.setDefaultContext(Global.instance())
|
Global.setDefaultContext(Global.instance())
|
||||||
WorkManager().startGlobal()
|
|
||||||
val view = find<NumassLoaderView>();
|
val view = find<NumassLoaderView>();
|
||||||
view.data = storage.provide("Fill_1/set_4", NumassSet::class.java).get();
|
view.data = storage.provide("Fill_1/set_4", NumassSet::class.java).get();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user