From dc5a97c002d449f1b09b4d1ab5f910570ab2cd15 Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Fri, 18 Dec 2015 16:20:47 +0300 Subject: [PATCH] Initial commit for new gradle model --- .hgignore | 12 + build.gradle | 42 + numass-control/build.gradle | 2 + numass-control/cryotemp/build.gradle | 17 + .../java/inr/numass/cryotemp/PKT8App.java | 85 ++ .../java/inr/numass/cryotemp/PKT8Device.java | 418 +++++++ .../cryotemp/PKT8MainViewController.java | 276 +++++ .../inr/numass/cryotemp/PKT8VirtualPort.java | 87 ++ .../main/resources/config/defaultConfig.xml | 14 + .../src/main/resources/fxml/PKT8MainView.fxml | 46 + numass-control/magnet/build.gradle | 26 + .../control/magnet/MagnetController.java | 444 +++++++ .../control/magnet/MagnetStateListener.java | 54 + .../numass/control/magnet/MagnetStatus.java | 88 ++ .../control/magnet/SafeMagnetController.java | 101 ++ .../inr/numass/control/magnet/SetCurrent.java | 46 + .../java/inr/numass/control/magnet/Talk.java | 75 ++ .../numass/control/magnet/TestController.java | 91 ++ .../inr/numass/control/magnet/TestSynch.java | 117 ++ .../control/magnet/VirtualLambdaPort.java | 180 +++ .../magnet/fx/MagnetControllerApp.java | 137 +++ .../magnet/fx/MagnetControllerComponent.java | 300 +++++ .../inr/numass/control/magnet/fx/TestApp.java | 22 + .../src/main/resources/fxml/SingleMagnet.fxml | 125 ++ .../magnet/src/main/resources/logback.xml | 23 + numass-control/msp/build.gradle | 17 + .../inr/numass/control/msp/MspDevice.java | 446 +++++++ .../inr/numass/control/msp/MspListener.java | 32 + .../java/inr/numass/control/msp/MspTest.java | 81 ++ .../inr/numass/control/msp/fx/MspApp.java | 87 ++ .../control/msp/fx/MspViewController.java | 341 ++++++ .../src/main/resources/config/msp-config.xml | 44 + .../msp/src/main/resources/fxml/MspView.fxml | 58 + .../inr/numass/control/msp/TestScanner.java | 38 + numass-control/vac/build.gradle | 18 + .../numass/readvac/MKSVacuumeterDevice.java | 193 +++ .../main/java/inr/numass/readvac/Main.java | 131 ++ .../numass/readvac/P1ControlException.java | 40 + .../readvac/ResponseParseException.java | 36 + .../numass/readvac/TextAreaOutputStream.java | 81 ++ .../inr/numass/readvac/VACDeviceReader.java | 412 +++++++ .../inr/numass/readvac/VACFileReader.java | 142 +++ .../java/inr/numass/readvac/VACFrame.form | 395 ++++++ .../java/inr/numass/readvac/VACFrame.java | 542 +++++++++ .../java/inr/numass/readvac/VACManager.java | 223 ++++ .../inr/numass/readvac/testConfig.xml | 6 + .../java/inr/numass/readvac/TestMain.java | 45 + .../java/inr/numass/readvac/TestRemote.java | 35 + .../inr/numass/readvac/TimeShiftTest.java | 48 + numass-control/vac/vac-config.xml | 6 + numass-main/build.gradle | 47 + numass-main/gradle.properties | 15 + .../numass/scripts/CalculateLossTail.groovy | 94 ++ .../inr/numass/scripts/FindExIonRatio.groovy | 115 ++ .../inr/numass/scripts/ListActions.groovy | 18 + .../groovy/inr/numass/scripts/Loss2014.groovy | 29 + .../numass/scripts/LossTailCalculation.groovy | 41 + .../numass/scripts/OldFitResultReader.groovy | 110 ++ .../groovy/inr/numass/scripts/OldTest.groovy | 112 ++ .../inr/numass/scripts/PlotViewer.groovy | 52 + .../numass/scripts/PrintLossFunctions.groovy | 46 + .../inr/numass/scripts/ResolutionTest.groovy | 92 ++ .../scripts/RunScriptsFromDirectory.groovy | 42 + .../numass/scripts/SignificanceTest.groovy | 112 ++ .../groovy/inr/numass/scripts/Simulate.groovy | 100 ++ .../inr/numass/scripts/SimulateGun.groovy | 71 ++ .../inr/numass/scripts/Systematics.groovy | 110 ++ ...estExperimentalVariableLossSpectrum.groovy | 71 ++ .../scripts/TheoreticalLossFunction.groovy | 46 + .../inr/numass/scripts/TritiumTest.groovy | 122 ++ .../plotfit/PlotFitResultAction.java | 109 ++ .../src/main/java/inr/numass/Main.java | 200 +++ .../main/java/inr/numass/NumassContext.java | 79 ++ .../src/main/java/inr/numass/NumassIO.java | 131 ++ .../main/java/inr/numass/NumassPlugin.java | 275 +++++ .../numass/actions/AdjustErrorsAction.java | 87 ++ .../java/inr/numass/actions/BorderData.java | 86 ++ .../inr/numass/actions/DebunchAction.java | 81 ++ .../inr/numass/actions/FindBorderAction.java | 67 + .../inr/numass/actions/MergeDataAction.java | 200 +++ .../numass/actions/MonitorCorrectAction.java | 182 +++ .../inr/numass/actions/PrepareDataAction.java | 125 ++ .../numass/actions/ReadNumassDataAction.java | 66 + .../actions/ShowLossSpectrumAction.java | 283 +++++ .../numass/actions/ShowSpectrumAction.java | 174 +++ .../java/inr/numass/actions/SlicedData.java | 91 ++ .../inr/numass/actions/SlicingAction.java | 85 ++ .../inr/numass/actions/SummaryAction.java | 117 ++ .../main/java/inr/numass/data/ESpectrum.java | 89 ++ .../java/inr/numass/data/ESpectrumUtils.java | 42 + .../inr/numass/data/MonitorCorrector.java | 90 ++ .../java/inr/numass/data/MonitorPoint.java | 74 ++ .../main/java/inr/numass/data/NMEvent.java | 49 + .../src/main/java/inr/numass/data/NMFile.java | 120 ++ .../main/java/inr/numass/data/NMPoint.java | 256 ++++ .../main/java/inr/numass/data/NumassData.java | 29 + .../inr/numass/data/NumassDataReader.java | 515 ++++++++ .../java/inr/numass/data/NumassPawReader.java | 60 + .../main/java/inr/numass/data/RawNMFile.java | 132 ++ .../main/java/inr/numass/data/RawNMPoint.java | 181 +++ .../inr/numass/data/SpectrumDataAdapter.java | 112 ++ .../inr/numass/data/SpectrumGenerator.java | 166 +++ .../inr/numass/data/SpectrumInformation.java | 124 ++ .../java/inr/numass/debunch/DebunchData.java | 207 ++++ .../java/inr/numass/debunch/DebunchEvent.java | 78 ++ .../inr/numass/debunch/DebunchReport.java | 35 + .../inr/numass/debunch/DebunchReportImpl.java | 83 ++ .../java/inr/numass/debunch/Debuncher.java | 26 + .../main/java/inr/numass/debunch/Frame.java | 101 ++ .../inr/numass/debunch/FrameAnalizer.java | 242 ++++ .../inr/numass/generators/BunchGenerator.java | 204 ++++ .../generators/EventChainGenerator.java | 183 +++ .../inr/numass/generators/EventGenerator.java | 114 ++ .../java/inr/numass/models/BetaSpectrum.java | 237 ++++ .../inr/numass/models/CustomNBkgSpectrum.java | 50 + .../numass/models/EmpiricalLossSpectrum.java | 75 ++ .../ExperimentalVariableLossSpectrum.java | 178 +++ .../src/main/java/inr/numass/models/FSS.java | 73 ++ .../inr/numass/models/GaussResolution.java | 166 +++ .../numass/models/GaussSourceSpectrum.java | 89 ++ .../java/inr/numass/models/GunSpectrum.java | 155 +++ .../inr/numass/models/GunTailSpectrum.java | 89 ++ .../inr/numass/models/LossCalculator.java | 438 +++++++ .../inr/numass/models/LossResConvolution.java | 44 + .../inr/numass/models/ModularSpectrum.java | 234 ++++ .../numass/models/ModularTritiumSpectrum.java | 216 ++++ .../java/inr/numass/models/NBkgSpectrum.java | 91 ++ .../numass/models/NamedSpectrumCaching.java | 236 ++++ .../numass/models/RangedNamedSetSpectrum.java | 26 + .../inr/numass/models/ResolutionFunction.java | 116 ++ .../java/inr/numass/models/SimpleRange.java | 50 + .../java/inr/numass/models/SpectrumRange.java | 28 + .../java/inr/numass/models/Transmission.java | 44 + .../models/TransmissionConvolution.java | 85 ++ .../models/TransmissionInterpolator.java | 185 +++ .../numass/models/TritiumSpectrumCaching.java | 69 ++ .../numass/models/VariableLossSpectrum.java | 147 +++ .../java/inr/numass/utils/DataModelUtils.java | 51 + .../java/inr/numass/utils/OldDataReader.java | 186 +++ .../java/inr/numass/utils/TritiumUtils.java | 125 ++ .../workbench/NumassWorkbenchController.java | 356 ++++++ .../java/inr/numass/workbench/OutputTab.java | 37 + .../inr/numass/workbench/PlotOutputTab.java | 46 + .../java/inr/numass/workbench/StagePane.java | 62 + .../inr/numass/workbench/StagePaneHolder.java | 15 + .../inr/numass/workbench/TextOutputTab.java | 48 + .../java/inr/numass/workbench/Workbench.java | 45 + .../numass/workbench/WorkbenchIOManager.java | 70 ++ .../inr/numass/workbench/WorkbenchUtils.java | 14 + .../services/hep.dataforge.context.Plugin | 1 + .../src/main/resources/data/d2_17_1.xml | 61 + .../main/resources/fxml/NumassWorkbench.fxml | 61 + .../main/resources/numass/models/transmission | 29 + .../java/inr/numass/models/PlotScatter.java | 41 + .../models/TestNeLossParametrisation.java | 68 ++ .../models/TransmissionInterpolatorTest.java | 40 + .../inr/numass/run/NumassSpectrumTest.java | 136 +++ numass-prop/build.gradle | 6 + numass-prop/pom.old | 46 + .../inr/numass/prop/AbstractTransmission.java | 165 +++ .../java/inr/numass/prop/BaseFunction.java | 62 + .../src/main/java/inr/numass/prop/Main.java | 32 + .../java/inr/numass/prop/PoissonAdapter.java | 39 + .../java/inr/numass/prop/PropContext.java | 53 + .../java/inr/numass/prop/PropResolution.java | 143 +++ .../main/java/inr/numass/prop/PropTest.java | 94 ++ .../inr/numass/prop/SplitNormalSpectrum.java | 61 + .../java/inr/numass/prop/ar/FitJNAData.java | 134 ++ .../java/inr/numass/prop/ar/JNAEpisode.java | 55 + .../java/inr/numass/prop/ar/JNASpectrum.java | 140 +++ .../numass/prop/ar/MergeJNADataAction.java | 72 ++ .../inr/numass/prop/ar/ReadJNADataAction.java | 170 +++ .../hep/dataforge/numass/prop/TestFit.java | 56 + .../hep/dataforge/numass/prop/TestReader.java | 87 ++ numass-storage/build.gradle | 11 + numass-storage/docs/server_commands.md | 189 +++ numass-storage/numass-client/build.gradle | 25 + .../inr/numass/scripts/FixStampEndings.groovy | 27 + .../inr/numass/scripts/TestClient.groovy | 46 + .../numass/scripts/TestFileTransfer.groovy | 44 + .../numass/scripts/TestRemoteClient.groovy | 46 + .../inr/numass/scripts/TestStateChange.groovy | 46 + .../numass/scripts/TestStorageAccess.groovy | 65 + .../java/inr/numass/client/NumassClient.java | 312 +++++ numass-storage/numass-server/build.gradle | 18 + .../inr/numass/scripts/TestServer.groovy | 41 + .../java/inr/numass/server/HandlerUtils.java | 69 ++ .../inr/numass/server/NumassRootHandler.java | 90 ++ .../java/inr/numass/server/NumassRun.java | 126 ++ .../java/inr/numass/server/NumassServer.java | 297 +++++ .../inr/numass/server/NumassServerDaemon.java | 115 ++ .../server/UnknownNumassActionException.java | 47 + .../inr/numass/storage/NumassDataLoader.java | 285 +++++ .../inr/numass/storage/NumassStorage.java | 258 ++++ numass-viewer/build.gradle | 18 + .../private/cache/retriever/catalog.xml | 21 + .../java/javase/overview/index.html | 1077 +++++++++++++++++ .../numass/viewer/MainViewerController.java | 271 +++++ .../inr/numass/viewer/MspViewController.java | 208 ++++ .../viewer/NumassLoaderTreeBuilder.java | 242 ++++ .../viewer/NumassLoaderViewComponent.java | 325 +++++ .../inr/numass/viewer/NumassViewerUtils.java | 53 + .../numass/viewer/ProgressUpdateCallback.java | 15 + .../numass/viewer/TestDirectoryViewer.java | 66 + .../main/java/inr/numass/viewer/Viewer.java | 64 + .../src/main/resources/fxml/MainView.fxml | 101 ++ .../src/main/resources/fxml/MspView.fxml | 53 + .../main/resources/fxml/NumassLoaderView.fxml | 117 ++ numass.gradle | 67 + settings.gradle | 25 + 210 files changed, 24428 insertions(+) create mode 100644 .hgignore create mode 100644 build.gradle create mode 100644 numass-control/build.gradle create mode 100644 numass-control/cryotemp/build.gradle create mode 100644 numass-control/cryotemp/src/main/java/inr/numass/cryotemp/PKT8App.java create mode 100644 numass-control/cryotemp/src/main/java/inr/numass/cryotemp/PKT8Device.java create mode 100644 numass-control/cryotemp/src/main/java/inr/numass/cryotemp/PKT8MainViewController.java create mode 100644 numass-control/cryotemp/src/main/java/inr/numass/cryotemp/PKT8VirtualPort.java create mode 100644 numass-control/cryotemp/src/main/resources/config/defaultConfig.xml create mode 100644 numass-control/cryotemp/src/main/resources/fxml/PKT8MainView.fxml create mode 100644 numass-control/magnet/build.gradle create mode 100644 numass-control/magnet/src/main/java/inr/numass/control/magnet/MagnetController.java create mode 100644 numass-control/magnet/src/main/java/inr/numass/control/magnet/MagnetStateListener.java create mode 100644 numass-control/magnet/src/main/java/inr/numass/control/magnet/MagnetStatus.java create mode 100644 numass-control/magnet/src/main/java/inr/numass/control/magnet/SafeMagnetController.java create mode 100644 numass-control/magnet/src/main/java/inr/numass/control/magnet/SetCurrent.java create mode 100644 numass-control/magnet/src/main/java/inr/numass/control/magnet/Talk.java create mode 100644 numass-control/magnet/src/main/java/inr/numass/control/magnet/TestController.java create mode 100644 numass-control/magnet/src/main/java/inr/numass/control/magnet/TestSynch.java create mode 100644 numass-control/magnet/src/main/java/inr/numass/control/magnet/VirtualLambdaPort.java create mode 100644 numass-control/magnet/src/main/java/inr/numass/control/magnet/fx/MagnetControllerApp.java create mode 100644 numass-control/magnet/src/main/java/inr/numass/control/magnet/fx/MagnetControllerComponent.java create mode 100644 numass-control/magnet/src/main/java/inr/numass/control/magnet/fx/TestApp.java create mode 100644 numass-control/magnet/src/main/resources/fxml/SingleMagnet.fxml create mode 100644 numass-control/magnet/src/main/resources/logback.xml create mode 100644 numass-control/msp/build.gradle create mode 100644 numass-control/msp/src/main/java/inr/numass/control/msp/MspDevice.java create mode 100644 numass-control/msp/src/main/java/inr/numass/control/msp/MspListener.java create mode 100644 numass-control/msp/src/main/java/inr/numass/control/msp/MspTest.java create mode 100644 numass-control/msp/src/main/java/inr/numass/control/msp/fx/MspApp.java create mode 100644 numass-control/msp/src/main/java/inr/numass/control/msp/fx/MspViewController.java create mode 100644 numass-control/msp/src/main/resources/config/msp-config.xml create mode 100644 numass-control/msp/src/main/resources/fxml/MspView.fxml create mode 100644 numass-control/msp/src/test/java/inr/numass/control/msp/TestScanner.java create mode 100644 numass-control/vac/build.gradle create mode 100644 numass-control/vac/src/main/java/inr/numass/readvac/MKSVacuumeterDevice.java create mode 100644 numass-control/vac/src/main/java/inr/numass/readvac/Main.java create mode 100644 numass-control/vac/src/main/java/inr/numass/readvac/P1ControlException.java create mode 100644 numass-control/vac/src/main/java/inr/numass/readvac/ResponseParseException.java create mode 100644 numass-control/vac/src/main/java/inr/numass/readvac/TextAreaOutputStream.java create mode 100644 numass-control/vac/src/main/java/inr/numass/readvac/VACDeviceReader.java create mode 100644 numass-control/vac/src/main/java/inr/numass/readvac/VACFileReader.java create mode 100644 numass-control/vac/src/main/java/inr/numass/readvac/VACFrame.form create mode 100644 numass-control/vac/src/main/java/inr/numass/readvac/VACFrame.java create mode 100644 numass-control/vac/src/main/java/inr/numass/readvac/VACManager.java create mode 100644 numass-control/vac/src/main/resources/inr/numass/readvac/testConfig.xml create mode 100644 numass-control/vac/src/test/java/inr/numass/readvac/TestMain.java create mode 100644 numass-control/vac/src/test/java/inr/numass/readvac/TestRemote.java create mode 100644 numass-control/vac/src/test/java/inr/numass/readvac/TimeShiftTest.java create mode 100644 numass-control/vac/vac-config.xml create mode 100644 numass-main/build.gradle create mode 100644 numass-main/gradle.properties create mode 100644 numass-main/src/main/groovy/inr/numass/scripts/CalculateLossTail.groovy create mode 100644 numass-main/src/main/groovy/inr/numass/scripts/FindExIonRatio.groovy create mode 100644 numass-main/src/main/groovy/inr/numass/scripts/ListActions.groovy create mode 100644 numass-main/src/main/groovy/inr/numass/scripts/Loss2014.groovy create mode 100644 numass-main/src/main/groovy/inr/numass/scripts/LossTailCalculation.groovy create mode 100644 numass-main/src/main/groovy/inr/numass/scripts/OldFitResultReader.groovy create mode 100644 numass-main/src/main/groovy/inr/numass/scripts/OldTest.groovy create mode 100644 numass-main/src/main/groovy/inr/numass/scripts/PlotViewer.groovy create mode 100644 numass-main/src/main/groovy/inr/numass/scripts/PrintLossFunctions.groovy create mode 100644 numass-main/src/main/groovy/inr/numass/scripts/ResolutionTest.groovy create mode 100644 numass-main/src/main/groovy/inr/numass/scripts/RunScriptsFromDirectory.groovy create mode 100644 numass-main/src/main/groovy/inr/numass/scripts/SignificanceTest.groovy create mode 100644 numass-main/src/main/groovy/inr/numass/scripts/Simulate.groovy create mode 100644 numass-main/src/main/groovy/inr/numass/scripts/SimulateGun.groovy create mode 100644 numass-main/src/main/groovy/inr/numass/scripts/Systematics.groovy create mode 100644 numass-main/src/main/groovy/inr/numass/scripts/TestExperimentalVariableLossSpectrum.groovy create mode 100644 numass-main/src/main/groovy/inr/numass/scripts/TheoreticalLossFunction.groovy create mode 100644 numass-main/src/main/groovy/inr/numass/scripts/TritiumTest.groovy create mode 100644 numass-main/src/main/java/hep/dataforge/plotfit/PlotFitResultAction.java create mode 100644 numass-main/src/main/java/inr/numass/Main.java create mode 100644 numass-main/src/main/java/inr/numass/NumassContext.java create mode 100644 numass-main/src/main/java/inr/numass/NumassIO.java create mode 100644 numass-main/src/main/java/inr/numass/NumassPlugin.java create mode 100644 numass-main/src/main/java/inr/numass/actions/AdjustErrorsAction.java create mode 100644 numass-main/src/main/java/inr/numass/actions/BorderData.java create mode 100644 numass-main/src/main/java/inr/numass/actions/DebunchAction.java create mode 100644 numass-main/src/main/java/inr/numass/actions/FindBorderAction.java create mode 100644 numass-main/src/main/java/inr/numass/actions/MergeDataAction.java create mode 100644 numass-main/src/main/java/inr/numass/actions/MonitorCorrectAction.java create mode 100644 numass-main/src/main/java/inr/numass/actions/PrepareDataAction.java create mode 100644 numass-main/src/main/java/inr/numass/actions/ReadNumassDataAction.java create mode 100644 numass-main/src/main/java/inr/numass/actions/ShowLossSpectrumAction.java create mode 100644 numass-main/src/main/java/inr/numass/actions/ShowSpectrumAction.java create mode 100644 numass-main/src/main/java/inr/numass/actions/SlicedData.java create mode 100644 numass-main/src/main/java/inr/numass/actions/SlicingAction.java create mode 100644 numass-main/src/main/java/inr/numass/actions/SummaryAction.java create mode 100644 numass-main/src/main/java/inr/numass/data/ESpectrum.java create mode 100644 numass-main/src/main/java/inr/numass/data/ESpectrumUtils.java create mode 100644 numass-main/src/main/java/inr/numass/data/MonitorCorrector.java create mode 100644 numass-main/src/main/java/inr/numass/data/MonitorPoint.java create mode 100644 numass-main/src/main/java/inr/numass/data/NMEvent.java create mode 100644 numass-main/src/main/java/inr/numass/data/NMFile.java create mode 100644 numass-main/src/main/java/inr/numass/data/NMPoint.java create mode 100644 numass-main/src/main/java/inr/numass/data/NumassData.java create mode 100644 numass-main/src/main/java/inr/numass/data/NumassDataReader.java create mode 100644 numass-main/src/main/java/inr/numass/data/NumassPawReader.java create mode 100644 numass-main/src/main/java/inr/numass/data/RawNMFile.java create mode 100644 numass-main/src/main/java/inr/numass/data/RawNMPoint.java create mode 100644 numass-main/src/main/java/inr/numass/data/SpectrumDataAdapter.java create mode 100644 numass-main/src/main/java/inr/numass/data/SpectrumGenerator.java create mode 100644 numass-main/src/main/java/inr/numass/data/SpectrumInformation.java create mode 100644 numass-main/src/main/java/inr/numass/debunch/DebunchData.java create mode 100644 numass-main/src/main/java/inr/numass/debunch/DebunchEvent.java create mode 100644 numass-main/src/main/java/inr/numass/debunch/DebunchReport.java create mode 100644 numass-main/src/main/java/inr/numass/debunch/DebunchReportImpl.java create mode 100644 numass-main/src/main/java/inr/numass/debunch/Debuncher.java create mode 100644 numass-main/src/main/java/inr/numass/debunch/Frame.java create mode 100644 numass-main/src/main/java/inr/numass/debunch/FrameAnalizer.java create mode 100644 numass-main/src/main/java/inr/numass/generators/BunchGenerator.java create mode 100644 numass-main/src/main/java/inr/numass/generators/EventChainGenerator.java create mode 100644 numass-main/src/main/java/inr/numass/generators/EventGenerator.java create mode 100644 numass-main/src/main/java/inr/numass/models/BetaSpectrum.java create mode 100644 numass-main/src/main/java/inr/numass/models/CustomNBkgSpectrum.java create mode 100644 numass-main/src/main/java/inr/numass/models/EmpiricalLossSpectrum.java create mode 100644 numass-main/src/main/java/inr/numass/models/ExperimentalVariableLossSpectrum.java create mode 100644 numass-main/src/main/java/inr/numass/models/FSS.java create mode 100644 numass-main/src/main/java/inr/numass/models/GaussResolution.java create mode 100644 numass-main/src/main/java/inr/numass/models/GaussSourceSpectrum.java create mode 100644 numass-main/src/main/java/inr/numass/models/GunSpectrum.java create mode 100644 numass-main/src/main/java/inr/numass/models/GunTailSpectrum.java create mode 100644 numass-main/src/main/java/inr/numass/models/LossCalculator.java create mode 100644 numass-main/src/main/java/inr/numass/models/LossResConvolution.java create mode 100644 numass-main/src/main/java/inr/numass/models/ModularSpectrum.java create mode 100644 numass-main/src/main/java/inr/numass/models/ModularTritiumSpectrum.java create mode 100644 numass-main/src/main/java/inr/numass/models/NBkgSpectrum.java create mode 100644 numass-main/src/main/java/inr/numass/models/NamedSpectrumCaching.java create mode 100644 numass-main/src/main/java/inr/numass/models/RangedNamedSetSpectrum.java create mode 100644 numass-main/src/main/java/inr/numass/models/ResolutionFunction.java create mode 100644 numass-main/src/main/java/inr/numass/models/SimpleRange.java create mode 100644 numass-main/src/main/java/inr/numass/models/SpectrumRange.java create mode 100644 numass-main/src/main/java/inr/numass/models/Transmission.java create mode 100644 numass-main/src/main/java/inr/numass/models/TransmissionConvolution.java create mode 100644 numass-main/src/main/java/inr/numass/models/TransmissionInterpolator.java create mode 100644 numass-main/src/main/java/inr/numass/models/TritiumSpectrumCaching.java create mode 100644 numass-main/src/main/java/inr/numass/models/VariableLossSpectrum.java create mode 100644 numass-main/src/main/java/inr/numass/utils/DataModelUtils.java create mode 100644 numass-main/src/main/java/inr/numass/utils/OldDataReader.java create mode 100644 numass-main/src/main/java/inr/numass/utils/TritiumUtils.java create mode 100644 numass-main/src/main/java/inr/numass/workbench/NumassWorkbenchController.java create mode 100644 numass-main/src/main/java/inr/numass/workbench/OutputTab.java create mode 100644 numass-main/src/main/java/inr/numass/workbench/PlotOutputTab.java create mode 100644 numass-main/src/main/java/inr/numass/workbench/StagePane.java create mode 100644 numass-main/src/main/java/inr/numass/workbench/StagePaneHolder.java create mode 100644 numass-main/src/main/java/inr/numass/workbench/TextOutputTab.java create mode 100644 numass-main/src/main/java/inr/numass/workbench/Workbench.java create mode 100644 numass-main/src/main/java/inr/numass/workbench/WorkbenchIOManager.java create mode 100644 numass-main/src/main/java/inr/numass/workbench/WorkbenchUtils.java create mode 100644 numass-main/src/main/resources/META-INF/services/hep.dataforge.context.Plugin create mode 100644 numass-main/src/main/resources/data/d2_17_1.xml create mode 100644 numass-main/src/main/resources/fxml/NumassWorkbench.fxml create mode 100644 numass-main/src/main/resources/numass/models/transmission create mode 100644 numass-main/src/test/java/inr/numass/models/PlotScatter.java create mode 100644 numass-main/src/test/java/inr/numass/models/TestNeLossParametrisation.java create mode 100644 numass-main/src/test/java/inr/numass/models/TransmissionInterpolatorTest.java create mode 100644 numass-main/src/test/java/inr/numass/run/NumassSpectrumTest.java create mode 100644 numass-prop/build.gradle create mode 100644 numass-prop/pom.old create mode 100644 numass-prop/src/main/java/inr/numass/prop/AbstractTransmission.java create mode 100644 numass-prop/src/main/java/inr/numass/prop/BaseFunction.java create mode 100644 numass-prop/src/main/java/inr/numass/prop/Main.java create mode 100644 numass-prop/src/main/java/inr/numass/prop/PoissonAdapter.java create mode 100644 numass-prop/src/main/java/inr/numass/prop/PropContext.java create mode 100644 numass-prop/src/main/java/inr/numass/prop/PropResolution.java create mode 100644 numass-prop/src/main/java/inr/numass/prop/PropTest.java create mode 100644 numass-prop/src/main/java/inr/numass/prop/SplitNormalSpectrum.java create mode 100644 numass-prop/src/main/java/inr/numass/prop/ar/FitJNAData.java create mode 100644 numass-prop/src/main/java/inr/numass/prop/ar/JNAEpisode.java create mode 100644 numass-prop/src/main/java/inr/numass/prop/ar/JNASpectrum.java create mode 100644 numass-prop/src/main/java/inr/numass/prop/ar/MergeJNADataAction.java create mode 100644 numass-prop/src/main/java/inr/numass/prop/ar/ReadJNADataAction.java create mode 100644 numass-prop/src/test/java/hep/dataforge/numass/prop/TestFit.java create mode 100644 numass-prop/src/test/java/hep/dataforge/numass/prop/TestReader.java create mode 100644 numass-storage/build.gradle create mode 100644 numass-storage/docs/server_commands.md create mode 100644 numass-storage/numass-client/build.gradle create mode 100644 numass-storage/numass-client/src/main/groovy/inr/numass/scripts/FixStampEndings.groovy create mode 100644 numass-storage/numass-client/src/main/groovy/inr/numass/scripts/TestClient.groovy create mode 100644 numass-storage/numass-client/src/main/groovy/inr/numass/scripts/TestFileTransfer.groovy create mode 100644 numass-storage/numass-client/src/main/groovy/inr/numass/scripts/TestRemoteClient.groovy create mode 100644 numass-storage/numass-client/src/main/groovy/inr/numass/scripts/TestStateChange.groovy create mode 100644 numass-storage/numass-client/src/main/groovy/inr/numass/scripts/TestStorageAccess.groovy create mode 100644 numass-storage/numass-client/src/main/java/inr/numass/client/NumassClient.java create mode 100644 numass-storage/numass-server/build.gradle create mode 100644 numass-storage/numass-server/src/main/groovy/inr/numass/scripts/TestServer.groovy create mode 100644 numass-storage/numass-server/src/main/java/inr/numass/server/HandlerUtils.java create mode 100644 numass-storage/numass-server/src/main/java/inr/numass/server/NumassRootHandler.java create mode 100644 numass-storage/numass-server/src/main/java/inr/numass/server/NumassRun.java create mode 100644 numass-storage/numass-server/src/main/java/inr/numass/server/NumassServer.java create mode 100644 numass-storage/numass-server/src/main/java/inr/numass/server/NumassServerDaemon.java create mode 100644 numass-storage/numass-server/src/main/java/inr/numass/server/UnknownNumassActionException.java create mode 100644 numass-storage/src/main/java/inr/numass/storage/NumassDataLoader.java create mode 100644 numass-storage/src/main/java/inr/numass/storage/NumassStorage.java create mode 100644 numass-viewer/build.gradle create mode 100644 numass-viewer/private/cache/retriever/catalog.xml create mode 100644 numass-viewer/private/cache/retriever/www.oracle.com/technetwork/java/javase/overview/index.html create mode 100644 numass-viewer/src/main/java/inr/numass/viewer/MainViewerController.java create mode 100644 numass-viewer/src/main/java/inr/numass/viewer/MspViewController.java create mode 100644 numass-viewer/src/main/java/inr/numass/viewer/NumassLoaderTreeBuilder.java create mode 100644 numass-viewer/src/main/java/inr/numass/viewer/NumassLoaderViewComponent.java create mode 100644 numass-viewer/src/main/java/inr/numass/viewer/NumassViewerUtils.java create mode 100644 numass-viewer/src/main/java/inr/numass/viewer/ProgressUpdateCallback.java create mode 100644 numass-viewer/src/main/java/inr/numass/viewer/TestDirectoryViewer.java create mode 100644 numass-viewer/src/main/java/inr/numass/viewer/Viewer.java create mode 100644 numass-viewer/src/main/resources/fxml/MainView.fxml create mode 100644 numass-viewer/src/main/resources/fxml/MspView.fxml create mode 100644 numass-viewer/src/main/resources/fxml/NumassLoaderView.fxml create mode 100644 numass.gradle create mode 100644 settings.gradle diff --git a/.hgignore b/.hgignore new file mode 100644 index 00000000..f4747601 --- /dev/null +++ b/.hgignore @@ -0,0 +1,12 @@ +syntax: glob +*.orig +*.orig.* +*.chg.* +*.rej +*.conflict +build/* +target/* +.gradle/* +.nb-gradle/* +.idea/ +*.iml diff --git a/build.gradle b/build.gradle new file mode 100644 index 00000000..bd042fae --- /dev/null +++ b/build.gradle @@ -0,0 +1,42 @@ +apply plugin: 'base' +apply plugin: 'project-report' +apply plugin: 'build-dashboard' + + +htmlDependencyReport { + projects = project.allprojects +} + +File dataforgeDir = new File(rootDir,'../dataforge'); + +if(dataforgeDir.exists()){ + rootProject.ext.dataforgeLocal = true; +} + +subprojects{ + if(path.startsWith(':dataforge')){ + apply from: new File(dataforgeDir, 'dataforge.gradle') + } + if(path.startsWith(':numass')){ + apply from: rootProject.file('numass.gradle') + } +} + +buildscript { + repositories { jcenter() } + dependencies { + classpath 'com.github.jengelman.gradle.plugins:shadow:1.2.+' + } +} +//task mergedJavadoc(type: Javadoc, description: 'Creates Javadoc from all the projects.') { +// title = 'All modules' +// destinationDir = new File(project.buildDir, 'merged-javadoc') +// +// // Note: The closures below are executed lazily. +// source { +// subprojects*.sourceSets*.main*.allSource +// } +// classpath.from { +// subprojects*.configurations*.compile*.copyRecursive({!(it instanceof ProjectDependency)})*.resolve() +// } +//} diff --git a/numass-control/build.gradle b/numass-control/build.gradle new file mode 100644 index 00000000..4b503e6a --- /dev/null +++ b/numass-control/build.gradle @@ -0,0 +1,2 @@ +apply plugin: 'base' // To add "clean" task to the root project. + diff --git a/numass-control/cryotemp/build.gradle b/numass-control/cryotemp/build.gradle new file mode 100644 index 00000000..bc9d702a --- /dev/null +++ b/numass-control/cryotemp/build.gradle @@ -0,0 +1,17 @@ +apply plugin: 'application' + +if (!hasProperty('mainClass')) { + ext.mainClass = 'inr.numass.cryotemp.PKT8App' +} +mainClassName = mainClass + + +//mainClassName = "inr.numass.readvac.Main" + +dependencies { + compile 'commons-cli:commons-cli:1.3' + compile 'de.jensd:shichimifx:1.0.5' + compile project(':dataforge-control') + compile project(':dataforge-storage') + compile project(':dataforge-plots') +} \ No newline at end of file diff --git a/numass-control/cryotemp/src/main/java/inr/numass/cryotemp/PKT8App.java b/numass-control/cryotemp/src/main/java/inr/numass/cryotemp/PKT8App.java new file mode 100644 index 00000000..34d7437e --- /dev/null +++ b/numass-control/cryotemp/src/main/java/inr/numass/cryotemp/PKT8App.java @@ -0,0 +1,85 @@ +/* + * Copyright 2015 Alexander Nozik. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package inr.numass.cryotemp; + +import ch.qos.logback.classic.Level; +import hep.dataforge.exceptions.ControlException; +import hep.dataforge.storage.commons.StoragePlugin; +import java.io.IOException; +import java.util.Locale; +import javafx.application.Application; +import javafx.fxml.FXMLLoader; +import javafx.scene.Parent; +import javafx.scene.Scene; +import javafx.stage.Stage; +import org.slf4j.LoggerFactory; + +/** + * + * @author darksnake + */ +public class PKT8App extends Application { + + PKT8MainViewController controller; + + @Override + public void start(Stage primaryStage) throws IOException, ControlException { + Locale.setDefault(Locale.US);// чтобы отделение десятичных знаков было точкой + ch.qos.logback.classic.Logger rootLogger = (ch.qos.logback.classic.Logger) LoggerFactory.getLogger(ch.qos.logback.classic.Logger.ROOT_LOGGER_NAME); + rootLogger.setLevel(Level.INFO); + new StoragePlugin().startGlobal(); + + FXMLLoader loader = new FXMLLoader(getClass().getResource("/fxml/PKT8MainView.fxml")); + + Parent parent = loader.load(); + controller = loader.getController(); + +// Meta deviceMeta = XMLMetaConverter.fromStream(getClass().getResourceAsStream("/defaultConfig.xml")); + +// controller.setupDevice(deviceMeta); + + Scene scene = new Scene(parent, 600, 400); + + + primaryStage.setTitle("PKT8 cryogenic temperature viewer"); + primaryStage.setScene(scene); + primaryStage.setMinHeight(400); + primaryStage.setMinWidth(600); +// primaryStage.setResizable(false); + + primaryStage.show(); + } + + @Override + public void stop() throws Exception { + super.stop(); + if(controller!=null){ + controller.close(); + controller = null; + } +// System.exit(0); + } + + + + /** + * @param args the command line arguments + */ + public static void main(String[] args) { + launch(args); + } + +} diff --git a/numass-control/cryotemp/src/main/java/inr/numass/cryotemp/PKT8Device.java b/numass-control/cryotemp/src/main/java/inr/numass/cryotemp/PKT8Device.java new file mode 100644 index 00000000..db5edb1c --- /dev/null +++ b/numass-control/cryotemp/src/main/java/inr/numass/cryotemp/PKT8Device.java @@ -0,0 +1,418 @@ +/* + * Copyright 2015 Alexander Nozik. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package inr.numass.cryotemp; + +import hep.dataforge.content.Named; +import hep.dataforge.context.Context; +import hep.dataforge.control.collectors.RegularPointCollector; +import hep.dataforge.control.devices.DataDevice; +import hep.dataforge.control.ports.PortHandler; +import hep.dataforge.control.ports.TcpPortHandler; +import hep.dataforge.data.DataFormatBuilder; +import hep.dataforge.exceptions.ControlException; +import hep.dataforge.exceptions.PortException; +import hep.dataforge.exceptions.StorageException; +import hep.dataforge.meta.Annotated; +import hep.dataforge.meta.Meta; +import hep.dataforge.meta.MetaBuilder; +import hep.dataforge.storage.api.PointLoader; +import hep.dataforge.storage.api.Storage; +import hep.dataforge.storage.commons.LoaderFactory; +import hep.dataforge.values.Value; +import java.time.Duration; +import java.time.Instant; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.function.Function; + +/** + * A device controller for Dubna PKT 8 cryogenic thermometry device + * + * @author Alexander Nozik + */ +public class PKT8Device extends DataDevice implements PortHandler.PortController { + + private static final String[] CHANNEL_DESIGNATIONS = {"a", "b", "c", "d", "e", "f", "g", "h"}; + + private PointLoader pointLoader; + private RegularPointCollector collector; + + private boolean isStarted = false; + private PortHandler handler; + private int sps = -1; + private int pga = -1; + private int abuf = -1; + + /** + * The key is the letter (a,b,c,d...) as in measurements + */ + private final Map channels = new HashMap<>(); + + public PKT8Device(String name, Context context, Meta annotation) { + super(name, context, annotation); + } + + /** + * Start measurement + * + * @throws ControlException + */ + @Override + public void doStart(Meta measurement) throws ControlException { + +// Meta meta = new MetaChain("device", measurement.meta(),meta()); + if (!isStarted) { + //setup storage + + try { + Storage storage = getPrimaryStorage(measurement); + String suffix = Integer.toString((int) Instant.now().toEpochMilli()); + + // Building data format + DataFormatBuilder formatBuilder = new DataFormatBuilder() + .addTime("timestamp"); + List names = new ArrayList<>(); + + for (PKT8Channel channel : this.channels.values()) { + formatBuilder.addNumber(channel.getName()); + names.add(channel.getName()); + } + + this.pointLoader = LoaderFactory.buildPointLoder(storage, "cryotemp_" + suffix, "", "timestamp", formatBuilder.build()); + + Duration duration = Duration.parse(meta().getString("averagingDuration", "PT30S")); + + collector = new RegularPointCollector((dp) -> { + if (pointLoader != null) { + try { + getLogger().debug("Point measurement complete. Pushing..."); + pointLoader.push(dp); + } catch (StorageException ex) { + getLogger().error("Error while pushing point to loader", ex); + } + } + }, duration, names); + } catch (StorageException ex) { + getLogger().error("Can't setup storage", ex); + } + + handler.send("s"); + isStarted = true; + } + } + + @Override + public void init() throws ControlException { + + //read channel configuration + if (meta().hasNode("channel")) { + for (Meta node : meta().getNodes("channel")) { + String designation = node.getString("designation", "default"); + this.channels.put(designation, new PKT8Channel(node)); + } + } else { + //set default channel configuration + for (String designation : CHANNEL_DESIGNATIONS) { + channels.put(designation, new PKT8Channel(designation)); + } + getLogger().warn("No channels defined in configuration"); + } + + //setup connection + if (meta().hasNode("debug")) { + handler = new PKT8VirtualPort("PKT8", meta().getNode("debug")); + } else { + String ip = this.meta().getString("connection.ip", "127.0.0.1"); + int port = this.meta().getInt("connection.port", 4001); + handler = new TcpPortHandler(ip, port, getName()); + } + handler.setDelimeter("\n"); + handler.holdBy(this); + handler.open(); + handler.send("p"); + handler.sendAndWait("p", null, 1000); + + //update parameters from meta + if (meta().hasValue("pga")) { + getLogger().info("Setting dynamic range to " + meta().getInt("pga")); + String response = handler.sendAndWait("g" + meta().getInt("pga"), null, 400).trim(); + if (response.contains("=")) { + this.pga = Integer.parseInt(response.substring(4)); + } else { + getLogger().error("Setting pga failsed with message: " + response); + } + } + + setSPS(meta().getInt("sps", 0)); + setBUF(meta().getInt("abuf", 100)); + + super.init(); + } + + @Override + public void shutdown() throws ControlException { + stop(); + try { + this.handler.unholdBy(this); + this.handler.close(); + + } catch (Exception ex) { + throw new ControlException(ex); + } + super.shutdown(); + } + + private void setSPS(int sps) throws PortException { + getLogger().info("Setting sampling rate to " + spsToStr(sps)); + String response = handler.sendAndWait("v" + sps, null, 400).trim(); + if (response.contains("=")) { + this.sps = Integer.parseInt(response.substring(4)); + getLogger().info("successfully sampling rate to {}", spsToStr(this.sps)); + } else { + getLogger().error("Setting sps failsed with message: " + response); + } + } + + public Collection getChanels() { + return this.channels.values(); + } + + private void setBUF(int buf) throws PortException { + getLogger().info("Setting avaraging buffer size to " + buf); + String response = handler.sendAndWait("b" + buf, null, 400).trim(); + if (response.contains("=")) { + this.abuf = Integer.parseInt(response.substring(14)); + getLogger().info("successfully set buffer size to {}", this.abuf); + } else { + getLogger().error("Setting averaging buffer failsed with message: " + response); + } + } + + @Override + public void doStop() throws ControlException { + handler.send("p"); + isStarted = false; + if (collector != null) { + collector.cancel(); + } + } + + public void changeParameters(int sps, int abuf) { + this.executor.submit(() -> { + try { + stop(); + //setting sps + setSPS(sps); + //setting buffer + setBUF(abuf); + start(); + } catch (ControlException ex) { + getLogger().error("Control error", ex); + } + }); + } + + @Override + public void accept(String message) { + String trimmed = message.trim(); + + if (isStarted) { + if (trimmed.equals("stopped")) { + isStarted = false; + getLogger().info("Measurement paused"); + } else { + String designation = trimmed.substring(0, 1); + double rawValue = Double.parseDouble(trimmed.substring(1)) / 100; + + if (channels.containsKey(designation)) { + PKT8Channel channel = channels.get(designation); + notifyMeasurementComplete(channel.getName(), rawValue, channel.getTemperature(rawValue)); + collector.put(channel.getName(), channel.getTemperature(rawValue)); + } else { + notifyMeasurementComplete(designation, rawValue, -1); + } + + } + } + } + + private void notifyMeasurementComplete(String channel, double rawValue, double temperature) { + measurementResult(null, new PKT8Measurement(channel, rawValue, temperature)); + } + + @Override + public void error(String errorMessage, Throwable error) { + + } + + /** + * '0' : 2,5 SPS '1' : 5 SPS '2' : 10 SPS '3' : 25 SPS '4' : 50 SPS '5' : + * 100 SPS '6' : 500 SPS '7' : 1 kSPS '8' : 3,75 kSPS + * + * @param sps + * @return + */ + private String spsToStr(int sps) { + switch (sps) { + case 0: + return "2,5 SPS"; + case 1: + return "5 SPS"; + case 2: + return "10 SPS"; + case 3: + return "25 SPS"; + case 4: + return "50 SPS"; + case 5: + return "100 SPS"; + case 6: + return "500 SPS"; + case 7: + return "1 kSPS"; + case 8: + return "3.75 kSPS"; + default: + return "unknown value"; + } + } + + /** + * '0' : ± 5 В '1' : ± 2,5 В '2' : ± 1,25 В '3' : ± 0,625 В '4' : ± 312.5 мВ + * '5' : ± 156,25 мВ '6' : ± 78,125 мВ + * + * @param sps + * @return + */ + private String pgaToStr(int sps) { + switch (sps) { + case 0: + return "± 5 V"; + case 1: + return "± 2,5 V"; + case 2: + return "± 1,25 V"; + case 3: + return "± 0,625 V"; + case 4: + return "± 312.5 mV"; + case 5: + return "± 156,25 mV"; + case 6: + return "± 78,125 mV"; + default: + return "unknown value"; + } + } + + public String getSPS() { + return spsToStr(sps); + } + + public String getPGA() { + return pgaToStr(pga); + } + + public String getABUF() { + return Integer.toString(abuf); + } + + public class PKT8Channel implements Named, Annotated { + + private final Meta meta; + private final Function transformation; + + public PKT8Channel(String name) { + this.meta = new MetaBuilder("channel") + .putValue("name", name); + transformation = (d) -> d; + } + + public PKT8Channel(Meta meta) { + this.meta = meta; + + String transformationType = meta.getString("transformationType", "default"); + if (meta.hasValue("coefs")) { + switch (transformationType) { + case "default": + case "hyperbolic": + List coefs = meta.getValue("coefs").listValue(); + double r0 = meta.getDouble("r0", 1000); + transformation = (r) -> { + if (coefs == null) { + return -1d; + } else { + double res = 0; + for (int i = 0; i < coefs.size(); i++) { + res += coefs.get(i).doubleValue() * Math.pow(r0 / r, i); + } + return res; + } + }; + break; + default: + throw new RuntimeException("Unknown transformation type"); + } + } else { + //identity transformation + transformation = (d) -> d; + + } + + } + + @Override + public String getName() { + return meta().getString("name"); + } + + @Override + public Meta meta() { + return meta; + } + + public String description() { + return meta().getString("description", ""); + } + + /** + * + * @param r negative if temperature transformation not defined + * @return + */ + public double getTemperature(double r) { + return transformation.apply(r); + } + + } + + public static class PKT8Measurement { + + public String channel; + public double rawValue; + public double temperature; + + public PKT8Measurement(String channel, double rawValue, double temperature) { + this.channel = channel; + this.rawValue = rawValue; + this.temperature = temperature; + } + + } +} diff --git a/numass-control/cryotemp/src/main/java/inr/numass/cryotemp/PKT8MainViewController.java b/numass-control/cryotemp/src/main/java/inr/numass/cryotemp/PKT8MainViewController.java new file mode 100644 index 00000000..498ab1af --- /dev/null +++ b/numass-control/cryotemp/src/main/java/inr/numass/cryotemp/PKT8MainViewController.java @@ -0,0 +1,276 @@ +/* + * Copyright 2015 Alexander Nozik. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package inr.numass.cryotemp; + +import ch.qos.logback.classic.spi.ILoggingEvent; +import ch.qos.logback.core.Appender; +import ch.qos.logback.core.AppenderBase; +import de.jensd.shichimifx.utils.SplitPaneDividerSlider; +import hep.dataforge.context.GlobalContext; +import hep.dataforge.control.devices.Device; +import hep.dataforge.control.devices.DeviceListener; +import hep.dataforge.control.devices.MeasurementDevice; +import hep.dataforge.control.devices.MeasurementListener; +import hep.dataforge.exceptions.ControlException; +import hep.dataforge.io.MetaFileReader; +import hep.dataforge.meta.Meta; +import hep.dataforge.meta.MetaBuilder; +import hep.dataforge.meta.MetaUtils; +import hep.dataforge.plots.XYPlotFrame; +import hep.dataforge.plots.data.DynamicPlottable; +import hep.dataforge.plots.data.DynamicPlottableSet; +import hep.dataforge.plots.jfreechart.JFreeChartFrame; +import hep.dataforge.values.Value; +import inr.numass.cryotemp.PKT8Device.PKT8Measurement; +import java.io.File; +import java.io.IOException; +import java.net.URISyntaxException; +import java.net.URL; +import java.text.ParseException; +import java.time.Instant; +import java.util.Collection; +import java.util.ResourceBundle; +import javafx.beans.value.ObservableValue; +import javafx.event.ActionEvent; +import javafx.fxml.FXML; +import javafx.fxml.Initializable; +import javafx.scene.control.Button; +import javafx.scene.control.SplitPane; +import javafx.scene.control.TextArea; +import javafx.scene.control.ToggleButton; +import javafx.scene.layout.AnchorPane; +import javafx.stage.FileChooser; + +/** + * FXML Controller class + * + * @author darksnake + */ +public class PKT8MainViewController implements Initializable, DeviceListener, MeasurementListener, AutoCloseable { + + public static final String DEFAULT_CONFIG_LOCATION = "devices.xml"; + private PKT8Device device; + private XYPlotFrame plotFrame; + private DynamicPlottableSet plottables; + private Meta currentPlotConfig; + + @FXML + private Button loadConfigButton; + @FXML + private SplitPane consoleSplitPane; + @FXML + private TextArea logArea; + @FXML + private ToggleButton startStopButton; + @FXML + private AnchorPane plotArea; + + @FXML + private ToggleButton consoleButton; + + @Override + public void close() throws Exception { + if (device != null) { + device.stop(); + device.shutdown(); + } + } + + /** + * Initializes the controller class. + */ + @Override + public void initialize(URL url, ResourceBundle rb) { + setupPlotFrame(null); + SplitPaneDividerSlider slider = new SplitPaneDividerSlider(consoleSplitPane, 0, SplitPaneDividerSlider.Direction.DOWN); + consoleButton.selectedProperty().addListener((ObservableValue observable, Boolean oldValue, Boolean newValue) -> { + slider.setAimContentVisible(newValue); + }); + slider.setAimContentVisible(false); + } + + @FXML + private void onLoadConfigClick(ActionEvent event) throws IOException, ParseException, ControlException { + FileChooser fileChooser = new FileChooser(); + fileChooser.setTitle("Open configuration file"); + fileChooser.setInitialFileName(DEFAULT_CONFIG_LOCATION); + fileChooser.setInitialDirectory(GlobalContext.instance().io().getRootDirectory()); + fileChooser.getExtensionFilters().add(new FileChooser.ExtensionFilter("xml", "*.xml", "*.XML")); + fileChooser.getExtensionFilters().add(new FileChooser.ExtensionFilter("json", "*.json", "*.JSON")); +// fileChooser.getExtensionFilters().add(new FileChooser.ExtensionFilter("all", "*.*")); + File cfgFile = fileChooser.showOpenDialog(loadConfigButton.getScene().getWindow()); + + if (cfgFile != null) { + setConfig(MetaFileReader.read(cfgFile)); + } + } + + private void loadTestConfig() throws ControlException { + try { + Meta testConfig = MetaFileReader + .read(new File(getClass().getResource("/config/defaultConfig.xml").toURI())); + setConfig(testConfig); + } catch (URISyntaxException | IOException | ParseException ex) { + throw new Error(ex); + } + } + + public String getDeviceName() { + return "PKT8"; + } + + public void setConfig(Meta config) throws ControlException { + if (config.hasNode("plotConfig")) { + Meta plotConfig = MetaUtils.findNodeByValue(config, "plotConfig", "device", getDeviceName()); + if (plotConfig == null) { + plotConfig = config.getNode("plotConfig"); + } + + setupPlotFrame(plotConfig.getNode("plotFrame", null)); + currentPlotConfig = plotConfig; + } + + if (config.hasNode("device")) { + Meta deviceMeta = MetaUtils.findNodeByValue(config, "device", "name", Value.of(getDeviceName())); + setupDevice(deviceMeta); + } else { + setupDevice(config); + } + + } + + /** + * Set o reset plot area + */ + private void setupPlotFrame(Meta plotFrameMeta) { + plottables = new DynamicPlottableSet(); + plotArea.getChildren().clear(); + Meta plotConfig; + if (plotFrameMeta != null) { + plotConfig = new MetaBuilder(plotFrameMeta) + .setValue("xAxis.timeAxis", true); + } else { + plotConfig = new MetaBuilder("plotFrame") + .setValue("xAxis.timeAxis", true); + } + plotFrame = new JFreeChartFrame("plot", plotConfig, plotArea); + } + + public void setupDevice(Meta deviceMeta) throws ControlException { + if (device != null) { + device.stop(); + device.shutdown(); + } + + this.device = new PKT8Device("PKT8", GlobalContext.instance(), deviceMeta); + device.addDeviceListener(this); + device.addMeasurementListener(this); + + logArea.appendText("Starting log...\n"); + + Appender appender = new AppenderBase() { +// private final DateTimeFormatter formatter = DateTimeFormatter.ISO_TIME; + @Override + protected void append(ILoggingEvent e) { + logArea.appendText(String.format("%s > (%s) [%s] %s%n", + e.getLoggerName(), + Instant.now().toString(), + e.getLevel(), + e.getFormattedMessage())); + } + }; + + appender.start(); + + device.getLogger().addAppender(appender); + + device.init(); + } + + @Override + public void notifyDeviceInitialized(Device device) { + Collection channels = this.device.getChanels(); + for (PKT8Device.PKT8Channel channel : channels) { + if (!plottables.hasPlottable(channel.getName())) { + + //plot config from device configuration + Meta deviceLineMeta = channel.meta().getNode("plot", channel.meta()); + + //Do not use view config here, it is applyed separately + DynamicPlottable plottable = new DynamicPlottable(channel.getName(), deviceLineMeta); + plottables.addPlottable(plottable); + plotFrame.add(plottable); + } + } + startStopButton.setDisable(false); + + if (currentPlotConfig != null) { + applyViewConfig(currentPlotConfig); + } + } + + public void applyViewConfig(Meta viewConfig) { + plottables.applyConfig(viewConfig); + } + + @Override + public void notifyDeviceShutdown(Device device) { + startStopButton.setDisable(true); + } + + @Override + public void notifyDeviceStateChanged(Device device, String name, Value oldState, Value newState) { + + } + +// @Override +// public void sendMessage(Device device, int priority, Meta message) { +// String tag = message.getString("tag", ""); +// logArea.appendText(String.format("%s > (%s) [%s] %s%n", device.getName(), Instant.now().toString(), tag, message)); +// } + + @Override + public void notifyMeasurementStarted(MeasurementDevice device, Meta measurement) { + + } + + @Override + public void notifyMeasurementStopped(MeasurementDevice device) { + + } + + @Override + public void notifyMeasurementResult(MeasurementDevice device, Meta measurement, PKT8Measurement measurementResult) { + plottables.put(measurementResult.channel, measurementResult.temperature); + } + + @FXML + private void onStartStopClick(ActionEvent event) { + if (device != null) { + try { + if (startStopButton.isSelected()) { + device.start(); + } else { + //in case device started + device.stop(); + } + } catch (ControlException ex) { + + } + } + } + +} diff --git a/numass-control/cryotemp/src/main/java/inr/numass/cryotemp/PKT8VirtualPort.java b/numass-control/cryotemp/src/main/java/inr/numass/cryotemp/PKT8VirtualPort.java new file mode 100644 index 00000000..1d195a6b --- /dev/null +++ b/numass-control/cryotemp/src/main/java/inr/numass/cryotemp/PKT8VirtualPort.java @@ -0,0 +1,87 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package inr.numass.cryotemp; + +import hep.dataforge.control.ports.VirtualPort; +import hep.dataforge.exceptions.PortException; +import hep.dataforge.meta.Annotated; +import hep.dataforge.meta.Meta; +import hep.dataforge.meta.MetaUtils; +import hep.dataforge.values.Value; +import java.time.Duration; +import java.util.Random; + + +/** + * + * @author Alexander Nozik + */ +public class PKT8VirtualPort extends VirtualPort implements Annotated { + + private final Meta meta; + private final Random generator = new Random(); + + public PKT8VirtualPort(String portName, Meta meta) { + super(portName); + this.meta = meta; + } + + @Override + public Meta meta() { + return meta; + } + + @Override + protected void evaluateRequest(String request) { + switch (request) { + case "s": + String[] letters = {"a", "b", "c", "d", "e", "f", "g", "h"}; + for (String letter : letters) { + Meta channelMeta = MetaUtils.findNodeByValue(meta(), "channel", "letter", Value.of(letter)); + + double average; + double sigma; + if (channelMeta != null) { + average = channelMeta.getDouble("av", 1200); + sigma = channelMeta.getDouble("sigma", 50); + } else { + average = 1200d; + sigma = 50d; + } + + this.planRegularResponse( + () -> { + double res = average + generator.nextGaussian() * sigma; + //TODO convert double value to formatted string + return letter + "000120000\n"; + }, + Duration.ZERO, Duration.ofSeconds(5), letter, "measurement" + ); + } + return; + case "p": + cancelByTag("measurement"); + this.recievePhrase("stopped\n\r"); + return; + } + } + + @Override + public void open() throws PortException { + + } + + @Override + public boolean isOpen() { + return true; + } + + @Override + public void close() throws Exception { + cancelByTag("measurement"); + } + +} diff --git a/numass-control/cryotemp/src/main/resources/config/defaultConfig.xml b/numass-control/cryotemp/src/main/resources/config/defaultConfig.xml new file mode 100644 index 00000000..9f11e3a2 --- /dev/null +++ b/numass-control/cryotemp/src/main/resources/config/defaultConfig.xml @@ -0,0 +1,14 @@ + + + + + 120 + + + + + + + + + diff --git a/numass-control/cryotemp/src/main/resources/fxml/PKT8MainView.fxml b/numass-control/cryotemp/src/main/resources/fxml/PKT8MainView.fxml new file mode 100644 index 00000000..e10ec8bc --- /dev/null +++ b/numass-control/cryotemp/src/main/resources/fxml/PKT8MainView.fxml @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + + + + +