From 95431715040c4158b87822d767099bf71486b014 Mon Sep 17 00:00:00 2001 From: Dhanya Thattil Date: Fri, 12 Apr 2019 09:12:44 +0200 Subject: [PATCH] merge from refgui. not completed --- CMakeLists.txt | 10 +- README.md | 0 RELEASE.txt | 0 catch/catch.hpp | 0 cmake/Catch.cmake | 0 cmake/CatchAddTests.cmake | 0 cmake/FindCBF.cmake | 0 cmake/FindQwt.cmake | 0 cmake/FindROOT.cmake | 0 cmake/FindZeroMQ.cmake | 0 cmake/ParseAndAddCatchTests.cmake | 0 cmake/package_config.cmake | 0 cmake/project-config.cmake.in | 0 cmake/project_version.cc.in | 0 cmake/project_version.cmake | 0 cmake/project_version.h.in | 0 cmk.sh | 4 +- conda-recepie/build.sh | 0 conda-recepie/build_pylib.sh | 0 conda-recepie/copy_gui.sh | 0 conda-recepie/copy_lib.sh | 0 conda-recepie/meta.yaml | 0 conda-recepie/run_test.sh | 0 evalVersionVariables.sh | 0 examples/bad.chans | 0 .../config_gen_script/beb_31_25.config_gen | 0 .../config_gen_script/eiger_2m_1gb.config_gen | 0 examples/eiger_10Gb.config | 0 examples/eiger_1Gb.config | 0 examples/gotthard.config | 0 examples/gotthard_setup.det | 0 examples/gotthard_two.config | 0 examples/howto_gotthard_twomodules.txt | 0 examples/jungfrau.config | 0 examples/jungfrau_two.config | 0 examples/moench01_T1_lab.config | 0 examples/mythen.config | 0 examples/receiver.config | 0 examples/scripts/.parab | 0 examples/two_gotthard.config | 0 examples/two_no_receiver.config | 0 integrationTests/CMakeLists.txt | 0 .../test-integrationDectector.cpp | 0 integrationTests/test-integrationMulti.cpp | 0 integrationTests/test.cpp | 0 manual/Makefile | 0 manual/index.html | 0 manual/manual-api/CMakeLists.txt | 0 manual/manual-api/Makefile | 0 manual/manual-api/mainClient.cpp | 0 manual/manual-api/mainReceiver.cpp | 0 manual/manual-api/slsDetectorUsers.doxy | 0 manual/manual-calwiz/Advanced.png | Bin manual/manual-calwiz/Constant_step.png | Bin manual/manual-calwiz/GUI_Advanced.eps | 0 manual/manual-calwiz/GUI_ThresholdScan.eps | 0 manual/manual-calwiz/Makefile | 0 manual/manual-calwiz/addEnergy.eps | 0 manual/manual-calwiz/addEnergy.png | Bin manual/manual-calwiz/ancCal.tex | 0 manual/manual-calwiz/angleFit.eps | 0 manual/manual-calwiz/angleFit.png | Bin .../manual-calwiz/angularCalibrationHowTo.tex | 0 manual/manual-calwiz/calibrateModule.eps | 0 manual/manual-calwiz/calibrateModule.png | Bin .../manual-calwiz/calibrationWizardsHowTo.tex | 0 manual/manual-calwiz/enCal.tex | 0 manual/manual-calwiz/enable_angcal.eps | 0 manual/manual-calwiz/eneble_angcal.png | Bin .../manual-calwiz/energyCalibrationHowTo.tex | 0 manual/manual-calwiz/fig4.eps | 0 manual/manual-calwiz/fig5.eps | 0 manual/manual-calwiz/fig7.eps | 0 manual/manual-calwiz/fig8.eps | 0 manual/manual-calwiz/installation.tex | 0 manual/manual-calwiz/peakFit.eps | 0 manual/manual-calwiz/peakFit.png | Bin manual/manual-calwiz/position_scan.eps | 0 manual/manual-calwiz/position_scan.png | Bin manual/manual-calwiz/setupAngcal.eps | 0 manual/manual-calwiz/setupAngcal.png | Bin manual/manual-calwiz/spectrum_expl.eps | 0 manual/manual-calwiz/thr_scan_expl.eps | 0 manual/manual-calwiz/thr_scan_fluo.eps | 0 manual/manual-client/Boards.png | Bin manual/manual-client/Client2.eps | 0 manual/manual-client/Client2.png | Bin manual/manual-client/EIGERUDPHeader.png | Bin manual/manual-client/Eiger-Chips.png | Bin manual/manual-client/Eiger_short.tex | 0 manual/manual-client/GapPixels.png | Bin manual/manual-client/LEDSim.png | Bin manual/manual-client/Makefile | 0 manual/manual-client/TansmissionRates.png | Bin manual/manual-client/commands.txt | 0 manual/manual-client/libs.txt | 0 manual/manual-client/slsDetectorClient.doxy | 0 .../manual-client/slsDetectorClientHowTo.tex | 0 manual/manual-client/tiggerIN.png | Bin manual/manual-gui/Makefile | 0 manual/manual-gui/libs.txt | 0 manual/manual-gui/slsDetectorGuiHowTo.tex | 0 manual/manual-main/AngConv.eps | 0 manual/manual-main/AngConv_fml.tex | 0 manual/manual-main/F90-C++Interface.doc | Bin manual/manual-main/Makefile | 0 manual/manual-main/Waver.tex | 0 manual/manual-main/angConv-FAQ.tex | 0 manual/manual-main/chargeInt-FAQ.tex | 0 manual/manual-main/data_receiver.eps | 0 manual/manual-main/data_receiver.fig | 0 manual/manual-main/generalDet-FAQ.tex | 0 manual/manual-main/images/FFSetup.eps | 0 manual/manual-main/images/bad_ff_col.eps | 0 .../images/continuos_trigger_acquisition.eps | 0 .../images/continuos_trigger_acquisition.fig | 0 manual/manual-main/images/ff_calibration.eps | 0 manual/manual-main/images/ff_window.eps | 0 .../manual-main/images/gated_acquisition.eps | 0 .../manual-main/images/gated_acquisition.fig | 0 .../images/gated_acquisition.fig.bak | 0 .../images/noise_thresholdscantrimmed.eps | 0 .../images/noise_thresholdscanuntrimmed.eps | 0 .../manual-main/images/normal_acquisition.eps | 0 .../manual-main/images/normal_acquisition.fig | 0 .../images/normal_acquisition.fig.bak | 0 .../images/ro_trigger_acquisition.eps | 0 .../images/ro_trigger_acquisition.fig | 0 .../images/ro_trigger_acquisition.fig.bak | 0 .../images/sample_with_fluorescence.eps | 0 manual/manual-main/images/settings.eps | 0 .../images/single_trigger_acquisition.eps | 0 .../images/single_trigger_acquisition.fig | 0 manual/manual-main/images/thr_scan_expl.eps | 0 manual/manual-main/images/thr_scan_fluo.eps | 0 .../images/trigger_acquisition.eps | 0 .../images/trigger_acquisition.fig | 0 .../images/trigger_acquisition.fig.bak | 0 manual/manual-main/images/win_acquisition.eps | 0 manual/manual-main/libs.txt | 0 manual/manual-main/manual.tex | 0 manual/manual-main/multi_detector.eps | 0 manual/manual-main/multi_detector.fig | 0 .../manual-main/singlePhotonCounting-FAQ.tex | 0 manual/manual-main/slsDetector-softFAQ.tex | 0 manual/manual-main/slsDetectorClientHowTo.tex | 0 manual/manual-main/slsDetectorGuiHowTo.tex | 0 manual/manual-main/slsDetectorInstall.tex | 0 manual/manual-main/slsDetectors-FAQ.tex | 0 python/CMakeLists.txt | 0 python/LICENSE | 0 python/README.md | 0 python/scripts/basic.py | 0 python/setup.py | 0 .../eiger/config_test.py | 0 .../eiger/fixtures.py | 0 .../settingsdir/standard/5000eV/noise.sn083 | Bin .../settingsdir/standard/5000eV/noise.sn098 | Bin .../standard/5000eV/trimbits.sn000 | Bin .../settingsdir/standard/6000eV/noise.sn083 | Bin .../settingsdir/standard/6000eV/noise.sn098 | Bin .../standard/6000eV/trimbits.sn000 | Bin .../settingsdir/standard/7000eV/noise.sn083 | Bin .../settingsdir/standard/7000eV/noise.sn098 | Bin .../standard/7000eV/trimbits.sn000 | Bin .../eiger/test.config | 0 .../simple-integration-tests/eiger/test.par | 0 .../eiger/test_dynamic_range.py | 0 .../eiger/test_eiger_specific.py | 0 .../eiger/test_firmware.py | 0 .../eiger/test_general.py | 0 .../eiger/test_load_config.py | 0 .../eiger/test_network.py | 0 .../eiger/test_paths_and_files.py | 0 .../eiger/test_threshold.py | 0 .../eiger/test_time.py | 0 .../eiger/test_trimbits_and_dacs.py | 0 .../eiger/test_version_numbers.py | 0 .../eiger/write_tb_files.py | 0 .../jungfrau_0_6/config_test.py | 0 .../jungfrau_0_6/fixtures.py | 0 .../jungfrau_0_6/test_main.py | 0 .../jungfrau_0_6/tests/test.config | 0 .../jungfrau_0_6/tests/test.par | 0 .../jungfrau_0_6/tests/test_load_config.py | 0 .../tests/test_overtemperature.py | 0 python/sls_detector/__init__.py | 0 python/sls_detector/adcs.py | 0 python/sls_detector/dacs.py | 0 python/sls_detector/decorators.py | 0 python/sls_detector/detector.py | 0 python/sls_detector/detector_property.py | 0 python/sls_detector/eiger.py | 0 python/sls_detector/errors.py | 0 python/sls_detector/experimental.py | 0 python/sls_detector/jungfrau.py | 0 python/sls_detector/jungfrau_ctb.py | 0 python/sls_detector/registers.py | 0 python/sls_detector/utils.py | 0 python/sphinx/Makefile | 0 python/sphinx/_static/tp_scurve.png | Bin python/sphinx/_static/untrimmed.png | Bin python/sphinx/code_quality.rst | 0 python/sphinx/command_line.rst | 0 python/sphinx/conf.py | 0 python/sphinx/cpp_api.rst | 0 python/sphinx/error-handling.rst | 0 python/sphinx/examples.rst | 0 python/sphinx/getting_started.rst | 0 python/sphinx/index.rst | 0 python/sphinx/installation.rst | 0 python/sphinx/modules.rst | 0 python/sphinx/sls_detector.rst | 0 python/src/Detector.h | 0 python/src/main.cpp | 0 .../dac_test.cpython-37-PYTEST.pyc | Bin .../detector_test.cpython-37-PYTEST.pyc | Bin ...st_detector_property.cpython-37-PYTEST.pyc | Bin .../test_utils.cpython-37-PYTEST.pyc | Bin python/unit-tests/dac_test.py | 0 python/unit-tests/detector_eiger.py | 0 python/unit-tests/detector_test.py | 0 python/unit-tests/test_detector_property.py | 0 python/unit-tests/test_utils.py | 0 .../eiger/highgain/calibration.snbeb045 | 0 settingsdir/eiger/highgain/highgain.cal | 0 settingsdir/eiger/highgain/highgain.trim | Bin settingsdir/eiger/highgain/settings.snbeb045 | Bin .../eiger/lowgain/calibration.snbeb045 | 0 settingsdir/eiger/lowgain/lowgain.cal | 0 settingsdir/eiger/lowgain/lowgain.trim | Bin settingsdir/eiger/lowgain/settings.snbeb045 | Bin settingsdir/eiger/standard/4500eV/noise.sn031 | Bin settingsdir/eiger/standard/4500eV/noise.sn032 | Bin settingsdir/eiger/standard/5400eV/noise.sn031 | Bin settingsdir/eiger/standard/5400eV/noise.sn032 | Bin settingsdir/eiger/standard/6400eV/noise.sn031 | Bin settingsdir/eiger/standard/6400eV/noise.sn032 | Bin settingsdir/eiger/standard/calibration.sn031 | 0 settingsdir/eiger/standard/calibration.sn032 | 0 settingsdir/eiger/standard/eigernoise.sn049 | Bin settingsdir/eiger/standard/noise.sn031 | Bin settingsdir/eiger/standard/noise.sn032 | Bin settingsdir/eiger/standard/standard.cal | 0 settingsdir/eiger/standard/standard.trim | Bin .../eiger/veryhighgain/calibration.sn031 | 0 .../eiger/veryhighgain/calibration.sn032 | 0 settingsdir/eiger/veryhighgain/noise.sn031 | Bin settingsdir/eiger/veryhighgain/noise.sn032 | Bin .../eiger/veryhighgain/veryhighgain.cal | 0 .../eiger/veryhighgain/veryhighgain.trim | Bin .../eiger/verylowgain/calibration.sn031 | 0 .../eiger/verylowgain/calibration.sn032 | 0 settingsdir/eiger/verylowgain/noise.sn031 | Bin settingsdir/eiger/verylowgain/noise.sn032 | Bin settingsdir/eiger/verylowgain/verylowgain.cal | 0 .../eiger/verylowgain/verylowgain.trim | Bin settingsdir/mythen/fast/noise.snxxx | 0 settingsdir/mythen/highgain/noise.snxxx | 0 settingsdir/mythen/standard/noise.snxxx | 0 settingsdir/mythen/standard/standard.trim | 0 slsDetectorGui/.gitignore | 0 slsDetectorGui/CMakeLists.txt | 58 +- slsDetectorGui/client/qClient.cpp | 310 +- slsDetectorGui/client/qClient.h | 95 +- slsDetectorGui/doxy.config | 8 +- slsDetectorGui/forms/form_action.ui | 169 - slsDetectorGui/forms/form_detectormain.ui | 6 +- slsDetectorGui/forms/form_scan.ui | 488 --- slsDetectorGui/forms/form_tab_advanced.ui | 709 +--- slsDetectorGui/forms/form_tab_dataoutput.ui | 185 +- slsDetectorGui/forms/form_tab_debugging.ui | 183 +- slsDetectorGui/forms/form_tab_measurement.ui | 443 +-- slsDetectorGui/forms/form_tab_messages.ui | 0 slsDetectorGui/forms/form_tab_plot.ui | 0 slsDetectorGui/forms/form_tab_settings.ui | 99 +- slsDetectorGui/gitInfo.txt | 9 - slsDetectorGui/images/add.png | Bin slsDetectorGui/images/browse.png | Bin slsDetectorGui/images/calculate.png | Bin slsDetectorGui/images/close.png | Bin slsDetectorGui/images/download.png | Bin slsDetectorGui/images/erase.png | Bin slsDetectorGui/images/leftArrow.png | Bin slsDetectorGui/images/mountain.png | Bin slsDetectorGui/images/new.png | Bin slsDetectorGui/images/refresh.png | Bin slsDetectorGui/images/refresher.png | Bin slsDetectorGui/images/remove.png | Bin slsDetectorGui/images/rightArrow.png | Bin slsDetectorGui/images/save.png | Bin slsDetectorGui/images/saveAll.png | Bin slsDetectorGui/images/setup.png | Bin slsDetectorGui/images/start.png | Bin slsDetectorGui/images/stop.png | Bin slsDetectorGui/images/upload.png | Bin slsDetectorGui/include/gitInfoGui.h | 6 - slsDetectorGui/include/gitInfoGuiTmp.h | 6 - slsDetectorGui/include/icons.qrc | 0 slsDetectorGui/include/qActionsWidget.h | 85 - slsDetectorGui/include/qCloneWidget.h | 167 +- slsDetectorGui/include/qDebugStream.h | 74 +- slsDetectorGui/include/qDefs.h | 537 ++- slsDetectorGui/include/qDetectorMain.h | 310 +- slsDetectorGui/include/qDrawPlot.h | 4 +- slsDetectorGui/include/qScanWidget.h | 193 - slsDetectorGui/include/qServer.h | 201 +- slsDetectorGui/include/qTabActions.h | 150 - slsDetectorGui/include/qTabAdvanced.h | 216 +- slsDetectorGui/include/qTabDataOutput.h | 227 +- slsDetectorGui/include/qTabDebugging.h | 96 +- slsDetectorGui/include/qTabDeveloper.h | 176 +- slsDetectorGui/include/qTabMeasurement.h | 238 +- slsDetectorGui/include/qTabMessages.h | 88 +- slsDetectorGui/include/qTabPlot.h | 4 +- slsDetectorGui/include/qTabSettings.h | 137 +- slsDetectorGui/slsDetectorGui.pro | 161 - .../slsDetectorPlotting/include/SlsQt1DPlot.h | 2 +- .../include/SlsQt1DZoomer.h | 0 .../slsDetectorPlotting/include/SlsQt2DHist.h | 0 .../slsDetectorPlotting/include/SlsQt2DPlot.h | 0 .../include/SlsQt2DPlotLayout.h | 0 .../include/SlsQt2DZoomer.h | 0 .../include/SlsQtNumberEntry.h | 0 .../include/SlsQtValidators.h | 0 .../slsDetectorPlotting/src/SlsQt1DPlot.cxx | 751 ++-- .../slsDetectorPlotting/src/SlsQt1DZoomer.cxx | 3 - .../slsDetectorPlotting/src/SlsQt2DHist.cxx | 0 .../slsDetectorPlotting/src/SlsQt2DPlot.cxx | 450 ++- .../src/SlsQt2DPlotLayout.cxx | 2 +- .../src/SlsQtNumberEntry.cxx | 1 - slsDetectorGui/src/qActionsWidget.cpp | 219 -- slsDetectorGui/src/qCloneWidget.cpp | 622 ++- slsDetectorGui/src/qDetectorMain.cpp | 1456 ++++--- slsDetectorGui/src/qDrawPlot.cpp | 3446 ++++++++--------- slsDetectorGui/src/qScanWidget.cpp | 1247 ------ slsDetectorGui/src/qServer.cpp | 530 +-- slsDetectorGui/src/qTabActions.cpp | 585 --- slsDetectorGui/src/qTabAdvanced.cpp | 1285 ++---- slsDetectorGui/src/qTabDataOutput.cpp | 1220 ++---- slsDetectorGui/src/qTabDebugging.cpp | 779 ++-- slsDetectorGui/src/qTabDeveloper.cpp | 848 ++-- slsDetectorGui/src/qTabMeasurement.cpp | 1263 +++--- slsDetectorGui/src/qTabMessages.cpp | 145 +- slsDetectorGui/src/qTabPlot.cpp | 2381 ++++++------ slsDetectorGui/src/qTabSettings.cpp | 595 ++- slsDetectorGui/updateGitVersion.sh | 26 - slsDetectorServers/ctbDetectorServer/Makefile | 5 +- .../ctbDetectorServer/Makefile.virtual | 0 .../ctbDetectorServer/RegisterDefs.h | 0 .../ctbDetectorServer/gitInfo.txt | 9 - .../ctbDetectorServer/gitInfoCtb.h | 6 - .../ctbDetectorServer/gitInfoCtbTmp.h | 6 - .../slsDetectorFunctionList.c | 2 - .../slsDetectorServer_defs.h | 0 .../ctbDetectorServer/updateAPIVersion.sh | 7 - .../ctbDetectorServer/updateGitVersion.sh | 31 - .../eigerDetectorServer/9mhvserial_bf.c | 0 slsDetectorServers/eigerDetectorServer/Beb.c | 0 slsDetectorServers/eigerDetectorServer/Beb.h | 0 .../eigerDetectorServer/FebControl.c | 0 .../eigerDetectorServer/FebControl.h | 0 .../eigerDetectorServer/FebInterface.c | 0 .../eigerDetectorServer/FebInterface.h | 0 .../eigerDetectorServer/FebRegisterDefs.h | 0 .../eigerDetectorServer/HardwareIO.c | 0 .../eigerDetectorServer/HardwareIO.h | 0 .../HardwareMMappingDefs.h | 0 .../eigerDetectorServer/LocalLinkInterface.c | 0 .../eigerDetectorServer/LocalLinkInterface.h | 0 .../eigerDetectorServer/Makefile | 7 +- .../eigerDetectorServer/Makefile.virtual | 0 .../eigerDetectorServer/gitInfo.txt | 9 - .../eigerDetectorServer/gitInfoEiger.h | 6 - .../eigerDetectorServer/gitInfoEigerTmp.h | 6 - .../eigerDetectorServer/renameServer.sh | 0 .../slsDetectorFunctionList.c | 6 +- .../slsDetectorServer_defs.h | 0 .../eigerDetectorServer/updateAPIVersion.sh | 7 - .../eigerDetectorServer/updateGitVersion.sh | 32 - .../eigerDetectorServer/xfs_types.h | 0 .../eigerDetectorServer/xparameters.h | 0 .../gotthardDetectorServer/Makefile | 5 +- .../gotthardDetectorServer/config.txt | 0 .../gotthardDetectorServer/gitInfo.txt | 9 - .../gotthardDetectorServer/gitInfoGotthard.h | 6 - .../gitInfoGotthardTmp.h | 6 - .../slsDetectorFunctionList.c | 2 - .../slsDetectorServer_defs.h | 0 .../updateAPIVersion.sh | 7 - .../updateGitVersion.sh | 30 - .../jungfrauDetectorServer/Makefile | 5 +- .../jungfrauDetectorServer/Makefile.virtual | 0 .../jungfrauDetectorServer/RegisterDefs.h | 0 .../jungfrauDetectorServer/gitInfo.txt | 9 - .../jungfrauDetectorServer/gitInfoJungfrau.h | 6 - .../gitInfoJungfrauTmp.h | 6 - .../slsDetectorFunctionList.c | 4 +- .../slsDetectorServer_defs.h | 0 .../updateAPIVersion.sh | 7 - .../updateGitVersion.sh | 31 - .../moenchDetectorServer/Makefile | 5 +- .../moenchDetectorServer/Makefile.virtual | 0 .../moenchDetectorServer/RegisterDefs.h | 0 .../moenchDetectorServer/gitInfo.txt | 9 - .../moenchDetectorServer/gitInfoMoench.h | 6 - .../moenchDetectorServer/gitInfoMoenchTmp.h | 6 - .../slsDetectorFunctionList.c | 2 - .../slsDetectorServer_defs.h | 0 .../moenchDetectorServer/updateAPIVersion.sh | 7 - .../moenchDetectorServer/updateGitVersion.sh | 31 - slsDetectorServers/slsDetectorServer/logger.h | 0 .../slsDetectorFunctionList.h | 0 .../slsDetectorServer/slsDetectorServer.c | 21 +- .../slsDetectorServer_funcs.c | 4 +- slsDetectorSoftware/CMakeLists.txt | 1 - slsDetectorSoftware/doxy.config | 0 slsDetectorSoftware/gitInfo.txt | 9 - slsDetectorSoftware/include/SharedMemory.h | 0 slsDetectorSoftware/include/detectorData.h | 0 slsDetectorSoftware/include/gitInfoLib.h | 6 - slsDetectorSoftware/include/gitInfoLibTmp.h | 6 - .../include/multiSlsDetector.h | 19 +- .../include/multiSlsDetectorClient.h | 0 slsDetectorSoftware/include/slsDetector.h | 2 +- .../include/slsDetectorCommand.h | 0 .../include/slsDetectorUsers.h | 0 slsDetectorSoftware/src/multiSlsDetector.cpp | 48 +- slsDetectorSoftware/src/slsDetector.cpp | 8 +- .../src/slsDetectorCommand.cpp | 10 +- slsDetectorSoftware/src/slsDetectorUsers.cpp | 7 +- .../src/sls_detector_client.cpp | 4 +- slsDetectorSoftware/tests/CMakeLists.txt | 0 .../tests/test-SharedMemory.cpp | 0 .../tests/test-multiSlsDetector.cpp | 0 .../tests/test-slsDetector.cpp | 0 slsDetectorSoftware/updateGitVersion.sh | 28 - slsReceiverSoftware/CMakeLists.txt | 0 slsReceiverSoftware/gitInfo.txt | 9 - slsReceiverSoftware/include/BinaryFile.h | 0 .../include/BinaryFileStatic.h | 0 slsReceiverSoftware/include/DataProcessor.h | 0 slsReceiverSoftware/include/DataStreamer.h | 0 slsReceiverSoftware/include/Fifo.h | 0 slsReceiverSoftware/include/File.h | 0 slsReceiverSoftware/include/GeneralData.h | 0 slsReceiverSoftware/include/HDF5File.h | 0 slsReceiverSoftware/include/HDF5FileStatic.h | 0 slsReceiverSoftware/include/Listener.h | 0 slsReceiverSoftware/include/ThreadObject.h | 0 slsReceiverSoftware/include/circularFifo.h | 0 slsReceiverSoftware/include/gitInfoReceiver.h | 6 - .../include/gitInfoReceiverTmp.h | 6 - slsReceiverSoftware/include/slsReceiver.h | 0 .../include/slsReceiverImplementation.h | 0 .../include/slsReceiverTCPIPInterface.h | 0 .../include/slsReceiverUsers.h | 0 slsReceiverSoftware/slsReceiverUsers.doxy | 0 slsReceiverSoftware/src/BinaryFile.cpp | 0 slsReceiverSoftware/src/DataProcessor.cpp | 0 slsReceiverSoftware/src/DataStreamer.cpp | 0 slsReceiverSoftware/src/Fifo.cpp | 0 slsReceiverSoftware/src/File.cpp | 0 slsReceiverSoftware/src/HDF5File.cpp | 0 slsReceiverSoftware/src/Listener.cpp | 0 slsReceiverSoftware/src/ThreadObject.cpp | 0 slsReceiverSoftware/src/main.cpp | 0 slsReceiverSoftware/src/slsReceiver.cpp | 7 +- .../src/slsReceiverImplementation.cpp | 0 .../src/slsReceiverTCPIPInterface.cpp | 4 +- slsReceiverSoftware/src/slsReceiverUsers.cpp | 0 slsReceiverSoftware/tests/CMakeLists.txt | 0 .../tests/test-GeneralData.cpp | 0 slsReceiverSoftware/updateAPIVersion.sh | 7 - slsReceiverSoftware/updateGitVersion.sh | 28 - slsSupportLib/CMakeLists.txt | 0 slsSupportLib/include/ClientInterface.h | 0 slsSupportLib/include/ClientSocket.h | 21 +- slsSupportLib/include/CmdLineParser.h | 0 slsSupportLib/include/DataSocket.h | 1 + slsSupportLib/include/MySocketTCP.h | 0 slsSupportLib/include/ServerInterface.h | 0 slsSupportLib/include/ServerSocket.h | 7 +- slsSupportLib/include/Timer.h | 0 slsSupportLib/include/ZmqSocket.h | 0 slsSupportLib/include/ansi.h | 0 slsSupportLib/include/container_utils.h | 0 slsSupportLib/include/error_defs.h | 0 slsSupportLib/include/file_utils.h | 0 slsSupportLib/include/genericSocket.h | 0 slsSupportLib/include/logger.h | 3 +- slsSupportLib/include/network_utils.h | 0 slsSupportLib/include/rapidjson/allocators.h | 0 slsSupportLib/include/rapidjson/document.h | 0 .../include/rapidjson/encodedstream.h | 0 slsSupportLib/include/rapidjson/encodings.h | 0 slsSupportLib/include/rapidjson/error/en.h | 0 slsSupportLib/include/rapidjson/error/error.h | 0 .../include/rapidjson/filereadstream.h | 0 .../include/rapidjson/filewritestream.h | 0 slsSupportLib/include/rapidjson/fwd.h | 0 .../include/rapidjson/internal/biginteger.h | 0 .../include/rapidjson/internal/diyfp.h | 0 .../include/rapidjson/internal/dtoa.h | 0 .../include/rapidjson/internal/ieee754.h | 0 .../include/rapidjson/internal/itoa.h | 0 .../include/rapidjson/internal/meta.h | 0 .../include/rapidjson/internal/pow10.h | 0 .../include/rapidjson/internal/regex.h | 0 .../include/rapidjson/internal/stack.h | 0 .../include/rapidjson/internal/strfunc.h | 0 .../include/rapidjson/internal/strtod.h | 0 .../include/rapidjson/internal/swap.h | 0 .../include/rapidjson/istreamwrapper.h | 0 .../include/rapidjson/memorybuffer.h | 0 .../include/rapidjson/memorystream.h | 0 .../include/rapidjson/msinttypes/inttypes.h | 0 .../include/rapidjson/msinttypes/stdint.h | 0 .../include/rapidjson/ostreamwrapper.h | 0 slsSupportLib/include/rapidjson/pointer.h | 0 .../include/rapidjson/prettywriter.h | 0 slsSupportLib/include/rapidjson/rapidjson.h | 0 slsSupportLib/include/rapidjson/reader.h | 0 slsSupportLib/include/rapidjson/schema.h | 0 slsSupportLib/include/rapidjson/stream.h | 0 .../include/rapidjson/stringbuffer.h | 0 slsSupportLib/include/rapidjson/writer.h | 0 slsSupportLib/include/sls_detector_defs.h | 29 +- .../include/sls_detector_exceptions.h | 44 +- slsSupportLib/include/sls_detector_funcs.h | 0 slsSupportLib/include/string_utils.h | 0 slsSupportLib/include/versionAPI.h | 12 +- slsSupportLib/src/ClientInterface.cpp | 0 slsSupportLib/src/ClientSocket.cpp | 33 +- slsSupportLib/src/CmdLineParser.cpp | 0 slsSupportLib/src/DataSocket.cpp | 5 + slsSupportLib/src/ServerInterface.cpp | 0 slsSupportLib/src/ServerSocket.cpp | 54 +- slsSupportLib/src/file_utils.cpp | 0 slsSupportLib/src/network_utils.cpp | 0 slsSupportLib/src/string_utils.cpp | 0 slsSupportLib/tests/CMakeLists.txt | 0 slsSupportLib/tests/test-ClientInterface.cpp | 0 slsSupportLib/tests/test-CmdLineParser.cpp | 0 slsSupportLib/tests/test-Timer.cpp | 0 slsSupportLib/tests/test-container_utils.cpp | 0 slsSupportLib/tests/test-network_utils.cpp | 0 slsSupportLib/tests/test-string_utils.cpp | 0 tests/CMakeLists.txt | 4 +- tests/test.cpp | 0 updateAPIVersion.sh | 37 + updateClientAPI.sh | 24 + 552 files changed, 8396 insertions(+), 16164 deletions(-) mode change 100644 => 100755 CMakeLists.txt mode change 100644 => 100755 README.md mode change 100644 => 100755 RELEASE.txt mode change 100644 => 100755 catch/catch.hpp mode change 100644 => 100755 cmake/Catch.cmake mode change 100644 => 100755 cmake/CatchAddTests.cmake mode change 100644 => 100755 cmake/FindCBF.cmake mode change 100644 => 100755 cmake/FindQwt.cmake mode change 100644 => 100755 cmake/FindROOT.cmake mode change 100644 => 100755 cmake/FindZeroMQ.cmake mode change 100644 => 100755 cmake/ParseAndAddCatchTests.cmake mode change 100644 => 100755 cmake/package_config.cmake mode change 100644 => 100755 cmake/project-config.cmake.in mode change 100644 => 100755 cmake/project_version.cc.in mode change 100644 => 100755 cmake/project_version.cmake mode change 100644 => 100755 cmake/project_version.h.in mode change 100644 => 100755 conda-recepie/build.sh mode change 100644 => 100755 conda-recepie/build_pylib.sh mode change 100644 => 100755 conda-recepie/copy_gui.sh mode change 100644 => 100755 conda-recepie/copy_lib.sh mode change 100644 => 100755 conda-recepie/meta.yaml mode change 100644 => 100755 conda-recepie/run_test.sh mode change 100644 => 100755 evalVersionVariables.sh mode change 100644 => 100755 examples/bad.chans mode change 100644 => 100755 examples/config_gen_script/beb_31_25.config_gen mode change 100644 => 100755 examples/config_gen_script/eiger_2m_1gb.config_gen mode change 100644 => 100755 examples/eiger_10Gb.config mode change 100644 => 100755 examples/eiger_1Gb.config mode change 100644 => 100755 examples/gotthard.config mode change 100644 => 100755 examples/gotthard_setup.det mode change 100644 => 100755 examples/gotthard_two.config mode change 100644 => 100755 examples/howto_gotthard_twomodules.txt mode change 100644 => 100755 examples/jungfrau.config mode change 100644 => 100755 examples/jungfrau_two.config mode change 100644 => 100755 examples/moench01_T1_lab.config mode change 100644 => 100755 examples/mythen.config mode change 100644 => 100755 examples/receiver.config mode change 100644 => 100755 examples/scripts/.parab mode change 100644 => 100755 examples/two_gotthard.config mode change 100644 => 100755 examples/two_no_receiver.config mode change 100644 => 100755 integrationTests/CMakeLists.txt mode change 100644 => 100755 integrationTests/test-integrationDectector.cpp mode change 100644 => 100755 integrationTests/test-integrationMulti.cpp mode change 100644 => 100755 integrationTests/test.cpp mode change 100644 => 100755 manual/Makefile mode change 100644 => 100755 manual/index.html mode change 100644 => 100755 manual/manual-api/CMakeLists.txt mode change 100644 => 100755 manual/manual-api/Makefile mode change 100644 => 100755 manual/manual-api/mainClient.cpp mode change 100644 => 100755 manual/manual-api/mainReceiver.cpp mode change 100644 => 100755 manual/manual-api/slsDetectorUsers.doxy mode change 100644 => 100755 manual/manual-calwiz/Advanced.png mode change 100644 => 100755 manual/manual-calwiz/Constant_step.png mode change 100644 => 100755 manual/manual-calwiz/GUI_Advanced.eps mode change 100644 => 100755 manual/manual-calwiz/GUI_ThresholdScan.eps mode change 100644 => 100755 manual/manual-calwiz/Makefile mode change 100644 => 100755 manual/manual-calwiz/addEnergy.eps mode change 100644 => 100755 manual/manual-calwiz/addEnergy.png mode change 100644 => 100755 manual/manual-calwiz/ancCal.tex mode change 100644 => 100755 manual/manual-calwiz/angleFit.eps mode change 100644 => 100755 manual/manual-calwiz/angleFit.png mode change 100644 => 100755 manual/manual-calwiz/angularCalibrationHowTo.tex mode change 100644 => 100755 manual/manual-calwiz/calibrateModule.eps mode change 100644 => 100755 manual/manual-calwiz/calibrateModule.png mode change 100644 => 100755 manual/manual-calwiz/calibrationWizardsHowTo.tex mode change 100644 => 100755 manual/manual-calwiz/enCal.tex mode change 100644 => 100755 manual/manual-calwiz/enable_angcal.eps mode change 100644 => 100755 manual/manual-calwiz/eneble_angcal.png mode change 100644 => 100755 manual/manual-calwiz/energyCalibrationHowTo.tex mode change 100644 => 100755 manual/manual-calwiz/fig4.eps mode change 100644 => 100755 manual/manual-calwiz/fig5.eps mode change 100644 => 100755 manual/manual-calwiz/fig7.eps mode change 100644 => 100755 manual/manual-calwiz/fig8.eps mode change 100644 => 100755 manual/manual-calwiz/installation.tex mode change 100644 => 100755 manual/manual-calwiz/peakFit.eps mode change 100644 => 100755 manual/manual-calwiz/peakFit.png mode change 100644 => 100755 manual/manual-calwiz/position_scan.eps mode change 100644 => 100755 manual/manual-calwiz/position_scan.png mode change 100644 => 100755 manual/manual-calwiz/setupAngcal.eps mode change 100644 => 100755 manual/manual-calwiz/setupAngcal.png mode change 100644 => 100755 manual/manual-calwiz/spectrum_expl.eps mode change 100644 => 100755 manual/manual-calwiz/thr_scan_expl.eps mode change 100644 => 100755 manual/manual-calwiz/thr_scan_fluo.eps mode change 100644 => 100755 manual/manual-client/Boards.png mode change 100644 => 100755 manual/manual-client/Client2.eps mode change 100644 => 100755 manual/manual-client/Client2.png mode change 100644 => 100755 manual/manual-client/EIGERUDPHeader.png mode change 100644 => 100755 manual/manual-client/Eiger-Chips.png mode change 100644 => 100755 manual/manual-client/Eiger_short.tex mode change 100644 => 100755 manual/manual-client/GapPixels.png mode change 100644 => 100755 manual/manual-client/LEDSim.png mode change 100644 => 100755 manual/manual-client/Makefile mode change 100644 => 100755 manual/manual-client/TansmissionRates.png mode change 100644 => 100755 manual/manual-client/commands.txt mode change 100644 => 100755 manual/manual-client/libs.txt mode change 100644 => 100755 manual/manual-client/slsDetectorClient.doxy mode change 100644 => 100755 manual/manual-client/slsDetectorClientHowTo.tex mode change 100644 => 100755 manual/manual-client/tiggerIN.png mode change 100644 => 100755 manual/manual-gui/Makefile mode change 100644 => 100755 manual/manual-gui/libs.txt mode change 100644 => 100755 manual/manual-gui/slsDetectorGuiHowTo.tex mode change 100644 => 100755 manual/manual-main/AngConv.eps mode change 100644 => 100755 manual/manual-main/AngConv_fml.tex mode change 100644 => 100755 manual/manual-main/F90-C++Interface.doc mode change 100644 => 100755 manual/manual-main/Makefile mode change 100644 => 100755 manual/manual-main/Waver.tex mode change 100644 => 100755 manual/manual-main/angConv-FAQ.tex mode change 100644 => 100755 manual/manual-main/chargeInt-FAQ.tex mode change 100644 => 100755 manual/manual-main/data_receiver.eps mode change 100644 => 100755 manual/manual-main/data_receiver.fig mode change 100644 => 100755 manual/manual-main/generalDet-FAQ.tex mode change 100644 => 100755 manual/manual-main/images/FFSetup.eps mode change 100644 => 100755 manual/manual-main/images/bad_ff_col.eps mode change 100644 => 100755 manual/manual-main/images/continuos_trigger_acquisition.eps mode change 100644 => 100755 manual/manual-main/images/continuos_trigger_acquisition.fig mode change 100644 => 100755 manual/manual-main/images/ff_calibration.eps mode change 100644 => 100755 manual/manual-main/images/ff_window.eps mode change 100644 => 100755 manual/manual-main/images/gated_acquisition.eps mode change 100644 => 100755 manual/manual-main/images/gated_acquisition.fig mode change 100644 => 100755 manual/manual-main/images/gated_acquisition.fig.bak mode change 100644 => 100755 manual/manual-main/images/noise_thresholdscantrimmed.eps mode change 100644 => 100755 manual/manual-main/images/noise_thresholdscanuntrimmed.eps mode change 100644 => 100755 manual/manual-main/images/normal_acquisition.eps mode change 100644 => 100755 manual/manual-main/images/normal_acquisition.fig mode change 100644 => 100755 manual/manual-main/images/normal_acquisition.fig.bak mode change 100644 => 100755 manual/manual-main/images/ro_trigger_acquisition.eps mode change 100644 => 100755 manual/manual-main/images/ro_trigger_acquisition.fig mode change 100644 => 100755 manual/manual-main/images/ro_trigger_acquisition.fig.bak mode change 100644 => 100755 manual/manual-main/images/sample_with_fluorescence.eps mode change 100644 => 100755 manual/manual-main/images/settings.eps mode change 100644 => 100755 manual/manual-main/images/single_trigger_acquisition.eps mode change 100644 => 100755 manual/manual-main/images/single_trigger_acquisition.fig mode change 100644 => 100755 manual/manual-main/images/thr_scan_expl.eps mode change 100644 => 100755 manual/manual-main/images/thr_scan_fluo.eps mode change 100644 => 100755 manual/manual-main/images/trigger_acquisition.eps mode change 100644 => 100755 manual/manual-main/images/trigger_acquisition.fig mode change 100644 => 100755 manual/manual-main/images/trigger_acquisition.fig.bak mode change 100644 => 100755 manual/manual-main/images/win_acquisition.eps mode change 100644 => 100755 manual/manual-main/libs.txt mode change 100644 => 100755 manual/manual-main/manual.tex mode change 100644 => 100755 manual/manual-main/multi_detector.eps mode change 100644 => 100755 manual/manual-main/multi_detector.fig mode change 100644 => 100755 manual/manual-main/singlePhotonCounting-FAQ.tex mode change 100644 => 100755 manual/manual-main/slsDetector-softFAQ.tex mode change 100644 => 100755 manual/manual-main/slsDetectorClientHowTo.tex mode change 100644 => 100755 manual/manual-main/slsDetectorGuiHowTo.tex mode change 100644 => 100755 manual/manual-main/slsDetectorInstall.tex mode change 100644 => 100755 manual/manual-main/slsDetectors-FAQ.tex mode change 100644 => 100755 python/CMakeLists.txt mode change 100644 => 100755 python/LICENSE mode change 100644 => 100755 python/README.md mode change 100644 => 100755 python/scripts/basic.py mode change 100644 => 100755 python/setup.py mode change 100644 => 100755 python/simple-integration-tests/eiger/config_test.py mode change 100644 => 100755 python/simple-integration-tests/eiger/fixtures.py mode change 100644 => 100755 python/simple-integration-tests/eiger/settingsdir/standard/5000eV/noise.sn083 mode change 100644 => 100755 python/simple-integration-tests/eiger/settingsdir/standard/5000eV/noise.sn098 mode change 100644 => 100755 python/simple-integration-tests/eiger/settingsdir/standard/5000eV/trimbits.sn000 mode change 100644 => 100755 python/simple-integration-tests/eiger/settingsdir/standard/6000eV/noise.sn083 mode change 100644 => 100755 python/simple-integration-tests/eiger/settingsdir/standard/6000eV/noise.sn098 mode change 100644 => 100755 python/simple-integration-tests/eiger/settingsdir/standard/6000eV/trimbits.sn000 mode change 100644 => 100755 python/simple-integration-tests/eiger/settingsdir/standard/7000eV/noise.sn083 mode change 100644 => 100755 python/simple-integration-tests/eiger/settingsdir/standard/7000eV/noise.sn098 mode change 100644 => 100755 python/simple-integration-tests/eiger/settingsdir/standard/7000eV/trimbits.sn000 mode change 100644 => 100755 python/simple-integration-tests/eiger/test.config mode change 100644 => 100755 python/simple-integration-tests/eiger/test.par mode change 100644 => 100755 python/simple-integration-tests/eiger/test_dynamic_range.py mode change 100644 => 100755 python/simple-integration-tests/eiger/test_eiger_specific.py mode change 100644 => 100755 python/simple-integration-tests/eiger/test_firmware.py mode change 100644 => 100755 python/simple-integration-tests/eiger/test_general.py mode change 100644 => 100755 python/simple-integration-tests/eiger/test_load_config.py mode change 100644 => 100755 python/simple-integration-tests/eiger/test_network.py mode change 100644 => 100755 python/simple-integration-tests/eiger/test_paths_and_files.py mode change 100644 => 100755 python/simple-integration-tests/eiger/test_threshold.py mode change 100644 => 100755 python/simple-integration-tests/eiger/test_time.py mode change 100644 => 100755 python/simple-integration-tests/eiger/test_trimbits_and_dacs.py mode change 100644 => 100755 python/simple-integration-tests/eiger/test_version_numbers.py mode change 100644 => 100755 python/simple-integration-tests/eiger/write_tb_files.py mode change 100644 => 100755 python/simple-integration-tests/jungfrau_0_6/config_test.py mode change 100644 => 100755 python/simple-integration-tests/jungfrau_0_6/fixtures.py mode change 100644 => 100755 python/simple-integration-tests/jungfrau_0_6/test_main.py mode change 100644 => 100755 python/simple-integration-tests/jungfrau_0_6/tests/test.config mode change 100644 => 100755 python/simple-integration-tests/jungfrau_0_6/tests/test.par mode change 100644 => 100755 python/simple-integration-tests/jungfrau_0_6/tests/test_load_config.py mode change 100644 => 100755 python/simple-integration-tests/jungfrau_0_6/tests/test_overtemperature.py mode change 100644 => 100755 python/sls_detector/__init__.py mode change 100644 => 100755 python/sls_detector/adcs.py mode change 100644 => 100755 python/sls_detector/dacs.py mode change 100644 => 100755 python/sls_detector/decorators.py mode change 100644 => 100755 python/sls_detector/detector.py mode change 100644 => 100755 python/sls_detector/detector_property.py mode change 100644 => 100755 python/sls_detector/eiger.py mode change 100644 => 100755 python/sls_detector/errors.py mode change 100644 => 100755 python/sls_detector/experimental.py mode change 100644 => 100755 python/sls_detector/jungfrau.py mode change 100644 => 100755 python/sls_detector/jungfrau_ctb.py mode change 100644 => 100755 python/sls_detector/registers.py mode change 100644 => 100755 python/sls_detector/utils.py mode change 100644 => 100755 python/sphinx/Makefile mode change 100644 => 100755 python/sphinx/_static/tp_scurve.png mode change 100644 => 100755 python/sphinx/_static/untrimmed.png mode change 100644 => 100755 python/sphinx/code_quality.rst mode change 100644 => 100755 python/sphinx/command_line.rst mode change 100644 => 100755 python/sphinx/conf.py mode change 100644 => 100755 python/sphinx/cpp_api.rst mode change 100644 => 100755 python/sphinx/error-handling.rst mode change 100644 => 100755 python/sphinx/examples.rst mode change 100644 => 100755 python/sphinx/getting_started.rst mode change 100644 => 100755 python/sphinx/index.rst mode change 100644 => 100755 python/sphinx/installation.rst mode change 100644 => 100755 python/sphinx/modules.rst mode change 100644 => 100755 python/sphinx/sls_detector.rst mode change 100644 => 100755 python/src/Detector.h mode change 100644 => 100755 python/src/main.cpp mode change 100644 => 100755 python/unit-tests/__pycache__/dac_test.cpython-37-PYTEST.pyc mode change 100644 => 100755 python/unit-tests/__pycache__/detector_test.cpython-37-PYTEST.pyc mode change 100644 => 100755 python/unit-tests/__pycache__/test_detector_property.cpython-37-PYTEST.pyc mode change 100644 => 100755 python/unit-tests/__pycache__/test_utils.cpython-37-PYTEST.pyc mode change 100644 => 100755 python/unit-tests/dac_test.py mode change 100644 => 100755 python/unit-tests/detector_eiger.py mode change 100644 => 100755 python/unit-tests/detector_test.py mode change 100644 => 100755 python/unit-tests/test_detector_property.py mode change 100644 => 100755 python/unit-tests/test_utils.py mode change 100644 => 100755 settingsdir/eiger/highgain/calibration.snbeb045 mode change 100644 => 100755 settingsdir/eiger/highgain/highgain.cal mode change 100644 => 100755 settingsdir/eiger/highgain/highgain.trim mode change 100644 => 100755 settingsdir/eiger/highgain/settings.snbeb045 mode change 100644 => 100755 settingsdir/eiger/lowgain/calibration.snbeb045 mode change 100644 => 100755 settingsdir/eiger/lowgain/lowgain.cal mode change 100644 => 100755 settingsdir/eiger/lowgain/lowgain.trim mode change 100644 => 100755 settingsdir/eiger/lowgain/settings.snbeb045 mode change 100644 => 100755 settingsdir/eiger/standard/4500eV/noise.sn031 mode change 100644 => 100755 settingsdir/eiger/standard/4500eV/noise.sn032 mode change 100644 => 100755 settingsdir/eiger/standard/5400eV/noise.sn031 mode change 100644 => 100755 settingsdir/eiger/standard/5400eV/noise.sn032 mode change 100644 => 100755 settingsdir/eiger/standard/6400eV/noise.sn031 mode change 100644 => 100755 settingsdir/eiger/standard/6400eV/noise.sn032 mode change 100644 => 100755 settingsdir/eiger/standard/calibration.sn031 mode change 100644 => 100755 settingsdir/eiger/standard/calibration.sn032 mode change 100644 => 100755 settingsdir/eiger/standard/eigernoise.sn049 mode change 100644 => 100755 settingsdir/eiger/standard/noise.sn031 mode change 100644 => 100755 settingsdir/eiger/standard/noise.sn032 mode change 100644 => 100755 settingsdir/eiger/standard/standard.cal mode change 100644 => 100755 settingsdir/eiger/standard/standard.trim mode change 100644 => 100755 settingsdir/eiger/veryhighgain/calibration.sn031 mode change 100644 => 100755 settingsdir/eiger/veryhighgain/calibration.sn032 mode change 100644 => 100755 settingsdir/eiger/veryhighgain/noise.sn031 mode change 100644 => 100755 settingsdir/eiger/veryhighgain/noise.sn032 mode change 100644 => 100755 settingsdir/eiger/veryhighgain/veryhighgain.cal mode change 100644 => 100755 settingsdir/eiger/veryhighgain/veryhighgain.trim mode change 100644 => 100755 settingsdir/eiger/verylowgain/calibration.sn031 mode change 100644 => 100755 settingsdir/eiger/verylowgain/calibration.sn032 mode change 100644 => 100755 settingsdir/eiger/verylowgain/noise.sn031 mode change 100644 => 100755 settingsdir/eiger/verylowgain/noise.sn032 mode change 100644 => 100755 settingsdir/eiger/verylowgain/verylowgain.cal mode change 100644 => 100755 settingsdir/eiger/verylowgain/verylowgain.trim mode change 100644 => 100755 settingsdir/mythen/fast/noise.snxxx mode change 100644 => 100755 settingsdir/mythen/highgain/noise.snxxx mode change 100644 => 100755 settingsdir/mythen/standard/noise.snxxx mode change 100644 => 100755 settingsdir/mythen/standard/standard.trim mode change 100644 => 100755 slsDetectorGui/.gitignore mode change 100644 => 100755 slsDetectorGui/CMakeLists.txt mode change 100644 => 100755 slsDetectorGui/client/qClient.cpp mode change 100644 => 100755 slsDetectorGui/client/qClient.h mode change 100644 => 100755 slsDetectorGui/doxy.config delete mode 100644 slsDetectorGui/forms/form_action.ui mode change 100644 => 100755 slsDetectorGui/forms/form_detectormain.ui delete mode 100644 slsDetectorGui/forms/form_scan.ui mode change 100644 => 100755 slsDetectorGui/forms/form_tab_advanced.ui mode change 100644 => 100755 slsDetectorGui/forms/form_tab_dataoutput.ui mode change 100644 => 100755 slsDetectorGui/forms/form_tab_debugging.ui mode change 100644 => 100755 slsDetectorGui/forms/form_tab_measurement.ui mode change 100644 => 100755 slsDetectorGui/forms/form_tab_messages.ui mode change 100644 => 100755 slsDetectorGui/forms/form_tab_plot.ui mode change 100644 => 100755 slsDetectorGui/forms/form_tab_settings.ui delete mode 100644 slsDetectorGui/gitInfo.txt mode change 100644 => 100755 slsDetectorGui/images/add.png mode change 100644 => 100755 slsDetectorGui/images/browse.png mode change 100644 => 100755 slsDetectorGui/images/calculate.png mode change 100644 => 100755 slsDetectorGui/images/close.png mode change 100644 => 100755 slsDetectorGui/images/download.png mode change 100644 => 100755 slsDetectorGui/images/erase.png mode change 100644 => 100755 slsDetectorGui/images/leftArrow.png mode change 100644 => 100755 slsDetectorGui/images/mountain.png mode change 100644 => 100755 slsDetectorGui/images/new.png mode change 100644 => 100755 slsDetectorGui/images/refresh.png mode change 100644 => 100755 slsDetectorGui/images/refresher.png mode change 100644 => 100755 slsDetectorGui/images/remove.png mode change 100644 => 100755 slsDetectorGui/images/rightArrow.png mode change 100644 => 100755 slsDetectorGui/images/save.png mode change 100644 => 100755 slsDetectorGui/images/saveAll.png mode change 100644 => 100755 slsDetectorGui/images/setup.png mode change 100644 => 100755 slsDetectorGui/images/start.png mode change 100644 => 100755 slsDetectorGui/images/stop.png mode change 100644 => 100755 slsDetectorGui/images/upload.png delete mode 100644 slsDetectorGui/include/gitInfoGui.h delete mode 100644 slsDetectorGui/include/gitInfoGuiTmp.h mode change 100644 => 100755 slsDetectorGui/include/icons.qrc delete mode 100644 slsDetectorGui/include/qActionsWidget.h mode change 100644 => 100755 slsDetectorGui/include/qCloneWidget.h mode change 100644 => 100755 slsDetectorGui/include/qDebugStream.h mode change 100644 => 100755 slsDetectorGui/include/qDefs.h mode change 100644 => 100755 slsDetectorGui/include/qDetectorMain.h mode change 100644 => 100755 slsDetectorGui/include/qDrawPlot.h delete mode 100644 slsDetectorGui/include/qScanWidget.h mode change 100644 => 100755 slsDetectorGui/include/qServer.h delete mode 100644 slsDetectorGui/include/qTabActions.h mode change 100644 => 100755 slsDetectorGui/include/qTabAdvanced.h mode change 100644 => 100755 slsDetectorGui/include/qTabDataOutput.h mode change 100644 => 100755 slsDetectorGui/include/qTabDebugging.h mode change 100644 => 100755 slsDetectorGui/include/qTabDeveloper.h mode change 100644 => 100755 slsDetectorGui/include/qTabMeasurement.h mode change 100644 => 100755 slsDetectorGui/include/qTabMessages.h mode change 100644 => 100755 slsDetectorGui/include/qTabPlot.h mode change 100644 => 100755 slsDetectorGui/include/qTabSettings.h delete mode 100644 slsDetectorGui/slsDetectorGui.pro mode change 100644 => 100755 slsDetectorGui/slsDetectorPlotting/include/SlsQt1DPlot.h mode change 100644 => 100755 slsDetectorGui/slsDetectorPlotting/include/SlsQt1DZoomer.h mode change 100644 => 100755 slsDetectorGui/slsDetectorPlotting/include/SlsQt2DHist.h mode change 100644 => 100755 slsDetectorGui/slsDetectorPlotting/include/SlsQt2DPlot.h mode change 100644 => 100755 slsDetectorGui/slsDetectorPlotting/include/SlsQt2DPlotLayout.h mode change 100644 => 100755 slsDetectorGui/slsDetectorPlotting/include/SlsQt2DZoomer.h mode change 100644 => 100755 slsDetectorGui/slsDetectorPlotting/include/SlsQtNumberEntry.h mode change 100644 => 100755 slsDetectorGui/slsDetectorPlotting/include/SlsQtValidators.h mode change 100644 => 100755 slsDetectorGui/slsDetectorPlotting/src/SlsQt1DPlot.cxx mode change 100644 => 100755 slsDetectorGui/slsDetectorPlotting/src/SlsQt1DZoomer.cxx mode change 100644 => 100755 slsDetectorGui/slsDetectorPlotting/src/SlsQt2DHist.cxx mode change 100644 => 100755 slsDetectorGui/slsDetectorPlotting/src/SlsQt2DPlot.cxx mode change 100644 => 100755 slsDetectorGui/slsDetectorPlotting/src/SlsQt2DPlotLayout.cxx mode change 100644 => 100755 slsDetectorGui/slsDetectorPlotting/src/SlsQtNumberEntry.cxx delete mode 100644 slsDetectorGui/src/qActionsWidget.cpp mode change 100644 => 100755 slsDetectorGui/src/qCloneWidget.cpp mode change 100644 => 100755 slsDetectorGui/src/qDetectorMain.cpp mode change 100644 => 100755 slsDetectorGui/src/qDrawPlot.cpp delete mode 100644 slsDetectorGui/src/qScanWidget.cpp mode change 100644 => 100755 slsDetectorGui/src/qServer.cpp delete mode 100644 slsDetectorGui/src/qTabActions.cpp mode change 100644 => 100755 slsDetectorGui/src/qTabAdvanced.cpp mode change 100644 => 100755 slsDetectorGui/src/qTabDataOutput.cpp mode change 100644 => 100755 slsDetectorGui/src/qTabDebugging.cpp mode change 100644 => 100755 slsDetectorGui/src/qTabDeveloper.cpp mode change 100644 => 100755 slsDetectorGui/src/qTabMeasurement.cpp mode change 100644 => 100755 slsDetectorGui/src/qTabMessages.cpp mode change 100644 => 100755 slsDetectorGui/src/qTabPlot.cpp mode change 100644 => 100755 slsDetectorGui/src/qTabSettings.cpp delete mode 100755 slsDetectorGui/updateGitVersion.sh mode change 100644 => 100755 slsDetectorServers/ctbDetectorServer/Makefile.virtual mode change 100644 => 100755 slsDetectorServers/ctbDetectorServer/RegisterDefs.h delete mode 100644 slsDetectorServers/ctbDetectorServer/gitInfo.txt delete mode 100644 slsDetectorServers/ctbDetectorServer/gitInfoCtb.h delete mode 100644 slsDetectorServers/ctbDetectorServer/gitInfoCtbTmp.h mode change 100644 => 100755 slsDetectorServers/ctbDetectorServer/slsDetectorFunctionList.c mode change 100644 => 100755 slsDetectorServers/ctbDetectorServer/slsDetectorServer_defs.h delete mode 100755 slsDetectorServers/ctbDetectorServer/updateAPIVersion.sh delete mode 100755 slsDetectorServers/ctbDetectorServer/updateGitVersion.sh mode change 100644 => 100755 slsDetectorServers/eigerDetectorServer/9mhvserial_bf.c mode change 100644 => 100755 slsDetectorServers/eigerDetectorServer/Beb.c mode change 100644 => 100755 slsDetectorServers/eigerDetectorServer/Beb.h mode change 100644 => 100755 slsDetectorServers/eigerDetectorServer/FebControl.c mode change 100644 => 100755 slsDetectorServers/eigerDetectorServer/FebControl.h mode change 100644 => 100755 slsDetectorServers/eigerDetectorServer/FebInterface.c mode change 100644 => 100755 slsDetectorServers/eigerDetectorServer/FebInterface.h mode change 100644 => 100755 slsDetectorServers/eigerDetectorServer/FebRegisterDefs.h mode change 100644 => 100755 slsDetectorServers/eigerDetectorServer/HardwareIO.c mode change 100644 => 100755 slsDetectorServers/eigerDetectorServer/HardwareIO.h mode change 100644 => 100755 slsDetectorServers/eigerDetectorServer/HardwareMMappingDefs.h mode change 100644 => 100755 slsDetectorServers/eigerDetectorServer/LocalLinkInterface.c mode change 100644 => 100755 slsDetectorServers/eigerDetectorServer/LocalLinkInterface.h mode change 100644 => 100755 slsDetectorServers/eigerDetectorServer/Makefile.virtual delete mode 100644 slsDetectorServers/eigerDetectorServer/gitInfo.txt delete mode 100644 slsDetectorServers/eigerDetectorServer/gitInfoEiger.h delete mode 100644 slsDetectorServers/eigerDetectorServer/gitInfoEigerTmp.h mode change 100644 => 100755 slsDetectorServers/eigerDetectorServer/renameServer.sh mode change 100644 => 100755 slsDetectorServers/eigerDetectorServer/slsDetectorFunctionList.c mode change 100644 => 100755 slsDetectorServers/eigerDetectorServer/slsDetectorServer_defs.h delete mode 100755 slsDetectorServers/eigerDetectorServer/updateAPIVersion.sh delete mode 100755 slsDetectorServers/eigerDetectorServer/updateGitVersion.sh mode change 100644 => 100755 slsDetectorServers/eigerDetectorServer/xfs_types.h mode change 100644 => 100755 slsDetectorServers/eigerDetectorServer/xparameters.h mode change 100644 => 100755 slsDetectorServers/gotthardDetectorServer/config.txt delete mode 100644 slsDetectorServers/gotthardDetectorServer/gitInfo.txt delete mode 100644 slsDetectorServers/gotthardDetectorServer/gitInfoGotthard.h delete mode 100644 slsDetectorServers/gotthardDetectorServer/gitInfoGotthardTmp.h mode change 100644 => 100755 slsDetectorServers/gotthardDetectorServer/slsDetectorFunctionList.c mode change 100644 => 100755 slsDetectorServers/gotthardDetectorServer/slsDetectorServer_defs.h delete mode 100755 slsDetectorServers/gotthardDetectorServer/updateAPIVersion.sh delete mode 100755 slsDetectorServers/gotthardDetectorServer/updateGitVersion.sh mode change 100644 => 100755 slsDetectorServers/jungfrauDetectorServer/Makefile.virtual mode change 100644 => 100755 slsDetectorServers/jungfrauDetectorServer/RegisterDefs.h delete mode 100644 slsDetectorServers/jungfrauDetectorServer/gitInfo.txt delete mode 100644 slsDetectorServers/jungfrauDetectorServer/gitInfoJungfrau.h delete mode 100644 slsDetectorServers/jungfrauDetectorServer/gitInfoJungfrauTmp.h mode change 100644 => 100755 slsDetectorServers/jungfrauDetectorServer/slsDetectorFunctionList.c mode change 100644 => 100755 slsDetectorServers/jungfrauDetectorServer/slsDetectorServer_defs.h delete mode 100755 slsDetectorServers/jungfrauDetectorServer/updateAPIVersion.sh delete mode 100755 slsDetectorServers/jungfrauDetectorServer/updateGitVersion.sh mode change 100644 => 100755 slsDetectorServers/moenchDetectorServer/Makefile.virtual mode change 100644 => 100755 slsDetectorServers/moenchDetectorServer/RegisterDefs.h delete mode 100644 slsDetectorServers/moenchDetectorServer/gitInfo.txt delete mode 100644 slsDetectorServers/moenchDetectorServer/gitInfoMoench.h delete mode 100644 slsDetectorServers/moenchDetectorServer/gitInfoMoenchTmp.h mode change 100644 => 100755 slsDetectorServers/moenchDetectorServer/slsDetectorFunctionList.c mode change 100644 => 100755 slsDetectorServers/moenchDetectorServer/slsDetectorServer_defs.h delete mode 100755 slsDetectorServers/moenchDetectorServer/updateAPIVersion.sh delete mode 100755 slsDetectorServers/moenchDetectorServer/updateGitVersion.sh mode change 100644 => 100755 slsDetectorServers/slsDetectorServer/logger.h mode change 100644 => 100755 slsDetectorServers/slsDetectorServer/slsDetectorFunctionList.h mode change 100644 => 100755 slsDetectorSoftware/CMakeLists.txt mode change 100644 => 100755 slsDetectorSoftware/doxy.config delete mode 100644 slsDetectorSoftware/gitInfo.txt mode change 100644 => 100755 slsDetectorSoftware/include/SharedMemory.h mode change 100644 => 100755 slsDetectorSoftware/include/detectorData.h delete mode 100644 slsDetectorSoftware/include/gitInfoLib.h delete mode 100644 slsDetectorSoftware/include/gitInfoLibTmp.h mode change 100644 => 100755 slsDetectorSoftware/include/multiSlsDetector.h mode change 100644 => 100755 slsDetectorSoftware/include/multiSlsDetectorClient.h mode change 100644 => 100755 slsDetectorSoftware/include/slsDetector.h mode change 100644 => 100755 slsDetectorSoftware/include/slsDetectorCommand.h mode change 100644 => 100755 slsDetectorSoftware/include/slsDetectorUsers.h mode change 100644 => 100755 slsDetectorSoftware/src/multiSlsDetector.cpp mode change 100644 => 100755 slsDetectorSoftware/src/slsDetector.cpp mode change 100644 => 100755 slsDetectorSoftware/src/slsDetectorCommand.cpp mode change 100644 => 100755 slsDetectorSoftware/src/slsDetectorUsers.cpp mode change 100644 => 100755 slsDetectorSoftware/src/sls_detector_client.cpp mode change 100644 => 100755 slsDetectorSoftware/tests/CMakeLists.txt mode change 100644 => 100755 slsDetectorSoftware/tests/test-SharedMemory.cpp mode change 100644 => 100755 slsDetectorSoftware/tests/test-multiSlsDetector.cpp mode change 100644 => 100755 slsDetectorSoftware/tests/test-slsDetector.cpp delete mode 100755 slsDetectorSoftware/updateGitVersion.sh mode change 100644 => 100755 slsReceiverSoftware/CMakeLists.txt delete mode 100644 slsReceiverSoftware/gitInfo.txt mode change 100644 => 100755 slsReceiverSoftware/include/BinaryFile.h mode change 100644 => 100755 slsReceiverSoftware/include/BinaryFileStatic.h mode change 100644 => 100755 slsReceiverSoftware/include/DataProcessor.h mode change 100644 => 100755 slsReceiverSoftware/include/DataStreamer.h mode change 100644 => 100755 slsReceiverSoftware/include/Fifo.h mode change 100644 => 100755 slsReceiverSoftware/include/File.h mode change 100644 => 100755 slsReceiverSoftware/include/GeneralData.h mode change 100644 => 100755 slsReceiverSoftware/include/HDF5File.h mode change 100644 => 100755 slsReceiverSoftware/include/HDF5FileStatic.h mode change 100644 => 100755 slsReceiverSoftware/include/Listener.h mode change 100644 => 100755 slsReceiverSoftware/include/ThreadObject.h mode change 100644 => 100755 slsReceiverSoftware/include/circularFifo.h delete mode 100644 slsReceiverSoftware/include/gitInfoReceiver.h delete mode 100644 slsReceiverSoftware/include/gitInfoReceiverTmp.h mode change 100644 => 100755 slsReceiverSoftware/include/slsReceiver.h mode change 100644 => 100755 slsReceiverSoftware/include/slsReceiverImplementation.h mode change 100644 => 100755 slsReceiverSoftware/include/slsReceiverTCPIPInterface.h mode change 100644 => 100755 slsReceiverSoftware/include/slsReceiverUsers.h mode change 100644 => 100755 slsReceiverSoftware/slsReceiverUsers.doxy mode change 100644 => 100755 slsReceiverSoftware/src/BinaryFile.cpp mode change 100644 => 100755 slsReceiverSoftware/src/DataProcessor.cpp mode change 100644 => 100755 slsReceiverSoftware/src/DataStreamer.cpp mode change 100644 => 100755 slsReceiverSoftware/src/Fifo.cpp mode change 100644 => 100755 slsReceiverSoftware/src/File.cpp mode change 100644 => 100755 slsReceiverSoftware/src/HDF5File.cpp mode change 100644 => 100755 slsReceiverSoftware/src/Listener.cpp mode change 100644 => 100755 slsReceiverSoftware/src/ThreadObject.cpp mode change 100644 => 100755 slsReceiverSoftware/src/main.cpp mode change 100644 => 100755 slsReceiverSoftware/src/slsReceiver.cpp mode change 100644 => 100755 slsReceiverSoftware/src/slsReceiverImplementation.cpp mode change 100644 => 100755 slsReceiverSoftware/src/slsReceiverTCPIPInterface.cpp mode change 100644 => 100755 slsReceiverSoftware/src/slsReceiverUsers.cpp mode change 100644 => 100755 slsReceiverSoftware/tests/CMakeLists.txt mode change 100644 => 100755 slsReceiverSoftware/tests/test-GeneralData.cpp delete mode 100755 slsReceiverSoftware/updateAPIVersion.sh delete mode 100755 slsReceiverSoftware/updateGitVersion.sh mode change 100644 => 100755 slsSupportLib/CMakeLists.txt mode change 100644 => 100755 slsSupportLib/include/ClientInterface.h mode change 100644 => 100755 slsSupportLib/include/ClientSocket.h mode change 100644 => 100755 slsSupportLib/include/CmdLineParser.h mode change 100644 => 100755 slsSupportLib/include/DataSocket.h mode change 100644 => 100755 slsSupportLib/include/MySocketTCP.h mode change 100644 => 100755 slsSupportLib/include/ServerInterface.h mode change 100644 => 100755 slsSupportLib/include/ServerSocket.h mode change 100644 => 100755 slsSupportLib/include/Timer.h mode change 100644 => 100755 slsSupportLib/include/ZmqSocket.h mode change 100644 => 100755 slsSupportLib/include/ansi.h mode change 100644 => 100755 slsSupportLib/include/container_utils.h mode change 100644 => 100755 slsSupportLib/include/error_defs.h mode change 100644 => 100755 slsSupportLib/include/file_utils.h mode change 100644 => 100755 slsSupportLib/include/genericSocket.h mode change 100644 => 100755 slsSupportLib/include/logger.h mode change 100644 => 100755 slsSupportLib/include/network_utils.h mode change 100644 => 100755 slsSupportLib/include/rapidjson/allocators.h mode change 100644 => 100755 slsSupportLib/include/rapidjson/document.h mode change 100644 => 100755 slsSupportLib/include/rapidjson/encodedstream.h mode change 100644 => 100755 slsSupportLib/include/rapidjson/encodings.h mode change 100644 => 100755 slsSupportLib/include/rapidjson/error/en.h mode change 100644 => 100755 slsSupportLib/include/rapidjson/error/error.h mode change 100644 => 100755 slsSupportLib/include/rapidjson/filereadstream.h mode change 100644 => 100755 slsSupportLib/include/rapidjson/filewritestream.h mode change 100644 => 100755 slsSupportLib/include/rapidjson/fwd.h mode change 100644 => 100755 slsSupportLib/include/rapidjson/internal/biginteger.h mode change 100644 => 100755 slsSupportLib/include/rapidjson/internal/diyfp.h mode change 100644 => 100755 slsSupportLib/include/rapidjson/internal/dtoa.h mode change 100644 => 100755 slsSupportLib/include/rapidjson/internal/ieee754.h mode change 100644 => 100755 slsSupportLib/include/rapidjson/internal/itoa.h mode change 100644 => 100755 slsSupportLib/include/rapidjson/internal/meta.h mode change 100644 => 100755 slsSupportLib/include/rapidjson/internal/pow10.h mode change 100644 => 100755 slsSupportLib/include/rapidjson/internal/regex.h mode change 100644 => 100755 slsSupportLib/include/rapidjson/internal/stack.h mode change 100644 => 100755 slsSupportLib/include/rapidjson/internal/strfunc.h mode change 100644 => 100755 slsSupportLib/include/rapidjson/internal/strtod.h mode change 100644 => 100755 slsSupportLib/include/rapidjson/internal/swap.h mode change 100644 => 100755 slsSupportLib/include/rapidjson/istreamwrapper.h mode change 100644 => 100755 slsSupportLib/include/rapidjson/memorybuffer.h mode change 100644 => 100755 slsSupportLib/include/rapidjson/memorystream.h mode change 100644 => 100755 slsSupportLib/include/rapidjson/msinttypes/inttypes.h mode change 100644 => 100755 slsSupportLib/include/rapidjson/msinttypes/stdint.h mode change 100644 => 100755 slsSupportLib/include/rapidjson/ostreamwrapper.h mode change 100644 => 100755 slsSupportLib/include/rapidjson/pointer.h mode change 100644 => 100755 slsSupportLib/include/rapidjson/prettywriter.h mode change 100644 => 100755 slsSupportLib/include/rapidjson/rapidjson.h mode change 100644 => 100755 slsSupportLib/include/rapidjson/reader.h mode change 100644 => 100755 slsSupportLib/include/rapidjson/schema.h mode change 100644 => 100755 slsSupportLib/include/rapidjson/stream.h mode change 100644 => 100755 slsSupportLib/include/rapidjson/stringbuffer.h mode change 100644 => 100755 slsSupportLib/include/rapidjson/writer.h mode change 100644 => 100755 slsSupportLib/include/sls_detector_exceptions.h mode change 100644 => 100755 slsSupportLib/include/sls_detector_funcs.h mode change 100644 => 100755 slsSupportLib/include/string_utils.h mode change 100644 => 100755 slsSupportLib/src/ClientInterface.cpp mode change 100644 => 100755 slsSupportLib/src/ClientSocket.cpp mode change 100644 => 100755 slsSupportLib/src/CmdLineParser.cpp mode change 100644 => 100755 slsSupportLib/src/DataSocket.cpp mode change 100644 => 100755 slsSupportLib/src/ServerInterface.cpp mode change 100644 => 100755 slsSupportLib/src/ServerSocket.cpp mode change 100644 => 100755 slsSupportLib/src/file_utils.cpp mode change 100644 => 100755 slsSupportLib/src/network_utils.cpp mode change 100644 => 100755 slsSupportLib/src/string_utils.cpp mode change 100644 => 100755 slsSupportLib/tests/CMakeLists.txt mode change 100644 => 100755 slsSupportLib/tests/test-ClientInterface.cpp mode change 100644 => 100755 slsSupportLib/tests/test-CmdLineParser.cpp mode change 100644 => 100755 slsSupportLib/tests/test-Timer.cpp mode change 100644 => 100755 slsSupportLib/tests/test-container_utils.cpp mode change 100644 => 100755 slsSupportLib/tests/test-network_utils.cpp mode change 100644 => 100755 slsSupportLib/tests/test-string_utils.cpp mode change 100644 => 100755 tests/CMakeLists.txt mode change 100644 => 100755 tests/test.cpp create mode 100755 updateAPIVersion.sh create mode 100755 updateClientAPI.sh diff --git a/CMakeLists.txt b/CMakeLists.txt old mode 100644 new mode 100755 index 858528c56..12e971414 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -35,11 +35,11 @@ if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR) endif() option (SLS_USE_HDF5 "HDF5 File format" OFF) -option (SLS_USE_TEXTCLIENT "Text Client" OFF) -option (SLS_USE_RECEIVER "Receiver" OFF) -option (SLS_USE_GUI "GUI" OFF) -option (SLS_USE_TESTS "TESTS" ON) -option (SLS_USE_INTEGRATION_TESTS "Integration Tests" ON) +option (SLS_USE_TEXTCLIENT "Text Client" ON) +option (SLS_USE_RECEIVER "Receiver" ON) +option (SLS_USE_GUI "GUI" ON) +option (SLS_USE_TESTS "TESTS" OFF) +option (SLS_USE_INTEGRATION_TESTS "Integration Tests" OFF) option(SLS_USE_SANITIZER "Sanitizers for debugging" OFF) option(SLS_USE_PYTHON "Python bindings" OFF) set(CMAKE_EXPORT_COMPILE_COMMANDS ON) diff --git a/README.md b/README.md old mode 100644 new mode 100755 diff --git a/RELEASE.txt b/RELEASE.txt old mode 100644 new mode 100755 diff --git a/catch/catch.hpp b/catch/catch.hpp old mode 100644 new mode 100755 diff --git a/cmake/Catch.cmake b/cmake/Catch.cmake old mode 100644 new mode 100755 diff --git a/cmake/CatchAddTests.cmake b/cmake/CatchAddTests.cmake old mode 100644 new mode 100755 diff --git a/cmake/FindCBF.cmake b/cmake/FindCBF.cmake old mode 100644 new mode 100755 diff --git a/cmake/FindQwt.cmake b/cmake/FindQwt.cmake old mode 100644 new mode 100755 diff --git a/cmake/FindROOT.cmake b/cmake/FindROOT.cmake old mode 100644 new mode 100755 diff --git a/cmake/FindZeroMQ.cmake b/cmake/FindZeroMQ.cmake old mode 100644 new mode 100755 diff --git a/cmake/ParseAndAddCatchTests.cmake b/cmake/ParseAndAddCatchTests.cmake old mode 100644 new mode 100755 diff --git a/cmake/package_config.cmake b/cmake/package_config.cmake old mode 100644 new mode 100755 diff --git a/cmake/project-config.cmake.in b/cmake/project-config.cmake.in old mode 100644 new mode 100755 diff --git a/cmake/project_version.cc.in b/cmake/project_version.cc.in old mode 100644 new mode 100755 diff --git a/cmake/project_version.cmake b/cmake/project_version.cmake old mode 100644 new mode 100755 diff --git a/cmake/project_version.h.in b/cmake/project_version.h.in old mode 100644 new mode 100755 diff --git a/cmk.sh b/cmk.sh index 8e00f07e9..99183d859 100755 --- a/cmk.sh +++ b/cmk.sh @@ -116,8 +116,8 @@ done if [ $TEXTCLIENT -eq 0 ] && [ $RECEIVER -eq 0 ] && [ $GUI -eq 0 ]; then -# CMAKE_POST+=" -DSLS_USE_TEXTCLIENT=ON -DSLS_USE_RECEIVER=ON -DSLS_USE_GUI=ON " - CMAKE_POST+=" -DSLS_USE_TEXTCLIENT=ON -DSLS_USE_RECEIVER=ON " + CMAKE_POST+=" -DSLS_USE_TEXTCLIENT=ON -DSLS_USE_RECEIVER=ON -DSLS_USE_GUI=ON " + #CMAKE_POST+=" -DSLS_USE_TEXTCLIENT=ON -DSLS_USE_RECEIVER=ON -DSLS_USE_GUI=OFF " echo "Compile Option: TextClient, Receiver and GUI" else if [ $TEXTCLIENT -eq 1 ]; then diff --git a/conda-recepie/build.sh b/conda-recepie/build.sh old mode 100644 new mode 100755 diff --git a/conda-recepie/build_pylib.sh b/conda-recepie/build_pylib.sh old mode 100644 new mode 100755 diff --git a/conda-recepie/copy_gui.sh b/conda-recepie/copy_gui.sh old mode 100644 new mode 100755 diff --git a/conda-recepie/copy_lib.sh b/conda-recepie/copy_lib.sh old mode 100644 new mode 100755 diff --git a/conda-recepie/meta.yaml b/conda-recepie/meta.yaml old mode 100644 new mode 100755 diff --git a/conda-recepie/run_test.sh b/conda-recepie/run_test.sh old mode 100644 new mode 100755 diff --git a/evalVersionVariables.sh b/evalVersionVariables.sh old mode 100644 new mode 100755 diff --git a/examples/bad.chans b/examples/bad.chans old mode 100644 new mode 100755 diff --git a/examples/config_gen_script/beb_31_25.config_gen b/examples/config_gen_script/beb_31_25.config_gen old mode 100644 new mode 100755 diff --git a/examples/config_gen_script/eiger_2m_1gb.config_gen b/examples/config_gen_script/eiger_2m_1gb.config_gen old mode 100644 new mode 100755 diff --git a/examples/eiger_10Gb.config b/examples/eiger_10Gb.config old mode 100644 new mode 100755 diff --git a/examples/eiger_1Gb.config b/examples/eiger_1Gb.config old mode 100644 new mode 100755 diff --git a/examples/gotthard.config b/examples/gotthard.config old mode 100644 new mode 100755 diff --git a/examples/gotthard_setup.det b/examples/gotthard_setup.det old mode 100644 new mode 100755 diff --git a/examples/gotthard_two.config b/examples/gotthard_two.config old mode 100644 new mode 100755 diff --git a/examples/howto_gotthard_twomodules.txt b/examples/howto_gotthard_twomodules.txt old mode 100644 new mode 100755 diff --git a/examples/jungfrau.config b/examples/jungfrau.config old mode 100644 new mode 100755 diff --git a/examples/jungfrau_two.config b/examples/jungfrau_two.config old mode 100644 new mode 100755 diff --git a/examples/moench01_T1_lab.config b/examples/moench01_T1_lab.config old mode 100644 new mode 100755 diff --git a/examples/mythen.config b/examples/mythen.config old mode 100644 new mode 100755 diff --git a/examples/receiver.config b/examples/receiver.config old mode 100644 new mode 100755 diff --git a/examples/scripts/.parab b/examples/scripts/.parab old mode 100644 new mode 100755 diff --git a/examples/two_gotthard.config b/examples/two_gotthard.config old mode 100644 new mode 100755 diff --git a/examples/two_no_receiver.config b/examples/two_no_receiver.config old mode 100644 new mode 100755 diff --git a/integrationTests/CMakeLists.txt b/integrationTests/CMakeLists.txt old mode 100644 new mode 100755 diff --git a/integrationTests/test-integrationDectector.cpp b/integrationTests/test-integrationDectector.cpp old mode 100644 new mode 100755 diff --git a/integrationTests/test-integrationMulti.cpp b/integrationTests/test-integrationMulti.cpp old mode 100644 new mode 100755 diff --git a/integrationTests/test.cpp b/integrationTests/test.cpp old mode 100644 new mode 100755 diff --git a/manual/Makefile b/manual/Makefile old mode 100644 new mode 100755 diff --git a/manual/index.html b/manual/index.html old mode 100644 new mode 100755 diff --git a/manual/manual-api/CMakeLists.txt b/manual/manual-api/CMakeLists.txt old mode 100644 new mode 100755 diff --git a/manual/manual-api/Makefile b/manual/manual-api/Makefile old mode 100644 new mode 100755 diff --git a/manual/manual-api/mainClient.cpp b/manual/manual-api/mainClient.cpp old mode 100644 new mode 100755 diff --git a/manual/manual-api/mainReceiver.cpp b/manual/manual-api/mainReceiver.cpp old mode 100644 new mode 100755 diff --git a/manual/manual-api/slsDetectorUsers.doxy b/manual/manual-api/slsDetectorUsers.doxy old mode 100644 new mode 100755 diff --git a/manual/manual-calwiz/Advanced.png b/manual/manual-calwiz/Advanced.png old mode 100644 new mode 100755 diff --git a/manual/manual-calwiz/Constant_step.png b/manual/manual-calwiz/Constant_step.png old mode 100644 new mode 100755 diff --git a/manual/manual-calwiz/GUI_Advanced.eps b/manual/manual-calwiz/GUI_Advanced.eps old mode 100644 new mode 100755 diff --git a/manual/manual-calwiz/GUI_ThresholdScan.eps b/manual/manual-calwiz/GUI_ThresholdScan.eps old mode 100644 new mode 100755 diff --git a/manual/manual-calwiz/Makefile b/manual/manual-calwiz/Makefile old mode 100644 new mode 100755 diff --git a/manual/manual-calwiz/addEnergy.eps b/manual/manual-calwiz/addEnergy.eps old mode 100644 new mode 100755 diff --git a/manual/manual-calwiz/addEnergy.png b/manual/manual-calwiz/addEnergy.png old mode 100644 new mode 100755 diff --git a/manual/manual-calwiz/ancCal.tex b/manual/manual-calwiz/ancCal.tex old mode 100644 new mode 100755 diff --git a/manual/manual-calwiz/angleFit.eps b/manual/manual-calwiz/angleFit.eps old mode 100644 new mode 100755 diff --git a/manual/manual-calwiz/angleFit.png b/manual/manual-calwiz/angleFit.png old mode 100644 new mode 100755 diff --git a/manual/manual-calwiz/angularCalibrationHowTo.tex b/manual/manual-calwiz/angularCalibrationHowTo.tex old mode 100644 new mode 100755 diff --git a/manual/manual-calwiz/calibrateModule.eps b/manual/manual-calwiz/calibrateModule.eps old mode 100644 new mode 100755 diff --git a/manual/manual-calwiz/calibrateModule.png b/manual/manual-calwiz/calibrateModule.png old mode 100644 new mode 100755 diff --git a/manual/manual-calwiz/calibrationWizardsHowTo.tex b/manual/manual-calwiz/calibrationWizardsHowTo.tex old mode 100644 new mode 100755 diff --git a/manual/manual-calwiz/enCal.tex b/manual/manual-calwiz/enCal.tex old mode 100644 new mode 100755 diff --git a/manual/manual-calwiz/enable_angcal.eps b/manual/manual-calwiz/enable_angcal.eps old mode 100644 new mode 100755 diff --git a/manual/manual-calwiz/eneble_angcal.png b/manual/manual-calwiz/eneble_angcal.png old mode 100644 new mode 100755 diff --git a/manual/manual-calwiz/energyCalibrationHowTo.tex b/manual/manual-calwiz/energyCalibrationHowTo.tex old mode 100644 new mode 100755 diff --git a/manual/manual-calwiz/fig4.eps b/manual/manual-calwiz/fig4.eps old mode 100644 new mode 100755 diff --git a/manual/manual-calwiz/fig5.eps b/manual/manual-calwiz/fig5.eps old mode 100644 new mode 100755 diff --git a/manual/manual-calwiz/fig7.eps b/manual/manual-calwiz/fig7.eps old mode 100644 new mode 100755 diff --git a/manual/manual-calwiz/fig8.eps b/manual/manual-calwiz/fig8.eps old mode 100644 new mode 100755 diff --git a/manual/manual-calwiz/installation.tex b/manual/manual-calwiz/installation.tex old mode 100644 new mode 100755 diff --git a/manual/manual-calwiz/peakFit.eps b/manual/manual-calwiz/peakFit.eps old mode 100644 new mode 100755 diff --git a/manual/manual-calwiz/peakFit.png b/manual/manual-calwiz/peakFit.png old mode 100644 new mode 100755 diff --git a/manual/manual-calwiz/position_scan.eps b/manual/manual-calwiz/position_scan.eps old mode 100644 new mode 100755 diff --git a/manual/manual-calwiz/position_scan.png b/manual/manual-calwiz/position_scan.png old mode 100644 new mode 100755 diff --git a/manual/manual-calwiz/setupAngcal.eps b/manual/manual-calwiz/setupAngcal.eps old mode 100644 new mode 100755 diff --git a/manual/manual-calwiz/setupAngcal.png b/manual/manual-calwiz/setupAngcal.png old mode 100644 new mode 100755 diff --git a/manual/manual-calwiz/spectrum_expl.eps b/manual/manual-calwiz/spectrum_expl.eps old mode 100644 new mode 100755 diff --git a/manual/manual-calwiz/thr_scan_expl.eps b/manual/manual-calwiz/thr_scan_expl.eps old mode 100644 new mode 100755 diff --git a/manual/manual-calwiz/thr_scan_fluo.eps b/manual/manual-calwiz/thr_scan_fluo.eps old mode 100644 new mode 100755 diff --git a/manual/manual-client/Boards.png b/manual/manual-client/Boards.png old mode 100644 new mode 100755 diff --git a/manual/manual-client/Client2.eps b/manual/manual-client/Client2.eps old mode 100644 new mode 100755 diff --git a/manual/manual-client/Client2.png b/manual/manual-client/Client2.png old mode 100644 new mode 100755 diff --git a/manual/manual-client/EIGERUDPHeader.png b/manual/manual-client/EIGERUDPHeader.png old mode 100644 new mode 100755 diff --git a/manual/manual-client/Eiger-Chips.png b/manual/manual-client/Eiger-Chips.png old mode 100644 new mode 100755 diff --git a/manual/manual-client/Eiger_short.tex b/manual/manual-client/Eiger_short.tex old mode 100644 new mode 100755 diff --git a/manual/manual-client/GapPixels.png b/manual/manual-client/GapPixels.png old mode 100644 new mode 100755 diff --git a/manual/manual-client/LEDSim.png b/manual/manual-client/LEDSim.png old mode 100644 new mode 100755 diff --git a/manual/manual-client/Makefile b/manual/manual-client/Makefile old mode 100644 new mode 100755 diff --git a/manual/manual-client/TansmissionRates.png b/manual/manual-client/TansmissionRates.png old mode 100644 new mode 100755 diff --git a/manual/manual-client/commands.txt b/manual/manual-client/commands.txt old mode 100644 new mode 100755 diff --git a/manual/manual-client/libs.txt b/manual/manual-client/libs.txt old mode 100644 new mode 100755 diff --git a/manual/manual-client/slsDetectorClient.doxy b/manual/manual-client/slsDetectorClient.doxy old mode 100644 new mode 100755 diff --git a/manual/manual-client/slsDetectorClientHowTo.tex b/manual/manual-client/slsDetectorClientHowTo.tex old mode 100644 new mode 100755 diff --git a/manual/manual-client/tiggerIN.png b/manual/manual-client/tiggerIN.png old mode 100644 new mode 100755 diff --git a/manual/manual-gui/Makefile b/manual/manual-gui/Makefile old mode 100644 new mode 100755 diff --git a/manual/manual-gui/libs.txt b/manual/manual-gui/libs.txt old mode 100644 new mode 100755 diff --git a/manual/manual-gui/slsDetectorGuiHowTo.tex b/manual/manual-gui/slsDetectorGuiHowTo.tex old mode 100644 new mode 100755 diff --git a/manual/manual-main/AngConv.eps b/manual/manual-main/AngConv.eps old mode 100644 new mode 100755 diff --git a/manual/manual-main/AngConv_fml.tex b/manual/manual-main/AngConv_fml.tex old mode 100644 new mode 100755 diff --git a/manual/manual-main/F90-C++Interface.doc b/manual/manual-main/F90-C++Interface.doc old mode 100644 new mode 100755 diff --git a/manual/manual-main/Makefile b/manual/manual-main/Makefile old mode 100644 new mode 100755 diff --git a/manual/manual-main/Waver.tex b/manual/manual-main/Waver.tex old mode 100644 new mode 100755 diff --git a/manual/manual-main/angConv-FAQ.tex b/manual/manual-main/angConv-FAQ.tex old mode 100644 new mode 100755 diff --git a/manual/manual-main/chargeInt-FAQ.tex b/manual/manual-main/chargeInt-FAQ.tex old mode 100644 new mode 100755 diff --git a/manual/manual-main/data_receiver.eps b/manual/manual-main/data_receiver.eps old mode 100644 new mode 100755 diff --git a/manual/manual-main/data_receiver.fig b/manual/manual-main/data_receiver.fig old mode 100644 new mode 100755 diff --git a/manual/manual-main/generalDet-FAQ.tex b/manual/manual-main/generalDet-FAQ.tex old mode 100644 new mode 100755 diff --git a/manual/manual-main/images/FFSetup.eps b/manual/manual-main/images/FFSetup.eps old mode 100644 new mode 100755 diff --git a/manual/manual-main/images/bad_ff_col.eps b/manual/manual-main/images/bad_ff_col.eps old mode 100644 new mode 100755 diff --git a/manual/manual-main/images/continuos_trigger_acquisition.eps b/manual/manual-main/images/continuos_trigger_acquisition.eps old mode 100644 new mode 100755 diff --git a/manual/manual-main/images/continuos_trigger_acquisition.fig b/manual/manual-main/images/continuos_trigger_acquisition.fig old mode 100644 new mode 100755 diff --git a/manual/manual-main/images/ff_calibration.eps b/manual/manual-main/images/ff_calibration.eps old mode 100644 new mode 100755 diff --git a/manual/manual-main/images/ff_window.eps b/manual/manual-main/images/ff_window.eps old mode 100644 new mode 100755 diff --git a/manual/manual-main/images/gated_acquisition.eps b/manual/manual-main/images/gated_acquisition.eps old mode 100644 new mode 100755 diff --git a/manual/manual-main/images/gated_acquisition.fig b/manual/manual-main/images/gated_acquisition.fig old mode 100644 new mode 100755 diff --git a/manual/manual-main/images/gated_acquisition.fig.bak b/manual/manual-main/images/gated_acquisition.fig.bak old mode 100644 new mode 100755 diff --git a/manual/manual-main/images/noise_thresholdscantrimmed.eps b/manual/manual-main/images/noise_thresholdscantrimmed.eps old mode 100644 new mode 100755 diff --git a/manual/manual-main/images/noise_thresholdscanuntrimmed.eps b/manual/manual-main/images/noise_thresholdscanuntrimmed.eps old mode 100644 new mode 100755 diff --git a/manual/manual-main/images/normal_acquisition.eps b/manual/manual-main/images/normal_acquisition.eps old mode 100644 new mode 100755 diff --git a/manual/manual-main/images/normal_acquisition.fig b/manual/manual-main/images/normal_acquisition.fig old mode 100644 new mode 100755 diff --git a/manual/manual-main/images/normal_acquisition.fig.bak b/manual/manual-main/images/normal_acquisition.fig.bak old mode 100644 new mode 100755 diff --git a/manual/manual-main/images/ro_trigger_acquisition.eps b/manual/manual-main/images/ro_trigger_acquisition.eps old mode 100644 new mode 100755 diff --git a/manual/manual-main/images/ro_trigger_acquisition.fig b/manual/manual-main/images/ro_trigger_acquisition.fig old mode 100644 new mode 100755 diff --git a/manual/manual-main/images/ro_trigger_acquisition.fig.bak b/manual/manual-main/images/ro_trigger_acquisition.fig.bak old mode 100644 new mode 100755 diff --git a/manual/manual-main/images/sample_with_fluorescence.eps b/manual/manual-main/images/sample_with_fluorescence.eps old mode 100644 new mode 100755 diff --git a/manual/manual-main/images/settings.eps b/manual/manual-main/images/settings.eps old mode 100644 new mode 100755 diff --git a/manual/manual-main/images/single_trigger_acquisition.eps b/manual/manual-main/images/single_trigger_acquisition.eps old mode 100644 new mode 100755 diff --git a/manual/manual-main/images/single_trigger_acquisition.fig b/manual/manual-main/images/single_trigger_acquisition.fig old mode 100644 new mode 100755 diff --git a/manual/manual-main/images/thr_scan_expl.eps b/manual/manual-main/images/thr_scan_expl.eps old mode 100644 new mode 100755 diff --git a/manual/manual-main/images/thr_scan_fluo.eps b/manual/manual-main/images/thr_scan_fluo.eps old mode 100644 new mode 100755 diff --git a/manual/manual-main/images/trigger_acquisition.eps b/manual/manual-main/images/trigger_acquisition.eps old mode 100644 new mode 100755 diff --git a/manual/manual-main/images/trigger_acquisition.fig b/manual/manual-main/images/trigger_acquisition.fig old mode 100644 new mode 100755 diff --git a/manual/manual-main/images/trigger_acquisition.fig.bak b/manual/manual-main/images/trigger_acquisition.fig.bak old mode 100644 new mode 100755 diff --git a/manual/manual-main/images/win_acquisition.eps b/manual/manual-main/images/win_acquisition.eps old mode 100644 new mode 100755 diff --git a/manual/manual-main/libs.txt b/manual/manual-main/libs.txt old mode 100644 new mode 100755 diff --git a/manual/manual-main/manual.tex b/manual/manual-main/manual.tex old mode 100644 new mode 100755 diff --git a/manual/manual-main/multi_detector.eps b/manual/manual-main/multi_detector.eps old mode 100644 new mode 100755 diff --git a/manual/manual-main/multi_detector.fig b/manual/manual-main/multi_detector.fig old mode 100644 new mode 100755 diff --git a/manual/manual-main/singlePhotonCounting-FAQ.tex b/manual/manual-main/singlePhotonCounting-FAQ.tex old mode 100644 new mode 100755 diff --git a/manual/manual-main/slsDetector-softFAQ.tex b/manual/manual-main/slsDetector-softFAQ.tex old mode 100644 new mode 100755 diff --git a/manual/manual-main/slsDetectorClientHowTo.tex b/manual/manual-main/slsDetectorClientHowTo.tex old mode 100644 new mode 100755 diff --git a/manual/manual-main/slsDetectorGuiHowTo.tex b/manual/manual-main/slsDetectorGuiHowTo.tex old mode 100644 new mode 100755 diff --git a/manual/manual-main/slsDetectorInstall.tex b/manual/manual-main/slsDetectorInstall.tex old mode 100644 new mode 100755 diff --git a/manual/manual-main/slsDetectors-FAQ.tex b/manual/manual-main/slsDetectors-FAQ.tex old mode 100644 new mode 100755 diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt old mode 100644 new mode 100755 diff --git a/python/LICENSE b/python/LICENSE old mode 100644 new mode 100755 diff --git a/python/README.md b/python/README.md old mode 100644 new mode 100755 diff --git a/python/scripts/basic.py b/python/scripts/basic.py old mode 100644 new mode 100755 diff --git a/python/setup.py b/python/setup.py old mode 100644 new mode 100755 diff --git a/python/simple-integration-tests/eiger/config_test.py b/python/simple-integration-tests/eiger/config_test.py old mode 100644 new mode 100755 diff --git a/python/simple-integration-tests/eiger/fixtures.py b/python/simple-integration-tests/eiger/fixtures.py old mode 100644 new mode 100755 diff --git a/python/simple-integration-tests/eiger/settingsdir/standard/5000eV/noise.sn083 b/python/simple-integration-tests/eiger/settingsdir/standard/5000eV/noise.sn083 old mode 100644 new mode 100755 diff --git a/python/simple-integration-tests/eiger/settingsdir/standard/5000eV/noise.sn098 b/python/simple-integration-tests/eiger/settingsdir/standard/5000eV/noise.sn098 old mode 100644 new mode 100755 diff --git a/python/simple-integration-tests/eiger/settingsdir/standard/5000eV/trimbits.sn000 b/python/simple-integration-tests/eiger/settingsdir/standard/5000eV/trimbits.sn000 old mode 100644 new mode 100755 diff --git a/python/simple-integration-tests/eiger/settingsdir/standard/6000eV/noise.sn083 b/python/simple-integration-tests/eiger/settingsdir/standard/6000eV/noise.sn083 old mode 100644 new mode 100755 diff --git a/python/simple-integration-tests/eiger/settingsdir/standard/6000eV/noise.sn098 b/python/simple-integration-tests/eiger/settingsdir/standard/6000eV/noise.sn098 old mode 100644 new mode 100755 diff --git a/python/simple-integration-tests/eiger/settingsdir/standard/6000eV/trimbits.sn000 b/python/simple-integration-tests/eiger/settingsdir/standard/6000eV/trimbits.sn000 old mode 100644 new mode 100755 diff --git a/python/simple-integration-tests/eiger/settingsdir/standard/7000eV/noise.sn083 b/python/simple-integration-tests/eiger/settingsdir/standard/7000eV/noise.sn083 old mode 100644 new mode 100755 diff --git a/python/simple-integration-tests/eiger/settingsdir/standard/7000eV/noise.sn098 b/python/simple-integration-tests/eiger/settingsdir/standard/7000eV/noise.sn098 old mode 100644 new mode 100755 diff --git a/python/simple-integration-tests/eiger/settingsdir/standard/7000eV/trimbits.sn000 b/python/simple-integration-tests/eiger/settingsdir/standard/7000eV/trimbits.sn000 old mode 100644 new mode 100755 diff --git a/python/simple-integration-tests/eiger/test.config b/python/simple-integration-tests/eiger/test.config old mode 100644 new mode 100755 diff --git a/python/simple-integration-tests/eiger/test.par b/python/simple-integration-tests/eiger/test.par old mode 100644 new mode 100755 diff --git a/python/simple-integration-tests/eiger/test_dynamic_range.py b/python/simple-integration-tests/eiger/test_dynamic_range.py old mode 100644 new mode 100755 diff --git a/python/simple-integration-tests/eiger/test_eiger_specific.py b/python/simple-integration-tests/eiger/test_eiger_specific.py old mode 100644 new mode 100755 diff --git a/python/simple-integration-tests/eiger/test_firmware.py b/python/simple-integration-tests/eiger/test_firmware.py old mode 100644 new mode 100755 diff --git a/python/simple-integration-tests/eiger/test_general.py b/python/simple-integration-tests/eiger/test_general.py old mode 100644 new mode 100755 diff --git a/python/simple-integration-tests/eiger/test_load_config.py b/python/simple-integration-tests/eiger/test_load_config.py old mode 100644 new mode 100755 diff --git a/python/simple-integration-tests/eiger/test_network.py b/python/simple-integration-tests/eiger/test_network.py old mode 100644 new mode 100755 diff --git a/python/simple-integration-tests/eiger/test_paths_and_files.py b/python/simple-integration-tests/eiger/test_paths_and_files.py old mode 100644 new mode 100755 diff --git a/python/simple-integration-tests/eiger/test_threshold.py b/python/simple-integration-tests/eiger/test_threshold.py old mode 100644 new mode 100755 diff --git a/python/simple-integration-tests/eiger/test_time.py b/python/simple-integration-tests/eiger/test_time.py old mode 100644 new mode 100755 diff --git a/python/simple-integration-tests/eiger/test_trimbits_and_dacs.py b/python/simple-integration-tests/eiger/test_trimbits_and_dacs.py old mode 100644 new mode 100755 diff --git a/python/simple-integration-tests/eiger/test_version_numbers.py b/python/simple-integration-tests/eiger/test_version_numbers.py old mode 100644 new mode 100755 diff --git a/python/simple-integration-tests/eiger/write_tb_files.py b/python/simple-integration-tests/eiger/write_tb_files.py old mode 100644 new mode 100755 diff --git a/python/simple-integration-tests/jungfrau_0_6/config_test.py b/python/simple-integration-tests/jungfrau_0_6/config_test.py old mode 100644 new mode 100755 diff --git a/python/simple-integration-tests/jungfrau_0_6/fixtures.py b/python/simple-integration-tests/jungfrau_0_6/fixtures.py old mode 100644 new mode 100755 diff --git a/python/simple-integration-tests/jungfrau_0_6/test_main.py b/python/simple-integration-tests/jungfrau_0_6/test_main.py old mode 100644 new mode 100755 diff --git a/python/simple-integration-tests/jungfrau_0_6/tests/test.config b/python/simple-integration-tests/jungfrau_0_6/tests/test.config old mode 100644 new mode 100755 diff --git a/python/simple-integration-tests/jungfrau_0_6/tests/test.par b/python/simple-integration-tests/jungfrau_0_6/tests/test.par old mode 100644 new mode 100755 diff --git a/python/simple-integration-tests/jungfrau_0_6/tests/test_load_config.py b/python/simple-integration-tests/jungfrau_0_6/tests/test_load_config.py old mode 100644 new mode 100755 diff --git a/python/simple-integration-tests/jungfrau_0_6/tests/test_overtemperature.py b/python/simple-integration-tests/jungfrau_0_6/tests/test_overtemperature.py old mode 100644 new mode 100755 diff --git a/python/sls_detector/__init__.py b/python/sls_detector/__init__.py old mode 100644 new mode 100755 diff --git a/python/sls_detector/adcs.py b/python/sls_detector/adcs.py old mode 100644 new mode 100755 diff --git a/python/sls_detector/dacs.py b/python/sls_detector/dacs.py old mode 100644 new mode 100755 diff --git a/python/sls_detector/decorators.py b/python/sls_detector/decorators.py old mode 100644 new mode 100755 diff --git a/python/sls_detector/detector.py b/python/sls_detector/detector.py old mode 100644 new mode 100755 diff --git a/python/sls_detector/detector_property.py b/python/sls_detector/detector_property.py old mode 100644 new mode 100755 diff --git a/python/sls_detector/eiger.py b/python/sls_detector/eiger.py old mode 100644 new mode 100755 diff --git a/python/sls_detector/errors.py b/python/sls_detector/errors.py old mode 100644 new mode 100755 diff --git a/python/sls_detector/experimental.py b/python/sls_detector/experimental.py old mode 100644 new mode 100755 diff --git a/python/sls_detector/jungfrau.py b/python/sls_detector/jungfrau.py old mode 100644 new mode 100755 diff --git a/python/sls_detector/jungfrau_ctb.py b/python/sls_detector/jungfrau_ctb.py old mode 100644 new mode 100755 diff --git a/python/sls_detector/registers.py b/python/sls_detector/registers.py old mode 100644 new mode 100755 diff --git a/python/sls_detector/utils.py b/python/sls_detector/utils.py old mode 100644 new mode 100755 diff --git a/python/sphinx/Makefile b/python/sphinx/Makefile old mode 100644 new mode 100755 diff --git a/python/sphinx/_static/tp_scurve.png b/python/sphinx/_static/tp_scurve.png old mode 100644 new mode 100755 diff --git a/python/sphinx/_static/untrimmed.png b/python/sphinx/_static/untrimmed.png old mode 100644 new mode 100755 diff --git a/python/sphinx/code_quality.rst b/python/sphinx/code_quality.rst old mode 100644 new mode 100755 diff --git a/python/sphinx/command_line.rst b/python/sphinx/command_line.rst old mode 100644 new mode 100755 diff --git a/python/sphinx/conf.py b/python/sphinx/conf.py old mode 100644 new mode 100755 diff --git a/python/sphinx/cpp_api.rst b/python/sphinx/cpp_api.rst old mode 100644 new mode 100755 diff --git a/python/sphinx/error-handling.rst b/python/sphinx/error-handling.rst old mode 100644 new mode 100755 diff --git a/python/sphinx/examples.rst b/python/sphinx/examples.rst old mode 100644 new mode 100755 diff --git a/python/sphinx/getting_started.rst b/python/sphinx/getting_started.rst old mode 100644 new mode 100755 diff --git a/python/sphinx/index.rst b/python/sphinx/index.rst old mode 100644 new mode 100755 diff --git a/python/sphinx/installation.rst b/python/sphinx/installation.rst old mode 100644 new mode 100755 diff --git a/python/sphinx/modules.rst b/python/sphinx/modules.rst old mode 100644 new mode 100755 diff --git a/python/sphinx/sls_detector.rst b/python/sphinx/sls_detector.rst old mode 100644 new mode 100755 diff --git a/python/src/Detector.h b/python/src/Detector.h old mode 100644 new mode 100755 diff --git a/python/src/main.cpp b/python/src/main.cpp old mode 100644 new mode 100755 diff --git a/python/unit-tests/__pycache__/dac_test.cpython-37-PYTEST.pyc b/python/unit-tests/__pycache__/dac_test.cpython-37-PYTEST.pyc old mode 100644 new mode 100755 diff --git a/python/unit-tests/__pycache__/detector_test.cpython-37-PYTEST.pyc b/python/unit-tests/__pycache__/detector_test.cpython-37-PYTEST.pyc old mode 100644 new mode 100755 diff --git a/python/unit-tests/__pycache__/test_detector_property.cpython-37-PYTEST.pyc b/python/unit-tests/__pycache__/test_detector_property.cpython-37-PYTEST.pyc old mode 100644 new mode 100755 diff --git a/python/unit-tests/__pycache__/test_utils.cpython-37-PYTEST.pyc b/python/unit-tests/__pycache__/test_utils.cpython-37-PYTEST.pyc old mode 100644 new mode 100755 diff --git a/python/unit-tests/dac_test.py b/python/unit-tests/dac_test.py old mode 100644 new mode 100755 diff --git a/python/unit-tests/detector_eiger.py b/python/unit-tests/detector_eiger.py old mode 100644 new mode 100755 diff --git a/python/unit-tests/detector_test.py b/python/unit-tests/detector_test.py old mode 100644 new mode 100755 diff --git a/python/unit-tests/test_detector_property.py b/python/unit-tests/test_detector_property.py old mode 100644 new mode 100755 diff --git a/python/unit-tests/test_utils.py b/python/unit-tests/test_utils.py old mode 100644 new mode 100755 diff --git a/settingsdir/eiger/highgain/calibration.snbeb045 b/settingsdir/eiger/highgain/calibration.snbeb045 old mode 100644 new mode 100755 diff --git a/settingsdir/eiger/highgain/highgain.cal b/settingsdir/eiger/highgain/highgain.cal old mode 100644 new mode 100755 diff --git a/settingsdir/eiger/highgain/highgain.trim b/settingsdir/eiger/highgain/highgain.trim old mode 100644 new mode 100755 diff --git a/settingsdir/eiger/highgain/settings.snbeb045 b/settingsdir/eiger/highgain/settings.snbeb045 old mode 100644 new mode 100755 diff --git a/settingsdir/eiger/lowgain/calibration.snbeb045 b/settingsdir/eiger/lowgain/calibration.snbeb045 old mode 100644 new mode 100755 diff --git a/settingsdir/eiger/lowgain/lowgain.cal b/settingsdir/eiger/lowgain/lowgain.cal old mode 100644 new mode 100755 diff --git a/settingsdir/eiger/lowgain/lowgain.trim b/settingsdir/eiger/lowgain/lowgain.trim old mode 100644 new mode 100755 diff --git a/settingsdir/eiger/lowgain/settings.snbeb045 b/settingsdir/eiger/lowgain/settings.snbeb045 old mode 100644 new mode 100755 diff --git a/settingsdir/eiger/standard/4500eV/noise.sn031 b/settingsdir/eiger/standard/4500eV/noise.sn031 old mode 100644 new mode 100755 diff --git a/settingsdir/eiger/standard/4500eV/noise.sn032 b/settingsdir/eiger/standard/4500eV/noise.sn032 old mode 100644 new mode 100755 diff --git a/settingsdir/eiger/standard/5400eV/noise.sn031 b/settingsdir/eiger/standard/5400eV/noise.sn031 old mode 100644 new mode 100755 diff --git a/settingsdir/eiger/standard/5400eV/noise.sn032 b/settingsdir/eiger/standard/5400eV/noise.sn032 old mode 100644 new mode 100755 diff --git a/settingsdir/eiger/standard/6400eV/noise.sn031 b/settingsdir/eiger/standard/6400eV/noise.sn031 old mode 100644 new mode 100755 diff --git a/settingsdir/eiger/standard/6400eV/noise.sn032 b/settingsdir/eiger/standard/6400eV/noise.sn032 old mode 100644 new mode 100755 diff --git a/settingsdir/eiger/standard/calibration.sn031 b/settingsdir/eiger/standard/calibration.sn031 old mode 100644 new mode 100755 diff --git a/settingsdir/eiger/standard/calibration.sn032 b/settingsdir/eiger/standard/calibration.sn032 old mode 100644 new mode 100755 diff --git a/settingsdir/eiger/standard/eigernoise.sn049 b/settingsdir/eiger/standard/eigernoise.sn049 old mode 100644 new mode 100755 diff --git a/settingsdir/eiger/standard/noise.sn031 b/settingsdir/eiger/standard/noise.sn031 old mode 100644 new mode 100755 diff --git a/settingsdir/eiger/standard/noise.sn032 b/settingsdir/eiger/standard/noise.sn032 old mode 100644 new mode 100755 diff --git a/settingsdir/eiger/standard/standard.cal b/settingsdir/eiger/standard/standard.cal old mode 100644 new mode 100755 diff --git a/settingsdir/eiger/standard/standard.trim b/settingsdir/eiger/standard/standard.trim old mode 100644 new mode 100755 diff --git a/settingsdir/eiger/veryhighgain/calibration.sn031 b/settingsdir/eiger/veryhighgain/calibration.sn031 old mode 100644 new mode 100755 diff --git a/settingsdir/eiger/veryhighgain/calibration.sn032 b/settingsdir/eiger/veryhighgain/calibration.sn032 old mode 100644 new mode 100755 diff --git a/settingsdir/eiger/veryhighgain/noise.sn031 b/settingsdir/eiger/veryhighgain/noise.sn031 old mode 100644 new mode 100755 diff --git a/settingsdir/eiger/veryhighgain/noise.sn032 b/settingsdir/eiger/veryhighgain/noise.sn032 old mode 100644 new mode 100755 diff --git a/settingsdir/eiger/veryhighgain/veryhighgain.cal b/settingsdir/eiger/veryhighgain/veryhighgain.cal old mode 100644 new mode 100755 diff --git a/settingsdir/eiger/veryhighgain/veryhighgain.trim b/settingsdir/eiger/veryhighgain/veryhighgain.trim old mode 100644 new mode 100755 diff --git a/settingsdir/eiger/verylowgain/calibration.sn031 b/settingsdir/eiger/verylowgain/calibration.sn031 old mode 100644 new mode 100755 diff --git a/settingsdir/eiger/verylowgain/calibration.sn032 b/settingsdir/eiger/verylowgain/calibration.sn032 old mode 100644 new mode 100755 diff --git a/settingsdir/eiger/verylowgain/noise.sn031 b/settingsdir/eiger/verylowgain/noise.sn031 old mode 100644 new mode 100755 diff --git a/settingsdir/eiger/verylowgain/noise.sn032 b/settingsdir/eiger/verylowgain/noise.sn032 old mode 100644 new mode 100755 diff --git a/settingsdir/eiger/verylowgain/verylowgain.cal b/settingsdir/eiger/verylowgain/verylowgain.cal old mode 100644 new mode 100755 diff --git a/settingsdir/eiger/verylowgain/verylowgain.trim b/settingsdir/eiger/verylowgain/verylowgain.trim old mode 100644 new mode 100755 diff --git a/settingsdir/mythen/fast/noise.snxxx b/settingsdir/mythen/fast/noise.snxxx old mode 100644 new mode 100755 diff --git a/settingsdir/mythen/highgain/noise.snxxx b/settingsdir/mythen/highgain/noise.snxxx old mode 100644 new mode 100755 diff --git a/settingsdir/mythen/standard/noise.snxxx b/settingsdir/mythen/standard/noise.snxxx old mode 100644 new mode 100755 diff --git a/settingsdir/mythen/standard/standard.trim b/settingsdir/mythen/standard/standard.trim old mode 100644 new mode 100755 diff --git a/slsDetectorGui/.gitignore b/slsDetectorGui/.gitignore old mode 100644 new mode 100755 diff --git a/slsDetectorGui/CMakeLists.txt b/slsDetectorGui/CMakeLists.txt old mode 100644 new mode 100755 index 69f59639a..aad448d94 --- a/slsDetectorGui/CMakeLists.txt +++ b/slsDetectorGui/CMakeLists.txt @@ -1,6 +1,15 @@ - set(CMAKE_AUTOMOC ON) +set(ENV{QMAKESPEC} "/afs/psi.ch/intranet/Controls/Software/Trolltech/RHEL7-x86_64/Qt-4.8.2/mkspecs/linux-g++") +set(ENV{PATH} "/afs/psi.ch/intranet/Controls/Software/Trolltech/RHEL7-x86_64/Qt-4.8.2/bin:$PATH") + +link_directories( + /afs/psi.ch/intranet/Controls/Software/Trolltech/RHEL7-x86_64/Qt-4.8.2/lib + /afs/psi.ch/intranet/Controls/Software/Trolltech/RHEL7-x86_64/qwt-6.0.1/lib + /afs/psi.ch/intranet/Controls/Software/Trolltech/RHEL7-x86_64/qwtplot3d/lib + /afs/psi.ch/project/sls_det_software/dhanya_softwareDevelopment/mySoft/slsDetectorPackage/build/bin +) + set(SOURCES slsDetectorPlotting/src/SlsQt1DPlot.cxx slsDetectorPlotting/src/SlsQt1DZoomer.cxx @@ -14,9 +23,6 @@ set(SOURCES src/qTabMeasurement.cpp src/qTabDataOutput.cpp src/qTabPlot.cpp - src/qTabActions.cpp - src/qActionsWidget.cpp - src/qScanWidget.cpp src/qTabAdvanced.cpp src/qTabSettings.cpp src/qTabDebugging.cpp @@ -33,8 +39,6 @@ set(FORMS forms/form_tab_advanced.ui forms/form_tab_settings.ui forms/form_tab_debugging.ui - forms/form_action.ui - forms/form_scan.ui ) qt4_wrap_ui(FORMS_H ${FORMS}) @@ -56,15 +60,12 @@ set(HEADERS include/qTabMeasurement.h include/qTabDataOutput.h include/qTabPlot.h - include/qTabActions.h - include/qActionsWidget.h - include/qScanWidget.h include/qTabAdvanced.h include/qTabSettings.h include/qTabDebugging.h include/qTabDeveloper.h include/qTabMessages.h - include/gitInfoGui.h + ../slsSupportLib/include/versionAPI.h include/qServer.h ) set(RESOURCES @@ -75,13 +76,7 @@ qt4_add_resources(RESOURCES_SRCS ${RESOURCES}) include_directories( include slsDetectorPlotting/include - ../slsSupportLib/include - ../slsDetectorSoftware/slsReceiverInterface - ../slsDetectorSoftware/slsDetector - ../slsDetectorSoftware/slsDetectorAnalysis - ../slsDetectorSoftware/multiSlsDetector - ../slsDetectorSoftware/usersFunctions - ../slsReceiverSoftware/include + ../slsSupportLib/include ${QT_INCLUDE_DIR} ${QT_QTCORE_INCLUDE_DIR} ${QT_QTGUI_INCLUDE_DIR} @@ -90,7 +85,7 @@ include_directories( ) add_definitions( - -DDACS_INT -DVERBOSE -DPRINT_LOG + -DPRINT_LOG #-DVERBOSE ) add_executable(slsDetectorGui @@ -100,13 +95,10 @@ add_executable(slsDetectorGui ${RESOURCES_SRCS} ) -set_target_properties(slsDetectorGui PROPERTIES - LINKER_LANGUAGE CXX - RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin -) - - -target_link_libraries(slsDetectorGui +target_link_libraries(slsDetectorGui PUBLIC + slsProjectOptions + slsProjectWarnings + slsSupportLib slsDetectorShared ${QT_QTCORE_LIBRARIES} ${QT_QTGUI_LIBRARIES} @@ -118,16 +110,28 @@ target_link_libraries(slsDetectorGui z Qt4::QtOpenGL Qt4::QtSvg +) +set_target_properties(slsDetectorGui PROPERTIES + RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin ) add_executable(gui_client client/qClient.h client/qClient.cpp ) + +target_link_libraries(gui_client PUBLIC + slsProjectOptions + slsProjectWarnings + slsSupportLib + slsDetectorShared + pthread + rt +) + set_target_properties(gui_client PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin ) -install(TARGETS slsDetectorGui gui_client - RUNTIME DESTINATION bin) +install(TARGETS slsDetectorGui gui_client DESTINATION bin) diff --git a/slsDetectorGui/client/qClient.cpp b/slsDetectorGui/client/qClient.cpp old mode 100644 new mode 100755 index a20e5288f..fee2b0c21 --- a/slsDetectorGui/client/qClient.cpp +++ b/slsDetectorGui/client/qClient.cpp @@ -1,236 +1,124 @@ -/* - * qClient.cpp - * - * Created on: Feb 27, 2013 - * Author: Dhanya Maliakal - */ -// Qt Project Class Headers #include "qClient.h" -// Project Class Headers -#include "MySocketTCP.h" -// C++ Include Headers +#include "ClientSocket.h" +#include "logger.h" +#include "sls_detector_exceptions.h" + #include #include -using namespace std; - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -int main(int argc, char *argv[]){ - qClient* cl = 0; - try { - cl = new qClient(argv[1]); - } catch(...) { - return 0; - } - cl->executeLine(argc-2, argv+2); - delete cl; - - return 0; +int main(int argc, char *argv[]) { + qClient *cl = 0; + cl = new qClient(argv[1]); + cl->executeLine(argc - 2, argv + 2); + delete cl; + return 0; } - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -qClient::qClient(char* hostname): - mySocket(0), - myStopSocket(0){ - - try { - // control socket - mySocket = new MySocketTCP(hostname, DEFAULT_GUI_PORTNO); - // stop socket - myStopSocket = new MySocketTCP(hostname, DEFAULT_GUI_PORTNO+1); - } catch(...) { - if (mySocket == 0) - cout << "Error: could not connect to control server:" << - hostname << " with port " << DEFAULT_GUI_PORTNO << endl; - else - cout << "Error: could not connect to stop server:" << - hostname << " with port " << DEFAULT_GUI_PORTNO + 1 << endl; - throw; - } +qClient::qClient(char *h) + : controlPort(DEFAULT_GUI_PORTNO), stopPort(DEFAULT_GUI_PORTNO + 1) { + hostname.assign(h); } +qClient::~qClient() {} -//------------------------------------------------------------------------------------------------------------------------------------------------- +void qClient::executeLine(int narg, char *args[]) { -qClient::~qClient() { - if(mySocket) delete mySocket; - if(myStopSocket) delete myStopSocket; + std::string retval = ""; + std::string cmd = args[0]; + + // validate command structure + if (narg < 1) { + throw sls::RuntimeError("No command parsed. " + printCommands()); + } + + // help + if (cmd == "help") { + retval = printCommands(); + } + + // file name + else if (cmd == "status") { + + if (narg > 1) { + std::string argument = args[1]; + // start acquisition + if (argument == "start") + startAcquisition(); + else if (argument == "stop") + stopAcquisition(); + else { + throw sls::RuntimeError("Could not parse arguments. " + + printCommands()); + } + } + retval = getStatus(); + } + + else if (cmd == "acquire") { + startAcquisition(true); + retval = getStatus(); + } + + else if (cmd == "exit") { + exitServer(); + retval.assign("Server exited successfully"); + } + + // unrecognized command + else { + throw sls::RuntimeError("Unrecognized command. " + printCommands()); + } + + // print result + FILE_LOG(logINFO) << cmd << ": " << retval; } - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -int qClient::executeLine(int narg, char *args[]){ - - string retval = ""; - string cmd = args[0]; - string argument; - - - //validate command structure - if(narg<1){ - cout << "Error: no command parsed" << endl; - return FAIL; - } - - - //help - if (cmd == "help"){ - retval = printCommands(); - } - - //file name - else if (cmd == "status"){ - - if(narg>1){ - argument = args[1]; - //start acquisition - if(argument == "start") - startAcquisition(); - else if (argument == "stop") - stopAcquisition(); - else{ - cprintf(RED,"Error: could not parse arguments: %s\n", argument.c_str()); - printCommands(); - return FAIL; - } - } - retval = getStatus(); - } - - - else if (cmd == "acquire"){ - startAcquisition(true); - retval = getStatus(); - } - - - else if (cmd == "exit"){ - return exitServer(); - } - - - //unrecognized command - else{ - cout << "Error: unrecognized command" << endl; - return FAIL; - } - - - //print result - cout << cmd << ": " << retval << endl; - - return OK; +std::string qClient::printCommands() { + std::ostringstream os; + os << "\nexit \t exits servers in gui" << std::endl; + os << "status \t gets status of acquisition in gui. - can be running or " + "idle" + << std::endl; + os << "status i starts/stops acquistion in gui-non blocking. i is start " + "or stop" + << std::endl; + os << "acquire starts acquistion in gui-blocking" << std::endl; + return os.str(); } -//------------------------------------------------------------------------------------------------------------------------------------------------- +std::string qClient::getStatus() { + int fnum = qDefs::F_GUI_GET_RUN_STATUS; + int retvals[2] = {static_cast(ERROR), 0}; + auto client = sls::GuiSocket(hostname, controlPort); + client.sendCommandThenRead(fnum, nullptr, 0, retvals, sizeof(retvals)); -string qClient::printCommands(){ - ostringstream os; - os << "\nexit \t exits servers in gui" << std::endl; - os << "status \t gets status of acquisition in gui. - can be running or idle" << std::endl; - os << "status i starts/stops acquistion in gui-non blocking. i is start or stop" << std::endl; - os << "acquire starts acquistion in gui-blocking" << std::endl; - return os.str(); + runStatus status = static_cast(retvals[0]); + int progress = retvals[1]; + return std::to_string(progress) + std::string("% ") + + slsDetectorDefs::runStatusType(status); } +void qClient::startAcquisition(bool blocking) { + int fnum = qDefs::F_GUI_START_ACQUISITION; + if (blocking) + fnum = qDefs::F_GUI_START_AND_READ_ALL; -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -string qClient::getStatus(){ - int fnum = F_GET_RUN_STATUS; - int ret = FAIL; - runStatus retval=ERROR; - int progress = 0; - char answer[100]; - - if (myStopSocket->Connect() >= 0) { - myStopSocket->SendDataOnly(&fnum,sizeof(fnum)); - myStopSocket->ReceiveDataOnly(&ret,sizeof(ret)); - myStopSocket->ReceiveDataOnly(&retval,sizeof(retval)); - myStopSocket->ReceiveDataOnly(&progress,sizeof(progress)); - myStopSocket->Disconnect(); - }else - exit(-1); - - - sprintf(answer,"%d%% ",progress); - strcat(answer,slsDetectorDefs::runStatusType((runStatus)retval).c_str()); - - return string(answer); + auto client = sls::GuiSocket(hostname.c_str(), controlPort); + client.sendCommandThenRead(fnum, nullptr, 0, nullptr, 0); } +void qClient::stopAcquisition() { + int fnum = qDefs::F_GUI_STOP_ACQUISITION; -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -int qClient::startAcquisition(bool blocking){ - int fnum = F_START_ACQUISITION; - if(blocking) fnum = F_START_AND_READ_ALL; - int ret = FAIL; - - if (mySocket->Connect() >= 0) { - mySocket->SendDataOnly(&fnum,sizeof(fnum)); - mySocket->ReceiveDataOnly(&ret,sizeof(ret)); - if (ret == FAIL){ - mySocket->ReceiveDataOnly(mess,sizeof(mess)); - std::cout<< "Gui returned error: " << mess << std::endl; - } - mySocket->Disconnect(); - }else - exit(-1); - - return ret; + auto client = sls::GuiSocket(hostname, stopPort); + client.sendCommandThenRead(fnum, nullptr, 0, nullptr, 0); } - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -int qClient::stopAcquisition(){ - int fnum = F_STOP_ACQUISITION; - int ret = FAIL; - - if (myStopSocket->Connect() >= 0) { - myStopSocket->SendDataOnly(&fnum,sizeof(fnum)); - myStopSocket->ReceiveDataOnly(&ret,sizeof(ret)); - if (ret == FAIL){ - myStopSocket->ReceiveDataOnly(mess,sizeof(mess)); - std::cout<< "Gui returned error: " << mess << std::endl; - } - myStopSocket->Disconnect(); - }else - exit(-1); - - return ret; -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -int qClient::exitServer(){ - int fnum = F_EXIT_SERVER; - int ret = FAIL; - - if (myStopSocket->Connect() >= 0) { - myStopSocket->SendDataOnly(&fnum,sizeof(fnum)); - myStopSocket->ReceiveDataOnly(&ret,sizeof(ret)); - myStopSocket->ReceiveDataOnly(mess,sizeof(mess)); - cout << mess << endl; - myStopSocket->Disconnect(); - }else - exit(-1); - - return ret; -} +void qClient::exitServer() { + int fnum = qDefs::F_GUI_EXIT_SERVER; + // closes both control and stop server + auto client = sls::GuiSocket(hostname, controlPort); + client.sendCommandThenRead(fnum, nullptr, 0, nullptr, 0); + } diff --git a/slsDetectorGui/client/qClient.h b/slsDetectorGui/client/qClient.h old mode 100644 new mode 100755 index fbec87a95..726be3fbf --- a/slsDetectorGui/client/qClient.h +++ b/slsDetectorGui/client/qClient.h @@ -1,65 +1,70 @@ -/* - * qClient.h - * - * Created on: Feb 27, 2013 - * Author: Dhanya Maliakal - */ -#ifndef QCLIENT_H -#define QCLIENT_H +#pragma once +#include "qDefs.h" -/** Qt Project Class Headers */ -/** Project Class Headers */ -class MySocketTCP; #include "sls_detector_defs.h" -/** C++ Include Headers */ + #include #include -using namespace std; /** *@short Sets up the gui server */ -class qClient: public virtual slsDetectorDefs{ +class qClient : public virtual slsDetectorDefs { + public: + /** + * The constructor + * @param h hostname + */ + qClient(char *h); + /** + * Destructor + */ + virtual ~qClient(); -public: - /** \short The constructor*/ - qClient(char* hostname); - /** Destructor */ - virtual ~qClient(); + /** + * Execute command + * @param narg number of arguments + * @param args argument list + */ + void executeLine(int narg, char *args[]); - /**Execute command*/ - int executeLine(int narg, char *args[]); + private: + /** + * Print list of commands + * @returns string of result + */ + std::string printCommands(); -private: - /** Print list of commands */ - string printCommands(); + /** + * Gets run status + * @returns status + */ + std::string getStatus(); - /** Start Acquisition - * @param blocking true if its a blocking acquistion - */ - int startAcquisition(bool blocking = false); + /** + * Start Acquisition + * @param blocking true if its a blocking acquistion + */ + void startAcquisition(bool blocking = false); - /** Stops Acquisition */ - int stopAcquisition(); + /** + * Stops Acquisition + */ + void stopAcquisition(); - /** Gets run status */ - string getStatus(); + /** + * Exits Server + */ + void exitServer(); - /** Exits Server */ - int exitServer(); + /** hostname */ + std::string hostname; - /** client socket */ - MySocketTCP *mySocket; - - /** client socket */ - MySocketTCP *myStopSocket; - - char mess[MAX_STR_LENGTH]; + /** control port */ + int controlPort; + /** stop port */ + int stopPort; }; - - - -#endif /* QCLIENT_H */ diff --git a/slsDetectorGui/doxy.config b/slsDetectorGui/doxy.config old mode 100644 new mode 100755 index 877d4c456..c5684c098 --- a/slsDetectorGui/doxy.config +++ b/slsDetectorGui/doxy.config @@ -84,13 +84,7 @@ INPUT = \ include/qTabDataOutput.h\ src/qTabDataOutput.cpp\ include/qTabPlot.h\ - src/qTabPlot.cpp\ - include/qTabActions.h\ - src/qTabActions.cpp\ - include/qActionsWidget.h\ - src/qActionsWidget.cpp\ - include/qScanWidget.h\ - src/qScanWidget.cpp\ + src/qTabPlot.cpp\ include/qTabAdvanced.h\ src/qTabAdvanced.cpp\ include/qTabSettings.h\ diff --git a/slsDetectorGui/forms/form_action.ui b/slsDetectorGui/forms/form_action.ui deleted file mode 100644 index 33d93c35e..000000000 --- a/slsDetectorGui/forms/form_action.ui +++ /dev/null @@ -1,169 +0,0 @@ - - - ActionsObject - - - - 0 - 0 - 680 - 25 - - - - - 0 - 0 - - - - - 0 - 0 - - - - - 1000 - 1000 - - - - Form - - - - 0 - - - 0 - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 20 - 20 - - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 40 - 20 - - - - - - - - - None - - - - - Custom Script - - - - - - - - false - - - - - - - false - - - Additional Parameter: - - - - - - - false - - - Browse - - - - :/icons/images/browse.png:/icons/images/browse.png - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 5 - 20 - - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 5 - 20 - - - - - - - - false - - - - 0 - 0 - - - - - - - - - - - diff --git a/slsDetectorGui/forms/form_detectormain.ui b/slsDetectorGui/forms/form_detectormain.ui old mode 100644 new mode 100755 index 1cdc2001b..aaac9ffff --- a/slsDetectorGui/forms/form_detectormain.ui +++ b/slsDetectorGui/forms/form_detectormain.ui @@ -10,7 +10,7 @@ 0 0 800 - 848 + 851 @@ -236,8 +236,6 @@ - - @@ -271,7 +269,7 @@ 36 - 422 + 425 diff --git a/slsDetectorGui/forms/form_scan.ui b/slsDetectorGui/forms/form_scan.ui deleted file mode 100644 index bd00b8c6e..000000000 --- a/slsDetectorGui/forms/form_scan.ui +++ /dev/null @@ -1,488 +0,0 @@ - - - ScanObject - - - - 0 - 0 - 724 - 125 - - - - - 0 - 0 - - - - - 0 - 0 - - - - - 1000 - 1000 - - - - Form - - - - 0 - - - 5 - - - 0 - - - - - false - - - - 0 - 0 - - - - - 180 - 0 - - - - - - - - 0 - - - 5 - - - 0 - - - 2 - - - 0 - - - 5 - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 10 - 20 - - - - - - - - <nobr> -Defines scan range for a <b>Constant Step Size</b> with the following constraints: -</nobr><br><nobr> -1. <b>Number of Steps</b> >=2. -</nobr><br><nobr> -2. <b>Size</b> not equal to 0. -</nobr><br><nobr> -3. <b>From</b> not equal to <b>To</b>. -</nobr><br> - - - Constant Step Size - - - true - - - - - - - <nobr>Measures only at specific values listed by the user.</nobr><br> -<nobr>Number of entries is restricted to <b>Number of Steps</b> field.</nobr> - - - Specific Values - - - false - - - - - - - - 0 - 0 - - - - <nobr>Measures only at the specific values listed in a file.</nobr><br> -<nobr>Select the file, where these values are listed.</nobr> - - - Values from File - - - false - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 10 - 20 - - - - - - - - - - - - - - - - - - - - 0 - - - - - false - - - - 0 - 0 - - - - Precision: - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 5 - 20 - - - - - - - - false - - - - 0 - 0 - - - - 0 - - - 10 - - - 0 - - - - - - - - - 0 - - - - - false - - - - 0 - 0 - - - - Additional Parameter: - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 5 - 20 - - - - - - - - false - - - - 0 - 0 - - - - - - - - - - 0 - - - - - false - - - - 0 - 0 - - - - Number of Steps: - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 5 - 20 - - - - - - - - false - - - - 0 - 0 - - - - false - - - 0 - - - 1000000 - - - 0 - - - - - - - - - - None - - - - - Energy Scan (eV) - - - - - Threshold Scan - - - - - Trimbits Scan - - - - - Position Scan - - - - - Custom Script - - - - - - - - 0 - - - - - false - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 5 - 20 - - - - - - - - false - - - Browse - - - - :/icons/images/browse.png:/icons/images/browse.png - - - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 30 - 20 - - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 40 - 20 - - - - - - - - comboScript - dispScript - btnBrowse - dispParameter - spinSteps - spinPrecision - radioRange - radioCustom - radioFile - - - - - - diff --git a/slsDetectorGui/forms/form_tab_advanced.ui b/slsDetectorGui/forms/form_tab_advanced.ui old mode 100644 new mode 100755 index 0e980a746..4044e0e41 --- a/slsDetectorGui/forms/form_tab_advanced.ui +++ b/slsDetectorGui/forms/form_tab_advanced.ui @@ -51,7 +51,7 @@ QTabWidget::North - 3 + 4 Qt::ElideLeft @@ -60,693 +60,18 @@ Logs - - - - 5 - 10 - 746 - 66 - - - - Calibration Logs - - - - - 25 - 20 - 345 - 31 - - - - - 42 - - - - - - 0 - 0 - - - - Energy Calibration - - - - - - - - 0 - 0 - - - - Angular Calibration - - - - - - Trimming - - - - 5 - 10 - 495 - 66 - - - - Trimbits Plot - - - true - - - false - - - - - 230 - 15 - 259 - 44 - - - - - 17 - - - - - <nobr> -Updates plot with Trimbits from Shared Memory, not from Detector. -</nobr> - - - false - - - Refresh - - - - :/icons/images/refresh.png:/icons/images/refresh.png - - - - 24 - 16 - - - - - - - - <nobr> -Plots Trimbits from Detector. This will take time. -</nobr> - - - Get Trimbits - - - - :/icons/images/download.png:/icons/images/download.png - - - - - - - - - 25 - 20 - 211 - 31 - - - - - - - Data Graph - - - true - - - - - - - Histogram - - - - - - - - - true - - - - 5 - 85 - 746 - 226 - - - - Trimming - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - false - - - true - - - true - - - - - 25 - 25 - 696 - 208 - - - - - 12 - - - - - - 0 - 0 - - - - Trimming Method: - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 20 - 20 - - - - - - - - - 0 - 0 - - - - Exposure Time: - - - - - - - true - - - - 0 - 0 - - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - Exposure time of each frame. - #exptime# - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - false - - - 9 - - - -1.000000000000000 - - - 2000000000.000000000000000 - - - 1.000000000000000 - - - - - - - true - - - - 0 - 0 - - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - Qt::LeftToRight - - - 2 - - - - hr - - - - - min - - - - - s - - - - - ms - - - - - us - - - - - ns - - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 20 - 20 - - - - - - - - Qt::Horizontal - - - QSizePolicy::Expanding - - - - 50 - 20 - - - - - - - - - 0 - 0 - - - - <nobr> -Trimfile to which the resulting trimbits will be written. -</nobr><br><nobr> -An extension given by the modules serial number will be attached. -</nobr> - - - Output Trim File: - - - - - - - <nobr> -Trimfile to which the resulting trimbits will be written. -</nobr><br><nobr> -An extension given by the modules serial number will be attached. -</nobr> - - - - - - - - 0 - 0 - - - - <nobr> -Trimfile to which the resulting trimbits will be written. -</nobr><br><nobr> -An extension given by the modules serial number will be attached. -</nobr> - - - Browse - - - - :/icons/images/browse.png:/icons/images/browse.png - - - - - - - 0 - - - - - - - - 0 - 0 - - - - Start Trimming - - - - :/icons/images/start.png:/icons/images/start.png - - - - - - - true - - - - 0 - 0 - - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - Exposure time of each frame. - #exptime# - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - false - - - 3 - - - -1.000000000000000 - - - 10000.000000000000000 - - - 560.000000000000000 - - - - - - - - 0 - 0 - - - - Sets the Threshold DAC - - - Threshold (DACu): - - - - - - - true - - - - 0 - 0 - - - - - 0 - 0 - - - - Optimize Settings - - - - - - - - 0 - 0 - - - - Resolution (a.u.): - - - - - - - - 0 - 0 - - - - Number of measurements (not in real time) that will be acquired. - #frames# - - - - - - - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - false - - - - - - 1 - - - 9 - - - 4 - - - - - - - - 0 - 0 - - - - - 0 - 0 - - - - - Adjust to Fix Count Level - - - - - Equalize to Median - - - - - - - - - 0 - 0 - - - - Counts/ Channel: - - - - - - - - 0 - 0 - - - - Number of measurements (not in real time) that will be acquired. - #frames# - - - - - - - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - false - - - - - - 0 - - - 16000000 - - - 500 - - - - - - false - 518 + 10 10 233 66 @@ -761,7 +86,7 @@ An extension given by the modules serial number will be attached. false - + 12 @@ -977,7 +302,7 @@ An extension given by the modules serial number will be attached. 25 21 686 - 119 + 148 @@ -1357,7 +682,7 @@ An extension given by the modules serial number will be attached. 35 10 686 - 123 + 146 @@ -1943,7 +1268,7 @@ Exposure Time of a sub frame. Only for Eiger in 32 bit mode - + false @@ -1962,7 +1287,7 @@ Default value is 0. A value less than the required minimum is ignored. - + false @@ -2002,7 +1327,7 @@ Default value is 0. A value less than the required minimum is ignored. - + false @@ -2066,24 +1391,6 @@ Default value is 0. A value less than the required minimum is ignored. tabAdvancedSettings - chkEnergyLog - chkAngularLog - boxPlot - radioDataGraph - radioHistogram - btnRefresh - btnGetTrimbits - boxTrimming - comboMethod - chkOptimize - spinResolution - spinCounts - spinExpTime - comboExpUnit - spinThreshold - dispFile - btnFile - btnStart btnGetRoi btnSetRoi btnClearRoi diff --git a/slsDetectorGui/forms/form_tab_dataoutput.ui b/slsDetectorGui/forms/form_tab_dataoutput.ui old mode 100644 new mode 100755 index 0ebfddfe9..17d6f9659 --- a/slsDetectorGui/forms/form_tab_dataoutput.ui +++ b/slsDetectorGui/forms/form_tab_dataoutput.ui @@ -43,78 +43,12 @@ Options - - - - 17 - 21 - 192 - 137 - - - - - 6 - - - - - false - - - <nobr> -Compression using Root. Available only for Gotthard in Expert Mode. -</nobr><br><nobr> - #r_compression# -</nobr> - - - Unused - - - - - - - false - - - Angular Conversion - - - - - - - Discard Bad Channels - - - - - - - false - - - <nobr> -Compression using Root. Available only for Gotthard in Expert Mode. -</nobr><br><nobr> - #r_compression# -</nobr> - - - 10GbE - - - - - - 255 + 14 21 - 476 + 475 76 @@ -122,7 +56,7 @@ Compression using Root. Available only for Gotthard in Expert Mode. 6 - + Qt::Horizontal @@ -148,72 +82,7 @@ Compression using Root. Available only for Gotthard in Expert Mode. - - - - false - - - - 0 - 0 - - - - Flat field corrections. - #flatfield# filename - - - Browse - - - - :/icons/images/browse.png:/icons/images/browse.png - - - - - - - false - - - Qt::ClickFocus - - - Flat field corrections. - #flatfield# filename - - - - - - - Flat field corrections. - #flatfield# filename - - - Flat Field File: - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 10 - 20 - - - - - + false @@ -274,7 +143,7 @@ Directory where one saves the data. - + @@ -293,7 +162,7 @@ Directory where one saves the data. - + false @@ -327,28 +196,29 @@ Directory where one saves the data. + + + + false + + + <nobr> +Compression using Root. Available only for Gotthard in Expert Mode. +</nobr><br><nobr> + #r_compression# +</nobr> + + + 10GbE + + + - - - - 230 - 21 - 20 - 134 - - - - QFrame::Raised - - - Qt::Vertical - - - 244 + 3 92 491 72 @@ -360,7 +230,7 @@ Directory where one saves the data. 11 4 475 - 62 + 68 @@ -513,7 +383,7 @@ Directory where one saves the data. 12 20 714 - 68 + 70 @@ -885,9 +755,6 @@ Directory where one saves the data. - chkFlatField - dispFlatField - btnFlatField chkRate diff --git a/slsDetectorGui/forms/form_tab_debugging.ui b/slsDetectorGui/forms/form_tab_debugging.ui old mode 100644 new mode 100755 index e8ebcd632..333a1f501 --- a/slsDetectorGui/forms/form_tab_debugging.ui +++ b/slsDetectorGui/forms/form_tab_debugging.ui @@ -51,8 +51,8 @@ 15 110 - 141 - 51 + 149 + 58 @@ -62,17 +62,17 @@ Qt::NoFocus - Readout Firmware + Module Firmware - + Qt::NoFocus - Readout Software + Module Bus @@ -83,7 +83,7 @@ 15 185 - 656 + 147 36 @@ -107,144 +107,13 @@ - - - - 415 - 30 - 256 - 31 - - - - - - - - 0 - 0 - - - - - 0 - 0 - - - - - 100 - 16777215 - - - - Module: - - - - - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - true - - - - All Modules - - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 10 - 20 - - - - - - - - - - 280 - 110 - 141 - 51 - - - - - - - Qt::NoFocus - - - Readout Bus - - - - - - - Qt::NoFocus - - - Readout Memory - - - - - - - - - 530 - 110 - 141 - 26 - - - - - - - Qt::NoFocus - - - Chip - - - - - 15 30 276 - 31 + 32 @@ -367,28 +236,6 @@ - - - - 530 - 135 - 141 - 26 - - - - - - - Qt::NoFocus - - - Module Firmware - - - - - @@ -402,19 +249,6 @@ Qt::Horizontal - - - - 5 - 165 - 676 - 16 - - - - Qt::Horizontal - - @@ -422,7 +256,7 @@ 45 25 686 - 31 + 34 @@ -461,7 +295,6 @@ btnGetInfo comboDetector - comboModule btnTest diff --git a/slsDetectorGui/forms/form_tab_measurement.ui b/slsDetectorGui/forms/form_tab_measurement.ui old mode 100644 new mode 100755 index f8a6853cf..034dcb733 --- a/slsDetectorGui/forms/form_tab_measurement.ui +++ b/slsDetectorGui/forms/form_tab_measurement.ui @@ -139,7 +139,7 @@ 390 8 362 - 342 + 281 @@ -154,10 +154,121 @@ 0 10 357 - 321 + 264 + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 10 + 20 + + + + + + + + false + + + + 0 + 0 + + + + <nobr> +Frame period between exposures. +</nobr><br><nobr> + #period# +</nobr> + + + Qt::LeftToRight + + + 2 + + + + hr + + + + + min + + + + + s + + + + + ms + + + + + us + + + + + ns + + + + + + + + + 0 + 0 + + + + Timing Mode of the detector. + #timing# + + + + None + + + + + Auto + + + + + Trigger Exposure Series + + + + + Gated with fixed number + + + + + Burst Trigger + + + + @@ -315,201 +426,6 @@ - - - - false - - - - 0 - 0 - - - - Number of Gate Signals per Frame. - #gates# - - - Number of Gates: - - - - - - - false - - - - 0 - 0 - - - - Number of Gate Signals per Frame. - #gates# - - - - - - - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - false - - - - - - -1 - - - 2000000000 - - - 1 - - - - - - - false - - - - 0 - 0 - - - - <nobr> -The data are accumulated over several (frames) pump cycles. -</nobr> -<br> -<nobr> -Enabled only in <b>Expert Mode</b> and if<b> Number of Frames</b> > 1. -</nobr> -<br> -<nobr>Setting <b>Number of Probes</b> will reset <b>Number of Triggers</b> to 1. -</nobr> -<br> -Maximum value is 3. <br> -#probes# - - - - Number of Probes: - - - - - - - false - - - - 0 - 0 - - - - <nobr> -The data are accumulated over several (frames) pump cycles. -</nobr> -<br> -<nobr> -Enabled only in <b>Expert Mode</b> and if<b> Number of Frames</b> > 1. -</nobr> -<br> -<nobr>Setting <b>Number of Probes</b> will reset <b>Number of Triggers</b> to 1. -</nobr> -<br> -Maximum value is 3. <br> -#probes# - - - - - - - - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - false - - - - - - -1 - - - 3 - - - 1 - - - - - - - - 0 - 0 - - - - Timing Mode of the detector. - #timing# - - - - None - - - - - Auto - - - - - Trigger Exposure Series - - - - - Trigger Readout - - - - - Gated with Fixed Number - - - - - Gated with Start Trigger - - - - - Burst Trigger - - - - @@ -727,78 +643,6 @@ Frame period between exposures. - - - - false - - - - 0 - 0 - - - - <nobr> -Frame period between exposures. -</nobr><br><nobr> - #period# -</nobr> - - - Qt::LeftToRight - - - 2 - - - - hr - - - - - min - - - - - s - - - - - ms - - - - - us - - - - - ns - - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 10 - 20 - - - - @@ -806,8 +650,65 @@ Frame period between exposures. + + + + false + + + Number of Triggers to be expected. + #cycles# + + + Number of Samples: + + + + + + + false + + + + 0 + 0 + + + + Number of Triggers to be expected. + #cycles# + + + + + + + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + false + + + + + + -1 + + + 2000000000 + + + 1 + + + + gridLayoutWidget + spinNumSamples @@ -967,7 +868,7 @@ Frame period between exposures. 30 298 318 - 31 + 34 @@ -1074,8 +975,6 @@ Frame period between exposures. spinNumTriggers spinDelay comboDelayUnit - spinNumGates - spinNumProbes diff --git a/slsDetectorGui/forms/form_tab_messages.ui b/slsDetectorGui/forms/form_tab_messages.ui old mode 100644 new mode 100755 diff --git a/slsDetectorGui/forms/form_tab_plot.ui b/slsDetectorGui/forms/form_tab_plot.ui old mode 100644 new mode 100755 diff --git a/slsDetectorGui/forms/form_tab_settings.ui b/slsDetectorGui/forms/form_tab_settings.ui old mode 100644 new mode 100755 index 7c9f8f3ed..c56af8243 --- a/slsDetectorGui/forms/form_tab_settings.ui +++ b/slsDetectorGui/forms/form_tab_settings.ui @@ -37,14 +37,14 @@ 30 20 316 - 171 + 135 - - + + - Settings: + Dynamic Range: @@ -142,43 +142,30 @@ - - - - false - - - eV - - - -100000 - - - 100000 - - - 100 - - - -1 - - - - - + + - Number of Modules: + Threshold: - - - - Dynamic Range: + + + + Qt::Horizontal - + + QSizePolicy::Fixed + + + + 20 + 20 + + + - + @@ -202,33 +189,32 @@ - - - - 1 + + + + Settings: - - - - Qt::Horizontal + + + + false - - QSizePolicy::Fixed + + eV - - - 20 - 20 - + + -100000 - - - - - - Threshold: + + 100000 + + + 100 + + + -1 @@ -238,7 +224,6 @@ comboSettings spinThreshold - spinNumModules comboDynamicRange diff --git a/slsDetectorGui/gitInfo.txt b/slsDetectorGui/gitInfo.txt deleted file mode 100644 index 617544e9a..000000000 --- a/slsDetectorGui/gitInfo.txt +++ /dev/null @@ -1,9 +0,0 @@ -Path: slsDetectorsPackage/slsDetectorGui -URL: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git -Repository Root: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git -Repsitory UUID: d2bce7e372c241cd235977b92be18555bca6a77d -Revision: 521 -Branch: 4.0.0 -Last Changed Author: Dhanya_Thattil -Last Changed Rev: 4020 -Last Changed Date: 2018-09-27 16:09:16.000000002 +0200 ./src/qTabSettings.cpp diff --git a/slsDetectorGui/images/add.png b/slsDetectorGui/images/add.png old mode 100644 new mode 100755 diff --git a/slsDetectorGui/images/browse.png b/slsDetectorGui/images/browse.png old mode 100644 new mode 100755 diff --git a/slsDetectorGui/images/calculate.png b/slsDetectorGui/images/calculate.png old mode 100644 new mode 100755 diff --git a/slsDetectorGui/images/close.png b/slsDetectorGui/images/close.png old mode 100644 new mode 100755 diff --git a/slsDetectorGui/images/download.png b/slsDetectorGui/images/download.png old mode 100644 new mode 100755 diff --git a/slsDetectorGui/images/erase.png b/slsDetectorGui/images/erase.png old mode 100644 new mode 100755 diff --git a/slsDetectorGui/images/leftArrow.png b/slsDetectorGui/images/leftArrow.png old mode 100644 new mode 100755 diff --git a/slsDetectorGui/images/mountain.png b/slsDetectorGui/images/mountain.png old mode 100644 new mode 100755 diff --git a/slsDetectorGui/images/new.png b/slsDetectorGui/images/new.png old mode 100644 new mode 100755 diff --git a/slsDetectorGui/images/refresh.png b/slsDetectorGui/images/refresh.png old mode 100644 new mode 100755 diff --git a/slsDetectorGui/images/refresher.png b/slsDetectorGui/images/refresher.png old mode 100644 new mode 100755 diff --git a/slsDetectorGui/images/remove.png b/slsDetectorGui/images/remove.png old mode 100644 new mode 100755 diff --git a/slsDetectorGui/images/rightArrow.png b/slsDetectorGui/images/rightArrow.png old mode 100644 new mode 100755 diff --git a/slsDetectorGui/images/save.png b/slsDetectorGui/images/save.png old mode 100644 new mode 100755 diff --git a/slsDetectorGui/images/saveAll.png b/slsDetectorGui/images/saveAll.png old mode 100644 new mode 100755 diff --git a/slsDetectorGui/images/setup.png b/slsDetectorGui/images/setup.png old mode 100644 new mode 100755 diff --git a/slsDetectorGui/images/start.png b/slsDetectorGui/images/start.png old mode 100644 new mode 100755 diff --git a/slsDetectorGui/images/stop.png b/slsDetectorGui/images/stop.png old mode 100644 new mode 100755 diff --git a/slsDetectorGui/images/upload.png b/slsDetectorGui/images/upload.png old mode 100644 new mode 100755 diff --git a/slsDetectorGui/include/gitInfoGui.h b/slsDetectorGui/include/gitInfoGui.h deleted file mode 100644 index 96c53f374..000000000 --- a/slsDetectorGui/include/gitInfoGui.h +++ /dev/null @@ -1,6 +0,0 @@ -#define GITURL "git@github.com:slsdetectorgroup/slsDetectorPackage.git" -#define GITREPUUID "d2bce7e372c241cd235977b92be18555bca6a77d" -#define GITAUTH "Dhanya_Thattil" -#define GITREV 0x4020 -#define GITDATE 0x20180927 -#define GITBRANCH "4.0.0" diff --git a/slsDetectorGui/include/gitInfoGuiTmp.h b/slsDetectorGui/include/gitInfoGuiTmp.h deleted file mode 100644 index dfd9bb246..000000000 --- a/slsDetectorGui/include/gitInfoGuiTmp.h +++ /dev/null @@ -1,6 +0,0 @@ -#define GITURL "" -#define GITREPUUID "" -#define GITAUTH "" -#define GITREV "" -#define GITDATE "" -#define GITBRANCH "" diff --git a/slsDetectorGui/include/icons.qrc b/slsDetectorGui/include/icons.qrc old mode 100644 new mode 100755 diff --git a/slsDetectorGui/include/qActionsWidget.h b/slsDetectorGui/include/qActionsWidget.h deleted file mode 100644 index 2e024c8a1..000000000 --- a/slsDetectorGui/include/qActionsWidget.h +++ /dev/null @@ -1,85 +0,0 @@ -/* - * qActionsWidget.h - * - * Created on: May 10, 2012 - * Author: l_maliakal_d - */ - -#ifndef QACTIONSWIDGET_H_ -#define QACTIONSWIDGET_H_ - -#include "qDefs.h" - -/** Form Header */ -#include "ui_form_action.h" -/** Project Class Headers */ -class multiSlsDetector; -/** Qt Include Headers */ - -/** C++ Include Headers */ -#include -using namespace std; - - - -class qActionsWidget : public QWidget,private Ui::ActionsObject{ - Q_OBJECT - -public: - /** \short The constructor - * @param parent is the parent tab widget - * @param detector is the detector returned from the detector tab - */ - qActionsWidget(QWidget *parent, multiSlsDetector*& detector); - - ~qActionsWidget(); - - /**to update the widgets*/ - void Refresh(); - - - /**number of action widgets*/ - static int NUM_ACTION_WIDGETS; - - - -private: - /** The sls detector object */ - multiSlsDetector *myDet; - /**id of the action widget*/ - int id; - - /** Sets up the widget - */ - void SetupWidgetWindow(); - - /** Sets up all the slots and signals - * */ - void Initialization(); - - -private slots: -/** Sets the scan or script. Accordingly enables, disables other widgets - * @param mode value chosen - * */ -void SetMode(int mode); - -/** Browse for the script - * */ -void BrowsePath(); - -/** Sets the script file - * */ -void SetScriptFile(); - -/** Set Parameter - * */ -void SetParameter(); - -}; - - - - -#endif /* QACTIONSWIDGET_H_ */ - diff --git a/slsDetectorGui/include/qCloneWidget.h b/slsDetectorGui/include/qCloneWidget.h old mode 100644 new mode 100755 index 07d4cff4c..b7c93b2ad --- a/slsDetectorGui/include/qCloneWidget.h +++ b/slsDetectorGui/include/qCloneWidget.h @@ -1,71 +1,59 @@ -/* - * qCloneWidget.h - * - * Created on: May 18, 2012 - * Author: l_maliakal_d - */ +#pragma once -#ifndef QCLONEWIDGET_H_ -#define QCLONEWIDGET_H_ - -#include "qDefs.h" - - -/** Qt Project Class Headers */ class SlsQtH1D; #include "SlsQt1DPlot.h" #include "SlsQt2DPlotLayout.h" -/** Qt Include Headers */ -#include -#include -#include + #include -#include +#include #include +#include +#include #include -#include #include #include #include -#include +#include +#include +#include #include -#include -#include #include +#include #include -/** C++ Include Headers */ -#include + #include -using namespace std; +#include /** *@short Sets up the clone plot widget */ -class qCloneWidget:public QMainWindow{ - Q_OBJECT +class qCloneWidget : public QMainWindow { + Q_OBJECT -public: - /** \short The constructor + public: + /** + * The constructor */ - qCloneWidget(QWidget *parent,int id,QString title,QString xTitle, QString yTitle, QString zTitle, int numDim,string FilePath, - bool displayStats, QString min, QString max, QString sum); + qCloneWidget(QWidget *parent, int id, QString title, QString xTitle, QString yTitle, QString zTitle, int numDim, std::string FilePath, + bool displayStats, QString min, QString max, QString sum); - /** Destructor + /** + * Destructor */ - ~qCloneWidget(); + ~qCloneWidget(); - /** Sets up the widget window + /** + * Sets up the widget window * @param title title of the image with frame number * @param xTitle title of x axis * @param yTitle title of y axis * @param zTitle title of z axis * @param numDim 1D or 2D * */ - void SetupWidgetWindow(QString title, QString xTitle, QString yTitle, QString zTitle, int numDim); + void SetupWidgetWindow(QString title, QString xTitle, QString yTitle, QString zTitle, int numDim); - - - /** Get the 1D hist values to plot + /** + * Get the 1D hist values to plot * @param nHists Number of graphs in 1D * @param histNBins Total Number of X axis values/channels in 1D * @param histXAxis X Axis value in 1D @@ -73,10 +61,11 @@ public: * @param histTitle Title for all the graphs in 1D * @param lines style of plot if lines or dots * @param markers style of plot markers or not - * */ - void SetCloneHists(int nHists,int histNBins,double* histXAxis,double* histYAxis[],string histTitle[],bool lines,bool markers); + */ + void SetCloneHists(int nHists, int histNBins, double *histXAxis, double *histYAxis[], std::string histTitle[], bool lines, bool markers); - /** Get the 1D hist values to plot for angle plotting + /** + * Get the 1D hist values to plot for angle plotting * @param nHists Number of graphs in 1D * @param histNBins Total Number of X axis values/channels in 1D * @param histXAxis X Axis value in 1D @@ -84,10 +73,11 @@ public: * @param histTitle Title for all the graphs in 1D * @param lines style of plot if lines or dots * @param markers style of plot markers or not - * */ - void SetCloneHists(int nHists,int histNBins,double* histXAxis,double* histYAxis,string histTitle[],bool lines,bool markers); + */ + void SetCloneHists(int nHists, int histNBins, double *histXAxis, double *histYAxis, std::string histTitle[], bool lines, bool markers); - /** Get the 1D hist values to plot for angle plotting + /** + * Get the 1D hist values to plot for angle plotting * @param nbinsx number of bins in x axis * @param xmin minimum in x axis * @param xmax maximum in x axis @@ -95,70 +85,63 @@ public: * @param ymin minimum in y axis * @param ymax maximum in y axis * @param d data - * */ - void SetCloneHists2D(int nbinsx,double xmin,double xmax,int nbinsy, double ymin, double ymax, double *d); + */ + void SetCloneHists2D(int nbinsx, double xmin, double xmax, int nbinsy, double ymin, double ymax, double *d); - /**Set the range of the 1d plot + /** + * Set the range of the 1d plot * @param IsXYRange array of x,y,min,max if these values are set * @param XYRangeValues array of set values of x,y, min, max */ - void SetRange(bool IsXYRange[], double XYRangeValues[]); + void SetRange(bool IsXYRange[], double XYRangeValues[]); - /** Returns the 1d plot + /** + * Returns the 1d plot */ - SlsQt1DPlot* Get1dPlot(){return cloneplot1D;}; + SlsQt1DPlot *Get1dPlot(); -public slots: -/** Save Plots automatically by save all clones - * returns -1 if fail*/ -int SavePlotAutomatic(); - - -private: - /** clone window id*/ - int id; - /** Default Save file path */ - string filePath; - /** clone 1D Plot */ - SlsQt1DPlot* cloneplot1D; - /** clone 2D Plot */ - SlsQt2DPlotLayout* cloneplot2D; - /** vector of 1D hist values */ - QVector cloneplot1D_hists; - - /** markers for the plot*/ - QwtSymbol *marker; - QwtSymbol *nomarker; - - QMenuBar *menubar; - QAction *actionSave; - - QGridLayout *mainLayout; - QGroupBox *cloneBox; - QGridLayout *gridClone; - - QLabel *lblHistTitle; + public slots: + /** + * Save Plots automatically by save all clones + * returns -1 if fail + */ + int SavePlotAutomatic(); + private: /** Gets the current time stamp for the window title*/ - char* GetCurrentTimeStamp(); + char *GetCurrentTimeStamp(); /** Display Statistics */ void DisplayStats(bool enable, QString min, QString max, QString sum); + /** clone window id*/ + int id; + /** Default Save file path */ + std::string filePath; + /** clone 1D Plot */ + SlsQt1DPlot *cloneplot1D; + /** clone 2D Plot */ + SlsQt2DPlotLayout *cloneplot2D; + /** vector of 1D hist values */ + QVector cloneplot1D_hists; -private slots: -/** Save Plot */ -void SavePlot(); + /** markers for the plot*/ + QwtSymbol *marker; + QwtSymbol *nomarker; -protected: - void closeEvent(QCloseEvent* event); + QGridLayout *mainLayout; + QGroupBox *cloneBox; -signals: -void CloneClosedSignal(int); + QLabel *lblHistTitle; + private slots: + /** Save Plot */ + void SavePlot(); + + protected: + void closeEvent(QCloseEvent *event); + + signals: + void CloneClosedSignal(int); }; - - - -#endif /* QCLONEWIDGET_H_ */ diff --git a/slsDetectorGui/include/qDebugStream.h b/slsDetectorGui/include/qDebugStream.h old mode 100644 new mode 100755 index 4335dbd0a..4855dd53b --- a/slsDetectorGui/include/qDebugStream.h +++ b/slsDetectorGui/include/qDebugStream.h @@ -1,101 +1,80 @@ -/* - * qDebugStream.h - * - * Created on: Jun 28, 2012 - * Author: Anna Bergamaschi - */ - -#ifndef QDEBUGSTREAM_H_ -#define QDEBUGSTREAM_H_ - - -#include "qDefs.h" - +#pragma once #include -#include -#include #include - +#include +#include #include #include #include -using namespace std; #define STREAMEVENT 60001 -//------------------------------------------------------------------------------------------------------------------------------------------------- - -class qStreamEvent:public QEvent{ +class qStreamEvent : public QEvent { public: - qStreamEvent(QString s):QEvent(static_cast(STREAMEVENT)),str(s){ + qStreamEvent(QString s) : QEvent(static_cast(STREAMEVENT)), str(s) { #ifdef PRINT_LOG - printf("%s\n",str.toAscii().constData()); + printf("%s\n", str.toAscii().constData()); #endif } /** \returns the progress index */ - QString getString() {return str;} + QString getString() { return str; } + private: QString str; - }; -//------------------------------------------------------------------------------------------------------------------------------------------------- -class qDebugStream : public basic_streambuf { +class qDebugStream : public std::basic_streambuf { public: - qDebugStream(ostream &stream, QWidget* w) : m_stream(stream), log_window(w) { + qDebugStream(std::ostream &stream, QWidget *w) : m_stream(stream), log_window(w) { pthread_mutex_init(&mutex, NULL); m_old_buf = stream.rdbuf(); stream.rdbuf(this); } -//------------------------------------------------------------------------------------------------------------------------------------------------- - ~qDebugStream(){ + ~qDebugStream() { // output anything that is left if (!m_string.empty()) { pthread_mutex_lock(&mutex); - const char* c_string = m_string.c_str(); + const char *c_string = m_string.c_str(); QApplication::postEvent(log_window, new qStreamEvent(c_string)); pthread_mutex_unlock(&mutex); } m_stream.rdbuf(m_old_buf); } -//------------------------------------------------------------------------------------------------------------------------------------------------- protected: - virtual int_type overflow(int_type v){ - if (v == '\n'){ + virtual int_type overflow(int_type v) { + if (v == '\n') { pthread_mutex_lock(&mutex); - const char* c_string = m_string.c_str(); + const char *c_string = m_string.c_str(); QApplication::postEvent(log_window, new qStreamEvent(c_string)); m_string.erase(m_string.begin(), m_string.end()); pthread_mutex_unlock(&mutex); - } - else + } else m_string += v; return v; } -//------------------------------------------------------------------------------------------------------------------------------------------------- - virtual streamsize xsputn(const char *p, streamsize n) { + virtual std::streamsize xsputn(const char *p, std::streamsize n) { pthread_mutex_lock(&mutex); m_string.append(p, p + n); //changed from uint because of 64 bit size_t pos = 0; - while (pos != string::npos){ + while (pos != std::string::npos) { pos = m_string.find('\n'); - if (pos != string::npos){ - string tmp(m_string.begin(), m_string.begin() + pos); - const char* c_tmp = tmp.c_str(); + if (pos != std::string::npos) { + std::string tmp(m_string.begin(), m_string.begin() + pos); + const char *c_tmp = tmp.c_str(); QApplication::postEvent(log_window, new qStreamEvent(c_tmp)); m_string.erase(m_string.begin(), m_string.begin() + pos + 1); } @@ -104,16 +83,13 @@ protected: return n; } -//------------------------------------------------------------------------------------------------------------------------------------------------- private: pthread_mutex_t mutex; - ostream &m_stream; - streambuf *m_old_buf; - string m_string; - QWidget* log_window; + std::ostream &m_stream; + std::streambuf *m_old_buf; + std::string m_string; + QWidget *log_window; }; -//------------------------------------------------------------------------------------------------------------------------------------------------- -#endif /* QDEBUGSTREAM_H_ */ diff --git a/slsDetectorGui/include/qDefs.h b/slsDetectorGui/include/qDefs.h old mode 100644 new mode 100755 index f1b7d2b51..3a241a4fa --- a/slsDetectorGui/include/qDefs.h +++ b/slsDetectorGui/include/qDefs.h @@ -1,301 +1,252 @@ -/* - * qDefs.h - * - * Created on: May 4, 2012 - * Author: l_maliakal_d - */ +#pragma once -#ifndef QDEFS_H -#define QDEFS_H - -#include "ansi.h" -#include "sls_detector_defs.h" -#include "slsDetector.h" #include "multiSlsDetector.h" -#include -#include -#include -#include +#include "sls_detector_defs.h" + #include -using namespace std; +#include -class qDefs:public QWidget{ -public: -//------------------------------------------------------------------------------------------------------------------------------------------------- +#include +#include +#include +#include - /** Empty Constructor - */ - qDefs(){}; -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -#define GOODBYE -200 -//------------------------------------------------------------------------------------------------------------------------------------------------- - - enum{ - OK, - FAIL - }; - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - enum MessageIndex{ - WARNING, - CRITICAL, - INFORMATION, - QUESTION - }; - -//------------------------------------------------------------------------------------------------------------------------------------------------- - /** unit of time - */ - enum timeUnit{ - HOURS, /** hr */ - MINUTES, /** min */ - SECONDS, /** s */ - MILLISECONDS, /** ms */ - MICROSECONDS, /** us */ - NANOSECONDS /** ns */ - }; - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - /** returns the unit in words - * @param unit is the time unit - */ - static string getUnitString(timeUnit unit){ - switch(unit){ - case HOURS: return string("hrs"); - case MINUTES: return string("min"); - case SECONDS: return string("sec"); - case MILLISECONDS: return string("msec"); - case MICROSECONDS: return string("usec"); - case NANOSECONDS: return string("nsec"); - default: return string("error"); - } - }; -//------------------------------------------------------------------------------------------------------------------------------------------------- - - /** returns the value in ns to send to server as the - * server class slsdetector accepts in ns. - * @param unit unit of time - * @param value time - * returns time value in ns - */ - static double getNSTime(timeUnit unit, double value){ - double valueNS=value; - switch(unit){ - case HOURS: valueNS*=60; - case MINUTES: valueNS*=60; - case SECONDS: valueNS*=1000; - case MILLISECONDS: valueNS*=1000; - case MICROSECONDS: valueNS*=1000; - case NANOSECONDS: - default:; - } - return valueNS; - }; - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - /** returns the time in the appropriate time unit - * @param unit unit of time - * @param value time in seconds - * returns the corresponding time value - */ - static double getCorrectTime(timeUnit& unit, double value){ - int intUnit = (int)SECONDS; - - /**0 ms*/ - if(!value){ - unit = MILLISECONDS; - return value; - } - - /** hr, min, sec */ - if(value>=1){ - double newVal = value; - while((newVal>=1)&&(intUnit>=(int)HOURS)){ - /** value retains the old value */ - value = newVal; - newVal = value/(double)60; - intUnit--; - } - /** returning the previous value*/ - unit = (timeUnit)(intUnit+1); - return value; - } - /** ms, us, ns */ - else{ - while((value<1)&&(intUnit<(int)NANOSECONDS)){ - value = value*(double)1000; - intUnit++; - } - unit = (timeUnit)(intUnit); - return value; - } - }; - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - /**displays an warning,error,info message - * @param message the message to be displayed - * @param source is the tab or the source of the message - * */ - static int Message(MessageIndex index, string message,string source) - { - static QMessageBox* msgBox; - size_t pos; - - //replace all \n with
- pos = 0; - while((pos = message.find("\n", pos)) != string::npos){ - message.replace(pos, 1, "
"); - pos += 1; - } - message.append(string("

Source:   ") + source + string("

")); - - switch(index){ - case WARNING: - msgBox= new QMessageBox(QMessageBox::Warning,"WARNING",tr(message.c_str()),QMessageBox::Ok, msgBox); - break; - case CRITICAL: - msgBox= new QMessageBox(QMessageBox::Critical,"CRITICAL",tr(message.c_str()),QMessageBox::Ok, msgBox); - break; - case INFORMATION: - msgBox= new QMessageBox(QMessageBox::Information,"INFORMATION",tr(message.c_str()),QMessageBox::Ok, msgBox); - break; - default: - msgBox= new QMessageBox(QMessageBox::Question,"QUESTION",tr(message.c_str()),QMessageBox::Ok| QMessageBox::Cancel, msgBox); - break; - } - //msgBox->setDetailedText(QString(source.c_str())); //close button doesnt work with this static function and this - if(msgBox->exec()==QMessageBox::Ok) return OK; else return FAIL; - } - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - /** range of x and y axes - */ - enum range{ - XMINIMUM, - XMAXIMUM, - YMINIMUM, - YMAXIMUM - }; - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - /**gets error mask and displays the message if it exists - * @param myDet is the multidetector object - /returns error message else an empty string - * */ - static string checkErrorMessage(multiSlsDetector*& myDet, string title = "Main"){ - - - int errorLevel= (int)WARNING; - string retval=""; - size_t pos; - - - retval = myDet->getErrorMessage(errorLevel); - - if(!retval.empty()){ - //replace all \n with
- pos = 0; - while((pos = retval.find("\n", pos)) != string::npos){ - retval.replace(pos, 1, "
"); - pos += 1; - } - - //get rid of the last \n - if(retval.find_last_of("
")==retval.length()-1) - retval.erase((int)retval.find_last_of("
")-3,4); - - retval.insert(0,""); - retval.append(""); - - //display message - qDefs::Message((MessageIndex)errorLevel,retval,title); - } - - myDet->clearAllErrorMask(); - return retval; - }; - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - /**gets error mask and displays the message if it exists - * @param myDet is the slsdetector object - * @param show to display the error message - /returns error message else an empty string - * */ - static string checkErrorMessage(slsDetector*& myDet, string title = "Main", bool show = true){ - - - int errorLevel= (int)WARNING; - string retval=""; - size_t pos; - int64_t emask=0; - - emask = myDet->getErrorMask(); - retval = myDet->getErrorMessage(emask); - - if(!retval.empty()){ - //replace all \n with
- pos = 0; - while((pos = retval.find("\n", pos)) != string::npos){ - retval.replace(pos, 1, "
"); - pos += 1; - } - - //get rid of the last \n - if(retval.find_last_of("
")==retval.length()-1) - retval.erase((int)retval.find_last_of("
")-3,4); - - retval.insert(0,""); - retval.append(""); - - //display message - if(show) - qDefs::Message((MessageIndex)errorLevel,retval,title); - } - - myDet->clearErrorMask(); - - return retval; - }; - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - - /** scan arguments*/ - enum scanArgumentList{ - None, - Level0, - Level1, - FileIndex, - AllFrames - }; - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - - /** histogram arguments*/ - enum histogramArgumentList{ - Intensity, - histLevel0, - histLevel1 - }; - - -//------------------------------------------------------------------------------------------------------------------------------------------------- +class qDefs : public QWidget { + public: + /** + * Empty Constructor + */ + qDefs(){}; + +#define GOODBYE -200 + + /** Success or FAIL */ + enum { OK, FAIL }; + + /** + * Message Criticality + */ + enum MessageIndex { WARNING, CRITICAL, INFORMATION, QUESTION }; + + /** + * unit of time + */ + enum timeUnit { + HOURS, /** hr */ + MINUTES, /** min */ + SECONDS, /** s */ + MILLISECONDS, /** ms */ + MICROSECONDS, /** us */ + NANOSECONDS /** ns */ + }; + + /** + * range of x and y axes + */ + enum range { XMINIMUM, XMAXIMUM, YMINIMUM, YMAXIMUM }; + + /** + * function enums for the qServer and qClient + */ + enum guiFuncs { + F_GUI_GET_RUN_STATUS, + F_GUI_START_ACQUISITION, + F_GUI_STOP_ACQUISITION, + F_GUI_START_AND_READ_ALL, + F_GUI_EXIT_SERVER, + NUM_GUI_FUNCS + }; + + /** + * returns the unit in words + * @param unit is the time unit + */ + static std::string getUnitString(timeUnit unit) { + switch (unit) { + case HOURS: + return std::string("hrs"); + case MINUTES: + return std::string("min"); + case SECONDS: + return std::string("sec"); + case MILLISECONDS: + return std::string("msec"); + case MICROSECONDS: + return std::string("usec"); + case NANOSECONDS: + return std::string("nsec"); + default: + return std::string("error"); + } + }; + + /** + * returns the value in ns to send to server as the + * server class slsdetector accepts in ns. + * @param unit unit of time + * @param value time + * returns time value in ns + */ + static double getNSTime(timeUnit unit, double value) { + double valueNS = value; + switch (unit) { + case HOURS: + valueNS *= 60; + case MINUTES: + valueNS *= 60; + case SECONDS: + valueNS *= 1000; + case MILLISECONDS: + valueNS *= 1000; + case MICROSECONDS: + valueNS *= 1000; + case NANOSECONDS: + default: + break; + } + return valueNS; + }; + + /** + * returns the time in the appropriate time unit + * @param unit unit of time + * @param value time in seconds + * returns the corresponding time value + */ + static double getCorrectTime(timeUnit &unit, double value) { + int intUnit = (int)SECONDS; + + /**0 ms*/ + if (!value) { + unit = MILLISECONDS; + return value; + } + + /** hr, min, sec */ + if (value >= 1) { + double newVal = value; + while ((newVal >= 1) && (intUnit >= (int)HOURS)) { + /** value retains the old value */ + value = newVal; + newVal = value / (double)60; + intUnit--; + } + /** returning the previous value*/ + unit = (timeUnit)(intUnit + 1); + return value; + } + /** ms, us, ns */ + else { + while ((value < 1) && (intUnit < (int)NANOSECONDS)) { + value = value * (double)1000; + intUnit++; + } + unit = (timeUnit)(intUnit); + return value; + } + }; + + /** + * displays an warning,error,info message + * @param message the message to be displayed + * @param source is the tab or the source of the message + * */ + static int Message(MessageIndex index, std::string message, + std::string source) { + static QMessageBox *msgBox; + size_t pos; + + // replace all \n with
+ pos = 0; + while ((pos = message.find("\n", pos)) != std::string::npos) { + message.replace(pos, 1, "
"); + pos += 1; + } + message.append( + std::string( + "

Source:   ") + + source + std::string("

")); + + switch (index) { + case WARNING: + msgBox = + new QMessageBox(QMessageBox::Warning, "WARNING", + tr(message.c_str()), QMessageBox::Ok, msgBox); + break; + case CRITICAL: + msgBox = + new QMessageBox(QMessageBox::Critical, "CRITICAL", + tr(message.c_str()), QMessageBox::Ok, msgBox); + break; + case INFORMATION: + msgBox = + new QMessageBox(QMessageBox::Information, "INFORMATION", + tr(message.c_str()), QMessageBox::Ok, msgBox); + break; + default: + msgBox = new QMessageBox( + QMessageBox::Question, "QUESTION", tr(message.c_str()), + QMessageBox::Ok | QMessageBox::Cancel, msgBox); + break; + } + // msgBox->setDetailedText(QString(source.c_str())); //close button + // doesnt work with this static function and this + if (msgBox->exec() == QMessageBox::Ok) + return OK; + else + return FAIL; + } + + /** + * Wrap around to ignore non critical exceptions + */ + template struct NonDeduced { using type = CT; }; + + // only executing multiSlsDetector function + template + static void IgnoreNonCriticalExceptions(multiSlsDetector* det, const std::string loc, RT (multiSlsDetector::*somefunc)(CT...), + typename NonDeduced::type... Args) { + try { + ((det->*somefunc)(Args...)); + } + // catch them here as they are not critical + catch (const sls::NonCriticalError &e) { + Message(qDefs::WARNING, e.what(), loc); + } + }; + + // executing multiSlsDetector funtion and using return value to set QWidget function + template + static void IgnoreNonCriticalExceptions(W* wid, + void (W::*someQfunc)(WRT), + multiSlsDetector* det, const std::string loc, + RT (multiSlsDetector::*somefunc)(CT...), + typename NonDeduced::type... Args) { + try { + auto val = ((det->*somefunc)(Args...)); + (wid->*someQfunc)(static_cast(val)); + } + // catch them here as they are not critical + catch (const sls::NonCriticalError &e) { + Message(qDefs::WARNING, e.what(), loc); + } + }; + // executing multiSlsDetector funtion and returning its value (integers, where value cannot be -1) + template + static RT IgnoreNonCriticalExceptionsandReturn( + multiSlsDetector* det, const std::string loc, + RT (multiSlsDetector::*somefunc)(CT...), + typename NonDeduced::type... Args) { + try { + return ((det->*somefunc)(Args...)); + } + // catch them here as they are not critical + catch (const sls::NonCriticalError &e) { + Message(qDefs::WARNING, e.what(), loc); + return static_cast(-1); + } + }; }; - - -#endif /* QDEFS_H */ diff --git a/slsDetectorGui/include/qDetectorMain.h b/slsDetectorGui/include/qDetectorMain.h old mode 100644 new mode 100755 index 0af189fc0..a6e8d198e --- a/slsDetectorGui/include/qDetectorMain.h +++ b/slsDetectorGui/include/qDetectorMain.h @@ -1,202 +1,200 @@ -/* - * qDetectorMain.h - * Main Window of the GUI - * Created on: Apr 30, 2012 - * Author: l_maliakal_d - */ -#ifndef QDETECTORMAIN_H -#define QDETECTORMAIN_H +#pragma once #include "qDefs.h" - -/** Form Header */ -#include "ui_form_detectormain.h" -/** Qt Project Class Headers */ #include "qDrawPlot.h" -#include "qTabMeasurement.h" #include "qTabDataOutput.h" +#include "qTabMeasurement.h" +#include "ui_form_detectormain.h" class qTabPlot; -class qTabActions; class qTabAdvanced; class qTabSettings; class qTabDebugging; class qTabDeveloper; class qTabMessages; class qServer; -/** Project Class Headers */ + class multiSlsDetector; -/** Qt Include Headers */ -#include + #include #include +#include #include #include -using namespace std; /** To Over-ride the QTabWidget class to get the tabBar */ -class MyTabWidget:public QTabWidget{ -public: - MyTabWidget(QWidget* parent = 0) {setParent(parent);} +class MyTabWidget : public QTabWidget { + public: + MyTabWidget(QWidget *parent = 0) { setParent(parent); } /** Overridden method from QTabWidget */ - QTabBar* tabBar(){return QTabWidget::tabBar();} + QTabBar *tabBar() { return QTabWidget::tabBar(); } }; - /** *@short Main window of the GUI. */ -class qDetectorMain:public QMainWindow, private Ui::DetectorMainObject{ - Q_OBJECT +class qDetectorMain : public QMainWindow, private Ui::DetectorMainObject { + Q_OBJECT + public: + /** + * Main Window constructor. + * This is mainly used to create detector object and all the tabs + * @param argc number of command line arguments for server options + * @param argv server options + * @param app the qapplication3 + * @param parent makes the parent window 0 by default + */ + qDetectorMain(int argc, char **argv, QApplication *app, + QWidget *parent = 0); -public: - /** \short Main Window constructor. - * This is mainly used to create detector object and all the tabs - * @param argc number of command line arguments for server options - * @param argv server options - * @param app the qapplication3 - * @param ret OK or FAIL of constructor (from command line arguments) - * @param parent makes the parent window 0 by default - * */ - qDetectorMain(int argc, char **argv, QApplication *app, int& ret, QWidget *parent = 0); + /** + * Destructor + */ + ~qDetectorMain(); - /**Destructor - * */ - ~qDetectorMain(); + /** + * Starts or stops Acquisition From gui client + * @param start 1 for start and 0 to stop + * @returns success or fail + */ + int StartStopAcquisitionFromClient(bool start); - /** Starts or stops Acquisition From gui client - * @param start 1 for start and 0 to stop - /returns success or fail - */ - int StartStopAcquisitionFromClient(bool start); + /** + * Returns if plot is running + */ + bool isPlotRunning(); - /** Returns if plot is running - */ - bool isPlotRunning(){return myPlot->isRunning();}; + /** + * Returns progress bar value + */ + int GetProgress(); - /** Returns progress bar value */ - int GetProgress(){return tab_measurement->GetProgress();}; + /** + * Verifies if output directories for all the receivers exist + */ + int DoesOutputDirExist(); - /** Returns file path */ - QString GetFilePath(){QString s = QString(myDet->getFilePath().c_str());qDefs::checkErrorMessage(myDet); return s;}; + private slots: + /** + * Enables modes as selected -Debug, Expert, Dockable: calls setdockablemode + */ + void EnableModes(QAction *action); - /** Verifies if output directories for all the receivers exist */ - int DoesOutputDirExist(){return tab_dataoutput->VerifyOutputDirectory();}; + /** + * Executes actions in the utilities menu as selected + */ + void ExecuteUtilities(QAction *action); - bool isCurrentlyTabDeveloper(); + /** + * Executes actions in the utilities menu as selected + */ + void ExecuteHelp(QAction *action); -private: - /** The Qt Application */ - QApplication *theApp; - /** The sls detector object */ - multiSlsDetector *myDet; - /** sls detector id */ - int detID; - /** true for mythen and eiger */ - bool digitalDetector; - /** The Plot widget */ - qDrawPlot *myPlot; - /**Tab Widget */ - MyTabWidget *tabs; - /**Layout of the central Widget */ - QGridLayout *layoutTabs; - /** default height of Plot Window when docked */ - int heightPlotWindow; - /** default height of central widgetwhen plot Window when docked */ - int heightCentralWidget; - /** The default zooming tool tip */ - QString zoomToolTip; + /** + * Refreshes the tab each time the tab is changed. Also displays the next + * enabled tab + */ + void Refresh(int index); - /** The default tab heading color */ - QColor defaultTabColor; - /** enumeration of the tabs */ - enum {Measurement, Settings, DataOutput, Plot, Actions, Advanced, Debugging, Developer, Messages, NumberOfTabs }; - /* Scroll Area for the tabs**/ - QScrollArea *scroll[NumberOfTabs]; - /**Measurement tab */ - qTabMeasurement *tab_measurement; - /**DataOutput tab */ - qTabDataOutput *tab_dataoutput; - /**Plot tab */ - qTabPlot *tab_plot; - /**Actions tab */ - qTabActions *tab_actions; - /**Settings tab */ - qTabSettings *tab_settings; - /**Advanced tab */ - qTabAdvanced *tab_advanced; - /**Debugging tab */ - qTabDebugging *tab_debugging; - /**Developer tab */ - qTabDeveloper *tab_developer; - /**Messages tab */ - qTabMessages *tab_messages; + /** + * Resizes the main window if the plot is docked/undocked + * @param b bool TRUE if undocked(outside main window), FALSE docked + */ + void ResizeMainWindow(bool b); - /** server object*/ - qServer *myServer; + /** + * Enables/disables tabs depending on if acquisition is currently in + * progress + */ + void EnableTabs(); - /**if the developer tab should be enabled,known from command line */ - int isDeveloper; + /** + * Set the tool tip of mouse controlled zooming depening on if its + * enabled/disabled + */ + void SetZoomToolTip(bool disable); - /**Sets up the layout of the widget - * */ - void SetUpWidgetWindow(); + /** + * Uncheck the Listen to gui client mode when the server has exited + */ + void UncheckServer(); - /**Sets up detector - * @param fName file name of the config file at start up - * */ - void SetUpDetector(const string fName); + protected: + /** + * Adjust the resizing to resize plot + */ + void resizeEvent(QResizeEvent *event); - /**Sets up the signals and the slots - * */ - void Initialization(); + private: + /** + * Sets up the layout of the widget + */ + void SetUpWidgetWindow(); - /** Loads config file at start up - * */ - void LoadConfigFile(const string fName); + /** + * Sets up detector + * @param fName file name of the config file at start up + * @param multi detector ID + */ + void SetUpDetector(const std::string fName, int multiID); + /** + * Sets up the signals and the slots + */ + void Initialization(); -private slots: -/** Enables modes as selected -Debug, Expert, Dockable(calls setdockablemode()) - * */ -void EnableModes(QAction *action); - -/** Executes actions in the utilities menu as selected - * */ -void ExecuteUtilities(QAction *action); - -/** Executes actions in the utilities menu as selected - * */ -void ExecuteHelp(QAction *action); - -/** Refreshes the tab each time the tab is changed. Also displays the next enabled tab - * */ -void Refresh(int index); - -/** Resizes the main window if the plot is docked/undocked - * @param b bool TRUE if undocked(outside main window), FALSE docked - * */ -void ResizeMainWindow(bool b); - -/** Enables/disables tabs depending on if acquisition is currently in progress - * */ -void EnableTabs(); - -/** Set the tool tip of mouse controlled zooming depening on if its enabled/disabled - * */ -void SetZoomToolTip(bool disable); - -/** Uncheck the Listen to gui client mode when the server has exited - */ -void UncheckServer(); - -protected: -/** Adjust the resizing to resize plot, except for actions tab - * */ -void resizeEvent(QResizeEvent* event); - + /** + * Loads config file at start up + */ + void LoadConfigFile(const std::string fName); + /** enumeration of the tabs */ + enum { + MEASUREMENT, + SETTINGS, + DATAOUTPUT, + PLOT, + ADVANCED, + DEBUGGING, + DEVELOPER, + MESSAGES, + NumberOfTabs + }; + /** Detector Type */ + slsDetectorDefs::detectorType detType; + /** The sls detector object */ + multiSlsDetector* myDet; + /** The Plot widget */ + qDrawPlot* myPlot; + /**Tab Widget */ + MyTabWidget* tabs; + /**Measurement tab */ + qTabMeasurement* tabMeasurement; + /**DataOutput tab */ + qTabDataOutput* tabDataOutput; + /**Plot tab */ + qTabPlot* tabPlot; + /**Settings tab */ + qTabSettings* tabSettings; + /**Advanced tab */ + qTabAdvanced* tabAdvanced; + /**Debugging tab */ + qTabDebugging* tabDebugging; + /**Developer tab */ + qTabDeveloper* tabDeveloper; + /**Messages tab */ + qTabMessages* tabMessages; + /** server object*/ + qServer* myServer; + /**if the developer tab should be enabled,known from command line */ + int isDeveloper; + /** default height of Plot Window when docked */ + int heightPlotWindow; + /** default height of central widgetwhen plot Window when docked */ + int heightCentralWidget; + /** The default zooming tool tip */ + QString zoomToolTip; + /** The default tab heading color */ + QColor defaultTabColor; }; - -#endif /* QDETECTORMAIN_H */ diff --git a/slsDetectorGui/include/qDrawPlot.h b/slsDetectorGui/include/qDrawPlot.h old mode 100644 new mode 100755 index 54a4a2542..dc32c2630 --- a/slsDetectorGui/include/qDrawPlot.h +++ b/slsDetectorGui/include/qDrawPlot.h @@ -50,7 +50,7 @@ class qDrawPlot:public QWidget{ public: /** \short The constructor */ - qDrawPlot(QWidget *parent,multiSlsDetector*& detector); + qDrawPlot(QWidget *parent, multiSlsDetector* detector); /** Destructor */ ~qDrawPlot(); @@ -181,7 +181,7 @@ void SetLines(bool enable){lines = enable;}; /** sets markers */ void SetMarkers(bool enable){markers = enable;}; /** sets the scan argument to prepare the plot*/ -void SetScanArgument(int scanArg); +// void SetScanArgument(int scanArg); /** sets stop_signal to true */ void StopAcquisition(){ stop_signal = true; }; /** Set/unset pedestal */ diff --git a/slsDetectorGui/include/qScanWidget.h b/slsDetectorGui/include/qScanWidget.h deleted file mode 100644 index 329a211da..000000000 --- a/slsDetectorGui/include/qScanWidget.h +++ /dev/null @@ -1,193 +0,0 @@ -/* - * qScanWidget.h - * - * Created on: May 10, 2012 - * Author: l_maliakal_d - */ - -#ifndef QSCANWIDGET_H_ -#define QSCANWIDGET_H_ - -#include "qDefs.h" - -/** Form Header */ -#include "ui_form_scan.h" -/** Project Class Headers */ -class multiSlsDetector; -/** Qt Include Headers */ -#include -/** C++ Include Headers */ -#include -#include -using namespace std; - - -class qScanWidget : public QWidget,private Ui::ScanObject{ - Q_OBJECT - -public: - /** \short The constructor - * @param parent is the parent tab widget - * @param detector is the detector returned from the detector tab - */ - qScanWidget(QWidget *parent, multiSlsDetector*& detector); - - ~qScanWidget(); - - /**to update the widgets*/ - void Refresh(); - - - /**number of scan widgets*/ - static int NUM_SCAN_WIDGETS; - -private: - /** The sls detector object */ - multiSlsDetector *myDet; - /**id of the scan widget*/ - int id; - /**type of steps*/ - enum sizeIndex{RangeValues, CustomValues, FileValues}; - enum modes{None,EnergyScan,ThresholdScan,TrimbitsScan,PositionScan,CustomScript,NumModes}; - static const string modeNames[NumModes]; - - /**values*/ - int actualNumSteps; - vector positions; - - /**non error font*/ - QPalette normal; - QPalette red; - QString customTip; - QString fileTip; - QString rangeTip; - - /**widgets needed for diff size types*/ - QButtonGroup *btnGroup; - QStackedLayout *stackedLayout; - QLabel *lblFrom; - QDoubleSpinBox *spinFrom; - QLabel *lblTo; - QDoubleSpinBox *spinTo; - QLabel *lblSize; - QDoubleSpinBox *spinSize; - QComboBox *comboCustom; - QPushButton *btnCustom; - QLineEdit *dispFile; - QPushButton *btnFile; - - - /** Sets up the widget - */ - void SetupWidgetWindow(); - - /** Sets up all the slots and signals */ - void Initialization(); - - /** Sets up all the parameters from server/client */ - void LoadPositions(); - - /** Sets up the scan parameters - * returns if it was set - */ - int SetScan(int mode); - -private slots: -/** Enables widgets depending on which size is clicked. - * Options: constant size,specific values,values from file - * */ -void EnableSizeWidgets(); - -/** Sets the scan or script. Accordingly enables, disables other widgets - * @param mode value chosen*/ -void SetMode(int mode); - -/** Browse for the script - * */ -void BrowsePath(); - -/** Sets the script file - * */ -void SetScriptFile(); - -/** Set Parameter - * */ -void SetParameter(); - -/** Set precision - * @param value value of precision to be set - * */ -void SetPrecision(int value); - -/** Set number of steps - * */ -void SetNSteps(); - -/**Checks if size is zero and return FAIL if it does - * */ -int RangeCheckSizeZero(); - -/**returns ok and number of steps if valid - * @param number of steps - * */ -int RangeCheckNumValid(int &num); - -/**returns fail if to is not exact - * */ -int RangeCheckToValid(); - -/** Sets number of steps if from changed - * */ -void RangeFromChanged(); - -/** Sets number of steps if to changed - * */ -void RangeToChanged(); - -/** Sets s of steps if size changed - * */ -void RangeSizeChanged(); - -/** Set range for scan - * */ -void SetRangeSteps(); - - -/** Range type: If size is changed, - * the Number of steps is calculated - * */ -//void RangeCalculateNumSteps(); - -/** Range type: If size is changed, the To is calculated - * */ -//void RangeCalculateTo(); - - -/** Set custom steps - * returns OK if set properly - * */ -int SetCustomSteps(); - -/** Delete custom steps - * */ -void DeleteCustomSteps(); - -/** Reads the file to get the steps - * */ -void SetFileSteps(); - -/** Browses for the file path for steps - * */ -void BrowseFileStepsPath(); - - - -signals: -void EnableScanBox(); -}; - - - - -#endif /* QSCANWIDGET_H_ */ - diff --git a/slsDetectorGui/include/qServer.h b/slsDetectorGui/include/qServer.h old mode 100644 new mode 100755 index bd26080c6..96f381b14 --- a/slsDetectorGui/include/qServer.h +++ b/slsDetectorGui/include/qServer.h @@ -1,137 +1,126 @@ -/* - * qServer.h.h - * - * Created on: Feb 27, 2013 - * Author: Dhanya Maliakal - */ -#ifndef QSERVER_H -#define QSERVER_H +#pragma once - -/** Qt Project Class Headers */ -#include "sls_detector_defs.h" #include "qDefs.h" +#include "sls_detector_defs.h" class qDetectorMain; -/** Project Class Headers */ -class multiSlsDetector; -class MySocketTCP; -/** Qt Include Headers */ -#include -/** C++ Include Headers */ +class multiSlsDetector; +class ServerSocket; + +#include + +#include /** *@short Sets up the gui server */ -class qServer: public QWidget, public virtual slsDetectorDefs{ - Q_OBJECT +class qServer : public QWidget, public virtual slsDetectorDefs { + Q_OBJECT + public: + /** + * The constructor + */ + qServer(qDetectorMain *t); + /** + * Destructor + */ + ~qServer(); -public: - /** \short The constructor */ - qServer(qDetectorMain *t); - /** Destructor */ - ~qServer(); + /** + * Create (Control and Stop) Gui Servers + */ + void CreateServers(); - /** Start or Stop Gui Server - * @param start is 1 to start and 0 to stop - */ - int StartStopServer(int start); + /** + * Destroy (Control and Stop) Gui Servers + */ + void DestroyServers(); -private: - /** assigns functions to the fnum enum */ - int FunctionTable(); + private: + /** + * Assigns functions to the fnum enum + */ + void FunctionTable(); - /** Decodes Function */ - int DecodeFunction(MySocketTCP* sock); + /** + * Decodes Function + * @param sock control or stop socket + * @returns OK or FAIL + */ + int DecodeFunction(ServerSocket *sock); - /** Exit Server */ - int ExitServer(); + /** + * Shut down Sockets + */ + void ShutDownSockets(); + /** + * Server thread + * @param pointer to control or stop socket + */ + void ServerThread(ServerSocket* sock); - /** - * Static function - Thread started which listens to client gui. - * Called by StartStopServer() - * @param this_pointer pointer to this object - */ - static void* StartServerThread(void *this_pointer); + /** + * Thread of stop server + */ + void StopServer(); - /** - * Thread started which listens to client gui. - * Called by startServerThread() - * - */ - int StartServer(); + /** + * Get Detector Status + * @returns success of operation + */ + int GetStatus(); - /** - * Static function - Thread started which listens to client gui to stop acquisition - * Called by StartStopServer() - * @param this_pointer pointer to this object - */ - static void* StopServerThread(void *this_pointer); + /** + * Starts Acquisition + * @returns success of operation + */ + int StartAcquisition(); - /** - * Thread started which listens to client gui to stop acquisition. - * Called by startServerThread() - * - */ - int StopServer(); + /** + * Stops Acquisition + * @returns success of operation + */ + int StopsAcquisition(); + /** + * Acquire - blocking + * @returns success of operation + */ + int Acquire(); + /** + * Exit Server + * @returns GOODBYE + */ + int ExitServer(); - /** Get Detector Status */ - int GetStatus(); + /** function list */ + std::vector flist; - /** Starts Acquisition */ - int StartAcquisition(); + /** if the gui server thread is running*/ + bool threadRunning; - /** Stops Acquisition */ - int StopsAcquisition(); + /** if thread started */ + bool threadStarted; - /** Acquire - blocking */ - int Acquire(); + /**The measurement tab object*/ + qDetectorMain *mainTab; + /** control port */ + int controlPort; + /** stop port */ + int stopPort; - /**The measurement tab object*/ - qDetectorMain *myMainTab; + /** control socket */ + ServerSocket *controlSocket; - /** tcp socket to gui client */ - MySocketTCP *mySocket; - /** tcp socket to gui client to stop or get status */ - MySocketTCP *myStopSocket; - - /** server port number*/ - int port_no; - - /** Lock Status if server locked to a client */ - int lockStatus; - - /** Function List */ - static const int NUMBER_OF_FUNCTIONS = 256; - int (qServer::*flist[NUMBER_OF_FUNCTIONS])(); - - - /** if the gui server thread is running*/ - static int gui_server_thread_running; - /** thread listening to gui client*/ - pthread_t gui_server_thread; - /** thread also listening to gui client to stop acquisition*/ - pthread_t gui_stop_server_thread; - - /** server started */ - int checkStarted; - int checkStopStarted; - - /** Message */ - char mess[MAX_STR_LENGTH]; - - -signals: - void ServerStoppedSignal(); + /** stop socket */ + ServerSocket *stopSocket; + signals: + // to update the Listening to Gui check box + void ServerStoppedSignal(); }; - - - -#endif /* QSERVER_H */ diff --git a/slsDetectorGui/include/qTabActions.h b/slsDetectorGui/include/qTabActions.h deleted file mode 100644 index d5d497fde..000000000 --- a/slsDetectorGui/include/qTabActions.h +++ /dev/null @@ -1,150 +0,0 @@ -/* - * qTabActions.h - * - * Created on: May 10, 2012 - * Author: l_maliakal_d - */ - -#ifndef QTABACTIONS_H_ -#define QTABACTIONS_H_ - -#include "qDefs.h" - - -/* Qt Project Class Headers */ -#include "qActionsWidget.h" -#include "qScanWidget.h" -/** C++ Project Class Headers */ -class multiSlsDetector; -/** Qt Include Headers */ -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -/** - *@short sets up the acions parameters - */ -class qTabActions:public QWidget{ - Q_OBJECT - -public: - /** \short The constructor - * @param parent is the parent tab widget - * @param detector is the detector returned from the detector tab - */ - qTabActions(QWidget *parent,multiSlsDetector*& detector); - - /** Destructor - */ - ~qTabActions(); - - /** To refresh and update widgets - */ - void Refresh(); - - -public slots: - /** Disable Positions - * @param enable true if to disable - * */ - void EnablePositions(bool enable); - - -private: - /** The sls detector object */ - multiSlsDetector *myDet; - - slsDetectorDefs::detectorType detType; - - - enum actionIndex{ - ActionStart, - Scan0, - Scan1, - ActionBefore, - NumPositions, - HeaderBefore, - HeaderAfter, - ActionAfter, - ActionStop, - NumTotalActions}; - - QGridLayout *gridLayout; - QButtonGroup *group; - QPalette *palette; - - /** all action widget objects */ - qActionsWidget *actionWidget[6]; - qScanWidget *scanWidget[2]; - QWidget *positionWidget; - QPushButton *btnExpand[NumTotalActions]; - QLabel *lblName[NumTotalActions]; - - - /** NumPositions widget */ - QLabel *lblNumPos; - QLabel *lblPosList; - QSpinBox *spinNumPos; - QComboBox *comboPos; - QPushButton *btnDelete; - QCheckBox *chkInvert; - QCheckBox *chkSeparate; - QCheckBox *chkReturn; - - double *positions; - QPalette normal; - QIcon *iconPlus; - QIcon *iconMinus; - - - /** Sets up the widget */ - void SetupWidgetWindow(); - - /** Sets up all the slots and signals */ - void Initialization(); - - /** creates the Num Positions object */ - void CreatePositionsWidget(); - - /** Returns the index in each of the classes - * of actionwidget and scanwidget - * @param index the index in the list of all widgets - * returns actual index of the class - */ - int GetActualIndex(int index); - - /** Updates to green color if collapsed and mode not none - */ - void UpdateCollapseColors(); - - - - -private slots: - /** To Expand the Action Widget - * */ - void Expand(QAbstractButton *button); - - /** Sets the positions list and the number of positions - * */ - void SetPosition(); - - /** Deletes current position - * */ - void DeletePosition(); - - -signals: - void EnableScanBox(); - -}; - -#endif /* QTABACTIONS_H_ */ - diff --git a/slsDetectorGui/include/qTabAdvanced.h b/slsDetectorGui/include/qTabAdvanced.h old mode 100644 new mode 100755 index e07305d77..568b8bcb1 --- a/slsDetectorGui/include/qTabAdvanced.h +++ b/slsDetectorGui/include/qTabAdvanced.h @@ -1,24 +1,15 @@ -/* - * qTabAdvanced.h - * - * Created on: May 10, 2012 - * Author: l_maliakal_d - */ - -#ifndef QTABADVANCED_H_ -#define QTABADVANCED_H_ +#pragma once #include "qDefs.h" #include "sls_detector_defs.h" -/** Form Header */ #include "ui_form_tab_advanced.h" -/** Project Class Headers */ + class multiSlsDetector; class slsDetector; -/** Qt Project Class Headers */ + class qDrawPlot; -/** Qt Include Header */ + #include #include /** @@ -28,239 +19,196 @@ class qTabAdvanced:public QWidget, private Ui::TabAdvancedObject{ Q_OBJECT public: - /** \short The constructor - * @param parent is the parent tab widget - * @param detector is the detector returned from the detector tab - * @param plot plot object reference + /** + * The constructor + * @param parent is the parent tab widget + * @param detector is the detector returned from the detector tab */ - qTabAdvanced(QWidget *parent,multiSlsDetector*& detector, qDrawPlot*& plot); + qTabAdvanced(QWidget *parent, multiSlsDetector* detector); - /** Destructor + /** + * Destructor */ ~qTabAdvanced(); public slots: - /** To refresh and update widgets + /** + * To refresh and update widgets */ void Refresh(); private: - /** Sets up the widget + /** + * Sets up the widget */ void SetupWidgetWindow(); - /** Sets up all the slots and signals + /** + * Sets up all the slots and signals */ void Initialization(); - /** Add ROI Input + /** + * Add ROI Input * @param num number of inputs to add */ void AddROIInput(int num); - /** Checks for a few conditions before trimming - /returns OK or FAIL - */ - int validateBeforeTrimming(); - - /** update the setalltrimbits value from server + /** + * Update the setalltrimbits value from server */ void updateAllTrimbitsFromServer(); private slots: - /** Enable/Disable Energy and Calibration Logs - */ - void SetLogs(); - - /** Set acquisition time - */ - void SetExposureTime(); - - /** Set the Threshold dac value - */ - void SetThreshold(); - - /** Set output directory for trimming - */ - void SetOutputFile(); - - /** Browse output directory for trimming - */ - void BrowseOutputFile(); - - /** Enables trimming method and calls SetTrimmingMethod if enabled - * @param enable to enable trimming - */ - void EnableTrimming(bool enable); - - /** Enabling resolution and Counts if this is enabled - * @param enable to enable - */ - void SetOptimize(bool enable); - - /** Sets the trimming method - * @param mode trimming method - */ - void SetTrimmingMethod(int mode); - - /** Ensures the right trimming mode and Executes Trimming - */ - void StartTrimming(); - - /** Updates the plot with trimbits from detector/shared memory - */ - void UpdateTrimbitPlot(int id); - - /** Sets control port + /** + * Sets control port * @param port control port */ void SetControlPort(int port); - /** Sets stop port + /** + * Sets stop port * @param port stop port */ void SetStopPort(int port); - /** Sets receiver tcp port + /** + * Sets receiver tcp port * @param port receiver tcp port */ void SetRxrTCPPort(int port); - /** Sets receiver udp port + /** + * Sets receiver udp port * @param port receiver udp port */ void SetRxrUDPPort(int port); - /** Sets client zmq receiver port + /** + * Sets client zmq receiver port * @param port client zmq receiver port */ void SetCltZmqPort(int port); - /** Sets receiver zmq transmitting port + /** + * Sets receiver zmq transmitting port * @param port receiver zmq transmitting port */ void SetRxrZmqPort(int port); - /** Sets receiver online + /** + * Sets receiver online * @param index 1 for online and 0 for offline */ void SetReceiverOnline(int index); - /** Sets detector online + /** + * Sets detector online * @param index 1 for online and 0 for offline */ void SetOnline(int index); - /** Sets network parameters like receiver udp ip, + /** + * Sets network parameters like receiver udp ip, * receiver udp mac, detector ip and detector mac */ void SetNetworkParameters(); - /** Sets client zmq ip to listen to + /** + * Sets client zmq ip to listen to */ void SetClientZMQIP(); - /** Sets receiver zmq ip to stream from + /** + * Sets receiver zmq ip to stream from */ void SetReceiverZMQIP(); - /** Sets the receiver. which also sets the receiver parameters + /** + * Sets the receiver. which also sets the receiver parameters */ void SetReceiver(); - /** Add ROI Input if the value changed in the last slot + /** + * Add ROI Input if the value changed in the last slot */ - void AddROIInputSlot(){AddROIInput(1);}; + void AddROIInputSlot(); - /** Clears all the ROI inputs + /** + * Clears all the ROI inputs */ void clearROI(); - /** Gets ROIs from detector and updates it + /** + * Gets ROIs from detector and updates it */ void updateROIList(); - /** Sets ROI in detector + /** + * Sets ROI in detector */ void setROI(); - /** Clears ROI in detector + /** + * Clears ROI in detector */ void clearROIinDetector(); - /** Clears ROI in detector + /** + * Select Readout + * @param index position index of readout */ void SetDetector(int index); - /** Set all trimbits to a value + /** + * Set all trimbits to a value */ void SetAllTrimbits(); - /** Set storage cells */ + /** + * Set storage cells + * @param value value to set to + */ void SetNumStoragecells(int value); - /** Set sub frame exposure time */ + /** + * Set sub frame exposure time + */ void SetSubExposureTime(); - /** Set sub frame period */ - void SetSubPeriod(); + /** + * Set sub frame dead time + */ + void SetSubDeadTime(); private: + /** The multi detector object */ multiSlsDetector *myDet; - /** The sls detector object */ - slsDetector *det; - /** detector type */ slsDetectorDefs::detectorType detType; - /** The Plot widget */ - qDrawPlot *myPlot; - - QButtonGroup *btnGroup; - - /** Tool Tip for the output dir */ - QString outputDirTip; - QString errOutputTip; + /** Tool Tip */ QString errOnlineTip; QString detOnlineTip; QString rxrOnlineTip; QPalette red; - /** Trimming mode */ - slsDetectorDefs::trimMode trimmingMode; - static const int TRIMMING_DYNAMIC_RANGE = 32; - static const int TRIMMING_FRAME_NUMBER = 1; - static const int TRIMMING_TRIGGER_NUMBER = 1; - static const int TRIMMING_PROBE_NUMBER = 0; - - bool isEnergy; - bool isAngular; - /** ROI */ - vector lblFromX; - vector spinFromX; - vector lblFromY; - vector spinFromY; - vector lblToX; - vector spinToX; - vector lblToY; - vector spinToY; + std::vector lblFromX; + std::vector spinFromX; + std::vector lblFromY; + std::vector spinFromY; + std::vector lblToX; + std::vector spinToX; + std::vector lblToY; + std::vector spinToY; int numRois; - /** sub period tool tip variables*/ - QString acqSubPeriodTip; - QString errSubPeriodTip; - - void CheckAcqPeriodGreaterThanExp(); - - }; - -#endif /* QTABADVANCED_H_ */ diff --git a/slsDetectorGui/include/qTabDataOutput.h b/slsDetectorGui/include/qTabDataOutput.h old mode 100644 new mode 100755 index 9f0957cd8..a0b9964c3 --- a/slsDetectorGui/include/qTabDataOutput.h +++ b/slsDetectorGui/include/qTabDataOutput.h @@ -1,21 +1,11 @@ -/* - * qTabDataOutput.h - * - * Created on: May 10, 2012 - * Author: l_maliakal_d - */ - -#ifndef QTABDATAOUTPUT_H_ -#define QTABDATAOUTPUT_H_ +#pragma once #include "qDefs.h" - -/** Form Header */ #include "ui_form_tab_dataoutput.h" -/** Project Class Headers */ + class multiSlsDetector; -/** Qt Include Headers */ + #include @@ -26,35 +16,132 @@ class qTabDataOutput:public QWidget, private Ui::TabDataOutputObject{ Q_OBJECT public: - /** \short The constructor - * @param parent is the parent tab widget - * @param detector is the detector returned from the detector tab + /** + * The constructor + * @param parent is the parent tab widget + * @param detector is the detector returned from the detector tab */ - qTabDataOutput(QWidget *parent,multiSlsDetector*& detector); + qTabDataOutput(QWidget *parent,multiSlsDetector* detector); - /** Destructor + /** + * Destructor */ ~qTabDataOutput(); - /** To refresh and update widgets + /** + * To refresh and update widgets */ void Refresh(); - /** verify output directories - * /returns success or fail + /** + * Verify output directories + * @returns success or fail */ int VerifyOutputDirectory(); -private: + + private slots: + + /** + * Open dialog to choose the output directory + */ + void BrowseOutputDir(); + + /** + * Set output directory + */ + void SetOutputDir(); + + /** + * Get output directory + */ + void GetOutputDir(); + + /** + * Set rate correction + */ + void SetRateCorrection(int deadtime=0); + + /** + * Set default rate correction + */ + void SetDefaultRateCorrection(); + + /** + * Set update rate correction from server + */ + void UpdateRateCorrectionFromServer(); + + /** + * Enable/Disable 10GbE + */ + void EnableTenGigabitEthernet(bool enable, int get=0); + + /** + * Set speed + */ + void SetSpeed(); + + /** + * Set flags + */ + void SetFlags(); + + /** + * Set file format + */ + void SetFileFormat(int format); + + /** + * Set overwrite enable + */ + void SetOverwriteEnable(bool enable); + + + private: + + /** + * Sets up the widget + */ + void SetupWidgetWindow(); + + /** + * Sets up all the slots and signals + */ + void Initialization(); + + /** + * Populate the readouts + */ + void PopulateDetectors(); + + /** + * Update speed + */ + void UpdateSpeedFromServer(); + + /** + * Update flags + */ + void UpdateFlagsFromServer(); + + /** + * Update file format + */ + void UpdateFileFormatFromServer(); + + /** + * Update overwrite enable + */ + void UpdateFileOverwriteFromServer(); + + /** The sls detector object */ multiSlsDetector *myDet; /** detector type */ slsDetectorDefs::detectorType detType; - - QString flatFieldTip; - QString errFlatFieldTip; QString outDirTip; QPalette red; QPalette black; @@ -62,95 +149,11 @@ private: QPalette *black1; /** enum for the Eiger clock divider */ - enum {FullSpeed, HalfSpeed, QuarterSpeed, SuperSlowSpeed, NumberofSpeeds}; + enum {FULLSPEED, HALFSPEED, QUARTERSPEED, SUPERSLOWSPEED, NUMBEROFSPEEDS}; /** enum for the Eiger readout flags1 */ - enum {Continous, Storeinram}; + enum {CONTINUOUS, STOREINRAM}; /** enum for the Eiger readout flags2 */ - enum {Parallel, NonParallel, Safe}; + enum {PARALLEL, NONPARALLEL, SAFE}; - -/** methods */ - /** Sets up the widget */ - void SetupWidgetWindow(); - - /** Sets up all the slots and signals */ - void Initialization(); - - /** Populate the readouts - */ - void PopulateDetectors(); - - /** update speed */ - void UpdateSpeedFromServer(); - - /** update flags */ - void UpdateFlagsFromServer(); - - /** update flags */ - void SetupFileFormat(); - - /** update file format */ - void UpdateFileFormatFromServer(); - - /** update overwrite enable */ - void UpdateFileOverwriteFromServer(); - - -private slots: - -/** Open dialog to choose the output directory */ -void BrowseOutputDir(); - -/**set flat field file*/ -void SetFlatField(); - -/** update flat field correction from server */ -void UpdateFlatFieldFromServer(); - -/**browse flat field*/ -void BrowseFlatFieldPath(); - -/**rate correction*/ -void SetRateCorrection(int deadtime=0); - -/** default rate correction */ -void SetDefaultRateCorrection(); - -/** update rate correction from server */ -void UpdateRateCorrectionFromServer(); - -/**angular correction*/ -void SetAngularCorrection(); - -/**discard bad channels*/ -void DiscardBadChannels(); - -/** set output directory*/ -void SetOutputDir(); - -/** set output directory*/ -void GetOutputDir(); - -/** enable 10GbE */ -void EnableTenGigabitEthernet(bool enable, int get=0); - -/** set speed */ -void SetSpeed(); - -/** set flags */ -void SetFlags(); - -/** set file format */ -void SetFileFormat(int format); - -/** set overwrite enable */ -void SetOverwriteEnable(bool enable); - -signals: -/**signal to enable/disable positions in Actions*/ -void AngularConversionSignal(bool); }; - - -#endif /* QTABDATAOUTPUT_H_ */ diff --git a/slsDetectorGui/include/qTabDebugging.h b/slsDetectorGui/include/qTabDebugging.h old mode 100644 new mode 100755 index 484dfa87d..62ef866b5 --- a/slsDetectorGui/include/qTabDebugging.h +++ b/slsDetectorGui/include/qTabDebugging.h @@ -1,24 +1,13 @@ -/* - * qTabDebugging.h - * - * Created on: May 10, 2012 - * Author: l_maliakal_d - */ - -#ifndef QTABDEBUGGING_H_ -#define QTABDEBUGGING_H_ +#pragma once #include "qDefs.h" - -/** Form Header */ #include "ui_form_tab_debugging.h" -/** Project Class Headers */ + class multiSlsDetector; class slsDetector; -/** Qt Include Headers */ -#include +#include /** @@ -28,76 +17,71 @@ class qTabDebugging:public QWidget, private Ui::TabDebuggingObject{ Q_OBJECT public: - /** \short The constructor - * @param parent is the parent tab widget - * @param detector is the detector returned from the detector tab + /** + * The constructor + * @param parent is the parent tab widget + * @param detector is the detector returned from the detector tab */ - qTabDebugging(QWidget *parent,multiSlsDetector*& detector); + qTabDebugging(QWidget *parent, multiSlsDetector* detector); - /** Destructor + /** + * Destructor */ ~qTabDebugging(); - /** To refresh and update widgets + /** + * To refresh and update widgets */ void Refresh(); + +private slots: + + /** + * Updates the status depending on current detector + */ + void UpdateStatus(); + + /** + * Gets id and versions etc + */ + void + GetInfo(); + + /** + * Sets id and versions on the display widget + */ + void SetParameters(QTreeWidgetItem *item); + + /** + * Test detector + */ + void TestDetector(); + private: - /** Sets up the widget + /** + * Sets up the widget */ void SetupWidgetWindow(); - /** Sets up all the slots and signals + /** + * Sets up all the slots and signals */ void Initialization(); - -private slots: - /** Updates the module list depending on current detector - */ - void UpdateModuleList(); - - /** Updates the status depending on current detector - */ - void UpdateStatus(); - - /** Gets id and versions etc - */ - void GetInfo(); - - /** Sets id and versions on the display widget - */ - void SetParameters(QTreeWidgetItem *item); - - /** Test detector and module - */ - void TestDetector(); - -private: /** The multi sls detector object */ multiSlsDetector *myDet; /** detector type */ slsDetectorDefs::detectorType detType; - /**sls detecctor object */ - slsDetector *det; - /** Tree Widget displaying the detectors, modules */ QTreeWidget *treeDet; /** Widget displaying the serial numbers, mac addresses etc */ - QFrame *dispFrame; QLabel *lblDetectorId; - QLabel *lblDetectorSerial; QLabel *lblDetectorFirmware; QLabel *lblDetectorSoftware; - QLabel *lblModuleId; - QLabel *lblModuleFirmware; - QLabel *lblModuleSerial; QPalette *blue; }; - - -#endif /* QTABDEBUGGING_H_ */ diff --git a/slsDetectorGui/include/qTabDeveloper.h b/slsDetectorGui/include/qTabDeveloper.h old mode 100644 new mode 100755 index 10fc334aa..8e0940984 --- a/slsDetectorGui/include/qTabDeveloper.h +++ b/slsDetectorGui/include/qTabDeveloper.h @@ -1,18 +1,9 @@ -/* - * qTabDeveloper.h - * - * Created on: May 10, 2012 - * Author: l_maliakal_d - */ - -#ifndef QTABDEVELOPER_H_ -#define QTABDEVELOPER_H_ +#pragma once #include "qDefs.h" -/** Project Class Headers */ class multiSlsDetector; -/** Qt Include Headers */ + #include #include #include @@ -26,10 +17,8 @@ class multiSlsDetector; #include class qDetectorMain; -/** C++ Include Headers */ #include #include -using namespace std; /**To override the spin box class to have an id and emit it*/ @@ -41,11 +30,8 @@ private: void valueChangedWithID() {emit editingFinished(myId);}; public: /** Overridden constructor from QDoubleSpinBox */ - MyDoubleSpinBox(int id,QWidget* parent = 0) - :QDoubleSpinBox(parent),myId(id){ - //setParent(parent); - connect(this,SIGNAL(editingFinished()), - this,SLOT(valueChangedWithID())); + MyDoubleSpinBox(int id,QWidget* parent = 0) :QDoubleSpinBox(parent), myId(id){ + connect(this, SIGNAL(editingFinished()), this, SLOT(valueChangedWithID())); } signals: void editingFinished(int myId); @@ -59,100 +45,104 @@ class qTabDeveloper:public QWidget { Q_OBJECT public: - /** \short The constructor - * @param parent is the parent tab widget - * @param detector is the detector returned from the detector tab + /** + * The constructor + * @param parent is the parent tab widget + * @param detector is the detector returned from the detector tab */ - qTabDeveloper(qDetectorMain *parent,multiSlsDetector*& detector); + qTabDeveloper(QWidget *parent, multiSlsDetector* detector); - /** Destructor + /** + * Destructor */ ~qTabDeveloper(); - /** To stop ADC Timer when starting acquisition - */ - void StopADCTimer(){if(adcTimer) adcTimer->stop();}; - -private: - /** parent widget */ - qDetectorMain *thisParent; - /** The sls detector object */ - multiSlsDetector *myDet; - /** The sls detector object */ - slsDetector *det; - /** detector type */ - slsDetectorDefs::detectorType detType; - /**number of dac widgets*/ - static int NUM_DAC_WIDGETS; - /**number of adc widgets*/ - static int NUM_ADC_WIDGETS; - - static const int ADC_TIMEOUT = 5000; - - vectordacNames; - vectoradcNames; - - - /**widgets needed*/ - QGridLayout *layout; - QScrollArea *scroll; - QGroupBox *boxDacs; - QGroupBox *boxAdcs; - QLabel *lblDacs[20]; - QLabel *lblAdcs[20]; - MyDoubleSpinBox *spinDacs[20]; - QLabel *lblDacsmV[20]; - QLineEdit *spinAdcs[20]; - QLabel *lblHV; - QComboBox *comboHV; - QTimer *adcTimer; - QGridLayout *dacLayout; - QString tipHV; - QPalette red; - QComboBox *comboDetector; - /** Sets up the widget - */ - void SetupWidgetWindow(); - - /** Sets up all the slots and signals - */ - void Initialization(); - - /** Sets up the DAC Widgets - */ - void CreateDACWidgets(); - - /** Sets up the ADC Widgets - */ - void CreateADCWidgets(); - - /** Gets the sls index to set/get dac/adc - * @param index is the gui dac/adc index - * returns the sls index - */ - slsDetectorDefs::dacIndex getSLSIndex(int index); - public slots: - /** To refresh and update widgets + /** + * Refresh and update widgets */ void Refresh(); private slots: - /** Refreshes the adcs + /** + * Refreshes the adcs */ void RefreshAdcs(); - /** Set Dac values + /** + * Set Dac values * @param id id of dac */ void SetDacValues(int id); - /** Set High Voltage + /** + * Set High Voltage */ void SetHighVoltage(); + +private: + + /** + * Sets up the widget + */ + void SetupWidgetWindow(); + + /** + * Sets up all the slots and signals + */ + void Initialization(); + + /** + * Sets up the DAC Widgets + */ + void CreateDACWidgets(); + + /** + * Sets up the ADC Widgets + */ + void CreateADCWidgets(); + + /** + * Sets up HV widget + */ + void CreateHVWidget(); + + /** + * Gets the sls index to set/get dac/adc + * @param index is the gui dac/adc index + * @returns the sls index + */ + slsDetectorDefs::dacIndex getSLSIndex(int index); + + /** The sls detector object */ + multiSlsDetector *myDet; + /** detector type */ + slsDetectorDefs::detectorType detType; + /**number of dac widgets*/ + int numDACWidgets; + /**number of adc widgets*/ + int numADCWidgets; + + /** list of dac and adc names */ + std::vectordacNames; + std::vectoradcNames; + + + /**widgets needed*/ + QGroupBox *boxDacs; + QGroupBox *boxAdcs; + std::vectorlblDacs; + std::vectorlblAdcs; + std::vectorspinDacs; + std::vectorlblDacsmV; + std::vectorspinAdcs; + QLabel *lblHV; + QComboBox *comboHV; + QSpinBox *spinHV; + QGridLayout *dacLayout; + QString tipHV; + QPalette red; + QComboBox *comboDetector; }; - - -#endif /* QTABDEVELOPER_H_ */ diff --git a/slsDetectorGui/include/qTabMeasurement.h b/slsDetectorGui/include/qTabMeasurement.h old mode 100644 new mode 100755 index 362fba590..bd7f6553e --- a/slsDetectorGui/include/qTabMeasurement.h +++ b/slsDetectorGui/include/qTabMeasurement.h @@ -1,20 +1,11 @@ -/* - * qTabMeasurement.h - * - * Created on: May 2, 2012 - * Author: l_maliakal_d - */ -#ifndef QTABMEASUREMENT -#define QTABMEASUREMENT +#pragma once #include "qDefs.h" - -/** Form Header */ #include "ui_form_tab_measurement.h" -/** Project Class Headers */ + class multiSlsDetector; -/** Qt Project Class Headers */ + #include #include "qDrawPlot.h" class qDetectorMain; @@ -26,157 +17,172 @@ class qTabMeasurement:public QWidget, private Ui::TabMeasurementObject{ Q_OBJECT public: - /** \short The constructor - * This tab allows to change the detector settings, the threshold, the number of (non real time) measurements, - * the acquisition time, the file name, the start run index and shows the current progress of the measurement - * via a progress bar and labels inidicating the current position, scan variable, frame number etc. - * Contains the start and stop acquisition button - * @param parent is the parent tab widget - * @param detector is the detector returned from the detector tab - * @param plot plot object reference + /** + * The constructor + * This tab allows to change measurement parameters and to start/stop an acquisition + * @param parent is the parent tab widget + * @param detector is the detector returned from the detector tab + * @param plot plot object reference */ - qTabMeasurement(qDetectorMain *parent,multiSlsDetector*& detector, qDrawPlot*& plot); + qTabMeasurement(QWidget *parent,multiSlsDetector* detector, qDrawPlot* plot); - /** Destructor + /** + * Destructor */ ~qTabMeasurement(); - /** To refresh and update widgets + /** + * Returns the status of the acquisition in gui */ - void Refresh(); + bool GetStartStatus(); - /** To enable expert mode - * @param enable to enable if true - */ - void SetExpertMode(bool enable); - - /** Returns the status of the acquisition in gui - */ - bool GetStartStatus(){return (!btnStart->isEnabled());}; - - /** Click the Start/Stop Acquisition button + /** + * Click the Start/Stop Acquisition button * This is used if this command came from gui client */ - void ClickStartStop(){startAcquisition();myPlot->SetClientInitiated();}; + void ClickStartStop(); - /** Returns progress bar value */ - int GetProgress(){return progressBar->value();}; + /** + * Returns progress bar value + */ + int GetProgress(); + + /** + * Refresh and update widgets + */ + void Refresh(); public slots: - /** update plot is finished, + /** + * Update plot is finished, * changes start/stop text and enables/disables all widgets */ void UpdateFinished(); - /** updates the current measurement + /** + * Updates the current measurement * @param val the value to be updated */ void SetCurrentMeasurement(int val); - - - -private: - /** Sets up the widget - */ - void SetupWidgetWindow(); - - /** Sets up the timing mode - */ - void SetupTimingMode(); - - /** Sets up all the slots and signals - */ - void Initialization(); - - /** Enables/Disables all the widgets - */ - void Enable(bool enable); - - /** Validates before enabling or disabling probes */ - void EnableProbes(); - - /** Get timing mode from detector - * @param startup is true when gui has just started up*/ - void GetModeFromDetector(bool startup = false); - - /** Checks if acquisition period is greater than exposure time - * and dsplays in red as a warning */ - void CheckAcqPeriodGreaterThanExp(); - - private slots: - /** Sets the timing mode - * @ param mode cane be None, Auto, Gated, Trigger Exposure Series, - * Trigger Frame, Trigger Readout, External Trigger Window - */ - void SetTimingMode(int mode); - /** Set number of measurements - * @param num number of measurements to be set */ + /** + * Set number of measurements + * @param num number of measurements to be set + */ void setNumMeasurements(int num); - /** Set file name - */ - void setFileName(); - - /** Set index of file name - * @param index index of selection - */ - void setRunIndex(int index); - - /** starts Acquisition - */ - void startAcquisition(); - - /** stops Acquisition - */ - void stopAcquisition(); - - /** Set number of frames + /** + * Set number of frames * @param val number of frames to be set */ void setNumFrames(int val); - /** Set acquisition time + /** + * Set acquisition time */ void setExposureTime(); - /** Set frame period between exposures + /** + * Set frame period between exposures */ void setAcquisitionPeriod(); - /** Set number of triggers + /** + * Set number of triggers * @param val number of triggers to be set */ void setNumTriggers(int val); - /** Set delay + /** + * Set delay */ void setDelay(); - /** Set number of gates - * @param val number of gates to be set + /** + * Set number of samples + * @param val number of samples to be set */ - void setNumGates(int val); + void setNumSamples(int val); - /** Set number of probes - * @param val number of probes to be set + /** + * Set file name */ - void setNumProbes(int val); + void setFileName(); - /** Update progress*/ - void UpdateProgress(); - - /** Enable write to file */ + /** + * Enable write to file + */ void EnableFileWrite(bool enable); + /** + * Set index of file name + * @param index index of selection + */ + void setRunIndex(int index); + + /** + * Update progress + */ + void UpdateProgress(); + + /** + * starts Acquisition + */ + void startAcquisition(); + + /** + * stops Acquisition + */ + void stopAcquisition(); + + /** + * Sets the timing mode + * @param mode timing mode + */ + void SetTimingMode(int mode); private: - /** parent widget */ - qDetectorMain *thisParent; + /** + * Sets up the widget + */ + void SetupWidgetWindow(); + + /** + * Sets up the timing mode + */ + void SetupTimingMode(); + + /** + * Sets up all the slots and signals + */ + void Initialization(); + + /** + * Get timing mode from detector + * @param startup is true when gui has just started up + */ + void GetTimingModeFromDetector(bool startup = false); + + /** + * Enables/Disables widgetframes to avoid setting measurement during an acquisition + */ + void Enable(bool enable); + + /** + * Checks if acquisition period is greater than exposure time + */ + void CheckAcqPeriodGreaterThanExp(); + + /** + * Verify if output directory existing error is set + * @returns OK or FAIL + */ + int VerifyOutputDirectoryError(); + /** The sls detector object */ multiSlsDetector *myDet; /** The Plot widget */ @@ -184,15 +190,13 @@ private: /** detector type */ slsDetectorDefs::detectorType detType; /** enum for the timing mode */ - enum{None, Auto, Trigger_Exp_Series, Trigger_Readout, Gated, Gated_Start, Burst_Trigger, NumTimingModes}; + enum{AUTO, TRIGGER, GATED, BURST_TRIGGER, NUM_TIMING_MODES}; /** timer to update the progress*/ QTimer *progressTimer; /** tool tip variables*/ QString acqPeriodTip; QString errPeriodTip; QPalette red; - /** expert mode */ - bool expertMode; /** to access items in settings combobox */ QStandardItemModel* model; @@ -201,7 +205,3 @@ signals: void StopSignal(); void CheckPlotIntervalSignal(); }; - - - -#endif /* QTABMEASUREMENT */ diff --git a/slsDetectorGui/include/qTabMessages.h b/slsDetectorGui/include/qTabMessages.h old mode 100644 new mode 100755 index 8dd7f611b..f32c6ff32 --- a/slsDetectorGui/include/qTabMessages.h +++ b/slsDetectorGui/include/qTabMessages.h @@ -1,26 +1,14 @@ -/* - * qTabMessages.h - * - * Created on: Jun 26, 2012 - * Author: l_maliakal_d - */ - -#ifndef QTABMESSAGES_H_ -#define QTABMESSAGES_H_ - +#pragma once #include "qDefs.h" - - - -/** Project Class Headers */ +#include "qDebugStream.h" class qDetectorMain; -/** Qt Include Headers */ + #include #include #include #include -#include "qDebugStream.h" + /** *@short sets up the Messages parameters @@ -29,17 +17,46 @@ class qTabMessages:public QWidget{ Q_OBJECT public: - /** \short The constructor - * @param det the qDetectorMain class reference + /** + * The constructor + * @param parent parent widget */ - qTabMessages(qDetectorMain* m); + qTabMessages(QWidget* parent); - /** Destructor + /** + * Destructor */ ~qTabMessages(); +private slots: + /** + * Stream log to textedit in GUI + */ + void customEvent(QEvent *e); + + /** + * Save Log to File + */ + void SaveLog(); + + /** + * Clear Log to File + */ + void ClearLog(); private: + + /** + * Sets up the widget + */ + void SetupWidgetWindow(); + + /** + * Sets up all the slots and signals + */ + void Initialization(); + + /** The qDetectorMain object */ qDetectorMain *myMainTab; @@ -51,36 +68,5 @@ private: /** To clear the log to file */ QPushButton *btnClear; - - /** This class creates the log */ - qDebugStream *qout; - qDebugStream *qerr; - - string errMsg; - -/** methods */ - /** Sets up the widget */ - void SetupWidgetWindow(); - - /** Sets up all the slots and signals */ - void Initialization(); - -private slots: -/** Stream log to textedit in GUI */ -void customEvent(QEvent *e); - -/** Save Log to File*/ -void SaveLog(); - -/** Clear Log to File*/ -void ClearLog(); - - - }; - - - - -#endif /* QTABMESSAGES_H_ */ diff --git a/slsDetectorGui/include/qTabPlot.h b/slsDetectorGui/include/qTabPlot.h old mode 100644 new mode 100755 index b2dbbd208..a73b72002 --- a/slsDetectorGui/include/qTabPlot.h +++ b/slsDetectorGui/include/qTabPlot.h @@ -35,7 +35,7 @@ public: * @param detector is the detector returned from the detector tab * @param plot plot object reference */ - qTabPlot(QWidget *parent,multiSlsDetector*& detector, qDrawPlot*& plot); + qTabPlot(QWidget *parent,multiSlsDetector* detector, qDrawPlot* plot); /** Destructor */ @@ -106,7 +106,7 @@ public slots: /** Enable Scan box */ - void EnableScanBox(); + void EnableScanBox(); private slots: diff --git a/slsDetectorGui/include/qTabSettings.h b/slsDetectorGui/include/qTabSettings.h old mode 100644 new mode 100755 index ddb0d4da6..fb2d2f422 --- a/slsDetectorGui/include/qTabSettings.h +++ b/slsDetectorGui/include/qTabSettings.h @@ -1,22 +1,10 @@ -/* - * qTabSettings.h - * - * Created on: May 10, 2012 - * Author: l_maliakal_d - */ - -#ifndef QTABSETTINGS_H_ -#define QTABSETTINGS_H_ +#pragma once #include "qDefs.h" - -/** Form Header */ #include "ui_form_tab_settings.h" -/** Project Class Headers */ + class multiSlsDetector; -/** Qt Include Headers */ -#include /** *@short sets up the Settings parameters @@ -25,92 +13,77 @@ class qTabSettings:public QWidget, private Ui::TabSettingsObject{ Q_OBJECT public: - /** \short The constructor - * @param parent is the parent tab widget - * @param detector is the detector returned from the detector tab + /** + * The constructor + * @param parent is the parent tab widget + * @param detector is the detector returned from the detector tab */ - qTabSettings(QWidget *parent,multiSlsDetector*& detector); + qTabSettings(QWidget *parent, multiSlsDetector* detector); - /** Destructor + /** + * Destructor */ ~qTabSettings(); - /** To refresh and update widgets + /** + * Refresh and update widgets */ void Refresh(); - /** To enable expert mode - * @param enable to enable if true + +private slots: + /** + * Set settings according to selection + * @param index index of selection */ - void SetExpertMode(bool enable){expertMode = enable;}; + void SetSettings(int index); + /** + * Set dynamic range if possible + * @param index selection + */ + void SetDynamicRange(int index); + /** + * Set threshold energy + */ + void SetEnergy(); private: + + /** + * Sets up the widget + */ + void SetupWidgetWindow(); + + /** + * Sets up the detector settings + */ + void SetupDetectorSettings(); + + /** + * Sets up all the slots and signals + */ + void Initialization(); + + /** + * Get Settings + */ + void GetSettings(); + + /** + * Gets the dynamic range and sets it on the gui + */ + void GetDynamicRange(); + /** The sls detector object */ multiSlsDetector *myDet; /** detector type */ slsDetectorDefs::detectorType detType; - /** expert mode */ - bool expertMode; - - enum{Standard,Fast,HighGain,DynamicGain,LowGain,MediumGain,VeryHighGain,LowNoise, - DynamicHG0,FixGain1,FixGain2,ForceSwitchG1,ForceSwitchG2, VeryLowGain, - Undefined,Uninitialized,NumSettings}; - - /** To be able to index items on a combo box */ - QStandardItemModel* model; - QModelIndex index[NumSettings]; - QStandardItem* item[NumSettings]; - - /** Sets up the widget - */ - void SetupWidgetWindow(); - - /** Sets up the detector settings - */ - void SetupDetectorSettings(); - - /** Sets up all the slots and signals - */ - void Initialization(); - - /** Gets the dynamic range and sets it on the gui - * @param setvalue the value set by the gui when used as a check - */ - void GetDynamicRange(int setvalue = -1); - - - -private slots: -/** Set settings according to selection - * @param index index of selection - */ -void setSettings(int index); - -/** Set number of modules if possible - * @param index number of modules - */ -void SetNumberOfModules(int index); - -/** Set dynamic range if possible - * @param index selection - */ -void SetDynamicRange(int index); - -/** Set threshold energy - */ -void SetEnergy(); - - -signals: -/**Update Trimbits after Set Settings */ -void UpdateTrimbitSignal(int); + enum{STANDARD, FAST, HIGHGAIN, DYNAMICGAIN, LOWGAIN, MEDIUMGAIN, VERYHIGHGAIN, LOWNOISE, + DYNAMICHG0, FIXGAIN1, FIXGAIN2, FORCESWITCHG1, FORCESWITCHG2, VERLOWGAIN, + UNDEFINED, UNINITIALIZED, NUMSETTINGS}; }; - - - -#endif /* QTABSETTINGS_H_ */ diff --git a/slsDetectorGui/slsDetectorGui.pro b/slsDetectorGui/slsDetectorGui.pro deleted file mode 100644 index e91bfa219..000000000 --- a/slsDetectorGui/slsDetectorGui.pro +++ /dev/null @@ -1,161 +0,0 @@ -#When using yum for qt, comment out all lines with $(QTDIR) or $(QWTDIR), but export QWTDIR = /usr/include/qwt/ -#and leave "$(QWTDIR) \"uncommented in the INCLUDEPATH - -#When using epics, uncomment epics defines, libs and a line in INCLUDEPATH - - - -QT_INSTALL_PREFIX = $(QTDIR) -QMAKE_UIC = $(QTDIR)/bin/uic -QMAKE_MOC = $(QTDIR)/bin/moc -QMAKE_RCC = $(QTDIR)/bin/rcc -QMAKE_INCDIR_QT = $(QTDIR)/include/ -QMAKE_LIBS_QT = -L$(QTDIR)/lib -QMAKE_LIBS = -L$(QTDIR)/lib - - - - -#epics -#DEFINES += EPICS VERBOSE DACS_INT PRINT_LOG #VERYVERBOSE -#LIBS = -L$(QWTDIR)/lib -lqwt -L$(QWT3D)/lib -Wl,-R$(QWTDIR)/lib -L /usr/local/epics/base/lib/$(EPICS_HOST_ARCH)/ -Wl,-R/usr/local/epics/base/lib/$(EPICS_HOST_ARCH) -lca -lCom - -#default -DEFINES += VERBOSE DACS_INT PRINT_LOG #VERYVERBOSE CHECKINFERROR -LIBS = -L$(QWTDIR)/lib -lqwt -L$(QWT3D)/lib $(LDFLAGDET) - -CXXFLAGS += -g - - -QMAKE_CXXFLAGS_WARN_ON = -w -QMAKE_CFLAGS_WARN_ON = -w - - - - -DESTDIR ?= bin -MOC_DIR = mocs -OBJECTS_DIR = objs -UI_HEADERS_DIR = forms/include -SLSDETLIB ?= ../slsDetectorSoftware -RESOURCES += icons.qrc -CONFIG += debug no_include_pwd - - - -target.path += $(DESTDIR) -documentation.path = /$(DOCPATH) -documentation.files = docs/* -INSTALLS += target -INSTALLS += documentation -QMAKE_CLEAN += docs/*/* - - - -extralib.target = extra -extralib.commands = echo `tput setaf 6`; \ - echo 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'; \ - echo 'x Compiling slsDetectorGui x'; \ - echo 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'; \ - echo `./updateGitVersion.sh; tput sgr0` -extralib.depends = $(target) - -QMAKE_EXTRA_TARGETS += extralib -PRE_TARGETDEPS = extra - - - - -DEPENDPATH += \ - slsDetectorPlotting/include\ - include\ - forms/include - - -INCLUDEPATH += \ - $(QWTDIR)/include\ - $(QWTDIR) \ - $(QWTDIR)/src\ - $(QWT3D)/include\ - slsDetectorPlotting/include\ - ../slsReceiverSoftware/include\ - include\ - forms/include\ - /usr/include/qwt\ #these are not included for standard installations, also bin path should include qt4 bin, not qt3 bin - /usr/include/qt4\ - /usr/include/Qt\ - /usr/include/QtCore\ - /usr/include/QtGui\ - $(INCLUDES) - -#epics -# $(INCLUDES) /usr/local/epics/base/include/ -I /usr/local/epics/base/include/os/Linux/ - - - - - - -SOURCES = \ - slsDetectorPlotting/src/SlsQt1DPlot.cxx\ - slsDetectorPlotting/src/SlsQt1DZoomer.cxx\ - slsDetectorPlotting/src/SlsQt2DHist.cxx\ - slsDetectorPlotting/src/SlsQt2DPlot.cxx\ - slsDetectorPlotting/src/SlsQt2DPlotLayout.cxx\ - slsDetectorPlotting/src/SlsQtNumberEntry.cxx\ - src/qDetectorMain.cpp\ - src/qDrawPlot.cpp\ - src/qCloneWidget.cpp\ - src/qTabMeasurement.cpp\ - src/qTabDataOutput.cpp\ - src/qTabPlot.cpp\ - src/qTabActions.cpp\ - src/qActionsWidget.cpp\ - src/qScanWidget.cpp\ - src/qTabAdvanced.cpp\ - src/qTabSettings.cpp\ - src/qTabDebugging.cpp\ - src/qTabDeveloper.cpp\ - src/qTabMessages.cpp\ - src/qServer.cpp - -HEADERS = \ - slsDetectorPlotting/include/SlsQt1DPlot.h\ - slsDetectorPlotting/include/SlsQt1DZoomer.h\ - slsDetectorPlotting/include/SlsQt2DHist.h\ - slsDetectorPlotting/include/SlsQt2DPlot.h\ - slsDetectorPlotting/include/SlsQt2DPlotLayout.h\ - slsDetectorPlotting/include/SlsQt2DZoomer.h\ - slsDetectorPlotting/include/SlsQtValidators.h\ - slsDetectorPlotting/include/SlsQtNumberEntry.h\ - include/qDefs.h\ - include/qDebugStream.h\ - include/qDetectorMain.h\ - include/qDrawPlot.h\ - include/qCloneWidget.h\ - include/qTabMeasurement.h\ - include/qTabDataOutput.h\ - include/qTabPlot.h\ - include/qTabActions.h\ - include/qActionsWidget.h\ - include/qScanWidget.h\ - include/qTabAdvanced.h\ - include/qTabSettings.h\ - include/qTabDebugging.h\ - include/qTabDeveloper.h\ - include/qTabMessages.h\ - include/gitInfoGui.h\ - ../slsSupportLib/include/sls_detector_defs.h\ - include/qServer.h - - -FORMS = \ - forms/form_detectormain.ui\ - forms/form_tab_measurement.ui\ - forms/form_tab_dataoutput.ui\ - forms/form_tab_plot.ui\ - forms/form_tab_advanced.ui\ - forms/form_tab_settings.ui\ - forms/form_tab_debugging.ui\ - forms/form_action.ui\ - forms/form_scan.ui diff --git a/slsDetectorGui/slsDetectorPlotting/include/SlsQt1DPlot.h b/slsDetectorGui/slsDetectorPlotting/include/SlsQt1DPlot.h old mode 100644 new mode 100755 index 40c066edf..6e48420fc --- a/slsDetectorGui/slsDetectorPlotting/include/SlsQt1DPlot.h +++ b/slsDetectorGui/slsDetectorPlotting/include/SlsQt1DPlot.h @@ -22,7 +22,7 @@ #include #include "SlsQt1DZoomer.h" #include -using namespace std; + class QPen; class SlsQt1DPlot; diff --git a/slsDetectorGui/slsDetectorPlotting/include/SlsQt1DZoomer.h b/slsDetectorGui/slsDetectorPlotting/include/SlsQt1DZoomer.h old mode 100644 new mode 100755 diff --git a/slsDetectorGui/slsDetectorPlotting/include/SlsQt2DHist.h b/slsDetectorGui/slsDetectorPlotting/include/SlsQt2DHist.h old mode 100644 new mode 100755 diff --git a/slsDetectorGui/slsDetectorPlotting/include/SlsQt2DPlot.h b/slsDetectorGui/slsDetectorPlotting/include/SlsQt2DPlot.h old mode 100644 new mode 100755 diff --git a/slsDetectorGui/slsDetectorPlotting/include/SlsQt2DPlotLayout.h b/slsDetectorGui/slsDetectorPlotting/include/SlsQt2DPlotLayout.h old mode 100644 new mode 100755 diff --git a/slsDetectorGui/slsDetectorPlotting/include/SlsQt2DZoomer.h b/slsDetectorGui/slsDetectorPlotting/include/SlsQt2DZoomer.h old mode 100644 new mode 100755 diff --git a/slsDetectorGui/slsDetectorPlotting/include/SlsQtNumberEntry.h b/slsDetectorGui/slsDetectorPlotting/include/SlsQtNumberEntry.h old mode 100644 new mode 100755 diff --git a/slsDetectorGui/slsDetectorPlotting/include/SlsQtValidators.h b/slsDetectorGui/slsDetectorPlotting/include/SlsQtValidators.h old mode 100644 new mode 100755 diff --git a/slsDetectorGui/slsDetectorPlotting/src/SlsQt1DPlot.cxx b/slsDetectorGui/slsDetectorPlotting/src/SlsQt1DPlot.cxx old mode 100644 new mode 100755 index 1382e0e50..a696ad3aa --- a/slsDetectorGui/slsDetectorPlotting/src/SlsQt1DPlot.cxx +++ b/slsDetectorGui/slsDetectorPlotting/src/SlsQt1DPlot.cxx @@ -4,514 +4,567 @@ * @version 1.0 */ +#include "SlsQt1DPlot.h" #include -#include +#include +#include #include #include #include -#include -#include #include #include -#include -#include "SlsQt1DPlot.h" +#include +#include #if QWT_VERSION >= 0x060100 #define QwtLog10ScaleEngine QwtLogScaleEngine #endif -using namespace std; - -SlsQtH1D::SlsQtH1D(QString title,int n, double min, double max, double* data):QwtPlotCurve(title){ - Initailize(); - SetData(n,min,max,data); +SlsQtH1D::SlsQtH1D(QString title, int n, double min, double max, double *data) : QwtPlotCurve(title) { + Initailize(); + SetData(n, min, max, data); } -SlsQtH1D::SlsQtH1D(QString title,int n, double* data_x, double* data_y):QwtPlotCurve(title){ - Initailize(); - SetData(n,data_x,data_y); +SlsQtH1D::SlsQtH1D(QString title, int n, double *data_x, double *data_y) : QwtPlotCurve(title) { + Initailize(); + SetData(n, data_x, data_y); } -void SlsQtH1D::Initailize(){ - ndata=n_array=0; - x=y=0; - pen_ptr = new QPen(); - SetLineColor(); +void SlsQtH1D::Initailize() { + ndata = n_array = 0; + x = y = 0; + pen_ptr = new QPen(); + SetLineColor(); } -SlsQtH1D::~SlsQtH1D(){delete x;delete y;delete pen_ptr;} - -void SlsQtH1D::Attach(SlsQt1DPlot* p){ - attach((QwtPlot*) p); - p->NewHistogramAttached(this); +SlsQtH1D::~SlsQtH1D() { + delete x; + delete y; + delete pen_ptr; } -void SlsQtH1D::Detach(SlsQt1DPlot* p){ - detach(); - p->HistogramDetached(this); +void SlsQtH1D::Attach(SlsQt1DPlot *p) { + attach((QwtPlot *)p); + p->NewHistogramAttached(this); } +void SlsQtH1D::Detach(SlsQt1DPlot *p) { + detach(); + p->HistogramDetached(this); +} -int SlsQtH1D::SetLineColor(int c){ - static int last_color = 1; - if(c<0) c=(last_color+1)%3; - - switch(c){ - case 0: pen_ptr->setColor(Qt::black); break; - case 1: pen_ptr->setColor(Qt::red); break; - case 2: pen_ptr->setColor(Qt::blue); break; - case 3: pen_ptr->setColor(Qt::green); break; - case 4: pen_ptr->setColor(Qt::magenta); break; - case 5: pen_ptr->setColor(Qt::cyan); break; - case 6: pen_ptr->setColor(Qt::darkYellow); break; - case 7: pen_ptr->setColor(Qt::gray); break; - case 8: pen_ptr->setColor(Qt::darkBlue); break; - case 9: pen_ptr->setColor(Qt::darkGreen); break; - case 10: pen_ptr->setColor(Qt::darkMagenta); break; - } -/* if(c==0) pen_ptr->setColor(Qt::black); +int SlsQtH1D::SetLineColor(int c) { + static int last_color = 1; + if (c < 0) + c = (last_color + 1) % 3; + + switch (c) { + case 0: + pen_ptr->setColor(Qt::black); + break; + case 1: + pen_ptr->setColor(Qt::red); + break; + case 2: + pen_ptr->setColor(Qt::blue); + break; + case 3: + pen_ptr->setColor(Qt::green); + break; + case 4: + pen_ptr->setColor(Qt::magenta); + break; + case 5: + pen_ptr->setColor(Qt::cyan); + break; + case 6: + pen_ptr->setColor(Qt::darkYellow); + break; + case 7: + pen_ptr->setColor(Qt::gray); + break; + case 8: + pen_ptr->setColor(Qt::darkBlue); + break; + case 9: + pen_ptr->setColor(Qt::darkGreen); + break; + case 10: + pen_ptr->setColor(Qt::darkMagenta); + break; + } + /* if(c==0) pen_ptr->setColor(Qt::black); else if(c==1) pen_ptr->setColor(Qt::red); else pen_ptr->setColor(Qt::blue);*/ - setPen(*pen_ptr); + setPen(*pen_ptr); - return last_color=c; + return last_color = c; } -int SlsQtH1D::SetLineWidth(int w){ - pen_ptr->setWidth(w); - setPen(*pen_ptr); - return w; +int SlsQtH1D::SetLineWidth(int w) { + pen_ptr->setWidth(w); + setPen(*pen_ptr); + return w; } -void SlsQtH1D::SetLineStyle(int s){ - if(s==1) pen_ptr->setStyle(Qt::DashLine); - else if(s==2) pen_ptr->setStyle(Qt::DotLine); - else if(s==3) pen_ptr->setStyle(Qt::DashDotLine); - else if(s==4) pen_ptr->setStyle(Qt::DashDotDotLine); - else if(s==5) pen_ptr->setStyle(Qt::CustomDashLine); - else pen_ptr->setStyle(Qt::SolidLine); - setPen(*pen_ptr); +void SlsQtH1D::SetLineStyle(int s) { + if (s == 1) + pen_ptr->setStyle(Qt::DashLine); + else if (s == 2) + pen_ptr->setStyle(Qt::DotLine); + else if (s == 3) + pen_ptr->setStyle(Qt::DashDotLine); + else if (s == 4) + pen_ptr->setStyle(Qt::DashDotDotLine); + else if (s == 5) + pen_ptr->setStyle(Qt::CustomDashLine); + else + pen_ptr->setStyle(Qt::SolidLine); + setPen(*pen_ptr); } +void SlsQtH1D::SetData(int n, double xmin, double xmax, double *data) { + n = SetUpArrays(n); -void SlsQtH1D::SetData(int n, double xmin, double xmax, double *data){ - n = SetUpArrays(n); - - ndata=n; - if(xmin>xmax){ - double t=xmin; - xmin=xmax; - xmax=t; - } + ndata = n; + if (xmin > xmax) { + double t = xmin; + xmin = xmax; + xmax = t; + } - dx = (xmax-xmin)/n; - ymin=ymax= data ? data[0]:0; - firstXgt0=-1; - firstYgt0=-1; + dx = (xmax - xmin) / n; + ymin = ymax = data ? data[0] : 0; + firstXgt0 = -1; + firstYgt0 = -1; - for(int i=0;iy[i]) ymin = y[i]; - if(data&&ymax0&&(firstXgt0<0||firstXgt0>x[i])) firstXgt0=x[i]; - if(y[i]>0&&(firstYgt0<0||firstYgt0>y[i])) firstYgt0=y[i]; - } + for (int i = 0; i < ndata; i++) { + x[i] = i ? x[i - 1] + dx : xmin; + y[i] = data ? data[i] : 0; + if (data && ymin > y[i]) + ymin = y[i]; + if (data && ymax < y[i]) + ymax = y[i]; + if (x[i] > 0 && (firstXgt0 < 0 || firstXgt0 > x[i])) + firstXgt0 = x[i]; + if (y[i] > 0 && (firstYgt0 < 0 || firstYgt0 > y[i])) + firstYgt0 = y[i]; + } - // cout<0&&data_x[0]>data_x[n-1]) ? 1:0; - n = SetUpArrays(n); + int reverse = (data_x && n > 0 && data_x[0] > data_x[n - 1]) ? 1 : 0; + n = SetUpArrays(n); - ndata=n; - dx=-1; //signifies not regular intervals + ndata = n; + dx = -1; //signifies not regular intervals - ymin=ymax= data_y ? data_y[0]:0; + ymin = ymax = data_y ? data_y[0] : 0; - firstXgt0=-1; - firstYgt0=-1; + firstXgt0 = -1; + firstYgt0 = -1; - for(int i=0;iy[b]) ymin = y[b]; - if(data_y&&ymax0&&(firstXgt0<0||firstXgt0>x[b])) firstXgt0=x[b]; - if(y[b]>0&&(firstYgt0<0||firstYgt0>y[b])) firstYgt0=y[b]; - } + for (int i = 0; i < ndata; i++) { + int b = reverse ? n - i - 1 : i; + x[b] = data_x ? data_x[i] : 0; + y[b] = data_y ? data_y[i] : 0; + if (data_y && ymin > y[b]) + ymin = y[b]; + if (data_y && ymax < y[b]) + ymax = y[b]; + if (x[b] > 0 && (firstXgt0 < 0 || firstXgt0 > x[b])) + firstXgt0 = x[b]; + if (y[b] > 0 && (firstYgt0 < 0 || firstYgt0 > y[b])) + firstYgt0 = y[b]; + } -#if QWT_VERSION<0x060000 - setRawData(x,y,ndata); -#else - setRawSamples(x,y,ndata); -#endif + // #if QWT_VERSION<0x060000 + // setRawData(x,y,ndata); + // #else + setRawSamples(x, y, ndata); + // #endif } -int SlsQtH1D::SetUpArrays(int n){ - n = n<1 ? 1 : n; //overflow bin - - if(n+1>n_array){ - n_array = n+1; - if(x) delete x; - if(y) delete y; - x = new double [n_array]; - y = new double [n_array]; - } +int SlsQtH1D::SetUpArrays(int n) { + n = n < 1 ? 1 : n; //overflow bin - return n; + if (n + 1 > n_array) { + n_array = n + 1; + if (x) + delete x; + if (y) + delete y; + x = new double[n_array]; + y = new double[n_array]; + } + + return n; } -double SlsQtH1D::FillBin(int bx, double v) { - bx = CheckIndex(bx); - return SetBinContent(bx,y[bx]+v); +double SlsQtH1D::FillBin(int bx, double v) { + bx = CheckIndex(bx); + return SetBinContent(bx, y[bx] + v); } -double SlsQtH1D::Fill(double x, double v){return FillBin(FindBinIndex(x),v);} +double SlsQtH1D::Fill(double x, double v) { return FillBin(FindBinIndex(x), v); } -double SlsQtH1D::SetBinContent(int bx,double v){ - bx = CheckIndex(bx); - y[bx]=v; - if(bx0&&(firstYgt0<=0||y[bx]ymax) ymax = y[bx]; - } - return y[bx]; +double SlsQtH1D::SetBinContent(int bx, double v) { + bx = CheckIndex(bx); + y[bx] = v; + if (bx < ndata) { + if (y[bx] < ymin) + ymin = y[bx]; + if (y[bx] > 0 && (firstYgt0 <= 0 || y[bx] < firstYgt0)) + firstYgt0 = y[bx]; + if (y[bx] > ymax) + ymax = y[bx]; + } + return y[bx]; } -double SlsQtH1D::SetContent(double x,double v) {return SetBinContent(FindBinIndex(x),v); } +double SlsQtH1D::SetContent(double x, double v) { return SetBinContent(FindBinIndex(x), v); } -int SlsQtH1D::FindBinIndex(double px){ - if(dx>0) CheckIndex(int((px-x[0])/dx)); - - //find closest bin - int b=0; for(;bpx) break; +int SlsQtH1D::FindBinIndex(double px) { + if (dx > 0) + CheckIndex(int((px - x[0]) / dx)); - if(b==0) return 0; - else if(fabs(px-x[b-1]) px) + break; - return b; + if (b == 0) + return 0; + else if (fabs(px - x[b - 1]) < fabs(px - x[b])) + return b - 1; + + return b; } -int SlsQtH1D::CheckIndex(int bx){return (bx<0||bx>ndata) ? ndata : bx;}//ndata is the overflow bin - -SlsQtH1D* SlsQtH1D::Add(double v){ for(int bx=0;bx ndata) ? ndata : bx; } //ndata is the overflow bin +SlsQtH1D *SlsQtH1D::Add(double v) { + for (int bx = 0; bx < ndata; bx++) + FillBin(bx, v); + return this; +} //1d hist list stuff -SlsQtH1DList::SlsQtH1DList(SlsQtH1D* hist){ - the_hist = hist; - the_next = 0; +SlsQtH1DList::SlsQtH1DList(SlsQtH1D *hist) { + the_hist = hist; + the_next = 0; } -SlsQtH1DList::~SlsQtH1DList(){ - if(the_next) delete the_next; +SlsQtH1DList::~SlsQtH1DList() { + if (the_next) + delete the_next; } -SlsQtH1D* SlsQtH1DList::Add(SlsQtH1D* hist){ - // cout<<"Adding: "<the_hist) return hist; //already added - if(!hl->the_next) break; - hl=hl->the_next; - } - if(hl->the_hist) hl->the_next = new SlsQtH1DList(hist); - else hl->the_hist = hist; - - // Print(); - - return hist; -} - -void SlsQtH1DList::Print(){ - // cout<<"Printing List"<the_hist<<" "<the_next<the_next; - if(i>10) break; - } -} - -void SlsQtH1DList::Remove(SlsQtH1D* hist){ - // cout<<"Removing: "<the_hist!=hist) hl = hl->the_next; - else{ //match - if(!hl->the_next) hl->the_hist=0; // first the_hist is zero when there's no next - else{ - SlsQtH1DList* t = hl->the_next; - hl->the_hist = t->the_hist; - hl->the_next = t->the_next; - t->the_next = 0; - delete t; - } + while (hl) { + if (hist == hl->the_hist) + return hist; //already added + if (!hl->the_next) + break; + hl = hl->the_next; } - } - // Print(); + if (hl->the_hist) + hl->the_next = new SlsQtH1DList(hist); + else + hl->the_hist = hist; + + // Print(); + + return hist; } +void SlsQtH1DList::Print() { + SlsQtH1DList *hl = this; + int i = 0; + while (hl) { + std::cout << " " << i++ << ") " << hl << " " << hl->the_hist << " " << hl->the_next << '\n'; + hl = hl->the_next; + if (i > 10) + break; + } +} +void SlsQtH1DList::Remove(SlsQtH1D *hist) { + SlsQtH1DList *hl = this; + while (hl) { //every match will be removed + if (hl->the_hist != hist) + hl = hl->the_next; + else { //match + if (!hl->the_next) + hl->the_hist = 0; // first the_hist is zero when there's no next + else { + SlsQtH1DList *t = hl->the_next; + hl->the_hist = t->the_hist; + hl->the_next = t->the_next; + t->the_next = 0; + delete t; + } + } + } +} //1d plot stuff -SlsQt1DPlot::SlsQt1DPlot(QWidget *parent):QwtPlot(parent){ - // n_histograms_attached=0; - hline=vline=0; - hist_list = new SlsQtH1DList(); +SlsQt1DPlot::SlsQt1DPlot(QWidget *parent) : QwtPlot(parent) { + // n_histograms_attached=0; + hline = vline = 0; + hist_list = new SlsQtH1DList(); - UnknownStuff(); - alignScales(); - SetupZoom(); + UnknownStuff(); + alignScales(); + SetupZoom(); - // Assign a title + // Assign a title #ifndef IAN - insertLegend(new QwtLegend(), QwtPlot::BottomLegend); + insertLegend(new QwtLegend(), QwtPlot::BottomLegend); #else - insertLegend(new QwtLegend(), QwtPlot::RightLegend); + insertLegend(new QwtLegend(), QwtPlot::RightLegend); #endif - axisScaleEngine(QwtPlot::yLeft)->setAttribute(QwtScaleEngine::Floating); - axisScaleEngine(QwtPlot::xBottom)->setAttribute(QwtScaleEngine::Floating); + axisScaleEngine(QwtPlot::yLeft)->setAttribute(QwtScaleEngine::Floating); + axisScaleEngine(QwtPlot::xBottom)->setAttribute(QwtScaleEngine::Floating); } -SlsQt1DPlot::~SlsQt1DPlot(){ - delete hist_list; +SlsQt1DPlot::~SlsQt1DPlot() { + delete hist_list; - if(hline) delete hline; - if(vline) delete vline; + if (hline) + delete hline; + if (vline) + delete vline; } -void SlsQt1DPlot::CalculateNResetZoomBase(){ - if(hist_list->Hist()) zoomer->SetZoomBase(hist_list->Hist()); - SlsQtH1DList* hl = hist_list->Next(); - while(hl){ - if(hl->Hist()) zoomer->ExtendZoomBase(hl->Hist()); - hl=hl->Next(); - } +void SlsQt1DPlot::CalculateNResetZoomBase() { + if (hist_list->Hist()) + zoomer->SetZoomBase(hist_list->Hist()); + SlsQtH1DList *hl = hist_list->Next(); + while (hl) { + if (hl->Hist()) + zoomer->ExtendZoomBase(hl->Hist()); + hl = hl->Next(); + } } -void SlsQt1DPlot::NewHistogramAttached(SlsQtH1D* h){ - hist_list->Add(h); - CalculateNResetZoomBase(); - //commented out by dhanya to take off zooming every hist in 1d plots - //if(!hist_list->Next()) UnZoom(); - Update(); +void SlsQt1DPlot::NewHistogramAttached(SlsQtH1D *h) { + hist_list->Add(h); + CalculateNResetZoomBase(); + //commented out by dhanya to take off zooming every hist in 1d plots + //if(!hist_list->Next()) UnZoom(); + Update(); } -void SlsQt1DPlot::HistogramDetached(SlsQtH1D* h){ - hist_list->Remove(h); - CalculateNResetZoomBase(); - Update(); +void SlsQt1DPlot::HistogramDetached(SlsQtH1D *h) { + hist_list->Remove(h); + CalculateNResetZoomBase(); + Update(); } -void SlsQt1DPlot::Update(){ +void SlsQt1DPlot::Update() { replot(); } - -void SlsQt1DPlot::SetTitle(const char* title){ - setTitle(title); + +void SlsQt1DPlot::SetTitle(const char *title) { + setTitle(title); } -void SlsQt1DPlot::SetXTitle(const char* title){ - QwtText t(title); - t.setFont(QFont("Sans Serif",11,QFont::Normal)); - setAxisTitle(QwtPlot::xBottom,t); +void SlsQt1DPlot::SetXTitle(const char *title) { + QwtText t(title); + t.setFont(QFont("Sans Serif", 11, QFont::Normal)); + setAxisTitle(QwtPlot::xBottom, t); } -void SlsQt1DPlot::SetYTitle(const char* title){ - QwtText t(title); - t.setFont(QFont("Sans Serif",11,QFont::Normal)); - setAxisTitle(QwtPlot::yLeft,t); +void SlsQt1DPlot::SetYTitle(const char *title) { + QwtText t(title); + t.setFont(QFont("Sans Serif", 11, QFont::Normal)); + setAxisTitle(QwtPlot::yLeft, t); } -void SlsQt1DPlot::SetLogX(bool yes){ SetLog(QwtPlot::xBottom,yes);} -void SlsQt1DPlot::SetLogY(bool yes){ SetLog(QwtPlot::yLeft,yes);} -void SlsQt1DPlot::SetLog(int axisId, bool yes){ - if(axisId==QwtPlot::xBottom) zoomer->SetLogX(yes); - if(axisId==QwtPlot::yLeft) zoomer->SetLogY(yes); +void SlsQt1DPlot::SetLogX(bool yes) { SetLog(QwtPlot::xBottom, yes); } +void SlsQt1DPlot::SetLogY(bool yes) { SetLog(QwtPlot::yLeft, yes); } +void SlsQt1DPlot::SetLog(int axisId, bool yes) { + if (axisId == QwtPlot::xBottom) + zoomer->SetLogX(yes); + if (axisId == QwtPlot::yLeft) + zoomer->SetLogY(yes); - zoomer->ResetZoomBase(); //needs to be done before setting Engine + zoomer->ResetZoomBase(); //needs to be done before setting Engine - //the old ones are deleted by in the setAxisScaleFunction() function see: 128 of file qwt_plot_axis.cpp - if(yes) setAxisScaleEngine(axisId,new QwtLog10ScaleEngine()); - else setAxisScaleEngine(axisId,new QwtLinearScaleEngine()); + //the old ones are deleted by in the setAxisScaleFunction() function see: 128 of file qwt_plot_axis.cpp + if (yes) + setAxisScaleEngine(axisId, new QwtLog10ScaleEngine()); + else + setAxisScaleEngine(axisId, new QwtLinearScaleEngine()); - axisScaleEngine(QwtPlot::yLeft)->setAttribute(QwtScaleEngine::Floating); - axisScaleEngine(QwtPlot::xBottom)->setAttribute(QwtScaleEngine::Floating); + axisScaleEngine(QwtPlot::yLeft)->setAttribute(QwtScaleEngine::Floating); + axisScaleEngine(QwtPlot::xBottom)->setAttribute(QwtScaleEngine::Floating); - Update(); + Update(); } -void SlsQt1DPlot::UnZoom(){ - setAxisScale(QwtPlot::xBottom,zoomer->x(),zoomer->x()+zoomer->w()); - setAxisScale(QwtPlot::yLeft,zoomer->y(),zoomer->y()+zoomer->h()); +void SlsQt1DPlot::UnZoom() { + setAxisScale(QwtPlot::xBottom, zoomer->x(), zoomer->x() + zoomer->w()); + setAxisScale(QwtPlot::yLeft, zoomer->y(), zoomer->y() + zoomer->h()); - zoomer->setZoomBase();//Call replot for the attached plot before initializing the zoomer with its scales. - Update(); + zoomer->setZoomBase(); //Call replot for the attached plot before initializing the zoomer with its scales. + Update(); } -void SlsQt1DPlot::SetZoom(double xmin,double ymin,double x_width,double y_width){ - setAxisScale(QwtPlot::xBottom,xmin,xmin+x_width); - setAxisScale(QwtPlot::yLeft ,ymin,ymin+y_width); - Update(); +void SlsQt1DPlot::SetZoom(double xmin, double ymin, double x_width, double y_width) { + setAxisScale(QwtPlot::xBottom, xmin, xmin + x_width); + setAxisScale(QwtPlot::yLeft, ymin, ymin + y_width); + Update(); } -void SlsQt1DPlot::RemoveHLine(){ - if(hline) hline->detach(); - delete hline; - hline=0; +void SlsQt1DPlot::RemoveHLine() { + if (hline) + hline->detach(); + delete hline; + hline = 0; } -void SlsQt1DPlot::InsertHLine(double y){ - if(!hline){ - hline = new QwtPlotMarker(); - hline->setLabelAlignment(Qt::AlignRight|Qt::AlignTop); - hline->setLineStyle(QwtPlotMarker::HLine); - hline->attach(this); - } - hline->setYValue(y); +void SlsQt1DPlot::InsertHLine(double y) { + if (!hline) { + hline = new QwtPlotMarker(); + hline->setLabelAlignment(Qt::AlignRight | Qt::AlignTop); + hline->setLineStyle(QwtPlotMarker::HLine); + hline->attach(this); + } + hline->setYValue(y); } -void SlsQt1DPlot::RemoveVLine(){ - if(vline) vline->detach(); - delete vline; - vline=0; +void SlsQt1DPlot::RemoveVLine() { + if (vline) + vline->detach(); + delete vline; + vline = 0; } -void SlsQt1DPlot::InsertVLine(double x){ - if(!vline){ - vline = new QwtPlotMarker(); - vline->setLabelAlignment(Qt::AlignRight|Qt::AlignTop); - vline->setLineStyle(QwtPlotMarker::VLine); - vline->attach(this); - } - vline->setXValue(x); +void SlsQt1DPlot::InsertVLine(double x) { + if (!vline) { + vline = new QwtPlotMarker(); + vline->setLabelAlignment(Qt::AlignRight | Qt::AlignTop); + vline->setLineStyle(QwtPlotMarker::VLine); + vline->attach(this); + } + vline->setXValue(x); } +void SlsQt1DPlot::SetupZoom() { + // LeftButton for the zooming + // MidButton for the panning + // RightButton: zoom out by 1 + // Ctrl+RighButton: zoom out to full size - + zoomer = new SlsQt1DZoomer(canvas()); -void SlsQt1DPlot::SetupZoom(){ - // LeftButton for the zooming - // MidButton for the panning - // RightButton: zoom out by 1 - // Ctrl+RighButton: zoom out to full size - - zoomer = new SlsQt1DZoomer(canvas()); - #if QT_VERSION < 0x040000 - zoomer->setMousePattern(QwtEventPattern::MouseSelect2,Qt::RightButton, Qt::ControlButton); + zoomer->setMousePattern(QwtEventPattern::MouseSelect2, Qt::RightButton, Qt::ControlButton); #else - zoomer->setMousePattern(QwtEventPattern::MouseSelect2,Qt::RightButton, Qt::ControlModifier); + zoomer->setMousePattern(QwtEventPattern::MouseSelect2, Qt::RightButton, Qt::ControlModifier); #endif - zoomer->setMousePattern(QwtEventPattern::MouseSelect3,Qt::RightButton); + zoomer->setMousePattern(QwtEventPattern::MouseSelect3, Qt::RightButton); - panner = new QwtPlotPanner((QwtPlotCanvas*)canvas()); + panner = new QwtPlotPanner((QwtPlotCanvas *)canvas()); panner->setAxisEnabled(QwtPlot::yRight, false); panner->setMouseButton(Qt::MidButton); - // Avoid jumping when labels with more/less digits - // appear/disappear when scrolling vertically + // Avoid jumping when labels with more/less digits + // appear/disappear when scrolling vertically - const QFontMetrics fm(axisWidget(QwtPlot::yLeft)->font()); - QwtScaleDraw *sd = axisScaleDraw(QwtPlot::yLeft); - sd->setMinimumExtent( fm.width("100.00") ); + const QFontMetrics fm(axisWidget(QwtPlot::yLeft)->font()); + QwtScaleDraw *sd = axisScaleDraw(QwtPlot::yLeft); + sd->setMinimumExtent(fm.width("100.00")); const QColor c(Qt::darkBlue); zoomer->setRubberBandPen(c); zoomer->setTrackerPen(c); } - // Set a plain canvas frame and align the scales to it -void SlsQt1DPlot::alignScales(){ +void SlsQt1DPlot::alignScales() { // The code below shows how to align the scales to // the canvas frame, but is also a good example demonstrating // why the spreaded API needs polishing. - ((QwtPlotCanvas*)canvas())->setFrameStyle(QFrame::Box | QFrame::Plain ); - ((QwtPlotCanvas*)canvas())->setLineWidth(1); + ((QwtPlotCanvas *)canvas())->setFrameStyle(QFrame::Box | QFrame::Plain); + ((QwtPlotCanvas *)canvas())->setLineWidth(1); - for(int i = 0; i < QwtPlot::axisCnt; i++ ){ - QwtScaleWidget *scaleWidget = (QwtScaleWidget *)axisWidget(i); - if(scaleWidget) scaleWidget->setMargin(0); - QwtScaleDraw *scaleDraw = (QwtScaleDraw *)axisScaleDraw(i); - if(scaleDraw) scaleDraw->enableComponent(QwtAbstractScaleDraw::Backbone, false); + for (int i = 0; i < QwtPlot::axisCnt; i++) { + QwtScaleWidget *scaleWidget = (QwtScaleWidget *)axisWidget(i); + if (scaleWidget) + scaleWidget->setMargin(0); + QwtScaleDraw *scaleDraw = (QwtScaleDraw *)axisScaleDraw(i); + if (scaleDraw) + scaleDraw->enableComponent(QwtAbstractScaleDraw::Backbone, false); } } -void SlsQt1DPlot::UnknownStuff(){ -#if QWT_VERSION<0x060000 - // Disable polygon clipping - //not supported for version 6 - QwtPainter::setDeviceClipping(false); - canvas()->setPaintAttribute(QwtPlotCanvas::PaintCached, false); - canvas()->setPaintAttribute(QwtPlotCanvas::PaintPacked, false); +void SlsQt1DPlot::UnknownStuff() { +#if QWT_VERSION < 0x060000 + // Disable polygon clipping + //not supported for version 6 + QwtPainter::setDeviceClipping(false); + canvas()->setPaintAttribute(QwtPlotCanvas::PaintCached, false); + canvas()->setPaintAttribute(QwtPlotCanvas::PaintPacked, false); #else - // We don't need the cache here - ((QwtPlotCanvas*)canvas())->setPaintAttribute(QwtPlotCanvas::BackingStore, false); + // We don't need the cache here + ((QwtPlotCanvas *)canvas())->setPaintAttribute(QwtPlotCanvas::BackingStore, false); #endif - - #if QT_VERSION >= 0x040000 #ifdef Q_WS_X11 - // Qt::WA_PaintOnScreen is only supported for X11, but leads - // to substantial bugs with Qt 4.2.x/Windows - canvas()->setAttribute(Qt::WA_PaintOnScreen, true); + // Qt::WA_PaintOnScreen is only supported for X11, but leads + // to substantial bugs with Qt 4.2.x/Windows + canvas()->setAttribute(Qt::WA_PaintOnScreen, true); #endif #endif } - - //Added by Dhanya on 19.06.2012 to disable zooming when any of the axes range has been set -void SlsQt1DPlot::DisableZoom(bool disableZoom){ +void SlsQt1DPlot::DisableZoom(bool disableZoom) { #ifdef VERBOSE - if(disableZoom) cout<<"Disabling zoom"<setMousePattern(QwtEventPattern::MouseSelect1,Qt::NoButton); + if (disableZoom) { + if (zoomer) { + zoomer->setMousePattern(QwtEventPattern::MouseSelect1, Qt::NoButton); #if QT_VERSION < 0x040000 - zoomer->setMousePattern(QwtEventPattern::MouseSelect2,Qt::NoButton, Qt::ControlButton); + zoomer->setMousePattern(QwtEventPattern::MouseSelect2, Qt::NoButton, Qt::ControlButton); #else - zoomer->setMousePattern(QwtEventPattern::MouseSelect2,Qt::NoButton, Qt::ControlModifier); + zoomer->setMousePattern(QwtEventPattern::MouseSelect2, Qt::NoButton, Qt::ControlModifier); #endif - zoomer->setMousePattern(QwtEventPattern::MouseSelect3,Qt::NoButton); - } - if(panner) panner->setMouseButton(Qt::NoButton); - }else { - if(zoomer){ - zoomer->setMousePattern(QwtEventPattern::MouseSelect1,Qt::LeftButton); + zoomer->setMousePattern(QwtEventPattern::MouseSelect3, Qt::NoButton); + } + if (panner) + panner->setMouseButton(Qt::NoButton); + } else { + if (zoomer) { + zoomer->setMousePattern(QwtEventPattern::MouseSelect1, Qt::LeftButton); #if QT_VERSION < 0x040000 - zoomer->setMousePattern(QwtEventPattern::MouseSelect2,Qt::RightButton, Qt::ControlButton); + zoomer->setMousePattern(QwtEventPattern::MouseSelect2, Qt::RightButton, Qt::ControlButton); #else - zoomer->setMousePattern(QwtEventPattern::MouseSelect2,Qt::RightButton, Qt::ControlModifier); + zoomer->setMousePattern(QwtEventPattern::MouseSelect2, Qt::RightButton, Qt::ControlModifier); #endif - zoomer->setMousePattern(QwtEventPattern::MouseSelect3,Qt::RightButton); - } - if(panner) panner->setMouseButton(Qt::MidButton); - } + zoomer->setMousePattern(QwtEventPattern::MouseSelect3, Qt::RightButton); + } + if (panner) + panner->setMouseButton(Qt::MidButton); + } } - - - - diff --git a/slsDetectorGui/slsDetectorPlotting/src/SlsQt1DZoomer.cxx b/slsDetectorGui/slsDetectorPlotting/src/SlsQt1DZoomer.cxx old mode 100644 new mode 100755 index 31386094e..18a03fc56 --- a/slsDetectorGui/slsDetectorPlotting/src/SlsQt1DZoomer.cxx +++ b/slsDetectorGui/slsDetectorPlotting/src/SlsQt1DZoomer.cxx @@ -13,7 +13,6 @@ #include "SlsQt1DPlot.h" #include "SlsQt1DZoomer.h" -using namespace std; void SlsQt1DZoomer::ResetZoomBase(){ SetZoomBase(x0,y0,x1-x0,y1-y0); //for going between log and nonlog plots @@ -100,8 +99,6 @@ void SlsQt1DZoomer::ExtendZoomBase(SlsQtH1D* h){ if(h->GetFirstXgtZero()GetFirstXgtZero(); if(h->GetFirstYgtZero()GetFirstYgtZero(); - // cout<<"extend "< +#include #include +#include #include #include -#include #if QT_VERSION >= 0x040000 #include #endif #include -#include -#include -#include -#include -#include #include +#include +#include +#include +#include #include +#include #include "SlsQt2DPlot.h" - -#if QWT_VERSION >= 0x060100 -#define QwtLog10ScaleEngine QwtLogScaleEngine -#endif -using namespace std; - -SlsQt2DPlot::SlsQt2DPlot(QWidget *parent):QwtPlot(parent){ - isLog=0; - - axisScaleEngine(QwtPlot::yLeft)->setAttribute(QwtScaleEngine::Floating); - axisScaleEngine(QwtPlot::xBottom)->setAttribute(QwtScaleEngine::Floating); - - d_spectrogram = new QwtPlotSpectrogram(); - - hist = new SlsQt2DHist(); - SetupZoom(); - SetupColorMap(); - - -#if QWT_VERSION<0x060000 - d_spectrogram->setData(*hist); -#else - d_spectrogram->setData(hist); +#if QWT_VERSION >= 0x060100 +#define QwtLog10ScaleEngine QwtLogScaleEngine #endif +SlsQt2DPlot::SlsQt2DPlot(QWidget *parent) : QwtPlot(parent) { + isLog = 0; - d_spectrogram->attach(this); + axisScaleEngine(QwtPlot::yLeft)->setAttribute(QwtScaleEngine::Floating); + axisScaleEngine(QwtPlot::xBottom)->setAttribute(QwtScaleEngine::Floating); - plotLayout()->setAlignCanvasToScales(true); + d_spectrogram = new QwtPlotSpectrogram(); - FillTestPlot(); - Update(); + hist = new SlsQt2DHist(); + SetupZoom(); + SetupColorMap(); +#if QWT_VERSION < 0x060000 + d_spectrogram->setData(*hist); +#else + d_spectrogram->setData(hist); +#endif + + d_spectrogram->attach(this); + + plotLayout()->setAlignCanvasToScales(true); + + FillTestPlot(); + Update(); } +void SlsQt2DPlot::SetupColorMap() { -void SlsQt2DPlot::SetupColorMap(){ - - - - - colorMapLinearScale = myColourMap(0); -#if QWT_VERSION<0x060000 - d_spectrogram->setColorMap(*colorMapLinearScale ); + colorMapLinearScale = myColourMap(0); +#if QWT_VERSION < 0x060000 + d_spectrogram->setColorMap(*colorMapLinearScale); #else - d_spectrogram->setColorMap(colorMapLinearScale ); + d_spectrogram->setColorMap(colorMapLinearScale); #endif - colorMapLogScale = myColourMap(1); -#if QWT_VERSION<0x060000 + colorMapLogScale = myColourMap(1); +#if QWT_VERSION < 0x060000 contourLevelsLinear = new QwtValueList(); - for(double level=0.5;level<10.0;level+=1.0 ) (*contourLevelsLinear) += level; + for (double level = 0.5; level < 10.0; level += 1.0) + (*contourLevelsLinear) += level; d_spectrogram->setContourLevels(*contourLevelsLinear); #else ; - - for(double level=0.5;level<10.0;level+=1.0 ) (contourLevelsLinear) += level; - d_spectrogram->setContourLevels(contourLevelsLinear); + + for (double level = 0.5; level < 10.0; level += 1.0) + (contourLevelsLinear) += level; + d_spectrogram->setContourLevels(contourLevelsLinear); #endif - - // -#if QWT_VERSION<0x060000 + // +#if QWT_VERSION < 0x060000 contourLevelsLog = new QwtValueList(); - for(double level=0.5;level<10.0;level+=1.0 ) (*contourLevelsLog) += (pow(10,2*level/10.0)-1)/99.0 * 10; - + for (double level = 0.5; level < 10.0; level += 1.0) + (*contourLevelsLog) += (pow(10, 2 * level / 10.0) - 1) / 99.0 * 10; + #else ; - - for(double level=0.5;level<10.0;level+=1.0 ) (contourLevelsLog) += (pow(10,2*level/10.0)-1)/99.0 * 10; + + for (double level = 0.5; level < 10.0; level += 1.0) + (contourLevelsLog) += (pow(10, 2 * level / 10.0) - 1) / 99.0 * 10; #endif - - // A color bar on the right axis + // A color bar on the right axis rightAxis = axisWidget(QwtPlot::yRight); - - rightAxis->setTitle("Intensity"); + + rightAxis->setTitle("Intensity"); rightAxis->setColorBarEnabled(true); enableAxis(QwtPlot::yRight); } -void SlsQt2DPlot::FillTestPlot(int mode){ - static int nx = 50; - static int ny = 50; - static double *the_data=0; - if(the_data==0) the_data = new double [nx*ny]; +void SlsQt2DPlot::FillTestPlot(int mode) { + static int nx = 50; + static int ny = 50; + static double *the_data = 0; + if (the_data == 0) + the_data = new double[nx * ny]; - double dmax = sqrt(pow(nx/2.0-0.5,2) + pow(ny/2.0-0.5,2)); - for(int i=0;iSetData(nx,200,822,ny,-0.5,ny-0.5,the_data); + hist->SetData(nx, 200, 822, ny, -0.5, ny - 0.5, the_data); } -void SlsQt2DPlot::SetupZoom(){ - // LeftButton for the zooming - // MidButton for the panning - // RightButton: zoom out by 1 - // Ctrl+RighButton: zoom out to full size +void SlsQt2DPlot::SetupZoom() { + // LeftButton for the zooming + // MidButton for the panning + // RightButton: zoom out by 1 + // Ctrl+RighButton: zoom out to full size - zoomer = new SlsQt2DZoomer(canvas()); + zoomer = new SlsQt2DZoomer(canvas()); zoomer->SetHist(hist); - -#if QT_VERSION < 0x040000 - zoomer->setMousePattern(QwtEventPattern::MouseSelect2,Qt::RightButton, Qt::ControlButton); -#else - zoomer->setMousePattern(QwtEventPattern::MouseSelect2,Qt::RightButton, Qt::ControlModifier); -#endif - zoomer->setMousePattern(QwtEventPattern::MouseSelect3,Qt::RightButton); - panner = new QwtPlotPanner(canvas()); +#if QT_VERSION < 0x040000 + zoomer->setMousePattern(QwtEventPattern::MouseSelect2, Qt::RightButton, Qt::ControlButton); +#else + zoomer->setMousePattern(QwtEventPattern::MouseSelect2, Qt::RightButton, Qt::ControlModifier); +#endif + zoomer->setMousePattern(QwtEventPattern::MouseSelect3, Qt::RightButton); + + panner = new QwtPlotPanner(canvas()); panner->setAxisEnabled(QwtPlot::yRight, false); panner->setMouseButton(Qt::MidButton); - // Avoid jumping when labels with more/less digits - // appear/disappear when scrolling vertically + // Avoid jumping when labels with more/less digits + // appear/disappear when scrolling vertically - const QFontMetrics fm(axisWidget(QwtPlot::yLeft)->font()); - QwtScaleDraw *sd = axisScaleDraw(QwtPlot::yLeft); - sd->setMinimumExtent( fm.width("100.00") ); + const QFontMetrics fm(axisWidget(QwtPlot::yLeft)->font()); + QwtScaleDraw *sd = axisScaleDraw(QwtPlot::yLeft); + sd->setMinimumExtent(fm.width("100.00")); const QColor c(Qt::darkBlue); zoomer->setRubberBandPen(c); @@ -164,211 +159,200 @@ void SlsQt2DPlot::SetupZoom(){ //replot(); }*/ -void SlsQt2DPlot::UnZoom(bool replot){ -#if QWT_VERSION<0x060000 - zoomer->setZoomBase(QwtDoubleRect(hist->GetXMin(),hist->GetYMin(),hist->GetXMax()-hist->GetXMin(),hist->GetYMax()-hist->GetYMin())); +void SlsQt2DPlot::UnZoom(bool replot) { +#if QWT_VERSION < 0x060000 + zoomer->setZoomBase(QwtDoubleRect(hist->GetXMin(), hist->GetYMin(), hist->GetXMax() - hist->GetXMin(), hist->GetYMax() - hist->GetYMin())); #else - zoomer->setZoomBase(QRectF(hist->GetXMin(),hist->GetYMin(),hist->GetXMax()-hist->GetXMin(),hist->GetYMax()-hist->GetYMin())); -#endif - zoomer->setZoomBase(replot);//Call replot for the attached plot before initializing the zoomer with its scales. - // zoomer->zoom(0); + zoomer->setZoomBase(QRectF(hist->GetXMin(), hist->GetYMin(), hist->GetXMax() - hist->GetXMin(), hist->GetYMax() - hist->GetYMin())); +#endif + zoomer->setZoomBase(replot); //Call replot for the attached plot before initializing the zoomer with its scales. + // zoomer->zoom(0); } -void SlsQt2DPlot::SetZoom(double xmin,double ymin,double x_width,double y_width){ +void SlsQt2DPlot::SetZoom(double xmin, double ymin, double x_width, double y_width) { -#if QWT_VERSION<0x060000 - zoomer->setZoomBase(QwtDoubleRect(xmin,ymin,x_width,y_width)); +#if QWT_VERSION < 0x060000 + zoomer->setZoomBase(QwtDoubleRect(xmin, ymin, x_width, y_width)); #else - zoomer->setZoomBase(QRectF(xmin,ymin,x_width,y_width)); + zoomer->setZoomBase(QRectF(xmin, ymin, x_width, y_width)); #endif } -void SlsQt2DPlot::SetZMinMax(double zmin,double zmax){ - hist->SetMinMax(zmin,zmax); +void SlsQt2DPlot::SetZMinMax(double zmin, double zmax) { + hist->SetMinMax(zmin, zmax); } +QwtLinearColorMap *SlsQt2DPlot::myColourMap(QVector colourStops) { -QwtLinearColorMap* SlsQt2DPlot::myColourMap(QVector colourStops) { - -int ns=5; - -double r[]={0.00, 0.00, 0.87, 1.00, 0.51}; -double g[]={0.00, 0.81, 1.00, 0.20, 0.00}; - double b[] = { 0.51, 1.00, 0.12, 0.00, 0.00 }; + int ns = 5; - QColor c1,c2,c; - c1.setRgbF(r[0],g[0],b[0],0); - c2.setRgbF(r[ns-1],g[ns-1],b[ns-1]); - QwtLinearColorMap* copyMap = new QwtLinearColorMap(Qt::lightGray, c2); + double r[] = {0.00, 0.00, 0.87, 1.00, 0.51}; + double g[] = {0.00, 0.81, 1.00, 0.20, 0.00}; + double b[] = {0.51, 1.00, 0.12, 0.00, 0.00}; - for (int is=0; isaddColorStop(colourStops.value(is),c ); - } + QColor c1, c2, c; + c1.setRgbF(r[0], g[0], b[0], 0); + c2.setRgbF(r[ns - 1], g[ns - 1], b[ns - 1]); + QwtLinearColorMap *copyMap = new QwtLinearColorMap(Qt::lightGray, c2); - return copyMap; + for (int is = 0; is < ns - 1; is++) { + c.setRgbF(r[is], g[is], b[is]); + copyMap->addColorStop(colourStops.value(is), c); + } - + return copyMap; } -QwtLinearColorMap* SlsQt2DPlot::myColourMap(int log) { - -int ns=5; - - - QVector cs1(0); - QVector lcs1(0); - - - cs1.append(0.); - cs1.append(0.34); - cs1.append(0.61); - cs1.append(0.84); - cs1.append(1.); -if (log) { - for (int is=0; is cs1(0); + QVector lcs1(0); + + cs1.append(0.); + cs1.append(0.34); + cs1.append(0.61); + cs1.append(0.84); + cs1.append(1.); + if (log) { + for (int is = 0; is < ns; is++) { + lcs1.append((pow(10, 2 * cs1.value(is)) - 1) / 99.0); + } + return myColourMap(lcs1); + } + + return myColourMap(cs1); } - -void SlsQt2DPlot::Update(){ -#if QWT_VERSION<0x060000 - rightAxis->setColorMap(d_spectrogram->data().range(),d_spectrogram->colorMap()); +void SlsQt2DPlot::Update() { +#if QWT_VERSION < 0x060000 + rightAxis->setColorMap(d_spectrogram->data().range(), d_spectrogram->colorMap()); #else - if (isLog) - hist->SetMinimumToFirstGreaterThanZero(); + if (isLog) + hist->SetMinimumToFirstGreaterThanZero(); - const QwtInterval zInterval = d_spectrogram->data()->interval( Qt::ZAxis ); - - rightAxis->setColorMap(zInterval,myColourMap(isLog)); + const QwtInterval zInterval = d_spectrogram->data()->interval(Qt::ZAxis); + + rightAxis->setColorMap(zInterval, myColourMap(isLog)); #endif - if(!zoomer->zoomRectIndex()) UnZoom(); - -#if QWT_VERSION<0x060000 + if (!zoomer->zoomRectIndex()) + UnZoom(); +#if QWT_VERSION < 0x060000 - setAxisScale(QwtPlot::yRight,d_spectrogram->data().range().minValue(), - d_spectrogram->data().range().maxValue()); -#else + setAxisScale(QwtPlot::yRight, d_spectrogram->data().range().minValue(), + d_spectrogram->data().range().maxValue()); +#else - - setAxisScale(QwtPlot::yRight,zInterval.minValue(), zInterval.maxValue()); + setAxisScale(QwtPlot::yRight, zInterval.minValue(), zInterval.maxValue()); #ifdef VERYVERBOSE - cout << "axis scale set" << endl; + std::cout << "axis scale set\n"; #endif - plotLayout()->setAlignCanvasToScales(true); + plotLayout()->setAlignCanvasToScales(true); #ifdef VERYVERBOSE - cout << "layout" << endl; + std::cout << "layout\n"; #endif #endif #ifdef VERYVERBOSE - cout << "going to replot" << endl; + std::cout << "going to replot\n"; #endif - replot(); + replot(); #ifdef VERYVERBOSE - cout << "done" << endl; + std::cout << "done\n"; #endif } - - -void SlsQt2DPlot::showContour(bool on){ - d_spectrogram->setDisplayMode(QwtPlotSpectrogram::ContourMode,on); - Update(); +void SlsQt2DPlot::showContour(bool on) { + d_spectrogram->setDisplayMode(QwtPlotSpectrogram::ContourMode, on); + Update(); } -void SlsQt2DPlot::showSpectrogram(bool on){ - // static int io=0; - // FillTestPlot(io++); - d_spectrogram->setDisplayMode(QwtPlotSpectrogram::ImageMode, on); - d_spectrogram->setDefaultContourPen(on ? QPen() : QPen(Qt::NoPen)); - Update(); +void SlsQt2DPlot::showSpectrogram(bool on) { + // static int io=0; + // FillTestPlot(io++); + d_spectrogram->setDisplayMode(QwtPlotSpectrogram::ImageMode, on); + d_spectrogram->setDefaultContourPen(on ? QPen() : QPen(Qt::NoPen)); + Update(); } -void SlsQt2DPlot::InterpolatedPlot(bool on){ - hist->Interpolate(on); - Update(); +void SlsQt2DPlot::InterpolatedPlot(bool on) { + hist->Interpolate(on); + Update(); } - -void SlsQt2DPlot::LogZ(bool on){ - if(on){ -isLog=1; - //if(hist->GetMinimum()<=0) hist->SetMinimumToFirstGreaterThanZero(); -#if QWT_VERSION<0x060000 - d_spectrogram->setColorMap(*colorMapLogScale); +void SlsQt2DPlot::LogZ(bool on) { + if (on) { + isLog = 1; + //if(hist->GetMinimum()<=0) hist->SetMinimumToFirstGreaterThanZero(); +#if QWT_VERSION < 0x060000 + d_spectrogram->setColorMap(*colorMapLogScale); #else - d_spectrogram->setColorMap(myColourMap(isLog)); + d_spectrogram->setColorMap(myColourMap(isLog)); #endif - setAxisScaleEngine(QwtPlot::yRight,new QwtLog10ScaleEngine); -#if QWT_VERSION<0x060000 - d_spectrogram->setContourLevels(*contourLevelsLog); + setAxisScaleEngine(QwtPlot::yRight, new QwtLog10ScaleEngine); +#if QWT_VERSION < 0x060000 + d_spectrogram->setContourLevels(*contourLevelsLog); #else - d_spectrogram->setContourLevels(contourLevelsLog); + d_spectrogram->setContourLevels(contourLevelsLog); #endif - }else{ -isLog=0; + } else { + isLog = 0; -#if QWT_VERSION<0x060000 - d_spectrogram->setColorMap(*colorMapLinearScale); +#if QWT_VERSION < 0x060000 + d_spectrogram->setColorMap(*colorMapLinearScale); #else - d_spectrogram->setColorMap(myColourMap(isLog)); -#endif - - + d_spectrogram->setColorMap(myColourMap(isLog)); +#endif - setAxisScaleEngine(QwtPlot::yRight,new QwtLinearScaleEngine); - -#if QWT_VERSION<0x060000 - d_spectrogram->setContourLevels(*contourLevelsLinear); + setAxisScaleEngine(QwtPlot::yRight, new QwtLinearScaleEngine); + +#if QWT_VERSION < 0x060000 + d_spectrogram->setContourLevels(*contourLevelsLinear); #else - d_spectrogram->setContourLevels(contourLevelsLinear); -#endif - - } - Update(); - + d_spectrogram->setContourLevels(contourLevelsLinear); +#endif + } + Update(); } //Added by Dhanya on 19.06.2012 to disable zooming when any of the axes range has been set -void SlsQt2DPlot::DisableZoom(bool disableZoom){ +void SlsQt2DPlot::DisableZoom(bool disableZoom) { #ifdef VERBOSE - if(disableZoom) cout<<"Disabling zoom"<setMousePattern(QwtEventPattern::MouseSelect1,Qt::NoButton); + if (disableZoom) { + if (zoomer) { + zoomer->setMousePattern(QwtEventPattern::MouseSelect1, Qt::NoButton); #if QT_VERSION < 0x040000 - zoomer->setMousePattern(QwtEventPattern::MouseSelect2,Qt::NoButton, Qt::ControlButton); + zoomer->setMousePattern(QwtEventPattern::MouseSelect2, Qt::NoButton, Qt::ControlButton); #else - zoomer->setMousePattern(QwtEventPattern::MouseSelect2,Qt::NoButton, Qt::ControlModifier); + zoomer->setMousePattern(QwtEventPattern::MouseSelect2, Qt::NoButton, Qt::ControlModifier); #endif - zoomer->setMousePattern(QwtEventPattern::MouseSelect3,Qt::NoButton); - } - if(panner) panner->setMouseButton(Qt::NoButton); - }else { - if(zoomer){ - zoomer->setMousePattern(QwtEventPattern::MouseSelect1,Qt::LeftButton); + zoomer->setMousePattern(QwtEventPattern::MouseSelect3, Qt::NoButton); + } + if (panner) + panner->setMouseButton(Qt::NoButton); + } else { + if (zoomer) { + zoomer->setMousePattern(QwtEventPattern::MouseSelect1, Qt::LeftButton); #if QT_VERSION < 0x040000 - zoomer->setMousePattern(QwtEventPattern::MouseSelect2,Qt::RightButton, Qt::ControlButton); + zoomer->setMousePattern(QwtEventPattern::MouseSelect2, Qt::RightButton, Qt::ControlButton); #else - zoomer->setMousePattern(QwtEventPattern::MouseSelect2,Qt::RightButton, Qt::ControlModifier); + zoomer->setMousePattern(QwtEventPattern::MouseSelect2, Qt::RightButton, Qt::ControlModifier); #endif - zoomer->setMousePattern(QwtEventPattern::MouseSelect3,Qt::RightButton); - } - if(panner) panner->setMouseButton(Qt::MidButton); - } + zoomer->setMousePattern(QwtEventPattern::MouseSelect3, Qt::RightButton); + } + if (panner) + panner->setMouseButton(Qt::MidButton); + } } - /* void SlsQt2DPlot::printPlot(){ QPrinter printer; diff --git a/slsDetectorGui/slsDetectorPlotting/src/SlsQt2DPlotLayout.cxx b/slsDetectorGui/slsDetectorPlotting/src/SlsQt2DPlotLayout.cxx old mode 100644 new mode 100755 index 220bf0f2c..805dac109 --- a/slsDetectorGui/slsDetectorPlotting/src/SlsQt2DPlotLayout.cxx +++ b/slsDetectorGui/slsDetectorPlotting/src/SlsQt2DPlotLayout.cxx @@ -14,7 +14,7 @@ #include "SlsQt2DPlotLayout.h" -using namespace std; + SlsQt2DPlotLayout::SlsQt2DPlotLayout(QWidget *parent):QGroupBox(parent){ the_layout=0; diff --git a/slsDetectorGui/slsDetectorPlotting/src/SlsQtNumberEntry.cxx b/slsDetectorGui/slsDetectorPlotting/src/SlsQtNumberEntry.cxx old mode 100644 new mode 100755 index 7d061bbbf..ac847ae5f --- a/slsDetectorGui/slsDetectorPlotting/src/SlsQtNumberEntry.cxx +++ b/slsDetectorGui/slsDetectorPlotting/src/SlsQtNumberEntry.cxx @@ -27,7 +27,6 @@ #include "SlsQtNumberEntry.h" -using namespace std; SlsQtNumberEntry::SlsQtNumberEntry(QWidget *parent, int with_checkbox, char *start_string, int num_type, char* middle_string, int num2_type, int n_units, char** units, double* unit_factors,char* end_string):QWidget(parent){ SetupNumberEntry(with_checkbox,start_string,num_type,middle_string,num2_type,n_units,units,unit_factors,end_string); diff --git a/slsDetectorGui/src/qActionsWidget.cpp b/slsDetectorGui/src/qActionsWidget.cpp deleted file mode 100644 index f86fd795f..000000000 --- a/slsDetectorGui/src/qActionsWidget.cpp +++ /dev/null @@ -1,219 +0,0 @@ -/* - * qActionsWidget.cpp - * - * Created on: May 10, 2012 - * Author: l_maliakal_d - */ -// Project Class Headers -#include "slsDetector.h" -#include "multiSlsDetector.h" -// Qt Project Class Headers -#include "qActionsWidget.h" -// Qt Include Headers -#include -// C++ Include Headers -#include -using namespace std; - -//------------------------------------------------------------------------------------------------------------------------------------------------- -int qActionsWidget::NUM_ACTION_WIDGETS(0); -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -qActionsWidget::qActionsWidget(QWidget *parent,multiSlsDetector*& detector): - QWidget(parent),myDet(detector){ - setupUi(this); - SetupWidgetWindow(); - Initialization(); -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -qActionsWidget::~qActionsWidget(){ - delete myDet; -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qActionsWidget::SetupWidgetWindow(){ - id = NUM_ACTION_WIDGETS; - NUM_ACTION_WIDGETS++; - - setFixedHeight(25); - -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qActionsWidget::Initialization(){ - //mode - connect(comboScript, SIGNAL(currentIndexChanged(int)), this,SLOT(SetMode(int))); - //file - connect(dispScript, SIGNAL(editingFinished()), this, SLOT(SetScriptFile())); - connect(btnBrowse, SIGNAL(clicked()), this, SLOT(BrowsePath())); - //parameter - connect(dispParameter, SIGNAL(editingFinished()), this, SLOT(SetParameter())); -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qActionsWidget::SetMode(int mode){ -#ifdef VERBOSE - cout << "Setting\taction:" << id << "\tmode:" << mode << endl; -#endif - //enabling/disabling - dispScript->setEnabled(mode); - btnBrowse->setEnabled(mode); - lblParameter->setEnabled(mode); - dispParameter->setEnabled(mode); - - QString fName = dispScript->text(); - //set the mode - if(mode) myDet->setActionScript(id,fName.toAscii().constData()); - else myDet->setActionScript(id,""); - //mode is not set when fname is blank - - if(!fName.isEmpty()){ - //check if mode didnt get set - if(mode!=myDet->getActionMode(id)){ - qDefs::Message(qDefs::WARNING,"The mode could not be changed.","qActionsWidget::SetMode"); - comboScript->setCurrentIndex(myDet->getActionMode(id)); - }//if mode got set and its custom script - else if(mode){ - //when the file name did not get set correctly - if(fName.compare(QString(myDet->getActionScript(id).c_str()))){ - qDefs::Message(qDefs::WARNING,"The file path could not be set.","qActionsWidget::SetMode"); - dispScript->setText(QString(myDet->getActionScript(id).c_str())); - SetScriptFile(); - } - } - } - qDefs::checkErrorMessage(myDet,"qActionsWidget::SetMode"); -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - -void qActionsWidget::BrowsePath(){ -#ifdef VERBOSE - cout << "Browsing Script File Path" << endl; -#endif - QString fName = dispScript->text(); - QString dir = fName.section('/',0,-2,QString::SectionIncludeLeadingSep); - if(dir.isEmpty()) dir = "/home"; - //dialog - fName = QFileDialog::getOpenFileName(this, - tr("Load Script File"),dir, - tr("Script Files(*.awk);;All Files(*)")); - //if empty, set the file name and it calls setscriptfile, else ignore - if (!fName.isEmpty()){ - dispScript->setText(fName); - SetScriptFile(); - } -} - -//------------------------------------------------------------------------------------------------------------------------------------------------- - -void qActionsWidget::SetScriptFile(){ - QString fName = dispScript->text(); -#ifdef VERBOSE - cout << "Setting\taction:" << id << "\tscript:" << fName.toAscii().constData() << endl; -#endif - bool set = false; - struct stat st_buf; - - //blank - if(fName.isEmpty()) - set = true; - else if(!fName.compare("none")) - set = true; - //not blank - else{ - //path doesnt exist - if(stat(fName.toAscii().constData(),&st_buf)){ - qDefs::Message(qDefs::WARNING,"The script file entered does not exist","qActionsWidget::SetScriptFile"); - dispScript->setText(QString(myDet->getActionScript(id).c_str())); - } - //if its not a file - else if (!S_ISREG (st_buf.st_mode)) { - qDefs::Message(qDefs::WARNING,"The script file path entered is not a file","qActionsWidget::SetScriptFile"); - dispScript->setText(QString(myDet->getActionScript(id).c_str())); - } - else - set=true; - } - - - //if blank or valid file - if(set){ - //scan and positions wouldnt get here - myDet->setActionScript(id,fName.toAscii().constData()); - if(fName.compare(QString(myDet->getActionScript(id).c_str()))){ - //did not get set, write what is was before - if(!fName.isEmpty()) - qDefs::Message(qDefs::WARNING,"The script file could not be set. Reverting to previous file.","qActionsWidget::SetScriptFile"); - dispScript->setText(QString(myDet->getActionScript(id).c_str())); - } - } - - //dont display if theres a none - if(!dispScript->text().compare("none")) dispScript->setText(""); - - qDefs::checkErrorMessage(myDet,"qActionsWidget::SetScriptFile"); - -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qActionsWidget::SetParameter(){ - QString parameter = dispParameter->text(); -#ifdef VERBOSE - cout << "Setting\taction:" << id << "\tparameter:" << parameter.toAscii().constData() << endl; -#endif - myDet->setActionParameter(id,parameter.toAscii().constData()); - //dont display if theres a none - if(!dispParameter->text().compare("none")) dispParameter->setText(""); - - qDefs::checkErrorMessage(myDet,"qActionsWidget::SetParameter"); -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qActionsWidget::Refresh(){ - int mode = (myDet->getActionMode(id)>0?1:0); - string script = myDet->getActionScript(id); - string parameter = myDet->getActionParameter(id); - - - //settings values and checking for none - if(QString(script.c_str()).compare("none")) - dispScript->setText(QString(script.c_str())); - if(mode)SetScriptFile(); - dispParameter->setText(QString(parameter.c_str())); - SetParameter(); - //set mode which also checks everything - comboScript->setCurrentIndex(mode); -#ifdef VERBOSE - cout << "Updated\taction:" << id << "\t" - "mode:"< #include #include -#include -#include "qwt_symbol.h" -/** C++ Include Headers */ +qCloneWidget::qCloneWidget(QWidget *parent, int id, QString title, QString xTitle, QString yTitle, QString zTitle, + int numDim, std::string FilePath, bool displayStats, QString min, QString max, QString sum) : QMainWindow(parent), id(id), filePath(FilePath), cloneplot1D(0), cloneplot2D(0) { + // Window title + char winTitle[300], currTime[50]; + strcpy(currTime, GetCurrentTimeStamp()); + sprintf(winTitle, "Snapshot:%d - %s", id, currTime); + setWindowTitle(QString(winTitle)); + marker = new QwtSymbol(); + nomarker = new QwtSymbol(); + marker->setStyle(QwtSymbol::Cross); + marker->setSize(5, 5); -//------------------------------------------------------------------------------------------------------------------------------------------------- - -qCloneWidget::qCloneWidget(QWidget *parent,int id,QString title,QString xTitle, QString yTitle, QString zTitle, - int numDim,string FilePath,bool displayStats, QString min, QString max, QString sum): - QMainWindow(parent),id(id),filePath(FilePath),cloneplot1D(0),cloneplot2D(0) - { - // Window title - char winTitle[300],currTime[50]; - strcpy(currTime,GetCurrentTimeStamp()); - sprintf(winTitle,"Snapshot:%d - %s",id,currTime); - setWindowTitle(QString(winTitle)); - - marker = new QwtSymbol(); - nomarker = new QwtSymbol(); - marker->setStyle(QwtSymbol::Cross); - marker->setSize(5,5); - - // Set up widget - SetupWidgetWindow(title,xTitle, yTitle, zTitle, numDim); - DisplayStats(displayStats,min,max,sum); + // Set up widget + SetupWidgetWindow(title, xTitle, yTitle, zTitle, numDim); + DisplayStats(displayStats, min, max, sum); } -//------------------------------------------------------------------------------------------------------------------------------------------------- -qCloneWidget::~qCloneWidget(){ - delete cloneplot1D; - delete cloneplot2D; - delete cloneBox; +qCloneWidget::~qCloneWidget() { + delete cloneplot1D; + delete cloneplot2D; + delete cloneBox; + cloneplot1D_hists.clear(); } -//------------------------------------------------------------------------------------------------------------------------------------------------- -void qCloneWidget::SetupWidgetWindow(QString title, QString xTitle, QString yTitle, QString zTitle, int numDim){ - - menubar = new QMenuBar(this); - actionSave = new QAction("&Save",this); - menubar->addAction(actionSave); - setMenuBar(menubar); - - - //Main Window Layout - QWidget *centralWidget = new QWidget(this); - mainLayout = new QGridLayout(centralWidget); - centralWidget->setLayout(mainLayout); - - //plot group box - cloneBox = new QGroupBox(this); - gridClone = new QGridLayout(cloneBox); - cloneBox->setLayout(gridClone); - cloneBox->setContentsMargins(0,0,0,0); - cloneBox->setAlignment(Qt::AlignHCenter); - cloneBox->setFont(QFont("Sans Serif",11,QFont::Normal)); - cloneBox->setTitle(title); - // According to dimensions, create appropriate 1D or 2Dplot - if(numDim==1){ - cloneplot1D = new SlsQt1DPlot(cloneBox); - - cloneplot1D->setFont(QFont("Sans Serif",9,QFont::Normal)); - cloneplot1D->SetXTitle(xTitle.toAscii().constData()); - cloneplot1D->SetYTitle(yTitle.toAscii().constData()); - - - cloneBox->setFlat(false); - cloneBox->setContentsMargins(0,30,0,0); - gridClone->addWidget(cloneplot1D,0,0); - - lblHistTitle = new QLabel(""); - mainLayout->addWidget(lblHistTitle,0,0); - - }else{ - cloneplot2D = new SlsQt2DPlotLayout(cloneBox); - cloneplot2D->setFont(QFont("Sans Serif",9,QFont::Normal)); - cloneplot2D->SetXTitle(xTitle); - cloneplot2D->SetYTitle(yTitle); - cloneplot2D->SetZTitle(zTitle); - cloneplot2D->setAlignment(Qt::AlignLeft); - - cloneBox->setFlat(true); - cloneBox->setContentsMargins(0,20,0,0); - gridClone->addWidget(cloneplot2D,0,0); - } - - // main window widgets - mainLayout->addWidget(cloneBox,1,0); - setCentralWidget(centralWidget); - - // Save - connect(actionSave,SIGNAL(triggered()),this,SLOT(SavePlot())); - - setMinimumHeight(300); - resize(500,350); +SlsQt1DPlot* qCloneWidget::Get1dPlot() { + return cloneplot1D; } -//------------------------------------------------------------------------------------------------------------------------------------------------- -void qCloneWidget::SetCloneHists(int nHists,int histNBins,double* histXAxis,double* histYAxis[],string histTitle[],bool lines,bool markers){ - //for each plot, create hists - for(int hist_num=0;hist_numcloneplot1D_hists.size()){ - cloneplot1D_hists.append(k=new SlsQtH1D("1d plot",histNBins,histXAxis,histYAxis[hist_num])); - k->SetLineColor(0); - }else{ - k=cloneplot1D_hists.at(hist_num); - k->SetData(histNBins,histXAxis,histYAxis[hist_num]); - } +void qCloneWidget::SetupWidgetWindow(QString title, QString xTitle, QString yTitle, QString zTitle, int numDim) { + + QMenuBar* menubar = new QMenuBar(this); + QAction* actionSave = new QAction("&Save", this); + menubar->addAction(actionSave); + setMenuBar(menubar); + + //Main Window Layout + QWidget *centralWidget = new QWidget(this); + mainLayout = new QGridLayout(centralWidget); + centralWidget->setLayout(mainLayout); + + //plot group box + cloneBox = new QGroupBox(this); + QGridLayout* gridClone = new QGridLayout(cloneBox); + cloneBox->setLayout(gridClone); + cloneBox->setContentsMargins(0, 0, 0, 0); + cloneBox->setAlignment(Qt::AlignHCenter); + cloneBox->setFont(QFont("Sans Serif", 11, QFont::Normal)); + cloneBox->setTitle(title); + // According to dimensions, create appropriate 1D or 2Dplot + if (numDim == 1) { + cloneplot1D = new SlsQt1DPlot(cloneBox); + + cloneplot1D->setFont(QFont("Sans Serif", 9, QFont::Normal)); + cloneplot1D->SetXTitle(xTitle.toAscii().constData()); + cloneplot1D->SetYTitle(yTitle.toAscii().constData()); + + cloneBox->setFlat(false); + cloneBox->setContentsMargins(0, 30, 0, 0); + gridClone->addWidget(cloneplot1D, 0, 0); + + lblHistTitle = new QLabel(""); + mainLayout->addWidget(lblHistTitle, 0, 0); + + } else { + cloneplot2D = new SlsQt2DPlotLayout(cloneBox); + cloneplot2D->setFont(QFont("Sans Serif", 9, QFont::Normal)); + cloneplot2D->SetXTitle(xTitle); + cloneplot2D->SetYTitle(yTitle); + cloneplot2D->SetZTitle(zTitle); + cloneplot2D->setAlignment(Qt::AlignLeft); + + cloneBox->setFlat(true); + cloneBox->setContentsMargins(0, 20, 0, 0); + gridClone->addWidget(cloneplot2D, 0, 0); + } + + // main window widgets + mainLayout->addWidget(cloneBox, 1, 0); + setCentralWidget(centralWidget); + + // Save + connect(actionSave, SIGNAL(triggered()), this, SLOT(SavePlot())); + + setMinimumHeight(300); + resize(500, 350); +} - //style of plot - if(lines) k->setStyle(QwtPlotCurve::Lines); - else k->setStyle(QwtPlotCurve::Dots); -#if QWT_VERSION<0x060000 - if(markers) k->setSymbol(*marker); - else k->setSymbol(*nomarker); +void qCloneWidget::SetCloneHists(int nHists, int histNBins, double *histXAxis, double *histYAxis[], std::string histTitle[], bool lines, bool markers) { + //for each plot, create hists + for (int hist_num = 0; hist_num < nHists; ++hist_num) { + SlsQtH1D *k; + if (hist_num + 1 > cloneplot1D_hists.size()) { + cloneplot1D_hists.append(k = new SlsQtH1D("1d plot", histNBins, histXAxis, histYAxis[hist_num])); + k->SetLineColor(0); + } else { + k = cloneplot1D_hists.at(hist_num); + k->SetData(histNBins, histXAxis, histYAxis[hist_num]); + } + + //style of plot + if (lines) + k->setStyle(QwtPlotCurve::Lines); + else + k->setStyle(QwtPlotCurve::Dots); +#if QWT_VERSION < 0x060000 + if (markers) + k->setSymbol(*marker); + else + k->setSymbol(*nomarker); #else - if(markers) k->setSymbol(marker); - else k->setSymbol(nomarker); + if (markers) + k->setSymbol(marker); + else + k->setSymbol(nomarker); #endif - //set title and attach plot - lblHistTitle->setText(QString(histTitle[0].c_str())); + //set title and attach plot + lblHistTitle->setText(QString(histTitle[0].c_str())); - k->Attach(cloneplot1D); - } - -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qCloneWidget::SetCloneHists(int nHists,int histNBins,double* histXAxis,double* histYAxis,string histTitle[],bool lines,bool markers){ - // for each plot create hists - for(int hist_num=0;hist_numcloneplot1D_hists.size()){ - cloneplot1D_hists.append(k=new SlsQtH1D("1d plot",histNBins,histXAxis,histYAxis)); - k->SetLineColor(hist_num+1); - }else{ - k=cloneplot1D_hists.at(hist_num); - k->SetData(histNBins,histXAxis,histYAxis); - } - //style of plot - if(lines) k->setStyle(QwtPlotCurve::Lines); - else k->setStyle(QwtPlotCurve::Dots); - if(markers) { - QwtSymbol *marker = new QwtSymbol(); - marker->setStyle(QwtSymbol::Cross); - marker->setSize(5,5); -#if QWT_VERSION<0x060000 - k->setSymbol(*marker); -#else - k->setSymbol(marker); -#endif - }else { - QwtSymbol *noMarker = new QwtSymbol(); -#if QWT_VERSION<0x060000 - k->setSymbol(*noMarker); -#else - k->setSymbol(noMarker); -#endif - } - //set title and attach plot - lblHistTitle->setText(QString(histTitle[0].c_str())); - k->Attach(cloneplot1D); - } -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qCloneWidget::SetCloneHists2D(int nbinsx,double xmin,double xmax,int nbinsy, double ymin, double ymax, double *d){ - cloneplot2D->GetPlot()->SetData(nbinsx,xmin,xmax,nbinsy,ymin,ymax,d); - cloneplot2D->UpdateNKeepSetRangeIfSet(); -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - - -void qCloneWidget::SetRange(bool IsXYRange[],double XYRangeValues[]){ - double XYCloneRangeValues[4]; - - if(!IsXYRange[qDefs::XMINIMUM]){ - if(cloneplot1D) XYCloneRangeValues[qDefs::XMINIMUM]= cloneplot1D->GetXMinimum(); - else XYCloneRangeValues[qDefs::XMINIMUM]= cloneplot2D->GetPlot()->GetXMinimum(); - }else XYCloneRangeValues[qDefs::XMINIMUM]= XYRangeValues[qDefs::XMINIMUM]; - - if(!IsXYRange[qDefs::XMAXIMUM]){ - if(cloneplot1D) XYCloneRangeValues[qDefs::XMAXIMUM]= cloneplot1D->GetXMaximum(); - else XYCloneRangeValues[qDefs::XMINIMUM]= cloneplot2D->GetPlot()->GetXMaximum(); - }else XYCloneRangeValues[qDefs::XMAXIMUM]= XYRangeValues[qDefs::XMAXIMUM]; - - if(!IsXYRange[qDefs::YMINIMUM]){ - if(cloneplot1D) XYCloneRangeValues[qDefs::YMINIMUM]= cloneplot1D->GetYMinimum(); - else XYCloneRangeValues[qDefs::XMINIMUM]= cloneplot2D->GetPlot()->GetYMinimum(); - }else XYCloneRangeValues[qDefs::YMINIMUM]= XYRangeValues[qDefs::YMINIMUM]; - - if(!IsXYRange[qDefs::YMAXIMUM]){ - if(cloneplot1D) XYCloneRangeValues[qDefs::YMAXIMUM]= cloneplot1D->GetYMaximum(); - else XYCloneRangeValues[qDefs::XMINIMUM]= cloneplot2D->GetPlot()->GetYMaximum(); - }else XYCloneRangeValues[qDefs::YMAXIMUM]= XYRangeValues[qDefs::YMAXIMUM]; - - if(cloneplot1D){ - cloneplot1D->SetXMinMax(XYCloneRangeValues[qDefs::XMINIMUM],XYCloneRangeValues[qDefs::XMAXIMUM]); - cloneplot1D->SetYMinMax(XYCloneRangeValues[qDefs::YMINIMUM],XYCloneRangeValues[qDefs::YMAXIMUM]); - }else{ - cloneplot2D->GetPlot()->SetXMinMax(XYRangeValues[qDefs::XMINIMUM],XYRangeValues[qDefs::XMAXIMUM]); - cloneplot2D->GetPlot()->SetYMinMax(XYRangeValues[qDefs::YMINIMUM],XYRangeValues[qDefs::YMAXIMUM]); - cloneplot2D->GetPlot()->Update(); - } -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -char* qCloneWidget::GetCurrentTimeStamp(){ - char output[30]; - char *result; - - //using sys cmds to get output or str - FILE* sysFile = popen("date", "r"); - fgets(output, sizeof(output), sysFile); - pclose(sysFile); - - result = output + 0; - return result; -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - -void qCloneWidget::SavePlot(){ - char cID[10]; - sprintf(cID,"%d",id); - //title - QString fName = QString(filePath.c_str()); - if(cloneBox->title().contains('.')){ - fName.append(QString('/')+cloneBox->title()); - fName.replace(".dat",".png"); - fName.replace(".raw",".png"); - }else fName.append(QString("/Snapshot_unknown_title.png")); - //save - QImage img(cloneBox->size().width(),cloneBox->size().height(),QImage::Format_RGB32); - QPainter painter(&img); - cloneBox->render(&painter); - - fName = QFileDialog::getSaveFileName(this,tr("Save Snapshot "),fName,tr("PNG Files (*.png);;XPM Files(*.xpm);;JPEG Files(*.jpg)"),0,QFileDialog::ShowDirsOnly); - if (!fName.isEmpty()) { - if((img.save(fName))) - qDefs::Message(qDefs::INFORMATION,"The SnapShot has been successfully saved","qCloneWidget::SavePlot"); - else - qDefs::Message(qDefs::WARNING,"Attempt to save snapshot failed.\n" - "Formats: .png, .jpg, .xpm.","qCloneWidget::SavePlot"); + k->Attach(cloneplot1D); } } -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -int qCloneWidget::SavePlotAutomatic(){ - char cID[10]; - sprintf(cID,"%d",id); - //title - QString fName = QString(filePath.c_str()); - if(cloneBox->title().contains('.')){ - fName.append(QString('/')+cloneBox->title()); - fName.replace(".dat",".png"); - fName.replace(".raw",".png"); - }else fName.append(QString("/Snapshot_unknown_title.png")); - cout<<"fname:"<size().width(),cloneBox->size().height(),QImage::Format_RGB32); - QPainter painter(&img); - cloneBox->render(&painter); - if(img.save(fName)) - return 0; - else return -1; - +void qCloneWidget::SetCloneHists(int nHists, int histNBins, double *histXAxis, double *histYAxis, std::string histTitle[], bool lines, bool markers) { + // for each plot create hists + for (int hist_num = 0; hist_num < nHists; ++hist_num) { + SlsQtH1D *k; + if (hist_num + 1 > cloneplot1D_hists.size()) { + cloneplot1D_hists.append(k = new SlsQtH1D("1d plot", histNBins, histXAxis, histYAxis)); + k->SetLineColor(hist_num + 1); + } else { + k = cloneplot1D_hists.at(hist_num); + k->SetData(histNBins, histXAxis, histYAxis); + } + //style of plot + if (lines) + k->setStyle(QwtPlotCurve::Lines); + else + k->setStyle(QwtPlotCurve::Dots); + if (markers) { + QwtSymbol *marker = new QwtSymbol(); + marker->setStyle(QwtSymbol::Cross); + marker->setSize(5, 5); +#if QWT_VERSION < 0x060000 + k->setSymbol(*marker); +#else + k->setSymbol(marker); +#endif + } else { + QwtSymbol *noMarker = new QwtSymbol(); +#if QWT_VERSION < 0x060000 + k->setSymbol(*noMarker); +#else + k->setSymbol(noMarker); +#endif + } + //set title and attach plot + lblHistTitle->setText(QString(histTitle[0].c_str())); + k->Attach(cloneplot1D); + } } -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qCloneWidget::closeEvent(QCloseEvent* event){ - emit CloneClosedSignal(id); - event->accept(); +void qCloneWidget::SetCloneHists2D(int nbinsx, double xmin, double xmax, int nbinsy, double ymin, double ymax, double *d) { + cloneplot2D->GetPlot()->SetData(nbinsx, xmin, xmax, nbinsy, ymin, ymax, d); + cloneplot2D->UpdateNKeepSetRangeIfSet(); } -//------------------------------------------------------------------------------------------------------------------------------------------------- +void qCloneWidget::SetRange(bool IsXYRange[], double XYRangeValues[]) { + double XYCloneRangeValues[4]; + if (!IsXYRange[qDefs::XMINIMUM]) { + if (cloneplot1D) + XYCloneRangeValues[qDefs::XMINIMUM] = cloneplot1D->GetXMinimum(); + else + XYCloneRangeValues[qDefs::XMINIMUM] = cloneplot2D->GetPlot()->GetXMinimum(); + } else + XYCloneRangeValues[qDefs::XMINIMUM] = XYRangeValues[qDefs::XMINIMUM]; -void qCloneWidget::DisplayStats(bool enable, QString min, QString max, QString sum){ - if(enable){ - QWidget *widgetStatistics = new QWidget(this); - widgetStatistics->setFixedHeight(15); - QHBoxLayout *hl1 = new QHBoxLayout; - hl1->setSpacing(0); - hl1->setContentsMargins(0, 0, 0, 0); - QLabel *lblMin = new QLabel("Min: "); - lblMin->setFixedWidth(40); - lblMin->setAlignment(Qt::AlignRight); - QLabel *lblMax = new QLabel("Max: "); - lblMax->setFixedWidth(40); - lblMax->setAlignment(Qt::AlignRight); - QLabel *lblSum = new QLabel("Sum: "); - lblSum->setFixedWidth(40); - lblSum->setAlignment(Qt::AlignRight); - QLabel *lblMinDisp = new QLabel(min); - lblMinDisp->setAlignment(Qt::AlignLeft); - QLabel *lblMaxDisp = new QLabel(max); - lblMaxDisp->setAlignment(Qt::AlignLeft); - QLabel *lblSumDisp = new QLabel(sum); - lblSumDisp->setAlignment(Qt::AlignLeft); - hl1->addItem(new QSpacerItem(20,20,QSizePolicy::Fixed,QSizePolicy::Fixed)); - hl1->addWidget(lblMin); - hl1->addWidget(lblMinDisp); - hl1->addItem(new QSpacerItem(20,20,QSizePolicy::Expanding,QSizePolicy::Fixed)); - hl1->addWidget(lblMax); - hl1->addWidget(lblMaxDisp); - hl1->addItem(new QSpacerItem(20,20,QSizePolicy::Expanding,QSizePolicy::Fixed)); - hl1->addWidget(lblSum); - hl1->addWidget(lblSumDisp); - hl1->addItem(new QSpacerItem(20,20,QSizePolicy::Fixed,QSizePolicy::Fixed)); - widgetStatistics->setLayout(hl1); - mainLayout->addWidget(widgetStatistics,2,0); - widgetStatistics->show(); + if (!IsXYRange[qDefs::XMAXIMUM]) { + if (cloneplot1D) + XYCloneRangeValues[qDefs::XMAXIMUM] = cloneplot1D->GetXMaximum(); + else + XYCloneRangeValues[qDefs::XMAXIMUM] = cloneplot2D->GetPlot()->GetXMaximum(); + } else + XYCloneRangeValues[qDefs::XMAXIMUM] = XYRangeValues[qDefs::XMAXIMUM]; - } + if (!IsXYRange[qDefs::YMINIMUM]) { + if (cloneplot1D) + XYCloneRangeValues[qDefs::YMINIMUM] = cloneplot1D->GetYMinimum(); + else + XYCloneRangeValues[qDefs::YMINIMUM] = cloneplot2D->GetPlot()->GetYMinimum(); + } else + XYCloneRangeValues[qDefs::YMINIMUM] = XYRangeValues[qDefs::YMINIMUM]; + + if (!IsXYRange[qDefs::YMAXIMUM]) { + if (cloneplot1D) + XYCloneRangeValues[qDefs::YMAXIMUM] = cloneplot1D->GetYMaximum(); + else + XYCloneRangeValues[qDefs::YMAXIMUM] = cloneplot2D->GetPlot()->GetYMaximum(); + } else + XYCloneRangeValues[qDefs::YMAXIMUM] = XYRangeValues[qDefs::YMAXIMUM]; + + if (cloneplot1D) { + cloneplot1D->SetXMinMax(XYCloneRangeValues[qDefs::XMINIMUM], XYCloneRangeValues[qDefs::XMAXIMUM]); + cloneplot1D->SetYMinMax(XYCloneRangeValues[qDefs::YMINIMUM], XYCloneRangeValues[qDefs::YMAXIMUM]); + } else { + cloneplot2D->GetPlot()->SetXMinMax(XYRangeValues[qDefs::XMINIMUM], XYRangeValues[qDefs::XMAXIMUM]); + cloneplot2D->GetPlot()->SetYMinMax(XYRangeValues[qDefs::YMINIMUM], XYRangeValues[qDefs::YMAXIMUM]); + cloneplot2D->GetPlot()->Update(); + } } -//------------------------------------------------------------------------------------------------------------------------------------------------- +void qCloneWidget::SavePlot() { + char cID[10]; + sprintf(cID, "%d", id); + //title + QString fName = QString(filePath.c_str()); + if (cloneBox->title().contains('.')) { + fName.append(QString('/') + cloneBox->title()); + fName.replace(".dat", ".png"); + fName.replace(".raw", ".png"); + } else + fName.append(QString("/Snapshot_unknown_title.png")); + //save + QImage img(cloneBox->size().width(), cloneBox->size().height(), QImage::Format_RGB32); + QPainter painter(&img); + cloneBox->render(&painter); + + fName = QFileDialog::getSaveFileName(this, tr("Save Snapshot "), fName, tr("PNG Files (*.png);;XPM Files(*.xpm);;JPEG Files(*.jpg)"), 0, QFileDialog::ShowDirsOnly); + if (!fName.isEmpty()) { + if ((img.save(fName))) { + qDefs::Message(qDefs::INFORMATION, "The SnapShot has been successfully saved", "qCloneWidget::SavePlot"); + FILE_LOG(logINFO) << "The SnapShot has been successfully saved"; + } else { + qDefs::Message(qDefs::WARNING, "Attempt to save snapshot failed.\n" + "Formats: .png, .jpg, .xpm.", + "qCloneWidget::SavePlot"); + FILE_LOG(logWARNING) << "Attempt to save snapshot failed"; + } + } +} +int qCloneWidget::SavePlotAutomatic() { + char cID[10]; + sprintf(cID, "%d", id); + //title + QString fName = QString(filePath.c_str()); + if (cloneBox->title().contains('.')) { + fName.append(QString('/') + cloneBox->title()); + fName.replace(".dat", ".png"); + fName.replace(".raw", ".png"); + } else + fName.append(QString("/Snapshot_unknown_title.png")); + FILE_LOG(logDEBUG) << "fname:" << fName.toAscii().constData(); + //save + QImage img(cloneBox->size().width(), cloneBox->size().height(), QImage::Format_RGB32); + QPainter painter(&img); + cloneBox->render(&painter); + if (img.save(fName)) + return 0; + else + return -1; +} + + +void qCloneWidget::closeEvent(QCloseEvent *event) { + emit CloneClosedSignal(id); + event->accept(); +} + + +char *qCloneWidget::GetCurrentTimeStamp() { + char output[30]; + char *result; + + //using sys cmds to get output or str + FILE *sysFile = popen("date", "r"); + fgets(output, sizeof(output), sysFile); + pclose(sysFile); + + result = output + 0; + return result; +} + + +void qCloneWidget::DisplayStats(bool enable, QString min, QString max, QString sum) { + if (enable) { + QWidget *widgetStatistics = new QWidget(this); + widgetStatistics->setFixedHeight(15); + QHBoxLayout *hl1 = new QHBoxLayout; + hl1->setSpacing(0); + hl1->setContentsMargins(0, 0, 0, 0); + QLabel *lblMin = new QLabel("Min: "); + lblMin->setFixedWidth(40); + lblMin->setAlignment(Qt::AlignRight); + QLabel *lblMax = new QLabel("Max: "); + lblMax->setFixedWidth(40); + lblMax->setAlignment(Qt::AlignRight); + QLabel *lblSum = new QLabel("Sum: "); + lblSum->setFixedWidth(40); + lblSum->setAlignment(Qt::AlignRight); + QLabel *lblMinDisp = new QLabel(min); + lblMinDisp->setAlignment(Qt::AlignLeft); + QLabel *lblMaxDisp = new QLabel(max); + lblMaxDisp->setAlignment(Qt::AlignLeft); + QLabel *lblSumDisp = new QLabel(sum); + lblSumDisp->setAlignment(Qt::AlignLeft); + hl1->addItem(new QSpacerItem(20, 20, QSizePolicy::Fixed, QSizePolicy::Fixed)); + hl1->addWidget(lblMin); + hl1->addWidget(lblMinDisp); + hl1->addItem(new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Fixed)); + hl1->addWidget(lblMax); + hl1->addWidget(lblMaxDisp); + hl1->addItem(new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Fixed)); + hl1->addWidget(lblSum); + hl1->addWidget(lblSumDisp); + hl1->addItem(new QSpacerItem(20, 20, QSizePolicy::Fixed, QSizePolicy::Fixed)); + widgetStatistics->setLayout(hl1); + mainLayout->addWidget(widgetStatistics, 2, 0); + widgetStatistics->show(); + } +} + diff --git a/slsDetectorGui/src/qDetectorMain.cpp b/slsDetectorGui/src/qDetectorMain.cpp old mode 100644 new mode 100755 index 3823b3c9f..debfae231 --- a/slsDetectorGui/src/qDetectorMain.cpp +++ b/slsDetectorGui/src/qDetectorMain.cpp @@ -1,908 +1,758 @@ -/********************************************************************** - * TO DO - * 1. settcpsocket is done with slsdetector.maybe do for all detectors connected: mythen - * ********************************************************************/ -// Qt Project Class Headers #include "qDetectorMain.h" -#include "qTabDataOutput.h" -#include "qTabPlot.h" -#include "qTabActions.h" +#include "qDefs.h" +#include "qServer.h" #include "qTabAdvanced.h" -#include "qTabSettings.h" +#include "qTabDataOutput.h" #include "qTabDebugging.h" #include "qTabDeveloper.h" #include "qTabMessages.h" -#include "qServer.h" -// Project Class Headers -#include "slsDetector.h" +#include "qTabPlot.h" +#include "qTabSettings.h" + #include "multiSlsDetector.h" #include "sls_detector_defs.h" -#include "gitInfoGui.h" -// Qt Include Headers -#include +#include "versionAPI.h" + #include #include -// C++ Include Headers -#include -#include +#include + #include -using namespace std; +#include +#include +#include - -//------------------------------------------------------------------------------------------------------------------------------------------------- - -int main (int argc, char **argv) { - QApplication *theApp = new QApplication(argc, argv); - // QApplication *theApp = new QApplication(argc, argv); - theApp->setStyle(new QPlastiqueStyle);//not default when desktop is windows - theApp->setWindowIcon(QIcon( ":/icons/images/mountain.png" )); - int ret = 1; - qDetectorMain *det=new qDetectorMain(argc, argv, theApp,ret,0); - if (ret == 1) - return EXIT_FAILURE; - det->show(); - //theApp->connect( theApp, SIGNAL(lastWindowClosed()), theApp, SLOT(quit())); - return theApp->exec(); +int main(int argc, char **argv) { + QApplication *theApp = new QApplication(argc, argv); + theApp->setStyle(new QPlastiqueStyle); + theApp->setWindowIcon(QIcon(":/icons/images/mountain.png")); + try { + qDetectorMain *det = new qDetectorMain(argc, argv, theApp, 0); + det->show(); + theApp->exec(); + } catch (const std::exception &e) { + qDefs::Message(qDefs::CRITICAL, + std::string(e.what()) + "\nExiting Gui :'( ", "main"); + } + return 0; } +qDetectorMain::qDetectorMain(int argc, char **argv, QApplication *app, + QWidget *parent) + : QMainWindow(parent), detType(slsDetectorDefs::GENERIC), isDeveloper(0), + heightPlotWindow(0), heightCentralWidget(0) { -//------------------------------------------------------------------------------------------------------------------------------------------------- + // options + std::string fname = ""; + int64_t tempval = 0; + int multiId = 0; + // parse command line for config + static struct option long_options[] = { + // These options set a flag. + //{"verbose", no_argument, &verbose_flag, 1}, + // These options don’t set a flag. We distinguish them by their indices. + {"developer", no_argument, 0, 'd'}, + {"config", required_argument, 0, 'f'}, + {"id", required_argument, 0, 'i'}, + {"version", no_argument, 0, 'v'}, + {"help", no_argument, 0, 'h'}, + {0, 0, 0, 0}}; -qDetectorMain::qDetectorMain(int argc, char **argv, QApplication *app, int& ret, QWidget *parent) : - QMainWindow(parent), theApp(app),myDet(0),detID(0),myPlot(0),tabs(0),isDeveloper(0){ + // getopt_long stores the option index here + optind = 1; + int option_index = 0; + int c = 0; - // options - string fname = ""; - int64_t tempval = 0; + while (c != -1) { + c = getopt_long(argc, argv, "hvdf:i:", long_options, &option_index); + // Detect the end of the options + if (c == -1) + break; + switch (c) { - //parse command line for config - static struct option long_options[] = { - // These options set a flag. - //{"verbose", no_argument, &verbose_flag, 1}, - // These options don’t set a flag. We distinguish them by their indices. - { "developer", no_argument, 0, 'd' }, - { "config", required_argument, 0, 'f' }, - { "id", required_argument, 0, 'i' }, - {"version", no_argument, 0, 'v'}, - { "help", no_argument, 0, 'h' }, - { 0, 0, 0, 0 } - }; + case 'f': + fname = optarg; + FILE_LOG(logDEBUG) + << long_options[option_index].name << " " << optarg; + break; + case 'd': + isDeveloper = 1; + break; - // getopt_long stores the option index here. - int option_index = 0; - int c = 0; + case 'i': + multiId = atoi(optarg); + break; - while ( c != -1 ){ - c = getopt_long (argc, argv, "hvdf:i:", long_options, &option_index); + case 'v': + tempval = APIGUI; + FILE_LOG(logINFO) << "SLS Detector GUI " << GITBRANCH << " (0x" + << std::hex << tempval << ")"; + return; - // Detect the end of the options. - if (c == -1) - break; + case 'h': + default: + std::string help_message = + "\n" + std::string(argv[0]) + "\n" + + "Usage: " + std::string(argv[0]) + " [arguments]\n" + + "Possible arguments are:\n" + + "\t-d, --developer : Enables the developer tab\n" + + "\t-f, --config : Loads config from file\n" + + "\t-i, --id : Sets the multi detector id to " + "i. Default: 0. Required \n" + + "\t only when more than one multi " + "detector object is needed.\n\n"; + FILE_LOG(logERROR) << help_message; + exit(EXIT_FAILURE); + } + } - switch(c){ - - case 'f': - fname=string(optarg); -#ifdef VERYVERBOSE - cout << long_options[option_index].name << " " << optarg << endl; -#endif - break; - - case 'd' : - isDeveloper = 1; - break; - - case 'i' : - detID=atoi(optarg); - break; - - case 'v': - tempval = GITDATE; - cout << "SLS Detector GUI " << GITBRANCH << " (0x" << hex << tempval << ")" << endl; - return; - - case 'h': - default: - string help_message = "\n" - + string(argv[0]) + "\n" - + "Usage: " + string(argv[0]) + " [arguments]\n" - + "Possible arguments are:\n" - + "\t-d, --developer : Enables the developer tab\n" - + "\t-f, --config : Loads config from file\n" - + "\t-i, --id : Sets the multi detector id to i. Default: 0. Required \n" - + "\t only when more than one multi detector object is needed.\n\n"; - cout << help_message << endl; - return; - - } - } - - setupUi(this); - SetUpDetector(fname); - SetUpWidgetWindow(); - Initialization(); - ret = 0; + setupUi(this); + SetUpDetector(fname, multiId); + SetUpWidgetWindow(); + Initialization(); } - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -qDetectorMain::~qDetectorMain(){ - if(myDet) delete myDet; - if (menubar) delete menubar; - if (centralwidget) delete centralwidget; +qDetectorMain::~qDetectorMain() { + if (myDet) + delete myDet; + if (myPlot) + delete myPlot; + if (tabs) + delete tabs; + if (tabMeasurement) + delete tabMeasurement; + if (tabDataOutput) + delete tabDataOutput; + if (tabPlot) + delete tabPlot; + if (tabSettings) + delete tabSettings; + if (tabAdvanced) + delete tabAdvanced; + if (tabDebugging) + delete tabDebugging; + if (tabDeveloper) + delete tabDeveloper; + if (tabMessages) + delete tabMessages; + if (myServer) + delete myServer; } +bool qDetectorMain::isPlotRunning() { return myPlot->isRunning(); } -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qDetectorMain::SetUpWidgetWindow(){ - -// Layout - layoutTabs= new QGridLayout; - centralwidget->setLayout(layoutTabs); - -//plot setup - myPlot = new qDrawPlot(dockWidgetPlot,myDet); cout<<"DockPlot ready"<setWidget(myPlot); - -//tabs setup - tabs = new MyTabWidget(this); - layoutTabs->addWidget(tabs); - - -// creating all the other tab widgets - tab_measurement = new qTabMeasurement (this, myDet,myPlot); cout<<"Measurement ready"<setFrameShape(QFrame::NoFrame); - } - // setting the tab widgets to the scrollareas - scroll[Measurement] ->setWidget(tab_measurement); - scroll[DataOutput] ->setWidget(tab_dataoutput); - scroll[Plot] ->setWidget(tab_plot); - scroll[Actions] ->setWidget(tab_actions); - scroll[Settings] ->setWidget(tab_settings); - scroll[Advanced] ->setWidget(tab_advanced); - scroll[Debugging] ->setWidget(tab_debugging); - scroll[Developer] ->setWidget(tab_developer); - // inserting all the tabs - tabs->insertTab(Measurement, scroll[Measurement], "Measurement"); - tabs->insertTab(DataOutput, scroll[DataOutput], "Data Output"); - tabs->insertTab(Plot, scroll[Plot], "Plot"); - tabs->insertTab(Actions, scroll[Actions], "Actions"); - tabs->insertTab(Settings, scroll[Settings], "Settings"); - tabs->insertTab(Advanced, scroll[Advanced], "Advanced"); - tabs->insertTab(Debugging, scroll[Debugging], "Debugging"); - tabs->insertTab(Developer, scroll[Developer], "Developer"); - //no scroll buttons this way - tabs->insertTab(Messages, tab_messages, "Messages"); - -//swap tabs so that messages is last tab - tabs->tabBar()->moveTab(tabs->indexOf(tab_measurement), Measurement); - tabs->tabBar()->moveTab(tabs->indexOf(tab_settings), Settings); - tabs->tabBar()->moveTab(tabs->indexOf(tab_dataoutput), DataOutput); - tabs->tabBar()->moveTab(tabs->indexOf(tab_plot), Plot); - tabs->tabBar()->moveTab(tabs->indexOf(tab_actions), Actions); - tabs->tabBar()->moveTab(tabs->indexOf(tab_advanced), Advanced); - tabs->tabBar()->moveTab(tabs->indexOf(tab_debugging), Debugging); - tabs->tabBar()->moveTab(tabs->indexOf(tab_developer), Developer); - tabs->tabBar()->moveTab(tabs->indexOf(tab_messages), Messages); - tabs->setCurrentIndex(Measurement); - -//other tab properties - // Default tab color - defaultTabColor = tabs->tabBar()->tabTextColor(DataOutput); - //Set the current tab(measurement) to blue as it is the current one - tabs->tabBar()->setTabTextColor(0,QColor(0,0,200,255)); - // increase the width so it uses all the empty space for the tab titles - tabs->tabBar()->setFixedWidth(width()+61); - - // mode setup - to set up the tabs initially as disabled, not in form so done here -#ifdef VERBOSE - cout << "Setting Debug Mode to 0\nSetting Expert Mode to 0\nSetting Developer Mode to " << isDeveloper << "\nSetting Dockable Mode to false\n" << endl; -#endif - tabs->setTabEnabled(Debugging,false); - tabs->setTabEnabled(Advanced,false); - tabs->setTabEnabled(Developer,isDeveloper); - actionLoadTrimbits->setVisible(false); - actionSaveTrimbits->setVisible(false); - actionLoadCalibration->setVisible(false); - actionSaveCalibration->setVisible(false); - - dockWidgetPlot->setFloating(false); - dockWidgetPlot->setFeatures(QDockWidget::NoDockWidgetFeatures); - -// Other setup - //Height of plot and central widget - heightPlotWindow = dockWidgetPlot->size().height(); - heightCentralWidget = centralwidget->size().height(); - // Default zoom Tool Tip - zoomToolTip = dockWidgetPlot->toolTip(); - +int qDetectorMain::GetProgress() { return tabMeasurement->GetProgress(); } +int qDetectorMain::DoesOutputDirExist() { + return tabDataOutput->VerifyOutputDirectory(); } +void qDetectorMain::SetUpWidgetWindow() { -//------------------------------------------------------------------------------------------------------------------------------------------------- + // Layout + QGridLayout *layoutTabs = new QGridLayout; + centralwidget->setLayout(layoutTabs); + // plot setup + myPlot = new qDrawPlot(dockWidgetPlot, myDet); + FILE_LOG(logDEBUG) << "DockPlot ready"; + dockWidgetPlot->setWidget(myPlot); -void qDetectorMain::SetUpDetector(const string fName){ + // tabs setup + tabs = new MyTabWidget(this); + layoutTabs->addWidget(tabs); + // creating all the other tab widgets + tabMeasurement = new qTabMeasurement(this, myDet, myPlot); + tabDataOutput = new qTabDataOutput(this, myDet); + tabPlot = new qTabPlot(this, myDet, myPlot); + tabSettings = new qTabSettings(this, myDet); + tabAdvanced = new qTabAdvanced(this, myDet); + tabDebugging = new qTabDebugging(this, myDet); + tabDeveloper = new qTabDeveloper(this, myDet); + myServer = new qServer(this); - //instantiate detector and set window title - myDet = new multiSlsDetector(detID); + // creating the scroll area widgets for the tabs + QScrollArea *scroll[NumberOfTabs]; + for (int i = 0; i < NumberOfTabs; ++i) { + scroll[i] = new QScrollArea; + scroll[i]->setFrameShape(QFrame::NoFrame); + } + // setting the tab widgets to the scrollareas + scroll[MEASUREMENT]->setWidget(tabMeasurement); + scroll[DATAOUTPUT]->setWidget(tabDataOutput); + scroll[PLOT]->setWidget(tabPlot); + scroll[SETTINGS]->setWidget(tabSettings); + scroll[ADVANCED]->setWidget(tabAdvanced); + scroll[DEBUGGING]->setWidget(tabDebugging); + scroll[DEVELOPER]->setWidget(tabDeveloper); + // inserting all the tabs + tabs->insertTab(MEASUREMENT, scroll[MEASUREMENT], "Measurement"); + tabs->insertTab(DATAOUTPUT, scroll[DATAOUTPUT], "Data Output"); + tabs->insertTab(PLOT, scroll[PLOT], "Plot"); + tabs->insertTab(SETTINGS, scroll[SETTINGS], "Settings"); + tabs->insertTab(ADVANCED, scroll[ADVANCED], "Advanced"); + tabs->insertTab(DEBUGGING, scroll[DEBUGGING], "Debugging"); + tabs->insertTab(DEVELOPER, scroll[DEVELOPER], "Developer"); + // no scroll buttons this way + tabs->insertTab(MESSAGES, tabMessages, "Messages"); - //create messages tab to capture config file loading logs - tab_messages = new qTabMessages (this); cout<<"Messages ready"<tabBar()->moveTab(tabs->indexOf(tabMeasurement), MEASUREMENT); + tabs->tabBar()->moveTab(tabs->indexOf(tabSettings), SETTINGS); + tabs->tabBar()->moveTab(tabs->indexOf(tabDataOutput), DATAOUTPUT); + tabs->tabBar()->moveTab(tabs->indexOf(tabPlot), PLOT); + tabs->tabBar()->moveTab(tabs->indexOf(tabAdvanced), ADVANCED); + tabs->tabBar()->moveTab(tabs->indexOf(tabDebugging), DEBUGGING); + tabs->tabBar()->moveTab(tabs->indexOf(tabDeveloper), DEVELOPER); + tabs->tabBar()->moveTab(tabs->indexOf(tabMessages), MESSAGES); + tabs->setCurrentIndex(MEASUREMENT); - //loads the config file at startup - if(!fName.empty()) LoadConfigFile(fName); + // other tab properties + // Default tab color + defaultTabColor = tabs->tabBar()->tabTextColor(DATAOUTPUT); + // Set the current tab(measurement) to blue as it is the current one + tabs->tabBar()->setTabTextColor(0, QColor(0, 0, 200, 255)); + // increase the width so it uses all the empty space for the tab titles + tabs->tabBar()->setFixedWidth(width() + 61); - //gets the hostname if it worked - string host = myDet->getHostname(); - qDefs::checkErrorMessage(myDet,"qDetectorMain::SetUpDetector"); + // mode setup - to set up the tabs initially as disabled, not in form so + // done here + FILE_LOG(logINFO) + << "Dockable Mode: 0, Debug Mode: 0, Expert Mode: 0, Developer Mode: " + << isDeveloper; + tabs->setTabEnabled(DEBUGGING, false); + tabs->setTabEnabled(ADVANCED, false); + tabs->setTabEnabled(DEVELOPER, isDeveloper); + actionLoadTrimbits->setVisible(false); + actionSaveTrimbits->setVisible(false); - //if hostname doesnt exist even in shared memory - if(!host.length()){ - cout << endl << "No Detector Connected." << endl; - qDefs::Message(qDefs::CRITICAL,"No Detectors Connected. ","qDetectorMain::SetUpDetector"); - exit(-1); - } + dockWidgetPlot->setFloating(false); + dockWidgetPlot->setFeatures(QDockWidget::NoDockWidgetFeatures); - //check if the detector is not even connected - string offline = myDet->checkOnline(); - qDefs::checkErrorMessage(myDet,"qDetectorMain::SetUpDetector"); - - if(!offline.empty()){ - qDefs::Message(qDefs::CRITICAL,string("The detector(s) ")+offline+string(" is/are not connected. Exiting GUI."),"qDetectorMain::SetUpDetector"); - cout << "The detector(s) " << host << " is/are not connected. Exiting GUI." << endl; - exit(-1); - } - - // Check if type valid. If not, exit - slsDetectorDefs::detectorType detType = myDet->getDetectorsType(); - qDefs::checkErrorMessage(myDet,"qDetectorMain::SetUpDetector"); - - switch(detType){ - case slsDetectorDefs::MYTHEN: break; - case slsDetectorDefs::EIGER: break; - case slsDetectorDefs::GOTTHARD: - case slsDetectorDefs::AGIPD: - case slsDetectorDefs::PROPIX: - case slsDetectorDefs::MOENCH: - case slsDetectorDefs::JUNGFRAU: - case slsDetectorDefs::CHIPTESTBOARD: - actionLoadTrimbits->setText("Load Settings"); actionSaveTrimbits->setText("Save Settings"); - break; - default: - string detName = myDet->slsDetectorDefs::getDetectorType(detType); - qDefs::checkErrorMessage(myDet,"qDetectorMain::SetUpDetector"); - cout << "ERROR: " + host + " has unknown detector type \"" + detName + "\". Exiting GUI." << endl; - string errorMess = host+string(" has unknown detector type \"")+ - detName+string("\". Exiting GUI."); - qDefs::Message(qDefs::CRITICAL,errorMess,"qDetectorMain::SetUpDetector"); - exit(-1); - } - setWindowTitle("SLS Detector GUI : "+ - QString(slsDetectorDefs::getDetectorType(detType).c_str())+ " - "+QString(host.c_str())); -//#ifdef VERBOSE - cout << endl << "Type : " << slsDetectorDefs::getDetectorType(detType) << "\nDetector : " << host << endl; -//#endif - myDet->setOnline(slsDetectorDefs::ONLINE_FLAG); - if(detType != slsDetectorDefs::MYTHEN) - myDet->setReceiverOnline(slsDetectorDefs::ONLINE_FLAG); - qDefs::checkErrorMessage(myDet,"qDetectorMain::SetUpDetector"); + // Other setup + // Height of plot and central widget + heightPlotWindow = dockWidgetPlot->size().height(); + heightCentralWidget = centralwidget->size().height(); + // Default zoom Tool Tip + zoomToolTip = dockWidgetPlot->toolTip(); } +void qDetectorMain::SetUpDetector(const std::string fName, int multiID) { -//------------------------------------------------------------------------------------------------------------------------------------------------- + // instantiate detector and set window title + myDet = new multiSlsDetector(multiID); + // create messages tab to capture config file loading logs + tabMessages = new qTabMessages(this); -void qDetectorMain::Initialization(){ -// Dockable Plot - connect(dockWidgetPlot, SIGNAL(topLevelChanged(bool)), this,SLOT(ResizeMainWindow(bool))); -// tabs - connect(tabs, SIGNAL(currentChanged(int)), this, SLOT(Refresh(int)));//( QWidget*))); - // Measurement tab - connect(tab_measurement, SIGNAL(StartSignal()), this,SLOT(EnableTabs())); - connect(tab_measurement, SIGNAL(StopSignal()), myPlot,SLOT(StopAcquisition())); - connect(tab_measurement, SIGNAL(CheckPlotIntervalSignal()), tab_plot,SLOT(SetFrequency())); - // Data Output Tab - connect(tab_dataoutput, SIGNAL(AngularConversionSignal(bool)), tab_actions,SLOT(EnablePositions(bool))); - //enable scanbox( for angles) - connect(tab_dataoutput, SIGNAL(AngularConversionSignal(bool)), tab_plot,SLOT(EnableScanBox())); - // Plot tab - connect(tab_plot, SIGNAL(DisableZoomSignal(bool)), this,SLOT(SetZoomToolTip(bool))); - // Actions tab (only for scan) - connect(tab_actions, SIGNAL(EnableScanBox()), tab_plot,SLOT(EnableScanBox())); - //settings to advanced tab(int is always 0 to only refresh) - connect(tab_settings, SIGNAL(UpdateTrimbitSignal(int)), tab_advanced,SLOT(UpdateTrimbitPlot(int))); -// Plotting - // When the acquisition is finished, must update the meas tab - connect(myPlot, SIGNAL(UpdatingPlotFinished()), this, SLOT(EnableTabs())); - connect(myPlot, SIGNAL(UpdatingPlotFinished()), tab_measurement, SLOT(UpdateFinished())); - //This should not be called as it will change file name to measurement when run finished - //connect(myPlot, SIGNAL(UpdatingPlotFinished()), tab_plot, SLOT(Refresh())); - connect(myPlot, SIGNAL(SetCurrentMeasurementSignal(int)), tab_measurement, SLOT(SetCurrentMeasurement(int))); + // loads the config file at startup + if (!fName.empty()) + LoadConfigFile(fName); + // validate detector type (for GUI) and update menu + detType = myDet->getDetectorTypeAsEnum(); + switch (detType) { + case slsDetectorDefs::EIGER: + break; + case slsDetectorDefs::GOTTHARD: + case slsDetectorDefs::JUNGFRAU: + actionLoadTrimbits->setText("Load Settings"); + actionSaveTrimbits->setText("Save Settings"); + case slsDetectorDefs::MOENCH: + actionLoadTrimbits->setEnabled(false); + actionSaveTrimbits->setEnabled(false); + break; + default: + std::string errorMess = + myDet->getHostname() + std::string(" has ") + + myDet->getDetectorTypeAsString() + std::string(" detector type (") + + std::to_string(detType) + std::string("). Exiting GUI."); + throw sls::RuntimeError(errorMess.c_str()); + } -// menubar - // Modes Menu - connect(menuModes, SIGNAL(triggered(QAction*)), this,SLOT(EnableModes(QAction*))); - // Utilities Menu - connect(menuUtilities, SIGNAL(triggered(QAction*)), this,SLOT(ExecuteUtilities(QAction*))); - // Help Menu - connect(menuHelp, SIGNAL(triggered(QAction*)), this,SLOT(ExecuteHelp(QAction*))); + std::string title = + "SLS Detector GUI : " + myDet->getDetectorTypeAsString() + " - " + + myDet->getHostname(); + // Plotting + // When the acquisition is finished, must update the meas tab + connect(myPlot, SIGNAL(UpdatingPlotFinished()), this, SLOT(EnableTabs())); + connect(myPlot, SIGNAL(UpdatingPlotFinished()), tabMeasurement, + SLOT(UpdateFinished())); + connect(myPlot, SIGNAL(SetCurrentMeasurementSignal(int)), tabMeasurement, + SLOT(SetCurrentMeasurement(int))); + // menubar + // Modes Menu + connect(menuModes, SIGNAL(triggered(QAction *)), this, + SLOT(EnableModes(QAction *))); + // Utilities Menu + connect(menuUtilities, SIGNAL(triggered(QAction *)), this, + SLOT(ExecuteUtilities(QAction *))); + // Help Menu + connect(menuHelp, SIGNAL(triggered(QAction *)), this, + SLOT(ExecuteHelp(QAction *))); -//server - connect(myServer, SIGNAL(ServerStoppedSignal()), this,SLOT(UncheckServer())); + // server + connect(myServer, SIGNAL(ServerStoppedSignal()), this, + SLOT(UncheckServer())); } +void qDetectorMain::LoadConfigFile(const std::string fName) { + FILE_LOG(logINFO) << "Loading config file at start up:" << fName; -//------------------------------------------------------------------------------------------------------------------------------------------------- + struct stat st_buf; + QString file = QString(fName.c_str()); - -void qDetectorMain::LoadConfigFile(const string fName){ -#ifdef VERBOSE - cout << "Loading config file at start up:" << fName << endl; -#endif - struct stat st_buf; - QString file = QString(fName.c_str()); - - //path doesnt exist - if(stat(fName.c_str(),&st_buf)) - qDefs::Message(qDefs::WARNING,string("Start up configuration failed to load. The following file does not exist:
")+fName,"qDetectorMain::LoadConfigFile"); - - //not a file - else if (!S_ISREG (st_buf.st_mode)) - qDefs::Message(qDefs::WARNING,string("Start up configuration failed to load. The following file is not a recognized file format:
")+fName,"qDetectorMain::LoadConfigFile"); - - else{ - //could not load config file - if(myDet->readConfigurationFile(fName)==slsDetectorDefs::FAIL) - qDefs::Message(qDefs::WARNING,string("Could not load all the Configuration Parameters from file:
")+fName,"qDetectorMain::LoadConfigFile"); - //successful - else - qDefs::Message(qDefs::INFORMATION,"
The Configuration Parameters have been loaded successfully at start up.","qDetectorMain::LoadConfigFile"); - - qDefs::checkErrorMessage(myDet,"qDetectorMain::LoadConfigFile"); - } + // path doesnt exist + if (stat(fName.c_str(), &st_buf)) { + qDefs::Message( + qDefs::WARNING, + std::string("Start up configuration failed to load. The " + "following file does not exist:
") + + fName, + "qDetectorMain::LoadConfigFile"); + FILE_LOG(logWARNING) << "Config file does not exist"; + } + // not a file + else if (!S_ISREG(st_buf.st_mode)) { + qDefs::Message( + qDefs::WARNING, + std::string( + "Start up configuration failed to load. The following " + "file is not a recognized file format:
") + + fName, + "qDetectorMain::LoadConfigFile"); + FILE_LOG(logWARNING) << "File not recognized"; + } else { + qDefs::IgnoreNonCriticalExceptions(myDet, "qDetectorMain::LoadConfigFile", + &multiSlsDetector::readConfigurationFile, fName); + } } +void qDetectorMain::EnableModes(QAction *action) { + bool enable; + // listen to gui client + if (action == actionListenGuiClient) { + disconnect(menuModes, SIGNAL(triggered(QAction *)), this, + SLOT(EnableModes(QAction *))); + if (actionListenGuiClient->isChecked()) + myServer->CreateServers(); + else + myServer->DestroyServers(); + connect(menuModes, SIGNAL(triggered(QAction *)), this, + SLOT(EnableModes(QAction *))); + } + // Set DebugMode + else if (action == actionDebug) { + enable = actionDebug->isChecked(); + tabs->setTabEnabled(DEBUGGING, enable); + FILE_LOG(logINFO) << "Debug Mode: " + << slsDetectorDefs::stringEnable(enable); -//------------------------------------------------------------------------------------------------------------------------------------------------- + } + // Set ExpertMode(comes here only if its a digital detector) + else if (action == actionExpert) { + enable = actionExpert->isChecked(); -void qDetectorMain::EnableModes(QAction *action){ - bool enable; + tabs->setTabEnabled(ADVANCED, enable); + // moench don't have settings + if (detType != slsDetectorDefs::MOENCH) { + actionLoadTrimbits->setVisible(enable); + actionSaveTrimbits->setVisible(enable); + } + FILE_LOG(logINFO) << "Expert Mode: " + << slsDetectorDefs::stringEnable(enable); + } - //listen to gui client - if(action==actionListenGuiClient){ - - myServer->StartStopServer(actionListenGuiClient->isChecked()); - - //disconnect(menuModes, SIGNAL(triggered(QAction*)), this,SLOT(EnableModes(QAction*))); - //actionListenGuiClient->setChecked(myServer->StartStopServer(actionListenGuiClient->isChecked())); - //connect(menuModes, SIGNAL(triggered(QAction*)), this,SLOT(EnableModes(QAction*))); - } - //Set DebugMode - else if(action==actionDebug){ - enable = actionDebug->isChecked(); - tabs->setTabEnabled(Debugging,enable); -#ifdef VERBOSE - cout << "Setting Debug Mode to " << enable << endl; -#endif - } - - //Set ExpertMode(comes here only if its a digital detector) - else if(action==actionExpert){ - enable = actionExpert->isChecked(); - - tabs->setTabEnabled(Advanced,enable); - actionLoadTrimbits->setVisible(enable); - actionSaveTrimbits->setVisible(enable); - actionLoadCalibration->setVisible(enable); - actionSaveCalibration->setVisible(enable); - tab_measurement->SetExpertMode(enable); - tab_settings->SetExpertMode(enable); -#ifdef VERBOSE - cout << "Setting Expert Mode to " << enable << endl; -#endif - } - - //Set DockableMode - else{ - enable = actionDockable->isChecked(); - if(enable) - dockWidgetPlot->setFeatures(QDockWidget::DockWidgetFloatable); - else{ - dockWidgetPlot->setFloating(false); - dockWidgetPlot->setFeatures(QDockWidget::NoDockWidgetFeatures); - } -#ifdef VERBOSE - cout << "Setting Dockable Mode to " << enable << endl; -#endif - } + // Set DockableMode + else { + enable = actionDockable->isChecked(); + if (enable) { + dockWidgetPlot->setFeatures(QDockWidget::DockWidgetFloatable); + } else { + dockWidgetPlot->setFloating(false); + dockWidgetPlot->setFeatures(QDockWidget::NoDockWidgetFeatures); + } + FILE_LOG(logINFO) << "Dockable Mode: " + << slsDetectorDefs::stringEnable(enable); + } } +void qDetectorMain::ExecuteUtilities(QAction *action) { + bool refreshTabs = false; + try { + if (action == actionOpenSetup) { + FILE_LOG(logDEBUG) << "Loading Setup"; + QString fName = QString(myDet->getFilePath().c_str()); + fName = QFileDialog::getOpenFileName( + this, tr("Load Detector Setup"), fName, + tr("Detector Setup files (*.det);;All Files(*)")); + // Gets called when cancelled as well + if (!fName.isEmpty()) { + refreshTabs = true; + myDet->retrieveDetectorSetup( + std::string(fName.toAscii().constData())); + qDefs::Message( + qDefs::INFORMATION, + "The Setup Parameters have been loaded successfully.", + "qDetectorMain::ExecuteUtilities"); + FILE_LOG(logINFO) << "Setup Parameters loaded successfully"; + } + } -//------------------------------------------------------------------------------------------------------------------------------------------------- + else if (action == actionSaveSetup) { + FILE_LOG(logDEBUG) << "Saving Setup"; + QString fName = QString(myDet->getFilePath().c_str()); + fName = QFileDialog::getSaveFileName( + this, tr("Save Current Detector Setup"), fName, + tr("Detector Setup files (*.det);;All Files(*) ")); + // Gets called when cancelled as well + if (!fName.isEmpty()) { + myDet->dumpDetectorSetup( + std::string(fName.toAscii().constData())); + qDefs::Message( + qDefs::INFORMATION, + "The Setup Parameters have been saved successfully.", + "qDetectorMain::ExecuteUtilities"); + FILE_LOG(logINFO) << "Setup Parameters saved successfully"; + } + } + else if (action == actionOpenConfiguration) { + FILE_LOG(logDEBUG) << "Loading Configuration"; + QString fName = QString(myDet->getFilePath().c_str()); + fName = QFileDialog::getOpenFileName( + this, tr("Load Detector Configuration"), fName, + tr("Configuration files (*.config);;All Files(*)")); + // Gets called when cancelled as well + if (!fName.isEmpty()) { + refreshTabs = true; + myDet->readConfigurationFile( + std::string(fName.toAscii().constData())); + qDefs::Message(qDefs::INFORMATION, + "The Configuration Parameters have been " + "configured successfully.", + "qDetectorMain::ExecuteUtilities"); + FILE_LOG(logINFO) + << "Configuration Parameters loaded successfully"; + } + } -void qDetectorMain::ExecuteUtilities(QAction *action){ - bool refreshTabs = false; - if(action==actionOpenSetup){ -#ifdef VERBOSE - cout << "Loading Setup" << endl; -#endif - QString fName = QString(myDet->getFilePath().c_str()); - qDefs::checkErrorMessage(myDet,"qDetectorMain::ExecuteUtilities"); - fName = QFileDialog::getOpenFileName(this, - tr("Load Detector Setup"),fName, - tr("Detector Setup files (*.det);;All Files(*)")); - // Gets called when cancelled as well - if (!fName.isEmpty()){ - if(myDet->retrieveDetectorSetup(string(fName.toAscii().constData()))!=slsDetectorDefs::FAIL){ - qDefs::Message(qDefs::INFORMATION,"The Setup Parameters have been loaded successfully.","qDetectorMain::ExecuteUtilities"); - refreshTabs=true; - }else qDefs::Message(qDefs::WARNING,string("Could not load the Setup Parameters from file:\n")+fName.toAscii().constData(),"qDetectorMain::ExecuteUtilities"); - qDefs::checkErrorMessage(myDet,"qDetectorMain::ExecuteUtilities"); - } - } - else if(action==actionSaveSetup){ -#ifdef VERBOSE - cout << "Saving Setup" << endl; -#endif - QString fName = QString(myDet->getFilePath().c_str()); - qDefs::checkErrorMessage(myDet,"qDetectorMain::ExecuteUtilities"); - fName = QFileDialog::getSaveFileName(this, - tr("Save Current Detector Setup"),fName, - tr("Detector Setup files (*.det);;All Files(*) ")); - // Gets called when cancelled as well - if (!fName.isEmpty()){ - if(myDet->dumpDetectorSetup(string(fName.toAscii().constData()))!=slsDetectorDefs::FAIL) - qDefs::Message(qDefs::INFORMATION,"The Setup Parameters have been saved successfully.","qDetectorMain::ExecuteUtilities"); - else qDefs::Message(qDefs::WARNING,string("Could not save the Setup Parameters from file:\n")+fName.toAscii().constData(),"qDetectorMain::ExecuteUtilities"); - qDefs::checkErrorMessage(myDet,"qDetectorMain::ExecuteUtilities"); - } - } - else if(action==actionOpenConfiguration){ -#ifdef VERBOSE - cout << "Loading Configuration" << endl; -#endif - QString fName = QString(myDet->getFilePath().c_str()); - qDefs::checkErrorMessage(myDet,"qDetectorMain::ExecuteUtilities"); - fName = QFileDialog::getOpenFileName(this, - tr("Load Detector Configuration"),fName, - tr("Configuration files (*.config);;All Files(*)")); - // Gets called when cancelled as well - if (!fName.isEmpty()){ - if(myDet->readConfigurationFile(string(fName.toAscii().constData()))!=slsDetectorDefs::FAIL){ - qDefs::Message(qDefs::INFORMATION,"The Configuration Parameters have been configured successfully.","qDetectorMain::ExecuteUtilities"); - refreshTabs=true; - }else qDefs::Message(qDefs::WARNING,string("Could not load all the Configuration Parameters from file:\n")+fName.toAscii().constData(),"qDetectorMain::ExecuteUtilities"); - qDefs::checkErrorMessage(myDet,"qDetectorMain::ExecuteUtilities"); - } - } - else if(action==actionSaveConfiguration){ -#ifdef VERBOSE - cout << "Saving Configuration" << endl; -#endif - QString fName = QString(myDet->getFilePath().c_str()); - qDefs::checkErrorMessage(myDet,"qDetectorMain::ExecuteUtilities"); - fName = QFileDialog::getSaveFileName(this, - tr("Save Current Detector Configuration"),fName, - tr("Configuration files (*.config) ;;All Files(*)")); - // Gets called when cancelled as well - if (!fName.isEmpty()){ - if(myDet->writeConfigurationFile(string(fName.toAscii().constData()))!=slsDetectorDefs::FAIL) - qDefs::Message(qDefs::INFORMATION,"The Configuration Parameters have been saved successfully.","qDetectorMain::ExecuteUtilities"); - else qDefs::Message(qDefs::WARNING,string("Could not save the Configuration Parameters from file:\n")+fName.toAscii().constData(),"qDetectorMain::ExecuteUtilities"); - qDefs::checkErrorMessage(myDet,"qDetectorMain::ExecuteUtilities"); - } - } - else if(action==actionLoadTrimbits){ - QString fName = QString( (myDet->getSettingsDir()).c_str()); - qDefs::checkErrorMessage(myDet,"qDetectorMain::ExecuteUtilities"); - //gotthard - if(actionLoadTrimbits->text().contains("Settings")){ -#ifdef VERBOSE - cout << "Loading Settings" << endl; -#endif - fName = QFileDialog::getOpenFileName(this, - tr("Load Detector Settings"),fName, - tr("Settings files (*.settings settings.sn*);;All Files(*)")); - // Gets called when cancelled as well - if (!fName.isEmpty()){ - if(myDet->loadSettingsFile(string(fName.toAscii().constData()),-1)!=slsDetectorDefs::FAIL) - qDefs::Message(qDefs::INFORMATION,"The Settings have been loaded successfully.","qDetectorMain::ExecuteUtilities"); - else qDefs::Message(qDefs::WARNING,string("Could not load the Settings from file:\n")+fName.toAscii().constData(),"qDetectorMain::ExecuteUtilities"); - qDefs::checkErrorMessage(myDet,"qDetectorMain::ExecuteUtilities"); - } + else if (action == actionSaveConfiguration) { + FILE_LOG(logDEBUG) << "Saving Configuration"; + QString fName = QString(myDet->getFilePath().c_str()); + fName = QFileDialog::getSaveFileName( + this, tr("Save Current Detector Configuration"), fName, + tr("Configuration files (*.config) ;;All Files(*)")); + // Gets called when cancelled as well + if (!fName.isEmpty()) { + myDet->writeConfigurationFile( + std::string(fName.toAscii().constData())); + qDefs::Message(qDefs::INFORMATION, + "The Configuration Parameters have been saved " + "successfully.", + "qDetectorMain::ExecuteUtilities"); + FILE_LOG(logINFO) + << "Configuration Parameters saved successfully"; + } + } - }//mythen and eiger - else{ -#ifdef VERBOSE - cout << "Loading Trimbits" << endl; -#endif - //so that even nonexisting files can be selected - QFileDialog *fileDialog = new QFileDialog(this, - tr("Load Detector Trimbits"),fName, - tr("Trimbit files (*.trim noise.sn*);;All Files(*)")); - fileDialog->setFileMode(QFileDialog::AnyFile ); - if ( fileDialog->exec() == QDialog::Accepted ) - fName = fileDialog->selectedFiles()[0]; + else if (action == actionLoadTrimbits) { + QString fName = QString((myDet->getSettingsDir()).c_str()); + // gotthard + if (actionLoadTrimbits->text().contains("Settings")) { + FILE_LOG(logDEBUG) << "Loading Settings"; + fName = QFileDialog::getOpenFileName( + this, tr("Load Detector Settings"), fName, + tr("Settings files (*.settings settings.sn*);;All " + "Files(*)")); + // Gets called when cancelled as well + if (!fName.isEmpty()) { + myDet->loadSettingsFile( + std::string(fName.toAscii().constData()), -1); + qDefs::Message( + qDefs::INFORMATION, + "The Settings have been loaded successfully.", + "qDetectorMain::ExecuteUtilities"); + FILE_LOG(logINFO) << "Settings loaded successfully"; + } - // Gets called when cancelled as well - if (!fName.isEmpty()){ - if(myDet->loadSettingsFile(string(fName.toAscii().constData()),-1)!=slsDetectorDefs::FAIL) - qDefs::Message(qDefs::INFORMATION,"The Trimbits have been loaded successfully.","qDetectorMain::ExecuteUtilities"); - else qDefs::Message(qDefs::WARNING,string("Could not load the Trimbits from file:\n")+fName.toAscii().constData(),"qDetectorMain::ExecuteUtilities"); - qDefs::checkErrorMessage(myDet,"qDetectorMain::ExecuteUtilities"); - } - } - } - else if(action==actionSaveTrimbits){ - //gotthard - if(actionLoadTrimbits->text().contains("Settings")){ -#ifdef VERBOSE - cout << "Saving Settings" << endl; -#endif - //different output directory so as not to overwrite - QString fName = QString( (myDet->getSettingsDir()).c_str() ); - qDefs::checkErrorMessage(myDet,"qDetectorMain::ExecuteUtilities"); - fName = QFileDialog::getSaveFileName(this, - tr("Save Current Detector Settings"),fName, - tr("Settings files (*.settings settings.sn*);;All Files(*) ")); - // Gets called when cancelled as well - if (!fName.isEmpty()){ - if(myDet->saveSettingsFile(string(fName.toAscii().constData()),-1)!=slsDetectorDefs::FAIL) - qDefs::Message(qDefs::INFORMATION,"The Settings have been saved successfully.","qDetectorMain::ExecuteUtilities"); - else qDefs::Message(qDefs::WARNING,string("Could not save the Settings to file:\n")+fName.toAscii().constData(),"qDetectorMain::ExecuteUtilities"); - qDefs::checkErrorMessage(myDet,"qDetectorMain::ExecuteUtilities"); - } - }//mythen and eiger - else{ -#ifdef VERBOSE - cout << "Saving Trimbits" << endl; -#endif//different output directory so as not to overwrite - QString fName = QString( (myDet->getSettingsDir()).c_str() ); - qDefs::checkErrorMessage(myDet,"qDetectorMain::ExecuteUtilities"); - fName = QFileDialog::getSaveFileName(this, - tr("Save Current Detector Trimbits"),fName, - tr("Trimbit files (*.trim noise.sn*) ;;All Files(*)")); - // Gets called when cancelled as well - if (!fName.isEmpty()){ - if(myDet->saveSettingsFile(string(fName.toAscii().constData()),-1)!=slsDetectorDefs::FAIL) - qDefs::Message(qDefs::INFORMATION,"The Trimbits have been saved successfully.","qDetectorMain::ExecuteUtilities"); - else qDefs::Message(qDefs::WARNING,string("Could not save the Trimbits to file:\n")+fName.toAscii().constData(),"qDetectorMain::ExecuteUtilities"); - qDefs::checkErrorMessage(myDet,"qDetectorMain::ExecuteUtilities"); - } - } - } - else if(action==actionLoadCalibration){ -#ifdef VERBOSE - cout << "Loading Calibration Data" << endl; -#endif - QString fName = QString( (myDet->getCalDir()).c_str() ); - qDefs::checkErrorMessage(myDet); + } // mythen and eiger + else { + FILE_LOG(logDEBUG) << "Loading Trimbits"; + // so that even nonexisting files can be selected + QFileDialog *fileDialog = new QFileDialog( + this, tr("Load Detector Trimbits"), fName, + tr("Trimbit files (*.trim noise.sn*);;All Files(*)")); + fileDialog->setFileMode(QFileDialog::AnyFile); + if (fileDialog->exec() == QDialog::Accepted) + fName = fileDialog->selectedFiles()[0]; - //so that even nonexisting files can be selected - QFileDialog *fileDialog = new QFileDialog(this, - tr("Load Detector Calibration Data"),fName, - tr("Calibration files (*.cal calibration.sn*);;All Files(*)")); - fileDialog->setFileMode(QFileDialog::AnyFile ); - if ( fileDialog->exec() == QDialog::Accepted ) - fName = fileDialog->selectedFiles()[0]; + // Gets called when cancelled as well + if (!fName.isEmpty()) { + myDet->loadSettingsFile( + std::string(fName.toAscii().constData()), -1); + qDefs::Message( + qDefs::INFORMATION, + "The Trimbits have been loaded successfully.", + "qDetectorMain::ExecuteUtilities"); + FILE_LOG(logINFO) << "Trimbits loaded successfully"; + } + } + } - // Gets called when cancelled as well - if (!fName.isEmpty()){ - if(myDet->loadCalibrationFile(string(fName.toAscii().constData()),-1)!=slsDetectorDefs::FAIL) - qDefs::Message(qDefs::INFORMATION,"The Calibration Data have been loaded successfully.","qDetectorMain::ExecuteUtilities"); - else qDefs::Message(qDefs::WARNING,string("Could not load the Calibration data from file:\n")+ fName.toAscii().constData(),"qDetectorMain::ExecuteUtilities"); - qDefs::checkErrorMessage(myDet,"qDetectorMain::ExecuteUtilities"); - } - } - else if(action==actionSaveCalibration){ -#ifdef VERBOSE - cout << "Saving Calibration Data" << endl; -#endif//different output directory so as not to overwrite - QString fName = QString( (myDet->getCalDir()).c_str() ); - qDefs::checkErrorMessage(myDet); - fName = QFileDialog::getSaveFileName(this, - tr("Save Current Detector Calibration Data"),fName, - tr("Calibration files (*.cal calibration.sn*);;All Files(*) ")); - // Gets called when cancelled as well - if (!fName.isEmpty()){ - if(myDet->saveCalibrationFile(string(fName.toAscii().constData()),-1)!=slsDetectorDefs::FAIL) - qDefs::Message(qDefs::INFORMATION,"The Calibration Data have been saved successfully.","qDetectorMain::ExecuteUtilities"); - else qDefs::Message(qDefs::WARNING,string("Could not save the Calibration data to file:\n")+fName.toAscii().constData(),"qDetectorMain::ExecuteUtilities"); - qDefs::checkErrorMessage(myDet,"qDetectorMain::ExecuteUtilities"); - } - } + else if (action == actionSaveTrimbits) { + // gotthard + if (actionLoadTrimbits->text().contains("Settings")) { + FILE_LOG(logDEBUG) << "Saving Settings"; + // different output directory so as not to overwrite + QString fName = QString((myDet->getSettingsDir()).c_str()); + fName = QFileDialog::getSaveFileName( + this, tr("Save Current Detector Settings"), fName, + tr("Settings files (*.settings settings.sn*);;All " + "Files(*) ")); + // Gets called when cancelled as well + if (!fName.isEmpty()) { + myDet->saveSettingsFile( + std::string(fName.toAscii().constData()), -1); + qDefs::Message(qDefs::INFORMATION, + "The Settings have been saved successfully.", + "qDetectorMain::ExecuteUtilities"); + FILE_LOG(logINFO) << "Settings saved successfully"; + } + } // mythen and eiger + else { + FILE_LOG(logDEBUG) << "Saving Trimbits"; + // different output directory so as not to overwrite + QString fName = QString((myDet->getSettingsDir()).c_str()); + fName = QFileDialog::getSaveFileName( + this, tr("Save Current Detector Trimbits"), fName, + tr("Trimbit files (*.trim noise.sn*) ;;All Files(*)")); + // Gets called when cancelled as well + if (!fName.isEmpty()) { + myDet->saveSettingsFile( + std::string(fName.toAscii().constData()), -1); + qDefs::Message(qDefs::INFORMATION, + "The Trimbits have been saved successfully.", + "qDetectorMain::ExecuteUtilities"); + FILE_LOG(logINFO) << "Trimbits saved successfully"; + } + } + } + } catch (const sls::NonCriticalError &e) { + qDefs::Message(qDefs::WARNING, e.what(), + "qDetectorMain::ExecuteUtilities"); + } - Refresh(tabs->currentIndex()); - if(refreshTabs){ - tab_actions->Refresh(); - tab_measurement->Refresh(); - tab_settings->Refresh(); - tab_dataoutput->Refresh(); - if(tab_advanced->isEnabled()) tab_advanced->Refresh(); - if(tab_debugging->isEnabled()) tab_debugging->Refresh(); - if(tab_developer->isEnabled()) tab_developer->Refresh(); - - tab_plot->Refresh(); - } + Refresh(tabs->currentIndex()); + if (refreshTabs) { + tabMeasurement->Refresh(); + tabSettings->Refresh(); + tabDataOutput->Refresh(); + if (tabAdvanced->isEnabled()) + tabAdvanced->Refresh(); + if (tabDebugging->isEnabled()) + tabDebugging->Refresh(); + if (tabDeveloper->isEnabled()) + tabDeveloper->Refresh(); + tabPlot->Refresh(); + } } +void qDetectorMain::ExecuteHelp(QAction *action) { + if (action == actionAbout) { + FILE_LOG(logINFO) << "About Common GUI for Eiger, Gotthard, Jungfrau " + "and Moench detectors"; -//------------------------------------------------------------------------------------------------------------------------------------------------- + char version[200]; + long long unsigned int retval = APIGUI; + sprintf(version, "%llx", retval); + std::string thisGUIVersion{version}; + sprintf(version, "%lx", + myDet->getId(slsDetectorDefs::THIS_SOFTWARE_VERSION)); + std::string thisClientVersion{version}; -void qDetectorMain::ExecuteHelp(QAction *action){ - if(action==actionAbout){ -#ifdef VERBOSE - cout << "About: Common GUI for Mythen, Eiger, Gotthard, Jungfrau, Moench and Propix detectors" << endl; -#endif - char version[200]; - long long unsigned int retval= GITDATE; - sprintf(version,"%llx",retval); - string thisGUIVersion = string(version); - - sprintf(version,"%llx",(long long unsigned int)myDet->getId(slsDetectorDefs::THIS_SOFTWARE_VERSION)); - qDefs::checkErrorMessage(myDet,"qDetectorMain::ExecuteHelp"); - string thisClientVersion = string(version); - - //

A heading

- qDefs::Message(qDefs::INFORMATION,"

" - "SLS Detector GUI version:   " + thisGUIVersion+"
" - "SLS Detector Client version: "+thisClientVersion+"

" - "Common GUI to control the SLS Detectors: " - "Mythen, Eiger, Gotthard, Jungfrau, Moench and Propix.

" - "It can be operated in parallel with the command line interface:
" - "sls_detector_put,
sls_detector_get,
sls_detector_acquire and
sls_detector_help.

" - "The GUI Software is still in progress. " - "Please report bugs to dhanya.maliakal@psi.ch or anna.bergamaschi@psi.ch.<\\p>","qDetectorMain::ExecuteHelp"); - } + qDefs::Message(qDefs::INFORMATION, + "

" + "SLS Detector GUI version:   " + + thisGUIVersion + + "
" + "SLS Detector Client version: " + + thisClientVersion + + "

" + "Common GUI to control the SLS Detectors: " + "Eiger, Gotthard, Jungfrau and Moench.

" + "It can be operated in parallel with the command " + "line interface:
" + "sls_detector_put,
sls_detector_get,
sls_" + "detector_acquire and
sls_detector_help.

" + "Please report bugs to:
" + "Dhanya.Thattil@psi.ch,
" + "Erik.Froejdh@psi.ch or
" + "Anna.Bergamaschi@psi.ch.<\\p>", + "qDetectorMain::ExecuteHelp"); + } } +void qDetectorMain::Refresh(int index) { + FILE_LOG(logDEBUG) << "Refresh Main Tab"; -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qDetectorMain::Refresh(int index){ - myDet->setOnline(slsDetectorDefs::ONLINE_FLAG); - myDet->setReceiverOnline(slsDetectorDefs::ONLINE_FLAG); - qDefs::checkErrorMessage(myDet,"qDetectorMain::Refresh"); - if(!tabs->isTabEnabled(index)) - tabs->setCurrentIndex((index++)<(tabs->count()-1)?index:Measurement); - else{ - switch(tabs->currentIndex()){ - case Measurement: tab_measurement->Refresh(); break; - case Settings: tab_settings->Refresh(); break; - case DataOutput: tab_dataoutput->Refresh(); break; - case Plot: tab_plot->Refresh(); break; - case Actions: tab_actions->Refresh(); break; - case Advanced: tab_advanced->Refresh(); break; - case Debugging: tab_debugging->Refresh(); break; - case Developer: tab_developer->Refresh(); break; - case Messages: break; - } - } - for(int i=0;itabBar()->setTabTextColor(i,defaultTabColor); - tabs->tabBar()->setTabTextColor(index,QColor(0,0,200,255)); + if (!tabs->isTabEnabled(index)) + tabs->setCurrentIndex((index++) < (tabs->count() - 1) ? index + : MEASUREMENT); + else { + switch (tabs->currentIndex()) { + case MEASUREMENT: + tabMeasurement->Refresh(); + break; + case SETTINGS: + tabSettings->Refresh(); + break; + case DATAOUTPUT: + tabDataOutput->Refresh(); + break; + case PLOT: + tabPlot->Refresh(); + break; + case ADVANCED: + tabAdvanced->Refresh(); + break; + case DEBUGGING: + tabDebugging->Refresh(); + break; + case DEVELOPER: + tabDeveloper->Refresh(); + break; + case MESSAGES: + break; + } + } + for (int i = 0; i < NumberOfTabs; ++i) + tabs->tabBar()->setTabTextColor(i, defaultTabColor); + tabs->tabBar()->setTabTextColor(index, QColor(0, 0, 200, 255)); } +void qDetectorMain::ResizeMainWindow(bool b) { + FILE_LOG(logDEBUG1) << "Resizing Main Window: height:" << height(); -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qDetectorMain::ResizeMainWindow(bool b){ -#ifdef VERBOSE - cout << "Resizing Main Window: height:" << height() << endl; -#endif - // undocked from the main window - if(b){ - // sets the main window height to a smaller maximum to get rid of space - setMaximumHeight(height()-heightPlotWindow-9); - dockWidgetPlot->setMinimumHeight(0); - cout << "undocking it from main window" << endl; - } - else{ - setMaximumHeight(QWIDGETSIZE_MAX); - // the minimum for plot will be set when the widget gets resized automatically - } + // undocked from the main window + if (b) { + // sets the main window height to a smaller maximum to get rid of space + setMaximumHeight(height() - heightPlotWindow - 9); + dockWidgetPlot->setMinimumHeight(0); + FILE_LOG(logINFO) << "Undocking from main window"; + } else { + setMaximumHeight(QWIDGETSIZE_MAX); + // the minimum for plot will be set when the widget gets resized + // automatically + } } +void qDetectorMain::resizeEvent(QResizeEvent *event) { + if (!dockWidgetPlot->isFloating()) { + dockWidgetPlot->setMinimumHeight(height() - centralwidget->height() - + 50); + centralwidget->setMaximumHeight(heightCentralWidget); + } -//------------------------------------------------------------------------------------------------------------------------------------------------- + // adjusting tab width + if (width() >= 800) { + tabs->tabBar()->setFixedWidth(width() + 61); + } else { + tabs->tabBar()->setMinimumWidth(0); + tabs->tabBar()->setExpanding(true); + tabs->tabBar()->setUsesScrollButtons(true); + } - -void qDetectorMain::resizeEvent(QResizeEvent* event){ - if(!dockWidgetPlot->isFloating()){ - if(tabs->currentIndex()== Actions){ - dockWidgetPlot->setMinimumHeight(heightPlotWindow-100); - centralwidget->setMaximumHeight(QWIDGETSIZE_MAX); - - } - else{ - dockWidgetPlot->setMinimumHeight(height()-centralwidget->height()-50); - centralwidget->setMaximumHeight(heightCentralWidget); - } - } - - //adjusting tab width - if(width()>=800){ tabs->tabBar()->setFixedWidth(width()+61);} - else { tabs->tabBar()->setMinimumWidth(0); - tabs->tabBar()->setExpanding(true); - tabs->tabBar()->setUsesScrollButtons(true); - } - - event->accept(); + event->accept(); } +void qDetectorMain::EnableTabs() { + FILE_LOG(logDEBUG1) << "Entering EnableTabs function"; -//------------------------------------------------------------------------------------------------------------------------------------------------- + bool enable; + enable = !(tabs->isTabEnabled(DATAOUTPUT)); + // or use the Enable/Disable button + // normal tabs + tabs->setTabEnabled(DATAOUTPUT, enable); + tabs->setTabEnabled(SETTINGS, enable); + tabs->setTabEnabled(MESSAGES, enable); -void qDetectorMain::EnableTabs(){ -#ifdef VERBOSE - cout << "Entering EnableTabs function" << endl; -#endif + // actions check + actionOpenSetup->setEnabled(enable); + actionSaveSetup->setEnabled(enable); + actionOpenConfiguration->setEnabled(enable); + actionSaveConfiguration->setEnabled(enable); + actionMeasurementWizard->setEnabled(enable); + actionDebug->setEnabled(enable); + actionExpert->setEnabled(enable); + // special tabs + tabs->setTabEnabled(DEBUGGING, enable && (actionDebug->isChecked())); + tabs->setTabEnabled(DEVELOPER, enable && isDeveloper); + // expert + bool expertTab = enable && (actionExpert->isChecked()); + tabs->setTabEnabled(ADVANCED, expertTab); + actionLoadTrimbits->setVisible(expertTab); + actionSaveTrimbits->setVisible(expertTab); - bool enable; - enable=!(tabs->isTabEnabled(DataOutput)); + // moved to here, so that its all in order, instead of signals and different + // threads + if (!enable) { + // tabMeasurement->Refresh(); too slow to refresh + tabSettings->Refresh(); + tabDataOutput->Refresh(); + if (tabAdvanced->isEnabled()) + tabAdvanced->Refresh(); + if (tabDebugging->isEnabled()) + tabDebugging->Refresh(); + if (tabDeveloper->isEnabled()) + tabDeveloper->Refresh(); + tabPlot->Refresh(); - // or use the Enable/Disable button - // normal tabs - tabs->setTabEnabled(DataOutput,enable); - tabs->setTabEnabled(Actions,enable); - tabs->setTabEnabled(Settings,enable); - tabs->setTabEnabled(Messages,enable); - - //actions check - actionOpenSetup->setEnabled(enable); - actionSaveSetup->setEnabled(enable); - actionOpenConfiguration->setEnabled(enable); - actionSaveConfiguration->setEnabled(enable); - actionMeasurementWizard->setEnabled(enable); - actionDebug->setEnabled(enable); - actionExpert->setEnabled(enable); - - - // special tabs - tabs->setTabEnabled(Debugging,enable && (actionDebug->isChecked())); - tabs->setTabEnabled(Developer,enable && isDeveloper); - //expert - bool expertTab = enable && (actionExpert->isChecked()); - tabs->setTabEnabled(Advanced,expertTab); - actionLoadTrimbits->setVisible(expertTab); - actionSaveTrimbits->setVisible(expertTab); - actionLoadCalibration->setVisible(expertTab); - actionSaveCalibration->setVisible(expertTab); - - - //moved to here, so that its all in order, instead of signals and different threads - if(!enable) { - myDet->setOnline(slsDetectorDefs::ONLINE_FLAG); - myDet->setReceiverOnline(slsDetectorDefs::ONLINE_FLAG); - qDefs::checkErrorMessage(myDet,"qDetectorMain::EnableTabs"); - //refresh all the required tabs - tab_actions->Refresh();// angular, positions, - - //too slow to refresh - /*tab_measurement->Refresh();*/ - - tab_settings->Refresh(); - tab_dataoutput->Refresh(); - if(tab_advanced->isEnabled()) tab_advanced->Refresh(); - if(tab_debugging->isEnabled()) tab_debugging->Refresh(); - if(tab_developer->isEnabled()) tab_developer->Refresh(); - - tab_plot->Refresh(); - - //stop the adc timer in gotthard - if(isDeveloper) - tab_developer->StopADCTimer(); - //set the plot type first(acccss shared memory) - tab_plot->SetScanArgument(); - //sets running to true - myPlot->StartStopDaqToggle(); - } - else{//to enable scan box - tab_plot->Refresh(); - //to start adc timer - if(tab_developer->isEnabled()) - tab_developer->Refresh(); - } + // set the plot type first(acccss shared memory) + tabPlot->SetScanArgument(); + // sets running to true + myPlot->StartStopDaqToggle(); + } else { // to enable scan box + tabPlot->Refresh(); + // to start adc timer + if (tabDeveloper->isEnabled()) + tabDeveloper->Refresh(); + } } - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qDetectorMain::SetZoomToolTip(bool disable){ - if(disable) - dockWidgetPlot->setToolTip("To Enable mouse-controlled zooming capabilities,\ndisable min and max for all axes. "); - else - dockWidgetPlot->setToolTip(zoomToolTip); +void qDetectorMain::SetZoomToolTip(bool disable) { + if (disable) + dockWidgetPlot->setToolTip( + "To Enable mouse-controlled " + "zooming capabilities,\ndisable min and max for all axes. "); + else + dockWidgetPlot->setToolTip(zoomToolTip); } +int qDetectorMain::StartStopAcquisitionFromClient(bool start) { + FILE_LOG(logINFO) << (start ? "Start" : "Stop") + << " Acquisition From Clien"; -//------------------------------------------------------------------------------------------------------------------------------------------------- + if (tabMeasurement->GetStartStatus() != start) { + tabMeasurement->ClickStartStop(); + while (myPlot->GetClientInitiated()) + ; + } - -int qDetectorMain::StartStopAcquisitionFromClient(bool start){ -#ifdef VERBOSE - cout << "Start/Stop Acquisition From Client:" << start << endl; -#endif - - if (tab_measurement->GetStartStatus() != start){ - if(start){ - if(!myPlot->isRunning()){ - //refresh all the required tabs - all these are done in button click anyway - /* tab_actions->Refresh(); - //too slow to refresh - //tab_measurement->Refresh(); - tab_settings->Refresh(); - tab_dataoutput->Refresh(); - if(tab_advanced->isEnabled()) tab_advanced->Refresh(); - if(tab_debugging->isEnabled()) tab_debugging->Refresh(); - if(tab_developer->isEnabled()) tab_developer->Refresh(); - - tab_plot->Refresh();*/ - } - } - //click start/stop - tab_measurement->ClickStartStop(); - while(myPlot->GetClientInitiated()); - } - - return slsDetectorDefs::OK; + return slsDetectorDefs::OK; } - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qDetectorMain::UncheckServer(){ -#ifdef VERBOSE - cout << "Unchecking Mode : Listen to Gui Client" << endl; -#endif - disconnect(menuModes, SIGNAL(triggered(QAction*)), this,SLOT(EnableModes(QAction*))); - actionListenGuiClient->setChecked(false); - connect(menuModes, SIGNAL(triggered(QAction*)), this,SLOT(EnableModes(QAction*))); +void qDetectorMain::UncheckServer() { + actionListenGuiClient->setChecked(false); } - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -bool qDetectorMain::isCurrentlyTabDeveloper(){ - return (tabs->currentIndex()==Developer); -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- diff --git a/slsDetectorGui/src/qDrawPlot.cpp b/slsDetectorGui/src/qDrawPlot.cpp old mode 100644 new mode 100755 index a31712d3c..5ba504819 --- a/slsDetectorGui/src/qDrawPlot.cpp +++ b/slsDetectorGui/src/qDrawPlot.cpp @@ -1,30 +1,24 @@ -/* - * qDrawPlot.cpp - * - * Created on: May 7, 2012 - * Author: Dhanya Maliakal - */ // Qt Project Class Headers #include "qDrawPlot.h" #include "qCloneWidget.h" #include "slsDetector.h" -#include"fileIOStatic.h" + // Project Class Headers -#include "slsDetector.h" #include "multiSlsDetector.h" -#include "postProcessing.h" +#include "slsDetector.h" +// #include "postProcessing.h" // Qt Include Headers +#include #include #include #include -#include //#include "qwt_double_interval.h" #include "qwt_series_data.h" // C++ Include Headers +#include #include -#include #include -using namespace std; +#include @@ -32,392 +26,390 @@ using namespace std; const double qDrawPlot::PLOT_TIMER_MS = DEFAULT_STREAMING_TIMER_IN_MS; -qDrawPlot::qDrawPlot(QWidget *parent,multiSlsDetector*& detector): - QWidget(parent),myDet(detector),plot1D_hists(0){ - SetupWidgetWindow(); - Initialization(); - StartStopDaqToggle(); //as default +qDrawPlot::qDrawPlot(QWidget *parent, multiSlsDetector *detector) : QWidget(parent), myDet(detector), plot1D_hists(0) { + SetupWidgetWindow(); + Initialization(); + StartStopDaqToggle(); //as default } - //------------------------------------------------------------------------------------------------------------------------------------------------- - -qDrawPlot::~qDrawPlot(){ - // Clear plot - Clear1DPlot(); - for(QVector::iterator h = plot1D_hists.begin();h!=plot1D_hists.end();h++) delete *h; - plot1D_hists.clear(); - if(lastImageArray) delete[] lastImageArray; lastImageArray=0; - if(gainImageArray) delete[] gainImageArray; gainImageArray=0; - StartOrStopThread(0); - delete myDet; myDet = 0; - for(int i=0;i::iterator h = plot1D_hists.begin(); h != plot1D_hists.end(); ++h) + delete *h; + plot1D_hists.clear(); + if (lastImageArray) + delete[] lastImageArray; + lastImageArray = 0; + if (gainImageArray) + delete[] gainImageArray; + gainImageArray = 0; + StartOrStopThread(0); + delete myDet; + myDet = 0; + for (int i = 0; i < MAXCloneWindows; ++i) + if (winClone[i]) { + delete winClone[i]; + winClone[i] = NULL; + } } - //------------------------------------------------------------------------------------------------------------------------------------------------- - -void qDrawPlot::SetupWidgetWindow(){ +void qDrawPlot::SetupWidgetWindow() { #ifdef VERBOSE - cout << "Setting up plot variables" << endl; + std::cout << "Setting up plot variables\n"; #endif - // Depending on whether the detector is 1d or 2d - detType = myDet->getDetectorsType(); - switch(detType){ - case slsDetectorDefs::MYTHEN: - case slsDetectorDefs::GOTTHARD: - originally2D = false; - break; - case slsDetectorDefs::EIGER: - case slsDetectorDefs::PROPIX: - case slsDetectorDefs::MOENCH: - case slsDetectorDefs::JUNGFRAU: - case slsDetectorDefs::CHIPTESTBOARD: - originally2D = true; - break; - default: - cout << "ERROR: Detector Type is Generic" << endl; - exit(-1); - } + // Depending on whether the detector is 1d or 2d + detType = myDet->getDetectorTypeAsEnum(); + switch (detType) { + case slsDetectorDefs::GOTTHARD: + originally2D = false; + break; + case slsDetectorDefs::EIGER: + case slsDetectorDefs::MOENCH: + case slsDetectorDefs::JUNGFRAU: + originally2D = true; + break; + default: + std::cout << "ERROR: Detector Type is Generic\n"; + exit(-1); + } + //initialization + data_pause_over = true; -//initialization - data_pause_over = true; + currentMeasurement = 0; + currentFrame = 0; + numFactor = 0; + currentScanDivLevel = 0; + currentScanValue = 0; + number_of_exposures = 0; + number_of_frames = 0; + acquisitionPeriod = 0; + exposureTime = 0; + currentFileIndex = 0; + currentFrameIndex = 0; - currentMeasurement = 0; - currentFrame = 0; - numFactor = 0; - currentScanDivLevel = 0; - currentScanValue = 0; - number_of_exposures = 0; - number_of_frames = 0; - acquisitionPeriod = 0; - exposureTime = 0; - currentFileIndex = 0; - currentFrameIndex = 0; + stop_signal = 0; + pthread_mutex_init(&last_image_complete_mutex, NULL); - stop_signal = 0; - pthread_mutex_init(&last_image_complete_mutex,NULL); + // Default titles- only for the initial picture + imageXAxisTitle = "Pixel"; + imageYAxisTitle = "Pixel"; + imageZAxisTitle = "Intensity"; + histXAxisTitle = "Channel Number"; + histYAxisTitle = "Counts"; + for (int i = 0; i < MAX_1DPLOTS; ++i) { + histTitle[i] = ""; + //char temp_title[2000]; + //sprintf(temp_title,"Frame -%d",i); + //histTitle[i] = temp_title; + } + imageTitle = ""; + plotTitle = ""; + plotTitle_prefix = ""; + plot_in_scope = 0; - // Default titles- only for the initial picture - imageXAxisTitle="Pixel"; - imageYAxisTitle="Pixel"; - imageZAxisTitle="Intensity"; - histXAxisTitle="Channel Number"; - histYAxisTitle="Counts"; - for(int i=0;igetTotalNumberOfChannelsInclGapPixels(slsDetectorDefs::X); + nPixelsY = myDet->getTotalNumberOfChannelsInclGapPixels(slsDetectorDefs::Y); + if (detType == slsDetectorDefs::MOENCH) { + npixelsy_jctb = (myDet->setTimer(slsDetectorDefs::SAMPLES, -1) * 2) / 25; // for moench 03 + nPixelsX = npixelsx_jctb; + nPixelsY = npixelsy_jctb; + } - nPixelsX = myDet->getTotalNumberOfChannelsInclGapPixels(slsDetectorDefs::X); - nPixelsY = myDet->getTotalNumberOfChannelsInclGapPixels(slsDetectorDefs::Y); - if (detType == slsDetectorDefs::CHIPTESTBOARD) { - npixelsy_jctb = (myDet->setTimer(slsDetectorDefs::SAMPLES, -1) * 2)/25;// for moench 03 - nPixelsX = npixelsx_jctb; - nPixelsY = npixelsy_jctb; - } + std::cout << "nPixelsX:" << nPixelsX << '\n'; + std::cout << "nPixelsY:" << nPixelsY << '\n'; - cout<<"nPixelsX:"<setStyle(QwtSymbol::Cross); + marker->setSize(5, 5); + noMarker = new QwtSymbol(); - //marker - lines = true; - markers = false; - marker = new QwtSymbol(); - marker->setStyle(QwtSymbol::Cross); - marker->setSize(5,5); - noMarker = new QwtSymbol(); + //for save automatically, + saveAll = false; + saveError = false; + lastSavedFrame = -1; + lastSavedMeasurement = -1; - //for save automatically, - saveAll = false; - saveError = false; - lastSavedFrame = -1; - lastSavedMeasurement = -1; + // This is so that it initially stop and plots + running = 1; - // This is so that it initially stop and plots - running = 1; + XYRangeChanged = false; + XYRangeValues[0] = 0; + XYRangeValues[1] = 0; + XYRangeValues[2] = 0; + XYRangeValues[3] = 0; + IsXYRange[0] = false; + IsXYRange[1] = false; + IsXYRange[2] = false; + IsXYRange[3] = false; - XYRangeChanged = false; - XYRangeValues[0] = 0; - XYRangeValues[1] = 0; - XYRangeValues[2] = 0; - XYRangeValues[3] = 0; - IsXYRange[0] = false; - IsXYRange[1] = false; - IsXYRange[2] = false; - IsXYRange[3] = false; + timerValue = PLOT_TIMER_MS; + frameFactor = 0; + isFrameEnabled = false; + isTriggerEnabled = false; - timerValue = PLOT_TIMER_MS; - frameFactor=0; - isFrameEnabled = false; - isTriggerEnabled = false; + scanArgument = qDefs::None; + histogramArgument = qDefs::Intensity; + anglePlot = false; + alreadyDisplayed = false; - scanArgument = qDefs::None; - histogramArgument = qDefs::Intensity; - anglePlot = false; - alreadyDisplayed = false; + //filepath and file name + filePath = QString(myDet->getFilePath().c_str()); + fileName = QString(myDet->getFileName().c_str()); - //filepath and file name - filePath = QString(myDet->getFilePath().c_str()); - fileName = QString(myDet->getFileName().c_str()); + backwardScanPlot = false; + fileSaveEnable = myDet->enableWriteToFile(); - backwardScanPlot = false; - fileSaveEnable= myDet->enableWriteToFile(); + //pedestal + pedestal = false; + pedestalVals = 0; + tempPedestalVals = 0; + pedestalCount = 0; + startPedestalCal = false; - //pedestal - pedestal = false; - pedestalVals = 0; - tempPedestalVals = 0; - pedestalCount = 0; - startPedestalCal = false; + //accumulate + accumulate = false; + resetAccumulate = false; - //accumulate - accumulate = false; - resetAccumulate = false; + clientInitiated = false; - clientInitiated = false; + //binary plot output + binary = false; + binaryFrom = 0; + binaryTo = 0; - //binary plot output - binary = false; - binaryFrom = 0; - binaryTo = 0; - - //histogram - histogram = false; - histFrom = 0; - histTo = 0; - histSize = 0; - /* + //histogram + histogram = false; + histFrom = 0; + histTo = 0; + histSize = 0; + /* grid = new QwtPlotGrid; grid->enableXMin(true); grid->enableYMin(true); grid->setMajPen(QPen(Qt::black, 0, Qt::DotLine)); grid->setMinPen(QPen(Qt::gray, 0 , Qt::DotLine)); */ - plotHistogram = new QwtPlotHistogram(); - plotHistogram->setStyle(QwtPlotHistogram::Columns);//Options:Outline,Columns, Lines + plotHistogram = new QwtPlotHistogram(); + plotHistogram->setStyle(QwtPlotHistogram::Columns); //Options:Outline,Columns, Lines + plotRequired = false; - plotRequired = false; + //widget related initialization -//widget related initialization + // clone + for (int i = 0; i < MAXCloneWindows; ++i) + winClone[i] = 0; - // clone - for(int i=0;isetLayout(layout); - // Setting up window - setFont(QFont("Sans Serif",9)); - layout = new QGridLayout; - this->setLayout(layout); + histFrameIndexTitle = new QLabel(""); + histFrameIndexTitle->setFixedHeight(10); + boxPlot = new QGroupBox(""); + layout->addWidget(boxPlot, 1, 0); + boxPlot->setAlignment(Qt::AlignHCenter); + boxPlot->setFont(QFont("Sans Serif", 11, QFont::Normal)); + boxPlot->setTitle("Sample Plot"); + data_pause_timer = new QTimer(this); + connect(data_pause_timer, SIGNAL(timeout()), this, SLOT(UpdatePause())); - histFrameIndexTitle = new QLabel(""); - histFrameIndexTitle->setFixedHeight(10); - boxPlot = new QGroupBox(""); - layout->addWidget(boxPlot,1,0); - boxPlot->setAlignment(Qt::AlignHCenter); - boxPlot->setFont(QFont("Sans Serif",11,QFont::Normal)); - boxPlot->setTitle("Sample Plot"); - data_pause_timer = new QTimer(this); - connect(data_pause_timer, SIGNAL(timeout()), this, SLOT(UpdatePause())); + //display statistics + displayStatistics = false; + widgetStatistics = new QWidget(this); + widgetStatistics->setFixedHeight(15); + QHBoxLayout *hl1 = new QHBoxLayout; + hl1->setSpacing(0); + hl1->setContentsMargins(0, 0, 0, 0); + QLabel *lblMin = new QLabel("Min: "); + lblMin->setFixedWidth(40); + lblMin->setAlignment(Qt::AlignRight); + QLabel *lblMax = new QLabel("Max: "); + lblMax->setFixedWidth(40); + lblMax->setAlignment(Qt::AlignRight); + QLabel *lblSum = new QLabel("Sum: "); + lblSum->setFixedWidth(40); + lblSum->setAlignment(Qt::AlignRight); + lblMinDisp = new QLabel("-"); + lblMinDisp->setAlignment(Qt::AlignLeft); + lblMaxDisp = new QLabel("-"); + lblMaxDisp->setAlignment(Qt::AlignLeft); + lblSumDisp = new QLabel("-"); + lblSumDisp->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed); + lblSumDisp->setAlignment(Qt::AlignLeft); + hl1->addItem(new QSpacerItem(20, 20, QSizePolicy::Fixed, QSizePolicy::Fixed)); + hl1->addWidget(lblMin); + hl1->addWidget(lblMinDisp); + hl1->addItem(new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Fixed)); + hl1->addWidget(lblMax); + hl1->addWidget(lblMaxDisp); + hl1->addItem(new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Fixed)); + hl1->addWidget(lblSum); + hl1->addWidget(lblSumDisp); + hl1->addItem(new QSpacerItem(20, 20, QSizePolicy::Fixed, QSizePolicy::Fixed)); + widgetStatistics->setLayout(hl1); + layout->addWidget(widgetStatistics, 2, 0); + widgetStatistics->hide(); + // setting default plot titles and settings + plot1D = new SlsQt1DPlot(boxPlot); - //display statistics - displayStatistics = false; - widgetStatistics = new QWidget(this); - widgetStatistics->setFixedHeight(15); - QHBoxLayout *hl1 = new QHBoxLayout; - hl1->setSpacing(0); - hl1->setContentsMargins(0, 0, 0, 0); - QLabel *lblMin = new QLabel("Min: "); - lblMin->setFixedWidth(40); - lblMin->setAlignment(Qt::AlignRight); - QLabel *lblMax = new QLabel("Max: "); - lblMax->setFixedWidth(40); - lblMax->setAlignment(Qt::AlignRight); - QLabel *lblSum = new QLabel("Sum: "); - lblSum->setFixedWidth(40); - lblSum->setAlignment(Qt::AlignRight); - lblMinDisp = new QLabel("-"); - lblMinDisp->setAlignment(Qt::AlignLeft); - lblMaxDisp = new QLabel("-"); - lblMaxDisp->setAlignment(Qt::AlignLeft); - lblSumDisp = new QLabel("-"); - lblSumDisp->setSizePolicy(QSizePolicy::Preferred,QSizePolicy::Fixed); - lblSumDisp->setAlignment(Qt::AlignLeft); - hl1->addItem(new QSpacerItem(20,20,QSizePolicy::Fixed,QSizePolicy::Fixed)); - hl1->addWidget(lblMin); - hl1->addWidget(lblMinDisp); - hl1->addItem(new QSpacerItem(20,20,QSizePolicy::Expanding,QSizePolicy::Fixed)); - hl1->addWidget(lblMax); - hl1->addWidget(lblMaxDisp); - hl1->addItem(new QSpacerItem(20,20,QSizePolicy::Expanding,QSizePolicy::Fixed)); - hl1->addWidget(lblSum); - hl1->addWidget(lblSumDisp); - hl1->addItem(new QSpacerItem(20,20,QSizePolicy::Fixed,QSizePolicy::Fixed)); - widgetStatistics->setLayout(hl1); - layout->addWidget(widgetStatistics,2,0); - widgetStatistics->hide(); + plot1D->setFont(QFont("Sans Serif", 9, QFont::Normal)); + plot1D->SetXTitle(histXAxisTitle.toAscii().constData()); + plot1D->SetYTitle(histYAxisTitle.toAscii().constData()); + plot1D->hide(); + SlsQtH1D *h; + histNBins = nPixelsX; + nHists = 1; + if (histXAxis) + delete[] histXAxis; + histXAxis = new double[nPixelsX]; + if (histYAxis[0]) + delete[] histYAxis[0]; + histYAxis[0] = new double[nPixelsX]; + for (unsigned int px = 0; px < nPixelsX; ++px) { + histXAxis[px] = px; + histYAxis[0][px] = 0; + } + Clear1DPlot(); + plot1D->SetXTitle("X Axis"); + plot1D->SetYTitle("Y Axis"); + plot1D_hists.append(h = new SlsQtH1D("", histNBins, histXAxis, histYAxis[0])); + h->SetLineColor(0); + SetStyle(h); + h->Attach(plot1D); + Clear1DPlot(); - // setting default plot titles and settings - plot1D = new SlsQt1DPlot(boxPlot); + plot2D = new SlsQt2DPlotLayout(boxPlot); + //default plot + lastImageArray = new double[nPixelsY * nPixelsX]; + for (unsigned int px = 0; px < nPixelsX; ++px) + for (unsigned int py = 0; py < nPixelsY; ++py) + lastImageArray[py * nPixelsX + px] = sqrt(pow(0 + 1, 2) * pow(double(px) - nPixelsX / 2, 2) / pow(nPixelsX / 2, 2) / pow(1 + 1, 2) + pow(double(py) - nPixelsY / 2, 2) / pow(nPixelsY / 2, 2)) / sqrt(2); + plot2D->setFont(QFont("Sans Serif", 9, QFont::Normal)); + plot2D->GetPlot()->SetData(nPixelsX, -0.5, nPixelsX - 0.5, nPixelsY, startPixel, endPixel, lastImageArray); + plot2D->setTitle(GetImageTitle()); + plot2D->SetXTitle(imageXAxisTitle); + plot2D->SetYTitle(imageYAxisTitle); + plot2D->SetZTitle(imageZAxisTitle); + plot2D->setAlignment(Qt::AlignLeft); + boxPlot->setFlat(true); + boxPlot->setContentsMargins(0, 15, 0, 0); - plot1D->setFont(QFont("Sans Serif",9,QFont::Normal)); - plot1D->SetXTitle(histXAxisTitle.toAscii().constData()); - plot1D->SetYTitle(histYAxisTitle.toAscii().constData()); - plot1D->hide(); + plotLayout = new QGridLayout(boxPlot); + plotLayout->setContentsMargins(0, 0, 0, 0); + plotLayout->addWidget(plot1D, 0, 0, 4, 4); + plotLayout->addWidget(plot2D, 0, 0, 4, 4); - SlsQtH1D* h; - histNBins = nPixelsX; - nHists = 1; - if(histXAxis) delete [] histXAxis; histXAxis = new double [nPixelsX]; - if(histYAxis[0]) delete [] histYAxis[0];histYAxis[0] = new double [nPixelsX]; - for(unsigned int px=0;pxSetXTitle("X Axis"); - plot1D->SetYTitle("Y Axis"); - plot1D_hists.append(h=new SlsQtH1D("",histNBins,histXAxis,histYAxis[0])); - h->SetLineColor(0); - SetStyle(h); - h->Attach(plot1D); - Clear1DPlot(); + //gainplot + gainplot2D = new SlsQt2DPlotLayout(boxPlot); + gainImageArray = new double[nPixelsY * nPixelsX]; + for (unsigned int px = 0; px < nPixelsX; ++px) + for (unsigned int py = 0; py < nPixelsY; ++py) + gainImageArray[py * nPixelsX + px] = sqrt(pow(0 + 1, 2) * pow(double(px) - nPixelsX / 2, 2) / pow(nPixelsX / 2, 2) / pow(1 + 1, 2) + pow(double(py) - nPixelsY / 2, 2) / pow(nPixelsY / 2, 2)) / sqrt(2); + gainplot2D->setFont(QFont("Sans Serif", 9, QFont::Normal)); + gainplot2D->GetPlot()->SetData(nPixelsX, -0.5, nPixelsX - 0.5, nPixelsY, startPixel, endPixel, gainImageArray); + gainplot2D->setTitle(GetImageTitle()); + gainplot2D->setAlignment(Qt::AlignLeft); + gainplot2D->GetPlot()->enableAxis(0, false); + gainplot2D->GetPlot()->enableAxis(1, false); + gainplot2D->GetPlot()->enableAxis(2, false); + plotLayout->addWidget(gainplot2D, 0, 4, 1, 1); + gainplot2D->hide(); + gainPlotEnable = false; + gainDataEnable = false; - plot2D = new SlsQt2DPlotLayout(boxPlot); - //default plot - lastImageArray = new double[nPixelsY*nPixelsX]; - for(unsigned int px=0;pxsetFont(QFont("Sans Serif",9,QFont::Normal)); - plot2D->GetPlot()->SetData(nPixelsX,-0.5,nPixelsX-0.5,nPixelsY,startPixel,endPixel,lastImageArray); - plot2D->setTitle(GetImageTitle()); - plot2D->SetXTitle(imageXAxisTitle); - plot2D->SetYTitle(imageYAxisTitle); - plot2D->SetZTitle(imageZAxisTitle); - plot2D->setAlignment(Qt::AlignLeft); - boxPlot->setFlat(true); - boxPlot->setContentsMargins(0,15,0,0); + // callbacks + // Setting the callback function to get data from detector class + myDet->registerDataCallback(&(GetDataCallBack), this); // also enables data streaming in client and receiver (if receiver exists) + //Setting the callback function to alert when acquisition finished from detector class + myDet->registerAcquisitionFinishedCallback(&(GetAcquisitionFinishedCallBack), this); + //Setting the callback function to alert when each measurement finished from detector class + myDet->registerMeasurementFinishedCallback(&(GetMeasurementFinishedCallBack), this); + //Setting the callback function to get progress from detector class(using receivers) + myDet->registerProgressCallback(&(GetProgressCallBack), this); - plotLayout = new QGridLayout(boxPlot); - plotLayout->setContentsMargins(0,0,0,0); - plotLayout->addWidget(plot1D,0,0,4,4); - plotLayout->addWidget(plot2D,0,0,4,4); - - - //gainplot - gainplot2D = new SlsQt2DPlotLayout(boxPlot); - gainImageArray = new double[nPixelsY*nPixelsX]; - for(unsigned int px=0;pxsetFont(QFont("Sans Serif",9,QFont::Normal)); - gainplot2D->GetPlot()->SetData(nPixelsX,-0.5,nPixelsX-0.5,nPixelsY,startPixel,endPixel,gainImageArray); - gainplot2D->setTitle(GetImageTitle()); - gainplot2D->setAlignment(Qt::AlignLeft); - gainplot2D->GetPlot()->enableAxis(0,false); - gainplot2D->GetPlot()->enableAxis(1,false); - gainplot2D->GetPlot()->enableAxis(2,false); - plotLayout->addWidget(gainplot2D,0,4,1,1); - gainplot2D->hide(); - gainPlotEnable = false; - gainDataEnable = false; - - - - // callbacks - // Setting the callback function to get data from detector class - myDet->registerDataCallback(&(GetDataCallBack),this); // also enables data streaming in client and receiver (if receiver exists) - //Setting the callback function to alert when acquisition finished from detector class - myDet->registerAcquisitionFinishedCallback(&(GetAcquisitionFinishedCallBack),this); - //Setting the callback function to alert when each measurement finished from detector class - myDet->registerMeasurementFinishedCallback(&(GetMeasurementFinishedCallBack),this); - //Setting the callback function to get progress from detector class(using receivers) - myDet->registerProgressCallback(&(GetProgressCallBack),this); - - qDefs::checkErrorMessage(myDet,"qDrawPlot::SetupWidgetWindow"); + qDefs::checkErrorMessage(myDet, "qDrawPlot::SetupWidgetWindow"); } - //------------------------------------------------------------------------------------------------------------------------------------------------- +void qDrawPlot::Initialization() { + connect(this, SIGNAL(UpdatePlotSignal()), this, SLOT(UpdatePlot())); + connect(this, SIGNAL(InterpolateSignal(bool)), plot2D, SIGNAL(InterpolateSignal(bool))); + connect(this, SIGNAL(ContourSignal(bool)), plot2D, SIGNAL(ContourSignal(bool))); + connect(this, SIGNAL(LogzSignal(bool)), plot2D, SLOT(SetZScaleToLog(bool))); + connect(this, SIGNAL(LogySignal(bool)), plot1D, SLOT(SetLogY(bool))); + connect(this, SIGNAL(ResetZMinZMaxSignal(bool, bool, double, double)), plot2D, SLOT(ResetZMinZMax(bool, bool, double, double))); -void qDrawPlot::Initialization(){ - connect(this, SIGNAL(UpdatePlotSignal()), this, SLOT(UpdatePlot())); - connect(this, SIGNAL(InterpolateSignal(bool)),plot2D, SIGNAL(InterpolateSignal(bool))); - connect(this, SIGNAL(ContourSignal(bool)), plot2D, SIGNAL(ContourSignal(bool))); - connect(this, SIGNAL(LogzSignal(bool)), plot2D, SLOT(SetZScaleToLog(bool))); - connect(this, SIGNAL(LogySignal(bool)), plot1D, SLOT(SetLogY(bool))); - connect(this, SIGNAL(ResetZMinZMaxSignal(bool,bool,double,double)),plot2D, SLOT(ResetZMinZMax(bool,bool,double,double))); + connect(this, SIGNAL(AcquisitionErrorSignal(QString)), this, SLOT(ShowAcquisitionErrorMessage(QString))); - connect(this, SIGNAL(AcquisitionErrorSignal(QString)), this, SLOT(ShowAcquisitionErrorMessage(QString))); - - - connect(this, SIGNAL(GainPlotSignal(bool)), this, SLOT(EnableGainPlot(bool))); + connect(this, SIGNAL(GainPlotSignal(bool)), this, SLOT(EnableGainPlot(bool))); } - //------------------------------------------------------------------------------------------------------------------------------------------------- - -void qDrawPlot::StartStopDaqToggle(bool stop_if_running){ +void qDrawPlot::StartStopDaqToggle(bool stop_if_running) { #ifdef VERYVERBOSE - cout << "Entering StartStopDaqToggle(" << stop_if_running << ")" <setTimer(slsDetectorDefs::FRAME_NUMBER,-1)); int numTriggers = (isTriggerEnabled)*((int)myDet->setTimer(slsDetectorDefs::CYCLES_NUMBER,-1)); numFrames = ((numFrames==0)?1:numFrames); numTriggers = ((numTriggers==0)?1:numTriggers); number_of_frames = numFrames * numTriggers; - cout << "\tNumber of Frames per Scan/Measurement:" << number_of_frames << endl; + std::cout << "\tNumber of Frames per Scan/Measurement:" << number_of_frames <<'\n'; //get #scansets for level 0 and level 1 int numScan0 = myDet->getScanSteps(0); numScan0 = ((numScan0==0)?1:numScan0); int numScan1 = myDet->getScanSteps(1); numScan1 = ((numScan1==0)?1:numScan1); @@ -425,1851 +417,1583 @@ void qDrawPlot::StartStopDaqToggle(bool stop_if_running){ number_of_exposures = number_of_frames * numScan0 * numScan1; if(anglePlot) number_of_exposures = numScan0 * numScan1;// * numPos; - cout << "\tNumber of Exposures Per Measurement:" << number_of_exposures << endl; + std::cout << "\tNumber of Exposures Per Measurement:" << number_of_exposures <<'\n'; */ - // ExposureTime - exposureTime= ((double)(myDet->setTimer(slsDetectorDefs::ACQUISITION_TIME,-1))*1E-9); - cout << "\tExposure Time:" << setprecision (10) << exposureTime << endl; - // Acquisition Period - acquisitionPeriod= ((double)(myDet->setTimer(slsDetectorDefs::FRAME_PERIOD,-1))*1E-9); - cout << "\tAcquisition Period:" << setprecision (10) << acquisitionPeriod << endl; - cout << "\tFile Index:" << myDet->getFileIndex() << endl; - //to take the first data if frameFactor - numFactor = 0; + // ExposureTime + exposureTime = ((double)(myDet->setTimer(slsDetectorDefs::ACQUISITION_TIME, -1)) * 1E-9); + std::cout << "\tExposure Time:" << std::setprecision(10) << exposureTime << '\n'; + // Acquisition Period + acquisitionPeriod = ((double)(myDet->setTimer(slsDetectorDefs::FRAME_PERIOD, -1)) * 1E-9); + std::cout << "\tAcquisition Period:" << std::setprecision(10) << acquisitionPeriod << '\n'; + std::cout << "\tFile Index:" << myDet->getFileIndex() << '\n'; + //to take the first data if frameFactor + numFactor = 0; - //for save automatically, - saveError = false; - lastSavedFrame = -1; - lastSavedMeasurement = -1; + //for save automatically, + saveError = false; + lastSavedFrame = -1; + lastSavedMeasurement = -1; - //update file path and file name - filePath = QString(myDet->getFilePath().c_str()); - fileName = QString(myDet->getFileName().c_str()); - //update index - currentFileIndex = myDet->getFileIndex(); - currentFrameIndex = 0; + //update file path and file name + filePath = QString(myDet->getFilePath().c_str()); + fileName = QString(myDet->getFileName().c_str()); + //update index + currentFileIndex = myDet->getFileIndex(); + currentFrameIndex = 0; - StartDaq(true); - running=!running; + StartDaq(true); + running = !running; - qDefs::checkErrorMessage(myDet,"qDrawPlot::StartStopDaqToggle"); - } - - /** if this is set during client initation */ - clientInitiated = false; + qDefs::checkErrorMessage(myDet, "qDrawPlot::StartStopDaqToggle"); + } + /** if this is set during client initation */ + clientInitiated = false; } - //------------------------------------------------------------------------------------------------------------------------------------------------- - -void qDrawPlot::StartDaq(bool start){ - if(start){ +void qDrawPlot::StartDaq(bool start) { + if (start) { #ifdef VERBOSE - cout << "Start Daq(true) function" << endl; + std::cout << "Start Daq(true) function" << '\n'; #endif - ResetDaqForGui(); - StartDaqForGui(); - }else{ + ResetDaqForGui(); + StartDaqForGui(); + } else { #ifdef VERBOSE - cout << "Start Daq(false) function" << endl; + std::cout << "Start Daq(false) function" << '\n'; #endif - StopDaqForGui(); - } + StopDaqForGui(); + } } - //------------------------------------------------------------------------------------------------------------------------------------------------- - -int qDrawPlot::ResetDaqForGui(){ - if(!StopDaqForGui()) return 0; - cout << "Resetting image number" << endl; - lastImageNumber = 0; - return 1; +int qDrawPlot::ResetDaqForGui() { + if (!StopDaqForGui()) + return 0; + std::cout << "Resetting image number" << '\n'; + lastImageNumber = 0; + return 1; } - //------------------------------------------------------------------------------------------------------------------------------------------------- - -bool qDrawPlot::StartOrStopThread(bool start){ +bool qDrawPlot::StartOrStopThread(bool start) { #ifdef VERYVERBOSE - cout << "StartOrStopThread:" << start << endl; + std::cout << "StartOrStopThread:" << start << '\n'; #endif - static bool firstTime = true; - static bool gui_acquisition_thread_running = 0; - static pthread_t gui_acquisition_thread; - static pthread_mutex_t gui_acquisition_start_stop_mutex = PTHREAD_MUTEX_INITIALIZER; + static bool firstTime = true; + static bool gui_acquisition_thread_running = 0; + static pthread_t gui_acquisition_thread; + static pthread_mutex_t gui_acquisition_start_stop_mutex = PTHREAD_MUTEX_INITIALIZER; - pthread_mutex_lock(&gui_acquisition_start_stop_mutex); - //stop part, before start or restart - if(gui_acquisition_thread_running){ - cout << "Stopping current acquisition thread ...." << endl; - stop_signal = 1;//sorta useless right now - gui_acquisition_thread_running = 0; - } + pthread_mutex_lock(&gui_acquisition_start_stop_mutex); + //stop part, before start or restart + if (gui_acquisition_thread_running) { + std::cout << "Stopping current acquisition thread ...." << '\n'; + stop_signal = 1; //sorta useless right now + gui_acquisition_thread_running = 0; + } - //start part - if(start){ - progress = 0; - //sets up the measurement parameters - SetupMeasurement(); + //start part + if (start) { + progress = 0; + //sets up the measurement parameters + SetupMeasurement(); - //refixing all the zooming - plot2D->GetPlot()->SetXMinMax(-0.5,nPixelsX+0.5); - plot2D->GetPlot()->SetYMinMax(startPixel,endPixel); - plot2D->GetPlot()->SetZoom(-0.5,startPixel,nPixelsX,endPixel-startPixel); - if (boxPlot->title() == "Sample Plot") - plot2D->GetPlot()->UnZoom(); - else - plot2D->GetPlot()->UnZoom(false); - /*XYRangeChanged = true;*/ - boxPlot->setTitle("Old_Plot.raw"); + //refixing all the zooming + plot2D->GetPlot()->SetXMinMax(-0.5, nPixelsX + 0.5); + plot2D->GetPlot()->SetYMinMax(startPixel, endPixel); + plot2D->GetPlot()->SetZoom(-0.5, startPixel, nPixelsX, endPixel - startPixel); + if (boxPlot->title() == "Sample Plot") + plot2D->GetPlot()->UnZoom(); + else + plot2D->GetPlot()->UnZoom(false); + /*XYRangeChanged = true;*/ + boxPlot->setTitle("Old_Plot.raw"); - cprintf(BLUE, "Starting new acquisition thread ....\n"); - // Start acquiring data from server - if(!firstTime) pthread_join(gui_acquisition_thread,NULL);//wait until he's finished, ie. exits - pthread_create(&gui_acquisition_thread, NULL,DataStartAcquireThread, (void*) this); - // This is set here and later reset to zero when all the plotting is done - // This is manually done instead of keeping track of thread because - // this thread returns immediately after executing the acquire command - gui_acquisition_thread_running=1; + cprintf(BLUE, "Starting new acquisition thread ....\n"); + // Start acquiring data from server + if (!firstTime) + pthread_join(gui_acquisition_thread, NULL); //wait until he's finished, ie. exits + pthread_create(&gui_acquisition_thread, NULL, DataStartAcquireThread, (void *)this); + // This is set here and later reset to zero when all the plotting is done + // This is manually done instead of keeping track of thread because + // this thread returns immediately after executing the acquire command + gui_acquisition_thread_running = 1; #ifdef VERYVERBOSE - cout << "Started acquiring thread" << endl; + std::cout << "Started acquiring thread" << '\n'; #endif - } - pthread_mutex_unlock(&gui_acquisition_start_stop_mutex); - return gui_acquisition_thread_running; + } + pthread_mutex_unlock(&gui_acquisition_start_stop_mutex); + return gui_acquisition_thread_running; } - //------------------------------------------------------------------------------------------------------------------------------------------------- +// void qDrawPlot::SetScanArgument(int scanArg){ +// #ifdef VERYVERBOSE +// std::cout << "SetScanArgument function:" << scanArg << " running:" << running <<'\n'; +// #endif +// scanArgument = scanArg; -void qDrawPlot::SetScanArgument(int scanArg){ -#ifdef VERYVERBOSE - cout << "SetScanArgument function:" << scanArg << " running:" << running << endl; -#endif - scanArgument = scanArg; +// LockLastImageArray(); - LockLastImageArray(); +// if(plot_in_scope==1) Clear1DPlot(); - if(plot_in_scope==1) Clear1DPlot(); +// // Number of Exposures - must be calculated here to get npixelsy for allframes/frameindex scans +// int numFrames = (isFrameEnabled)*((int)myDet->setTimer(slsDetectorDefs::FRAME_NUMBER,-1)); +// int numTriggers = (isTriggerEnabled)*((int)myDet->setTimer(slsDetectorDefs::CYCLES_NUMBER,-1)); +// int numStoragecells = 0; +// if (detType == slsDetectorDefs::JUNGFRAU) +// numStoragecells = (int)myDet->setTimer(slsDetectorDefs::STORAGE_CELL_NUMBER, -1); +// numFrames = ((numFrames==0)?1:numFrames); +// numTriggers = ((numTriggers==0)?1:numTriggers); +// numStoragecells = ((numStoragecells<=0)?1:numStoragecells+1); +// number_of_frames = numFrames * numTriggers * numStoragecells; +// std::cout << "\tNumber of Frames per Scan/Measurement:" << number_of_frames <<'\n'; +// //get #scansets for level 0 and level 1 +// int numScan0 = myDet->getScanSteps(0); numScan0 = ((numScan0==0)?1:numScan0); +// int numScan1 = myDet->getScanSteps(1); numScan1 = ((numScan1==0)?1:numScan1); +// //int numPos=myDet->getPositions(); +// number_of_exposures = number_of_frames * numScan0 * numScan1; +// if(anglePlot) number_of_exposures = numScan0 * numScan1;// * numPos; +// std::cout << "\tNumber of Exposures Per Measurement:" << number_of_exposures <<'\n'; - // Number of Exposures - must be calculated here to get npixelsy for allframes/frameindex scans - int numFrames = (isFrameEnabled)*((int)myDet->setTimer(slsDetectorDefs::FRAME_NUMBER,-1)); - int numTriggers = (isTriggerEnabled)*((int)myDet->setTimer(slsDetectorDefs::CYCLES_NUMBER,-1)); - int numStoragecells = 0; - if (detType == slsDetectorDefs::JUNGFRAU) - numStoragecells = (int)myDet->setTimer(slsDetectorDefs::STORAGE_CELL_NUMBER, -1); - numFrames = ((numFrames==0)?1:numFrames); - numTriggers = ((numTriggers==0)?1:numTriggers); - numStoragecells = ((numStoragecells<=0)?1:numStoragecells+1); - number_of_frames = numFrames * numTriggers * numStoragecells; - cout << "\tNumber of Frames per Scan/Measurement:" << number_of_frames << endl; - //get #scansets for level 0 and level 1 - int numScan0 = myDet->getScanSteps(0); numScan0 = ((numScan0==0)?1:numScan0); - int numScan1 = myDet->getScanSteps(1); numScan1 = ((numScan1==0)?1:numScan1); - //int numPos=myDet->getPositions(); +// maxPixelsY = 0; +// minPixelsY = 0; +// nPixelsX = myDet->getTotalNumberOfChannelsInclGapPixels(slsDetectorDefs::X); +// nPixelsY = myDet->getTotalNumberOfChannelsInclGapPixels(slsDetectorDefs::Y); +// if (detType == slsDetectorDefs::MOENCH) { +// npixelsy_jctb = (myDet->setTimer(slsDetectorDefs::SAMPLES, -1) * 2)/25; // for moench 03 +// nPixelsX = npixelsx_jctb; +// nPixelsY = npixelsy_jctb; +// } - number_of_exposures = number_of_frames * numScan0 * numScan1; - if(anglePlot) number_of_exposures = numScan0 * numScan1;// * numPos; - cout << "\tNumber of Exposures Per Measurement:" << number_of_exposures << endl; +// //cannot do this in between measurements , so update instantly +// if(scanArgument==qDefs::Level0){ +// //no need to check if numsteps=0,cuz otherwise this mode wont be set in plot tab +// int numSteps = myDet->getScanSteps(0); +// double *values = new double[numSteps]; +// myDet->getScanSteps(0,values); +// maxPixelsY = values[numSteps-1]; +// minPixelsY = values[0]; +// nPixelsY = numSteps; +// }else if(scanArgument==qDefs::Level1) { +// //no need to check if numsteps=0,cuz otherwise this mode wont be set in plot tab +// int numSteps = myDet->getScanSteps(1); +// double *values = new double[numSteps]; +// myDet->getScanSteps(1,values); - maxPixelsY = 0; - minPixelsY = 0; - nPixelsX = myDet->getTotalNumberOfChannelsInclGapPixels(slsDetectorDefs::X); - nPixelsY = myDet->getTotalNumberOfChannelsInclGapPixels(slsDetectorDefs::Y); - if (detType == slsDetectorDefs::CHIPTESTBOARD) { - npixelsy_jctb = (myDet->setTimer(slsDetectorDefs::SAMPLES, -1) * 2)/25; // for moench 03 - nPixelsX = npixelsx_jctb; - nPixelsY = npixelsy_jctb; - } +// maxPixelsY = values[numSteps-1]; +// minPixelsY = values[0]; +// nPixelsY = numSteps; +// }else if(scanArgument==qDefs::AllFrames) +// nPixelsY = number_of_exposures; +// else if(scanArgument==qDefs::FileIndex) +// nPixelsY = number_of_frames; - //cannot do this in between measurements , so update instantly - if(scanArgument==qDefs::Level0){ - //no need to check if numsteps=0,cuz otherwise this mode wont be set in plot tab - int numSteps = myDet->getScanSteps(0); - double *values = new double[numSteps]; - myDet->getScanSteps(0,values); +// if(minPixelsY>maxPixelsY){ +// double temp = minPixelsY; +// minPixelsY = maxPixelsY; +// maxPixelsY = temp; +// backwardScanPlot = true; +// }else backwardScanPlot = false; - maxPixelsY = values[numSteps-1]; - minPixelsY = values[0]; - nPixelsY = numSteps; - }else if(scanArgument==qDefs::Level1) { - //no need to check if numsteps=0,cuz otherwise this mode wont be set in plot tab - int numSteps = myDet->getScanSteps(1); - double *values = new double[numSteps]; - myDet->getScanSteps(1,values); +// //1d +// if(histXAxis) delete [] histXAxis; histXAxis = new double [nPixelsX]; - maxPixelsY = values[numSteps-1]; - minPixelsY = values[0]; - nPixelsY = numSteps; - }else if(scanArgument==qDefs::AllFrames) - nPixelsY = number_of_exposures; - else if(scanArgument==qDefs::FileIndex) - nPixelsY = number_of_frames; +// if(histYAxis[0]) delete [] histYAxis[0]; histYAxis[0] = new double [nPixelsX]; +// //2d +// if(lastImageArray) delete [] lastImageArray; lastImageArray = new double[nPixelsY*nPixelsX]; +// if(gainImageArray) delete [] gainImageArray; gainImageArray = new double[nPixelsY*nPixelsX]; - if(minPixelsY>maxPixelsY){ - double temp = minPixelsY; - minPixelsY = maxPixelsY; - maxPixelsY = temp; - backwardScanPlot = true; - }else backwardScanPlot = false; +// //initializing 1d x axis +// for(unsigned int px=0;pxmyDet->setReceiverOnline() == slsDetectorDefs::ONLINE_FLAG) { -void* qDrawPlot::DataStartAcquireThread(void *this_pointer){ - // stream data from receiver to the gui - if(((qDrawPlot*)this_pointer)->myDet->setReceiverOnline() == slsDetectorDefs::ONLINE_FLAG) { + // if receiver data up streaming not on, switch it on + if (((qDrawPlot *)this_pointer)->myDet->enableDataStreamingFromReceiver() != 1) { + // switch on receiver + if (((qDrawPlot *)this_pointer)->myDet->enableDataStreamingFromReceiver(1) != 1) { + qDefs::checkErrorMessage(((qDrawPlot *)this_pointer)->myDet, "qDrawPlot::DataStartAcquireThread"); + return this_pointer; + } + } + } - // if receiver data up streaming not on, switch it on - if (((qDrawPlot*)this_pointer)->myDet->enableDataStreamingFromReceiver() != 1) { - // switch on receiver - if (((qDrawPlot*)this_pointer)->myDet->enableDataStreamingFromReceiver(1) != 1) { - qDefs::checkErrorMessage(((qDrawPlot*)this_pointer)->myDet,"qDrawPlot::DataStartAcquireThread"); - return this_pointer; - } - } - } + if (((qDrawPlot *)this_pointer)->myDet->getAcquiringFlag() == true) { + ((qDrawPlot *)this_pointer)->myDet->setAcquiringFlag(false); + } + ((qDrawPlot *)this_pointer)->myDet->acquire(); - if (((qDrawPlot*)this_pointer)->myDet->getAcquiringFlag() == true) { - ((qDrawPlot*)this_pointer)->myDet->setAcquiringFlag(false); - } - ((qDrawPlot*)this_pointer)->myDet->acquire(1); - - return this_pointer; + return this_pointer; } - //------------------------------------------------------------------------------------------------------------------------------------------------- - -int qDrawPlot::GetDataCallBack(detectorData *data, int fIndex, int subIndex, void *this_pointer){ - ((qDrawPlot*)this_pointer)->GetData(data,fIndex, subIndex); - return 0; +int qDrawPlot::GetDataCallBack(detectorData *data, int fIndex, int subIndex, void *this_pointer) { + ((qDrawPlot *)this_pointer)->GetData(data, fIndex, subIndex); + return 0; } - //------------------------------------------------------------------------------------------------------------------------------------------------- - -int qDrawPlot::GetData(detectorData *data,int fIndex, int subIndex){ +int qDrawPlot::GetData(detectorData *data, int fIndex, int subIndex) { #ifdef VERYVERBOSE - cout << "******Entering GetDatafunction********" << endl; - cout << "fIndex " << fIndex << endl; - cout << "subIndex " << subIndex << endl; - cout << "fname " << data->fileName << endl; - cout << "npoints " << data->npoints << endl; - cout << "npy " << data->npy << endl; - cout << "progress " << data->progressIndex << endl; - if (data->values != NULL) cout << "values " << data->values << endl; - cout << "errors " << data->errors << endl; - cout << "angle " << data->angles << endl; - cout << "databytes " << data->databytes << endl; - cout << "dynamicRange " << data->dynamicRange << endl; - cout << "fileIndex " << data->fileIndex << endl; + std::cout << "******Entering GetDatafunction********\n"; + std::cout << "fIndex " << fIndex << '\n'; + std::cout << "subIndex " << subIndex << '\n'; + std::cout << "fname " << data->fileName << '\n'; + std::cout << "npoints " << data->npoints << '\n'; + std::cout << "npy " << data->npy << '\n'; + std::cout << "progress " << data->progressIndex << '\n'; + if (data->values != NULL) + std::cout << "values " << data->values << '\n'; + std::cout << "databytes " << data->databytes << '\n'; + std::cout << "dynamicRange " << data->dynamicRange << '\n'; + std::cout << "fileIndex " << data->fileIndex << '\n'; #endif - if(!stop_signal){ + if (!stop_signal) { - //set progress - progress=(int)data->progressIndex; - currentFrameIndex = fileIOStatic::getIndicesFromFileName(string(data->fileName),currentFileIndex); - currentFileIndex = data->fileIndex; - //happens if receiver sends a null and empty file name - /*if(string(data->fileName).empty()){ - cout << "Received empty file name. Exiting function without updating data for plot." << endl; - return -1; - }*/ + //set progress + progress = (int)data->progressIndex; + //TODO! + // currentFrameIndex = fileIOStatic::getIndicesFromFileName(std::string(data->fileName),currentFileIndex); + currentFileIndex = data->fileIndex; + //happens if receiver sends a null and empty file name + /*if(std::string(data->fileName).empty()){ + std::cout << "Received empty file name. Exiting function without updating data for plot." <<'\n'; + return -1; + }*/ #ifdef VERYVERBOSE - cout << "progress:" << progress << endl; + std::cout << "progress:" << progress << '\n'; #endif - // secondary title necessary to differentiate between frames when not saving data - char temp_title[2000]; - //findex is the frame index given by receiver, cannot be derived from file name - if(fIndex!=-1){ - currentFrameIndex=fIndex; - sprintf(temp_title,"#%d",fIndex); - if((detType==slsDetectorDefs::EIGER) && (subIndex != -1)) - sprintf(temp_title,"#%d %d",fIndex,subIndex); - }else{ - if(fileSaveEnable) strcpy(temp_title,"#%d"); - else sprintf(temp_title,"#%d",currentFrame); - } - if(subIndex != -1) - sprintf(temp_title,"#%d %d",fIndex,subIndex); + // secondary title necessary to differentiate between frames when not saving data + char temp_title[2000]; + //findex is the frame index given by receiver, cannot be derived from file name + if (fIndex != -1) { + currentFrameIndex = fIndex; + sprintf(temp_title, "#%d", fIndex); + if ((detType == slsDetectorDefs::EIGER) && (subIndex != -1)) + sprintf(temp_title, "#%d %d", fIndex, subIndex); + } else { + if (fileSaveEnable) + strcpy(temp_title, "#%d"); + else + sprintf(temp_title, "#%d", currentFrame); + } + if (subIndex != -1) + sprintf(temp_title, "#%d %d", fIndex, subIndex); - //Plot Disabled - if(!plotEnable) - return 0; + //Plot Disabled + if (!plotEnable) + return 0; + if (scanArgument == qDefs::None) { + //if the time is not over, RETURN + if (!data_pause_over) { + return 0; + } + data_pause_over = false; + data_pause_timer->start((int)(timerValue)); + } + // convert char* to double + if (data->values == NULL) { + data->values = new double[nPixelsX * nPixelsY]; + if (gainDataEnable) { + data->dgainvalues = new double[nPixelsX * nPixelsY]; + toDoublePixelData(data->values, data->cvalues, nPixelsX * nPixelsY, data->databytes, data->dynamicRange, data->dgainvalues); + } else + toDoublePixelData(data->values, data->cvalues, nPixelsX * nPixelsY, data->databytes, data->dynamicRange); + } - //angle plotting - if(anglePlot){ + //if scan + //alframes + if (scanArgument == qDefs::AllFrames) { + LockLastImageArray(); + //set title + plotTitle = QString(plotTitle_prefix) + QString(data->fileName).section('/', -1); + //variables + lastImageNumber = currentFrame + 1; + //title + imageTitle = temp_title; + //copy data + memcpy(lastImageArray + (currentScanDivLevel * nPixelsX), data->values, nPixelsX * sizeof(double)); + plotRequired = true; + UnlockLastImageArray(); + currentFrame++; + currentScanDivLevel++; + emit UpdatePlotSignal(); + return 0; + } + //file index + if (scanArgument == qDefs::FileIndex) { + LockLastImageArray(); + //set title + plotTitle = QString(plotTitle_prefix) + QString(data->fileName).section('/', -1); + //variables + if (currentFrameIndex == 0) + currentScanDivLevel = 0; + lastImageNumber = currentFrame + 1; + //title + imageTitle = temp_title; + //copy data + for (unsigned int px = 0; px < nPixelsX; ++px) + lastImageArray[currentScanDivLevel * nPixelsX + px] += data->values[px]; + plotRequired = true; + UnlockLastImageArray(); + currentFrame++; + currentScanDivLevel++; + emit UpdatePlotSignal(); + return 0; + } + //level0 + if (scanArgument == qDefs::Level0) { + std::cout << "Should not end up here! 0\n"; + // LockLastImageArray(); + // //set title + // plotTitle = QString(plotTitle_prefix) + QString(data->fileName).section('/', -1); + // //get scanvariable0 + // int ci = 0, fi = 0, p = 0, di = 0; + // double cs0 = 0, cs1 = 0; + // fileIOStatic::getVariablesFromFileName(std::string(data->fileName), ci, fi, p, cs0, cs1, di); + // //variables + // if (cs0 != currentScanValue) { + // if (backwardScanPlot) + // currentScanDivLevel--; + // else + // currentScanDivLevel++; + // } + // currentScanValue = cs0; + // lastImageNumber = currentFrame + 1; + // //title + // imageTitle = temp_title; + // //copy data + // for (unsigned int px = 0; px < nPixelsX; ++px) + // lastImageArray[currentScanDivLevel * nPixelsX + px] += data->values[px]; + // plotRequired = true; + // UnlockLastImageArray(); + // currentFrame++; + // emit UpdatePlotSignal(); + return 0; + } + if (scanArgument == qDefs::Level1) { + std::cout << "Should not end up here! 1\n"; + // LockLastImageArray(); + // //set title + // plotTitle = QString(plotTitle_prefix) + QString(data->fileName).section('/', -1); + // //get scanvariable1 + // int ci = 0, fi = 0, p = 0, di = 0; + // double cs0 = 0, cs1 = 0; + // fileIOStatic::getVariablesFromFileName(std::string(data->fileName), ci, fi, p, cs0, cs1, di); + // //variables + // if (cs1 != currentScanValue) { + // if (backwardScanPlot) + // currentScanDivLevel--; + // else + // currentScanDivLevel++; + // } + // currentScanValue = cs1; + // lastImageNumber = currentFrame + 1; + // //title + // imageTitle = temp_title; + // //copy data + // for (unsigned int px = 0; px < nPixelsX; ++px) + // lastImageArray[currentScanDivLevel * nPixelsX + px] += data->values[px]; + // plotRequired = true; + // UnlockLastImageArray(); + // currentFrame++; + // emit UpdatePlotSignal(); + return 0; + } - // convert char* to double - if(data->values==NULL) { - data->values = new double[nPixelsX*nPixelsY]; - toDoublePixelData(data->values, data->cvalues, nPixelsX*nPixelsY, data->databytes, data->dynamicRange); - } + //normal measurement or 1d scans + LockLastImageArray(); + /*if(!pthread_mutex_trylock(&(last_image_complete_mutex))){*/ + //set title + plotTitle = QString(plotTitle_prefix) + QString(data->fileName).section('/', -1); + // only if you got the lock, do u need to remember lastimagenumber to plot + lastImageNumber = currentFrame + 1; + //cout<<"got last imagenumber:"<fileName).section('/',-1); - // Title - histTitle[0] = temp_title; + //histogram + if (histogram) { + resetAccumulate = false; + lastImageNumber = currentFrame + 1; - if(data->angles==NULL){ - cout<<"\n\nWARNING:RETURNED NULL instead of angles."<values,nAnglePixelsX*sizeof(double)); - SetHistXAxisTitle("Channel Number"); + int numValues = nPixelsX; + if (originally2D) + numValues = nPixelsX * nPixelsY; - } - else{ - lastImageNumber= currentFrame+1; - nAnglePixelsX = data->npoints; - histNBins = nAnglePixelsX; - nHists=1; - if(histXAngleAxis) delete [] histXAngleAxis; histXAngleAxis = new double[nAnglePixelsX]; - if(histYAngleAxis) delete [] histYAngleAxis; histYAngleAxis = new double[nAnglePixelsX]; -#ifdef CHECKINFERROR - int k = 0; - for(int i = 0; i < data->npoints; i++){ - if(isinf(data->values[i])){ - //cout << "*** ERROR: value at " << i << " infinity" << endl; - k++; - data->values[i] = -1; - } - } - if (k>0) { - cout << "*** ERROR: value at " << k << " places have infinity values!" << endl; - double m1,m2,s1; - GetStatistics(m1,m2,s1,data->angles,nAnglePixelsX); - cout << "angle min:" << m1 << endl; - cout << "angle max:" << m2 << endl; - cout << "angle sum:" << s1 << endl; - GetStatistics(m1,m2,s1,data->values,nAnglePixelsX); - cout << "value min:" << m1 << endl; - cout << "value max:" << m2 << endl; - cout << "value sum:" << s1 << endl; - } -#endif - memcpy(histXAngleAxis,data->angles,nAnglePixelsX*sizeof(double)); - memcpy(histYAngleAxis,data->values,nAnglePixelsX*sizeof(double)); - SetHistXAxisTitle("Angles"); - } - plotRequired = true; - UnlockLastImageArray(); - currentFrame++; -#ifdef VERYVERBOSE - cout << "Exiting GetData Function " << endl; -#endif - emit UpdatePlotSignal(); - return 0; - } + //clean up graph + if (histogramArgument == qDefs::Intensity) { + for (int j = 0; j < histogramSamples.size(); ++j) { + histogramSamples[j].value = 0; + } + } + int val = 0; + for (int i = 0; i < numValues; ++i) { + //frequency of intensity + if (histogramArgument == qDefs::Intensity) { + //ignore outside limits + if ((data->values[i] < histFrom) || (data->values[i] > histTo)) + continue; + //check for intervals, increment if validates + for (int j = 0; j < histogramSamples.size(); ++j) { + if (histogramSamples[j].interval.contains(data->values[i])) + histogramSamples[j].value += 1; + } + } + //get sum of data pixels + else + val += data->values[i]; + } - //nth frame or delay decision (data copied later on) - if (detType == slsDetectorDefs::MYTHEN){ - //Nth Frame - if(frameFactor){ - //plots if numfactor becomes 0 - if(!numFactor) numFactor=frameFactor-1; - //return if not - else{ - numFactor--; - return 0; - } - } + if (histogramArgument != qDefs::Intensity) { + std::cout << "histogramArgument != qDefs::Intensity\n"; + // val /= numValues; - //Not Nth Frame, to check time out(NOT for Scans and angle plots) - else{ - if (scanArgument == qDefs::None) { - //if the time is not over, RETURN - if(!data_pause_over){ - return 0; - } - data_pause_over=false; - data_pause_timer->start((int)(timerValue)); - } - } - } + // //find scan value + // int ci = 0, fi = 0; + // double cs0 = 0, cs1 = 0; + // fileIOStatic::getVariablesFromFileName(std::string(data->fileName), ci, fi, cs0, cs1); - // convert char* to double - if(data->values == NULL) { - data->values = new double[nPixelsX*nPixelsY]; - if (gainDataEnable) { - data->dgainvalues = new double[nPixelsX*nPixelsY]; - toDoublePixelData(data->values, data->cvalues, nPixelsX*nPixelsY, data->databytes, data->dynamicRange, data->dgainvalues); - } - else - toDoublePixelData(data->values, data->cvalues, nPixelsX*nPixelsY, data->databytes, data->dynamicRange); - } + // int scanval = -1; + // if (cs0 != -1) + // scanval = cs0; + // else + // scanval = cs1; - //if scan - //alframes - if(scanArgument==qDefs::AllFrames){ - LockLastImageArray(); - //set title - plotTitle=QString(plotTitle_prefix)+QString(data->fileName).section('/',-1); - //variables - lastImageNumber= currentFrame+1; - //title - imageTitle = temp_title; - //copy data - memcpy(lastImageArray+(currentScanDivLevel*nPixelsX),data->values,nPixelsX*sizeof(double)); - plotRequired = true; - UnlockLastImageArray(); - currentFrame++; - currentScanDivLevel++; - emit UpdatePlotSignal(); - return 0; - } - //file index - if(scanArgument==qDefs::FileIndex){ - LockLastImageArray(); - //set title - plotTitle=QString(plotTitle_prefix)+QString(data->fileName).section('/',-1); - //variables - if(currentFrameIndex == 0) currentScanDivLevel = 0; - lastImageNumber= currentFrame+1; - //title - imageTitle = temp_title; - //copy data - for(unsigned int px=0;pxvalues[px]; - plotRequired = true; - UnlockLastImageArray(); - currentFrame++; - currentScanDivLevel++; - emit UpdatePlotSignal(); - return 0; - } - //level0 - if(scanArgument==qDefs::Level0){ - LockLastImageArray(); - //set title - plotTitle=QString(plotTitle_prefix)+QString(data->fileName).section('/',-1); - //get scanvariable0 - int ci = 0, fi = 0, p = 0, di = 0; double cs0 = 0 , cs1 = 0; - fileIOStatic::getVariablesFromFileName(string(data->fileName), ci, fi, p, cs0, cs1, di); - //variables - if(cs0!=currentScanValue) { - if(backwardScanPlot) currentScanDivLevel--; - else currentScanDivLevel++; - } - currentScanValue = cs0; - lastImageNumber= currentFrame+1; - //title - imageTitle = temp_title; - //copy data - for(unsigned int px=0;pxvalues[px]; - plotRequired = true; - UnlockLastImageArray(); - currentFrame++; - emit UpdatePlotSignal(); - return 0; - } - //level1 - if(scanArgument==qDefs::Level1){ - LockLastImageArray(); - //set title - plotTitle=QString(plotTitle_prefix)+QString(data->fileName).section('/',-1); - //get scanvariable1 - int ci = 0, fi = 0, p = 0, di = 0; double cs0 = 0 , cs1 = 0; - fileIOStatic::getVariablesFromFileName(string(data->fileName), ci, fi, p, cs0, cs1, di); - //variables - if(cs1!=currentScanValue){ - if(backwardScanPlot) currentScanDivLevel--; - else currentScanDivLevel++; - } - currentScanValue = cs1; - lastImageNumber= currentFrame+1; - //title - imageTitle = temp_title; - //copy data - for(unsigned int px=0;pxvalues[px]; - plotRequired = true; - UnlockLastImageArray(); - currentFrame++; - emit UpdatePlotSignal(); - return 0; - } + // //ignore outside limits + // if ((scanval < histFrom) || (scanval > histTo) || (scanval == -1)) + // scanval = -1; + // //check for intervals, increment if validates + // for (int j = 0; j < histogramSamples.size(); ++j) { + // if (histogramSamples[j].interval.contains(scanval)) { + // histogramSamples[j].value = val; + // cout << "j:" << j << " scanval:" << scanval << " val:" << val << endl; + // } + // } + } + } + //not histogram + else { + // Persistency + if (currentPersistency < persistency) + currentPersistency++; + else + currentPersistency = persistency; + nHists = currentPersistency + 1; + histNBins = nPixelsX; + // copy data + for (int i = currentPersistency; i > 0; i--) + memcpy(histYAxis[i], histYAxis[i - 1], nPixelsX * sizeof(double)); - //normal measurement or 1d scans - LockLastImageArray(); - /*if(!pthread_mutex_trylock(&(last_image_complete_mutex))){*/ - //set title - plotTitle=QString(plotTitle_prefix)+QString(data->fileName).section('/',-1); - // only if you got the lock, do u need to remember lastimagenumber to plot - lastImageNumber= currentFrame+1; - //cout<<"got last imagenumber:"<values[px]; + memcpy(histYAxis[0], data->values, nPixelsX * sizeof(double)); + pedestalCount++; + } + //calculate the pedestal value + if (pedestalCount == NUM_PEDESTAL_FRAMES) { + cout << "Pedestal Calculated" << '\n'; + for (unsigned int px = 0; px < nPixelsX; ++px) + tempPedestalVals[px] = tempPedestalVals[px] / (double)NUM_PEDESTAL_FRAMES; + memcpy(pedestalVals, tempPedestalVals, nPixelsX * sizeof(double)); + startPedestalCal = 0; + } + } - //histogram - if(histogram){ - resetAccumulate = false; - lastImageNumber= currentFrame+1; + //normal data + if (((!pedestal) & (!accumulate) & (!binary)) || (resetAccumulate)) { + memcpy(histYAxis[0], data->values, nPixelsX * sizeof(double)); + resetAccumulate = false; + } + //pedestal or accumulate + else { + double temp; //cannot overwrite cuz of accumulate + for (unsigned int px = 0; px < (nPixelsX * nPixelsY); ++px) { + temp = data->values[px]; + if (pedestal) + temp = data->values[px] - (pedestalVals[px]); + if (binary) { + if ((temp >= binaryFrom) && (temp <= binaryTo)) + temp = 1; + else + temp = 0; + } + if (accumulate) + temp += histYAxis[0][px]; + //after all processing + histYAxis[0][px] = temp; + } + } + } + } + //2d + else { + // Titles + imageTitle = temp_title; - int numValues = nPixelsX; - if(originally2D) - numValues = nPixelsX*nPixelsY; + //jungfrau mask gain + if (data->dgainvalues != NULL) { + memcpy(gainImageArray, data->dgainvalues, nPixelsX * nPixelsY * sizeof(double)); + gainPlotEnable = true; + } else + gainPlotEnable = false; - //clean up graph - if(histogramArgument == qDefs::Intensity){ - for(int j=0;jvalues[px]; + memcpy(lastImageArray, data->values, nPixelsX * nPixelsY * sizeof(double)); + pedestalCount++; + } + //calculate the pedestal value + if (pedestalCount == NUM_PEDESTAL_FRAMES) { + std::cout << "Pedestal Calculated" << '\n'; + for (unsigned int px = 0; px < (nPixelsX * nPixelsY); ++px) + tempPedestalVals[px] = tempPedestalVals[px] / (double)NUM_PEDESTAL_FRAMES; + memcpy(pedestalVals, tempPedestalVals, nPixelsX * nPixelsY * sizeof(double)); + startPedestalCal = 0; + } + } - } - } - - int val = 0 ; - for(int i=0;ivalues[i] < histFrom) || (data->values[i] > histTo)) - continue; - //check for intervals, increment if validates - for(int j=0;jvalues[i])) - histogramSamples[j].value += 1; - - } - } - //get sum of data pixels - else - val += data->values[i]; - - } - - - if(histogramArgument != qDefs::Intensity){ - val /= numValues; - - //find scan value - int ci = 0, fi = 0; double cs0 = 0 , cs1 = 0; - fileIOStatic::getVariablesFromFileName(string(data->fileName), ci, fi, cs0, cs1); - - int scanval=-1; - if(cs0 != -1) - scanval = cs0; - else scanval = cs1; - - //ignore outside limits - if ((scanval < histFrom) || (scanval > histTo) || (scanval == -1)) - scanval = -1; - //check for intervals, increment if validates - for(int j=0;j0;i--) - memcpy(histYAxis[i],histYAxis[i-1],nPixelsX*sizeof(double)); - - //recalculating pedestal - if(startPedestalCal){ - //start adding frames to get to the pedestal value - if(pedestalCountvalues[px]; - memcpy(histYAxis[0],data->values,nPixelsX*sizeof(double)); - pedestalCount++; - } - //calculate the pedestal value - if(pedestalCount==NUM_PEDESTAL_FRAMES){ - cout << "Pedestal Calculated" << endl; - for(unsigned int px=0;pxvalues,nPixelsX*sizeof(double)); - resetAccumulate = false; - } - //pedestal or accumulate - else{ - double temp;//cannot overwrite cuz of accumulate - for(unsigned int px=0;px<(nPixelsX*nPixelsY);px++){ - temp = data->values[px]; - if(pedestal) - temp = data->values[px] - (pedestalVals[px]); - if(binary) { - if ((temp >= binaryFrom) && (temp <= binaryTo)) - temp = 1; - else - temp = 0; - } - if(accumulate) - temp += histYAxis[0][px]; - //after all processing - histYAxis[0][px] = temp; - } - } - } - } - //2d - else{ - // Titles - imageTitle = temp_title; - - //jungfrau mask gain - if(data->dgainvalues != NULL) { - memcpy(gainImageArray, data->dgainvalues, nPixelsX*nPixelsY*sizeof(double)); - gainPlotEnable = true; - }else - gainPlotEnable = false; - - - //recalculating pedestal - if(startPedestalCal){ - //start adding frames to get to the pedestal value - if(pedestalCountvalues[px]; - memcpy(lastImageArray,data->values,nPixelsX*nPixelsY*sizeof(double)); - pedestalCount++; - } - //calculate the pedestal value - if(pedestalCount==NUM_PEDESTAL_FRAMES){ - cout << "Pedestal Calculated" << endl; - for(unsigned int px=0;px<(nPixelsX*nPixelsY);px++) - tempPedestalVals[px] = tempPedestalVals[px]/(double)NUM_PEDESTAL_FRAMES; - memcpy(pedestalVals,tempPedestalVals,nPixelsX*nPixelsY*sizeof(double)); - startPedestalCal = 0; - } - } - - //normal data - if(((!pedestal)&(!accumulate)&(!binary)) || (resetAccumulate)){ - memcpy(lastImageArray,data->values,nPixelsX*nPixelsY*sizeof(double)); - resetAccumulate = false; - } - //pedestal or accumulate or binary - else{ - double temp; - for(unsigned int px=0;px<(nPixelsX*nPixelsY);px++){ - temp = data->values[px]; - if(pedestal) - temp = data->values[px] - (pedestalVals[px]); - if(binary) { - if ((temp >= binaryFrom) && (temp <= binaryTo)) - temp = 1; - else - temp = 0; - } - if(accumulate) - temp += lastImageArray[px]; - //after all processing - lastImageArray[px] = temp; - } - } - - } - /* pthread_mutex_unlock(&(last_image_complete_mutex)); - }*/ - plotRequired = true; - UnlockLastImageArray(); + //normal data + if (((!pedestal) & (!accumulate) & (!binary)) || (resetAccumulate)) { + memcpy(lastImageArray, data->values, nPixelsX * nPixelsY * sizeof(double)); + resetAccumulate = false; + } + //pedestal or accumulate or binary + else { + double temp; + for (unsigned int px = 0; px < (nPixelsX * nPixelsY); ++px) { + temp = data->values[px]; + if (pedestal) + temp = data->values[px] - (pedestalVals[px]); + if (binary) { + if ((temp >= binaryFrom) && (temp <= binaryTo)) + temp = 1; + else + temp = 0; + } + if (accumulate) + temp += lastImageArray[px]; + //after all processing + lastImageArray[px] = temp; + } + } + } + /* pthread_mutex_unlock(&(last_image_complete_mutex)); + }*/ + plotRequired = true; + UnlockLastImageArray(); #ifdef VERYVERBOSE - cprintf(BLUE,"currentframe:%d \tcurrentframeindex:%d\n",currentFrame,currentFrameIndex); + cprintf(BLUE, "currentframe:%d \tcurrentframeindex:%d\n", currentFrame, currentFrameIndex); #endif - currentFrame++; - emit UpdatePlotSignal(); - } - + currentFrame++; + emit UpdatePlotSignal(); + } #ifdef VERYVERBOSE - cout << "Exiting GetData function" << endl; + std::cout << "Exiting GetData function" << '\n'; #endif - return 0; + return 0; } - //------------------------------------------------------------------------------------------------------------------------------------------------- - -int qDrawPlot::GetAcquisitionFinishedCallBack(double currentProgress,int detectorStatus, void *this_pointer){ - ((qDrawPlot*)this_pointer)->AcquisitionFinished(currentProgress,detectorStatus); +int qDrawPlot::GetAcquisitionFinishedCallBack(double currentProgress, int detectorStatus, void *this_pointer) { + ((qDrawPlot *)this_pointer)->AcquisitionFinished(currentProgress, detectorStatus); #ifdef VERYVERBOSE - cout << "acquisition finished callback worked ok" << endl; + std::cout << "acquisition finished callback worked ok\n"; #endif - return 0; + return 0; } - //------------------------------------------------------------------------------------------------------------------------------------------------- - -int qDrawPlot::AcquisitionFinished(double currentProgress, int detectorStatus){ +int qDrawPlot::AcquisitionFinished(double currentProgress, int detectorStatus) { #ifdef VERBOSE - cout << "\nEntering Acquisition Finished with status " ; + std::cout << "\nEntering Acquisition Finished with status "; #endif - QString status = QString(slsDetectorDefs::runStatusType(slsDetectorDefs::runStatus(detectorStatus)).c_str()); + QString status = QString(slsDetectorDefs::runStatusType(slsDetectorDefs::runStatus(detectorStatus)).c_str()); #ifdef VERBOSE - cout << status.toAscii().constData() << " and progress " << currentProgress << endl; + std::cout << status.toAscii().constData() << " and progress " << currentProgress << '\n'; #endif - //error or stopped - if((stop_signal)||(detectorStatus==slsDetectorDefs::ERROR)){ + //error or stopped + if ((stop_signal) || (detectorStatus == slsDetectorDefs::ERROR)) { #ifdef VERBOSE - cout << "Error in Acquisition" << endl << endl; + std::cout << "Error in Acquisition\n\n"; #endif - //stop_signal = 1;//just to be sure - emit AcquisitionErrorSignal(status); - } + //stop_signal = 1;//just to be sure + emit AcquisitionErrorSignal(status); + } #ifdef VERBOSE - //all measurements are over - else if(currentProgress==100){ - cout << "Acquisition Finished" << endl << endl; - } + //all measurements are over + else if (currentProgress == 100) { + std::cout << "Acquisition Finished\n"; + } #endif - StartStopDaqToggle(true); - //this lets the measurement tab know its over, and to enable tabs - emit UpdatingPlotFinished(); + StartStopDaqToggle(true); + //this lets the measurement tab know its over, and to enable tabs + emit UpdatingPlotFinished(); - //calculate s curve inflection point - int l1=0,l2=0,j; - if((histogram)&&(histogramArgument != qDefs::Intensity)){ - for(j=0;j l2){ - cout << "***** s curve inflectionfound at " << histogramSamples[j].interval.maxValue() << "" - "or j at " << j << " with l1 " << l1 << " and l2 " << l2 << endl; - } - } - } + //calculate s curve inflection point + int l1 = 0, l2 = 0, j; + if ((histogram) && (histogramArgument != qDefs::Intensity)) { + for (j = 0; j < histogramSamples.size() - 2; ++j) { + l1 = histogramSamples[j + 1].value - histogramSamples[j].value; + l2 = histogramSamples[j + 2].value - histogramSamples[j + 1].value; + if (l1 > l2) { + std::cout << "***** s curve inflectionfound at " << histogramSamples[j].interval.maxValue() << "" + "or j at " + << j << " with l1 " << l1 << " and l2 " << l2 << '\n'; + } + } + } - return 0; + return 0; } - //------------------------------------------------------------------------------------------------------------------------------------------------- - -int qDrawPlot::GetProgressCallBack(double currentProgress, void *this_pointer){ - ((qDrawPlot*)this_pointer)->progress= currentProgress; - return 0; +int qDrawPlot::GetProgressCallBack(double currentProgress, void *this_pointer) { + ((qDrawPlot *)this_pointer)->progress = currentProgress; + return 0; } - //------------------------------------------------------------------------------------------------------------------------------------------------- - -void qDrawPlot::ShowAcquisitionErrorMessage(QString status){ - if(!alreadyDisplayed){ - alreadyDisplayed = true; - qDefs::Message(qDefs::WARNING,string("
The acquisiton has ended abruptly. " - "Current Detector Status: ")+status.toAscii().constData()+ - string("."),"qDrawPlot::ShowAcquisitionErrorMessage"); - } +void qDrawPlot::ShowAcquisitionErrorMessage(QString status) { + if (!alreadyDisplayed) { + alreadyDisplayed = true; + qDefs::Message(qDefs::WARNING, std::string("The acquisiton has ended abruptly. " + "Current Detector Status: ") + + status.toAscii().constData() + std::string("."), + "qDrawPlot::ShowAcquisitionErrorMessage"); + } } - //------------------------------------------------------------------------------------------------------------------------------------------------- - -int qDrawPlot::GetMeasurementFinishedCallBack(int currentMeasurementIndex, int fileIndex, void *this_pointer){ - ((qDrawPlot*)this_pointer)->MeasurementFinished(currentMeasurementIndex, fileIndex); - return 0; +int qDrawPlot::GetMeasurementFinishedCallBack(int currentMeasurementIndex, int fileIndex, void *this_pointer) { + ((qDrawPlot *)this_pointer)->MeasurementFinished(currentMeasurementIndex, fileIndex); + return 0; } - //------------------------------------------------------------------------------------------------------------------------------------------------- - -int qDrawPlot::MeasurementFinished(int currentMeasurementIndex, int fileIndex){ +int qDrawPlot::MeasurementFinished(int currentMeasurementIndex, int fileIndex) { #ifdef VERBOSE - cout << "Entering Measurement Finished with currentMeasurement " << currentMeasurementIndex << " and fileIndex " << fileIndex << endl; + std::cout << "Entering Measurement Finished with currentMeasurement " << currentMeasurementIndex << " and fileIndex " << fileIndex << '\n'; #endif - //to make sure it plots the last frame - while(plotRequired){ - usleep(2000); - } + //to make sure it plots the last frame + while (plotRequired) { + usleep(2000); + } - currentMeasurement = currentMeasurementIndex+1; - currentFileIndex = fileIndex; + currentMeasurement = currentMeasurementIndex + 1; + currentFileIndex = fileIndex; #ifdef VERBOSE - cout << "currentMeasurement:" << currentMeasurement << endl; + std::cout << "currentMeasurement:" << currentMeasurement << '\n'; #endif - emit SetCurrentMeasurementSignal(currentMeasurement); - SetupMeasurement(); - /*if((myDet->setReceiverOnline()==slsDetectorDefs::ONLINE_FLAG) && (myDet->getFramesCaughtByReceiver() == 0)) + emit SetCurrentMeasurementSignal(currentMeasurement); + SetupMeasurement(); + /*if((myDet->setReceiverOnline()==slsDetectorDefs::ONLINE_FLAG) && (myDet->getFramesCaughtByReceiver() == 0)) boxPlot->setTitle("OLD_plot.raw");*/ - return 0; + return 0; } - //------------------------------------------------------------------------------------------------------------------------------------------------- - -void qDrawPlot::SelectPlot(int i){ //1 for 1D otherwise 2D - if(i==1){ - //Clear1DPlot(); it clears the last measurement - plot1D->SetXTitle(histXAxisTitle.toAscii().constData()); - plot1D->SetYTitle(histYAxisTitle.toAscii().constData()); - plot1D->show(); - plot2D->hide(); - boxPlot->setFlat(false); - plot_in_scope=1; - layout->addWidget(histFrameIndexTitle,0,0); - plotLayout->setContentsMargins(10,10,10,10); - }else{ - plot2D->SetXTitle(imageXAxisTitle); - plot2D->SetYTitle(imageYAxisTitle); - plot2D->SetZTitle(imageZAxisTitle); - plot1D->hide(); - plot2D->show(); - boxPlot->setFlat(true); - plot_in_scope=2; - histFrameIndexTitle->setText(""); - layout->removeWidget(histFrameIndexTitle); - plotLayout->setContentsMargins(0,0,0,0); - - } +void qDrawPlot::SelectPlot(int i) { //1 for 1D otherwise 2D + if (i == 1) { + //Clear1DPlot(); it clears the last measurement + plot1D->SetXTitle(histXAxisTitle.toAscii().constData()); + plot1D->SetYTitle(histYAxisTitle.toAscii().constData()); + plot1D->show(); + plot2D->hide(); + boxPlot->setFlat(false); + plot_in_scope = 1; + layout->addWidget(histFrameIndexTitle, 0, 0); + plotLayout->setContentsMargins(10, 10, 10, 10); + } else { + plot2D->SetXTitle(imageXAxisTitle); + plot2D->SetYTitle(imageYAxisTitle); + plot2D->SetZTitle(imageZAxisTitle); + plot1D->hide(); + plot2D->show(); + boxPlot->setFlat(true); + plot_in_scope = 2; + histFrameIndexTitle->setText(""); + layout->removeWidget(histFrameIndexTitle); + plotLayout->setContentsMargins(0, 0, 0, 0); + } } - //------------------------------------------------------------------------------------------------------------------------------------------------- +void qDrawPlot::Clear1DPlot() { + for (QVector::iterator h = plot1D_hists.begin(); h != plot1D_hists.end(); ++h) { + (*h)->Detach(plot1D); + //do not delete *h or h. + } -void qDrawPlot::Clear1DPlot(){ - for(QVector::iterator h = plot1D_hists.begin(); h!=plot1D_hists.end();h++){ - (*h)->Detach(plot1D); - //do not delete *h or h. - } - - plotHistogram->detach(); + plotHistogram->detach(); } - //------------------------------------------------------------------------------------------------------------------------------------------------- - -void qDrawPlot::UpdatePlot(){ +void qDrawPlot::UpdatePlot() { #ifdef VERYVERBOSE - cout << "Entering UpdatePlot function" << endl; + std::cout << "Entering UpdatePlot function\n"; #endif - // only if no plot isnt enabled - if(plotEnable && plotRequired){ - LockLastImageArray(); - //so that it doesnt plot every single thing + // only if no plot isnt enabled + if (plotEnable && plotRequired) { + LockLastImageArray(); + //so that it doesnt plot every single thing #ifdef VERYVERBOSE - cprintf(GREEN,"Updating Plot\n"); + cprintf(GREEN, "Updating Plot\n"); #endif - //so as to not plot it again and to let measurment finished know its done plotting it - //1-d plot stuff - if(plot_in_scope==1){ + //so as to not plot it again and to let measurment finished know its done plotting it + //1-d plot stuff + if (plot_in_scope == 1) { #ifdef VERYVERBOSE - cout << "Last Image Number:" << lastImageNumber << endl; + std::cout << "Last Image Number:" << lastImageNumber << '\n'; #endif - if(histNBins){ - Clear1DPlot(); - plot1D->SetXTitle(histXAxisTitle.toAscii().constData()); - plot1D->SetYTitle(histYAxisTitle.toAscii().constData()); + if (histNBins) { + Clear1DPlot(); + plot1D->SetXTitle(histXAxisTitle.toAscii().constData()); + plot1D->SetYTitle(histYAxisTitle.toAscii().constData()); - //histogram - if(histogram){ - plotHistogram->setData(new QwtIntervalSeriesData(histogramSamples)); - plotHistogram->setPen(QPen(Qt::red)); - plotHistogram->setBrush(QBrush(Qt::red,Qt::Dense4Pattern));//Qt::SolidPattern - histFrameIndexTitle->setText(GetHistTitle(0)); - plotHistogram->attach(plot1D); - //refixing all the zooming + //histogram + if (histogram) { + plotHistogram->setData(new QwtIntervalSeriesData(histogramSamples)); + plotHistogram->setPen(QPen(Qt::red)); + plotHistogram->setBrush(QBrush(Qt::red, Qt::Dense4Pattern)); //Qt::SolidPattern + histFrameIndexTitle->setText(GetHistTitle(0)); + plotHistogram->attach(plot1D); + //refixing all the zooming - plot1D->SetXMinMax(startPixel,endPixel); - plot1D->SetYMinMax(0,plotHistogram->boundingRect().height()); - plot1D->SetZoomBase(startPixel,0,endPixel-startPixel,plotHistogram->boundingRect().height()); + plot1D->SetXMinMax(startPixel, endPixel); + plot1D->SetYMinMax(0, plotHistogram->boundingRect().height()); + plot1D->SetZoomBase(startPixel, 0, endPixel - startPixel, plotHistogram->boundingRect().height()); - } - //not histogram - else{ - for(int hist_num=0;hist_num<(int)nHists;hist_num++){ - SlsQtH1D* h; - if(hist_num+1>plot1D_hists.size()){ - if(anglePlot) - plot1D_hists.append(h=new SlsQtH1D("",histNBins,histXAngleAxis,histYAngleAxis)); - else - plot1D_hists.append(h=new SlsQtH1D("",histNBins,histXAxis,GetHistYAxis(hist_num))); - h->SetLineColor(hist_num); - }else{ - h=plot1D_hists.at(hist_num); - if(anglePlot) - h->SetData(histNBins,histXAngleAxis,histYAngleAxis); - else - h->SetData(histNBins,histXAxis,GetHistYAxis(hist_num)); - } - SetStyle(h); - histFrameIndexTitle->setText(GetHistTitle(0)); - //h->setTitle(GetHistTitle(hist_num)); - h->Attach(plot1D); - //refixing all the zooming - //if((firstPlot) || (anglePlot)){ - /*plot1D->SetXMinMax(h->minXValue(),h->maxXValue()); + } + //not histogram + else { + for (int hist_num = 0; hist_num < (int)nHists; ++hist_num) { + SlsQtH1D *h; + if (hist_num + 1 > plot1D_hists.size()) { + if (anglePlot) + plot1D_hists.append(h = new SlsQtH1D("", histNBins, histXAngleAxis, histYAngleAxis)); + else + plot1D_hists.append(h = new SlsQtH1D("", histNBins, histXAxis, GetHistYAxis(hist_num))); + h->SetLineColor(hist_num); + } else { + h = plot1D_hists.at(hist_num); + if (anglePlot) + h->SetData(histNBins, histXAngleAxis, histYAngleAxis); + else + h->SetData(histNBins, histXAxis, GetHistYAxis(hist_num)); + } + SetStyle(h); + histFrameIndexTitle->setText(GetHistTitle(0)); + //h->setTitle(GetHistTitle(hist_num)); + h->Attach(plot1D); + //refixing all the zooming + //if((firstPlot) || (anglePlot)){ + /*plot1D->SetXMinMax(h->minXValue(),h->maxXValue()); plot1D->SetYMinMax(h->minYValue(),h->maxYValue()); plot1D->SetZoomBase(h->minXValue(),h->minYValue(), h->maxXValue()-h->minXValue(),h->maxYValue()-h->minYValue());*/ - // firstPlot = false; - //} - } + // firstPlot = false; + //} + } - /**moved from below (had applied to histograms as well) to here, */ - // update range if required - if(XYRangeChanged){ - if(!IsXYRange[qDefs::XMINIMUM]) XYRangeValues[qDefs::XMINIMUM]= plot1D->GetXMinimum(); - if(!IsXYRange[qDefs::XMAXIMUM]) XYRangeValues[qDefs::XMAXIMUM]= plot1D->GetXMaximum(); - if(!IsXYRange[qDefs::YMINIMUM]) XYRangeValues[qDefs::YMINIMUM]= plot1D->GetYMinimum(); - if(!IsXYRange[qDefs::YMAXIMUM]) XYRangeValues[qDefs::YMAXIMUM]= plot1D->GetYMaximum(); - plot1D->SetXMinMax(XYRangeValues[qDefs::XMINIMUM],XYRangeValues[qDefs::XMAXIMUM]); - plot1D->SetYMinMax(XYRangeValues[qDefs::YMINIMUM],XYRangeValues[qDefs::YMAXIMUM]); - //Should not be reset for histogram, - //that is the only way to zoom in (new plots are zoomed out as its different each time) - if(!histogram) - XYRangeChanged = false; - } - /**moved from below (had applied to histograms as well) to here, */ - //Display Statistics - if(displayStatistics){ - double min=0,max=0,sum=0; - if(anglePlot) - GetStatistics(min,max,sum,histYAngleAxis,histNBins); - else - GetStatistics(min,max,sum,histYAxis[0],histNBins); - lblMinDisp->setText(QString("%1").arg(min)); - lblMaxDisp->setText(QString("%1").arg(max)); - lblSumDisp->setText(QString("%1").arg(sum)); - } - } + /**moved from below (had applied to histograms as well) to here, */ + // update range if required + if (XYRangeChanged) { + if (!IsXYRange[qDefs::XMINIMUM]) + XYRangeValues[qDefs::XMINIMUM] = plot1D->GetXMinimum(); + if (!IsXYRange[qDefs::XMAXIMUM]) + XYRangeValues[qDefs::XMAXIMUM] = plot1D->GetXMaximum(); + if (!IsXYRange[qDefs::YMINIMUM]) + XYRangeValues[qDefs::YMINIMUM] = plot1D->GetYMinimum(); + if (!IsXYRange[qDefs::YMAXIMUM]) + XYRangeValues[qDefs::YMAXIMUM] = plot1D->GetYMaximum(); + plot1D->SetXMinMax(XYRangeValues[qDefs::XMINIMUM], XYRangeValues[qDefs::XMAXIMUM]); + plot1D->SetYMinMax(XYRangeValues[qDefs::YMINIMUM], XYRangeValues[qDefs::YMAXIMUM]); + //Should not be reset for histogram, + //that is the only way to zoom in (new plots are zoomed out as its different each time) + if (!histogram) + XYRangeChanged = false; + } + /**moved from below (had applied to histograms as well) to here, */ + //Display Statistics + if (displayStatistics) { + double min = 0, max = 0, sum = 0; + if (anglePlot) + GetStatistics(min, max, sum, histYAngleAxis, histNBins); + else + GetStatistics(min, max, sum, histYAxis[0], histNBins); + lblMinDisp->setText(QString("%1").arg(min)); + lblMaxDisp->setText(QString("%1").arg(max)); + lblSumDisp->setText(QString("%1").arg(sum)); + } + } - if(saveAll) SavePlotAutomatic(); - - } - }//2-d plot stuff - else{ - if(lastImageArray){ - if(nPixelsX>0&&nPixelsY>0){ - plot2D->GetPlot()->SetData(nPixelsX,-0.5,nPixelsX-0.5,nPixelsY,startPixel,endPixel,lastImageArray); - plot2D->setTitle(GetImageTitle()); - plot2D->SetXTitle(imageXAxisTitle); - plot2D->SetYTitle(imageYAxisTitle); - plot2D->SetZTitle(imageZAxisTitle); - plot2D->UpdateNKeepSetRangeIfSet(); //keep a "set" z range, and call Update(); - if (gainPlotEnable) { - gainplot2D->GetPlot()->SetData(nPixelsX,-0.5,nPixelsX-0.5,nPixelsY,startPixel,endPixel,gainImageArray); - gainplot2D->setTitle(GetImageTitle()); - gainplot2D->show(); - }else { - gainplot2D->hide(); - } - } - // update range if required - if(XYRangeChanged){ - if(!IsXYRange[qDefs::XMINIMUM]) XYRangeValues[qDefs::XMINIMUM]= plot2D->GetPlot()->GetXMinimum(); - if(!IsXYRange[qDefs::XMAXIMUM]) XYRangeValues[qDefs::XMAXIMUM]= plot2D->GetPlot()->GetXMaximum(); - if(!IsXYRange[qDefs::YMINIMUM]) XYRangeValues[qDefs::YMINIMUM]= plot2D->GetPlot()->GetYMinimum(); - if(!IsXYRange[qDefs::YMAXIMUM]) XYRangeValues[qDefs::YMAXIMUM]= plot2D->GetPlot()->GetYMaximum(); - plot2D->GetPlot()->SetXMinMax(XYRangeValues[qDefs::XMINIMUM],XYRangeValues[qDefs::XMAXIMUM]); - plot2D->GetPlot()->SetYMinMax(XYRangeValues[qDefs::YMINIMUM],XYRangeValues[qDefs::YMAXIMUM]); - gainplot2D->GetPlot()->SetXMinMax(XYRangeValues[qDefs::XMINIMUM],XYRangeValues[qDefs::XMAXIMUM]); - gainplot2D->GetPlot()->SetYMinMax(XYRangeValues[qDefs::YMINIMUM],XYRangeValues[qDefs::YMAXIMUM]); - XYRangeChanged = false; - } - plot2D->GetPlot()->Update(); - if (gainPlotEnable) { - gainplot2D->GetPlot()->Update(); - gainplot2D->setFixedWidth(plot2D->width()/4); - gainplot2D->setFixedHeight(plot2D->height()/4); - gainplot2D->show(); - }else - gainplot2D->hide(); - //Display Statistics - if(displayStatistics){ - double min=0,max=0,sum=0; - GetStatistics(min,max,sum,lastImageArray,nPixelsX*nPixelsY); - lblMinDisp->setText(QString("%1").arg(min)); - lblMaxDisp->setText(QString("%1").arg(max)); - lblSumDisp->setText(QString("%1").arg(sum)); - } - if(saveAll) SavePlotAutomatic(); - } - } - //set plot title - boxPlot->setTitle(plotTitle); - //to notify the measurement finished when its done - plotRequired = false; - UnlockLastImageArray(); - } + if (saveAll) + SavePlotAutomatic(); + } + } //2-d plot stuff + else { + if (lastImageArray) { + if (nPixelsX > 0 && nPixelsY > 0) { + plot2D->GetPlot()->SetData(nPixelsX, -0.5, nPixelsX - 0.5, nPixelsY, startPixel, endPixel, lastImageArray); + plot2D->setTitle(GetImageTitle()); + plot2D->SetXTitle(imageXAxisTitle); + plot2D->SetYTitle(imageYAxisTitle); + plot2D->SetZTitle(imageZAxisTitle); + plot2D->UpdateNKeepSetRangeIfSet(); //keep a "set" z range, and call Update(); + if (gainPlotEnable) { + gainplot2D->GetPlot()->SetData(nPixelsX, -0.5, nPixelsX - 0.5, nPixelsY, startPixel, endPixel, gainImageArray); + gainplot2D->setTitle(GetImageTitle()); + gainplot2D->show(); + } else { + gainplot2D->hide(); + } + } + // update range if required + if (XYRangeChanged) { + if (!IsXYRange[qDefs::XMINIMUM]) + XYRangeValues[qDefs::XMINIMUM] = plot2D->GetPlot()->GetXMinimum(); + if (!IsXYRange[qDefs::XMAXIMUM]) + XYRangeValues[qDefs::XMAXIMUM] = plot2D->GetPlot()->GetXMaximum(); + if (!IsXYRange[qDefs::YMINIMUM]) + XYRangeValues[qDefs::YMINIMUM] = plot2D->GetPlot()->GetYMinimum(); + if (!IsXYRange[qDefs::YMAXIMUM]) + XYRangeValues[qDefs::YMAXIMUM] = plot2D->GetPlot()->GetYMaximum(); + plot2D->GetPlot()->SetXMinMax(XYRangeValues[qDefs::XMINIMUM], XYRangeValues[qDefs::XMAXIMUM]); + plot2D->GetPlot()->SetYMinMax(XYRangeValues[qDefs::YMINIMUM], XYRangeValues[qDefs::YMAXIMUM]); + gainplot2D->GetPlot()->SetXMinMax(XYRangeValues[qDefs::XMINIMUM], XYRangeValues[qDefs::XMAXIMUM]); + gainplot2D->GetPlot()->SetYMinMax(XYRangeValues[qDefs::YMINIMUM], XYRangeValues[qDefs::YMAXIMUM]); + XYRangeChanged = false; + } + plot2D->GetPlot()->Update(); + if (gainPlotEnable) { + gainplot2D->GetPlot()->Update(); + gainplot2D->setFixedWidth(plot2D->width() / 4); + gainplot2D->setFixedHeight(plot2D->height() / 4); + gainplot2D->show(); + } else + gainplot2D->hide(); + //Display Statistics + if (displayStatistics) { + double min = 0, max = 0, sum = 0; + GetStatistics(min, max, sum, lastImageArray, nPixelsX * nPixelsY); + lblMinDisp->setText(QString("%1").arg(min)); + lblMaxDisp->setText(QString("%1").arg(max)); + lblSumDisp->setText(QString("%1").arg(sum)); + } + if (saveAll) + SavePlotAutomatic(); + } + } + //set plot title + boxPlot->setTitle(plotTitle); + //to notify the measurement finished when its done + plotRequired = false; + UnlockLastImageArray(); + } #ifdef VERYVERBOSE - cout << "Exiting UpdatePlot function" << endl; + std::cout << "Exiting UpdatePlot function\n"; #endif } - //------------------------------------------------------------------------------------------------------------------------------------------------- +void qDrawPlot::ClonePlot() { + int i; -void qDrawPlot::ClonePlot(){ - int i; + //check for space for more clone widget references + bool found = false; + for (i = 0; i < MAXCloneWindows; ++i) + if (!winClone[i]) { + found = true; + break; + } + // no space + if (!found) { + std::cout << "Too many clones\n"; + exit(-1); + } - //check for space for more clone widget references - bool found = false; - for(i=0;igetFilePath(); + qDefs::checkErrorMessage(myDet, "qDrawPlot::ClonePlot"); + } + LockLastImageArray(); - //get file path while acquisition runnign without accessing shared memory - string sFilePath; - if(running) sFilePath = filePath.toAscii().constData(); - else { - sFilePath = myDet->getFilePath(); - qDefs::checkErrorMessage(myDet,"qDrawPlot::ClonePlot"); - } + // create clone & copy data + if (plot_in_scope == 1) { + winClone[i] = new qCloneWidget(this, i, boxPlot->title(), histXAxisTitle, histYAxisTitle, "", + (int)plot_in_scope, sFilePath, displayStatistics, lblMinDisp->text(), lblMaxDisp->text(), lblSumDisp->text()); + if (!anglePlot) + winClone[i]->SetCloneHists((int)nHists, histNBins, histXAxis, histYAxis, histTitle, lines, markers); + else + winClone[i]->SetCloneHists((int)nHists, histNBins, histXAngleAxis, histYAngleAxis, histTitle, lines, markers); + } else { + winClone[i] = new qCloneWidget(this, i, boxPlot->title(), imageXAxisTitle, imageYAxisTitle, imageZAxisTitle, + (int)plot_in_scope, sFilePath, displayStatistics, lblMinDisp->text(), lblMaxDisp->text(), lblSumDisp->text()); + winClone[i]->SetCloneHists2D(nPixelsX, -0.5, nPixelsX - 0.5, nPixelsY, startPixel, endPixel, lastImageArray); + } + // update range + found = false; + for (int index = 0; index < 4; ++index) + if (IsXYRange[index]) { + found = true; + break; + } + if (found) + winClone[i]->SetRange(IsXYRange, XYRangeValues); - LockLastImageArray(); + UnlockLastImageArray(); + winClone[i]->show(); - // create clone & copy data - if(plot_in_scope==1){ - winClone[i] = new qCloneWidget(this,i,boxPlot->title(),histXAxisTitle,histYAxisTitle,"", - (int)plot_in_scope,sFilePath,displayStatistics,lblMinDisp->text(),lblMaxDisp->text(),lblSumDisp->text()); - if(!anglePlot) - winClone[i]->SetCloneHists((int)nHists,histNBins,histXAxis,histYAxis,histTitle,lines,markers); - else - winClone[i]->SetCloneHists((int)nHists,histNBins,histXAngleAxis,histYAngleAxis,histTitle,lines,markers); - - }else{ - winClone[i] = new qCloneWidget(this,i,boxPlot->title(),imageXAxisTitle, imageYAxisTitle, imageZAxisTitle, - (int)plot_in_scope,sFilePath,displayStatistics,lblMinDisp->text(),lblMaxDisp->text(),lblSumDisp->text()); - winClone[i]->SetCloneHists2D(nPixelsX,-0.5,nPixelsX-0.5,nPixelsY,startPixel,endPixel,lastImageArray); - } - - // update range - found =false; - for(int index=0;index<4;index++) - if(IsXYRange[index]){ - found=true; - break; - } - if(found) - winClone[i]->SetRange(IsXYRange,XYRangeValues); - - - UnlockLastImageArray(); - - winClone[i]->show(); - - // to remember which all clone widgets were closed - connect(winClone[i], SIGNAL(CloneClosedSignal(int)),this, SLOT(CloneCloseEvent(int))); + // to remember which all clone widgets were closed + connect(winClone[i], SIGNAL(CloneClosedSignal(int)), this, SLOT(CloneCloseEvent(int))); } - //------------------------------------------------------------------------------------------------------------------------------------------------- - -void qDrawPlot::SaveClones(){ - char errID[200]; - string errMessage= "The Snapshots with ID's: "; - bool success = true; - for(int i=0;iSavePlotAutomatic()){ - success = false; - sprintf(errID,"%d",i); - errMessage.append(string(errID)+string(", ")); - } - } - if(success) - qDefs::Message(qDefs::INFORMATION,"The Snapshots have all been saved successfully in .png.","Dock"); - else - qDefs::Message(qDefs::WARNING,errMessage + string("were not saved."),"qDrawPlot::SaveClones"); +void qDrawPlot::SaveClones() { + char errID[200]; + std::string errMessage = "The Snapshots with ID's: "; + bool success = true; + for (int i = 0; i < MAXCloneWindows; ++i) + if (winClone[i]) { + if (winClone[i]->SavePlotAutomatic()) { + success = false; + sprintf(errID, "%d", i); + errMessage.append(std::string(errID) + std::string(", ")); + } + } + if (success) + qDefs::Message(qDefs::INFORMATION, "The Snapshots have all been saved successfully in .png.", "Dock"); + else + qDefs::Message(qDefs::WARNING, errMessage + std::string("were not saved."), "qDrawPlot::SaveClones"); } - //------------------------------------------------------------------------------------------------------------------------------------------------- - -void qDrawPlot::CloseClones(){ - for(int i=0;iclose(); - +void qDrawPlot::CloseClones() { + for (int i = 0; i < MAXCloneWindows; ++i) + if (winClone[i]) + winClone[i]->close(); } - //------------------------------------------------------------------------------------------------------------------------------------------------- - -void qDrawPlot::CloneCloseEvent(int id){ - winClone[id]=0; +void qDrawPlot::CloneCloseEvent(int id) { + winClone[id] = 0; #ifdef VERBOSE - cout << "Closing Clone Window id:" << id << endl; + std::cout << "Closing Clone Window id:" << id << '\n'; #endif } - //------------------------------------------------------------------------------------------------------------------------------------------------- +void qDrawPlot::SavePlot() { + // render image + QImage savedImage(size().width(), size().height(), QImage::Format_RGB32); + QPainter painter(&savedImage); + render(&painter); -void qDrawPlot::SavePlot(){ - // render image - QImage savedImage(size().width(),size().height(),QImage::Format_RGB32); - QPainter painter(&savedImage); - render(&painter); + QString fName; + if (running) + fName = filePath; + else { + fName = QString(myDet->getFilePath().c_str()); + qDefs::checkErrorMessage(myDet, "qDrawPlot::SavePlot"); + } - QString fName; - if(running) fName = filePath; - else { - fName = QString(myDet->getFilePath().c_str()); - qDefs::checkErrorMessage(myDet,"qDrawPlot::SavePlot"); - } + if (boxPlot->title().contains('.')) { + fName.append(QString('/') + boxPlot->title()); + fName.replace(".dat", ".png"); + fName.replace(".raw", ".png"); + } else + fName.append(QString("/Image.png")); - if(boxPlot->title().contains('.')){ - fName.append(QString('/')+boxPlot->title()); - fName.replace(".dat",".png"); - fName.replace(".raw",".png"); - }else fName.append(QString("/Image.png")); + fName = QFileDialog::getSaveFileName(0, tr("Save Image"), fName, tr("PNG Files (*.png);;XPM Files(*.xpm);;JPEG Files(*.jpg)"), 0, QFileDialog::ShowDirsOnly); - fName = QFileDialog::getSaveFileName(0,tr("Save Image"),fName,tr("PNG Files (*.png);;XPM Files(*.xpm);;JPEG Files(*.jpg)"),0,QFileDialog::ShowDirsOnly); - - if (!fName.isEmpty()) { - if(savedImage.save(fName)) - qDefs::Message(qDefs::INFORMATION,"The Image has been successfully saved","qDrawPlot::SavePlot"); - else - qDefs::Message(qDefs::WARNING,"Attempt to save image failed.\n" - "Formats: .png, .jpg, .xpm.","qDrawPlot::SavePlot"); - } + if (!fName.isEmpty()) { + if (savedImage.save(fName)) + qDefs::Message(qDefs::INFORMATION, "The Image has been successfully saved", "qDrawPlot::SavePlot"); + else + qDefs::Message(qDefs::WARNING, "Attempt to save image failed.\n" + "Formats: .png, .jpg, .xpm.", + "qDrawPlot::SavePlot"); + } } - //------------------------------------------------------------------------------------------------------------------------------------------------- +void qDrawPlot::SavePlotAutomatic() { + //no need to save the same plot many times + if ((currentFrame > lastSavedFrame) && (currentMeasurement >= lastSavedMeasurement)) { -void qDrawPlot::SavePlotAutomatic(){ - //no need to save the same plot many times - if((currentFrame>lastSavedFrame)&&(currentMeasurement>=lastSavedMeasurement)){ + QString qFilePath; + if (running) + qFilePath = filePath; + else { + qFilePath = QString(myDet->getFilePath().c_str()); + qDefs::checkErrorMessage(myDet, "qDrawPlot::SavePlotAutomatic"); + } - QString qFilePath; - if(running) qFilePath = filePath; - else { - qFilePath = QString(myDet->getFilePath().c_str()); - qDefs::checkErrorMessage(myDet,"qDrawPlot::SavePlotAutomatic"); - } - - - lastSavedFrame = currentFrame; - lastSavedMeasurement = currentMeasurement; - char cID[10]; - sprintf(cID,"%d",lastSavedFrame); - //title - QString fName = qFilePath; - if(boxPlot->title().contains('.')){ - fName.append(QString('/')+boxPlot->title()); - fName.replace(".dat",".png"); - fName.replace(".raw",".png"); - }else fName.append(QString("/Image_unknown_title.png")); - //save - QImage img(size().width(),size().height(),QImage::Format_RGB32); - QPainter painter(&img); - render(&painter); - //if error while saving - if(!img.save(fName)){ - //mention the error only the first time - if(!saveError){ - //so it doesnt repeat again - saveError = true; - connect(this,SIGNAL(saveErrorSignal(QString)),this,SLOT(ShowSaveErrorMessage(QString))); - emit saveErrorSignal(fName); - } - } - } + lastSavedFrame = currentFrame; + lastSavedMeasurement = currentMeasurement; + char cID[10]; + sprintf(cID, "%d", lastSavedFrame); + //title + QString fName = qFilePath; + if (boxPlot->title().contains('.')) { + fName.append(QString('/') + boxPlot->title()); + fName.replace(".dat", ".png"); + fName.replace(".raw", ".png"); + } else + fName.append(QString("/Image_unknown_title.png")); + //save + QImage img(size().width(), size().height(), QImage::Format_RGB32); + QPainter painter(&img); + render(&painter); + //if error while saving + if (!img.save(fName)) { + //mention the error only the first time + if (!saveError) { + //so it doesnt repeat again + saveError = true; + connect(this, SIGNAL(saveErrorSignal(QString)), this, SLOT(ShowSaveErrorMessage(QString))); + emit saveErrorSignal(fName); + } + } + } } - //------------------------------------------------------------------------------------------------------------------------------------------------- - -void qDrawPlot::ShowSaveErrorMessage(QString fileName){ - qDefs::Message(qDefs::WARNING,string("Automatic Saving: Could not save the first file:\n")+ - string(fileName.toAscii().constData()) + string("\n\nNote: Will not show future file save errors for this acquisition."),"qDrawPlot::ShowSaveErrorMessage"); - +void qDrawPlot::ShowSaveErrorMessage(QString fileName) { + qDefs::Message(qDefs::WARNING, std::string("Automatic Saving: Could not save the first file:\n") + std::string(fileName.toAscii().constData()) + std::string("\n\nNote: Will not show future file save errors for this acquisition."), "qDrawPlot::ShowSaveErrorMessage"); } - //------------------------------------------------------------------------------------------------------------------------------------------------- - -void qDrawPlot::SetPersistency(int val){ - for(int i=0;i<=val;i++) - if(!histYAxis[i]) histYAxis[i] = new double [nPixelsX]; - persistency = val; +void qDrawPlot::SetPersistency(int val) { + for (int i = 0; i <= val; ++i) + if (!histYAxis[i]) + histYAxis[i] = new double[nPixelsX]; + persistency = val; } - //------------------------------------------------------------------------------------------------------------------------------------------------- - -void qDrawPlot::EnablePlot(bool enable){ +void qDrawPlot::EnablePlot(bool enable) { #ifdef VERBOSE - cout << "Plotting set to:" << enable << endl; + std::cout << "Plotting set to:" << enable << '\n'; #endif - plotEnable = enable; - //if no plot, cant do setting range. - // not true vice versa where plot was false and now set it to true - Clear1DPlot(); - -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qDrawPlot::DisableZoom(bool disable){ - if(plot_in_scope==1) - plot1D->DisableZoom(disable); - else - plot2D->GetPlot()->DisableZoom(disable); -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -int qDrawPlot::UpdateTrimbitPlot(bool fromDetector,bool Histogram){ - int ret,actualPixelsX; - double min=0,max=0,sum=0; -#ifdef VERBOSE - if(fromDetector) cout << "Geting Trimbits from Detector" << endl; - else cout << "Getting Trimbits from Shared Memory" << endl; -#endif - - LockLastImageArray(); - - if(detType == slsDetectorDefs::MYTHEN){ - - //get trimbits - actualPixelsX = myDet->getTotalNumberOfChannels(slsDetectorDefs::X); - if(histTrimbits) delete [] histTrimbits; histTrimbits = new double[actualPixelsX]; - ret = myDet->getChanRegs(histTrimbits,fromDetector); - // cout << "got it!" << endl; - if(!ret){ - qDefs::Message(qDefs::WARNING,"No Trimbit data found in shared memory.","qDrawPlot::UpdateTrimbitPlot"); - UnlockLastImageArray(); - return qDefs::FAIL; - } -#ifdef VERBOSE - cout << "Got Trimbits" << endl; -#endif - - qDefs::checkErrorMessage(myDet,"qDrawPlot::UpdateTrimbitPlot"); - - //clear/select plot and set titles - Select1DPlot(); - Clear1DPlot(); - - //Display Statistics - if(displayStatistics){ - GetStatistics(min,max,sum,histTrimbits,actualPixelsX); - lblMinDisp->setText(QString("%1").arg(min)); - lblMaxDisp->setText(QString("%1").arg(max)); - lblSumDisp->setText(QString("%1").arg(sum)); - } - - - if(!Histogram){ - cout << "Data Graph:" << nPixelsX << endl; - - //initialize - nPixelsX = actualPixelsX; - if(histXAxis) delete [] histXAxis; histXAxis = new double [nPixelsX]; - if(histYAxis[0]) delete [] histYAxis[0]; histYAxis[0]= new double [nPixelsX]; - //initializing - for(unsigned int px=0;pxsetTitle("Trimbits_Plot_Data Graph"); - plot1D->SetXTitle("Channel Number"); - plot1D->SetYTitle("Trimbits"); - //set plot parameters - plot1D->SetXMinMax(0,nPixelsX); - /*plot1D->SetYMinMax(0,plotHistogram->boundingRect().height()); plot1D->SetZoomBase(0,0,nPixelsX,plot1D->GetYMaximum());*/ - //for some reason this plothistogram works as well. - plot1D->SetZoomBase(0,0,nPixelsX,plotHistogram->boundingRect().height()); - SlsQtH1D* h; - plot1D_hists.append(h=new SlsQtH1D("",nPixelsX,histXAxis,histYAxis[0])); - h->SetLineColor(0); - histFrameIndexTitle->setText(GetHistTitle(0)); - //attach plot - h->Attach(plot1D); - //refixing all the zooming - /*plot1D->SetXMinMax(h->minXValue(),h->maxXValue()); - plot1D->SetYMinMax(h->minYValue(),h->maxYValue()); - plot1D->SetZoomBase(h->minXValue(),h->minYValue(), - h->maxXValue()-h->minXValue(),h->maxYValue()-h->minYValue());*/ - } - - else{ - cout << "Histogram: " << TRIM_HISTOGRAM_XMAX << endl; - - //create intervals - histogramSamples.resize(TRIM_HISTOGRAM_XMAX+1); - for(unsigned int i=0; i= 0)){//if(histogramSamples[j].interval.contains(data->values[i])) - value = (int) histTrimbits[i]; - histogramSamples[value].value += 1; - } - else cout<<"OUT OF BOUNDS:"<setTitle("Trimbits_Plot_Histogram"); - plot1D->SetXTitle("Trimbits"); - plot1D->SetYTitle("Frequency"); - plotHistogram->setData(new QwtIntervalSeriesData(histogramSamples)); - plotHistogram->setPen(QPen(Qt::red)); - plotHistogram->setBrush(QBrush(Qt::red,Qt::Dense4Pattern));//Qt::SolidPattern - histFrameIndexTitle->setText(GetHistTitle(0)); - plotHistogram->attach(plot1D); - //refixing all the zooming - plot1D->SetXMinMax(0,TRIM_HISTOGRAM_XMAX+1); - plot1D->SetYMinMax(0,plotHistogram->boundingRect().height()); - plot1D->SetZoomBase(0,0,actualPixelsX,plotHistogram->boundingRect().height()); - } - } - - - /**needs to be changed */ - else if(detType == slsDetectorDefs::EIGER){ - - //defining axes - nPixelsX = 100;/**??*/ - nPixelsY = 100; - if(lastImageArray) delete [] lastImageArray; lastImageArray = new double[nPixelsY*nPixelsX]; - //initializing 2d array - memset(lastImageArray, 0 ,nPixelsY * nPixelsX * sizeof(double)); - /* - for(int py=0;py<(int)nPixelsY;py++) - for(int px=0;px<(int)nPixelsX;px++) - lastImageArray[py*nPixelsX+px] = 0; - */ - //get trimbits - ret = 1;/*myDet->getChanRegs(lastImageArray,fromDetector);*/ - if(!ret){ - qDefs::Message(qDefs::WARNING,"No Trimbit data found in shared memory.","qDrawPlot::UpdateTrimbitPlot"); - UnlockLastImageArray(); - return qDefs::FAIL; - } - //clear/select plot and set titles - Select2DPlot(); - plot2D->GetPlot()->SetData(nPixelsX,-0.5,nPixelsX-0.5,nPixelsY,-0.5,nPixelsY-0.5,lastImageArray); - plot2D->setTitle("Image"); - plot2D->SetXTitle("Pixel"); - plot2D->SetYTitle("Pixel"); - plot2D->SetZTitle("Trimbits"); - plot2D->UpdateNKeepSetRangeIfSet(); -#ifdef VERBOSE - cout << "Trimbits Plot updated" << endl; -#endif - - //Display Statistics - if(displayStatistics){ - GetStatistics(min,max,sum,lastImageArray,nPixelsX*nPixelsY); - lblMinDisp->setText(QString("%1").arg(min)); - lblMaxDisp->setText(QString("%1").arg(max)); - lblSumDisp->setText(QString("%1").arg(sum)); - } - - } - - UnlockLastImageArray(); -#ifdef VERBOSE - cout << "Trimbits Plot updated" << endl; -#endif - return qDefs::OK; -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qDrawPlot::SetPedestal(bool enable){ -#ifdef VERBOSE - cout << "Setting Pedestal to " << enable << endl; -#endif - if(enable){ - pedestal = true; - if(pedestalVals == 0) - RecalculatePedestal(); - }else{ - pedestal = false; - } -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qDrawPlot::RecalculatePedestal(){ -#ifdef VERBOSE - cout << "Recalculating Pedestal" << endl; -#endif - LockLastImageArray(); - startPedestalCal = 1; - pedestalCount = 0; - - //create array - if(pedestalVals) delete [] pedestalVals; pedestalVals = new double[nPixelsX*nPixelsY]; - if(tempPedestalVals) delete [] tempPedestalVals; tempPedestalVals = new double[nPixelsX*nPixelsY]; - //reset all values - for(unsigned int px=0;px<(nPixelsX*nPixelsY);px++) - pedestalVals[px] = 0; - for(unsigned int px=0;px<(nPixelsX*nPixelsY);px++) - tempPedestalVals[px] = 0; - UnlockLastImageArray(); -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qDrawPlot::SetAccumulate(bool enable){ -#ifdef VERBOSE - cout << "Setting Accumulate to " << enable << endl; -#endif - accumulate = enable; + plotEnable = enable; + //if no plot, cant do setting range. + // not true vice versa where plot was false and now set it to true + Clear1DPlot(); } //------------------------------------------------------------------------------------------------------------------------------------------------- - -void qDrawPlot::ResetAccumulate(){ -#ifdef VERBOSE - cout << "Resetting Accumulation" << endl; -#endif - LockLastImageArray(); - resetAccumulate = true; - UnlockLastImageArray(); -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qDrawPlot::SetPlotTimer(double time){ - timerValue = time; - if(myDet->setReceiverOnline()==slsDetectorDefs::ONLINE_FLAG){ - time = myDet->setReceiverReadTimer(timerValue); -#ifdef VERBOSE - cout << "Receiver read timer set to : " << time << endl; -#endif - qDefs::checkErrorMessage(myDet,"qDrawPlot::SetPlotTimer"); - } +void qDrawPlot::DisableZoom(bool disable) { + if (plot_in_scope == 1) + plot1D->DisableZoom(disable); + else + plot2D->GetPlot()->DisableZoom(disable); } //------------------------------------------------------------------------------------------------------------------------------------------------- + int qDrawPlot::UpdateTrimbitPlot(bool fromDetector,bool Histogram){ + int ret; + double min=0,max=0,sum=0; + #ifdef VERBOSE + if(fromDetector) std::cout << "Geting Trimbits from Detector" <<'\n'; + else std::cout << "Getting Trimbits from Shared Memory" <<'\n'; + #endif -void qDrawPlot::SetFrameFactor(int frame){ - frameFactor = frame; - if(myDet->setReceiverOnline()==slsDetectorDefs::ONLINE_FLAG){ - frame = myDet->setReadReceiverFrequency(frame); + LockLastImageArray(); + + if(detType == slsDetectorDefs::EIGER){ + + //defining axes + nPixelsX = 100;/**??*/ + nPixelsY = 100; + if(lastImageArray) delete [] lastImageArray; lastImageArray = new double[nPixelsY*nPixelsX]; + //initializing 2d array + memset(lastImageArray, 0 ,nPixelsY * nPixelsX * sizeof(double)); + /* + for(int py=0;py<(int)nPixelsY;++py) + for(int px=0;px<(int)nPixelsX;++px) + lastImageArray[py*nPixelsX+px] = 0; + */ + //get trimbits + ret = 1;/*myDet->getChanRegs(lastImageArray,fromDetector);*/ + if(!ret){ + qDefs::Message(qDefs::WARNING,"No Trimbit data found in shared memory.","qDrawPlot::UpdateTrimbitPlot"); + UnlockLastImageArray(); + return qDefs::FAIL; + } + //clear/select plot and set titles + Select2DPlot(); + plot2D->GetPlot()->SetData(nPixelsX,-0.5,nPixelsX-0.5,nPixelsY,-0.5,nPixelsY-0.5,lastImageArray); + plot2D->setTitle("Image"); + plot2D->SetXTitle("Pixel"); + plot2D->SetYTitle("Pixel"); + plot2D->SetZTitle("Trimbits"); + plot2D->UpdateNKeepSetRangeIfSet(); + #ifdef VERBOSE + std::cout << "Trimbits Plot updated" <<'\n'; + #endif + + //Display Statistics + if(displayStatistics){ + GetStatistics(min,max,sum,lastImageArray,nPixelsX*nPixelsY); + lblMinDisp->setText(QString("%1").arg(min)); + lblMaxDisp->setText(QString("%1").arg(max)); + lblSumDisp->setText(QString("%1").arg(sum)); + } + + } + + UnlockLastImageArray(); + #ifdef VERBOSE + std::cout << "Trimbits Plot updated" <<'\n'; + #endif + return qDefs::OK; + } + +//------------------------------------------------------------------------------------------------------------------------------------------------- + +void qDrawPlot::SetPedestal(bool enable) { #ifdef VERBOSE - cout << "Receiver read frequency set to : " << frame << endl; + std::cout << "Setting Pedestal to " << enable << '\n'; #endif - } + if (enable) { + pedestal = true; + if (pedestalVals == 0) + RecalculatePedestal(); + } else { + pedestal = false; + } } //------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qDrawPlot::UpdateAfterCloning(bool points, bool logy, bool interpolate, bool contour, bool logz){ +void qDrawPlot::RecalculatePedestal() { #ifdef VERBOSE - cout << endl << "**Updating Plot After Cloning" << endl; + std::cout << "Recalculating Pedestal\n"; #endif + LockLastImageArray(); + startPedestalCal = 1; + pedestalCount = 0; - //1d - if(plot_in_scope == 1){ - SetMarkers(points); - emit LogySignal(logy); - } - //2d - else{ - emit InterpolateSignal(interpolate); - emit ContourSignal(contour); - emit LogzSignal(logz); - } - + //create array + if (pedestalVals) + delete[] pedestalVals; + pedestalVals = new double[nPixelsX * nPixelsY]; + if (tempPedestalVals) + delete[] tempPedestalVals; + tempPedestalVals = new double[nPixelsX * nPixelsY]; + //reset all values + for (unsigned int px = 0; px < (nPixelsX * nPixelsY); ++px) + pedestalVals[px] = 0; + for (unsigned int px = 0; px < (nPixelsX * nPixelsY); ++px) + tempPedestalVals[px] = 0; + UnlockLastImageArray(); } - //------------------------------------------------------------------------------------------------------------------------------------------------- - -void qDrawPlot::SetBinary(bool enable, int from, int to){ +void qDrawPlot::SetAccumulate(bool enable) { #ifdef VERBOSE - if(!enable) - cout << "Disabling Binary output " << endl; - else - cout << "Enabling Binary output from " << from << " to " << to << endl; + std::cout << "Setting Accumulate to " << enable << '\n'; #endif - binary = enable; - binaryFrom = from; - binaryTo = to; + accumulate = enable; } - //------------------------------------------------------------------------------------------------------------------------------------------------- - -void qDrawPlot::DisplayStatistics(bool enable){ +void qDrawPlot::ResetAccumulate() { #ifdef VERBOSE - if(!enable) - cout << "Disabling Statistics Display" << endl; - else - cout << "Enabling Statistics Display" << endl; + std::cout << "Resetting Accumulation" << '\n'; #endif - if(enable) widgetStatistics->show(); - else widgetStatistics->hide(); - - displayStatistics = enable; - lblMinDisp->setText("-"); - lblMaxDisp->setText("-"); - lblSumDisp->setText("-"); + LockLastImageArray(); + resetAccumulate = true; + UnlockLastImageArray(); } - //------------------------------------------------------------------------------------------------------------------------------------------------- +void qDrawPlot::SetPlotTimer(double time) { + // timerValue = time; + // if(myDet->setReceiverOnline()==slsDetectorDefs::ONLINE_FLAG){ + // time = myDet->setReceiverReadTimer(timerValue); + // #ifdef VERBOSE + // std::cout << "Receiver read timer set to : " << time <<'\n'; + // #endif + // qDefs::checkErrorMessage(myDet,"qDrawPlot::SetPlotTimer"); + // } +} -void qDrawPlot::GetStatistics(double &min, double &max, double &sum, double* array, int size){ +//------------------------------------------------------------------------------------------------------------------------------------------------- + +void qDrawPlot::SetFrameFactor(int frame) { + // frameFactor = frame; + // if(myDet->setReceiverOnline()==slsDetectorDefs::ONLINE_FLAG){ + // frame = myDet->setReadReceiverFrequency(frame); + // #ifdef VERBOSE + // std::cout << "Receiver read frequency set to : " << frame <<'\n'; + // #endif + // } +} + +//------------------------------------------------------------------------------------------------------------------------------------------------- + +void qDrawPlot::UpdateAfterCloning(bool points, bool logy, bool interpolate, bool contour, bool logz) { +#ifdef VERBOSE + std::cout << "**Updating Plot After Cloning\n"; +#endif + + //1d + if (plot_in_scope == 1) { + SetMarkers(points); + emit LogySignal(logy); + } + //2d + else { + emit InterpolateSignal(interpolate); + emit ContourSignal(contour); + emit LogzSignal(logz); + } +} + +//------------------------------------------------------------------------------------------------------------------------------------------------- + +void qDrawPlot::SetBinary(bool enable, int from, int to) { +#ifdef VERBOSE + if (!enable) + std::cout << "Disabling Binary output \n"; + else + std::cout << "Enabling Binary output from " << from << " to " << to << '\n'; +#endif + binary = enable; + binaryFrom = from; + binaryTo = to; +} + +//------------------------------------------------------------------------------------------------------------------------------------------------- + +void qDrawPlot::DisplayStatistics(bool enable) { +#ifdef VERBOSE + if (!enable) + std::cout << "Disabling Statistics Display\n"; + else + std::cout << "Enabling Statistics Display\n"; +#endif + if (enable) + widgetStatistics->show(); + else + widgetStatistics->hide(); + + displayStatistics = enable; + lblMinDisp->setText("-"); + lblMaxDisp->setText("-"); + lblSumDisp->setText("-"); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------- + +void qDrawPlot::GetStatistics(double &min, double &max, double &sum, double *array, int size) { #ifdef VERYVERBOSE - cout << "Calculating Statistics" << endl; + std::cout << "Calculating Statistics\n"; #endif - for(int i=0; i < size; i++){ - //calculate min - if(array[i] < min) - min = array[i]; - //calculate max - if(array[i] > max) - max = array[i]; - //calculate sum - sum += array[i]; - } + for (int i = 0; i < size; ++i) { + //calculate min + if (array[i] < min) + min = array[i]; + //calculate max + if (array[i] > max) + max = array[i]; + //calculate sum + sum += array[i]; + } } - //------------------------------------------------------------------------------------------------------------------------------------------------- - void qDrawPlot::EnableGainPlot(bool e) { #ifdef VERBOSE - cout << "Setting Gain Data enable to " << e << endl; + std::cout << "Setting Gain Data enable to " << e << '\n'; #endif - gainDataEnable = e; + gainDataEnable = e; } - //------------------------------------------------------------------------------------------------------------------------------------------------- -void qDrawPlot::toDoublePixelData(double* dest, char* source,int size, int databytes, int dr, double* gaindest) { - int ichan=0; - int ibyte=0; - int halfbyte=0; - char cbyte = '\0'; - int mask=0x00ffffff; +void qDrawPlot::toDoublePixelData(double *dest, char *source, int size, int databytes, int dr, double *gaindest) { + int ichan = 0; + int ibyte = 0; + int halfbyte = 0; + char cbyte = '\0'; - switch(dr) { + switch (dr) { - case 4: - for (ibyte = 0; ibyte < databytes; ++ibyte) { - cbyte = source[ibyte]; - for (halfbyte = 1; halfbyte >= 0; --halfbyte) { - dest[ichan] = (cbyte >> (halfbyte * 4)) & 0xf; - ++ichan; - } - } - break; + case 4: + for (ibyte = 0; ibyte < databytes; ++ibyte) { + cbyte = source[ibyte]; + for (halfbyte = 1; halfbyte >= 0; --halfbyte) { + dest[ichan] = (cbyte >> (halfbyte * 4)) & 0xf; + ++ichan; + } + } + break; - case 8: - for (ichan = 0; ichan < databytes; ++ichan) { - dest[ichan] = *((u_int8_t*)source); - ++source; - } - break; + case 8: + for (ichan = 0; ichan < databytes; ++ichan) { + dest[ichan] = *((u_int8_t *)source); + ++source; + } + break; - case 16: - if (detType == slsDetectorDefs::JUNGFRAU || detType == slsDetectorDefs::CHIPTESTBOARD) { + case 16: + if (detType == slsDetectorDefs::JUNGFRAU || detType == slsDetectorDefs::MOENCH) { - // show gain plot - if(gaindest!=NULL) { - for (ichan = 0; ichan < size; ++ichan) { - if ( (*((u_int16_t*)source)) == 0xFFFF ) { - gaindest[ichan] = 0xFFFF; - dest[ichan] = 0xFFFF; - } - else{ - gaindest[ichan] = (((*((u_int16_t*)source)) & 0xC000) >> 14); - dest[ichan] = ((*((u_int16_t*)source)) & 0x3FFF); - } - source += 2; - } - } + // show gain plot + if (gaindest != NULL) { + for (ichan = 0; ichan < size; ++ichan) { + if ((*((u_int16_t *)source)) == 0xFFFF) { + gaindest[ichan] = 0xFFFF; + dest[ichan] = 0xFFFF; + } else { + gaindest[ichan] = (((*((u_int16_t *)source)) & 0xC000) >> 14); + dest[ichan] = ((*((u_int16_t *)source)) & 0x3FFF); + } + source += 2; + } + } - // only data plot - else { - for (ichan = 0; ichan < size; ++ichan) { - /*if ( (*((u_int16_t*)source)) == 0xFFFF ) + // only data plot + else { + for (ichan = 0; ichan < size; ++ichan) { + /*if ( (*((u_int16_t*)source)) == 0xFFFF ) dest[ichan] = 0xFFFF; else*/ - dest[ichan] = ((*((u_int16_t*)source)) & 0x3FFF); - source += 2; - } - } - break; - } + dest[ichan] = ((*((u_int16_t *)source)) & 0x3FFF); + source += 2; + } + } + break; + } + // other detectors + for (ichan = 0; ichan < size; ++ichan) { + dest[ichan] = *((u_int16_t *)source); + source += 2; + } + break; - // other detectors - for (ichan = 0; ichan < size; ++ichan) { - dest[ichan] = *((u_int16_t*)source); - source += 2; - } - break; - - default: - if (detType == slsDetectorDefs::MYTHEN) { - for (ichan = 0; ichan < size; ++ichan) { - dest[ichan] = (*((u_int32_t*)source) & mask); - source += 4; - } - break; - } - - // other detectors - for (ichan = 0; ichan < size; ++ichan) { - dest[ichan] = *((u_int32_t*)source); - source += 4; - } - break; - } - + default: + for (ichan = 0; ichan < size; ++ichan) { + dest[ichan] = *((u_int32_t *)source); + source += 4; + } + break; + } } - diff --git a/slsDetectorGui/src/qScanWidget.cpp b/slsDetectorGui/src/qScanWidget.cpp deleted file mode 100644 index df21eb056..000000000 --- a/slsDetectorGui/src/qScanWidget.cpp +++ /dev/null @@ -1,1247 +0,0 @@ -/* - * qScanWidget.cpp - * - * Created on: May 10, 2012 - * Author: l_maliakal_d - */ -// Project Class Headers -#include "slsDetector.h" -#include "multiSlsDetector.h" -// Qt Project Class Headers -#include "qScanWidget.h" -// Qt Include Headers -#include -#include - -// C++ Include Headers -#include -#include -#include -#include -using namespace std; - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -int qScanWidget::NUM_SCAN_WIDGETS(0); -const string qScanWidget::modeNames[NumModes]={"","energy","threshold","trimbits","position","custom script"}; -//------------------------------------------------------------------------------------------------------------------------------------------------- - -qScanWidget::qScanWidget(QWidget *parent,multiSlsDetector*& detector): - QWidget(parent),myDet(detector),actualNumSteps(0){ - setupUi(this); - positions.resize(0); - SetupWidgetWindow(); - Initialization(); - LoadPositions(); -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -qScanWidget::~qScanWidget(){ - delete myDet; - delete stackedLayout; -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qScanWidget::SetupWidgetWindow(){ - id = NUM_SCAN_WIDGETS; - NUM_SCAN_WIDGETS++; - - setFixedHeight(125); - - btnGroup = new QButtonGroup(this); - btnGroup->addButton(radioRange,0); - btnGroup->addButton(radioCustom,1); - btnGroup->addButton(radioFile,2); - - - normal = radioCustom->palette(); - red = QPalette(); - red.setColor(QPalette::Active,QPalette::WindowText,Qt::red); - fileTip = radioFile->toolTip(); - customTip = radioCustom->toolTip(); - rangeTip = radioRange->toolTip(); - - //layout for the size widgets - stackedLayout = new QStackedLayout; - stackedLayout->setSpacing(0); - - - // Range Size Layout - QWidget *widgetRange = new QWidget; - QHBoxLayout *layoutRange = new QHBoxLayout(widgetRange); - layoutRange->setContentsMargins(0, 0, 0, 0); - lblFrom = new QLabel("from",widgetRange); - spinFrom = new QDoubleSpinBox(widgetRange); - lblTo = new QLabel("to",widgetRange); - spinTo = new QDoubleSpinBox(widgetRange); - lblSize = new QLabel("step size:",widgetRange); - spinSize = new QDoubleSpinBox(widgetRange); - lblFrom->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed); - lblFrom->setToolTip(rangeTip); - spinFrom->setValue(0); - spinFrom->setToolTip(rangeTip); - spinFrom->setMaximum(1000000); - spinFrom->setMinimum(-1000000); - spinFrom->setKeyboardTracking(false); - spinFrom->setFixedWidth(80); - spinFrom->setDecimals(2); - lblTo->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed); - lblTo->setToolTip(rangeTip); - lblTo->setFixedWidth(18); - spinTo->setValue(1); - spinTo->setToolTip(rangeTip); - spinTo->setMaximum(1000000); - spinTo->setMinimum(-1000000); - spinTo->setKeyboardTracking(false); - spinTo->setFixedWidth(80); - spinTo->setDecimals(2); - lblSize->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed); - lblSize->setToolTip(rangeTip); - lblSize->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed); - lblSize->setFixedWidth(67); - spinSize->setMaximum(1000000); - spinSize->setMinimum(-1000000); - spinSize->setValue(1); - spinSize->setSingleStep(0.1); - spinSize->setToolTip(rangeTip); - spinSize->setKeyboardTracking(false); - spinSize->setDecimals(2); - - //spinSize->setMinimum(0.0001); - layoutRange->addItem(new QSpacerItem(40,20,QSizePolicy::Fixed,QSizePolicy::Fixed)); - layoutRange->addWidget(lblFrom); - layoutRange->addItem(new QSpacerItem(5,20,QSizePolicy::Fixed,QSizePolicy::Fixed)); - layoutRange->addWidget(spinFrom); - layoutRange->addItem(new QSpacerItem(5,20,QSizePolicy::Fixed,QSizePolicy::Fixed)); - layoutRange->addWidget(lblTo); - layoutRange->addItem(new QSpacerItem(5,20,QSizePolicy::Fixed,QSizePolicy::Fixed)); - layoutRange->addWidget(spinTo); - layoutRange->addItem(new QSpacerItem(30,20,QSizePolicy::Fixed,QSizePolicy::Fixed)); - layoutRange->addWidget(lblSize); - layoutRange->addWidget(spinSize); - layoutRange->addItem(new QSpacerItem(40,20,QSizePolicy::Fixed,QSizePolicy::Fixed)); - - - // Custom Values Layout - QWidget *widgetCustom = new QWidget; - QHBoxLayout *layoutCustom = new QHBoxLayout(widgetCustom); - layoutCustom->setContentsMargins(0, 0, 0, 0); - comboCustom = new QComboBox(widgetCustom); - btnCustom = new QPushButton("Delete ",widgetCustom); - btnCustom->setIcon(QIcon( ":/icons/images/close.png" )); - comboCustom->setEditable(true); - comboCustom->setCompleter(NULL); - comboCustom->setValidator(new QDoubleValidator(comboCustom)); - comboCustom->setToolTip(customTip); - btnCustom->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed); - btnCustom->setToolTip("Deletes current position from list and reduces Number of Positions by 1."); - layoutCustom->addItem(new QSpacerItem(160,20,QSizePolicy::Fixed,QSizePolicy::Fixed)); - layoutCustom->addWidget(comboCustom); - layoutCustom->addItem(new QSpacerItem(5,20,QSizePolicy::Fixed,QSizePolicy::Fixed)); - layoutCustom->addWidget(btnCustom); - layoutCustom->addItem(new QSpacerItem(160,20,QSizePolicy::Fixed,QSizePolicy::Fixed)); - - // File values From a File Layout - QWidget *widgetFile = new QWidget; - QHBoxLayout *layoutFile = new QHBoxLayout(widgetFile); - layoutFile->setContentsMargins(0, 0, 0, 0); - layoutFile->addItem(new QSpacerItem(50,20,QSizePolicy::Fixed,QSizePolicy::Fixed)); - dispFile = new QLineEdit(widgetFile); - dispFile->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed); - dispFile->setToolTip(fileTip); - layoutFile->addWidget(dispFile); - btnFile = new QPushButton("Browse",widgetFile); - btnFile->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed); - btnFile->setToolTip(fileTip); - layoutFile->addWidget(btnFile); - layoutFile->addItem(new QSpacerItem(50,20,QSizePolicy::Fixed,QSizePolicy::Fixed)); - - - stackedLayout->addWidget(widgetRange); - stackedLayout->addWidget(widgetCustom); - stackedLayout->addWidget(widgetFile); - stackedWidget->setLayout(stackedLayout); - - radioCustom->setChecked(true); - stackedLayout->setCurrentIndex(CustomValues); - -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qScanWidget::Initialization(){ - //mode - connect(comboScript, SIGNAL(currentIndexChanged(int)), this,SLOT(SetMode(int))); - //file - connect(dispScript, SIGNAL(editingFinished()), this, SLOT(SetScriptFile())); - connect(btnBrowse, SIGNAL(clicked()), this, SLOT(BrowsePath())); - //parameter - connect(dispParameter, SIGNAL(editingFinished()), this, SLOT(SetParameter())); - //sizewidgets - connect(btnGroup, SIGNAL(buttonClicked(QAbstractButton*)),this,SLOT(EnableSizeWidgets())); - //numsteps - connect(spinSteps, SIGNAL(valueChanged(int)), this, SLOT(SetNSteps())); - //precision - connect(spinPrecision, SIGNAL(valueChanged(int)), this, SLOT(SetPrecision(int))); - //range values - connect(spinFrom, SIGNAL(valueChanged(double)), this, SLOT(RangeFromChanged())); - connect(spinTo, SIGNAL(valueChanged(double)), this, SLOT(RangeToChanged())); - connect(spinSize, SIGNAL(valueChanged(double)), this, SLOT(RangeSizeChanged())); - //custom values - connect(comboCustom, SIGNAL(currentIndexChanged(int)), this, SLOT(SetCustomSteps())); - connect(btnCustom, SIGNAL(clicked()), this, SLOT(DeleteCustomSteps())); - //file values - connect(dispFile, SIGNAL(editingFinished()), this, SLOT(SetFileSteps())); - connect(btnFile, SIGNAL(clicked()), this, SLOT(BrowseFileStepsPath())); -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qScanWidget::EnableSizeWidgets(){ -#ifdef VERYVERBOSE - cout << "Entering EnableSizeWidgets()" << endl; -#endif - //setting to defaults is not done here as this is called even if mode changes - //so only if its to change the size widget type, its set to default for the others - - //scan is none - if(!comboScript->currentIndex()){ - radioCustom->setText("Specific Values"); - radioCustom->setPalette(normal); - radioCustom->setToolTip(customTip); - comboCustom->setToolTip(customTip); - - radioFile->setPalette(normal); - radioFile->setText("Values from File:"); - radioFile->setToolTip(fileTip); - dispFile->setToolTip(fileTip); - btnFile->setToolTip(fileTip); - - lblTo->setPalette(normal); - lblTo->setText("to"); - lblTo->setToolTip(rangeTip); - spinTo->setToolTip(rangeTip); - } - else{ - //range values - if(radioRange->isChecked()){ -#ifdef VERBOSE - cout << "Constant Range Values" << endl; -#endif - - radioCustom->setText("Specific Values"); - radioCustom->setPalette(normal); - radioCustom->setToolTip(customTip); - comboCustom->setToolTip(customTip); - - radioFile->setPalette(normal); - radioFile->setText("Values from File:"); - radioFile->setToolTip(fileTip); - dispFile->setToolTip(fileTip); - btnFile->setToolTip(fileTip); - - stackedLayout->setCurrentIndex(RangeValues); - - //recaluculate number of steps - disconnect(spinSteps, SIGNAL(valueChanged(int)), this, SLOT(SetNSteps())); - spinSteps->setValue(1+(int)(abs((spinTo->value() - spinFrom->value()) / spinSize->value()))); - connect(spinSteps, SIGNAL(valueChanged(int)), this, SLOT(SetNSteps())); - - spinSteps->setMinimum(2); - RangeCheckToValid(); - SetRangeSteps(); - } - //custom values - else if(radioCustom->isChecked()){ -#ifdef VERBOSE - cout << "Custom Values" << endl; -#endif - spinSteps->setMinimum(0); - //defaults for other mode - radioFile->setPalette(normal); - radioFile->setText("Values from File:"); - radioFile->setToolTip(fileTip); - dispFile->setToolTip(fileTip); - btnFile->setToolTip(fileTip); - - lblTo->setPalette(normal); - lblTo->setText("to"); - lblTo->setToolTip(rangeTip); - spinTo->setToolTip(rangeTip); - - //change it back as this list is what will be loaded. - //also numstpes could have been changed in other modes too - disconnect(spinSteps, SIGNAL(valueChanged(int)), this, SLOT(SetNSteps())); - spinSteps ->setValue(comboCustom->count()); - connect(spinSteps, SIGNAL(valueChanged(int)), this, SLOT(SetNSteps())); - - stackedLayout->setCurrentIndex(CustomValues); - //only for custom steps out here because many signals go through - //custom steps and we want to give the info msg only when changig range types - if(SetCustomSteps()==qDefs::OK){ -#ifdef VERYVERBOSE - char cNum[200];sprintf(cNum,"%d",actualNumSteps); - char cId[5];sprintf(cId,"%d",id); - qDefs::Message(qDefs::INFORMATION,string("Scan Level ")+string(cId)+ - string(": Specific Values

Number of positions added: ")+ - string(cNum)+string(""),"qScanWidget::EnableSizeWidgets"); -#endif - } - } - - //file values - else{ -#ifdef VERBOSE - cout << "File Values" << endl; -#endif - spinSteps->setMinimum(0); - //defaults for other mode - radioCustom->setText("Specific Values"); - radioCustom->setPalette(normal); - radioCustom->setToolTip(customTip); - comboCustom->setToolTip(customTip); - - lblTo->setPalette(normal); - lblTo->setText("to"); - lblTo->setToolTip(rangeTip); - spinTo->setToolTip(rangeTip); - - stackedLayout->setCurrentIndex(FileValues); - SetFileSteps(); - } - } - -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qScanWidget::SetMode(int mode){ -#ifdef VERYVERBOSE - cout << "Entering SetMode()" << endl; -#endif -#ifdef VERBOSE - cout << "Setting\tscan:" << id << "\tmode:" << mode << endl; -#endif - // defaults - dispScript->setEnabled(false); - btnBrowse->setEnabled(false); - lblParameter->setEnabled(false); - dispParameter->setEnabled(false); - group->setEnabled(false); - lblSteps->setEnabled(false); - spinSteps->setEnabled(false); - lblPrecision->setEnabled(false); - spinPrecision->setEnabled(false); - - // If anything other than None is selected - if(mode){ - lblSteps->setEnabled(true); - spinSteps->setEnabled(true); - // Custom Script only enables the first layout with addnl parameters etc - if(mode==CustomScript){ - dispScript->setEnabled(true); - btnBrowse->setEnabled(true); - lblParameter->setEnabled(true); - dispParameter->setEnabled(true); - } - group->setEnabled(true); - lblPrecision->setEnabled(true); - spinPrecision->setEnabled(true); - - } - - //set the group box widgets and also calls setscan - EnableSizeWidgets(); - - //set the mode if mode = none - if(!mode) SetScan(mode); -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -int qScanWidget::SetScan(int mode){ -#ifdef VERYVERBOSE - cout << "Entering SetScan()" << endl; -#endif - string parameter = string(dispParameter->text().toAscii().constData()); - string script = string(dispScript->text().toAscii().constData()); -#ifdef VERBOSE - cout << "SETTING scan:" << id << "\tmode:" << comboScript->currentIndex() << - "\tnumSteps:" << actualNumSteps << - "\tscript:" << script << "\tparameter:" << parameter << endl; -#endif - double *values; - if(actualNumSteps) values = new double[actualNumSteps]; - else values = NULL; - for(int i=0;isetScan(id,script,actualNumSteps,values,parameter); - else - myDet->setScan(id,modeNames[mode],actualNumSteps,values,parameter); - - //custom script - int actualMode = myDet->getScanMode(id); - if((mode==CustomScript)&&((script=="")||(script=="none"))){ - return qDefs::OK; - }else{//mode NOT set - if((mode!=actualMode)&&(actualNumSteps)){ - qDefs::Message(qDefs::WARNING,"The mode could not be changed for an unknown reason.","qScanWidget::SetScan"); - comboScript->setCurrentIndex(actualMode); - return qDefs::FAIL; - } - } - - emit EnableScanBox(); - - qDefs::checkErrorMessage(myDet,"qScanWidget::SetScan"); - - return qDefs::OK; -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - -void qScanWidget::BrowsePath(){ -#ifdef VERYVERBOSE - cout << "Entering BrowsePath()" << endl; -#endif -#ifdef VERBOSE - cout << "Browsing Script File Path\tscan:" << id << endl; -#endif - QString fName = dispScript->text(); - QString dir = fName.section('/',0,-2,QString::SectionIncludeLeadingSep); - if(dir.isEmpty()) dir = "/home/"; - //dialog - fName = QFileDialog::getOpenFileName(this, - tr("Load Script File"),dir, - tr("Script Files(*.awk);;All Files(*)")); - //if empty, set the file name and it calls setscriptfile, else ignore - if (!fName.isEmpty()){ - dispScript->setText(fName); - SetScriptFile(); - } -} - -//------------------------------------------------------------------------------------------------------------------------------------------------- - -void qScanWidget::SetScriptFile(){ -#ifdef VERYVERBOSE - cout << "Entering SetScriptFile()" << endl; -#endif - QString fName = dispScript->text(); -#ifdef VERBOSE - cout << "Setting\tscan:" << id << "\tscript:" << fName.toAscii().constData() << endl; -#endif - bool set = false; - struct stat st_buf; - - //blank - if(fName.isEmpty()) - set = true; - //none isnt in the modeNames list, so check separately - else if(!fName.compare("none")) - set = true; - else{//if one of the other modes - for(int i=1;isetText(QString(myDet->getScanScript(id).c_str())); - } - //if its not a file - else if (!S_ISREG (st_buf.st_mode)) { - qDefs::Message(qDefs::WARNING,"The script file path entered is not a file","qScanWidget::SetScriptFile"); - dispScript->setText(QString(myDet->getScanScript(id).c_str())); - } - else - set=true; - } - - //if blank or valid file - if(set){ - myDet->setScanScript(id,fName.toAscii().constData()); - if(fName.compare(QString(myDet->getScanScript(id).c_str()))){ - //did not get set, write what is was before - if(!fName.isEmpty()) - qDefs::Message(qDefs::WARNING,"The script file could not be set. Reverting to previous file.","qScanWidget::SetScriptFile"); - dispScript->setText(QString(myDet->getScanScript(id).c_str())); - } - - } - - //dont display if theres a none - fName = dispScript->text(); - //none isnt in the modeNames list, so check separately - if(!fName.compare("none")) - dispScript->setText(""); - for(int i=1;isetText(""); - - qDefs::checkErrorMessage(myDet,"qScanWidget::SetScriptFile"); -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qScanWidget::SetParameter(){ -#ifdef VERYVERBOSE - cout << "Entering SetParameter()" << endl; -#endif - QString parameter = dispParameter->text(); -#ifdef VERBOSE - cout << "Setting\tscan:" << id << "\tparameter:" << parameter.toAscii().constData() << endl; -#endif - - myDet->setScanParameter(id,parameter.toAscii().constData()); - //dont display if theres a none - parameter = dispParameter->text(); - //none isnt in the modeNames list, so check separately - if(!parameter.compare("none")) - dispParameter->setText(""); - for(int i=1;isetText(""); - - qDefs::checkErrorMessage(myDet,"qScanWidget::SetParameter"); -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qScanWidget::SetPrecision(int value){ -#ifdef VERYVERBOSE - cout << "Entering SetPrecision()" << endl; -#endif -#ifdef VERBOSE - cout << "Setting\tscan:" << id << "\tprecision:" << value << endl; -#endif - myDet->setScanPrecision(id,value); - if(myDet->getScanPrecision(id)!=value) - qDefs::Message(qDefs::WARNING,"The precision was not set for an unknown reason.","qScanWidget::SetPrecision");; - - qDefs::checkErrorMessage(myDet,"qScanWidget::SetPrecision"); -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qScanWidget::SetNSteps(){ -#ifdef VERYVERBOSE - cout << "Entering SetNSteps()" << endl; -#endif -#ifdef VERBOSE - cout << "Setting number of steps" << endl; -#endif - - //check if its ok - if(radioRange->isChecked()){ - disconnect(spinSize, SIGNAL(valueChanged(double)), this, SLOT(RangeSizeChanged())); - spinSize->setValue( (spinTo->value()-spinFrom->value()) / (spinSteps->value()-1)); - connect(spinSize, SIGNAL(valueChanged(double)), this, SLOT(RangeSizeChanged())); - RangeCheckToValid(); - SetRangeSteps(); - }else if(radioCustom->isChecked()){ - comboCustom->setMaxCount(spinSteps->value()); - SetCustomSteps(); - }else if(radioFile->isChecked()){ - SetFileSteps(); - } - -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -int qScanWidget::RangeCheckSizeZero(){ -#ifdef VERYVERBOSE - cout << "Entering RangeCheckSizeZero()" << endl; -#endif - if((spinTo->value()-spinFrom->value())/(spinSteps->value()-1)) - return qDefs::OK; - - return qDefs::FAIL; -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -int qScanWidget::RangeCheckNumValid(int &num){ -#ifdef VERYVERBOSE - cout << "Entering RangeCheckNumValid()" << endl; -#endif - double div = abs(spinTo->value()-spinFrom->value())/(abs(spinSize->value())); - - //num = (to-from)/size +1 - num = (int)(div) + 1; - - if(num>=2) return qDefs::OK; - - return qDefs::FAIL; -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -int qScanWidget::RangeCheckToValid(){ -#ifdef VERYVERBOSE - cout << "Entering RangeCheckToValid()" << endl; -#endif - double to = (spinSize->value() * spinSteps->value()) - spinSize->value() + spinFrom->value(); - - //not exact value - if (abs(to-spinTo->value())>0.01){ - lblTo->setPalette(red); - lblTo->setText("to*"); - QString tip = rangeTip + QString("

" - "To is not exact. Entering Size should recalculate To."); - lblTo->setToolTip(tip); - spinTo->setToolTip(tip); - return qDefs::FAIL; - } - - lblTo->setPalette(normal); - lblTo->setText("to"); - lblTo->setToolTip(rangeTip); - spinTo->setToolTip(rangeTip); - return qDefs::OK; -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qScanWidget::RangeFromChanged(){ -#ifdef VERYVERBOSE - cout << "Entering RangeFromChanged()" << endl; -#endif - bool change = false; - int numSteps; - - disconnect(spinSteps, SIGNAL(valueChanged(int)), this, SLOT(SetNSteps())); - disconnect(spinFrom, SIGNAL(valueChanged(double)), this, SLOT(RangeFromChanged())); - disconnect(spinSize, SIGNAL(valueChanged(double)), this, SLOT(RangeSizeChanged())); - - - //check size validity - if(RangeCheckSizeZero()==qDefs::FAIL) - qDefs::Message(qDefs::WARNING,"From cannot be equal to To. Changing From back to previous value.","Scan"); - //check size validity - else if(RangeCheckNumValid(numSteps)==qDefs::FAIL) - qDefs::Message(qDefs::WARNING,"Number of Steps = 1 + ( To - From ) / Size.
" - "Number of Steps must be >= 2. Changing From back to previous value.","qScanWidget::RangeFromChanged"); - else change = true; - - //change it back from = to - size*num + size - if(!change) { - spinFrom->setValue(spinTo->value() - (spinSize->value() * spinSteps->value()) + spinSize->value()); -#ifdef VERBOSE - cout << "Changing From back:"<< spinFrom->value() << endl; -#endif - } - //change num steps - else{ - spinSteps->setValue(numSteps); - //size will lnever be zero here - //size should be positive - if(spinTo->value()>spinFrom->value()) - spinSize->setValue(abs(spinSize->value())); - //size should be negative - else if(spinSize->value()>0) - spinSize->setValue(-1*(spinSize->value())); - } - - RangeCheckToValid(); - SetRangeSteps(); - - connect(spinSteps, SIGNAL(valueChanged(int)), this, SLOT(SetNSteps())); - connect(spinFrom, SIGNAL(valueChanged(double)), this, SLOT(RangeFromChanged())); - connect(spinSize, SIGNAL(valueChanged(double)), this, SLOT(RangeSizeChanged())); -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qScanWidget::RangeToChanged(){ -#ifdef VERYVERBOSE - cout << "Entering RangeToChanged()" << endl; -#endif - bool change = false; - int numSteps; - - disconnect(spinSteps, SIGNAL(valueChanged(int)), this, SLOT(SetNSteps())); - disconnect(spinTo, SIGNAL(valueChanged(double)), this, SLOT(RangeToChanged())); - disconnect(spinSize, SIGNAL(valueChanged(double)), this, SLOT(RangeSizeChanged())); - - //check size validity - if(RangeCheckSizeZero()==qDefs::FAIL) - qDefs::Message(qDefs::WARNING,"From cannot be equal to To. Changing To back to previous value.","qScanWidget::RangeToChanged"); - //check size validity - else if(RangeCheckNumValid(numSteps)==qDefs::FAIL) - qDefs::Message(qDefs::WARNING,"Number of Steps = 1 + ( To - From ) / Size.
" - "Number of Steps must be >= 2. Changing To back to previous value.","qScanWidget::RangeToChanged"); - else change = true; - - //change it back to = size*num - size + from - if(!change) { - spinTo->setValue((spinSize->value() * spinSteps->value()) - spinSize->value() + spinFrom->value()); -#ifdef VERBOSE - cout << "Changing To back:"<< spinTo->value() << endl; -#endif - } - //change num steps - else{ - spinSteps->setValue(numSteps); - //size will lnever be zero here - //size should be positive - if(spinTo->value()>spinFrom->value()) - spinSize->setValue(abs(spinSize->value())); - //size should be negative - else if(spinSize->value()>0) - spinSize->setValue(-1*(spinSize->value())); - - } - - RangeCheckToValid(); - SetRangeSteps(); - - connect(spinSteps, SIGNAL(valueChanged(int)), this, SLOT(SetNSteps())); - connect(spinTo, SIGNAL(valueChanged(double)), this, SLOT(RangeToChanged())); - connect(spinSize, SIGNAL(valueChanged(double)), this, SLOT(RangeSizeChanged())); -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qScanWidget::RangeSizeChanged(){ -#ifdef VERYVERBOSE - cout << "Entering RangeSizeChanged()" << endl; -#endif - bool change = false; - int numSteps; - - disconnect(spinSteps, SIGNAL(valueChanged(int)), this, SLOT(SetNSteps())); - disconnect(spinSize, SIGNAL(valueChanged(double)), this, SLOT(RangeSizeChanged())); - disconnect(spinTo, SIGNAL(valueChanged(double)), this, SLOT(RangeToChanged())); - - //check size validity - if(!spinSize->value()) - qDefs::Message(qDefs::WARNING,"Size cannot be 0. Changing Size back to previous value.","qScanWidget::RangeSizeChanged"); - //check size validity - else if(RangeCheckNumValid(numSteps)==qDefs::FAIL) - qDefs::Message(qDefs::WARNING,"Number of Steps = 1 + ( To - From ) / Size.
" - "Number of Steps must be >= 2. Changing Size back to previous value.","qScanWidget::RangeSizeChanged"); - else change = true; - - //change it back size = (to-from)/(num-1) - if(!change) { - spinSize->setValue((spinTo->value()-spinFrom->value())/(spinSteps->value()-1)); -#ifdef VERBOSE - cout << "Changing Size back:"<< spinSize->value() << endl; -#endif - } - //change num steps - else{ - spinSteps->setValue(numSteps); - //in case size changed to negative - spinTo->setValue((spinSize->value() * spinSteps->value()) - spinSize->value() + spinFrom->value()); - lblTo->setPalette(normal); - lblTo->setText("to"); - lblTo->setToolTip(rangeTip); - spinTo->setToolTip(rangeTip); - } - - RangeCheckToValid(); - SetRangeSteps(); - - connect(spinSteps, SIGNAL(valueChanged(int)), this, SLOT(SetNSteps())); - connect(spinSize, SIGNAL(valueChanged(double)), this, SLOT(RangeSizeChanged())); - connect(spinTo, SIGNAL(valueChanged(double)), this, SLOT(RangeToChanged())); -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qScanWidget::SetRangeSteps(){ -#ifdef VERYVERBOSE - cout << "Entering SetRangeSteps()" << endl; -#endif -#ifdef VERBOSE - cout << "Setting\tscan:" << id << "\trange\t"; -#endif - double fromVal = spinFrom->value(); - double sizeVal = spinSize->value(); - actualNumSteps = spinSteps->value(); - - -#ifdef VERBOSE - cout << "num pos:" << actualNumSteps << endl; -#endif - - //set the vector positions - positions.resize(actualNumSteps); - for(int i=0;icurrentIndex())==qDefs::OK){ - char cId[5];sprintf(cId,"%d",id); - QString script = dispScript->text(); - - - //positions wont be loaded if its custom script - if((comboScript->currentIndex()==CustomScript)&&((script=="")||(script=="none"))){ - qDefs::Message(qDefs::INFORMATION,string("Scan Level ")+string(cId)+ - string(": Constant Step Size

" - "Positions could not be loaded as the script file path is empty."),"qScanWidget::SetRangeSteps"); - }else{ - //error loading positions - if(myDet->getScanSteps(id)!=actualNumSteps){ - qDefs::Message(qDefs::WARNING,string("Scan Level ")+string(cId)+ - string(": Values From File

" - "The positions list was not set for an unknown reason."),"qScanWidget::SetRangeSteps"); - /*LoadPositions(); - comboScript->setCurrentIndex(myDet->getScanMode(id))*/ - } -#ifdef VERYVERBOSE - else{//SUCCESS - char cNum[200];sprintf(cNum,"%d",actualNumSteps); - qDefs::Message(qDefs::INFORMATION,string("Scan Level ")+string(cId)+ - string(": Constant Step Size

Number of positions added: ")+ - string(cNum)+string(""),"qScanWidget::SetRangeSteps"); - } -#endif - } - } - - qDefs::checkErrorMessage(myDet,"qScanWidget::SetRangeSteps"); -} -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -int qScanWidget::SetCustomSteps(){ -#ifdef VERYVERBOSE - cout << "Entering SetCustomSteps()" << endl; -#endif -#ifdef VERBOSE - cout << "Setting\tscan:" << id << "\tcustom\tnum pos:" << comboCustom->count() << endl; -#endif - disconnect(comboCustom, SIGNAL(currentIndexChanged(int)), this, SLOT(SetCustomSteps())); - - //get number of positions - int numSteps = spinSteps->value(); - comboCustom->setMaxCount(numSteps); - comboCustom->setEnabled(numSteps); - btnCustom->setEnabled(numSteps); - - //deleting too many or not entering enough - if(numSteps>comboCustom->count()){ -#ifdef VERBOSE - cout << "Too few entries" << endl; -#endif - int diff = numSteps - (comboCustom->count()); - radioCustom->setPalette(red); - radioCustom->setText("Specific Values*"); - QString tip = customTip + QString("

Add ")+ - (QString("%1").arg(diff))+ - QString(" more positions to the list to match Number of Steps.
" - "
Or reduce Number of Steps.
"); - radioCustom->setToolTip(tip); - comboCustom->setToolTip(tip); - }else{ - radioCustom->setText("Specific Values"); - radioCustom->setPalette(normal); - radioCustom->setToolTip(customTip); - comboCustom->setToolTip(customTip); - } - - actualNumSteps = comboCustom->count(); - //delete existing positions - positions.resize(actualNumSteps); - //copying the list - for(int i=0;iitemText(i).toDouble(); -#ifdef VERBOSE - cout << "positions[" << i << "]:" << positions[i] << endl; -#endif - } - - //sets the scan - if(SetScan(comboScript->currentIndex())==qDefs::OK){ - char cId[5];sprintf(cId,"%d",id); - QString script = dispScript->text(); - //positions wont be loaded if its custom script - if((comboScript->currentIndex()==CustomScript)&&((script=="")||(script=="none"))){ - qDefs::Message(qDefs::INFORMATION,string("Scan Level ")+string(cId)+ - string(": Values From File

" - "Positions could not be loaded as the script file path is empty."),"qScanWidget::SetCustomSteps"); - return qDefs::FAIL; - }else{ - if(myDet->getScanSteps(id)!=actualNumSteps){ - qDefs::Message(qDefs::WARNING,"The positions list was not set for an unknown reason.","qScanWidget::SetCustomSteps"); - LoadPositions(); - comboScript->setCurrentIndex(myDet->getScanMode(id)); - qDefs::checkErrorMessage(myDet,"qScanWidget::qScanWidget::SetCustomSteps"); - return qDefs::FAIL; - } - //else success is checked in enabledsizewidgets , else it does this for every add, delete etc - } - } - - //if num of steps = 0 - if(!spinSteps->value()){ - comboCustom->setEnabled(false); - btnCustom->setEnabled(false); - radioCustom->setPalette(red); - radioCustom->setText("Specific Values*"); - QString tip = customTip + QString("

First, increase Number of Steps. " - "Then, enter values here."); - radioCustom->setToolTip(tip); - comboCustom->setToolTip(tip); - } - connect(comboCustom, SIGNAL(currentIndexChanged(int)), this, SLOT(SetCustomSteps())); - - return qDefs::OK; -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qScanWidget::DeleteCustomSteps(){ -#ifdef VERYVERBOSE - cout << "Entering DeleteCustomSteps()" << endl; -#endif - QString pos = comboCustom->currentText(); - bool found = false; - //loops through to find the index and to make sure its in the list - for(int i=0;icount();i++){ - if(!comboCustom->itemText(i).compare(pos)){ - found = true; - comboCustom->removeItem(i); - break; - } - } - if(found){ -#ifdef VERBOSE - cout << "Deleting Position " << endl; -#endif - } -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qScanWidget::SetFileSteps(){ -#ifdef VERYVERBOSE - cout << "Entering SetFileSteps()" << endl; -#endif - QString fName = dispFile->text(); -#ifdef VERBOSE - cout << "Setting\tscan:" << id << "\tfile\t:" << fName.toAscii().constData() << endl; -#endif - bool set = false; - struct stat st_buf; - - //blank - if(fName.isEmpty()){ -#ifdef VERBOSE - cout << "Empty file" << endl; -#endif - radioFile->setPalette(red); - radioFile->setText("Values from File:*"); - QString errTip = fileTip + QString("

The file path is empty.");; - radioFile->setToolTip(errTip);dispFile->setToolTip(errTip);btnFile->setToolTip(errTip); - } - //not a blank - else{ - QString file = dispFile->text().section('/',-1); - - //path doesnt exist - if(stat(file.toAscii().constData(),&st_buf)){ -#ifdef VERBOSE - cout << "The file entered does not exist." << endl; -#endif - radioFile->setPalette(red); - radioFile->setText("Values from File:*"); - QString errTip = fileTip + QString("

The file entered does not exist."); - radioFile->setToolTip(errTip);dispFile->setToolTip(errTip);btnFile->setToolTip(errTip); - } - //if its not a file - else if (!S_ISREG (st_buf.st_mode)) { -#ifdef VERBOSE - cout << "The file path entered is not a file." << endl; -#endif - radioFile->setPalette(red); - radioFile->setText("Values from File:*"); - QString errTip = fileTip + QString("

The file path entered is not a file."); - radioFile->setToolTip(errTip); dispFile->setToolTip(errTip);btnFile->setToolTip(errTip); - } - else - set = true; - } - - //if valid file - if(set){ - ifstream inFile;string sLine;char sArg[200]=""; - //open file - inFile.open(fName.toAscii().constData(), ifstream::in); - if(inFile.is_open()){ - //delete existing positions - positions.resize(0); - actualNumSteps = 0; -#ifdef VERBOSE - cout << "Opening file "<< fName.toAscii().constData() << endl; -#endif - while(inFile.good()) { - getline(inFile,sLine); - if(sLine.find('#')!=string::npos) continue;//commented out - else if(sLine.length()<2) continue;// empty line - else { - istringstream sstr(sLine); - if(sstr.good()){ - actualNumSteps++; - positions.resize(actualNumSteps); - sstr>>sArg; - if(!sscanf(sArg,"%lf",&positions[actualNumSteps-1])){ - actualNumSteps--; - positions.resize(actualNumSteps); - } - else cout << "value[" << actualNumSteps-1 << "]:" << positions[actualNumSteps-1] << endl; - } - } - } - disconnect(spinSteps, SIGNAL(valueChanged(int)), this, SLOT(SetNSteps())); - spinSteps->setValue(actualNumSteps); - connect(spinSteps, SIGNAL(valueChanged(int)), this, SLOT(SetNSteps())); - inFile.close(); - }else {//could not open file -#ifdef VERBOSE - cout << "Could not open file" << endl; -#endif - set = false; - radioFile->setPalette(red); - radioFile->setText("Values from File:*"); - QString errTip = fileTip + QString("

Could not read file."); - radioFile->setToolTip(errTip);dispFile->setToolTip(errTip); btnFile->setToolTip(errTip); - } - } - if(set){//no error while reading file - //sets the scan and positions - if(SetScan(comboScript->currentIndex())==qDefs::OK){ - char cId[5];sprintf(cId,"%d",id); - QString script = dispScript->text(); - radioFile->setPalette(normal); - radioFile->setText("Values from File:"); - radioFile->setToolTip(fileTip);dispFile->setToolTip(fileTip);btnFile->setToolTip(fileTip); - //positions wont be loaded if its custom script - if((comboScript->currentIndex()==CustomScript)&&((script=="")||(script=="none"))){ - qDefs::Message(qDefs::INFORMATION,string("Scan Level ")+string(cId)+ - string(": Values From File

" - "Positions could not be loaded as the script file path is empty."),"qScanWidget::SetFileSteps"); - }else{ - //error loading positions - if(myDet->getScanSteps(id)!=actualNumSteps){ - qDefs::Message(qDefs::WARNING,string("Scan Level ")+string(cId)+ - string(": Values From File

" - "The positions list was not set for an unknown reason."),"qScanWidget::SetFileSteps"); - } -#ifdef VERYVERBOSE - else{//SUCCESS - char cNum[200];sprintf(cNum,"%d",actualNumSteps); - qDefs::Message(qDefs::INFORMATION,string("Scan Level ")+string(cId)+ - string(": Values From File

Number of positions added: ")+ - string(cNum)+string(""),"qScanWidget::SetFileSteps"); - } -#endif - } - } - } - //ERROR IN WRITING FILENAME OR READING FILE - else{ - actualNumSteps=0; - positions.resize(0); - SetScan(comboScript->currentIndex()); - disconnect(spinSteps, SIGNAL(valueChanged(int)), this, SLOT(SetNSteps())); - spinSteps->setValue(actualNumSteps); - connect(spinSteps, SIGNAL(valueChanged(int)), this, SLOT(SetNSteps())); - } - - qDefs::checkErrorMessage(myDet,"qScanWidget::SetFileSteps"); -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qScanWidget::BrowseFileStepsPath(){ -#ifdef VERYVERBOSE - cout << "Entering BrowseFileStepsPath()" << endl; -#endif -#ifdef VERBOSE - cout << "Browsing Steps File Path\tscan:" << id << endl; -#endif - QString fName = dispFile->text(); - QString dir = fName.section('/',0,-2,QString::SectionIncludeLeadingSep); - if(dir.isEmpty()) dir = "/home/"; - //dialog - fName = QFileDialog::getOpenFileName(this, - tr("Load Scan Steps Script File"),dir, - tr("Scan Steps Script Files(*.awk);;All Files(*)")); - //if empty, set the file name and it calls SetFileSteps, else ignore - if (!fName.isEmpty()){ - dispFile->setText(fName); - SetFileSteps(); - } - -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qScanWidget::LoadPositions(){ -#ifdef VERYVERBOSE - cout << "Entering LoadPositions()" << endl; -#endif - disconnect(comboCustom, SIGNAL(currentIndexChanged(int)), this, SLOT(SetCustomSteps())); - disconnect(spinSteps, SIGNAL(valueChanged(int)), this, SLOT(SetNSteps())); - disconnect(btnGroup, SIGNAL(buttonClicked(QAbstractButton*)),this,SLOT(EnableSizeWidgets())); - - - int mode = myDet->getScanMode(id); - radioCustom->setChecked(true); - - int numSteps = myDet->getScanSteps(id); - actualNumSteps = numSteps; - comboCustom->setMaxCount(numSteps); - positions.resize(actualNumSteps); - - //set the number of steps in the gui - spinSteps->setValue(numSteps); - - //load the positions - double *values = NULL; - if(actualNumSteps){ - values = new double[actualNumSteps]; - myDet->getScanSteps(id,values); - } - for(int i=0;isetText("Specific Values"); - radioCustom->setPalette(normal); - radioCustom->setToolTip(customTip); - comboCustom->setToolTip(customTip); - }//no positions and has a mode - else if(mode){ - radioCustom->setPalette(red); - radioCustom->setText("Specific Values*"); - QString tip = customTip + QString("

First, increase Number of Steps. " - "Then, enter values here."); - radioCustom->setToolTip(tip); - comboCustom->setToolTip(tip); - } - for(int i=0;icount();i++) - comboCustom->removeItem(i); - for(int i=0;iinsertItem(i,QString("%1").arg(positions[i])); - - //delete the combolist and reload it - comboCustom->setEnabled(numSteps&&mode); - btnCustom->setEnabled(numSteps&&mode); - - connect(comboCustom, SIGNAL(currentIndexChanged(int)), this, SLOT(SetCustomSteps())); - connect(spinSteps, SIGNAL(valueChanged(int)), this, SLOT(SetNSteps())); - connect(btnGroup, SIGNAL(buttonClicked(QAbstractButton*)),this,SLOT(EnableSizeWidgets())); - - qDefs::checkErrorMessage(myDet,"qScanWidget::LoadPositions"); - //do not set the range variables because if the stepsize is by any chance 0.. - //then the number of steps should change to 1. so only set custom steps -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qScanWidget::Refresh(){ -#ifdef VERYVERBOSE - cout << "Entering Refresh()" << endl; -#endif - int mode = (myDet->getScanMode(id)); - string script = myDet->getScanScript(id); - string parameter = myDet->getScanParameter(id); - int precision = myDet->getScanPrecision(id); - - - //settings values and checking for none - if(QString(script.c_str()).compare("none")) - dispScript->setText(QString(script.c_str())); - if(mode) SetScriptFile(); - dispParameter->setText(QString(parameter.c_str())); - SetParameter(); - spinPrecision->setValue(precision); - - //set mode which also checks number of steps - //and enable size widgets and set the positions from combolist to server - comboScript->setCurrentIndex(mode); - - -#ifdef VERBOSE - cout << "Updated\tscan:" << id << "\t" - "mode:" << mode << "\t" - "script:" << script << "\t" - "numSteps:" << actualNumSteps << "\t" - //"values:" << arrSteps << "\t" - "parameter:" << parameter << "\t" - "precision:" << precision << "\t***" << endl; -#endif - - qDefs::checkErrorMessage(myDet,"qScanWidget::Refresh"); -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- diff --git a/slsDetectorGui/src/qServer.cpp b/slsDetectorGui/src/qServer.cpp old mode 100644 new mode 100755 index 9b83a8d9c..e8ae77581 --- a/slsDetectorGui/src/qServer.cpp +++ b/slsDetectorGui/src/qServer.cpp @@ -1,431 +1,171 @@ -/* - * qServer.cpp - * - * Created on: Feb 27, 2013 - * Author: Dhanya Maliakal - */ -// Qt Project Class Headers #include "qServer.h" #include "qDetectorMain.h" -// Project Class Headers -#include "slsDetector.h" + +#include "ServerSocket.h" #include "multiSlsDetector.h" -#include "MySocketTCP.h" -// C++ Include Headers +#include "string_utils.h" + #include #include -using namespace std; - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -int qServer::gui_server_thread_running(0); - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -qServer::qServer(qDetectorMain *t): - myMainTab(t), mySocket(0),myStopSocket(0),port_no(DEFAULT_GUI_PORTNO),lockStatus(0),checkStarted(0),checkStopStarted(0){ - strcpy(mess,""); - FunctionTable(); +#include +qServer::qServer(qDetectorMain *t) + : threadRunning(false), threadStarted(false), mainTab(t), + controlPort(DEFAULT_GUI_PORTNO), stopPort(DEFAULT_GUI_PORTNO + 1), + controlSocket(nullptr), stopSocket(nullptr) { + FILE_LOG(logDEBUG) << "Client Server ready"; } +qServer::~qServer() {} -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -qServer::~qServer(){ - delete myMainTab; - if(mySocket) delete mySocket; - if(myStopSocket) delete myStopSocket; +void qServer::FunctionTable() { + flist.push_back(qServer::GetStatus); + flist.push_back(qServer::StartAcquisition); + flist.push_back(qServer::StopsAcquisition); + flist.push_back(qServer::Acquire); + flist.push_back(qServer::ExitServer); } +int qServer::DecodeFunction(ServerSocket *sock) { + int ret = qDefs::FAIL; + int fnum = 0; + int n = sock->ReceiveDataOnly(&fnum, sizeof(fnum)); + if (n <= 0) { + FILE_LOG(logDEBUG3) << "Received " << n << " bytes"; + throw sls::RuntimeError("Could not read socket"); + } -//------------------------------------------------------------------------------------------------------------------------------------------------- + // unrecognized function + if (fnum < 0 && fnum >= qDefs::NUM_GUI_FUNCS) { + ret = qDefs::FAIL; + char mess[MAX_STR_LENGTH] = {}; + sls::strcpy_safe(mess, "Unrecognized function"); + // will throw an exception + sock->SendResult(ret, nullptr, 0, mess); + } + // calling function + FILE_LOG(logDEBUG1) << "calling function fnum: " << fnum; + ret = (this->*flist[fnum])(); -int qServer::FunctionTable(){ - - flist[F_GET_RUN_STATUS] = &qServer::GetStatus; - flist[F_START_ACQUISITION] = &qServer::StartAcquisition; - flist[F_STOP_ACQUISITION] = &qServer::StopsAcquisition; - flist[F_START_AND_READ_ALL] = &qServer::Acquire; - flist[F_EXIT_SERVER] = &qServer::ExitServer; - - return qDefs::OK; + return ret; } - -//------------------------------------------------------------------------------------------------------------------------------------------ - - -int qServer::DecodeFunction(MySocketTCP* sock){ - int ret = qDefs::FAIL; - int n,fnum; -#ifdef VERYVERBOSE - cout << "receive data" << endl; -#endif - n = sock->ReceiveDataOnly(&fnum,sizeof(fnum)); - if (n <= 0) { -#ifdef VERYVERBOSE - cout << "ERROR reading from socket " << n << ", " << fnum << endl; -#endif - return qDefs::FAIL; - } -#ifdef VERYVERBOSE - else - cout << "size of data received " << n <ShutDownSocket(); - - myStopSocket->SendDataOnly(&ret,sizeof(ret)); - myStopSocket->SendDataOnly(mess,sizeof(mess)); - return GOODBYE; - } - - - //calling function - ret = (this->*flist[fnum])(); - if (ret==qDefs::FAIL) - cout << "Error executing the function = " << fnum << endl; - - return ret; +void qServer::ShutDownSockets() { + threadRunning = false; + if (controlSocket) { + controlSocket->shutDownSocket(); + delete controlSocket; + controlSocket = nullptr; + } + if (stopSocket) { + stopSocket->shutDownSocket(); + delete stopSocket; + stopSocket = nullptr; + } } - -//------------------------------------------------------------------------------------------------------------------------------------------ - - -int qServer::ExitServer(){ - - int ret = OK; - strcpy(mess," Gui Server closed successfully\n"); - - if(mySocket) - mySocket->ShutDownSocket(); - - myStopSocket->SendDataOnly(&ret,sizeof(ret)); - myStopSocket->SendDataOnly(mess,sizeof(mess)); - cout << mess << endl; - - return GOODBYE; +void qServer::CreateServers() { + if (!threadRunning) { + FILE_LOG(logINFO) << "Starting Gui Servers"; + threadRunning = true; + + try { + // start control server + controlSocket = new ServerSocket(controlPort); + std::async(std::launch::async, ServerThread, controlSocket); + FILE_LOG(logDEBUG) + << "Gui control server thread created successfully."; + // start stop server + stopSocket = new ServerSocket(stopPort); + std::async(std::launch::async, ServerThread, stopSocket); + FILE_LOG(logDEBUG) + << "Gui stop server thread created successfully."; + } catch (...) { + ShutDownSockets(); + std::string message = "Can't create gui control server thread"; + FILE_LOG(logERROR) << message; + qDefs::Message(qDefs::WARNING, message, "qServer::CreateServers"); + } + } } - -//------------------------------------------------------------------------------------------------------------------------------------------ - - - -int qServer::StartStopServer(int start){ - - //start server - if(start){ -#ifdef VERBOSE - cout << endl << "Starting Gui Server" << endl; -#endif - - if(!gui_server_thread_running){ - gui_server_thread_running=1; - - - //error creating thread - checkStarted=1; - if (pthread_create(&gui_server_thread, NULL,StartServerThread, (void*) this)){ - gui_server_thread_running=0; - qDefs::Message(qDefs::WARNING,"Can't create gui server thread", "qServer::StartStopServer"); - cout << "ERROR: Can't create gui server thread" << endl; - return FAIL; - } - while(checkStarted); - checkStarted = 0; -#ifdef VERBOSE - if(gui_server_thread_running) - cout << "Server thread created successfully." << endl; -#endif - - - //error creating thread - checkStopStarted=1; - if (pthread_create(&gui_stop_server_thread, NULL,StopServerThread, (void*) this)){ - gui_server_thread_running=0; - qDefs::Message(qDefs::WARNING,"Can't create gui stop server thread", "qServer::StartStopServer"); - cout << "ERROR: Can't create gui stop server thread" << endl; - return FAIL; - } - while(checkStopStarted); - checkStopStarted=0; -#ifdef VERBOSE - if(gui_server_thread_running) - cout << "Server Stop thread created successfully." << endl; -#endif - } - } - - - //stop server - else{ -#ifdef VERBOSE - cout << "Stopping Gui Server" << endl; -#endif - - if(gui_server_thread_running){ - gui_server_thread_running=0; - - if(mySocket) - mySocket->ShutDownSocket(); - pthread_join(gui_server_thread,NULL); - if(mySocket){ - delete mySocket; - mySocket = 0; - } - - if(myStopSocket) - myStopSocket->ShutDownSocket(); - pthread_join(gui_stop_server_thread,NULL); - if(myStopSocket){ - delete myStopSocket; - myStopSocket = 0; - } - } -#ifdef VERBOSE - cout << "Server threads stopped successfully." << endl; -#endif - } - - return gui_server_thread_running; +void qServer::DestroyServers() { + if (threadRunning) { + FILE_LOG(logINFO) << "Stopping Gui Servers"; + ShutDownSockets(); + FILE_LOG(logDEBUG) << "Server threads stopped successfully."; + } } +void qServer::ServerThread(ServerSocket* sock) { + FILE_LOG(logDEBUG) << "Starting Gui Server at port " << sock->getPort(); -//------------------------------------------------------------------------------------------------------------------------------------------------- + while (threadRunning)) { + try{ + sock->accept(); + if (DecodeFunction(sock) == GOODBYE) { + threadRunning = false; + } + sock->close(); + } + // any fails will throw an exception, which will be displayed at client side. Ignore here + catch (...) {} + } + FILE_LOG(logDEBUG) << "Stopped gui server thread"; - -void* qServer::StopServerThread(void* this_pointer){ - ((qServer*)this_pointer)->StopServer(); - return this_pointer; + // stop port is closed last + if (sock->getPort() == stopPort) + emit ServerStoppedSignal(); } +int qServer::GetStatus(ServerSock* sock) { + slsDetectorDefs::runStatus status = slsDetectorDefs::ERROR; + int progress = 0; + if (myMainTab->isPlotRunning()) + status = slsDetectorDefs::RUNNING; + else + status = slsDetectorDefs::IDLE; -//------------------------------------------------------------------------------------------------------------------------------------------------- + progress = myMainTab->GetProgress(); - - -int qServer::StopServer(){ -#ifdef VERYVERBOSE - cout << "In StopServer()" << endl; -#endif - int ret = qDefs::OK; - - try { - MySocketTCP* s = new MySocketTCP(port_no+1); - myStopSocket = s; - } catch(...) { - gui_server_thread_running = 0; - qDefs::Message(qDefs::WARNING,"Could not start gui stop server socket","qServer::StopServer"); - } - checkStopStarted = 0; - - while ((gui_server_thread_running) && (ret!=GOODBYE)) { -#ifdef VERBOSE - cout<< endl; -#endif -#ifdef VERYVERBOSE - cout << "Waiting for client call" << endl; -#endif - if(myStopSocket->Connect()>=0){ -#ifdef VERYVERBOSE - cout << "Conenction accepted" << endl; -#endif - ret = DecodeFunction(myStopSocket); -#ifdef VERYVERBOSE - cout << "function executed" << endl; -#endif - myStopSocket->Disconnect(); -#ifdef VERYVERBOSE - cout << "connection closed" << endl; -#endif - } - } -#ifdef VERBOSE - cout << "Stopped gui stop server thread" << endl; -#endif - gui_server_thread_running = 0; - //delete socket(via exit server) - if(myStopSocket){ - delete myStopSocket; - myStopSocket = 0; - } - - if(!gui_server_thread_running) - emit ServerStoppedSignal(); - - return qDefs::OK; + int ret = qDefs::OK + int retvals[2] = {static_cast(retval), progress}; + sock->SendResult(ret, retvals, sizeof(retvals), nullptr); + return ret; } - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - - -void* qServer::StartServerThread(void* this_pointer){ - ((qServer*)this_pointer)->StartServer(); - return this_pointer; +int qServer::StartAcquisition(ServerSock* sock) { + char mess[MAX_STR_LENGTH] = {}; + sls::strcpy_safe(mess, "Could not start acquistion in Gui"); + int ret = myMainTab->StartStopAcquisitionFromClient(true); + sock->SendResult(ret, nullptr, 0, mess); + return ret; } - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - - -int qServer::StartServer(){ -#ifdef VERYVERBOSE - cout << "In StartServer()" << endl; -#endif - int ret = qDefs::OK; - - try { - MySocketTCP* s = new MySocketTCP(port_no); - mySocket = s; - } catch(...) { - gui_server_thread_running = 0; - qDefs::Message(qDefs::WARNING,"Could not start gui server socket","qServer::StartServer"); - } - checkStarted = 0; - - while ((gui_server_thread_running) && (ret!=GOODBYE)) { -#ifdef VERBOSE - cout<< endl; -#endif -#ifdef VERYVERBOSE - cout << "Waiting for client call" << endl; -#endif - if(mySocket->Connect()>=0){ -#ifdef VERYVERBOSE - cout << "Conenction accepted" << endl; -#endif - ret = DecodeFunction(mySocket); -#ifdef VERYVERBOSE - cout << "function executed" << endl; -#endif - mySocket->Disconnect(); -#ifdef VERYVERBOSE - cout << "connection closed" << endl; -#endif - } - } -#ifdef VERBOSE - cout << "Stopped gui server thread" << endl; -#endif - gui_server_thread_running = 0; - //delete socket(via exit server) - if(mySocket){ - delete mySocket; - mySocket = 0; - } - - if(!gui_server_thread_running) - emit ServerStoppedSignal(); - - return qDefs::OK; +int qServer::StopsAcquisition(ServerSock* sock) { + char mess[MAX_STR_LENGTH] = {}; + sls::strcpy_safe(mess, "Could not stop acquistion in Gui"); + int ret = myMainTab->StartStopAcquisitionFromClient(false); + sock->SendResult(ret, nullptr, 0, mess); + return ret; } - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -int qServer::GetStatus(){ - - int ret = qDefs::OK; - enum slsDetectorDefs::runStatus retval; - int progress = 0; - - // execute action if the arguments correctly arrived - if(myMainTab->isPlotRunning()) - retval = slsDetectorDefs::RUNNING; - else - retval = slsDetectorDefs::IDLE; - - progress = myMainTab->GetProgress(); - - // send answer - myStopSocket->SendDataOnly(&ret,sizeof(ret)); - myStopSocket->SendDataOnly(&retval,sizeof(retval)); - myStopSocket->SendDataOnly(&progress,sizeof(progress)); - //return ok/fail - return ret; +int qServer::Acquire(ServerSock* sock) { + char mess[MAX_STR_LENGTH] = {}; + sls::strcpy_safe(mess, "Could not start blocking acquistion in Gui"); + int ret = myMainTab->StartStopAcquisitionFromClient(true); + // blocking + usleep(5000); + while (myMainTab->isPlotRunning()) + ; + sock->SendResult(ret, nullptr, 0, mess); + return ret; } - -//------------------------------------------------------------------------------------------------------------------------------------------ - - -int qServer::StartAcquisition(){ - - strcpy(mess,"Could not start acquisition in gui. \n"); - - int ret = myMainTab->StartStopAcquisitionFromClient(true); - mySocket->SendDataOnly(&ret,sizeof(ret)); - if(ret==FAIL) - mySocket->SendDataOnly(mess,sizeof(mess)); - - return ret; -} - - -//------------------------------------------------------------------------------------------------------------------------------------------ - - -int qServer::StopsAcquisition(){ - - strcpy(mess,"Could not stop acquisition in gui. \n"); - - int ret = myMainTab->StartStopAcquisitionFromClient(false); - myStopSocket->SendDataOnly(&ret,sizeof(ret)); - if(ret==FAIL) - myStopSocket->SendDataOnly(mess,sizeof(mess)); - - return ret; -} - - -//------------------------------------------------------------------------------------------------------------------------------------------ - - -int qServer::Acquire(){ - - strcpy(mess,"Could not start blocking acquisition in gui. \n"); - - int ret = myMainTab->StartStopAcquisitionFromClient(true); - - usleep(5000); - while(myMainTab->isPlotRunning()); - - mySocket->SendDataOnly(&ret,sizeof(ret)); - if(ret==FAIL) - mySocket->SendDataOnly(mess,sizeof(mess)); - - return ret; -} - - -//------------------------------------------------------------------------------------------------------------------------------------------ - +int qServer::ExitServer(ServerSock* sock) { + DestroyServers(); + int ret = qDefs::OK; + sock->SendResult(ret, nullptr, 0, mess); + return GOODBYE; +} \ No newline at end of file diff --git a/slsDetectorGui/src/qTabActions.cpp b/slsDetectorGui/src/qTabActions.cpp deleted file mode 100644 index 2ed3dc68c..000000000 --- a/slsDetectorGui/src/qTabActions.cpp +++ /dev/null @@ -1,585 +0,0 @@ -/* - * qTabActions.cpp - * - * Created on: May 10, 2012 - * Author: l_maliakal_d - */ -// Qt Project Class Headers -#include "qTabActions.h" -// Project Class Headers -#include "slsDetector.h" -#include "multiSlsDetector.h" -// Qt Include Headers -#include -// C++ Include Headers -#include -using namespace std; - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -qTabActions::qTabActions(QWidget *parent,multiSlsDetector*& detector): - QWidget(parent),myDet(detector), - positionWidget(0), - lblNumPos(0), - lblPosList(0), - spinNumPos(0), - comboPos(0), - btnDelete(0), - chkInvert(0), - chkSeparate(0), - chkReturn(0), - positions(0), - iconPlus(0), - iconMinus(0){ - for(int i=0;i<6;i++) - actionWidget[i]=0; - for(int i=0;i<2;i++) - scanWidget[i]=0; - for(int i=0;isetWidget(this); - scroll->setWidgetResizable(true); - - // Layout Settings - gridLayout = new QGridLayout(scroll); - setLayout(gridLayout); - gridLayout->setContentsMargins(10,5,0,0); - gridLayout->setVerticalSpacing(2); - - // Buttongroup to know which +/- button was clicked - group = new QButtonGroup(this); - group->setExclusive(false); - palette = new QPalette(); - - QPalette p; - p.setColor(QPalette::Shadow,QColor(0,0,0,0)); - p.setColor(QPalette::Button,QColor(0,0,0,0)); -/*get rid of this vector*/ - char names[NumTotalActions][200] = { - "Action at Start", - "Scan Level 0", - "Scan Level 1", - "Action before each Frame", - "Positions", - "Header before Frame", - "Header after Frame", - "Action after each Frame", - "Action at Stop" - }; - - //creating the icons for the buttons - iconPlus = new QIcon(":/icons/images/add.png"); - iconMinus = new QIcon(":/icons/images/remove.png"); - - QString tip = "Click on the \"+\" to Expand or \"-\" to Collapse."; - - - - int hIndent=0, vIndent=0, colspan=6, posVal=0; - QLabel *lblReal; - // For each level of Actions - for(int i=0;isetToolTip(tip); - btnExpand[i]->setCheckable(true); - btnExpand[i]->setChecked(false); - btnExpand[i]->setFixedSize(16,16); - btnExpand[i]->setToolTip(tip); - btnExpand[i]->setIcon(*iconPlus); - btnExpand[i]->setFocusPolicy(Qt::NoFocus); - btnExpand[i]->setFlat(true); - btnExpand[i]->setIconSize(QSize(16,16)); - btnExpand[i]->setPalette(p); - group->addButton(btnExpand[i],i); - - - //add label and button to expand or collapse - gridLayout->addWidget(btnExpand[i],vIndent,hIndent,1,1); - gridLayout->addWidget(lblName[i],vIndent,hIndent+1,1,colspan); - - //creating the action/scan/position widgets and adding them - switch(i){ - case NumPositions: - CreatePositionsWidget(); - gridLayout->addWidget(positionWidget,vIndent+1,hIndent+1,1,colspan); - positionWidget->hide(); - break; - case Scan0: - case Scan1: - posVal = qScanWidget::NUM_SCAN_WIDGETS; - scanWidget[posVal] = new qScanWidget(this,myDet); - gridLayout->addWidget(scanWidget[posVal],vIndent+1,hIndent+1,1,colspan); - scanWidget[posVal]->hide(); - break; - default: - posVal = qActionsWidget::NUM_ACTION_WIDGETS; - actionWidget[posVal] = new qActionsWidget(this,myDet); - gridLayout->addWidget(actionWidget[posVal],vIndent+1,hIndent+1,1,colspan); - actionWidget[posVal]->hide(); - break; - } - - //incrementing the vertical and horizontal indent - vIndent+=2; - switch(i){ - case HeaderBefore: - //real time acquisition - palette->setColor(QPalette::Active,QPalette::WindowText,QColor(0,0,200,255)); - lblReal = new QLabel(" Real Time Acquisition"); - lblReal->setFixedHeight(25); - //lblReal->setPalette(*palette); - gridLayout->addWidget(lblReal,vIndent,hIndent+1,1,colspan); - vIndent++; - break; - case HeaderAfter: - hIndent-=2; - colspan+=2; - break; - case ActionAfter: - hIndent=0; - colspan=6; - break; - default: - hIndent++; - colspan--; - break; - } - - } - - - //Number of positions is only for mythen or gotthard - detType = myDet->getDetectorsType(); - if((detType == slsDetectorDefs::EIGER) || - (detType == slsDetectorDefs::AGIPD) || - (detType == slsDetectorDefs::PROPIX) || - (detType == slsDetectorDefs::JUNGFRAU) || - (detType == slsDetectorDefs::CHIPTESTBOARD) || - (detType == slsDetectorDefs::MOENCH)) { - lblName[NumPositions]->setEnabled(false); - btnExpand[NumPositions]->setEnabled(false); - }else{ - //disable positions if angular conversion is enabled - int ang; - if(!myDet->getAngularConversion(ang)){ - lblName[NumPositions]->setEnabled(false); - btnExpand[NumPositions]->setEnabled(false); - } - - } - - //load positions - if(lblName[NumPositions]->isEnabled()){ - //delete existing positions - if (positions) {delete [] positions; positions = NULL;} - //get number of positions - int numPos=myDet->getPositions(); - comboPos->setMaxCount(numPos); - - //set the number of positions in the gui - spinNumPos->setValue(numPos); - - positions=new double[numPos]; - //load the positions - myDet->getPositions(positions); - - //delete the combolist and reload it - comboPos->setEnabled(numPos); - lblPosList->setEnabled(numPos); - btnDelete->setEnabled(numPos); - lblPosList->setText("List of Positions: "); - lblPosList->setPalette(normal); - for(int i=0;icount();i++) comboPos->removeItem(i); - for(int i=0;iinsertItem(i,QString("%1").arg(positions[i])); - } - - - qDefs::checkErrorMessage(myDet,"qTabActions::SetupWidgetWindow"); -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qTabActions::CreatePositionsWidget(){ - positionWidget = new QWidget; - positionWidget->setFixedHeight(25); - positionWidget->setFixedWidth(680); - - QGridLayout *layout = new QGridLayout(positionWidget); - layout->setContentsMargins(0,0,0,0); - layout->setHorizontalSpacing(0); - layout->setVerticalSpacing(5); - - lblNumPos = new QLabel("Number of Positions: "); - lblNumPos->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed); - layout->addWidget(lblNumPos,0,0); - layout->addItem(new QSpacerItem(5,20,QSizePolicy::Fixed,QSizePolicy::Fixed),0,1); - spinNumPos = new QSpinBox(this); - layout->addWidget(spinNumPos,0,2); - layout->addItem(new QSpacerItem(80,20,QSizePolicy::Fixed,QSizePolicy::Fixed),0,3); - lblPosList = new QLabel("List of Positions: "); - lblPosList->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed); - lblPosList->setFixedWidth(108); - lblPosList->setEnabled(false); - lblPosList->setToolTip("Enter the positions at which the detector should be moved.
" - "Number of entries is restricted to Number of Positions field."); - layout->addWidget(lblPosList,0,4); - comboPos = new QComboBox(this); - comboPos->setEditable(true); -// comboPos->setCompleter(false); - comboPos->setCompleter(NULL); - normal = comboPos->palette(); - comboPos->setEnabled(false); - QDoubleValidator *validate = new QDoubleValidator(comboPos); - comboPos->setValidator(validate); - layout->addWidget(comboPos,0,5); - layout->addItem(new QSpacerItem(5,20,QSizePolicy::Fixed,QSizePolicy::Fixed),0,6); - btnDelete = new QPushButton("Delete "); - btnDelete->setEnabled(false); - btnDelete->setIcon(QIcon( ":/icons/images/close.png" )); - btnDelete->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed); - layout->addWidget(btnDelete,0,7); - - //might be included at some point -/* QGroupBox *w = new QGroupBox; - layout->addWidget(w,1,0,1,9); - QHBoxLayout *l1 = new QHBoxLayout(w); - l1->setContentsMargins(0,0,0,0); - l1->addItem(new QSpacerItem(20,20,QSizePolicy::Fixed,QSizePolicy::Fixed)); - chkInvert = new QCheckBox("Invert Angles"); - l1->addWidget(chkInvert); - chkSeparate = new QCheckBox("Separate Two Halves"); - l1->addWidget(chkSeparate); - chkReturn = new QCheckBox("Return to Start Position"); - chkReturn->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed); - l1->addWidget(chkReturn); - l1->addItem(new QSpacerItem(20,20,QSizePolicy::Fixed,QSizePolicy::Fixed)); - w->setLayout(l1);*/ - - positionWidget->setLayout(layout); -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qTabActions::Initialization(){ - //expand - connect(group, SIGNAL(buttonClicked(QAbstractButton*)), this,SLOT(Expand(QAbstractButton*))); - //enable scan box in plot tab - for(int i=0;iid(button); - - // Collapse - if(!button->isChecked()){ - palette->setColor(QPalette::Active,QPalette::WindowText,Qt::black); - - - lblName[index]->setPalette(*palette); - button->setIcon(*iconPlus); - - if(index==NumPositions) { - positionWidget->hide(); - setFixedHeight(height()-30);//-80 if the checkboxes are included - if(myDet->getPositions()) { - palette->setColor(QPalette::Active,QPalette::WindowText,Qt::darkGreen); - lblName[index]->setPalette(*palette); - } - } - else if((index==Scan0)||(index==Scan1)) { - scanWidget[GetActualIndex(index)]->hide(); - setFixedHeight(height()-130); - if(myDet->getScanMode(GetActualIndex(index))){ - palette->setColor(QPalette::Active,QPalette::WindowText,Qt::darkGreen); - lblName[index]->setPalette(*palette); - } - } - else { - actionWidget[GetActualIndex(index)]->hide(); - setFixedHeight(height()-30); - if(myDet->getActionMode(GetActualIndex(index))){ - palette->setColor(QPalette::Active,QPalette::WindowText,Qt::darkGreen); - lblName[index]->setPalette(*palette); - } - } - }else{ - // Expand - //always set title color to blue for expan\d - - palette->setColor(QPalette::Active,QPalette::WindowText,QColor(0,0,200,255)); - - - lblName[index]->setPalette(*palette); - button->setIcon(*iconMinus); - - if(index==NumPositions){ - positionWidget->show(); - setFixedHeight(height()+30);//+80 if the checkboxes are included - } - else if((index==Scan0)||(index==Scan1)){ - scanWidget[GetActualIndex(index)]->show(); - setFixedHeight(height()+130); - } - else{ - actionWidget[GetActualIndex(index)]->show(); - setFixedHeight(height()+30); - } - } - - qDefs::checkErrorMessage(myDet,"qTabActions::Expand"); -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qTabActions::SetPosition(){ -#ifdef VERBOSE - cout << "Entering SetPosition\tnum Pos:" << spinNumPos->value() << "\tlist count:" << comboPos->count() << endl; -#endif - //get number of positions - int numPos = spinNumPos->value(); - comboPos->setMaxCount(numPos); - comboPos->setEnabled(numPos); - lblPosList->setEnabled(numPos); - btnDelete->setEnabled(numPos); - - //deleting too many or not entering enough - if(numPos>comboPos->count()){ - - QPalette red = QPalette(); - red.setColor(QPalette::Active,QPalette::WindowText,Qt::red); - lblPosList->setPalette(red); - QString tip = QString("Enter the positions at which the detector should be moved.
" - "Number of entries is restricted to Number of Positions field.

")+ - QString("Add ")+ - (QString("%1").arg(((numPos)-(comboPos->count()))))+ - QString(" more positions to the list to match Number of Positions.
" - "Or reduce Number of Positions.
"); - lblPosList->setToolTip(tip); - lblPosList->setText("List of Positions:*"); - }else{ - lblPosList->setText("List of Positions: "); - lblPosList->setPalette(normal); - lblPosList->setToolTip("Enter the positions at which the detector should be moved.
" - "Number of entries is restricted to Number of Positions field."); - } - - //delete existing positions - if (positions) {delete [] positions; positions = NULL;} - positions=new double[comboPos->count()]; - //copying the list - for(int i=0;icount();i++) - positions[i] = comboPos->itemText(i).toDouble(); - //setting the list and catching error - if(myDet->setPositions(comboPos->count(),positions)!=comboPos->count()) - qDefs::Message(qDefs::WARNING,"The positions list was not set for some reason.","qTabActions::SetPosition"); - - - qDefs::checkErrorMessage(myDet,"qTabActions::SetPosition"); -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qTabActions::DeletePosition(){ - QString pos = comboPos->currentText(); - bool found = false; - //loops through to find the index and to make sure its in the list - for(int i=0;icount();i++){ - if(!comboPos->itemText(i).compare(pos)){ - found = true; - comboPos->removeItem(i); - break; - } - } - if(found){ -#ifdef VERBOSE - cout << "Deleting Position " << endl; -#endif - } -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - -void qTabActions::EnablePositions(bool enable){ -#ifdef VERBOSE - cout << "Enable Positions: " << enable << endl; -#endif - if(enable){ - lblName[NumPositions]->setEnabled(true); - btnExpand[NumPositions]->setEnabled(true); - }else{ - //deletes all positions - for(int i=0;icount();i++) - comboPos->removeItem(i); - cout<<"Number of Positions set to :"<getPositions()<isChecked()){ - disconnect(group, SIGNAL(buttonClicked(QAbstractButton*)), this,SLOT(Expand(QAbstractButton*))); - btnExpand[NumPositions]->setChecked(false); - connect(group, SIGNAL(buttonClicked(QAbstractButton*)), this,SLOT(Expand(QAbstractButton*))); - Expand(group->button(NumPositions)); - } - lblName[NumPositions]->setEnabled(false); - btnExpand[NumPositions]->setEnabled(false); - } - - qDefs::checkErrorMessage(myDet,"qTabActions::EnablePositions"); -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qTabActions::Refresh(){ -#ifdef VERBOSE - cout << endl <<"**Updating all action widgets: " << endl; -#endif - if((detType == slsDetectorDefs::MYTHEN) || (detType == slsDetectorDefs::GOTTHARD)){ - //positions is enabled only if angular conversion is enabled - int ang; if(!myDet->getAngularConversion(ang)) EnablePositions(false); - - if(lblName[NumPositions]->isEnabled()){ - //delete existing positions - if (positions) {delete [] positions; positions = NULL;} - //get number of positions - int numPos=myDet->getPositions(); - comboPos->setMaxCount(numPos); - - //set the number of positions in the gui - disconnect(spinNumPos, SIGNAL(valueChanged(int)), this, SLOT(SetPosition())); - spinNumPos->setValue(numPos); - connect(spinNumPos, SIGNAL(valueChanged(int)), this, SLOT(SetPosition())); - - positions=new double[numPos]; - //load the positions - myDet->getPositions(positions); - - //delete the combolist and reload it - disconnect(comboPos,SIGNAL(currentIndexChanged(int)), this, SLOT(SetPosition())); - comboPos->setEnabled(numPos); - lblPosList->setEnabled(numPos); - btnDelete->setEnabled(numPos); - lblPosList->setText("List of Positions: "); - lblPosList->setPalette(normal); - for(int i=0;icount();i++) - comboPos->removeItem(i); - for(int i=0;iinsertItem(i,QString("%1").arg(positions[i])); - connect(comboPos, SIGNAL(currentIndexChanged(int)), this, SLOT(SetPosition())); - - -#ifdef VERBOSE - cout << "Updated position widget\tnum:" << numPos << "\t***" << endl; -#endif - } - } - for(int i=0;iRefresh(); - for(int i=0;iRefresh(); - UpdateCollapseColors(); -#ifdef VERBOSE - cout << "**Updated all action widgets: " << endl << endl; -#endif - - qDefs::checkErrorMessage(myDet,"qTabActions::Refresh"); -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -int qTabActions::GetActualIndex(int index){ - switch(index){ - case 0: return slsDetectorDefs::startScript; - case Scan0: return 0; - case Scan1: return 1; - case 3: return slsDetectorDefs::scriptBefore; - case 5: return slsDetectorDefs::headerBefore; - case 6: return slsDetectorDefs::headerAfter; - case 7: return slsDetectorDefs::scriptAfter; - case 8: return slsDetectorDefs::stopScript; - default: return -1; - } -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qTabActions::UpdateCollapseColors(){ -#ifdef VERYVERBOSE - cout << "Updating Collapse Colors" << endl; -#endif - for(int i=0;igetPositions()) palette->setColor(QPalette::Active,QPalette::WindowText,Qt::darkGreen); - else palette->setColor(QPalette::Active,QPalette::WindowText,Qt::black); - lblName[i]->setPalette(*palette); - } - //scans - else if((i==Scan0)||(i==Scan1)){ - if(myDet->getScanMode(GetActualIndex(i))) palette->setColor(QPalette::Active,QPalette::WindowText,Qt::darkGreen); - else palette->setColor(QPalette::Active,QPalette::WindowText,Qt::black); - lblName[i]->setPalette(*palette); - } - //actions - else{ - if(myDet->getActionMode(GetActualIndex(i))) palette->setColor(QPalette::Active,QPalette::WindowText,Qt::darkGreen); - else palette->setColor(QPalette::Active,QPalette::WindowText,Qt::black); - lblName[i]->setPalette(*palette); - } - } - -} -//------------------------------------------------------------------------------------------------------------------------------------------------- diff --git a/slsDetectorGui/src/qTabAdvanced.cpp b/slsDetectorGui/src/qTabAdvanced.cpp old mode 100644 new mode 100755 index 78c5316be..d808196e0 --- a/slsDetectorGui/src/qTabAdvanced.cpp +++ b/slsDetectorGui/src/qTabAdvanced.cpp @@ -1,200 +1,88 @@ -/* - * qTabAdvanced.cpp - * - * Created on: May 10, 2012 - * Author: l_maliakal_d - */ #include "qTabAdvanced.h" #include "qDrawPlot.h" -/** Project Class Headers */ -#include "slsDetector.h" + #include "multiSlsDetector.h" -/** Qt Include Headers */ -#include -/** C++ Include Headers */ + #include -using namespace std; -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -qTabAdvanced::qTabAdvanced(QWidget *parent,multiSlsDetector*& detector, qDrawPlot*& plot): - QWidget(parent),myDet(detector),det(0),myPlot(plot),btnGroup(NULL),isEnergy(false),isAngular(false), - lblFromX(0), - spinFromX(0), - lblFromY(0), - spinFromY(0), - lblToX(0), - spinToX(0), - lblToY(0), - spinToY(0), - numRois(0){ +qTabAdvanced::qTabAdvanced(QWidget *parent, multiSlsDetector* detector): +QWidget(parent), myDet(detector),detType(slsDetectorDefs::GENERIC), +lblFromX(0), +spinFromX(0), +lblFromY(0), +spinFromY(0), +lblToX(0), +spinToX(0), +lblToY(0), +spinToY(0), +numRois(0){ setupUi(this); SetupWidgetWindow(); + FILE_LOG(logDEBUG) << "Advanced ready"; } -//------------------------------------------------------------------------------------------------------------------------------------------------- - - - qTabAdvanced::~qTabAdvanced(){ delete myDet; - if(det) delete det; } -//------------------------------------------------------------------------------------------------------------------------------------------------- - - void qTabAdvanced::SetupWidgetWindow(){ -//executed even for non digital, so make sure its necessary - - //Network - lblIP->setEnabled(false); - lblMAC->setEnabled(false); - dispIP->setEnabled(false); - dispMAC->setEnabled(false); - boxRxr->setEnabled(false); - boxSetAllTrimbits->setEnabled(false); - - red = QPalette(); red.setColor(QPalette::Active,QPalette::WindowText,Qt::red); - outputDirTip = dispFile->toolTip(); - errOutputTip = QString("

" - "Output Trim File should contain both existing directory and a file name.
" - "The extensions are automatically added.

" - "Enter valid Output Trim File to enable Start Trimming button.
"); detOnlineTip = comboOnline->toolTip(); rxrOnlineTip = comboRxrOnline->toolTip(); errOnlineTip = QString("

It is offline!"); - acqSubPeriodTip = spinSubPeriod->toolTip(); - errSubPeriodTip = acqSubPeriodTip + - QString("

Sub Frame Period " - "should be greater than or equal to " - "Sub Frame Exposure Time.
"); - - - - detType = myDet->getDetectorsType(); - switch(detType){ - case slsDetectorDefs::MYTHEN: - isEnergy = true; - isAngular = true; - spinZmqPort->setEnabled(false); - spinZmqPort2->setEnabled(false); - dispZMQIP->setEnabled(false); - dispZMQIP2->setEnabled(false); - break; - case slsDetectorDefs::EIGER: - isEnergy = true; - isAngular = false; - lblIP->setEnabled(true); - lblMAC->setEnabled(true); - dispIP->setEnabled(true); - dispMAC->setEnabled(true); - boxRxr->setEnabled(true); + detType = myDet->getDetectorTypeAsEnum(); + if (detType == slsDetectorDefs::EIGER ) { boxSetAllTrimbits->setEnabled(true); lblSubExpTime->setEnabled(true); spinSubExpTime->setEnabled(true); comboSubExpTimeUnit->setEnabled(true); - lblSubPeriod->setEnabled(true); - spinSubPeriod->setEnabled(true); - comboSubPeriodUnit->setEnabled(true); - break; - case slsDetectorDefs::MOENCH: - isEnergy = false; - isAngular = false; - lblIP->setEnabled(true); - lblMAC->setEnabled(true); - dispIP->setEnabled(true); - dispMAC->setEnabled(true); - boxRxr->setEnabled(true); - break; - case slsDetectorDefs::GOTTHARD: - isEnergy = false; - isAngular = true; - lblIP->setEnabled(true); - lblMAC->setEnabled(true); - dispIP->setEnabled(true); - dispMAC->setEnabled(true); - boxRxr->setEnabled(true); - break; - case slsDetectorDefs::JUNGFRAU: - case slsDetectorDefs::CHIPTESTBOARD: - isEnergy = false; - isAngular = false; - lblIP->setEnabled(true); - lblMAC->setEnabled(true); - dispIP->setEnabled(true); - dispMAC->setEnabled(true); - boxRxr->setEnabled(true); - break; - default: break; + lblSubDeadTime->setEnabled(true); + spinSubDeadTime->setEnabled(true); + comboSubDeadTimeUnit->setEnabled(true); } - //logs and trimming - if(!isAngular && !isEnergy) boxLogs->setEnabled(false); - else{ - if(!isAngular) chkAngularLog->setEnabled(false); - if(!isEnergy){ - chkEnergyLog->setEnabled(false); - boxPlot->setEnabled(false); - boxTrimming->setEnabled(false); - }else{ - boxTrimming->setChecked(false); - SetOptimize(false); - - btnGroup = new QButtonGroup(this); - btnGroup->addButton(btnRefresh,0); - btnGroup->addButton(btnGetTrimbits,1); - } - } - trimmingMode = slsDetectorDefs::NOISE_TRIMMING; - //network //add detectors - for(int i=0;igetNumberOfDetectors();i++) + for(int i=0;igetNumberOfDetectors(); ++i) comboDetector->addItem(QString(myDet->getHostname(i).c_str())); comboDetector->setCurrentIndex(0); - - det = myDet->getSlsDetector(comboDetector->currentIndex()); + int moduleId = comboDetector->currentIndex(); qDefs::checkErrorMessage(myDet,"qTabAdvanced::SetupWidgetWindow"); - cout << "Getting ports" << endl; - spinControlPort->setValue(det->getControlPort()); - spinStopPort->setValue(det->getStopPort()); - spinTCPPort->setValue(det->getReceiverPort()); - spinUDPPort->setValue(atoi(det->getReceiverUDPPort().c_str())); - spinZmqPort->setValue(atoi(det->getClientStreamingPort().c_str())); - spinZmqPort2->setValue(atoi(det->getReceiverStreamingPort().c_str())); + FILE_LOG(logDEBUG) << "Getting ports"; + spinControlPort->setValue(myDet->setControlPort(-1, moduleId)); + spinStopPort->setValue(myDet->setStopPort(-1, moduleId)); + spinTCPPort->setValue(myDet->setReceiverPort(-1, moduleId)); + spinUDPPort->setValue(myDet->getReceiverUDPPort(moduleId)); + spinZmqPort->setValue(myDet->getClientStreamingPort(moduleId)); + spinZmqPort2->setValue(myDet->getReceiverStreamingPort(moduleId)); - cout << "Getting network information" << endl; - dispIP->setText(det->getDetectorIP().c_str()); - dispMAC->setText(det->getDetectorMAC().c_str()); - dispRxrHostname->setText(det->getReceiver().c_str()); - dispUDPIP->setText(det->getReceiverUDPIP().c_str()); - dispUDPMAC->setText(det->getReceiverUDPMAC().c_str()); - dispZMQIP->setText(det->getClientStreamingIP().c_str()); - dispZMQIP2->setText(det->getReceiverStreamingIP().c_str()); + FILE_LOG(logDEBUG) << "Getting network information"; + dispIP->setText(myDet->getDetectorIP(moduleId).c_str()); + dispMAC->setText(myDet->getDetectorMAC(moduleId).c_str()); + dispRxrHostname->setText(myDet->getReceiverHostname(moduleId).c_str()); + dispUDPIP->setText(myDet->getReceiverUDPIP(moduleId).c_str()); + dispUDPMAC->setText(myDet->getReceiverUDPMAC(moduleId).c_str()); + dispZMQIP->setText(myDet->getClientStreamingIP(moduleId).c_str()); + dispZMQIP2->setText(myDet->getReceiverStreamingIP(moduleId).c_str()); //check if its online and set it to red if offline -#ifdef VERYVERBOSE - cout << "online" << endl; -#endif - if(det->setOnline()==slsDetectorDefs::ONLINE_FLAG) - det->checkOnline(); - if(det->setReceiverOnline()==slsDetectorDefs::ONLINE_FLAG) - det->checkReceiverOnline(); - comboOnline->setCurrentIndex(det->setOnline()); - comboRxrOnline->setCurrentIndex(det->setReceiverOnline()); + FILE_LOG(logDEBUG) << "Getting online status"; + if(myDet->setOnline(moduleId)==slsDetectorDefs::ONLINE_FLAG) + myDet->checkOnline(moduleId); + if(myDet->setReceiverOnline(moduleId)==slsDetectorDefs::ONLINE_FLAG) + myDet->checkReceiverOnline(moduleId); + comboOnline->setCurrentIndex(myDet->setOnline(moduleId)); + comboRxrOnline->setCurrentIndex(myDet->setReceiverOnline(moduleId)); if(!comboOnline->currentIndex()){ comboOnline->setToolTip(detOnlineTip + errOnlineTip); lblOnline->setToolTip(detOnlineTip + errOnlineTip); @@ -210,22 +98,16 @@ void qTabAdvanced::SetupWidgetWindow(){ //updates roi - cout << "Getting ROI" << endl; + FILE_LOG(logDEBUG) << "Getting ROI"; if (detType == slsDetectorDefs::GOTTHARD) updateROIList(); -#ifdef VERYVERBOSE - // print receiver configurations - if(detType != slsDetectorDefs::MYTHEN){ - cout << endl; - myDet->printReceiverConfiguration(); - } -#endif + myDet->printReceiverConfiguration(logDEBUG); // jungfrau if (detType == slsDetectorDefs::JUNGFRAU) { - lblNumStoragecells->setEnabled(true); - spinNumStoragecells->setEnabled(true); - spinNumStoragecells->setValue((int)myDet->setTimer(slsDetectorDefs::STORAGE_CELL_NUMBER,-1)); + lblNumStoragecells->setEnabled(true); + spinNumStoragecells->setEnabled(true); + spinNumStoragecells->setValue((int)myDet->setTimer(slsDetectorDefs::STORAGE_CELL_NUMBER,-1)); } else if (detType == slsDetectorDefs::EIGER) { //subexptime qDefs::timeUnit unit; @@ -234,555 +116,119 @@ void qTabAdvanced::SetupWidgetWindow(){ comboSubExpTimeUnit->setCurrentIndex((int)unit); //period time = qDefs::getCorrectTime(unit,((double)(myDet->setTimer(slsDetectorDefs::SUBFRAME_DEADTIME,-1)*(1E-9)))); - spinSubPeriod->setValue(time); - comboSubPeriodUnit->setCurrentIndex((int)unit); + spinSubDeadTime->setValue(time); + comboSubDeadTimeUnit->setCurrentIndex((int)unit); - CheckAcqPeriodGreaterThanExp(); } Initialization(); - qDefs::checkErrorMessage(det,"qTabAdvanced::SetupWidgetWindow"); + qDefs::checkErrorMessage(myDet, moduleId,"qTabAdvanced::SetupWidgetWindow"); } - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - void qTabAdvanced::Initialization(){ connect(tabAdvancedSettings,SIGNAL(currentChanged(int)), this, SLOT(Refresh())); - //energy/angular logs - if(isAngular) - connect(chkEnergyLog, SIGNAL(toggled(bool)), this, SLOT(SetLogs())); - - if(isEnergy){ - connect(chkAngularLog, SIGNAL(toggled(bool)), this, SLOT(SetLogs())); - - //exptime - connect(spinExpTime, SIGNAL(valueChanged(double)), this, SLOT(SetExposureTime())); - connect(comboExpUnit, SIGNAL(currentIndexChanged(int)), this, SLOT(SetExposureTime())); - - //threshold dac - connect(spinThreshold, SIGNAL(valueChanged(double)), this, SLOT(SetThreshold())); - - //output directory - connect(dispFile, SIGNAL(editingFinished()), this, SLOT(SetOutputFile())); - connect(btnFile, SIGNAL(clicked()), this, SLOT(BrowseOutputFile())); - - //setalltrimbits - if(boxSetAllTrimbits->isEnabled()) - connect(spinSetAllTrimbits, SIGNAL(editingFinished()), this, SLOT(SetAllTrimbits())); - - //enable trimming method group box - connect(boxTrimming, SIGNAL(toggled(bool)), this, SLOT(EnableTrimming(bool))); - - //trimming method combo - connect(comboMethod, SIGNAL(currentIndexChanged(int)), this, SLOT(SetTrimmingMethod(int))); - - //method options - connect(chkOptimize, SIGNAL(toggled(bool)), this, SLOT(SetOptimize(bool))); - - //start Trimming - connect(btnStart, SIGNAL(clicked()), this, SLOT(StartTrimming())); - - //refresh - connect(btnGroup, SIGNAL(buttonClicked(int)), this, SLOT(UpdateTrimbitPlot(int))); - } - //network connect(comboDetector, SIGNAL(currentIndexChanged(int)), this, SLOT(SetDetector(int))); connect(spinControlPort, SIGNAL(valueChanged(int)), this, SLOT(SetControlPort(int))); connect(spinStopPort, SIGNAL(valueChanged(int)), this, SLOT(SetStopPort(int))); connect(comboOnline, SIGNAL(currentIndexChanged(int)), this, SLOT(SetOnline(int))); - if(detType!=slsDetectorDefs::MYTHEN){ + //network + connect(spinTCPPort, SIGNAL(valueChanged(int)), this, SLOT(SetRxrTCPPort(int))); + connect(spinUDPPort, SIGNAL(valueChanged(int)), this, SLOT(SetRxrUDPPort(int))); + connect(spinZmqPort, SIGNAL(valueChanged(int)), this, SLOT(SetCltZmqPort(int))); + connect(spinZmqPort2, SIGNAL(valueChanged(int)), this, SLOT(SetRxrZmqPort(int))); + connect(comboRxrOnline, SIGNAL(currentIndexChanged(int)), this, SLOT(SetReceiverOnline(int))); - //network - connect(spinTCPPort, SIGNAL(valueChanged(int)), this, SLOT(SetRxrTCPPort(int))); - connect(spinUDPPort, SIGNAL(valueChanged(int)), this, SLOT(SetRxrUDPPort(int))); - connect(spinZmqPort, SIGNAL(valueChanged(int)), this, SLOT(SetCltZmqPort(int))); - connect(spinZmqPort2, SIGNAL(valueChanged(int)), this, SLOT(SetRxrZmqPort(int))); - connect(comboRxrOnline, SIGNAL(currentIndexChanged(int)), this, SLOT(SetReceiverOnline(int))); + connect(dispIP, SIGNAL(editingFinished()), this, SLOT(SetNetworkParameters())); + connect(dispMAC, SIGNAL(editingFinished()), this, SLOT(SetNetworkParameters())); + connect(dispUDPIP, SIGNAL(editingFinished()), this, SLOT(SetNetworkParameters())); + connect(dispUDPMAC, SIGNAL(editingFinished()), this, SLOT(SetNetworkParameters())); - connect(dispIP, SIGNAL(editingFinished()), this, SLOT(SetNetworkParameters())); - connect(dispMAC, SIGNAL(editingFinished()), this, SLOT(SetNetworkParameters())); - connect(dispUDPIP, SIGNAL(editingFinished()), this, SLOT(SetNetworkParameters())); - connect(dispUDPMAC, SIGNAL(editingFinished()), this, SLOT(SetNetworkParameters())); + connect(dispZMQIP, SIGNAL(editingFinished()), this, SLOT(SetClientZMQIP())); + connect(dispZMQIP2, SIGNAL(editingFinished()), this, SLOT(SetReceiverZMQIP())); - connect(dispZMQIP, SIGNAL(editingFinished()), this, SLOT(SetClientZMQIP())); - connect(dispZMQIP2, SIGNAL(editingFinished()), this, SLOT(SetReceiverZMQIP())); + connect(btnRxr, SIGNAL(clicked()), this, SLOT(SetReceiver())); - connect(btnRxr, SIGNAL(clicked()), this, SLOT(SetReceiver())); - } - - - //roi if (detType == slsDetectorDefs::GOTTHARD) { + // roi connect(btnClearRoi, SIGNAL(clicked()), this, SLOT(clearROIinDetector())); connect(btnGetRoi, SIGNAL(clicked()), this, SLOT(updateROIList())); connect(btnSetRoi, SIGNAL(clicked()), this, SLOT(setROI())); } - if(detType == slsDetectorDefs::JUNGFRAU) { - connect(spinNumStoragecells, SIGNAL(valueChanged(int)), this, SLOT(SetNumStoragecells(int))); - } else if (detType == slsDetectorDefs::EIGER) { + else if(detType == slsDetectorDefs::JUNGFRAU) { + // storage cells + connect(spinNumStoragecells, SIGNAL(valueChanged(int)), this, SLOT(SetNumStoragecells(int))); + } + + else if (detType == slsDetectorDefs::EIGER) { + // all trimbits + connect(spinSetAllTrimbits, SIGNAL(editingFinished()), this, SLOT(SetAllTrimbits())); + //Exposure Time connect(spinSubExpTime,SIGNAL(valueChanged(double)), this, SLOT(SetSubExposureTime())); connect(comboSubExpTimeUnit,SIGNAL(currentIndexChanged(int)), this, SLOT(SetSubExposureTime())); + //Frame Period between exposures - connect(spinSubPeriod,SIGNAL(valueChanged(double)), this, SLOT(SetSubPeriod())); - connect(comboSubPeriodUnit,SIGNAL(currentIndexChanged(int)),this, SLOT(SetSubPeriod())); + connect(spinSubDeadTime,SIGNAL(valueChanged(double)), this, SLOT(SetSubDeadTime())); + connect(comboSubDeadTimeUnit,SIGNAL(currentIndexChanged(int)),this, SLOT(SetSubDeadTime())); } } -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qTabAdvanced::SetLogs(){ - QCheckBox *checkedBox = qobject_cast(sender()); - int index = ((!checkedBox->text().compare("Energy Calibration"))?slsDetectorDefs::enCalLog:slsDetectorDefs::angCalLog); - bool enable = checkedBox->isChecked(); -#ifdef VERBOSE - if(index==slsDetectorDefs::enCalLog) - cout << "Setting Energy Calibration Logs to " << enable << endl; - else - cout << "Setting Angular Calibration Logs to " << enable << endl; -#endif - //set/unset the log - myDet->setAction(index,(enable?"set":"none")); - //verify - if(myDet->getActionMode(index)!=(enable)){ -#ifdef VERBOSE - cout << "Could not set/reset Log." << endl; -#endif - qDefs::Message(qDefs::WARNING,"Could not set/reset Log.","qTabAdvanced::SetLogs"); - checkedBox->setChecked(!enable); - } - - qDefs::checkErrorMessage(myDet,"qTabAdvanced::SetLogs"); -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qTabAdvanced::SetExposureTime(){ - //Get the value of timer in ns - double exptimeNS = qDefs::getNSTime((qDefs::timeUnit)comboExpUnit->currentIndex(),spinExpTime->value()); -#ifdef VERBOSE - cout << "Setting Exposure Time to " << exptimeNS << " clocks" << "/" << spinExpTime->value() << qDefs::getUnitString((qDefs::timeUnit)comboExpUnit->currentIndex()) << endl; -#endif - myDet->setTimer(slsDetectorDefs::ACQUISITION_TIME,(int64_t)exptimeNS); - - qDefs::checkErrorMessage(myDet,"qTabAdvanced::SetExposureTime"); -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qTabAdvanced::SetThreshold(){ -#ifdef VERBOSE - cout << "Setting Threshold DACu:" << spinThreshold->value() << endl; -#endif - spinThreshold->setValue((double)myDet->setDAC((dacs_t)spinThreshold->value(),slsDetectorDefs::THRESHOLD,0)); - qDefs::checkErrorMessage(myDet,"qTabAdvanced::SetThreshold"); -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qTabAdvanced::SetOutputFile(){ -#ifdef VERBOSE - cout << "Setting Output File for Trimming:" << endl; -#endif - QString dirPath = dispFile->text().section('/',0,-2,QString::SectionIncludeLeadingSep); - cout << "Directory:" << dirPath.toAscii().constData() << "." << endl; - QString fName = dispFile->text().section('/',-1); - cout << "File Name:" << fName.toAscii().constData() << "." << endl; - //checks if directory exists and file name is not empty - if((QFile::exists(dirPath))&&(!fName.isEmpty())){ - - dispFile->setToolTip(outputDirTip); - lblFile->setToolTip(outputDirTip); - lblFile->setPalette(lblExpTime->palette()); - lblFile->setText("Output Trim File: "); - btnStart->setEnabled(true); - - - //check if you're overwriting original trimsettings - QDir dir; - //gets the clean absolute path - dirPath = dir.absoluteFilePath(dirPath); - dirPath = dir.cleanPath(dirPath); - QString trimdir = QString::fromStdString(myDet->getSettingsFile()).section('/',0,-2,QString::SectionIncludeLeadingSep); - trimdir = dir.absoluteFilePath(trimdir); - trimdir = dir.cleanPath(trimdir); - if(!dirPath.compare(trimdir)){ - int ret = qDefs::Message(qDefs::QUESTION,string("This will possibly overwrite your original trimbits.
" - "Proposed file path:") + string(dirPath.toAscii().constData())+ - string("
Do you still want to continue?"),"qTabAdvanced::SetOutputFile"); - if(ret==qDefs::FAIL){ - dispFile->setText(""); - dispFile->setToolTip(outputDirTip + errOutputTip); - lblFile->setToolTip(outputDirTip + errOutputTip); - lblFile->setPalette(red); - lblFile->setText("Output Trim File:*"); - btnStart->setEnabled(false); - } - } - - }//if the directory doesnt exist or if file name is empty - else{ - cout<<"Invalid Trimming output File"<setToolTip(outputDirTip + errOutputTip); - lblFile->setToolTip(outputDirTip + errOutputTip); - lblFile->setPalette(red); - lblFile->setText("Output Trim File:*"); - btnStart->setEnabled(false); - } - - qDefs::checkErrorMessage(myDet,"qTabAdvanced::SetOutputFile"); -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qTabAdvanced::BrowseOutputFile(){ -#ifdef VERBOSE - cout << "Browsing Output Dir for Trimming" << endl; -#endif - QString fName = dispFile->text(); - //dialog - QFileDialog *fileDialog = new QFileDialog(this, - tr("Save Trimbits"),fName, - tr("Trimbit files (*.trim noise.sn*);;All Files(*) ")); - fileDialog->setFileMode(QFileDialog::AnyFile ); - if ( fileDialog->exec() == QDialog::Accepted ) - fName = fileDialog->selectedFiles()[0]; - - //if empty, set the file name and it calls SetFileSteps, else ignore - if (!fName.isEmpty()){ - dispFile->setText(fName); - SetOutputFile(); - } -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qTabAdvanced::EnableTrimming(bool enable){ -#ifdef VERBOSE - cout << "Enable Trimming set to:" << enable << endl; -#endif - if(enable){ - //show error label if invalid output dir - SetOutputFile(); - SetTrimmingMethod(comboMethod->currentIndex()); - }else{ - //error label shouldnt show when disabled - dispFile->setToolTip(outputDirTip); - lblFile->setToolTip(outputDirTip); - lblFile->setPalette(lblExpTime->palette()); - lblFile->setText("Output Trim File: "); - } -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- -void qTabAdvanced::SetOptimize(bool enable){ -#ifdef VERBOSE - cout << "Setting Optimize to:" << enable << endl; -#endif - //trimming method is adjust to count - if(!comboMethod->currentIndex()){ - lblCounts->setEnabled(true); - spinCounts->setEnabled(true); - lblResolution->setEnabled(enable); - spinResolution->setEnabled(enable); - }//trimming method is equalize to median - else{ - lblCounts->setEnabled(false); - spinCounts->setEnabled(false); - lblResolution->setEnabled(true); - spinResolution->setEnabled(true); - } -} - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qTabAdvanced::SetTrimmingMethod(int mode){ -#ifdef VERBOSE - cout << "Setting Trimming method to :" << mode << endl; -#endif - //make sure the right resolution/Counts is enabled - SetOptimize(chkOptimize->isChecked()); - - //set mode - switch(mode){ - case 0: trimmingMode = slsDetectorDefs::NOISE_TRIMMING; break; - case 1: trimmingMode = slsDetectorDefs::IMPROVE_TRIMMING; break; - } -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -int qTabAdvanced::validateBeforeTrimming(){ -#ifdef VERBOSE - cout << "Validating conditions before Trimming" << endl; -#endif - char temp[100]; - string message = "All conditions satisfied for Trimming.
"; - switch(detType){ - case slsDetectorDefs::MYTHEN: - - //dynamic range - if(myDet->setDynamicRange(-1) != TRIMMING_DYNAMIC_RANGE){ - sprintf(temp,"%d",TRIMMING_DYNAMIC_RANGE); - if(myDet->setDynamicRange(TRIMMING_DYNAMIC_RANGE) != TRIMMING_DYNAMIC_RANGE){ - qDefs::Message(qDefs::WARNING, - string("Trimming Pre-condition not satisfied:
" - "Could not set dynamic range to ") + string(temp)+string(".
" - "Trimming Aborted."),"qTabAdvanced::validateBeforeTrimming"); - return slsDetectorDefs::FAIL; - }else - message.append(string("Dynamic Range has been changed to ") + string(temp) + string(".
")); - } - //frames - if((int)myDet->setTimer(slsDetectorDefs::FRAME_NUMBER,-1) != TRIMMING_FRAME_NUMBER){ - sprintf(temp,"%d",TRIMMING_FRAME_NUMBER); - if((int)myDet->setTimer(slsDetectorDefs::FRAME_NUMBER,TRIMMING_FRAME_NUMBER) != TRIMMING_FRAME_NUMBER){ - qDefs::Message(qDefs::WARNING, - string("
Trimming Pre-condition not satisfied:
" - "Could not set Number of Frames to ") + string(temp)+string(".
" - "Trimming Aborted."),"qTabAdvanced::validateBeforeTrimming"); - return slsDetectorDefs::FAIL; - }else - message.append(string("Number of Frames has been changed to ") + string(temp) + string(".
")); - } - //trigger - if((int)myDet->setTimer(slsDetectorDefs::CYCLES_NUMBER,-1) != TRIMMING_TRIGGER_NUMBER){ - sprintf(temp,"%d",TRIMMING_TRIGGER_NUMBER); - if((int)myDet->setTimer(slsDetectorDefs::CYCLES_NUMBER,TRIMMING_TRIGGER_NUMBER) != TRIMMING_TRIGGER_NUMBER){ - qDefs::Message(qDefs::WARNING, - string("
Trimming Pre-condition not satisfied:
" - "Could not set Number of Triggers to ") + string(temp)+string(".
" - "Trimming Aborted."),"qTabAdvanced::validateBeforeTrimming"); - return slsDetectorDefs::FAIL; - }else - message.append(string("Number of Triggers has been changed to ") + string(temp) + string(".
")); - } - //probes - if((int)myDet->setTimer(slsDetectorDefs::PROBES_NUMBER,-1) != TRIMMING_PROBE_NUMBER){ - sprintf(temp,"%d",TRIMMING_PROBE_NUMBER); - if((int)myDet->setTimer(slsDetectorDefs::PROBES_NUMBER,TRIMMING_PROBE_NUMBER) != TRIMMING_PROBE_NUMBER){ - qDefs::Message(qDefs::WARNING, - string("
Trimming Pre-condition not satisfied:
" - "Could not set Number of Probes to ") + string(temp)+string(".
" - "Trimming Aborted."),"qTabAdvanced::validateBeforeTrimming"); - return slsDetectorDefs::FAIL; - }else - message.append(string("Number of Probes has been changed to ") + string(temp) + string(".
")); - } - //Setting - if(myDet->getSettings() == slsDetectorDefs::UNINITIALIZED){ - if(qDefs::Message(qDefs::QUESTION, - string("
Trimming Pre-condition not satisfied:
")+ - string("Settings cannot be Uninitialized to start Trimming.
" - "Change it to Standard and proceed?"),"qTabAdvanced::validateBeforeTrimming") == slsDetectorDefs::FAIL){ - qDefs::Message(qDefs::INFORMATION, - "Please change the Settings in the Settings tab to your choice.
" - "Aborting Trimming.","qTabAdvanced::validateBeforeTrimming"); - return slsDetectorDefs::FAIL; - } - //user asked to change settings to standard - else{ - if((int)myDet->setSettings(slsDetectorDefs::STANDARD) != slsDetectorDefs::STANDARD){ - qDefs::Message(qDefs::WARNING, - string("Trimming Pre-condition not satisfied:
" - "Could not change Settings to Standard
" - "Trimming Aborted."),"qTabAdvanced::validateBeforeTrimming"); - return slsDetectorDefs::FAIL; - }else - message.append(string("Settings has been changed to Standard.
")); - } - } - break; - default: - return slsDetectorDefs::FAIL; - - } - - message.append("
Initiating Trimming..."); - qDefs::Message(qDefs::INFORMATION,message,"qTabAdvanced::validateBeforeTrimming"); - return slsDetectorDefs::OK; - -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qTabAdvanced::StartTrimming(){ - //check a few conditions before trimming - if(validateBeforeTrimming() == slsDetectorDefs::FAIL) - return; - -#ifdef VERBOSE - cout << "Starting Trimming" << endl; -#endif - int parameter1=0, parameter2=0; - //optimize - bool optimize = chkOptimize->isChecked(); - - //set the mode again and also set resolution, counts - switch(trimmingMode){ - - case slsDetectorDefs::NOISE_TRIMMING: - //define parameters - parameter1 = spinCounts->value(); - parameter2 = spinResolution->value(); - if(!optimize){ - parameter2 = -1; - trimmingMode = slsDetectorDefs::FIXEDSETTINGS_TRIMMING; -#ifdef VERBOSE - cout << "Trimming Mode: FIXEDSETTINGS_TRIMMING" << endl; -#endif - }else{ -#ifdef VERBOSE - cout << "Trimming Mode: NOISE_TRIMMING" << endl; -#endif - } - break; - - case slsDetectorDefs::IMPROVE_TRIMMING: -#ifdef VERBOSE - cout << "Trimming Mode: IMPROVE_TRIMMING" << endl; -#endif - //define parameters - parameter1 = spinResolution->value(); - parameter2 = 1; - if(!optimize) parameter2 = 0; - break; - default: - cout << "Should never come here. Start Trimming will have only 2 methods. Trimming Method:" << trimmingMode << endl; - return; - } - - //execute - int ret = myDet->executeTrimming(trimmingMode,parameter1,parameter2,-1); - - if((ret!=slsDetectorDefs::FAIL)&&(ret!=-1)); - else - qDefs::Message(qDefs::WARNING,"Atleast 1 channel could not be trimmed.","qTabAdvanced::StartTrimming"); - //save trim file - ret = myDet->saveSettingsFile(string(dispFile->text().toAscii().constData()),-1); - if((ret!=slsDetectorDefs::FAIL)&&(ret!=-1)){ - qDefs::Message(qDefs::INFORMATION,"The Trimbits have been saved successfully.","qTabAdvanced::StartTrimming"); - //updates plots - myPlot->UpdateTrimbitPlot(false,radioHistogram->isChecked()); - } - else qDefs::Message(qDefs::WARNING,string("Could not Save the Trimbits to file:\n")+dispFile->text().toAscii().constData(),"qTabAdvanced::StartTrimming"); - - qDefs::checkErrorMessage(myDet,"qTabAdvanced::StartTrimming"); -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qTabAdvanced::UpdateTrimbitPlot(int id){ - if(boxPlot->isChecked()){ - //refresh - if(!id) myPlot->UpdateTrimbitPlot(false,radioHistogram->isChecked()); - //from detector - else myPlot->UpdateTrimbitPlot(true,radioHistogram->isChecked()); - } -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - void qTabAdvanced::SetControlPort(int port){ -#ifdef VERBOSE - cout << "Setting Control Port:" << port << endl; -#endif + FILE_LOG(logINFO) << "Setting Control Port:" << port; disconnect(spinControlPort, SIGNAL(valueChanged(int)), this, SLOT(SetControlPort(int))); - spinControlPort->setValue(det->setPort(slsDetectorDefs::CONTROL_PORT,port)); - qDefs::checkErrorMessage(det,"qTabAdvanced::SetControlPort"); + spinControlPort->setValue(myDet->setControlPort(port, comboDetector->currentIndex())); + qDefs::checkErrorMessage(myDet, comboDetector->currentIndex(), "qTabAdvanced::SetControlPort"); connect(spinControlPort, SIGNAL(valueChanged(int)), this, SLOT(SetControlPort(int))); } -//------------------------------------------------------------------------------------------------------------------------------------------------- - - void qTabAdvanced::SetStopPort(int port){ -#ifdef VERBOSE - cout << "Setting Stop Port:" << port << endl; -#endif + FILE_LOG(logINFO) << "Setting Stop Port:" << port; disconnect(spinStopPort, SIGNAL(valueChanged(int)), this, SLOT(SetStopPort(int))); - spinStopPort->setValue(det->setPort(slsDetectorDefs::STOP_PORT,port)); - qDefs::checkErrorMessage(det,"qTabAdvanced::SetStopPort"); + spinStopPort->setValue(myDet->setStopPort(port, comboDetector->currentIndex())); + qDefs::checkErrorMessage(myDet, comboDetector->currentIndex(), "qTabAdvanced::SetStopPort"); connect(spinStopPort, SIGNAL(valueChanged(int)), this, SLOT(SetStopPort(int))); } -//------------------------------------------------------------------------------------------------------------------------------------------------- - - void qTabAdvanced::SetRxrTCPPort(int port){ -#ifdef VERBOSE - cout << "Setting Receiver TCP Port:" << port << endl; -#endif + FILE_LOG(logINFO) << "Setting Receiver TCP Port:" << port; disconnect(spinTCPPort, SIGNAL(valueChanged(int)), this, SLOT(SetRxrTCPPort(int))); - spinTCPPort->setValue(det->setPort(slsDetectorDefs::DATA_PORT,port)); - qDefs::checkErrorMessage(det,"qTabAdvanced::SetRxrTCPPort"); + spinTCPPort->setValue(myDet->setReceiverPort(port, comboDetector->currentIndex())); + qDefs::checkErrorMessage(myDet, comboDetector->currentIndex(), "qTabAdvanced::SetRxrTCPPort"); connect(spinTCPPort, SIGNAL(valueChanged(int)), this, SLOT(SetRxrTCPPort(int))); } -//------------------------------------------------------------------------------------------------------------------------------------------------- - - void qTabAdvanced::SetRxrUDPPort(int port){ -#ifdef VERBOSE - cout << "Setting Receiver UDP Port:" << port << endl; -#endif + FILE_LOG(logINFO) << "Setting Receiver UDP Port:" << port; disconnect(spinUDPPort, SIGNAL(valueChanged(int)), this, SLOT(SetRxrUDPPort(int))); - spinUDPPort->setValue(det->setReceiverUDPPort(port)); - qDefs::checkErrorMessage(det,"qTabAdvanced::SetRxrUDPPort"); + spinUDPPort->setValue(myDet->setReceiverUDPPort(port, comboDetector->currentIndex())); + qDefs::checkErrorMessage(myDet, comboDetector->currentIndex(), "qTabAdvanced::SetRxrUDPPort"); connect(spinUDPPort, SIGNAL(valueChanged(int)), this, SLOT(SetRxrUDPPort(int))); } -//------------------------------------------------------------------------------------------------------------------------------------------------- - - void qTabAdvanced::SetCltZmqPort(int port){ -#ifdef VERBOSE - cout << "Setting Client UDP Port:" << port << endl; -#endif - ostringstream ss; ss << port; string sport = ss.str(); + FILE_LOG(logINFO) << "Setting Client UDP Port:" << port; + std::ostringstream ss; ss << port; std::string sport = ss.str(); disconnect(spinZmqPort, SIGNAL(valueChanged(int)), this, SLOT(SetCltZmqPort(int))); - spinZmqPort->setValue(atoi(det->setClientStreamingPort(sport).c_str())); - qDefs::checkErrorMessage(det,"qTabAdvanced::SetCltZmqPort"); + myDet->setClientDataStreamingInPort(port, comboDetector->currentIndex()); + spinZmqPort->setValue(myDet->getClientStreamingPort(comboDetector->currentIndex())); + qDefs::checkErrorMessage(myDet, comboDetector->currentIndex(), "qTabAdvanced::SetCltZmqPort"); myDet->enableDataStreamingToClient(false); myDet->enableDataStreamingToClient(true); qDefs::checkErrorMessage(myDet,"qTabAdvanced::SetCltZmqPort"); @@ -790,18 +236,14 @@ void qTabAdvanced::SetCltZmqPort(int port){ } -//------------------------------------------------------------------------------------------------------------------------------------------------- - - void qTabAdvanced::SetRxrZmqPort(int port){ -#ifdef VERBOSE - cout << "Setting Receiver UDP Port:" << port << endl; -#endif - ostringstream ss; ss << port; string sport = ss.str(); + FILE_LOG(logINFO) << "Setting Receiver UDP Port:" << port; + std::ostringstream ss; ss << port; std::string sport = ss.str(); disconnect(spinZmqPort2, SIGNAL(valueChanged(int)), this, SLOT(SetRxrZmqPort(int))); - spinZmqPort2->setValue(atoi(det->setReceiverStreamingPort(sport).c_str())); - qDefs::checkErrorMessage(det,"qTabAdvanced::SetRxrZmqPort"); + myDet->setReceiverDataStreamingOutPort(port, comboDetector->currentIndex()); + spinZmqPort2->setValue(myDet->getReceiverStreamingPort(comboDetector->currentIndex())); + qDefs::checkErrorMessage(myDet, comboDetector->currentIndex(), "qTabAdvanced::SetRxrZmqPort"); myDet->enableDataStreamingFromReceiver(false); myDet->enableDataStreamingFromReceiver(true); qDefs::checkErrorMessage(myDet,"qTabAdvanced::SetRxrZmqPort"); @@ -809,19 +251,15 @@ void qTabAdvanced::SetRxrZmqPort(int port){ } -//------------------------------------------------------------------------------------------------------------------------------------------------- - - void qTabAdvanced::SetReceiverOnline(int index){ -#ifdef VERBOSE - cout << "Setting Reciever Online to :" << index << endl; -#endif + FILE_LOG(logINFO) << "Setting Reciever Online to :" << index; disconnect(comboRxrOnline, SIGNAL(currentIndexChanged(int)), this, SLOT(SetReceiverOnline(int))); - if(index) + if(index){ SetReceiver(); - else - comboRxrOnline->setCurrentIndex(det->setReceiverOnline(index)); - qDefs::checkErrorMessage(det,"qTabAdvanced::SetReceiverOnline"); + }else{ + comboRxrOnline->setCurrentIndex(myDet->setReceiverOnline(index, comboDetector->currentIndex())); + } + qDefs::checkErrorMessage(myDet, comboDetector->currentIndex(), "qTabAdvanced::SetReceiverOnline"); connect(comboRxrOnline, SIGNAL(currentIndexChanged(int)), this, SLOT(SetReceiverOnline(int))); //highlight in red if offline if(!comboRxrOnline->currentIndex()){ @@ -838,16 +276,11 @@ void qTabAdvanced::SetReceiverOnline(int index){ } -//------------------------------------------------------------------------------------------------------------------------------------------------- - - void qTabAdvanced::SetOnline(int index){ -#ifdef VERBOSE - cout << "Setting Detector Online to " << index << endl; -#endif + FILE_LOG(logINFO) << "Setting Detector Online to " << index; disconnect(comboOnline, SIGNAL(currentIndexChanged(int)), this, SLOT(SetOnline(int))); - comboOnline->setCurrentIndex(det->setOnline(index)); - qDefs::checkErrorMessage(det,"qTabAdvanced::SetOnline"); + comboOnline->setCurrentIndex(myDet->setOnline(index, comboDetector->currentIndex())); + qDefs::checkErrorMessage(myDet, comboDetector->currentIndex(), "qTabAdvanced::SetOnline"); connect(comboOnline, SIGNAL(currentIndexChanged(int)), this, SLOT(SetOnline(int))); //highlight in red if offline if(!comboOnline->currentIndex()){ @@ -865,23 +298,19 @@ void qTabAdvanced::SetOnline(int index){ } -//------------------------------------------------------------------------------------------------------------------------------------------------- - - void qTabAdvanced::SetNetworkParameters(){ -#ifdef VERBOSE - cout << "Setting Network Parametrs" << endl; -#endif + FILE_LOG(logINFO) << "Setting Network Parametrs"; disconnect(dispIP, SIGNAL(editingFinished()), this, SLOT(SetNetworkParameters())); disconnect(dispMAC, SIGNAL(editingFinished()), this, SLOT(SetNetworkParameters())); disconnect(dispUDPIP, SIGNAL(editingFinished()), this, SLOT(SetNetworkParameters())); disconnect(dispUDPMAC, SIGNAL(editingFinished()), this, SLOT(SetNetworkParameters())); - dispIP->setText(QString(det->setDetectorIP(dispIP->text().toAscii().constData()).c_str())); - dispMAC->setText(QString(det->setDetectorMAC(dispMAC->text().toAscii().constData()).c_str())); - dispUDPIP->setText(QString(det->setReceiverUDPIP(dispUDPIP->text().toAscii().constData()).c_str())); - dispUDPMAC->setText(QString(det->setReceiverUDPMAC(dispUDPMAC->text().toAscii().constData()).c_str())); - qDefs::checkErrorMessage(det,"qTabAdvanced::SetNetworkParameters"); + auto moduleId = comboDetector->currentIndex(); + dispIP->setText(QString(myDet->setDetectorIP(dispIP->text().toAscii().constData(), moduleId).c_str())); + dispMAC->setText(QString(myDet->setDetectorMAC(dispMAC->text().toAscii().constData(), moduleId).c_str())); + dispUDPIP->setText(QString(myDet->setReceiverUDPIP(dispUDPIP->text().toAscii().constData(), moduleId).c_str())); + dispUDPMAC->setText(QString(myDet->setReceiverUDPMAC(dispUDPMAC->text().toAscii().constData(), moduleId).c_str())); + qDefs::checkErrorMessage(myDet, comboDetector->currentIndex(), "qTabAdvanced::SetNetworkParameters"); connect(dispIP, SIGNAL(editingFinished()), this, SLOT(SetNetworkParameters())); connect(dispMAC, SIGNAL(editingFinished()), this, SLOT(SetNetworkParameters())); @@ -890,65 +319,55 @@ void qTabAdvanced::SetNetworkParameters(){ } -//------------------------------------------------------------------------------------------------------------------------------------------------- - - void qTabAdvanced::SetClientZMQIP(){ -#ifdef VERBOSE - cout << "Setting Client ZMQ IP" << endl; -#endif + FILE_LOG(logINFO) << "Setting Client ZMQ IP"; disconnect(dispZMQIP, SIGNAL(editingFinished()), this, SLOT(SetClientZMQIP())); - dispZMQIP->setText(QString(det->setClientStreamingIP(dispZMQIP->text().toAscii().constData()).c_str())); + auto moduleId = comboDetector->currentIndex(); + myDet->setClientDataStreamingInIP(dispZMQIP->text().toAscii().constData(), moduleId); + dispZMQIP->setText(QString(myDet->getClientStreamingIP(moduleId).c_str())); myDet->enableDataStreamingToClient(false); myDet->enableDataStreamingToClient(true); - qDefs::checkErrorMessage(det,"qTabAdvanced::SetClientZMQIP"); + qDefs::checkErrorMessage(myDet, comboDetector->currentIndex(), "qTabAdvanced::SetClientZMQIP"); connect(dispZMQIP, SIGNAL(editingFinished()), this, SLOT(SetClientZMQIP())); } -//------------------------------------------------------------------------------------------------------------------------------------------------- - - void qTabAdvanced::SetReceiverZMQIP(){ -#ifdef VERBOSE - cout << "Setting Receiver ZMQ IP" << endl; -#endif + FILE_LOG(logINFO) << "Setting Receiver ZMQ IP"; disconnect(dispZMQIP2, SIGNAL(editingFinished()), this, SLOT(SetReceiverZMQIP())); - dispZMQIP2->setText(QString(det->setReceiverStreamingIP(dispZMQIP2->text().toAscii().constData()).c_str())); + auto moduleId = comboDetector->currentIndex(); + myDet->setReceiverDataStreamingOutIP(dispZMQIP2->text().toAscii().constData(), moduleId); + dispZMQIP2->setText(QString(myDet->getReceiverStreamingIP(moduleId).c_str())); myDet->enableDataStreamingFromReceiver(false); myDet->enableDataStreamingFromReceiver(true); - qDefs::checkErrorMessage(det,"qTabAdvanced::SetReceiverZMQIP"); + qDefs::checkErrorMessage(myDet, comboDetector->currentIndex(),"qTabAdvanced::SetReceiverZMQIP"); connect(dispZMQIP2, SIGNAL(editingFinished()), this, SLOT(SetReceiverZMQIP())); } -//------------------------------------------------------------------------------------------------------------------------------------------------- - - void qTabAdvanced::SetReceiver(){ -#ifdef VERBOSE - cout << "Setting Receiver" << endl; -#endif - string outdir = myDet->getFilePath(); - dispRxrHostname->setText(QString(det->setReceiver(dispRxrHostname->text().toAscii().constData()).c_str())); - qDefs::checkErrorMessage(det,"qTabAdvanced::SetReceiver"); - det->setFilePath(outdir); - qDefs::checkErrorMessage(det,"qTabAdvanced::SetReceiver"); + FILE_LOG(logINFO) << "Setting Receiver"; + auto outdir = myDet->getFilePath(); + auto moduleId = comboDetector->currentIndex(); + dispRxrHostname->setText(QString(myDet->setReceiverHostname(dispRxrHostname->text().toAscii().constData(), moduleId).c_str())); + qDefs::checkErrorMessage(myDet, comboDetector->currentIndex(), "qTabAdvanced::SetReceiver"); + myDet->setFilePath(outdir, moduleId); + qDefs::checkErrorMessage(myDet, comboDetector->currentIndex(), "qTabAdvanced::SetReceiver"); Refresh(); } -//------------------------------------------------------------------------------------------------------------------------------------------------- +void qTabAdvanced::AddROIInputSlot(){ + AddROIInput(1); +} void qTabAdvanced::updateROIList(){ -#ifdef VERYVERBOSE - cout<<"in updateROIList() " << endl; -#endif + FILE_LOG(logDEBUG) << "Updating ROIList"; clearROI(); int n,i; @@ -970,20 +389,15 @@ void qTabAdvanced::updateROIList(){ spinToX[i]->setValue(allroi[i].xmax); spinToY[i]->setValue(allroi[i].ymax); } - cout << "ROIs populated: " << n << endl; + FILE_LOG(logDEBUG) << "ROIs populated: " << n; } } -//------------------------------------------------------------------------------------------------------------------------------------------------- - - void qTabAdvanced::AddROIInput(int num){ -#ifdef VERVERBOSE - cout<<"in AddROIInput() " << num << endl; -#endif + FILE_LOG(logDEBUG) << "Add ROI Input " << num; if((int)lblFromX.size()){ disconnect(spinFromX[numRois], SIGNAL(valueChanged(int)), this, SLOT(AddROIInputSlot())); disconnect(spinFromY[numRois], SIGNAL(valueChanged(int)), this, SLOT(AddROIInputSlot())); @@ -1032,10 +446,10 @@ void qTabAdvanced::AddROIInput(int num){ spinToX[i]->setFixedHeight(19); spinToY[i]->setFixedHeight(19); - spinFromX[i]->setMaximum(myDet->getMaxNumberOfChannels(slsDetectorDefs::X)-1); - spinToX[i]->setMaximum(myDet->getMaxNumberOfChannels(slsDetectorDefs::X)-1); - spinFromY[i]->setMaximum(myDet->getMaxNumberOfChannels(slsDetectorDefs::Y)-1); - spinToY[i]->setMaximum(myDet->getMaxNumberOfChannels(slsDetectorDefs::Y)-1); + spinFromX[i]->setMaximum(myDet->getTotalNumberOfChannels(slsDetectorDefs::X)-1); + spinToX[i]->setMaximum(myDet->getTotalNumberOfChannels(slsDetectorDefs::X)-1); + spinFromY[i]->setMaximum(myDet->getTotalNumberOfChannels(slsDetectorDefs::Y)-1); + spinToY[i]->setMaximum(myDet->getTotalNumberOfChannels(slsDetectorDefs::Y)-1); spinFromX[i]->setMinimum(-1); spinToX[i]->setMinimum(-1); spinFromY[i]->setMinimum(-1); @@ -1075,30 +489,21 @@ void qTabAdvanced::AddROIInput(int num){ connect(spinToX[numRois], SIGNAL(valueChanged(int)), this, SLOT(AddROIInputSlot())); connect(spinToY[numRois], SIGNAL(valueChanged(int)), this, SLOT(AddROIInputSlot())); -#ifdef VERYVERBOSE - cout<<"ROI Inputs added " << num << endl; -#endif + FILE_LOG(logDEBUG) << "ROI Inputs added " << num; qDefs::checkErrorMessage(myDet,"qTabAdvanced::AddROIInput"); } -//------------------------------------------------------------------------------------------------------------------------------------------------- - - void qTabAdvanced::clearROI(){ -#ifdef VERYVERBOSE - cout<<"in clearROI() " << endl; -#endif + FILE_LOG(logDEBUG) << "in clearROI() "; if((int)lblFromX.size()){ disconnect(spinFromX[numRois], SIGNAL(valueChanged(int)), this, SLOT(AddROIInputSlot())); disconnect(spinFromY[numRois], SIGNAL(valueChanged(int)), this, SLOT(AddROIInputSlot())); disconnect(spinToX[numRois], SIGNAL(valueChanged(int)), this, SLOT(AddROIInputSlot())); disconnect(spinToY[numRois], SIGNAL(valueChanged(int)), this, SLOT(AddROIInputSlot())); - } - for (int i=0;isetValue(-1); spinFromY[i]->setValue(-1); @@ -1123,13 +528,8 @@ void qTabAdvanced::clearROI(){ } -//------------------------------------------------------------------------------------------------------------------------------------------------- - - void qTabAdvanced::setROI(){ -#ifdef VERYVERBOSE - cout<<"in setROI() " << endl; -#endif + FILE_LOG(logINFO) << "Setting ROI"; slsDetectorDefs::ROI allroi[MAX_ROIS]; @@ -1142,7 +542,7 @@ void qTabAdvanced::setROI(){ myDet->setROI(numRois,allroi); //qDefs::checkErrorMessage(myDet); - cout<<"ROIs set" << endl; + FILE_LOG(logDEBUG) << "ROIs set"; //get the correct list back updateROIList(); //configuremac @@ -1152,13 +552,8 @@ void qTabAdvanced::setROI(){ } -//------------------------------------------------------------------------------------------------------------------------------------------------- - - void qTabAdvanced::clearROIinDetector(){ -#ifdef VERYVERBOSE - cout<<"in clearROIinDetector() " << endl; -#endif + FILE_LOG(logINFO) << "Clearing ROI"; if (QMessageBox::warning(this, "Clear ROI", "Are you sure you want to clear all the ROI in detector?", @@ -1166,46 +561,39 @@ void qTabAdvanced::clearROIinDetector(){ clearROI(); setROI(); -#ifdef VERBOSE - cout << "ROIs cleared" << endl; -#endif + FILE_LOG(logDEBUG) << "ROIs cleared"; } } -//------------------------------------------------------------------------------------------------------------------------------------------------- - - void qTabAdvanced::SetDetector(int index){ -#ifdef VERYVERBOSE - cout<<"in SetDetector: " << index << endl; -#endif - det = myDet->getSlsDetector(comboDetector->currentIndex()); + FILE_LOG(logINFO) << "in SetDetector: " << index; + // det = myDet->getSlsDetector(comboDetector->currentIndex()); + auto moduleId = comboDetector->currentIndex(); + spinControlPort->setValue(myDet->setControlPort(-1, moduleId)); + spinStopPort->setValue(myDet->setStopPort(-1, moduleId)); + spinTCPPort->setValue(myDet->setReceiverPort(-1, moduleId)); + spinUDPPort->setValue(myDet->getReceiverUDPPort(moduleId)); + spinZmqPort->setValue(myDet->getClientStreamingPort(moduleId)); + spinZmqPort2->setValue(myDet->getReceiverStreamingPort(moduleId)); - spinControlPort->setValue(det->getControlPort()); - spinStopPort->setValue(det->getStopPort()); - spinTCPPort->setValue(det->getReceiverPort()); - spinUDPPort->setValue(atoi(det->getReceiverUDPPort().c_str())); - spinZmqPort->setValue(atoi(det->getClientStreamingPort().c_str())); - spinZmqPort2->setValue(atoi(det->getReceiverStreamingPort().c_str())); - - dispIP->setText(det->getDetectorIP().c_str()); - dispMAC->setText(det->getDetectorMAC().c_str()); - dispRxrHostname->setText(det->getReceiver().c_str()); - dispUDPIP->setText(det->getReceiverUDPIP().c_str()); - dispUDPMAC->setText(det->getReceiverUDPMAC().c_str()); - dispZMQIP->setText(det->getClientStreamingIP().c_str()); - dispZMQIP2->setText(det->getReceiverStreamingIP().c_str()); + dispIP->setText(myDet->getDetectorIP(moduleId).c_str()); + dispMAC->setText(myDet->getDetectorMAC(moduleId).c_str()); + dispRxrHostname->setText(myDet->getReceiverHostname(moduleId).c_str()); + dispUDPIP->setText(myDet->getReceiverUDPIP(moduleId).c_str()); + dispUDPMAC->setText(myDet->getReceiverUDPMAC(moduleId).c_str()); + dispZMQIP->setText(myDet->getClientStreamingIP(moduleId).c_str()); + dispZMQIP2->setText(myDet->getReceiverStreamingIP(moduleId).c_str()); //check if its online and set it to red if offline - if(det->setOnline()==slsDetectorDefs::ONLINE_FLAG) - det->checkOnline(); - if(det->setReceiverOnline()==slsDetectorDefs::ONLINE_FLAG) - det->checkReceiverOnline(); - comboOnline->setCurrentIndex(det->setOnline()); - comboRxrOnline->setCurrentIndex(det->setReceiverOnline()); + if(myDet->getOnline(moduleId) == slsDetectorDefs::ONLINE_FLAG) + myDet->checkOnline(moduleId); + if(myDet->getReceiverOnline(moduleId)==slsDetectorDefs::ONLINE_FLAG) + myDet->checkReceiverOnline(moduleId); + comboOnline->setCurrentIndex(myDet->getOnline(moduleId)); + comboRxrOnline->setCurrentIndex(myDet->getReceiverOnline(moduleId)); //highlight in red if detector or receiver is offline if(!comboOnline->currentIndex()){ comboOnline->setToolTip(detOnlineTip + errOnlineTip); @@ -1232,31 +620,21 @@ void qTabAdvanced::SetDetector(int index){ } } - qDefs::checkErrorMessage(det,"qTabAdvanced::SetDetector"); + qDefs::checkErrorMessage(myDet, comboDetector->currentIndex(), "qTabAdvanced::SetDetector"); } -//------------------------------------------------------------------------------------------------------------------------------------------------- - - void qTabAdvanced::SetAllTrimbits(){ -#ifdef VERBOSE - cout<<"Set all trimbits to " << spinSetAllTrimbits->value() << endl; -#endif + FILE_LOG(logINFO) << "Set all trimbits to " << spinSetAllTrimbits->value(); myDet->setAllTrimbits(spinSetAllTrimbits->value()); - qDefs::checkErrorMessage(myDet,"qTabAdvanced::SetAllTrimbits"); - updateAllTrimbitsFromServer(); + qDefs::checkErrorMessage(myDet,"qTabAdvanced::SetAllTrimbits"); + updateAllTrimbitsFromServer(); } -//------------------------------------------------------------------------------------------------------------------------------------------------- - - void qTabAdvanced::updateAllTrimbitsFromServer(){ -#ifdef VERBOSE - cout<<"Getting all trimbits value" << endl; -#endif + FILE_LOG(logDEBUG) << "Getting all trimbits value"; disconnect(spinSetAllTrimbits, SIGNAL(editingFinished()), this, SLOT(SetAllTrimbits())); int ret = myDet->setAllTrimbits(-1); @@ -1267,26 +645,18 @@ void qTabAdvanced::updateAllTrimbitsFromServer(){ } -//------------------------------------------------------------------------------------------------------------------------------------------------- - - void qTabAdvanced::SetNumStoragecells(int value) { -#ifdef VERBOSE - cout << "Setting number of stoarge cells to " << value << endl; -#endif - myDet->setTimer(slsDetectorDefs::STORAGE_CELL_NUMBER,value); + FILE_LOG(logINFO) << "Setting number of stoarge cells to " << value; + myDet->setTimer(slsDetectorDefs::STORAGE_CELL_NUMBER,value); - disconnect(spinNumStoragecells,SIGNAL(valueChanged(int)),this, SLOT(SetNumStoragecells(int))); - spinNumStoragecells->setValue((int)myDet->setTimer(slsDetectorDefs::STORAGE_CELL_NUMBER,-1)); - connect(spinNumStoragecells,SIGNAL(valueChanged(int)), this, SLOT(SetNumStoragecells(int))); + disconnect(spinNumStoragecells,SIGNAL(valueChanged(int)),this, SLOT(SetNumStoragecells(int))); + spinNumStoragecells->setValue((int)myDet->setTimer(slsDetectorDefs::STORAGE_CELL_NUMBER,-1)); + connect(spinNumStoragecells,SIGNAL(valueChanged(int)), this, SLOT(SetNumStoragecells(int))); - qDefs::checkErrorMessage(myDet,"qTabAdvanced::SetNumStoragecells"); + qDefs::checkErrorMessage(myDet,"qTabAdvanced::SetNumStoragecells"); } -//------------------------------------------------------------------------------------------------------------------------------------------------- - - void qTabAdvanced::SetSubExposureTime() { disconnect(spinSubExpTime,SIGNAL(valueChanged(double)), this, SLOT(SetSubExposureTime())); disconnect(comboSubExpTimeUnit,SIGNAL(currentIndexChanged(int)),this, SLOT(SetSubExposureTime())); @@ -1297,11 +667,9 @@ void qTabAdvanced::SetSubExposureTime() { spinSubExpTime->value()); // set value -#ifdef VERBOSE - cout << "Setting sub frame acquisition time to " << timeNS << " clocks" << + FILE_LOG(logINFO) << "Setting sub frame acquisition time to " << timeNS << " clocks" << "/" << spinSubExpTime->value() << - qDefs::getUnitString((qDefs::timeUnit)comboSubExpTimeUnit->currentIndex()) << endl; -#endif + qDefs::getUnitString((qDefs::timeUnit)comboSubExpTimeUnit->currentIndex()); myDet->setTimer(slsDetectorDefs::SUBFRAME_ACQUISITION_TIME,(int64_t)timeNS); qDefs::checkErrorMessage(myDet,"qTabAdvanced::SetSubExposureTime"); @@ -1313,9 +681,6 @@ void qTabAdvanced::SetSubExposureTime() { comboSubExpTimeUnit->setCurrentIndex((int)unit); - // highlight if period < exptime - CheckAcqPeriodGreaterThanExp(); - connect(spinSubExpTime,SIGNAL(valueChanged(double)), this, SLOT(SetSubExposureTime())); connect(comboSubExpTimeUnit,SIGNAL(currentIndexChanged(int)), this, SLOT(SetSubExposureTime())); @@ -1324,163 +689,59 @@ void qTabAdvanced::SetSubExposureTime() { } -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qTabAdvanced::SetSubPeriod() { - disconnect(spinSubPeriod,SIGNAL(valueChanged(double)), this, SLOT(SetSubPeriod())); - disconnect(comboSubPeriodUnit,SIGNAL(currentIndexChanged(int)),this, SLOT(SetSubPeriod())); +void qTabAdvanced::SetSubDeadTime() { + disconnect(spinSubDeadTime,SIGNAL(valueChanged(double)), this, SLOT(SetSubDeadTime())); + disconnect(comboSubDeadTimeUnit,SIGNAL(currentIndexChanged(int)),this, SLOT(SetSubDeadTime())); //Get the value of timer in ns double timeNS = qDefs::getNSTime( - (qDefs::timeUnit)comboSubPeriodUnit->currentIndex(), - spinSubPeriod->value()); + (qDefs::timeUnit)comboSubDeadTimeUnit->currentIndex(), + spinSubDeadTime->value()); // set value -#ifdef VERBOSE - cout << "Setting sub frame period to " << timeNS << " clocks" << - "/" << spinSubPeriod->value() << - qDefs::getUnitString((qDefs::timeUnit)comboSubPeriodUnit->currentIndex()) << endl; -#endif + FILE_LOG(logINFO) << "Setting sub dead time to " << timeNS << " clocks" << + "/" << spinSubDeadTime->value() << + qDefs::getUnitString((qDefs::timeUnit)comboSubDeadTimeUnit->currentIndex()); myDet->setTimer(slsDetectorDefs::SUBFRAME_DEADTIME,(int64_t)timeNS); - qDefs::checkErrorMessage(myDet,"qTabAdvanced::SetSubPeriod"); + qDefs::checkErrorMessage(myDet,"qTabAdvanced::SetSubDeadTime"); // update value in gui qDefs::timeUnit unit; double time = qDefs::getCorrectTime(unit,((double)( myDet->setTimer(slsDetectorDefs::SUBFRAME_DEADTIME,-1)*(1E-9)))); - spinSubPeriod->setValue(time); - comboSubPeriodUnit->setCurrentIndex((int)unit); + spinSubDeadTime->setValue(time); + comboSubDeadTimeUnit->setCurrentIndex((int)unit); - // highlight if period < exptime - CheckAcqPeriodGreaterThanExp(); + connect(spinSubDeadTime,SIGNAL(valueChanged(double)), this, SLOT(SetSubDeadTime())); + connect(comboSubDeadTimeUnit,SIGNAL(currentIndexChanged(int)),this, SLOT(SetSubDeadTime())); - connect(spinSubPeriod,SIGNAL(valueChanged(double)), this, SLOT(SetSubPeriod())); - connect(comboSubPeriodUnit,SIGNAL(currentIndexChanged(int)),this, SLOT(SetSubPeriod())); - - - qDefs::checkErrorMessage(myDet,"qTabAdvanced::SetSubPeriod"); + qDefs::checkErrorMessage(myDet,"qTabAdvanced::SetSubDeadTime"); } -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qTabAdvanced::CheckAcqPeriodGreaterThanExp(){ - double exptimeNS = qDefs::getNSTime( - (qDefs::timeUnit)comboSubExpTimeUnit->currentIndex(), - spinSubExpTime->value()); - double acqtimeNS = qDefs::getNSTime( - (qDefs::timeUnit)comboSubPeriodUnit->currentIndex(), - spinSubPeriod->value()); - if(exptimeNS>acqtimeNS && acqtimeNS > 0) { - spinSubPeriod->setToolTip(errSubPeriodTip); - lblSubPeriod->setToolTip(errSubPeriodTip); - lblSubPeriod->setPalette(red); - lblSubPeriod->setText("Sub Frame Period:*"); - } - else { - spinSubPeriod->setToolTip(acqSubPeriodTip); - lblSubPeriod->setToolTip(acqSubPeriodTip); - lblSubPeriod->setPalette(lblExpTime->palette()); - lblSubPeriod->setText("Sub Frame Period:"); - } -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - void qTabAdvanced::Refresh(){ -#ifdef VERBOSE - cout << endl << "**Updating Advanced Tab" << endl; -#endif - //setting color of tab - //void setTabBar ( QTabBar * tb ) - //QTabBar * tabBar () const - /* - for(int i=0;itabBar()->setTabTextColor(i,defaultTabColor); - tabAdvancedSettings->tabBar()->setTabTextColor(index,QColor(0,0,200,255)); - */ - - if(isAngular){ -#ifdef VERBOSE - cout << "Angular Calibration Log set to " << chkAngularLog->isChecked() << endl; -#endif - - disconnect(chkAngularLog, SIGNAL(toggled(bool)), this, SLOT(SetLogs())); - - chkAngularLog->setChecked(myDet->getActionMode(slsDetectorDefs::angCalLog)); - - connect(chkAngularLog, SIGNAL(toggled(bool)), this, SLOT(SetLogs())); - } - - - if(isEnergy){ - //disconnect - disconnect(chkEnergyLog, SIGNAL(toggled(bool)), this, SLOT(SetLogs())); - disconnect(spinExpTime, SIGNAL(valueChanged(double)), this, SLOT(SetExposureTime())); - disconnect(comboExpUnit, SIGNAL(currentIndexChanged(int)), this, SLOT(SetExposureTime())); - disconnect(spinThreshold, SIGNAL(valueChanged(double)), this, SLOT(SetThreshold())); - - - //energy/angular logs - chkEnergyLog->setChecked(myDet->getActionMode(slsDetectorDefs::enCalLog)); -#ifdef VERBOSE - cout << "Energy Calibration Log set to " << chkEnergyLog->isChecked() << endl; -#endif - - - //exptime - qDefs::timeUnit unit; - double time = qDefs::getCorrectTime(unit,((double)(myDet->setTimer(slsDetectorDefs::ACQUISITION_TIME,-1)*(1E-9)))); -#ifdef VERBOSE - cout << "Getting acquisition time : " << time << qDefs::getUnitString(unit) << endl; -#endif - spinExpTime->setValue(time); - comboExpUnit->setCurrentIndex((int)unit); - - - //threshold - double threshold = (double)myDet->setDAC(-1,slsDetectorDefs::THRESHOLD,0); -#ifdef VERBOSE - cout << "Getting Threshold DACu : " << threshold << endl; -#endif - spinThreshold->setValue(threshold); - - - //connect - connect(chkEnergyLog, SIGNAL(toggled(bool)), this, SLOT(SetLogs())); - connect(spinExpTime, SIGNAL(valueChanged(double)), this, SLOT(SetExposureTime())); - connect(comboExpUnit, SIGNAL(currentIndexChanged(int)), this, SLOT(SetExposureTime())); - connect(spinThreshold, SIGNAL(valueChanged(double)), this, SLOT(SetThreshold())); - } - + FILE_LOG(logDEBUG) << endl << "**Updating Advanced Tab"; //network - det = myDet->getSlsDetector(comboDetector->currentIndex()); - + auto moduleId = comboDetector->currentIndex(); qDefs::checkErrorMessage(myDet,"qTabAdvanced::Refresh"); -#ifdef VERBOSE - cout << "Getting Detector Ports" << endl; -#endif + FILE_LOG(logDEBUG) << "Getting Detector Ports"; //disconnect disconnect(spinControlPort, SIGNAL(valueChanged(int)), this, SLOT(SetControlPort(int))); disconnect(spinStopPort, SIGNAL(valueChanged(int)), this, SLOT(SetStopPort(int))); disconnect(comboOnline, SIGNAL(currentIndexChanged(int)), this, SLOT(SetOnline(int))); //so that updated status - if(det->setOnline()==slsDetectorDefs::ONLINE_FLAG) - det->checkOnline(); - comboOnline->setCurrentIndex(det->setOnline()); - spinControlPort->setValue(det->getControlPort()); - spinStopPort->setValue(det->getStopPort()); + if(myDet->getOnline(moduleId)==slsDetectorDefs::ONLINE_FLAG) + myDet->checkOnline(moduleId); + comboOnline->setCurrentIndex(myDet->getOnline(moduleId)); + spinControlPort->setValue(myDet->setControlPort(-1, moduleId)); + spinStopPort->setValue(myDet->setStopPort(-1, moduleId)); //connect connect(spinControlPort, SIGNAL(valueChanged(int)), this, SLOT(SetControlPort(int))); @@ -1488,60 +749,56 @@ void qTabAdvanced::Refresh(){ connect(comboOnline, SIGNAL(currentIndexChanged(int)), this, SLOT(SetOnline(int))); -#ifdef VERBOSE - cout << "Getting Receiver Network Information" << endl; -#endif - if (detType!=slsDetectorDefs::MYTHEN){ - //disconnect - disconnect(spinTCPPort, SIGNAL(valueChanged(int)), this, SLOT(SetRxrTCPPort(int))); - disconnect(spinUDPPort, SIGNAL(valueChanged(int)), this, SLOT(SetRxrUDPPort(int))); - disconnect(spinZmqPort, SIGNAL(valueChanged(int)), this, SLOT(SetCltZmqPort(int))); - disconnect(spinZmqPort2, SIGNAL(valueChanged(int)), this, SLOT(SetRxrZmqPort(int))); - disconnect(comboRxrOnline, SIGNAL(currentIndexChanged(int)), this, SLOT(SetReceiverOnline(int))); - disconnect(dispIP, SIGNAL(editingFinished()), this, SLOT(SetNetworkParameters())); - disconnect(dispMAC, SIGNAL(editingFinished()), this, SLOT(SetNetworkParameters())); - disconnect(dispUDPIP, SIGNAL(editingFinished()), this, SLOT(SetNetworkParameters())); - disconnect(dispUDPMAC, SIGNAL(editingFinished()), this, SLOT(SetNetworkParameters())); - disconnect(btnRxr, SIGNAL(clicked()), this, SLOT(SetReceiver())); + FILE_LOG(logDEBUG) << "Getting Receiver Network Information"; + //disconnect + disconnect(spinTCPPort, SIGNAL(valueChanged(int)), this, SLOT(SetRxrTCPPort(int))); + disconnect(spinUDPPort, SIGNAL(valueChanged(int)), this, SLOT(SetRxrUDPPort(int))); + disconnect(spinZmqPort, SIGNAL(valueChanged(int)), this, SLOT(SetCltZmqPort(int))); + disconnect(spinZmqPort2, SIGNAL(valueChanged(int)), this, SLOT(SetRxrZmqPort(int))); + disconnect(comboRxrOnline, SIGNAL(currentIndexChanged(int)), this, SLOT(SetReceiverOnline(int))); + disconnect(dispIP, SIGNAL(editingFinished()), this, SLOT(SetNetworkParameters())); + disconnect(dispMAC, SIGNAL(editingFinished()), this, SLOT(SetNetworkParameters())); + disconnect(dispUDPIP, SIGNAL(editingFinished()), this, SLOT(SetNetworkParameters())); + disconnect(dispUDPMAC, SIGNAL(editingFinished()), this, SLOT(SetNetworkParameters())); + disconnect(btnRxr, SIGNAL(clicked()), this, SLOT(SetReceiver())); - dispIP->setText(det->getDetectorIP().c_str()); - dispMAC->setText(det->getDetectorMAC().c_str()); + dispIP->setText(myDet->getDetectorIP(moduleId).c_str()); + dispMAC->setText(myDet->getDetectorMAC(moduleId).c_str()); - //so that updated status - if(det->setReceiverOnline()==slsDetectorDefs::ONLINE_FLAG) - det->checkReceiverOnline(); - comboRxrOnline->setCurrentIndex(det->setReceiverOnline()); + //so that updated status + if(myDet->setReceiverOnline(slsDetectorDefs::GET_ONLINE_FLAG, moduleId)==slsDetectorDefs::ONLINE_FLAG) + myDet->checkReceiverOnline(moduleId); + comboRxrOnline->setCurrentIndex(myDet->setReceiverOnline(slsDetectorDefs::GET_ONLINE_FLAG, moduleId)); - dispRxrHostname->setText(det->getReceiver().c_str()); - spinTCPPort->setValue(det->getReceiverPort()); - spinUDPPort->setValue(atoi(det->getReceiverUDPPort().c_str())); - spinZmqPort->setValue(atoi(det->getClientStreamingPort().c_str())); - spinZmqPort2->setValue(atoi(det->getReceiverStreamingPort().c_str())); + dispRxrHostname->setText(myDet->getReceiverHostname(moduleId).c_str()); + spinTCPPort->setValue(myDet->setReceiverPort(-1, moduleId)); + spinUDPPort->setValue(myDet->getReceiverUDPPort(moduleId)); + spinZmqPort->setValue(myDet->getClientStreamingPort(moduleId)); + spinZmqPort2->setValue(myDet->getReceiverStreamingPort(moduleId)); - dispUDPIP->setText(det->getReceiverUDPIP().c_str()); - dispUDPMAC->setText(det->getReceiverUDPMAC().c_str()); + dispUDPIP->setText(myDet->getReceiverUDPIP(moduleId).c_str()); + dispUDPMAC->setText(myDet->getReceiverUDPMAC(moduleId).c_str()); - //connect - connect(spinTCPPort, SIGNAL(valueChanged(int)), this, SLOT(SetRxrTCPPort(int))); - connect(spinUDPPort, SIGNAL(valueChanged(int)), this, SLOT(SetRxrUDPPort(int))); - connect(spinZmqPort, SIGNAL(valueChanged(int)), this, SLOT(SetCltZmqPort(int))); - connect(spinZmqPort2, SIGNAL(valueChanged(int)), this, SLOT(SetRxrZmqPort(int))); - connect(comboRxrOnline, SIGNAL(currentIndexChanged(int)), this, SLOT(SetReceiverOnline(int))); - connect(dispIP, SIGNAL(editingFinished()), this, SLOT(SetNetworkParameters())); - connect(dispMAC, SIGNAL(editingFinished()), this, SLOT(SetNetworkParameters())); - connect(dispUDPIP, SIGNAL(editingFinished()), this, SLOT(SetNetworkParameters())); - connect(dispUDPMAC, SIGNAL(editingFinished()), this, SLOT(SetNetworkParameters())); - connect(btnRxr, SIGNAL(clicked()), this, SLOT(SetReceiver())); + //connect + connect(spinTCPPort, SIGNAL(valueChanged(int)), this, SLOT(SetRxrTCPPort(int))); + connect(spinUDPPort, SIGNAL(valueChanged(int)), this, SLOT(SetRxrUDPPort(int))); + connect(spinZmqPort, SIGNAL(valueChanged(int)), this, SLOT(SetCltZmqPort(int))); + connect(spinZmqPort2, SIGNAL(valueChanged(int)), this, SLOT(SetRxrZmqPort(int))); + connect(comboRxrOnline, SIGNAL(currentIndexChanged(int)), this, SLOT(SetReceiverOnline(int))); + connect(dispIP, SIGNAL(editingFinished()), this, SLOT(SetNetworkParameters())); + connect(dispMAC, SIGNAL(editingFinished()), this, SLOT(SetNetworkParameters())); + connect(dispUDPIP, SIGNAL(editingFinished()), this, SLOT(SetNetworkParameters())); + connect(dispUDPMAC, SIGNAL(editingFinished()), this, SLOT(SetNetworkParameters())); + connect(btnRxr, SIGNAL(clicked()), this, SLOT(SetReceiver())); - // zmq parameters - disconnect(dispZMQIP, SIGNAL(editingFinished()), this, SLOT(SetClientZMQIP())); - dispZMQIP->setText(det->getClientStreamingIP().c_str()); - connect(dispZMQIP, SIGNAL(editingFinished()), this, SLOT(SetClientZMQIP())); + // zmq parameters + disconnect(dispZMQIP, SIGNAL(editingFinished()), this, SLOT(SetClientZMQIP())); + dispZMQIP->setText(myDet->getClientStreamingIP(moduleId).c_str()); + connect(dispZMQIP, SIGNAL(editingFinished()), this, SLOT(SetClientZMQIP())); - disconnect(dispZMQIP2, SIGNAL(editingFinished()), this, SLOT(SetReceiverZMQIP())); - dispZMQIP2->setText(det->getReceiverStreamingIP().c_str()); - connect(dispZMQIP2, SIGNAL(editingFinished()), this, SLOT(SetReceiverZMQIP())); - } + disconnect(dispZMQIP2, SIGNAL(editingFinished()), this, SLOT(SetReceiverZMQIP())); + dispZMQIP2->setText(myDet->getReceiverStreamingIP(moduleId).c_str()); + connect(dispZMQIP2, SIGNAL(editingFinished()), this, SLOT(SetReceiverZMQIP())); //highlight in red if detector or receiver is offline if(!comboOnline->currentIndex()){ @@ -1570,11 +827,9 @@ void qTabAdvanced::Refresh(){ } //roi -#ifdef VERBOSE - cout << "Getting ROI" << endl; -#endif - if (detType == slsDetectorDefs::GOTTHARD) - updateROIList(); + FILE_LOG(logDEBUG) << "Getting ROI"; + if (detType == slsDetectorDefs::GOTTHARD) + updateROIList(); //update alltirmbits from server if(boxSetAllTrimbits->isEnabled()) @@ -1582,21 +837,19 @@ void qTabAdvanced::Refresh(){ // storage cells if (detType == slsDetectorDefs::JUNGFRAU) { - disconnect(spinNumStoragecells,SIGNAL(valueChanged(int)),this, SLOT(SetNumStoragecells(int))); - spinNumStoragecells->setValue((int)myDet->setTimer(slsDetectorDefs::STORAGE_CELL_NUMBER,-1)); - connect(spinNumStoragecells,SIGNAL(valueChanged(int)), this, SLOT(SetNumStoragecells(int))); + disconnect(spinNumStoragecells,SIGNAL(valueChanged(int)),this, SLOT(SetNumStoragecells(int))); + spinNumStoragecells->setValue((int)myDet->setTimer(slsDetectorDefs::STORAGE_CELL_NUMBER,-1)); + connect(spinNumStoragecells,SIGNAL(valueChanged(int)), this, SLOT(SetNumStoragecells(int))); } - // sub exptime and sub period + // sub exptime and sub dead time else if (detType == slsDetectorDefs::EIGER) { disconnect(spinSubExpTime,SIGNAL(valueChanged(double)), this, SLOT(SetSubExposureTime())); disconnect(comboSubExpTimeUnit,SIGNAL(currentIndexChanged(int)),this, SLOT(SetSubExposureTime())); - disconnect(spinSubPeriod,SIGNAL(valueChanged(double)), this, SLOT(SetSubPeriod())); - disconnect(comboSubPeriodUnit,SIGNAL(currentIndexChanged(int)),this, SLOT(SetSubPeriod())); + disconnect(spinSubDeadTime,SIGNAL(valueChanged(double)), this, SLOT(SetSubDeadTime())); + disconnect(comboSubDeadTimeUnit,SIGNAL(currentIndexChanged(int)),this, SLOT(SetSubDeadTime())); -#ifdef VERBOSE - cout << "Getting Sub Exposure time and Sub Period" << endl; -#endif + FILE_LOG(logDEBUG) << "Getting Sub Exposure time and Sub Dead Time"; // subexptime qDefs::timeUnit unit; double time = qDefs::getCorrectTime(unit,((double)( @@ -1604,28 +857,20 @@ void qTabAdvanced::Refresh(){ spinSubExpTime->setValue(time); comboSubExpTimeUnit->setCurrentIndex((int)unit); - // subperiod + // subdeadtime time = qDefs::getCorrectTime(unit,((double)(myDet->setTimer(slsDetectorDefs::SUBFRAME_DEADTIME,-1)*(1E-9)))); - spinSubPeriod->setValue(time); - comboSubPeriodUnit->setCurrentIndex((int)unit); + spinSubDeadTime->setValue(time); + comboSubDeadTimeUnit->setCurrentIndex((int)unit); - // highlight if period < exptime - CheckAcqPeriodGreaterThanExp(); - connect(spinSubExpTime,SIGNAL(valueChanged(double)), this, SLOT(SetSubExposureTime())); connect(comboSubExpTimeUnit,SIGNAL(currentIndexChanged(int)), this, SLOT(SetSubExposureTime())); - connect(spinSubPeriod,SIGNAL(valueChanged(double)), this, SLOT(SetSubPeriod())); - connect(comboSubPeriodUnit,SIGNAL(currentIndexChanged(int)),this, SLOT(SetSubPeriod())); + connect(spinSubDeadTime,SIGNAL(valueChanged(double)), this, SLOT(SetSubDeadTime())); + connect(comboSubDeadTimeUnit,SIGNAL(currentIndexChanged(int)),this, SLOT(SetSubDeadTime())); } -#ifdef VERBOSE - cout << "**Updated Advanced Tab" << endl << endl; -#endif + FILE_LOG(logDEBUG) << "**Updated Advanced Tab"; - qDefs::checkErrorMessage(det,"qTabAdvanced::Refresh"); + qDefs::checkErrorMessage(myDet, moduleId, "qTabAdvanced::Refresh"); } - -//------------------------------------------------------------------------------------------------------------------------------------------------- - diff --git a/slsDetectorGui/src/qTabDataOutput.cpp b/slsDetectorGui/src/qTabDataOutput.cpp old mode 100644 new mode 100755 index 02e644ea8..6256b0363 --- a/slsDetectorGui/src/qTabDataOutput.cpp +++ b/slsDetectorGui/src/qTabDataOutput.cpp @@ -1,556 +1,149 @@ -/* - * qTabDataOutput.cpp - * - * Created on: May 10, 2012 - * Author: l_maliakal_d - */ -/********************************************************************** - * ********************************************************************/ - #include "qTabDataOutput.h" -// Project Class Headers -#include "slsDetector.h" + #include "multiSlsDetector.h" -// Qt Include Headers -#include + #include -// C++ Include Headers +#include + #include #include -using namespace std; -//------------------------------------------------------------------------------------------------------------------------------------------------- - - - -qTabDataOutput::qTabDataOutput(QWidget *parent,multiSlsDetector*& detector): - QWidget(parent),myDet(detector){ +qTabDataOutput::qTabDataOutput(QWidget *parent, multiSlsDetector *detector) : QWidget(parent), myDet(detector) { setupUi(this); SetupWidgetWindow(); Refresh(); + FILE_LOG(logDEBUG) << "DataOutput ready"; } -//------------------------------------------------------------------------------------------------------------------------------------------------- +qTabDataOutput::~qTabDataOutput() {} -qTabDataOutput::~qTabDataOutput(){ - delete myDet; -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qTabDataOutput::SetupWidgetWindow(){ - // Detector Type - detType=myDet->getDetectorsType(); - widgetEiger->setVisible(false); - - //rate correction - not for charge integrating detectors - if((detType == slsDetectorDefs::MYTHEN)||(detType == slsDetectorDefs::EIGER)) - chkRate->setEnabled(true); - - if((detType == slsDetectorDefs::MYTHEN)||(detType == slsDetectorDefs::GOTTHARD)) - chkAngular->setEnabled(true); - - if(detType == slsDetectorDefs::EIGER){ - chkRate->setEnabled(true); - chkTenGiga->setEnabled(true); - widgetEiger->setVisible(true); - } - - /** error message **/ +void qTabDataOutput::SetupWidgetWindow() { red = QPalette(); - red.setColor(QPalette::Active,QPalette::WindowText,Qt::red); + red.setColor(QPalette::Active, QPalette::WindowText, Qt::red); black = QPalette(); - black.setColor(QPalette::Active,QPalette::WindowText,Qt::black); + black.setColor(QPalette::Active, QPalette::WindowText, Qt::black); red1 = new QPalette(); - red1->setColor(QPalette::Text,Qt::red); + red1->setColor(QPalette::Text, Qt::red); black1 = new QPalette(); - black1->setColor(QPalette::Text,Qt::black); + black1->setColor(QPalette::Text, Qt::black); - flatFieldTip = dispFlatField->toolTip(); - errFlatFieldTip = QString("Flat field corrections.
" - " #flatfield# filename

")+ - QString("" - "Enter a valid file to enable Flat Field."); outDirTip = lblOutputDir->toolTip(); + // Detector Type + detType = myDet->getDetectorTypeAsEnum(); - //not used at all, later used for gappixels - chkUnused->setEnabled(false); - - //enabling file format depending on detector type - SetupFileFormat(); + // disabling depening on detector type + chkRate->setEnabled(false); + widgetEiger->setVisible(false); + if (detType == slsDetectorDefs::EIGER) { + chkRate->setEnabled(true); + widgetEiger->setVisible(true); + } + chkTenGiga->setEnabled(false); + if (detType == slsDetectorDefs::EIGER || detType == slsDetectorDefs::MOENCH) { + chkTenGiga->setEnabled(true); + } Initialization(); - disconnect(comboDetector, SIGNAL(currentIndexChanged(int)), this, SLOT(GetOutputDir())); + // populate detectors, get output dir PopulateDetectors(); - connect(comboDetector, SIGNAL(currentIndexChanged(int)), this, SLOT(GetOutputDir())); - //flat field correction from server -#ifdef VERBOSE - cout << "Getting flat field" << endl; -#endif - UpdateFlatFieldFromServer(); + VerifyOutputDirectory(); + // over write + UpdateFileOverwriteFromServer(); - //rate correction - not for charge integrating detectors - if((detType == slsDetectorDefs::MYTHEN)||(detType == slsDetectorDefs::EIGER)){ -#ifdef VERBOSE - cout << "Getting rate correction" << endl; -#endif + // file format + UpdateFileFormatFromServer(); + + // rate correction + if (chkRate->isEnabled()) { UpdateRateCorrectionFromServer(); } - - //update angular conversion from server - if((detType == slsDetectorDefs::MYTHEN)||(detType == slsDetectorDefs::GOTTHARD)){ -#ifdef VERBOSE - cout << "Getting angular conversion" << endl; -#endif - int ang; - if(myDet->getAngularConversion(ang)) - chkAngular->setChecked(true); - emit AngularConversionSignal(chkAngular->isChecked()); + // 10 gbe + if (chkTenGiga->isEnabled()) { + EnableTenGigabitEthernet(-1, 1); } - - //discard bad channels from server -#ifdef VERBOSE - cout << "Getting bad channel correction:" << myDet->getBadChannelCorrection() << endl; -#endif - disconnect(chkDiscardBad, SIGNAL(toggled(bool))); - if(myDet->getBadChannelCorrection()) - chkDiscardBad->setChecked(true); - else - chkDiscardBad->setChecked(false); - connect(chkDiscardBad, SIGNAL(toggled(bool)), this, SLOT(DiscardBadChannels())); - -/* - if(detType == slsDetectorDefs::MYTHEN){ - comboDetector->hide(); + //Eiger specific + if (widgetEiger->isVisible()) { + //speed + UpdateSpeedFromServer(); + //flags + UpdateFlagsFromServer(); } -*/ - qDefs::checkErrorMessage(myDet,"qTabDataOutput::SetupWidgetWindow"); + + qDefs::checkErrorMessage(myDet, "qTabDataOutput::SetupWidgetWindow"); } -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qTabDataOutput::Initialization(){ +void qTabDataOutput::Initialization() { //output dir - connect(comboDetector, SIGNAL(currentIndexChanged(int)), this, SLOT(GetOutputDir())); - connect(dispOutputDir, SIGNAL(editingFinished()), this, SLOT(SetOutputDir())); + connect(comboDetector, SIGNAL(currentIndexChanged(int)), this, SLOT(GetOutputDir())); + connect(dispOutputDir, SIGNAL(editingFinished()), this, SLOT(SetOutputDir())); + connect(btnOutputBrowse, SIGNAL(clicked()), this, SLOT(BrowseOutputDir())); //overwrite enable - connect(chkOverwriteEnable, SIGNAL(toggled(bool)), this, SLOT(SetOverwriteEnable(bool))); + connect(chkOverwriteEnable, SIGNAL(toggled(bool)), this, SLOT(SetOverwriteEnable(bool))); //file format - connect(comboFileFormat, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFileFormat(int))); + connect(comboFileFormat, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFileFormat(int))); - connect(btnOutputBrowse, SIGNAL(clicked()), this, SLOT(BrowseOutputDir())); - //flat field correction - connect(chkFlatField, SIGNAL(toggled(bool)), this, SLOT(SetFlatField())); - connect(btnFlatField, SIGNAL(clicked()), this, SLOT(BrowseFlatFieldPath())); //rate correction - connect(chkRate, SIGNAL(toggled(bool)), this, SLOT(SetRateCorrection())); - connect(btnDefaultRate, SIGNAL(clicked()), this, SLOT(SetDefaultRateCorrection())); - connect(spinDeadTime, SIGNAL(editingFinished()), this, SLOT(SetRateCorrection())); + connect(chkRate, SIGNAL(toggled(bool)), this, SLOT(SetRateCorrection())); + connect(btnDefaultRate, SIGNAL(clicked()), this, SLOT(SetDefaultRateCorrection())); + connect(spinDeadTime, SIGNAL(editingFinished()), this, SLOT(SetRateCorrection())); - //angular correction - connect(chkAngular, SIGNAL(toggled(bool)), this, SLOT(SetAngularCorrection())); - //discard bad channels - connect(chkDiscardBad, SIGNAL(toggled(bool)), this, SLOT(DiscardBadChannels())); //10GbE - connect(chkTenGiga, SIGNAL(toggled(bool)), this, SLOT(EnableTenGigabitEthernet(bool))); + connect(chkTenGiga, SIGNAL(toggled(bool)), this, SLOT(EnableTenGigabitEthernet(bool))); //eiger - if(widgetEiger->isVisible()){ + if (widgetEiger->isVisible()) { //speed - connect(comboEigerClkDivider,SIGNAL(currentIndexChanged(int)), this, SLOT(SetSpeed())); + connect(comboEigerClkDivider, SIGNAL(currentIndexChanged(int)), this, SLOT(SetSpeed())); //flags - connect(comboEigerFlags1, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFlags())); - connect(comboEigerFlags2, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFlags())); + connect(comboEigerFlags1, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFlags())); + connect(comboEigerFlags2, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFlags())); } } -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qTabDataOutput::BrowseOutputDir() -{ - QString directory = QFileDialog::getExistingDirectory(this,tr("Choose Output Directory "),dispOutputDir->text()); +void qTabDataOutput::BrowseOutputDir() { + QString directory = QFileDialog::getExistingDirectory(this, tr("Choose Output Directory "), dispOutputDir->text()); if (!directory.isEmpty()) dispOutputDir->setText(directory); SetOutputDir(); } -//------------------------------------------------------------------------------------------------------------------------------------------------- +void qTabDataOutput::GetOutputDir() { + FILE_LOG(logDEBUG) << "Getting output directory"; - -void qTabDataOutput::SetFlatField(){ -#ifdef VERYVERBOSE - cout << "Entering Set Flat Field Correction Function" << endl; -#endif - // so that it doesnt call it twice - disconnect(dispFlatField, SIGNAL(editingFinished()), this, SLOT(SetFlatField())); - - //enable/disable - dispFlatField->setEnabled(chkFlatField->isChecked()); - btnFlatField->setEnabled(chkFlatField->isChecked()); - - if(chkFlatField->isChecked()){ - if(dispFlatField->text().isEmpty()){ - chkFlatField->setToolTip(errFlatFieldTip); - dispFlatField->setToolTip(errFlatFieldTip); - chkFlatField->setPalette(red); - chkFlatField->setText("Flat Field File:*"); -#ifdef VERBOSE - cout << "Flat Field File is not set." << endl; -#endif - }else{ - QString fName = dispFlatField->text(); - QString file = fName.section('/',-1); - QString dir = fName.section('/',0,-2,QString::SectionIncludeLeadingSep); - - chkFlatField->setToolTip(flatFieldTip); - dispFlatField->setToolTip(flatFieldTip); - chkFlatField->setPalette(chkDiscardBad->palette()); - chkFlatField->setText("Flat Field File:"); - //set ff dir - myDet->setFlatFieldCorrectionDir(dir.toAscii().constData()); - //set ff file and catch error if -1 - if(myDet->setFlatFieldCorrectionFile(file.toAscii().constData())<0){ - string sDir = dir.toAscii().constData(),sFile = file.toAscii().constData(); - if(sDir.length()<1) {sDir = string(QDir::current().absolutePath().toAscii().constData()); /*"/home/";*/} - qDefs::Message(qDefs::WARNING,"Invalid Flat Field file: "+sDir+"/"+sFile+ - ".\nUnsetting Flat Field.","qTabDataOutput::SetFlatField"); - - //Unsetting flat field - myDet->setFlatFieldCorrectionFile(""); - dispFlatField->setText(""); - chkFlatField->setToolTip(errFlatFieldTip); - dispFlatField->setToolTip(errFlatFieldTip); - chkFlatField->setPalette(red); - chkFlatField->setText("Flat Field File:*"); -#ifdef VERBOSE - cout << "Invalid Flat Field File - "<< sDir << sFile << ". Unsetting Flat Field." << endl; -#endif - } - else{ -#ifdef VERBOSE - cout << "Setting flat field file to "<< dispFlatField->text().toAscii().constData() << endl; -#endif - } - } - }else{ - chkFlatField->setToolTip(flatFieldTip); - dispFlatField->setToolTip(flatFieldTip); - chkFlatField->setPalette(chkDiscardBad->palette()); - chkFlatField->setText("Flat Field File:"); - //Unsetting flat field - myDet->setFlatFieldCorrectionFile(""); - dispFlatField->setText(""); -#ifdef VERBOSE - cout << "Unsetting flat field correction file" << endl; -#endif - } - - connect(dispFlatField,SIGNAL(editingFinished()),this,SLOT(SetFlatField())); - - qDefs::checkErrorMessage(myDet,"qTabDataOutput::SetFlatField"); -} - -//------------------------------------------------------------------------------------------------------------------------------------------------- - -void qTabDataOutput::UpdateFlatFieldFromServer(){ - disconnect(dispFlatField, SIGNAL(editingFinished()), this, SLOT(SetFlatField())); - - dispFlatField->setText(QString(myDet->getFlatFieldCorrectionDir().c_str())+"/"+QString(myDet->getFlatFieldCorrectionFile().c_str())); -#ifdef VERBOSE - cout << "Getting flat field correction file" << dispFlatField->text().toAscii().constData() << endl; -#endif - //calls setflatfield to ensure the file still exists or disable it - if(!QString(myDet->getFlatFieldCorrectionFile().c_str()).compare("none")){ - dispFlatField->setText(""); - chkFlatField->setChecked(false); -#ifdef VERBOSE - cout << "Flat Field is not set." << endl; -#endif - } - else - chkFlatField->setChecked(true); - - chkFlatField->setToolTip(flatFieldTip); - dispFlatField->setToolTip(flatFieldTip); - chkFlatField->setPalette(chkDiscardBad->palette()); - chkFlatField->setText("Flat Field File:"); - - connect(dispFlatField, SIGNAL(editingFinished()), this, SLOT(SetFlatField())); - - qDefs::checkErrorMessage(myDet,"qTabDataOutput::UpdateFlatFieldFromServer"); -} - -//------------------------------------------------------------------------------------------------------------------------------------------------- - -void qTabDataOutput::BrowseFlatFieldPath(){ - QString fName = dispFlatField->text(); - QString dir = fName.section('/',0,-2,QString::SectionIncludeLeadingSep); - if(dir.isEmpty()) dir = QString(myDet->getFlatFieldCorrectionDir().c_str());/*"/home/";*/ - fName = QFileDialog::getOpenFileName(this, - tr("Load Flat Field Correction File"),dir, - tr("Data Files(*.raw *.dat);; All Files (*.*)"),0,QFileDialog::ShowDirsOnly); - if (!fName.isEmpty()){ - dispFlatField->setText(fName); - SetFlatField(); - } - - qDefs::checkErrorMessage(myDet,"qTabDataOutput::BrowseFlatFieldPath"); - -} - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qTabDataOutput::SetRateCorrection(int deadtime){ - disconnect(btnDefaultRate, SIGNAL(clicked()), this, SLOT(SetDefaultRateCorrection())); - disconnect(spinDeadTime, SIGNAL(editingFinished()), this, SLOT(SetRateCorrection())); - -#ifdef VERBOSE - cout << "Entering Set Rate Correction function" << endl; -#endif - - if(chkRate->isChecked()){ - if(!btnDefaultRate->isEnabled()){ - btnDefaultRate->setEnabled(true); - lblDeadTime->setEnabled(true); - spinDeadTime->setEnabled(true); - } - - if(deadtime!=-1){ - deadtime = (double)spinDeadTime->value(); -#ifdef VERBOSE - cout << "Setting rate corrections with custom dead time: " << deadtime << endl; -#endif - }else{; -#ifdef VERBOSE - cout << "Setting rate corrections with default dead time" << endl; -#endif - } - myDet->setRateCorrection(deadtime); - - }//unsetting rate correction - else{ - btnDefaultRate->setEnabled(false); - lblDeadTime->setEnabled(false); - spinDeadTime->setEnabled(false); - myDet->setRateCorrection(0); -#ifdef VERBOSE - cout << "Unsetting rate correction" << endl; -#endif - } - qDefs::checkErrorMessage(myDet,"qTabDataOutput::SetRateCorrection"); - - //update just the value - double rate = (double)myDet->getRateCorrectionTau(); - spinDeadTime->setValue((double)rate); - if(rate == -1){ - qDefs::Message(qDefs::WARNING,"Dead time is inconsistent for all detectors. Returned Value: -1.","qTabDataOutput::UpdateRateCorrectionFromServer"); - QString errorTip = QString("Rate Corrections.
" - " #ratecorr# tau in seconds

")+ - QString("" - "Dead time is inconsistent for all detectors."); - chkRate->setToolTip(errorTip); - spinDeadTime->setToolTip(errorTip); - chkRate->setPalette(red); - chkRate->setText("Rate:*"); - }else{ - QString normalTip = QString("Rate Corrections.
" - " #ratecorr# tau in seconds

"); - chkRate->setToolTip(normalTip); - spinDeadTime->setToolTip(normalTip); - chkRate->setPalette(chkDiscardBad->palette()); - chkRate->setText("Rate:"); - } - - connect(btnDefaultRate, SIGNAL(clicked()), this, SLOT(SetDefaultRateCorrection())); - connect(spinDeadTime, SIGNAL(editingFinished()), this, SLOT(SetRateCorrection())); - -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qTabDataOutput::SetDefaultRateCorrection(){ - SetRateCorrection(-1); -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qTabDataOutput::UpdateRateCorrectionFromServer(){ - disconnect(chkRate, SIGNAL(toggled(bool)), this, SLOT(SetRateCorrection())); - disconnect(btnDefaultRate, SIGNAL(clicked()), this, SLOT(SetDefaultRateCorrection())); - disconnect(spinDeadTime, SIGNAL(editingFinished()), this, SLOT(SetRateCorrection())); - - double rate; - rate = (double)myDet->getRateCorrectionTau(); - qDefs::checkErrorMessage(myDet,"qTabDataOutput::UpdateRateCorrectionFromServer"); -#ifdef VERBOSE - cout << "Getting rate correction from server: " << rate << endl; -#endif - if(rate==0){ - chkRate->setChecked(false); - btnDefaultRate->setEnabled(false); - lblDeadTime->setEnabled(false); - spinDeadTime->setEnabled(false); - } - - else{ - chkRate->setChecked(true); - btnDefaultRate->setEnabled(true); - lblDeadTime->setEnabled(true); - spinDeadTime->setEnabled(true); - spinDeadTime->setValue((double)rate); - } - - if(rate == -1){ - qDefs::Message(qDefs::WARNING,"Dead time is inconsistent for all detectors. Returned Value: -1.","qTabDataOutput::UpdateRateCorrectionFromServer"); - QString errorTip = QString("Rate Corrections.
" - " #ratecorr# tau in seconds

")+ - QString("" - "Dead time is inconsistent for all detectors."); - chkRate->setToolTip(errorTip); - spinDeadTime->setToolTip(errorTip); - chkRate->setPalette(red); - chkRate->setText("Rate:*"); - }else{ - QString normalTip = QString("Rate Corrections.
" - " #ratecorr# tau in seconds

"); - chkRate->setToolTip(normalTip); - spinDeadTime->setToolTip(normalTip); - chkRate->setPalette(chkDiscardBad->palette()); - chkRate->setText("Rate:"); - } - - connect(chkRate, SIGNAL(toggled(bool)), this, SLOT(SetRateCorrection())); - connect(btnDefaultRate, SIGNAL(clicked()), this, SLOT(SetDefaultRateCorrection())); - connect(spinDeadTime, SIGNAL(editingFinished()), this, SLOT(SetRateCorrection())); -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qTabDataOutput::SetAngularCorrection(){ - disconnect(chkAngular, SIGNAL(toggled(bool)), this, SLOT(SetAngularCorrection())); -#ifdef VERYVERBOSE - cout << "Entering Set Angular Correction function" << endl; -#endif - bool enabled = chkAngular->isChecked(); - //set - if(myDet->setAngularCorrectionMask(enabled) == enabled){ -#ifdef VERBOSE - cout << "Angular Conversion mask:" << enabled << endl; -#endif - } - //error - else{ -#ifdef VERBOSE - cout << "Could not set angular conversion to default" << endl; -#endif - qDefs::Message(qDefs::WARNING,"Angular Conversion could not be set/reset. Please set the default file name using the command line, if you want to set it.","qTabDataOutput::SetAngularCorrection"); - chkAngular->setChecked(!enabled); - } - - emit AngularConversionSignal(chkAngular->isChecked()); - connect(chkAngular, SIGNAL(toggled(bool)), this, SLOT(SetAngularCorrection())); - qDefs::checkErrorMessage(myDet,"qTabDataOutput::SetAngularCorrection"); -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qTabDataOutput::DiscardBadChannels(){ -#ifdef VERBOSE - cout << "Entering Discard bad channels function" << endl; -#endif - if(chkDiscardBad->isChecked()){ -#ifdef VERBOSE - cout << "Setting bad channel correction to default" << endl; -#endif - myDet->setBadChannelCorrection("default"); - }else{ -#ifdef VERBOSE - cout << "Unsetting bad channel correction" << endl; -#endif - myDet->setBadChannelCorrection(""); - } - - qDefs::checkErrorMessage(myDet,"qTabDataOutput::DiscardBadChannels"); -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qTabDataOutput::PopulateDetectors(){ -#ifdef VERBOSE - cout << "Populating detectors" << endl; -#endif - comboDetector->clear(); - comboDetector->addItem("All"); - lblOutputDir->setText("Path:"); - //add specific detector options only if more than 1 detector - if(myDet->getNumberOfDetectors()>1){ - for(int i=0;igetNumberOfDetectors();i++) - comboDetector->addItem(QString(myDet->getHostname(i).c_str())); - } - GetOutputDir(); -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qTabDataOutput::GetOutputDir(){ -#ifdef VERBOSE - cout << "Getting output directory" << endl; -#endif - - disconnect(dispOutputDir, SIGNAL(editingFinished()), this, SLOT(SetOutputDir())); + disconnect(dispOutputDir, SIGNAL(editingFinished()), this, SLOT(SetOutputDir())); //all - if(!comboDetector->currentIndex()) { + if (!comboDetector->currentIndex()) { dispOutputDir->setText(QString(myDet->getFilePath().c_str())); + qDefs::checkErrorMessage(myDet, "qTabDataOutput::GetOutputDir"); + //multi file path blank means sls file paths are different if (dispOutputDir->text().isEmpty()) { -#ifdef VERYVERBOSE - qDefs::Message(qDefs::INFORMATION,"The file path for individual units are different.\n" - "Hence, leaving the common field blank.","qTabDataOutput::GetOutputDir"); -#endif -#ifdef VERBOSE - cout << "The file path for individual units are different.\n" - "Hence, leaving the common field blank." << endl; -#endif - QString errTip = QString("
" - "Output Directory Information only: The file path for individual units are different.
" - "Hence, leaving the common field blank.
"); - lblOutputDir->setText("Path*:"); - lblOutputDir->setPalette(red); - lblOutputDir->setToolTip(errTip); - btnOutputBrowse->setToolTip(errTip); - dispOutputDir->setToolTip(errTip); + qDefs::Message(qDefs::INFORMATION, "The file path for individual readouts are different.\n" + "Hence, leaving the common field blank.", "qTabDataOutput::GetOutputDir"); + FILE_LOG(logWARNING) << "The file path for individual units are different."; + QString errTip = QString("
" + "Output Directory Information only: The file path for individual readouts are different.
" + "Hence, leaving the common field blank.
"); + lblOutputDir->setText("Path*:"); + lblOutputDir->setPalette(red); + lblOutputDir->setToolTip(errTip); + btnOutputBrowse->setToolTip(errTip); + dispOutputDir->setToolTip(errTip); } else { lblOutputDir->setText("Path:"); lblOutputDir->setPalette(*black1); @@ -561,64 +154,57 @@ void qTabDataOutput::GetOutputDir(){ } //specific - else{ - slsDetector *det = myDet->getSlsDetector(comboDetector->currentIndex()-1); - qDefs::checkErrorMessage(myDet,"qTabDataOutput::GetOutputDir"); - dispOutputDir->setText(QString(det->getFilePath().c_str())); + else { + dispOutputDir->setText(QString(myDet->getFilePath(comboDetector->currentIndex() - 1).c_str())); + qDefs::checkErrorMessage(myDet, comboDetector->currentIndex() - 1, "qTabDataOutput::GetOutputDir"); } - connect(dispOutputDir, SIGNAL(editingFinished()), this, SLOT(SetOutputDir())); + connect(dispOutputDir, SIGNAL(editingFinished()), this, SLOT(SetOutputDir())); } -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -int qTabDataOutput::VerifyOutputDirectory(){ -#ifdef VERBOSE - cout << "Verifying output directory" << endl; -#endif +int qTabDataOutput::VerifyOutputDirectory() { + FILE_LOG(logDEBUG) << "Verifying output directory"; GetOutputDir(); bool error = false; - string detName = ""; - string mess = ""; + std::string detName = ""; + std::string mess = ""; - //common - myDet->setFilePath(myDet->getFilePath()); - if(!qDefs::checkErrorMessage(myDet,"qTabDataOutput::VerifyOutputDirectory").empty()) - error = true; + //common (check only if no +, different values) + std::string fpath = myDet->getFilePath(); + if (fpath.find('+') == std::string::npos) { + myDet->setFilePath(myDet->getFilePath()); + if (!qDefs::checkErrorMessage(myDet, "qTabDataOutput::VerifyOutputDirectory").empty()) + error = true; + } //for each detector - for(int i=0;igetNumberOfDetectors();i++){ - slsDetector *det = myDet->getSlsDetector(i); - qDefs::checkErrorMessage(myDet,"qTabDataOutput::VerifyOutputDirectory"); - detName = string("\n - ") + string(comboDetector->itemText(i+1).toAscii().constData()); - det->setFilePath(det->getFilePath()); - if(!qDefs::checkErrorMessage(det,"qTabDataOutput::VerifyOutputDirectory").empty()) { - mess. append(detName); - error = true; - } + for (int i = 0; i < myDet->getNumberOfDetectors(); ++i) { + detName = std::string("\n - ") + std::string(comboDetector->itemText(i+1).toAscii().constData()); + myDet->setFilePath(myDet->getFilePath(i), i); + if(!qDefs::checkErrorMessage(myDet, i, "qTabDataOutput::VerifyOutputDirectory").empty()) { + mess. append(detName); + error = true; + } } //invalid - if(error){ - qDefs::Message(qDefs::WARNING,string("Invalid Output Directory ")+ mess ,"qTabDataOutput::VerifyOutputDirectory"); -#ifdef VERBOSE - cout << "The output path doesnt exist anymore" << endl; -#endif + if (error) { + qDefs::Message(qDefs::WARNING, std::string("Invalid Output Directory ") + mess, "qTabDataOutput::VerifyOutputDirectory"); + FILE_LOG(logWARNING) << "The output path doesnt exist anymore"; //replace all \n with
size_t pos = 0; - while((pos = mess.find("\n", pos)) != string::npos){ + while ((pos = mess.find("\n", pos)) != std::string::npos) { mess.replace(pos, 1, "
"); pos += 1; } QString errTip = outDirTip + QString("
" - "Invalid Output Directory") + - QString(mess.c_str()) + - QString( "."); + "Invalid Output Directory") + + QString(mess.c_str()) + + QString("."); lblOutputDir->setText("Path*:"); lblOutputDir->setPalette(red); lblOutputDir->setToolTip(errTip); @@ -629,10 +215,8 @@ int qTabDataOutput::VerifyOutputDirectory(){ } //valid - else{ -#ifdef VERBOSE - cout << "The output pathid valid" << endl; -#endif + else { + FILE_LOG(logDEBUG) << "The output path is valid"; lblOutputDir->setText("Path:"); lblOutputDir->setPalette(*black1); lblOutputDir->setToolTip(outDirTip); @@ -644,351 +228,390 @@ int qTabDataOutput::VerifyOutputDirectory(){ } -//------------------------------------------------------------------------------------------------------------------------------------------------- +void qTabDataOutput::SetOutputDir() { + FILE_LOG(logDEBUG) << "Setting output directory"; -void qTabDataOutput::SetOutputDir(){ - -#ifdef VERBOSE - cout << "Setting output directory" << endl; -#endif - - disconnect(dispOutputDir, SIGNAL(editingFinished()), this, SLOT(SetOutputDir())); - + disconnect(dispOutputDir, SIGNAL(editingFinished()), this, SLOT(SetOutputDir())); bool error = false; QString path = dispOutputDir->text(); //empty - if(path.isEmpty()) { - qDefs::Message(qDefs::WARNING,"Invalid Output Path. Must not be empty.","qTabDataOutput::SetOutputDir"); -#ifdef VERBOSE - cout << "Invalid Output Path. Must not be empty." << endl; -#endif + if (path.isEmpty()) { + qDefs::Message(qDefs::WARNING, "Invalid Output Path. Must not be empty.", "qTabDataOutput::SetOutputDir"); + FILE_LOG(logWARNING) << "Invalid Output Path. Must not be empty."; error = true; } //gets rid of the end '/'s - else if (path.endsWith('/')){ - while(path.endsWith('/')) + else if (path.endsWith('/')) { + while (path.endsWith('/')) path.chop(1); dispOutputDir->setText(path); } //specific - if(comboDetector->currentIndex()){ - slsDetector *det = myDet->getSlsDetector(comboDetector->currentIndex()-1); - qDefs::checkErrorMessage(myDet,"qTabDataOutput::SetOutputDir"); - det->setFilePath(string(dispOutputDir->text().toAscii().constData())); - if(!qDefs::checkErrorMessage(det,"qTabDataOutput::SetOutputDir").empty()) + if (comboDetector->currentIndex()) { + myDet->setFilePath(std::string(dispOutputDir->text().toAscii().constData()), comboDetector->currentIndex() - 1); + if (!qDefs::checkErrorMessage(myDet, comboDetector->currentIndex() - 1, "qTabDataOutput::SetOutputDir").empty()) error = true; } //multi - else{ - myDet->setFilePath(string(path.toAscii().constData())); - if(!qDefs::checkErrorMessage(myDet,"qTabDataOutput::SetOutputDir").empty()) + else { + myDet->setFilePath(std::string(path.toAscii().constData())); + if (!qDefs::checkErrorMessage(myDet, "qTabDataOutput::SetOutputDir").empty()) error = true; } - - if(error){ -#ifdef VERBOSE - cout << "The output path could not be set" << endl; -#endif + if (error) { + FILE_LOG(logWARNING) << "The output path could not be set"; QString errTip = outDirTip + QString("
" - "Invalid File Path"); + "Invalid File Path"); lblOutputDir->setText("Path*:"); lblOutputDir->setPalette(red); lblOutputDir->setToolTip(errTip); btnOutputBrowse->setToolTip(errTip); dispOutputDir->setToolTip(errTip); - } - else{ -#ifdef VERBOSE - cout << "The output path has been modified" << endl; -#endif + } else { + FILE_LOG(logINFO) << "Output dir set to " << path.toAscii().constData(); lblOutputDir->setText("Path:"); lblOutputDir->setPalette(*black1); lblOutputDir->setToolTip(outDirTip); btnOutputBrowse->setToolTip(outDirTip); dispOutputDir->setToolTip(outDirTip); - } - - connect(dispOutputDir, SIGNAL(editingFinished()), this, SLOT(SetOutputDir())); - + connect(dispOutputDir, SIGNAL(editingFinished()), this, SLOT(SetOutputDir())); } -//------------------------------------------------------------------------------------------------------------------------------------------------- + +void qTabDataOutput::SetRateCorrection(int deadtime) { + disconnect(btnDefaultRate, SIGNAL(clicked()), this, SLOT(SetDefaultRateCorrection())); + disconnect(spinDeadTime, SIGNAL(editingFinished()), this, SLOT(SetRateCorrection())); + + FILE_LOG(logDEBUG) << "Entering Set Rate Correction function"; + + if (chkRate->isChecked()) { + if (!btnDefaultRate->isEnabled()) { + btnDefaultRate->setEnabled(true); + lblDeadTime->setEnabled(true); + spinDeadTime->setEnabled(true); + } + + if (deadtime != -1) { + deadtime = (double)spinDeadTime->value(); + FILE_LOG(logINFO) << "Setting rate corrections with custom dead time: " << deadtime << '\n'; + } else { + FILE_LOG(logINFO) << "Setting rate corrections with default dead time" << '\n'; + } + myDet->setRateCorrection(deadtime); + + } //unsetting rate correction + else { + btnDefaultRate->setEnabled(false); + lblDeadTime->setEnabled(false); + spinDeadTime->setEnabled(false); + myDet->setRateCorrection(0); + FILE_LOG(logINFO) << "Unsetting rate correction"; + } + qDefs::checkErrorMessage(myDet, "qTabDataOutput::SetRateCorrection"); + + //update just the value + double rate = (double)myDet->getRateCorrection(); + spinDeadTime->setValue((double)rate); + if (rate == -1) { + qDefs::Message(qDefs::WARNING, "Dead time is inconsistent for all detectors. Returned Value: -1.", "qTabDataOutput::UpdateRateCorrectionFromServer"); + QString errorTip = QString("Rate Corrections.
" + " #ratecorr# tau in seconds

") + + QString("" + "Dead time is inconsistent for all detectors."); + chkRate->setToolTip(errorTip); + spinDeadTime->setToolTip(errorTip); + chkRate->setPalette(red); + chkRate->setText("Rate:*"); + } else { + QString normalTip = QString("Rate Corrections.
" + " #ratecorr# tau in seconds

"); + chkRate->setToolTip(normalTip); + spinDeadTime->setToolTip(normalTip); + chkRate->setPalette(chkDiscardBad->palette()); + chkRate->setText("Rate:"); + } + + connect(btnDefaultRate, SIGNAL(clicked()), this, SLOT(SetDefaultRateCorrection())); + connect(spinDeadTime, SIGNAL(editingFinished()), this, SLOT(SetRateCorrection())); +} -void qTabDataOutput::EnableTenGigabitEthernet(bool enable,int get){ -#ifdef VERBOSE - cout << endl << "Enabling/Disabling 10GbE" << endl; -#endif - disconnect(chkTenGiga, SIGNAL(toggled(bool)), this, SLOT(EnableTenGigabitEthernet(bool))); +void qTabDataOutput::SetDefaultRateCorrection() { + SetRateCorrection(-1); +} + + +void qTabDataOutput::UpdateRateCorrectionFromServer() { + disconnect(chkRate, SIGNAL(toggled(bool)), this, SLOT(SetRateCorrection())); + disconnect(btnDefaultRate, SIGNAL(clicked()), this, SLOT(SetDefaultRateCorrection())); + disconnect(spinDeadTime, SIGNAL(editingFinished()), this, SLOT(SetRateCorrection())); + + double rate; + rate = (double)myDet->getRateCorrection(); + qDefs::checkErrorMessage(myDet, "qTabDataOutput::UpdateRateCorrectionFromServer"); + FILE_LOG(logDEBUG) << "Getting rate correction from server: " << rate << '\n'; + if (rate == 0) { + chkRate->setChecked(false); + btnDefaultRate->setEnabled(false); + lblDeadTime->setEnabled(false); + spinDeadTime->setEnabled(false); + } + + else { + chkRate->setChecked(true); + btnDefaultRate->setEnabled(true); + lblDeadTime->setEnabled(true); + spinDeadTime->setEnabled(true); + spinDeadTime->setValue((double)rate); + } + + if (rate == -1) { + qDefs::Message(qDefs::WARNING, "Dead time is inconsistent for all detectors. Returned Value: -1.", "qTabDataOutput::UpdateRateCorrectionFromServer"); + FILE_LOG(logWARNING) << "Dead time is inconsistent for all detectors."; + QString errorTip = QString("Rate Corrections.
" + " #ratecorr# tau in seconds

") + + QString("" + "Dead time is inconsistent for all detectors."); + chkRate->setToolTip(errorTip); + spinDeadTime->setToolTip(errorTip); + chkRate->setPalette(red); + chkRate->setText("Rate:*"); + } else { + QString normalTip = QString("Rate Corrections.
" + " #ratecorr# tau in seconds

"); + chkRate->setToolTip(normalTip); + spinDeadTime->setToolTip(normalTip); + chkRate->setPalette(chkDiscardBad->palette()); + chkRate->setText("Rate:"); + } + + connect(chkRate, SIGNAL(toggled(bool)), this, SLOT(SetRateCorrection())); + connect(btnDefaultRate, SIGNAL(clicked()), this, SLOT(SetDefaultRateCorrection())); + connect(spinDeadTime, SIGNAL(editingFinished()), this, SLOT(SetRateCorrection())); +} + + +void qTabDataOutput::PopulateDetectors() { + disconnect(comboDetector, SIGNAL(currentIndexChanged(int)), this, SLOT(GetOutputDir())); + + FILE_LOG(logDEBUG) << "Populating detectors"; + comboDetector->clear(); + comboDetector->addItem("All"); + lblOutputDir->setText("Path:"); + //add specific detector options only if more than 1 detector + if (myDet->getNumberOfDetectors() > 1) { + for (int i = 0; i < myDet->getNumberOfDetectors(); i++) + comboDetector->addItem(QString(myDet->getHostname(i).c_str())); + } + GetOutputDir(); + connect(comboDetector, SIGNAL(currentIndexChanged(int)), this, SLOT(GetOutputDir())); +} + + + + +void qTabDataOutput::EnableTenGigabitEthernet(bool enable, int get) { + if (get || enable == -1) { + FILE_LOG(logDEBUG) << "Getting 10Gbe enable"; + } else { + FILE_LOG(logINFO) << (enable == 0 ? "Disabling" : "Enabling") << "10GbE"; + } + disconnect(chkTenGiga, SIGNAL(toggled(bool)), this, SLOT(EnableTenGigabitEthernet(bool))); int ret; - if(get) + if (get) ret = myDet->enableTenGigabitEthernet(-1); else ret = myDet->enableTenGigabitEthernet(enable); - if(ret > 0) chkTenGiga->setChecked(true); - else chkTenGiga->setChecked(false); - connect(chkTenGiga, SIGNAL(toggled(bool)), this, SLOT(EnableTenGigabitEthernet(bool))); + if (ret > 0) + chkTenGiga->setChecked(true); + else + chkTenGiga->setChecked(false); + connect(chkTenGiga, SIGNAL(toggled(bool)), this, SLOT(EnableTenGigabitEthernet(bool))); - qDefs::checkErrorMessage(myDet,"qTabDataOutput::EnableTenGigabitEthernet"); + qDefs::checkErrorMessage(myDet, "qTabDataOutput::EnableTenGigabitEthernet"); } -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qTabDataOutput::SetSpeed(){ -#ifdef VERBOSE - cout << endl << "Setting Speed" << endl; -#endif - if(widgetEiger->isVisible()){ - myDet->setSpeed(slsDetectorDefs::CLOCK_DIVIDER,comboEigerClkDivider->currentIndex()); - qDefs::checkErrorMessage(myDet,"qTabDataOutput::SetSpeed"); - UpdateSpeedFromServer(); - } - -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qTabDataOutput::SetFlags(){ -#ifdef VERBOSE - cout << endl << "Setting Readout Flags" << endl; -#endif - slsDetectorDefs::readOutFlags val = slsDetectorDefs::GET_READOUT_FLAGS; - if(widgetEiger->isVisible()){ - - //set to continous or storeinram - switch(comboEigerFlags1->currentIndex()){ - case Storeinram: val = slsDetectorDefs::STORE_IN_RAM; break; - default: val = slsDetectorDefs::CONTINOUS_RO; break; - } - myDet->setReadOutFlags(val); - qDefs::checkErrorMessage(myDet,"qTabDataOutput::setFlags"); - - //set to parallel, nonparallel or safe - switch(comboEigerFlags2->currentIndex()){ - case Parallel: val = slsDetectorDefs::PARALLEL; break; - case Safe: val = slsDetectorDefs::SAFE; break; - default: val = slsDetectorDefs::NONPARALLEL; break; - } - myDet->setReadOutFlags(val); - qDefs::checkErrorMessage(myDet,"qTabDataOutput::setFlags"); - - //update flags - UpdateFlagsFromServer(); - } - -} - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qTabDataOutput::UpdateSpeedFromServer(){ +void qTabDataOutput::UpdateSpeedFromServer() { int ret; - if(widgetEiger->isVisible()){ - disconnect(comboEigerClkDivider, SIGNAL(currentIndexChanged(int)), this, SLOT(SetSpeed())); + if (widgetEiger->isVisible()) { + disconnect(comboEigerClkDivider, SIGNAL(currentIndexChanged(int)), this, SLOT(SetSpeed())); //get speed ret = myDet->setSpeed(slsDetectorDefs::CLOCK_DIVIDER, -1); - qDefs::checkErrorMessage(myDet,"qTabDataOutput::updateSpeedFromServer"); + qDefs::checkErrorMessage(myDet, "qTabDataOutput::updateSpeedFromServer"); //valid speed - if(ret >= 0 && ret < NumberofSpeeds) + if (ret >= 0 && ret < NUMBEROFSPEEDS) comboEigerClkDivider->setCurrentIndex(ret); //invalid speed - else{ - qDefs::Message(qDefs::WARNING,"Inconsistent value from clock divider.\n" - "Setting it for all detectors involved to half speed.","qTabDataOutput::updateSpeedFromServer"); + else { + qDefs::Message(qDefs::WARNING, "Inconsistent value from clock divider.\n" + "Setting it for all detectors involved to half speed.", + "qTabDataOutput::updateSpeedFromServer"); + FILE_LOG(logWARNING) << "Inconsistent value from clock divider."; //set to default - comboEigerClkDivider->setCurrentIndex(HalfSpeed); - myDet->setSpeed(slsDetectorDefs::CLOCK_DIVIDER,HalfSpeed); - qDefs::checkErrorMessage(myDet,"qTabDataOutput::updateSpeedFromServer"); - + comboEigerClkDivider->setCurrentIndex(HALFSPEED); + myDet->setSpeed(slsDetectorDefs::CLOCK_DIVIDER, HALFSPEED); + qDefs::checkErrorMessage(myDet, "qTabDataOutput::updateSpeedFromServer"); } - connect(comboEigerClkDivider, SIGNAL(currentIndexChanged(int)), this, SLOT(SetSpeed())); + connect(comboEigerClkDivider, SIGNAL(currentIndexChanged(int)), this, SLOT(SetSpeed())); } } -//------------------------------------------------------------------------------------------------------------------------------------------------- +void qTabDataOutput::SetSpeed() { + FILE_LOG(logINFO) << "Setting Speed"; + myDet->setSpeed(slsDetectorDefs::CLOCK_DIVIDER, comboEigerClkDivider->currentIndex()); + qDefs::checkErrorMessage(myDet, "qTabDataOutput::SetSpeed"); + UpdateSpeedFromServer(); +} -void qTabDataOutput::UpdateFlagsFromServer(){ + +void qTabDataOutput::UpdateFlagsFromServer() { int ret; - if(widgetEiger->isVisible()){ - disconnect(comboEigerFlags1, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFlags())); - disconnect(comboEigerFlags2, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFlags())); + if (widgetEiger->isVisible()) { + disconnect(comboEigerFlags1, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFlags())); + disconnect(comboEigerFlags2, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFlags())); //get speed ret = myDet->setReadOutFlags(slsDetectorDefs::GET_READOUT_FLAGS); - qDefs::checkErrorMessage(myDet,"qTabDataOutput::updateFlagsFromServer"); + qDefs::checkErrorMessage(myDet, "qTabDataOutput::updateFlagsFromServer"); //invalid flags - if(ret==-1){ - qDefs::Message(qDefs::WARNING,"Inconsistent value for readout flags.\n" - "Setting it for all detectors involved to continous nonparallel mode.", - "qTabDataOutput::updateFlagsFromServer"); + if (ret == -1) { + qDefs::Message(qDefs::WARNING, "Inconsistent value for readout flags.\n" + "Setting it for all detectors involved to continous nonparallel mode.", + "qTabDataOutput::updateFlagsFromServer"); + FILE_LOG(logWARNING) << "Inconsistent value for readout flags."; //set to default - comboEigerFlags1->setCurrentIndex(Continous); - myDet->setReadOutFlags(slsDetectorDefs::CONTINOUS_RO); - qDefs::checkErrorMessage(myDet,"qTabDataOutput::updateFlagsFromServer"); - comboEigerFlags2->setCurrentIndex(NonParallel); - myDet->setReadOutFlags(slsDetectorDefs::NONPARALLEL); - qDefs::checkErrorMessage(myDet,"qTabDataOutput::updateFlagsFromServer"); + comboEigerFlags1->setCurrentIndex(CONTINUOUS); + myDet->setReadOutFlags(slsDetectorDefs::CONTINOUS_RO); + qDefs::checkErrorMessage(myDet, "qTabDataOutput::updateFlagsFromServer"); + comboEigerFlags2->setCurrentIndex(NONPARALLEL); + myDet->setReadOutFlags(slsDetectorDefs::NONPARALLEL); + qDefs::checkErrorMessage(myDet, "qTabDataOutput::updateFlagsFromServer"); } //valid flags - else{ - if(ret & slsDetectorDefs::STORE_IN_RAM) - comboEigerFlags1->setCurrentIndex(Storeinram); - else if(ret & slsDetectorDefs::CONTINOUS_RO) - comboEigerFlags1->setCurrentIndex(Continous); - if(ret & slsDetectorDefs::PARALLEL) - comboEigerFlags2->setCurrentIndex(Parallel); - else if(ret & slsDetectorDefs::NONPARALLEL) - comboEigerFlags2->setCurrentIndex(NonParallel); - else if(ret & slsDetectorDefs::SAFE) - comboEigerFlags2->setCurrentIndex(Safe); + else { + if (ret & slsDetectorDefs::STORE_IN_RAM) + comboEigerFlags1->setCurrentIndex(STOREINRAM); + else if (ret & slsDetectorDefs::CONTINOUS_RO) + comboEigerFlags1->setCurrentIndex(CONTINUOUS); + if (ret & slsDetectorDefs::PARALLEL) + comboEigerFlags2->setCurrentIndex(PARALLEL); + else if (ret & slsDetectorDefs::NONPARALLEL) + comboEigerFlags2->setCurrentIndex(NONPARALLEL); + else if (ret & slsDetectorDefs::SAFE) + comboEigerFlags2->setCurrentIndex(SAFE); } - connect(comboEigerFlags1, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFlags())); - connect(comboEigerFlags2, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFlags())); + connect(comboEigerFlags1, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFlags())); + connect(comboEigerFlags2, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFlags())); } } -//------------------------------------------------------------------------------------------------------------------------------------------------- +void qTabDataOutput::SetFlags() { + FILE_LOG(logINFO) << "Setting Readout Flags"; + slsDetectorDefs::readOutFlags val = slsDetectorDefs::GET_READOUT_FLAGS; - -void qTabDataOutput::SetupFileFormat(){ - - - //To be able to index items on a combo box - QStandardItemModel* model = qobject_cast(comboFileFormat->model()); - QModelIndex index[slsDetectorDefs::NUM_FILE_FORMATS]; - QStandardItem* item[slsDetectorDefs::NUM_FILE_FORMATS]; - if (model) { - for(int i=0;iindex(i, comboFileFormat->modelColumn(), comboFileFormat->rootModelIndex()); - item[i] = model->itemFromIndex(index[i]); - } - //Enabling/Disabling depending on the detector type - switch(detType){ - case slsDetectorDefs::MYTHEN: - item[(int)slsDetectorDefs::BINARY]->setEnabled(false); - item[(int)slsDetectorDefs::ASCII]->setEnabled(true); - item[(int)slsDetectorDefs::HDF5]->setEnabled(false); - break; - case slsDetectorDefs::EIGER: - case slsDetectorDefs::MOENCH: - case slsDetectorDefs::PROPIX: - case slsDetectorDefs::GOTTHARD: - case slsDetectorDefs::JUNGFRAU: - case slsDetectorDefs::CHIPTESTBOARD: - item[(int)slsDetectorDefs::BINARY]->setEnabled(true); - item[(int)slsDetectorDefs::ASCII]->setEnabled(false); - item[(int)slsDetectorDefs::HDF5]->setEnabled(true); - break; - default: - cout << "Unknown detector type " << endl; - qDefs::Message(qDefs::CRITICAL,"Unknown detector type.","qTabDataOutput::SetupFileFormat"); - exit(-1); - break; - } + //set to continous or storeinram + switch (comboEigerFlags1->currentIndex()) { + case STOREINRAM: + val = slsDetectorDefs::STORE_IN_RAM; + break; + default: + val = slsDetectorDefs::CONTINOUS_RO; + break; } + myDet->setReadOutFlags(val); + qDefs::checkErrorMessage(myDet, "qTabDataOutput::setFlags"); + + //set to parallel, nonparallel or safe + switch (comboEigerFlags2->currentIndex()) { + case PARALLEL: + val = slsDetectorDefs::PARALLEL; + break; + case SAFE: + val = slsDetectorDefs::SAFE; + break; + default: + val = slsDetectorDefs::NONPARALLEL; + break; + } + myDet->setReadOutFlags(val); + qDefs::checkErrorMessage(myDet, "qTabDataOutput::setFlags"); + + //update flags + UpdateFlagsFromServer(); - comboFileFormat->setCurrentIndex((int)myDet->getFileFormat()); } -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qTabDataOutput::UpdateFileFormatFromServer(){ -#ifdef VERBOSE - cout << endl << "Getting File Format" << endl; -#endif - disconnect(comboFileFormat, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFileFormat(int))); +void qTabDataOutput::UpdateFileFormatFromServer() { + FILE_LOG(logDEBUG) << "Getting File Format"; + disconnect(comboFileFormat, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFileFormat(int))); comboFileFormat->setCurrentIndex((int)myDet->getFileFormat()); - connect(comboFileFormat, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFileFormat(int))); + connect(comboFileFormat, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFileFormat(int))); } -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qTabDataOutput::SetFileFormat(int format){ -#ifdef VERBOSE - cout << endl << "Setting File Format" << endl; -#endif - disconnect(comboFileFormat, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFileFormat(int))); +void qTabDataOutput::SetFileFormat(int format) { + FILE_LOG(logINFO) << "Setting File Format"; + disconnect(comboFileFormat, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFileFormat(int))); int ret = (int)myDet->setFileFormat((slsDetectorDefs::fileFormat)comboFileFormat->currentIndex()); if (ret != comboFileFormat->currentIndex()) { - qDefs::Message(qDefs::WARNING,"Could not set file format.","qTabDataOutput::SetFileFormat"); + qDefs::Message(qDefs::WARNING, "Could not set file format.", "qTabDataOutput::SetFileFormat"); comboFileFormat->setCurrentIndex((int)ret); } - connect(comboFileFormat, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFileFormat(int))); + connect(comboFileFormat, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFileFormat(int))); } -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qTabDataOutput::UpdateFileOverwriteFromServer(){ -#ifdef VERBOSE - cout << endl << "Getting File Over Write Enable" << endl; -#endif - disconnect(chkOverwriteEnable, SIGNAL(toggled(bool)), this, SLOT(SetOverwriteEnable(bool))); +void qTabDataOutput::UpdateFileOverwriteFromServer() { + FILE_LOG(logDEBUG) << "Getting File Over Write Enable"; + disconnect(chkOverwriteEnable, SIGNAL(toggled(bool)), this, SLOT(SetOverwriteEnable(bool))); chkOverwriteEnable->setChecked(myDet->overwriteFile()); - connect(chkOverwriteEnable, SIGNAL(toggled(bool)), this, SLOT(SetOverwriteEnable(bool))); + connect(chkOverwriteEnable, SIGNAL(toggled(bool)), this, SLOT(SetOverwriteEnable(bool))); } -//------------------------------------------------------------------------------------------------------------------------------------------------- +void qTabDataOutput::SetOverwriteEnable(bool enable) { + FILE_LOG(logINFO) << "Setting File Over Write Enable"; + disconnect(chkOverwriteEnable, SIGNAL(toggled(bool)), this, SLOT(SetOverwriteEnable(bool))); - -void qTabDataOutput::SetOverwriteEnable(bool enable){ -#ifdef VERBOSE - cout << endl << "Setting File Over Write Enable" << endl; -#endif - disconnect(chkOverwriteEnable, SIGNAL(toggled(bool)), this, SLOT(SetOverwriteEnable(bool))); - - int valid = (enable?1:0); + int valid = (enable ? 1 : 0); if (myDet->overwriteFile(enable) != valid) - qDefs::Message(qDefs::WARNING,"Could not over write enable.","qTabDataOutput::SetOverwriteEnable"); + qDefs::Message(qDefs::WARNING, "Could not over write enable.", "qTabDataOutput::SetOverwriteEnable"); - connect(chkOverwriteEnable, SIGNAL(toggled(bool)), this, SLOT(SetOverwriteEnable(bool))); + connect(chkOverwriteEnable, SIGNAL(toggled(bool)), this, SLOT(SetOverwriteEnable(bool))); UpdateFileOverwriteFromServer(); } -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qTabDataOutput::Refresh(){ -#ifdef VERBOSE - cout << endl << "**Updating DataOutput Tab" << endl; -#endif +void qTabDataOutput::Refresh() { + FILE_LOG(logDEBUG) << "**Updating DataOutput Tab"; if (!myDet->enableWriteToFile()) boxFileWriteEnabled->setEnabled(false); @@ -996,107 +619,46 @@ void qTabDataOutput::Refresh(){ boxFileWriteEnabled->setEnabled(true); // output dir -#ifdef VERBOSE - cout << "Getting output directory" << endl; -#endif - - disconnect(comboDetector, SIGNAL(currentIndexChanged(int)), this, SLOT(GetOutputDir())); PopulateDetectors(); - connect(comboDetector, SIGNAL(currentIndexChanged(int)), this, SLOT(GetOutputDir())); - - //file format - UpdateFileFormatFromServer(); //overwrite UpdateFileOverwriteFromServer(); + //file format + UpdateFileFormatFromServer(); + //file name dispFileName->setText(QString(myDet->getFileName().c_str())); - //flat field correction from server -#ifdef VERBOSE - cout << "Getting flat field" << endl; -#endif - UpdateFlatFieldFromServer(); - - - //rate correction - not for charge integrating detectors - if((detType == slsDetectorDefs::MYTHEN)||(detType == slsDetectorDefs::EIGER)){ -#ifdef VERBOSE - cout << "Getting rate correction" << endl; -#endif + // rate correction + if (chkRate->isEnabled()) { UpdateRateCorrectionFromServer(); } - - //update angular conversion from server - if((detType == slsDetectorDefs::MYTHEN)||(detType == slsDetectorDefs::GOTTHARD)){ -#ifdef VERBOSE - cout << "Getting angular conversion" << endl; -#endif - int ang; - if(myDet->getAngularConversion(ang)) - chkAngular->setChecked(true); - emit AngularConversionSignal(chkAngular->isChecked()); - } - - - //discard bad channels from server -#ifdef VERBOSE - cout << "Getting bad channel correction" << endl;//cout << "ff " << myDet->getBadChannelCorrection() << endl; -#endif - - - disconnect(chkDiscardBad, SIGNAL(toggled(bool))); - if(myDet->getBadChannelCorrection()) - chkDiscardBad->setChecked(true); - else - chkDiscardBad->setChecked(false); - connect(chkDiscardBad, SIGNAL(toggled(bool)), this, SLOT(DiscardBadChannels())); - - if(myDet->setReceiverOnline()==slsDetectorDefs::ONLINE_FLAG){ + if (myDet->setReceiverOnline() == slsDetectorDefs::ONLINE_FLAG) { btnOutputBrowse->setEnabled(false); btnOutputBrowse->setToolTip("This button is disabled as receiver PC is different from " - "client PC and hence different directory structures.

" + dispOutputDir->toolTip()); - }else{ + "client PC and hence different directory structures.

" + + dispOutputDir->toolTip()); + } else { btnOutputBrowse->setEnabled(true); btnOutputBrowse->setToolTip(dispOutputDir->toolTip()); } - //getting 10GbE - if(chkTenGiga->isEnabled()){ -#ifdef VERBOSE - cout << "Getting 10GbE enable" << endl; -#endif - EnableTenGigabitEthernet(-1,1); + // 10GbE + if (chkTenGiga->isEnabled()) { + EnableTenGigabitEthernet(-1, 1); } //Eiger specific - if(widgetEiger->isVisible()){ + if (widgetEiger->isVisible()) { //speed -#ifdef VERBOSE - cout << "Getting Speed" << endl; -#endif UpdateSpeedFromServer(); //flags -#ifdef VERBOSE - cout << "Getting Readout Flags" << endl; -#endif UpdateFlagsFromServer(); - - - } + FILE_LOG(logDEBUG) << "**Updated DataOutput Tab"; -#ifdef VERBOSE - cout << "**Updated DataOutput Tab" << endl << endl; -#endif - - qDefs::checkErrorMessage(myDet,"qTabDataOutput::Refresh"); + qDefs::checkErrorMessage(myDet, "qTabDataOutput::Refresh"); } - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - diff --git a/slsDetectorGui/src/qTabDebugging.cpp b/slsDetectorGui/src/qTabDebugging.cpp old mode 100644 new mode 100755 index 4b0830fea..f0cc36e14 --- a/slsDetectorGui/src/qTabDebugging.cpp +++ b/slsDetectorGui/src/qTabDebugging.cpp @@ -1,619 +1,272 @@ -/* - * qTabDebugging.cpp - * - * Created on: May 10, 2012 - * Author: l_maliakal_d - */ #include "qTabDebugging.h" -// Project Class Headers -#include "slsDetector.h" + #include "multiSlsDetector.h" -// Qt Include Headers + #include #include -// C++ Include Headers -#include -using namespace std; - +#include //------------------------------------------------------------------------------------------------------------------------------------------------- +qTabDebugging::qTabDebugging(QWidget *parent, multiSlsDetector *detector) : QWidget(parent), + myDet(detector), + detType(slsDetectorDefs::GENERIC), + treeDet(0), + lblDetectorId(0), + lblDetectorFirmware(0), + lblDetectorSoftware(0) { + setupUi(this); + SetupWidgetWindow(); + Initialization(); + FILE_LOG(logDEBUG) << "Debugging ready"; +} -qTabDebugging::qTabDebugging(QWidget *parent,multiSlsDetector*& detector): - QWidget(parent), - myDet(detector), - det(0), - treeDet(0), - dispFrame(0), - lblDetectorId(0), - lblDetectorSerial(0), - lblDetectorFirmware(0), - lblDetectorSoftware(0), - lblModuleId(0), - lblModuleFirmware(0), - lblModuleSerial(0){ - setupUi(this); - SetupWidgetWindow(); - Initialization(); +qTabDebugging::~qTabDebugging() { + delete myDet; } -//------------------------------------------------------------------------------------------------------------------------------------------------- +void qTabDebugging::SetupWidgetWindow() { + blue = new QPalette(); + blue->setColor(QPalette::Active, QPalette::WindowText, Qt::darkBlue); -qTabDebugging::~qTabDebugging(){ - delete myDet; - if(det) delete det; + // Detector Type + detType = myDet->getDetectorTypeAsEnum(); + + // rename label and disable tests + if (detType == slsDetectorDefs::EIGER) { + lblDetector->setText("Half Module:"); + chkDetectorFirmware->setEnabled(false); + chkDetectorBus->setEnabled(false); + btnTest->setEnabled(false); + } + + //add detectors + for (int i = 0; i < myDet->getNumberOfDetectors(); ++i) { + comboDetector->addItem(QString(myDet->getHostname(i).c_str())); + } + + UpdateStatus(); + + qDefs::checkErrorMessage(myDet, "qTabDebugging::SetupWidgetWindow"); } -//------------------------------------------------------------------------------------------------------------------------------------------------- +void qTabDebugging::Initialization() { - -void qTabDebugging::SetupWidgetWindow(){ - - blue = new QPalette(); - blue->setColor(QPalette::Active,QPalette::WindowText,Qt::darkBlue); - - - // Detector Type - detType=myDet->getDetectorsType(); - ///change module label - switch(detType){ - case slsDetectorDefs::EIGER: - lblDetector->setText("Half Module:"); - chkDetectorFirmware->setText("Half Module Firmware:"); - chkDetectorSoftware->setText("Half Module Software:"); - chkDetectorMemory->setText("Half Module Memory:"); - chkDetectorBus->setText("Half Module Bus:"); - lblModule->hide(); - comboModule->hide(); - chkModuleFirmware->hide(); - chkChip->setEnabled(false); - chkModuleFirmware->setEnabled(false); - break; - case slsDetectorDefs::JUNGFRAU: - case slsDetectorDefs::CHIPTESTBOARD: - case slsDetectorDefs::PROPIX: - case slsDetectorDefs::GOTTHARD: - lblDetector->setText("Module:"); - chkDetectorFirmware->setText("Module Firmware:"); - chkDetectorSoftware->setText("Module Software:"); - chkDetectorMemory->setText("Module Memory:"); - chkDetectorBus->setText("Module Bus:"); - lblModule->hide(); - comboModule->hide(); - chkModuleFirmware->hide(); - chkChip->setEnabled(false); - chkModuleFirmware->setEnabled(false); - break; - case slsDetectorDefs::MOENCH: - lblDetector->setText("Module:"); - chkDetectorFirmware->setText("Module Firmware:"); - chkDetectorSoftware->setText("Module Software:"); - chkDetectorMemory->setText("Module Memory:"); - chkDetectorBus->setText("Module Bus:"); - lblModule->hide(); - comboModule->hide(); - chkModuleFirmware->hide(); - chkChip->setEnabled(false); - chkModuleFirmware->setEnabled(false); - break; - case slsDetectorDefs::MYTHEN: - break; - default: - //leave everything as it is(mythen is default) - break; - } - - - //add detectors - for(int i=0;igetNumberOfDetectors();i++){ - comboDetector->addItem(QString(myDet->getHostname(i).c_str())); - } - - - //add modules and status for current detector - if(detType==slsDetectorDefs::MYTHEN) UpdateModuleList(); - UpdateStatus(); - - qDefs::checkErrorMessage(myDet,"qTabDebugging::SetupWidgetWindow"); -} - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qTabDebugging::Initialization(){ - if(detType==slsDetectorDefs::MYTHEN) - connect(comboDetector, SIGNAL(currentIndexChanged(int)), this, SLOT(UpdateModuleList())); - - connect(comboDetector, SIGNAL(currentIndexChanged(int)), this, SLOT(UpdateStatus())); - connect(btnGetInfo, SIGNAL(clicked()), this, SLOT(GetInfo())); - connect(btnTest, SIGNAL(clicked()), this, SLOT(TestDetector())); + connect(comboDetector, SIGNAL(currentIndexChanged(int)), this, SLOT(UpdateStatus())); + connect(btnGetInfo, SIGNAL(clicked()), this, SLOT(GetInfo())); + if (btnTest ->isEnabled()) + connect(btnTest, SIGNAL(clicked()), this, SLOT(TestDetector())); } +void qTabDebugging::UpdateStatus() { + FILE_LOG(logDEBUG) << "Getting Status"; -//------------------------------------------------------------------------------------------------------------------------------------------------- + auto moduleId = comboDetector->currentIndex(); + int detStatus = (int)myDet->getRunStatus(moduleId); + std::string status = slsDetectorDefs::runStatusType(slsDetectorDefs::runStatus(detStatus)); + lblStatus->setText(QString(status.c_str()).toUpper()); - -void qTabDebugging::UpdateModuleList(){ -#ifdef VERBOSE - cout << "Getting Module List" << endl; -#endif - det = myDet->getSlsDetector(comboDetector->currentIndex()); - qDefs::checkErrorMessage(myDet,"qTabDebugging::UpdateModuleList"); - //deletes all modules except "all modules" - for(int i=0;icount()-1;i++) - comboModule->removeItem(i); - for(int i=0;igetNMods();i++){ - comboModule->addItem(QString("Module %1").arg(i)); - } - - qDefs::checkErrorMessage(det,"qTabDebugging::UpdateModuleList"); + qDefs::checkErrorMessage(myDet, comboDetector->currentIndex(), "qTabDebugging::UpdateStatus"); } -//------------------------------------------------------------------------------------------------------------------------------------------------- +void qTabDebugging::GetInfo() { + FILE_LOG(logDEBUG) << "Getting Readout Info"; + + //window + QFrame *popup1 = new QFrame(this, Qt::Popup | Qt::SubWindow); + QList items; + + //layout + QGridLayout *layout = new QGridLayout(popup1); + //treewidget + treeDet = new QTreeWidget(popup1); + layout->addWidget(treeDet, 0, 0); + //display the details + QFrame *dispFrame = new QFrame(popup1); + QGridLayout *formLayout = new QGridLayout(dispFrame); + // hostname + lblDetectorId = new QLabel(""); + lblDetectorId->setPalette(*blue); + // firmware version + lblDetectorFirmware = new QLabel(""); + lblDetectorFirmware->setPalette(*blue); + // software version + lblDetectorSoftware = new QLabel(""); + lblDetectorSoftware->setPalette(*blue); + //to make sure the size is constant + lblDetectorFirmware->setFixedWidth(100); + layout->addWidget(dispFrame, 0, 1); + + QString detName = QString(myDet->getDetectorTypeAsString().c_str()); + + switch (detType) { -void qTabDebugging::UpdateStatus(){ -#ifdef VERBOSE - cout << "Getting Status" << endl; -#endif - det = myDet->getSlsDetector(comboDetector->currentIndex()); - qDefs::checkErrorMessage(myDet,"qTabDebugging::UpdateStatus"); - int detStatus = (int)det->getRunStatus(); - string status = slsDetectorDefs::runStatusType(slsDetectorDefs::runStatus(detStatus)); - lblStatus->setText(QString(status.c_str()).toUpper()); + case slsDetectorDefs::EIGER: + //display widget + formLayout->addWidget(new QLabel("Half Module:"), 0, 0); + formLayout->addItem(new QSpacerItem(15, 20, QSizePolicy::Fixed, QSizePolicy::Fixed), 0, 1); + formLayout->addWidget(lblDetectorId, 0, 2); + formLayout->addWidget(new QLabel("Half Module Firmware Version:"), 1, 0); + formLayout->addWidget(lblDetectorFirmware, 1, 2); + formLayout->addWidget(new QLabel("Half Module Software Version:"), 2, 0); + formLayout->addWidget(lblDetectorSoftware, 2, 2); - qDefs::checkErrorMessage(det,"qTabDebugging::UpdateStatus"); + //tree widget + treeDet->setHeaderLabel("Eiger Detector"); + //get num modules + for (int i = 0; i < comboDetector->count() / 2; ++i) + items.append(new QTreeWidgetItem((QTreeWidget *)0, QStringList(QString("Module %1").arg(i)))); + treeDet->insertTopLevelItems(0, items); + //gets det names + for (int i = 0; i < comboDetector->count(); ++i) { + QList childItems; + childItems.append(new QTreeWidgetItem((QTreeWidget *)0, QStringList(QString("Half Module (%1)").arg(comboDetector->itemText(i))))); + treeDet->topLevelItem(i * 2)->insertChildren(0, childItems); + } + break; + + default: + + //display widget + formLayout->addWidget(new QLabel("Module:"), 0, 0); + formLayout->addItem(new QSpacerItem(15, 20, QSizePolicy::Fixed, QSizePolicy::Fixed), 0, 1); + formLayout->addWidget(lblDetectorId, 0, 2); + formLayout->addWidget(new QLabel("Module Firmware Version:"), 1, 0); + formLayout->addWidget(lblDetectorFirmware, 1, 2); + formLayout->addWidget(new QLabel("Module Software Version:"), 2, 0); + formLayout->addWidget(lblDetectorSoftware, 2, 2); + //tree widget + treeDet->setHeaderLabel(QString(detName + " Detector")); + //gets det names + for (int i = 0; i < comboDetector->count(); ++i) + items.append(new QTreeWidgetItem((QTreeWidget *)0, QStringList(QString("Module (%1)").arg(comboDetector->itemText(i))))); + treeDet->insertTopLevelItems(0, items); + + break; + } + + //show and center widget + int x = ((parentWidget()->width()) - (popup1->frameGeometry().width())) / 2; + int y = ((parentWidget()->height()) - (popup1->frameGeometry().height())) / 2; + QDesktopWidget *desktop = QApplication::desktop(); + int screen = desktop->screenNumber(this); + popup1->setWindowModality(Qt::WindowModal); + popup1->move((desktop->screenGeometry(screen).x()) + x, (desktop->screenGeometry(screen).y()) + y); + popup1->show(); + + //put the first parameters + SetParameters(treeDet->topLevelItem(0)); + + //initializations + connect(treeDet, SIGNAL(itemDoubleClicked(QTreeWidgetItem *, int)), this, SLOT(SetParameters(QTreeWidgetItem *))); } -//------------------------------------------------------------------------------------------------------------------------------------------------- +void qTabDebugging::SetParameters(QTreeWidgetItem *item) { + char value[200]; + int i; + + auto moduleId = comboDetector->currentIndex(); + switch (detType) { -void qTabDebugging::GetInfo(){ -#ifdef VERBOSE - cout << "Getting Info" << endl; -#endif - //window - QFrame* popup1 = new QFrame(this, Qt::Popup | Qt::SubWindow ); - QList items; + case slsDetectorDefs::EIGER: + //only if half module clicked + if (item->text(0).contains("Half Module")) { + //find index + for (i = 0; i < comboDetector->count(); ++i) + if (item == treeDet->topLevelItem(i)) + break; + sprintf(value, "%lx", (long long unsigned int)myDet->getId(slsDetectorDefs::DETECTOR_FIRMWARE_VERSION, moduleId)); + lblDetectorFirmware->setText(QString(value)); + sprintf(value, "%lx", (long long unsigned int)myDet->getId(slsDetectorDefs::DETECTOR_SOFTWARE_VERSION, moduleId)); + lblDetectorSoftware->setText(QString(value)); + qDefs::checkErrorMessage(myDet, comboDetector->currentIndex(), "qTabDebugging::SetParameters"); + } + break; - //layout - QGridLayout *layout = new QGridLayout(popup1); - //treewidget - treeDet = new QTreeWidget(popup1); - layout->addWidget(treeDet,0,0); - //display the details - dispFrame = new QFrame(popup1); - QGridLayout *formLayout = new QGridLayout(dispFrame); - lblDetectorId = new QLabel(""); lblDetectorId->setPalette(*blue); - lblDetectorSerial = new QLabel(""); lblDetectorSerial->setPalette(*blue); - lblDetectorFirmware = new QLabel(""); lblDetectorFirmware->setPalette(*blue); - lblDetectorSoftware = new QLabel(""); lblDetectorSoftware->setPalette(*blue); - lblModuleId = new QLabel(""); lblModuleId->setPalette(*blue); - lblModuleSerial = new QLabel(""); lblModuleSerial->setPalette(*blue); - lblModuleFirmware = new QLabel(""); lblModuleFirmware->setPalette(*blue); - //to make sure the size is constant - lblDetectorFirmware->setFixedWidth(100); - layout->addWidget(dispFrame,0,1); + default: + //find index + for (i = 0; i < comboDetector->count(); ++i) + if (item == treeDet->topLevelItem(i)) + break; - switch(detType){ + sprintf(value, "%lx", (long long unsigned int)myDet->getId(slsDetectorDefs::DETECTOR_FIRMWARE_VERSION, moduleId)); + lblDetectorFirmware->setText(QString(value)); + sprintf(value, "%lx", (long long unsigned int)myDet->getId(slsDetectorDefs::DETECTOR_SOFTWARE_VERSION, moduleId)); + lblDetectorSoftware->setText(QString(value)); - case slsDetectorDefs::MYTHEN: - //display widget - formLayout->addWidget(new QLabel("Readout:"),0,0); - formLayout->addItem(new QSpacerItem(15,20,QSizePolicy::Fixed,QSizePolicy::Fixed),0,1); - formLayout->addWidget(lblDetectorId,0,2); - formLayout->addWidget(new QLabel("Readout MAC Address:"),1,0); - formLayout->addWidget(lblDetectorSerial,1,2); - formLayout->addWidget(new QLabel("Readout Firmware Version:"),2,0); - formLayout->addWidget(lblDetectorFirmware,2,2); - formLayout->addWidget(new QLabel("Readout Software Version:"),3,0); - formLayout->addWidget(lblDetectorSoftware,3,2); - formLayout->addWidget(new QLabel("Module:"),4,0); - formLayout->addWidget(lblModuleId,4,2); - formLayout->addWidget(new QLabel("Module Serial Number:"),5,0); - formLayout->addWidget(lblModuleSerial,5,2); - formLayout->addWidget(new QLabel("Module Firmware Version:"),6,0); - formLayout->addWidget(lblModuleFirmware,6,2); - - - //tree widget - treeDet->setHeaderLabel("Mythen Detector"); - //gets det names - for (int i=0;icount();i++) - items.append(new QTreeWidgetItem((QTreeWidget*)0, QStringList(QString("Readout (%1)").arg(comboDetector->itemText(i))))); - treeDet->insertTopLevelItems(0, items); - //gets module names - for (int i=0;icount();i++){ - QList childItems; - det = myDet->getSlsDetector(i); - qDefs::checkErrorMessage(myDet,"qTabDebugging::GetInfo"); - for(int j=0;jgetNMods();j++) - childItems.append(new QTreeWidgetItem((QTreeWidget*)0, QStringList(QString("Module %1").arg(j)))); - treeDet->topLevelItem(i)->insertChildren(0,childItems); - qDefs::checkErrorMessage(det,"qTabDebugging::GetInfo"); - } - - break; - - - - - case slsDetectorDefs::EIGER: - //display widget - formLayout->addWidget(new QLabel("Half Module:"),0,0); - formLayout->addItem(new QSpacerItem(15,20,QSizePolicy::Fixed,QSizePolicy::Fixed),0,1); - formLayout->addWidget(lblDetectorId,0,2); - formLayout->addWidget(new QLabel("Half Module MAC Address:"),1,0); - formLayout->addWidget(lblDetectorSerial,1,2); - formLayout->addWidget(new QLabel("Half Module Firmware Version:"),2,0); - formLayout->addWidget(lblDetectorFirmware,2,2); - formLayout->addWidget(new QLabel("Half Module Software Version:"),3,0); - formLayout->addWidget(lblDetectorSoftware,3,2); - - //tree widget - treeDet->setHeaderLabel("Eiger Detector"); - //get num modules - for (int i=0;icount()/2;i++) - items.append(new QTreeWidgetItem((QTreeWidget*)0, QStringList(QString("Module %1").arg(i)))); - treeDet->insertTopLevelItems(0, items); - //gets det names - for (int i=0;icount();i++){ - QList childItems; - childItems.append(new QTreeWidgetItem((QTreeWidget*)0, QStringList(QString("Half Module (%1)").arg(comboDetector->itemText(i))))); - treeDet->topLevelItem(i*2)->insertChildren(0,childItems); - } - break; - - - - case slsDetectorDefs::MOENCH: - - //display widget - formLayout->addWidget(new QLabel("Module:"),0,0); - formLayout->addItem(new QSpacerItem(15,20,QSizePolicy::Fixed,QSizePolicy::Fixed),0,1); - formLayout->addWidget(lblDetectorId,0,2); - formLayout->addWidget(new QLabel("Module MAC Address:"),1,0); - formLayout->addWidget(lblDetectorSerial,1,2); - formLayout->addWidget(new QLabel("Module Firmware Version:"),2,0); - formLayout->addWidget(lblDetectorFirmware,2,2); - formLayout->addWidget(new QLabel("Module Software Version:"),3,0); - formLayout->addWidget(lblDetectorSoftware,3,2); - //tree widget - treeDet->setHeaderLabel("Moench Detector"); - //gets det names - for (int i=0;icount();i++) - items.append(new QTreeWidgetItem((QTreeWidget*)0, QStringList(QString("Module (%1)").arg(comboDetector->itemText(i))))); - treeDet->insertTopLevelItems(0, items); - - break; - - - - case slsDetectorDefs::PROPIX: - - //display widget - formLayout->addWidget(new QLabel("Module:"),0,0); - formLayout->addItem(new QSpacerItem(15,20,QSizePolicy::Fixed,QSizePolicy::Fixed),0,1); - formLayout->addWidget(lblDetectorId,0,2); - formLayout->addWidget(new QLabel("Module MAC Address:"),1,0); - formLayout->addWidget(lblDetectorSerial,1,2); - formLayout->addWidget(new QLabel("Module Firmware Version:"),2,0); - formLayout->addWidget(lblDetectorFirmware,2,2); - formLayout->addWidget(new QLabel("Module Software Version:"),3,0); - formLayout->addWidget(lblDetectorSoftware,3,2); - //tree widget - treeDet->setHeaderLabel("Propix Detector"); - //gets det names - for (int i=0;icount();i++) - items.append(new QTreeWidgetItem((QTreeWidget*)0, QStringList(QString("Module (%1)").arg(comboDetector->itemText(i))))); - treeDet->insertTopLevelItems(0, items); - - break; - - - - case slsDetectorDefs::GOTTHARD: - - //display widget - formLayout->addWidget(new QLabel("Module:"),0,0); - formLayout->addItem(new QSpacerItem(15,20,QSizePolicy::Fixed,QSizePolicy::Fixed),0,1); - formLayout->addWidget(lblDetectorId,0,2); - formLayout->addWidget(new QLabel("Module MAC Address:"),1,0); - formLayout->addWidget(lblDetectorSerial,1,2); - formLayout->addWidget(new QLabel("Module Firmware Version:"),2,0); - formLayout->addWidget(lblDetectorFirmware,2,2); - formLayout->addWidget(new QLabel("Module Software Version:"),3,0); - formLayout->addWidget(lblDetectorSoftware,3,2); - //tree widget - treeDet->setHeaderLabel("Gotthard Detector"); - //gets det names - for (int i=0;icount();i++) - items.append(new QTreeWidgetItem((QTreeWidget*)0, QStringList(QString("Module (%1)").arg(comboDetector->itemText(i))))); - treeDet->insertTopLevelItems(0, items); - - break; - - - case slsDetectorDefs::JUNGFRAU: - case slsDetectorDefs::CHIPTESTBOARD: - //display widget - formLayout->addWidget(new QLabel("Module:"),0,0); - formLayout->addItem(new QSpacerItem(15,20,QSizePolicy::Fixed,QSizePolicy::Fixed),0,1); - formLayout->addWidget(lblDetectorId,0,2); - formLayout->addWidget(new QLabel("Module MAC Address:"),1,0); - formLayout->addWidget(lblDetectorSerial,1,2); - formLayout->addWidget(new QLabel("Module Firmware Version:"),2,0); - formLayout->addWidget(lblDetectorFirmware,2,2); - formLayout->addWidget(new QLabel("Module Software Version:"),3,0); - formLayout->addWidget(lblDetectorSoftware,3,2); - //tree widget - if (detType == slsDetectorDefs::JUNGFRAU) - treeDet->setHeaderLabel("JungFrau Detector"); - else - treeDet->setHeaderLabel("JungFrauCTB Detector"); - //gets det names - for (int i=0;icount();i++) - items.append(new QTreeWidgetItem((QTreeWidget*)0, QStringList(QString("Module (%1)").arg(comboDetector->itemText(i))))); - treeDet->insertTopLevelItems(0, items); - - break; - - - default: - break; - } - - //show and center widget - - int x = ((parentWidget()->width()) - (popup1->frameGeometry().width())) / 2; - int y = ((parentWidget()->height()) - (popup1->frameGeometry().height())) / 2; - QDesktopWidget *desktop = QApplication::desktop(); - int screen = desktop->screenNumber(this); - popup1->setWindowModality(Qt::WindowModal); - popup1->move( (desktop->screenGeometry(screen).x())+x, (desktop->screenGeometry(screen).y())+y ); - popup1->show(); - - //put the first parameters - SetParameters(treeDet->topLevelItem(0)); - - //initializations - connect(treeDet, SIGNAL(itemDoubleClicked(QTreeWidgetItem *,int)) , this, SLOT(SetParameters(QTreeWidgetItem *))); - -} -//------------------------------------------------------------------------------------------------------------------------------------------------- - -void qTabDebugging::SetParameters(QTreeWidgetItem *item){ - char value[200]; - int i; - - - switch(detType){ - - case slsDetectorDefs::MYTHEN: - if(item->text(0).contains("Readout")){ - //find index - for(i=0;icount();i++) - if(item== treeDet->topLevelItem(i)) - break; - - det = myDet->getSlsDetector(i); - qDefs::checkErrorMessage(myDet,"qTabDebugging::SetParameters"); - lblDetectorId->setText(comboDetector->itemText(i)); - sprintf(value,"%llx",(long long unsigned int)det->getId(slsDetectorDefs::DETECTOR_SERIAL_NUMBER)); - lblDetectorSerial->setText(QString(value)); - sprintf(value,"%llx",(long long unsigned int)det->getId(slsDetectorDefs::DETECTOR_FIRMWARE_VERSION)); - lblDetectorFirmware ->setText(QString(value)); - sprintf(value,"%llx",(long long unsigned int)det->getId(slsDetectorDefs::DETECTOR_SOFTWARE_VERSION)); - lblDetectorSoftware->setText(QString(value)); - qDefs::checkErrorMessage(det,"qTabDebugging::SetParameters"); - - lblModuleId->setText(""); - lblModuleSerial->setText(""); - lblModuleFirmware->setText(""); - }else{ - //find index - for(i=0;icount();i++) - if(item->parent() == treeDet->topLevelItem(i)) - break; - int im = item->parent()->indexOfChild(item); - - det = myDet->getSlsDetector(i); - qDefs::checkErrorMessage(myDet,"qTabDebugging::SetParameters"); - lblDetectorId->setText(comboDetector->itemText(i)); - sprintf(value,"%llx",(long long unsigned int)det->getId(slsDetectorDefs::DETECTOR_SERIAL_NUMBER)); - lblDetectorSerial->setText(QString(value)); - sprintf(value,"%llx",(long long unsigned int)det->getId(slsDetectorDefs::DETECTOR_FIRMWARE_VERSION)); - lblDetectorFirmware ->setText(QString(value)); - sprintf(value,"%llx",(long long unsigned int)det->getId(slsDetectorDefs::DETECTOR_SOFTWARE_VERSION)); - lblDetectorSoftware->setText(QString(value)); - - lblModuleId->setText(QString("%1").arg(im)); - sprintf(value,"%llx",(long long unsigned int)det->getId(slsDetectorDefs::MODULE_SERIAL_NUMBER,im)); - lblModuleSerial->setText(QString(value)); - sprintf(value,"%llx",(long long unsigned int)det->getId(slsDetectorDefs::MODULE_FIRMWARE_VERSION,im)); - lblModuleFirmware->setText(QString(value)); - - qDefs::checkErrorMessage(det,"qTabDebugging::SetParameters"); - } - break; - - - - - - case slsDetectorDefs::EIGER: - //only if half module clicked - if(item->text(0).contains("Half Module")){ - //find index - for(i=0;icount();i++) - if(item== treeDet->topLevelItem(i)) - break; - - det = myDet->getSlsDetector(i); - qDefs::checkErrorMessage(myDet,"qTabDebugging::SetParameters"); - lblDetectorId->setText(comboDetector->itemText(i)); - sprintf(value,"%llx",(long long unsigned int)det->getId(slsDetectorDefs::DETECTOR_SERIAL_NUMBER)); - lblDetectorSerial->setText(QString(value)); - sprintf(value,"%llx",(long long unsigned int)det->getId(slsDetectorDefs::DETECTOR_FIRMWARE_VERSION)); - lblDetectorFirmware ->setText(QString(value)); - sprintf(value,"%llx",(long long unsigned int)det->getId(slsDetectorDefs::DETECTOR_SOFTWARE_VERSION)); - lblDetectorSoftware->setText(QString(value)); - - qDefs::checkErrorMessage(det,"qTabDebugging::SetParameters"); - } - break; - - - case slsDetectorDefs::JUNGFRAU: - case slsDetectorDefs::CHIPTESTBOARD: - case slsDetectorDefs::PROPIX: - case slsDetectorDefs::MOENCH: - case slsDetectorDefs::GOTTHARD: - //find index - for(i=0;icount();i++) - if(item== treeDet->topLevelItem(i)) - break; - - det = myDet->getSlsDetector(i); - qDefs::checkErrorMessage(myDet,"qTabDebugging::SetParameters"); - lblDetectorId->setText(comboDetector->itemText(i)); - sprintf(value,"%llx",(long long unsigned int)det->getId(slsDetectorDefs::DETECTOR_SERIAL_NUMBER)); - lblDetectorSerial->setText(QString(value)); - sprintf(value,"%llx",(long long unsigned int)det->getId(slsDetectorDefs::DETECTOR_FIRMWARE_VERSION)); - lblDetectorFirmware ->setText(QString(value)); - sprintf(value,"%llx",(long long unsigned int)det->getId(slsDetectorDefs::DETECTOR_SOFTWARE_VERSION)); - lblDetectorSoftware->setText(QString(value)); - - qDefs::checkErrorMessage(det,"qTabDebugging::SetParameters"); - break; - - - - - default: - break; - } + qDefs::checkErrorMessage(myDet, comboDetector->currentIndex(), "qTabDebugging::SetParameters"); + break; + } } -//------------------------------------------------------------------------------------------------------------------------------------------------- +void qTabDebugging::TestDetector() { + FILE_LOG(logINFO) << "Testing Readout"; -void qTabDebugging::TestDetector(){ -#ifdef VERBOSE - cout << "Testing" << endl; -#endif + int retval = slsDetectorDefs::FAIL; + QString message; + QString Detector = "Detector"; - int retval=slsDetectorDefs::FAIL; - QString message; - QString Detector = "Detector"; + //main messagebox title + switch (detType) { + case slsDetectorDefs::EIGER: + Detector = "Half Module"; + break; + default: + Detector = "Module"; + break; + } - //main messagebox title - switch(detType){ - case slsDetectorDefs::MYTHEN: - message = QString("Test Results for %1 and %2:

").arg(comboDetector->currentText(),comboModule->currentText()); - break; - case slsDetectorDefs::EIGER: Detector = "Half Module"; break; - case slsDetectorDefs::JUNGFRAU: - case slsDetectorDefs::CHIPTESTBOARD: - case slsDetectorDefs::MOENCH: - case slsDetectorDefs::PROPIX: - case slsDetectorDefs::GOTTHARD: Detector = "Module"; break; - default: break; - } + // construct message + message = QString("Test Results for %1:

").arg(comboDetector->currentText()); + auto moduleId = comboDetector->currentIndex(); - if(detType==slsDetectorDefs::MYTHEN) - message = QString("Test Results for %1 and %2:

").arg(comboDetector->currentText(),comboModule->currentText()); - else message = QString("Test Results for %1:

").arg(comboDetector->currentText()); + //detector firmware + if (chkDetectorFirmware->isChecked()) { + retval = myDet->digitalTest(slsDetectorDefs::DETECTOR_FIRMWARE_TEST, moduleId); + if (retval == slsDetectorDefs::FAIL) { + message.append(QString("%1 Firmware: FAIL
").arg(Detector)); + FILE_LOG(logERROR) << "Firmware fail"; + } + else + message.append(QString("%1 Firmware: %2
").arg(Detector, QString::number(retval))); + FILE_LOG(logINFO) << "Detector Firmware Test: " << retval; + } - //get sls det object - det = myDet->getSlsDetector(comboDetector->currentIndex()); - qDefs::checkErrorMessage(myDet,"qTabDebugging::TestDetector"); + //detector CPU-FPGA bus + if (chkDetectorBus->isChecked()) { + retval = myDet->digitalTest(slsDetectorDefs::DETECTOR_BUS_TEST, moduleId); + if (retval == slsDetectorDefs::FAIL) { + message.append(QString("%1 Bus:     FAIL
").arg(Detector)); + FILE_LOG(logERROR) << "Bus Test fail"; + } else + message.append(QString("%1 Bus:     %2
").arg(Detector, QString::number(retval))); + FILE_LOG(logINFO) << "Detector Bus Test: " << retval; + } - //detector firmware - if(chkDetectorFirmware->isChecked()){ - retval = det->digitalTest(slsDetectorDefs::DETECTOR_FIRMWARE_TEST); - if(retval== slsDetectorDefs::FAIL) message.append(QString("%1 Firmware: FAIL
").arg(Detector)); - else message.append(QString("%1 Firmware: %2
").arg(Detector,QString::number(retval))); -#ifdef VERBOSE - cout<<"Detector Firmware: "<isChecked()){ - retval = det->digitalTest(slsDetectorDefs::DETECTOR_SOFTWARE_TEST); - if(retval== slsDetectorDefs::FAIL) message.append(QString("%1 Software: FAIL
").arg(Detector)); - else message.append(QString("%1 Software: %2
").arg(Detector,QString::number(retval))); -#ifdef VERBOSE - cout<<"Detector Software: "<isChecked()){ - retval = det->digitalTest(slsDetectorDefs::DETECTOR_BUS_TEST); - if(retval== slsDetectorDefs::FAIL) message.append(QString("%1 Bus:     FAIL
").arg(Detector)); - else message.append(QString("%1 Bus:     %2
").arg(Detector,QString::number(retval))); -#ifdef VERBOSE - cout<<"Detector Bus: "<isChecked()){ - retval = det->digitalTest(slsDetectorDefs::DETECTOR_MEMORY_TEST); - if(retval== slsDetectorDefs::FAIL) message.append(QString("%1 Memory:  FAIL
").arg(Detector)); - else message.append(QString("%1 Memory:  %2
").arg(Detector,QString::number(retval))); -#ifdef VERBOSE - cout<<"Detector Memory: "<isChecked()){ - retval = det->digitalTest(slsDetectorDefs::CHIP_TEST,comboModule->currentIndex()); - if(retval== slsDetectorDefs::FAIL) message.append("
Chip: FAIL
"); - else message.append(QString("Chip: %1
").arg(retval)); -#ifdef VERBOSE - cout<<"Chip: "<isChecked()){ - retval = det->digitalTest(slsDetectorDefs::MODULE_FIRMWARE_TEST,comboModule->currentIndex()); - if(retval== slsDetectorDefs::FAIL) message.append("Module Firmware: FAIL
"); - else message.append(QString("Module Firmware: %1
").arg(retval)); -#ifdef VERBOSE - cout<<"Module Firmware: "<currentIndex(), "qTabDebugging::TestDetector"); } -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qTabDebugging::Refresh(){ -#ifdef VERBOSE - cout << endl << "**Updating Debugging Tab" << endl; -#endif - UpdateStatus(); -#ifdef VERBOSE - cout << "**Updated Debugging Tab" << endl << endl; -#endif +void qTabDebugging::Refresh() { + FILE_LOG(logDEBUG) << "\n**Updating Debugging Tab"; + UpdateStatus(); + FILE_LOG(logDEBUG) << "**Updated Debugging Tab"; } - -//------------------------------------------------------------------------------------------------------------------------------------------------- - diff --git a/slsDetectorGui/src/qTabDeveloper.cpp b/slsDetectorGui/src/qTabDeveloper.cpp old mode 100644 new mode 100755 index 0df8aeb2a..291625c36 --- a/slsDetectorGui/src/qTabDeveloper.cpp +++ b/slsDetectorGui/src/qTabDeveloper.cpp @@ -1,90 +1,58 @@ -/* - * qTabDeveloper.cpp - * - * Created on: May 10, 2012 - * Author: l_maliakal_d - */ #include "qTabDeveloper.h" #include "qDetectorMain.h" -//Project Class Headers -#include "slsDetector.h" + #include "multiSlsDetector.h" -//Qt Include Headers + +#include #include #include -#include -//C++ Include Headers -#include -using namespace std; - -//------------------------------------------------------------------------------------------------------------------------------------------------- - -int qTabDeveloper::NUM_DAC_WIDGETS(0); -int qTabDeveloper::NUM_ADC_WIDGETS(0); - -//------------------------------------------------------------------------------------------------------------------------------------------------- +#include -qTabDeveloper::qTabDeveloper(qDetectorMain *parent,multiSlsDetector*& detector): - thisParent(parent), - myDet(detector), - det(0), - boxDacs(0), - boxAdcs(0), - lblHV(0), - comboHV(0), - adcTimer(0), - dacLayout(0){ - for(int i=0;i<20;i++) { - lblDacs[i]=0; - lblAdcs[i]=0; - spinDacs[i]=0; - spinAdcs[i]=0; - lblDacsmV[i]=0; - } +qTabDeveloper::qTabDeveloper(QWidget *parent, multiSlsDetector *detector) : QWidget(parent), + myDet(detector), + detType(slsDetectorDefs::GENERIC), + numDACWidgets(0), + numADCWidgets(0), + boxDacs(0), + boxAdcs(0), + lblHV(0), + comboHV(0), + dacLayout(0), + comboDetector(0) { + + + lblDacs.clear(); + lblAdcs.clear(); + spinDacs.clear(); + spinAdcs.clear(); + lblDacsmV.clear(); + SetupWidgetWindow(); Initialization(); + FILE_LOG(logDEBUG) << "Developer ready"; } -//------------------------------------------------------------------------------------------------------------------------------------------------- - - qTabDeveloper::~qTabDeveloper() { - delete myDet; - if(det) delete det; - if(thisParent) delete thisParent; + if (myDet) + delete myDet; } - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - void qTabDeveloper::SetupWidgetWindow() { //Detector Type - detType=myDet->getDetectorsType(); + detType = myDet->getDetectorTypeAsEnum(); //palette red = QPalette(); - red.setColor(QPalette::Active,QPalette::WindowText,Qt::red); - + red.setColor(QPalette::Active, QPalette::WindowText, Qt::red); //the number of dacs and adcs - switch(detType){ - case slsDetectorDefs::MYTHEN: - NUM_DAC_WIDGETS = 6; - NUM_ADC_WIDGETS = 0; - dacNames.push_back("v Trimbit:"); - dacNames.push_back("v Threshold:"); - dacNames.push_back("v Shaper1:"); - dacNames.push_back("v Shaper2:"); - dacNames.push_back("v Calibration:"); - dacNames.push_back("v Preamp:"); - break; + switch (detType) { case slsDetectorDefs::EIGER: - NUM_DAC_WIDGETS = 17; - NUM_ADC_WIDGETS = 6; + numDACWidgets = 17; + numADCWidgets = 6; dacNames.push_back("v SvP:"); dacNames.push_back("v SvN"); @@ -112,10 +80,10 @@ void qTabDeveloper::SetupWidgetWindow() { adcNames.push_back("Temperature FPGA:"); break; - case slsDetectorDefs::PROPIX: + case slsDetectorDefs::GOTTHARD: - NUM_DAC_WIDGETS = 8; - NUM_ADC_WIDGETS = 2; + numDACWidgets = 8; + numADCWidgets = 2; dacNames.push_back("v Reference:"); dacNames.push_back("v Cascode n:"); dacNames.push_back("v Cascode p:"); @@ -129,28 +97,10 @@ void qTabDeveloper::SetupWidgetWindow() { adcNames.push_back("Temperature FPGA:"); break; - case slsDetectorDefs::MOENCH: - NUM_DAC_WIDGETS = 8; - NUM_ADC_WIDGETS = 2; - dacNames.push_back("v Dac 0:"); - dacNames.push_back("v Dac 1:"); - dacNames.push_back("v Dac 2:"); - dacNames.push_back("v Dac 3:"); - dacNames.push_back("v Dac 4:"); - dacNames.push_back("v Dac 5:"); - dacNames.push_back("v Dac 6:"); - dacNames.push_back("i Dac 7:"); - - adcNames.push_back("Temperature ADC:"); - adcNames.push_back("Temperature FPGA:"); - - break; - case slsDetectorDefs::JUNGFRAU: - case slsDetectorDefs::CHIPTESTBOARD: - NUM_DAC_WIDGETS = 8; - NUM_ADC_WIDGETS = 1; + numDACWidgets = 8; + numADCWidgets = 1; dacNames.push_back("v vb comp:"); dacNames.push_back("v vdd prot:"); dacNames.push_back("v vin com:"); @@ -164,51 +114,154 @@ void qTabDeveloper::SetupWidgetWindow() { break; + case slsDetectorDefs::MOENCH: + + numDACWidgets = 8; + numADCWidgets = 0; + dacNames.push_back("v Dac 0:"); + dacNames.push_back("v Dac 1:"); + dacNames.push_back("v Dac 2:"); + dacNames.push_back("v Dac 3:"); + dacNames.push_back("v Dac 4:"); + dacNames.push_back("v Dac 5:"); + dacNames.push_back("v Dac 6:"); + dacNames.push_back("i Dac 7:"); + + break; + default: - cout << "ERROR: Unknown detector type: " + myDet->slsDetectorDefs::getDetectorType(detType) << endl; - qDefs::Message(qDefs::CRITICAL,string("Unknown detector type:")+myDet->slsDetectorDefs::getDetectorType(detType),"qTabDeveloper::SetupWidgetWindow"); + FILE_LOG(logERROR) << "Unknown detector type: " + myDet->getDetectorTypeAsString(); + qDefs::Message(qDefs::CRITICAL, std::string("Unknown detector type:") + myDet->getDetectorTypeAsString(), "qTabDeveloper::SetupWidgetWindow"); exit(-1); break; } - //layout setFixedWidth(765); - setFixedHeight(20+50+(NUM_DAC_WIDGETS/2)*35); - //setHeight(340); + setFixedHeight(20 + 50 + (numDACWidgets / 2) * 35); - scroll = new QScrollArea; - //scroll->setFrameShape(QFrame::NoFrame); + QScrollArea* scroll = new QScrollArea; scroll->setWidget(this); scroll->setWidgetResizable(true); - layout = new QGridLayout(scroll); - layout->setContentsMargins(20,10,10,5); + QGridLayout *layout = new QGridLayout(scroll); + layout->setContentsMargins(20, 10, 10, 5); setLayout(layout); //readout comboDetector = new QComboBox(this); - //comboDetector->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed); comboDetector->addItem("All"); //add detectors - for(int i=1;igetNumberOfDetectors()+1;i++) - comboDetector->addItem(QString(myDet->getHostname(i-1).c_str())); + for (int i = 1; i < myDet->getNumberOfDetectors() + 1; ++i) + comboDetector->addItem(QString(myDet->getHostname(i - 1).c_str())); comboDetector->setCurrentIndex(0); - //dacs - boxDacs = new QGroupBox("Dacs",this); - boxDacs->setFixedHeight(25+(NUM_DAC_WIDGETS/2)*35); CreateDACWidgets(); - //HV for gotthard - if ((detType==slsDetectorDefs::GOTTHARD) || - (detType==slsDetectorDefs::PROPIX) || - (detType==slsDetectorDefs::MOENCH)){ - boxDacs->setFixedHeight(boxDacs->height()+35); + // hv for gotthard, jungfrau, moench + if ((detType == slsDetectorDefs::GOTTHARD) || + (detType == slsDetectorDefs::JUNGFRAU) || + (detType == slsDetectorDefs::MOENCH)) { + CreateHVWidget(); - lblHV = new QLabel("High Voltage",boxDacs); - comboHV = new QComboBox(boxDacs); + } + layout->addWidget(comboDetector, 0, 0); + layout->addWidget(boxDacs, 1, 0); + + //adcs + if (numADCWidgets) { + CreateADCWidgets(); + layout->addWidget(boxAdcs, 2, 0); + } + + qDefs::checkErrorMessage(myDet, "qTabDeveloper::SetupWidgetWindow"); +} + + +void qTabDeveloper::Initialization() { + connect(comboDetector, SIGNAL(currentIndexChanged(int)), this, SLOT(Refresh())); + + // dacs + for (int i = 0; i < numDACWidgets; ++i) + connect(spinDacs[i], SIGNAL(editingFinished(int)), this, SLOT(SetDacValues(int))); + + // hv + if (comboHV) { + connect(comboHV, SIGNAL(currentIndexChanged(int)), this, SLOT(SetHighVoltage())); + } else { + connect(spinHV, SIGNAL(valueChanged(int)), this, SLOT(SetHighVoltage())); + } +} + + +void qTabDeveloper::CreateDACWidgets() { + boxDacs = new QGroupBox("Dacs", this); + boxDacs->setFixedHeight(25 + (numDACWidgets / 2) * 35); + dacLayout = new QGridLayout(boxDacs); + + for (int i = 0; i < numDACWidgets; ++i) { + lblDacs[i] = new QLabel(QString(dacNames[i].c_str()), boxDacs); + spinDacs[i] = new MyDoubleSpinBox(i, boxDacs); + spinDacs[i]->setMinimum(-1); + spinDacs[i]->setMaximum(10000); + lblDacsmV[i] = new QLabel("", boxDacs); + + dacLayout->addWidget(lblDacs[i], (int)(i / 2), ((i % 2) == 0) ? 1 : 5); + dacLayout->addWidget(spinDacs[i], (int)(i / 2), ((i % 2) == 0) ? 2 : 6); + dacLayout->addWidget(lblDacsmV[i], (int)(i / 2), ((i % 2) == 0) ? 3 : 7); + if (!(i % 2)) { + dacLayout->addItem(new QSpacerItem(20, 20, QSizePolicy::Fixed, QSizePolicy::Fixed), (int)(i / 2), 0); + dacLayout->addItem(new QSpacerItem(60, 20, QSizePolicy::Fixed, QSizePolicy::Fixed), (int)(i / 2), 4); + dacLayout->addItem(new QSpacerItem(20, 20, QSizePolicy::Fixed, QSizePolicy::Fixed), (int)(i / 2), 8); + } + } +} + + +void qTabDeveloper::CreateADCWidgets() { + int rows = numADCWidgets / 2; + if (numADCWidgets % 2) + rows++; + setFixedHeight(20 + (50 + (numDACWidgets / 2) * 35) + (50 + rows * 35)); + boxAdcs = new QGroupBox("ADCs", this); + boxAdcs->setFixedHeight(25 + rows * 35); + + QGridLayout *adcLayout = new QGridLayout(boxAdcs); + + for (int i = 0; i < numADCWidgets; ++i) { + lblAdcs[i] = new QLabel(QString(adcNames[i].c_str()), boxAdcs); + spinAdcs[i] = new QLineEdit(boxAdcs); + spinAdcs[i]->setReadOnly(true); + + adcLayout->addWidget(lblAdcs[i], (int)(i / 2), ((i % 2) == 0) ? 1 : 4); + adcLayout->addWidget(spinAdcs[i], (int)(i / 2), ((i % 2) == 0) ? 2 : 5); + if (!(i % 2)) { + adcLayout->addItem(new QSpacerItem(20, 20, QSizePolicy::Fixed, QSizePolicy::Fixed), (int)(i / 2), 0); + adcLayout->addItem(new QSpacerItem(60, 20, QSizePolicy::Fixed, QSizePolicy::Fixed), (int)(i / 2), 3); + adcLayout->addItem(new QSpacerItem(20, 20, QSizePolicy::Fixed, QSizePolicy::Fixed), (int)(i / 2), 6); + } + } + + //to make the adcs at the bottom most + if (detType != slsDetectorDefs::EIGER) { + int diff = 340 - height(); + setFixedHeight(340); + layout->setVerticalSpacing(diff / 2); + } +} + +void qTabDeveloper::CreateHVWidget() { + boxDacs->setFixedHeight(boxDacs->height() + 35); + lblHV = new QLabel("High Voltage", boxDacs); + dacLayout->addWidget(lblHV, (int)(numDACWidgets / 2), 1); + + comboHV = nullptr; + spinHV = nullptr; + + // drop down with specific values + if (detType == slsDetectorDefs::GOTTHARD) { + comboHV = new QComboBox(boxDacs); comboHV->addItem("0"); comboHV->addItem("90"); comboHV->addItem("110"); @@ -217,415 +270,306 @@ void qTabDeveloper::SetupWidgetWindow() { comboHV->addItem("180"); comboHV->addItem("200"); tipHV = "Set high voltage to 0, 90, 110, 120, 150 or 200V."; - lblHV->setToolTip(tipHV); comboHV->setToolTip(tipHV); - dacLayout->addWidget(lblHV,(int)(NUM_DAC_WIDGETS/2),1); - dacLayout->addWidget(comboHV,(int)(NUM_DAC_WIDGETS/2),2); - connect(comboHV, SIGNAL(currentIndexChanged(int)), this, SLOT(SetHighVoltage())); - } - layout->addWidget(comboDetector,0,0); - layout->addWidget(boxDacs,1,0); - - //adcs - if(NUM_ADC_WIDGETS) { - int rows = NUM_ADC_WIDGETS/2; - if (NUM_ADC_WIDGETS%2)rows++; - setFixedHeight(20+(50+(NUM_DAC_WIDGETS/2)*35)+(50+rows*35)); - boxAdcs = new QGroupBox("ADCs",this); - boxAdcs->setFixedHeight(25+rows*35); - layout->addWidget(boxAdcs,2,0); - CreateADCWidgets(); - //to make the adcs at the bottom most - if (detType!=slsDetectorDefs::EIGER) { - int diff = 340-height(); - setFixedHeight(340); - layout->setVerticalSpacing(diff/2); - } - //timer to check adcs - /*adcTimer = new QTimer(this); adc timer disabled, display adcs only when refreshing developer tab */ + dacLayout->addWidget(comboHV, (int)(numDACWidgets / 2), 2); } - qDefs::checkErrorMessage(myDet,"qTabDeveloper::SetupWidgetWindow"); -} - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qTabDeveloper::Initialization(){ - /*if(NUM_ADC_WIDGETS) connect(adcTimer, SIGNAL(timeout()), this, SLOT(RefreshAdcs()));*/ - - for(int i=0;isetMinimum(-1); - spinDacs[i]->setMaximum(10000); - lblDacsmV[i]= new QLabel("",boxDacs); - - - dacLayout->addWidget(lblDacs[i],(int)(i/2),((i%2)==0)?1:5); - dacLayout->addWidget(spinDacs[i],(int)(i/2),((i%2)==0)?2:6); - dacLayout->addWidget(lblDacsmV[i],(int)(i/2),((i%2)==0)?3:7); - if(!(i%2)){ - dacLayout->addItem(new QSpacerItem(20,20,QSizePolicy::Fixed,QSizePolicy::Fixed),(int)(i/2),0); - dacLayout->addItem(new QSpacerItem(60,20,QSizePolicy::Fixed,QSizePolicy::Fixed),(int)(i/2),4); - dacLayout->addItem(new QSpacerItem(20,20,QSizePolicy::Fixed,QSizePolicy::Fixed),(int)(i/2),8); - } + spinDacs[i]->setMaximum(200); + tipHV = "Set high voltage to 0 or 60 - 200V"; + spinHV->setToolTip(tipHV); + dacLayout->addWidget(spinHV, (int)(numDACWidgets / 2), 2); } + lblHV->setToolTip(tipHV); } -//------------------------------------------------------------------------------------------------------------------------------------------------- +void qTabDeveloper::SetDacValues(int id) { + FILE_LOG(logINFO) << "Setting dac:" << dacNames[id] << " : " << spinDacs[id]->value(); + int moduleId = comboDetector->currentIndex() - 1; -void qTabDeveloper::CreateADCWidgets(){ - QGridLayout *adcLayout = new QGridLayout(boxAdcs); - - for(int i=0;isetReadOnly(true); - - adcLayout->addWidget(lblAdcs[i],(int)(i/2),((i%2)==0)?1:4); - adcLayout->addWidget(spinAdcs[i],(int)(i/2),((i%2)==0)?2:5); - if(!(i%2)){ - adcLayout->addItem(new QSpacerItem(20,20,QSizePolicy::Fixed,QSizePolicy::Fixed),(int)(i/2),0); - adcLayout->addItem(new QSpacerItem(60,20,QSizePolicy::Fixed,QSizePolicy::Fixed),(int)(i/2),3); - adcLayout->addItem(new QSpacerItem(20,20,QSizePolicy::Fixed,QSizePolicy::Fixed),(int)(i/2),6); - } - } + myDet->setDAC(spinDacs[id]->value(),getSLSIndex(id), 0, moduleId); + lblDacsmV[id]->setText(QString("%1mV").arg(myDet->setDAC(-1, getSLSIndex(id), 1, moduleId),-10)); + qDefs::checkErrorMessage(myDet, moduleId, "qTabDeveloper::SetDacValues"); } -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qTabDeveloper::SetDacValues(int id){ -#ifdef VERBOSE - cout << "Setting dac:" << dacNames[id] << " : " << spinDacs[id]->value() << endl; -#endif - - int detid = comboDetector->currentIndex(); - if(detid) - det = myDet->getSlsDetector(detid-1); - - //all detectors - if(!detid){ - myDet->setDAC((dacs_t)spinDacs[id]->value(),getSLSIndex(id),0); - lblDacsmV[id]->setText(QString("%1mV").arg(myDet->setDAC(-1,getSLSIndex(id),1),-10)); - qDefs::checkErrorMessage(myDet,"qTabDeveloper::SetDacValues"); - } - //specific detector - else{ - det->setDAC((dacs_t)spinDacs[id]->value(),getSLSIndex(id),0); - lblDacsmV[id]->setText(QString("%1mV").arg(det->setDAC(-1,getSLSIndex(id),1),-10)); - qDefs::checkErrorMessage(det,"qTabDeveloper::SetDacValues"); - } - -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qTabDeveloper::SetHighVoltage(){ -#ifdef VERBOSE - cout << "Setting high voltage:" << comboHV->currentText().toAscii().constData() << endl; -#endif - - int detid = comboDetector->currentIndex(); - if(detid) - det = myDet->getSlsDetector(detid-1); - - int highvoltage = comboHV->currentText().toInt(); - int ret; - - //all detectors - if(!detid){ - ret = myDet->setDAC(highvoltage,slsDetectorDefs::HV_POT,0); - qDefs::checkErrorMessage(myDet,"qTabDeveloper::SetHighVoltage"); - } - //specific detector - else{ - ret = det->setDAC(highvoltage,slsDetectorDefs::HV_POT,0); - qDefs::checkErrorMessage(det,"qTabDeveloper::SetHighVoltage"); - } +void qTabDeveloper::SetHighVoltage() { + int highvoltage = (comboHV ? comboHV->currentText().toInt() : spinHV->value()); + FILE_LOG(logINFO) << "Setting high voltage:" << highvoltage; + auto moduleId = comboDetector->currentIndex() - 1; + int ret = det->setDAC(highvoltage,slsDetectorDefs::HIGH_VOLTAGE, 0, moduleId); + qDefs::checkErrorMessage(myDet, moduleId, "qTabDeveloper::SetHighVoltage"); //error - if(ret != highvoltage){ - qDefs::Message(qDefs::CRITICAL,"High Voltage could not be set to this value.","qTabDeveloper::SetHighVoltage"); + if (ret != highvoltage && highvoltage != -1) { + qDefs::Message(qDefs::CRITICAL, "High Voltage could not be set to this value.", "qTabDeveloper::SetHighVoltage"); + FILE_LOG(logERROR) << "Could not set High voltage"; lblHV->setPalette(red); lblHV->setText("High Voltage:*"); - QString errTip = tipHV+QString("

High Voltage could not be set. The return value is ")+ - QString::number(ret)+ QString(""); + QString errTip = tipHV + QString("

High Voltage could not be set. The return value is ") + + QString::number(ret) + QString(""); lblHV->setToolTip(errTip); - comboHV->setToolTip(errTip); - }else{ + if (comboHV) + comboHV->setToolTip(errTip); + else + spinHV->setToolTip(errTip); + } else { lblHV->setPalette(lblDacs[0]->palette()); lblHV->setText("High Voltage:"); lblHV->setToolTip(tipHV); - comboHV->setToolTip(tipHV); + if (comboHV) + comboHV->setToolTip(tipHV); + else + spinHV->setToolTip(errTip); } } -//------------------------------------------------------------------------------------------------------------------------------------------------- +slsDetectorDefs::dacIndex qTabDeveloper::getSLSIndex(int index) { + switch (detType) { - -slsDetectorDefs::dacIndex qTabDeveloper::getSLSIndex(int index){ - switch(detType){ - case slsDetectorDefs::MYTHEN: - switch(index){ - case 0: return slsDetectorDefs::TRIMBIT_SIZE; - case 1: return slsDetectorDefs::THRESHOLD; - case 2: return slsDetectorDefs::SHAPER1; - case 3: return slsDetectorDefs::SHAPER2; - case 4: return slsDetectorDefs::CALIBRATION_PULSE; - case 5: return slsDetectorDefs::PREAMP; + case slsDetectorDefs::EIGER: + switch (index) { + case 0: + return slsDetectorDefs::E_SvP; + case 1: + return slsDetectorDefs::E_SvN; + case 2: + return slsDetectorDefs::E_Vrf; + case 3: + return slsDetectorDefs::E_Vrs; + case 4: + return slsDetectorDefs::E_Vtr; + case 5: + return slsDetectorDefs::E_Vtgstv; + case 6: + return slsDetectorDefs::E_cal; + case 7: + return slsDetectorDefs::E_Vcp; + case 8: + return slsDetectorDefs::E_Vcn; + case 9: + return slsDetectorDefs::E_Vis; + case 10: + return slsDetectorDefs::E_rxb_lb; + case 11: + return slsDetectorDefs::E_rxb_rb; + case 12: + return slsDetectorDefs::E_Vcmp_ll; + case 13: + return slsDetectorDefs::E_Vcmp_lr; + case 14: + return slsDetectorDefs::E_Vcmp_rl; + case 15: + return slsDetectorDefs::E_Vcmp_rr; + case 16: + return slsDetectorDefs::THRESHOLD; + case 17: + return slsDetectorDefs::TEMPERATURE_FPGAEXT; + case 18: + return slsDetectorDefs::TEMPERATURE_10GE; + case 19: + return slsDetectorDefs::TEMPERATURE_DCDC; + case 20: + return slsDetectorDefs::TEMPERATURE_SODL; + case 21: + return slsDetectorDefs::TEMPERATURE_SODR; + case 22: + return slsDetectorDefs::TEMPERATURE_FPGA; default: - qDefs::Message(qDefs::CRITICAL,"Unknown DAC/ADC Index. Weird Error Index:"+ index,"qTabDeveloper::getSLSIndex"); + qDefs::Message(qDefs::CRITICAL, "Unknown DAC/ADC Index. Weird Error Index:" + index, "qTabDeveloper::getSLSIndex"); Refresh(); break; } break; - case slsDetectorDefs::EIGER: - switch(index){ - case 0: return slsDetectorDefs::E_SvP; - case 1: return slsDetectorDefs::E_SvN; - case 2: return slsDetectorDefs::E_Vrf; - case 3: return slsDetectorDefs::E_Vrs; - case 4: return slsDetectorDefs::E_Vtr; - case 5: return slsDetectorDefs::E_Vtgstv; - case 6: return slsDetectorDefs::E_cal; - case 7: return slsDetectorDefs::E_Vcp; - case 8: return slsDetectorDefs::E_Vcn; - case 9: return slsDetectorDefs::E_Vis; - case 10:return slsDetectorDefs::E_rxb_lb; - case 11:return slsDetectorDefs::E_rxb_rb; - case 12:return slsDetectorDefs::E_Vcmp_ll; - case 13:return slsDetectorDefs::E_Vcmp_lr; - case 14:return slsDetectorDefs::E_Vcmp_rl; - case 15:return slsDetectorDefs::E_Vcmp_rr; - case 16:return slsDetectorDefs::THRESHOLD; - case 17:return slsDetectorDefs::TEMPERATURE_FPGAEXT; - case 18:return slsDetectorDefs::TEMPERATURE_10GE; - case 19:return slsDetectorDefs::TEMPERATURE_DCDC; - case 20:return slsDetectorDefs::TEMPERATURE_SODL; - case 21:return slsDetectorDefs::TEMPERATURE_SODR; - case 22:return slsDetectorDefs::TEMPERATURE_FPGA; - default: - qDefs::Message(qDefs::CRITICAL,"Unknown DAC/ADC Index. Weird Error Index:"+ index,"qTabDeveloper::getSLSIndex"); - Refresh(); - break; - } + case slsDetectorDefs::GOTTHARD: + switch (index) { + case 0: + return slsDetectorDefs::G_VREF_DS; + case 1: + return slsDetectorDefs::G_VCASCN_PB; + case 2: + return slsDetectorDefs::G_VCASCP_PB; + case 3: + return slsDetectorDefs::G_VOUT_CM; + case 4: + return slsDetectorDefs::G_VCASC_OUT; + case 5: + return slsDetectorDefs::G_VIN_CM; + case 6: + return slsDetectorDefs::G_VREF_COMP; + case 7: + return slsDetectorDefs::G_IB_TESTC; + case 8: + return slsDetectorDefs::TEMPERATURE_ADC; + case 9: + return slsDetectorDefs::TEMPERATURE_FPGA; + default: + qDefs::Message(qDefs::CRITICAL, "Unknown DAC/ADC Index. Weird Error Index:" + index, "qTabDeveloper::getSLSIndex"); + Refresh(); break; - case slsDetectorDefs::MOENCH: - switch(index){ - case 0: return slsDetectorDefs::V_DAC0; - case 1: return slsDetectorDefs::V_DAC1; - case 2: return slsDetectorDefs::V_DAC2; - case 3: return slsDetectorDefs::V_DAC3; - case 4: return slsDetectorDefs::V_DAC4; - case 5: return slsDetectorDefs::V_DAC5; - case 6: return slsDetectorDefs::V_DAC6; - case 7: return slsDetectorDefs::V_DAC7; - case 8: return slsDetectorDefs::TEMPERATURE_ADC; - case 9:return slsDetectorDefs::TEMPERATURE_FPGA; + } + break; - default: - qDefs::Message(qDefs::CRITICAL,"Unknown DAC/ADC Index. Weird Error. Index:"+ index,"qTabDeveloper::getSLSIndex"); - Refresh(); - break; - } - break; - case slsDetectorDefs::PROPIX: - case slsDetectorDefs::GOTTHARD: - switch(index){ - case 0: return slsDetectorDefs::G_VREF_DS; - case 1: return slsDetectorDefs::G_VCASCN_PB; - case 2: return slsDetectorDefs::G_VCASCP_PB; - case 3: return slsDetectorDefs::G_VOUT_CM; - case 4: return slsDetectorDefs::G_VCASC_OUT; - case 5: return slsDetectorDefs::G_VIN_CM; - case 6: return slsDetectorDefs::G_VREF_COMP; - case 7: return slsDetectorDefs::G_IB_TESTC; - case 8: return slsDetectorDefs::TEMPERATURE_ADC; - case 9:return slsDetectorDefs::TEMPERATURE_FPGA; - default: - qDefs::Message(qDefs::CRITICAL,"Unknown DAC/ADC Index. Weird Error Index:"+ index,"qTabDeveloper::getSLSIndex"); - Refresh(); - break; - } - break; - case slsDetectorDefs::JUNGFRAU: - case slsDetectorDefs::CHIPTESTBOARD: + case slsDetectorDefs::JUNGFRAU: + if (index >= 0 && index <= 7) { + return (slsDetectorDefs::dacIndex)index; + } + if (index == 8) { + return slsDetectorDefs::TEMPERATURE_ADC; + } else { + qDefs::Message(qDefs::CRITICAL, "Unknown DAC/ADC Index. Weird Error Index:" + index, "qTabDeveloper::getSLSIndex"); + Refresh(); + } + break; + case slsDetectorDefs::MOENCH: + if (index >= 0 && index <= 7) { + return (slsDetectorDefs::dacIndex)index; + } else { + qDefs::Message(qDefs::CRITICAL, "Unknown DAC/ADC Index. Weird Error Index:" + index, "qTabDeveloper::getSLSIndex"); + Refresh(); + } + break; - switch(index){ - case 0: - case 1: - case 2: - case 3: - case 4: - case 5: - case 6: - case 7: - return (slsDetectorDefs::dacIndex)index; - break; - case 8: return slsDetectorDefs::TEMPERATURE_ADC; - default: - qDefs::Message(qDefs::CRITICAL,"Unknown DAC/ADC Index. Weird Error Index:"+ index,"qTabDeveloper::getSLSIndex"); - Refresh(); - break; - } - break; - default: - cout << "Unknown detector type:" + myDet->slsDetectorDefs::getDetectorType(detType) << endl; - qDefs::Message(qDefs::CRITICAL,string("Unknown detector type:")+myDet->slsDetectorDefs::getDetectorType(detType),"qTabDeveloper::getSLSIndex"); - qDefs::checkErrorMessage(myDet,"qTabDeveloper::getSLSIndex"); - exit(-1); - break; + default: + FILE_LOG(logERROR) << "Unknown detector type:" + myDet->getDetectorTypeAsString(); + qDefs::Message(qDefs::CRITICAL, std::string("Unknown detector type:") + myDet->getDetectorTypeAsString(), "qTabDeveloper::getSLSIndex"); + qDefs::checkErrorMessage(myDet, "qTabDeveloper::getSLSIndex"); + exit(-1); + break; } - return slsDetectorDefs::HUMIDITY; + return (slsDetectorDefs::dacIndex)0; } -//------------------------------------------------------------------------------------------------------------------------------------------------- +void qTabDeveloper::RefreshAdcs() { + FILE_LOG(logDEBUG) << "Updating ADCs"; + auto moduleId = comboDetector->currentIndex() - 1; -void qTabDeveloper::RefreshAdcs(){ - if(!thisParent->isCurrentlyTabDeveloper()) - return; + for (int i = 0; i < numADCWidgets; ++i) { -#ifdef VERYVERBOSE - cout << "Updating ADCs" <stop();*/ - - int detid = comboDetector->currentIndex(); - if(detid) - det = myDet->getSlsDetector(detid-1); - - for(int i=0;igetADC(getSLSIndex(i+NUM_DAC_WIDGETS),-1); - - if(value == -1) - spinAdcs[i]->setText(QString("Different values")); - else { - if(detType == slsDetectorDefs::EIGER || detType == slsDetectorDefs::JUNGFRAU || detType == slsDetectorDefs::CHIPTESTBOARD) - value/=1000.00; - spinAdcs[i]->setText(QString::number(value,'f',2)+0x00b0+QString("C")); - } - } - //specific detector - else{ - double value = (double)det->getADC(getSLSIndex(i+NUM_DAC_WIDGETS)); - - if(detType == slsDetectorDefs::EIGER || detType == slsDetectorDefs::JUNGFRAU || detType == slsDetectorDefs::CHIPTESTBOARD) - value/=1000.00; - spinAdcs[i]->setText(QString::number(value,'f',2)+0x00b0+QString("C")); + double value = (double)myDet->getADC(getSLSIndex(i + numDACWidgets), moduleId); + if (value == -1 && moduleId == -1) { + spinAdcs[i]->setText(QString("Different values")); + } else { + if (detType == slsDetectorDefs::EIGER || detType == slsDetectorDefs::JUNGFRAU) + value /= 1000.00; + spinAdcs[i]->setText(QString::number(value, 'f', 2) + 0x00b0 + QString("C")); } } - - /*adcTimer->start(ADC_TIMEOUT);*/ - qDefs::checkErrorMessage(myDet,"qTabDeveloper::RefreshAdcs"); + qDefs::checkErrorMessage(myDet, "qTabDeveloper::RefreshAdcs"); } -//------------------------------------------------------------------------------------------------------------------------------------------------- +void qTabDeveloper::Refresh() { + FILE_LOG(logDEBUG) << "**Updating Developer Tab\n"; + auto moduleId = comboDetector->currentIndex() - 1; -void qTabDeveloper::Refresh(){ -#ifdef VERBOSE - cout << endl << "**Updating Developer Tab" << endl; -#endif - - - int detid = comboDetector->currentIndex(); - if(detid) - det = myDet->getSlsDetector(detid-1); - - - //dacs -#ifdef VERBOSE - cout << "Getting DACs" << NUM_DAC_WIDGETS <setValue((double)myDet->setDAC(-1,getSLSIndex(i),0)); - lblDacsmV[i]->setText(QString("%1mV").arg(myDet->setDAC(-1,getSLSIndex(i),1),-10)); - } - //specific detector - else{ - spinDacs[i]->setValue((double)det->setDAC(-1,getSLSIndex(i),0)); - lblDacsmV[i]->setText(QString("%1mV").arg(det->setDAC(-1,getSLSIndex(i),1),-10)); - } + // dacs + FILE_LOG(logDEBUG) << "Getting DACs"; + for (int i = 0; i < numDACWidgets; ++i) { + spinDacs[i]->setValue(myDet->setDAC(-1, getSLSIndex(i), 0, moduleId)); + lblDacsmV[i]->setText(QString("%1mV").arg(myDet->setDAC(-1, getSLSIndex(i), 1, moduleId), -10)); } - //adcs - if(NUM_ADC_WIDGETS) RefreshAdcs(); + if (numADCWidgets) + RefreshAdcs(); //gotthard -high voltage - if((detType == slsDetectorDefs::GOTTHARD) || - (detType == slsDetectorDefs::PROPIX) || - (detType == slsDetectorDefs::MOENCH)){ - disconnect(comboHV, SIGNAL(currentIndexChanged(int)), this, SLOT(SetHighVoltage())); + if ((detType == slsDetectorDefs::GOTTHARD) || + (detType == slsDetectorDefs::JUNGFRAU) || + (detType == slsDetectorDefs::MOENCH)) { + + if (comboHV) + disconnect(comboHV, SIGNAL(currentIndexChanged(int)), this, SLOT(SetHighVoltage())); + else + disconnect(spinHV, SIGNAL(valueChanged(int)), this, SLOT(SetHighVoltage())); //default should be correct lblHV->setPalette(lblDacs[0]->palette()); lblHV->setText("High Voltage:"); lblHV->setToolTip(tipHV); - comboHV->setToolTip(tipHV); - //getting hv value - int ret; - if(!detid) ret = (int)myDet->setDAC(-1,slsDetectorDefs::HV_POT,0); - else ret = (int)det->setDAC(-1,slsDetectorDefs::HV_POT,0); + if (comboHV) + comboHV->setToolTip(tipHV); + else + spinHV->setToolTip(tipHV); - switch(ret){ - case 0: comboHV->setCurrentIndex(0);break; - case 90: comboHV->setCurrentIndex(1);break; - case 110: comboHV->setCurrentIndex(2);break; - case 120: comboHV->setCurrentIndex(3);break; - case 150: comboHV->setCurrentIndex(4);break; - case 180: comboHV->setCurrentIndex(5);break; - case 200: comboHV->setCurrentIndex(6);break; - default: comboHV->setCurrentIndex(0);//error - lblHV->setPalette(red); - lblHV->setText("High Voltage:*"); - QString errTip = tipHV+QString("

High Voltage could not be set. The return value is ")+ - QString::number(ret)+ QString(""); - lblHV->setToolTip(errTip); - comboHV->setToolTip(errTip); - break; + //getting hv value + int ret = myDet->setDAC(-1, slsDetectorDefs::HIGH_VOLTAGE, 0, moduleId); + + bool error = false; + if (spinHV) { + if (ret != 0 && ret < 60 && ret > 200) + error = true; + else + spinHV->setValue(ret); + } else { + switch (ret) { + case 0: + comboHV->setCurrentIndex(0); + break; + case 90: + comboHV->setCurrentIndex(1); + break; + case 110: + comboHV->setCurrentIndex(2); + break; + case 120: + comboHV->setCurrentIndex(3); + break; + case 150: + comboHV->setCurrentIndex(4); + break; + case 180: + comboHV->setCurrentIndex(5); + break; + case 200: + comboHV->setCurrentIndex(6); + break; + default: + comboHV->setCurrentIndex(0); //error + error = true; + break; + } } - connect(comboHV, SIGNAL(currentIndexChanged(int)), this, SLOT(SetHighVoltage())); + if (error) { + lblHV->setPalette(red); + lblHV->setText("High Voltage:*"); + QString errTip = tipHV + QString("

High Voltage could not be set. The return value is ") + + QString::number(ret) + QString(""); + lblHV->setToolTip(errTip); + if (comboHV) + comboHV->setToolTip(errTip); + else + spinHV->setToolTip(errTip); + } else { + lblHV->setPalette(lblDacs[0]->palette()); + lblHV->setText("High Voltage:"); + lblHV->setToolTip(tipHV); + if (comboHV) + comboHV->setToolTip(tipHV); + else + spinHV->setToolTip(errTip); + } + if (comboHV) + connect(comboHV, SIGNAL(currentIndexChanged(int)), this, SLOT(SetHighVoltage())); + else + connect(spinHV, SIGNAL(valueChanged(int)), this, SLOT(SetHighVoltage())); } -#ifdef VERBOSE - cout << "**Updated Developer Tab" << endl << endl; -#endif + FILE_LOG(logDEBUG) << "**Updated Developer Tab"; - qDefs::checkErrorMessage(myDet,"qTabDeveloper::Refresh"); + qDefs::checkErrorMessage(myDet, "qTabDeveloper::Refresh"); } - -//------------------------------------------------------------------------------------------------------------------------------------------------- diff --git a/slsDetectorGui/src/qTabMeasurement.cpp b/slsDetectorGui/src/qTabMeasurement.cpp old mode 100644 new mode 100755 index 2b525407f..fab4ab919 --- a/slsDetectorGui/src/qTabMeasurement.cpp +++ b/slsDetectorGui/src/qTabMeasurement.cpp @@ -1,517 +1,265 @@ -/* - * qTabMeasurement.cpp - * - * Created on: May 2, 2012 - * Author: l_maliakal_d - */ - -//Qt Project Class Headers #include "qTabMeasurement.h" #include "qDetectorMain.h" -//Project Class Headers -#include "slsDetector.h" + #include "multiSlsDetector.h" -//C++ Include Headers -#include -using namespace std; + +#include - - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -qTabMeasurement::qTabMeasurement(qDetectorMain *parent,multiSlsDetector*& detector, qDrawPlot*& plot): - thisParent(parent),myDet(detector),myPlot(plot),expertMode(false){ +qTabMeasurement::qTabMeasurement(QWidget *parent, multiSlsDetector *detector, qDrawPlot *plot) : QWidget(parent), myDet(detector), myPlot(plot) { setupUi(this); SetupWidgetWindow(); Initialization(); - SetupTimingMode(); + + // updated after slots to enable/disable widgets + GetTimingModeFromDetector(true); + + FILE_LOG(logDEBUG) << "Measurement ready"; } -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -qTabMeasurement::~qTabMeasurement(){ +qTabMeasurement::~qTabMeasurement() { delete myDet; - delete myPlot; - delete thisParent; } -//------------------------------------------------------------------------------------------------------------------------------------------------- +bool qTabMeasurement::GetStartStatus(){ + return (!btnStart->isEnabled()); +} -void qTabMeasurement::SetupWidgetWindow(){ +void qTabMeasurement::ClickStartStop(){ + startAcquisition(); + myPlot->SetClientInitiated(); +} - detType = myDet->getDetectorsType(); - //Number of measurements - spinNumMeasurements->setValue((int)myDet->setTimer(slsDetectorDefs::MEASUREMENTS_NUMBER,-1)); - //Number of frames - spinNumFrames->setValue((int)myDet->setTimer(slsDetectorDefs::FRAME_NUMBER,-1)); +int qTabMeasurement::GetProgress(){ + return progressBar->value(); +} + + +void qTabMeasurement::SetupWidgetWindow() { + + detType = myDet->getDetectorTypeAsEnum(); + + //measurements + spinNumMeasurements->setValue((int)myDet->setTimer(slsDetectorDefs::MEASUREMENTS_NUMBER, -1)); + //frames + spinNumFrames->setValue((int)myDet->setTimer(slsDetectorDefs::FRAME_NUMBER, -1)); //Exp Time qDefs::timeUnit unit; - double time = qDefs::getCorrectTime(unit,((double)(myDet->setTimer(slsDetectorDefs::ACQUISITION_TIME,-1)*(1E-9)))); + double time = qDefs::getCorrectTime(unit, ((double)(myDet->setTimer(slsDetectorDefs::ACQUISITION_TIME, -1) * (1E-9)))); spinExpTime->setValue(time); comboExpUnit->setCurrentIndex((int)unit); //period - time = qDefs::getCorrectTime(unit,((double)(myDet->setTimer(slsDetectorDefs::FRAME_PERIOD,-1)*(1E-9)))); + time = qDefs::getCorrectTime(unit, ((double)(myDet->setTimer(slsDetectorDefs::FRAME_PERIOD, -1) * (1E-9)))); spinPeriod->setValue(time); comboPeriodUnit->setCurrentIndex((int)unit); - //Number of Triggers - spinNumTriggers->setValue((int)myDet->setTimer(slsDetectorDefs::CYCLES_NUMBER,-1)); + //triggers + spinNumTriggers->setValue((int)myDet->setTimer(slsDetectorDefs::CYCLES_NUMBER, -1)); //delay if (detType == slsDetectorDefs::EIGER) { lblDelay->setEnabled(false); spinDelay->setEnabled(false); comboDelayUnit->setEnabled(false); } else { - time = qDefs::getCorrectTime(unit,((double)(myDet->setTimer(slsDetectorDefs::DELAY_AFTER_TRIGGER,-1)*(1E-9)))); + time = qDefs::getCorrectTime(unit, ((double)(myDet->setTimer(slsDetectorDefs::DELAY_AFTER_TRIGGER, -1) * (1E-9)))); spinDelay->setValue(time); comboDelayUnit->setCurrentIndex((int)unit); } - //gates - if ((detType == slsDetectorDefs::EIGER) || (detType == slsDetectorDefs::JUNGFRAU) || (detType == slsDetectorDefs::CHIPTESTBOARD)) { - lblNumGates->setEnabled(false); - spinNumGates->setEnabled(false); - } else - spinNumGates->setValue((int)myDet->setTimer(slsDetectorDefs::GATES_NUMBER,-1)); - //probes - if(detType == slsDetectorDefs::MYTHEN) - spinNumProbes->setValue((int)myDet->setTimer(slsDetectorDefs::PROBES_NUMBER,-1)); - //File Name + //samples + if (detType != slsDetectorDefs::MOENCH) { + lblNumSamples->setEnabled(false); + spinNumSamples->setEnabled(false); + } else { + spinNumSamples->setValue((int)myDet->setTimer(slsDetectorDefs::SAMPLES, -1)); + } + //file name dispFileName->setText(QString(myDet->getFileName().c_str())); - //File Index + //file write enable + chkFile->setChecked(myDet->enableWriteToFile()); + dispFileName->setEnabled(chkFile->isChecked()); + //file index spinIndex->setValue(myDet->getFileIndex()); //only initially lblProgressIndex->setText(QString::number(0)); - //ly initially progressBar->setValue(0); - //file write enabled/disabled - chkFile->setChecked(myDet->enableWriteToFile()); - dispFileName->setEnabled(myDet->enableWriteToFile()); //Timer to update the progress bar progressTimer = new QTimer(this); //Hide the error message red = QPalette(); - red.setColor(QPalette::Active,QPalette::WindowText,Qt::red); + red.setColor(QPalette::Active, QPalette::WindowText, Qt::red); acqPeriodTip = spinPeriod->toolTip(); errPeriodTip = QString("Frame period between exposures.
" - " #period#

")+ - QString("Acquisition Period should be" - " greater than or equal to Exposure Time."); + " #period#

") + + QString("Acquisition Period should be" + " greater than or equal to Exposure Time."); - qDefs::checkErrorMessage(myDet,"qTabMeasurement::SetupWidgetWindow"); + SetupTimingMode(); + // update timing mode after enabling slots to enable/disable widgets + + qDefs::checkErrorMessage(myDet, "qTabMeasurement::SetupWidgetWindow"); } -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qTabMeasurement::SetExpertMode(bool enable){ - expertMode = enable; - qDefs::checkErrorMessage(myDet,"qTabMeasurement::SetExpertMode"); - - EnableProbes(); -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qTabMeasurement::SetupTimingMode(){ +void qTabMeasurement::SetupTimingMode() { //To be able to index items on a combo box - model = qobject_cast(comboTimingMode->model()); - QModelIndex index[NumTimingModes]; - QStandardItem* item[NumTimingModes]; + model = qobject_cast(comboTimingMode->model()); + QModelIndex index[NUM_TIMING_MODES]; + QStandardItem *item[NUM_TIMING_MODES]; if (model) { - for(int i=0;iindex(i, comboTimingMode->modelColumn(), comboTimingMode->rootModelIndex()); + for (int i = 0; i < NUM_TIMING_MODES; i++) { + index[i] = model->index(i, comboTimingMode->modelColumn(), comboTimingMode->rootModelIndex()); item[i] = model->itemFromIndex(index[i]); } - //Enabling/Disabling depending on the detector type - switch(detType){ - case slsDetectorDefs::MYTHEN: - item[(int)Trigger_Exp_Series]->setEnabled(true); - item[(int)Trigger_Readout]->setEnabled(true); - item[(int)Gated]->setEnabled(true); - item[(int)Gated_Start]->setEnabled(true); - item[(int)Burst_Trigger]->setEnabled(false); - break; - case slsDetectorDefs::EIGER: - item[(int)Trigger_Exp_Series]->setEnabled(true); - item[(int)Trigger_Readout]->setEnabled(false); - item[(int)Gated]->setEnabled(true); - item[(int)Gated_Start]->setEnabled(false); - item[(int)Burst_Trigger]->setEnabled(true); - break; - case slsDetectorDefs::MOENCH: - case slsDetectorDefs::PROPIX: - case slsDetectorDefs::GOTTHARD: - case slsDetectorDefs::JUNGFRAU: - case slsDetectorDefs::CHIPTESTBOARD: - item[(int)Trigger_Exp_Series]->setEnabled(true); - item[(int)Trigger_Readout]->setEnabled(false); - item[(int)Gated]->setEnabled(false); - item[(int)Gated_Start]->setEnabled(false); - item[(int)Burst_Trigger]->setEnabled(false); - break; - default: - cout << "Unknown detector type." << endl; - qDefs::Message(qDefs::CRITICAL,"Unknown detector type.","qTabMeasurement::SetupTimingMode"); - exit(-1); - break; + + if (detType != slsDetectorDefs::EIGER) { + item[(int)GATED]->setEnabled(false); + item[(int)BURST_TRIGGER]->setEnabled(false); } } - - GetModeFromDetector(true); } -//------------------------------------------------------------------------------------------------------------------------------------------------- + +void qTabMeasurement::Initialization() { + //measurements + connect(spinNumMeasurements, SIGNAL(valueChanged(int)), this, SLOT(setNumMeasurements(int))); + //frames + connect(spinNumFrames, SIGNAL(valueChanged(int)), this, SLOT(setNumFrames(int))); + //exposure time + connect(spinExpTime, SIGNAL(valueChanged(double)), this, SLOT(setExposureTime())); + connect(comboExpUnit, SIGNAL(currentIndexChanged(int)), this, SLOT(setExposureTime())); + //frame period between exposures + connect(spinPeriod, SIGNAL(valueChanged(double)), this, SLOT(setAcquisitionPeriod())); + connect(comboPeriodUnit, SIGNAL(currentIndexChanged(int)), this, SLOT(setAcquisitionPeriod())); + //triggers + connect(spinNumTriggers, SIGNAL(valueChanged(int)), this, SLOT(setNumTriggers(int))); + //Delay After Trigger + if (spinDelay->isEnabled()) { + connect(spinDelay, SIGNAL(valueChanged(double)), this, SLOT(setDelay())); + connect(comboDelayUnit, SIGNAL(currentIndexChanged(int)), this, SLOT(setDelay())); + } + //samples + if (spinSamples->isEnabled()) + connect(spinNumSamples, SIGNAL(valueChanged(int)), this, SLOT(setNumSamples(int))); + //file name + connect(dispFileName, SIGNAL(editingFinished()), this, SLOT(setFileName())); + //file write enable + connect(chkFile, SIGNAL(toggled(bool)), this, SLOT(EnableFileWrite(bool))); + //file index + connect(spinIndex, SIGNAL(valueChanged(int)), this, SLOT(setRunIndex(int))); + //progress bar + connect(progressTimer, SIGNAL(timeout()), this, SLOT(UpdateProgress())); + //start acquisition + connect(btnStart, SIGNAL(clicked()), this, SLOT(startAcquisition())); + //stop acquisition + connect(btnStop, SIGNAL(clicked()), this, SLOT(stopAcquisition())); + //timing mode + connect(comboTimingMode, SIGNAL(currentIndexChanged(int)), this, SLOT(SetTimingMode(int))); +} -void qTabMeasurement::GetModeFromDetector(bool startup){ -#ifdef VERBOSE - cout << "Getting timing mode" << endl; -#endif + +void qTabMeasurement::GetTimingModeFromDetector(bool startup) { + FILE_LOG(logDEBUG) << "Getting timing mode"; + //Get timing mode from detector slsDetectorDefs::externalCommunicationMode mode = myDet->setExternalCommunicationMode(); + qDefs::checkErrorMessage(myDet, "qTabMeasurement::GetTimingModeFromDetector"); - //Setting the timing mode in gui - if(model && model->itemFromIndex(model->index(mode+1,comboTimingMode->modelColumn(), comboTimingMode->rootModelIndex()))->isEnabled()){ + //if the mode is enabled + if (model && model->itemFromIndex(model->index(mode, comboTimingMode->modelColumn(), comboTimingMode->rootModelIndex()))->isEnabled()) { - //these are things checked in setuptimingmode - - // to let qdrawplot know that triggers or frames are used - myPlot->setFrameEnabled(lblNumFrames->isEnabled()); - myPlot->setTriggerEnabled(lblNumTriggers->isEnabled()); - if((!startup) && (comboTimingMode->currentIndex() == (mode+1))){ - if(lblPeriod->isEnabled()) - CheckAcqPeriodGreaterThanExp(); - else{ - spinPeriod->setToolTip(acqPeriodTip); - lblPeriod->setToolTip(acqPeriodTip); - lblPeriod->setPalette(lblTimingMode->palette()); - lblPeriod->setText("Acquisition Period:"); - } - EnableProbes(); - emit CheckPlotIntervalSignal(); + // first time + if (startup) { + // explicitly call SetTimingMode first time + disconnect(comboTimingMode, SIGNAL(currentIndexChanged(int)), this, SLOT(SetTimingMode(int))); + comboTimingMode->setCurrentIndex((int)mode); + SetTimingMode((int)mode); + connect(comboTimingMode, SIGNAL(currentIndexChanged(int)), this, SLOT(SetTimingMode(int))); return; } - //if the timing mode is Auto and - // number of Frames and number of triggers is 1, - // then the timing mode is 'None'. - // This is for the inexperienced user - if(mode==slsDetectorDefs::AUTO_TIMING){ - int frames = spinNumFrames->value(); - int triggers = spinNumTriggers->value(); - int storagecells = 0; - if (detType == slsDetectorDefs::JUNGFRAU) - storagecells = myDet->setTimer(slsDetectorDefs::STORAGE_CELL_NUMBER, -1); - if((frames==1)&&(triggers==1)&&(storagecells==0)){ - comboTimingMode->setCurrentIndex((int)None); - SetTimingMode((int)None); - }else{ - comboTimingMode->setCurrentIndex((int)Auto); - SetTimingMode((int)Auto); - } - }else{ - //mode +1 since the detector class has no timingmode as "None" - comboTimingMode->setCurrentIndex((int)mode+1); - SetTimingMode((int)mode+1); + // mode is the different from current (from refresh), + if (comboTimingMode->currentIndex() != mode) { + comboTimingMode->setCurrentIndex((int)mode); } - } - // Mode NOT ENABLED. - // This should not happen -only if the server and gui has a mismatch - // on which all modes are allowed in detectors - else{ - //check if the detector is not even connected - string offline = myDet->checkOnline(); - qDefs::checkErrorMessage(myDet,"qTabMeasurement::GetModeFromDetector"); - if(!offline.empty()){ - qDefs::Message(qDefs::CRITICAL,string("The detector(s) ")+offline+string(" is/are not connected. Exiting GUI."),"Main"); - cout << "The detector(s) " << offline << " is/are not connected. Exiting GUI." << endl; + } + // Mode not enabled + else { + //check if the detector is not even connected + std::string offline = myDet->checkOnline(); + qDefs::checkErrorMessage(myDet, "qTabMeasurement::GetTimingModeFromDetector"); + if (!offline.empty()) { + qDefs::Message(qDefs::CRITICAL, std::string("The detector(s) ") + offline + std::string(" is/are not connected. Exiting GUI."), "Main"); + FILE_LOG(logERROR) << "The detector(s) " << offline << " is/are not connected. Exiting GUI."; exit(-1); } - cout << "Unknown Timing Mode " << mode << " detected from detector" << endl; - qDefs::Message(qDefs::WARNING,"Unknown Timing Mode detected from detector." - "\n\nSetting the following defaults:\nTiming Mode \t: None\n" - "Number of Frames \t: 1\nNumber of Triggers \t: 1","qTabMeasurement::GetModeFromDetector"); - comboTimingMode->setCurrentIndex((int)None); - SetTimingMode((int)None); - } - qDefs::checkErrorMessage(myDet,"qTabMeasurement::GetModeFromDetector"); - -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - - -void qTabMeasurement::Initialization(){ - //Number of Measurements - connect(spinNumMeasurements,SIGNAL(valueChanged(int)), this, SLOT(setNumMeasurements(int))); - //File Name - connect(dispFileName, SIGNAL(editingFinished()),this, SLOT(setFileName())); - //File Index - connect(spinIndex, SIGNAL(valueChanged(int)), this, SLOT(setRunIndex(int))); - //Start Acquisition - connect(btnStart, SIGNAL(clicked()), this, SLOT(startAcquisition())); - //Stop Acquisition - connect(btnStop, SIGNAL(clicked()), this, SLOT(stopAcquisition())); - //Timing Mode - connect(comboTimingMode, SIGNAL(currentIndexChanged(int)), this, SLOT(SetTimingMode(int)));// - //progress bar - connect(progressTimer, SIGNAL(timeout()), this, SLOT(UpdateProgress())); - //enable write to file - connect(chkFile, SIGNAL(toggled(bool)), this, SLOT(EnableFileWrite(bool))); - //Number of Frames - connect(spinNumFrames,SIGNAL(valueChanged(int)), this, SLOT(setNumFrames(int))); - //Exposure Time - connect(spinExpTime,SIGNAL(valueChanged(double)), this, SLOT(setExposureTime())); - connect(comboExpUnit,SIGNAL(currentIndexChanged(int)), this, SLOT(setExposureTime())); - //Frame Period between exposures - connect(spinPeriod,SIGNAL(valueChanged(double)), this, SLOT(setAcquisitionPeriod())); - connect(comboPeriodUnit,SIGNAL(currentIndexChanged(int)), this, SLOT(setAcquisitionPeriod())); - //Number of Triggers - connect(spinNumTriggers,SIGNAL(valueChanged(int)), this, SLOT(setNumTriggers(int))); - - //Delay After Trigger - if (detType != slsDetectorDefs::EIGER) { - connect(spinDelay,SIGNAL(valueChanged(double)), this, SLOT(setDelay())); - connect(comboDelayUnit,SIGNAL(currentIndexChanged(int)), this, SLOT(setDelay())); - } - - //Number of Gates - if ((detType != slsDetectorDefs::EIGER) && (detType != slsDetectorDefs::JUNGFRAU) && (detType != slsDetectorDefs::CHIPTESTBOARD)) - connect(spinNumGates,SIGNAL(valueChanged(int)), this, SLOT(setNumGates(int))); - - //Number of Probes - connect(spinNumProbes,SIGNAL(valueChanged(int)), this, SLOT(setNumProbes(int))); -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qTabMeasurement::Enable(bool enable){ - frameTimeResolved->setEnabled(enable); - frameNotTimeResolved->setEnabled(enable); - - //shortcut each time, else it doesnt work a second time - btnStart->setShortcut(QApplication::translate("TabMeasurementObject", "Shift+Space", 0, QApplication::UnicodeUTF8)); -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qTabMeasurement::startAcquisition(){ - btnStart->setEnabled(false); - //if file write enabled and output dir doesnt exist - if((chkFile->isChecked())&&(thisParent->DoesOutputDirExist() == slsDetectorDefs::FAIL)){ - if(qDefs::Message(qDefs::QUESTION, - "Your data will not be saved.
Disable File write and Proceed with acquisition anyway?", - "qTabMeasurement::startAcquisition") == slsDetectorDefs::FAIL){ - btnStart->setEnabled(true); - return; - }else{ - //done because for receiver it cant save a file with blank file path and returns without acquiring even to the gui - disconnect(chkFile, SIGNAL(toggled(bool)), this, SLOT(EnableFileWrite(bool))); - chkFile->setChecked(false); - EnableFileWrite(false); - connect(chkFile, SIGNAL(toggled(bool)), this, SLOT(EnableFileWrite(bool))); - } - } - -#ifdef VERBOSE - cout << endl << endl << "Starting Acquisition" << endl; -#endif - lblProgressIndex->setText(QString::number(0)); - Enable(0); - progressBar->setValue(0); - progressTimer->start(100); - - emit StartSignal(); - qDefs::checkErrorMessage(myDet,"qTabMeasurement::startAcquisition"); -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qTabMeasurement::stopAcquisition(){ -#ifdef VERBOSE - cout << "Stopping Acquisition" << endl<< endl; -#endif - myDet->stopAcquisition(); - qDefs::checkErrorMessage(myDet,"qTabMeasurement::stopAcquisition"); -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qTabMeasurement::UpdateFinished(){ - UpdateProgress(); - disconnect(spinIndex, SIGNAL(valueChanged(int)), this, SLOT(setRunIndex(int))); - spinIndex->setValue(myDet->getFileIndex()); - connect(spinIndex, SIGNAL(valueChanged(int)), this, SLOT(setRunIndex(int))); - progressTimer->stop(); - - Enable(1); - btnStart->setEnabled(true); - qDefs::checkErrorMessage(myDet,"qTabMeasurement::UpdateFinished"); -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qTabMeasurement::SetCurrentMeasurement(int val){ - if((val)value()) - lblCurrentMeasurement->setText(QString::number(val)); - -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qTabMeasurement::UpdateProgress(){ - progressBar->setValue((int)myPlot->GetProgress()); - lblProgressIndex->setText(QString::number(myPlot->GetFrameIndex())); - qDefs::checkErrorMessage(myDet,"qTabMeasurement::UpdateProgress"); -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qTabMeasurement::setFileName(){ - QString fName = dispFileName->text(); -#ifdef VERBOSE - cout << "Setting File name to " << fName.toAscii().constData() << endl; -#endif - myDet->setFileName(fName.toAscii().data()); - - disconnect(dispFileName, SIGNAL(editingFinished()),this, SLOT(setFileName())); - dispFileName->setText(QString(myDet->getFileName().c_str())); - connect(dispFileName, SIGNAL(editingFinished()),this, SLOT(setFileName())); - - qDefs::checkErrorMessage(myDet,"qTabMeasurement::setFileName"); -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - -void qTabMeasurement::setRunIndex(int index){ -#ifdef VERBOSE - cout << "Setting File Index to " << index << endl; -#endif - myDet->setFileIndex(index); - - disconnect(spinIndex, SIGNAL(valueChanged(int)), this, SLOT(setRunIndex(int))); - spinIndex->setValue(myDet->getFileIndex()); - connect(spinIndex, SIGNAL(valueChanged(int)), this, SLOT(setRunIndex(int))); - - qDefs::checkErrorMessage(myDet,"qTabMeasurement::setRunIndex"); -} - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qTabMeasurement::setNumMeasurements(int val){ -#ifdef VERBOSE - cout << "Setting Number of Measurements to " << val << endl; -#endif - myDet->setTimer(slsDetectorDefs::MEASUREMENTS_NUMBER,val); - - disconnect(spinNumMeasurements,SIGNAL(valueChanged(int)), this, SLOT(setNumMeasurements(int))); - spinNumMeasurements->setValue((int)myDet->setTimer(slsDetectorDefs::MEASUREMENTS_NUMBER,-1)); - connect(spinNumMeasurements,SIGNAL(valueChanged(int)), this, SLOT(setNumMeasurements(int))); - - qDefs::checkErrorMessage(myDet,"qTabMeasurement::setNumMeasurements"); -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qTabMeasurement::setNumFrames(int val){ -#ifdef VERBOSE - cout << "Setting number of frames to " << val << endl; -#endif - myDet->setTimer(slsDetectorDefs::FRAME_NUMBER,val); - - disconnect(spinNumFrames,SIGNAL(valueChanged(int)), this, SLOT(setNumFrames(int))); - spinNumFrames->setValue((int)myDet->setTimer(slsDetectorDefs::FRAME_NUMBER,-1)); - connect(spinNumFrames,SIGNAL(valueChanged(int)), this, SLOT(setNumFrames(int))); - - qDefs::checkErrorMessage(myDet,"qTabMeasurement::setNumFrames"); - - EnableProbes(); -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qTabMeasurement::CheckAcqPeriodGreaterThanExp(){ - double exptimeNS = qDefs::getNSTime((qDefs::timeUnit)comboExpUnit->currentIndex(),spinExpTime->value()); - double acqtimeNS = qDefs::getNSTime((qDefs::timeUnit)comboPeriodUnit->currentIndex(),spinPeriod->value()); - if(exptimeNS>acqtimeNS) { - spinPeriod->setToolTip(errPeriodTip); - lblPeriod->setToolTip(errPeriodTip); - lblPeriod->setPalette(red); - lblPeriod->setText("Acquisition Period:*"); - } - else { - spinPeriod->setToolTip(acqPeriodTip); - lblPeriod->setToolTip(acqPeriodTip); - lblPeriod->setPalette(lblTimingMode->palette()); - lblPeriod->setText("Acquisition Period:"); + // onlne but mismatch in timing mode + FILE_LOG(logWARNING) << "Unknown Timing Mode " << mode << " from detector"; + qDefs::Message(qDefs::WARNING, "Unknown Timing Mode from detector.\n\nSetting timing mode to Auto.", + "qTabMeasurement::GetTimingModeFromDetector"); + comboTimingMode->setCurrentIndex((int)AUTO); + SetTimingMode((int)AUTO); } } -//------------------------------------------------------------------------------------------------------------------------------------------------- +void qTabMeasurement::setNumMeasurements(int val) { + FILE_LOG(logINFO) << "Setting Number of Measurements to " << val; + + myDet->setTimer(slsDetectorDefs::MEASUREMENTS_NUMBER, val); + + disconnect(spinNumMeasurements, SIGNAL(valueChanged(int)), this, SLOT(setNumMeasurements(int))); + spinNumMeasurements->setValue((int)myDet->setTimer(slsDetectorDefs::MEASUREMENTS_NUMBER, -1)); + connect(spinNumMeasurements, SIGNAL(valueChanged(int)), this, SLOT(setNumMeasurements(int))); + + qDefs::checkErrorMessage(myDet, "qTabMeasurement::setNumMeasurements"); +} -void qTabMeasurement::setExposureTime(){ +void qTabMeasurement::setNumFrames(int val) { + FILE_LOG(logINFO) << "Setting number of frames to " << val; + + myDet->setTimer(slsDetectorDefs::FRAME_NUMBER, val); + + disconnect(spinNumFrames, SIGNAL(valueChanged(int)), this, SLOT(setNumFrames(int))); + spinNumFrames->setValue((int)myDet->setTimer(slsDetectorDefs::FRAME_NUMBER, -1)); + connect(spinNumFrames, SIGNAL(valueChanged(int)), this, SLOT(setNumFrames(int))); + + qDefs::checkErrorMessage(myDet, "qTabMeasurement::setNumFrames"); +} + + +void qTabMeasurement::setExposureTime() { //Get the value of timer in ns - double exptimeNS = qDefs::getNSTime((qDefs::timeUnit)comboExpUnit->currentIndex(),spinExpTime->value()); -#ifdef VERBOSE - cout << "Setting acquisition time to " << exptimeNS << " clocks" << "/" << spinExpTime->value() << qDefs::getUnitString((qDefs::timeUnit)comboExpUnit->currentIndex()) << endl; -#endif - myDet->setTimer(slsDetectorDefs::ACQUISITION_TIME,(int64_t)exptimeNS); - qDefs::checkErrorMessage(myDet,"qTabMeasurement::setExposureTime"); + double exptimeNS = qDefs::getNSTime((qDefs::timeUnit)comboExpUnit->currentIndex(), spinExpTime->value()); + FILE_LOG(logINFO) << "Setting acquisition time to " << exptimeNS << " ns" + << "/" << spinExpTime->value() << qDefs::getUnitString((qDefs::timeUnit)comboExpUnit->currentIndex()); - if(lblPeriod->isEnabled()) - CheckAcqPeriodGreaterThanExp(); + myDet->setTimer(slsDetectorDefs::ACQUISITION_TIME, (int64_t)exptimeNS); + qDefs::checkErrorMessage(myDet, "qTabMeasurement::setExposureTime"); + + CheckAcqPeriodGreaterThanExp(); + + //Check if the interval between plots is ok + emit CheckPlotIntervalSignal(); } -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qTabMeasurement::setAcquisitionPeriod(){ +void qTabMeasurement::setAcquisitionPeriod() { //Get the value of timer in ns - double acqtimeNS = qDefs::getNSTime((qDefs::timeUnit)comboPeriodUnit->currentIndex(),spinPeriod->value()); -#ifdef VERBOSE - cout << "Setting frame period between exposures to " << acqtimeNS << " clocks"<< "/" << spinPeriod->value() << qDefs::getUnitString((qDefs::timeUnit)comboPeriodUnit->currentIndex()) << endl; -#endif - myDet->setTimer(slsDetectorDefs::FRAME_PERIOD,(int64_t)acqtimeNS); - qDefs::checkErrorMessage(myDet,"qTabMeasurement::setAcquisitionPeriod"); + double acqtimeNS = qDefs::getNSTime((qDefs::timeUnit)comboPeriodUnit->currentIndex(), spinPeriod->value()); + FILE_LOG(logINFO) << "Setting frame period between exposures to " << acqtimeNS << " ns" + << "/" << spinPeriod->value() << qDefs::getUnitString((qDefs::timeUnit)comboPeriodUnit->currentIndex()); + + myDet->setTimer(slsDetectorDefs::FRAME_PERIOD, (int64_t)acqtimeNS); + qDefs::checkErrorMessage(myDet, "qTabMeasurement::setAcquisitionPeriod"); CheckAcqPeriodGreaterThanExp(); //Check if the interval between plots is ok @@ -519,408 +267,407 @@ void qTabMeasurement::setAcquisitionPeriod(){ } -//------------------------------------------------------------------------------------------------------------------------------------------------- +void qTabMeasurement::setNumTriggers(int val) { + FILE_LOG(logINFO) << "Setting number of triggers to " << val; + myDet->setTimer(slsDetectorDefs::CYCLES_NUMBER, val); -void qTabMeasurement::setNumTriggers(int val){ -#ifdef VERBOSE - cout << "Setting number of triggers to " << val << endl; -#endif - myDet->setTimer(slsDetectorDefs::CYCLES_NUMBER,val); + disconnect(spinNumTriggers, SIGNAL(valueChanged(int)), this, SLOT(setNumTriggers(int))); + spinNumTriggers->setValue((int)myDet->setTimer(slsDetectorDefs::CYCLES_NUMBER, -1)); + connect(spinNumTriggers, SIGNAL(valueChanged(int)), this, SLOT(setNumTriggers(int))); - disconnect(spinNumTriggers,SIGNAL(valueChanged(int)), this, SLOT(setNumTriggers(int))); - spinNumTriggers->setValue((int)myDet->setTimer(slsDetectorDefs::CYCLES_NUMBER,-1)); - connect(spinNumTriggers,SIGNAL(valueChanged(int)), this, SLOT(setNumTriggers(int))); - - qDefs::checkErrorMessage(myDet,"qTabMeasurement::setNumTriggers"); + qDefs::checkErrorMessage(myDet, "qTabMeasurement::setNumTriggers"); } -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qTabMeasurement::setDelay(){ +void qTabMeasurement::setDelay() { //Get the value of timer in ns - double exptimeNS = qDefs::getNSTime((qDefs::timeUnit)comboDelayUnit->currentIndex(),spinDelay->value()); -#ifdef VERBOSE - cout << "Setting delay after trigger to " << exptimeNS << " clocks" << "/" << spinDelay->value() << qDefs::getUnitString((qDefs::timeUnit)comboDelayUnit->currentIndex()) << endl; -#endif - myDet->setTimer(slsDetectorDefs::DELAY_AFTER_TRIGGER,(int64_t)exptimeNS); -/* - //updating value set - disconnect(spinDelay,SIGNAL(valueChanged(double)), this, SLOT(setDelay())); - disconnect(comboDelayUnit,SIGNAL(currentIndexChanged(int)), this, SLOT(setDelay())); - qDefs::timeUnit unit; - double time = qDefs::getCorrectTime(unit,((double)(myDet->setTimer(slsDetectorDefs::DELAY_AFTER_TRIGGER,-1)*(1E-9)))); - spinDelay->setValue(time); - comboDelayUnit->setCurrentIndex((int)unit); - connect(spinDelay,SIGNAL(valueChanged(double)), this, SLOT(setDelay())); - connect(comboDelayUnit,SIGNAL(currentIndexChanged(int)), this, SLOT(setDelay())); -*/ + double exptimeNS = qDefs::getNSTime((qDefs::timeUnit)comboDelayUnit->currentIndex(), spinDelay->value()); + FILE_LOG(logINFO) << "Setting delay after trigger to " << exptimeNS << " ns" + << "/" << spinDelay->value() << qDefs::getUnitString((qDefs::timeUnit)comboDelayUnit->currentIndex()); - qDefs::checkErrorMessage(myDet,"qTabMeasurement::setDelay"); + myDet->setTimer(slsDetectorDefs::DELAY_AFTER_TRIGGER, (int64_t)exptimeNS); + + qDefs::checkErrorMessage(myDet, "qTabMeasurement::setDelay"); } -//------------------------------------------------------------------------------------------------------------------------------------------------- +void qTabMeasurement::setNumSamples(int val) { + FILE_LOG(logINFO) << "Setting number of samples to " << val; + myDet->setTimer(slsDetectorDefs::SAMPLES, val); -void qTabMeasurement::setNumGates(int val){ -#ifdef VERBOSE - cout << "Setting number of gates to " << val << endl; -#endif - myDet->setTimer(slsDetectorDefs::GATES_NUMBER,val); + disconnect(spinNumSamples, SIGNAL(valueChanged(int)), this, SLOT(setNumSamples(int))); + spinNumSamples->setValue((int)myDet->setTimer(slsDetectorDefs::SAMPLES, -1)); + connect(spinNumSamples, SIGNAL(valueChanged(int)), this, SLOT(setNumSamples(int))); - disconnect(spinNumGates,SIGNAL(valueChanged(int)), this, SLOT(setNumGates(int))); - spinNumGates->setValue((int)myDet->setTimer(slsDetectorDefs::GATES_NUMBER,-1)); - connect(spinNumGates,SIGNAL(valueChanged(int)), this, SLOT(setNumGates(int))); - - qDefs::checkErrorMessage(myDet,"qTabMeasurement::setNumGates"); + qDefs::checkErrorMessage(myDet, "qTabMeasurement::setNumSamples"); } -//------------------------------------------------------------------------------------------------------------------------------------------------- +void qTabMeasurement::setFileName() { + QString fName = dispFileName->text(); + FILE_LOG(logINFO) << "Setting File name to " << fName.toAscii().constData(); + myDet->setFileName(fName.toAscii().data()); -void qTabMeasurement::setNumProbes(int val){ -#ifdef VERBOSE - cout << "Setting number of probes to " << val << endl; -#endif - disconnect(spinNumTriggers,SIGNAL(valueChanged(int)), this, SLOT(setNumTriggers(int))); - disconnect(spinNumProbes,SIGNAL(valueChanged(int)), this, SLOT(setNumProbes(int))); + disconnect(dispFileName, SIGNAL(editingFinished()), this, SLOT(setFileName())); + dispFileName->setText(QString(myDet->getFileName().c_str())); + connect(dispFileName, SIGNAL(editingFinished()), this, SLOT(setFileName())); - //set probes - int ret = myDet->setTimer(slsDetectorDefs::PROBES_NUMBER,val); - if(ret != val) - ret = myDet->setTimer(slsDetectorDefs::PROBES_NUMBER,-1); - spinNumProbes->setValue(ret); - qDefs::checkErrorMessage(myDet,"qTabMeasurement::setNumProbes"); - - - //Setting number of probes should reset number of triggers to 1, need to check if enabled, cuz its updated when refresh - if((spinNumProbes->isEnabled()) && (ret > 0) && (spinNumTriggers->value() != 1)){ - qDefs::Message(qDefs::INFORMATION,"Number of Triggers has been reset to 1.
" - "This is mandatory to use probes.","qTabMeasurement::setNumProbes"); - cout << "Resetting Number of triggers to 1" << endl; - spinNumTriggers->setValue(1); - } - qDefs::checkErrorMessage(myDet,"qTabMeasurement::setNumProbes"); - - connect(spinNumTriggers,SIGNAL(valueChanged(int)), this, SLOT(setNumTriggers(int))); - connect(spinNumProbes,SIGNAL(valueChanged(int)), this, SLOT(setNumProbes(int))); + qDefs::checkErrorMessage(myDet, "qTabMeasurement::setFileName"); } -//------------------------------------------------------------------------------------------------------------------------------------------------- +void qTabMeasurement::EnableFileWrite(bool enable) { + FILE_LOG(logINFO) << "Enable File Write:" << enable; + + myDet->enableWriteToFile(enable); + disconnect(chkFile, SIGNAL(toggled(bool)), this, SLOT(EnableFileWrite(bool))); + chkFile->setChecked(myDet->enableWriteToFile()); + connect(chkFile, SIGNAL(toggled(bool)), this, SLOT(EnableFileWrite(bool))); + + bool ret = chkFile->isChecked(); + dispFileName->setEnabled(ret); + if (ret) + setFileName(); + myPlot->SetEnableFileWrite(ret); + qDefs::checkErrorMessage(myDet, "qTabMeasurement::EnableFileWrite"); +} -void qTabMeasurement::SetTimingMode(int mode){ -#ifdef VERBOSE - cout << "Setting Timing mode to " << comboTimingMode->currentText().toAscii().data() << endl; -#endif - //Default settings - lblNumFrames->setEnabled(false); spinNumFrames->setEnabled(false); - lblExpTime->setEnabled(false); spinExpTime->setEnabled(false); comboExpUnit->setEnabled(false); - lblPeriod->setEnabled(false); spinPeriod->setEnabled(false); comboPeriodUnit->setEnabled(false); - lblNumTriggers->setEnabled(false); spinNumTriggers->setEnabled(false); - lblDelay->setEnabled(false); spinDelay->setEnabled(false); comboDelayUnit->setEnabled(false); - lblNumGates->setEnabled(false); spinNumGates->setEnabled(false); - lblNumProbes->setEnabled(false); spinNumProbes->setEnabled(false); +void qTabMeasurement::setRunIndex(int index) { + FILE_LOG(logINFO) << "Setting File Index to " << index; - bool success = false; - switch(mode){ - case None://Exposure Time - lblExpTime->setEnabled(true); spinExpTime->setEnabled(true); comboExpUnit->setEnabled(true); - spinNumTriggers->setValue(1); - spinNumFrames->setValue(1); - if (detType == slsDetectorDefs::JUNGFRAU) - myDet->setTimer(slsDetectorDefs::STORAGE_CELL_NUMBER, 0); - if(myDet->setExternalCommunicationMode(slsDetectorDefs::AUTO_TIMING)==slsDetectorDefs::AUTO_TIMING) - success = true; - break; - case Auto://#Frames, ExpTime, Period - spinNumTriggers->setValue(1); - lblNumFrames->setEnabled(true); spinNumFrames->setEnabled(true); - lblExpTime->setEnabled(true); spinExpTime->setEnabled(true); comboExpUnit->setEnabled(true); - lblPeriod->setEnabled(true); spinPeriod->setEnabled(true); comboPeriodUnit->setEnabled(true); - if(myDet->setExternalCommunicationMode(slsDetectorDefs::AUTO_TIMING)==slsDetectorDefs::AUTO_TIMING) - success = true; - break; - case Trigger_Exp_Series://#(Frames), #Triggers, ExpTime, Period, (Delay) - if(detType == slsDetectorDefs::EIGER) //only 1 frame for each trigger for eiger - spinNumFrames->setValue(1); - else{ - lblNumFrames->setEnabled(true); spinNumFrames->setEnabled(true); - lblDelay->setEnabled(true); spinDelay->setEnabled(true); comboDelayUnit->setEnabled(true); - lblPeriod->setEnabled(true); spinPeriod->setEnabled(true); comboPeriodUnit->setEnabled(true); + myDet->setFileIndex(index); + + disconnect(spinIndex, SIGNAL(valueChanged(int)), this, SLOT(setRunIndex(int))); + spinIndex->setValue(myDet->getFileIndex()); + connect(spinIndex, SIGNAL(valueChanged(int)), this, SLOT(setRunIndex(int))); + + qDefs::checkErrorMessage(myDet, "qTabMeasurement::setRunIndex"); +} + + +void qTabMeasurement::UpdateProgress() { + progressBar->setValue((int)myPlot->GetProgress()); + lblProgressIndex->setText(QString::number(myPlot->GetFrameIndex())); + qDefs::checkErrorMessage(myDet, "qTabMeasurement::UpdateProgress"); +} + + +void qTabMeasurement::startAcquisition() { + btnStart->setEnabled(false); + //if file write enabled and output dir doesnt exist + if ((chkFile->isChecked()) && (VerifyOutputDirectoryError() == slsDetectorDefs::FAIL)) { + if (qDefs::Message(qDefs::QUESTION, + "Your data will not be saved.
Disable File write and Proceed with acquisition anyway?", + "qTabMeasurement::startAcquisition") == slsDetectorDefs::FAIL) { + btnStart->setEnabled(true); + return; + } else { + //done because for receiver it cant save a file with blank file path and returns without acquiring even to the gui + disconnect(chkFile, SIGNAL(toggled(bool)), this, SLOT(EnableFileWrite(bool))); + EnableFileWrite(false); + connect(chkFile, SIGNAL(toggled(bool)), this, SLOT(EnableFileWrite(bool))); } - lblExpTime->setEnabled(true); spinExpTime->setEnabled(true); comboExpUnit->setEnabled(true); - lblNumTriggers->setEnabled(true); spinNumTriggers->setEnabled(true); - if(myDet->setExternalCommunicationMode(slsDetectorDefs::TRIGGER_EXPOSURE)==slsDetectorDefs::TRIGGER_EXPOSURE) - success = true; - break; - case Trigger_Readout://#Frames, ExpTime, Period, (Delay) - spinNumTriggers->setValue(1); - lblNumFrames->setEnabled(true); spinNumFrames->setEnabled(true); - lblExpTime->setEnabled(true); spinExpTime->setEnabled(true); comboExpUnit->setEnabled(true); - lblPeriod->setEnabled(true); spinPeriod->setEnabled(true); comboPeriodUnit->setEnabled(true); - if(myDet->setExternalCommunicationMode(slsDetectorDefs::TRIGGER_READOUT)==slsDetectorDefs::TRIGGER_READOUT) - success = true; - break; - case Gated://#Frames, #(Gates) - if(detType != slsDetectorDefs::EIGER){ - lblNumGates->setEnabled(true); spinNumGates->setEnabled(true); - } - spinNumTriggers->setValue(1); - lblNumFrames->setEnabled(true); spinNumFrames->setEnabled(true); - - - if(myDet->setExternalCommunicationMode(slsDetectorDefs::GATE_FIX_NUMBER)==slsDetectorDefs::GATE_FIX_NUMBER) - success = true; - break; - case Gated_Start://#Frames, #Triggers, #Gates, ExpTime, Period - lblNumFrames->setEnabled(true); spinNumFrames->setEnabled(true); - lblExpTime->setEnabled(true); spinExpTime->setEnabled(true); comboExpUnit->setEnabled(true); - lblPeriod->setEnabled(true); spinPeriod->setEnabled(true); comboPeriodUnit->setEnabled(true); - lblNumTriggers->setEnabled(true); spinNumTriggers->setEnabled(true); - lblNumGates->setEnabled(true); spinNumGates->setEnabled(true); - if(myDet->setExternalCommunicationMode(slsDetectorDefs::GATE_WITH_START_TRIGGER)==slsDetectorDefs::GATE_WITH_START_TRIGGER) - success = true; - break; - case Burst_Trigger://#Frames, ExpTime, Period, (Delay) - spinNumTriggers->setValue(1); - if(detType != slsDetectorDefs::EIGER){ - lblDelay->setEnabled(true); spinDelay->setEnabled(true); comboDelayUnit->setEnabled(true); - } - lblNumFrames->setEnabled(true); spinNumFrames->setEnabled(true); - lblExpTime->setEnabled(true); spinExpTime->setEnabled(true); comboExpUnit->setEnabled(true); - lblPeriod->setEnabled(true); spinPeriod->setEnabled(true); comboPeriodUnit->setEnabled(true); - if(myDet->setExternalCommunicationMode(slsDetectorDefs::BURST_TRIGGER)==slsDetectorDefs::BURST_TRIGGER) - success = true; - break; - default: - cout << "Timing mode unknown to GUI" << endl; - //This should never happen - qDefs::Message(qDefs::CRITICAL,"Timing mode unknown to GUI","qTabMeasurement::SetTimingMode"); - qDefs::checkErrorMessage(myDet,"qTabMeasurement::SetTimingMode"); - exit(-1); - } - qDefs::checkErrorMessage(myDet,"qTabMeasurement::SetTimingMode"); - if(!success){ - qDefs::Message(qDefs::WARNING,"The detector timing mode could not be set.\n" - "Please check the external flags." - "\n\nSetting the following defaults:\nTiming Mode \t: None\n" - "Number of Frames \t: 1\nNumber of Triggers \t: 1","qTabMeasurement::SetTimingMode"); - spinNumFrames->setValue(1); - spinNumTriggers->setValue(1); - if (detType == slsDetectorDefs::JUNGFRAU) - myDet->setTimer(slsDetectorDefs::STORAGE_CELL_NUMBER, 0); - comboTimingMode->setCurrentIndex((int)None); - return; } + FILE_LOG(logINFOBLUE) << "Starting Acquisition"; + lblProgressIndex->setText(QString::number(0)); + Enable(0); + progressBar->setValue(0); + progressTimer->start(100); - //Frame Period between exposures - if(lblPeriod->isEnabled()) - CheckAcqPeriodGreaterThanExp(); - else{ + emit StartSignal(); + qDefs::checkErrorMessage(myDet, "qTabMeasurement::startAcquisition"); +} + + +void qTabMeasurement::stopAcquisition() { + FILE_LOG(logINFORED) << "Stopping Acquisition"; + myDet->stopAcquisition(); + qDefs::checkErrorMessage(myDet, "qTabMeasurement::stopAcquisition"); +} + + +void qTabMeasurement::Enable(bool enable) { + frameTimeResolved->setEnabled(enable); + frameNotTimeResolved->setEnabled(enable); + + //shortcut each time, else it doesnt work a second time + btnStart->setShortcut(QApplication::translate("TabMeasurementObject", "Shift+Space", 0, QApplication::UnicodeUTF8)); +} + +int qTabMeasurement::VerifyOutputDirectoryError() { + for (int i = 0; i < myDet->getNumberOfDetectors(); i++) { + if (getModuleErrorMask(i) == FILE_PATH_DOES_NOT_EXIST) { + return slsDetectorDefs:: FAIL; + } + return slsDetectorDefs:: OK; + } +} + + +void qTabMeasurement::UpdateFinished() { + UpdateProgress(); + disconnect(spinIndex, SIGNAL(valueChanged(int)), this, SLOT(setRunIndex(int))); + spinIndex->setValue(myDet->getFileIndex()); + connect(spinIndex, SIGNAL(valueChanged(int)), this, SLOT(setRunIndex(int))); + progressTimer->stop(); + + Enable(1); + btnStart->setEnabled(true); + qDefs::checkErrorMessage(myDet, "qTabMeasurement::UpdateFinished"); +} + + +void qTabMeasurement::SetCurrentMeasurement(int val) { + if ((val) < spinNumMeasurements->value()) + lblCurrentMeasurement->setText(QString::number(val)); +} + + +void qTabMeasurement::CheckAcqPeriodGreaterThanExp() { + bool error = false; + if (lblPeriod->isEnabled()) { + double exptimeNS = qDefs::getNSTime((qDefs::timeUnit)comboExpUnit->currentIndex(), spinExpTime->value()); + double acqtimeNS = qDefs::getNSTime((qDefs::timeUnit)comboPeriodUnit->currentIndex(), spinPeriod->value()); + if (exptimeNS > acqtimeNS) { + error = true; + spinPeriod->setToolTip(errPeriodTip); + lblPeriod->setToolTip(errPeriodTip); + lblPeriod->setPalette(red); + lblPeriod->setText("Acquisition Period:*"); + } + } + + // no error or period disabled + if (!error) { spinPeriod->setToolTip(acqPeriodTip); lblPeriod->setToolTip(acqPeriodTip); lblPeriod->setPalette(lblTimingMode->palette()); lblPeriod->setText("Acquisition Period:"); } +} - //Check if Number of Probes should be enabled - EnableProbes(); +void qTabMeasurement::SetTimingMode(int mode) { + FILE_LOG(logINFO) << "Setting Timing mode to " << comboTimingMode->currentText().toAscii().data(); + + //Default settings + lblNumFrames->setEnabled(false); + spinNumFrames->setEnabled(false); + lblExpTime->setEnabled(false); + spinExpTime->setEnabled(false); + comboExpUnit->setEnabled(false); + lblPeriod->setEnabled(false); + spinPeriod->setEnabled(false); + comboPeriodUnit->setEnabled(false); + lblNumTriggers->setEnabled(false); + spinNumTriggers->setEnabled(false); + lblDelay->setEnabled(false); + spinDelay->setEnabled(false); + comboDelayUnit->setEnabled(false); + + bool success = false; + switch (mode) { + case AUTO: //#Frames, ExpTime, Period + spinNumTriggers->setValue(1); + lblNumFrames->setEnabled(true); + spinNumFrames->setEnabled(true); + lblExpTime->setEnabled(true); + spinExpTime->setEnabled(true); + comboExpUnit->setEnabled(true); + lblPeriod->setEnabled(true); + spinPeriod->setEnabled(true); + comboPeriodUnit->setEnabled(true); + if (myDet->setExternalCommunicationMode(slsDetectorDefs::AUTO_TIMING) == slsDetectorDefs::AUTO_TIMING) + success = true; + break; + case TRIGGER: // #Triggers, ExpTime, (#Frames, Period, Delay) + if (detType == slsDetectorDefs::EIGER) //only 1 frame for each trigger for eiger + spinNumFrames->setValue(1); + else { + lblNumFrames->setEnabled(true); + spinNumFrames->setEnabled(true); + lblDelay->setEnabled(true); + spinDelay->setEnabled(true); + comboDelayUnit->setEnabled(true); + lblPeriod->setEnabled(true); + spinPeriod->setEnabled(true); + comboPeriodUnit->setEnabled(true); + } + lblExpTime->setEnabled(true); + spinExpTime->setEnabled(true); + comboExpUnit->setEnabled(true); + lblNumTriggers->setEnabled(true); + spinNumTriggers->setEnabled(true); + if (myDet->setExternalCommunicationMode(slsDetectorDefs::TRIGGER_EXPOSURE) == slsDetectorDefs::TRIGGER_EXPOSURE) + success = true; + break; + + case GATED: //#Frames (Only Eiger) + + spinNumTriggers->setValue(1); + lblNumFrames->setEnabled(true); + spinNumFrames->setEnabled(true); + + if (myDet->setExternalCommunicationMode(slsDetectorDefs::GATED) == slsDetectorDefs::GATED) + success = true; + break; + + case BURST_TRIGGER: //#Frames, ExpTime, Period (Only Eiger) + spinNumTriggers->setValue(1); + + lblNumFrames->setEnabled(true); + spinNumFrames->setEnabled(true); + lblExpTime->setEnabled(true); + spinExpTime->setEnabled(true); + comboExpUnit->setEnabled(true); + lblPeriod->setEnabled(true); + spinPeriod->setEnabled(true); + comboPeriodUnit->setEnabled(true); + if (myDet->setExternalCommunicationMode(slsDetectorDefs::BURST_TRIGGER) == slsDetectorDefs::BURST_TRIGGER) + success = true; + break; + default: + FILE_LOG(logERROR) << "Timing mode unknown to GUI"; + //This should never happen + qDefs::Message(qDefs::CRITICAL, "Timing mode unknown to GUI", "qTabMeasurement::SetTimingMode"); + qDefs::checkErrorMessage(myDet, "qTabMeasurement::SetTimingMode"); + exit(-1); + } + qDefs::checkErrorMessage(myDet, "qTabMeasurement::SetTimingMode"); + if (!success) { + + if (mode != AUTO) { + qDefs::Message(qDefs::WARNING, "The detector timing mode could not be set.\n\nSetting timing mode to Auto", + "qTabMeasurement::SetTimingMode"); + comboTimingMode->setCurrentIndex((int)AUTO); + return; + } else { + // can't do anything. just ignore + qDefs::Message(qDefs::ERROR, "The detector timing mode could not be set.", "qTabMeasurement::SetTimingMode"); + } + } + + //Frame Period between exposures + CheckAcqPeriodGreaterThanExp(); // to let qdrawplot know that triggers or frames are used myPlot->setFrameEnabled(lblNumFrames->isEnabled()); myPlot->setTriggerEnabled(lblNumTriggers->isEnabled()); - qDefs::checkErrorMessage(myDet,"qTabMeasurement::SetTimingMode"); + qDefs::checkErrorMessage(myDet, "qTabMeasurement::SetTimingMode"); emit CheckPlotIntervalSignal(); - - return; } -//------------------------------------------------------------------------------------------------------------------------------------------------- +void qTabMeasurement::Refresh() { + FILE_LOG(logDEBUG) << "**Updating Measurement Tab"; + if (!myPlot->isRunning()) { -void qTabMeasurement::EnableFileWrite(bool enable){ -#ifdef VERBOSE - cout << "Enable File Write:" << enable << endl; -#endif - myDet->enableWriteToFile(enable); - dispFileName->setEnabled(enable); - if(enable) setFileName(); - myPlot->SetEnableFileWrite(enable); + //timing mode - will also check if exptime>acq period + GetTimingModeFromDetector(); - disconnect(chkFile, SIGNAL(toggled(bool)), this, SLOT(EnableFileWrite(bool))); - chkFile->setChecked(myDet->enableWriteToFile()); - connect(chkFile, SIGNAL(toggled(bool)), this, SLOT(EnableFileWrite(bool))); - - qDefs::checkErrorMessage(myDet,"qTabMeasurement::EnableFileWrite"); -}; - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qTabMeasurement::Refresh(){ -#ifdef VERBOSE - cout << endl << "**Updating Measurement Tab" << endl; -#endif - - if(!myPlot->isRunning()){ //to prevent it from recalculating forever - disconnect(spinNumMeasurements, SIGNAL(valueChanged(int)), this, SLOT(setNumMeasurements(int))); - disconnect(dispFileName, SIGNAL(editingFinished()), this, SLOT(setFileName())); - disconnect(spinIndex, SIGNAL(valueChanged(int)), this, SLOT(setRunIndex(int))); - disconnect(progressTimer, SIGNAL(timeout()), this, SLOT(UpdateProgress())); - disconnect(chkFile, SIGNAL(toggled(bool)), this, SLOT(EnableFileWrite(bool))); - disconnect(spinNumFrames, SIGNAL(valueChanged(int)), this, SLOT(setNumFrames(int))); - disconnect(spinExpTime, SIGNAL(valueChanged(double)), this, SLOT(setExposureTime())); - disconnect(comboExpUnit, SIGNAL(currentIndexChanged(int)), this, SLOT(setExposureTime())); - disconnect(spinPeriod, SIGNAL(valueChanged(double)), this, SLOT(setAcquisitionPeriod())); - disconnect(comboPeriodUnit, SIGNAL(currentIndexChanged(int)), this, SLOT(setAcquisitionPeriod())); - disconnect(spinNumTriggers, SIGNAL(valueChanged(int)), this, SLOT(setNumTriggers(int))); - if (detType != slsDetectorDefs::EIGER) { - disconnect(spinDelay, SIGNAL(valueChanged(double)), this, SLOT(setDelay())); - disconnect(comboDelayUnit, SIGNAL(currentIndexChanged(int)), this, SLOT(setDelay())); + disconnect(spinNumMeasurements, SIGNAL(valueChanged(int)), this, SLOT(setNumMeasurements(int))); + disconnect(spinNumFrames, SIGNAL(valueChanged(int)), this, SLOT(setNumFrames(int))); + disconnect(spinExpTime, SIGNAL(valueChanged(double)), this, SLOT(setExposureTime())); + disconnect(comboExpUnit, SIGNAL(currentIndexChanged(int)), this, SLOT(setExposureTime())); + disconnect(spinPeriod, SIGNAL(valueChanged(double)), this, SLOT(setAcquisitionPeriod())); + disconnect(comboPeriodUnit, SIGNAL(currentIndexChanged(int)), this, SLOT(setAcquisitionPeriod())); + disconnect(spinNumTriggers, SIGNAL(valueChanged(int)), this, SLOT(setNumTriggers(int))); + if (spinDelay->isEnabled()) { + disconnect(spinDelay, SIGNAL(valueChanged(double)), this, SLOT(setDelay())); + disconnect(comboDelayUnit, SIGNAL(currentIndexChanged(int)), this, SLOT(setDelay())); } - if ((detType != slsDetectorDefs::EIGER) && (detType != slsDetectorDefs::JUNGFRAU) && (detType != slsDetectorDefs::CHIPTESTBOARD)) - disconnect(spinNumGates, SIGNAL(valueChanged(int)), this, SLOT(setNumGates(int))); - -#ifdef VERBOSE - cout << "Getting number of measurements & frames" << endl; -#endif - //Number of measurements - spinNumMeasurements->setValue((int)myDet->setTimer(slsDetectorDefs::MEASUREMENTS_NUMBER,-1)); - //Number of frames - spinNumFrames->setValue((int)myDet->setTimer(slsDetectorDefs::FRAME_NUMBER,-1)); + if (spinSamples->isEnabled()) + disconnect(spinNumSamples, SIGNAL(valueChanged(int)), this, SLOT(setNumSamples(int))); + disconnect(dispFileName, SIGNAL(editingFinished()), this, SLOT(setFileName())); + disconnect(chkFile, SIGNAL(toggled(bool)), this, SLOT(EnableFileWrite(bool))); + disconnect(spinIndex, SIGNAL(valueChanged(int)), this, SLOT(setRunIndex(int))); + disconnect(progressTimer, SIGNAL(timeout()), this, SLOT(UpdateProgress())); -#ifdef VERBOSE - cout << "Getting Exposure time and Acquisition Period" << endl; -#endif - //Exp Time + FILE_LOG(logDEBUG) << "Getting number of measurements & frames"; + //measurements + spinNumMeasurements->setValue((int)myDet->setTimer(slsDetectorDefs::MEASUREMENTS_NUMBER, -1)); + //frames + spinNumFrames->setValue((int)myDet->setTimer(slsDetectorDefs::FRAME_NUMBER, -1)); + + FILE_LOG(logDEBUG) << "Getting Exposure time"; qDefs::timeUnit unit; - double time = qDefs::getCorrectTime(unit,((double)(myDet->setTimer(slsDetectorDefs::ACQUISITION_TIME,-1)*(1E-9)))); + //Exp Time + double oldExptimeNs = qDefs::getNSTime((qDefs::timeUnit)comboExpUnit->currentIndex(), spinExpTime->value()); + double time = qDefs::getCorrectTime(unit, ((double)(myDet->setTimer(slsDetectorDefs::ACQUISITION_TIME, -1) * (1E-9)))); spinExpTime->setValue(time); comboExpUnit->setCurrentIndex((int)unit); + double newExptimeNs = qDefs::getNSTime((qDefs::timeUnit)comboExpUnit->currentIndex(), spinExpTime->value()); + //period - time = qDefs::getCorrectTime(unit,((double)(myDet->setTimer(slsDetectorDefs::FRAME_PERIOD,-1)*(1E-9)))); + FILE_LOG(logDEBUG) << "Getting Acquisition Period"; + double oldAcqtimeNS = qDefs::getNSTime((qDefs::timeUnit)comboPeriodUnit->currentIndex(), spinPeriod->value()); + time = qDefs::getCorrectTime(unit, ((double)(myDet->setTimer(slsDetectorDefs::FRAME_PERIOD, -1) * (1E-9)))); spinPeriod->setValue(time); comboPeriodUnit->setCurrentIndex((int)unit); + double newAcqtimeNS = qDefs::getNSTime((qDefs::timeUnit)comboPeriodUnit->currentIndex(), spinPeriod->value()); + // change in period or exptime + if (newExptimeNs != oldExptimeNs || newAcqtimeNS != oldAcqtimeNS) { + //Frame Period between exposures + CheckAcqPeriodGreaterThanExp(); + + emit CheckPlotIntervalSignal(); + } + + FILE_LOG(logDEBUG) << "Getting #triggers and delay"; + //triggers + spinNumTriggers->setValue((int)myDet->setTimer(slsDetectorDefs::CYCLES_NUMBER, -1)); -#ifdef VERBOSE - cout << "Getting delay after trigger, number of triggers and number of gates" << endl; -#endif //delay - if (detType != slsDetectorDefs::EIGER) - time = qDefs::getCorrectTime(unit,((double)(myDet->setTimer(slsDetectorDefs::DELAY_AFTER_TRIGGER,-1)*(1E-9)))); + if (spinDelay->isEnabled()) + time = qDefs::getCorrectTime(unit, ((double)(myDet->setTimer(slsDetectorDefs::DELAY_AFTER_TRIGGER, -1) * (1E-9)))); - //gates - if ((detType != slsDetectorDefs::EIGER) && (detType != slsDetectorDefs::JUNGFRAU) && (detType != slsDetectorDefs::CHIPTESTBOARD) ) - spinNumGates->setValue((int)myDet->setTimer(slsDetectorDefs::GATES_NUMBER,-1)); + // samples + if (spinSamples->isEnabled()) { + spinNumSamples->setValue((int)myDet->setTimer(slsDetectorDefs::SAMPLES, -1)); + } - - //Number of Triggers - spinNumTriggers->setValue((int)myDet->setTimer(slsDetectorDefs::CYCLES_NUMBER,-1)); - -#ifdef VERBOSE - cout << "Getting file name prefix, file index, file write enable and progress index" << endl; -#endif - //File Name + FILE_LOG(logDEBUG) << "Getting file name prefix, file index, file write enable and progress index"; + //file name dispFileName->setText(QString(myDet->getFileName().c_str())); - //File Index - spinIndex->setValue(myDet->getFileIndex()); - //file write enabled/disabled + //file write enable chkFile->setChecked(myDet->enableWriteToFile()); + //file index + spinIndex->setValue(myDet->getFileIndex()); //progress label index - if(myDet->getFrameIndex()==-1) - lblProgressIndex->setText("0"); - else - lblProgressIndex->setText(QString::number(myDet->getFrameIndex())); + lblProgressIndex->setText("0"); - connect(spinNumMeasurements,SIGNAL(valueChanged(int)), this, SLOT(setNumMeasurements(int))); - connect(dispFileName, SIGNAL(editingFinished()), this, SLOT(setFileName())); - connect(spinIndex, SIGNAL(valueChanged(int)), this, SLOT(setRunIndex(int))); - connect(progressTimer, SIGNAL(timeout()), this, SLOT(UpdateProgress())); - connect(chkFile, SIGNAL(toggled(bool)), this, SLOT(EnableFileWrite(bool))); - connect(spinNumFrames, SIGNAL(valueChanged(int)), this, SLOT(setNumFrames(int))); - connect(spinExpTime, SIGNAL(valueChanged(double)), this, SLOT(setExposureTime())); - connect(comboExpUnit, SIGNAL(currentIndexChanged(int)), this, SLOT(setExposureTime())); - connect(spinPeriod, SIGNAL(valueChanged(double)), this, SLOT(setAcquisitionPeriod())); - connect(comboPeriodUnit, SIGNAL(currentIndexChanged(int)), this, SLOT(setAcquisitionPeriod())); - connect(spinNumTriggers, SIGNAL(valueChanged(int)), this, SLOT(setNumTriggers(int))); - if (detType != slsDetectorDefs::EIGER) { - connect(spinDelay, SIGNAL(valueChanged(double)), this, SLOT(setDelay())); - connect(comboDelayUnit, SIGNAL(currentIndexChanged(int)), this, SLOT(setDelay())); + connect(spinNumMeasurements, SIGNAL(valueChanged(int)), this, SLOT(setNumMeasurements(int))); + connect(spinNumFrames, SIGNAL(valueChanged(int)), this, SLOT(setNumFrames(int))); + connect(spinExpTime, SIGNAL(valueChanged(double)), this, SLOT(setExposureTime())); + connect(comboExpUnit, SIGNAL(currentIndexChanged(int)), this, SLOT(setExposureTime())); + connect(spinPeriod, SIGNAL(valueChanged(double)), this, SLOT(setAcquisitionPeriod())); + connect(comboPeriodUnit, SIGNAL(currentIndexChanged(int)), this, SLOT(setAcquisitionPeriod())); + connect(spinNumTriggers, SIGNAL(valueChanged(int)), this, SLOT(setNumTriggers(int))); + if (spinDelay->isEnabled()) { + connect(spinDelay, SIGNAL(valueChanged(double)), this, SLOT(setDelay())); + connect(comboDelayUnit, SIGNAL(currentIndexChanged(int)), this, SLOT(setDelay())); } - if ((detType != slsDetectorDefs::EIGER) && (detType != slsDetectorDefs::JUNGFRAU) && (detType != slsDetectorDefs::CHIPTESTBOARD)) - connect(spinNumGates, SIGNAL(valueChanged(int)), this, SLOT(setNumGates(int))); + if (spinSamples->isEnabled()) + connect(spinNumSamples, SIGNAL(valueChanged(int)), this, SLOT(setNumSamples(int))); + disconnect(dispFileName, SIGNAL(editingFinished()), this, SLOT(setFileName())); + connect(chkFile, SIGNAL(toggled(bool)), this, SLOT(EnableFileWrite(bool))); + connect(spinIndex, SIGNAL(valueChanged(int)), this, SLOT(setRunIndex(int))); + connect(progressTimer, SIGNAL(timeout()), this, SLOT(UpdateProgress())); - //timing mode - will also check if exptime>acq period and also enableprobes() - GetModeFromDetector(); - - // to let qdrawplot know that triggers or frames are used - myPlot->setFrameEnabled(lblNumFrames->isEnabled()); - myPlot->setTriggerEnabled(lblNumTriggers->isEnabled()); - - qDefs::checkErrorMessage(myDet,"qTabMeasurement::Refresh"); + qDefs::checkErrorMessage(myDet, "qTabMeasurement::Refresh"); } -#ifdef VERBOSE - cout << "**Updated Measurement Tab" << endl << endl; -#endif + FILE_LOG(logDEBUG) << "**Updated Measurement Tab"; } - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qTabMeasurement::EnableProbes(){ - - //disconnect(spinNumProbes,SIGNAL(valueChanged(int)), this, SLOT(setNumProbes(int))); - disconnect(spinNumTriggers,SIGNAL(valueChanged(int)), this, SLOT(setNumTriggers(int))); - - - //enabled only in expert mode and if #Frames > 1 - if((expertMode)&&(detType==slsDetectorDefs::MYTHEN)&&(spinNumFrames->value()>1)){ - lblNumProbes->setEnabled(true); - spinNumProbes->setEnabled(true); - spinNumProbes->setValue((int)myDet->setTimer(slsDetectorDefs::PROBES_NUMBER,-1)); -#ifdef VERBOSE - cout << "Getting number of probes : " << spinNumProbes->value() << endl; -#endif - - //Setting number of probes should reset number of triggers to 1, need to check if enabled, cuz its updated when refresh - if((spinNumProbes->isEnabled()) && (spinNumProbes->value() > 0) && (spinNumTriggers->value() != 1)){ - qDefs::Message(qDefs::INFORMATION,"Number of Triggers has been reset to 1.
" - "This is mandatory to use probes.","qTabMeasurement::EnableProbes"); - cout << "Resetting Number of triggers to 1" << endl; - spinNumTriggers->setValue(1); - } - qDefs::checkErrorMessage(myDet,"qTabMeasurement::EnableProbes"); - - connect(spinNumProbes, SIGNAL(valueChanged(int)), this, SLOT(setNumProbes(int))); - connect(spinNumTriggers, SIGNAL(valueChanged(int)), this, SLOT(setNumTriggers(int))); - return; - } - cout << "Probes not enabled" << endl; - if(detType==slsDetectorDefs::MYTHEN) - spinNumProbes->setValue(0); - lblNumProbes->setEnabled(false); - spinNumProbes->setEnabled(false); - - //connect(spinNumProbes,SIGNAL(valueChanged(int)), this, SLOT(setNumProbes(int))); - connect(spinNumTriggers,SIGNAL(valueChanged(int)), this, SLOT(setNumTriggers(int))); -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- diff --git a/slsDetectorGui/src/qTabMessages.cpp b/slsDetectorGui/src/qTabMessages.cpp old mode 100644 new mode 100755 index 460351164..c350c1e37 --- a/slsDetectorGui/src/qTabMessages.cpp +++ b/slsDetectorGui/src/qTabMessages.cpp @@ -1,122 +1,95 @@ -/* - * qTabMessages.cpp - * - * Created on: Jun 26, 2012 - * Author: l_maliakal_d - */ - -/** Qt Project Class Headers */ #include "qTabMessages.h" #include "qDetectorMain.h" -/** Project Class Headers */ -/** Qt Include Headers */ -#include + #include -#include #include +#include +#include - -/** C++ Include Headers */ #include #include -using namespace std; -//------------------------------------------------------------------------------------------------------------------------------------------------- -qTabMessages::qTabMessages(qDetectorMain* m):myMainTab(m),qout(0),qerr(0){ - SetupWidgetWindow(); - Initialization(); +qTabMessages::qTabMessages(QWidget *parent) : QWidget(parent) { + SetupWidgetWindow(); + Initialization(); + FILE_LOG(logDEBUG) << "Messages ready"; } -//------------------------------------------------------------------------------------------------------------------------------------------------- -qTabMessages::~qTabMessages(){ - delete myMainTab; - delete dispLog; - delete qout; - delete qerr; +qTabMessages::~qTabMessages() { + delete dispLog; } -//------------------------------------------------------------------------------------------------------------------------------------------------- -void qTabMessages::SetupWidgetWindow(){ - /** Layout */ - QGridLayout *gridLayout = new QGridLayout(this); +void qTabMessages::SetupWidgetWindow() { + /** Layout */ + QGridLayout *gridLayout = new QGridLayout(this); - dispLog = new QTextEdit(this); - dispLog->setReadOnly(true); - dispLog->setFocusPolicy(Qt::NoFocus); - dispLog->setTextColor(Qt::darkBlue); + dispLog = new QTextEdit(this); + dispLog->setReadOnly(true); + dispLog->setFocusPolicy(Qt::NoFocus); + dispLog->setTextColor(Qt::darkBlue); + btnSave = new QPushButton("Save Log ", this); + btnSave->setFocusPolicy(Qt::NoFocus); + btnSave->setFixedWidth(100); + btnSave->setIcon(QIcon(":/icons/images/save.png")); - btnSave = new QPushButton("Save Log ",this); - btnSave->setFocusPolicy(Qt::NoFocus); - btnSave->setFixedWidth(100); - btnSave->setIcon(QIcon( ":/icons/images/save.png" )); + btnClear = new QPushButton("Clear ", this); + btnClear->setFocusPolicy(Qt::NoFocus); + btnClear->setFixedWidth(100); + btnClear->setIcon(QIcon(":/icons/images/erase.png")); - btnClear = new QPushButton("Clear ",this); - btnClear->setFocusPolicy(Qt::NoFocus); - btnClear->setFixedWidth(100); - btnClear->setIcon(QIcon( ":/icons/images/erase.png" )); - - gridLayout->addItem(new QSpacerItem(15,10,QSizePolicy::Fixed,QSizePolicy::Fixed),0,0); - gridLayout->addWidget(btnSave,1,0,1,1); - gridLayout->addWidget(btnClear,1,4,1,1); - gridLayout->addItem(new QSpacerItem(15,10,QSizePolicy::Fixed,QSizePolicy::Fixed),2,0); - gridLayout->addWidget(dispLog,3,0,1,5); - - errMsg = " Please check Messages Tab. Following message was caught:

"; - qout=new qDebugStream(std::cout,this); - qerr=new qDebugStream(std::cerr,this); + gridLayout->addItem(new QSpacerItem(15, 10, QSizePolicy::Fixed, QSizePolicy::Fixed), 0, 0); + gridLayout->addWidget(btnSave, 1, 0, 1, 1); + gridLayout->addWidget(btnClear, 1, 4, 1, 1); + gridLayout->addItem(new QSpacerItem(15, 10, QSizePolicy::Fixed, QSizePolicy::Fixed), 2, 0); + gridLayout->addWidget(dispLog, 3, 0, 1, 5); + qDebugStream *qout = new qDebugStream(std::cout, this); + qDebugStream *qerr = new qDebugStream(std::cerr, this); } -//------------------------------------------------------------------------------------------------------------------------------------------------- -void qTabMessages::Initialization(){ - connect(btnSave,SIGNAL(clicked()),this,SLOT(SaveLog())); - connect(btnClear,SIGNAL(clicked()),this,SLOT(ClearLog())); +void qTabMessages::Initialization() { + connect(btnSave, SIGNAL(clicked()), this, SLOT(SaveLog())); + connect(btnClear, SIGNAL(clicked()), this, SLOT(ClearLog())); } -//------------------------------------------------------------------------------------------------------------------------------------------------- void qTabMessages::customEvent(QEvent *e) { - if (e->type() == (STREAMEVENT)){ - QString temp = ((qStreamEvent*)e)->getString(); - dispLog->append(temp); - } - + if (e->type() == (STREAMEVENT)) { + QString temp = ((qStreamEvent *)e)->getString(); + dispLog->append(temp); + } } -//------------------------------------------------------------------------------------------------------------------------------------------------- void qTabMessages::SaveLog() { - QString fName = QString(myMainTab->GetFilePath()); - fName = fName+"/LogFile.txt"; - fName = QFileDialog::getSaveFileName(this,tr("Save Snapshot "), - fName,tr("Text files (*.txt);;All Files(*)")); - if (!fName.isEmpty()){ - QFile outfile; - outfile.setFileName(fName); - if(outfile.open(QIODevice::WriteOnly | QIODevice::Text)){//Append - QTextStream out(&outfile); - out<toPlainText() << endl; - qDefs::Message(qDefs::INFORMATION,string("The Log has been successfully saved to " - "")+fName.toAscii().constData(),"qTabMessages::SaveLog"); - } - else qDefs::Message(qDefs::WARNING,"Attempt to save log file failed.","qTabMessages::SaveLog"); - } + QString fName = QString(""); //FIXME:current directory? + fName = fName + "/LogFile.txt"; + fName = QFileDialog::getSaveFileName(this, tr("Save Snapshot "), + fName, tr("Text files (*.txt);;All Files(*)")); + if (!fName.isEmpty()) { + QFile outfile; + outfile.setFileName(fName); + if (outfile.open(QIODevice::WriteOnly | QIODevice::Text)) { //Append + QTextStream out(&outfile); + out << dispLog->toPlainText() << endl; + qDefs::Message(qDefs::INFORMATION, std::string("The Log has been successfully saved to " + "") + + fName.toAscii().constData(), + "qTabMessages::SaveLog"); + } else { + FILE_LOG(logWARNING) << "Attempt to save log file failed."; + qDefs::Message(qDefs::WARNING, "Attempt to save log file failed.", "qTabMessages::SaveLog"); + } + } } -//------------------------------------------------------------------------------------------------------------------------------------------------- - void qTabMessages::ClearLog() { - dispLog->clear(); -#ifdef VERBOSE - cout<<"Log Cleared"<clear(); + FILE_LOG(logINFO) << "Log Cleared"; } - - -//------------------------------------------------------------------------------------------------------------------------------------------------- diff --git a/slsDetectorGui/src/qTabPlot.cpp b/slsDetectorGui/src/qTabPlot.cpp old mode 100644 new mode 100755 index e42c117d6..41c051d85 --- a/slsDetectorGui/src/qTabPlot.cpp +++ b/slsDetectorGui/src/qTabPlot.cpp @@ -1,26 +1,17 @@ -/* - * qTabPlot.cpp - * - * Created on: May 10, 2012 - * Author: l_maliakal_d - */ - #include "qTabPlot.h" #include "qDrawPlot.h" // Project Class Headers -#include "slsDetector.h" #include "multiSlsDetector.h" // Qt Include Headers #include // C++ Include Headers #include -#include #include -using namespace std; +#include //------------------------------------------------------------------------------------------------------------------------------------------------- -const QString qTabPlot::modeNames[5]={"None","Energy Scan","Threshold Scan","Trimbits Scan","Custom Script Scan"}; +// const QString qTabPlot::modeNames[5] = {"None", "Energy Scan", "Threshold Scan", "Trimbits Scan", "Custom Script Scan"}; QString qTabPlot::defaultPlotTitle(""); QString qTabPlot::defaultHistXAxisTitle("Channel Number"); @@ -29,1514 +20,1434 @@ QString qTabPlot::defaultImageXAxisTitle("Pixel"); QString qTabPlot::defaultImageYAxisTitle("Pixel"); QString qTabPlot::defaultImageZAxisTitle("Intensity"); - //------------------------------------------------------------------------------------------------------------------------------------------------- - -qTabPlot::qTabPlot(QWidget *parent,multiSlsDetector*& detector, qDrawPlot*& plot): - QWidget(parent), - myDet(detector), - myPlot(plot), - isOneD(false), - isOriginallyOneD(false), - wrongInterval(0), - stackedLayout(0), - spinNthFrame(0), - spinTimeGap(0), - comboTimeGapUnit(0), - btnGroupScan(0), - btnGroupPlotType(0), - btnGroupHistogram(0){ - setupUi(this); - SetupWidgetWindow(); - Initialization(); +qTabPlot::qTabPlot(QWidget *parent, multiSlsDetector *detector, qDrawPlot *plot) : QWidget(parent), + myDet(detector), + myPlot(plot), + isOneD(false), + isOriginallyOneD(false), + wrongInterval(0), + stackedLayout(0), + spinNthFrame(0), + spinTimeGap(0), + comboTimeGapUnit(0), + btnGroupScan(0), + btnGroupPlotType(0), + btnGroupHistogram(0) { + setupUi(this); + SetupWidgetWindow(); + Initialization(); + FILE_LOG(logDEBUG) << "Plot ready"; } - //------------------------------------------------------------------------------------------------------------------------------------------------- - -qTabPlot::~qTabPlot(){ - delete myDet; - delete myPlot; +qTabPlot::~qTabPlot() { + delete myDet; + delete myPlot; } - //------------------------------------------------------------------------------------------------------------------------------------------------- +void qTabPlot::SetupWidgetWindow() { + //error for interval between plots + red = new QPalette(); + ; + red->setColor(QPalette::Active, QPalette::WindowText, Qt::red); + intervalTip = boxFrequency->toolTip(); -void qTabPlot::SetupWidgetWindow(){ - //error for interval between plots - red = new QPalette();; - red->setColor(QPalette::Active,QPalette::WindowText,Qt::red); - intervalTip = boxFrequency->toolTip(); + //scan arguments + btnGroupScan = new QButtonGroup(this); + btnGroupScan->addButton(radioLevel0, 0); + btnGroupScan->addButton(radioLevel1, 1); + btnGroupScan->addButton(radioFileIndex, 2); + btnGroupScan->addButton(radioAllFrames, 3); + //plot type + btnGroupPlotType = new QButtonGroup(this); + btnGroupPlotType->addButton(radioNoPlot, 0); + btnGroupPlotType->addButton(radioDataGraph, 1); + btnGroupPlotType->addButton(radioHistogram, 2); -//scan arguments - btnGroupScan = new QButtonGroup(this); - btnGroupScan->addButton(radioLevel0,0); - btnGroupScan->addButton(radioLevel1,1); - btnGroupScan->addButton(radioFileIndex,2); - btnGroupScan->addButton(radioAllFrames,3); + //histogram arguments + btnGroupHistogram = new QButtonGroup(this); + btnGroupHistogram->addButton(radioHistIntensity, 0); + btnGroupHistogram->addButton(radioHistLevel0, 1); + btnGroupHistogram->addButton(radioHistLevel1, 2); -//plot type - btnGroupPlotType = new QButtonGroup(this); - btnGroupPlotType->addButton(radioNoPlot,0); - btnGroupPlotType->addButton(radioDataGraph,1); - btnGroupPlotType->addButton(radioHistogram,2); + // Plot Axis + dispTitle->setEnabled(false); + dispXAxis->setEnabled(false); + dispYAxis->setEnabled(false); + dispZAxis->setEnabled(false); + dispXMin->setEnabled(false); + dispYMin->setEnabled(false); + dispZMin->setEnabled(false); + dispXMax->setEnabled(false); + dispYMax->setEnabled(false); + dispZMax->setEnabled(false); + dispXMin->setValidator(new QDoubleValidator(dispXMin)); + dispYMin->setValidator(new QDoubleValidator(dispYMin)); + dispZMin->setValidator(new QDoubleValidator(dispZMin)); + dispXMax->setValidator(new QDoubleValidator(dispXMax)); + dispYMax->setValidator(new QDoubleValidator(dispYMax)); + dispZMax->setValidator(new QDoubleValidator(dispZMax)); -//histogram arguments - btnGroupHistogram = new QButtonGroup(this); - btnGroupHistogram->addButton(radioHistIntensity,0); - btnGroupHistogram->addButton(radioHistLevel0,1); - btnGroupHistogram->addButton(radioHistLevel1,2); + //default titles + dispTitle->setText(""); + myPlot->SetPlotTitlePrefix(""); + dispXAxis->setText(defaultHistXAxisTitle); + dispYAxis->setText(defaultHistYAxisTitle); + myPlot->SetHistXAxisTitle(defaultHistXAxisTitle); + myPlot->SetHistYAxisTitle(defaultHistYAxisTitle); + dispXAxis->setText(defaultImageXAxisTitle); + dispYAxis->setText(defaultImageYAxisTitle); + dispZAxis->setText(defaultImageZAxisTitle); + myPlot->SetImageXAxisTitle(defaultImageXAxisTitle); + myPlot->SetImageYAxisTitle(defaultImageYAxisTitle); + myPlot->SetImageZAxisTitle(defaultImageZAxisTitle); -// Plot Axis - dispTitle->setEnabled(false); - dispXAxis->setEnabled(false); - dispYAxis->setEnabled(false); - dispZAxis->setEnabled(false); - dispXMin->setEnabled(false); - dispYMin->setEnabled(false); - dispZMin->setEnabled(false); - dispXMax->setEnabled(false); - dispYMax->setEnabled(false); - dispZMax->setEnabled(false); - dispXMin->setValidator(new QDoubleValidator(dispXMin)); - dispYMin->setValidator(new QDoubleValidator(dispYMin)); - dispZMin->setValidator(new QDoubleValidator(dispZMin)); - dispXMax->setValidator(new QDoubleValidator(dispXMax)); - dispYMax->setValidator(new QDoubleValidator(dispYMax)); - dispZMax->setValidator(new QDoubleValidator(dispZMax)); + // Plotting Frequency - //default titles - dispTitle->setText(""); - myPlot->SetPlotTitlePrefix(""); - dispXAxis->setText(defaultHistXAxisTitle); - dispYAxis->setText(defaultHistYAxisTitle); - myPlot->SetHistXAxisTitle(defaultHistXAxisTitle); - myPlot->SetHistYAxisTitle(defaultHistYAxisTitle); - dispXAxis->setText(defaultImageXAxisTitle); - dispYAxis->setText(defaultImageYAxisTitle); - dispZAxis->setText(defaultImageZAxisTitle); - myPlot->SetImageXAxisTitle(defaultImageXAxisTitle); - myPlot->SetImageYAxisTitle(defaultImageYAxisTitle); - myPlot->SetImageZAxisTitle(defaultImageZAxisTitle); + stackedLayout = new QStackedLayout; + stackedLayout->setSpacing(0); + spinNthFrame = new QSpinBox; + spinNthFrame->setMinimum(1); + spinNthFrame->setMaximum(2000000000); + spinTimeGap = new QDoubleSpinBox; + spinTimeGap->setMinimum(0); + spinTimeGap->setDecimals(3); + spinTimeGap->setMaximum(999999); + spinTimeGap->setValue(myPlot->GetMinimumPlotTimer()); + comboTimeGapUnit = new QComboBox; + comboTimeGapUnit->addItem("hr"); + comboTimeGapUnit->addItem("min"); + comboTimeGapUnit->addItem("s"); + comboTimeGapUnit->addItem("ms"); + comboTimeGapUnit->setCurrentIndex(3); + QWidget *w = new QWidget; + QHBoxLayout *h1 = new QHBoxLayout; + w->setLayout(h1); + h1->setContentsMargins(0, 0, 0, 0); + h1->setSpacing(3); + h1->addWidget(spinTimeGap); + h1->addWidget(comboTimeGapUnit); - // Plotting Frequency + stackedLayout->addWidget(w); + stackedLayout->addWidget(spinNthFrame); + stackWidget->setLayout(stackedLayout); - stackedLayout = new QStackedLayout; - stackedLayout->setSpacing(0); - spinNthFrame = new QSpinBox; - spinNthFrame->setMinimum(1); - spinNthFrame->setMaximum(2000000000); - spinTimeGap = new QDoubleSpinBox; - spinTimeGap->setMinimum(0); - spinTimeGap->setDecimals(3); - spinTimeGap->setMaximum(999999); - spinTimeGap->setValue(myPlot->GetMinimumPlotTimer()); - comboTimeGapUnit = new QComboBox; - comboTimeGapUnit->addItem("hr"); - comboTimeGapUnit->addItem("min"); - comboTimeGapUnit->addItem("s"); - comboTimeGapUnit->addItem("ms"); - comboTimeGapUnit->setCurrentIndex(3); - QWidget *w = new QWidget; - QHBoxLayout *h1 = new QHBoxLayout; - w->setLayout(h1); - h1->setContentsMargins(0,0,0,0); - h1->setSpacing(3); - h1->addWidget(spinTimeGap); - h1->addWidget(comboTimeGapUnit); + stackedWidget->setCurrentIndex(0); + stackedWidget_2->setCurrentIndex(0); - stackedLayout->addWidget(w); - stackedLayout->addWidget(spinNthFrame); - stackWidget->setLayout(stackedLayout); + // Depending on whether the detector is 1d or 2d + switch (myDet->getDetectorTypeAsEnum()) { + case slsDetectorDefs::EIGER: + isOriginallyOneD = false; + pagePedestal->setEnabled(false); + pagePedestal_2->setEnabled(false); + chkBinary->setEnabled(false); + chkBinary_2->setEnabled(false); + chkGapPixels->setEnabled(true); + break; + case slsDetectorDefs::GOTTHARD: + isOriginallyOneD = true; + break; + case slsDetectorDefs::JUNGFRAU: + case slsDetectorDefs::MOENCH: + isOriginallyOneD = false; + chkGainPlot->setEnabled(true); + break; + default: + cout << "ERROR: Detector Type is Generic" << endl; + exit(-1); + } - stackedWidget->setCurrentIndex(0); - stackedWidget_2->setCurrentIndex(0); + Select1DPlot(isOriginallyOneD); - // Depending on whether the detector is 1d or 2d - switch(myDet->getDetectorsType()){ - case slsDetectorDefs::MYTHEN: - isOriginallyOneD = true; - pagePedestal->setEnabled(false); - pagePedestal_2->setEnabled(false); - chkBinary->setEnabled(false); - chkBinary_2->setEnabled(false); - break; - case slsDetectorDefs::EIGER: - isOriginallyOneD = false; - pagePedestal->setEnabled(false); - pagePedestal_2->setEnabled(false); - chkBinary->setEnabled(false); - chkBinary_2->setEnabled(false); - chkGapPixels->setEnabled(true); - break; - case slsDetectorDefs::GOTTHARD: - isOriginallyOneD = true; - break; - case slsDetectorDefs::PROPIX: - isOriginallyOneD = false; - break; - case slsDetectorDefs::MOENCH: - isOriginallyOneD = false; - break; - case slsDetectorDefs::JUNGFRAU: - case slsDetectorDefs::CHIPTESTBOARD: - isOriginallyOneD = false; - chkGainPlot->setEnabled(true); - break; - default: - cout << "ERROR: Detector Type is Generic" << endl; - exit(-1); - } + //to check if this should be enabled + // EnableScanBox(); - Select1DPlot(isOriginallyOneD); - - //to check if this should be enabled - EnableScanBox(); - - //disable histogram initially - boxHistogram->hide(); + //disable histogram initially + boxHistogram->hide(); if (chkGapPixels->isEnabled()) { - int ret = myDet->enableGapPixels(-1); - qDefs::checkErrorMessage(myDet,"qTabPlot::SetupWidgetWindow"); + int ret = myDet->enableGapPixels(-1); + qDefs::checkErrorMessage(myDet, "qTabPlot::SetupWidgetWindow"); chkGapPixels->setChecked((ret == 1) ? true : false); } - qDefs::checkErrorMessage(myDet,"qTabPlot::SetupWidgetWindow"); -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qTabPlot::SetPlotOptionsRightPage(){ - if(isOneD){ - int i = stackedWidget->currentIndex(); - if(i == (stackedWidget->count()-1)) - stackedWidget->setCurrentIndex(0); - else - stackedWidget->setCurrentIndex(i+1); - box1D->setTitle(QString("1D Plot Options %1").arg(stackedWidget->currentIndex()+1)); - } - else{ - int i = stackedWidget_2->currentIndex(); - if(i == (stackedWidget_2->count()-1)) - stackedWidget_2->setCurrentIndex(0); - else - stackedWidget_2->setCurrentIndex(i+1); - box2D->setTitle(QString("2D Plot Options %1").arg(stackedWidget_2->currentIndex()+1)); - } + qDefs::checkErrorMessage(myDet, "qTabPlot::SetupWidgetWindow"); } //------------------------------------------------------------------------------------------------------------------------------------------------- - -void qTabPlot::SetPlotOptionsLeftPage(){ - if(isOneD){ - int i = stackedWidget->currentIndex(); - if(i == 0) - stackedWidget->setCurrentIndex(stackedWidget->count()-1); - else - stackedWidget->setCurrentIndex(i-1); - box1D->setTitle(QString("1D Plot Options %1").arg(stackedWidget->currentIndex()+1)); - } - else{ - int i = stackedWidget_2->currentIndex(); - if(i == 0) - stackedWidget_2->setCurrentIndex(stackedWidget_2->count()-1); - else - stackedWidget_2->setCurrentIndex(i-1); - box2D->setTitle(QString("2D Plot Options %1").arg(stackedWidget_2->currentIndex()+1)); - } +void qTabPlot::SetPlotOptionsRightPage() { + if (isOneD) { + int i = stackedWidget->currentIndex(); + if (i == (stackedWidget->count() - 1)) + stackedWidget->setCurrentIndex(0); + else + stackedWidget->setCurrentIndex(i + 1); + box1D->setTitle(QString("1D Plot Options %1").arg(stackedWidget->currentIndex() + 1)); + } else { + int i = stackedWidget_2->currentIndex(); + if (i == (stackedWidget_2->count() - 1)) + stackedWidget_2->setCurrentIndex(0); + else + stackedWidget_2->setCurrentIndex(i + 1); + box2D->setTitle(QString("2D Plot Options %1").arg(stackedWidget_2->currentIndex() + 1)); + } } - //------------------------------------------------------------------------------------------------------------------------------------------------- +void qTabPlot::SetPlotOptionsLeftPage() { + if (isOneD) { + int i = stackedWidget->currentIndex(); + if (i == 0) + stackedWidget->setCurrentIndex(stackedWidget->count() - 1); + else + stackedWidget->setCurrentIndex(i - 1); + box1D->setTitle(QString("1D Plot Options %1").arg(stackedWidget->currentIndex() + 1)); + } else { + int i = stackedWidget_2->currentIndex(); + if (i == 0) + stackedWidget_2->setCurrentIndex(stackedWidget_2->count() - 1); + else + stackedWidget_2->setCurrentIndex(i - 1); + box2D->setTitle(QString("2D Plot Options %1").arg(stackedWidget_2->currentIndex() + 1)); + } +} -void qTabPlot::Select1DPlot(bool b){ +//------------------------------------------------------------------------------------------------------------------------------------------------- + +void qTabPlot::Select1DPlot(bool b) { #ifdef VERBOSE - if(b) - cout << "Selecting 1D Plot" << endl; - else - cout << "Selecting 2D Plot" << endl; + if (b) + cout << "Selecting 1D Plot" << endl; + else + cout << "Selecting 2D Plot" << endl; #endif - isOneD = b; - lblFrom->setEnabled(false); - lblTo->setEnabled(false); - lblFrom_2->setEnabled(false); - lblTo_2->setEnabled(false); - spinFrom->setEnabled(false); - spinFrom_2->setEnabled(false); - spinTo->setEnabled(false); - spinTo_2->setEnabled(false); - if(b){ - box1D->show(); - box2D->hide(); - chkZAxis->setEnabled(false); - chkZMin->setEnabled(false); - chkZMax->setEnabled(false); - myPlot->Select1DPlot(); - }else{ - box1D->hide(); - box2D->show(); - chkZAxis->setEnabled(true); - chkZMin->setEnabled(true); - chkZMax->setEnabled(true); - myPlot->Select2DPlot(); - } + isOneD = b; + lblFrom->setEnabled(false); + lblTo->setEnabled(false); + lblFrom_2->setEnabled(false); + lblTo_2->setEnabled(false); + spinFrom->setEnabled(false); + spinFrom_2->setEnabled(false); + spinTo->setEnabled(false); + spinTo_2->setEnabled(false); + if (b) { + box1D->show(); + box2D->hide(); + chkZAxis->setEnabled(false); + chkZMin->setEnabled(false); + chkZMax->setEnabled(false); + myPlot->Select1DPlot(); + } else { + box1D->hide(); + box2D->show(); + chkZAxis->setEnabled(true); + chkZMin->setEnabled(true); + chkZMax->setEnabled(true); + myPlot->Select2DPlot(); + } } - //------------------------------------------------------------------------------------------------------------------------------------------------- +void qTabPlot::Initialization() { + // Plot arguments box + connect(btnGroupPlotType, SIGNAL(buttonClicked(int)), this, SLOT(SetPlot())); + // Histogram arguments box + connect(btnGroupHistogram, SIGNAL(buttonClicked(int)), this, SLOT(SetHistogramOptions())); + // Scan box + // connect(boxScan, SIGNAL(toggled(bool)), this, SLOT(EnableScanBox())); + // Snapshot box + connect(btnClone, SIGNAL(clicked()), myPlot, SLOT(ClonePlot())); + connect(btnCloseClones, SIGNAL(clicked()), myPlot, SLOT(CloseClones())); + connect(btnSaveClones, SIGNAL(clicked()), myPlot, SLOT(SaveClones())); + // 1D Plot box + //to change pages + connect(btnRight, SIGNAL(clicked()), this, SLOT(SetPlotOptionsRightPage())); + connect(btnLeft, SIGNAL(clicked()), this, SLOT(SetPlotOptionsLeftPage())); -void qTabPlot::Initialization(){ -// Plot arguments box - connect(btnGroupPlotType,SIGNAL(buttonClicked(int)),this, SLOT(SetPlot())); -// Histogram arguments box - connect(btnGroupHistogram,SIGNAL(buttonClicked(int)),this, SLOT(SetHistogramOptions())); -// Scan box - connect(boxScan, SIGNAL(toggled(bool)), this, SLOT(EnableScanBox())); -// Snapshot box - connect(btnClone, SIGNAL(clicked()),myPlot, SLOT(ClonePlot())); - connect(btnCloseClones, SIGNAL(clicked()),myPlot, SLOT(CloseClones())); - connect(btnSaveClones, SIGNAL(clicked()),myPlot, SLOT(SaveClones())); -// 1D Plot box - //to change pages - connect(btnRight, SIGNAL(clicked()), this, SLOT(SetPlotOptionsRightPage())); - connect(btnLeft, SIGNAL(clicked()), this, SLOT(SetPlotOptionsLeftPage())); + connect(chkSuperimpose, SIGNAL(toggled(bool)), this, SLOT(EnablePersistency(bool))); + connect(spinPersistency, SIGNAL(valueChanged(int)), myPlot, SLOT(SetPersistency(int))); + connect(chkPoints, SIGNAL(toggled(bool)), myPlot, SLOT(SetMarkers(bool))); + connect(chkLines, SIGNAL(toggled(bool)), myPlot, SLOT(SetLines(bool))); + connect(chk1DLog, SIGNAL(toggled(bool)), myPlot, SIGNAL(LogySignal(bool))); + connect(chkStatistics, SIGNAL(toggled(bool)), myPlot, SLOT(DisplayStatistics(bool))); - connect(chkSuperimpose, SIGNAL(toggled(bool)), this, SLOT(EnablePersistency(bool))); - connect(spinPersistency,SIGNAL(valueChanged(int)), myPlot,SLOT(SetPersistency(int))); - connect(chkPoints, SIGNAL(toggled(bool)), myPlot, SLOT(SetMarkers(bool))); - connect(chkLines, SIGNAL(toggled(bool)), myPlot, SLOT(SetLines(bool))); - connect(chk1DLog, SIGNAL(toggled(bool)), myPlot, SIGNAL(LogySignal(bool))); - connect(chkStatistics, SIGNAL(toggled(bool)), myPlot, SLOT(DisplayStatistics(bool))); + // 2D Plot box + connect(chkInterpolate, SIGNAL(toggled(bool)), myPlot, SIGNAL(InterpolateSignal(bool))); + connect(chkContour, SIGNAL(toggled(bool)), myPlot, SIGNAL(ContourSignal(bool))); + connect(chkLogz, SIGNAL(toggled(bool)), myPlot, SIGNAL(LogzSignal(bool))); + connect(chkStatistics_2, SIGNAL(toggled(bool)), myPlot, SLOT(DisplayStatistics(bool))); + // Plotting frequency box + connect(comboFrequency, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFrequency())); + connect(comboTimeGapUnit, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFrequency())); + connect(spinTimeGap, SIGNAL(editingFinished()), this, SLOT(SetFrequency())); + connect(spinNthFrame, SIGNAL(editingFinished()), this, SLOT(SetFrequency())); + // Plot Axis * + connect(chkTitle, SIGNAL(toggled(bool)), this, SLOT(EnableTitles())); + connect(chkXAxis, SIGNAL(toggled(bool)), this, SLOT(EnableTitles())); + connect(chkYAxis, SIGNAL(toggled(bool)), this, SLOT(EnableTitles())); + connect(chkZAxis, SIGNAL(toggled(bool)), this, SLOT(EnableTitles())); + connect(dispTitle, SIGNAL(textChanged(const QString &)), this, SLOT(SetTitles())); + connect(dispXAxis, SIGNAL(textChanged(const QString &)), this, SLOT(SetTitles())); + connect(dispYAxis, SIGNAL(textChanged(const QString &)), this, SLOT(SetTitles())); + connect(dispZAxis, SIGNAL(textChanged(const QString &)), this, SLOT(SetTitles())); -// 2D Plot box - connect(chkInterpolate, SIGNAL(toggled(bool)),myPlot, SIGNAL(InterpolateSignal(bool))); - connect(chkContour, SIGNAL(toggled(bool)),myPlot, SIGNAL(ContourSignal(bool))); - connect(chkLogz, SIGNAL(toggled(bool)),myPlot, SIGNAL(LogzSignal(bool))); - connect(chkStatistics_2,SIGNAL(toggled(bool)),myPlot, SLOT(DisplayStatistics(bool))); -// Plotting frequency box - connect(comboFrequency, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFrequency())); - connect(comboTimeGapUnit,SIGNAL(currentIndexChanged(int)), this, SLOT(SetFrequency())); - connect(spinTimeGap, SIGNAL(editingFinished()), this, SLOT(SetFrequency())); - connect(spinNthFrame, SIGNAL(editingFinished()), this, SLOT(SetFrequency())); -// Plot Axis * - connect(chkTitle, SIGNAL(toggled(bool)), this, SLOT(EnableTitles())); - connect(chkXAxis, SIGNAL(toggled(bool)), this, SLOT(EnableTitles())); - connect(chkYAxis, SIGNAL(toggled(bool)), this, SLOT(EnableTitles())); - connect(chkZAxis, SIGNAL(toggled(bool)), this, SLOT(EnableTitles())); - connect(dispTitle, SIGNAL(textChanged(const QString&)), this, SLOT(SetTitles())); - connect(dispXAxis, SIGNAL(textChanged(const QString&)), this, SLOT(SetTitles())); - connect(dispYAxis, SIGNAL(textChanged(const QString&)), this, SLOT(SetTitles())); - connect(dispZAxis, SIGNAL(textChanged(const QString&)), this, SLOT(SetTitles())); + connect(chkXMin, SIGNAL(toggled(bool)), this, SLOT(EnableXRange())); + connect(chkXMax, SIGNAL(toggled(bool)), this, SLOT(EnableXRange())); + connect(chkYMin, SIGNAL(toggled(bool)), this, SLOT(EnableYRange())); + connect(chkYMax, SIGNAL(toggled(bool)), this, SLOT(EnableYRange())); + connect(chkZMin, SIGNAL(toggled(bool)), this, SLOT(EnableZRange())); + connect(chkZMax, SIGNAL(toggled(bool)), this, SLOT(EnableZRange())); + connect(chkAspectRatio, SIGNAL(toggled(bool)), this, SLOT(checkAspectRatio())); + connect(this, SIGNAL(ResetZMinZMaxSignal(bool, bool, double, double)), myPlot, SIGNAL(ResetZMinZMaxSignal(bool, bool, double, double))); - connect(chkXMin, SIGNAL(toggled(bool)), this, SLOT(EnableXRange())); - connect(chkXMax, SIGNAL(toggled(bool)), this, SLOT(EnableXRange())); - connect(chkYMin, SIGNAL(toggled(bool)), this, SLOT(EnableYRange())); - connect(chkYMax, SIGNAL(toggled(bool)), this, SLOT(EnableYRange())); - connect(chkZMin, SIGNAL(toggled(bool)), this, SLOT(EnableZRange())); - connect(chkZMax, SIGNAL(toggled(bool)), this, SLOT(EnableZRange())); - connect(chkAspectRatio, SIGNAL(toggled(bool)), this, SLOT(checkAspectRatio())); - connect(this, SIGNAL(ResetZMinZMaxSignal(bool,bool,double,double)), myPlot, SIGNAL(ResetZMinZMaxSignal(bool,bool,double,double))); + connect(dispXMin, SIGNAL(editingFinished()), this, SLOT(SetXAxisRange())); + connect(dispXMax, SIGNAL(editingFinished()), this, SLOT(SetXAxisRange())); + connect(dispYMin, SIGNAL(editingFinished()), this, SLOT(SetYAxisRange())); + connect(dispYMax, SIGNAL(editingFinished()), this, SLOT(SetYAxisRange())); + connect(dispZMin, SIGNAL(editingFinished()), this, SLOT(SetZRange())); + connect(dispZMax, SIGNAL(editingFinished()), this, SLOT(SetZRange())); + // Save + connect(btnSave, SIGNAL(clicked()), myPlot, SLOT(SavePlot())); + connect(chkSaveAll, SIGNAL(toggled(bool)), myPlot, SLOT(SaveAll(bool))); - connect(dispXMin, SIGNAL(editingFinished()), this, SLOT(SetXAxisRange())); - connect(dispXMax, SIGNAL(editingFinished()), this, SLOT(SetXAxisRange())); - connect(dispYMin, SIGNAL(editingFinished()), this, SLOT(SetYAxisRange())); - connect(dispYMax, SIGNAL(editingFinished()), this, SLOT(SetYAxisRange())); - connect(dispZMin, SIGNAL(editingFinished()), this, SLOT(SetZRange())); - connect(dispZMax, SIGNAL(editingFinished()), this, SLOT(SetZRange())); -// Save - connect(btnSave, SIGNAL(clicked()), myPlot, SLOT(SavePlot())); - connect(chkSaveAll, SIGNAL(toggled(bool)), myPlot, SLOT(SaveAll(bool))); + //pedstal + connect(chkPedestal, SIGNAL(toggled(bool)), myPlot, SLOT(SetPedestal(bool))); + connect(btnRecalPedestal, SIGNAL(clicked()), myPlot, SLOT(RecalculatePedestal())); + connect(chkPedestal_2, SIGNAL(toggled(bool)), myPlot, SLOT(SetPedestal(bool))); + connect(btnRecalPedestal_2, SIGNAL(clicked()), myPlot, SLOT(RecalculatePedestal())); -//pedstal - connect(chkPedestal, SIGNAL(toggled(bool)), myPlot, SLOT(SetPedestal(bool))); - connect(btnRecalPedestal, SIGNAL(clicked()), myPlot, SLOT(RecalculatePedestal())); - connect(chkPedestal_2, SIGNAL(toggled(bool)), myPlot, SLOT(SetPedestal(bool))); - connect(btnRecalPedestal_2, SIGNAL(clicked()), myPlot, SLOT(RecalculatePedestal())); + //accumulate + connect(chkAccumulate, SIGNAL(toggled(bool)), myPlot, SLOT(SetAccumulate(bool))); + connect(btnResetAccumulate, SIGNAL(clicked()), myPlot, SLOT(ResetAccumulate())); + connect(chkAccumulate_2, SIGNAL(toggled(bool)), myPlot, SLOT(SetAccumulate(bool))); + connect(btnResetAccumulate_2, SIGNAL(clicked()), myPlot, SLOT(ResetAccumulate())); -//accumulate - connect(chkAccumulate, SIGNAL(toggled(bool)), myPlot, SLOT(SetAccumulate(bool))); - connect(btnResetAccumulate, SIGNAL(clicked()), myPlot, SLOT(ResetAccumulate())); - connect(chkAccumulate_2, SIGNAL(toggled(bool)), myPlot, SLOT(SetAccumulate(bool))); - connect(btnResetAccumulate_2, SIGNAL(clicked()), myPlot, SLOT(ResetAccumulate())); + //binary + connect(chkBinary, SIGNAL(toggled(bool)), this, SLOT(SetBinary())); + connect(chkBinary_2, SIGNAL(toggled(bool)), this, SLOT(SetBinary())); + connect(spinFrom, SIGNAL(valueChanged(int)), this, SLOT(SetBinary())); + connect(spinFrom_2, SIGNAL(valueChanged(int)), this, SLOT(SetBinary())); + connect(spinTo, SIGNAL(valueChanged(int)), this, SLOT(SetBinary())); + connect(spinTo_2, SIGNAL(valueChanged(int)), this, SLOT(SetBinary())); - //binary - connect(chkBinary, SIGNAL(toggled(bool)), this, SLOT(SetBinary())); - connect(chkBinary_2, SIGNAL(toggled(bool)), this, SLOT(SetBinary())); - connect(spinFrom, SIGNAL(valueChanged(int)), this, SLOT(SetBinary())); - connect(spinFrom_2, SIGNAL(valueChanged(int)), this, SLOT(SetBinary())); - connect(spinTo, SIGNAL(valueChanged(int)), this, SLOT(SetBinary())); - connect(spinTo_2, SIGNAL(valueChanged(int)), this, SLOT(SetBinary())); + //gainplot + if (chkGainPlot->isEnabled()) + connect(chkGainPlot, SIGNAL(toggled(bool)), myPlot, SIGNAL(GainPlotSignal(bool))); - //gainplot - if (chkGainPlot->isEnabled()) - connect(chkGainPlot, SIGNAL(toggled(bool)),myPlot, SIGNAL(GainPlotSignal(bool))); - - // gap pixels + // gap pixels if (chkGapPixels->isEnabled()) - connect(chkGapPixels, SIGNAL(toggled(bool)),this, SLOT(EnableGapPixels(bool))); + connect(chkGapPixels, SIGNAL(toggled(bool)), this, SLOT(EnableGapPixels(bool))); } - //------------------------------------------------------------------------------------------------------------------------------------------------- - -void qTabPlot::EnablePersistency(bool enable){ +void qTabPlot::EnablePersistency(bool enable) { #ifdef VERBOSE - if(enable) - cout << "Enabling Persistency" << endl; - else - cout << "Disabling Persistency" << endl; + if (enable) + cout << "Enabling Persistency" << endl; + else + cout << "Disabling Persistency" << endl; #endif - lblPersistency->setEnabled(enable); - spinPersistency->setEnabled(enable); - if(enable) myPlot->SetPersistency(spinPersistency->value()); - else myPlot->SetPersistency(0); - + lblPersistency->setEnabled(enable); + spinPersistency->setEnabled(enable); + if (enable) + myPlot->SetPersistency(spinPersistency->value()); + else + myPlot->SetPersistency(0); } - //------------------------------------------------------------------------------------------------------------------------------------------------- - -void qTabPlot::SetTitles(){ +void qTabPlot::SetTitles() { #ifdef VERBOSE - cout << "Setting Plot Titles" << endl; + cout << "Setting Plot Titles" << endl; #endif - // Plot Title - if(dispTitle->isEnabled()) - myPlot->SetPlotTitlePrefix(dispTitle->text()); - // X Axis - if(dispXAxis->isEnabled()){ - if(isOneD) myPlot->SetHistXAxisTitle(dispXAxis->text()); - else myPlot->SetImageXAxisTitle(dispXAxis->text()); - } - // Y Axis - if(dispYAxis->isEnabled()){ - if(isOneD) myPlot->SetHistYAxisTitle(dispYAxis->text()); - else myPlot->SetImageYAxisTitle(dispYAxis->text()); - } - // Z Axis - if(dispZAxis->isEnabled()) - myPlot->SetImageZAxisTitle(dispZAxis->text()); + // Plot Title + if (dispTitle->isEnabled()) + myPlot->SetPlotTitlePrefix(dispTitle->text()); + // X Axis + if (dispXAxis->isEnabled()) { + if (isOneD) + myPlot->SetHistXAxisTitle(dispXAxis->text()); + else + myPlot->SetImageXAxisTitle(dispXAxis->text()); + } + // Y Axis + if (dispYAxis->isEnabled()) { + if (isOneD) + myPlot->SetHistYAxisTitle(dispYAxis->text()); + else + myPlot->SetImageYAxisTitle(dispYAxis->text()); + } + // Z Axis + if (dispZAxis->isEnabled()) + myPlot->SetImageZAxisTitle(dispZAxis->text()); } - //------------------------------------------------------------------------------------------------------------------------------------------------- - -void qTabPlot::EnableTitles(){ - // Plot Title - dispTitle->setEnabled(chkTitle->isChecked()); - if(!chkTitle->isChecked()){ - myPlot->SetPlotTitlePrefix(""); - dispTitle->setText(""); - } - // X Axis - dispXAxis->setEnabled(chkXAxis->isChecked()); - if(!chkXAxis->isChecked()){ - if(isOneD){ - myPlot->SetHistXAxisTitle(defaultHistXAxisTitle); - dispXAxis->setText(defaultHistXAxisTitle); - } - else{ - myPlot->SetImageXAxisTitle(defaultImageXAxisTitle); - dispXAxis->setText(defaultImageXAxisTitle); - } - } - // Y Axis - dispYAxis->setEnabled(chkYAxis->isChecked()); - if(!chkYAxis->isChecked()){ - if(isOneD){ - myPlot->SetHistYAxisTitle(defaultHistYAxisTitle); - dispYAxis->setText(defaultHistYAxisTitle); - }else{ - myPlot->SetImageYAxisTitle(defaultImageYAxisTitle); - dispYAxis->setText(defaultImageYAxisTitle); - } - } - // Z Axis - dispZAxis->setEnabled(chkZAxis->isChecked()); - if(!chkZAxis->isChecked()){ - myPlot->SetImageZAxisTitle(defaultImageZAxisTitle); - dispZAxis->setText(defaultImageZAxisTitle); - } +void qTabPlot::EnableTitles() { + // Plot Title + dispTitle->setEnabled(chkTitle->isChecked()); + if (!chkTitle->isChecked()) { + myPlot->SetPlotTitlePrefix(""); + dispTitle->setText(""); + } + // X Axis + dispXAxis->setEnabled(chkXAxis->isChecked()); + if (!chkXAxis->isChecked()) { + if (isOneD) { + myPlot->SetHistXAxisTitle(defaultHistXAxisTitle); + dispXAxis->setText(defaultHistXAxisTitle); + } else { + myPlot->SetImageXAxisTitle(defaultImageXAxisTitle); + dispXAxis->setText(defaultImageXAxisTitle); + } + } + // Y Axis + dispYAxis->setEnabled(chkYAxis->isChecked()); + if (!chkYAxis->isChecked()) { + if (isOneD) { + myPlot->SetHistYAxisTitle(defaultHistYAxisTitle); + dispYAxis->setText(defaultHistYAxisTitle); + } else { + myPlot->SetImageYAxisTitle(defaultImageYAxisTitle); + dispYAxis->setText(defaultImageYAxisTitle); + } + } + // Z Axis + dispZAxis->setEnabled(chkZAxis->isChecked()); + if (!chkZAxis->isChecked()) { + myPlot->SetImageZAxisTitle(defaultImageZAxisTitle); + dispZAxis->setText(defaultImageZAxisTitle); + } } - //------------------------------------------------------------------------------------------------------------------------------------------------- - void qTabPlot::checkAspectRatio() { - if (chkAspectRatio->isChecked()) { - maintainAspectRatio(-1); - } + if (chkAspectRatio->isChecked()) { + maintainAspectRatio(-1); + } } - //------------------------------------------------------------------------------------------------------------------------------------------------- - void qTabPlot::maintainAspectRatio(int axis) { #ifdef VERBOSE - cout << "Maintaining Aspect Ratio" << endl; + cout << "Maintaining Aspect Ratio" << endl; #endif - disconnect(chkXMin, SIGNAL(toggled(bool)), this, SLOT(EnableXRange())); - disconnect(chkXMax, SIGNAL(toggled(bool)), this, SLOT(EnableXRange())); - disconnect(chkYMin, SIGNAL(toggled(bool)), this, SLOT(EnableYRange())); - disconnect(chkYMax, SIGNAL(toggled(bool)), this, SLOT(EnableYRange())); - disconnect(dispXMin, SIGNAL(editingFinished()), this, SLOT(SetXAxisRange())); - disconnect(dispXMax, SIGNAL(editingFinished()), this, SLOT(SetXAxisRange())); - disconnect(dispYMin, SIGNAL(editingFinished()), this, SLOT(SetYAxisRange())); - disconnect(dispYMax, SIGNAL(editingFinished()), this, SLOT(SetYAxisRange())); + disconnect(chkXMin, SIGNAL(toggled(bool)), this, SLOT(EnableXRange())); + disconnect(chkXMax, SIGNAL(toggled(bool)), this, SLOT(EnableXRange())); + disconnect(chkYMin, SIGNAL(toggled(bool)), this, SLOT(EnableYRange())); + disconnect(chkYMax, SIGNAL(toggled(bool)), this, SLOT(EnableYRange())); + disconnect(dispXMin, SIGNAL(editingFinished()), this, SLOT(SetXAxisRange())); + disconnect(dispXMax, SIGNAL(editingFinished()), this, SLOT(SetXAxisRange())); + disconnect(dispYMin, SIGNAL(editingFinished()), this, SLOT(SetYAxisRange())); + disconnect(dispYMax, SIGNAL(editingFinished()), this, SLOT(SetYAxisRange())); - double ranges[4]; - //get previous plot limits - ranges[qDefs::XMINIMUM] = myPlot->GetXMinimum(); - ranges[qDefs::XMAXIMUM] = myPlot->GetXMaximum(); - ranges[qDefs::YMINIMUM] = myPlot->GetYMinimum(); - ranges[qDefs::YMAXIMUM] = myPlot->GetYMaximum(); + double ranges[4]; + //get previous plot limits + ranges[qDefs::XMINIMUM] = myPlot->GetXMinimum(); + ranges[qDefs::XMAXIMUM] = myPlot->GetXMaximum(); + ranges[qDefs::YMINIMUM] = myPlot->GetYMinimum(); + ranges[qDefs::YMAXIMUM] = myPlot->GetYMaximum(); #ifdef VERYVERBOSE - cprintf(BLUE,"ideal values: xmin:%f, xmax:%f ymin:%f ymax:%f\n",ranges[qDefs::XMINIMUM],ranges[qDefs::XMAXIMUM],ranges[qDefs::YMINIMUM],ranges[qDefs::YMAXIMUM]); + cprintf(BLUE, "ideal values: xmin:%f, xmax:%f ymin:%f ymax:%f\n", ranges[qDefs::XMINIMUM], ranges[qDefs::XMAXIMUM], ranges[qDefs::YMINIMUM], ranges[qDefs::YMAXIMUM]); #endif - double idealAspectratio = (ranges[qDefs::XMAXIMUM] - ranges[qDefs::XMINIMUM]) / (ranges[qDefs::YMAXIMUM] - ranges[qDefs::YMINIMUM]); + double idealAspectratio = (ranges[qDefs::XMAXIMUM] - ranges[qDefs::XMINIMUM]) / (ranges[qDefs::YMAXIMUM] - ranges[qDefs::YMINIMUM]); - // enable all - chkXMin->setChecked(true); dispXMin->setEnabled(true); - chkXMax->setChecked(true); dispXMax->setEnabled(true); - chkYMin->setChecked(true); dispYMin->setEnabled(true); - chkYMax->setChecked(true); dispYMax->setEnabled(true); + // enable all + chkXMin->setChecked(true); + dispXMin->setEnabled(true); + chkXMax->setChecked(true); + dispXMax->setEnabled(true); + chkYMin->setChecked(true); + dispYMin->setEnabled(true); + chkYMax->setChecked(true); + dispYMax->setEnabled(true); - // if any empty, set it to previous plots boundaries - if (dispXMin->text().isEmpty()) dispXMin->setText(QString::number(myPlot->GetXMinimum())); - if (dispXMax->text().isEmpty()) dispXMax->setText(QString::number(myPlot->GetXMaximum())); - if (dispYMin->text().isEmpty()) dispYMin->setText(QString::number(myPlot->GetYMinimum())); - if (dispYMax->text().isEmpty()) dispYMax->setText(QString::number(myPlot->GetYMaximum())); + // if any empty, set it to previous plots boundaries + if (dispXMin->text().isEmpty()) + dispXMin->setText(QString::number(myPlot->GetXMinimum())); + if (dispXMax->text().isEmpty()) + dispXMax->setText(QString::number(myPlot->GetXMaximum())); + if (dispYMin->text().isEmpty()) + dispYMin->setText(QString::number(myPlot->GetYMinimum())); + if (dispYMax->text().isEmpty()) + dispYMax->setText(QString::number(myPlot->GetYMaximum())); - //get actual limits - ranges[qDefs::XMINIMUM] = dispXMin->text().toDouble(); - ranges[qDefs::XMAXIMUM] = dispXMax->text().toDouble(); - ranges[qDefs::YMINIMUM] = dispYMin->text().toDouble(); - ranges[qDefs::YMAXIMUM] = dispYMax->text().toDouble(); + //get actual limits + ranges[qDefs::XMINIMUM] = dispXMin->text().toDouble(); + ranges[qDefs::XMAXIMUM] = dispXMax->text().toDouble(); + ranges[qDefs::YMINIMUM] = dispYMin->text().toDouble(); + ranges[qDefs::YMAXIMUM] = dispYMax->text().toDouble(); #ifdef VERYVERBOSE - cprintf(BLUE,"new limits: xmin:%f, xmax:%f ymin:%f ymax:%f\n",ranges[qDefs::XMINIMUM],ranges[qDefs::XMAXIMUM],ranges[qDefs::YMINIMUM],ranges[qDefs::YMAXIMUM]); + cprintf(BLUE, "new limits: xmin:%f, xmax:%f ymin:%f ymax:%f\n", ranges[qDefs::XMINIMUM], ranges[qDefs::XMAXIMUM], ranges[qDefs::YMINIMUM], ranges[qDefs::YMAXIMUM]); #endif - // calcualte new aspect ratio - double newAspectRatio = (ranges[qDefs::XMAXIMUM] - ranges[qDefs::XMINIMUM]) / (ranges[qDefs::YMAXIMUM] - ranges[qDefs::YMINIMUM]); + // calcualte new aspect ratio + double newAspectRatio = (ranges[qDefs::XMAXIMUM] - ranges[qDefs::XMINIMUM]) / (ranges[qDefs::YMAXIMUM] - ranges[qDefs::YMINIMUM]); - // if not ideal aspect ratio - if (newAspectRatio != idealAspectratio) { + // if not ideal aspect ratio + if (newAspectRatio != idealAspectratio) { - // find the larger difference - if (axis == -1) { - if ((ranges[qDefs::XMAXIMUM] - ranges[qDefs::XMINIMUM]) > (ranges[qDefs::YMAXIMUM] - ranges[qDefs::YMINIMUM])) { - //change x - axis = 0; - } else { - //change y - axis = 1; - } - } + // find the larger difference + if (axis == -1) { + if ((ranges[qDefs::XMAXIMUM] - ranges[qDefs::XMINIMUM]) > (ranges[qDefs::YMAXIMUM] - ranges[qDefs::YMINIMUM])) { + //change x + axis = 0; + } else { + //change y + axis = 1; + } + } - // if x changed: y adjusted, y changed: x adjusted, aspect ratio clicked: larger one adjusted - double newval=0; - switch(axis) { - case 0: - //change x - newval = idealAspectratio * (ranges[qDefs::YMAXIMUM] - ranges[qDefs::YMINIMUM]) + ranges[qDefs::XMINIMUM]; - if (newval <= myPlot->GetXMaximum()) { - dispXMax->setText(QString::number(newval)); + // if x changed: y adjusted, y changed: x adjusted, aspect ratio clicked: larger one adjusted + double newval = 0; + switch (axis) { + case 0: + //change x + newval = idealAspectratio * (ranges[qDefs::YMAXIMUM] - ranges[qDefs::YMINIMUM]) + ranges[qDefs::XMINIMUM]; + if (newval <= myPlot->GetXMaximum()) { + dispXMax->setText(QString::number(newval)); #ifdef VERYVERBOSE - cprintf(BLUE,"new xmax: %f\n",newval); + cprintf(BLUE, "new xmax: %f\n", newval); #endif - } else { - newval = ranges[qDefs::XMAXIMUM] - (idealAspectratio * (ranges[qDefs::YMAXIMUM] - ranges[qDefs::YMINIMUM])); - dispXMin->setText(QString::number(newval)); + } else { + newval = ranges[qDefs::XMAXIMUM] - (idealAspectratio * (ranges[qDefs::YMAXIMUM] - ranges[qDefs::YMINIMUM])); + dispXMin->setText(QString::number(newval)); #ifdef VERYVERBOSE - cprintf(BLUE,"new xmin: %f\n",newval); + cprintf(BLUE, "new xmin: %f\n", newval); #endif - } + } - break; - case 1: - // change y - newval = ((ranges[qDefs::XMAXIMUM] - ranges[qDefs::XMINIMUM]) / idealAspectratio) + ranges[qDefs::YMINIMUM]; - if (newval <= myPlot->GetYMaximum()) { - dispYMax->setText(QString::number(newval)); - //#ifdef VERYVERBOSE - cprintf(BLUE,"new ymax: %f\n",newval); - //#endif - } else { - newval = ranges[qDefs::YMAXIMUM] - ((ranges[qDefs::XMAXIMUM] - ranges[qDefs::XMINIMUM]) / idealAspectratio); - dispYMin->setText(QString::number(newval)); + break; + case 1: + // change y + newval = ((ranges[qDefs::XMAXIMUM] - ranges[qDefs::XMINIMUM]) / idealAspectratio) + ranges[qDefs::YMINIMUM]; + if (newval <= myPlot->GetYMaximum()) { + dispYMax->setText(QString::number(newval)); + //#ifdef VERYVERBOSE + cprintf(BLUE, "new ymax: %f\n", newval); + //#endif + } else { + newval = ranges[qDefs::YMAXIMUM] - ((ranges[qDefs::XMAXIMUM] - ranges[qDefs::XMINIMUM]) / idealAspectratio); + dispYMin->setText(QString::number(newval)); #ifdef VERYVERBOSE - cprintf(BLUE,"new ymin: %f\n",newval); + cprintf(BLUE, "new ymin: %f\n", newval); #endif - } - break; - default: - break; - } - } + } + break; + default: + break; + } + } - connect(chkXMin, SIGNAL(toggled(bool)), this, SLOT(EnableXRange())); - connect(chkXMax, SIGNAL(toggled(bool)), this, SLOT(EnableXRange())); - connect(chkYMin, SIGNAL(toggled(bool)), this, SLOT(EnableYRange())); - connect(chkYMax, SIGNAL(toggled(bool)), this, SLOT(EnableYRange())); - connect(dispXMin, SIGNAL(editingFinished()), this, SLOT(SetXAxisRange())); - connect(dispXMax, SIGNAL(editingFinished()), this, SLOT(SetXAxisRange())); - connect(dispYMin, SIGNAL(editingFinished()), this, SLOT(SetYAxisRange())); - connect(dispYMax, SIGNAL(editingFinished()), this, SLOT(SetYAxisRange())); + connect(chkXMin, SIGNAL(toggled(bool)), this, SLOT(EnableXRange())); + connect(chkXMax, SIGNAL(toggled(bool)), this, SLOT(EnableXRange())); + connect(chkYMin, SIGNAL(toggled(bool)), this, SLOT(EnableYRange())); + connect(chkYMax, SIGNAL(toggled(bool)), this, SLOT(EnableYRange())); + connect(dispXMin, SIGNAL(editingFinished()), this, SLOT(SetXAxisRange())); + connect(dispXMax, SIGNAL(editingFinished()), this, SLOT(SetXAxisRange())); + connect(dispYMin, SIGNAL(editingFinished()), this, SLOT(SetYAxisRange())); + connect(dispYMax, SIGNAL(editingFinished()), this, SLOT(SetYAxisRange())); - // disable mouse zooming if any checked - myPlot->DisableZoom(true); - emit DisableZoomSignal(true); + // disable mouse zooming if any checked + myPlot->DisableZoom(true); + emit DisableZoomSignal(true); - // set XY values in plot - myPlot->SetXYRangeValues(dispXMin->text().toDouble(),qDefs::XMINIMUM); - myPlot->SetXYRangeValues(dispXMax->text().toDouble(),qDefs::XMAXIMUM); - myPlot->SetXYRangeValues(dispYMin->text().toDouble(),qDefs::YMINIMUM); - myPlot->SetXYRangeValues(dispYMax->text().toDouble(),qDefs::YMAXIMUM); + // set XY values in plot + myPlot->SetXYRangeValues(dispXMin->text().toDouble(), qDefs::XMINIMUM); + myPlot->SetXYRangeValues(dispXMax->text().toDouble(), qDefs::XMAXIMUM); + myPlot->SetXYRangeValues(dispYMin->text().toDouble(), qDefs::YMINIMUM); + myPlot->SetXYRangeValues(dispYMax->text().toDouble(), qDefs::YMAXIMUM); + myPlot->IsXYRangeValues(true, qDefs::XMINIMUM); + myPlot->IsXYRangeValues(true, qDefs::XMAXIMUM); + myPlot->IsXYRangeValues(true, qDefs::YMINIMUM); + myPlot->IsXYRangeValues(true, qDefs::YMAXIMUM); - myPlot->IsXYRangeValues(true,qDefs::XMINIMUM); - myPlot->IsXYRangeValues(true,qDefs::XMAXIMUM); - myPlot->IsXYRangeValues(true,qDefs::YMINIMUM); - myPlot->IsXYRangeValues(true,qDefs::YMAXIMUM); - - // To remind the updateplot in qdrawplot to set range after updating plot - myPlot->SetXYRange(true); + // To remind the updateplot in qdrawplot to set range after updating plot + myPlot->SetXYRange(true); } - //------------------------------------------------------------------------------------------------------------------------------------------------- -void qTabPlot::EnableXRange(){ +void qTabPlot::EnableXRange() { #ifdef VERBOSE - cout << "Enable X Axis Range" << endl; + cout << "Enable X Axis Range" << endl; #endif - // keeping aspect ratio - if (chkAspectRatio->isChecked()) { - maintainAspectRatio(1); - return; - } - disconnect(dispXMin, SIGNAL(editingFinished()), this, SLOT(SetXAxisRange())); - disconnect(dispXMax, SIGNAL(editingFinished()), this, SLOT(SetXAxisRange())); + // keeping aspect ratio + if (chkAspectRatio->isChecked()) { + maintainAspectRatio(1); + return; + } + disconnect(dispXMin, SIGNAL(editingFinished()), this, SLOT(SetXAxisRange())); + disconnect(dispXMax, SIGNAL(editingFinished()), this, SLOT(SetXAxisRange())); - // enable/disable lineedit - if(chkXMin->isChecked()) { - dispXMin->setEnabled(true); - // if any empty, set it to previous plots boundaries - if (dispXMin->text().isEmpty()) - dispXMin->setText(QString::number(myPlot->GetXMinimum())); - } else { - dispXMin->setEnabled(false); - } - // enable/disable lineedit - if(chkXMax->isChecked()) { - dispXMax->setEnabled(true); - // if any empty, set it to previous plots boundaries - if (dispXMax->text().isEmpty()) - dispXMax->setText(QString::number(myPlot->GetXMaximum())); - } else { - dispXMax->setEnabled(false); - } + // enable/disable lineedit + if (chkXMin->isChecked()) { + dispXMin->setEnabled(true); + // if any empty, set it to previous plots boundaries + if (dispXMin->text().isEmpty()) + dispXMin->setText(QString::number(myPlot->GetXMinimum())); + } else { + dispXMin->setEnabled(false); + } + // enable/disable lineedit + if (chkXMax->isChecked()) { + dispXMax->setEnabled(true); + // if any empty, set it to previous plots boundaries + if (dispXMax->text().isEmpty()) + dispXMax->setText(QString::number(myPlot->GetXMaximum())); + } else { + dispXMax->setEnabled(false); + } - connect(dispXMin, SIGNAL(editingFinished()), this, SLOT(SetXAxisRange())); - connect(dispXMax, SIGNAL(editingFinished()), this, SLOT(SetXAxisRange())); + connect(dispXMin, SIGNAL(editingFinished()), this, SLOT(SetXAxisRange())); + connect(dispXMax, SIGNAL(editingFinished()), this, SLOT(SetXAxisRange())); - EnableRange(); + EnableRange(); } - //------------------------------------------------------------------------------------------------------------------------------------------------- - -void qTabPlot::EnableYRange(){ +void qTabPlot::EnableYRange() { #ifdef VERBOSE - cout << "Enable Y Axis Range" << endl; + cout << "Enable Y Axis Range" << endl; #endif - // keeping aspect ratio - if (chkAspectRatio->isChecked()) { - maintainAspectRatio(0); - return; - } - disconnect(dispYMin, SIGNAL(editingFinished()), this, SLOT(SetYAxisRange())); - disconnect(dispYMax, SIGNAL(editingFinished()), this, SLOT(SetYAxisRange())); + // keeping aspect ratio + if (chkAspectRatio->isChecked()) { + maintainAspectRatio(0); + return; + } + disconnect(dispYMin, SIGNAL(editingFinished()), this, SLOT(SetYAxisRange())); + disconnect(dispYMax, SIGNAL(editingFinished()), this, SLOT(SetYAxisRange())); - // enable/disable lineedit - if(chkYMin->isChecked()) { - dispYMin->setEnabled(true); - // if any empty, set it to previous plots boundaries - if (dispYMin->text().isEmpty()) - dispYMin->setText(QString::number(myPlot->GetYMinimum())); - } else { - dispYMin->setEnabled(false); - } - // enable/disable lineedit - if(chkYMax->isChecked()) { - dispYMax->setEnabled(true); - // if any empty, set it to previous plots boundaries - if (dispYMax->text().isEmpty()) - dispYMax->setText(QString::number(myPlot->GetYMaximum())); - } else { - dispYMax->setEnabled(false); - } + // enable/disable lineedit + if (chkYMin->isChecked()) { + dispYMin->setEnabled(true); + // if any empty, set it to previous plots boundaries + if (dispYMin->text().isEmpty()) + dispYMin->setText(QString::number(myPlot->GetYMinimum())); + } else { + dispYMin->setEnabled(false); + } + // enable/disable lineedit + if (chkYMax->isChecked()) { + dispYMax->setEnabled(true); + // if any empty, set it to previous plots boundaries + if (dispYMax->text().isEmpty()) + dispYMax->setText(QString::number(myPlot->GetYMaximum())); + } else { + dispYMax->setEnabled(false); + } - connect(dispYMin, SIGNAL(editingFinished()), this, SLOT(SetYAxisRange())); - connect(dispYMax, SIGNAL(editingFinished()), this, SLOT(SetYAxisRange())); + connect(dispYMin, SIGNAL(editingFinished()), this, SLOT(SetYAxisRange())); + connect(dispYMax, SIGNAL(editingFinished()), this, SLOT(SetYAxisRange())); - EnableRange(); + EnableRange(); } - //------------------------------------------------------------------------------------------------------------------------------------------------- - -void qTabPlot::EnableRange(){ +void qTabPlot::EnableRange() { #ifdef VERBOSE - cout << "Enable Axes Range" << endl; + cout << "Enable Axes Range" << endl; #endif - // disable mouse zooming if any checked - bool disableZoom= false; - if(chkYMin->isChecked() || chkYMax->isChecked() || chkYMin->isChecked() || chkYMax->isChecked()) - disableZoom = true; - emit DisableZoomSignal(disableZoom); - SetAxesRange(); + // disable mouse zooming if any checked + bool disableZoom = false; + if (chkYMin->isChecked() || chkYMax->isChecked() || chkYMin->isChecked() || chkYMax->isChecked()) + disableZoom = true; + emit DisableZoomSignal(disableZoom); + SetAxesRange(); } - //------------------------------------------------------------------------------------------------------------------------------------------------- - -void qTabPlot::SetXAxisRange(){ +void qTabPlot::SetXAxisRange() { #ifdef VERBOSE - cout << "Setting X Axis Range" << endl; + cout << "Setting X Axis Range" << endl; #endif - disconnect(dispXMin, SIGNAL(editingFinished()), this, SLOT(SetXAxisRange())); - disconnect(dispXMax, SIGNAL(editingFinished()), this, SLOT(SetXAxisRange())); + disconnect(dispXMin, SIGNAL(editingFinished()), this, SLOT(SetXAxisRange())); + disconnect(dispXMax, SIGNAL(editingFinished()), this, SLOT(SetXAxisRange())); - if (dispXMin->text().toDouble() < myPlot->GetXMinimum()) { - qDefs::Message(qDefs::WARNING,"Outside Plot Range","qTabPlot::CheckZRange"); - dispXMin->setText(QString::number(myPlot->GetXMinimum())); - } + if (dispXMin->text().toDouble() < myPlot->GetXMinimum()) { + qDefs::Message(qDefs::WARNING, "Outside Plot Range", "qTabPlot::CheckZRange"); + dispXMin->setText(QString::number(myPlot->GetXMinimum())); + } - if (dispXMax->text().toDouble() > myPlot->GetXMaximum()) { - qDefs::Message(qDefs::WARNING,"Outside Plot Range","qTabPlot::CheckZRange"); - dispXMax->setText(QString::number(myPlot->GetXMaximum())); - } + if (dispXMax->text().toDouble() > myPlot->GetXMaximum()) { + qDefs::Message(qDefs::WARNING, "Outside Plot Range", "qTabPlot::CheckZRange"); + dispXMax->setText(QString::number(myPlot->GetXMaximum())); + } - connect(dispXMin, SIGNAL(editingFinished()), this, SLOT(SetXAxisRange())); - connect(dispXMax, SIGNAL(editingFinished()), this, SLOT(SetXAxisRange())); + connect(dispXMin, SIGNAL(editingFinished()), this, SLOT(SetXAxisRange())); + connect(dispXMax, SIGNAL(editingFinished()), this, SLOT(SetXAxisRange())); - // keeping aspect ratio - if (chkAspectRatio->isChecked()) { - maintainAspectRatio(1); - return; - } + // keeping aspect ratio + if (chkAspectRatio->isChecked()) { + maintainAspectRatio(1); + return; + } - SetAxesRange(); + SetAxesRange(); } - //------------------------------------------------------------------------------------------------------------------------------------------------- - -void qTabPlot::SetYAxisRange(){ +void qTabPlot::SetYAxisRange() { #ifdef VERBOSE - cout << "Setting Y Axis Range" << endl; + cout << "Setting Y Axis Range" << endl; #endif - disconnect(dispYMin, SIGNAL(editingFinished()), this, SLOT(SetYAxisRange())); - disconnect(dispYMax, SIGNAL(editingFinished()), this, SLOT(SetYAxisRange())); + disconnect(dispYMin, SIGNAL(editingFinished()), this, SLOT(SetYAxisRange())); + disconnect(dispYMax, SIGNAL(editingFinished()), this, SLOT(SetYAxisRange())); - if (dispYMin->text().toDouble() < myPlot->GetYMinimum()) { - qDefs::Message(qDefs::WARNING,"Outside Plot Range","qTabPlot::CheckZRange"); - dispYMin->setText(QString::number(myPlot->GetYMinimum())); - } + if (dispYMin->text().toDouble() < myPlot->GetYMinimum()) { + qDefs::Message(qDefs::WARNING, "Outside Plot Range", "qTabPlot::CheckZRange"); + dispYMin->setText(QString::number(myPlot->GetYMinimum())); + } - if (dispYMax->text().toDouble() > myPlot->GetYMaximum()) { - qDefs::Message(qDefs::WARNING,"Outside Plot Range","qTabPlot::CheckZRange"); - dispYMax->setText(QString::number(myPlot->GetYMaximum())); - } + if (dispYMax->text().toDouble() > myPlot->GetYMaximum()) { + qDefs::Message(qDefs::WARNING, "Outside Plot Range", "qTabPlot::CheckZRange"); + dispYMax->setText(QString::number(myPlot->GetYMaximum())); + } - connect(dispYMin, SIGNAL(editingFinished()), this, SLOT(SetYAxisRange())); - connect(dispYMax, SIGNAL(editingFinished()), this, SLOT(SetYAxisRange())); + connect(dispYMin, SIGNAL(editingFinished()), this, SLOT(SetYAxisRange())); + connect(dispYMax, SIGNAL(editingFinished()), this, SLOT(SetYAxisRange())); + // keeping aspect ratio + if (chkAspectRatio->isChecked()) { + maintainAspectRatio(0); + return; + } - // keeping aspect ratio - if (chkAspectRatio->isChecked()) { - maintainAspectRatio(0); - return; - } - - SetAxesRange(); + SetAxesRange(); } - //------------------------------------------------------------------------------------------------------------------------------------------------- - -void qTabPlot::SetAxesRange(){ +void qTabPlot::SetAxesRange() { #ifdef VERBOSE - cout << "Setting Axes Range" << endl; + cout << "Setting Axes Range" << endl; #endif - // x min - if (dispXMin->isEnabled()) { - myPlot->SetXYRangeValues(dispXMin->text().toDouble(),qDefs::XMINIMUM); - myPlot->IsXYRangeValues(true,qDefs::XMINIMUM); - } - else - myPlot->IsXYRangeValues(false,qDefs::XMINIMUM); - // x max - if (dispXMax->isEnabled()) { - myPlot->SetXYRangeValues(dispXMax->text().toDouble(),qDefs::XMAXIMUM); - myPlot->IsXYRangeValues(true,qDefs::XMAXIMUM); - } - else - myPlot->IsXYRangeValues(false,qDefs::XMAXIMUM); - // y min - if (dispYMin->isEnabled()) { - myPlot->SetXYRangeValues(dispYMin->text().toDouble(),qDefs::YMINIMUM); - myPlot->IsXYRangeValues(true,qDefs::YMINIMUM); - } - else - myPlot->IsXYRangeValues(false,qDefs::YMINIMUM); - // y max - if (dispYMax->isEnabled()) { - myPlot->SetXYRangeValues(dispYMax->text().toDouble(),qDefs::YMAXIMUM); - myPlot->IsXYRangeValues(true,qDefs::YMAXIMUM); - } - else - myPlot->IsXYRangeValues(false,qDefs::YMAXIMUM); + // x min + if (dispXMin->isEnabled()) { + myPlot->SetXYRangeValues(dispXMin->text().toDouble(), qDefs::XMINIMUM); + myPlot->IsXYRangeValues(true, qDefs::XMINIMUM); + } else + myPlot->IsXYRangeValues(false, qDefs::XMINIMUM); + // x max + if (dispXMax->isEnabled()) { + myPlot->SetXYRangeValues(dispXMax->text().toDouble(), qDefs::XMAXIMUM); + myPlot->IsXYRangeValues(true, qDefs::XMAXIMUM); + } else + myPlot->IsXYRangeValues(false, qDefs::XMAXIMUM); + // y min + if (dispYMin->isEnabled()) { + myPlot->SetXYRangeValues(dispYMin->text().toDouble(), qDefs::YMINIMUM); + myPlot->IsXYRangeValues(true, qDefs::YMINIMUM); + } else + myPlot->IsXYRangeValues(false, qDefs::YMINIMUM); + // y max + if (dispYMax->isEnabled()) { + myPlot->SetXYRangeValues(dispYMax->text().toDouble(), qDefs::YMAXIMUM); + myPlot->IsXYRangeValues(true, qDefs::YMAXIMUM); + } else + myPlot->IsXYRangeValues(false, qDefs::YMAXIMUM); - // To remind the updateplot in qdrawplot to set range after updating plot - myPlot->SetXYRange(true); + // To remind the updateplot in qdrawplot to set range after updating plot + myPlot->SetXYRange(true); } - //------------------------------------------------------------------------------------------------------------------------------------------------- - -void qTabPlot::SetZRange(){ - emit ResetZMinZMaxSignal( - (chkZMin->isChecked() && CheckZRange(dispZMin->text())), - (chkZMax->isChecked() && CheckZRange(dispZMax->text())), - dispZMin->text().toDouble(), - dispZMax->text().toDouble()); +void qTabPlot::SetZRange() { + emit ResetZMinZMaxSignal( + (chkZMin->isChecked() && CheckZRange(dispZMin->text())), + (chkZMax->isChecked() && CheckZRange(dispZMax->text())), + dispZMin->text().toDouble(), + dispZMax->text().toDouble()); } - //------------------------------------------------------------------------------------------------------------------------------------------------- +void qTabPlot::EnableZRange() { -void qTabPlot::EnableZRange(){ + disconnect(dispZMin, SIGNAL(editingFinished()), this, SLOT(SetZRange())); + disconnect(dispZMax, SIGNAL(editingFinished()), this, SLOT(SetZRange())); - disconnect(dispZMin, SIGNAL(editingFinished()), this, SLOT(SetZRange())); - disconnect(dispZMax, SIGNAL(editingFinished()), this, SLOT(SetZRange())); + dispZMin->setEnabled(chkZMin->isChecked()); + dispZMax->setEnabled(chkZMax->isChecked()); + emit ResetZMinZMaxSignal( + (chkZMin->isChecked() && CheckZRange(dispZMin->text())), + (chkZMax->isChecked() && CheckZRange(dispZMax->text())), + dispZMin->text().toDouble(), + dispZMax->text().toDouble()); - dispZMin->setEnabled(chkZMin->isChecked()); - dispZMax->setEnabled(chkZMax->isChecked()); - emit ResetZMinZMaxSignal( - (chkZMin->isChecked() && CheckZRange(dispZMin->text())), - (chkZMax->isChecked() && CheckZRange(dispZMax->text())), - dispZMin->text().toDouble(), - dispZMax->text().toDouble()); - - connect(dispZMin, SIGNAL(editingFinished()), this, SLOT(SetZRange())); - connect(dispZMax, SIGNAL(editingFinished()), this, SLOT(SetZRange())); + connect(dispZMin, SIGNAL(editingFinished()), this, SLOT(SetZRange())); + connect(dispZMax, SIGNAL(editingFinished()), this, SLOT(SetZRange())); } - //------------------------------------------------------------------------------------------------------------------------------------------------- +bool qTabPlot::CheckZRange(QString value) { + if (value.isEmpty()) + return false; -bool qTabPlot::CheckZRange(QString value){ - if(value.isEmpty()) - return false; + bool ok; + value.toDouble(&ok); + if (!ok) { + qDefs::Message(qDefs::WARNING, "Check Z Range
" + "Zmin and Zmax should be in double", + "qTabPlot::CheckZRange"); + return false; + } - bool ok; - value.toDouble(&ok); - if(!ok) { - qDefs::Message(qDefs::WARNING,"Check Z Range
" - "Zmin and Zmax should be in double","qTabPlot::CheckZRange"); - return false; - } - - return true; + return true; } - //------------------------------------------------------------------------------------------------------------------------------------------------- - -void qTabPlot::SetPlot(){ +void qTabPlot::SetPlot() { #ifdef VERBOSE - cout << "Entering Set Plot()" ; + cout << "Entering Set Plot()"; #endif - if(radioNoPlot->isChecked()){ - cout << " - No Plot" << endl; + if (radioNoPlot->isChecked()) { + cout << " - No Plot" << endl; - boxScan->show(); - boxHistogram->hide(); - myPlot->EnablePlot(false); - boxSnapshot->setEnabled(false); - boxSave->setEnabled(false); - boxFrequency->setEnabled(false); - boxPlotAxis->setEnabled(false); - boxScan->setEnabled(false); + boxScan->show(); + boxHistogram->hide(); + myPlot->EnablePlot(false); + boxSnapshot->setEnabled(false); + boxSave->setEnabled(false); + boxFrequency->setEnabled(false); + boxPlotAxis->setEnabled(false); + boxScan->setEnabled(false); - }else if(radioDataGraph->isChecked()){ - cout << " - DataGraph" << endl; + } else if (radioDataGraph->isChecked()) { + cout << " - DataGraph" << endl; - boxScan->show(); - boxHistogram->hide(); - myPlot->EnablePlot(true); - Select1DPlot(isOriginallyOneD); - boxSnapshot->setEnabled(true); - boxSave->setEnabled(true); - boxFrequency->setEnabled(true); - boxPlotAxis->setEnabled(true); - if(!myPlot->isRunning()) - EnableScanBox(); - // To remind the updateplot in qdrawplot to set range after updating plot - myPlot->SetXYRange(true); - } - else{ - //histogram and 2d scans dont work - if(boxScan->isChecked()){ - qDefs::Message(qDefs::WARNING,"Histogram cannot be used together with 2D Scan Plots.
" - "Uncheck 2D Scan plots to plot Histograms", "qTabPlot::SetPlot"); - radioDataGraph->setChecked(true); - boxScan->show(); - boxHistogram->hide(); - return; - } + boxScan->show(); + boxHistogram->hide(); + myPlot->EnablePlot(true); + Select1DPlot(isOriginallyOneD); + boxSnapshot->setEnabled(true); + boxSave->setEnabled(true); + boxFrequency->setEnabled(true); + boxPlotAxis->setEnabled(true); + // if(!myPlot->isRunning()) + // EnableScanBox(); + // To remind the updateplot in qdrawplot to set range after updating plot + myPlot->SetXYRange(true); + } else { + //histogram and 2d scans dont work + if (boxScan->isChecked()) { + qDefs::Message(qDefs::WARNING, "Histogram cannot be used together with 2D Scan Plots.
" + "Uncheck 2D Scan plots to plot Histograms", + "qTabPlot::SetPlot"); + radioDataGraph->setChecked(true); + boxScan->show(); + boxHistogram->hide(); + return; + } - cout << " - Histogram" << endl; + cout << " - Histogram" << endl; - if(radioHistIntensity->isChecked()){ - pageHistogram->setEnabled(true); - pageHistogram_2->setEnabled(true); - }else{ - pageHistogram->setEnabled(false); - pageHistogram_2->setEnabled(false); - } - boxScan->hide(); - boxHistogram->show(); - myPlot->EnablePlot(true); - Select1DPlot(isOriginallyOneD); - boxSnapshot->setEnabled(true); - boxSave->setEnabled(true); - boxFrequency->setEnabled(true); - boxPlotAxis->setEnabled(true); - if(!myPlot->isRunning()) - EnableScanBox(); + if (radioHistIntensity->isChecked()) { + pageHistogram->setEnabled(true); + pageHistogram_2->setEnabled(true); + } else { + pageHistogram->setEnabled(false); + pageHistogram_2->setEnabled(false); + } + boxScan->hide(); + boxHistogram->show(); + myPlot->EnablePlot(true); + Select1DPlot(isOriginallyOneD); + boxSnapshot->setEnabled(true); + boxSave->setEnabled(true); + boxFrequency->setEnabled(true); + boxPlotAxis->setEnabled(true); + // if(!myPlot->isRunning()) + // EnableScanBox(); - //qDefs::Message(qDefs::INFORMATION,"Please check the Plot Histogram Options below " - // "before Starting Acquitision","qTabPlot::SetPlot"); - } + //qDefs::Message(qDefs::INFORMATION,"Please check the Plot Histogram Options below " + // "before Starting Acquitision","qTabPlot::SetPlot"); + } } - //------------------------------------------------------------------------------------------------------------------------------------------------- -void qTabPlot::SetFrequency(){ +void qTabPlot::SetFrequency() { #ifdef VERBOSE - cout << "Setting Plot Interval Frequency" << endl; + cout << "Setting Plot Interval Frequency" << endl; #endif - disconnect(comboTimeGapUnit,SIGNAL(currentIndexChanged(int)), this, SLOT(SetFrequency())); - disconnect(spinTimeGap, SIGNAL(editingFinished()), this, SLOT(SetFrequency())); - disconnect(spinNthFrame, SIGNAL(editingFinished()), this, SLOT(SetFrequency())); - disconnect(comboFrequency, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFrequency())); - double timeMS,acqPeriodMS; - double minPlotTimer = myPlot->GetMinimumPlotTimer(); - char cMin[200]; - sprintf(cMin,"%f ms",minPlotTimer); + disconnect(comboTimeGapUnit, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFrequency())); + disconnect(spinTimeGap, SIGNAL(editingFinished()), this, SLOT(SetFrequency())); + disconnect(spinNthFrame, SIGNAL(editingFinished()), this, SLOT(SetFrequency())); + disconnect(comboFrequency, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFrequency())); + double timeMS, acqPeriodMS; + double minPlotTimer = myPlot->GetMinimumPlotTimer(); + char cMin[200]; + sprintf(cMin, "%f ms", minPlotTimer); + acqPeriodMS = (myDet->setTimer(slsDetectorDefs::FRAME_PERIOD, -1) * (1E-6)); + //if period is 0, check exptime, if that is also 0, give warning and set to min timer + if (acqPeriodMS == 0) { + acqPeriodMS = (myDet->setTimer(slsDetectorDefs::ACQUISITION_TIME, -1) * (1E-6)); - acqPeriodMS = (myDet->setTimer(slsDetectorDefs::FRAME_PERIOD,-1)*(1E-6)); - //if period is 0, check exptime, if that is also 0, give warning and set to min timer - if(acqPeriodMS==0){ - acqPeriodMS = (myDet->setTimer(slsDetectorDefs::ACQUISITION_TIME,-1)*(1E-6)); + if (acqPeriodMS == 0) { + //to reduce the warnings displayed + if ((comboFrequency->currentIndex() == 0) && (spinTimeGap->value() == minPlotTimer)) + ; + else + qDefs::Message(qDefs::WARNING, "Interval between Plots:
" + "Every Nth Image: Period betwen Frames and Exposure Time cannot both be 0 ms.
" + "Resetting to minimum plotting time interval", + "qTabPlot::SetFrequency"); + comboFrequency->setCurrentIndex(0); + stackedLayout->setCurrentIndex(comboFrequency->currentIndex()); + spinTimeGap->setValue(minPlotTimer); + comboTimeGapUnit->setCurrentIndex(qDefs::MILLISECONDS); + timeMS = minPlotTimer; + //This is done so that its known which one was selected + myPlot->SetFrameFactor(0); + // Setting the timer value(ms) between plots + myPlot->SetPlotTimer(timeMS); - if(acqPeriodMS==0){ - //to reduce the warnings displayed - if((comboFrequency->currentIndex() == 0) && (spinTimeGap->value() == minPlotTimer)); - else - qDefs::Message(qDefs::WARNING,"Interval between Plots:
" - "Every Nth Image: Period betwen Frames and Exposure Time cannot both be 0 ms.
" - "Resetting to minimum plotting time interval","qTabPlot::SetFrequency"); - comboFrequency->setCurrentIndex(0); - stackedLayout->setCurrentIndex(comboFrequency->currentIndex()); - spinTimeGap->setValue(minPlotTimer); - comboTimeGapUnit->setCurrentIndex(qDefs::MILLISECONDS); - timeMS=minPlotTimer; - //This is done so that its known which one was selected - myPlot->SetFrameFactor(0); - // Setting the timer value(ms) between plots - myPlot->SetPlotTimer(timeMS); + connect(comboTimeGapUnit, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFrequency())); + connect(spinTimeGap, SIGNAL(editingFinished()), this, SLOT(SetFrequency())); + connect(spinNthFrame, SIGNAL(editingFinished()), this, SLOT(SetFrequency())); + connect(comboFrequency, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFrequency())); + qDefs::checkErrorMessage(myDet, "qTabPlot::SetFrequency"); + return; + } + } - connect(comboTimeGapUnit,SIGNAL(currentIndexChanged(int)), this, SLOT(SetFrequency())); - connect(spinTimeGap, SIGNAL(editingFinished()), this, SLOT(SetFrequency())); - connect(spinNthFrame, SIGNAL(editingFinished()), this, SLOT(SetFrequency())); - connect(comboFrequency, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFrequency())); - qDefs::checkErrorMessage(myDet,"qTabPlot::SetFrequency"); - return; - } - } + stackedLayout->setCurrentIndex(comboFrequency->currentIndex()); + switch (comboFrequency->currentIndex()) { + case 0: + // Get the time interval from gui in ms + timeMS = (qDefs::getNSTime((qDefs::timeUnit)comboTimeGapUnit->currentIndex(), spinTimeGap->value())) / (1e6); + if ((int)timeMS == 0) { + qDefs::Message(qDefs::WARNING, "Interval between Plots:
" + "Time Interval must be atleast >= 1 ms. Resetting to minimum plotting time interval.", + "qTabPlot::SetFrequency"); + spinTimeGap->setValue(minPlotTimer); + comboTimeGapUnit->setCurrentIndex(qDefs::MILLISECONDS); + timeMS = minPlotTimer; + } - stackedLayout->setCurrentIndex(comboFrequency->currentIndex()); - switch(comboFrequency->currentIndex()){ - case 0: - // Get the time interval from gui in ms - timeMS = (qDefs::getNSTime((qDefs::timeUnit)comboTimeGapUnit->currentIndex(),spinTimeGap->value()))/(1e6); + //show red if min intervalInterval between Plots: You might be losing Images!","Plot"); + boxFrequency->setPalette(*red); + boxFrequency->setTitle("Interval between Plots*"); + QString errTip = intervalTip + QString("

" + "Time Interval Condition: min of ") + + QString("%1").arg(minPlotTimer) + + QString("ms.
You might be losing images!
"); + boxFrequency->setToolTip(errTip); + } + //show red if acqPeriodInterval between Plots: You might be losing Images!","Plot"); + boxFrequency->setPalette(*red); + boxFrequency->setTitle("Interval between Plots*"); + QString errTip = intervalTip + QString("

" + "Time Interval Acquisition Period should be >= Time Interval between plots.
" + "You might be losing images!
"); + boxFrequency->setToolTip(errTip); + } + //correct + else { + boxFrequency->setPalette(boxSnapshot->palette()); + boxFrequency->setTitle("Interval between Plots"); + boxFrequency->setToolTip(intervalTip); + } - if((int)timeMS==0){ - qDefs::Message(qDefs::WARNING,"Interval between Plots:
" - "Time Interval must be atleast >= 1 ms. Resetting to minimum plotting time interval.","qTabPlot::SetFrequency"); - spinTimeGap->setValue(minPlotTimer); - comboTimeGapUnit->setCurrentIndex(qDefs::MILLISECONDS); - timeMS=minPlotTimer; - } - - - //show red if min intervalInterval between Plots: You might be losing Images!","Plot"); - boxFrequency->setPalette(*red); - boxFrequency->setTitle("Interval between Plots*"); - QString errTip = intervalTip + QString("

" - "Time Interval Condition: min of ")+QString("%1").arg(minPlotTimer)+ - QString("ms.
You might be losing images!
"); - boxFrequency->setToolTip(errTip); - } - //show red if acqPeriodInterval between Plots: You might be losing Images!","Plot"); - boxFrequency->setPalette(*red); - boxFrequency->setTitle("Interval between Plots*"); - QString errTip = intervalTip + QString("

" - "Time Interval Acquisition Period should be >= Time Interval between plots.
" - "You might be losing images!
"); - boxFrequency->setToolTip(errTip); - } - //correct - else{ - boxFrequency->setPalette(boxSnapshot->palette()); - boxFrequency->setTitle("Interval between Plots"); - boxFrequency->setToolTip(intervalTip); - } - - //This is done so that its known which one was selected - myPlot->SetFrameFactor(0); - // Setting the timer value(ms) between plots - myPlot->SetPlotTimer(timeMS); + //This is done so that its known which one was selected + myPlot->SetFrameFactor(0); + // Setting the timer value(ms) between plots + myPlot->SetPlotTimer(timeMS); #ifdef VERBOSE - cout << "Plotting Frequency: Time Gap - " << spinTimeGap->value() << qDefs::getUnitString((qDefs::timeUnit)comboTimeGapUnit->currentIndex()) << endl; + cout << "Plotting Frequency: Time Gap - " << spinTimeGap->value() << qDefs::getUnitString((qDefs::timeUnit)comboTimeGapUnit->currentIndex()) << endl; #endif - break; + break; + case 1: + // gets the acq period * number of nth frames + timeMS = (spinNthFrame->value()) * acqPeriodMS; + //Show red to make sure the period between plotting is not less than minimum plot timer in ms + if (timeMS < minPlotTimer) { + int minFrame = (int)(ceil)(minPlotTimer / acqPeriodMS); + //qDefs::Message(qDefs::WARNING,"Interval between Plots: You might be losing Images!","Plot"); + boxFrequency->setPalette(*red); + boxFrequency->setTitle("Interval between Plots*"); + QString errTip = intervalTip + QString("

" + "Every nth Image Condition: min nth Image for this time period: ") + + QString("%1").arg(minFrame) + + QString(".
You might be losing images!
"); + boxFrequency->setToolTip(errTip); + } else { + boxFrequency->setPalette(boxSnapshot->palette()); + boxFrequency->setTitle("Interval between Plots"); + boxFrequency->setToolTip(intervalTip); + } - case 1: - - // gets the acq period * number of nth frames - timeMS = (spinNthFrame->value())*acqPeriodMS; - - //Show red to make sure the period between plotting is not less than minimum plot timer in ms - if(timeMSInterval between Plots: You might be losing Images!","Plot"); - boxFrequency->setPalette(*red); - boxFrequency->setTitle("Interval between Plots*"); - QString errTip = intervalTip + QString("

" - "Every nth Image Condition: min nth Image for this time period: ")+QString("%1").arg(minFrame)+ - QString(".
You might be losing images!
"); - boxFrequency->setToolTip(errTip); - }else{ - boxFrequency->setPalette(boxSnapshot->palette()); - boxFrequency->setTitle("Interval between Plots"); - boxFrequency->setToolTip(intervalTip); - } - - // Setting the timer value (nth frames) between plots - myPlot->SetFrameFactor(spinNthFrame->value()); - + // Setting the timer value (nth frames) between plots + myPlot->SetFrameFactor(spinNthFrame->value()); #ifdef VERBOSE - cout << "Plotting Frequency: Nth Frame - " << spinNthFrame->value() << endl; + cout << "Plotting Frequency: Nth Frame - " << spinNthFrame->value() << endl; #endif - break; - } + break; + } - connect(comboTimeGapUnit,SIGNAL(currentIndexChanged(int)), this, SLOT(SetFrequency())); - connect(spinTimeGap, SIGNAL(editingFinished()), this, SLOT(SetFrequency())); - connect(spinNthFrame, SIGNAL(editingFinished()), this, SLOT(SetFrequency())); - connect(comboFrequency, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFrequency())); - qDefs::checkErrorMessage(myDet,"qTabPlot::SetFrequency"); + connect(comboTimeGapUnit, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFrequency())); + connect(spinTimeGap, SIGNAL(editingFinished()), this, SLOT(SetFrequency())); + connect(spinNthFrame, SIGNAL(editingFinished()), this, SLOT(SetFrequency())); + connect(comboFrequency, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFrequency())); + qDefs::checkErrorMessage(myDet, "qTabPlot::SetFrequency"); } - //------------------------------------------------------------------------------------------------------------------------------------------------- -void qTabPlot::EnableScanBox(){ -#ifdef VERBOSE - cout << "Entering Enable Scan Box"<< endl; -#endif - disconnect(btnGroupPlotType,SIGNAL(buttonClicked(int)),this, SLOT(SetPlot())); - disconnect(boxScan, SIGNAL(toggled(bool)), this, SLOT(EnableScanBox())); + void qTabPlot::EnableScanBox(){ + #ifdef VERBOSE + cout << "Entering Enable Scan Box"<< endl; + #endif + disconnect(btnGroupPlotType,SIGNAL(buttonClicked(int)),this, SLOT(SetPlot())); + disconnect(boxScan, SIGNAL(toggled(bool)), this, SLOT(EnableScanBox())); - int oldfreqvalue = myDet->setReadReceiverFrequency(); + int oldfreqvalue = myDet->setReadReceiverFrequency(); - int mode0 = myDet->getScanMode(0); - int mode1 = myDet->getScanMode(1); + int mode0 = myDet->getScanMode(0); + int mode1 = myDet->getScanMode(1); - radioHistLevel0->setEnabled(mode0); - radioHistLevel1->setEnabled(mode1); - int ang; - bool angConvert = myDet->getAngularConversion(ang); - myPlot->EnableAnglePlot(angConvert); + radioHistLevel0->setEnabled(mode0); + radioHistLevel1->setEnabled(mode1); + int ang; + bool angConvert = myDet->getAngularConversion(ang); + myPlot->EnableAnglePlot(angConvert); - radioDataGraph->setEnabled(true); - radioHistogram->setEnabled(true); - chkSuperimpose->setEnabled(true); - pageAccumulate->setEnabled(true); - pageAccumulate_2->setEnabled(true); - if((myDet->getDetectorsType() == slsDetectorDefs::GOTTHARD) || - (myDet->getDetectorsType() == slsDetectorDefs::PROPIX) || - (myDet->getDetectorsType() == slsDetectorDefs::JUNGFRAU) || - (myDet->getDetectorsType() == slsDetectorDefs::CHIPTESTBOARD) || - (myDet->getDetectorsType() == slsDetectorDefs::MOENCH)){ - pagePedestal->setEnabled(true); - pagePedestal_2->setEnabled(true); - chkBinary->setEnabled(true); - chkBinary_2->setEnabled(true); - } + radioDataGraph->setEnabled(true); + radioHistogram->setEnabled(true); + chkSuperimpose->setEnabled(true); + pageAccumulate->setEnabled(true); + pageAccumulate_2->setEnabled(true); + if((myDet->getDetectorsType() == slsDetectorDefs::GOTTHARD) || + (myDet->getDetectorsType() == slsDetectorDefs::PROPIX) || + (myDet->getDetectorsType() == slsDetectorDefs::JUNGFRAU) || + (myDet->getDetectorsType() == slsDetectorDefs::MOENCH)){ + pagePedestal->setEnabled(true); + pagePedestal_2->setEnabled(true); + chkBinary->setEnabled(true); + chkBinary_2->setEnabled(true); + } + //if angle plot or originally 2d, uncheck and disable scanbox + if ((angConvert) || (!isOriginallyOneD)){ + boxScan->setChecked(false); + boxScan->setEnabled(false); + /**Newly added*/ + // To remind the updateplot in qdrawplot to set range after updating plot + if(!isOriginallyOneD) + myPlot->SetXYRange(true); + //2d scans read every frame, not compulsory, but for historgrams + if((!isOriginallyOneD) && (mode0 || mode1)){ + //read every frame + disconnect(spinNthFrame, SIGNAL(editingFinished()), this, SLOT(SetFrequency())); + disconnect(comboFrequency, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFrequency())); + comboFrequency->setCurrentIndex(1); + spinNthFrame->setValue(1); + SetFrequency(); + connect(spinNthFrame, SIGNAL(editingFinished()), this, SLOT(SetFrequency())); + connect(comboFrequency, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFrequency())); + } - //if angle plot or originally 2d, uncheck and disable scanbox - if ((angConvert) || (!isOriginallyOneD)){ - boxScan->setChecked(false); - boxScan->setEnabled(false); + //persistency, accumulate, pedestal, binary + if(angConvert){ + if(chkSuperimpose->isChecked()) chkSuperimpose->setChecked(false); + if(chkPedestal->isChecked()) chkPedestal->setChecked(false); + if(chkPedestal_2->isChecked()) chkPedestal_2->setChecked(false); + if(chkAccumulate->isChecked()) chkAccumulate->setChecked(false); + if(chkAccumulate_2->isChecked())chkAccumulate_2->setChecked(false); + if(chkBinary->isChecked()) chkBinary->setChecked(false); + if(chkBinary_2->isChecked()) chkBinary_2->setChecked(false); + pagePedestal->setEnabled(false); + pagePedestal_2->setEnabled(false); + chkBinary->setEnabled(false); + chkBinary_2->setEnabled(false); + pageAccumulate->setEnabled(false); + pageAccumulate_2->setEnabled(false); + } - /**Newly added*/ - // To remind the updateplot in qdrawplot to set range after updating plot - if(!isOriginallyOneD) - myPlot->SetXYRange(true); + if(angConvert){ + boxScan->setToolTip("Only 1D Plots enabled for Angle Plots"); + //disable histogram + if(radioHistogram->isChecked()){ + radioDataGraph->setChecked(true); + radioHistogram->setEnabled(false); + // To remind the updateplot in qdrawplot to set range after updating plot + myPlot->SetXYRange(true); + boxScan->show(); + boxHistogram->hide(); + } + } + } - //2d scans read every frame, not compulsory, but for historgrams - if((!isOriginallyOneD) && (mode0 || mode1)){ - //read every frame - disconnect(spinNthFrame, SIGNAL(editingFinished()), this, SLOT(SetFrequency())); - disconnect(comboFrequency, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFrequency())); - comboFrequency->setCurrentIndex(1); - spinNthFrame->setValue(1); - SetFrequency(); - connect(spinNthFrame, SIGNAL(editingFinished()), this, SLOT(SetFrequency())); - connect(comboFrequency, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFrequency())); - } + //originally1d && not angle plot + else{ + boxScan->setToolTip(""); + boxScan->setEnabled(true); + /*if(mode0 || mode1) + boxScan->setChecked(true);*/ - //persistency, accumulate, pedestal, binary - if(angConvert){ - if(chkSuperimpose->isChecked()) chkSuperimpose->setChecked(false); - if(chkPedestal->isChecked()) chkPedestal->setChecked(false); - if(chkPedestal_2->isChecked()) chkPedestal_2->setChecked(false); - if(chkAccumulate->isChecked()) chkAccumulate->setChecked(false); - if(chkAccumulate_2->isChecked())chkAccumulate_2->setChecked(false); - if(chkBinary->isChecked()) chkBinary->setChecked(false); - if(chkBinary_2->isChecked()) chkBinary_2->setChecked(false); - pagePedestal->setEnabled(false); - pagePedestal_2->setEnabled(false); - chkBinary->setEnabled(false); - chkBinary_2->setEnabled(false); - pageAccumulate->setEnabled(false); - pageAccumulate_2->setEnabled(false); - } + //2d enabled with boxscan + if(boxScan->isChecked()){ - if(angConvert){ - boxScan->setToolTip("Only 1D Plots enabled for Angle Plots"); - //disable histogram - if(radioHistogram->isChecked()){ - radioDataGraph->setChecked(true); - radioHistogram->setEnabled(false); - // To remind the updateplot in qdrawplot to set range after updating plot - myPlot->SetXYRange(true); - boxScan->show(); - boxHistogram->hide(); - } - } - } + //2d for 1d detctors and histogram dont go + if(radioHistogram->isChecked()){ + radioDataGraph->setChecked(true); + // To remind the updateplot in qdrawplot to set range after updating plot + myPlot->SetXYRange(true); + boxScan->show(); + boxHistogram->hide(); + } + //read every frame + disconnect(spinNthFrame, SIGNAL(editingFinished()), this, SLOT(SetFrequency())); + disconnect(comboFrequency, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFrequency())); + comboFrequency->setCurrentIndex(1); + spinNthFrame->setValue(1); + SetFrequency(); + connect(spinNthFrame, SIGNAL(editingFinished()), this, SLOT(SetFrequency())); + connect(comboFrequency, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFrequency())); + //enabling options + radioFileIndex->setEnabled(mode0||mode1); + if(mode0 && mode1){ + radioLevel0->setEnabled(false); + radioLevel1->setEnabled(false); + }else{ + radioLevel0->setEnabled(mode0); + radioLevel1->setEnabled(mode1); + } + //default is allframes if checked button is disabled + if(!btnGroupScan->checkedButton()->isEnabled()) + radioAllFrames->setChecked(true); + } + } + //histogram + if(radioHistogram->isChecked()){ + if(radioHistIntensity->isChecked()){ + pageHistogram->setEnabled(true); + pageHistogram_2->setEnabled(true); + }else{ + pageHistogram->setEnabled(false); + pageHistogram_2->setEnabled(false); + } + stackedWidget->setCurrentIndex(stackedWidget->count()-1); + stackedWidget_2->setCurrentIndex(stackedWidget_2->count()-1); + box1D->setTitle(QString("1D Plot Options %1 - Histogram").arg(stackedWidget->currentIndex()+1)); + box2D->setTitle(QString("2D Plot Options %1 - Histogram").arg(stackedWidget_2->currentIndex()+1)); - //originally1d && not angle plot - else{ - boxScan->setToolTip(""); - boxScan->setEnabled(true); - /*if(mode0 || mode1) - boxScan->setChecked(true);*/ + if(chkSuperimpose->isChecked()) chkSuperimpose->setChecked(false); + if(chkPedestal->isChecked()) chkPedestal->setChecked(false); + if(chkPedestal_2->isChecked()) chkPedestal_2->setChecked(false); + if(chkAccumulate->isChecked()) chkAccumulate->setChecked(false); + if(chkAccumulate_2->isChecked())chkAccumulate_2->setChecked(false); + if(chkBinary->isChecked()) chkBinary->setChecked(false); + if(chkBinary_2->isChecked()) chkBinary_2->setChecked(false); + pagePedestal->setEnabled(false); + pagePedestal_2->setEnabled(false); + chkBinary->setEnabled(false); + chkBinary_2->setEnabled(false); + pageAccumulate->setEnabled(false); + pageAccumulate_2->setEnabled(false); - //2d enabled with boxscan - if(boxScan->isChecked()){ + //read every frame + disconnect(spinNthFrame, SIGNAL(editingFinished()), this, SLOT(SetFrequency())); + disconnect(comboFrequency, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFrequency())); + comboFrequency->setCurrentIndex(1); + spinNthFrame->setValue(1); + SetFrequency(); + connect(spinNthFrame, SIGNAL(editingFinished()), this, SLOT(SetFrequency())); + connect(comboFrequency, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFrequency())); - //2d for 1d detctors and histogram dont go - if(radioHistogram->isChecked()){ - radioDataGraph->setChecked(true); - // To remind the updateplot in qdrawplot to set range after updating plot - myPlot->SetXYRange(true); - boxScan->show(); - boxHistogram->hide(); - } + }else{ + pageHistogram->setEnabled(false); + pageHistogram_2->setEnabled(false); + } - //read every frame - disconnect(spinNthFrame, SIGNAL(editingFinished()), this, SLOT(SetFrequency())); - disconnect(comboFrequency, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFrequency())); - comboFrequency->setCurrentIndex(1); - spinNthFrame->setValue(1); - SetFrequency(); - connect(spinNthFrame, SIGNAL(editingFinished()), this, SLOT(SetFrequency())); - connect(comboFrequency, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFrequency())); + // if it was set to read every frame + if (oldfreqvalue != 0 && (comboFrequency->currentIndex() != 1 || spinNthFrame->value() != oldfreqvalue)) { + disconnect(spinNthFrame, SIGNAL(editingFinished()), this, SLOT(SetFrequency())); + disconnect(comboFrequency, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFrequency())); + comboFrequency->setCurrentIndex(1); + spinNthFrame->setValue(1); + SetFrequency(); + connect(spinNthFrame, SIGNAL(editingFinished()), this, SLOT(SetFrequency())); + connect(comboFrequency, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFrequency())); + } - //enabling options - radioFileIndex->setEnabled(mode0||mode1); - if(mode0 && mode1){ - radioLevel0->setEnabled(false); - radioLevel1->setEnabled(false); - }else{ - radioLevel0->setEnabled(mode0); - radioLevel1->setEnabled(mode1); - } - //default is allframes if checked button is disabled - if(!btnGroupScan->checkedButton()->isEnabled()) - radioAllFrames->setChecked(true); - } - } - - - //histogram - if(radioHistogram->isChecked()){ - if(radioHistIntensity->isChecked()){ - pageHistogram->setEnabled(true); - pageHistogram_2->setEnabled(true); - }else{ - pageHistogram->setEnabled(false); - pageHistogram_2->setEnabled(false); - } - stackedWidget->setCurrentIndex(stackedWidget->count()-1); - stackedWidget_2->setCurrentIndex(stackedWidget_2->count()-1); - box1D->setTitle(QString("1D Plot Options %1 - Histogram").arg(stackedWidget->currentIndex()+1)); - box2D->setTitle(QString("2D Plot Options %1 - Histogram").arg(stackedWidget_2->currentIndex()+1)); - - if(chkSuperimpose->isChecked()) chkSuperimpose->setChecked(false); - if(chkPedestal->isChecked()) chkPedestal->setChecked(false); - if(chkPedestal_2->isChecked()) chkPedestal_2->setChecked(false); - if(chkAccumulate->isChecked()) chkAccumulate->setChecked(false); - if(chkAccumulate_2->isChecked())chkAccumulate_2->setChecked(false); - if(chkBinary->isChecked()) chkBinary->setChecked(false); - if(chkBinary_2->isChecked()) chkBinary_2->setChecked(false); - pagePedestal->setEnabled(false); - pagePedestal_2->setEnabled(false); - chkBinary->setEnabled(false); - chkBinary_2->setEnabled(false); - pageAccumulate->setEnabled(false); - pageAccumulate_2->setEnabled(false); - - //read every frame - disconnect(spinNthFrame, SIGNAL(editingFinished()), this, SLOT(SetFrequency())); - disconnect(comboFrequency, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFrequency())); - comboFrequency->setCurrentIndex(1); - spinNthFrame->setValue(1); - SetFrequency(); - connect(spinNthFrame, SIGNAL(editingFinished()), this, SLOT(SetFrequency())); - connect(comboFrequency, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFrequency())); - - - }else{ - pageHistogram->setEnabled(false); - pageHistogram_2->setEnabled(false); - } - - - // if it was set to read every frame - if (oldfreqvalue != 0 && (comboFrequency->currentIndex() != 1 || spinNthFrame->value() != oldfreqvalue)) { - disconnect(spinNthFrame, SIGNAL(editingFinished()), this, SLOT(SetFrequency())); - disconnect(comboFrequency, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFrequency())); - comboFrequency->setCurrentIndex(1); - spinNthFrame->setValue(1); - SetFrequency(); - connect(spinNthFrame, SIGNAL(editingFinished()), this, SLOT(SetFrequency())); - connect(comboFrequency, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFrequency())); - } - - connect(btnGroupPlotType,SIGNAL(buttonClicked(int)),this, SLOT(SetPlot())); - connect(boxScan, SIGNAL(toggled(bool)), this, SLOT(EnableScanBox())); - -} + connect(btnGroupPlotType,SIGNAL(buttonClicked(int)),this, SLOT(SetPlot())); + connect(boxScan, SIGNAL(toggled(bool)), this, SLOT(EnableScanBox())); + } //------------------------------------------------------------------------------------------------------------------------------------------------- -void qTabPlot::SetScanArgument(){ -#ifdef VERYVERBOSE - cout << "Entering qTabPlot::SetScanArgument()" << endl; -#endif + void qTabPlot::SetScanArgument(){ + #ifdef VERYVERBOSE + cout << "Entering qTabPlot::SetScanArgument()" << endl; + #endif - //1d - if(isOriginallyOneD){ - dispXAxis->setText(defaultHistXAxisTitle); - dispYAxis->setText(defaultHistYAxisTitle); - myPlot->SetHistXAxisTitle(defaultHistXAxisTitle); - myPlot->SetHistYAxisTitle(defaultHistYAxisTitle); - Select1DPlot(true); - } - //2d - else{ - dispXAxis->setText(defaultImageXAxisTitle); - dispYAxis->setText(defaultImageYAxisTitle); - dispZAxis->setText(defaultImageZAxisTitle); - myPlot->SetImageXAxisTitle(defaultImageXAxisTitle); - myPlot->SetImageYAxisTitle(defaultImageYAxisTitle); - myPlot->SetImageZAxisTitle(defaultImageZAxisTitle); - Select1DPlot(false); - } + //1d + if(isOriginallyOneD){ + dispXAxis->setText(defaultHistXAxisTitle); + dispYAxis->setText(defaultHistYAxisTitle); + myPlot->SetHistXAxisTitle(defaultHistXAxisTitle); + myPlot->SetHistYAxisTitle(defaultHistYAxisTitle); + Select1DPlot(true); + } + //2d + else{ + dispXAxis->setText(defaultImageXAxisTitle); + dispYAxis->setText(defaultImageYAxisTitle); + dispZAxis->setText(defaultImageZAxisTitle); + myPlot->SetImageXAxisTitle(defaultImageXAxisTitle); + myPlot->SetImageYAxisTitle(defaultImageYAxisTitle); + myPlot->SetImageZAxisTitle(defaultImageZAxisTitle); + Select1DPlot(false); + } + //histogram default - set before setscanargument + int min = spinHistFrom->value(); + int max = spinHistTo->value(); + double size = spinHistSize->value(); + int histArg = qDefs::Intensity; + if(radioHistogram->isChecked()){ + if(!radioHistIntensity->isChecked()){ - //histogram default - set before setscanargument - int min = spinHistFrom->value(); - int max = spinHistTo->value(); - double size = spinHistSize->value(); - int histArg = qDefs::Intensity; - if(radioHistogram->isChecked()){ - if(!radioHistIntensity->isChecked()){ + int mode = 0; + histArg = qDefs::histLevel0; + if(radioHistLevel1->isChecked()){ + mode = 1; + histArg = qDefs::histLevel1; + } - int mode = 0; - histArg = qDefs::histLevel0; - if(radioHistLevel1->isChecked()){ - mode = 1; - histArg = qDefs::histLevel1; - } + int numSteps = myDet->getScanSteps(mode); + double *values = NULL; + min = 0;max = 1;size = 1; + if(numSteps > 0){ + values = new double[numSteps]; + myDet->getScanSteps(mode,values); + min = values[0]; + max = values[numSteps - 1]; + size = (max - min)/(numSteps - 1); + } + } - int numSteps = myDet->getScanSteps(mode); - double *values = NULL; - min = 0;max = 1;size = 1; + } - if(numSteps > 0){ - values = new double[numSteps]; - myDet->getScanSteps(mode,values); - min = values[0]; - max = values[numSteps - 1]; - size = (max - min)/(numSteps - 1); - } - } + //cout <<"min:"<SetHistogram(radioHistogram->isChecked(),histArg,min,max,size); - } + if(radioHistogram->isChecked()){ + if(radioHistIntensity->isChecked()) + dispXAxis->setText("Intensity"); + else if (radioHistLevel0->isChecked()) + dispXAxis->setText("Level 0"); + else + dispXAxis->setText("Level 1"); + dispYAxis->setText("Frequency"); + myPlot->SetHistXAxisTitle("Intensity"); + myPlot->SetHistYAxisTitle("Frequency"); + Select1DPlot(true); + } - //cout <<"min:"<SetHistogram(radioHistogram->isChecked(),histArg,min,max,size); + //angles (1D) + int ang; + if(myDet->getAngularConversion(ang)){ + dispXAxis->setText("Angles"); + myPlot->SetHistXAxisTitle("Angles"); + Select1DPlot(true); + } + //1d with scan + if(boxScan->isChecked()){ + myPlot->SetScanArgument(btnGroupScan->checkedId()+1); - if(radioHistogram->isChecked()){ - if(radioHistIntensity->isChecked()) - dispXAxis->setText("Intensity"); - else if (radioHistLevel0->isChecked()) - dispXAxis->setText("Level 0"); - else - dispXAxis->setText("Level 1"); - dispYAxis->setText("Frequency"); - myPlot->SetHistXAxisTitle("Intensity"); - myPlot->SetHistYAxisTitle("Frequency"); - Select1DPlot(true); - } + switch(btnGroupScan->checkedId()){ + case 0://level0 + dispYAxis->setText("Scan Level 0"); + myPlot->SetImageYAxisTitle("Scan Level 0"); + break; + case 1://level1 + dispYAxis->setText("Scan Level 1"); + myPlot->SetImageYAxisTitle("Scan Level 1"); + break; + break; + case 2://file index + dispYAxis->setText("Frame Index"); + myPlot->SetImageYAxisTitle("Frame Index"); + break; + case 3://all frames + dispYAxis->setText("All Frames"); + myPlot->SetImageYAxisTitle("All Frames"); + break; + } + Select1DPlot(false); + }else + myPlot->SetScanArgument(qDefs::None); - //angles (1D) - int ang; - if(myDet->getAngularConversion(ang)){ - dispXAxis->setText("Angles"); - myPlot->SetHistXAxisTitle("Angles"); - Select1DPlot(true); - } + //update the from and to labels to be enabled + SetBinary(); + qDefs::checkErrorMessage(myDet,"qTabPlot::SetScanArgument"); - //1d with scan - if(boxScan->isChecked()){ - myPlot->SetScanArgument(btnGroupScan->checkedId()+1); - - switch(btnGroupScan->checkedId()){ - case 0://level0 - dispYAxis->setText("Scan Level 0"); - myPlot->SetImageYAxisTitle("Scan Level 0"); - break; - case 1://level1 - dispYAxis->setText("Scan Level 1"); - myPlot->SetImageYAxisTitle("Scan Level 1"); - break; - break; - case 2://file index - dispYAxis->setText("Frame Index"); - myPlot->SetImageYAxisTitle("Frame Index"); - break; - case 3://all frames - dispYAxis->setText("All Frames"); - myPlot->SetImageYAxisTitle("All Frames"); - break; - } - Select1DPlot(false); - }else - myPlot->SetScanArgument(qDefs::None); - - //update the from and to labels to be enabled - SetBinary(); - - qDefs::checkErrorMessage(myDet,"qTabPlot::SetScanArgument"); - -} - + } //------------------------------------------------------------------------------------------------------------------------------------------------- +void qTabPlot::SetBinary() { + //1d + if (isOneD) { + if (chkBinary->isChecked()) { +#ifdef VERBOSE + cout << endl + << "Enabling Binary" << endl; +#endif + lblFrom->setEnabled(true); + lblTo->setEnabled(true); + spinFrom->setEnabled(true); + spinTo->setEnabled(true); + myPlot->SetBinary(true, spinFrom->value(), spinTo->value()); + } else { +#ifdef VERBOSE + cout << endl + << "Disabling Binary" << endl; +#endif + lblFrom->setEnabled(false); + lblTo->setEnabled(false); + spinFrom->setEnabled(false); + spinTo->setEnabled(false); + myPlot->SetBinary(false); + } + } + //2d + else { + if (chkBinary_2->isChecked()) { +#ifdef VERBOSE + cout << endl + << "Enabling Binary" << endl; +#endif + lblFrom_2->setEnabled(true); + lblTo_2->setEnabled(true); + spinFrom_2->setEnabled(true); + spinTo_2->setEnabled(true); + myPlot->SetBinary(true, spinFrom_2->value(), spinTo_2->value()); -void qTabPlot::SetBinary(){ - //1d - if(isOneD){ - if(chkBinary->isChecked()){ + } else { #ifdef VERBOSE - cout << endl << "Enabling Binary" << endl; -#endif - lblFrom->setEnabled(true); - lblTo->setEnabled(true); - spinFrom->setEnabled(true); - spinTo->setEnabled(true); - myPlot->SetBinary(true,spinFrom->value(),spinTo->value()); - }else{ -#ifdef VERBOSE - cout << endl << "Disabling Binary" << endl; -#endif - lblFrom->setEnabled(false); - lblTo->setEnabled(false); - spinFrom->setEnabled(false); - spinTo->setEnabled(false); - myPlot->SetBinary(false); - } - } - //2d - else{ - if(chkBinary_2->isChecked()){ -#ifdef VERBOSE - cout << endl << "Enabling Binary" << endl; -#endif - lblFrom_2->setEnabled(true); - lblTo_2->setEnabled(true); - spinFrom_2->setEnabled(true); - spinTo_2->setEnabled(true); - myPlot->SetBinary(true,spinFrom_2->value(),spinTo_2->value()); - - }else{ -#ifdef VERBOSE - cout << endl << "Disabling Binary" << endl; + cout << endl + << "Disabling Binary" << endl; #endif - lblFrom_2->setEnabled(false); - lblTo_2->setEnabled(false); - spinFrom_2->setEnabled(false); - spinTo_2->setEnabled(false); - myPlot->SetBinary(false); - } - } + lblFrom_2->setEnabled(false); + lblTo_2->setEnabled(false); + spinFrom_2->setEnabled(false); + spinTo_2->setEnabled(false); + myPlot->SetBinary(false); + } + } } - //------------------------------------------------------------------------------------------------------------------------------------------------- - -void qTabPlot::SetHistogramOptions(){ - if(radioHistIntensity->isChecked()){ - pageHistogram->setEnabled(true); - pageHistogram_2->setEnabled(true); - }else { - pageHistogram->setEnabled(false); - pageHistogram_2->setEnabled(false); - } +void qTabPlot::SetHistogramOptions() { + if (radioHistIntensity->isChecked()) { + pageHistogram->setEnabled(true); + pageHistogram_2->setEnabled(true); + } else { + pageHistogram->setEnabled(false); + pageHistogram_2->setEnabled(false); + } } - - //------------------------------------------------------------------------------------------------------------------------------------------------- - void qTabPlot::EnableGapPixels(bool enable) { #ifdef VERBOSE - cout << "Setting Gap pixels to " << enable << endl; + cout << "Setting Gap pixels to " << enable << endl; #endif - disconnect(chkGapPixels, SIGNAL(toggled(bool)),this, SLOT(EnableGapPixels(bool))); + disconnect(chkGapPixels, SIGNAL(toggled(bool)), this, SLOT(EnableGapPixels(bool))); myDet->enableGapPixels(enable); - int ret = myDet->enableGapPixels(-1); - qDefs::checkErrorMessage(myDet,"qTabPlot::SetScanArgument"); + int ret = myDet->enableGapPixels(-1); + qDefs::checkErrorMessage(myDet, "qTabPlot::SetScanArgument"); chkGapPixels->setChecked((ret == 1) ? true : false); - connect(chkGapPixels, SIGNAL(toggled(bool)),this, SLOT(EnableGapPixels(bool))); + connect(chkGapPixels, SIGNAL(toggled(bool)), this, SLOT(EnableGapPixels(bool))); } - //------------------------------------------------------------------------------------------------------------------------------------------------- - -void qTabPlot::Refresh(){ +void qTabPlot::Refresh() { #ifdef VERBOSE - cout << endl << "**Updating Plot Tab" << endl; + cout << endl + << "**Updating Plot Tab" << endl; #endif - if(!myPlot->isRunning()){ - if (!radioNoPlot->isChecked()) - boxFrequency->setEnabled(true); - connect(boxScan, SIGNAL(toggled(bool)), this, SLOT(EnableScanBox())); - EnableScanBox(); - /*if(myDet->getDetectorsType() == slsDetectorDefs::EIGER) - comboFrequency->setCurrentIndex(1);*/ - SetFrequency(); + if (!myPlot->isRunning()) { + if (!radioNoPlot->isChecked()) + boxFrequency->setEnabled(true); + SetFrequency(); - if (chkGapPixels->isEnabled()) { - disconnect(chkGapPixels, SIGNAL(toggled(bool)),this, SLOT(EnableGapPixels(bool))); - int ret = myDet->enableGapPixels(-1); - qDefs::checkErrorMessage(myDet,"qTabPlot::Refresh"); - chkGapPixels->setChecked((ret == 1) ? true : false); - connect(chkGapPixels, SIGNAL(toggled(bool)),this, SLOT(EnableGapPixels(bool))); - } + if (chkGapPixels->isEnabled()) { + disconnect(chkGapPixels, SIGNAL(toggled(bool)), this, SLOT(EnableGapPixels(bool))); + int ret = myDet->enableGapPixels(-1); + qDefs::checkErrorMessage(myDet, "qTabPlot::Refresh"); + chkGapPixels->setChecked((ret == 1) ? true : false); + connect(chkGapPixels, SIGNAL(toggled(bool)), this, SLOT(EnableGapPixels(bool))); + } - }else{ - boxFrequency->setEnabled(false); - disconnect(boxScan, SIGNAL(toggled(bool)), this, SLOT(EnableScanBox())); - boxScan->setEnabled(false); - pageHistogram->setEnabled(false); - pageHistogram_2->setEnabled(false); - if(radioHistogram->isChecked()) - radioDataGraph->setEnabled(false); - else - radioHistogram->setEnabled(false); - } + } else { + boxFrequency->setEnabled(false); + disconnect(boxScan, SIGNAL(toggled(bool)), this, SLOT(EnableScanBox())); + boxScan->setEnabled(false); + pageHistogram->setEnabled(false); + pageHistogram_2->setEnabled(false); + if (radioHistogram->isChecked()) + radioDataGraph->setEnabled(false); + else + radioHistogram->setEnabled(false); + } #ifdef VERBOSE - cout << "**Updated Plot Tab" << endl << endl; + cout << "**Updated Plot Tab" << endl + << endl; #endif } - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - diff --git a/slsDetectorGui/src/qTabSettings.cpp b/slsDetectorGui/src/qTabSettings.cpp old mode 100644 new mode 100755 index 1f9985080..b1d48f867 --- a/slsDetectorGui/src/qTabSettings.cpp +++ b/slsDetectorGui/src/qTabSettings.cpp @@ -1,385 +1,304 @@ -/* - * qTabSettings.cpp - * - * Created on: May 10, 2012 - * Author: l_maliakal_d - */ - #include "qTabSettings.h" -// Project Class Headers -#include "slsDetector.h" + #include "multiSlsDetector.h" -// C++ Include Headers -#include + +#include + #include -using namespace std; +#include -//------------------------------------------------------------------------------------------------------------------------------------------------- +qTabSettings::qTabSettings(QWidget *parent, multiSlsDetector *detector) + : QWidget(parent), myDet(detector), detType(slsDetectorDefs::GENERIC) { -qTabSettings::qTabSettings(QWidget *parent,multiSlsDetector*& detector): - QWidget(parent),myDet(detector),expertMode(false){ - - for(int i=0;igetDetectorTypeAsEnum(); + + // Settings + comboSettings->setCurrentIndex(UNINITIALIZED); + if (detType == slsDetectorDefs::MOENCH) { + lblSettings->setEnabled(false); + comboSettings->setEnabled(false); + } else { + SetupDetectorSettings(); + GetSettings(); + } + + // Dynamic Range + GetDynamicRange(); + // cannot change dr for other types + if (detType != slsDetectorDefs::EIGER) { + lblDynamicRange->setEnabled(false); + comboDynamicRange->setEnabled(false); + } + + // threshold energy + if (detType == slsDetectorDefs::EIGER) { + qDefs::IgnoreNonCriticalExceptions( + spinThreshold, + &QSpinBox::setValue, + myDet, + std::string("qTabSettings::SetupWidgetWindow"), + &multiSlsDetector::getThresholdEnergy, -1); + } else { + lblThreshold->setEnabled(false); + spinThreshold->setEnabled(false); + } } -//------------------------------------------------------------------------------------------------------------------------------------------------- +void qTabSettings::SetupDetectorSettings() { -void qTabSettings::SetupWidgetWindow(){ - // Detector Type - detType=myDet->getDetectorsType(); + // To be able to index items on a combo box + QStandardItemModel *model = + qobject_cast(comboSettings->model()); + if (model) { + QModelIndex index[NUMSETTINGS]; + QStandardItem *item[NUMSETTINGS]; + for (int i = 0; i < NUMSETTINGS; ++i) { + index[i] = model->index(i, comboSettings->modelColumn(), + comboSettings->rootModelIndex()); + item[i] = model->itemFromIndex(index[i]); + } - // Settings - if (detType != slsDetectorDefs::CHIPTESTBOARD) { - SetupDetectorSettings(); - } else - comboSettings->setEnabled(false); + item[(int)UNDEFINED]->setEnabled(false); + item[(int)UNINITIALIZED]->setEnabled(false); - //threshold - if((detType == slsDetectorDefs::MYTHEN) || (detType == slsDetectorDefs::EIGER)) - spinThreshold->setValue(myDet->getThresholdEnergy()); + switch (detType) { + case slsDetectorDefs::EIGER: + item[(int)STANDARD]->setEnabled(true); + item[(int)HIGHGAIN]->setEnabled(true); + item[(int)LOWGAIN]->setEnabled(true); + item[(int)VERYHIGHGAIN]->setEnabled(true); + item[(int)VERLOWGAIN]->setEnabled(true); - //expert mode is not enabled initially - lblThreshold->setEnabled(false); - spinThreshold->setEnabled(false); + item[(int)FAST]->setEnabled(false); + item[(int)DYNAMICGAIN]->setEnabled(false); + item[(int)MEDIUMGAIN]->setEnabled(false); + item[(int)LOWNOISE]->setEnabled(false); + item[(int)DYNAMICHG0]->setEnabled(false); + item[(int)FIXGAIN1]->setEnabled(false); + item[(int)FIXGAIN2]->setEnabled(false); + item[(int)FORCESWITCHG1]->setEnabled(false); + item[(int)FORCESWITCHG2]->setEnabled(false); + break; - // Number of Modules - spinNumModules->setMaximum(myDet->getMaxNumberOfModules()); - spinNumModules->setValue(myDet->setNumberOfModules()); + case slsDetectorDefs::GOTTHARD: + item[(int)HIGHGAIN]->setEnabled(true); + item[(int)DYNAMICGAIN]->setEnabled(true); + item[(int)LOWGAIN]->setEnabled(true); + item[(int)MEDIUMGAIN]->setEnabled(true); + item[(int)VERYHIGHGAIN]->setEnabled(true); - Initialization(); + item[(int)STANDARD]->setEnabled(false); + item[(int)FAST]->setEnabled(false); + item[(int)LOWNOISE]->setEnabled(false); + item[(int)DYNAMICHG0]->setEnabled(false); + item[(int)FIXGAIN1]->setEnabled(false); + item[(int)FIXGAIN2]->setEnabled(false); + item[(int)FORCESWITCHG1]->setEnabled(false); + item[(int)FORCESWITCHG2]->setEnabled(false); + item[(int)VERLOWGAIN]->setEnabled(false); + break; - // Dynamic Range - GetDynamicRange(); + case slsDetectorDefs::JUNGFRAU: + item[(int)DYNAMICGAIN]->setEnabled(true); + item[(int)DYNAMICHG0]->setEnabled(true); + item[(int)FIXGAIN1]->setEnabled(true); + item[(int)FIXGAIN2]->setEnabled(true); + item[(int)FORCESWITCHG1]->setEnabled(true); + item[(int)FORCESWITCHG2]->setEnabled(true); - qDefs::checkErrorMessage(myDet,"qTabSettings::SetupWidgetWindow"); + item[(int)STANDARD]->setEnabled(false); + item[(int)FAST]->setEnabled(false); + item[(int)HIGHGAIN]->setEnabled(false); + item[(int)LOWGAIN]->setEnabled(false); + item[(int)MEDIUMGAIN]->setEnabled(false); + item[(int)VERYHIGHGAIN]->setEnabled(false); + item[(int)LOWNOISE]->setEnabled(false); + item[(int)VERLOWGAIN]->setEnabled(false); + break; + + default: + FILE_LOG(logDEBUG) << "Unknown detector type. Exiting GUI."; + qDefs::Message(qDefs::CRITICAL, + "Unknown detector type. Exiting GUI.", + "qTabSettings::SetupDetectorSettings"); + exit(-1); + } + } } - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qTabSettings::GetDynamicRange(int setvalue){ -#ifdef VERBOSE - cout << "Getting dynamic range" << endl; -#endif - int ret = myDet->setDynamicRange(-1); - if(detType == slsDetectorDefs::MYTHEN) { - if(ret==24) - ret=32; - else if(ret==24) - cout<<"ret:"<setCurrentIndex(0); break; - case 16: comboDynamicRange->setCurrentIndex(1); break; - case 8: comboDynamicRange->setCurrentIndex(2); break; - case 4: comboDynamicRange->setCurrentIndex(3); break; - default: comboDynamicRange->setCurrentIndex(0); break; - } - connect(comboDynamicRange, SIGNAL(activated(int)), this, SLOT(SetDynamicRange(int))); +void qTabSettings::Initialization() { + // Settings + if (comboSettings->isEnabled()) + connect(comboSettings, SIGNAL(currentIndexChanged(int)), this, + SLOT(SetSettings(int))); + // Dynamic Range + if (comboDynamicRange->isEnabled()) + connect(comboDynamicRange, SIGNAL(activated(int)), this, + SLOT(SetDynamicRange(int))); + // Threshold + if (spinThreshold->isEnabled()) + connect(spinThreshold, SIGNAL(valueChanged(int)), this, + SLOT(SetEnergy())); } +void qTabSettings::GetSettings() { + FILE_LOG(logDEBUG) << "Getting settings"; -//------------------------------------------------------------------------------------------------------------------------------------------------- + int sett = qDefs::IgnoreNonCriticalExceptionsandReturn( + myDet, std::string("qTabSettings::SetupWidgetWindow"), + &multiSlsDetector::getSettings, -1); + FILE_LOG(logDEBUG) << "Settings from Detector:" << sett; -void qTabSettings::SetupDetectorSettings(){ - // Get detector settings from detector - int sett = (int)myDet->getSettings();cout<<"sett:"<(comboSettings->model()); - if (model) { - for(int i=0;iindex(i, comboSettings->modelColumn(), comboSettings->rootModelIndex()); - item[i] = model->itemFromIndex(index[i]); - } + if (sett == -1) + sett = UNDEFINED; + if (sett == slsDetectorDefs::UNDEFINED) + sett = UNDEFINED; + else if (sett == slsDetectorDefs::UNINITIALIZED) + sett = UNINITIALIZED; - switch(detType){ - case slsDetectorDefs::MYTHEN: - item[(int)Standard]->setEnabled(true); - item[(int)Fast]->setEnabled(true); - item[(int)HighGain]->setEnabled(true); - item[(int)DynamicGain]->setEnabled(false); - item[(int)LowGain]->setEnabled(false); - item[(int)MediumGain]->setEnabled(false); - item[(int)VeryHighGain]->setEnabled(false); - item[(int)LowNoise]->setEnabled(false); - item[(int)DynamicHG0]->setEnabled(false); - item[(int)FixGain1]->setEnabled(false); - item[(int)FixGain2]->setEnabled(false); - item[(int)ForceSwitchG1]->setEnabled(false); - item[(int)ForceSwitchG2]->setEnabled(false); - item[(int)VeryLowGain]->setEnabled(false); - break; - case slsDetectorDefs::EIGER: - item[(int)Standard]->setEnabled(true); - item[(int)Fast]->setEnabled(false); - item[(int)HighGain]->setEnabled(true); - item[(int)DynamicGain]->setEnabled(false); - item[(int)LowGain]->setEnabled(true); - item[(int)MediumGain]->setEnabled(false); - item[(int)VeryHighGain]->setEnabled(true); - item[(int)LowNoise]->setEnabled(false); - item[(int)DynamicHG0]->setEnabled(false); - item[(int)FixGain1]->setEnabled(false); - item[(int)FixGain2]->setEnabled(false); - item[(int)ForceSwitchG1]->setEnabled(false); - item[(int)ForceSwitchG2]->setEnabled(false); - item[(int)VeryLowGain]->setEnabled(true); - break; - case slsDetectorDefs::MOENCH: - case slsDetectorDefs::PROPIX: - case slsDetectorDefs::GOTTHARD: - item[(int)Standard]->setEnabled(false); - item[(int)Fast]->setEnabled(false); - item[(int)HighGain]->setEnabled(true); - item[(int)DynamicGain]->setEnabled(true); - item[(int)LowGain]->setEnabled(true); - item[(int)MediumGain]->setEnabled(true); - item[(int)VeryHighGain]->setEnabled(true); - item[(int)LowNoise]->setEnabled(false); - item[(int)DynamicHG0]->setEnabled(false); - item[(int)FixGain1]->setEnabled(false); - item[(int)FixGain2]->setEnabled(false); - item[(int)ForceSwitchG1]->setEnabled(false); - item[(int)ForceSwitchG2]->setEnabled(false); - item[(int)VeryLowGain]->setEnabled(false); - break; - case slsDetectorDefs::JUNGFRAU: - item[(int)Standard]->setEnabled(false); - item[(int)Fast]->setEnabled(false); - item[(int)HighGain]->setEnabled(false); - item[(int)DynamicGain]->setEnabled(true); - item[(int)LowGain]->setEnabled(false); - item[(int)MediumGain]->setEnabled(false); - item[(int)VeryHighGain]->setEnabled(false); - item[(int)LowNoise]->setEnabled(false); - item[(int)DynamicHG0]->setEnabled(true); - item[(int)FixGain1]->setEnabled(true); - item[(int)FixGain2]->setEnabled(true); - item[(int)ForceSwitchG1]->setEnabled(true); - item[(int)ForceSwitchG2]->setEnabled(true); - item[(int)VeryLowGain]->setEnabled(false); - break; - default: - cout << "Unknown detector type. Exiting GUI." << endl; - qDefs::Message(qDefs::CRITICAL,"Unknown detector type. Exiting GUI.","qTabSettings::SetupDetectorSettings"); - exit(-1); - break; - } - // detector settings selected NOT ENABLED. - // This should not happen -only if the server and gui has a mismatch - // on which all modes are allowed in detectors - if(!(item[sett]->isEnabled())){ - qDefs::Message(qDefs::CRITICAL,"Unknown Detector Settings retrieved from detector. Exiting GUI.","qTabSettings::SetupDetectorSettings"); -#ifdef VERBOSE - cout << "ERROR: Unknown Detector Settings retrieved from detector." << endl; -#endif - sett= Undefined; - // exit(-1); - } - // Setting the detector settings - else comboSettings->setCurrentIndex(sett); - } + comboSettings->setCurrentIndex(sett); } -//------------------------------------------------------------------------------------------------------------------------------------------------- +void qTabSettings::GetDynamicRange() { + FILE_LOG(logDEBUG) << "Getting dynamic range"; -void qTabSettings::Initialization(){ - // Settings - if (detType != slsDetectorDefs::CHIPTESTBOARD) - connect(comboSettings, SIGNAL(currentIndexChanged(int)), this, SLOT(setSettings(int))); - // Number of Modules - connect(spinNumModules, SIGNAL(valueChanged(int)), this, SLOT(SetNumberOfModules(int))); - // Dynamic Range - connect(comboDynamicRange, SIGNAL(activated(int)), this, SLOT(SetDynamicRange(int))); - // Threshold - connect(spinThreshold, SIGNAL(valueChanged(int)), this, SLOT(SetEnergy())); + int ret = qDefs::IgnoreNonCriticalExceptionsandReturn( + myDet, std::string("qTabSettings::GetDynamicRange"), + &multiSlsDetector::setDynamicRange, -1, -1); + + // set the final value on gui + switch (ret) { + case 32: + comboDynamicRange->setCurrentIndex(0); + break; + case 16: + comboDynamicRange->setCurrentIndex(1); + break; + case 8: + comboDynamicRange->setCurrentIndex(2); + break; + case 4: + comboDynamicRange->setCurrentIndex(3); + break; + default: + if (ret != -1) { + qDefs::Message(qDefs::WARNING, + "Unknown Dyanmic Range " + std::to_string(ret) + ".", + "qTabSettings::SetupDetectorSettings"); + } + break; + } } -//------------------------------------------------------------------------------------------------------------------------------------------------- +void qTabSettings::SetSettings(int index) { + slsDetectorDefs::detectorSettings sett = + myDet->setSettings((slsDetectorDefs::detectorSettings)index); + FILE_LOG(logINFO) << "Settings set to " + << myDet->slsDetectorDefs::getDetectorSettings(sett); -void qTabSettings::setSettings(int index){ - //dont set it if settings is set to undefined or uninitialized - if((index==Undefined)||(index==Uninitialized)){ - qDefs::Message(qDefs::WARNING,"Cannot change settings to Undefined or Uninitialized.","qTabSettings::setSettings"); - disconnect(comboSettings, SIGNAL(currentIndexChanged(int)), this, SLOT(setSettings(int))); - int sett = (int)myDet->getSettings(); - if(sett==-1) sett = Undefined; - if(sett == slsDetectorDefs::UNDEFINED) sett = Undefined; - else if(sett == slsDetectorDefs::UNINITIALIZED) sett = Uninitialized; - comboSettings->setCurrentIndex(sett); - connect(comboSettings, SIGNAL(currentIndexChanged(int)), this, SLOT(setSettings(int))); - } + // threshold + if (spinThreshold->isEnabled()) { + SetEnergy(); + } - else{ - slsDetectorDefs::detectorSettings sett = myDet->setSettings((slsDetectorDefs::detectorSettings)index); - #ifdef VERBOSE - cout << endl << "Settings have been set to " << myDet->slsDetectorDefs::getDetectorSettings(sett) << endl; - #endif - - //threshold - if((detType==slsDetectorDefs::MYTHEN)||(detType==slsDetectorDefs::EIGER)){ - lblThreshold->setEnabled(true); - spinThreshold->setEnabled(true); - SetEnergy(); - //also update trimbits plot - if(expertMode) emit UpdateTrimbitSignal(0); - } - } - - qDefs::checkErrorMessage(myDet,"qTabSettings::setSettings"); + qDefs::checkErrorMessage(myDet, "qTabSettings::SetSettings"); } -//------------------------------------------------------------------------------------------------------------------------------------------------- +void qTabSettings::SetDynamicRange(int index) { + int dr; + switch (index) { + case 0: + dr = 32; + break; + case 1: + dr = 16; + break; + case 2: + dr = 8; + break; + case 3: + dr = 4; + break; + default: + break; + } + int ret = myDet->setDynamicRange(dr); + FILE_LOG(logINFO) << "Setting dynamic range to " << dr; + qDefs::checkErrorMessage(myDet, "qTabSettings::SetDynamicRange"); -void qTabSettings::SetNumberOfModules(int index){ -#ifdef VERBOSE - cout << "Setting number of modules to "<< index << endl; -#endif - int i = myDet->setNumberOfModules(index); - if(index!=i) - qDefs::Message(qDefs::WARNING,"Number of modules cannot be set for this value.","qTabSettings::SetNumberOfModules"); -#ifdef VERBOSE - cout << "ERROR: Setting number of modules to "<< i << endl; -#endif - spinNumModules->setValue(i); - - qDefs::checkErrorMessage(myDet,"qTabSettings::SetNumberOfModules"); + // check + if (ret != dr) { + qDefs::Message(qDefs::WARNING, "Could not set dynamic range.", + "qTabSettings::SetDynamicRange"); + disconnect(comboDynamicRange, SIGNAL(activated(int)), this, + SLOT(SetDynamicRange(int))); + GetDynamicRange(); + connect(comboDynamicRange, SIGNAL(activated(int)), this, + SLOT(SetDynamicRange(int))); + } } -//------------------------------------------------------------------------------------------------------------------------------------------------- +void qTabSettings::SetEnergy() { + int index = spinThreshold->value(); + FILE_LOG(logINFO) << "Settings threshold energy to " << index; + myDet->setThresholdEnergy(index); + int ret = myDet->getThresholdEnergy(); + if ((ret - index) > 200) { + qDefs::Message(qDefs::WARNING, + "Threshold energy could not be set (tolerance 200).", + "qTabSettings::SetEnergy"); + } + disconnect(spinThreshold, SIGNAL(valueChanged(int)), this, + SLOT(SetEnergy())); + spinThreshold->setValue(ret); + connect(spinThreshold, SIGNAL(valueChanged(int)), this, SLOT(SetEnergy())); -void qTabSettings::SetDynamicRange(int index){ - int dr; - switch (index) { - case 0: dr=32; break; - case 1: dr=16; break; - case 2: dr=8; break; - case 3: dr=4; break; - default: dr=32; break; - } - myDet->setDynamicRange(dr); -#ifdef VERBOSE - cout << "Setting dynamic range to "<< dr << endl; -#endif - //check - GetDynamicRange(dr); - qDefs::checkErrorMessage(myDet,"qTabSettings::SetDynamicRange"); + qDefs::checkErrorMessage(myDet, "qTabSettings::SetEnergy"); } +void qTabSettings::Refresh() { + FILE_LOG(logDEBUG) << "\n**Updating Settings Tab"; -//------------------------------------------------------------------------------------------------------------------------------------------------- + // settings + if (comboSettings->isEnabled()) { + disconnect(comboSettings, SIGNAL(currentIndexChanged(int)), this, + SLOT(SetSettings(int))); + GetSettings(); + connect(comboSettings, SIGNAL(currentIndexChanged(int)), this, + SLOT(SetSettings(int))); + } + // threshold + if (spinThreshold->isEnabled()) { + disconnect(spinThreshold, SIGNAL(valueChanged(int)), this, + SLOT(SetEnergy())); + spinThreshold->setValue(myDet->getThresholdEnergy()); + connect(spinThreshold, SIGNAL(valueChanged(int)), this, + SLOT(SetEnergy())); + } -void qTabSettings::SetEnergy(){ - int index = spinThreshold->value(); -#ifdef VERBOSE - cout << "Settings threshold energy to "<< index << endl; -#endif - myDet->setThresholdEnergy(index); - int ret = (int)myDet->getThresholdEnergy(); - if((ret-index)>200){ - qDefs::Message(qDefs::WARNING,"Threshold energy could not be set. The difference is greater than 200.","qTabSettings::SetEnergy"); - } - disconnect(spinThreshold, SIGNAL(valueChanged(int)), this, SLOT(SetEnergy())); - spinThreshold->setValue(ret); - connect(spinThreshold, SIGNAL(valueChanged(int)), this, SLOT(SetEnergy())); + // Dynamic Range + if (comboDynamicRange->isEnabled()) { + disconnect(comboDynamicRange, SIGNAL(activated(int)), this, + SLOT(SetDynamicRange(int))); + GetDynamicRange(); + connect(comboDynamicRange, SIGNAL(activated(int)), this, + SLOT(SetDynamicRange(int))); + } - qDefs::checkErrorMessage(myDet,"qTabSettings::SetEnergy"); + FILE_LOG(logDEBUG) << "**Updated Settings Tab"; + + qDefs::checkErrorMessage(myDet, "qTabSettings::Refresh"); } - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qTabSettings::Refresh(){ -#ifdef VERBOSE - cout << endl << "**Updating Settings Tab" << endl; -#endif - - if (detType != slsDetectorDefs::CHIPTESTBOARD) - disconnect(comboSettings, SIGNAL(currentIndexChanged(int)), this, SLOT(setSettings(int))); - disconnect(spinNumModules, SIGNAL(valueChanged(int)), this, SLOT(SetNumberOfModules(int))); - disconnect(spinThreshold, SIGNAL(valueChanged(int)), this, SLOT(SetEnergy())); - - - // Number of Modules -#ifdef VERBOSE - cout << "Getting number of modules:" ; -#endif - int numMod = myDet->setNumberOfModules(); -#ifdef VERBOSE - cout << numMod << endl; -#endif - spinNumModules->setValue(numMod); - - // Dynamic Range - GetDynamicRange(); - - // Settings - if (detType != slsDetectorDefs::CHIPTESTBOARD) { -#ifdef VERBOSE - cout << "Getting settings" << endl; -#endif - int sett = (int)myDet->getSettings(); - if(sett==-1) sett = Undefined;//slsDetectorDefs::UNDEFINED; - if(sett == slsDetectorDefs::UNDEFINED) sett = Undefined; - else if(sett == slsDetectorDefs::UNINITIALIZED) sett = Uninitialized; - comboSettings->setCurrentIndex(sett); - - //threshold - sett = comboSettings->currentIndex(); - if((detType==slsDetectorDefs::MYTHEN)||(detType==slsDetectorDefs::EIGER)){ - if((sett==Undefined)||(sett==Uninitialized)){ - lblThreshold->setEnabled(false); - spinThreshold->setEnabled(false); - }else{ - lblThreshold->setEnabled(true); - spinThreshold->setEnabled(true); -#ifdef VERBOSE - cout << "Getting threshold energy" << endl; -#endif - spinThreshold->setValue(myDet->getThresholdEnergy()); - } - } -} - - if (detType != slsDetectorDefs::CHIPTESTBOARD) - connect(comboSettings, SIGNAL(currentIndexChanged(int)), this, SLOT(setSettings(int))); - connect(spinNumModules, SIGNAL(valueChanged(int)), this, SLOT(SetNumberOfModules(int))); - connect(spinThreshold, SIGNAL(valueChanged(int)), this, SLOT(SetEnergy())); - -#ifdef VERBOSE - cout << "**Updated Settings Tab" << endl << endl; -#endif - - qDefs::checkErrorMessage(myDet,"qTabSettings::Refresh"); -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- diff --git a/slsDetectorGui/updateGitVersion.sh b/slsDetectorGui/updateGitVersion.sh deleted file mode 100755 index f82322712..000000000 --- a/slsDetectorGui/updateGitVersion.sh +++ /dev/null @@ -1,26 +0,0 @@ -MAINDIR=slsDetectorsPackage -SPECDIR=slsDetectorGui -TMPFILE=include/gitInfoGuiTmp.h -INCLFILE=include/gitInfoGui.h -WD=$PWD - -#evaluate the variables -EVALFILE=../evalVersionVariables.sh -source $EVALFILE - -#get modified date -#RDATE1='git log --pretty=format:"%ci" -1' -RDATE1="find . -type f -exec stat --format '%Y :%y %n' '{}' \; | sort -nr | cut -d: -f2- | egrep -v 'gitInfo|build|.git|updateGitVersion|ui*.h|*.o|Makefile.gui' | head -n 1" -RDATE=`eval $RDATE1` -NEWDATE=$(sed "s/-//g" <<< $RDATE | awk '{print $1;}') -NEWDATE=${NEWDATE/#/0x} - -#get old date from INCLFILE -OLDDATE=$(more $INCLFILE | grep '#define GITDATE' | awk '{print $3}') -#update INCLFILE if changes -#if [ "$OLDDATE" != "$NEWDATE" ]; then - echo Path: ${MAINDIR}/${SPECDIR} $'\n'URL: ${GITREPO} $'\n'Repository Root: ${GITREPO} $'\n'Repsitory UUID: ${REPUID} $'\n'Revision: ${FOLDERREV} $'\n'Branch: ${BRANCH} $'\n'Last Changed Author: ${AUTH1}_${AUTH2} $'\n'Last Changed Rev: ${REV} $'\n'Last Changed Date: ${RDATE} > gitInfo.txt - cd .. - ./genVersionHeader.sh $SPECDIR/gitInfo.txt $SPECDIR/$TMPFILE $SPECDIR/$INCLFILE - cd $WD -#fi diff --git a/slsDetectorServers/ctbDetectorServer/Makefile b/slsDetectorServers/ctbDetectorServer/Makefile index a6a3e48a3..b26f833d1 100755 --- a/slsDetectorServers/ctbDetectorServer/Makefile +++ b/slsDetectorServers/ctbDetectorServer/Makefile @@ -14,8 +14,11 @@ all: clean versioning $(PROGS) boot: $(OBJS) +version_name=APICTB +version_path=slsDetectorServers/ctbDetectorServer versioning: - @echo `tput setaf 6; ./updateGitVersion.sh; tput sgr0;` + cd ../../ && echo $(PWD) && echo `tput setaf 6; ./updateAPIVersion.sh $(version_name) $(version_path); tput sgr0;` + $(PROGS): $(OBJS) # echo $(OBJS) diff --git a/slsDetectorServers/ctbDetectorServer/Makefile.virtual b/slsDetectorServers/ctbDetectorServer/Makefile.virtual old mode 100644 new mode 100755 diff --git a/slsDetectorServers/ctbDetectorServer/RegisterDefs.h b/slsDetectorServers/ctbDetectorServer/RegisterDefs.h old mode 100644 new mode 100755 diff --git a/slsDetectorServers/ctbDetectorServer/gitInfo.txt b/slsDetectorServers/ctbDetectorServer/gitInfo.txt deleted file mode 100644 index e2f214e14..000000000 --- a/slsDetectorServers/ctbDetectorServer/gitInfo.txt +++ /dev/null @@ -1,9 +0,0 @@ -Path: slsDetectorPackage/slsDetectorServers/ctbDetectorServer -URL: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git -Repository Root: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git -Repsitory UUID: c284b2439746a148dcdb1249d9f95ce1c6bf06dd -Revision: 53 -Branch: refactor -Last Changed Author: Erik_Frojdh -Last Changed Rev: 4519 -Last Changed Date: 2019-04-04 11:50:16.000000002 +0200 ./slsDetectorServer_defs.h diff --git a/slsDetectorServers/ctbDetectorServer/gitInfoCtb.h b/slsDetectorServers/ctbDetectorServer/gitInfoCtb.h deleted file mode 100644 index ccd6b05cc..000000000 --- a/slsDetectorServers/ctbDetectorServer/gitInfoCtb.h +++ /dev/null @@ -1,6 +0,0 @@ -#define GITURL "git@github.com:slsdetectorgroup/slsDetectorPackage.git" -#define GITREPUUID "c284b2439746a148dcdb1249d9f95ce1c6bf06dd" -#define GITAUTH "Erik_Frojdh" -#define GITREV 0x4519 -#define GITDATE 0x20190404 -#define GITBRANCH "refactor" diff --git a/slsDetectorServers/ctbDetectorServer/gitInfoCtbTmp.h b/slsDetectorServers/ctbDetectorServer/gitInfoCtbTmp.h deleted file mode 100644 index dfd9bb246..000000000 --- a/slsDetectorServers/ctbDetectorServer/gitInfoCtbTmp.h +++ /dev/null @@ -1,6 +0,0 @@ -#define GITURL "" -#define GITREPUUID "" -#define GITAUTH "" -#define GITREV "" -#define GITDATE "" -#define GITBRANCH "" diff --git a/slsDetectorServers/ctbDetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/ctbDetectorServer/slsDetectorFunctionList.c old mode 100644 new mode 100755 index aab345f1d..4df427af2 --- a/slsDetectorServers/ctbDetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/ctbDetectorServer/slsDetectorFunctionList.c @@ -1,5 +1,4 @@ #include "slsDetectorFunctionList.h" -#include "gitInfoCtb.h" #include "versionAPI.h" #include "logger.h" @@ -343,7 +342,6 @@ int64_t getDetectorId(enum idMode arg){ case SOFTWARE_FIRMWARE_API_VERSION: return getFirmwareAPIVersion(); case DETECTOR_SOFTWARE_VERSION: - return (GITDATE & 0xFFFFFF); case CLIENT_SOFTWARE_API_VERSION: return APICTB; default: diff --git a/slsDetectorServers/ctbDetectorServer/slsDetectorServer_defs.h b/slsDetectorServers/ctbDetectorServer/slsDetectorServer_defs.h old mode 100644 new mode 100755 diff --git a/slsDetectorServers/ctbDetectorServer/updateAPIVersion.sh b/slsDetectorServers/ctbDetectorServer/updateAPIVersion.sh deleted file mode 100755 index 783125033..000000000 --- a/slsDetectorServers/ctbDetectorServer/updateAPIVersion.sh +++ /dev/null @@ -1,7 +0,0 @@ -SRCFILE=gitInfoCtb.h -DSTFILE=versionAPI.h - -SRCPATTERN=GITDATE -DSTPATTERN=APICTB - -awk -v a="$SRCFILE" -v b="$DSTFILE" -v c="$SRCPATTERN" -v d="$DSTPATTERN" 'FNR==NR&&$2==c{x=$3} NR!=FNR{if($2==d){$3="0x"substr(x,5)}print > b}' $SRCFILE $DSTFILE \ No newline at end of file diff --git a/slsDetectorServers/ctbDetectorServer/updateGitVersion.sh b/slsDetectorServers/ctbDetectorServer/updateGitVersion.sh deleted file mode 100755 index 0ffe552c9..000000000 --- a/slsDetectorServers/ctbDetectorServer/updateGitVersion.sh +++ /dev/null @@ -1,31 +0,0 @@ -SERVER=ctbDetectorServer -MAINDIR=slsDetectorPackage -SPECDIR=slsDetectorServers/$SERVER -TMPFILE=gitInfoCtbTmp.h -INCLFILE=gitInfoCtb.h - - -#evaluate the variables -EVALFILE=../../evalVersionVariables.sh -source $EVALFILE - - -#get modified date -#RDATE1='git log --pretty=format:"%ci" -1' -RDATE1="find ../slsDetectorServer . -type f -exec stat --format '%Y :%y %n' '{}' \; | sort -nr | cut -d: -f2- | egrep -v '(\.)o' | egrep -v '(gitInfo).*' | egrep -v bin | egrep -v 'updateGit' | head -n 1" -RDATE=`eval $RDATE1` -NEWDATE=$(sed "s/-//g" <<< $RDATE | awk '{print $1;}') -NEWDATE=${NEWDATE/#/0x} - - -#get old date from INCLFILE -OLDDATE=$(more $INCLFILE | grep '#define GITDATE' | awk '{print $3}') - - -#update INCLFILE if changes -if [ "$OLDDATE" != "$NEWDATE" ]; then - echo Path: ${MAINDIR}/${SPECDIR} $'\n'URL: ${GITREPO} $'\n'Repository Root: ${GITREPO} $'\n'Repsitory UUID: ${REPUID} $'\n'Revision: ${FOLDERREV} $'\n'Branch: ${BRANCH} $'\n'Last Changed Author: ${AUTH1}_${AUTH2} $'\n'Last Changed Rev: ${REV} $'\n'Last Changed Date: ${RDATE} > gitInfo.txt - cd ../../ - ./genVersionHeader.sh $SPECDIR/gitInfo.txt $SPECDIR/$TMPFILE $SPECDIR/$INCLFILE - cd $WD -fi \ No newline at end of file diff --git a/slsDetectorServers/eigerDetectorServer/9mhvserial_bf.c b/slsDetectorServers/eigerDetectorServer/9mhvserial_bf.c old mode 100644 new mode 100755 diff --git a/slsDetectorServers/eigerDetectorServer/Beb.c b/slsDetectorServers/eigerDetectorServer/Beb.c old mode 100644 new mode 100755 diff --git a/slsDetectorServers/eigerDetectorServer/Beb.h b/slsDetectorServers/eigerDetectorServer/Beb.h old mode 100644 new mode 100755 diff --git a/slsDetectorServers/eigerDetectorServer/FebControl.c b/slsDetectorServers/eigerDetectorServer/FebControl.c old mode 100644 new mode 100755 diff --git a/slsDetectorServers/eigerDetectorServer/FebControl.h b/slsDetectorServers/eigerDetectorServer/FebControl.h old mode 100644 new mode 100755 diff --git a/slsDetectorServers/eigerDetectorServer/FebInterface.c b/slsDetectorServers/eigerDetectorServer/FebInterface.c old mode 100644 new mode 100755 diff --git a/slsDetectorServers/eigerDetectorServer/FebInterface.h b/slsDetectorServers/eigerDetectorServer/FebInterface.h old mode 100644 new mode 100755 diff --git a/slsDetectorServers/eigerDetectorServer/FebRegisterDefs.h b/slsDetectorServers/eigerDetectorServer/FebRegisterDefs.h old mode 100644 new mode 100755 diff --git a/slsDetectorServers/eigerDetectorServer/HardwareIO.c b/slsDetectorServers/eigerDetectorServer/HardwareIO.c old mode 100644 new mode 100755 diff --git a/slsDetectorServers/eigerDetectorServer/HardwareIO.h b/slsDetectorServers/eigerDetectorServer/HardwareIO.h old mode 100644 new mode 100755 diff --git a/slsDetectorServers/eigerDetectorServer/HardwareMMappingDefs.h b/slsDetectorServers/eigerDetectorServer/HardwareMMappingDefs.h old mode 100644 new mode 100755 diff --git a/slsDetectorServers/eigerDetectorServer/LocalLinkInterface.c b/slsDetectorServers/eigerDetectorServer/LocalLinkInterface.c old mode 100644 new mode 100755 diff --git a/slsDetectorServers/eigerDetectorServer/LocalLinkInterface.h b/slsDetectorServers/eigerDetectorServer/LocalLinkInterface.h old mode 100644 new mode 100755 diff --git a/slsDetectorServers/eigerDetectorServer/Makefile b/slsDetectorServers/eigerDetectorServer/Makefile index 150c3a208..88ec734f7 100755 --- a/slsDetectorServers/eigerDetectorServer/Makefile +++ b/slsDetectorServers/eigerDetectorServer/Makefile @@ -17,8 +17,11 @@ all: clean versioning $(PROGS) #hv9m_blackfin_server boot: $(OBJS) -versioning: - @echo `tput setaf 6; ./updateGitVersion.sh; tput sgr0;` +version_name=APIEIGER +version_path=slsDetectorServers/eigerDetectorServer +versioning: + cd ../../ && echo $(PWD) && echo `tput setaf 6; ./updateAPIVersion.sh $(version_name) $(version_path); tput sgr0;` + $(PROGS): $(OBJS) # echo $(OBJS) diff --git a/slsDetectorServers/eigerDetectorServer/Makefile.virtual b/slsDetectorServers/eigerDetectorServer/Makefile.virtual old mode 100644 new mode 100755 diff --git a/slsDetectorServers/eigerDetectorServer/gitInfo.txt b/slsDetectorServers/eigerDetectorServer/gitInfo.txt deleted file mode 100644 index 3390e70c3..000000000 --- a/slsDetectorServers/eigerDetectorServer/gitInfo.txt +++ /dev/null @@ -1,9 +0,0 @@ -Path: slsDetectorPackage/slsDetectorServers/eigerDetectorServer -URL: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git -Repository Root: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git -Repsitory UUID: 45b837b42a9f190cb68688fd2b1a8d77c3050578 -Revision: 33 -Branch: program2 -Last Changed Author: Dhanya_Thattil -Last Changed Rev: 4490 -Last Changed Date: 2019-04-02 14:46:09.000000002 +0200 ../slsDetectorServer/slsDetectorServer_funcs.c diff --git a/slsDetectorServers/eigerDetectorServer/gitInfoEiger.h b/slsDetectorServers/eigerDetectorServer/gitInfoEiger.h deleted file mode 100644 index 7cb23e08f..000000000 --- a/slsDetectorServers/eigerDetectorServer/gitInfoEiger.h +++ /dev/null @@ -1,6 +0,0 @@ -#define GITURL "git@github.com:slsdetectorgroup/slsDetectorPackage.git" -#define GITREPUUID "45b837b42a9f190cb68688fd2b1a8d77c3050578" -#define GITAUTH "Dhanya_Thattil" -#define GITREV 0x4490 -#define GITDATE 0x20190402 -#define GITBRANCH "program2" diff --git a/slsDetectorServers/eigerDetectorServer/gitInfoEigerTmp.h b/slsDetectorServers/eigerDetectorServer/gitInfoEigerTmp.h deleted file mode 100644 index dfd9bb246..000000000 --- a/slsDetectorServers/eigerDetectorServer/gitInfoEigerTmp.h +++ /dev/null @@ -1,6 +0,0 @@ -#define GITURL "" -#define GITREPUUID "" -#define GITAUTH "" -#define GITREV "" -#define GITDATE "" -#define GITBRANCH "" diff --git a/slsDetectorServers/eigerDetectorServer/renameServer.sh b/slsDetectorServers/eigerDetectorServer/renameServer.sh old mode 100644 new mode 100755 diff --git a/slsDetectorServers/eigerDetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/eigerDetectorServer/slsDetectorFunctionList.c old mode 100644 new mode 100755 index a61dc9698..ca5614029 --- a/slsDetectorServers/eigerDetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/eigerDetectorServer/slsDetectorFunctionList.c @@ -1,5 +1,4 @@ #include "slsDetectorFunctionList.h" -#include "gitInfoEiger.h" #include "versionAPI.h" #include "logger.h" #include "common.h" @@ -195,7 +194,6 @@ int64_t getDetectorId(enum idMode arg) { case SOFTWARE_FIRMWARE_API_VERSION: return (int64_t)getFirmwareAPIVersion(); case DETECTOR_SOFTWARE_VERSION: - return (GITDATE & 0xFFFFFF); case CLIENT_SOFTWARE_API_VERSION: return APIEIGER; default: @@ -1182,7 +1180,7 @@ void setTiming( enum externalCommunicationMode arg) { case AUTO_TIMING: ret = 0; break; case TRIGGER_EXPOSURE: ret = 2; break; case BURST_TRIGGER: ret = 1; break; - case GATE_FIX_NUMBER: ret = 3; break; + case GATED: ret = 3; break; } FILE_LOG(logDEBUG1, ("Setting Triggering Mode: %d\n", (int)ret)); #ifndef VIRTUAL @@ -1200,7 +1198,7 @@ enum externalCommunicationMode getTiming() { case 0: ret = AUTO_TIMING; break; case 2: ret = TRIGGER_EXPOSURE; break; case 1: ret = BURST_TRIGGER; break; - case 3: ret = GATE_FIX_NUMBER; break; + case 3: ret = GATED; break; default: FILE_LOG(logERROR, ("Unknown trigger mode found %d\n", ret)); ret = 0; diff --git a/slsDetectorServers/eigerDetectorServer/slsDetectorServer_defs.h b/slsDetectorServers/eigerDetectorServer/slsDetectorServer_defs.h old mode 100644 new mode 100755 diff --git a/slsDetectorServers/eigerDetectorServer/updateAPIVersion.sh b/slsDetectorServers/eigerDetectorServer/updateAPIVersion.sh deleted file mode 100755 index 618a9b601..000000000 --- a/slsDetectorServers/eigerDetectorServer/updateAPIVersion.sh +++ /dev/null @@ -1,7 +0,0 @@ -SRCFILE=gitInfoEiger.h -DSTFILE=versionAPI.h - -SRCPATTERN=GITDATE -DSTPATTERN=APIEIGER - -awk -v a="$SRCFILE" -v b="$DSTFILE" -v c="$SRCPATTERN" -v d="$DSTPATTERN" 'FNR==NR&&$2==c{x=$3} NR!=FNR{if($2==d){$3="0x"substr(x,5)}print > b}' $SRCFILE $DSTFILE \ No newline at end of file diff --git a/slsDetectorServers/eigerDetectorServer/updateGitVersion.sh b/slsDetectorServers/eigerDetectorServer/updateGitVersion.sh deleted file mode 100755 index 8f57ac890..000000000 --- a/slsDetectorServers/eigerDetectorServer/updateGitVersion.sh +++ /dev/null @@ -1,32 +0,0 @@ -SERVER=eigerDetectorServer -MAINDIR=slsDetectorPackage -SPECDIR=slsDetectorServers/$SERVER -TMPFILE=gitInfoEigerTmp.h -INCLFILE=gitInfoEiger.h - -#evaluate the variables -EVALFILE=../../evalVersionVariables.sh -source $EVALFILE - - -#get modified date -#RDATE1='git log --pretty=format:"%ci" -1' -RDATE1="find ../slsDetectorServer . -type f -exec stat --format '%Y :%y %n' '{}' \; | sort -nr | cut -d: -f2- | egrep -v '(\.)o' | egrep -v '(gitInfo).*' | egrep -v bin | egrep -v 'updateGit' | head -n 1" -RDATE=`eval $RDATE1` -NEWDATE=$(sed "s/-//g" <<< $RDATE | awk '{print $1;}') -NEWDATE=${NEWDATE/#/0x} - - -#get old date from INCLFILE -OLDDATE=$(more $INCLFILE | grep '#define GITDATE' | awk '{print $3}') - - -#update INCLFILE if changes -if [ "$OLDDATE" != "$NEWDATE" ]; then - echo Path: ${MAINDIR}/${SPECDIR} $'\n'URL: ${GITREPO} $'\n'Repository Root: ${GITREPO} $'\n'Repsitory UUID: ${REPUID} $'\n'Revision: ${FOLDERREV} $'\n'Branch: ${BRANCH} $'\n'Last Changed Author: ${AUTH1}_${AUTH2} $'\n'Last Changed Rev: ${REV} $'\n'Last Changed Date: ${RDATE} > gitInfo.txt - cd ../../ - ./genVersionHeader.sh $SPECDIR/gitInfo.txt $SPECDIR/$TMPFILE $SPECDIR/$INCLFILE - cd $WD -fi - - diff --git a/slsDetectorServers/eigerDetectorServer/xfs_types.h b/slsDetectorServers/eigerDetectorServer/xfs_types.h old mode 100644 new mode 100755 diff --git a/slsDetectorServers/eigerDetectorServer/xparameters.h b/slsDetectorServers/eigerDetectorServer/xparameters.h old mode 100644 new mode 100755 diff --git a/slsDetectorServers/gotthardDetectorServer/Makefile b/slsDetectorServers/gotthardDetectorServer/Makefile index 453d2e635..9d606f0c6 100755 --- a/slsDetectorServers/gotthardDetectorServer/Makefile +++ b/slsDetectorServers/gotthardDetectorServer/Makefile @@ -15,8 +15,11 @@ all: clean versioning $(PROGS) boot: $(OBJS) +version_name=APIGOTTHARD +version_path=slsDetectorServers/gotthardDetectorServer versioning: - @echo `tput setaf 6; ./updateGitVersion.sh; tput sgr0;` + cd ../../ && echo $(PWD) && echo `tput setaf 6; ./updateAPIVersion.sh $(version_name) $(version_path); tput sgr0;` + $(PROGS): $(OBJS) # echo $(OBJS) diff --git a/slsDetectorServers/gotthardDetectorServer/config.txt b/slsDetectorServers/gotthardDetectorServer/config.txt old mode 100644 new mode 100755 diff --git a/slsDetectorServers/gotthardDetectorServer/gitInfo.txt b/slsDetectorServers/gotthardDetectorServer/gitInfo.txt deleted file mode 100644 index 5c32dd9cb..000000000 --- a/slsDetectorServers/gotthardDetectorServer/gitInfo.txt +++ /dev/null @@ -1,9 +0,0 @@ -Path: slsDetectorPackage/slsDetectorServers/gotthardDetectorServer -URL: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git -Repository Root: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git -Repsitory UUID: 45b837b42a9f190cb68688fd2b1a8d77c3050578 -Revision: 28 -Branch: program2 -Last Changed Author: Dhanya_Thattil -Last Changed Rev: 4490 -Last Changed Date: 2019-04-02 17:21:48.000000002 +0200 ./slsDetectorServer_defs.h diff --git a/slsDetectorServers/gotthardDetectorServer/gitInfoGotthard.h b/slsDetectorServers/gotthardDetectorServer/gitInfoGotthard.h deleted file mode 100644 index 7cb23e08f..000000000 --- a/slsDetectorServers/gotthardDetectorServer/gitInfoGotthard.h +++ /dev/null @@ -1,6 +0,0 @@ -#define GITURL "git@github.com:slsdetectorgroup/slsDetectorPackage.git" -#define GITREPUUID "45b837b42a9f190cb68688fd2b1a8d77c3050578" -#define GITAUTH "Dhanya_Thattil" -#define GITREV 0x4490 -#define GITDATE 0x20190402 -#define GITBRANCH "program2" diff --git a/slsDetectorServers/gotthardDetectorServer/gitInfoGotthardTmp.h b/slsDetectorServers/gotthardDetectorServer/gitInfoGotthardTmp.h deleted file mode 100644 index dfd9bb246..000000000 --- a/slsDetectorServers/gotthardDetectorServer/gitInfoGotthardTmp.h +++ /dev/null @@ -1,6 +0,0 @@ -#define GITURL "" -#define GITREPUUID "" -#define GITAUTH "" -#define GITREV "" -#define GITDATE "" -#define GITBRANCH "" diff --git a/slsDetectorServers/gotthardDetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/gotthardDetectorServer/slsDetectorFunctionList.c old mode 100644 new mode 100755 index 4409ef5ec..0c1c7ae38 --- a/slsDetectorServers/gotthardDetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/gotthardDetectorServer/slsDetectorFunctionList.c @@ -1,5 +1,4 @@ #include "slsDetectorFunctionList.h" -#include "gitInfoGotthard.h" #include "versionAPI.h" #include "logger.h" #include "RegisterDefs.h" @@ -275,7 +274,6 @@ int64_t getDetectorId(enum idMode arg){ case DETECTOR_FIRMWARE_VERSION: return getFirmwareVersion(); case DETECTOR_SOFTWARE_VERSION: - return (GITDATE & 0xFFFFFF); case CLIENT_SOFTWARE_API_VERSION: return APIGOTTHARD; default: diff --git a/slsDetectorServers/gotthardDetectorServer/slsDetectorServer_defs.h b/slsDetectorServers/gotthardDetectorServer/slsDetectorServer_defs.h old mode 100644 new mode 100755 diff --git a/slsDetectorServers/gotthardDetectorServer/updateAPIVersion.sh b/slsDetectorServers/gotthardDetectorServer/updateAPIVersion.sh deleted file mode 100755 index 2d5d8d04d..000000000 --- a/slsDetectorServers/gotthardDetectorServer/updateAPIVersion.sh +++ /dev/null @@ -1,7 +0,0 @@ -SRCFILE=gitInfoGotthard.h -DSTFILE=versionAPI.h - -SRCPATTERN=GITDATE -DSTPATTERN=APIGOTTHARD - -awk -v a="$SRCFILE" -v b="$DSTFILE" -v c="$SRCPATTERN" -v d="$DSTPATTERN" 'FNR==NR&&$2==c{x=$3} NR!=FNR{if($2==d){$3="0x"substr(x,5)}print > b}' $SRCFILE $DSTFILE \ No newline at end of file diff --git a/slsDetectorServers/gotthardDetectorServer/updateGitVersion.sh b/slsDetectorServers/gotthardDetectorServer/updateGitVersion.sh deleted file mode 100755 index c6af679a6..000000000 --- a/slsDetectorServers/gotthardDetectorServer/updateGitVersion.sh +++ /dev/null @@ -1,30 +0,0 @@ -SERVER=gotthardDetectorServer -MAINDIR=slsDetectorPackage -SPECDIR=slsDetectorServers/$SERVER -TMPFILE=gitInfoGotthardTmp.h -INCLFILE=gitInfoGotthard.h - -#evaluate the variables -EVALFILE=../../evalVersionVariables.sh -source $EVALFILE - - -#get modified date -#RDATE1='git log --pretty=format:"%ci" -1' -RDATE1="find ../slsDetectorServer . -type f -exec stat --format '%Y :%y %n' '{}' \; | sort -nr | cut -d: -f2- | egrep -v '(\.)o' | egrep -v '(gitInfo).*' | egrep -v bin | egrep -v 'updateGit' | head -n 1" -RDATE=`eval $RDATE1` -NEWDATE=$(sed "s/-//g" <<< $RDATE | awk '{print $1;}') -NEWDATE=${NEWDATE/#/0x} - - -#get old date from INCLFILE -OLDDATE=$(more $INCLFILE | grep '#define GITDATE' | awk '{print $3}') - - -#update INCLFILE if changes -if [ "$OLDDATE" != "$NEWDATE" ]; then - echo Path: ${MAINDIR}/${SPECDIR} $'\n'URL: ${GITREPO} $'\n'Repository Root: ${GITREPO} $'\n'Repsitory UUID: ${REPUID} $'\n'Revision: ${FOLDERREV} $'\n'Branch: ${BRANCH} $'\n'Last Changed Author: ${AUTH1}_${AUTH2} $'\n'Last Changed Rev: ${REV} $'\n'Last Changed Date: ${RDATE} > gitInfo.txt - cd ../../ - ./genVersionHeader.sh $SPECDIR/gitInfo.txt $SPECDIR/$TMPFILE $SPECDIR/$INCLFILE - cd $WD -fi diff --git a/slsDetectorServers/jungfrauDetectorServer/Makefile b/slsDetectorServers/jungfrauDetectorServer/Makefile index 850cbf826..f197d60dd 100755 --- a/slsDetectorServers/jungfrauDetectorServer/Makefile +++ b/slsDetectorServers/jungfrauDetectorServer/Makefile @@ -14,8 +14,11 @@ all: clean versioning $(PROGS) boot: $(OBJS) +version_name=APIJUNGFRAU +version_path=slsDetectorServers/jungfrauDetectorServer versioning: - @echo `tput setaf 6; ./updateGitVersion.sh; tput sgr0;` + cd ../../ && echo $(PWD) && echo `tput setaf 6; ./updateAPIVersion.sh $(version_name) $(version_path); tput sgr0;` + $(PROGS): $(OBJS) # echo $(OBJS) diff --git a/slsDetectorServers/jungfrauDetectorServer/Makefile.virtual b/slsDetectorServers/jungfrauDetectorServer/Makefile.virtual old mode 100644 new mode 100755 diff --git a/slsDetectorServers/jungfrauDetectorServer/RegisterDefs.h b/slsDetectorServers/jungfrauDetectorServer/RegisterDefs.h old mode 100644 new mode 100755 diff --git a/slsDetectorServers/jungfrauDetectorServer/gitInfo.txt b/slsDetectorServers/jungfrauDetectorServer/gitInfo.txt deleted file mode 100644 index b08798871..000000000 --- a/slsDetectorServers/jungfrauDetectorServer/gitInfo.txt +++ /dev/null @@ -1,9 +0,0 @@ -Path: slsDetectorPackage/slsDetectorServers/jungfrauDetectorServer -URL: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git -Repository Root: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git -Repsitory UUID: 45b837b42a9f190cb68688fd2b1a8d77c3050578 -Revision: 34 -Branch: program2 -Last Changed Author: Dhanya_Thattil -Last Changed Rev: 4490 -Last Changed Date: 2019-04-02 08:57:37.000000002 +0200 ../slsDetectorServer/slsDetectorServer_funcs.c diff --git a/slsDetectorServers/jungfrauDetectorServer/gitInfoJungfrau.h b/slsDetectorServers/jungfrauDetectorServer/gitInfoJungfrau.h deleted file mode 100644 index 7cb23e08f..000000000 --- a/slsDetectorServers/jungfrauDetectorServer/gitInfoJungfrau.h +++ /dev/null @@ -1,6 +0,0 @@ -#define GITURL "git@github.com:slsdetectorgroup/slsDetectorPackage.git" -#define GITREPUUID "45b837b42a9f190cb68688fd2b1a8d77c3050578" -#define GITAUTH "Dhanya_Thattil" -#define GITREV 0x4490 -#define GITDATE 0x20190402 -#define GITBRANCH "program2" diff --git a/slsDetectorServers/jungfrauDetectorServer/gitInfoJungfrauTmp.h b/slsDetectorServers/jungfrauDetectorServer/gitInfoJungfrauTmp.h deleted file mode 100644 index dfd9bb246..000000000 --- a/slsDetectorServers/jungfrauDetectorServer/gitInfoJungfrauTmp.h +++ /dev/null @@ -1,6 +0,0 @@ -#define GITURL "" -#define GITREPUUID "" -#define GITAUTH "" -#define GITREV "" -#define GITDATE "" -#define GITBRANCH "" diff --git a/slsDetectorServers/jungfrauDetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/jungfrauDetectorServer/slsDetectorFunctionList.c old mode 100644 new mode 100755 index 4f5766979..bf6721e63 --- a/slsDetectorServers/jungfrauDetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/jungfrauDetectorServer/slsDetectorFunctionList.c @@ -1,5 +1,4 @@ #include "slsDetectorFunctionList.h" -#include "gitInfoJungfrau.h" #include "versionAPI.h" #include "logger.h" @@ -265,8 +264,7 @@ int64_t getDetectorId(enum idMode arg){ case SOFTWARE_FIRMWARE_API_VERSION: return getFirmwareAPIVersion(); case DETECTOR_SOFTWARE_VERSION: - return (GITDATE & 0xFFFFFF); - case CLIENT_SOFTWARE_API_VERSION: + case CLIENT_SOFTWARE_API_VERSION: return APIJUNGFRAU; default: return retval; diff --git a/slsDetectorServers/jungfrauDetectorServer/slsDetectorServer_defs.h b/slsDetectorServers/jungfrauDetectorServer/slsDetectorServer_defs.h old mode 100644 new mode 100755 diff --git a/slsDetectorServers/jungfrauDetectorServer/updateAPIVersion.sh b/slsDetectorServers/jungfrauDetectorServer/updateAPIVersion.sh deleted file mode 100755 index ef65ec7e7..000000000 --- a/slsDetectorServers/jungfrauDetectorServer/updateAPIVersion.sh +++ /dev/null @@ -1,7 +0,0 @@ -SRCFILE=gitInfoJungfrau.h -DSTFILE=versionAPI.h - -SRCPATTERN=GITDATE -DSTPATTERN=APIJUNGFRAU - -awk -v a="$SRCFILE" -v b="$DSTFILE" -v c="$SRCPATTERN" -v d="$DSTPATTERN" 'FNR==NR&&$2==c{x=$3} NR!=FNR{if($2==d){$3="0x"substr(x,5)}print > b}' $SRCFILE $DSTFILE \ No newline at end of file diff --git a/slsDetectorServers/jungfrauDetectorServer/updateGitVersion.sh b/slsDetectorServers/jungfrauDetectorServer/updateGitVersion.sh deleted file mode 100755 index ce85b1e0c..000000000 --- a/slsDetectorServers/jungfrauDetectorServer/updateGitVersion.sh +++ /dev/null @@ -1,31 +0,0 @@ -SERVER=jungfrauDetectorServer -MAINDIR=slsDetectorPackage -SPECDIR=slsDetectorServers/$SERVER -TMPFILE=gitInfoJungfrauTmp.h -INCLFILE=gitInfoJungfrau.h - - -#evaluate the variables -EVALFILE=../../evalVersionVariables.sh -source $EVALFILE - - -#get modified date -#RDATE1='git log --pretty=format:"%ci" -1' -RDATE1="find ../slsDetectorServer . -type f -exec stat --format '%Y :%y %n' '{}' \; | sort -nr | cut -d: -f2- | egrep -v '(\.)o' | egrep -v '(gitInfo).*' | egrep -v bin | egrep -v 'updateGit' | head -n 1" -RDATE=`eval $RDATE1` -NEWDATE=$(sed "s/-//g" <<< $RDATE | awk '{print $1;}') -NEWDATE=${NEWDATE/#/0x} - - -#get old date from INCLFILE -OLDDATE=$(more $INCLFILE | grep '#define GITDATE' | awk '{print $3}') - - -#update INCLFILE if changes -if [ "$OLDDATE" != "$NEWDATE" ]; then - echo Path: ${MAINDIR}/${SPECDIR} $'\n'URL: ${GITREPO} $'\n'Repository Root: ${GITREPO} $'\n'Repsitory UUID: ${REPUID} $'\n'Revision: ${FOLDERREV} $'\n'Branch: ${BRANCH} $'\n'Last Changed Author: ${AUTH1}_${AUTH2} $'\n'Last Changed Rev: ${REV} $'\n'Last Changed Date: ${RDATE} > gitInfo.txt - cd ../../ - ./genVersionHeader.sh $SPECDIR/gitInfo.txt $SPECDIR/$TMPFILE $SPECDIR/$INCLFILE - cd $WD -fi \ No newline at end of file diff --git a/slsDetectorServers/moenchDetectorServer/Makefile b/slsDetectorServers/moenchDetectorServer/Makefile index f116954be..65960a021 100755 --- a/slsDetectorServers/moenchDetectorServer/Makefile +++ b/slsDetectorServers/moenchDetectorServer/Makefile @@ -14,8 +14,11 @@ all: clean versioning $(PROGS) boot: $(OBJS) +version_name=APIMOENCH +version_path=slsDetectorServers/moenchDetectorServer versioning: - @echo `tput setaf 6; ./updateGitVersion.sh; tput sgr0;` + cd ../../ && echo $(PWD) && echo `tput setaf 6; ./updateAPIVersion.sh $(version_name) $(version_path); tput sgr0;` + $(PROGS): $(OBJS) # echo $(OBJS) diff --git a/slsDetectorServers/moenchDetectorServer/Makefile.virtual b/slsDetectorServers/moenchDetectorServer/Makefile.virtual old mode 100644 new mode 100755 diff --git a/slsDetectorServers/moenchDetectorServer/RegisterDefs.h b/slsDetectorServers/moenchDetectorServer/RegisterDefs.h old mode 100644 new mode 100755 diff --git a/slsDetectorServers/moenchDetectorServer/gitInfo.txt b/slsDetectorServers/moenchDetectorServer/gitInfo.txt deleted file mode 100644 index 9ac1e348e..000000000 --- a/slsDetectorServers/moenchDetectorServer/gitInfo.txt +++ /dev/null @@ -1,9 +0,0 @@ -Path: slsDetectorPackage/slsDetectorServers/moenchDetectorServer -URL: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git -Repository Root: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git -Repsitory UUID: 45b837b42a9f190cb68688fd2b1a8d77c3050578 -Revision: 28 -Branch: program2 -Last Changed Author: Dhanya_Thattil -Last Changed Rev: 4490 -Last Changed Date: 2019-04-02 17:21:40.000000002 +0200 ./slsDetectorServer_defs.h diff --git a/slsDetectorServers/moenchDetectorServer/gitInfoMoench.h b/slsDetectorServers/moenchDetectorServer/gitInfoMoench.h deleted file mode 100644 index 7cb23e08f..000000000 --- a/slsDetectorServers/moenchDetectorServer/gitInfoMoench.h +++ /dev/null @@ -1,6 +0,0 @@ -#define GITURL "git@github.com:slsdetectorgroup/slsDetectorPackage.git" -#define GITREPUUID "45b837b42a9f190cb68688fd2b1a8d77c3050578" -#define GITAUTH "Dhanya_Thattil" -#define GITREV 0x4490 -#define GITDATE 0x20190402 -#define GITBRANCH "program2" diff --git a/slsDetectorServers/moenchDetectorServer/gitInfoMoenchTmp.h b/slsDetectorServers/moenchDetectorServer/gitInfoMoenchTmp.h deleted file mode 100644 index dfd9bb246..000000000 --- a/slsDetectorServers/moenchDetectorServer/gitInfoMoenchTmp.h +++ /dev/null @@ -1,6 +0,0 @@ -#define GITURL "" -#define GITREPUUID "" -#define GITAUTH "" -#define GITREV "" -#define GITDATE "" -#define GITBRANCH "" diff --git a/slsDetectorServers/moenchDetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/moenchDetectorServer/slsDetectorFunctionList.c old mode 100644 new mode 100755 index 1d6627c87..0a87846d6 --- a/slsDetectorServers/moenchDetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/moenchDetectorServer/slsDetectorFunctionList.c @@ -1,5 +1,4 @@ #include "slsDetectorFunctionList.h" -#include "gitInfoMoench.h" #include "versionAPI.h" #include "logger.h" @@ -340,7 +339,6 @@ int64_t getDetectorId(enum idMode arg){ case SOFTWARE_FIRMWARE_API_VERSION: return getFirmwareAPIVersion(); case DETECTOR_SOFTWARE_VERSION: - return (GITDATE & 0xFFFFFF); case CLIENT_SOFTWARE_API_VERSION: return APIMOENCH; default: diff --git a/slsDetectorServers/moenchDetectorServer/slsDetectorServer_defs.h b/slsDetectorServers/moenchDetectorServer/slsDetectorServer_defs.h old mode 100644 new mode 100755 diff --git a/slsDetectorServers/moenchDetectorServer/updateAPIVersion.sh b/slsDetectorServers/moenchDetectorServer/updateAPIVersion.sh deleted file mode 100755 index f1fc67c18..000000000 --- a/slsDetectorServers/moenchDetectorServer/updateAPIVersion.sh +++ /dev/null @@ -1,7 +0,0 @@ -SRCFILE=gitInfoMoench.h -DSTFILE=versionAPI.h - -SRCPATTERN=GITDATE -DSTPATTERN=APIMOENCH - -awk -v a="$SRCFILE" -v b="$DSTFILE" -v c="$SRCPATTERN" -v d="$DSTPATTERN" 'FNR==NR&&$2==c{x=$3} NR!=FNR{if($2==d){$3="0x"substr(x,5)}print > b}' $SRCFILE $DSTFILE \ No newline at end of file diff --git a/slsDetectorServers/moenchDetectorServer/updateGitVersion.sh b/slsDetectorServers/moenchDetectorServer/updateGitVersion.sh deleted file mode 100755 index b5868c72c..000000000 --- a/slsDetectorServers/moenchDetectorServer/updateGitVersion.sh +++ /dev/null @@ -1,31 +0,0 @@ -SERVER=moenchDetectorServer -MAINDIR=slsDetectorPackage -SPECDIR=slsDetectorServers/$SERVER -TMPFILE=gitInfoMoenchTmp.h -INCLFILE=gitInfoMoench.h - - -#evaluate the variables -EVALFILE=../../evalVersionVariables.sh -source $EVALFILE - - -#get modified date -#RDATE1='git log --pretty=format:"%ci" -1' -RDATE1="find ../slsDetectorServer . -type f -exec stat --format '%Y :%y %n' '{}' \; | sort -nr | cut -d: -f2- | egrep -v '(\.)o' | egrep -v '(gitInfo).*' | egrep -v bin | egrep -v 'updateGit' | head -n 1" -RDATE=`eval $RDATE1` -NEWDATE=$(sed "s/-//g" <<< $RDATE | awk '{print $1;}') -NEWDATE=${NEWDATE/#/0x} - - -#get old date from INCLFILE -OLDDATE=$(more $INCLFILE | grep '#define GITDATE' | awk '{print $3}') - - -#update INCLFILE if changes -if [ "$OLDDATE" != "$NEWDATE" ]; then - echo Path: ${MAINDIR}/${SPECDIR} $'\n'URL: ${GITREPO} $'\n'Repository Root: ${GITREPO} $'\n'Repsitory UUID: ${REPUID} $'\n'Revision: ${FOLDERREV} $'\n'Branch: ${BRANCH} $'\n'Last Changed Author: ${AUTH1}_${AUTH2} $'\n'Last Changed Rev: ${REV} $'\n'Last Changed Date: ${RDATE} > gitInfo.txt - cd ../../ - ./genVersionHeader.sh $SPECDIR/gitInfo.txt $SPECDIR/$TMPFILE $SPECDIR/$INCLFILE - cd $WD -fi \ No newline at end of file diff --git a/slsDetectorServers/slsDetectorServer/logger.h b/slsDetectorServers/slsDetectorServer/logger.h old mode 100644 new mode 100755 diff --git a/slsDetectorServers/slsDetectorServer/slsDetectorFunctionList.h b/slsDetectorServers/slsDetectorServer/slsDetectorFunctionList.h old mode 100644 new mode 100755 diff --git a/slsDetectorServers/slsDetectorServer/slsDetectorServer.c b/slsDetectorServers/slsDetectorServer/slsDetectorServer.c index e98af35a4..6c8413ed5 100755 --- a/slsDetectorServers/slsDetectorServer/slsDetectorServer.c +++ b/slsDetectorServers/slsDetectorServer/slsDetectorServer.c @@ -6,6 +6,7 @@ #include "communication_funcs.h" #include "slsDetectorServer_funcs.h" #include "slsDetectorServer_defs.h" +#include "versionAPI.h" #include #include @@ -29,7 +30,25 @@ void error(char *msg){ } int main(int argc, char *argv[]){ - int portno = DEFAULT_PORTNO; + + // print version + if (argc > 1 && !strcasecmp(argv[1], "-version")) { + int version = 0; +#ifdef GOTTHARDD + version = APIGOTTHARD; +#elif EIGERD + version = APIEIGER; +#elif JUNGFRAUD + version = APIJUNGFRAU; +#elif CHIPTESTBOARDD + version = APICTB; +#elif MOENCHD + version = APIMOENCH; +#endif + FILE_LOG(logINFO, ("SLS Detector Server %s (0x%x)\n", GITBRANCH, version)); + } + + int portno = DEFAULT_PORTNO; int retval = OK; int fd = 0; diff --git a/slsDetectorServers/slsDetectorServer/slsDetectorServer_funcs.c b/slsDetectorServers/slsDetectorServer/slsDetectorServer_funcs.c index f8c294343..f8d3e10bf 100755 --- a/slsDetectorServers/slsDetectorServer/slsDetectorServer_funcs.c +++ b/slsDetectorServers/slsDetectorServer/slsDetectorServer_funcs.c @@ -507,7 +507,7 @@ int set_external_communication_mode(int file_des) { case AUTO_TIMING: case TRIGGER_EXPOSURE: #ifdef EIGERD - case GATE_FIX_NUMBER: + case GATED: case BURST_TRIGGER: #endif setTiming(arg); @@ -1566,7 +1566,9 @@ int set_timer(int file_des) { case ACQUISITION_TIME: case FRAME_PERIOD: case CYCLES_NUMBER: +#if defined(CHIPTESTBOARDD) || defined(MOENCHD) case SAMPLES: +#endif #ifndef EIGERD case DELAY_AFTER_TRIGGER: #endif diff --git a/slsDetectorSoftware/CMakeLists.txt b/slsDetectorSoftware/CMakeLists.txt old mode 100644 new mode 100755 index 491af3f89..a7c7c8db6 --- a/slsDetectorSoftware/CMakeLists.txt +++ b/slsDetectorSoftware/CMakeLists.txt @@ -39,7 +39,6 @@ set(PUBLICHEADERS include/slsDetectorUsers.h include/detectorData.h include/multiSlsDetector.h - include/gitInfoLib.h ) set_target_properties(slsDetectorShared PROPERTIES LIBRARY_OUTPUT_NAME SlsDetector diff --git a/slsDetectorSoftware/doxy.config b/slsDetectorSoftware/doxy.config old mode 100644 new mode 100755 diff --git a/slsDetectorSoftware/gitInfo.txt b/slsDetectorSoftware/gitInfo.txt deleted file mode 100644 index 53b993d33..000000000 --- a/slsDetectorSoftware/gitInfo.txt +++ /dev/null @@ -1,9 +0,0 @@ -Path: slsDetectorsPackage/slsDetectorSoftware -URL: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git -Repository Root: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git -Repsitory UUID: c24a9b223cbb066d3851599f4d977ae835feffe4 -Revision: 2098 -Branch: refactor -Last Changed Author: Dhanya_Thattil -Last Changed Rev: 4099 -Last Changed Date: 2018-10-11 13:56:19.000000002 +0200 ./doxy.config diff --git a/slsDetectorSoftware/include/SharedMemory.h b/slsDetectorSoftware/include/SharedMemory.h old mode 100644 new mode 100755 diff --git a/slsDetectorSoftware/include/detectorData.h b/slsDetectorSoftware/include/detectorData.h old mode 100644 new mode 100755 diff --git a/slsDetectorSoftware/include/gitInfoLib.h b/slsDetectorSoftware/include/gitInfoLib.h deleted file mode 100644 index ab7cbff4d..000000000 --- a/slsDetectorSoftware/include/gitInfoLib.h +++ /dev/null @@ -1,6 +0,0 @@ -#define GITURL "git@github.com:slsdetectorgroup/slsDetectorPackage.git" -#define GITREPUUID "c24a9b223cbb066d3851599f4d977ae835feffe4" -#define GITAUTH "Dhanya_Thattil" -#define GITREV 0x4099 -#define GITDATE 0x20181011 -#define GITBRANCH "refactor" diff --git a/slsDetectorSoftware/include/gitInfoLibTmp.h b/slsDetectorSoftware/include/gitInfoLibTmp.h deleted file mode 100644 index dfd9bb246..000000000 --- a/slsDetectorSoftware/include/gitInfoLibTmp.h +++ /dev/null @@ -1,6 +0,0 @@ -#define GITURL "" -#define GITREPUUID "" -#define GITAUTH "" -#define GITREV "" -#define GITDATE "" -#define GITBRANCH "" diff --git a/slsDetectorSoftware/include/multiSlsDetector.h b/slsDetectorSoftware/include/multiSlsDetector.h old mode 100644 new mode 100755 index c68880ac6..57af13111 --- a/slsDetectorSoftware/include/multiSlsDetector.h +++ b/slsDetectorSoftware/include/multiSlsDetector.h @@ -2,7 +2,6 @@ #include "SharedMemory.h" #include "error_defs.h" -#include "gitInfoLib.h" #include "logger.h" #include "sls_detector_defs.h" @@ -225,10 +224,16 @@ class multiSlsDetector : public virtual slsDetectorDefs { */ int64_t getId(idMode mode, int detPos = -1); - int64_t getClientSoftwareVersion() const { - return GITDATE; - } + /** + * Get Client Software version + * @returns client software version + */ + int64_t getClientSoftwareVersion() const; + /** + * Get Receiver software version + * @return receiver software version + */ int64_t getReceiverSoftwareVersion(int detPos = -1) const; std::vector getDetectorNumber(); @@ -468,9 +473,8 @@ class multiSlsDetector : public virtual slsDetectorDefs { /** * Load configuration from a configuration File * @param fname configuration file name - * @return OK or FAIL */ - int readConfigurationFile(const std::string &fname); + void readConfigurationFile(const std::string &fname); /** * Write current configuration to a file @@ -1511,9 +1515,10 @@ class multiSlsDetector : public virtual slsDetectorDefs { /** * Prints receiver configuration + * @param level print level * @param detPos -1 for all detectors in list or specific detector position */ - void printReceiverConfiguration(int detPos = -1); + void printReceiverConfiguration(TLogLevel level = logINFO, int detPos = -1); /** * Sets up receiver socket if online and sets the flag diff --git a/slsDetectorSoftware/include/multiSlsDetectorClient.h b/slsDetectorSoftware/include/multiSlsDetectorClient.h old mode 100644 new mode 100755 diff --git a/slsDetectorSoftware/include/slsDetector.h b/slsDetectorSoftware/include/slsDetector.h old mode 100644 new mode 100755 index 83817ac95..b778372b1 --- a/slsDetectorSoftware/include/slsDetector.h +++ b/slsDetectorSoftware/include/slsDetector.h @@ -1355,7 +1355,7 @@ class slsDetector : public virtual slsDetectorDefs{ /** * Prints receiver configuration - * #param level print level + * @param level print level */ void printReceiverConfiguration(TLogLevel level = logINFO); diff --git a/slsDetectorSoftware/include/slsDetectorCommand.h b/slsDetectorSoftware/include/slsDetectorCommand.h old mode 100644 new mode 100755 diff --git a/slsDetectorSoftware/include/slsDetectorUsers.h b/slsDetectorSoftware/include/slsDetectorUsers.h old mode 100644 new mode 100755 diff --git a/slsDetectorSoftware/src/multiSlsDetector.cpp b/slsDetectorSoftware/src/multiSlsDetector.cpp old mode 100644 new mode 100755 index 4ec08b834..b55eabb69 --- a/slsDetectorSoftware/src/multiSlsDetector.cpp +++ b/slsDetectorSoftware/src/multiSlsDetector.cpp @@ -8,6 +8,7 @@ #include "slsDetector.h" #include "slsDetectorCommand.h" #include "sls_detector_exceptions.h" +#include "versionAPI.h" #include "container_utils.h" @@ -152,6 +153,7 @@ int multiSlsDetector::decodeNChannel(int offsetX, int offsetY, int &channelX, in return -1; } + void multiSlsDetector::setAcquiringFlag(bool flag) { multi_shm()->acquiringFlag = flag; } bool multiSlsDetector::getAcquiringFlag() const { return multi_shm()->acquiringFlag; } @@ -194,6 +196,10 @@ int64_t multiSlsDetector::getId(idMode mode, int detPos) { return sls::minusOneIfDifferent(r); } +int64_t multiSlsDetector::getClientSoftwareVersion() const { + return APILIB; +} + int64_t multiSlsDetector::getReceiverSoftwareVersion(int detPos) const { if (detPos >= 0) { return detectors[detPos]->getReceiverSoftwareVersion(); @@ -739,31 +745,28 @@ int multiSlsDetector::execCommand(const std::string &cmd, int detPos) { return sls::allEqualTo(r, static_cast(OK)) ? OK : FAIL; } -int multiSlsDetector::readConfigurationFile(const std::string &fname) { +void multiSlsDetector::readConfigurationFile(const std::string &fname) { freeSharedMemory(); setupMultiDetector(); FILE_LOG(logINFO) << "Loading configuration file: " << fname; std::ifstream input_file; input_file.open(fname, std::ios_base::in); - if (input_file.is_open()) { - std::string current_line; - while (input_file.good()) { - getline(input_file, current_line); - if (current_line.find('#') != std::string::npos) { - current_line.erase(current_line.find('#')); - } - FILE_LOG(logDEBUG1) << "current_line after removing comments:\n\t" << current_line; - if (current_line.length() > 1) { - multiSlsDetectorClient(current_line, PUT_ACTION, this); - } - } - input_file.close(); - } else { - FILE_LOG(logERROR) << "Could not openconfiguration file " << fname << " for reading"; - return FAIL; + if (!input_file.is_open()) { + throw RuntimeError("Could not open configuration file " + fname + " for reading"); } - return OK; + std::string current_line; + while (input_file.good()) { + getline(input_file, current_line); + if (current_line.find('#') != std::string::npos) { + current_line.erase(current_line.find('#')); + } + FILE_LOG(logDEBUG1) << "current_line after removing comments:\n\t" << current_line; + if (current_line.length() > 1) { + multiSlsDetectorClient(current_line, PUT_ACTION, this); + } + } + input_file.close(); } int multiSlsDetector::writeConfigurationFile(const std::string &fname) { @@ -2751,15 +2754,15 @@ int64_t multiSlsDetector::getRateCorrection(int detPos) { return sls::minusOneIfDifferent(r); } -void multiSlsDetector::printReceiverConfiguration(int detPos) { +void multiSlsDetector::printReceiverConfiguration(TLogLevel level, int detPos) { // single if (detPos >= 0) { - return detectors[detPos]->printReceiverConfiguration(); + return detectors[detPos]->printReceiverConfiguration(level); } // multi for (auto &d : detectors) { - d->printReceiverConfiguration(); + d->printReceiverConfiguration(level); } } @@ -3880,8 +3883,7 @@ int multiSlsDetector::dumpDetectorSetup(const std::string &fname, int level) { } outfile.close(); } else { - FILE_LOG(logERROR) << "Could not open parameters file " << outfname << " for writing"; - return FAIL; + throw RuntimeError("Error opening parameters file " + fname + " for writing"); } FILE_LOG(logDEBUG1) << "wrote " << names.size() << " lines to " << outfname; diff --git a/slsDetectorSoftware/src/slsDetector.cpp b/slsDetectorSoftware/src/slsDetector.cpp old mode 100644 new mode 100755 index 934044eea..76ac1d4f2 --- a/slsDetectorSoftware/src/slsDetector.cpp +++ b/slsDetectorSoftware/src/slsDetector.cpp @@ -5,7 +5,6 @@ #include "ServerInterface.h" #include "SharedMemory.h" #include "file_utils.h" -#include "gitInfoLib.h" #include "multiSlsDetector.h" #include "network_utils.h" #include "slsDetectorCommand.h" @@ -575,7 +574,7 @@ slsDetector::getTypeFromDetector(const std::string &hostname, int cport) { int ret = FAIL; detectorType retval = GENERIC; FILE_LOG(logDEBUG1) << "Getting detector type "; - sls::ClientSocket cs(false, hostname, cport); + sls::ClientSocket cs("Detector", hostname, cport); cs.sendData(reinterpret_cast(&fnum), sizeof(fnum)); cs.receiveData(reinterpret_cast(&ret), sizeof(ret)); cs.receiveData(reinterpret_cast(&retval), sizeof(retval)); @@ -3971,9 +3970,8 @@ int slsDetector::updateCachedReceiverVariables() const { FILE_LOG(logDEBUG1) << "Sending update client to receiver server"; if (detector_shm()->receiverOnlineFlag == ONLINE_FLAG) { - auto receiver = - sls::ClientSocket(true, detector_shm()->receiver_hostname, - detector_shm()->receiverTCPPort); + auto receiver = sls::ClientSocket("Receiver", detector_shm()->receiver_hostname, + detector_shm()->receiverTCPPort); ret = receiver.sendCommandThenRead(fnum, nullptr, 0, nullptr, 0); if (ret == FAIL) { std::string msg = "Could not update receiver: " + diff --git a/slsDetectorSoftware/src/slsDetectorCommand.cpp b/slsDetectorSoftware/src/slsDetectorCommand.cpp old mode 100644 new mode 100755 index 399a387e0..21fd974fa --- a/slsDetectorSoftware/src/slsDetectorCommand.cpp +++ b/slsDetectorSoftware/src/slsDetectorCommand.cpp @@ -8,7 +8,7 @@ #include #include -// using namespace std; + /*! \mainpage Introduction @@ -1541,7 +1541,7 @@ slsDetectorCommand::slsDetectorCommand(multiSlsDetector *det) { ++i; /*! \page output - - fileformat sets/gets the file format for data in receiver. Options: [ascii, binary, hdf5]. Ascii is not implemented in Receiver. \c Returns \c (string) + - fileformat sets/gets the file format for data in receiver. Options: [binary, hdf5]. \c Returns \c (string) */ descrToFuncMap[i].m_pFuncName = "fileformat"; descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdFileName; @@ -2568,8 +2568,6 @@ std::string slsDetectorCommand::cmdFileName(int narg, char *args[], int action, if (action == PUT_ACTION) { if (std::string(args[1]) == "binary") myDet->setFileFormat(BINARY, detPos); - else if (std::string(args[1]) == "ascii") - myDet->setFileFormat(ASCII, detPos); else if (std::string(args[1]) == "hdf5") myDet->setFileFormat(HDF5, detPos); else @@ -2588,7 +2586,7 @@ std::string slsDetectorCommand::helpFileName(int action) { } if (action == PUT_ACTION || action == HELP_ACTION) { os << std::string("fname s \t sets the filename for the data (index and extension will be automatically appended)\n"); - os << std::string("fileformat s \t sets the file format for the data (binary, ascii, hdf5)\n"); + os << std::string("fileformat s \t sets the file format for the data (binary, hdf5)\n"); } return os.str(); } @@ -4918,7 +4916,7 @@ std::string slsDetectorCommand::cmdConfiguration(int narg, char *args[], int act myDet->setReceiverOnline(ONLINE_FLAG, detPos); if (action == PUT_ACTION) return std::string("cannot put"); - myDet->printReceiverConfiguration(detPos); + myDet->printReceiverConfiguration(logINFO, detPos); return std::string(""); } else if (cmd == "parameters") { myDet->setReceiverOnline(ONLINE_FLAG, detPos); diff --git a/slsDetectorSoftware/src/slsDetectorUsers.cpp b/slsDetectorSoftware/src/slsDetectorUsers.cpp old mode 100644 new mode 100755 index 005d3df71..6a37dc0b7 --- a/slsDetectorSoftware/src/slsDetectorUsers.cpp +++ b/slsDetectorSoftware/src/slsDetectorUsers.cpp @@ -39,7 +39,12 @@ int slsDetectorUsers::setReceiverOnline(int const online, int detPos){ } int slsDetectorUsers::readConfigurationFile(const std::string& fname){ - return detector.readConfigurationFile(fname); + try{ + detector.readConfigurationFile(fname); + return slsDetectorDefs::OK; + } catch (...) { + return slsDetectorDefs::FAIL; + } } int slsDetectorUsers::writeConfigurationFile(const std::string& fname){ diff --git a/slsDetectorSoftware/src/sls_detector_client.cpp b/slsDetectorSoftware/src/sls_detector_client.cpp old mode 100644 new mode 100755 index 0f31d2e1d..875950978 --- a/slsDetectorSoftware/src/sls_detector_client.cpp +++ b/slsDetectorSoftware/src/sls_detector_client.cpp @@ -1,11 +1,11 @@ -#include "gitInfoLib.h" +#include "versionAPI.h" #include "multiSlsDetectorClient.h" #include int main(int argc, char *argv[]) { for (int i = 1; i < argc; ++i) { if (!(strcmp(argv[i], "--version")) || !(strcmp(argv[i], "-v"))) { - int64_t tempval = GITDATE; + int64_t tempval = APILIB; std::cout << argv[0] << " " << GITBRANCH << " (0x" << std::hex << tempval << ")" << std::endl; return 0; } diff --git a/slsDetectorSoftware/tests/CMakeLists.txt b/slsDetectorSoftware/tests/CMakeLists.txt old mode 100644 new mode 100755 diff --git a/slsDetectorSoftware/tests/test-SharedMemory.cpp b/slsDetectorSoftware/tests/test-SharedMemory.cpp old mode 100644 new mode 100755 diff --git a/slsDetectorSoftware/tests/test-multiSlsDetector.cpp b/slsDetectorSoftware/tests/test-multiSlsDetector.cpp old mode 100644 new mode 100755 diff --git a/slsDetectorSoftware/tests/test-slsDetector.cpp b/slsDetectorSoftware/tests/test-slsDetector.cpp old mode 100644 new mode 100755 diff --git a/slsDetectorSoftware/updateGitVersion.sh b/slsDetectorSoftware/updateGitVersion.sh deleted file mode 100755 index 70fee75d4..000000000 --- a/slsDetectorSoftware/updateGitVersion.sh +++ /dev/null @@ -1,28 +0,0 @@ -MAINDIR=slsDetectorsPackage -SPECDIR=slsDetectorSoftware -TMPFILE=slsDetector/gitInfoLibTmp.h -INCLFILE=slsDetector/gitInfoLib.h -WD=$PWD - -#evaluate the variables -EVALFILE=../evalVersionVariables.sh -source $EVALFILE - -#get modified date -#RDATE1='git log --pretty=format:"%ci" -1' -RDATE1="find . -not -path '*DetectorServer/*' -type f -exec stat --format '%Y :%y %n' '{}' \; | sort -nr | cut -d: -f2- | egrep -v 'gitInfo|build|.git|updateGitVersion' | head -n 1" -RDATE=`eval $RDATE1` -NEWDATE=$(sed "s/-//g" <<< $RDATE | awk '{print $1;}') -NEWDATE=${NEWDATE/#/0x} - -#get old date from INCLFILE -OLDDATE=$(more $INCLFILE | grep '#define GITDATE' | awk '{print $3}') - - -#update INCLFILE if changes -#if [ "$OLDDATE" != "$NEWDATE" ]; then - echo Path: ${MAINDIR}/${SPECDIR} $'\n'URL: ${GITREPO} $'\n'Repository Root: ${GITREPO} $'\n'Repsitory UUID: ${REPUID} $'\n'Revision: ${FOLDERREV} $'\n'Branch: ${BRANCH} $'\n'Last Changed Author: ${AUTH1}_${AUTH2} $'\n'Last Changed Rev: ${REV} $'\n'Last Changed Date: ${RDATE} > gitInfo.txt - cd .. - ./genVersionHeader.sh $SPECDIR/gitInfo.txt $SPECDIR/$TMPFILE $SPECDIR/$INCLFILE - cd $WD -#fi \ No newline at end of file diff --git a/slsReceiverSoftware/CMakeLists.txt b/slsReceiverSoftware/CMakeLists.txt old mode 100644 new mode 100755 diff --git a/slsReceiverSoftware/gitInfo.txt b/slsReceiverSoftware/gitInfo.txt deleted file mode 100644 index 5bc0b7c85..000000000 --- a/slsReceiverSoftware/gitInfo.txt +++ /dev/null @@ -1,9 +0,0 @@ -Path: slsDetectorsPackage/slsReceiverSoftware -URL: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git -Repository Root: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git -Repsitory UUID: def79807f6f40ed1797b8154240adbc0e35c95e0 -Revision: 840 -Branch: refactor -Last Changed Author: Dhanya_Thattil -Last Changed Rev: 4039 -Last Changed Date: 2018-10-02 10:40:58.000000002 +0200 diff --git a/slsReceiverSoftware/include/BinaryFile.h b/slsReceiverSoftware/include/BinaryFile.h old mode 100644 new mode 100755 diff --git a/slsReceiverSoftware/include/BinaryFileStatic.h b/slsReceiverSoftware/include/BinaryFileStatic.h old mode 100644 new mode 100755 diff --git a/slsReceiverSoftware/include/DataProcessor.h b/slsReceiverSoftware/include/DataProcessor.h old mode 100644 new mode 100755 diff --git a/slsReceiverSoftware/include/DataStreamer.h b/slsReceiverSoftware/include/DataStreamer.h old mode 100644 new mode 100755 diff --git a/slsReceiverSoftware/include/Fifo.h b/slsReceiverSoftware/include/Fifo.h old mode 100644 new mode 100755 diff --git a/slsReceiverSoftware/include/File.h b/slsReceiverSoftware/include/File.h old mode 100644 new mode 100755 diff --git a/slsReceiverSoftware/include/GeneralData.h b/slsReceiverSoftware/include/GeneralData.h old mode 100644 new mode 100755 diff --git a/slsReceiverSoftware/include/HDF5File.h b/slsReceiverSoftware/include/HDF5File.h old mode 100644 new mode 100755 diff --git a/slsReceiverSoftware/include/HDF5FileStatic.h b/slsReceiverSoftware/include/HDF5FileStatic.h old mode 100644 new mode 100755 diff --git a/slsReceiverSoftware/include/Listener.h b/slsReceiverSoftware/include/Listener.h old mode 100644 new mode 100755 diff --git a/slsReceiverSoftware/include/ThreadObject.h b/slsReceiverSoftware/include/ThreadObject.h old mode 100644 new mode 100755 diff --git a/slsReceiverSoftware/include/circularFifo.h b/slsReceiverSoftware/include/circularFifo.h old mode 100644 new mode 100755 diff --git a/slsReceiverSoftware/include/gitInfoReceiver.h b/slsReceiverSoftware/include/gitInfoReceiver.h deleted file mode 100644 index fbb980f19..000000000 --- a/slsReceiverSoftware/include/gitInfoReceiver.h +++ /dev/null @@ -1,6 +0,0 @@ -#define GITURL "git@github.com:slsdetectorgroup/slsDetectorPackage.git" -#define GITREPUUID "def79807f6f40ed1797b8154240adbc0e35c95e0" -#define GITAUTH "Dhanya_Thattil" -#define GITREV 0x4039 -#define GITDATE 0x20181002 -#define GITBRANCH "refactor" diff --git a/slsReceiverSoftware/include/gitInfoReceiverTmp.h b/slsReceiverSoftware/include/gitInfoReceiverTmp.h deleted file mode 100644 index dfd9bb246..000000000 --- a/slsReceiverSoftware/include/gitInfoReceiverTmp.h +++ /dev/null @@ -1,6 +0,0 @@ -#define GITURL "" -#define GITREPUUID "" -#define GITAUTH "" -#define GITREV "" -#define GITDATE "" -#define GITBRANCH "" diff --git a/slsReceiverSoftware/include/slsReceiver.h b/slsReceiverSoftware/include/slsReceiver.h old mode 100644 new mode 100755 diff --git a/slsReceiverSoftware/include/slsReceiverImplementation.h b/slsReceiverSoftware/include/slsReceiverImplementation.h old mode 100644 new mode 100755 diff --git a/slsReceiverSoftware/include/slsReceiverTCPIPInterface.h b/slsReceiverSoftware/include/slsReceiverTCPIPInterface.h old mode 100644 new mode 100755 diff --git a/slsReceiverSoftware/include/slsReceiverUsers.h b/slsReceiverSoftware/include/slsReceiverUsers.h old mode 100644 new mode 100755 diff --git a/slsReceiverSoftware/slsReceiverUsers.doxy b/slsReceiverSoftware/slsReceiverUsers.doxy old mode 100644 new mode 100755 diff --git a/slsReceiverSoftware/src/BinaryFile.cpp b/slsReceiverSoftware/src/BinaryFile.cpp old mode 100644 new mode 100755 diff --git a/slsReceiverSoftware/src/DataProcessor.cpp b/slsReceiverSoftware/src/DataProcessor.cpp old mode 100644 new mode 100755 diff --git a/slsReceiverSoftware/src/DataStreamer.cpp b/slsReceiverSoftware/src/DataStreamer.cpp old mode 100644 new mode 100755 diff --git a/slsReceiverSoftware/src/Fifo.cpp b/slsReceiverSoftware/src/Fifo.cpp old mode 100644 new mode 100755 diff --git a/slsReceiverSoftware/src/File.cpp b/slsReceiverSoftware/src/File.cpp old mode 100644 new mode 100755 diff --git a/slsReceiverSoftware/src/HDF5File.cpp b/slsReceiverSoftware/src/HDF5File.cpp old mode 100644 new mode 100755 diff --git a/slsReceiverSoftware/src/Listener.cpp b/slsReceiverSoftware/src/Listener.cpp old mode 100644 new mode 100755 diff --git a/slsReceiverSoftware/src/ThreadObject.cpp b/slsReceiverSoftware/src/ThreadObject.cpp old mode 100644 new mode 100755 diff --git a/slsReceiverSoftware/src/main.cpp b/slsReceiverSoftware/src/main.cpp old mode 100644 new mode 100755 diff --git a/slsReceiverSoftware/src/slsReceiver.cpp b/slsReceiverSoftware/src/slsReceiver.cpp old mode 100644 new mode 100755 index 73bea514c..ea400b5c2 --- a/slsReceiverSoftware/src/slsReceiver.cpp +++ b/slsReceiverSoftware/src/slsReceiver.cpp @@ -16,7 +16,7 @@ #include "slsReceiver.h" #include "slsReceiverTCPIPInterface.h" #include "sls_detector_exceptions.h" -#include "gitInfoReceiver.h" +#include "versionAPI.h" #include "logger.h" slsReceiver::slsReceiver(int argc, char *argv[]): @@ -25,7 +25,6 @@ slsReceiver::slsReceiver(int argc, char *argv[]): // options std::map configuration_map; int tcpip_port_no = 1954; - int64_t tempval = 0; //parse command line for config static struct option long_options[] = { @@ -58,9 +57,7 @@ slsReceiver::slsReceiver(int argc, char *argv[]): break; case 'v': - tempval = GITREV; - tempval = (tempval <<32) | GITDATE; - std::cout << "SLS Receiver " << GITBRANCH << " (0x" << std::hex << tempval << ")" << std::endl; + std::cout << "SLS Receiver " << GITBRANCH << " (0x" << std::hex << APIRECEIVER << ")" << std::endl; throw sls::RuntimeError(); case 'h': diff --git a/slsReceiverSoftware/src/slsReceiverImplementation.cpp b/slsReceiverSoftware/src/slsReceiverImplementation.cpp old mode 100644 new mode 100755 diff --git a/slsReceiverSoftware/src/slsReceiverTCPIPInterface.cpp b/slsReceiverSoftware/src/slsReceiverTCPIPInterface.cpp old mode 100644 new mode 100755 index 04652583c..a64bc9d3b --- a/slsReceiverSoftware/src/slsReceiverTCPIPInterface.cpp +++ b/slsReceiverSoftware/src/slsReceiverTCPIPInterface.cpp @@ -7,7 +7,6 @@ #include "slsReceiverImplementation.h" #include "MySocketTCP.h" #include "ServerInterface.h" -#include "gitInfoReceiver.h" #include "slsReceiverUsers.h" #include "slsReceiver.h" #include "versionAPI.h" @@ -103,8 +102,7 @@ void slsReceiverTCPIPInterface::stop(){ int64_t slsReceiverTCPIPInterface::getReceiverVersion(){ - int64_t retval = GITDATE & 0xFFFFFF; - return retval; + return APIRECEIVER; } diff --git a/slsReceiverSoftware/src/slsReceiverUsers.cpp b/slsReceiverSoftware/src/slsReceiverUsers.cpp old mode 100644 new mode 100755 diff --git a/slsReceiverSoftware/tests/CMakeLists.txt b/slsReceiverSoftware/tests/CMakeLists.txt old mode 100644 new mode 100755 diff --git a/slsReceiverSoftware/tests/test-GeneralData.cpp b/slsReceiverSoftware/tests/test-GeneralData.cpp old mode 100644 new mode 100755 diff --git a/slsReceiverSoftware/updateAPIVersion.sh b/slsReceiverSoftware/updateAPIVersion.sh deleted file mode 100755 index 389b2929e..000000000 --- a/slsReceiverSoftware/updateAPIVersion.sh +++ /dev/null @@ -1,7 +0,0 @@ -SRCFILE=include/gitInfoReceiver.h -DSTFILE=include/versionAPI.h - -SRCPATTERN=GITDATE -DSTPATTERN=APIRECEIVER - -awk -v a="$SRCFILE" -v b="$DSTFILE" -v c="$SRCPATTERN" -v d="$DSTPATTERN" 'FNR==NR&&$2==c{x=$3} NR!=FNR{if($2==d){$3="0x"substr(x,5)}print > b}' $SRCFILE $DSTFILE \ No newline at end of file diff --git a/slsReceiverSoftware/updateGitVersion.sh b/slsReceiverSoftware/updateGitVersion.sh deleted file mode 100755 index 96e58f255..000000000 --- a/slsReceiverSoftware/updateGitVersion.sh +++ /dev/null @@ -1,28 +0,0 @@ -MAINDIR=slsDetectorPackage -SPECDIR=slsReceiverSoftware -TMPFILE=include/gitInfoReceiverTmp.h -INCLFILE=include/gitInfoReceiver.h -WD=$PWD - -#evaluate the variables -EVALFILE=../evalVersionVariables.sh -source $EVALFILE - -#get modified date -#RDATE1='git log --pretty=format:"%ci" -1' -RDATE1="find . -type f -exec stat --format '%Y :%y %n' '{}' \; | sort -nr | cut -d: -f2- | egrep -v 'gitInfo|build|.git|updateGitVersion' | head -n 1" -RDATE=`eval $RDATE1` -NEWDATE=$(sed "s/-//g" <<< $RDATE | awk '{print $1;}') -NEWDATE=${NEWDATE/#/0x} - -#get old date from INCLFILE -OLDDATE=$(more $INCLFILE | grep '#define GITDATE' | awk '{print $3}') - -#update INCLFILE if changes -if [ "$OLDDATE" != "$NEWDATE" ]; then - echo Path: ${MAINDIR}/${SPECDIR} $'\n'URL: ${GITREPO} $'\n'Repository Root: ${GITREPO} $'\n'Repsitory UUID: ${REPUID} $'\n'Revision: ${FOLDERREV} $'\n'Branch: ${BRANCH} $'\n'Last Changed Author: ${AUTH1}_${AUTH2} $'\n'Last Changed Rev: ${REV} $'\n'Last Changed Date: ${RDATE} > gitInfo.txt - cd .. - ./genVersionHeader.sh $SPECDIR/gitInfo.txt $SPECDIR/$TMPFILE $SPECDIR/$INCLFILE - cd $WD -fi - diff --git a/slsSupportLib/CMakeLists.txt b/slsSupportLib/CMakeLists.txt old mode 100644 new mode 100755 diff --git a/slsSupportLib/include/ClientInterface.h b/slsSupportLib/include/ClientInterface.h old mode 100644 new mode 100755 diff --git a/slsSupportLib/include/ClientSocket.h b/slsSupportLib/include/ClientSocket.h old mode 100644 new mode 100755 index 76d680699..14ec6e639 --- a/slsSupportLib/include/ClientSocket.h +++ b/slsSupportLib/include/ClientSocket.h @@ -9,29 +9,36 @@ namespace sls { class ClientSocket : public DataSocket { public: - ClientSocket(const bool isRx, const std::string &hostname, uint16_t port_number); - ClientSocket(const bool isRx, struct sockaddr_in addr); + ClientSocket(std::string stype, const std::string &hostname, uint16_t port_number); + ClientSocket(std::string stype, struct sockaddr_in addr); int sendCommandThenRead(int fnum, void *args, size_t args_size, void *retval, size_t retval_size); private: void readReply(int &ret, void *retval, size_t retval_size); struct sockaddr_in serverAddr {}; - bool isReceiver; + std::string socketType; }; class ReceiverSocket : public ClientSocket { public: ReceiverSocket(const std::string &hostname, uint16_t port_number) - : ClientSocket(true, hostname, port_number){}; - ReceiverSocket(struct sockaddr_in addr) : ClientSocket(true, addr){}; + : ClientSocket("Receiver", hostname, port_number){}; + ReceiverSocket(struct sockaddr_in addr) : ClientSocket("Receiver", addr){}; }; class DetectorSocket : public ClientSocket { public: DetectorSocket(const std::string &hostname, uint16_t port_number) - : ClientSocket(false, hostname, port_number){}; - DetectorSocket(struct sockaddr_in addr) : ClientSocket(false, addr){}; + : ClientSocket("Detector", hostname, port_number){}; + DetectorSocket(struct sockaddr_in addr) : ClientSocket("Detector", addr){}; +}; + +class GuiSocket : public ClientSocket { + public: + GuiSocket(const std::string &hostname, uint16_t port_number) + : ClientSocket("Gui", hostname, port_number){}; + GuiSocket(struct sockaddr_in addr) : ClientSocket("Gui", addr){}; }; }; // namespace sls diff --git a/slsSupportLib/include/CmdLineParser.h b/slsSupportLib/include/CmdLineParser.h old mode 100644 new mode 100755 diff --git a/slsSupportLib/include/DataSocket.h b/slsSupportLib/include/DataSocket.h old mode 100644 new mode 100755 index 95b0c7bb6..5b455b6dc --- a/slsSupportLib/include/DataSocket.h +++ b/slsSupportLib/include/DataSocket.h @@ -22,6 +22,7 @@ class DataSocket { size_t receiveData(void *buffer, size_t size); int setTimeOut(int t_seconds); void close(); + void shutDownSocket(); private: int socketId_ = -1; diff --git a/slsSupportLib/include/MySocketTCP.h b/slsSupportLib/include/MySocketTCP.h old mode 100644 new mode 100755 diff --git a/slsSupportLib/include/ServerInterface.h b/slsSupportLib/include/ServerInterface.h old mode 100644 new mode 100755 diff --git a/slsSupportLib/include/ServerSocket.h b/slsSupportLib/include/ServerSocket.h old mode 100644 new mode 100755 index 00a3536d0..cb6545c5d --- a/slsSupportLib/include/ServerSocket.h +++ b/slsSupportLib/include/ServerSocket.h @@ -14,12 +14,15 @@ class ServerSocket : public DataSocket { public: ServerSocket(int port); DataSocket accept(); - const std::string &getLastClient() { return lastClient_; } + const std::string &getLastClient(); + const int getPort(); + void SendResult(int &ret, void *retval, int retvalSize, char* mess); private: std::string lastClient_ = std::string(INET_ADDRSTRLEN, '\0'); std::string thisClient_ = std::string(INET_ADDRSTRLEN, '\0'); + int serverPort; // char lastClient_[INET_ADDRSTRLEN]{}; }; -}; //namespace sls \ No newline at end of file +}; // namespace sls \ No newline at end of file diff --git a/slsSupportLib/include/Timer.h b/slsSupportLib/include/Timer.h old mode 100644 new mode 100755 diff --git a/slsSupportLib/include/ZmqSocket.h b/slsSupportLib/include/ZmqSocket.h old mode 100644 new mode 100755 diff --git a/slsSupportLib/include/ansi.h b/slsSupportLib/include/ansi.h old mode 100644 new mode 100755 diff --git a/slsSupportLib/include/container_utils.h b/slsSupportLib/include/container_utils.h old mode 100644 new mode 100755 diff --git a/slsSupportLib/include/error_defs.h b/slsSupportLib/include/error_defs.h old mode 100644 new mode 100755 diff --git a/slsSupportLib/include/file_utils.h b/slsSupportLib/include/file_utils.h old mode 100644 new mode 100755 diff --git a/slsSupportLib/include/genericSocket.h b/slsSupportLib/include/genericSocket.h old mode 100644 new mode 100755 diff --git a/slsSupportLib/include/logger.h b/slsSupportLib/include/logger.h old mode 100644 new mode 100755 index 2be26378a..1a7dae07a --- a/slsSupportLib/include/logger.h +++ b/slsSupportLib/include/logger.h @@ -18,6 +18,7 @@ #ifndef FILELOG_MAX_LEVEL #define FILELOG_MAX_LEVEL logINFO +//#define FILELOG_MAX_LEVEL logDEBUG5 #endif @@ -80,7 +81,7 @@ class FILELOG_DECLSPEC FILELog : public Log {}; inline std::string NowTime() { - char buffer[11]; + char buffer[12]; const int buffer_len = sizeof(buffer); time_t t; time(&t); diff --git a/slsSupportLib/include/network_utils.h b/slsSupportLib/include/network_utils.h old mode 100644 new mode 100755 diff --git a/slsSupportLib/include/rapidjson/allocators.h b/slsSupportLib/include/rapidjson/allocators.h old mode 100644 new mode 100755 diff --git a/slsSupportLib/include/rapidjson/document.h b/slsSupportLib/include/rapidjson/document.h old mode 100644 new mode 100755 diff --git a/slsSupportLib/include/rapidjson/encodedstream.h b/slsSupportLib/include/rapidjson/encodedstream.h old mode 100644 new mode 100755 diff --git a/slsSupportLib/include/rapidjson/encodings.h b/slsSupportLib/include/rapidjson/encodings.h old mode 100644 new mode 100755 diff --git a/slsSupportLib/include/rapidjson/error/en.h b/slsSupportLib/include/rapidjson/error/en.h old mode 100644 new mode 100755 diff --git a/slsSupportLib/include/rapidjson/error/error.h b/slsSupportLib/include/rapidjson/error/error.h old mode 100644 new mode 100755 diff --git a/slsSupportLib/include/rapidjson/filereadstream.h b/slsSupportLib/include/rapidjson/filereadstream.h old mode 100644 new mode 100755 diff --git a/slsSupportLib/include/rapidjson/filewritestream.h b/slsSupportLib/include/rapidjson/filewritestream.h old mode 100644 new mode 100755 diff --git a/slsSupportLib/include/rapidjson/fwd.h b/slsSupportLib/include/rapidjson/fwd.h old mode 100644 new mode 100755 diff --git a/slsSupportLib/include/rapidjson/internal/biginteger.h b/slsSupportLib/include/rapidjson/internal/biginteger.h old mode 100644 new mode 100755 diff --git a/slsSupportLib/include/rapidjson/internal/diyfp.h b/slsSupportLib/include/rapidjson/internal/diyfp.h old mode 100644 new mode 100755 diff --git a/slsSupportLib/include/rapidjson/internal/dtoa.h b/slsSupportLib/include/rapidjson/internal/dtoa.h old mode 100644 new mode 100755 diff --git a/slsSupportLib/include/rapidjson/internal/ieee754.h b/slsSupportLib/include/rapidjson/internal/ieee754.h old mode 100644 new mode 100755 diff --git a/slsSupportLib/include/rapidjson/internal/itoa.h b/slsSupportLib/include/rapidjson/internal/itoa.h old mode 100644 new mode 100755 diff --git a/slsSupportLib/include/rapidjson/internal/meta.h b/slsSupportLib/include/rapidjson/internal/meta.h old mode 100644 new mode 100755 diff --git a/slsSupportLib/include/rapidjson/internal/pow10.h b/slsSupportLib/include/rapidjson/internal/pow10.h old mode 100644 new mode 100755 diff --git a/slsSupportLib/include/rapidjson/internal/regex.h b/slsSupportLib/include/rapidjson/internal/regex.h old mode 100644 new mode 100755 diff --git a/slsSupportLib/include/rapidjson/internal/stack.h b/slsSupportLib/include/rapidjson/internal/stack.h old mode 100644 new mode 100755 diff --git a/slsSupportLib/include/rapidjson/internal/strfunc.h b/slsSupportLib/include/rapidjson/internal/strfunc.h old mode 100644 new mode 100755 diff --git a/slsSupportLib/include/rapidjson/internal/strtod.h b/slsSupportLib/include/rapidjson/internal/strtod.h old mode 100644 new mode 100755 diff --git a/slsSupportLib/include/rapidjson/internal/swap.h b/slsSupportLib/include/rapidjson/internal/swap.h old mode 100644 new mode 100755 diff --git a/slsSupportLib/include/rapidjson/istreamwrapper.h b/slsSupportLib/include/rapidjson/istreamwrapper.h old mode 100644 new mode 100755 diff --git a/slsSupportLib/include/rapidjson/memorybuffer.h b/slsSupportLib/include/rapidjson/memorybuffer.h old mode 100644 new mode 100755 diff --git a/slsSupportLib/include/rapidjson/memorystream.h b/slsSupportLib/include/rapidjson/memorystream.h old mode 100644 new mode 100755 diff --git a/slsSupportLib/include/rapidjson/msinttypes/inttypes.h b/slsSupportLib/include/rapidjson/msinttypes/inttypes.h old mode 100644 new mode 100755 diff --git a/slsSupportLib/include/rapidjson/msinttypes/stdint.h b/slsSupportLib/include/rapidjson/msinttypes/stdint.h old mode 100644 new mode 100755 diff --git a/slsSupportLib/include/rapidjson/ostreamwrapper.h b/slsSupportLib/include/rapidjson/ostreamwrapper.h old mode 100644 new mode 100755 diff --git a/slsSupportLib/include/rapidjson/pointer.h b/slsSupportLib/include/rapidjson/pointer.h old mode 100644 new mode 100755 diff --git a/slsSupportLib/include/rapidjson/prettywriter.h b/slsSupportLib/include/rapidjson/prettywriter.h old mode 100644 new mode 100755 diff --git a/slsSupportLib/include/rapidjson/rapidjson.h b/slsSupportLib/include/rapidjson/rapidjson.h old mode 100644 new mode 100755 diff --git a/slsSupportLib/include/rapidjson/reader.h b/slsSupportLib/include/rapidjson/reader.h old mode 100644 new mode 100755 diff --git a/slsSupportLib/include/rapidjson/schema.h b/slsSupportLib/include/rapidjson/schema.h old mode 100644 new mode 100755 diff --git a/slsSupportLib/include/rapidjson/stream.h b/slsSupportLib/include/rapidjson/stream.h old mode 100644 new mode 100755 diff --git a/slsSupportLib/include/rapidjson/stringbuffer.h b/slsSupportLib/include/rapidjson/stringbuffer.h old mode 100644 new mode 100755 diff --git a/slsSupportLib/include/rapidjson/writer.h b/slsSupportLib/include/rapidjson/writer.h old mode 100644 new mode 100755 diff --git a/slsSupportLib/include/sls_detector_defs.h b/slsSupportLib/include/sls_detector_defs.h index ef309509b..4db2091ff 100755 --- a/slsSupportLib/include/sls_detector_defs.h +++ b/slsSupportLib/include/sls_detector_defs.h @@ -204,7 +204,6 @@ public: enum fileFormat { GET_FILE_FORMAT=-1,/**< the receiver will return its file format */ BINARY, /**< binary format */ - ASCII, /**< ascii format */ HDF5, /**< hdf5 format */ NUM_FILE_FORMATS }; @@ -307,8 +306,7 @@ public: */ enum dimension { X=0, /**< X dimension */ - Y=1, /**< Y dimension */ - Z=2 /**< Z dimension */ + Y=1 /**< Y dimension */ }; /** @@ -350,9 +348,7 @@ public: GET_EXTERNAL_COMMUNICATION_MODE=-1,/** namespace sls { -ClientSocket::ClientSocket(const bool isRx, const std::string &host, uint16_t port) - : DataSocket(socket(AF_INET, SOCK_STREAM, 0)), isReceiver(isRx) { +ClientSocket::ClientSocket(std::string stype, const std::string &host, uint16_t port) + : DataSocket(socket(AF_INET, SOCK_STREAM, 0)), socketType(stype) { struct addrinfo hints, *result; memset(&hints, 0, sizeof(hints)); @@ -34,22 +34,20 @@ ClientSocket::ClientSocket(const bool isRx, const std::string &host, uint16_t po if (::connect(getSocketId(), (struct sockaddr *)&serverAddr, sizeof(serverAddr)) != 0) { freeaddrinfo(result); - const std::string name{(isReceiver ? "Receiver" : "Detector")}; - std::string msg = "ClientSocket: Cannot connect to " + name + ":" + host + " on port " + - std::to_string(port) + "\n"; + std::string msg = "ClientSocket: Cannot connect to " + socketType + ":" + + host + " on port " + std::to_string(port) + "\n"; throw SocketError(msg); } freeaddrinfo(result); } -ClientSocket::ClientSocket(const bool isRx, struct sockaddr_in addr) - : DataSocket(socket(AF_INET, SOCK_STREAM, 0)), isReceiver(isRx) { +ClientSocket::ClientSocket(std::string sType, struct sockaddr_in addr) + : DataSocket(socket(AF_INET, SOCK_STREAM, 0)), socketType(sType) { if (::connect(getSocketId(), (struct sockaddr *)&addr, sizeof(addr)) != 0) { char address[INET_ADDRSTRLEN]; inet_ntop(AF_INET, &addr.sin_addr, address, INET_ADDRSTRLEN); - const std::string name{(isReceiver ? "Receiver" : "Detector")}; - std::string msg = "ClientSocket: Cannot connect to " + name + ":" + address + " on port " + + std::string msg = "ClientSocket: Cannot connect to " + socketType + ":" + address + " on port " + std::to_string(addr.sin_port) + "\n"; throw SocketError(msg); } @@ -67,30 +65,25 @@ int ClientSocket::sendCommandThenRead(int fnum, void *args, size_t args_size, vo void ClientSocket::readReply(int &ret, void *retval, size_t retval_size) { receiveData(&ret, sizeof(ret)); - bool unrecognizedFunction = false; if (ret == slsDetectorDefs::FAIL) { char mess[MAX_STR_LENGTH]{}; // get error message receiveData(mess, sizeof(mess)); - // cprintf(RED, "%s %d returned error: %s", type.c_str(), index, mess); - cprintf(RED, "%s returned error: %s", (isReceiver ? "Receiver" : "Detector"), mess); + FILE_LOG(logERROR) << socketType << " returned error: " << mess; std::cout << "\n"; // needed to reset the color. - // unrecognized function, do not ask for retval - if (strstr(mess, "Unrecognized Function") != nullptr) - unrecognizedFunction = true; - // Do we need to know hostname here? // In that case save it??? - if (isReceiver) { + if (socketType == "Receiver") { throw ReceiverError(mess); - } else { + } else if (socketType == "Detector") { throw DetectorError(mess); + } else { + throw GuiError(mess); } } // get retval - if (!unrecognizedFunction) - receiveData(retval, retval_size); + receiveData(retval, retval_size); } }; // namespace sls diff --git a/slsSupportLib/src/CmdLineParser.cpp b/slsSupportLib/src/CmdLineParser.cpp old mode 100644 new mode 100755 diff --git a/slsSupportLib/src/DataSocket.cpp b/slsSupportLib/src/DataSocket.cpp old mode 100644 new mode 100755 index 2991ff21e..b64b9fda8 --- a/slsSupportLib/src/DataSocket.cpp +++ b/slsSupportLib/src/DataSocket.cpp @@ -88,6 +88,11 @@ void DataSocket::close() { } } +void DataSocket::shutDownSocket() { + shutdown(getSocketId(), SHUT_RDWR); + close(); +} + struct sockaddr_in ConvertHostnameToInternetAddress(const std::string &hostname) { struct addrinfo hints, *result; memset(&hints, 0, sizeof(hints)); diff --git a/slsSupportLib/src/ServerInterface.cpp b/slsSupportLib/src/ServerInterface.cpp old mode 100644 new mode 100755 diff --git a/slsSupportLib/src/ServerSocket.cpp b/slsSupportLib/src/ServerSocket.cpp old mode 100644 new mode 100755 index 3107277b1..29fd50447 --- a/slsSupportLib/src/ServerSocket.cpp +++ b/slsSupportLib/src/ServerSocket.cpp @@ -1,25 +1,31 @@ #include "ServerSocket.h" #include "DataSocket.h" +#include "logger.h" +#include "sls_detector_defs.h" +#include "sls_detector_exceptions.h" +#include "string_utils.h" + #include #include -#include #include +#include +#include #define DEFAULT_PACKET_SIZE 1286 -#define SOCKET_BUFFER_SIZE (100 * 1024 * 1024) //100 MB +#define SOCKET_BUFFER_SIZE (100 * 1024 * 1024) // 100 MB #define DEFAULT_BACKLOG 5 namespace sls { -ServerSocket::ServerSocket(int port) : DataSocket(socket(AF_INET, SOCK_STREAM, 0)) { - - std::cout << "Server constructed\n"; +ServerSocket::ServerSocket(int port) + : DataSocket(socket(AF_INET, SOCK_STREAM, 0)), serverPort(port) { struct sockaddr_in serverAddr; serverAddr.sin_family = AF_INET; serverAddr.sin_port = htons(port); serverAddr.sin_addr.s_addr = htonl(INADDR_ANY); - if (bind(getSocketId(), (struct sockaddr *)&serverAddr, sizeof(serverAddr)) != 0) { + if (bind(getSocketId(), (struct sockaddr *)&serverAddr, + sizeof(serverAddr)) != 0) { close(); throw std::runtime_error("Server ERROR: cannot bind socket"); } @@ -32,16 +38,42 @@ ServerSocket::ServerSocket(int port) : DataSocket(socket(AF_INET, SOCK_STREAM, 0 DataSocket ServerSocket::accept() { struct sockaddr_in clientAddr; socklen_t addr_size = sizeof clientAddr; - int newSocket = ::accept(getSocketId(), (struct sockaddr *)&clientAddr, &addr_size); + int newSocket = + ::accept(getSocketId(), (struct sockaddr *)&clientAddr, &addr_size); if (newSocket == -1) { throw std::runtime_error("Server ERROR: socket accept failed\n"); } - inet_ntop(AF_INET, &(clientAddr.sin_addr), &thisClient_.front(), INET_ADDRSTRLEN); - std::cout << "lastClient: " << lastClient_ << " thisClient: " << thisClient_ << '\n'; - //Here goes any check for locks etc + inet_ntop(AF_INET, &(clientAddr.sin_addr), &thisClient_.front(), + INET_ADDRSTRLEN); + std::cout << "lastClient: " << lastClient_ << " thisClient: " << thisClient_ + << '\n'; + // Here goes any check for locks etc lastClient_ = thisClient_; return DataSocket(newSocket); } -}; //namespace sls +const std::string &ServerSocket::getLastClient() { return lastClient_; } + +const int ServerSocket::getPort() { return serverPort; } + +void ServerSocket::SendResult(int &ret, void* retval, int retvalSize, char* mess) { + + // send success of operation + sendData(&ret, sizeof(ret)); + + if (ret == slsDetectorDefs::FAIL) { + // create error message if empty + if (!strlen(mess)) { + strcpy(mess, "No error message provided for this failure in server. Will mess up TCP."); + } + + sendData(mess, MAX_STR_LENGTH); + throw sls::RuntimeError(mess); + } + // send return value + sendData(retval, retvalSize); +} + + +}; // namespace sls diff --git a/slsSupportLib/src/file_utils.cpp b/slsSupportLib/src/file_utils.cpp old mode 100644 new mode 100755 diff --git a/slsSupportLib/src/network_utils.cpp b/slsSupportLib/src/network_utils.cpp old mode 100644 new mode 100755 diff --git a/slsSupportLib/src/string_utils.cpp b/slsSupportLib/src/string_utils.cpp old mode 100644 new mode 100755 diff --git a/slsSupportLib/tests/CMakeLists.txt b/slsSupportLib/tests/CMakeLists.txt old mode 100644 new mode 100755 diff --git a/slsSupportLib/tests/test-ClientInterface.cpp b/slsSupportLib/tests/test-ClientInterface.cpp old mode 100644 new mode 100755 diff --git a/slsSupportLib/tests/test-CmdLineParser.cpp b/slsSupportLib/tests/test-CmdLineParser.cpp old mode 100644 new mode 100755 diff --git a/slsSupportLib/tests/test-Timer.cpp b/slsSupportLib/tests/test-Timer.cpp old mode 100644 new mode 100755 diff --git a/slsSupportLib/tests/test-container_utils.cpp b/slsSupportLib/tests/test-container_utils.cpp old mode 100644 new mode 100755 diff --git a/slsSupportLib/tests/test-network_utils.cpp b/slsSupportLib/tests/test-network_utils.cpp old mode 100644 new mode 100755 diff --git a/slsSupportLib/tests/test-string_utils.cpp b/slsSupportLib/tests/test-string_utils.cpp old mode 100644 new mode 100755 diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt old mode 100644 new mode 100755 index 61415ddc3..9f2139483 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -19,8 +19,6 @@ target_link_libraries(tests set_target_properties(tests PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin ) -include(CTest) -include(Catch) -catch_discover_tests(tests) + # #TODO! Move to automatic test discovery # add_test(test ${CMAKE_BINARY_DIR}/bin/testSlsReceiver) \ No newline at end of file diff --git a/tests/test.cpp b/tests/test.cpp old mode 100644 new mode 100755 diff --git a/updateAPIVersion.sh b/updateAPIVersion.sh new file mode 100755 index 000000000..6f4cb119f --- /dev/null +++ b/updateAPIVersion.sh @@ -0,0 +1,37 @@ +#require 2 arguments, API_NAME API_DIR (relative to package) +if [ $# -lt 2 ]; then + echo "wrong usage of updateVersion.sh" + exit -1 +fi + +API_NAME=$1 +PACKAGE_DIR=$PWD +API_DIR=$PACKAGE_DIR/$2 +API_FILE=$PACKAGE_DIR/slsSupportLib/include/versionAPI.h +CURR_DIR=$PWD + +#go to directory +cd $API_DIR + +#deleting line from file +NUM=$(sed -n '/'$API_NAME'/=' $API_FILE) +#echo $NUM + +if [ "$NUM" -gt 0 ]; then + sed -i ${NUM}d $API_FILE +fi + +#find new API date +API_DATE="find . -printf \"%T@ %CY-%Cm-%CdT%CH:%CM:%CS %p\n\"| sort -nr | cut -d' ' -f2- | egrep -v build | egrep -v '(\.)o'| egrep -v 'versionAPI.h' | head -n 1" +API_DATE=`eval $API_DATE` +API_DATE=$(sed "s/-//g" <<< $API_DATE | awk '{print $1;}' ) +#extracting only date +API_DATE=${API_DATE:2:6} +#prefix of 0x +API_DATE=${API_DATE/#/0x} + +#copy it to versionAPI.h +echo "#define "$API_NAME $API_DATE >> $API_FILE + +#go back to original directory +cd $CURR_DIR diff --git a/updateClientAPI.sh b/updateClientAPI.sh new file mode 100755 index 000000000..49e8be65a --- /dev/null +++ b/updateClientAPI.sh @@ -0,0 +1,24 @@ +API_FILE=$PWD/slsSupportLib/include/versionAPI.h +arraylength=3 + +LIB_DIR=slsDetectorSoftware +RXR_DIR=slsReceiverSoftware +GUI_DIR=slsDetectorGui + +declare -a arraydirs=($LIB_DIR $RXR_DIR $GUI_DIR) +declare -a arraynames=("APILIB" "APIRECEIVER" "APIGUI") + +for (( i=0; i<${arraylength}; ++i )); +do + ./updateAPIVersion.sh ${arraynames[$i]} ${arraydirs[$i]} +done + +#find branch +CURR_BRANCH=$(git branch | grep \* | cut -d ' ' -f2) + +#update branch +BRANCH=$(cat $API_FILE | grep GITBRANCH | cut -d' ' -f3) +sed -i s/$BRANCH/\"$CURR_BRANCH\"/g $API_FILE + + +