From 67dd8d907e92d053a810a537795cd6975aac3e4e Mon Sep 17 00:00:00 2001 From: Jerome Locatelli <locatelli@ill.fr> Date: Tue, 5 Jan 2016 16:06:59 +0000 Subject: [PATCH] Merge of branch Instrument_RC_174 --- .cproject | 8 +- build.sh | 2 +- modgen.jar | Bin 14654 -> 14670 bytes .../lss/d22special/CountWithSpectro.cpp | 186 ++- .../lss/d22special/CountWithSpectro.h | 11 +- .../lss/d22special/D22SampleSequencer.cpp | 205 --- .../lss/d22special/D22SampleSequencer.h | 80 - .../d22special/D22SpectroSampleSequencer.cpp | 309 ++++ .../d22special/D22SpectroSampleSequencer.h | 89 + .../DualSwitchSpectroController.cpp | 155 +- .../d22special/DualSwitchSpectroController.h | 13 + src/controllers/lss/d22special/Module.xml | 2 +- .../count_with_spectro.properties | 5 +- .../count_with_spectroCommandView.xml | 9 +- .../count_with_spectroProperties.xml | 10 +- .../count_with_spectroView.xml | 3 +- .../d22_sample_sequencer.properties | 60 - .../d22_sample_sequencerCommandView.xml | 11 - .../d22_sample_sequencerPlugin.xml | 12 - .../d22_sample_sequencerProperties.xml | 64 - .../d22_sample_sequencerView.xml | 74 - .../d22spectroSampleSequencer.properties | 28 + .../d22spectroSampleSequencerCommandView.xml | 12 + .../d22spectroSampleSequencerPlugin.xml | 10 + .../d22spectroSampleSequencerProperties.xml | 46 + .../d22spectroSampleSequencerView.xml | 44 + .../npp/BidimHistoDetectorElement.cpp | 62 + .../npp/BidimHistoDetectorElement.h | 75 + src/controllers/npp/CAENAdcController.cpp | 20 +- src/controllers/npp/CAENAdcController.h | 19 +- src/controllers/npp/CAENCfdController.cpp | 222 +++ src/controllers/npp/CAENCfdController.h | 100 ++ src/controllers/npp/CAENPhaController.cpp | 9 +- src/controllers/npp/CAENPhaController.h | 22 +- src/controllers/npp/CAENPksController.cpp | 96 ++ src/controllers/npp/CAENPksController.h | 78 + src/controllers/npp/CAENPsdController.cpp | 8 +- src/controllers/npp/CAENPsdController.h | 24 +- .../npp/DPPAcquisitionController.cpp | 206 ++- .../npp/DPPAcquisitionController.h | 9 +- .../npp/DPPLiveProcessCountRelay.cpp | 4 +- src/controllers/npp/Module.xml | 5 + .../cfd_controler/cfd_controller.properties | 152 ++ .../cfd_controler/cfd_controllerPlotDatas.xml | 23 + .../cfd_controler/cfd_controllerPlugin.xml | 7 + .../cfd_controllerProperties.xml | 102 ++ .../gui/cfd_controler/cfd_controllerView.xml | 81 + .../dpp_coincidence/dpp_coincidenceView.xml | 17 +- .../gui/pha_controller/pha_controllerView.xml | 1 - .../pks_controller/pks_controller.properties | 11 + .../pks_controller/pks_controllerPlugin.xml | 7 + .../pks_controllerProperties.xml | 16 + .../gui/pks_controller/pks_controllerView.xml | 21 + .../psd_controllerProperties.xml | 10 +- src/controllers/remotefiletest/Module.xml | 4 + .../remotefiletest/RemoteFileTest.cpp | 171 ++ .../remotefiletest/RemoteFileTest.h | 63 + src/controllers/remotenpp/DPPReader.cpp | 111 -- src/controllers/remotenpp/DPPReader.h | 98 -- .../remotenpp/{Module.xml.new => Module.xml} | 3 + .../remotenpp/RemoteDPPCoincidence.cpp | 312 ++-- .../remotenpp/RemoteDPPCoincidence.h | 36 +- .../remotenpp/RemoteDPPContext.cpp | 79 + src/controllers/remotenpp/RemoteDPPContext.h | 43 + .../remotenpp/RemoteDPPHistogram.cpp | 338 ++-- .../remotenpp/RemoteDPPHistogram.h | 34 +- .../remotenpp/RemoteDPPLiveProcess.cpp | 43 + .../remotenpp/RemoteDPPLiveProcess.h | 41 + .../remote_dpp_coincidence.properties | 6 +- .../remote_dpp_coincidenceProperties.xml | 21 +- .../remote_dpp_coincidenceView.xml | 17 +- .../remote_dpp_histogram.properties | 27 +- .../remote_dpp_histogramPlotDatas.xml | 10 +- .../remote_dpp_histogramProperties.xml | 112 +- .../remote_dpp_histogramView.xml | 84 +- src/controllers/remotetas/Module.xml | 7 + src/controllers/remotetas/NumorMessages.pb.cc | 1464 +++++++++++++++++ src/controllers/remotetas/NumorMessages.pb.h | 1403 ++++++++++++++++ src/controllers/remotetas/NumorMessages.proto | 34 + src/controllers/remotetas/RemoteMatlab.cpp | 345 ++++ src/controllers/remotetas/RemoteMatlab.h | 91 + .../spectrometer/QE65000Controller.cpp | 148 +- .../spectrometer/QE65000Controller.h | 4 +- src/drivers/caen_cd/CAENCdDef.h | 45 + src/drivers/caen_cd/CAENCdDriver.cpp | 223 +++ src/drivers/caen_cd/CAENCdDriver.h | 119 ++ src/drivers/caen_cd/CAENCdState.h | 74 + src/drivers/caen_cd/Module.xml | 6 + src/drivers/caen_cd/PerfectCAENCdDriver.cpp | 83 + src/drivers/caen_cd/PerfectCAENCdDriver.h | 79 + src/drivers/caen_cd/RealCAENCdDriver.cpp | 329 ++++ src/drivers/caen_cd/RealCAENCdDriver.h | 96 ++ src/drivers/caen_cd/gui/caen_cd.properties | 34 + src/drivers/caen_cd/gui/caen_cdPlugin.xml | 7 + src/drivers/caen_cd/gui/caen_cdProperties.xml | 82 + src/drivers/caen_cd/gui/caen_cdView.xml | 68 + src/drivers/caen_pha/RealCAENPhaDriver.cpp | 69 +- src/drivers/caen_pks/CAENPksDef.h | 39 + src/drivers/caen_pks/CAENPksDriver.cpp | 134 ++ src/drivers/caen_pks/CAENPksDriver.h | 85 + src/drivers/caen_pks/CAENPksState.h | 69 + src/drivers/caen_pks/Module.xml | 6 + src/drivers/caen_pks/PerfectCAENPksDriver.cpp | 76 + src/drivers/caen_pks/PerfectCAENPksDriver.h | 74 + src/drivers/caen_pks/RealCAENPksDriver.cpp | 106 ++ src/drivers/caen_pks/RealCAENPksDriver.h | 77 + src/drivers/caen_pks/gui/caen_pks.properties | 11 + src/drivers/caen_pks/gui/caen_pksPlugin.xml | 7 + .../caen_pks/gui/caen_pksProperties.xml | 17 + src/drivers/caen_pks/gui/caen_pksView.xml | 25 + src/drivers/caen_psd/RealCAENPsdDriver.cpp | 83 +- src/drivers/ioxos/cfd/CfdDef.h | 74 + src/drivers/ioxos/cfd/CfdDriver.cpp | 172 ++ src/drivers/ioxos/cfd/CfdDriver.h | 103 ++ src/drivers/ioxos/cfd/CfdState.h | 64 + src/drivers/ioxos/cfd/Module.xml | 4 + src/drivers/ioxos/cfd/PerfectCfdDriver.cpp | 57 + src/drivers/ioxos/cfd/PerfectCfdDriver.h | 68 + src/drivers/ioxos/cfd/RealCfdDriver.cpp | 190 +++ src/drivers/ioxos/cfd/RealCfdDriver.h | 75 + src/drivers/ioxos/cfd/gui/cfd.properties | 106 ++ src/drivers/ioxos/cfd/gui/cfdPlugin.xml | 7 + src/drivers/ioxos/cfd/gui/cfdProperties.xml | 45 + src/drivers/ioxos/cfd/gui/cfdView.xml | 56 + src/drivers/oceanoptics/Module.xml | 4 +- src/drivers/oceanoptics/QE65000Driver.cpp | 7 +- src/drivers/oceanoptics/QE65000Driver.h | 1 + src/drivers/oceanoptics/QE65000State.h | 2 +- src/drivers/oceanoptics/RealQE65000Driver.cpp | 221 +-- src/drivers/oceanoptics/RealQE65000Driver.h | 18 +- .../oceanoptics/SimulatedQE65000Driver.cpp | 38 +- .../oceanoptics/SimulatedQE65000Driver.h | 5 +- src/drivers/oceanoptics/readme.txt | 6 +- .../princeton/usbpvcam/RealUsbPVCamDriver.cpp | 2 +- 134 files changed, 9722 insertions(+), 1730 deletions(-) delete mode 100644 src/controllers/lss/d22special/D22SampleSequencer.cpp delete mode 100644 src/controllers/lss/d22special/D22SampleSequencer.h create mode 100644 src/controllers/lss/d22special/D22SpectroSampleSequencer.cpp create mode 100644 src/controllers/lss/d22special/D22SpectroSampleSequencer.h delete mode 100644 src/controllers/lss/d22special/gui/d22_sample_sequencer/d22_sample_sequencer.properties delete mode 100644 src/controllers/lss/d22special/gui/d22_sample_sequencer/d22_sample_sequencerCommandView.xml delete mode 100644 src/controllers/lss/d22special/gui/d22_sample_sequencer/d22_sample_sequencerPlugin.xml delete mode 100644 src/controllers/lss/d22special/gui/d22_sample_sequencer/d22_sample_sequencerProperties.xml delete mode 100644 src/controllers/lss/d22special/gui/d22_sample_sequencer/d22_sample_sequencerView.xml create mode 100644 src/controllers/lss/d22special/gui/d22spectroSampleSequencer/d22spectroSampleSequencer.properties create mode 100644 src/controllers/lss/d22special/gui/d22spectroSampleSequencer/d22spectroSampleSequencerCommandView.xml create mode 100644 src/controllers/lss/d22special/gui/d22spectroSampleSequencer/d22spectroSampleSequencerPlugin.xml create mode 100644 src/controllers/lss/d22special/gui/d22spectroSampleSequencer/d22spectroSampleSequencerProperties.xml create mode 100644 src/controllers/lss/d22special/gui/d22spectroSampleSequencer/d22spectroSampleSequencerView.xml create mode 100644 src/controllers/npp/BidimHistoDetectorElement.cpp create mode 100644 src/controllers/npp/BidimHistoDetectorElement.h create mode 100644 src/controllers/npp/CAENCfdController.cpp create mode 100644 src/controllers/npp/CAENCfdController.h create mode 100644 src/controllers/npp/CAENPksController.cpp create mode 100644 src/controllers/npp/CAENPksController.h create mode 100644 src/controllers/npp/gui/cfd_controler/cfd_controller.properties create mode 100644 src/controllers/npp/gui/cfd_controler/cfd_controllerPlotDatas.xml create mode 100644 src/controllers/npp/gui/cfd_controler/cfd_controllerPlugin.xml create mode 100644 src/controllers/npp/gui/cfd_controler/cfd_controllerProperties.xml create mode 100644 src/controllers/npp/gui/cfd_controler/cfd_controllerView.xml create mode 100644 src/controllers/npp/gui/pks_controller/pks_controller.properties create mode 100644 src/controllers/npp/gui/pks_controller/pks_controllerPlugin.xml create mode 100644 src/controllers/npp/gui/pks_controller/pks_controllerProperties.xml create mode 100644 src/controllers/npp/gui/pks_controller/pks_controllerView.xml create mode 100644 src/controllers/remotefiletest/Module.xml create mode 100644 src/controllers/remotefiletest/RemoteFileTest.cpp create mode 100644 src/controllers/remotefiletest/RemoteFileTest.h delete mode 100644 src/controllers/remotenpp/DPPReader.cpp delete mode 100644 src/controllers/remotenpp/DPPReader.h rename src/controllers/remotenpp/{Module.xml.new => Module.xml} (67%) create mode 100644 src/controllers/remotenpp/RemoteDPPContext.cpp create mode 100644 src/controllers/remotenpp/RemoteDPPContext.h create mode 100644 src/controllers/remotenpp/RemoteDPPLiveProcess.cpp create mode 100644 src/controllers/remotenpp/RemoteDPPLiveProcess.h create mode 100644 src/controllers/remotetas/Module.xml create mode 100644 src/controllers/remotetas/NumorMessages.pb.cc create mode 100644 src/controllers/remotetas/NumorMessages.pb.h create mode 100644 src/controllers/remotetas/NumorMessages.proto create mode 100644 src/controllers/remotetas/RemoteMatlab.cpp create mode 100644 src/controllers/remotetas/RemoteMatlab.h create mode 100644 src/drivers/caen_cd/CAENCdDef.h create mode 100644 src/drivers/caen_cd/CAENCdDriver.cpp create mode 100644 src/drivers/caen_cd/CAENCdDriver.h create mode 100644 src/drivers/caen_cd/CAENCdState.h create mode 100644 src/drivers/caen_cd/Module.xml create mode 100644 src/drivers/caen_cd/PerfectCAENCdDriver.cpp create mode 100644 src/drivers/caen_cd/PerfectCAENCdDriver.h create mode 100644 src/drivers/caen_cd/RealCAENCdDriver.cpp create mode 100644 src/drivers/caen_cd/RealCAENCdDriver.h create mode 100644 src/drivers/caen_cd/gui/caen_cd.properties create mode 100644 src/drivers/caen_cd/gui/caen_cdPlugin.xml create mode 100644 src/drivers/caen_cd/gui/caen_cdProperties.xml create mode 100644 src/drivers/caen_cd/gui/caen_cdView.xml create mode 100644 src/drivers/caen_pks/CAENPksDef.h create mode 100644 src/drivers/caen_pks/CAENPksDriver.cpp create mode 100644 src/drivers/caen_pks/CAENPksDriver.h create mode 100644 src/drivers/caen_pks/CAENPksState.h create mode 100644 src/drivers/caen_pks/Module.xml create mode 100644 src/drivers/caen_pks/PerfectCAENPksDriver.cpp create mode 100644 src/drivers/caen_pks/PerfectCAENPksDriver.h create mode 100644 src/drivers/caen_pks/RealCAENPksDriver.cpp create mode 100644 src/drivers/caen_pks/RealCAENPksDriver.h create mode 100644 src/drivers/caen_pks/gui/caen_pks.properties create mode 100644 src/drivers/caen_pks/gui/caen_pksPlugin.xml create mode 100644 src/drivers/caen_pks/gui/caen_pksProperties.xml create mode 100644 src/drivers/caen_pks/gui/caen_pksView.xml create mode 100644 src/drivers/ioxos/cfd/CfdDef.h create mode 100644 src/drivers/ioxos/cfd/CfdDriver.cpp create mode 100644 src/drivers/ioxos/cfd/CfdDriver.h create mode 100644 src/drivers/ioxos/cfd/CfdState.h create mode 100644 src/drivers/ioxos/cfd/Module.xml create mode 100644 src/drivers/ioxos/cfd/PerfectCfdDriver.cpp create mode 100644 src/drivers/ioxos/cfd/PerfectCfdDriver.h create mode 100644 src/drivers/ioxos/cfd/RealCfdDriver.cpp create mode 100644 src/drivers/ioxos/cfd/RealCfdDriver.h create mode 100644 src/drivers/ioxos/cfd/gui/cfd.properties create mode 100644 src/drivers/ioxos/cfd/gui/cfdPlugin.xml create mode 100644 src/drivers/ioxos/cfd/gui/cfdProperties.xml create mode 100644 src/drivers/ioxos/cfd/gui/cfdView.xml diff --git a/.cproject b/.cproject index 1c45b627..7055ac20 100644 --- a/.cproject +++ b/.cproject @@ -14,7 +14,7 @@ </extensions> </storageModule> <storageModule moduleId="cdtBuildSystem" version="4.0.0"> - <configuration artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.debug,org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe" cleanCommand="rm -rf" description="" id="cdt.managedbuild.config.gnu.exe.debug.779576013" name="Debug" parent="cdt.managedbuild.config.gnu.exe.debug"> + <configuration artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe,org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.debug" cleanCommand="rm -rf" description="" id="cdt.managedbuild.config.gnu.exe.debug.779576013" name="Debug" parent="cdt.managedbuild.config.gnu.exe.debug"> <folderInfo id="cdt.managedbuild.config.gnu.exe.debug.779576013." name="/" resourcePath=""> <toolChain id="cdt.managedbuild.toolchain.gnu.exe.debug.1794005325" name="Linux GCC" superClass="cdt.managedbuild.toolchain.gnu.exe.debug"> <targetPlatform id="cdt.managedbuild.target.gnu.platform.exe.debug.1935120537" name="Debug Platform" superClass="cdt.managedbuild.target.gnu.platform.exe.debug"/> @@ -25,7 +25,7 @@ <option id="gnu.cpp.compiler.exe.debug.option.debugging.level.1951401360" name="Debug Level" superClass="gnu.cpp.compiler.exe.debug.option.debugging.level" value="gnu.cpp.compiler.debugging.level.max" valueType="enumerated"/> <option id="gnu.cpp.compiler.option.include.paths.221887624" name="Include paths (-I)" superClass="gnu.cpp.compiler.option.include.paths" valueType="includePath"> <listOptionValue builtIn="false" value=""${workspace_loc:/NomadServer/src/ics}""/> - <listOptionValue builtIn="false" value="/users/stereo/RawDataManager/include"/> + <listOptionValue builtIn="false" value=""${workspace_loc:/NomadModules/src}""/> </option> <inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.1751055782" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/> </tool> @@ -47,8 +47,6 @@ </tool> </toolChain> </folderInfo> - <fileInfo id="cdt.managedbuild.config.gnu.exe.debug.779576013.1142121045" name="RealStereoElecDriver.h" rcbsApplicability="disable" resourcePath="src/drivers/stereo_elec/RealStereoElecDriver.h" toolsToInvoke=""/> - <fileInfo id="cdt.managedbuild.config.gnu.exe.debug.779576013.1892460713" name="StereoElecDriver.h" rcbsApplicability="disable" resourcePath="src/drivers/stereo_elec/StereoElecDriver.h" toolsToInvoke=""/> </configuration> </storageModule> <storageModule moduleId="org.eclipse.cdt.core.externalSettings"/> @@ -68,7 +66,7 @@ </extensions> </storageModule> <storageModule moduleId="cdtBuildSystem" version="4.0.0"> - <configuration artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.release,org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe" cleanCommand="rm -rf" description="" id="cdt.managedbuild.config.gnu.exe.release.867724389" name="Release" parent="cdt.managedbuild.config.gnu.exe.release"> + <configuration artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe,org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.release" cleanCommand="rm -rf" description="" id="cdt.managedbuild.config.gnu.exe.release.867724389" name="Release" parent="cdt.managedbuild.config.gnu.exe.release"> <folderInfo id="cdt.managedbuild.config.gnu.exe.release.867724389." name="/" resourcePath=""> <toolChain id="cdt.managedbuild.toolchain.gnu.exe.release.1095010789" name="Linux GCC" superClass="cdt.managedbuild.toolchain.gnu.exe.release"> <targetPlatform id="cdt.managedbuild.target.gnu.platform.exe.release.703158621" name="Debug Platform" superClass="cdt.managedbuild.target.gnu.platform.exe.release"/> diff --git a/build.sh b/build.sh index 5267af51..13a08ac7 100755 --- a/build.sh +++ b/build.sh @@ -21,7 +21,7 @@ autoconf automake --gnu --add-missing -export CXXFLAGS="-Wall -Wconversion -O2 -g -pthread" +export CXXFLAGS="$CXXFLAGS -Wall -Wconversion -O2 -g -pthread" cd build diff --git a/modgen.jar b/modgen.jar index efa651d42e316e54fe2e7c83bf865ec65b6371c6..f68a0c992810fe88ae7694520194773e8a2e3114 100644 GIT binary patch delta 2369 zcmdm2bgqamz?+$ci-CcIfnjq_h5JN4b&gFr74CDjL>eaAMzfvOEuGBcJ8_;e%fV_- z_lZXpA@nO1O%R^}39vITFy!W^l;))BBa8$onrzM}57xCgig7M8g!P*x7|IIbU>D|{ znN#8Z(e3Wyo$L$@rIXX7<?H{)M~6$+<$3H-jNzKHOm~fL&sq^C#q4x*-H5juu{S48 znZ|qVnx+0jA-%KP@7^(3v2Anlt2v){`#Ij7Q~YT9s@plu(Odmim%d}KFQ{*}|DpfJ zIDCHbJ6{i`--;(K-&?+~p7+`2{qK2uJ|CQYol)k1eQ1Tq7M0$f#Fu5)x_n-)tS@d` zddU0ro_!14gR0adEe&n+RdQH+HwwGU_x0I{*$YXBZZO@oFZs~6Gd@Kgj+Z^mCU5`R zW4m%WSDQR97t_W!K8mS4ddq^jW}Wp>3Y}q?CX*cJI9qsG!t9kN3T^Gp6L0ifHb_)6 z-W9unhxNDFJBfQ0-x8}#rMpcpGFNGZ&a2l*&+s@MdF9M!r-NN5+;zO;h0>0_ym`h> zrZh&`&!#fr?}nL%Zx3_5s`{-aTH(IQ*o~p|#>zzLCM_$GEqM&`4%TI64hQpi8BMwZ zm$&Jjdr`)FHY2c*edbLT7lyli`TcESIZvl9PCM2ie(7@C*9mrWjau|>w#=J#MK}0N z?BeV7^Nc?ytqsdw7<p+!vgn#OFW&wZh^sP>zu6;cnw~1`HZOhKH!Hg|v!XLkvhJra z{4U(y#mu$klqj$KK}WCoNgjsN_tmDa-rM?quasR^zoGouKY^E%veMS7Y95r_Xtg9! zLSCIIPJ7+*%AdKaH>Um+I-p+Qa#Ve_(cQ?)1@dkh>*_yNIQk2^ZZMCE=5c<c!@5|i z?_u4elKj^K3JpP*Z&hF4AaX#WEyTuwag~_MofT~okDes?l_y_YP@u0EP?8*T*pqRG z-~5?^_k^Y74jty&wqu3bCRT057jITIhBSL<EKcw`tf1sGb57oQLyxW9O#3GqU2;2? zw&&UAt=(TU#dC}6eRIO*pFA(|_?%bOEVUflLcL|rQ`%Npygtq&&i<KO(mqYJg6(;W zOR<#C!It|c&OBM}Q+=+#IO%qbo;rt5_6d#+ynB8XI?p%Mu`f!pop}0Z;>5`ZT@LX_ zAMxgBXXW*uA|n&`CqjrX$3N-sW+^-MYtlRGPMz3ot#`@5!>qV1wSKnSz5esu(<|q$ z{iG?Dbv5*Osdjz@W6UAHiGA@`J}eEg>YE(6@k3AB`UjEA>iyo-s?04iN(*jPZ#`Tr zwXbcxaOuvF)ZCmCEB^ji)|UV9wqKwyXK7K=_9<BjdnX+G5X*aCczWn(KC@Tqf{}|% z^NKWAy*Mp6Eyr0~s;)ymQ1WtpnN?TQ+t9y>XSVX2K4Sgja<u!6y>z(go|gHO&h~7~ zxIS%FbT;n~$+~rqroIY_J$0MyY5Y<B6-C=N+&fo!xR7xYk5ttx@xP*atACWPTo|UG z{e!no`?jd>$}{aEznAPdv|1`oIM+Qj@R(|ps;}n>S^2$@#w#Cbo%c9Vc*JmO(Zl+# z6Rp}6ZZ&%sKJ<-I77xi-^Uahe%rK&gzxDQflNkM-y<zsnNk4UY>jfXo;&|tAbhda; z9#e*gjbr`g59Jq4|J+G<ou;PmGU2b$1Ch4L7QN@J4K)HDmVIlt`d9j4Ve|Z|b0Oz! zK72mByr<ar-0UAWgN&bVRy$s^?bJ83Dy>H=>z{lti}G;`|8ZMB>Tur$(=GGk4(En% z%&y&`{$y{L-nreD`#)=a+o#6-_Hj8oV`F<&<rIrG&F-b2Is|g}#$23p;l*NBneWLB z^Y|ugu(5Mmed95A?7@5CryE}{Ep&Gkh_^hkpk&czBiA=f2PXe@y(1d@sPub9xS@@} z7deY3+22L$3(s@?I{JR$+J8!X`k&R_?lYC?Z9n8H6Mwk*^o1iE=ggf^b!#=tUgqoZ zyGoU7CO`Z4LCSA!(tMtqfr3Snyo!c1bgcile+X1hJYHFzAbzkca9Lhgfx7PR0_lU_ zh3Z;(WR%#IW4b@yf8cqiS99ON^a6qT2lvi+n#Jb4!E*nJFrE5!^<7OLyWV|0`a*Dy z8l&Bu<@Y0nmL&<!KeYIWK*AIM$A+&iw(XYqXi{!_N~9=fvyZ^>W!`W9$S?3bx~0qT z>4N9BTlVtLzjVyeHu;ljv1i>i)t|ABo18!P7O2YaKH@WBj>1XpikV+{JU&g6eb=ir zNjsxZ?em-o-xv+O*Crj@m{$LE+TC+cKA!sfv+Hkbs7&#i?n}4!t$W+G`{^I8cLi(2 zwHDiGemA#>UQ&?AWxhx6PVJ^3H;=O#!QbnaePmv9on6ym%A%t`Ynz;UJ}<QDTy9Y% zC|uF1@^`AqUf=ok!6J&+65Cg8ig>>(sdM6l6NiQWsiv-8yypFmLtB#8I?X6!`B&fW z#<h4)zntjr+kb8Uz5Dk4!RHHe|JU9*RNG{%UvItsp%C|H?v0FGUrGey<uo3x{%D|n zU*nPW!>_Y$o%^A{WnZ}E!ySe5cX~5Bt)H}LJ$^T(;>OB|=JSt#_XwmES$Zye!2a}I zVWajU>#rSFT1l4Mx^kKG9~|epcPQdZ=^h`6{q;*8mUD&W{VkvSe(k3{Dv!@>jG1(! zyRtLc`my1xZsikK>gJ|vO`0B7krz0}D)id{@dMr(KWbM>KCl$`+VNlQ*ZPNCmYUNn zBDp6{vF})S?7n^1v}5<}H?Ll+d`tOvR@;tEZ!9d!Ji1SO(n*-jx?AC5sU`cANUq&F znK6~~c0QPB5pr_Ei=sc~FO|FxE3d!mIq93gh2GR3uk?y99c>KfDdT+o)JV*IrE1(a zo9Gj)Njp7mFXd{}nz~DK_fm_S-2Rhay!$_4*8acsu!aB!1E?Xe*-BZ79a8@%XdPvN zur&2Av9W+!9+Ur@nsdOK9+U0NtibY<Ys?HGjE!a{5Jrue)MRFJaR^7wTpz*+G<SwD zW|-SS7`Mzlcu^Y``WEI8sVoaAMw`j47D^EAY6~f*B(2GLTGEp{%z5NNZe5==FL53l a1H)QA1_lYFR?d<}?a92B+HC(#L4p8ut4Wgp delta 2353 zcmX?Cw6BOSz?+$ci-CcIfx#x!*li-8I)`<rv0G`dX!k_hXtrLT(#bu%6Xz+jxW}ry zO+2ayp<k(Jg7^$bfSrMXAvZszG$&ObVI)Y=WOGJ&u&&KfjB}YGtluob%q(w1jNLW| zaj*;Xf|Paj?lxM<&cF~mIZax={%?JBsO0~9CNF(2-~O8W^4g}gOE;~{&%9BfkUh6= z-3F&grLQw?sy)grx_wVK|IVGBvQ54Mf+hQuZ*?i{3oX?0nZ-3#Q|asHkN-cg|7W#3 z@n>Ff{v{P%dlk#)md`8Ceg9c^{_~tazaN+9F<P|Lul%5qG0XT;+tS;T+BR#|^`)lO zbLp=Y|KeR`v2ywIL+a^z5{1!@wO^imbXQLHKho!VTx5%jS-H=xX*1_Zhg~q3<@r3v zHrM~<$vqF<=QcT*Og^FByRbDR$Z_$^KK0L>$`2)qxuWJ8RNnS!^MA4Pr|03cIlDZI z_1505JRMMw@Val}+I0D);fps0h}tetpS-lQsIR_l${g1-GQwQbT<y{#e=RaF_B&tp zZDPk`sj^2WnX}!`Y{`@l4Y+*UeCYw}S)LM%R}!|j&E;72BH+Rv)*6PlH)7dYt4&z~ z^xfu4m02vdHZ@t~d35=SGiC}*FUo4FO-vTIYPz4<B6xav8qez<yU8XkdNX&-n{!Dw z_)P5L>+{Tu>yy?-WiPxrC(-?M#LcU>zjN;SlDB`8tZ~-0Q%8Db&gZ-<tvTcK!*TNJ z+F(YRBeq(6nio!mo770PYt~LuJR0-s+uZeE#P)s9{K50?d96wDao_H6<78bg&U2kt z6M2<?=m;9DoiQ)zlXdro)9<|*<{vf`oxgs^%X72Z*bTf2d(}VJS54Ar+B@-8l7v{g zro`nB3UW$*=F#m8j8kTXJ&!#a#PC=m?4tqeiU@&1WvN9S6T2(#_C~fI@^xD9;#f;t zFjGPAJP(fdp1kQFRy4`#tvcy*uZ!Di_bP=@MWIs~Gp-r57_9dR+x}c~$tBmu`yNu7 z%DKjIkAJ>8dTUDewvAe5tLx7{NuN`gu4>CWd7IpRiL0AGwXL#v@7~nyywf|=K25Zu z?OChKXDOe9E%!ati!Lv-eSh3_W3Jt7QI=&UOIUAMEvq|pLAdRyd)S)en<MRYii|}1 ze<yZV6h18QJRI!G-Y#x0*2;W)a>V~lZOe~V*<SaTwk$s$D%Ex(?b?Q%%O_UW|KK{k zS?M6>-BXfb4A(bA#~fOpRk5yuQ~ku^h>Ezw*FQ4p*M_~R)tOrI?&P*zew^+389&t4 z31_c#NOjHG>CXN!m-qg`^0`53LaQDh$<w;`=j<oR<KIpHI4oK5OeQD9S80=r^BpzK ztmmhNrsde#U)#`<`YQ33pM2nju#2L{Vt>~c*v1_^AM$5PZ2Id}ZQ&n_FU>O(d-IB^ zRC^8I{sZen{%qRhAYQ!9@nU`N{eas(b(=el4|6h3;*qNA>ij3Re)W&ojlE%d**|Ra zPN=yC8~x=}wNnlHvAE5?Gi~uEkz}E@lNPBw>GQw4#&Y?i^ES$Q#}ki-?BO;)8oQ(O z`O)jM+UoZ|$SrbgJ+}J(fdtm(qu~KN)@J|6zL>k_Q=#zb?IwSG8?qI4B&X`f8f@ZS zkofV#ALqlr7lr@WdGOlV62A_G-6;n&*`GhUV!i(G1cz4Zo1$4i+7Gt#)n!=*TYf%p zo?qVJoT+90gLL<+bNXk>eBP*aGy3Jq4)#g+bGOXsS@)rQL47^%?qAn0)|K&=uSq)p ztRQ}WxoGU1^5VMdTHp3-GRr<FXJ>3|ud1A4v8LI*^ixOOt*V`iEEisM=eCeLpkOPj zpjcTmBW&aG>;J{R?GNON(eB-Ss_BQ9W7`tpxl=Qf#2MD{iWHQGbY8vlI`-g+gbUR# zI@aF}Kd|?-gus6Hs6VXrGO<Z&Z}*wX^nY#Vve?+>K5ao~vZb}<-#Ou&RqXkD%YOg8 zz;>2-q3N8sgN%}!7VA6_diCpQ!m1}9<PW;{w#X*GJ0REec9G9rk%xLwd=L1V-mCsG zkhE~(bK5EQwEjTw4))76mFFKC>}&aLaQdoATViqDRNjas^|P7`UCnC^tLk~uJsbF^ zzbv2EvNGa;_y-F^7KxwT6-`xJ9_6{&oR01P%w@SPGEU(5GViy4<QF?0?dd9fy5YI= zmO7UCmrgnACV%2B_N=?5TIoFDO+XCC)Xy8;&#;^<oV2HBy65=?D(`n4-Wzz}j?t_+ zCt3YGelM7z8lGTvt>@0B>oaX4_t}SUtGD0Z^jr3I)0S=dS-aol?cCF3cD%|pZ)NeC zpw$9frS4yO#TY5GI3>Af`&Y$#ciJNt^-uWBQQGzKx601>54uaZ&KG^rQoH%{T*A~d zYc4-$ex>lm^3{gmOX-KNy7#nb$<6yPFJx7l*S^<T7kjRs-g2XN*Z+m{qBP_ex*t7Q zR^Pw>cfIqLiWg`9TjZ^@J34dv{<*Jr91E&Zv-0qqr~4qgnRSl@cj2eCO#8%dtyyH& z#_srob8+W!w#p}QXFP8F^;;qI#*edoZ)fOtp}G?sj&bVGqckgaUeRAy;QD2;T%aZE zAB|m2bDQ%Yt8@M9`*^~4kDG+H$sfmqpWgn@yL4CS{Osg8^_5~LWWGIaI&$$?MbEQG z9G{H#A2b&A^ftEHzS6f>Yxh0v1R<__I@9de?GA8amX?S(?pyRJY~tjrb(4YwYJ2v- z?@&8-zx?KLGr_l$=bHG&NPe54Q@zMF#d6x3vqF1SE|yxdPl@2#sgoH~*(q7A;%B7t zOX|Prt`k8YPHeIAykzIXRF%)UZ<h3&lEMd~&9;ZC7PlM?%$j&IF75ITC!O%j>Sa9( zi<bV={Jq%XCbxg{i|6tlXU+fd!zz9b2Fp-mx6NM4O6)AHpjy5_>nIDP=C{<p#Kr<@ zX-wufGlw@dCi|ILf#oOnm>EJC2hB_%j2<(o$-?I15RRU?K7^5I?hIk9Ft-D@BqqNy z_dsh%*jt#hfE+Tp%0h}!XYy1FC9rEI@3xR)3euWfrzJgkhB=QssP(ZvX<p(yHU@^Z Xd<+Z{NUfSBjnb24Ew$O+n}P%ZuChJ} diff --git a/src/controllers/lss/d22special/CountWithSpectro.cpp b/src/controllers/lss/d22special/CountWithSpectro.cpp index 3c6e222d..aeb50e51 100644 --- a/src/controllers/lss/d22special/CountWithSpectro.cpp +++ b/src/controllers/lss/d22special/CountWithSpectro.cpp @@ -36,12 +36,14 @@ CountWithSpectro::CountWithSpectro(const std::string & name) : spectro.init(this, "spectro"); count.init(this, "count"); - spectroSwitcher.init(this, "spectroSwitcher"); + spectroSwitcher.init(this, "spectro_switcher"); integrationTime.init(this, SAVE, "integration_time"); //in microseconds! numSpectroMeasures.init(this, SAVE, "num_spectro"); + numTotalMeasures.init(this, SAVE, "num_total_measures"); timeType.init(this, SAVE, "time_type"); countTime.init(this, SAVE, "count_time"); + scansToAverage.init(this, SAVE, "scans_average"); xSize.init(this, SAVE, "x_size"); ySize.init(this, SAVE, "y_size"); @@ -55,6 +57,10 @@ CountWithSpectro::CountWithSpectro(const std::string & name) : measureDuration.init(this, NOSAVE, "measure_duration"); yDataArraySecondChannel.init(this, NOSAVE, "yDataArray_secondChannel"); + + //initialize pointers + m_yDataArray = NULL; + m_yDataArraySecondChannel = NULL; } CountWithSpectro::~CountWithSpectro() { @@ -62,23 +68,37 @@ CountWithSpectro::~CountWithSpectro() { } void CountWithSpectro::postConfiguration() { - xSize = XSIZE; + xSize = spectro->size(); ySize = numSpectroMeasures(); zSize = 1; subtitle = count->subtitle(); registerRefresher(numSpectroMeasures, &CountWithSpectro::refreshNumSpectroMeasures, this); + registerRefresher(useSwitcher, &CountWithSpectro::refreshUseSwitcher, this); registerUpdater(count->subtitle, &CountWithSpectro::updateSubtitle, this); registerProgression(count, &CountWithSpectro::updateProgression, this); - -// initSwitcherArrays(); //init both arrays to avoid errors } void CountWithSpectro::refreshNumSpectroMeasures(int32 number) { ySize = number; //This property is only used to save the data in nexus file //initialize here the dynamic properties - measureDuration.resize(number); + if (useSwitcher()) { + measureDuration.resize(number * 2); + numTotalMeasures = number * 2; + } else { + measureDuration.resize(number); + numTotalMeasures = number; + } +} + +void CountWithSpectro::refreshUseSwitcher(bool value) { + if (value) { + numTotalMeasures = numSpectroMeasures() * 2; //using switcher + } else { + numTotalMeasures = numSpectroMeasures(); + } + measureDuration.resize(numTotalMeasures()); } void CountWithSpectro::updateProgression() { @@ -91,75 +111,85 @@ void CountWithSpectro::updateSubtitle() { void CountWithSpectro::start() { - if (!useSwitcher()) { + //to avoid problems of synchronization, get the xSize any time we do a measure + xSize = spectro->size(); + spectro->scansToAverage = scansToAverage(); - //Time already in microseconds! - spectro->integrationTime = integrationTime(); + if (spectro->isConnected()) { + if (!useSwitcher()) { - //check the total time of spectro measurement is smaller than the count time - float64 spectroTime = integrationTime() * 0.000001 * numSpectroMeasures(); //should be in seconds - float64 countTime = getCountTimeInSec(); //count->time.setpoint(); + //Time already in microseconds! + spectro->integrationTime = integrationTime(); - if (spectroTime <= countTime) { + //check the total time of spectro measurement is smaller than the count time (comparison in seconds!) + float64 spectroTime = integrationTime() * 0.000001 * numSpectroMeasures() * scansToAverage(); + float64 countTime = getCountTimeInSec(); - setupCountParams(); + if (spectroTime <= countTime) { - initArrays(); //before initArray() + setupCountParams(); - commandStatus.setRunning(); - spectro->mode = QE65000Controller::COUNT_SINGLE; + initArrays(); //before initArray() - //Launch count and spectro at the same time - // Run the threads in parallel in a group - boost::thread_group group; + commandStatus.setRunning(); + spectro->mode = QE65000Controller::COUNT_SINGLE; - group.create_thread(boost::bind(&CountWithSpectro::startCount, this)); - group.create_thread(boost::bind(&CountWithSpectro::startSpectro, this)); + //Launch count and spectro at the same time + // Run the threads in parallel in a group + boost::thread_group group; - // Wait for the termination of the threads - group.join_all(); + group.create_thread(boost::bind(&CountWithSpectro::startCount, this)); + group.create_thread(boost::bind(&CountWithSpectro::startSpectro, this)); - //Get data - saveSpectroData(); + // Wait for the termination of the threads + group.join_all(); - commandStatus.setIdle(); - spectro->mode = QE65000Controller::IDLE; - } + //Get data + saveSpectroData(); - } else { - //Suppose here we also keep the same rule as before (but now is double) - spectroSwitcher->integrationTime = integrationTime(); - spectroSwitcher->numberOfCycles = 1; + commandStatus.setIdle(); + spectro->mode = QE65000Controller::IDLE; + } - //check the total time of spectro measurement is smaller than the count time - float64 spectroTime = integrationTime() * 0.000001 * numSpectroMeasures() * 2; //!!!!!!!!!!!!!! - float64 countTime = getCountTimeInSec(); + } else { + + //Suppose here we also keep the same rule as before (but now is double) + spectroSwitcher->numberOfCycles = 1; //even if it is not clear, the number of cycles will be established by this controller + spectroSwitcher->integrationTime = integrationTime(); - if (spectroTime <= countTime) { + //check the total time of spectro measurement is smaller than the count time + float64 spectroTime = integrationTime() * 0.000001 * numSpectroMeasures() * scansToAverage() * 2; //left and right measure + float64 countTime = getCountTimeInSec(); - setupCountParams(); + if (spectroTime <= countTime) { - initArrays(); + setupCountParams(); - commandStatus.setRunning(); - spectro->mode = QE65000Controller::COUNT_SWITCHER; + initArrays(); - //Launch count and spectro at the same time - // Run the threads in parallel in a group - boost::thread_group group; + commandStatus.setRunning(); + spectro->mode = QE65000Controller::COUNT_SWITCHER; - group.create_thread(boost::bind(&CountWithSpectro::startCount, this)); - group.create_thread(boost::bind(&CountWithSpectro::startSwitcher, this)); + //Launch count and spectro at the same time + // Run the threads in parallel in a group + boost::thread_group group; - // Wait for the termination of the threads - group.join_all(); + group.create_thread(boost::bind(&CountWithSpectro::startCount, this)); + group.create_thread(boost::bind(&CountWithSpectro::startSwitcher, this)); - //Get data - saveSwitcherSpectroData(); + // Wait for the termination of the threads + group.join_all(); - commandStatus.setIdle(); - spectro->mode = QE65000Controller::IDLE; + //Get data + saveSwitcherSpectroData(); + + commandStatus.setIdle(); + spectro->mode = QE65000Controller::IDLE; + } } + + //clean arrays + initArrays(); } } @@ -167,6 +197,7 @@ void CountWithSpectro::stop() { if (commandStatus.isRunning()) { count->stopParallel(); spectro->stopParallel(); + spectroSwitcher->stopParallel(); } commandStatus.setWarning(); @@ -182,6 +213,8 @@ void CountWithSpectro::startSpectro() { initialTime = startTime.toString("%H:%M:%S"); common::Date formerTime = startTime; + int32 sleepTime = calculateWaitingTimeInSec(); + for (int i = 0; i < numSpectroMeasures(); i++) { if (commandStatus.isRunning()) { @@ -191,32 +224,35 @@ void CountWithSpectro::startSpectro() { spectro->startCommand(); - int32 ySize = YSIZE; + int32 ySize = spectro->size(); float64* tempYData = spectro->yData(); for (int32 j = 0; j < ySize; j++) { m_yDataArray[ySize * i + j] = tempYData[j]; } formerTime = time; + sleep(sleepTime); } } } void CountWithSpectro::startSwitcher() { + common::Date startTime = common::Date(); initialTime = startTime.toString("%H:%M:%S"); - common::Date formerTime = startTime; + + int32 sleepTime = calculateWaitingTimeInSec(); + + common::Date initialTime = common::Date(); for (int i = 0; i < numSpectroMeasures(); i++) { if (commandStatus.isRunning()) { - common::Date time = common::Date(); - common::Duration duration = time - formerTime; - measureDuration.set(i, duration.getMilliseconds()); + spectroSwitcher->setInitialTime(initialTime); spectroSwitcher->startCommand(); - int32 ySize = YSIZE; + int32 ySize = spectro->size(); float64* tempLeftYData = spectroSwitcher->yLeftData(); for (int32 j = 0; j < ySize; j++) { m_yDataArray[ySize * i + j] = tempLeftYData[j]; @@ -227,7 +263,11 @@ void CountWithSpectro::startSwitcher() { m_yDataArraySecondChannel[ySize * i + j] = tempRightYData[j]; } - formerTime = time; + measureDuration.set((i * 2), spectroSwitcher->durationLeft()); + measureDuration.set((i * 2 + 1), spectroSwitcher->durationRight()); + + initialTime = common::Date(); + sleep(sleepTime); } } } @@ -245,7 +285,7 @@ void CountWithSpectro::initArrays() { delete[] m_yDataArraySecondChannel; } - int32 totalSize = YSIZE * numSpectroMeasures(); + int32 totalSize = spectro->size() * numSpectroMeasures(); m_yDataArray = new int32[totalSize]; memset(m_yDataArray, 0, totalSize * sizeof(int32)); //set to zero yDataArray.update(m_yDataArray); @@ -268,6 +308,7 @@ void CountWithSpectro::saveSpectroData() { } void CountWithSpectro::saveSwitcherSpectroData() { + int32 totalSize = YSIZE * numSpectroMeasures(); yDataArray.update(m_yDataArray); yDataArray.setSize(totalSize); @@ -277,7 +318,6 @@ void CountWithSpectro::saveSwitcherSpectroData() { int32 numor = any_cast<int32>(count->getValue("numor")); NexusDataFile::appendTo(numor, "NxD22SpecialServerFile.xml", "NxD22SpecialClientFile.xml"); - } float64 CountWithSpectro::getCountTimeInSec() { @@ -289,9 +329,33 @@ float64 CountWithSpectro::getCountTimeInSec() { } else if (timeType() == "s") { time = countTime(); } - return time; } +/** + * This method calculates the waiting time necessary to distribute the spectrometer measures (in both single or switcher mode) equally through the acquisition time + */ +float64 CountWithSpectro::calculateWaitingTimeInSec() { + //Convert all units into seconds + float64 totalSpectroTime; + float64 switcherSleep = (spectroSwitcher->SLEEP_TIME_MICROSEC) * 0.000001;//0.0001; + float64 singleWaitTime = 0.0; + + if (numSpectroMeasures() > 1) { + int32 scansToAverage = spectro->scansToAverage(); + + if (useSwitcher()) { + totalSpectroTime = 2 * (integrationTime() * 0.000001 * numSpectroMeasures() * scansToAverage + switcherSleep); + } else { + totalSpectroTime = integrationTime() * 0.000001 * numSpectroMeasures() * scansToAverage; + } + + float64 countTime = getCountTimeInSec(); + float64 totalWaitTime = (countTime - totalSpectroTime); + singleWaitTime = 0.95 * (totalWaitTime / (numSpectroMeasures() - 1)); //0.95 -> factor to avoid having spectro measures just at the end + } + return singleWaitTime; +} + } diff --git a/src/controllers/lss/d22special/CountWithSpectro.h b/src/controllers/lss/d22special/CountWithSpectro.h index 6d41d070..d7aef076 100644 --- a/src/controllers/lss/d22special/CountWithSpectro.h +++ b/src/controllers/lss/d22special/CountWithSpectro.h @@ -50,13 +50,17 @@ public: Property<int32> integrationTime; Property<int32> numSpectroMeasures; + Property<int32> scansToAverage; + Property<int32> numTotalMeasures; + Property<bool> useSwitcher; + Property<std::string> timeType; Property<float64> countTime; + Property<std::string> subtitle; + Property<int32> xSize; Property<int32> ySize; Property<int32> zSize; - Property<std::string> subtitle; - Property<bool> useSwitcher; ArrayProperty<int32> yDataArray; ArrayProperty<int32> yDataArraySecondChannel; @@ -65,8 +69,10 @@ public: Property<std::string> initialTime; void refreshNumSpectroMeasures(int32 number); + void refreshUseSwitcher(bool value); void updateProgression(); void updateSubtitle(); + void update(); private: void saveSpectroData(); @@ -77,6 +83,7 @@ private: void initArrays(); void setupCountParams(); float64 getCountTimeInSec(); + float64 calculateWaitingTimeInSec(); int32* m_yDataArray; int32* m_yDataArraySecondChannel; diff --git a/src/controllers/lss/d22special/D22SampleSequencer.cpp b/src/controllers/lss/d22special/D22SampleSequencer.cpp deleted file mode 100644 index d368087c..00000000 --- a/src/controllers/lss/d22special/D22SampleSequencer.cpp +++ /dev/null @@ -1,205 +0,0 @@ -/* - * Nomad Instrument Control Software - * - * Copyright 2011 Institut Laue-Langevin - * - * Licensed under the EUPL, Version 1.1 only (the "License"); - * You may not use this work except in compliance with the Licence. - * You may obtain a copy of the Licence at: - * - * http://joinup.ec.europa.eu/software/page/eupl - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the Licence is distributed on an "AS IS" basis, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the Licence for the specific language governing permissions and - * limitations under the Licence. - */ -#include <Controller.h> -#include "D22SampleSequencer.h" -#include "controllers/common/family/Families.h" -#include "PersistenceServices/DataFile/NexusDataFile.h" - -namespace d22special { - -const string D22SampleSequencer::TYPE = "d22_sample_sequencer"; - -D22SampleSequencer::D22SampleSequencer(const std::string& name) : - ::SampleSequencer(name, "") { - registerFunction(TYPE); - - setFamily(family::SAMPLE_ENVIRONMENT); - - //init properties - integrationTime.init(this, SAVE, "integration_time"); - scansToAverage.init(this, SAVE, "scan_average"); - useSpectro.init(this, SAVE, "useSpectro"); - spectroController.init(this, "spectro"); - - m_started = false; -} - -D22SampleSequencer::~D22SampleSequencer() { -} - -void D22SampleSequencer::postConfiguration() { - SampleSequencer::postConfiguration(); -} - -void D22SampleSequencer::execute(const string& command, bool blocking, bool logging) { - spectroController->mode = QE65000Controller::SEQUENCE; - - if (command == START_COMMAND) { - m_started = true; - } else if (command == STOP_COMMAND) { - m_started = false; - } - - SampleSequencer::execute(command, blocking, logging); - //Once the last count is done force to do another spectro measure - if (command == START_COMMAND) { - doLastMeasure(); - m_started = false; - } -// spectroController->mode = QE65000Controller::ALONE; -} - -void D22SampleSequencer::updateProperty(ChangeAspect* aChangeAspect) { - - SampleSequencer::updateProgress(aChangeAspect); - string propertyName = aChangeAspect->getStringParam(); - - if (propertyName == "actual_cha") { - int32 actualSlot = any_cast<int32>(m_sampleChanger->getValue(propertyName)); - spectroController->setPlotName(actualSlot); - actualSlotNumber = actualSlot; - - } else if (propertyName == "status_message") { - std::string countStatus = any_cast<std::string>(m_Count->getValue(propertyName)); - - if (countStatus == "Idle" && m_started == true) { // only save spectro if count has been started from this controller - getSpectro(); - } - - } else if (propertyName == "numor") { - lastNumor = any_cast<int32>(m_Count->getValue(propertyName)); - - } -} - -void D22SampleSequencer::refreshSetValue(string propertyName, const boost::any aValue) throw (CannotSetValue) { - SampleSequencer::refreshSetValue(propertyName, aValue); - -} - -void D22SampleSequencer::getSpectro() { - spectroController->start(); - - //Copy data in nexus file (remember it is delayed in one position) - if (actualSlotNumber > 1) { - int32 numor = any_cast<int32>(m_Count->getValue("numor")); - NexusDataFile::appendTo(numor - 1, "NxD22SpecialServerFile.xml", "NxD22SpecialClientFile.xml"); - } -} - -void D22SampleSequencer::doLastMeasure() { - - //Last measure = move sample (using sampleChanger) + get spectro + save data in nexus file - Sender<ClientCommand>::begin(); - Sender<ClientCommand>::post(ClientCommand(m_sampleChanger, START_COMMAND)); - Sender<ClientCommand>::endIf(); - - spectroController->start(); - - int32 numor = any_cast<int32>(m_Count->getValue("numor")); - - NexusDataFile::appendTo(numor, "NxD22SpecialServerFile.xml", "NxD22SpecialClientFile.xml"); - -// cout << "adding new data (theoretically) in data file: " << numor << " value of last numor: " << lastNumor << endl; -} - -} - -/* - void D22SampleSequencer::postConfiguration() { - SampleSequencer::postConfiguration(); - //Set up measuring mode in spectro controller - // spectroController->mode = QE65000Controller::SEQUENCE; - - registerUpdater(sampleChanger->slot, &D22SampleSequencer::updateActualSlot, this); - registerUpdater(count->statusMessage, &D22SampleSequencer::updateStatusMessage, this); - registerUpdater(count->numor, &D22SampleSequencer::updateNumor, this); - registerUpdater(spectroController->integrationTime, &D22SampleSequencer::updateIntegrationTime, this); - registerUpdater(spectroController->scansToAverage, &D22SampleSequencer::updateScansToAverage, this); - - } - - void D22SampleSequencer::updateActualSlot() { - spectroController->setPlotName(sampleChanger->slot()); - actualSlotNumber = sampleChanger->slot(); - } - - void D22SampleSequencer::updateStatusMessage() { - std::string countStatus = count->statusMessage(); - if (countStatus == "Idle") { - getSpectro(); - } - } - - void D22SampleSequencer::updateNumor() { - lastNumor = count->numor(); - } - - void D22SampleSequencer::updateIntegrationTime() { - integrationTime = spectroController->integrationTime(); - } - - void D22SampleSequencer::updateScansToAverage() { - scansToAverage = spectroController->scansToAverage(); - } - - void D22SampleSequencer::start() { - commandStatus.setRunning(); - spectroController->mode = QE65000Controller::SEQUENCE; - d22::SampleSequencer::start(); - //Once the last count is done force to do another spectro measure - doLastMeasure(); - commandStatus.setIdle(); - spectroController->mode = QE65000Controller::ALONE; - } - - void D22SampleSequencer::stop() { - commandStatus.setWarning(); - d22::SampleSequencer::stop(); - } - - void D22SampleSequencer::getSpectro() { - //Check the sampleSequencer is running - if (commandStatus.isRunning()) { - spectroController->start(); - //Copy data in nexus file (remember it is delayed in one position) - if (actualSlotNumber > 1 && commandStatus.isRunning()) { - int32 numor = any_cast<int32>(count->getValue("numor")); - cout << "appending data to nexus file! (1)" << numor - 1 << endl; - NexusDataFile::appendTo(numor - 1, "NxD22SpecialServerFile.xml", "NxD22SpecialClientFile.xml"); - } - } - } - - void D22SampleSequencer::doLastMeasure() { - if (commandStatus.isRunning()) { - //Last measure = move sample (using sampleChanger) + get spectro + save data in nexus file - sampleChanger->start(); - spectroController->start(); - - int32 numor = any_cast<int32>(count->getValue("numor")); - cout << "appending data to nexus file! (2) " << numor << endl; - NexusDataFile::appendTo(numor, "NxD22SpecialServerFile.xml", "NxD22SpecialClientFile.xml"); - // cout << "adding new data (theoretically) in data file: " << numor << " value of last numor: " << lastNumor << endl; - } - - } - - -}*/ - diff --git a/src/controllers/lss/d22special/D22SampleSequencer.h b/src/controllers/lss/d22special/D22SampleSequencer.h deleted file mode 100644 index 2949d86f..00000000 --- a/src/controllers/lss/d22special/D22SampleSequencer.h +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Nomad Instrument Control Software - * - * Copyright 2011 Institut Laue-Langevin - * - * Licensed under the EUPL, Version 1.1 only (the "License"); - * You may not use this work except in compliance with the Licence. - * You may obtain a copy of the Licence at: - * - * http://joinup.ec.europa.eu/software/page/eupl - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the Licence is distributed on an "AS IS" basis, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the Licence for the specific language governing permissions and - * limitations under the Licence. - */ - -#ifndef IN16BSAMPLESEQUENCER_H_ -#define IN16BSAMPLESEQUENCER_H_ - - -#include "InstrumentAbstraction/Lss/SampleSequencer.h" -#include "controllers/spectrometer/QE65000Controller.h" - -using namespace spectrometer; -//using namespace d22; - -namespace d22special { - -class D22SampleSequencer : public ::SampleSequencer { - -public: - - static const std::string TYPE; - - D22SampleSequencer(const std::string & name); - - virtual ~D22SampleSequencer(); - - DynamicProperty<int32> useSpectro; - Property<int32> integrationTime; - Property<int32> scansToAverage; - - ControllerPtr<QE65000Controller> spectroController; - - virtual void postConfiguration(); - - virtual void execute(const string& command, bool blocking, bool logging = false); - - virtual void updateProperty(ChangeAspect* aChangeAspect); - - virtual void refreshSetValue(string propertyName, const boost::any aValue) throw (CannotSetValue); - - - //new things here! - -// virtual void start(); -// virtual void stop(); - -// virtual void updateActualSlot(); -// virtual void updateStatusMessage(); -// virtual void updateNumor(); -// virtual void updateIntegrationTime(); -// virtual void updateScansToAverage(); - -private: - - void getSpectro(); - void doLastMeasure(); - - int32 actualSlotNumber; - int32 lastNumor; - - bool m_started; -}; - -} - -#endif diff --git a/src/controllers/lss/d22special/D22SpectroSampleSequencer.cpp b/src/controllers/lss/d22special/D22SpectroSampleSequencer.cpp new file mode 100644 index 00000000..89c0bc75 --- /dev/null +++ b/src/controllers/lss/d22special/D22SpectroSampleSequencer.cpp @@ -0,0 +1,309 @@ +/* + * Nomad Instrument Control Software + * + * Copyright 2011 Institut Laue-Langevin + * + * Licensed under the EUPL, Version 1.1 only (the "License"); + * You may not use this work except in compliance with the Licence. + * You may obtain a copy of the Licence at: + * + * http://joinup.ec.europa.eu/software/page/eupl + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the Licence is distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Licence for the specific language governing permissions and + * limitations under the Licence. + */ + +#include "D22SpectroSampleSequencer.h" +#include "InstrumentAbstraction/Lss/SampleChangerController.h" +#include "InstrumentAbstraction/Base/DataParams.h" +#include "controllers/common/family/Families.h" + +#include "LoggingServices/Level.h" +#include "LoggingServices/Trace.h" + +namespace d22special { + +const std::string D22SpectroSampleSequencer::TYPE = "d22spectroSampleSequencer"; +const int32 D22SpectroSampleSequencer::MAX_POSITIONS = 25; + +const char D22SpectroSampleSequencer::DATAPARAM_THICKNESS_PROPERTY[] = "dataparam_thickness"; +const char D22SpectroSampleSequencer::DATAPARAM_TRANSMISSION_PROPERTY[] = "dataparam_transmission"; + +D22SpectroSampleSequencer::D22SpectroSampleSequencer(const std::string & name) : + ExperimentController(name), controller::Stoppable(this), m_dataParams(0) { + + setFamily(family::SAMPLE_ENVIRONMENT); + + registerConfiguration("SampleChanger", SAMPLE_CHANGER_EXPERIMENT_CONTROLLER, (AbstractController**) &m_sampleChanger); + registerConfiguration("DataParams", DATA_PARAMS_EXPERIMENT_CONTROLLER, (AbstractController**) &m_dataParams); + countWithSpectro.init(this, "count_spectro"); + + maxPos.init(this, SAVE, "max_pos"); + + maxSlot.init(this, SAVE, "max_slot"); + numSlot.init(this, SAVE, "actual_numSlot", "wanted_numSlot"); + + changerNum.init(this, SAVE, "changer_num"); + changer.init(this, NOSAVE, "actual_changer", "wanted_changer"); + changerValues.init(this, NOSAVE, "changer_values"); + changerLabels.init(this, NOSAVE, "changer_labels"); + + samplePosition.init(this, NOSAVE, "sample_position"); + acquisitionTime.init(this, NOSAVE, "acquisition_time"); + transmission.init(this, NOSAVE, "transmission"); + thickness.init(this, NOSAVE, "thickness"); + acquisitionTitle.init(this, NOSAVE, "acquisition_title"); + + dataparamsThickness.init(this, SAVE, "dataparam_thickness"); + dataparamsTransmission.init(this, SAVE, "dataparam_transmission"); + + timeType.init(this, SAVE, "time_type"); + integrationTime.init(this, SAVE, "integration_time"); //in microseconds! + numSpectroMeasures.init(this, SAVE, "num_spectro"); + scansToAverage.init(this, SAVE, "scans_average"); + + totalTime.init(this, SAVE, "total_time"); + + //default initialization + m_ChangerStarted = false; + + maxPos = MAX_POSITIONS; + + samplePosition.resize(MAX_POSITIONS); + acquisitionTime.resize(MAX_POSITIONS); + transmission.resize(MAX_POSITIONS); + thickness.resize(MAX_POSITIONS); + acquisitionTitle.resize(MAX_POSITIONS); + + for (int i = 0; i < MAX_POSITIONS; i++) { + //fill new properties with default values + int32 index = i + 1; + ostringstream title; + title << "Sample " << index; + + samplePosition.set(i, index); + acquisitionTime.set(i, 10.0); + transmission.set(i, 1.0); + thickness.set(i, 0.1); + acquisitionTitle.set(i, title.str()); + } + +} + +D22SpectroSampleSequencer::~D22SpectroSampleSequencer() { + +} + + +D22SpectroSampleSequencer::D22SpectroSampleSequencer(const D22SpectroSampleSequencer& controller) : + ExperimentController(controller), + controller::Stoppable(this) { + + maxPos.copy(this, controller.maxPos); + + maxSlot.copy(this, controller.maxSlot); + numSlot.copy(this, controller.numSlot); + numSlot.setpoint.copy(this, controller.numSlot.setpoint); + + changerNum.copy(this, controller.changerNum); + changer.copy(this, controller.changer); + changer.setpoint.copy(this, controller.changer.setpoint); + changerValues.copy(this, controller.changerValues); + changerLabels.copy(this, controller.changerLabels); + + dataparamsThickness.copy(this, controller.dataparamsThickness); + dataparamsTransmission.copy(this, controller.dataparamsTransmission); + + samplePosition.copy(this, controller.samplePosition); + acquisitionTime.copy(this, controller.acquisitionTime); + transmission.copy(this, controller.transmission); + thickness.copy(this, controller.thickness); + acquisitionTitle.copy(this, controller.acquisitionTitle); + + timeType.copy(this, controller.timeType); + integrationTime.copy(this, controller.integrationTime); //in microseconds! + numSpectroMeasures.copy(this, controller.numSpectroMeasures); + scansToAverage.copy(this, controller.scansToAverage); + + totalTime.copy(this, controller.totalTime); + + countWithSpectro.copy(controller.countWithSpectro); + + m_sampleChanger = controller.m_sampleChanger; + m_dataParams = controller.m_dataParams; + +} + +void D22SpectroSampleSequencer::postConfiguration() { + + Publisher::attach(this); + + //Init values from sampleChanger + int32 size = 8; //we use old sampleChanger controller whose size is fixed to 8 + for (int i = 0; i < size; i++) { + changerNum.set(size); + changerValues.resize(size); + changerLabels.resize(size); + for (int i = 0; i < size; i++) { + //the same thing... very careful with this, we fill the combo with "static" values from sampleChanger (that is, values defined in its .properties file!) + int32 index = i + 1; + ostringstream title; + title << "Changer# " << index; + int32 value = index; + std::string label = title.str(); //Changer#i + changerValues.set(i, value); + changerLabels.set(i, label); + } + changer.setpoint.setEnumeratedValues(changerValues); + changer.setpoint.setEnumeratedLabels(changerLabels); + } + //Another default values + maxSlot = any_cast<int32>(m_sampleChanger->getValue(SampleChangerController::MAX_CHA_PROPERTY)); + changer.setpoint = 1; + totalTime = 10; + + registerRefresher(scansToAverage, &ExperimentController::copyValue<int32>, this, countWithSpectro->scansToAverage); + registerRefresher(numSpectroMeasures, &ExperimentController::copyValue<int32>, this, countWithSpectro->numSpectroMeasures); + registerRefresher(integrationTime, &ExperimentController::copyValue<int32>, this, countWithSpectro->integrationTime); + registerRefresher(changer.setpoint, &D22SpectroSampleSequencer::refreshChangerSetpoint, this); + registerRefresher(numSlot.setpoint, &D22SpectroSampleSequencer::refreshNumSlotSetpoint, this); + + registerRefresher(acquisitionTime, &D22SpectroSampleSequencer::refreshAcquisitionTime, this); + +} + +void D22SpectroSampleSequencer::refreshChangerSetpoint(int32 number) { + m_sampleChanger->setValue(SampleChangerController::CHANGER_NUMBER_PROPERTY, number); + maxSlot = any_cast<int32>(m_sampleChanger->getValue(SampleChangerController::MAX_CHA_PROPERTY)); +} + +void D22SpectroSampleSequencer::refreshNumSlotSetpoint(int32 number) { + totalTime = 0; + for (int32 i = 0; i < number; ++i) { + totalTime = totalTime() + acquisitionTime.get(i); + } +} + +void D22SpectroSampleSequencer::refreshAcquisitionTime(int32 index, float64 value) throw (CannotSetValue) { + //Calculate total time + totalTime = 0; + for (int32 i = 0; i < numSlot.setpoint(); ++i) { + if (i == index) { + totalTime = totalTime() + value; //done like this, otherwise when doing a set of the property the server crashes... + + } else { + totalTime = totalTime() + acquisitionTime.get(i); + } + } +} + +void D22SpectroSampleSequencer::start() { + + bool countSpectroControllerOk = true; + + int32 apply_nbSlot = numSlot.setpoint(); + float64 apply_acquisitionTime[apply_nbSlot]; + int32 apply_samplePosition[apply_nbSlot]; + float64 apply_Transmission[apply_nbSlot]; + float64 apply_Thickness[apply_nbSlot]; + string apply_acquisitionTitle[apply_nbSlot]; + + for (int32 i = 0; i < apply_nbSlot; i++) { + apply_samplePosition[i] = samplePosition.get(i); + apply_acquisitionTime[i] = acquisitionTime.get(i); + apply_Transmission[i] = transmission.get(i); + apply_Thickness[i] = thickness.get(i); + apply_acquisitionTitle[i] = acquisitionTitle.get(i); + } + + commandProgression = 0; + commandStatus.setRunning(); + + for (int32 i = 0; i < apply_nbSlot; ++i) { + try { + if (apply_acquisitionTime[i] != 0.0) { + + commandProgression = ((float64) i / (float64) numSlot.setpoint()) * 100; + + //(1) Set up values of controllers + m_sampleChanger->setValue(SampleChangerController::WANTED_CHA_PROPERTY, apply_samplePosition[i]); + + try { + //We will always work with the count controller in TIME MODE + countWithSpectro->countTime = apply_acquisitionTime[i]; //units? + countWithSpectro->subtitle = apply_acquisitionTitle[i]; + countWithSpectro->timeType = timeType(); + + // Set total repetition to 1 by default (TODO) +// m_Count->setValue(Count::TOTAL_REPS_PROPERTY, (int32 ) 1); + // + } catch (CannotSetValue) { + log(Level::s_Error) << name << emptycursor << "Cannot set value for acquisition controller" << endlog; + countSpectroControllerOk = false; + } + + try { + // Set values for transmission and thickness +// m_dataParams->setValue(any_cast<string>(m_dataParams->getValue(DATAPARAM_TRANSMISSION_PROPERTY)), apply_Transmission[i]); //TODO check it is correct +// m_dataParams->setValue("Thickness", apply_Thickness[i]); //TODO check it is correct + } catch (...) { + cerr << "error in setting dataParams properties" << endl; + } + + // (2) Move sampleChanger + m_ChangerStarted = true; + Sender<ClientCommand>::begin(); + Sender<ClientCommand>::post(ClientCommand(m_sampleChanger, START_COMMAND)); + Sender<ClientCommand>::endIf(); + m_ChangerStarted = false; + + if (commandStatus.isWarning()) { + //the state warning means the controller has been stopped during its execution + break; + } + + commandProgression = commandProgression() + (100 / numSlot.setpoint() * 0.5); + + // (3) Move CountWithSpectro + if (countSpectroControllerOk) { + m_CountStarted = true; + countWithSpectro->useSwitcher = false; //always in NO switcher mode + countWithSpectro->startCommand(); + m_CountStarted = false; + } else { + log(Level::s_Error) << name << emptycursor << "Cannot start acquisition controller" << endlog; + } + //TODO: log here + + if (commandStatus.isWarning()) { + break; + } + } + } catch (CannotSetValue &e) { + cerr << "Cannot set value" << endl; + } + } + + commandStatus.setIdle(); +} + +void D22SpectroSampleSequencer::stop() { + if (commandStatus.isRunning()) { + if (m_CountStarted) { + countWithSpectro->stopCommand(); + m_CountStarted = false; + } else if (m_ChangerStarted) { + Sender<ClientCommand>::post(ClientCommand(m_sampleChanger, STOP_COMMAND)); + m_ChangerStarted = false; + } + } +// log((logging ? Level::s_Info : Level::s_Debug)) << name << emptycursor << "stopped" << endlog; + commandStatus.setWarning(); + +} + +} + diff --git a/src/controllers/lss/d22special/D22SpectroSampleSequencer.h b/src/controllers/lss/d22special/D22SpectroSampleSequencer.h new file mode 100644 index 00000000..ccfdeff9 --- /dev/null +++ b/src/controllers/lss/d22special/D22SpectroSampleSequencer.h @@ -0,0 +1,89 @@ +/* + * Nomad Instrument Control Software + * + * Copyright 2011 Institut Laue-Langevin + * + * Licensed under the EUPL, Version 1.1 only (the "License"); + * You may not use this work except in compliance with the Licence. + * You may obtain a copy of the Licence at: + * + * http://joinup.ec.europa.eu/software/page/eupl + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the Licence is distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Licence for the specific language governing permissions and + * limitations under the Licence. + */ + +#ifndef D22SPECTROSAMPLESEQUENCER_H_ +#define D22SPECTROSAMPLESEQUENCER_H_ + +#include <Controller.h> +#include "CountWithSpectro.h" + +namespace d22special { + +class D22SpectroSampleSequencer: public ExperimentController, public controller::Stoppable { + +public: + + static const std::string TYPE; + static const int32 MAX_POSITIONS; + + static const char DATAPARAM_TRANSMISSION_PROPERTY[]; + static const char DATAPARAM_THICKNESS_PROPERTY[]; + + D22SpectroSampleSequencer(const std::string & name); + D22SpectroSampleSequencer(const D22SpectroSampleSequencer& controller); + virtual ~D22SpectroSampleSequencer(); + void postConfiguration(); + + void start(); // virtual? + void stop(); + +private: + + void refreshChangerSetpoint(int32 number); + void refreshAcquisitionTime(int32 index, float64 value) throw (CannotSetValue); + void refreshNumSlotSetpoint(int32 number); + + AbstractController* m_sampleChanger; + AbstractController* m_dataParams; + ControllerPtr<CountWithSpectro> countWithSpectro; + + Property<int32> maxPos; + Property<int32> maxSlot; + Property<int32, SETPOINT> numSlot; + + Property<int32> changerNum; + Property<int32, SETPOINT> changer; + DynamicProperty<int32> changerValues; + DynamicProperty<std::string> changerLabels; + + DynamicProperty<int32> samplePosition; + DynamicProperty<float64> acquisitionTime; + DynamicProperty<float64> transmission; + DynamicProperty<float64> thickness; + DynamicProperty<std::string> acquisitionTitle; + + Property<std::string> dataparamsThickness; + Property<std::string> dataparamsTransmission; + + //specific countWithSpectro properties + Property<std::string> timeType; + Property<int32> integrationTime; + Property<int32> numSpectroMeasures; + Property<int32> scansToAverage; + + //Info properties + Property<float64> totalTime; + + bool m_ChangerStarted; + bool m_CountStarted; + +}; + +} + +#endif /* D22SPECTROSAMPLESEQUENCER_H_ */ diff --git a/src/controllers/lss/d22special/DualSwitchSpectroController.cpp b/src/controllers/lss/d22special/DualSwitchSpectroController.cpp index ad6e737f..13093992 100644 --- a/src/controllers/lss/d22special/DualSwitchSpectroController.cpp +++ b/src/controllers/lss/d22special/DualSwitchSpectroController.cpp @@ -25,6 +25,7 @@ namespace d22special { const std::string DualSwitchSpectroController::TYPE = "dualSwitchSpectro"; +const int32 DualSwitchSpectroController::SLEEP_TIME_MICROSEC = 100; //0.0001 sec DualSwitchSpectroController::DualSwitchSpectroController(const std::string& name) : ExperimentController(name), controller::Stoppable(this) { @@ -41,7 +42,13 @@ DualSwitchSpectroController::DualSwitchSpectroController(const std::string& name yLeftData.init(this, SAVE, "y_leftData"); yRightData.init(this, SAVE, "y_rightData"); + durationLeft.init(this, NOSAVE, "duration_left"); + durationRight.init(this, NOSAVE, "duration_right"); + m_StopActivated = false; + m_yRightData = 0; + m_yLeftData = 0; + m_InitialTime = 0; //It has attached one module (QE65000 controller) and one controller (switcher) spectroController.init(this, "spectro"); @@ -59,49 +66,71 @@ void DualSwitchSpectroController::postConfiguration() { void DualSwitchSpectroController::start() { + //init necessary stuff + initArrays(); + m_StopActivated = false; commandProgression = 0; -//spectroController->mode = QE65000Controller::SWITCH; //Before measuring spectrum check if the spectrometer is plugged in -// if (spectroController->isConnected()) { - executionStatus.update("idle"); - - //Set up values of spectro - spectroController->integrationTime = integrationTime(); - - int32 cyclesNumber = numberOfCycles(); - while (cyclesNumber > 0 && !m_StopActivated) { - - commandProgression = (numberOfCycles() - cyclesNumber) * 100 / numberOfCycles(); - - // First: start switcher -> we begin for OPEN position (== IN) - executionStatus.update("Measuring Left"); - switcherController->setOpen(); - switcherController->startCommand(); - - //Second: start spectro - spectroController->start(); - updateData(); - - //Again same process: start switcher (now to CLOSE == OUT) and then spectro - executionStatus.update("Measuring Right"); - switcherController->setClose(); - switcherController->startCommand(); - - spectroController->start(); - updateData(); - - cyclesNumber = cyclesNumber - 1; + if (spectroController->isConnected()) { + executionStatus.update("idle"); + + //Set up values of spectro + spectroController->integrationTime = integrationTime(); + + // To get the requires timestamps + common::Duration duration; + + int32 cyclesNumber = numberOfCycles(); + while (cyclesNumber > 0 && !m_StopActivated) { + + commandProgression = (numberOfCycles() - cyclesNumber) * 100 / numberOfCycles(); +// common::Date initialTime = common::Date(); + + common::Date initialTime = m_InitialTime; + + if (!m_StopActivated) { + // First: start switcher -> we begin for OPEN position (== IN) + cout << "starting left" << endl; + executionStatus.update("Measuring Left"); + switcherController->setOpen(); + switcherController->startCommand(); + usleep(SLEEP_TIME_MICROSEC); // introduce a small sleep to make sure the switcher is in the correct channel + + //Second: start spectro + spectroController->start(); + updateData(); + } + common::Date leftTime = common::Date(); + duration = leftTime - initialTime; + durationLeft = duration.getMilliseconds(); + + if (!m_StopActivated) { + //Again same process: start switcher (now to CLOSE == OUT) and then spectro + cout << "starting right" << endl; + executionStatus.update("Measuring Right"); + switcherController->setClose(); + switcherController->startCommand(); + usleep(SLEEP_TIME_MICROSEC); // introduce a small sleep to make sure the switcher is in the correct channel + + spectroController->start(); + updateData(); + } + common::Date rightTime = common::Date(); + duration = rightTime - leftTime; + durationRight = duration.getMilliseconds(); + + cyclesNumber = cyclesNumber - 1; + + } + commandProgression = 100; + executionStatus.update("finished"); + } else { + cout << "spectro disconnected" << endl; + executionStatus.update("disconnected"); } - commandProgression = 99; - executionStatus.update("finished"); - -// } else { -// cout << "spectro disconnected" << endl; -// executionStatus.update("disconnected"); -// } } void DualSwitchSpectroController::stop() { @@ -115,32 +144,62 @@ void DualSwitchSpectroController::updateProgression() { } void DualSwitchSpectroController::updateData() { - //should be done with an updater... + + int32 size = spectroController->size(); + if (executionStatus() == "Measuring Right") { - int32 xSize = spectroController->xData.getSize(); xData.update(spectroController->xData()); - xData.setSize(xSize); + xData.setSize(size); xData.sendEvent(); - int32 yRightSize = spectroController->yData.getSize(); - yRightData.update(spectroController->yData()); - yRightData.setSize(yRightSize); + float64* tempYData = spectroController->yData(); + for (int32 i = 0; i < size; i++) { + m_yRightData[i] = tempYData[i]; + } + yRightData.update(m_yRightData); + yRightData.setSize(size); yRightData.sendEvent(); } else { //testing two x arrays of data - int32 xSize = spectroController->xData.getSize(); xLeftData.update(spectroController->xData()); - xLeftData.setSize(xSize); + xLeftData.setSize(size); xLeftData.sendEvent(); - int32 yLeftSize = spectroController->yData.getSize(); - yLeftData.update(spectroController->yData()); - yLeftData.setSize(yLeftSize); + float64* tempYData = spectroController->yData(); + for (int32 i = 0; i < size; i++) { + m_yLeftData[i] = tempYData[i]; + } + yLeftData.update(m_yLeftData); + yLeftData.setSize(size); yLeftData.sendEvent(); } } +void DualSwitchSpectroController::initArrays() { + if (m_yRightData) { + delete[] m_yRightData; + } else if (m_yLeftData) { + delete[] m_yLeftData; + } + +// int32 totalSize = 1044; +// cout << "init arrays: " << spectroController->size() << endl; + + int32 size = spectroController->size(); + + m_yRightData = new float64[size]; + memset(m_yRightData, 0, size * sizeof(float64)); //set to zero + + m_yLeftData = new float64[size]; + memset(m_yLeftData, 0, size * sizeof(float64)); //set to zero + +} + +void DualSwitchSpectroController::setInitialTime(common::Date initialTime) { + m_InitialTime = initialTime; +} + } diff --git a/src/controllers/lss/d22special/DualSwitchSpectroController.h b/src/controllers/lss/d22special/DualSwitchSpectroController.h index 685fc30f..0ea58d82 100644 --- a/src/controllers/lss/d22special/DualSwitchSpectroController.h +++ b/src/controllers/lss/d22special/DualSwitchSpectroController.h @@ -21,6 +21,8 @@ #include "controllers/spectrometer/QE65000Controller.h" #include "controllers/common/state/stateio/ShutterController.h" +#include <boost/date_time/posix_time/posix_time.hpp> +#include <common/base/Date.h> using namespace spectrometer; @@ -31,6 +33,8 @@ class DualSwitchSpectroController : public ExperimentController, public controll public: static const std::string TYPE; + static const int32 SLEEP_TIME_MICROSEC; + Property<int32> integrationTime; Property<int32> numberOfCycles; Property<std::string> executionStatus; @@ -40,6 +44,9 @@ public: ArrayProperty<float64> yLeftData; ArrayProperty<float64> yRightData; + Property<int32> durationLeft; + Property<int32> durationRight; + bool m_StopActivated; DualSwitchSpectroController(const std::string& name); @@ -54,6 +61,12 @@ public: void postConfiguration(); void updateProgression(); void updateData(); + void initArrays(); + void setInitialTime(common::Date initialTime); +private: + float64* m_yRightData; + float64* m_yLeftData; + common::Date m_InitialTime; }; diff --git a/src/controllers/lss/d22special/Module.xml b/src/controllers/lss/d22special/Module.xml index 2814f5d8..7f45c002 100644 --- a/src/controllers/lss/d22special/Module.xml +++ b/src/controllers/lss/d22special/Module.xml @@ -1,6 +1,6 @@ <module name="d22special"> <include path="$(NOMAD_HOME)/../NomadModules/src"/> - <controller class="d22special::D22SampleSequencer"/> <controller class="d22special::CountWithSpectro"/> <controller class="d22special::DualSwitchSpectroController"/> + <controller class="d22special::D22SpectroSampleSequencer"/> </module> \ No newline at end of file diff --git a/src/controllers/lss/d22special/gui/count_with_spectro/count_with_spectro.properties b/src/controllers/lss/d22special/gui/count_with_spectro/count_with_spectro.properties index 50b9508e..48fff0b0 100644 --- a/src/controllers/lss/d22special/gui/count_with_spectro/count_with_spectro.properties +++ b/src/controllers/lss/d22special/gui/count_with_spectro/count_with_spectro.properties @@ -1,6 +1,9 @@ count_with_spectro.integration_timePrefix=Integration time +count_with_spectro.integration_timeShortPrefix=Int. time count_with_spectro.integration_timeSuffix=~mus -count_with_spectro.numSpectro=Num. Spectros +count_with_spectro.numSpectro=Num. Measures +count_with_spectro.scansAverage=Num. spectros average per measure +count_with_spectro.scansAverageShort=Num. Average count_with_spectro.countTime=Time count_with_spectro.subtitlePrefix=Subtitle diff --git a/src/controllers/lss/d22special/gui/count_with_spectro/count_with_spectroCommandView.xml b/src/controllers/lss/d22special/gui/count_with_spectro/count_with_spectroCommandView.xml index 9210cc33..0c02db0e 100644 --- a/src/controllers/lss/d22special/gui/count_with_spectro/count_with_spectroCommandView.xml +++ b/src/controllers/lss/d22special/gui/count_with_spectro/count_with_spectroCommandView.xml @@ -1,7 +1,12 @@ <plugin> <controller type="count_with_spectro" role="count_with_spectro1" /> + <number_of_lines nb_lines="2"/> + <text role="count_with_spectro1" property="subtitle" prefix="count_with_spectro.subtitlePrefix"/> + <check role="count_with_spectro1" property="use_switcher" prefix="count_with_spectro.useSwitcherPrefix" checkBoxValues="count_with_spectro.useSwitcher" key="useSwitcherCheck"/> + <newLine/> <text role="count_with_spectro1" property="count_time" prefix="count_with_spectro.countTime" key="countTimeText"/> - <radio role="count_with_spectro1" property="time_type" valuesAndLabels="count_with_spectro.h,count_with_spectro.m,count_with_spectro.s" spaceBefore="false" /> - <text role="count_with_spectro1" property="integration_time" prefix="count_with_spectro.integration_timePrefix" suffix="count_with_spectro.integration_timeSuffix" key="spectroTimeText"/> + <radio role="count_with_spectro1" property="time_type" valuesAndLabels="count_with_spectro.h,count_with_spectro.m,count_with_spectro.s" spaceBefore="false" key="timeTypeRadio"/> + <text role="count_with_spectro1" property="integration_time" prefix="count_with_spectro.integration_timeShortPrefix" suffix="count_with_spectro.integration_timeSuffix" key="spectroTimeText"/> <text role="count_with_spectro1" property="num_spectro" prefix="count_with_spectro.numSpectro" key="numSpectroMeasuresText"/> + <text role="count_with_spectro1" property="scans_average" prefix="count_with_spectro.scansAverageShort" key="numSpectroToAverageText"/> </plugin> \ No newline at end of file diff --git a/src/controllers/lss/d22special/gui/count_with_spectro/count_with_spectroProperties.xml b/src/controllers/lss/d22special/gui/count_with_spectro/count_with_spectroProperties.xml index b07e631b..abbde247 100644 --- a/src/controllers/lss/d22special/gui/count_with_spectro/count_with_spectroProperties.xml +++ b/src/controllers/lss/d22special/gui/count_with_spectro/count_with_spectroProperties.xml @@ -1,4 +1,10 @@ <controller type="count_with_spectro"> - <property name="num_spectro" type="int32" max_length="3"/> - <property name="subtitle" type="string"/> + <property name="num_spectro" type="int32" max_length="3"> + <strictly_positive /> + </property> + <property name="scans_average" type="int32" max_length="3"> + <strictly_positive /> + </property> + <property name="subtitle" type="string" max_length="40" /> + <property name="count_time" type="float64" max_length="8" /> </controller> \ No newline at end of file diff --git a/src/controllers/lss/d22special/gui/count_with_spectro/count_with_spectroView.xml b/src/controllers/lss/d22special/gui/count_with_spectro/count_with_spectroView.xml index 01a92363..55c5ead5 100644 --- a/src/controllers/lss/d22special/gui/count_with_spectro/count_with_spectroView.xml +++ b/src/controllers/lss/d22special/gui/count_with_spectro/count_with_spectroView.xml @@ -5,10 +5,11 @@ <newLine /> <group title="count_with_spectro.countGroup"> <text role="count_with_spectro1" property="count_time" prefix="count_with_spectro.countTime" key="countTimeText"/> - <radio role="count_with_spectro1" property="time_type" valuesAndLabels="count_with_spectro.h,count_with_spectro.m,count_with_spectro.s" spaceBefore="false" /> + <radio role="count_with_spectro1" property="time_type" valuesAndLabels="count_with_spectro.h,count_with_spectro.m,count_with_spectro.s" spaceBefore="false" key="timeTypeRadio"/> </group> <group title="count_with_spectro.spectroGroup"> <text role="count_with_spectro1" property="integration_time" prefix="count_with_spectro.integration_timePrefix" suffix="count_with_spectro.integration_timeSuffix" key="spectroTimeText"/> <text role="count_with_spectro1" property="num_spectro" prefix="count_with_spectro.numSpectro" key="numSpectroMeasuresText"/> + <text role="count_with_spectro1" property="scans_average" prefix="count_with_spectro.scansAverage" key="numSpectroToAverageText"/> </group> </plugin> \ No newline at end of file diff --git a/src/controllers/lss/d22special/gui/d22_sample_sequencer/d22_sample_sequencer.properties b/src/controllers/lss/d22special/gui/d22_sample_sequencer/d22_sample_sequencer.properties deleted file mode 100644 index a73f549b..00000000 --- a/src/controllers/lss/d22special/gui/d22_sample_sequencer/d22_sample_sequencer.properties +++ /dev/null @@ -1,60 +0,0 @@ -d22_sample_sequencer.changer_numberPrefix=Changer name -d22_sample_sequencer.slotPrefix=Slot -d22_sample_sequencer.acquisitionTimePrefix=Duration -d22_sample_sequencer.titlePrefix=Run Title -d22_sample_sequencer.transmissionPrefix=Transmission -d22_sample_sequencer.thicknessPrefix=Thickness -d22_sample_sequencer.shortSlotPrefix=Slot -d22_sample_sequencer.shortAcquisitionTimePrefix=Time -d22_sample_sequencer.shortTitlePrefix=Title -d22_sample_sequencer.shortTransmissionPrefix=Trans -d22_sample_sequencer.shortThicknessPrefix=Thick -d22_sample_sequencer.samplechangerGroup=Sample Changer -d22_sample_sequencer.acquisitionGroup=Acquisition -d22_sample_sequencer.slotLabel=Used Slots -d22_sample_sequencer.maxSlotLabel=Max Slots -d22_sample_sequencer.totalTimeLabel=Total Time -d22_sample_sequencer.changer_numberPrefix=Changer # -d22_sample_sequencer.wanted_nbpositionLabel=Wanted number of positions - -# Radio buttons h/m/s -d22_sample_sequencer.hValue=h -d22_sample_sequencer.hLabel=h -d22_sample_sequencer.mValue=m -d22_sample_sequencer.mLabel=m -d22_sample_sequencer.sValue=s -d22_sample_sequencer.sLabel=s - -# Time-Monitor switcher -d22_sample_sequencer.timeValue=time -d22_sample_sequencer.timeLabel=Time -d22_sample_sequencer.timeImage=MODE_TIME -d22_sample_sequencer.countsImage=MODE_COUNTS -d22_sample_sequencer.countsValue=counts -d22_sample_sequencer.countsLabel=Monitor - -#values and labels -d22_sample_sequencer.changer1Value=1 -d22_sample_sequencer.changer1Label=Changer#1 -d22_sample_sequencer.changer2Value=2 -d22_sample_sequencer.changer2Label=Changer#2 -d22_sample_sequencer.changer3Value=3 -d22_sample_sequencer.changer3Label=Changer#3 -d22_sample_sequencer.changer4Value=4 -d22_sample_sequencer.changer4Label=Changer#4 -d22_sample_sequencer.changer5Value=5 -d22_sample_sequencer.changer5Label=Changer#5 -d22_sample_sequencer.changer6Value=6 -d22_sample_sequencer.changer6Label=Changer#6 -d22_sample_sequencer.changer7Value=7 -d22_sample_sequencer.changer7Label=Changer#7 - -d22_sample_sequencer.setFollowingValuesMessage=Set following values to current one -d22_sample_sequencer.incrementFollowingValuesMessage=Autofill following incrementally - - -d22_sample_sequencer.spectroGroup=Spectro -d22_sample_sequencer.integration_time=Time -d22_sample_sequencer.integration_timeSuffix=~mus -d22_sample_sequencer.scan_average=Scans to average - diff --git a/src/controllers/lss/d22special/gui/d22_sample_sequencer/d22_sample_sequencerCommandView.xml b/src/controllers/lss/d22special/gui/d22_sample_sequencer/d22_sample_sequencerCommandView.xml deleted file mode 100644 index b1475254..00000000 --- a/src/controllers/lss/d22special/gui/d22_sample_sequencer/d22_sample_sequencerCommandView.xml +++ /dev/null @@ -1,11 +0,0 @@ -<plugin> - <controller type="d22_sample_sequencer" role="d22_sample_sequencer1"/> - <number_of_lines nb_lines="3"/> - <label role="d22_sample_sequencer1" prefix="d22_sample_sequencer.changer_numberPrefix" property="changer_number"/> - <label role="d22_sample_sequencer1" prefix="d22_sample_sequencer.wanted_nbpositionLabel" property="wanted_nbposition"/> - <label role="d22_sample_sequencer1" prefix="d22_sample_sequencer.totalTimeLabel" property="total_time"/> - <label role="d22_sample_sequencer1" property="time_type" spaceBefore="false"/> - <newLine/> - <text role="d22_sample_sequencer1" prefix="d22_sample_sequencer.integration_time" property="integration_time" suffix="d22_sample_sequencer.integration_timeSuffix"/> - <text role="d22_sample_sequencer1" prefix="d22_sample_sequencer.scan_average" property="scan_average" /> -</plugin> \ No newline at end of file diff --git a/src/controllers/lss/d22special/gui/d22_sample_sequencer/d22_sample_sequencerPlugin.xml b/src/controllers/lss/d22special/gui/d22_sample_sequencer/d22_sample_sequencerPlugin.xml deleted file mode 100644 index 8ceff3e0..00000000 --- a/src/controllers/lss/d22special/gui/d22_sample_sequencer/d22_sample_sequencerPlugin.xml +++ /dev/null @@ -1,12 +0,0 @@ -<controller_plugin_config type="d22_sample_sequencer" isSettings="true"> - - <image key="SAMPLE_CHANGER"/> - - <settings view="d22_sample_sequencerView.xml"> - <plugin class="SampleSequencerControllerSetupPlugin"/> - <swt_plugin_peer class="SWTSampleSequencerControllerSetupPluginPeer"/> - </settings> - - <command view="d22_sample_sequencerCommandView.xml"/> - -</controller_plugin_config> diff --git a/src/controllers/lss/d22special/gui/d22_sample_sequencer/d22_sample_sequencerProperties.xml b/src/controllers/lss/d22special/gui/d22_sample_sequencer/d22_sample_sequencerProperties.xml deleted file mode 100644 index ad7be329..00000000 --- a/src/controllers/lss/d22special/gui/d22_sample_sequencer/d22_sample_sequencerProperties.xml +++ /dev/null @@ -1,64 +0,0 @@ -<?xml version="1.0" encoding="ISO-8859-1" ?> - -<controller type="d22_sample_sequencer"> - - <property name="integration_time" type="int32" max_length="10"> - </property> - - <property name="scan_average" type="int32" max_length="2"> - <strictly_positive/> - </property> - - <property name="wanted_nbposition" type="Long" max_length="3"> - <property_range min_property="min_slot" max_property="max_slot"/> - </property> - - <property name="n_property" type="Long"> - </property> - - <property name="min_slot" type="Long"> - </property> - - <property name="max_slot" type="Long"> - </property> - - <property name="mode" type="String"> - </property> - - <property name="changer_number" type="Long"> - <strictly_positive/> - </property> - - <property name="time_type" type="String"> - </property> - - <property name="total_time" type="Double" max_length="8"> - <decimal_format nb_decimal_places="2"/> - </property> - - <dynamic_property name="wanted_sample_position" size_property="n_property" type="Long" max_length="3"> - <property_range min_property="min_slot" max_property="max_slot"/> - <strictly_positive/> - </dynamic_property> - - <dynamic_property name="wanted_acquisition_time" size_property="n_property" type="Double" max_length="8"> - <decimal_format nb_decimal_places="2"/> - <positive/> <!-- Isabelle Grillo said that counting 0 second can be very useful... --> - </dynamic_property> - - <dynamic_property name="wanted_acquisition_title" size_property="n_property" type="String" max_length="30"> - </dynamic_property> - - <dynamic_property name="thickness" size_property="n_property" type="Double" max_length="6"> - <decimal_format nb_decimal_places="2"/> - <strictly_positive/> - </dynamic_property> - - <dynamic_property name="transmission" size_property="n_property" type="Double" max_length="6"> - <decimal_format nb_decimal_places="2"/> - </dynamic_property> - - <dynamic_property name="show" type="Boolean"> - </dynamic_property> - -</controller> diff --git a/src/controllers/lss/d22special/gui/d22_sample_sequencer/d22_sample_sequencerView.xml b/src/controllers/lss/d22special/gui/d22_sample_sequencer/d22_sample_sequencerView.xml deleted file mode 100644 index 10ca901d..00000000 --- a/src/controllers/lss/d22special/gui/d22_sample_sequencer/d22_sample_sequencerView.xml +++ /dev/null @@ -1,74 +0,0 @@ -<plugin> - <controller type="d22_sample_sequencer" role="d22_sample_sequencer1"/> - <property role="d22_sample_sequencer1" property="min_slot" save_value="true"/> - <property role="d22_sample_sequencer1" property="max_slot" save_value="true"/> - <group title="d22_sample_sequencer.acquisitionGroup"> - <image_button role="d22_sample_sequencer1" property="mode" valuesAndImages="d22_sample_sequencer.time,d22_sample_sequencer.counts"/> - <property_switcher role="d22_sample_sequencer1" property="mode" switcher_key="acquisitionModeSwitcher"/> - <switchable_composite switch_values="time" switcher_key="acquisitionModeSwitcher"> - <radio role="d22_sample_sequencer1" property="time_type" valuesAndLabels="d22_sample_sequencer.h,d22_sample_sequencer.m,d22_sample_sequencer.s" spaceBefore="false"/> - </switchable_composite> - </group> - - <newLine/> - - <group title="d22_sample_sequencer.samplechangerGroup"> - <combo role="d22_sample_sequencer1" property="changer_number" valuesAndLabels="d22_sample_sequencer.changer1,d22_sample_sequencer.changer2,d22_sample_sequencer.changer3,d22_sample_sequencer.changer4,d22_sample_sequencer.changer5,d22_sample_sequencer.changer6,d22_sample_sequencer.changer7" prefix="d22_sample_sequencer.changer_numberPrefix" key="changerNumberCombo"/> - <label role="d22_sample_sequencer1" prefix="d22_sample_sequencer.maxSlotLabel" property="max_slot" save_value="true"/> - <newLine/> - <text role="d22_sample_sequencer1" prefix="d22_sample_sequencer.wanted_nbpositionLabel" property="wanted_nbposition"/> - </group> - <group title="d22_sample_sequencer.spectroGroup"> - <text role="d22_sample_sequencer1" prefix="d22_sample_sequencer.integration_time" property="integration_time" suffix="d22_sample_sequencer.integration_timeSuffix"/> - <text role="d22_sample_sequencer1" prefix="d22_sample_sequencer.scan_average" property="scan_average" /> - </group> - - <newLine/> - - <table_composite nbColumns="10" border="true"> - <simple_label prefix="d22_sample_sequencer.slotPrefix" font_size="10" font_style="BOLD" horizontal_span="2" hAlignment="center"/> - <simple_label prefix="d22_sample_sequencer.acquisitionTimePrefix" font_size="10" font_style="BOLD" horizontal_span="2" hAlignment="center"/> - <simple_label prefix="d22_sample_sequencer.titlePrefix" font_size="10" font_style="BOLD" horizontal_span="2" hAlignment="center"/> - <simple_label prefix="d22_sample_sequencer.transmissionPrefix" font_size="10" font_style="BOLD" horizontal_span="2" hAlignment="center"/> - <simple_label prefix="d22_sample_sequencer.thicknessPrefix" font_size="10" font_style="BOLD" horizontal_span="2" hAlignment="center"/> - <dynamic_composite role="d22_sample_sequencer1" properties="wanted_sample_position,wanted_acquisition_time,wanted_acquisition_title,transmission,thickness,show,copyPositionButton,copyTimeButton,copyTitleButton,copyTransmissionButton,copyThicknessButton,title"> - <property_switcher role="d22_sample_sequencer1" property="show" switcher_key="show"/> - <switchable_composite switcher_key="show" switch_values="true"> - <simple_image key="copyPositionButton" prefix="ARROW_DOWN" height="10"/> - </switchable_composite> - <switchable_composite switcher_key="show" switch_values="true"> - <text role="d22_sample_sequencer1" property="wanted_sample_position" font_size="10"/> - </switchable_composite> - <switchable_composite switcher_key="show" switch_values="true"> - <simple_image key="copyTimeButton" prefix="ARROW_DOWN" height="10"/> - </switchable_composite> - <switchable_composite switcher_key="show" switch_values="true"> - <text role="d22_sample_sequencer1" property="wanted_acquisition_time" font_size="10"/> - </switchable_composite> - <switchable_composite switcher_key="show" switch_values="true"> - <simple_image key="copyTitleButton" prefix="ARROW_DOWN" height="10"/> - </switchable_composite> - <switchable_composite switcher_key="show" switch_values="true"> - <text role="d22_sample_sequencer1" property="wanted_acquisition_title" font_size="10" key="title"/> - </switchable_composite> - <switchable_composite switcher_key="show" switch_values="true"> - <simple_image key="copyTransmissionButton" prefix="ARROW_DOWN" height="10"/> - </switchable_composite> - <switchable_composite switcher_key="show" switch_values="true"> - <text role="d22_sample_sequencer1" property="transmission" font_size="10"/> - </switchable_composite> - <switchable_composite switcher_key="show" switch_values="true"> - <simple_image key="copyThicknessButton" prefix="ARROW_DOWN" height="10"/> - </switchable_composite> - <switchable_composite switcher_key="show" switch_values="true"> - <text role="d22_sample_sequencer1" property="thickness" font_size="10"/> - </switchable_composite> - </dynamic_composite> - </table_composite> - <newLine/> - - <composite> - <label role="d22_sample_sequencer1" prefix="d22_sample_sequencer.totalTimeLabel" property="total_time" save_value="true"/> - <label role="d22_sample_sequencer1" property="time_type" spaceBefore="false"/> - </composite> -</plugin> diff --git a/src/controllers/lss/d22special/gui/d22spectroSampleSequencer/d22spectroSampleSequencer.properties b/src/controllers/lss/d22special/gui/d22spectroSampleSequencer/d22spectroSampleSequencer.properties new file mode 100644 index 00000000..941557dd --- /dev/null +++ b/src/controllers/lss/d22special/gui/d22spectroSampleSequencer/d22spectroSampleSequencer.properties @@ -0,0 +1,28 @@ +sample_sequencer.changer_numberPrefix=Changer # +sample_sequencer.wanted_numSlotLabel=Wanted number of positions +sample_sequencer.maxSlotLabel= Max Slots +sample_sequencer.integration_time=Time +sample_sequencer.integration_timeSuffix=~mus +sample_sequencer.scan_average=Num. Averages per measure +sample_sequencer.numSpectro=Num. Measures +sample_sequencer.countTime=Time + +#groups names +sample_sequencer.spectroGroup=Spectro +sample_sequencer.countGroup=Count + +# Radio buttons h/m/s +sample_sequencer.hValue=h +sample_sequencer.hLabel=h +sample_sequencer.mValue=m +sample_sequencer.mLabel=m +sample_sequencer.sValue=s +sample_sequencer.sLabel=s + +# Time-Monitor switcher +sample_sequencer.timeValue=time +sample_sequencer.timeLabel=Time +sample_sequencer.timeImage=MODE_TIME +sample_sequencer.countsImage=MODE_COUNTS +sample_sequencer.countsValue=counts +sample_sequencer.countsLabel=Monitor \ No newline at end of file diff --git a/src/controllers/lss/d22special/gui/d22spectroSampleSequencer/d22spectroSampleSequencerCommandView.xml b/src/controllers/lss/d22special/gui/d22spectroSampleSequencer/d22spectroSampleSequencerCommandView.xml new file mode 100644 index 00000000..08d48767 --- /dev/null +++ b/src/controllers/lss/d22special/gui/d22spectroSampleSequencer/d22spectroSampleSequencerCommandView.xml @@ -0,0 +1,12 @@ +<plugin> + <controller type="d22spectroSampleSequencer" role="d22spectroSampleSequencer1" /> + <number_of_lines nb_lines="3" /> + <label role="d22spectroSampleSequencer1" prefix="sample_sequencer.changer_numberPrefix" property="wanted_changer" /> + <label role="d22spectroSampleSequencer1" prefix="sample_sequencer.wanted_nbpositionLabel" property="wanted_numSlot" /> + <label role="d22spectroSampleSequencer1" prefix="sample_sequencer.totalTimeLabel" property="total_time" /> + <label role="d22spectroSampleSequencer1" property="time_type" spaceBefore="false" /> + <newLine /> + <text role="d22spectroSampleSequencer1" prefix="sample_sequencer.integration_time" property="integration_time" suffix="sample_sequencer.integration_timeSuffix" /> + <text role="d22spectroSampleSequencer1" property="num_spectro" prefix="sample_sequencer.numSpectro"/> + <text role="d22spectroSampleSequencer1" prefix="sample_sequencer.scan_average" property="scans_average" /> +</plugin> \ No newline at end of file diff --git a/src/controllers/lss/d22special/gui/d22spectroSampleSequencer/d22spectroSampleSequencerPlugin.xml b/src/controllers/lss/d22special/gui/d22spectroSampleSequencer/d22spectroSampleSequencerPlugin.xml new file mode 100644 index 00000000..85b0c2be --- /dev/null +++ b/src/controllers/lss/d22special/gui/d22spectroSampleSequencer/d22spectroSampleSequencerPlugin.xml @@ -0,0 +1,10 @@ +<controller_plugin_config type="d22spectroSampleSequencer" isSettings="true"> + + <image key="SAMPLE_CHANGER" /> + <settings view="d22spectroSampleSequencerView.xml"> + <plugin class="D22SpectroSampleSequencerControllerSetupPlugin" /> + <swt_plugin_peer class="SWTSampleSequencerNewControllerSetupPluginPeer" /> + </settings> + + <command view="d22spectroSampleSequencerCommandView.xml" /> +</controller_plugin_config> \ No newline at end of file diff --git a/src/controllers/lss/d22special/gui/d22spectroSampleSequencer/d22spectroSampleSequencerProperties.xml b/src/controllers/lss/d22special/gui/d22spectroSampleSequencer/d22spectroSampleSequencerProperties.xml new file mode 100644 index 00000000..eb3ddd48 --- /dev/null +++ b/src/controllers/lss/d22special/gui/d22spectroSampleSequencer/d22spectroSampleSequencerProperties.xml @@ -0,0 +1,46 @@ +<controller type="d22spectroSampleSequencer"> + + <property name="num_spectro" type="int32" max_length="3"> + <strictly_positive /> + </property> + <property name="scans_average" type="int32" max_length="3"> + <strictly_positive /> + </property> + + <property name="changer_num" type="int32"> + </property> + + <property name="actual_numSlot" type="int32"> + </property> + + <property name="wanted_numSlot" type="int32" max_length="3"> + <!-- <property_range min_property="min_pos" max_property="max_pos" /> <strictly_positive /> --> + </property> + + <dynamic_property name="changer_values" size_property="changer_num" type="int32"> + </dynamic_property> + + <dynamic_property name="changer_labels" size_property="changer_num" type="String"> + </dynamic_property> + + <dynamic_property name="sample_position" size_property="wanted_numSlot" type="int32" max_length="3"> + </dynamic_property> + + <dynamic_property name="acquisition_time" size_property="wanted_numSlot" type="float64" max_length="8"> + <decimal_format nb_decimal_places="2" /> + <strictly_positive /> + </dynamic_property> + + <dynamic_property name="transmission" size_property="wanted_numSlot" type="float64" max_length="6"> + <decimal_format nb_decimal_places="2" /> + </dynamic_property> + + <dynamic_property name="thickness" size_property="wanted_numSlot" type="float64" max_length="6"> + <decimal_format nb_decimal_places="2" /> + <strictly_positive /> + </dynamic_property> + + <dynamic_property name="acquisition_title" size_property="wanted_numSlot" type="string" max_length="30"> + </dynamic_property> + +</controller> \ No newline at end of file diff --git a/src/controllers/lss/d22special/gui/d22spectroSampleSequencer/d22spectroSampleSequencerView.xml b/src/controllers/lss/d22special/gui/d22spectroSampleSequencer/d22spectroSampleSequencerView.xml new file mode 100644 index 00000000..0780fee7 --- /dev/null +++ b/src/controllers/lss/d22special/gui/d22spectroSampleSequencer/d22spectroSampleSequencerView.xml @@ -0,0 +1,44 @@ +<plugin> + <controller type="d22spectroSampleSequencer" role="d22spectroSampleSequencer1" /> + <group title="sample_sequencer.countGroup"> + <radio role="d22spectroSampleSequencer1" property="time_type" valuesAndLabels="sample_sequencer.h,sample_sequencer.m,sample_sequencer.s" spaceBefore="false" key="timeTypeRadio" /> + </group> + <group title="sample_sequencer.spectroGroup"> + <text role="d22spectroSampleSequencer1" prefix="sample_sequencer.integration_time" property="integration_time" suffix="sample_sequencer.integration_timeSuffix" /> + <text role="d22spectroSampleSequencer1" property="num_spectro" prefix="sample_sequencer.numSpectro" key="numSpectroMeasuresText" /> + <text role="d22spectroSampleSequencer1" prefix="sample_sequencer.scan_average" property="scans_average" /> + </group> + <newLine /> + <group title="sample_sequencer.samplechangerGroup"> + <property_combo role="d22spectroSampleSequencer1" property="wanted_changer" /> + <label role="d22spectroSampleSequencer1" prefix="sample_sequencer.maxSlotLabel" property="max_slot" /> + <newLine /> + <text role="d22spectroSampleSequencer1" prefix="sample_sequencer.wanted_numSlotLabel" property="wanted_numSlot" /> + </group> + <newLine /> + <table_composite nbColumns="10" border="true"> + <simple_label prefix="Slot" font_size="10" font_style="BOLD" horizontal_span="2" hAlignment="center" /> + <simple_label prefix="Duration" font_size="10" font_style="BOLD" horizontal_span="2" hAlignment="center" /> + <simple_label prefix="Run Title" font_size="10" font_style="BOLD" horizontal_span="2" hAlignment="center" /> + <simple_label prefix="Transmission" font_size="10" font_style="BOLD" horizontal_span="2" hAlignment="center" /> + <simple_label prefix="thickness" font_size="10" font_style="BOLD" horizontal_span="2" hAlignment="center" /> + + <dynamic_composite role="d22spectroSampleSequencer1" properties="sample_position,acquisition_time,transmission,thickness,acquisition_title,copyPositionButton,copyTimeButton,copyTitleButton,copyTransmissionButton,copyThicknessButton"> + <simple_image key="copyPositionButton" prefix="ARROW_DOWN" height="20" /> + <text role="d22spectroSampleSequencer1" property="sample_position" font_size="10" /> + <simple_image key="copyTimeButton" prefix="ARROW_DOWN" height="20" /> + <text role="d22spectroSampleSequencer1" property="acquisition_time" font_size="10" /> + <simple_image key="copyTitleButton" prefix="ARROW_DOWN" height="20" /> + <text role="d22spectroSampleSequencer1" property="acquisition_title" font_size="10" /> + <simple_image key="copyTransmissionButton" prefix="ARROW_DOWN" height="20" /> + <text role="d22spectroSampleSequencer1" property="transmission" font_size="10" /> + <simple_image key="copyThicknessButton" prefix="ARROW_DOWN" height="20" /> + <text role="d22spectroSampleSequencer1" property="thickness" font_size="10" /> + </dynamic_composite> + </table_composite> + <newLine /> + <composite> + <label role="d22spectroSampleSequencer1" prefix="sample_sequencer.totalTimeLabel" property="total_time" save_value="true"/> + <label role="d22spectroSampleSequencer1" property="time_type" spaceBefore="false" /> + </composite> +</plugin> \ No newline at end of file diff --git a/src/controllers/npp/BidimHistoDetectorElement.cpp b/src/controllers/npp/BidimHistoDetectorElement.cpp new file mode 100644 index 00000000..2c1ae1d9 --- /dev/null +++ b/src/controllers/npp/BidimHistoDetectorElement.cpp @@ -0,0 +1,62 @@ +/* + * Nomad Instrument Control Software + * + * Copyright 2011 Institut Laue-Langevin + * + * Licensed under the EUPL, Version 1.1 only (the "License"); + * You may not use this work except in compliance with the Licence. + * You may obtain a copy of the Licence at: + * + * http://joinup.ec.europa.eu/software/page/eupl + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the Licence is distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Licence for the specific language governing permissions and + * limitations under the Licence. + */ + +#include "BidimHistoDetectorElement.h" + +namespace npp { + +const string BidimHistoDetectorElement::TYPE = "npp_bidim_histo_detector_element"; + +/* + * Constructor + */ +BidimHistoDetectorElement::BidimHistoDetectorElement(const string& name) : + acquisition::DetectorElement(name) { + + registerFunction(TYPE); + + m_Driver.init(this, "driver"); +} + +/* + * postConfiguration + */ +void BidimHistoDetectorElement::postConfiguration() { + acquisition::DetectorElement::postConfiguration(); + registerUpdater(m_Driver->pf1bPsdBidimHistoZData, &BidimHistoDetectorElement::updateData, this); +} + +/* + * Destructor + */ +BidimHistoDetectorElement::~BidimHistoDetectorElement() { +} + +/* + * updateData + */ +void BidimHistoDetectorElement::updateData() { + detSize = m_Driver->pf1bPsdBidimHistoZData.getSize(); + int32* ldata = m_Driver->pf1bPsdBidimHistoZData(); + data.update(ldata); + data.setSize(detSize()); + data.sendEvent(); + calculateDetectorSum(); +} + +} diff --git a/src/controllers/npp/BidimHistoDetectorElement.h b/src/controllers/npp/BidimHistoDetectorElement.h new file mode 100644 index 00000000..daaa284e --- /dev/null +++ b/src/controllers/npp/BidimHistoDetectorElement.h @@ -0,0 +1,75 @@ +/* + * Nomad Instrument Control Software + * + * Copyright 2011 Institut Laue-Langevin + * + * Licensed under the EUPL, Version 1.1 only (the "License"); + * You may not use this work except in compliance with the Licence. + * You may obtain a copy of the Licence at: + * + * http://joinup.ec.europa.eu/software/page/eupl + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the Licence is distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Licence for the specific language governing permissions and + * limitations under the Licence. + */ + +/*! + * \brief PN1Coincidence Detector Element class + * \author J. Locatelli + * \date 10-01-2010 + */ + +#ifndef NPP_BIDIMHISTODETECTORELEMENT_H +#define NPP_BIDIMHISTODETECTORELEMENT_H + +#include "controllers/common/acquisition/detector/DetectorElement.h" +#include "drivers/ioxos/mpda_dpp/MpdaDPPDriver.h" + +namespace npp { + +/*! + * \class BidimHistoDetectorElement + * \brief BidimHisto Detector Element class + * + * \par + * This class overload. DetectorElement class. It creates a new data array for plot window. + * The data have to be rotated for the plot. + */ +class BidimHistoDetectorElement: public acquisition::DetectorElement { + +public: + + //! Type of controller + static const std::string TYPE; + + /*! + * \brief Constructor + * \param[in] name the name of the experiment controller + */ + BidimHistoDetectorElement(const std::string& name); + + /*! + * \brief Destructor + */ + virtual ~BidimHistoDetectorElement(); + + /*! + * \brief Method called before changing the property value + * + * This method is called after setting configuration during the creation of controller. + */ + virtual void postConfiguration(); + +private: + + DriverPtr<mpda_dpp::MpdaDPPDriver> m_Driver; //! Pointer on histo data + + void updateData(); + +}; + +} +#endif diff --git a/src/controllers/npp/CAENAdcController.cpp b/src/controllers/npp/CAENAdcController.cpp index 7962f5b3..5ebd0f9f 100644 --- a/src/controllers/npp/CAENAdcController.cpp +++ b/src/controllers/npp/CAENAdcController.cpp @@ -20,6 +20,7 @@ #include "drivers/global/DriversCommands.h" #include "controllers/common/family/Families.h" #include <boost/thread/thread.hpp> +#include <controllers/common/acquisition/mode/DPPAcquisitionCommon.h> using namespace std; using namespace boost; @@ -31,7 +32,7 @@ const string CAENAdcController::TYPE = "adc_controller"; /* * Constructor */ -CAENAdcController::CAENAdcController(const string& name) : ExperimentController(name), ClearData(this) { +CAENAdcController::CAENAdcController(const string& name) : ExperimentController(name), ClearData(this), acquisition::ListModeProperties(this) { setFamily(family::ACQUISITION, family::SETTING); @@ -40,10 +41,11 @@ CAENAdcController::CAENAdcController(const string& name) : ExperimentController( acqBoardIndex.init(this, SAVE, "acq_board_index"); channels.init(this, NOSAVE, "channels"); nbChannels.init(this, NOSAVE, "nb_channels"); - dppAcqMode.init(this, NOSAVE, "dpp_acq_mode"); - recordLength.init(this, SAVE, "record_length"); + dppAcqMode.init(this, NOSAVE, "dpp_acq_mode"); + dppAcqMode.update(acquisition::DPPAcquisitionCommon::LISTMODE_MODE); + + recordLength.init(this, SAVE, "record_length"); - displayChannel.init(this, SAVE, "display_channel"); minRange.init(this, NOSAVE, "min_range"); maxRange.init(this, NOSAVE, "max_range"); @@ -68,4 +70,14 @@ CAENAdcController::~CAENAdcController() { } +void CAENAdcController::refreshDppAcqModeProperty(int32 aValue) throw (CannotSetValue) { + if (aValue == acquisition::DPPAcquisitionCommon::SCOPE_MODE) { + scope = true; + } + else { + scope = false; + } +} + + } diff --git a/src/controllers/npp/CAENAdcController.h b/src/controllers/npp/CAENAdcController.h index 309dbe5f..51af6b6b 100644 --- a/src/controllers/npp/CAENAdcController.h +++ b/src/controllers/npp/CAENAdcController.h @@ -20,6 +20,7 @@ #define CAENADCCONTROLLER_H #include <Controller.h> +#include <controllers/common/acquisition/mode/ListModeProperties.h> namespace npp { @@ -53,7 +54,7 @@ public: */ -class CAENAdcController: public ExperimentController, public ClearData { +class CAENAdcController: public ExperimentController, public ClearData, public acquisition::ListModeProperties { public: @@ -80,7 +81,6 @@ public: Property<int32> recordLength; // Channels properties - Property<int32> displayChannel; Property<int32> minRange; Property<int32> maxRange; @@ -96,6 +96,21 @@ public: ArrayProperty<int32> curve2; ArrayProperty<int32> curve3; ArrayProperty<int32> curve4; + +protected: + + virtual void refreshNbChannelsProperty(int32 aValue) throw (CannotSetValue) = 0; + virtual void refreshDisplayChannelProperty(int32 aValue) throw (CannotSetValue) = 0; + virtual void refreshRecordLengthProperty(int32 aValue) throw (CannotSetValue) = 0; + virtual void refreshDppAcqModeProperty(int32 aValue) throw (CannotSetValue); + + virtual void refreshChannelActiveProperty(int32 aValue) throw (CannotSetValue) = 0; + + virtual void updateBoardProperties() = 0; + + virtual void writeParam() = 0; + virtual void initChannel(int32 aChannel) = 0; + }; } diff --git a/src/controllers/npp/CAENCfdController.cpp b/src/controllers/npp/CAENCfdController.cpp new file mode 100644 index 00000000..16a6c03e --- /dev/null +++ b/src/controllers/npp/CAENCfdController.cpp @@ -0,0 +1,222 @@ +/* + * Nomad Instrument Control Software + * + * Copyright 2011 Institut Laue-Langevin + * + * Licensed under the EUPL, Version 1.1 only (the "License"); + * You may not use this work except in compliance with the Licence. + * You may obtain a copy of the Licence at: + * + * http://joinup.ec.europa.eu/software/page/eupl + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the Licence is distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Licence for the specific language governing permissions and + * limitations under the Licence. + */ + +#include "CAENCfdController.h" +#include "drivers/global/DriversCommands.h" +#include "controllers/common/family/Families.h" +#include <boost/thread/thread.hpp> +#include <controllers/common/acquisition/mode/DPPAcquisitionCommon.h> +#include "controllers/common/acquisition/mode/ListModeTypes.h" + +using namespace std; +using namespace boost; + +namespace npp { + +const string CAENCfdController::TYPE = "cfd_controller"; + +/* + * Constructor + */ +CAENCfdController::CAENCfdController(const string& name) : CAENAdcController(name) { + + setFamily(family::ACQUISITION, family::SETTING); + + // Register properties + // CFD parameters + delay.init(this, NOSAVE, "delay"); + attenuation.init(this, NOSAVE, "attenuation"); + + // Energy filter parameters + trapezoidRise.init(this, NOSAVE, "trapezoid_rise"); + trapezoidFlat.init(this, NOSAVE, "trapezoid_flat"); + decayTime.init(this, NOSAVE, "decay_time"); + peaking.init(this, NOSAVE, "peaking"); + bitShift.init(this, NOSAVE, "bit_shift"); + channelOffset.init(this, SAVE, "channel_offset"); + + m_CfdDriver.init(this, "cfd_driver"); + + registerFunction(TYPE); +} + +/* + * Destructor + */ +CAENCfdController::~CAENCfdController() { + +} + +/* + * postConfiguration + */ +void CAENCfdController::postConfiguration() { + registerRefresher(recordLength, &CAENCfdController::refreshRecordLengthProperty, this); + registerRefresher(nbChannels, &CAENCfdController::refreshNbChannelsProperty, this); + registerRefresher(dppAcqMode, &CAENCfdController::refreshDppAcqModeProperty, this); + registerRefresher(displayChannel, &CAENCfdController::refreshDisplayChannelProperty, this); + registerRefresher(channelActive, &CAENCfdController::refreshChannelActiveProperty, this); + registerRefresher(pulsePolarity, &CAENCfdController::refreshPulsePolarityProperty, this); + registerRefresher(delay, &CAENCfdController::refreshDelayProperty, this); + registerRefresher(attenuation, &CAENCfdController::refreshAttenuationProperty, this); + registerRefresher(pulsePolarity, &CAENCfdController::refreshPulsePolarityProperty, this); + registerRefresher(trapezoidRise, &CAENCfdController::refreshTrapezoidRiseProperty, this); + registerRefresher(trapezoidFlat, &CAENCfdController::refreshTrapezoidFlatProperty, this); + registerRefresher(decayTime, &CAENCfdController::refreshDecayTimeProperty, this); + registerRefresher(peaking, &CAENCfdController::refreshPeakingProperty, this); + registerRefresher(bitShift, &CAENCfdController::refreshBitShiftProperty, this); + registerRefresher(channelOffset, &CAENCfdController::refreshChannelOffsetProperty, this); + + updateBoardProperties(); + updateCfdProperties(displayChannel() + channelOffset()); + cardType = CFD_BOARD_TYPE; +} + +void CAENCfdController::refreshDelayProperty(int32 aValue) throw (CannotSetValue) { + cout << "CAENCfdController::refreshDelayProperty" << endl; + m_CfdDriver->delay = aValue; + boost::thread td(boost::bind(&CAENCfdController::writeParam, this)); +} + +void CAENCfdController::refreshAttenuationProperty(int32 aValue) throw (CannotSetValue) { + cout << "CAENCfdController::refreshAttenuationProperty" << endl; + m_CfdDriver->attenuation = aValue; + boost::thread td(boost::bind(&CAENCfdController::writeParam, this)); +} + +void CAENCfdController::refreshPulsePolarityProperty(int32 aValue) throw (CannotSetValue) { + cout << "CAENCfdController::refreshPulsePolarityProperty" << endl; + m_CfdDriver->pulsePolarity.set(displayChannel() + channelOffset(), aValue); + boost::thread td(boost::bind(&CAENCfdController::writeParam, this)); +} + +void CAENCfdController::refreshTrapezoidRiseProperty(int32 aValue) throw (CannotSetValue) { + cout << "CAENCfdController::refreshTrapezoidRiseProperty" << endl; + m_CfdDriver->trapezoidRise.set(displayChannel() + channelOffset(), aValue); + boost::thread td(boost::bind(&CAENCfdController::writeParam, this)); +} + +void CAENCfdController::refreshTrapezoidFlatProperty(int32 aValue) throw (CannotSetValue) { + cout << "CAENCfdController::refreshTrapezoidFlatProperty" << endl; + m_CfdDriver->trapezoidFlat.set(displayChannel() + channelOffset(), aValue); + boost::thread td(boost::bind(&CAENCfdController::writeParam, this)); +} + +void CAENCfdController::refreshDecayTimeProperty(int32 aValue) throw (CannotSetValue) { + cout << "CAENCfdController::refreshDecayTimeProperty" << endl; + m_CfdDriver->decayTime.set(displayChannel() + channelOffset(), aValue); + boost::thread td(boost::bind(&CAENCfdController::writeParam, this)); +} + +void CAENCfdController::refreshPeakingProperty(int32 aValue) throw (CannotSetValue) { + cout << "CAENCfdController::refreshPeakingProperty" << endl; + m_CfdDriver->peaking.set(displayChannel() + channelOffset(), aValue); + boost::thread td(boost::bind(&CAENCfdController::writeParam, this)); +} + +void CAENCfdController::refreshBitShiftProperty(int32 aValue) throw (CannotSetValue) { + cout << "CAENCfdController::refreshBitShiftProperty" << endl; + m_CfdDriver->bitShift.set(displayChannel() + channelOffset(), aValue); + boost::thread td(boost::bind(&CAENCfdController::writeParam, this)); +} + +void CAENCfdController::refreshDisplayChannelProperty(int32 aChannel) throw (CannotSetValue) { + updateCfdProperties(aChannel + channelOffset()); +} + +void CAENCfdController::refreshChannelActiveProperty(int32 aValue) throw (CannotSetValue) { + cout << "CAENCfdController::refreshChannelActiveProperty" << endl; + m_CfdDriver->channelActive.set(displayChannel(), aValue); + boost::thread td(boost::bind(&CAENCfdController::writeParam, this)); +} + +void CAENCfdController::refreshChannelOffsetProperty(int32 aChannel) throw (CannotSetValue) { + cout << "CAENCfdController::refreshChannelOffsetProperty" << endl; + updateCfdProperties(displayChannel() + aChannel); + boost::thread td(boost::bind(&CAENCfdController::writeParam, this)); +} + +void CAENCfdController::refreshNbChannelsProperty(int32 aValue) throw (CannotSetValue) { + minRange = 0; + maxRange = aValue - 1; + m_CfdDriver->nbChannels = aValue; + if (displayChannel() >= aValue) + displayChannel = aValue - 1; +} + +void CAENCfdController::refreshDppAcqModeProperty(int32 aValue) throw (CannotSetValue) { + cout << "CAENCfdController::refreshDppAcqModeProperty" << endl; + if (aValue == acquisition::DPPAcquisitionCommon::SCOPE_MODE) { + m_CfdDriver->dppAcqMode = 1; + } + else { + m_CfdDriver->dppAcqMode = 0; + } + boost::thread td(boost::bind(&CAENCfdController::writeParam, this)); +} + +void CAENCfdController::refreshRecordLengthProperty(int32 aValue) throw (CannotSetValue) { + +// m_CfdDriver->recordLength = aValue; +} + +/* + * updateBoardProperties + */ +void CAENCfdController::updateBoardProperties() { +// modelName.update(m_CfdDriver->modelName()); + channels.update(m_CfdDriver->channels()); + nbChannels.update(m_CfdDriver->nbChannels()); + minRange = 0; + maxRange = m_CfdDriver->nbChannels() - 1; + dppAcqMode.update(m_CfdDriver->dppAcqMode()); + delay.update(m_CfdDriver->delay()); + attenuation.update(m_CfdDriver->attenuation()); +} + +/* + * updateCfdProperties + */ +void CAENCfdController::updateCfdProperties(int32 channel) { + cout << "updateCfdProperties : " << channel << endl; + m_CfdDriver->scopeChannel = channel; + channelActive.update(m_CfdDriver->channelActive.get(channel)); + pulsePolarity.update(m_CfdDriver->pulsePolarity.get(channel)); + trapezoidRise.update(m_CfdDriver->trapezoidRise.get(channel)); + trapezoidFlat.update(m_CfdDriver->trapezoidFlat.get(channel)); + decayTime.update(m_CfdDriver->decayTime.get(channel)); + peaking.update(m_CfdDriver->peaking.get(channel)); + bitShift.update(m_CfdDriver->bitShift.get(channel)); +} + +void CAENCfdController::writeParam() { + + m_CfdDriver.execute(cfd::CfdDriver::WRITE_PARAMETERS_COMMAND, false); +} + +void CAENCfdController::clearData() { + commandProgression = 0; +// m_CfdDriver.execute(cfd::CfdDriver::CLEAR_COMMAND, true); + commandProgression = 100; +} + +void CAENCfdController::initChannel(int32 aChannel) { + +} + +} diff --git a/src/controllers/npp/CAENCfdController.h b/src/controllers/npp/CAENCfdController.h new file mode 100644 index 00000000..3bc41251 --- /dev/null +++ b/src/controllers/npp/CAENCfdController.h @@ -0,0 +1,100 @@ +/* + * Nomad Instrument Control Software + * + * Copyright 2011 Institut Laue-Langevin + * + * Licensed under the EUPL, Version 1.1 only (the "License"); + * You may not use this work except in compliance with the Licence. + * You may obtain a copy of the Licence at: + * + * http://joinup.ec.europa.eu/software/page/eupl + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the Licence is distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Licence for the specific language governing permissions and + * limitations under the Licence. + */ + +#ifndef CAENCFDCONTROLLER_H +#define CAENCFDCONTROLLER_H + +#include "CAENAdcController.h" +#include "drivers/ioxos/cfd/CfdDriver.h" + +namespace npp { + +/*! + * \class CAENV1724Driver + * \brief Main class for the CAENV1724Driver device driver + * + * \par + * Class for CAENV1724Driver driver. Implements DeviceDriver methods. + * \par + * The CAENV1724Driver device manages the global functionality of the CAEN V1724 VME Digitiser. + */ +class CAENCfdController: public CAENAdcController { + +public: + + //! Driver type value + static const std::string TYPE; + + /*! + * \brief Constructor + * \param[in] name the name of the device driver + */ + CAENCfdController(const std::string& name); + + /*! + * \brief Destructor + */ + virtual ~CAENCfdController(); + + /** + * \brief Postconfiguration + */ + virtual void postConfiguration(); + + // Global properties + Property<int32> delay; + Property<int32> attenuation; + // Channel property + Property<int32> trapezoidRise; + Property<int32> trapezoidFlat; + Property<int32> decayTime; + Property<int32> peaking; + Property<int32> bitShift; + Property<int32> channelOffset; + +protected: + + DriverPtr<cfd::CfdDriver> m_CfdDriver; + +private: + + void refreshDelayProperty(int32 aValue) throw (CannotSetValue); + void refreshAttenuationProperty(int32 aValue) throw (CannotSetValue); + void refreshTrapezoidRiseProperty(int32 aValue) throw (CannotSetValue); + void refreshTrapezoidFlatProperty(int32 aValue) throw (CannotSetValue); + void refreshDecayTimeProperty(int32 aValue) throw (CannotSetValue); + void refreshPeakingProperty(int32 aValue) throw (CannotSetValue); + void refreshBitShiftProperty(int32 aValue) throw (CannotSetValue); + virtual void refreshChannelActiveProperty(int32 aValue) throw (CannotSetValue); + virtual void refreshRecordLengthProperty(int32 aValue) throw (CannotSetValue); + virtual void refreshDisplayChannelProperty(int32 aValue) throw (CannotSetValue); + virtual void refreshChannelOffsetProperty(int32 aValue) throw (CannotSetValue); + virtual void refreshNbChannelsProperty(int32 aValue) throw (CannotSetValue); + virtual void refreshPulsePolarityProperty(int32 aValue) throw (CannotSetValue); + virtual void refreshDppAcqModeProperty(int32 aValue) throw (CannotSetValue); + virtual void updateBoardProperties(); + + void updateCfdProperties(int32 channel); + + virtual void clearData(); + virtual void writeParam(); + virtual void initChannel(int32 aChannel); +}; + +} +#endif //CAENV1724CONTROLLER_H diff --git a/src/controllers/npp/CAENPhaController.cpp b/src/controllers/npp/CAENPhaController.cpp index a2c8cda9..ba6b5f93 100644 --- a/src/controllers/npp/CAENPhaController.cpp +++ b/src/controllers/npp/CAENPhaController.cpp @@ -19,6 +19,7 @@ #include "CAENPhaController.h" #include "drivers/global/DriversCommands.h" #include "controllers/common/family/Families.h" +#include "controllers/common/acquisition/mode/ListModeTypes.h" #include <boost/thread/thread.hpp> using namespace std; @@ -117,7 +118,7 @@ void CAENPhaController::refreshNbChannelsProperty(int32 aValue) throw (CannotSe } void CAENPhaController::refreshDppAcqModeProperty(int32 aValue) throw (CannotSetValue) { - + CAENAdcController::refreshDppAcqModeProperty(aValue); m_dgtzDriver->dppAcqMode = aValue; boost::thread td(boost::bind(&CAENPhaController::initBoard, this)); } @@ -360,6 +361,12 @@ void CAENPhaController::refreshUseFirstDerivativeProperty(int32 aValue) throw (C void CAENPhaController::updateBoardProperties() { modelName.update(m_dgtzDriver->modelName()); + if (modelName() == "V1724") { + cardType = V1724_BOARD_TYPE; + } + else if (modelName() == "V1730") { + cardType = V1730_BOARD_TYPE; + } channels.update(m_dgtzDriver->channels()); nbChannels.update(m_dgtzDriver->nbChannels()); minRange = 0; diff --git a/src/controllers/npp/CAENPhaController.h b/src/controllers/npp/CAENPhaController.h index 3f23f710..b6329d06 100644 --- a/src/controllers/npp/CAENPhaController.h +++ b/src/controllers/npp/CAENPhaController.h @@ -88,13 +88,14 @@ protected: private: - void updateNbBitsProperty(); - void updateRecordLengthProperty(); - void refreshRecordLengthProperty(int32 aValue) throw (CannotSetValue); - void refreshNbChannelsProperty(int32 aValue) throw (CannotSetValue); - void refreshDppAcqModeProperty(int32 aValue) throw (CannotSetValue); - void refreshDisplayChannelProperty(int32 aValue) throw (CannotSetValue); + virtual void refreshNbChannelsProperty(int32 aValue) throw (CannotSetValue); + virtual void refreshDisplayChannelProperty(int32 aValue) throw (CannotSetValue); + virtual void refreshRecordLengthProperty(int32 aValue) throw (CannotSetValue); + virtual void refreshDppAcqModeProperty(int32 aValue) throw (CannotSetValue); + + virtual void refreshChannelActiveProperty(int32 aValue) throw (CannotSetValue); + void refreshSignalDecayTime(float64 aValue) throw (CannotSetValue); void refreshTrapezoidFlatTopProperty(float64 aValue) throw (CannotSetValue); void refreshTrapezoidRiseTimeProperty(float64 aValue) throw (CannotSetValue); @@ -112,19 +113,18 @@ private: void refreshDigitalGainProperty(int32 aValue) throw (CannotSetValue); void refreshTrapezoidGainProperty(float64 aValue) throw (CannotSetValue); void refreshDecimationProperty(int32 aValue) throw (CannotSetValue); - void refreshChannelActiveProperty(int32 aValue) throw (CannotSetValue); void refreshDcOffsetProperty(int32 aValue) throw (CannotSetValue); void refreshPreTriggerProperty(int32 aValue) throw (CannotSetValue); void refreshPulsePolarityProperty(int32 aValue) throw (CannotSetValue); void refreshUseFirstDerivativeProperty(int32 aValue) throw (CannotSetValue); - void updateBoardProperties(); - void updateCurveProperties(); + virtual void updateBoardProperties(); + void updateNbBitsProperty(); virtual void clearData(); - void writeParam(); + virtual void writeParam(); + virtual void initChannel(int32 aChannel); void initBoard(); - void initChannel(int32 aChannel); }; } diff --git a/src/controllers/npp/CAENPksController.cpp b/src/controllers/npp/CAENPksController.cpp new file mode 100644 index 00000000..ee800c76 --- /dev/null +++ b/src/controllers/npp/CAENPksController.cpp @@ -0,0 +1,96 @@ +/* + * Nomad Instrument Control Software + * + * Copyright 2011 Institut Laue-Langevin + * + * Licensed under the EUPL, Version 1.1 only (the "License"); + * You may not use this work except in compliance with the Licence. + * You may obtain a copy of the Licence at: + * + * http://joinup.ec.europa.eu/software/page/eupl + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the Licence is distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Licence for the specific language governing permissions and + * limitations under the Licence. + */ + +#include "CAENPksController.h" +#include "drivers/global/DriversCommands.h" +#include "controllers/common/family/Families.h" +#include "controllers/common/acquisition/mode/ListModeTypes.h" +#include <boost/thread/thread.hpp> + +using namespace std; +using namespace boost; + +namespace npp { + +const string CAENPksController::TYPE = "pks_controller"; + +/* + * Constructor + */ +CAENPksController::CAENPksController(const string& name) : + ExperimentController(name) { + + setFamily(family::ACQUISITION, family::SETTING); + + nbChannels.init(this, NOSAVE, "nb_channels"); + channelsActive.init(this, NOSAVE, "channels_active"); + triggerThreshold.init(this, NOSAVE, "trigger_threshold"); + + m_adcDriver.init(this, "pks_driver"); + + registerFunction(TYPE); +} + +/* + * Destructor + */ +CAENPksController::~CAENPksController() { + +} + +/* + * postConfiguration + */ +void CAENPksController::postConfiguration() { + + // Get ADC nb channels + nbChannels = m_adcDriver->nbChannels(); + channelsActive.resize(nbChannels()); + triggerThreshold.resize(nbChannels()); + for(int32 i=0;i<nbChannels();++i) { + channelsActive.update(i, m_adcDriver->channelActive.get(i)); + triggerThreshold.update(i, m_adcDriver->triggerThreshold.get(i)); + } + registerRefresher(channelsActive, &CAENPksController::refreshChannelsActiveProperty, this); + registerRefresher(triggerThreshold, &CAENPksController::refreshTriggerThresholdProperty, this); +} + +/* + * refreshChanneslActiveProperty + */ +void CAENPksController::refreshChannelsActiveProperty(int32 index, int32 aValue) throw (CannotSetValue) { + m_adcDriver->channelActive.set(index, aValue); + boost::thread td(boost::bind(&CAENPksController::writeParam, this)); +} + +/* + * refreshTriggerThresholdProperty + */ +void CAENPksController::refreshTriggerThresholdProperty(int32 index, int32 aValue) throw (CannotSetValue) { + m_adcDriver->triggerThreshold.set(index, aValue); + boost::thread td(boost::bind(&CAENPksController::writeParam, this)); +} + +/* + * writeParam + */ +void CAENPksController::writeParam() { + m_adcDriver.execute(caen_pks::CAENPksDriver::WRITE_PARAMETERS_COMMAND, false); +} + +} diff --git a/src/controllers/npp/CAENPksController.h b/src/controllers/npp/CAENPksController.h new file mode 100644 index 00000000..228a90d1 --- /dev/null +++ b/src/controllers/npp/CAENPksController.h @@ -0,0 +1,78 @@ +/* + * Nomad Instrument Control Software + * + * Copyright 2011 Institut Laue-Langevin + * + * Licensed under the EUPL, Version 1.1 only (the "License"); + * You may not use this work except in compliance with the Licence. + * You may obtain a copy of the Licence at: + * + * http://joinup.ec.europa.eu/software/page/eupl + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the Licence is distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Licence for the specific language governing permissions and + * limitations under the Licence. + */ + +#ifndef CAENPKSCONTROLLER_H +#define CAENPKSCONTROLLER_H + +#include <Controller.h> +#include "drivers/caen_pks/CAENPksDriver.h" + +namespace npp { + +/*! + * \class CAENVPhaDriver + * \brief Main class for the CAENPhaDriver device driver + * + * \par + * Class for CAENPhaDriver driver. Implements DeviceDriver methods. + * \par + * The CAENPhaDriver device manages the global functionality of the + * CAEN V1724 and CAEN V1730 VME Digitizers. + */ + + +class CAENPksController: public ExperimentController { + +public: + + //! Driver type value + static const std::string TYPE; + + /*! + * \brief Constructor + * \param[in] name the name of the device driver + */ + CAENPksController(const std::string& name); + + /*! + * \brief Destructor + */ + virtual ~CAENPksController(); + + /** + * \brief Postconfiguration + */ + virtual void postConfiguration(); + + // Channels properties + Property<int32> nbChannels; + DynamicProperty<int32> channelsActive; + DynamicProperty<int32> triggerThreshold; + +private: + + DriverPtr<caen_pks::CAENPksDriver> m_adcDriver; + + void refreshChannelsActiveProperty(int32 index, int32 aValue) throw (CannotSetValue); + void refreshTriggerThresholdProperty(int32 index, int32 aValue) throw (CannotSetValue); + + void writeParam(); +}; + +} +#endif //CAENPKSCONTROLLER_H diff --git a/src/controllers/npp/CAENPsdController.cpp b/src/controllers/npp/CAENPsdController.cpp index 824aeb41..36aca2fc 100644 --- a/src/controllers/npp/CAENPsdController.cpp +++ b/src/controllers/npp/CAENPsdController.cpp @@ -19,6 +19,7 @@ #include "CAENPsdController.h" #include "drivers/global/DriversCommands.h" #include "controllers/common/family/Families.h" +#include "controllers/common/acquisition/mode/ListModeTypes.h" #include <boost/thread/thread.hpp> using namespace std; @@ -81,6 +82,7 @@ void CAENPsdController::postConfiguration() { registerRefresher(pulsePolarity, &CAENPsdController::refreshPulsePolarityProperty, this); updateBoardProperties(); + cardType = V1751_BOARD_TYPE; } void CAENPsdController::refreshRecordLengthProperty(int32 aValue) throw (CannotSetValue) { @@ -89,7 +91,7 @@ void CAENPsdController::refreshRecordLengthProperty(int32 aValue) throw (CannotS } void CAENPsdController::refreshNbChannelsProperty(int32 aValue) throw (CannotSetValue) { - + cout << "CAENPsdController::refreshNbChannelsProperty : " << aValue << endl; minRange = 0; maxRange = aValue - 1; m_dgtzDriver->nbChannels = aValue; @@ -98,12 +100,13 @@ void CAENPsdController::refreshNbChannelsProperty(int32 aValue) throw (CannotSe } void CAENPsdController::refreshDppAcqModeProperty(int32 aValue) throw (CannotSetValue) { - + CAENAdcController::refreshDppAcqModeProperty(aValue); m_dgtzDriver->dppAcqMode = aValue; boost::thread td(boost::bind(&CAENPsdController::initBoard, this)); } void CAENPsdController::refreshDisplayChannelProperty(int32 aChannel) throw (CannotSetValue) { + cout << "CAENPsdController::refreshDisplayChannelProperty : " << aChannel << endl; float64 holdOff = m_dgtzDriver->triggerHoldOff() / 1000.0; if (holdOff == 0) @@ -288,7 +291,6 @@ void CAENPsdController::initChannel(int32 aChannel) { } void CAENPsdController::clearData() { - commandProgression = 0; m_dgtzDriver.execute(caen_psd::CAENPsdDriver::CLEAR_COMMAND, true); commandProgression = 100; diff --git a/src/controllers/npp/CAENPsdController.h b/src/controllers/npp/CAENPsdController.h index a32d44a8..f18e6260 100644 --- a/src/controllers/npp/CAENPsdController.h +++ b/src/controllers/npp/CAENPsdController.h @@ -68,19 +68,23 @@ public: Property<float64>preGate; Property<int32>triggerValidationWindow; Property<int32>baselineMean; + void initBoard(); protected: DriverPtr<caen_psd::CAENPsdDriver> m_dgtzDriver; + virtual void refreshNbChannelsProperty(int32 aValue) throw (CannotSetValue); + virtual void refreshDisplayChannelProperty(int32 aValue) throw (CannotSetValue); + virtual void refreshDppAcqModeProperty(int32 aValue) throw (CannotSetValue); + virtual void refreshPulsePolarityProperty(int32 aValue) throw (CannotSetValue); + virtual void updateBoardProperties(); + private: - void updateRecordLengthProperty(); + virtual void refreshChannelActiveProperty(int32 aValue) throw (CannotSetValue); - void refreshRecordLengthProperty(int32 aValue) throw (CannotSetValue); - void refreshNbChannelsProperty(int32 aValue) throw (CannotSetValue); - void refreshDppAcqModeProperty(int32 aValue) throw (CannotSetValue); - void refreshDisplayChannelProperty(int32 aValue) throw (CannotSetValue); + virtual void refreshRecordLengthProperty(int32 aValue) throw (CannotSetValue); void refreshTriggerHoldOffProperty(float64 aValue) throw (CannotSetValue); void refreshTriggerThresholdProperty(int32 aValue) throw (CannotSetValue); void refreshSelfTriggerProperty(int32 aValue) throw (CannotSetValue); @@ -89,18 +93,12 @@ private: void refreshLongGateProperty(float64 aValue) throw (CannotSetValue); void refreshPreGateProperty(float64 aValue) throw (CannotSetValue); void refreshBaselineMean(int32 aValue) throw (CannotSetValue); - void refreshChannelActiveProperty(int32 aValue) throw (CannotSetValue); void refreshDcOffsetProperty(int32 aValue) throw (CannotSetValue); void refreshPreTriggerProperty(int32 aValue) throw (CannotSetValue); - void refreshPulsePolarityProperty(int32 aValue) throw (CannotSetValue); - - void updateBoardProperties(); - void updateCurveProperties(); virtual void clearData(); - void writeParam(); - void initBoard(); - void initChannel(int32 aChannel); + virtual void writeParam(); + virtual void initChannel(int32 aChannel); }; } diff --git a/src/controllers/npp/DPPAcquisitionController.cpp b/src/controllers/npp/DPPAcquisitionController.cpp index 2da1cd77..14cfee49 100644 --- a/src/controllers/npp/DPPAcquisitionController.cpp +++ b/src/controllers/npp/DPPAcquisitionController.cpp @@ -18,9 +18,11 @@ #include "DPPAcquisitionController.h" #include "controllers/common/family/Families.h" +#include <lstdpp/lstdpp.h> using namespace std; using namespace acquisition; +using namespace lstdpp; namespace npp { @@ -77,14 +79,14 @@ void DPPAcquisitionController::postConfiguration() { TimeAcquisitionController::postConfiguration(); // Copy local ptr for setting the write type cast - m_dppDriver.resize(m_nRegisteredDrivers); + dppDriver.resize(m_nRegisteredDrivers); for (int32 i = 0; i < m_nRegisteredDrivers; ++i) { - m_dppDriver[i].copy(m_Drivers[i]); - registerUpdater(m_dppDriver[i]->curve0, &DPPAcquisitionController::updateCurve0ArrayProperty, this, i); - registerUpdater(m_dppDriver[i]->curve1, &DPPAcquisitionController::updateCurve1ArrayProperty, this, i); - registerUpdater(m_dppDriver[i]->curve2, &DPPAcquisitionController::updateCurve2ArrayProperty, this, i); - registerUpdater(m_dppDriver[i]->curve3, &DPPAcquisitionController::updateCurve3ArrayProperty, this, i); - registerUpdater(m_dppDriver[i]->curve4, &DPPAcquisitionController::updateCurve4ArrayProperty, this, i); + dppDriver[i].copy(m_Drivers[i]); + registerUpdater(dppDriver[i]->curve0, &DPPAcquisitionController::updateCurve0ArrayProperty, this, i); + registerUpdater(dppDriver[i]->curve1, &DPPAcquisitionController::updateCurve1ArrayProperty, this, i); + registerUpdater(dppDriver[i]->curve2, &DPPAcquisitionController::updateCurve2ArrayProperty, this, i); + registerUpdater(dppDriver[i]->curve3, &DPPAcquisitionController::updateCurve3ArrayProperty, this, i); + registerUpdater(dppDriver[i]->curve4, &DPPAcquisitionController::updateCurve4ArrayProperty, this, i); } registerRefresher(useListMode, &DPPAcquisitionController::refreshUseListModeProperty, this); @@ -92,14 +94,15 @@ void DPPAcquisitionController::postConfiguration() { registerRefresher(nbBits, &DPPAcquisitionController::refreshNbBitsProperty, this); for (int32 i = 0; i < nbAdcControllers(); ++i) { - registerUpdater(m_adcController[i]->dppAcqMode, &DPPAcquisitionController::updateUseScopeProperty, this, i); - registerUpdater(m_adcController[i]->displayChannel, &DPPAcquisitionController::updateUseScopeProperty, this, i); - registerUpdater(m_adcController[i]->channels, &DPPAcquisitionController::setChannelsPerBoard, this); - registerUpdater(m_adcController[i]->recordLength, &DPPAcquisitionController::updateRecordLengthProperty, this, i); + registerUpdater(adcController[i]->dppAcqMode, &DPPAcquisitionController::updateUseScopeProperty, this, i); + registerUpdater(adcController[i]->displayChannel, &DPPAcquisitionController::updateUseScopeProperty, this, i); + registerUpdater(adcController[i]->channels, &DPPAcquisitionController::setChannelsPerBoard, this); + registerUpdater(adcController[i]->recordLength, &DPPAcquisitionController::updateRecordLengthProperty, this, i); } setChannelsPerBoard(); setScopeMode(); + setCrateNumber(); registerRefresher(liveProcessType, &DPPAcquisitionController::refreshLiveProcessTypeProperty, this); } @@ -123,11 +126,11 @@ void DPPAcquisitionController::refreshNbAdcControllersProperty(int32 aValue) thr if (aValue == nbAdcControllers()) { return; } - m_adcController.resize(aValue); + adcController.resize(aValue); for (int32 i = 0; i < aValue; ++i) { string controllerName = "adc_controller" + lexical_cast<string>(i + 1); - m_adcController[i].init(this, controllerName); + adcController[i].init(this, controllerName); } } @@ -136,9 +139,9 @@ void DPPAcquisitionController::refreshNbAdcControllersProperty(int32 aValue) thr * updateRecordLengthProperty */ void DPPAcquisitionController::updateRecordLengthProperty(int32 index) { - int32 rencordlength = m_adcController[index]->recordLength(); + int32 rencordlength = adcController[index]->recordLength(); for (int32 i = 0; i < m_nRegisteredDrivers; ++i) { - m_dppDriver[i]->recordLength = rencordlength; + dppDriver[i]->recordLength = rencordlength; } } @@ -148,9 +151,9 @@ void DPPAcquisitionController::updateRecordLengthProperty(int32 index) { void DPPAcquisitionController::updateCurve0ArrayProperty(int32 index) { for (int32 adc = 0; adc < nbAdcControllers(); ++adc) { - m_adcController[adc]->curve0.update(m_dppDriver[index]->curve0()); - m_adcController[adc]->curve0.setSize(m_dppDriver[index]->curve0.getSize()); - m_adcController[adc]->curve0.sendEvent(); + adcController[adc]->curve0.update(dppDriver[index]->curve0()); + adcController[adc]->curve0.setSize(dppDriver[index]->curve0.getSize()); + adcController[adc]->curve0.sendEvent(); } } @@ -160,9 +163,9 @@ void DPPAcquisitionController::updateCurve0ArrayProperty(int32 index) { void DPPAcquisitionController::updateCurve1ArrayProperty(int32 index) { for (int32 adc = 0; adc < nbAdcControllers(); ++adc) { - m_adcController[adc]->curve1.update(m_dppDriver[index]->curve1()); - m_adcController[adc]->curve1.setSize(m_dppDriver[index]->curve1.getSize()); - m_adcController[adc]->curve1.sendEvent(); + adcController[adc]->curve1.update(dppDriver[index]->curve1()); + adcController[adc]->curve1.setSize(dppDriver[index]->curve1.getSize()); + adcController[adc]->curve1.sendEvent(); } } @@ -172,9 +175,9 @@ void DPPAcquisitionController::updateCurve1ArrayProperty(int32 index) { void DPPAcquisitionController::updateCurve2ArrayProperty(int32 index) { for (int32 adc = 0; adc < nbAdcControllers(); ++adc) { - m_adcController[adc]->curve2.update(m_dppDriver[index]->curve2()); - m_adcController[adc]->curve2.setSize(m_dppDriver[index]->curve2.getSize()); - m_adcController[adc]->curve2.sendEvent(); + adcController[adc]->curve2.update(dppDriver[index]->curve2()); + adcController[adc]->curve2.setSize(dppDriver[index]->curve2.getSize()); + adcController[adc]->curve2.sendEvent(); } } @@ -184,9 +187,9 @@ void DPPAcquisitionController::updateCurve2ArrayProperty(int32 index) { void DPPAcquisitionController::updateCurve3ArrayProperty(int32 index) { for (int32 adc = 0; adc < nbAdcControllers(); ++adc) { - m_adcController[adc]->curve3.update(m_dppDriver[index]->curve3()); - m_adcController[adc]->curve3.setSize(m_dppDriver[index]->curve3.getSize()); - m_adcController[adc]->curve3.sendEvent(); + adcController[adc]->curve3.update(dppDriver[index]->curve3()); + adcController[adc]->curve3.setSize(dppDriver[index]->curve3.getSize()); + adcController[adc]->curve3.sendEvent(); } } @@ -196,9 +199,9 @@ void DPPAcquisitionController::updateCurve3ArrayProperty(int32 index) { void DPPAcquisitionController::updateCurve4ArrayProperty(int32 index) { for (int32 adc = 0; adc < nbAdcControllers(); ++adc) { - m_adcController[adc]->curve4.update(m_dppDriver[index]->curve4()); - m_adcController[adc]->curve4.setSize(m_dppDriver[index]->curve4.getSize()); - m_adcController[adc]->curve4.sendEvent(); + adcController[adc]->curve4.update(dppDriver[index]->curve4()); + adcController[adc]->curve4.setSize(dppDriver[index]->curve4.getSize()); + adcController[adc]->curve4.sendEvent(); } } @@ -208,36 +211,36 @@ void DPPAcquisitionController::updateCurve4ArrayProperty(int32 index) { void DPPAcquisitionController::updateUseScopeProperty(int32 index) { int32 boardChannel = 0; - int32 aValue = m_adcController[index]->dppAcqMode(); + int32 aValue = adcController[index]->dppAcqMode(); - switch (aValue) { - case 0: + if (aValue == acquisition::DPPAcquisitionCommon::SCOPE_MODE) { for (int32 i=0; i<nbAdcControllers(); ++i) { if (i != index) { - m_adcController[i]->dppAcqMode = acquisition::DPPAcquisitionCommon::LISTMODE_MODE; + adcController[i]->dppAcqMode = acquisition::DPPAcquisitionCommon::LISTMODE_MODE; } } useScope = 1; useScopeStr = "Active"; for (int32 i=0; i<index; ++i) { - boardChannel += m_adcController[i]->channels(); + boardChannel += adcController[i]->channels(); } - boardChannel += m_adcController[index]->displayChannel(); + boardChannel += adcController[index]->displayChannel(); useListMode = 0; usePn1Coincidence = 0; - break; - case 1: + } + else if (aValue == acquisition::DPPAcquisitionCommon::LISTMODE_MODE) { useScope = 0; useScopeStr = "Inactive"; - break; } scopeChannel = boardChannel; - int32 board = m_adcController[index]->acqBoardIndex(); - m_dppDriver[board]->useScope = useScope(); - m_dppDriver[board]->scopeChannel = boardChannel; - m_dppDriver[board]->useListMode = useListMode(); - m_dppDriver[board]->usePn1Coincidence = usePn1Coincidence(); + int32 board = adcController[index]->acqBoardIndex(); + dppDriver[board]->useScope = useScope(); + dppDriver[board]->scopeChannel = boardChannel; + dppDriver[board]->scopeCardActivated = adcController[index]->modelName(); + dppDriver[board]->recordLength = adcController[index]->recordLength(); + dppDriver[board]->useListMode = useListMode(); + dppDriver[board]->usePn1Coincidence = usePn1Coincidence(); } /* @@ -246,12 +249,12 @@ void DPPAcquisitionController::updateUseScopeProperty(int32 index) { void DPPAcquisitionController::refreshUseListModeProperty(int32 aValue) throw (CannotSetValue) { for (int32 board=0; board<nDrivers(); ++board) { - m_dppDriver[board]->useListMode = aValue; + dppDriver[board]->useListMode = aValue; } if (aValue == 1) { for (int32 adc = 0; adc < nbAdcControllers(); ++adc) { - m_adcController[adc]->dppAcqMode = acquisition::DPPAcquisitionCommon::LISTMODE_MODE; + adcController[adc]->dppAcqMode = acquisition::DPPAcquisitionCommon::LISTMODE_MODE; } } } @@ -262,13 +265,13 @@ void DPPAcquisitionController::refreshUseListModeProperty(int32 aValue) throw (C void DPPAcquisitionController::refreshUsePn1CoincidenceModeProperty(int32 aValue) throw (CannotSetValue) { for (int32 board=0; board<nDrivers(); ++board) { - m_dppDriver[board]->usePn1Coincidence = aValue; - m_dppDriver[board]->gateWidth = gateWidth(); + dppDriver[board]->usePn1Coincidence = aValue; + dppDriver[board]->gateWidth = gateWidth(); } if (aValue == 1) { for (int32 adc = 0; adc < nbAdcControllers(); ++adc) { - m_adcController[adc]->dppAcqMode = acquisition::DPPAcquisitionCommon::LISTMODE_MODE; + adcController[adc]->dppAcqMode = acquisition::DPPAcquisitionCommon::LISTMODE_MODE; } } } @@ -279,7 +282,7 @@ void DPPAcquisitionController::refreshUsePn1CoincidenceModeProperty(int32 aValue void DPPAcquisitionController::refreshNbBitsProperty(int32 aValue) throw (CannotSetValue) { for (int32 i = 0; i < m_nRegisteredDrivers; ++i) { - m_dppDriver[i]->nbBits = aValue; + dppDriver[i]->nbBits = aValue; } } @@ -305,7 +308,9 @@ void DPPAcquisitionController::refreshLiveProcessTypeProperty(const std::string& */ void DPPAcquisitionController::resize() throw (CannotOpenFile, SlicesFileError, TooManySlices, SliceTooBig) { + cout << "resolution = " << nbBits() << endl; int32 resolution = (int32) pow(2.0, nbBits()); + cout << "resolution = " <<resolution<< endl; m_Detector->setDataSize(resolution, 1); } @@ -325,7 +330,7 @@ void DPPAcquisitionController::writeParams() { Parallel::begin(); for (int32 adc = 0; adc < nbAdcControllers(); ++adc) { - m_adcController[adc]->clearDataParallel(); + adcController[adc]->clearDataParallel(); } Parallel::end(); @@ -333,20 +338,19 @@ void DPPAcquisitionController::writeParams() { Parallel::begin(); for (int32 i = 0; i < nDrivers(); ++i) { - m_dppDriver[i]->wantedMode = m_AcquisitionMode; - m_dppDriver[i]->boardIndex = i; - m_dppDriver[i]->nbBits = nbBits(); - m_dppDriver[i]->nbChannels = channelsPerBoard.get(i); - m_dppDriver[i]->scopeChannel = scopeChannel(); - m_dppDriver[i]->gateWidth = gateWidth(); - m_dppDriver[i]->usePn1Coincidence = usePn1Coincidence(); - m_dppDriver[i]->useListMode = useListMode(); - m_dppDriver[i]->useScope = useScope(); + dppDriver[i]->wantedMode = m_AcquisitionMode; + dppDriver[i]->nbBits = nbBits(); + dppDriver[i]->nbChannels = channelsPerBoard.get(i); + dppDriver[i]->scopeChannel = scopeChannel(); + dppDriver[i]->gateWidth = gateWidth(); + dppDriver[i]->usePn1Coincidence = usePn1Coincidence(); + dppDriver[i]->useListMode = useListMode(); + dppDriver[i]->useScope = useScope(); /* * Execute the write param command */ - m_dppDriver[i].executeParallel(AcquisitionCommon::WRITE_PARAMETERS_COMMAND); + dppDriver[i].executeParallel(AcquisitionCommon::WRITE_PARAMETERS_COMMAND); } Parallel::end(); @@ -354,7 +358,7 @@ void DPPAcquisitionController::writeParams() { * Execute the write param command */ for (int32 i = 0; i < nDrivers(); ++i) { - m_dppDriver[i].execute(AcquisitionCommon::LIST_MODE_COMMAND, false, true); + dppDriver[i].execute(AcquisitionCommon::LIST_MODE_COMMAND, false, true); } // starting DPPCoincidence @@ -363,6 +367,9 @@ void DPPAcquisitionController::writeParams() { m_liveProcessController->numberOfADCs = totalAdc; m_liveProcessController->numberOfChannels = (1 << nbBits()); + // set the lst context + setContext(); + // start the process in parallel to avoid blocking m_liveProcessController->startParallel(); @@ -401,7 +408,7 @@ void DPPAcquisitionController::setScopeMode() { int32 index = 0; for (int32 board=0; board<nDrivers(); ++board) { for (int32 adc = 0; adc < nbAdcControllers(); ++adc) { - if (m_adcController[adc]->dppAcqMode() == acquisition::DPPAcquisitionCommon::SCOPE_MODE) { + if (adcController[adc]->dppAcqMode() == acquisition::DPPAcquisitionCommon::SCOPE_MODE) { index = adc; scope = 1; useScopeStr = "Active"; @@ -411,15 +418,17 @@ void DPPAcquisitionController::setScopeMode() { } if (scope == 1) { for (int32 i=0; i<index; ++i) { - boardChannel += m_adcController[i]->channels(); + boardChannel += adcController[i]->channels(); } - boardChannel += m_adcController[index]->displayChannel(); + boardChannel += adcController[index]->displayChannel(); scopeChannel = boardChannel; } - m_dppDriver[board]->useScope = scope; - m_dppDriver[board]->scopeChannel = boardChannel; - m_dppDriver[board]->scopeCardActivated = m_adcController[index]->modelName(); - m_dppDriver[board]->recordLength = m_adcController[index]->recordLength(); + dppDriver[board]->useScope = scope; + dppDriver[board]->scopeChannel = boardChannel; + dppDriver[board]->scopeCardActivated = adcController[index]->modelName(); + dppDriver[board]->recordLength = adcController[index]->recordLength(); + dppDriver[board]->useListMode = useListMode(); + dppDriver[board]->usePn1Coincidence = usePn1Coincidence(); } useScope = scope; } @@ -429,14 +438,67 @@ void DPPAcquisitionController::setChannelsPerBoard() { for (int32 board=0; board<nDrivers(); ++board) { int32 totalChannels = 0; for (int32 adc = 0; adc < nbAdcControllers(); ++adc) { - if (m_adcController[adc]->acqBoardIndex() == board) { - totalChannels += m_adcController[adc]->channels(); + if (adcController[adc]->acqBoardIndex() == board) { + totalChannels += adcController[adc]->channels(); } } boardIndex.set(board, board); channelsPerBoard.set(board, totalChannels); - m_dppDriver[board]->nbChannels = totalChannels; + dppDriver[board]->nbChannels = totalChannels; + } +} + +void DPPAcquisitionController::setCrateNumber() { + for (int32 board=0; board<nDrivers(); ++board) { + for (int32 adc = 0; adc < nbAdcControllers(); ++adc) { + if (adcController[adc]->acqBoardIndex() == board) { + adcController[adc]->crateNumber = dppDriver[board]->crateNumber(); + } + } + } +} + +/** + * Warning: we suppose that the list mode block is ordered like the ADC controllers + */ +void DPPAcquisitionController::setContext() { + + releaseListModeContext(listModeContext); + + int32 nbCrates = 0; + + for (int32 adc = 0; adc < nbAdcControllers(); ++adc) { + int32 crate = adcController[adc]->crateNumber(); + if (crate >= nbCrates) { + nbCrates = crate + 1; + } + } + + listModeContext.crateBoard.nbCrates = nbCrates; + listModeContext.crateBoard.crates = new Crate[nbCrates]; + + for (int32 crate = 0; crate < nbCrates; ++crate) { + int32 nbBoards = 0; + + for (int32 board = 0; board < nbAdcControllers(); ++board) { + if (board >= nbBoards) { + nbBoards = board + 1; + } + } + + listModeContext.crateBoard.crates[crate].nbBoards = nbBoards; + listModeContext.crateBoard.crates[crate].boards = new Board[nbBoards]; + + for (int32 board = 0; board < nbAdcControllers(); ++board) { + listModeContext.crateBoard.crates[0].boards[board].boardType = (BoardType)adcController[board]->cardType(); + listModeContext.crateBoard.crates[0].boards[board].crate = crate; + listModeContext.crateBoard.crates[0].boards[board].eventType = 0; + listModeContext.crateBoard.crates[0].boards[board].nbChannels = adcController[board]->nbChannels(); + } } + + cout << "context before live process" << endl; + cout << listModeContext << endl; } } diff --git a/src/controllers/npp/DPPAcquisitionController.h b/src/controllers/npp/DPPAcquisitionController.h index 2df501f1..556ec6d2 100644 --- a/src/controllers/npp/DPPAcquisitionController.h +++ b/src/controllers/npp/DPPAcquisitionController.h @@ -105,11 +105,10 @@ public: static const std::string HISTOGRAM_PROCESS; static const std::string COINCIDENCE_PROCESS; -private: - - std::vector<DriverPtr<acquisition::DPPAcquisitionCommon> > m_dppDriver; - std::vector<ControllerPtr<CAENAdcController> > m_adcController; + std::vector<DriverPtr<acquisition::DPPAcquisitionCommon> > dppDriver; + std::vector<ControllerPtr<CAENAdcController> > adcController; +private: virtual void refreshNDriversProperty(int32 aValue) throw (CannotSetValue); void updateCurve0ArrayProperty(int32 index); @@ -140,6 +139,8 @@ private: void setScopeMode(); void setChannelsPerBoard(); + void setCrateNumber(); + void setContext(); ControllerPtr<DPPLiveProcess> m_histogramController; ControllerPtr<DPPLiveProcess> m_coincidenceController; diff --git a/src/controllers/npp/DPPLiveProcessCountRelay.cpp b/src/controllers/npp/DPPLiveProcessCountRelay.cpp index 00f7ba1d..1de5d028 100644 --- a/src/controllers/npp/DPPLiveProcessCountRelay.cpp +++ b/src/controllers/npp/DPPLiveProcessCountRelay.cpp @@ -41,8 +41,8 @@ void DPPLiveProcessCountRelay::postConfiguration() { registerUpdater(m_count->numor, &DPPLiveProcessCountRelay::updateNumor, this); registerProgression(m_count, &DPPLiveProcessCountRelay::updateProgression, this); - m_histogramController->setDetectorControllers(m_count->m_DetectorControllers); - m_coincidenceController->setDetectorControllers(m_count->m_DetectorControllers); + m_histogramController->setDetectorControllers(m_count->detectorControllers); + m_coincidenceController->setDetectorControllers(m_count->detectorControllers); } void DPPLiveProcessCountRelay::updateNumor() { diff --git a/src/controllers/npp/Module.xml b/src/controllers/npp/Module.xml index 3ea59653..b21d76f7 100644 --- a/src/controllers/npp/Module.xml +++ b/src/controllers/npp/Module.xml @@ -1,10 +1,15 @@ <module name="npp_s"> + <controller class="npp::CAENCfdController"/> <controller class="npp::CAENPhaController"/> + <controller class="npp::CAENPksController"/> <controller class="npp::CAENPsdController"/> <controller class="npp::DPPAcquisitionController"/> <controller class="npp::DPPHistogram"/> <controller class="npp::DPPCoincidence"/> <controller class="npp::DPPLiveProcessCountRelay"/> + <controller class="npp::BidimHistoDetectorElement"/> <include path="$(NOMAD_HOME)/../NomadModules/src"/> + + <link path="/usr/local/lib" lib="lstdpp"/> </module> diff --git a/src/controllers/npp/gui/cfd_controler/cfd_controller.properties b/src/controllers/npp/gui/cfd_controler/cfd_controller.properties new file mode 100644 index 00000000..c3200f92 --- /dev/null +++ b/src/controllers/npp/gui/cfd_controler/cfd_controller.properties @@ -0,0 +1,152 @@ +# Board Params +cfd_controller.boardParamsTitle=Board Parameters +cfd_controller.nbChannels=Nb channels: +cfd_controller.acqMode=Acquisition mode: + +# Channel General Settings +cfd_controller.generalSettingsTitle=General Settings +cfd_controller.recordLength=Record length +cfd_controller.displayChannel=Channel +cfd_controller.channelEnabled=Channel enabled +cfd_controller.pulsePolarity=Pulse polarity +cfd_controller.dcOffset=DC offset +cfd_controller.enabledCheckedValue=1 +cfd_controller.enabledUncheckedValue=0 + +# Timing Filter +cfd_controller.selfTrigger=Self-trigger +cfd_controller.stenabledLabel=Enable +cfd_controller.stenabledValue=1 +cfd_controller.stdisableLabel=Disable +cfd_controller.stdisableValue=0 +cfd_controller.timingFilterTitle=Trigger and Timing Filter +cfd_controller.preTrigger=Pre-trigger +cfd_controller.threshold=Threshold +cfd_controller.triggerHoldOff=Trigger holdoff + +cfd_controller.charge_sensitivity=Charge sens. +cfd_controller.fcversuslsb=fc/LSB +cfd_controller.20csValue=0 +cfd_controller.20csLabel=20 +cfd_controller.40csValue=1 +cfd_controller.40csLabel=40 +cfd_controller.80csValue=2 +cfd_controller.80csLabel=80 +cfd_controller.160csValue=3 +cfd_controller.160csLabel=160 +cfd_controller.320csValue=4 +cfd_controller.320csLabel=320 +cfd_controller.640csValue=5 +cfd_controller.640csLabel=640 + +# Energy Filter +cfd_controller.energyFilterTitle=Energy Filter +cfd_controller.baselineMean=Baseline mean +cfd_controller.shortGate=Short gate +cfd_controller.longGate=Long gate +cfd_controller.preGate=Pre gate + +# Units +cfd_controller.lsbUnit=LSB +cfd_controller.uSecUnit=us + +# Combo polarity +cfd_controller.positiveValue=0 +cfd_controller.positiveLabel=Positive +cfd_controller.negativeValue=1 +cfd_controller.negativeLabel=Negative + +# Combo digital gain +cfd_controller.gain1Value=0 +cfd_controller.gain1Label=1 +cfd_controller.gain2Value=1 +cfd_controller.gain2Label=2 +cfd_controller.gain4Value=2 +cfd_controller.gain4Label=4 +cfd_controller.gain8Value=3 +cfd_controller.gain8Label=8 + +# Combo decimation +cfd_controller.dec0Value=0 +cfd_controller.dec0Label=0 +cfd_controller.dec2Value=1 +cfd_controller.dec2Label=2 +cfd_controller.dec4Value=2 +cfd_controller.dec4Label=4 +cfd_controller.dec8Value=3 +cfd_controller.dec8Label=8 + +# Combo trigger smoothing +cfd_controller.smooth1Value=1 +cfd_controller.smooth1Label=1 +cfd_controller.smooth2Value=2 +cfd_controller.smooth2Label=2 +cfd_controller.smooth4Value=4 +cfd_controller.smooth4Label=4 +cfd_controller.smooth8Value=8 +cfd_controller.smooth8Label=8 +cfd_controller.smooth16Value=16 +cfd_controller.smooth16Label=16 +cfd_controller.smooth32Value=32 +cfd_controller.smooth32Label=32 + +# Combo base mean +cfd_controller.base0Value=0 +cfd_controller.base0Label=Fixed +cfd_controller.base8Value=1 +cfd_controller.base8Label=8 +cfd_controller.base16Value=2 +cfd_controller.base16Label=16 +cfd_controller.base32Value=3 +cfd_controller.base32Label=32 +cfd_controller.base64Value=4 +cfd_controller.base64Label=64 +cfd_controller.base128Value=5 +cfd_controller.base128Label=128 +cfd_controller.base256Value=6 +cfd_controller.base256Label=256 +cfd_controller.base512Value=7 +cfd_controller.base512Label=512 + +# Combo peak mean +cfd_controller.peak1Value=0 +cfd_controller.peak1Label=1 +cfd_controller.peak4Value=1 +cfd_controller.peak4Label=4 +cfd_controller.peak16Value=2 +cfd_controller.peak16Label=16 +cfd_controller.peak64Value=3 +cfd_controller.peak64Label=64 + +# Combo acq mode +cfd_controller.oscilloscopeValue=0 +cfd_controller.oscilloscopeLabel=Oscilloscope +cfd_controller.histogramValue=1 +cfd_controller.histogramLabel=Histogram + +# Plot group +cfd_controller.histogranPlotTitle=Energy histogram +cfd_controller.inputPlotTitle=Signals +cfd_controller.histoPrefix=Histogram +cfd_controller.signalPrefix=Signals +cfd_controller.postTrigPrefix=Post trigger samples +cfd_controller.offsetPrefix=Input DC offset +cfd_controller.histogramLegend=Energy +cfd_controller.inputLegend=Input +cfd_controller.trapezoidLegend=Trapezoid +cfd_controller.triggerLegend=Trigger +cfd_controller.peakingLegend=Peaking +cfd_controller.percentSuffix=% +cfd_controller.pn1CoincidencePlotTitle=E-dE + +cfd_controller.cfdGlobalTitle=CFD global parameters +cfd_controller.channelOffset=Channel offset +cfd_controller.delay=Delay +cfd_controller.attenuation=Attenuation +cfd_controller.cfdEnergyTitle=CFD Energy parameters +cfd_controller.pulse_polarity=Pulse polarity +cfd_controller.trapezoid_rise=Trapezoid rise +cfd_controller.trapezoid_flat=Trapezoid flat +cfd_controller.decay_time=Decay time +cfd_controller.peaking=Peaking +cfd_controller.bitShift=Bit shift \ No newline at end of file diff --git a/src/controllers/npp/gui/cfd_controler/cfd_controllerPlotDatas.xml b/src/controllers/npp/gui/cfd_controler/cfd_controllerPlotDatas.xml new file mode 100644 index 00000000..3c8b5fb3 --- /dev/null +++ b/src/controllers/npp/gui/cfd_controler/cfd_controllerPlotDatas.xml @@ -0,0 +1,23 @@ +<plotdatas> + + <plotdata key="cfd_histogram_plot" legend_key="cfd_controller.histogramLegend" color="FFFFFF" plugins="SETUP"> + <dataY p_role="cfd_controller1" p_name="curve0_table"/> + </plotdata> + + <plotdata key="cfd_input_plot" legend_key="cfd_controller.inputLegend" color="F60B0B" plugins="SETUP"> + <dataY p_role="cfd_controller1" p_name="curve1_table"/> + </plotdata> + + <plotdata key="cfd_trapezoid_plot" legend_key="cfd_controller.trapezoidLegend" color="0DC93D" plugins="SETUP"> + <dataY p_role="cfd_controller1" p_name="curve2_table"/> + </plotdata> + + <plotdata key="cfd_trigger_plot" legend_key="cfd_controller.triggerLegend" color="FFFD18" plugins="SETUP"> + <dataY p_role="cfd_controller1" p_name="curve3_table"/> + </plotdata> + + <plotdata key="cfd_peaking_plot" legend_key="cfd_controller.peakingLegend" color="18F0FF" plugins="SETUP"> + <dataY p_role="cfd_controller1" p_name="curve4_table"/> + </plotdata> + +</plotdatas> \ No newline at end of file diff --git a/src/controllers/npp/gui/cfd_controler/cfd_controllerPlugin.xml b/src/controllers/npp/gui/cfd_controler/cfd_controllerPlugin.xml new file mode 100644 index 00000000..0e16b7e8 --- /dev/null +++ b/src/controllers/npp/gui/cfd_controler/cfd_controllerPlugin.xml @@ -0,0 +1,7 @@ +<controller_plugin_config type="cfd_controller"> + + <image key="HARDWARE_VME_MODULE"/> + + <settings view="cfd_controllerView.xml"/> + +</controller_plugin_config> diff --git a/src/controllers/npp/gui/cfd_controler/cfd_controllerProperties.xml b/src/controllers/npp/gui/cfd_controler/cfd_controllerProperties.xml new file mode 100644 index 00000000..3bb0f720 --- /dev/null +++ b/src/controllers/npp/gui/cfd_controler/cfd_controllerProperties.xml @@ -0,0 +1,102 @@ +<?xml version="1.0" encoding="ISO-8859-1" ?> + +<controller type="cfd_controller"> + + <property name="nb_channels" type="int32" max_length="2"> + <strictly_positive/> + </property> + + <property name="display_channel" type="int32" max_length="3"> + <property_range min_property="min_range" max_property="max_range"/> + </property> + + <property name="channel_offset" type="int32" max_length="3"> + </property> + + <property name="record_length" type="int32" max_length="6"> + </property> + +<!-- <property name="trigger_holdoff" type="float64" max_length="6"> --> +<!-- <decimal_format nb_decimal_places="2"/> --> +<!-- <strictly_positive/> --> +<!-- </property> --> + +<!-- <property name="trigger_threshold" type="int32" max_length="3"> --> +<!-- <strictly_positive/> --> +<!-- </property> --> + +<!-- <property name="self_trigger" type="int32"> --> +<!-- </property> --> + +<!-- <property name="charge_sensitivity" type="int32"> --> +<!-- </property> --> + +<!-- <property name="short_gate" type="float64" max_length="6"> --> +<!-- <decimal_format nb_decimal_places="2"/> --> +<!-- <strictly_positive/> --> +<!-- </property> --> + +<!-- <property name="long_gate" type="float64" max_length="6"> --> +<!-- <decimal_format nb_decimal_places="2"/> --> +<!-- <strictly_positive/> --> +<!-- </property> --> + +<!-- <property name="pre_gate" type="float64" max_length="6"> --> +<!-- <decimal_format nb_decimal_places="2"/> --> +<!-- <strictly_positive/> --> +<!-- </property> --> + + <property name="trigger_validation" type="int32"> + </property> + +<!-- <property name="base_mean" type="int32"> --> +<!-- </property> --> + + <property name="channel_active" type="int32"> + </property> + + <property name="pre_trigger" type="int32" max_length="4"> + <strictly_positive/> + </property> + + <property name="delay" type="int32"> + </property> + + <property name="attenuation" type="int32"> + </property> + + <property name="pulse_polarity" type="int32"> + </property> + + <property name="trapezoid_rise" type="int32"> + </property> + + <property name="trapezoid_flat" type="int32"> + </property> + + <property name="decay_time" type="int32"> + </property> + + <property name="peaking" type="int32"> + </property> + + <property name="bit_shift" type="int32"> + </property> + + <!-- OSCILLOSCOPE CURVES --> + <property name="curve0_table" type="longarray"> + </property> + + <property name="curve1_table" type="longarray"> + </property> + + <property name="curve2_table" type="longarray"> + </property> + + <property name="curve3_table" type="longarray"> + </property> + + <property name="curve4_table" type="longarray"> + </property> + +</controller> diff --git a/src/controllers/npp/gui/cfd_controler/cfd_controllerView.xml b/src/controllers/npp/gui/cfd_controler/cfd_controllerView.xml new file mode 100644 index 00000000..48ec4eda --- /dev/null +++ b/src/controllers/npp/gui/cfd_controler/cfd_controllerView.xml @@ -0,0 +1,81 @@ +<plugin> + <controller type="cfd_controller" role="cfd_controller1"/> + + <property_switcher role="cfd_controller1" property="dpp_acq_mode" switcher_key="useScopeSwitcher"/> + <group title="cfd_controller.boardParamsTitle"> + <text role="cfd_controller1" property="nb_channels" prefix="cfd_controller.nbChannels"/> + <newLine/> + <combo role="cfd_controller1" property="dpp_acq_mode" prefix="cfd_controller.acqMode" valuesAndLabels="cfd_controller.oscilloscope,cfd_controller.histogram"/> + <switchable_composite switcher_key="useScopeSwitcher" switch_values="0"> + <simple_label prefix="cfd_controller.recordLength"/> + <text role="cfd_controller1" property="record_length"/> + <plot_launcher role="cfd_controller1" data="cfd_input_plot,cfd_trapezoid_plot,cfd_trigger_plot,cfd_peaking_plot" title="cfd_controller.inputPlotTitle" height="20"/> + </switchable_composite> + </group> + + <newLine/> + <group title="cfd_controller.generalSettingsTitle"> + <table_composite nbColumns="4"> + <simple_label prefix="cfd_controller.displayChannel"/> + <text role="cfd_controller1" property="display_channel"/> + <simple_label prefix="cfd_controller.channelEnabled"/> + <check role="cfd_controller1" property="channel_active" checkBoxValues="cfd_controller.enabled"/> + <simple_label prefix="cfd_controller.pulsePolarity"/> + <combo role="cfd_controller1" property="pulse_polarity" valuesAndLabels="cfd_controller.positive,cfd_controller.negative"/> + </table_composite> + </group> + <newLine/> +<!-- <composite alignment="top_left"> --> +<!-- <group title="cfd_controller.timingFilterTitle" alignment="top_left"> --> +<!-- <table_composite nbColumns="2"> --> +<!-- <simple_label prefix="cfd_controller.selfTrigger"/> --> +<!-- <combo role="cfd_controller1" property="self_trigger" valuesAndLabels="cfd_controller.stenabled,cfd_controller.stdisable"/> --> +<!-- <simple_label prefix="cfd_controller.preTrigger"/> --> +<!-- <text role="cfd_controller1" property="pre_trigger"/> --> +<!-- <simple_label prefix="cfd_controller.charge_sensitivity"/> --> +<!-- <combo role="cfd_controller1" property="charge_sensitivity" valuesAndLabels="cfd_controller.20cs,cfd_controller.40cs,cfd_controller.80cs,cfd_controller.160cs,cfd_controller.320cs,cfd_controller.640cs" suffix="cfd_controller.fcversuslsb"/> --> +<!-- <simple_label prefix="cfd_controller.baselineMean"/> --> +<!-- <combo role="cfd_controller1" property="base_mean" valuesAndLabels="cfd_controller.base0,cfd_controller.base8,cfd_controller.base16,cfd_controller.base32,cfd_controller.base64,cfd_controller.base128,cfd_controller.base256,cfd_controller.base512"/> --> +<!-- <simple_label prefix="cfd_controller.triggerHoldOff"/> --> +<!-- <text role="cfd_controller1" property="trigger_holdoff" suffix="cfd_controller.uSecUnit"/> --> +<!-- </table_composite> --> +<!-- </group> --> +<!-- <group title="cfd_controller.energyFilterTitle" alignment="top_left"> --> +<!-- <table_composite nbColumns="2"> --> +<!-- <simple_label prefix="cfd_controller.threshold"/> --> +<!-- <text role="cfd_controller1" property="trigger_threshold" suffix="cfd_controller.lsbUnit"/> --> +<!-- <simple_label prefix="cfd_controller.shortGate"/> --> +<!-- <text role="cfd_controller1" property="short_gate" suffix="cfd_controller.uSecUnit"/> --> +<!-- <simple_label prefix="cfd_controller.longGate"/> --> +<!-- <text role="cfd_controller1" property="long_gate" suffix="cfd_controller.uSecUnit"/> --> +<!-- <simple_label prefix="cfd_controller.preGate"/> --> +<!-- <text role="cfd_controller1" property="pre_gate" suffix="cfd_controller.uSecUnit"/> --> +<!-- </table_composite> --> +<!-- </group> --> + <newLine/> + <group title="cfd_controller.cfdGlobalTitle" alignment="top_left"> + <table_composite nbColumns="2"> + <simple_label prefix="cfd_controller.channelOffset"/> + <text role="cfd_controller1" property="channel_offset"/> + <simple_label prefix="cfd_controller.delay"/> + <text role="cfd_controller1" property="delay"/> + <simple_label prefix="cfd_controller.attenuation"/> + <text role="cfd_controller1" property="attenuation"/> + </table_composite> + </group> + <group title="cfd_controller.cfdEnergyTitle" alignment="top_left"> + <table_composite nbColumns="2"> + <simple_label prefix="cfd_controller.trapezoid_rise"/> + <text role="cfd_controller1" property="trapezoid_rise"/> + <simple_label prefix="cfd_controller.trapezoid_flat"/> + <text role="cfd_controller1" property="trapezoid_flat"/> + <simple_label prefix="cfd_controller.decay_time"/> + <text role="cfd_controller1" property="decay_time"/> + <simple_label prefix="cfd_controller.peaking"/> + <text role="cfd_controller1" property="peaking"/> + <simple_label prefix="cfd_controller.bitShift"/> + <text role="cfd_controller1" property="bit_shift"/> + </table_composite> + </group> + </composite> +</plugin> diff --git a/src/controllers/npp/gui/dpp_coincidence/dpp_coincidenceView.xml b/src/controllers/npp/gui/dpp_coincidence/dpp_coincidenceView.xml index 38147403..b1d7e214 100644 --- a/src/controllers/npp/gui/dpp_coincidence/dpp_coincidenceView.xml +++ b/src/controllers/npp/gui/dpp_coincidence/dpp_coincidenceView.xml @@ -43,13 +43,16 @@ <summary> <summary_content> - <label role="dpp_coincidence1" property="global_rate.0" prefix="dpp_coincidence.global_rate" suffix="dpp_coincidence.rate_unit"/> - <newLine/> - <label role="dpp_coincidence1" property="global_clean_rate.0" prefix="dpp_coincidence.global_clean_rate" suffix="dpp_coincidence.rate_unit"/> - <newLine/> - <label role="dpp_coincidence1" property="detector_rate.0" prefix="dpp_coincidence.detector_rate" suffix="dpp_coincidence.rate_unit"/> - <newLine/> - <label role="dpp_coincidence1" property="detector_clean_rate.0" prefix="dpp_coincidence.detector_clean_rate" suffix="dpp_coincidence.rate_unit"/> + <table_composite nbColumns="2"> + <simple_label prefix="dpp_coincidence.global_rate"/> + <label role="dpp_coincidence1" property="global_rate.0" suffix="dpp_coincidence.rate_unit"/> + <simple_label prefix="dpp_coincidence.global_clean_rate"/> + <label role="dpp_coincidence1" property="global_clean_rate.0" suffix="dpp_coincidence.rate_unit"/> + <simple_label prefix="dpp_coincidence.detector_rate"/> + <label role="dpp_coincidence1" property="detector_rate.0" suffix="dpp_coincidence.rate_unit"/> + <simple_label prefix="dpp_coincidence.detector_clean_rate"/> + <label role="dpp_coincidence1" property="detector_clean_rate.0" suffix="dpp_coincidence.rate_unit"/> + </table_composite> </summary_content> </summary> diff --git a/src/controllers/npp/gui/pha_controller/pha_controllerView.xml b/src/controllers/npp/gui/pha_controller/pha_controllerView.xml index 8f28a2a3..b7c21e5d 100644 --- a/src/controllers/npp/gui/pha_controller/pha_controllerView.xml +++ b/src/controllers/npp/gui/pha_controller/pha_controllerView.xml @@ -9,7 +9,6 @@ <combo role="pha_controller1" property="dpp_acq_mode" prefix="pha_controller.acqMode" valuesAndLabels="pha_controller.oscilloscope,pha_controller.histogram"/> <switchable_composite switcher_key="useScopeSwitcher" switch_values="0"> <text role="pha_controller1" property="record_length" prefix="pha_controller.recordLength"/> - <newLine/> <plot_launcher role="pha_controller1" data="pha_input_plot,pha_trapezoid_plot,pha_trigger_plot,pha_peaking_plot" title="pha_controller.inputPlotTitle" height="20"/> </switchable_composite> </group> diff --git a/src/controllers/npp/gui/pks_controller/pks_controller.properties b/src/controllers/npp/gui/pks_controller/pks_controller.properties new file mode 100644 index 00000000..ea33bc76 --- /dev/null +++ b/src/controllers/npp/gui/pks_controller/pks_controller.properties @@ -0,0 +1,11 @@ +# Board Params +pks_controller.boardParamsTitle=Board Parameters +pks_controller.nbChannelsPrefix=Nb channels: + +# Channel General Settings +pks_controller.generalSettingsTitle=General Settings +pks_controller.channelsActivePrefix=Channel enabled +pks_controller.triggerThresholdPrefix=Trigger Threshold + +pks_controller.channelsActiveCheckedValue=1 +pks_controller.channelsActiveUncheckedValue=0 diff --git a/src/controllers/npp/gui/pks_controller/pks_controllerPlugin.xml b/src/controllers/npp/gui/pks_controller/pks_controllerPlugin.xml new file mode 100644 index 00000000..dc0cdbbf --- /dev/null +++ b/src/controllers/npp/gui/pks_controller/pks_controllerPlugin.xml @@ -0,0 +1,7 @@ +<controller_plugin_config type="pks_controller"> + + <image key="HARDWARE_VME_MODULE"/> + + <settings view="pks_controllerView.xml"/> + +</controller_plugin_config> diff --git a/src/controllers/npp/gui/pks_controller/pks_controllerProperties.xml b/src/controllers/npp/gui/pks_controller/pks_controllerProperties.xml new file mode 100644 index 00000000..fc35a63d --- /dev/null +++ b/src/controllers/npp/gui/pks_controller/pks_controllerProperties.xml @@ -0,0 +1,16 @@ +<?xml version="1.0" encoding="ISO-8859-1" ?> + +<controller type="pks_controller"> + + <property name="nb_channels" type="int32" max_length="2"> + <strictly_positive/> + </property> + + <dynamic_property size_property="nb_channels" name="channels_active" type="int32"> + </dynamic_property> + + <dynamic_property size_property="nb_channels" name="trigger_threshold" type="int32" max_length="5"> + <positive/> + </dynamic_property> + +</controller> diff --git a/src/controllers/npp/gui/pks_controller/pks_controllerView.xml b/src/controllers/npp/gui/pks_controller/pks_controllerView.xml new file mode 100644 index 00000000..617ca927 --- /dev/null +++ b/src/controllers/npp/gui/pks_controller/pks_controllerView.xml @@ -0,0 +1,21 @@ +<plugin> + <controller type="pks_controller" role="pks_controller1"/> + + <group title="pks_controller.boardParamsTitle"> + <label role="pks_controller1" property="nb_channels" prefix="pks_controller.nbChannelsPrefix"/> + </group> + + <newLine/> + + <group title="pks_controller.generalSettingsTitle" isVertical="true"> + <table_composite nbColumns="2"> + <simple_label prefix="pks_controller.channelsActivePrefix" /> + <simple_label prefix="pks_controller.triggerThresholdPrefix" /> + <dynamic_composite role="pks_controller1" properties="channels_active,trigger_threshold"> + <check role="pks_controller1" property="channels_active" checkBoxValues="pks_controller.channelsActive"/> + <text role="pks_controller1" property="trigger_threshold"/> + </dynamic_composite> + </table_composite> + </group> + +</plugin> diff --git a/src/controllers/npp/gui/psd_controller/psd_controllerProperties.xml b/src/controllers/npp/gui/psd_controller/psd_controllerProperties.xml index cfe0cc83..a906a6bd 100644 --- a/src/controllers/npp/gui/psd_controller/psd_controllerProperties.xml +++ b/src/controllers/npp/gui/psd_controller/psd_controllerProperties.xml @@ -14,7 +14,7 @@ </property> <property name="trigger_holdoff" type="float64" max_length="6"> - <decimal_format nb_decimal_places="2"/> + <decimal_format nb_decimal_places="3"/> <strictly_positive/> </property> @@ -29,18 +29,18 @@ </property> <property name="short_gate" type="float64" max_length="6"> - <decimal_format nb_decimal_places="2"/> + <decimal_format nb_decimal_places="3"/> <strictly_positive/> </property> <property name="long_gate" type="float64" max_length="6"> - <decimal_format nb_decimal_places="2"/> + <decimal_format nb_decimal_places="3"/> <strictly_positive/> </property> <property name="pre_gate" type="float64" max_length="6"> - <decimal_format nb_decimal_places="2"/> - <strictly_positive/> + <decimal_format nb_decimal_places="3"/> + <positive/> </property> <property name="trigger_validation" type="int32"> diff --git a/src/controllers/remotefiletest/Module.xml b/src/controllers/remotefiletest/Module.xml new file mode 100644 index 00000000..a6d9f954 --- /dev/null +++ b/src/controllers/remotefiletest/Module.xml @@ -0,0 +1,4 @@ +<module name="remotefiletest"> + <controller class="test::RemoteFileTest"/> + <include path="$(NOMAD_HOME)/../NomadModules/src"/> +</module> diff --git a/src/controllers/remotefiletest/RemoteFileTest.cpp b/src/controllers/remotefiletest/RemoteFileTest.cpp new file mode 100644 index 00000000..8d77d3f2 --- /dev/null +++ b/src/controllers/remotefiletest/RemoteFileTest.cpp @@ -0,0 +1,171 @@ +/* + * Nomad Instrument Control Software + * + * Copyright 2011 Institut Laue-Langevin + * + * Licensed under the EUPL, Version 1.1 only (the "License"); + * You may not use this work except in compliance with the Licence. + * You may obtain a copy of the Licence at: + * + * http://joinup.ec.europa.eu/software/page/eupl + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the Licence is distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Licence for the specific language governing permissions and + * limitations under the Licence. + */ + +#include "RemoteFileTest.h" +#include <boost/lexical_cast.hpp> +#include <common/base/Date.h> +#include <fstream> +#include <iostream> + +namespace test { + +using namespace std; +using namespace common; +using namespace boost; +using namespace nappli; + +const std::string RemoteFileTest::TYPE = "remote_file_test"; +const std::string RemoteFileTest::REMOTE_APPLICATION = "nfiletest"; +const std::string RemoteFileTest::FILE_PUBLISHER = "file_publisher"; +const std::string RemoteFileTest::RESULT_PUBLISHER = "file_result"; + +RemoteFileTest::RemoteFileTest(const std::string& name) : + ExperimentController(name), + controller::Stoppable(this) { + + serverEndpoint.init(this, SAVE, "nappli_server"); + initialized.init(this, NOSAVE, "initialized"); + filename.init(this, SAVE, "filename"); +} + +RemoteFileTest::RemoteFileTest(const RemoteFileTest& controller) : + ExperimentController(controller), + controller::Stoppable(this) { +} + +RemoteFileTest::~RemoteFileTest() { + + // Stop the subscriber + m_subscriber->cancel(); + + // Notify the application + m_publisher->sendEnd(); + + // Wait for the termination + application::State state = m_remoteApplication->waitFor(); + + cout << "Remote application terminated with state " << state << endl; +} + +void RemoteFileTest::postConfiguration() { + + if (serverEndpoint() == "") { + m_server.reset(new Server(application::This::getServer().getEndpoint())); + + } else { + m_server.reset(new Server(serverEndpoint())); + } + + initialized = initApplication(); +} + +bool RemoteFileTest::initApplication() { + + // Do not initialize if it is already done + if (initialized()) { + return true; + } + + // Start the Matlab server + if (!m_server->isAvailable(1000)) { + cout << "Remote server is not available" << endl; + return false; + } + + cout << "Remote server is connected" << endl; + + m_remoteApplication = m_server->connect(REMOTE_APPLICATION); + if (m_remoteApplication->exists()) { + // The application exists from a previous server session + m_remoteApplication->kill(); + application::State state = m_remoteApplication->waitFor(); + cout << "Terminated remote application with state " << state << endl; + } + + m_remoteApplication = m_server->start(REMOTE_APPLICATION); + + if (!m_remoteApplication->exists()) { + cout << "No remote application" << endl; + return false; + } + + // Create the publisher after the start of the application, because it is a blocking call + m_publisher = application::Publisher::create(FILE_PUBLISHER, 1); + cout << "Publisher " << *m_publisher << endl; + + // Wait for the subscriber + bool sync = m_publisher->waitForSubscribers(); + + // Create the subscriber after the publisher + m_subscriber = application::Subscriber::create(*m_remoteApplication, RESULT_PUBLISHER); + cout << "subscriber " << *m_subscriber << endl; + + // Application initialized + initialized = true; + + return true; +} + +void RemoteFileTest::sendFile() { + + if (!initApplication()) { + return; + } + + ifstream numorFile; + numorFile.open(filename().c_str()); + + stringstream stream; + stream << numorFile.rdbuf(); + + Date begin; + + string content = stream.str(); + + // Publish the message + m_publisher->sendBinary(content); + + // Wait for result + vector<int32> result; + if (m_subscriber->receive(result)) { + Date end; + double ms = (end - begin).getMilliseconds(); + cout << "Sent and received file in " << ms << " ms (" << (content.size() / ms) << " ko/s)" << endl; + if (content.size() != result[0]) { + cout << "\tProblem with size" << endl; + } + } +} + +void RemoteFileTest::start() { + + for (int i = 0; i < 100; i++) { + // Send the numor + sendFile(); + + if (isStopped()) { + break; + } + } +} + +void RemoteFileTest::stop() { + +} + +} diff --git a/src/controllers/remotefiletest/RemoteFileTest.h b/src/controllers/remotefiletest/RemoteFileTest.h new file mode 100644 index 00000000..e1fe5dcc --- /dev/null +++ b/src/controllers/remotefiletest/RemoteFileTest.h @@ -0,0 +1,63 @@ +/* + * Nomad Instrument Control Software + * + * Copyright 2011 Institut Laue-Langevin + * + * Licensed under the EUPL, Version 1.1 only (the "License"); + * You may not use this work except in compliance with the Licence. + * You may obtain a copy of the Licence at: + * + * http://joinup.ec.europa.eu/software/page/eupl + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the Licence is distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Licence for the specific language governing permissions and + * limitations under the Licence. + */ + +#ifndef TAS_REMOTEFILETEST_H +#define TAS_REMOTEFILETEST_H + +#include <Controller.h> +#include <nappli/nappli.h> + +namespace test { + +class RemoteFileTest : public ExperimentController, + public controller::Stoppable { + +public: + //! Type of controller + static const std::string TYPE; + + RemoteFileTest(const std::string& name); + RemoteFileTest(const RemoteFileTest& controller); + virtual ~RemoteFileTest(); + + virtual void postConfiguration(); + + virtual void start(); + virtual void stop(); + + Property<std::string> serverEndpoint; + Property<bool> initialized; + Property<string> filename; + +private: + bool initApplication(); + void sendFile(); + + static const std::string REMOTE_APPLICATION; + static const std::string FILE_PUBLISHER; + static const std::string RESULT_PUBLISHER; + + std::auto_ptr<nappli::Server> m_server; + std::auto_ptr<nappli::application::Instance> m_remoteApplication; + std::auto_ptr<nappli::application::Publisher> m_publisher; + std::auto_ptr<nappli::application::Subscriber> m_subscriber; +}; + +} + +#endif diff --git a/src/controllers/remotenpp/DPPReader.cpp b/src/controllers/remotenpp/DPPReader.cpp deleted file mode 100644 index 8e157918..00000000 --- a/src/controllers/remotenpp/DPPReader.cpp +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Nomad Instrument Control Software - * - * Copyright 2011 Institut Laue-Langevin - * - * Licensed under the EUPL, Version 1.1 only (the "License"); - * You may not use this work except in compliance with the Licence. - * You may obtain a copy of the Licence at: - * - * http://www.osor.eu/eupl - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the Licence is distributed on an "AS IS" basis, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the Licence for the specific language governing permissions and - * limitations under the Licence. - */ - -#include "DPPReader.h" -#include <iostream> - -using namespace std; - -namespace npp { - -DPPReader::DPPReader(int32_t size) : - _size(0), - _sizeInBytes(0), - _memoryBlock(0), - _nbAdc(0), - _nbChannels(0), - _listMode(0), - _listModeSize(0) { - - init(size); -} - -DPPReader::~DPPReader() { - delete [] _memoryBlock; -} - -void DPPReader::init(int32_t size) { - _size = size; - _sizeInBytes = size * sizeof(int32_t); - _memoryBlock = new int32_t[size]; -} - -bool DPPReader::openFile(std::string const & fileName) { - - _dataFile.open(fileName.c_str(), ios::in | ios::binary); - - if (!_dataFile.is_open()) { - cerr << "problem reading " << fileName << endl; - return false; - } - - _dataFile.seekg(0, ios::end); - _fileSize = _dataFile.tellg(); - _dataFile.seekg(0, ios::beg); - - // just reading 4 elements for the header - _dataFile.read((char *)_memoryBlock, 4 * sizeof(int32_t)); - - _nbAdc = _memoryBlock[0]; - _nbChannels = _memoryBlock[1]; - _listMode = _memoryBlock[2]; - _listModeSize = _memoryBlock[3]; - - return true; -} - -int32_t DPPReader::numberOfADCs() const { - return _nbAdc; -} - -int32_t DPPReader::numberOfChannels() const { - return _nbChannels; -} - -int32_t DPPReader::listMode() const { - return _listMode; -} - -int32_t DPPReader::numberOfEvents() const { - return _listModeSize; -} - -int32_t DPPReader::readBlock() { - - // reading next block - int32_t blockSize = getBlockSizeInBytes(); - _dataFile.read((char *)_memoryBlock, blockSize); - - return (blockSize / 4); -} - -int32_t DPPReader::getBlockSizeInBytes() { - - FileSize size = _fileSize - _dataFile.tellg(); - if (size < (FileSize)_sizeInBytes) { - return size; - } - - return _sizeInBytes; -} - -int32_t * DPPReader::memoryBlock() const { - return _memoryBlock; -} - -} diff --git a/src/controllers/remotenpp/DPPReader.h b/src/controllers/remotenpp/DPPReader.h deleted file mode 100644 index 754b1b51..00000000 --- a/src/controllers/remotenpp/DPPReader.h +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Nomad Instrument Control Software - * - * Copyright 2011 Institut Laue-Langevin - * - * Licensed under the EUPL, Version 1.1 only (the "License"); - * You may not use this work except in compliance with the Licence. - * You may obtain a copy of the Licence at: - * - * http://www.osor.eu/eupl - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the Licence is distributed on an "AS IS" basis, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the Licence for the specific language governing permissions and - * limitations under the Licence. - */ - -#ifndef NPP_DPPREADER_H -#define NPP_DPPREADER_H - -#include <string> -#include <stdint.h> -#include <fstream> -#include <sstream> - -namespace npp { - -class DPPReader { - -public: - /** - * Constructor. - */ - DPPReader(int32_t size); - - /** - * Destructor. - */ - virtual ~DPPReader(); - - /** - * Opens the file. Returns false if problem opening the file. - */ - bool openFile(std::string const & fileName); - - /** - * Returns the number of ADC. - */ - int32_t numberOfADCs() const; - - /** - * Returns the number of channels. - */ - int32_t numberOfChannels() const; - - /** - * Returns the list mode. - */ - int32_t listMode() const; - - /** - * Returns the list mode size. - */ - int32_t numberOfEvents() const; - - /** - * Returns the number of elements read. - */ - int32_t readBlock(); - - /** - * Returns the memory block. - */ - int32_t * memoryBlock() const; - -private: - void init(int32_t size); - int32_t getBlockSizeInBytes(); - - int32_t _size; - int32_t _sizeInBytes; - - int32_t * _memoryBlock; - std::ifstream _dataFile; - - int32_t _nbAdc; - int32_t _nbChannels; - int32_t _listMode; - int32_t _listModeSize; - - typedef std::ifstream::pos_type FileSize; - FileSize _fileSize; -}; - -} - -#endif diff --git a/src/controllers/remotenpp/Module.xml.new b/src/controllers/remotenpp/Module.xml similarity index 67% rename from src/controllers/remotenpp/Module.xml.new rename to src/controllers/remotenpp/Module.xml index 19fb7be5..746b5160 100644 --- a/src/controllers/remotenpp/Module.xml.new +++ b/src/controllers/remotenpp/Module.xml @@ -1,6 +1,9 @@ <module name="remotenpp"> + <controller class="npp::RemoteDPPContext"/> <controller class="npp::RemoteDPPHistogram"/> <controller class="npp::RemoteDPPCoincidence"/> <include path="$(NOMAD_HOME)/../NomadModules/src"/> + + <link path="/usr/local/lib" lib="lstdpp"/> </module> diff --git a/src/controllers/remotenpp/RemoteDPPCoincidence.cpp b/src/controllers/remotenpp/RemoteDPPCoincidence.cpp index f6404de5..04fa6aa3 100644 --- a/src/controllers/remotenpp/RemoteDPPCoincidence.cpp +++ b/src/controllers/remotenpp/RemoteDPPCoincidence.cpp @@ -21,6 +21,7 @@ #include <boost/thread.hpp> #include <boost/bind.hpp> #include <boost/lexical_cast.hpp> +#include <boost/property_tree/json_parser.hpp> #include <cstdlib> namespace npp { @@ -29,34 +30,45 @@ using namespace std; using namespace common; using namespace boost; using namespace nappli; +using namespace lstdpp; + +using boost::property_tree::ptree; const std::string RemoteDPPCoincidence::TYPE = "remote_dpp_coincidence"; RemoteDPPCoincidence::RemoteDPPCoincidence(const std::string& name) : - DPPLiveProcess(name) { + RemoteDPPLiveProcess(name) { serverEndpoint.init(this, SAVE, "nappli_server"); dT.init(this, SAVE, "dT"); cleanDT.init(this, SAVE, "clean_dT"); - blockSize.init(this, SAVE, "process_block_size"); + numberOfDetectorChannels.init(this, SAVE, "number_of_detector_channels"); + detectorChannel.init(this, SAVE, "detector_channel"); + coincidenceResolution.init(this, SAVE, "coincidence_resolution"); + maxBlock.init(this, SAVE, "max_block"); + blockSize.init(this, SAVE, "block_size"); test.init(this, SAVE, "test"); testFileName.init(this, SAVE, "test_file_name"); - xData.init(this, NOSAVE, "x_data"); - coincidenceResolution.init(this, SAVE, "coincidence_resolution"); - nOrder.init(this, NOSAVE, "n_order"); refreshTimeS.init(this, SAVE, "refresh_time_s"); - one.init(this, NOSAVE, "one"); + totalNumberOfChannels.init(this, NOSAVE, "total_number_of_channels"); + + nOrder.init(this, NOSAVE, "n_order"); order.init(this, NOSAVE, "order"); globalRate.init(this, NOSAVE, "global_rate"); globalCleanRate.init(this, NOSAVE, "global_clean_rate"); detectorRate.init(this, NOSAVE, "detector_rate"); detectorCleanRate.init(this, NOSAVE, "detector_clean_rate"); - ADCId.init(this, NOSAVE, "adc_id"); - ADCRate.init(this, NOSAVE, "adc_rate"); + + crateId.init(this, NOSAVE, "crate_id"); + boardId.init(this, NOSAVE, "board_id"); + channelId.init(this, NOSAVE, "channel_id"); + channelRate.init(this, NOSAVE, "channel_rate"); + + registerRefresher(numberOfDetectorChannels, &RemoteDPPCoincidence::refreshNumberOfDetectorChannels, this); } RemoteDPPCoincidence::RemoteDPPCoincidence(const RemoteDPPCoincidence& controller) : - DPPLiveProcess(controller) { + RemoteDPPLiveProcess(controller) { } RemoteDPPCoincidence::~RemoteDPPCoincidence() { @@ -64,12 +76,11 @@ RemoteDPPCoincidence::~RemoteDPPCoincidence() { void RemoteDPPCoincidence::postConfiguration() { - string endpoint = serverEndpoint(); - if (endpoint == "") { - m_server = Application::getLocalServer(); + if (serverEndpoint() == "") { + m_server.reset(new Server(application::This::getServer().getEndpoint())); } else { - m_server.reset(new Server(endpoint)); + m_server.reset(new Server(serverEndpoint())); } // order @@ -86,13 +97,6 @@ void RemoteDPPCoincidence::postConfiguration() { order.set(i, i + 2); } - ADCId.resize(MAX_ADC); - ADCRate.resize(MAX_ADC); - - for (int32 i = 0; i < MAX_ADC; i++) { - ADCId.set(i, i); - } - resetData(); } @@ -110,14 +114,11 @@ void RemoteDPPCoincidence::setDetectorControllers(const std::vector<ControllerPt void RemoteDPPCoincidence::start() { - auto_ptr<DPPReader> reader = initTest(); + auto_ptr<lstdpp::Reader> reader = initTest(); resetData(); - // napplicoincidence <numor> <number of ADCs> <number of channels> <coincidence dT> <clean dT> <crateboard.txt> <detectoradc.txt> [processBlockSize] [result period] - vector<string> args; - - // numor + // Numor string numor; size_t size = fileName().size(); @@ -127,43 +128,75 @@ void RemoteDPPCoincidence::start() { } else { numor = fileName(); } - args.push_back(numor); - args.push_back(lexical_cast<string>(numberOfADCs())); - args.push_back(lexical_cast<string>(numberOfChannels())); - args.push_back(lexical_cast<string>(dT() / 10)); - args.push_back(lexical_cast<string>(cleanDT() / 10)); - args.push_back(ServerProperties::getInstance()->getHomePath() + "/.nomadserver/crateboardcoincidence.txt"); - args.push_back(ServerProperties::getInstance()->getHomePath() + "/.nomadserver/detectoradc.txt"); - args.push_back(lexical_cast<string>(blockSize())); - args.push_back(lexical_cast<string>(refreshTimeS())); - - // kill the application if one remains + + // Setting the parameters + ptree parameters; + + parameters.put("numor", numor); + parameters.put("dT", dT() / 10); + parameters.put("cleanDT", cleanDT() / 10); + + // detector channels + ptree detectorChannelArray; + ptree channel; + int32 detectorChannelSize = detectorChannel.getSize(); + for (int32 i = 0; i < detectorChannelSize; ++i) { + channel.put("", detectorChannel(i)); + detectorChannelArray.push_back(std::make_pair("", channel)); + } + parameters.put_child("detectorChannels", detectorChannelArray); + + parameters.put("matrixResolution", coincidenceResolution()); + parameters.put("maxBlocks", maxBlock()); + parameters.put("blockSize", blockSize()); + parameters.put("refreshTime", refreshTimeS()); + + ptree context = writeListModeContextToPropertyTree(listModeContext); + + parameters.put_child("context", context); + + // Serialize the parameters + stringstream os; + write_json(os, parameters, false); + + + // Kill the application if one remains m_server->killAllAndWaitFor("ncoincidence"); - // start the application + vector<string> args; + args.push_back(os.str()); + + // Start the application m_coincidenceApplication = m_server->start("ncoincidence", args); - // test if application started + // Test if application started if (!m_coincidenceApplication->exists()) { log(Level::s_Error) << "cannot start coincidence application" << endlog; return; } - // create the publisher after the start of the application, because it is a blocking call - m_publisher = Application::publish("dpp_publisher", 1); + // Create the publisher after the start of the application, because it is a blocking call + m_publisher.reset(); + m_publisher = application::Publisher::create("dpp_publisher", 1); + + cout << "publisher " << *m_publisher << endl; + + // Wait for the subscriber + bool sync = m_publisher->waitForSubscribers(); - // create the subscriber after the publisher - auto_ptr<nappli::Application::Subscriber> subscriber = m_coincidenceApplication->subscribe("dpp_coincidence_results"); + // Create the subscriber after the publisher + auto_ptr<nappli::application::Subscriber> subscriber = application::Subscriber::create(*m_coincidenceApplication, "dpp_coincidence_results"); + cout << "subscriber " << *subscriber << endl; - // start the test thread if necessary + // Start the test thread if necessary auto_ptr<boost::thread> thread = startTest(reader.get()); - // listen the result stream - vector<double> ADCRates; - while (subscriber->receive(ADCRates)) { + // Listen to the result stream + vector<double> channelRates; + while (subscriber->receive(channelRates)) { // copying the rates - for (int32 i = 0; i < numberOfADCs(); i++) { - ADCRate.set(i, ADCRates[i]); + for (int32 i = 0; i < totalNumberOfChannels(); i++) { + channelRate.set(i, channelRates[i]); } vector<double> coincidenceRates; @@ -172,7 +205,7 @@ void RemoteDPPCoincidence::start() { } if (coincidenceRates.size() <= 4 * 7) { - // copying values + // Copying values for (int32 i = 0; i < 7; ++i) { globalRate.set(i, coincidenceRates[i]); globalCleanRate.set(i, coincidenceRates[7 + i]); @@ -185,23 +218,21 @@ void RemoteDPPCoincidence::start() { } } - // wait for the termination of the application - Application::State state = m_coincidenceApplication->waitFor(); + // Wait for the termination of the application + application::State state = m_coincidenceApplication->waitFor(); cout << "coincidence application terminated with state " << state << endl; - // join the test thread + // Join the test thread finishTest(thread); - - // terminate the publisher - m_publisher->terminate(); } void RemoteDPPCoincidence::stop() { - if (m_coincidenceApplication.get() != 0) { + // Test the coincidence application and the publisher + if (m_coincidenceApplication.get() != 0 && m_publisher.get() != 0) { cout << *m_publisher << " end of stream" << endl; - m_publisher->setEndOfStream(); + m_publisher->sendEnd(); // we do not stop the application because the termination of the publisher will do it. } } @@ -210,9 +241,13 @@ void RemoteDPPCoincidence::raz() { resetData(); } +void RemoteDPPCoincidence::refreshNumberOfDetectorChannels(int32 value) { + detectorChannel.resize(value); +} + void RemoteDPPCoincidence::updateListModeData(int index) { - if (m_publisher.get() != 0 && !m_publisher->isEndOfStream()) { + if (m_publisher.get() != 0 && !m_publisher->hasEnded()) { int32 size = detectorControllers[index]->listModeData.getSize(); int32 * memoryBlock = detectorControllers[index]->listModeData(); @@ -226,67 +261,91 @@ void RemoteDPPCoincidence::updateListModeData(int index) { } } -auto_ptr<DPPReader> RemoteDPPCoincidence::initTest() { +auto_ptr<lstdpp::Reader> RemoteDPPCoincidence::initTest() { if (test()) { - auto_ptr<DPPReader> reader(new DPPReader(blockSize())); + auto_ptr<lstdpp::Reader> reader(new lstdpp::Reader(blockSize())); - reader->openFile(testFileName()); - - cout << "#ADCs " << reader->numberOfADCs() << endl; - cout << "#channels " << reader->numberOfChannels() << endl; + reader->open(testFileName()); // override real values - numberOfADCs = reader->numberOfADCs(); - numberOfChannels = reader->numberOfChannels(); + numberOfADCs = 0; + numberOfChannels = 0; return reader; } - return auto_ptr<DPPReader>(); + return auto_ptr<lstdpp::Reader>(); } -void RemoteDPPCoincidence::testLoop(DPPReader * reader) { +void RemoteDPPCoincidence::testLoop(lstdpp::Reader * reader) { - // loop over events - while (!m_publisher->isEndOfStream()) { - // reading next block - int32_t blockSize = reader->readBlock(); + if (test()) { + // loop over events + while (!m_publisher->hasEnded()) { + // reading next block + int32_t blockSize = reader->read(); + + // exiting if no data + if (blockSize == 0) { + break; + } - // exiting if no data - if (blockSize == 0) { - break; - } + // sending block + int32_t * memoryBlock = reader->buffer(); - // sending block - int32_t * memoryBlock = reader->memoryBlock(); + // put the array into a string + string data(reinterpret_cast<char *>(memoryBlock), sizeof(int32_t) * blockSize); - // put the array into a string - string data(reinterpret_cast<char *>(memoryBlock), sizeof(int32_t) * blockSize); + // send the data + m_publisher->sendBinary(data); - // send the data - m_publisher->send(data); + //sleep(refreshTimeS()); + usleep(10000); + } - //sleep(refreshTimeS()); - usleep(10000); + cout << "finished reading test file " << testFileName() << endl; } - - cout << "finished reading test file " << testFileName() << endl; } -std::auto_ptr<boost::thread> RemoteDPPCoincidence::startTest(DPPReader * reader) { +std::auto_ptr<boost::thread> RemoteDPPCoincidence::startTest(lstdpp::Reader * reader) { - return auto_ptr<thread>(new thread(bind(&RemoteDPPCoincidence::testLoop, this, reader))); + if (test()) { + return auto_ptr<thread>(new thread(bind(&RemoteDPPCoincidence::testLoop, this, reader))); + } + return auto_ptr<thread>(); } void RemoteDPPCoincidence::finishTest(std::auto_ptr<boost::thread> thread) { - // join the thread - thread->join(); + if (test()) { + // join the thread + thread->join(); + } } void RemoteDPPCoincidence::resetData() { + // Calculate the total number of channels + BoardIterator b; + + if (b.end()) { + totalNumberOfChannels = 0; + + } else { + int32_t currentNbChannels = (*b).nbChannels; + + ++b; + while (!b.end()) { + currentNbChannels += (*b).nbChannels; + ++b; + } + + totalNumberOfChannels = currentNbChannels; + } + + cout << "totalNumberOfChannels " << totalNumberOfChannels() << endl; + // resetting values for (int32 i = 0; i < 7; ++i) { globalRate.set(i, 0.0); @@ -295,57 +354,30 @@ void RemoteDPPCoincidence::resetData() { detectorCleanRate.set(i, 0.0); } - // setting dynamic properties - for (int32 i = 0; i < MAX_ADC; i++) { - ADCRate.set(i, 0.0); + crateId.resize(totalNumberOfChannels()); + boardId.resize(totalNumberOfChannels()); + channelId.resize(totalNumberOfChannels()); + channelRate.resize(totalNumberOfChannels()); + + int32 i = 0; + + // Set the ids + BoardIterator bc; + while (!bc.end()) { + int32 nbChannels = (*bc).nbChannels; + int32 histogramSize = (1 << BoardDataResolution[(*bc).boardType]); + + for (int32 j = 0; j < nbChannels; ++j) { + crateId.set(i, bc.crate()); + boardId.set(i, bc.board()); + channelId.set(i, j); + channelRate.set(i, 0.0); + + ++i; + } + + ++bc; } } -//void RemoteDPPCoincidence::executeRefreshProcess() { -// -// while (_liveRunning) { -// sleep(refreshTimeS()); -// -// // copying values -// for (int32 i = 0; i < 7; ++i) { -// globalRate.set(i, _data[i]); -// globalCleanRate.set(i, _data[7 + i]); -// detectorRate.set(i, _data[7 * 2 + i]); -// detectorCleanRate.set(i, _data[7 * 3 + i]); -// } -// -// coincidenceData.sendEvent(); -// -// // setting dynamic properties -// for (int32 i = 0; i < numberOfADCs(); i++) { -// ADCRate.set(i, _ADCRates[i]); -// } -// } -// -// float64 crystalRate2 = globalRate(0); -// float64 crystalCleanRate2 = globalCleanRate(0); -// float64 detectorRate2 = detectorRate(0); -// float64 detectorCleanRate2 = detectorCleanRate(0); -// -// float64 crystalRate3 = globalRate(1); -// float64 crystalCleanRate3 = globalCleanRate(1); -// float64 detectorRate3 = detectorRate(1); -// float64 detectorCleanRate3 = detectorCleanRate(1); -// -// ostringstream ss1, ss2, ss3; -// -// ss1 << " Order" -// << " Crystal (c/s)" -// << " Crystal clean (c/s)" -// << " Detector (c/s)" -// << " Detector clean (c/s)"; -// -// ss2 << " 2 " << boost::format("%20.3d") % crystalRate2 << " " << boost::format("%20.3d") % crystalCleanRate2 << " " << boost::format("%20.3d") % detectorRate2 << " " << boost::format("%20.3d") % detectorCleanRate2; -// ss3 << " 3 " << boost::format("%20.3d") % crystalRate3 << " " << boost::format("%20.3d") % crystalCleanRate3 << " " << boost::format("%20.3d") % detectorRate3 << " " << boost::format("%20.3d") % detectorCleanRate3; -// -// log(Level::s_Info) << ss1.str() << endlog; -// log(Level::s_Info) << ss2.str() << endlog; -// log(Level::s_Info) << ss3.str() << endlog; -//} - } diff --git a/src/controllers/remotenpp/RemoteDPPCoincidence.h b/src/controllers/remotenpp/RemoteDPPCoincidence.h index 18e9b877..177b7145 100644 --- a/src/controllers/remotenpp/RemoteDPPCoincidence.h +++ b/src/controllers/remotenpp/RemoteDPPCoincidence.h @@ -19,16 +19,14 @@ #ifndef NPP_REMOTEDPPCOINCIDENCE_H #define NPP_REMOTEDPPCOINCIDENCE_H -#include "../npp/DPPLiveProcess.h" -#include "DPPReader.h" -#include <nappli/nappli.h> +#include "RemoteDPPLiveProcess.h" #include <boost/thread.hpp> #include <stdint.h> #include <memory> namespace npp { -class RemoteDPPCoincidence : public DPPLiveProcess { +class RemoteDPPCoincidence : public RemoteDPPLiveProcess { public: //! Type of controller @@ -45,37 +43,45 @@ public: virtual void stop(); virtual void raz(); + void refreshNumberOfDetectorChannels(int32 value); void updateListModeData(int index); private: void resetData(); - std::auto_ptr<DPPReader> initTest(); - void testLoop(DPPReader * reader); - std::auto_ptr<boost::thread> startTest(DPPReader * reader); + std::auto_ptr<lstdpp::Reader> initTest(); + void testLoop(lstdpp::Reader * reader); + std::auto_ptr<boost::thread> startTest(lstdpp::Reader * reader); void finishTest(std::auto_ptr<boost::thread> thread); Property<std::string> serverEndpoint; Property<int32> dT; Property<int32> cleanDT; + Property<int32> numberOfDetectorChannels; + DynamicProperty<int32> detectorChannel; + Property<int32> coincidenceResolution; + Property<int32> maxBlock; Property<int32> blockSize; Property<bool> test; Property<std::string> testFileName; - ArrayProperty<int32> xData; - Property<int32> coincidenceResolution; - Property<int32> nOrder; Property<int32> refreshTimeS; - Property<int32> one; + + Property<int32> totalNumberOfChannels; + + Property<int32> nOrder; DynamicProperty<int32> order; DynamicProperty<float64> globalRate; DynamicProperty<float64> globalCleanRate; DynamicProperty<float64> detectorRate; DynamicProperty<float64> detectorCleanRate; - DynamicProperty<int32> ADCId; - DynamicProperty<float64> ADCRate; + + DynamicProperty<int32> crateId; + DynamicProperty<int32> boardId; + DynamicProperty<int32> channelId; + DynamicProperty<float64> channelRate; std::auto_ptr<nappli::Server> m_server; - std::auto_ptr<nappli::Application::Future> m_coincidenceApplication; - auto_ptr<nappli::Application::Publisher> m_publisher; + std::auto_ptr<nappli::application::Instance> m_coincidenceApplication; + std::auto_ptr<nappli::application::Publisher> m_publisher; static const int32 MAX_ADC = 128; }; diff --git a/src/controllers/remotenpp/RemoteDPPContext.cpp b/src/controllers/remotenpp/RemoteDPPContext.cpp new file mode 100644 index 00000000..fcfc4dba --- /dev/null +++ b/src/controllers/remotenpp/RemoteDPPContext.cpp @@ -0,0 +1,79 @@ +/* + * Nomad Instrument Control Software + * + * Copyright 2011 Institut Laue-Langevin + * + * Licensed under the EUPL, Version 1.1 only (the "License"); + * You may not use this work except in compliance with the Licence. + * You may obtain a copy of the Licence at: + * + * http://joinup.ec.europa.eu/software/page/eupl + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the Licence is distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Licence for the specific language governing permissions and + * limitations under the Licence. + */ + +#include "RemoteDPPContext.h" + +namespace npp { + +using namespace std; +using namespace lstdpp; + +const std::string RemoteDPPContext::TYPE = "remote_dpp_context"; + +RemoteDPPContext::RemoteDPPContext(const std::string& name) : + ExperimentController(name) { + + acquisitionController.init(this, "acquisition_controller"); +} + +RemoteDPPContext::~RemoteDPPContext() { +} + +void RemoteDPPContext::postConfiguration() { + + // Warning: we suppose that the list mode block is ordered like the ADC controllers + releaseListModeContext(listModeContext); + + int32 nbCrates = 0; + + for (int32 adc = 0; adc < acquisitionController->nbAdcControllers(); ++adc) { + int32 crate = acquisitionController->adcController[adc]->crateNumber(); + if (crate >= nbCrates) { + nbCrates = crate + 1; + } + } + + listModeContext.crateBoard.nbCrates = nbCrates; + listModeContext.crateBoard.crates = new Crate[nbCrates]; + + for (int32 crate = 0; crate < nbCrates; ++crate) { + int32 nbBoards = 0; + + for (int32 board = 0; board < acquisitionController->nbAdcControllers(); ++board) { + if (board >= nbBoards) { + nbBoards = board + 1; + } + } + + listModeContext.crateBoard.crates[crate].nbBoards = nbBoards; + listModeContext.crateBoard.crates[crate].boards = new Board[nbBoards]; + + for (int32 board = 0; board < acquisitionController->nbAdcControllers(); ++board) { + listModeContext.crateBoard.crates[0].boards[board].boardType = (BoardType)acquisitionController->adcController[board]->cardType(); + listModeContext.crateBoard.crates[0].boards[board].crate = crate; + listModeContext.crateBoard.crates[0].boards[board].eventType = 0; + listModeContext.crateBoard.crates[0].boards[board].nbChannels = acquisitionController->adcController[board]->nbChannels(); + } + } + + cout << "DPP context" << endl; + cout << listModeContext << endl; +} + +} + diff --git a/src/controllers/remotenpp/RemoteDPPContext.h b/src/controllers/remotenpp/RemoteDPPContext.h new file mode 100644 index 00000000..9c4efed6 --- /dev/null +++ b/src/controllers/remotenpp/RemoteDPPContext.h @@ -0,0 +1,43 @@ +/* + * Nomad Instrument Control Software + * + * Copyright 2011 Institut Laue-Langevin + * + * Licensed under the EUPL, Version 1.1 only (the "License"); + * You may not use this work except in compliance with the Licence. + * You may obtain a copy of the Licence at: + * + * http://joinup.ec.europa.eu/software/page/eupl + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the Licence is distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Licence for the specific language governing permissions and + * limitations under the Licence. + */ + +#ifndef NPP_REMOTEDPPCONTEXT_H +#define NPP_REMOTEDPPCONTEXT_H + +#include "../npp/DPPAcquisitionController.h" +#include <lstdpp/lstdpp.h> + +namespace npp { + +class RemoteDPPContext : public ExperimentController { + +public: + //! Type of controller + static const std::string TYPE; + + RemoteDPPContext(const std::string& name); + virtual ~RemoteDPPContext(); + + virtual void postConfiguration(); + + ControllerPtr<DPPAcquisitionController> acquisitionController; +}; + +} + +#endif diff --git a/src/controllers/remotenpp/RemoteDPPHistogram.cpp b/src/controllers/remotenpp/RemoteDPPHistogram.cpp index c93da7f7..d45babac 100644 --- a/src/controllers/remotenpp/RemoteDPPHistogram.cpp +++ b/src/controllers/remotenpp/RemoteDPPHistogram.cpp @@ -21,6 +21,7 @@ #include <boost/thread.hpp> #include <boost/bind.hpp> #include <boost/lexical_cast.hpp> +#include <boost/property_tree/json_parser.hpp> #include <cstdlib> namespace npp { @@ -29,13 +30,18 @@ using namespace std; using namespace common; using namespace boost; using namespace nappli; +using namespace lstdpp; + +using boost::property_tree::ptree; const std::string RemoteDPPHistogram::TYPE = "remote_dpp_histogram"; RemoteDPPHistogram::RemoteDPPHistogram(const std::string& name) : - DPPLiveProcess(name) { + RemoteDPPLiveProcess(name) { serverEndpoint.init(this, SAVE, "nappli_server"); + triggerCrate.init(this, SAVE, "trigger_crate"); + triggerBoard.init(this, SAVE, "trigger_board"); triggerChannel.init(this, SAVE, "trigger_channel"); delay.init(this, SAVE, "delay"); dT.init(this, SAVE, "dT"); @@ -43,16 +49,23 @@ RemoteDPPHistogram::RemoteDPPHistogram(const std::string& name) : blockSize.init(this, SAVE, "block_size"); test.init(this, SAVE, "test"); testFileName.init(this, SAVE, "test_file_name"); - xData.init(this, NOSAVE, "x_data"); - one.init(this, NOSAVE, "one"); refreshTimeS.init(this, SAVE, "refresh_time_s"); + totalNumberOfChannels.init(this, NOSAVE, "total_number_of_channels"); + + crateId.init(this, NOSAVE, "crate_id"); + boardId.init(this, NOSAVE, "board_id"); + channelId.init(this, NOSAVE, "channel_id"); + channelRate.init(this, NOSAVE, "channel_rate"); + + xData.init(this, NOSAVE, "x_data"); histogram.init(this, NOSAVE, "histogram"); - ADCId.init(this, NOSAVE, "adc_id"); - ADCRate.init(this, NOSAVE, "adc_rate"); + histogramName.init(this, NOSAVE, "histogram_name"); + xLegend.init(this, NOSAVE, "x_legend"); + yLegend.init(this, NOSAVE, "y_legend"); } RemoteDPPHistogram::RemoteDPPHistogram(const RemoteDPPHistogram& controller) : - DPPLiveProcess(controller) { + RemoteDPPLiveProcess(controller) { } RemoteDPPHistogram::~RemoteDPPHistogram() { @@ -60,21 +73,11 @@ RemoteDPPHistogram::~RemoteDPPHistogram() { void RemoteDPPHistogram::postConfiguration() { - string endpoint = serverEndpoint(); - if (endpoint == "") { - m_server = Application::getLocalServer(); + if (serverEndpoint() == "") { + m_server.reset(new Server(application::This::getServer().getEndpoint())); } else { - m_server.reset(new Server(endpoint)); - } - - histogram.resize(MAX_ADC); - ADCId.resize(MAX_ADC); - ADCRate.resize(MAX_ADC); - - // allocating - for (int32 i = 0; i < MAX_ADC; i++) { - ADCId.set(i, i); + m_server.reset(new Server(serverEndpoint())); } resetData(); @@ -84,9 +87,11 @@ void RemoteDPPHistogram::setDetectorControllers(const std::vector<ControllerPtr< DPPLiveProcess::setDetectorControllers(detectorControllers); - // register the list mode data + // Register the list mode data int32 index = 0; for (vector<ControllerPtr<acquisition::DetectorController> >::const_iterator c = detectorControllers.begin(); c != detectorControllers.end(); ++c) { + // Force the attachment to receive updates + (*c)->attach(this); registerUpdater((*c)->listModeData, &RemoteDPPHistogram::updateListModeData, this, index); index++; } @@ -94,14 +99,11 @@ void RemoteDPPHistogram::setDetectorControllers(const std::vector<ControllerPtr< void RemoteDPPHistogram::start() { - auto_ptr<DPPReader> reader = initTest(); + auto_ptr<lstdpp::Reader> reader = initTest(); resetData(); - // napplihisto <numor> <number of ADCs> <number of channels> <channel> <delay> <dT> <crateboard.txt> [maxBlocks] [blockSize] [result period] - vector<string> args; - - // numor + // Numor string numor; size_t size = fileName().size(); @@ -111,47 +113,67 @@ void RemoteDPPHistogram::start() { } else { numor = fileName(); } - args.push_back(numor); - args.push_back(lexical_cast<string>(numberOfADCs())); - args.push_back(lexical_cast<string>(numberOfChannels())); - args.push_back(lexical_cast<string>(triggerChannel())); - args.push_back(lexical_cast<string>(delay() / 10)); - args.push_back(lexical_cast<string>(dT() / 10)); - args.push_back(ServerProperties::getInstance()->getHomePath() + "/.nomadserver/crateboardhistogram.txt"); - args.push_back(lexical_cast<string>(maxBlock())); - args.push_back(lexical_cast<string>(blockSize())); - args.push_back(lexical_cast<string>(refreshTimeS())); - - // kill the application if one remains + + // Setting the parameters + ptree parameters; + + parameters.put("numor", numor); + parameters.put("crate", triggerCrate()); + parameters.put("board", triggerBoard()); + parameters.put("channel", triggerChannel()); + parameters.put("delay", delay() / 10); + parameters.put("dT", dT() / 10); + parameters.put("maxBlocks", maxBlock()); + parameters.put("blockSize", blockSize()); + parameters.put("refreshTime", refreshTimeS()); + + ptree context = writeListModeContextToPropertyTree(listModeContext); + + parameters.put_child("context", context); + + // Serialize the parameters + stringstream os; + write_json(os, parameters, false); + + + // Kill the application if one remains m_server->killAllAndWaitFor("nhisto"); - // start the application + vector<string> args; + args.push_back(os.str()); + + // Start the application m_histoApplication = m_server->start("nhisto", args); - // test if application started + // Test if application started if (!m_histoApplication->exists()) { log(Level::s_Error) << "cannot start histogram application" << endlog; return; } - // create the publisher after the start of the application, because it is a blocking call - m_publisher = Application::publish("dpp_publisher", 1); + // Create the publisher after the start of the application, because it is a blocking call + m_publisher.reset(); + m_publisher = application::Publisher::create("dpp_publisher", 1); cout << "publisher " << *m_publisher << endl; - // create the subscriber after the publisher - auto_ptr<nappli::Application::Subscriber> subscriber = m_histoApplication->subscribe("dpp_histogram_results"); + // Wait for the subscriber + bool sync = m_publisher->waitForSubscribers(); + + // Create the subscriber after the publisher + auto_ptr<application::Subscriber> subscriber = application::Subscriber::create(*m_histoApplication, "dpp_histogram_results"); cout << "subscriber " << *subscriber << endl; - // start the test thread if necessary + // Start the test thread if necessary auto_ptr<boost::thread> thread = startTest(reader.get()); - // listen the result stream - vector<double> ADCRates; - while (subscriber->receive(ADCRates)) { - // copying the rates - for (int32 i = 0; i < numberOfADCs(); i++) { - ADCRate.set(i, ADCRates[i]); + // Listen to the result stream + vector<double> channelRates; + while (subscriber->receive(channelRates)) { + + // Copying the rates + for (int32 i = 0; i < totalNumberOfChannels(); i++) { + channelRate.set(i, channelRates[i]); } vector<int32_t> histograms; @@ -159,45 +181,52 @@ void RemoteDPPHistogram::start() { break; } - if (histograms.size() <= numberOfADCs() * numberOfChannels()) { + // Copying the data + vector<int32_t>::const_iterator h = histograms.begin(); + for (int32 i = 0; i < totalNumberOfChannels(); i++) { - int32 N = numberOfADCs(); - int32 M = numberOfChannels(); - - for (int32 i = 0; i < N; i++) { + if (h == histograms.end()) { + cerr << "problem with the histogram data" << endl; + break; + } - int32 * histo = histogram(i); + int32 size = histogram.getSize(i); + int32 * data = histogram(i); - for (int32 j = 0; j < M; j++) { - histo[j] = histograms[i * M + j]; + for (int32 j = 0; j < size; ++j) { + if (h == histograms.end()) { + cerr << "problem with the histogram data" << endl; + break; } - histogram.sendEvent(i); + data[j] = *h; + ++h; } - } else { - cerr << "problem with histogram size" << endl; + if (h == histograms.end()) { + // ok + } + + histogram.sendEvent(i); } } - // wait for the termination of the application - Application::State state = m_histoApplication->waitFor(); + // Wait for the termination of the application + application::State state = m_histoApplication->waitFor(); cout << "histogram application terminated with state " << state << endl; - // join the test thread + // Join the test thread finishTest(thread); - - // terminate the publisher - m_publisher->terminate(); } void RemoteDPPHistogram::stop() { - if (m_histoApplication.get() != 0) { + // Test the histogram application and the publisher + if (m_histoApplication.get() != 0 && m_publisher.get() != 0) { cout << *m_publisher << " end of stream" << endl; - m_publisher->setEndOfStream(); - // we do not stop the application because the termination of the publisher will do it. + m_publisher->sendEnd(); + // We do not stop the application because the termination of the publisher will do it. } } @@ -207,112 +236,159 @@ void RemoteDPPHistogram::raz() { void RemoteDPPHistogram::updateListModeData(int index) { - if (m_publisher.get() != 0 && !m_publisher->isEndOfStream()) { + if (m_publisher.get() != 0 && !m_publisher->hasEnded()) { int32 size = detectorControllers[index]->listModeData.getSize(); int32 * memoryBlock = detectorControllers[index]->listModeData(); - // put the array into a string + // Put the array into a string string data(reinterpret_cast<char *>(memoryBlock), sizeof(int32) * size); - // send the data + // Send the data m_publisher->send(data); - - cout << "updateListModeData " << index << " size " << size << endl; } } -auto_ptr<DPPReader> RemoteDPPHistogram::initTest() { +auto_ptr<lstdpp::Reader> RemoteDPPHistogram::initTest() { if (test()) { - auto_ptr<DPPReader> reader(new DPPReader(blockSize())); + auto_ptr<lstdpp::Reader> reader(new lstdpp::Reader(blockSize())); - reader->openFile(testFileName()); + reader->open(testFileName()); - cout << "#ADCs " << reader->numberOfADCs() << endl; - cout << "#channels " << reader->numberOfChannels() << endl; - - // override real values - numberOfADCs = reader->numberOfADCs(); - numberOfChannels = reader->numberOfChannels(); + // Override real values + numberOfADCs = 0; + numberOfChannels = 0; return reader; } - return auto_ptr<DPPReader>(); + return auto_ptr<lstdpp::Reader>(); } -void RemoteDPPHistogram::testLoop(DPPReader * reader) { +void RemoteDPPHistogram::testLoop(lstdpp::Reader * reader) { - // loop over events - while (!m_publisher->isEndOfStream()) { - // reading next block - int32_t blockSize = reader->readBlock(); + if (test()) { + // Loop over events + while (!m_publisher->hasEnded()) { + // Reading next block + int32_t blockSize = reader->read(); + + // Exiting if no data + if (blockSize == 0) { + break; + } - // exiting if no data - if (blockSize == 0) { - break; - } + // Sending block + int32_t * memoryBlock = reader->buffer(); - // sending block - int32_t * memoryBlock = reader->memoryBlock(); + // Put the array into a string + string data(reinterpret_cast<char *>(memoryBlock), sizeof(int32_t) * blockSize); - // put the array into a string - string data(reinterpret_cast<char *>(memoryBlock), sizeof(int32_t) * blockSize); + // Send the data + m_publisher->sendBinary(data); - // send the data - m_publisher->send(data); + //sleep(refreshTimeS()); + usleep(10000); + } - //sleep(refreshTimeS()); - usleep(10000); + cout << "finished reading test file " << testFileName() << endl; } - - cout << "finished reading test file " << testFileName() << endl; } -std::auto_ptr<boost::thread> RemoteDPPHistogram::startTest(DPPReader * reader) { +std::auto_ptr<boost::thread> RemoteDPPHistogram::startTest(lstdpp::Reader * reader) { - return auto_ptr<thread>(new thread(bind(&RemoteDPPHistogram::testLoop, this, reader))); + if (test()) { + return auto_ptr<thread>(new thread(bind(&RemoteDPPHistogram::testLoop, this, reader))); + } + return auto_ptr<thread>(); } void RemoteDPPHistogram::finishTest(std::auto_ptr<boost::thread> thread) { - // join the thread - thread->join(); - - cout << "finished test loop" << endl; + if (test()) { + // Join the thread + thread->join(); + } } void RemoteDPPHistogram::resetData() { - // number of elements - int32_t size = numberOfChannels() * numberOfADCs(); + // Calculate the total number of channels + BoardIterator b; - // ADC X data - delete [] xData(); - xData.set(new int32[numberOfChannels()]); + if (b.end()) { + totalNumberOfChannels = 0; - // initializing - for (int32 i = 0; i < numberOfChannels(); ++i) { - xData()[i] = i; - } + } else { + int32_t currentNbChannels = (*b).nbChannels; - xData.setSize(numberOfChannels()); + ++b; + while (!b.end()) { + currentNbChannels += (*b).nbChannels; + ++b; + } - // setting dynamic properties - for (int32 i = 0; i < numberOfADCs(); i++) { - delete [] histogram(i); - histogram.set(i, new int32[numberOfChannels()]); - histogram.setSize(i, numberOfChannels()); + totalNumberOfChannels = currentNbChannels; } - for (int32 i = numberOfADCs(); i < MAX_ADC; i++) { - histogram.set(i, 0); - histogram.setSize(i, 0); - } + cout << "totalNumberOfChannels " << totalNumberOfChannels() << endl; + + crateId.resize(totalNumberOfChannels()); + boardId.resize(totalNumberOfChannels()); + channelId.resize(totalNumberOfChannels()); + channelRate.resize(totalNumberOfChannels()); + xData.resize(totalNumberOfChannels()); + histogram.resize(totalNumberOfChannels()); + histogramName.resize(totalNumberOfChannels()); + xLegend.resize(totalNumberOfChannels()); + yLegend.resize(totalNumberOfChannels()); + + int32 i = 0; + + // Set the ids + BoardIterator bc; + while (!bc.end()) { + int32 nbChannels = (*bc).nbChannels; + int32 histogramSize = (1 << BoardDataResolution[(*bc).boardType]); + + for (int32 j = 0; j < nbChannels; ++j) { + crateId.set(i, bc.crate()); + boardId.set(i, bc.board()); + channelId.set(i, j); + channelRate.set(i, 0.0); + + delete [] xData(i); + int32 * values = new int32[histogramSize]; + for (int32 k = 0; k < histogramSize; ++k) { + values[k] = k; + } + xData.set(i, values); + xData.setSize(i, histogramSize); + + delete [] histogram(i); + int32 * data = new int32[histogramSize]; + memset(reinterpret_cast<void *>(data), 0, sizeof(int32) * histogramSize); + histogram.set(i, data); + histogram.setSize(i, histogramSize); + + string name("ADC"); + name += lexical_cast<string>((int)bc.crate()); + name += "."; + name += lexical_cast<string>(bc.board()); + name += "."; + name += lexical_cast<string>(j); + name += "T"; + histogramName.set(i, name); + + xLegend.set(i, "Energy"); + yLegend.set(i, "Counts"); + + ++i; + } - for (int32 i = 0; i < MAX_ADC; i++) { - ADCRate.set(i, 0.0); + ++bc; } } } + diff --git a/src/controllers/remotenpp/RemoteDPPHistogram.h b/src/controllers/remotenpp/RemoteDPPHistogram.h index 8cbca3cd..78f4a192 100644 --- a/src/controllers/remotenpp/RemoteDPPHistogram.h +++ b/src/controllers/remotenpp/RemoteDPPHistogram.h @@ -19,16 +19,14 @@ #ifndef NPP_REMOTEDPPHISTOGRAM_H #define NPP_REMOTEDPPHISTOGRAM_H -#include "../npp/DPPLiveProcess.h" -#include "DPPReader.h" -#include <nappli/nappli.h> +#include "RemoteDPPLiveProcess.h" #include <boost/thread.hpp> #include <stdint.h> #include <memory> namespace npp { -class RemoteDPPHistogram : public DPPLiveProcess { +class RemoteDPPHistogram : public RemoteDPPLiveProcess { public: //! Type of controller @@ -49,12 +47,14 @@ public: private: void resetData(); - std::auto_ptr<DPPReader> initTest(); - void testLoop(DPPReader * reader); - std::auto_ptr<boost::thread> startTest(DPPReader * reader); + std::auto_ptr<lstdpp::Reader> initTest(); + void testLoop(lstdpp::Reader * reader); + std::auto_ptr<boost::thread> startTest(lstdpp::Reader * reader); void finishTest(std::auto_ptr<boost::thread> thread); Property<std::string> serverEndpoint; + Property<int32> triggerCrate; + Property<int32> triggerBoard; Property<int32> triggerChannel; Property<int32> delay; Property<int32> dT; @@ -62,16 +62,24 @@ private: Property<int32> blockSize; Property<bool> test; Property<std::string> testFileName; - ArrayProperty<int32> xData; - Property<int32> one; Property<int32> refreshTimeS; + + Property<int32> totalNumberOfChannels; + + DynamicProperty<int32> crateId; + DynamicProperty<int32> boardId; + DynamicProperty<int32> channelId; + DynamicProperty<float64> channelRate; + + DynamicArrayProperty<int32> xData; DynamicArrayProperty<int32> histogram; - DynamicProperty<int32> ADCId; - DynamicProperty<float64> ADCRate; + DynamicProperty<std::string> histogramName; + DynamicProperty<std::string> xLegend; + DynamicProperty<std::string> yLegend; std::auto_ptr<nappli::Server> m_server; - std::auto_ptr<nappli::Application::Future> m_histoApplication; - auto_ptr<nappli::Application::Publisher> m_publisher; + std::auto_ptr<nappli::application::Instance> m_histoApplication; + std::auto_ptr<nappli::application::Publisher> m_publisher; static const int32 MAX_ADC = 128; }; diff --git a/src/controllers/remotenpp/RemoteDPPLiveProcess.cpp b/src/controllers/remotenpp/RemoteDPPLiveProcess.cpp new file mode 100644 index 00000000..57d3455d --- /dev/null +++ b/src/controllers/remotenpp/RemoteDPPLiveProcess.cpp @@ -0,0 +1,43 @@ +/* + * Nomad Instrument Control Software + * + * Copyright 2011 Institut Laue-Langevin + * + * Licensed under the EUPL, Version 1.1 only (the "License"); + * You may not use this work except in compliance with the Licence. + * You may obtain a copy of the Licence at: + * + * http://joinup.ec.europa.eu/software/page/eupl + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the Licence is distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Licence for the specific language governing permissions and + * limitations under the Licence. + */ + +#include "RemoteDPPLiveProcess.h" + +namespace npp { + +using namespace std; +using namespace common; +using namespace boost; +using namespace nappli; +using namespace lstdpp; + +const std::string RemoteDPPLiveProcess::TYPE = "remote_dpp_live_process"; + +RemoteDPPLiveProcess::RemoteDPPLiveProcess(const std::string& name) : + DPPLiveProcess(name) { +} + +RemoteDPPLiveProcess::RemoteDPPLiveProcess(const RemoteDPPLiveProcess& controller) : + DPPLiveProcess(controller) { +} + +RemoteDPPLiveProcess::~RemoteDPPLiveProcess() { +} + +} + diff --git a/src/controllers/remotenpp/RemoteDPPLiveProcess.h b/src/controllers/remotenpp/RemoteDPPLiveProcess.h new file mode 100644 index 00000000..41161af9 --- /dev/null +++ b/src/controllers/remotenpp/RemoteDPPLiveProcess.h @@ -0,0 +1,41 @@ +/* + * Nomad Instrument Control Software + * + * Copyright 2011 Institut Laue-Langevin + * + * Licensed under the EUPL, Version 1.1 only (the "License"); + * You may not use this work except in compliance with the Licence. + * You may obtain a copy of the Licence at: + * + * http://joinup.ec.europa.eu/software/page/eupl + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the Licence is distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Licence for the specific language governing permissions and + * limitations under the Licence. + */ + +#ifndef NPP_REMOTEDPPLIVEPROCESS_H +#define NPP_REMOTEDPPLIVEPROCESS_H + +#include "../npp/DPPLiveProcess.h" +#include <nappli/nappli.h> +#include <lstdpp/lstdpp.h> + +namespace npp { + +class RemoteDPPLiveProcess : public DPPLiveProcess { + +public: + //! Type of controller + static const std::string TYPE; + + RemoteDPPLiveProcess(const std::string& name); + RemoteDPPLiveProcess(const RemoteDPPLiveProcess& controller); + virtual ~RemoteDPPLiveProcess(); +}; + +} + +#endif diff --git a/src/controllers/remotenpp/gui/remote_dpp_coincidence/remote_dpp_coincidence.properties b/src/controllers/remotenpp/gui/remote_dpp_coincidence/remote_dpp_coincidence.properties index 84285b23..184e5f1c 100644 --- a/src/controllers/remotenpp/gui/remote_dpp_coincidence/remote_dpp_coincidence.properties +++ b/src/controllers/remotenpp/gui/remote_dpp_coincidence/remote_dpp_coincidence.properties @@ -15,9 +15,11 @@ dpp_coincidence.global_rate=Crystal rate dpp_coincidence.global_clean_rate=Crystal clean rate dpp_coincidence.detector_rate=Detector rate dpp_coincidence.detector_clean_rate=Detector clean rate -dpp_coincidence.adc_id=ADC -dpp_coincidence.adc_rate=ADC rate +dpp_coincidence.crate=Crate +dpp_coincidence.board=Board +dpp_coincidence.channel=Channel +dpp_coincidence.rate=Rate dpp_coincidence.rate_unit=c/s dpp_coincidence.coincidences=Coincidences diff --git a/src/controllers/remotenpp/gui/remote_dpp_coincidence/remote_dpp_coincidenceProperties.xml b/src/controllers/remotenpp/gui/remote_dpp_coincidence/remote_dpp_coincidenceProperties.xml index 77dcc3e8..9d757e0d 100644 --- a/src/controllers/remotenpp/gui/remote_dpp_coincidence/remote_dpp_coincidenceProperties.xml +++ b/src/controllers/remotenpp/gui/remote_dpp_coincidence/remote_dpp_coincidenceProperties.xml @@ -4,7 +4,7 @@ <property name="isCommand" type="boolean"> </property> - <property name="process_block_size" type="int32"> + <property name="block_size" type="int32"> </property> <property name="number_of_channels" type="int32"> @@ -24,12 +24,18 @@ <property name="clean_dT" type="int32"> </property> - - <property name="number_of_ADCs" type="int32"> - </property> <property name="n_order" type="Long"> </property> + + <property name="total_number_of_channels" type="int32"> + </property> + + <dynamic_property name="crate_id" size_property="total_number_of_channels" type="int32"> + </dynamic_property> + + <dynamic_property name="board_id" size_property="total_number_of_channels" type="int32"> + </dynamic_property> <dynamic_property name="order" size_property="n_order" type="Long"> </dynamic_property> @@ -50,11 +56,10 @@ <scientific_format nb_decimal_places="0"/> </dynamic_property> - <dynamic_property name="adc_id" size_property="number_of_ADCs" type="Long"> + <dynamic_property name="channel_id" size_property="total_number_of_channels" type="int32"> </dynamic_property> - <dynamic_property name="adc_rate" size_property="number_of_ADCs" type="Double"> - <scientific_format nb_decimal_places="0"/> + <dynamic_property name="channel_rate" size_property="total_number_of_channels" type="float64"> </dynamic_property> - + </controller> diff --git a/src/controllers/remotenpp/gui/remote_dpp_coincidence/remote_dpp_coincidenceView.xml b/src/controllers/remotenpp/gui/remote_dpp_coincidence/remote_dpp_coincidenceView.xml index 988f26b3..2fe20142 100644 --- a/src/controllers/remotenpp/gui/remote_dpp_coincidence/remote_dpp_coincidenceView.xml +++ b/src/controllers/remotenpp/gui/remote_dpp_coincidence/remote_dpp_coincidenceView.xml @@ -31,10 +31,19 @@ <newLine/> <newLine/> <group title="dpp_coincidence.adc_rates"> - <table_composite nbColumns="8" alignment="fill_horizontal"> - <dynamic_composite role="dpp_coincidence1" properties="adc_id,adc_rate"> - <label role="dpp_coincidence1" property="adc_id"/> - <label role="dpp_coincidence1" property="adc_rate" suffix="dpp_coincidence.rate_unit"/> + + <table_composite nbColumns="4" alignment="fill_horizontal"> + + <simple_label prefix="dpp_coincidence.crate" font_size="8" hAlignment="center" font_style="BOLD"/> + <simple_label prefix="dpp_coincidence.board" font_size="8" hAlignment="center" font_style="BOLD"/> + <simple_label prefix="dpp_coincidence.channel" font_size="8" hAlignment="center" font_style="BOLD"/> + <simple_label prefix="dpp_coincidence.rate" font_size="8" hAlignment="center" font_style="BOLD"/> + + <dynamic_composite role="dpp_coincidence1" properties="crate_id,board_id,channel_id,channel_rate"> + <label role="dpp_coincidence1" property="crate_id" hAlignment="center"/> + <label role="dpp_coincidence1" property="board_id" hAlignment="center"/> + <label role="dpp_coincidence1" property="channel_id" hAlignment="center"/> + <label role="dpp_coincidence1" property="channel_rate" suffix="dpp_coincidence.rate_unit" hAlignment="center"/> </dynamic_composite> </table_composite> </group> diff --git a/src/controllers/remotenpp/gui/remote_dpp_histogram/remote_dpp_histogram.properties b/src/controllers/remotenpp/gui/remote_dpp_histogram/remote_dpp_histogram.properties index 27c58937..655ab061 100644 --- a/src/controllers/remotenpp/gui/remote_dpp_histogram/remote_dpp_histogram.properties +++ b/src/controllers/remotenpp/gui/remote_dpp_histogram/remote_dpp_histogram.properties @@ -1,4 +1,7 @@ # labels + +dpp_histogram.trigger_crate=Trigger crate +dpp_histogram.trigger_board=Trigger board dpp_histogram.trigger_channel=Trigger channel dpp_histogram.delay=Delay dpp_histogram.gate_width=Gate width @@ -8,26 +11,16 @@ dpp_histogram.max_block=Max. number of blocks dpp_histogram.refresh_time=Refresh time dpp_histogram.refresh_time_unit=s +dpp_histogram.crate=Crate +dpp_histogram.board=Board +dpp_histogram.channel=Channel +dpp_histogram.rate=Rate +dpp_histogram.histogram=Histogram + + # plot dpp_histogram.plot_x_label=Energy dpp_histogram.plot_y_label=Counts - -dpp_histogram.histogramTitle0=ADC0T -dpp_histogram.histogramTitle1=ADC1T -dpp_histogram.histogramTitle2=ADC2T -dpp_histogram.histogramTitle3=ADC3T -dpp_histogram.histogramTitle4=ADC4T -dpp_histogram.histogramTitle5=ADC5T -dpp_histogram.histogramTitle6=ADC6T -dpp_histogram.histogramTitle7=ADC7T -dpp_histogram.histogramTitle8=ADC8T -dpp_histogram.histogramTitle9=ADC9T -dpp_histogram.histogramTitle10=ADC10T -dpp_histogram.histogramTitle11=ADC11T -dpp_histogram.histogramTitle12=ADC12T -dpp_histogram.histogramTitle13=ADC13T -dpp_histogram.histogramTitle14=ADC14T -dpp_histogram.histogramTitle15=ADC15T dpp_histogram.adcs=ADCs dpp_histogram.rate_unit=c/s \ No newline at end of file diff --git a/src/controllers/remotenpp/gui/remote_dpp_histogram/remote_dpp_histogramPlotDatas.xml b/src/controllers/remotenpp/gui/remote_dpp_histogram/remote_dpp_histogramPlotDatas.xml index 75f962cb..381bb7fb 100644 --- a/src/controllers/remotenpp/gui/remote_dpp_histogram/remote_dpp_histogramPlotDatas.xml +++ b/src/controllers/remotenpp/gui/remote_dpp_histogram/remote_dpp_histogramPlotDatas.xml @@ -1,5 +1,11 @@ <plotdatas> - <plotdata key="coincidenceHistogram.0" color="1F96C0" plugins="SETUP"> + + <dynamic_plotdata key="histogram_plot_data" color="1F96C0" size_property_role="dpp_histogram1" size_property="total_number_of_channels" legend_key="genericDataLabel" plugins="SETUP"> + <dataX p_role="dpp_histogram1" p_name="x_data"/> + <dataY p_role="dpp_histogram1" p_name="histogram"/> + </dynamic_plotdata> + +<!-- <plotdata key="coincidenceHistogram.0" color="1F96C0" plugins="SETUP"> <dataX p_role="dpp_histogram1" p_name="x_data"/> <dataY p_role="dpp_histogram1" p_name="histogram.0"/> </plotdata> @@ -62,5 +68,5 @@ <plotdata key="coincidenceHistogram.15" color="1F96C0" plugins="SETUP"> <dataX p_role="dpp_histogram1" p_name="x_data"/> <dataY p_role="dpp_histogram1" p_name="histogram.15"/> - </plotdata> + </plotdata> --> </plotdatas> diff --git a/src/controllers/remotenpp/gui/remote_dpp_histogram/remote_dpp_histogramProperties.xml b/src/controllers/remotenpp/gui/remote_dpp_histogram/remote_dpp_histogramProperties.xml index 4584b5ee..df9ff0c0 100644 --- a/src/controllers/remotenpp/gui/remote_dpp_histogram/remote_dpp_histogramProperties.xml +++ b/src/controllers/remotenpp/gui/remote_dpp_histogram/remote_dpp_histogramProperties.xml @@ -31,106 +31,36 @@ <property name="dT" type="int32"> </property> - <property name="number_of_ADCs" type="int32"> + <property name="total_number_of_channels" type="int32"> </property> - <property name="x_data" type="LongArray"> - </property> - - <property name="histogram.0" type="LongArray"> - </property> - - <property name="histogram.1" type="LongArray"> - </property> - - <property name="histogram.2" type="LongArray"> - </property> - - <property name="histogram.3" type="LongArray"> - </property> - - <property name="histogram.4" type="LongArray"> - </property> - - <property name="histogram.5" type="LongArray"> - </property> - - <property name="histogram.6" type="LongArray"> - </property> + <dynamic_property name="crate_id" size_property="total_number_of_channels" type="int32"> + </dynamic_property> - <property name="histogram.7" type="LongArray"> - </property> - - <property name="histogram.8" type="LongArray"> - </property> - - <property name="histogram.9" type="LongArray"> - </property> + <dynamic_property name="board_id" size_property="total_number_of_channels" type="int32"> + </dynamic_property> - <property name="histogram.10" type="LongArray"> - </property> + <dynamic_property name="channel_id" size_property="total_number_of_channels" type="int32"> + </dynamic_property> - <property name="histogram.11" type="LongArray"> - </property> + <dynamic_property name="channel_rate" size_property="total_number_of_channels" type="float64"> + </dynamic_property> - <property name="histogram.12" type="LongArray"> - </property> + <dynamic_property name="x_data" size_property="total_number_of_channels" type="int32array"> + </dynamic_property> - <property name="histogram.13" type="LongArray"> - </property> - - <property name="histogram.14" type="LongArray"> - </property> - - <property name="histogram.15" type="LongArray"> - </property> - - <property name="adc_rate.0" type="Double"> - </property> - - <property name="adc_rate.1" type="Double"> - </property> - - <property name="adc_rate.2" type="Double"> - </property> - - <property name="adc_rate.3" type="Double"> - </property> - - <property name="adc_rate.4" type="Double"> - </property> - - <property name="adc_rate.5" type="Double"> - </property> - - <property name="adc_rate.6" type="Double"> - </property> - - <property name="adc_rate.7" type="Double"> - </property> - - <property name="adc_rate.8" type="Double"> - </property> - - <property name="adc_rate.9" type="Double"> - </property> - - <property name="adc_rate.10" type="Double"> - </property> - - <property name="adc_rate.11" type="Double"> - </property> + <dynamic_property name="histogram" size_property="total_number_of_channels" type="int32array"> + </dynamic_property> + + <dynamic_property name="histogram_name" size_property="total_number_of_channels" type="string"> + </dynamic_property> - <property name="adc_rate.12" type="Double"> - </property> + <dynamic_property name="x_legend" size_property="total_number_of_channels" type="string"> + </dynamic_property> - <property name="adc_rate.13" type="Double"> - </property> + <dynamic_property name="y_legend" size_property="total_number_of_channels" type="string"> + </dynamic_property> - <property name="adc_rate.14" type="Double"> - </property> - - <property name="adc_rate.15" type="Double"> - </property> + </controller> diff --git a/src/controllers/remotenpp/gui/remote_dpp_histogram/remote_dpp_histogramView.xml b/src/controllers/remotenpp/gui/remote_dpp_histogram/remote_dpp_histogramView.xml index 81b8f746..0c6dcd1a 100644 --- a/src/controllers/remotenpp/gui/remote_dpp_histogram/remote_dpp_histogramView.xml +++ b/src/controllers/remotenpp/gui/remote_dpp_histogram/remote_dpp_histogramView.xml @@ -1,9 +1,15 @@ <plugin> <controller type="remote_dpp_histogram" role="dpp_histogram1"/> - <table_composite nbColumns="2"> + <table_composite nbColumns="6"> + + <simple_label prefix="dpp_histogram.trigger_crate"/> + <text role="dpp_histogram1" property="trigger_crate"/> + <simple_label prefix="dpp_histogram.trigger_board"/> + <text role="dpp_histogram1" property="trigger_board"/> <simple_label prefix="dpp_histogram.trigger_channel"/> <text role="dpp_histogram1" property="trigger_channel"/> + <simple_label prefix="dpp_histogram.delay"/> <text role="dpp_histogram1" property="delay" suffix="dpp_histogram.time_unit"/> <simple_label prefix="dpp_histogram.gate_width"/> @@ -20,70 +26,20 @@ <group title="dpp_histogram.adcs"> - <table_composite nbColumns="6"> - <simple_label prefix="dpp_histogram.histogramTitle0"/> - <plot_launcher role="dpp_histogram1" data="coincidenceHistogram.0" title="dpp_histogram.histogramTitle0" x_axis_title="dpp_histogram.plot_x_label" y_axis_title="dpp_histogram.plot_y_label" height="20"/> - <label role="dpp_histogram1" property="adc_rate.0" suffix="dpp_histogram.rate_unit"/> - - <simple_label prefix="dpp_histogram.histogramTitle1"/> - <plot_launcher role="dpp_histogram1" data="coincidenceHistogram.1" title="dpp_histogram.histogramTitle1" x_axis_title="dpp_histogram.plot_x_label" y_axis_title="dpp_histogram.plot_y_label" height="20"/> - <label role="dpp_histogram1" property="adc_rate.1" suffix="dpp_histogram.rate_unit"/> - - <simple_label prefix="dpp_histogram.histogramTitle2"/> - <plot_launcher role="dpp_histogram1" data="coincidenceHistogram.2" title="dpp_histogram.histogramTitle2" x_axis_title="dpp_histogram.plot_x_label" y_axis_title="dpp_histogram.plot_y_label" height="20"/> - <label role="dpp_histogram1" property="adc_rate.2" suffix="dpp_histogram.rate_unit"/> - - <simple_label prefix="dpp_histogram.histogramTitle3"/> - <plot_launcher role="dpp_histogram1" data="coincidenceHistogram.3" title="dpp_histogram.histogramTitle3" x_axis_title="dpp_histogram.plot_x_label" y_axis_title="dpp_histogram.plot_y_label" height="20"/> - <label role="dpp_histogram1" property="adc_rate.3" suffix="dpp_histogram.rate_unit"/> - - <simple_label prefix="dpp_histogram.histogramTitle4"/> - <plot_launcher role="dpp_histogram1" data="coincidenceHistogram.4" title="dpp_histogram.histogramTitle4" x_axis_title="dpp_histogram.plot_x_label" y_axis_title="dpp_histogram.plot_y_label" height="20"/> - <label role="dpp_histogram1" property="adc_rate.4" suffix="dpp_histogram.rate_unit"/> - - <simple_label prefix="dpp_histogram.histogramTitle5"/> - <plot_launcher role="dpp_histogram1" data="coincidenceHistogram.5" title="dpp_histogram.histogramTitle5" x_axis_title="dpp_histogram.plot_x_label" y_axis_title="dpp_histogram.plot_y_label" height="20"/> - <label role="dpp_histogram1" property="adc_rate.5" suffix="dpp_histogram.rate_unit"/> - - <simple_label prefix="dpp_histogram.histogramTitle6"/> - <plot_launcher role="dpp_histogram1" data="coincidenceHistogram.6" title="dpp_histogram.histogramTitle6" x_axis_title="dpp_histogram.plot_x_label" y_axis_title="dpp_histogram.plot_y_label" height="20"/> - <label role="dpp_histogram1" property="adc_rate.6" suffix="dpp_histogram.rate_unit"/> - - <simple_label prefix="dpp_histogram.histogramTitle7"/> - <plot_launcher role="dpp_histogram1" data="coincidenceHistogram.7" title="dpp_histogram.histogramTitle7" x_axis_title="dpp_histogram.plot_x_label" y_axis_title="dpp_histogram.plot_y_label" height="20"/> - <label role="dpp_histogram1" property="adc_rate.7" suffix="dpp_histogram.rate_unit"/> - - <simple_label prefix="dpp_histogram.histogramTitle8"/> - <plot_launcher role="dpp_histogram1" data="coincidenceHistogram.8" title="dpp_histogram.histogramTitle8" x_axis_title="dpp_histogram.plot_x_label" y_axis_title="dpp_histogram.plot_y_label" height="20"/> - <label role="dpp_histogram1" property="adc_rate.8" suffix="dpp_histogram.rate_unit"/> - - <simple_label prefix="dpp_histogram.histogramTitle9"/> - <plot_launcher role="dpp_histogram1" data="coincidenceHistogram.9" title="dpp_histogram.histogramTitle9" x_axis_title="dpp_histogram.plot_x_label" y_axis_title="dpp_histogram.plot_y_label" height="20"/> - <label role="dpp_histogram1" property="adc_rate.9" suffix="dpp_histogram.rate_unit"/> - - <simple_label prefix="dpp_histogram.histogramTitle10"/> - <plot_launcher role="dpp_histogram1" data="coincidenceHistogram.10" title="dpp_histogram.histogramTitle10" x_axis_title="dpp_histogram.plot_x_label" y_axis_title="dpp_histogram.plot_y_label" height="20"/> - <label role="dpp_histogram1" property="adc_rate.10" suffix="dpp_histogram.rate_unit"/> - - <simple_label prefix="dpp_histogram.histogramTitle11"/> - <plot_launcher role="dpp_histogram1" data="coincidenceHistogram.11" title="dpp_histogram.histogramTitle11" x_axis_title="dpp_histogram.plot_x_label" y_axis_title="dpp_histogram.plot_y_label" height="20"/> - <label role="dpp_histogram1" property="adc_rate.11" suffix="dpp_histogram.rate_unit"/> - - <simple_label prefix="dpp_histogram.histogramTitle12"/> - <plot_launcher role="dpp_histogram1" data="coincidenceHistogram.12" title="dpp_histogram.histogramTitle12" x_axis_title="dpp_histogram.plot_x_label" y_axis_title="dpp_histogram.plot_y_label" height="20"/> - <label role="dpp_histogram1" property="adc_rate.12" suffix="dpp_histogram.rate_unit"/> + <table_composite nbColumns="5"> + <simple_label prefix="dpp_histogram.crate" font_size="8" hAlignment="center" font_style="BOLD"/> + <simple_label prefix="dpp_histogram.board" font_size="8" hAlignment="center" font_style="BOLD"/> + <simple_label prefix="dpp_histogram.channel" font_size="8" hAlignment="center" font_style="BOLD"/> + <simple_label prefix="dpp_histogram.rate" font_size="8" hAlignment="center" font_style="BOLD"/> + <simple_label prefix="dpp_histogram.histogram" font_size="8" hAlignment="center" font_style="BOLD"/> - <simple_label prefix="dpp_histogram.histogramTitle13"/> - <plot_launcher role="dpp_histogram1" data="coincidenceHistogram.13" title="dpp_histogram.histogramTitle13" x_axis_title="dpp_histogram.plot_x_label" y_axis_title="dpp_histogram.plot_y_label" height="20"/> - <label role="dpp_histogram1" property="adc_rate.13" suffix="dpp_histogram.rate_unit"/> - - <simple_label prefix="dpp_histogram.histogramTitle14"/> - <plot_launcher role="dpp_histogram1" data="coincidenceHistogram.14" title="dpp_histogram.histogramTitle14" x_axis_title="dpp_histogram.plot_x_label" y_axis_title="dpp_histogram.plot_y_label" height="20"/> - <label role="dpp_histogram1" property="adc_rate.14" suffix="dpp_histogram.rate_unit"/> - - <simple_label prefix="dpp_histogram.histogramTitle15"/> - <plot_launcher role="dpp_histogram1" data="coincidenceHistogram.15" title="dpp_histogram.histogramTitle15" x_axis_title="dpp_histogram.plot_x_label" y_axis_title="dpp_histogram.plot_y_label" height="20"/> - <label role="dpp_histogram1" property="adc_rate.15" suffix="dpp_histogram.rate_unit"/> + <dynamic_composite role="dpp_histogram1" properties="histogram_plot_data,crate_id,board_id,channel_id,channel_rate"> + <label role="dpp_histogram1" property="crate_id" hAlignment="center"/> + <label role="dpp_histogram1" property="board_id" hAlignment="center"/> + <label role="dpp_histogram1" property="channel_id" hAlignment="center"/> + <label role="dpp_histogram1" property="channel_rate" suffix="dpp_coincidence.rate_unit" hAlignment="center"/> + <plot_launcher role="dpp_histogram1" data="histogram_plot_data" titleProperty="histogram_name" xAxisTitleProperty="x_legend" yAxisTitleProperty="y_legend" height="20"/> + </dynamic_composite> </table_composite> </group> diff --git a/src/controllers/remotetas/Module.xml b/src/controllers/remotetas/Module.xml new file mode 100644 index 00000000..98653695 --- /dev/null +++ b/src/controllers/remotetas/Module.xml @@ -0,0 +1,7 @@ +<module name="remotetas"> + <controller class="tas::RemoteMatlab"/> + + <include path="$(NOMAD_HOME)/../NomadModules/src"/> + + <!-- If necessary, regenerate the NumorMessages files with protoc --cpp_out=. NumorMessages.proto --> +</module> diff --git a/src/controllers/remotetas/NumorMessages.pb.cc b/src/controllers/remotetas/NumorMessages.pb.cc new file mode 100644 index 00000000..008a4fa7 --- /dev/null +++ b/src/controllers/remotetas/NumorMessages.pb.cc @@ -0,0 +1,1464 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: NumorMessages.proto + +#define INTERNAL_SUPPRESS_PROTOBUF_FIELD_DEPRECATION +#include "NumorMessages.pb.h" + +#include <algorithm> + +#include <google/protobuf/stubs/common.h> +#include <google/protobuf/stubs/once.h> +#include <google/protobuf/io/coded_stream.h> +#include <google/protobuf/wire_format_lite_inl.h> +#include <google/protobuf/descriptor.h> +#include <google/protobuf/generated_message_reflection.h> +#include <google/protobuf/reflection_ops.h> +#include <google/protobuf/wire_format.h> +// @@protoc_insertion_point(includes) + +namespace proto { + +namespace { + +const ::google::protobuf::Descriptor* NumorInfo_descriptor_ = NULL; +const ::google::protobuf::internal::GeneratedMessageReflection* + NumorInfo_reflection_ = NULL; +const ::google::protobuf::EnumDescriptor* NumorInfo_Type_descriptor_ = NULL; +const ::google::protobuf::Descriptor* NumorRequest_descriptor_ = NULL; +const ::google::protobuf::internal::GeneratedMessageReflection* + NumorRequest_reflection_ = NULL; +const ::google::protobuf::Descriptor* NumorResponse_descriptor_ = NULL; +const ::google::protobuf::internal::GeneratedMessageReflection* + NumorResponse_reflection_ = NULL; + +} // namespace + + +void protobuf_AssignDesc_NumorMessages_2eproto() { + protobuf_AddDesc_NumorMessages_2eproto(); + const ::google::protobuf::FileDescriptor* file = + ::google::protobuf::DescriptorPool::generated_pool()->FindFileByName( + "NumorMessages.proto"); + GOOGLE_CHECK(file != NULL); + NumorInfo_descriptor_ = file->message_type(0); + static const int NumorInfo_offsets_[10] = { + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(NumorInfo, type_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(NumorInfo, propid_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(NumorInfo, proposal_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(NumorInfo, instrid_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(NumorInfo, instrument_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(NumorInfo, sampid_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(NumorInfo, sample_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(NumorInfo, cycle_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(NumorInfo, imageid_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(NumorInfo, numor_), + }; + NumorInfo_reflection_ = + new ::google::protobuf::internal::GeneratedMessageReflection( + NumorInfo_descriptor_, + NumorInfo::default_instance_, + NumorInfo_offsets_, + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(NumorInfo, _has_bits_[0]), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(NumorInfo, _unknown_fields_), + -1, + ::google::protobuf::DescriptorPool::generated_pool(), + ::google::protobuf::MessageFactory::generated_factory(), + sizeof(NumorInfo)); + NumorInfo_Type_descriptor_ = NumorInfo_descriptor_->enum_type(0); + NumorRequest_descriptor_ = file->message_type(1); + static const int NumorRequest_offsets_[2] = { + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(NumorRequest, info_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(NumorRequest, content_), + }; + NumorRequest_reflection_ = + new ::google::protobuf::internal::GeneratedMessageReflection( + NumorRequest_descriptor_, + NumorRequest::default_instance_, + NumorRequest_offsets_, + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(NumorRequest, _has_bits_[0]), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(NumorRequest, _unknown_fields_), + -1, + ::google::protobuf::DescriptorPool::generated_pool(), + ::google::protobuf::MessageFactory::generated_factory(), + sizeof(NumorRequest)); + NumorResponse_descriptor_ = file->message_type(2); + static const int NumorResponse_offsets_[2] = { + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(NumorResponse, info_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(NumorResponse, image_), + }; + NumorResponse_reflection_ = + new ::google::protobuf::internal::GeneratedMessageReflection( + NumorResponse_descriptor_, + NumorResponse::default_instance_, + NumorResponse_offsets_, + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(NumorResponse, _has_bits_[0]), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(NumorResponse, _unknown_fields_), + -1, + ::google::protobuf::DescriptorPool::generated_pool(), + ::google::protobuf::MessageFactory::generated_factory(), + sizeof(NumorResponse)); +} + +namespace { + +GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AssignDescriptors_once_); +inline void protobuf_AssignDescriptorsOnce() { + ::google::protobuf::GoogleOnceInit(&protobuf_AssignDescriptors_once_, + &protobuf_AssignDesc_NumorMessages_2eproto); +} + +void protobuf_RegisterTypes(const ::std::string&) { + protobuf_AssignDescriptorsOnce(); + ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( + NumorInfo_descriptor_, &NumorInfo::default_instance()); + ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( + NumorRequest_descriptor_, &NumorRequest::default_instance()); + ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( + NumorResponse_descriptor_, &NumorResponse::default_instance()); +} + +} // namespace + +void protobuf_ShutdownFile_NumorMessages_2eproto() { + delete NumorInfo::default_instance_; + delete NumorInfo_reflection_; + delete NumorRequest::default_instance_; + delete NumorRequest_reflection_; + delete NumorResponse::default_instance_; + delete NumorResponse_reflection_; +} + +void protobuf_AddDesc_NumorMessages_2eproto() { + static bool already_here = false; + if (already_here) return; + already_here = true; + GOOGLE_PROTOBUF_VERIFY_VERSION; + + ::google::protobuf::DescriptorPool::InternalAddGeneratedFile( + "\n\023NumorMessages.proto\022\005proto\"\341\001\n\tNumorIn" + "fo\022#\n\004type\030\001 \002(\0162\025.proto.NumorInfo.Type\022" + "\016\n\006propid\030\002 \002(\t\022\020\n\010proposal\030\003 \002(\t\022\017\n\007ins" + "trid\030\004 \002(\t\022\022\n\ninstrument\030\005 \002(\t\022\016\n\006sampid" + "\030\006 \002(\t\022\016\n\006sample\030\007 \002(\t\022\r\n\005cycle\030\010 \002(\t\022\017\n" + "\007imageid\030\t \002(\t\022\r\n\005numor\030\n \002(\t\"\031\n\004Type\022\007\n" + "\003LOG\020\001\022\010\n\004LIVE\020\002\"\?\n\014NumorRequest\022\036\n\004info" + "\030\001 \002(\0132\020.proto.NumorInfo\022\017\n\007content\030\002 \002(" + "\t\">\n\rNumorResponse\022\036\n\004info\030\001 \002(\0132\020.proto" + ".NumorInfo\022\r\n\005image\030\002 \002(\014B\002H\001", 389); + ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile( + "NumorMessages.proto", &protobuf_RegisterTypes); + NumorInfo::default_instance_ = new NumorInfo(); + NumorRequest::default_instance_ = new NumorRequest(); + NumorResponse::default_instance_ = new NumorResponse(); + NumorInfo::default_instance_->InitAsDefaultInstance(); + NumorRequest::default_instance_->InitAsDefaultInstance(); + NumorResponse::default_instance_->InitAsDefaultInstance(); + ::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_NumorMessages_2eproto); +} + +// Force AddDescriptors() to be called at static initialization time. +struct StaticDescriptorInitializer_NumorMessages_2eproto { + StaticDescriptorInitializer_NumorMessages_2eproto() { + protobuf_AddDesc_NumorMessages_2eproto(); + } +} static_descriptor_initializer_NumorMessages_2eproto_; + +// =================================================================== + +const ::google::protobuf::EnumDescriptor* NumorInfo_Type_descriptor() { + protobuf_AssignDescriptorsOnce(); + return NumorInfo_Type_descriptor_; +} +bool NumorInfo_Type_IsValid(int value) { + switch(value) { + case 1: + case 2: + return true; + default: + return false; + } +} + +#ifndef _MSC_VER +const NumorInfo_Type NumorInfo::LOG; +const NumorInfo_Type NumorInfo::LIVE; +const NumorInfo_Type NumorInfo::Type_MIN; +const NumorInfo_Type NumorInfo::Type_MAX; +const int NumorInfo::Type_ARRAYSIZE; +#endif // _MSC_VER +#ifndef _MSC_VER +const int NumorInfo::kTypeFieldNumber; +const int NumorInfo::kPropidFieldNumber; +const int NumorInfo::kProposalFieldNumber; +const int NumorInfo::kInstridFieldNumber; +const int NumorInfo::kInstrumentFieldNumber; +const int NumorInfo::kSampidFieldNumber; +const int NumorInfo::kSampleFieldNumber; +const int NumorInfo::kCycleFieldNumber; +const int NumorInfo::kImageidFieldNumber; +const int NumorInfo::kNumorFieldNumber; +#endif // !_MSC_VER + +NumorInfo::NumorInfo() + : ::google::protobuf::Message() { + SharedCtor(); +} + +void NumorInfo::InitAsDefaultInstance() { +} + +NumorInfo::NumorInfo(const NumorInfo& from) + : ::google::protobuf::Message() { + SharedCtor(); + MergeFrom(from); +} + +void NumorInfo::SharedCtor() { + _cached_size_ = 0; + type_ = 1; + propid_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); + proposal_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); + instrid_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); + instrument_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); + sampid_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); + sample_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); + cycle_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); + imageid_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); + numor_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); + ::memset(_has_bits_, 0, sizeof(_has_bits_)); +} + +NumorInfo::~NumorInfo() { + SharedDtor(); +} + +void NumorInfo::SharedDtor() { + if (propid_ != &::google::protobuf::internal::kEmptyString) { + delete propid_; + } + if (proposal_ != &::google::protobuf::internal::kEmptyString) { + delete proposal_; + } + if (instrid_ != &::google::protobuf::internal::kEmptyString) { + delete instrid_; + } + if (instrument_ != &::google::protobuf::internal::kEmptyString) { + delete instrument_; + } + if (sampid_ != &::google::protobuf::internal::kEmptyString) { + delete sampid_; + } + if (sample_ != &::google::protobuf::internal::kEmptyString) { + delete sample_; + } + if (cycle_ != &::google::protobuf::internal::kEmptyString) { + delete cycle_; + } + if (imageid_ != &::google::protobuf::internal::kEmptyString) { + delete imageid_; + } + if (numor_ != &::google::protobuf::internal::kEmptyString) { + delete numor_; + } + if (this != default_instance_) { + } +} + +void NumorInfo::SetCachedSize(int size) const { + GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); + _cached_size_ = size; + GOOGLE_SAFE_CONCURRENT_WRITES_END(); +} +const ::google::protobuf::Descriptor* NumorInfo::descriptor() { + protobuf_AssignDescriptorsOnce(); + return NumorInfo_descriptor_; +} + +const NumorInfo& NumorInfo::default_instance() { + if (default_instance_ == NULL) protobuf_AddDesc_NumorMessages_2eproto(); + return *default_instance_; +} + +NumorInfo* NumorInfo::default_instance_ = NULL; + +NumorInfo* NumorInfo::New() const { + return new NumorInfo; +} + +void NumorInfo::Clear() { + if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { + type_ = 1; + if (has_propid()) { + if (propid_ != &::google::protobuf::internal::kEmptyString) { + propid_->clear(); + } + } + if (has_proposal()) { + if (proposal_ != &::google::protobuf::internal::kEmptyString) { + proposal_->clear(); + } + } + if (has_instrid()) { + if (instrid_ != &::google::protobuf::internal::kEmptyString) { + instrid_->clear(); + } + } + if (has_instrument()) { + if (instrument_ != &::google::protobuf::internal::kEmptyString) { + instrument_->clear(); + } + } + if (has_sampid()) { + if (sampid_ != &::google::protobuf::internal::kEmptyString) { + sampid_->clear(); + } + } + if (has_sample()) { + if (sample_ != &::google::protobuf::internal::kEmptyString) { + sample_->clear(); + } + } + if (has_cycle()) { + if (cycle_ != &::google::protobuf::internal::kEmptyString) { + cycle_->clear(); + } + } + } + if (_has_bits_[8 / 32] & (0xffu << (8 % 32))) { + if (has_imageid()) { + if (imageid_ != &::google::protobuf::internal::kEmptyString) { + imageid_->clear(); + } + } + if (has_numor()) { + if (numor_ != &::google::protobuf::internal::kEmptyString) { + numor_->clear(); + } + } + } + ::memset(_has_bits_, 0, sizeof(_has_bits_)); + mutable_unknown_fields()->Clear(); +} + +bool NumorInfo::MergePartialFromCodedStream( + ::google::protobuf::io::CodedInputStream* input) { +#define DO_(EXPRESSION) if (!(EXPRESSION)) return false + ::google::protobuf::uint32 tag; + while ((tag = input->ReadTag()) != 0) { + switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { + // required .proto.NumorInfo.Type type = 1; + case 1: { + if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == + ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + int value; + DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< + int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>( + input, &value))); + if (::proto::NumorInfo_Type_IsValid(value)) { + set_type(static_cast< ::proto::NumorInfo_Type >(value)); + } else { + mutable_unknown_fields()->AddVarint(1, value); + } + } else { + goto handle_uninterpreted; + } + if (input->ExpectTag(18)) goto parse_propid; + break; + } + + // required string propid = 2; + case 2: { + if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == + ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + parse_propid: + DO_(::google::protobuf::internal::WireFormatLite::ReadString( + input, this->mutable_propid())); + ::google::protobuf::internal::WireFormat::VerifyUTF8String( + this->propid().data(), this->propid().length(), + ::google::protobuf::internal::WireFormat::PARSE); + } else { + goto handle_uninterpreted; + } + if (input->ExpectTag(26)) goto parse_proposal; + break; + } + + // required string proposal = 3; + case 3: { + if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == + ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + parse_proposal: + DO_(::google::protobuf::internal::WireFormatLite::ReadString( + input, this->mutable_proposal())); + ::google::protobuf::internal::WireFormat::VerifyUTF8String( + this->proposal().data(), this->proposal().length(), + ::google::protobuf::internal::WireFormat::PARSE); + } else { + goto handle_uninterpreted; + } + if (input->ExpectTag(34)) goto parse_instrid; + break; + } + + // required string instrid = 4; + case 4: { + if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == + ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + parse_instrid: + DO_(::google::protobuf::internal::WireFormatLite::ReadString( + input, this->mutable_instrid())); + ::google::protobuf::internal::WireFormat::VerifyUTF8String( + this->instrid().data(), this->instrid().length(), + ::google::protobuf::internal::WireFormat::PARSE); + } else { + goto handle_uninterpreted; + } + if (input->ExpectTag(42)) goto parse_instrument; + break; + } + + // required string instrument = 5; + case 5: { + if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == + ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + parse_instrument: + DO_(::google::protobuf::internal::WireFormatLite::ReadString( + input, this->mutable_instrument())); + ::google::protobuf::internal::WireFormat::VerifyUTF8String( + this->instrument().data(), this->instrument().length(), + ::google::protobuf::internal::WireFormat::PARSE); + } else { + goto handle_uninterpreted; + } + if (input->ExpectTag(50)) goto parse_sampid; + break; + } + + // required string sampid = 6; + case 6: { + if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == + ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + parse_sampid: + DO_(::google::protobuf::internal::WireFormatLite::ReadString( + input, this->mutable_sampid())); + ::google::protobuf::internal::WireFormat::VerifyUTF8String( + this->sampid().data(), this->sampid().length(), + ::google::protobuf::internal::WireFormat::PARSE); + } else { + goto handle_uninterpreted; + } + if (input->ExpectTag(58)) goto parse_sample; + break; + } + + // required string sample = 7; + case 7: { + if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == + ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + parse_sample: + DO_(::google::protobuf::internal::WireFormatLite::ReadString( + input, this->mutable_sample())); + ::google::protobuf::internal::WireFormat::VerifyUTF8String( + this->sample().data(), this->sample().length(), + ::google::protobuf::internal::WireFormat::PARSE); + } else { + goto handle_uninterpreted; + } + if (input->ExpectTag(66)) goto parse_cycle; + break; + } + + // required string cycle = 8; + case 8: { + if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == + ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + parse_cycle: + DO_(::google::protobuf::internal::WireFormatLite::ReadString( + input, this->mutable_cycle())); + ::google::protobuf::internal::WireFormat::VerifyUTF8String( + this->cycle().data(), this->cycle().length(), + ::google::protobuf::internal::WireFormat::PARSE); + } else { + goto handle_uninterpreted; + } + if (input->ExpectTag(74)) goto parse_imageid; + break; + } + + // required string imageid = 9; + case 9: { + if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == + ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + parse_imageid: + DO_(::google::protobuf::internal::WireFormatLite::ReadString( + input, this->mutable_imageid())); + ::google::protobuf::internal::WireFormat::VerifyUTF8String( + this->imageid().data(), this->imageid().length(), + ::google::protobuf::internal::WireFormat::PARSE); + } else { + goto handle_uninterpreted; + } + if (input->ExpectTag(82)) goto parse_numor; + break; + } + + // required string numor = 10; + case 10: { + if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == + ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + parse_numor: + DO_(::google::protobuf::internal::WireFormatLite::ReadString( + input, this->mutable_numor())); + ::google::protobuf::internal::WireFormat::VerifyUTF8String( + this->numor().data(), this->numor().length(), + ::google::protobuf::internal::WireFormat::PARSE); + } else { + goto handle_uninterpreted; + } + if (input->ExpectAtEnd()) return true; + break; + } + + default: { + handle_uninterpreted: + if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == + ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { + return true; + } + DO_(::google::protobuf::internal::WireFormat::SkipField( + input, tag, mutable_unknown_fields())); + break; + } + } + } + return true; +#undef DO_ +} + +void NumorInfo::SerializeWithCachedSizes( + ::google::protobuf::io::CodedOutputStream* output) const { + // required .proto.NumorInfo.Type type = 1; + if (has_type()) { + ::google::protobuf::internal::WireFormatLite::WriteEnum( + 1, this->type(), output); + } + + // required string propid = 2; + if (has_propid()) { + ::google::protobuf::internal::WireFormat::VerifyUTF8String( + this->propid().data(), this->propid().length(), + ::google::protobuf::internal::WireFormat::SERIALIZE); + ::google::protobuf::internal::WireFormatLite::WriteString( + 2, this->propid(), output); + } + + // required string proposal = 3; + if (has_proposal()) { + ::google::protobuf::internal::WireFormat::VerifyUTF8String( + this->proposal().data(), this->proposal().length(), + ::google::protobuf::internal::WireFormat::SERIALIZE); + ::google::protobuf::internal::WireFormatLite::WriteString( + 3, this->proposal(), output); + } + + // required string instrid = 4; + if (has_instrid()) { + ::google::protobuf::internal::WireFormat::VerifyUTF8String( + this->instrid().data(), this->instrid().length(), + ::google::protobuf::internal::WireFormat::SERIALIZE); + ::google::protobuf::internal::WireFormatLite::WriteString( + 4, this->instrid(), output); + } + + // required string instrument = 5; + if (has_instrument()) { + ::google::protobuf::internal::WireFormat::VerifyUTF8String( + this->instrument().data(), this->instrument().length(), + ::google::protobuf::internal::WireFormat::SERIALIZE); + ::google::protobuf::internal::WireFormatLite::WriteString( + 5, this->instrument(), output); + } + + // required string sampid = 6; + if (has_sampid()) { + ::google::protobuf::internal::WireFormat::VerifyUTF8String( + this->sampid().data(), this->sampid().length(), + ::google::protobuf::internal::WireFormat::SERIALIZE); + ::google::protobuf::internal::WireFormatLite::WriteString( + 6, this->sampid(), output); + } + + // required string sample = 7; + if (has_sample()) { + ::google::protobuf::internal::WireFormat::VerifyUTF8String( + this->sample().data(), this->sample().length(), + ::google::protobuf::internal::WireFormat::SERIALIZE); + ::google::protobuf::internal::WireFormatLite::WriteString( + 7, this->sample(), output); + } + + // required string cycle = 8; + if (has_cycle()) { + ::google::protobuf::internal::WireFormat::VerifyUTF8String( + this->cycle().data(), this->cycle().length(), + ::google::protobuf::internal::WireFormat::SERIALIZE); + ::google::protobuf::internal::WireFormatLite::WriteString( + 8, this->cycle(), output); + } + + // required string imageid = 9; + if (has_imageid()) { + ::google::protobuf::internal::WireFormat::VerifyUTF8String( + this->imageid().data(), this->imageid().length(), + ::google::protobuf::internal::WireFormat::SERIALIZE); + ::google::protobuf::internal::WireFormatLite::WriteString( + 9, this->imageid(), output); + } + + // required string numor = 10; + if (has_numor()) { + ::google::protobuf::internal::WireFormat::VerifyUTF8String( + this->numor().data(), this->numor().length(), + ::google::protobuf::internal::WireFormat::SERIALIZE); + ::google::protobuf::internal::WireFormatLite::WriteString( + 10, this->numor(), output); + } + + if (!unknown_fields().empty()) { + ::google::protobuf::internal::WireFormat::SerializeUnknownFields( + unknown_fields(), output); + } +} + +::google::protobuf::uint8* NumorInfo::SerializeWithCachedSizesToArray( + ::google::protobuf::uint8* target) const { + // required .proto.NumorInfo.Type type = 1; + if (has_type()) { + target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray( + 1, this->type(), target); + } + + // required string propid = 2; + if (has_propid()) { + ::google::protobuf::internal::WireFormat::VerifyUTF8String( + this->propid().data(), this->propid().length(), + ::google::protobuf::internal::WireFormat::SERIALIZE); + target = + ::google::protobuf::internal::WireFormatLite::WriteStringToArray( + 2, this->propid(), target); + } + + // required string proposal = 3; + if (has_proposal()) { + ::google::protobuf::internal::WireFormat::VerifyUTF8String( + this->proposal().data(), this->proposal().length(), + ::google::protobuf::internal::WireFormat::SERIALIZE); + target = + ::google::protobuf::internal::WireFormatLite::WriteStringToArray( + 3, this->proposal(), target); + } + + // required string instrid = 4; + if (has_instrid()) { + ::google::protobuf::internal::WireFormat::VerifyUTF8String( + this->instrid().data(), this->instrid().length(), + ::google::protobuf::internal::WireFormat::SERIALIZE); + target = + ::google::protobuf::internal::WireFormatLite::WriteStringToArray( + 4, this->instrid(), target); + } + + // required string instrument = 5; + if (has_instrument()) { + ::google::protobuf::internal::WireFormat::VerifyUTF8String( + this->instrument().data(), this->instrument().length(), + ::google::protobuf::internal::WireFormat::SERIALIZE); + target = + ::google::protobuf::internal::WireFormatLite::WriteStringToArray( + 5, this->instrument(), target); + } + + // required string sampid = 6; + if (has_sampid()) { + ::google::protobuf::internal::WireFormat::VerifyUTF8String( + this->sampid().data(), this->sampid().length(), + ::google::protobuf::internal::WireFormat::SERIALIZE); + target = + ::google::protobuf::internal::WireFormatLite::WriteStringToArray( + 6, this->sampid(), target); + } + + // required string sample = 7; + if (has_sample()) { + ::google::protobuf::internal::WireFormat::VerifyUTF8String( + this->sample().data(), this->sample().length(), + ::google::protobuf::internal::WireFormat::SERIALIZE); + target = + ::google::protobuf::internal::WireFormatLite::WriteStringToArray( + 7, this->sample(), target); + } + + // required string cycle = 8; + if (has_cycle()) { + ::google::protobuf::internal::WireFormat::VerifyUTF8String( + this->cycle().data(), this->cycle().length(), + ::google::protobuf::internal::WireFormat::SERIALIZE); + target = + ::google::protobuf::internal::WireFormatLite::WriteStringToArray( + 8, this->cycle(), target); + } + + // required string imageid = 9; + if (has_imageid()) { + ::google::protobuf::internal::WireFormat::VerifyUTF8String( + this->imageid().data(), this->imageid().length(), + ::google::protobuf::internal::WireFormat::SERIALIZE); + target = + ::google::protobuf::internal::WireFormatLite::WriteStringToArray( + 9, this->imageid(), target); + } + + // required string numor = 10; + if (has_numor()) { + ::google::protobuf::internal::WireFormat::VerifyUTF8String( + this->numor().data(), this->numor().length(), + ::google::protobuf::internal::WireFormat::SERIALIZE); + target = + ::google::protobuf::internal::WireFormatLite::WriteStringToArray( + 10, this->numor(), target); + } + + if (!unknown_fields().empty()) { + target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( + unknown_fields(), target); + } + return target; +} + +int NumorInfo::ByteSize() const { + int total_size = 0; + + if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { + // required .proto.NumorInfo.Type type = 1; + if (has_type()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::EnumSize(this->type()); + } + + // required string propid = 2; + if (has_propid()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::StringSize( + this->propid()); + } + + // required string proposal = 3; + if (has_proposal()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::StringSize( + this->proposal()); + } + + // required string instrid = 4; + if (has_instrid()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::StringSize( + this->instrid()); + } + + // required string instrument = 5; + if (has_instrument()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::StringSize( + this->instrument()); + } + + // required string sampid = 6; + if (has_sampid()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::StringSize( + this->sampid()); + } + + // required string sample = 7; + if (has_sample()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::StringSize( + this->sample()); + } + + // required string cycle = 8; + if (has_cycle()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::StringSize( + this->cycle()); + } + + } + if (_has_bits_[8 / 32] & (0xffu << (8 % 32))) { + // required string imageid = 9; + if (has_imageid()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::StringSize( + this->imageid()); + } + + // required string numor = 10; + if (has_numor()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::StringSize( + this->numor()); + } + + } + if (!unknown_fields().empty()) { + total_size += + ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( + unknown_fields()); + } + GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); + _cached_size_ = total_size; + GOOGLE_SAFE_CONCURRENT_WRITES_END(); + return total_size; +} + +void NumorInfo::MergeFrom(const ::google::protobuf::Message& from) { + GOOGLE_CHECK_NE(&from, this); + const NumorInfo* source = + ::google::protobuf::internal::dynamic_cast_if_available<const NumorInfo*>( + &from); + if (source == NULL) { + ::google::protobuf::internal::ReflectionOps::Merge(from, this); + } else { + MergeFrom(*source); + } +} + +void NumorInfo::MergeFrom(const NumorInfo& from) { + GOOGLE_CHECK_NE(&from, this); + if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { + if (from.has_type()) { + set_type(from.type()); + } + if (from.has_propid()) { + set_propid(from.propid()); + } + if (from.has_proposal()) { + set_proposal(from.proposal()); + } + if (from.has_instrid()) { + set_instrid(from.instrid()); + } + if (from.has_instrument()) { + set_instrument(from.instrument()); + } + if (from.has_sampid()) { + set_sampid(from.sampid()); + } + if (from.has_sample()) { + set_sample(from.sample()); + } + if (from.has_cycle()) { + set_cycle(from.cycle()); + } + } + if (from._has_bits_[8 / 32] & (0xffu << (8 % 32))) { + if (from.has_imageid()) { + set_imageid(from.imageid()); + } + if (from.has_numor()) { + set_numor(from.numor()); + } + } + mutable_unknown_fields()->MergeFrom(from.unknown_fields()); +} + +void NumorInfo::CopyFrom(const ::google::protobuf::Message& from) { + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +void NumorInfo::CopyFrom(const NumorInfo& from) { + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +bool NumorInfo::IsInitialized() const { + if ((_has_bits_[0] & 0x000003ff) != 0x000003ff) return false; + + return true; +} + +void NumorInfo::Swap(NumorInfo* other) { + if (other != this) { + std::swap(type_, other->type_); + std::swap(propid_, other->propid_); + std::swap(proposal_, other->proposal_); + std::swap(instrid_, other->instrid_); + std::swap(instrument_, other->instrument_); + std::swap(sampid_, other->sampid_); + std::swap(sample_, other->sample_); + std::swap(cycle_, other->cycle_); + std::swap(imageid_, other->imageid_); + std::swap(numor_, other->numor_); + std::swap(_has_bits_[0], other->_has_bits_[0]); + _unknown_fields_.Swap(&other->_unknown_fields_); + std::swap(_cached_size_, other->_cached_size_); + } +} + +::google::protobuf::Metadata NumorInfo::GetMetadata() const { + protobuf_AssignDescriptorsOnce(); + ::google::protobuf::Metadata metadata; + metadata.descriptor = NumorInfo_descriptor_; + metadata.reflection = NumorInfo_reflection_; + return metadata; +} + + +// =================================================================== + +#ifndef _MSC_VER +const int NumorRequest::kInfoFieldNumber; +const int NumorRequest::kContentFieldNumber; +#endif // !_MSC_VER + +NumorRequest::NumorRequest() + : ::google::protobuf::Message() { + SharedCtor(); +} + +void NumorRequest::InitAsDefaultInstance() { + info_ = const_cast< ::proto::NumorInfo*>(&::proto::NumorInfo::default_instance()); +} + +NumorRequest::NumorRequest(const NumorRequest& from) + : ::google::protobuf::Message() { + SharedCtor(); + MergeFrom(from); +} + +void NumorRequest::SharedCtor() { + _cached_size_ = 0; + info_ = NULL; + content_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); + ::memset(_has_bits_, 0, sizeof(_has_bits_)); +} + +NumorRequest::~NumorRequest() { + SharedDtor(); +} + +void NumorRequest::SharedDtor() { + if (content_ != &::google::protobuf::internal::kEmptyString) { + delete content_; + } + if (this != default_instance_) { + delete info_; + } +} + +void NumorRequest::SetCachedSize(int size) const { + GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); + _cached_size_ = size; + GOOGLE_SAFE_CONCURRENT_WRITES_END(); +} +const ::google::protobuf::Descriptor* NumorRequest::descriptor() { + protobuf_AssignDescriptorsOnce(); + return NumorRequest_descriptor_; +} + +const NumorRequest& NumorRequest::default_instance() { + if (default_instance_ == NULL) protobuf_AddDesc_NumorMessages_2eproto(); + return *default_instance_; +} + +NumorRequest* NumorRequest::default_instance_ = NULL; + +NumorRequest* NumorRequest::New() const { + return new NumorRequest; +} + +void NumorRequest::Clear() { + if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { + if (has_info()) { + if (info_ != NULL) info_->::proto::NumorInfo::Clear(); + } + if (has_content()) { + if (content_ != &::google::protobuf::internal::kEmptyString) { + content_->clear(); + } + } + } + ::memset(_has_bits_, 0, sizeof(_has_bits_)); + mutable_unknown_fields()->Clear(); +} + +bool NumorRequest::MergePartialFromCodedStream( + ::google::protobuf::io::CodedInputStream* input) { +#define DO_(EXPRESSION) if (!(EXPRESSION)) return false + ::google::protobuf::uint32 tag; + while ((tag = input->ReadTag()) != 0) { + switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { + // required .proto.NumorInfo info = 1; + case 1: { + if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == + ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( + input, mutable_info())); + } else { + goto handle_uninterpreted; + } + if (input->ExpectTag(18)) goto parse_content; + break; + } + + // required string content = 2; + case 2: { + if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == + ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + parse_content: + DO_(::google::protobuf::internal::WireFormatLite::ReadString( + input, this->mutable_content())); + ::google::protobuf::internal::WireFormat::VerifyUTF8String( + this->content().data(), this->content().length(), + ::google::protobuf::internal::WireFormat::PARSE); + } else { + goto handle_uninterpreted; + } + if (input->ExpectAtEnd()) return true; + break; + } + + default: { + handle_uninterpreted: + if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == + ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { + return true; + } + DO_(::google::protobuf::internal::WireFormat::SkipField( + input, tag, mutable_unknown_fields())); + break; + } + } + } + return true; +#undef DO_ +} + +void NumorRequest::SerializeWithCachedSizes( + ::google::protobuf::io::CodedOutputStream* output) const { + // required .proto.NumorInfo info = 1; + if (has_info()) { + ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( + 1, this->info(), output); + } + + // required string content = 2; + if (has_content()) { + ::google::protobuf::internal::WireFormat::VerifyUTF8String( + this->content().data(), this->content().length(), + ::google::protobuf::internal::WireFormat::SERIALIZE); + ::google::protobuf::internal::WireFormatLite::WriteString( + 2, this->content(), output); + } + + if (!unknown_fields().empty()) { + ::google::protobuf::internal::WireFormat::SerializeUnknownFields( + unknown_fields(), output); + } +} + +::google::protobuf::uint8* NumorRequest::SerializeWithCachedSizesToArray( + ::google::protobuf::uint8* target) const { + // required .proto.NumorInfo info = 1; + if (has_info()) { + target = ::google::protobuf::internal::WireFormatLite:: + WriteMessageNoVirtualToArray( + 1, this->info(), target); + } + + // required string content = 2; + if (has_content()) { + ::google::protobuf::internal::WireFormat::VerifyUTF8String( + this->content().data(), this->content().length(), + ::google::protobuf::internal::WireFormat::SERIALIZE); + target = + ::google::protobuf::internal::WireFormatLite::WriteStringToArray( + 2, this->content(), target); + } + + if (!unknown_fields().empty()) { + target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( + unknown_fields(), target); + } + return target; +} + +int NumorRequest::ByteSize() const { + int total_size = 0; + + if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { + // required .proto.NumorInfo info = 1; + if (has_info()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + this->info()); + } + + // required string content = 2; + if (has_content()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::StringSize( + this->content()); + } + + } + if (!unknown_fields().empty()) { + total_size += + ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( + unknown_fields()); + } + GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); + _cached_size_ = total_size; + GOOGLE_SAFE_CONCURRENT_WRITES_END(); + return total_size; +} + +void NumorRequest::MergeFrom(const ::google::protobuf::Message& from) { + GOOGLE_CHECK_NE(&from, this); + const NumorRequest* source = + ::google::protobuf::internal::dynamic_cast_if_available<const NumorRequest*>( + &from); + if (source == NULL) { + ::google::protobuf::internal::ReflectionOps::Merge(from, this); + } else { + MergeFrom(*source); + } +} + +void NumorRequest::MergeFrom(const NumorRequest& from) { + GOOGLE_CHECK_NE(&from, this); + if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { + if (from.has_info()) { + mutable_info()->::proto::NumorInfo::MergeFrom(from.info()); + } + if (from.has_content()) { + set_content(from.content()); + } + } + mutable_unknown_fields()->MergeFrom(from.unknown_fields()); +} + +void NumorRequest::CopyFrom(const ::google::protobuf::Message& from) { + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +void NumorRequest::CopyFrom(const NumorRequest& from) { + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +bool NumorRequest::IsInitialized() const { + if ((_has_bits_[0] & 0x00000003) != 0x00000003) return false; + + if (has_info()) { + if (!this->info().IsInitialized()) return false; + } + return true; +} + +void NumorRequest::Swap(NumorRequest* other) { + if (other != this) { + std::swap(info_, other->info_); + std::swap(content_, other->content_); + std::swap(_has_bits_[0], other->_has_bits_[0]); + _unknown_fields_.Swap(&other->_unknown_fields_); + std::swap(_cached_size_, other->_cached_size_); + } +} + +::google::protobuf::Metadata NumorRequest::GetMetadata() const { + protobuf_AssignDescriptorsOnce(); + ::google::protobuf::Metadata metadata; + metadata.descriptor = NumorRequest_descriptor_; + metadata.reflection = NumorRequest_reflection_; + return metadata; +} + + +// =================================================================== + +#ifndef _MSC_VER +const int NumorResponse::kInfoFieldNumber; +const int NumorResponse::kImageFieldNumber; +#endif // !_MSC_VER + +NumorResponse::NumorResponse() + : ::google::protobuf::Message() { + SharedCtor(); +} + +void NumorResponse::InitAsDefaultInstance() { + info_ = const_cast< ::proto::NumorInfo*>(&::proto::NumorInfo::default_instance()); +} + +NumorResponse::NumorResponse(const NumorResponse& from) + : ::google::protobuf::Message() { + SharedCtor(); + MergeFrom(from); +} + +void NumorResponse::SharedCtor() { + _cached_size_ = 0; + info_ = NULL; + image_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); + ::memset(_has_bits_, 0, sizeof(_has_bits_)); +} + +NumorResponse::~NumorResponse() { + SharedDtor(); +} + +void NumorResponse::SharedDtor() { + if (image_ != &::google::protobuf::internal::kEmptyString) { + delete image_; + } + if (this != default_instance_) { + delete info_; + } +} + +void NumorResponse::SetCachedSize(int size) const { + GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); + _cached_size_ = size; + GOOGLE_SAFE_CONCURRENT_WRITES_END(); +} +const ::google::protobuf::Descriptor* NumorResponse::descriptor() { + protobuf_AssignDescriptorsOnce(); + return NumorResponse_descriptor_; +} + +const NumorResponse& NumorResponse::default_instance() { + if (default_instance_ == NULL) protobuf_AddDesc_NumorMessages_2eproto(); + return *default_instance_; +} + +NumorResponse* NumorResponse::default_instance_ = NULL; + +NumorResponse* NumorResponse::New() const { + return new NumorResponse; +} + +void NumorResponse::Clear() { + if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { + if (has_info()) { + if (info_ != NULL) info_->::proto::NumorInfo::Clear(); + } + if (has_image()) { + if (image_ != &::google::protobuf::internal::kEmptyString) { + image_->clear(); + } + } + } + ::memset(_has_bits_, 0, sizeof(_has_bits_)); + mutable_unknown_fields()->Clear(); +} + +bool NumorResponse::MergePartialFromCodedStream( + ::google::protobuf::io::CodedInputStream* input) { +#define DO_(EXPRESSION) if (!(EXPRESSION)) return false + ::google::protobuf::uint32 tag; + while ((tag = input->ReadTag()) != 0) { + switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { + // required .proto.NumorInfo info = 1; + case 1: { + if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == + ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( + input, mutable_info())); + } else { + goto handle_uninterpreted; + } + if (input->ExpectTag(18)) goto parse_image; + break; + } + + // required bytes image = 2; + case 2: { + if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == + ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + parse_image: + DO_(::google::protobuf::internal::WireFormatLite::ReadBytes( + input, this->mutable_image())); + } else { + goto handle_uninterpreted; + } + if (input->ExpectAtEnd()) return true; + break; + } + + default: { + handle_uninterpreted: + if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == + ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { + return true; + } + DO_(::google::protobuf::internal::WireFormat::SkipField( + input, tag, mutable_unknown_fields())); + break; + } + } + } + return true; +#undef DO_ +} + +void NumorResponse::SerializeWithCachedSizes( + ::google::protobuf::io::CodedOutputStream* output) const { + // required .proto.NumorInfo info = 1; + if (has_info()) { + ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( + 1, this->info(), output); + } + + // required bytes image = 2; + if (has_image()) { + ::google::protobuf::internal::WireFormatLite::WriteBytes( + 2, this->image(), output); + } + + if (!unknown_fields().empty()) { + ::google::protobuf::internal::WireFormat::SerializeUnknownFields( + unknown_fields(), output); + } +} + +::google::protobuf::uint8* NumorResponse::SerializeWithCachedSizesToArray( + ::google::protobuf::uint8* target) const { + // required .proto.NumorInfo info = 1; + if (has_info()) { + target = ::google::protobuf::internal::WireFormatLite:: + WriteMessageNoVirtualToArray( + 1, this->info(), target); + } + + // required bytes image = 2; + if (has_image()) { + target = + ::google::protobuf::internal::WireFormatLite::WriteBytesToArray( + 2, this->image(), target); + } + + if (!unknown_fields().empty()) { + target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( + unknown_fields(), target); + } + return target; +} + +int NumorResponse::ByteSize() const { + int total_size = 0; + + if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { + // required .proto.NumorInfo info = 1; + if (has_info()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + this->info()); + } + + // required bytes image = 2; + if (has_image()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::BytesSize( + this->image()); + } + + } + if (!unknown_fields().empty()) { + total_size += + ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( + unknown_fields()); + } + GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); + _cached_size_ = total_size; + GOOGLE_SAFE_CONCURRENT_WRITES_END(); + return total_size; +} + +void NumorResponse::MergeFrom(const ::google::protobuf::Message& from) { + GOOGLE_CHECK_NE(&from, this); + const NumorResponse* source = + ::google::protobuf::internal::dynamic_cast_if_available<const NumorResponse*>( + &from); + if (source == NULL) { + ::google::protobuf::internal::ReflectionOps::Merge(from, this); + } else { + MergeFrom(*source); + } +} + +void NumorResponse::MergeFrom(const NumorResponse& from) { + GOOGLE_CHECK_NE(&from, this); + if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { + if (from.has_info()) { + mutable_info()->::proto::NumorInfo::MergeFrom(from.info()); + } + if (from.has_image()) { + set_image(from.image()); + } + } + mutable_unknown_fields()->MergeFrom(from.unknown_fields()); +} + +void NumorResponse::CopyFrom(const ::google::protobuf::Message& from) { + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +void NumorResponse::CopyFrom(const NumorResponse& from) { + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +bool NumorResponse::IsInitialized() const { + if ((_has_bits_[0] & 0x00000003) != 0x00000003) return false; + + if (has_info()) { + if (!this->info().IsInitialized()) return false; + } + return true; +} + +void NumorResponse::Swap(NumorResponse* other) { + if (other != this) { + std::swap(info_, other->info_); + std::swap(image_, other->image_); + std::swap(_has_bits_[0], other->_has_bits_[0]); + _unknown_fields_.Swap(&other->_unknown_fields_); + std::swap(_cached_size_, other->_cached_size_); + } +} + +::google::protobuf::Metadata NumorResponse::GetMetadata() const { + protobuf_AssignDescriptorsOnce(); + ::google::protobuf::Metadata metadata; + metadata.descriptor = NumorResponse_descriptor_; + metadata.reflection = NumorResponse_reflection_; + return metadata; +} + + +// @@protoc_insertion_point(namespace_scope) + +} // namespace proto + +// @@protoc_insertion_point(global_scope) diff --git a/src/controllers/remotetas/NumorMessages.pb.h b/src/controllers/remotetas/NumorMessages.pb.h new file mode 100644 index 00000000..017fbfff --- /dev/null +++ b/src/controllers/remotetas/NumorMessages.pb.h @@ -0,0 +1,1403 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: NumorMessages.proto + +#ifndef PROTOBUF_NumorMessages_2eproto__INCLUDED +#define PROTOBUF_NumorMessages_2eproto__INCLUDED + +#include <string> + +#include <google/protobuf/stubs/common.h> + +#if GOOGLE_PROTOBUF_VERSION < 2005000 +#error This file was generated by a newer version of protoc which is +#error incompatible with your Protocol Buffer headers. Please update +#error your headers. +#endif +#if 2005000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION +#error This file was generated by an older version of protoc which is +#error incompatible with your Protocol Buffer headers. Please +#error regenerate this file with a newer version of protoc. +#endif + +#include <google/protobuf/generated_message_util.h> +#include <google/protobuf/message.h> +#include <google/protobuf/repeated_field.h> +#include <google/protobuf/extension_set.h> +#include <google/protobuf/generated_enum_reflection.h> +#include <google/protobuf/unknown_field_set.h> +// @@protoc_insertion_point(includes) + +namespace proto { + +// Internal implementation detail -- do not call these. +void protobuf_AddDesc_NumorMessages_2eproto(); +void protobuf_AssignDesc_NumorMessages_2eproto(); +void protobuf_ShutdownFile_NumorMessages_2eproto(); + +class NumorInfo; +class NumorRequest; +class NumorResponse; + +enum NumorInfo_Type { + NumorInfo_Type_LOG = 1, + NumorInfo_Type_LIVE = 2 +}; +bool NumorInfo_Type_IsValid(int value); +const NumorInfo_Type NumorInfo_Type_Type_MIN = NumorInfo_Type_LOG; +const NumorInfo_Type NumorInfo_Type_Type_MAX = NumorInfo_Type_LIVE; +const int NumorInfo_Type_Type_ARRAYSIZE = NumorInfo_Type_Type_MAX + 1; + +const ::google::protobuf::EnumDescriptor* NumorInfo_Type_descriptor(); +inline const ::std::string& NumorInfo_Type_Name(NumorInfo_Type value) { + return ::google::protobuf::internal::NameOfEnum( + NumorInfo_Type_descriptor(), value); +} +inline bool NumorInfo_Type_Parse( + const ::std::string& name, NumorInfo_Type* value) { + return ::google::protobuf::internal::ParseNamedEnum<NumorInfo_Type>( + NumorInfo_Type_descriptor(), name, value); +} +// =================================================================== + +class NumorInfo : public ::google::protobuf::Message { + public: + NumorInfo(); + virtual ~NumorInfo(); + + NumorInfo(const NumorInfo& from); + + inline NumorInfo& operator=(const NumorInfo& from) { + CopyFrom(from); + return *this; + } + + inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { + return _unknown_fields_; + } + + inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { + return &_unknown_fields_; + } + + static const ::google::protobuf::Descriptor* descriptor(); + static const NumorInfo& default_instance(); + + void Swap(NumorInfo* other); + + // implements Message ---------------------------------------------- + + NumorInfo* New() const; + void CopyFrom(const ::google::protobuf::Message& from); + void MergeFrom(const ::google::protobuf::Message& from); + void CopyFrom(const NumorInfo& from); + void MergeFrom(const NumorInfo& from); + void Clear(); + bool IsInitialized() const; + + int ByteSize() const; + bool MergePartialFromCodedStream( + ::google::protobuf::io::CodedInputStream* input); + void SerializeWithCachedSizes( + ::google::protobuf::io::CodedOutputStream* output) const; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const; + int GetCachedSize() const { return _cached_size_; } + private: + void SharedCtor(); + void SharedDtor(); + void SetCachedSize(int size) const; + public: + + ::google::protobuf::Metadata GetMetadata() const; + + // nested types ---------------------------------------------------- + + typedef NumorInfo_Type Type; + static const Type LOG = NumorInfo_Type_LOG; + static const Type LIVE = NumorInfo_Type_LIVE; + static inline bool Type_IsValid(int value) { + return NumorInfo_Type_IsValid(value); + } + static const Type Type_MIN = + NumorInfo_Type_Type_MIN; + static const Type Type_MAX = + NumorInfo_Type_Type_MAX; + static const int Type_ARRAYSIZE = + NumorInfo_Type_Type_ARRAYSIZE; + static inline const ::google::protobuf::EnumDescriptor* + Type_descriptor() { + return NumorInfo_Type_descriptor(); + } + static inline const ::std::string& Type_Name(Type value) { + return NumorInfo_Type_Name(value); + } + static inline bool Type_Parse(const ::std::string& name, + Type* value) { + return NumorInfo_Type_Parse(name, value); + } + + // accessors ------------------------------------------------------- + + // required .proto.NumorInfo.Type type = 1; + inline bool has_type() const; + inline void clear_type(); + static const int kTypeFieldNumber = 1; + inline ::proto::NumorInfo_Type type() const; + inline void set_type(::proto::NumorInfo_Type value); + + // required string propid = 2; + inline bool has_propid() const; + inline void clear_propid(); + static const int kPropidFieldNumber = 2; + inline const ::std::string& propid() const; + inline void set_propid(const ::std::string& value); + inline void set_propid(const char* value); + inline void set_propid(const char* value, size_t size); + inline ::std::string* mutable_propid(); + inline ::std::string* release_propid(); + inline void set_allocated_propid(::std::string* propid); + + // required string proposal = 3; + inline bool has_proposal() const; + inline void clear_proposal(); + static const int kProposalFieldNumber = 3; + inline const ::std::string& proposal() const; + inline void set_proposal(const ::std::string& value); + inline void set_proposal(const char* value); + inline void set_proposal(const char* value, size_t size); + inline ::std::string* mutable_proposal(); + inline ::std::string* release_proposal(); + inline void set_allocated_proposal(::std::string* proposal); + + // required string instrid = 4; + inline bool has_instrid() const; + inline void clear_instrid(); + static const int kInstridFieldNumber = 4; + inline const ::std::string& instrid() const; + inline void set_instrid(const ::std::string& value); + inline void set_instrid(const char* value); + inline void set_instrid(const char* value, size_t size); + inline ::std::string* mutable_instrid(); + inline ::std::string* release_instrid(); + inline void set_allocated_instrid(::std::string* instrid); + + // required string instrument = 5; + inline bool has_instrument() const; + inline void clear_instrument(); + static const int kInstrumentFieldNumber = 5; + inline const ::std::string& instrument() const; + inline void set_instrument(const ::std::string& value); + inline void set_instrument(const char* value); + inline void set_instrument(const char* value, size_t size); + inline ::std::string* mutable_instrument(); + inline ::std::string* release_instrument(); + inline void set_allocated_instrument(::std::string* instrument); + + // required string sampid = 6; + inline bool has_sampid() const; + inline void clear_sampid(); + static const int kSampidFieldNumber = 6; + inline const ::std::string& sampid() const; + inline void set_sampid(const ::std::string& value); + inline void set_sampid(const char* value); + inline void set_sampid(const char* value, size_t size); + inline ::std::string* mutable_sampid(); + inline ::std::string* release_sampid(); + inline void set_allocated_sampid(::std::string* sampid); + + // required string sample = 7; + inline bool has_sample() const; + inline void clear_sample(); + static const int kSampleFieldNumber = 7; + inline const ::std::string& sample() const; + inline void set_sample(const ::std::string& value); + inline void set_sample(const char* value); + inline void set_sample(const char* value, size_t size); + inline ::std::string* mutable_sample(); + inline ::std::string* release_sample(); + inline void set_allocated_sample(::std::string* sample); + + // required string cycle = 8; + inline bool has_cycle() const; + inline void clear_cycle(); + static const int kCycleFieldNumber = 8; + inline const ::std::string& cycle() const; + inline void set_cycle(const ::std::string& value); + inline void set_cycle(const char* value); + inline void set_cycle(const char* value, size_t size); + inline ::std::string* mutable_cycle(); + inline ::std::string* release_cycle(); + inline void set_allocated_cycle(::std::string* cycle); + + // required string imageid = 9; + inline bool has_imageid() const; + inline void clear_imageid(); + static const int kImageidFieldNumber = 9; + inline const ::std::string& imageid() const; + inline void set_imageid(const ::std::string& value); + inline void set_imageid(const char* value); + inline void set_imageid(const char* value, size_t size); + inline ::std::string* mutable_imageid(); + inline ::std::string* release_imageid(); + inline void set_allocated_imageid(::std::string* imageid); + + // required string numor = 10; + inline bool has_numor() const; + inline void clear_numor(); + static const int kNumorFieldNumber = 10; + inline const ::std::string& numor() const; + inline void set_numor(const ::std::string& value); + inline void set_numor(const char* value); + inline void set_numor(const char* value, size_t size); + inline ::std::string* mutable_numor(); + inline ::std::string* release_numor(); + inline void set_allocated_numor(::std::string* numor); + + // @@protoc_insertion_point(class_scope:proto.NumorInfo) + private: + inline void set_has_type(); + inline void clear_has_type(); + inline void set_has_propid(); + inline void clear_has_propid(); + inline void set_has_proposal(); + inline void clear_has_proposal(); + inline void set_has_instrid(); + inline void clear_has_instrid(); + inline void set_has_instrument(); + inline void clear_has_instrument(); + inline void set_has_sampid(); + inline void clear_has_sampid(); + inline void set_has_sample(); + inline void clear_has_sample(); + inline void set_has_cycle(); + inline void clear_has_cycle(); + inline void set_has_imageid(); + inline void clear_has_imageid(); + inline void set_has_numor(); + inline void clear_has_numor(); + + ::google::protobuf::UnknownFieldSet _unknown_fields_; + + ::std::string* propid_; + ::std::string* proposal_; + ::std::string* instrid_; + ::std::string* instrument_; + ::std::string* sampid_; + ::std::string* sample_; + ::std::string* cycle_; + ::std::string* imageid_; + ::std::string* numor_; + int type_; + + mutable int _cached_size_; + ::google::protobuf::uint32 _has_bits_[(10 + 31) / 32]; + + friend void protobuf_AddDesc_NumorMessages_2eproto(); + friend void protobuf_AssignDesc_NumorMessages_2eproto(); + friend void protobuf_ShutdownFile_NumorMessages_2eproto(); + + void InitAsDefaultInstance(); + static NumorInfo* default_instance_; +}; +// ------------------------------------------------------------------- + +class NumorRequest : public ::google::protobuf::Message { + public: + NumorRequest(); + virtual ~NumorRequest(); + + NumorRequest(const NumorRequest& from); + + inline NumorRequest& operator=(const NumorRequest& from) { + CopyFrom(from); + return *this; + } + + inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { + return _unknown_fields_; + } + + inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { + return &_unknown_fields_; + } + + static const ::google::protobuf::Descriptor* descriptor(); + static const NumorRequest& default_instance(); + + void Swap(NumorRequest* other); + + // implements Message ---------------------------------------------- + + NumorRequest* New() const; + void CopyFrom(const ::google::protobuf::Message& from); + void MergeFrom(const ::google::protobuf::Message& from); + void CopyFrom(const NumorRequest& from); + void MergeFrom(const NumorRequest& from); + void Clear(); + bool IsInitialized() const; + + int ByteSize() const; + bool MergePartialFromCodedStream( + ::google::protobuf::io::CodedInputStream* input); + void SerializeWithCachedSizes( + ::google::protobuf::io::CodedOutputStream* output) const; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const; + int GetCachedSize() const { return _cached_size_; } + private: + void SharedCtor(); + void SharedDtor(); + void SetCachedSize(int size) const; + public: + + ::google::protobuf::Metadata GetMetadata() const; + + // nested types ---------------------------------------------------- + + // accessors ------------------------------------------------------- + + // required .proto.NumorInfo info = 1; + inline bool has_info() const; + inline void clear_info(); + static const int kInfoFieldNumber = 1; + inline const ::proto::NumorInfo& info() const; + inline ::proto::NumorInfo* mutable_info(); + inline ::proto::NumorInfo* release_info(); + inline void set_allocated_info(::proto::NumorInfo* info); + + // required string content = 2; + inline bool has_content() const; + inline void clear_content(); + static const int kContentFieldNumber = 2; + inline const ::std::string& content() const; + inline void set_content(const ::std::string& value); + inline void set_content(const char* value); + inline void set_content(const char* value, size_t size); + inline ::std::string* mutable_content(); + inline ::std::string* release_content(); + inline void set_allocated_content(::std::string* content); + + // @@protoc_insertion_point(class_scope:proto.NumorRequest) + private: + inline void set_has_info(); + inline void clear_has_info(); + inline void set_has_content(); + inline void clear_has_content(); + + ::google::protobuf::UnknownFieldSet _unknown_fields_; + + ::proto::NumorInfo* info_; + ::std::string* content_; + + mutable int _cached_size_; + ::google::protobuf::uint32 _has_bits_[(2 + 31) / 32]; + + friend void protobuf_AddDesc_NumorMessages_2eproto(); + friend void protobuf_AssignDesc_NumorMessages_2eproto(); + friend void protobuf_ShutdownFile_NumorMessages_2eproto(); + + void InitAsDefaultInstance(); + static NumorRequest* default_instance_; +}; +// ------------------------------------------------------------------- + +class NumorResponse : public ::google::protobuf::Message { + public: + NumorResponse(); + virtual ~NumorResponse(); + + NumorResponse(const NumorResponse& from); + + inline NumorResponse& operator=(const NumorResponse& from) { + CopyFrom(from); + return *this; + } + + inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { + return _unknown_fields_; + } + + inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { + return &_unknown_fields_; + } + + static const ::google::protobuf::Descriptor* descriptor(); + static const NumorResponse& default_instance(); + + void Swap(NumorResponse* other); + + // implements Message ---------------------------------------------- + + NumorResponse* New() const; + void CopyFrom(const ::google::protobuf::Message& from); + void MergeFrom(const ::google::protobuf::Message& from); + void CopyFrom(const NumorResponse& from); + void MergeFrom(const NumorResponse& from); + void Clear(); + bool IsInitialized() const; + + int ByteSize() const; + bool MergePartialFromCodedStream( + ::google::protobuf::io::CodedInputStream* input); + void SerializeWithCachedSizes( + ::google::protobuf::io::CodedOutputStream* output) const; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const; + int GetCachedSize() const { return _cached_size_; } + private: + void SharedCtor(); + void SharedDtor(); + void SetCachedSize(int size) const; + public: + + ::google::protobuf::Metadata GetMetadata() const; + + // nested types ---------------------------------------------------- + + // accessors ------------------------------------------------------- + + // required .proto.NumorInfo info = 1; + inline bool has_info() const; + inline void clear_info(); + static const int kInfoFieldNumber = 1; + inline const ::proto::NumorInfo& info() const; + inline ::proto::NumorInfo* mutable_info(); + inline ::proto::NumorInfo* release_info(); + inline void set_allocated_info(::proto::NumorInfo* info); + + // required bytes image = 2; + inline bool has_image() const; + inline void clear_image(); + static const int kImageFieldNumber = 2; + inline const ::std::string& image() const; + inline void set_image(const ::std::string& value); + inline void set_image(const char* value); + inline void set_image(const void* value, size_t size); + inline ::std::string* mutable_image(); + inline ::std::string* release_image(); + inline void set_allocated_image(::std::string* image); + + // @@protoc_insertion_point(class_scope:proto.NumorResponse) + private: + inline void set_has_info(); + inline void clear_has_info(); + inline void set_has_image(); + inline void clear_has_image(); + + ::google::protobuf::UnknownFieldSet _unknown_fields_; + + ::proto::NumorInfo* info_; + ::std::string* image_; + + mutable int _cached_size_; + ::google::protobuf::uint32 _has_bits_[(2 + 31) / 32]; + + friend void protobuf_AddDesc_NumorMessages_2eproto(); + friend void protobuf_AssignDesc_NumorMessages_2eproto(); + friend void protobuf_ShutdownFile_NumorMessages_2eproto(); + + void InitAsDefaultInstance(); + static NumorResponse* default_instance_; +}; +// =================================================================== + + +// =================================================================== + +// NumorInfo + +// required .proto.NumorInfo.Type type = 1; +inline bool NumorInfo::has_type() const { + return (_has_bits_[0] & 0x00000001u) != 0; +} +inline void NumorInfo::set_has_type() { + _has_bits_[0] |= 0x00000001u; +} +inline void NumorInfo::clear_has_type() { + _has_bits_[0] &= ~0x00000001u; +} +inline void NumorInfo::clear_type() { + type_ = 1; + clear_has_type(); +} +inline ::proto::NumorInfo_Type NumorInfo::type() const { + return static_cast< ::proto::NumorInfo_Type >(type_); +} +inline void NumorInfo::set_type(::proto::NumorInfo_Type value) { + assert(::proto::NumorInfo_Type_IsValid(value)); + set_has_type(); + type_ = value; +} + +// required string propid = 2; +inline bool NumorInfo::has_propid() const { + return (_has_bits_[0] & 0x00000002u) != 0; +} +inline void NumorInfo::set_has_propid() { + _has_bits_[0] |= 0x00000002u; +} +inline void NumorInfo::clear_has_propid() { + _has_bits_[0] &= ~0x00000002u; +} +inline void NumorInfo::clear_propid() { + if (propid_ != &::google::protobuf::internal::kEmptyString) { + propid_->clear(); + } + clear_has_propid(); +} +inline const ::std::string& NumorInfo::propid() const { + return *propid_; +} +inline void NumorInfo::set_propid(const ::std::string& value) { + set_has_propid(); + if (propid_ == &::google::protobuf::internal::kEmptyString) { + propid_ = new ::std::string; + } + propid_->assign(value); +} +inline void NumorInfo::set_propid(const char* value) { + set_has_propid(); + if (propid_ == &::google::protobuf::internal::kEmptyString) { + propid_ = new ::std::string; + } + propid_->assign(value); +} +inline void NumorInfo::set_propid(const char* value, size_t size) { + set_has_propid(); + if (propid_ == &::google::protobuf::internal::kEmptyString) { + propid_ = new ::std::string; + } + propid_->assign(reinterpret_cast<const char*>(value), size); +} +inline ::std::string* NumorInfo::mutable_propid() { + set_has_propid(); + if (propid_ == &::google::protobuf::internal::kEmptyString) { + propid_ = new ::std::string; + } + return propid_; +} +inline ::std::string* NumorInfo::release_propid() { + clear_has_propid(); + if (propid_ == &::google::protobuf::internal::kEmptyString) { + return NULL; + } else { + ::std::string* temp = propid_; + propid_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); + return temp; + } +} +inline void NumorInfo::set_allocated_propid(::std::string* propid) { + if (propid_ != &::google::protobuf::internal::kEmptyString) { + delete propid_; + } + if (propid) { + set_has_propid(); + propid_ = propid; + } else { + clear_has_propid(); + propid_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); + } +} + +// required string proposal = 3; +inline bool NumorInfo::has_proposal() const { + return (_has_bits_[0] & 0x00000004u) != 0; +} +inline void NumorInfo::set_has_proposal() { + _has_bits_[0] |= 0x00000004u; +} +inline void NumorInfo::clear_has_proposal() { + _has_bits_[0] &= ~0x00000004u; +} +inline void NumorInfo::clear_proposal() { + if (proposal_ != &::google::protobuf::internal::kEmptyString) { + proposal_->clear(); + } + clear_has_proposal(); +} +inline const ::std::string& NumorInfo::proposal() const { + return *proposal_; +} +inline void NumorInfo::set_proposal(const ::std::string& value) { + set_has_proposal(); + if (proposal_ == &::google::protobuf::internal::kEmptyString) { + proposal_ = new ::std::string; + } + proposal_->assign(value); +} +inline void NumorInfo::set_proposal(const char* value) { + set_has_proposal(); + if (proposal_ == &::google::protobuf::internal::kEmptyString) { + proposal_ = new ::std::string; + } + proposal_->assign(value); +} +inline void NumorInfo::set_proposal(const char* value, size_t size) { + set_has_proposal(); + if (proposal_ == &::google::protobuf::internal::kEmptyString) { + proposal_ = new ::std::string; + } + proposal_->assign(reinterpret_cast<const char*>(value), size); +} +inline ::std::string* NumorInfo::mutable_proposal() { + set_has_proposal(); + if (proposal_ == &::google::protobuf::internal::kEmptyString) { + proposal_ = new ::std::string; + } + return proposal_; +} +inline ::std::string* NumorInfo::release_proposal() { + clear_has_proposal(); + if (proposal_ == &::google::protobuf::internal::kEmptyString) { + return NULL; + } else { + ::std::string* temp = proposal_; + proposal_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); + return temp; + } +} +inline void NumorInfo::set_allocated_proposal(::std::string* proposal) { + if (proposal_ != &::google::protobuf::internal::kEmptyString) { + delete proposal_; + } + if (proposal) { + set_has_proposal(); + proposal_ = proposal; + } else { + clear_has_proposal(); + proposal_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); + } +} + +// required string instrid = 4; +inline bool NumorInfo::has_instrid() const { + return (_has_bits_[0] & 0x00000008u) != 0; +} +inline void NumorInfo::set_has_instrid() { + _has_bits_[0] |= 0x00000008u; +} +inline void NumorInfo::clear_has_instrid() { + _has_bits_[0] &= ~0x00000008u; +} +inline void NumorInfo::clear_instrid() { + if (instrid_ != &::google::protobuf::internal::kEmptyString) { + instrid_->clear(); + } + clear_has_instrid(); +} +inline const ::std::string& NumorInfo::instrid() const { + return *instrid_; +} +inline void NumorInfo::set_instrid(const ::std::string& value) { + set_has_instrid(); + if (instrid_ == &::google::protobuf::internal::kEmptyString) { + instrid_ = new ::std::string; + } + instrid_->assign(value); +} +inline void NumorInfo::set_instrid(const char* value) { + set_has_instrid(); + if (instrid_ == &::google::protobuf::internal::kEmptyString) { + instrid_ = new ::std::string; + } + instrid_->assign(value); +} +inline void NumorInfo::set_instrid(const char* value, size_t size) { + set_has_instrid(); + if (instrid_ == &::google::protobuf::internal::kEmptyString) { + instrid_ = new ::std::string; + } + instrid_->assign(reinterpret_cast<const char*>(value), size); +} +inline ::std::string* NumorInfo::mutable_instrid() { + set_has_instrid(); + if (instrid_ == &::google::protobuf::internal::kEmptyString) { + instrid_ = new ::std::string; + } + return instrid_; +} +inline ::std::string* NumorInfo::release_instrid() { + clear_has_instrid(); + if (instrid_ == &::google::protobuf::internal::kEmptyString) { + return NULL; + } else { + ::std::string* temp = instrid_; + instrid_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); + return temp; + } +} +inline void NumorInfo::set_allocated_instrid(::std::string* instrid) { + if (instrid_ != &::google::protobuf::internal::kEmptyString) { + delete instrid_; + } + if (instrid) { + set_has_instrid(); + instrid_ = instrid; + } else { + clear_has_instrid(); + instrid_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); + } +} + +// required string instrument = 5; +inline bool NumorInfo::has_instrument() const { + return (_has_bits_[0] & 0x00000010u) != 0; +} +inline void NumorInfo::set_has_instrument() { + _has_bits_[0] |= 0x00000010u; +} +inline void NumorInfo::clear_has_instrument() { + _has_bits_[0] &= ~0x00000010u; +} +inline void NumorInfo::clear_instrument() { + if (instrument_ != &::google::protobuf::internal::kEmptyString) { + instrument_->clear(); + } + clear_has_instrument(); +} +inline const ::std::string& NumorInfo::instrument() const { + return *instrument_; +} +inline void NumorInfo::set_instrument(const ::std::string& value) { + set_has_instrument(); + if (instrument_ == &::google::protobuf::internal::kEmptyString) { + instrument_ = new ::std::string; + } + instrument_->assign(value); +} +inline void NumorInfo::set_instrument(const char* value) { + set_has_instrument(); + if (instrument_ == &::google::protobuf::internal::kEmptyString) { + instrument_ = new ::std::string; + } + instrument_->assign(value); +} +inline void NumorInfo::set_instrument(const char* value, size_t size) { + set_has_instrument(); + if (instrument_ == &::google::protobuf::internal::kEmptyString) { + instrument_ = new ::std::string; + } + instrument_->assign(reinterpret_cast<const char*>(value), size); +} +inline ::std::string* NumorInfo::mutable_instrument() { + set_has_instrument(); + if (instrument_ == &::google::protobuf::internal::kEmptyString) { + instrument_ = new ::std::string; + } + return instrument_; +} +inline ::std::string* NumorInfo::release_instrument() { + clear_has_instrument(); + if (instrument_ == &::google::protobuf::internal::kEmptyString) { + return NULL; + } else { + ::std::string* temp = instrument_; + instrument_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); + return temp; + } +} +inline void NumorInfo::set_allocated_instrument(::std::string* instrument) { + if (instrument_ != &::google::protobuf::internal::kEmptyString) { + delete instrument_; + } + if (instrument) { + set_has_instrument(); + instrument_ = instrument; + } else { + clear_has_instrument(); + instrument_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); + } +} + +// required string sampid = 6; +inline bool NumorInfo::has_sampid() const { + return (_has_bits_[0] & 0x00000020u) != 0; +} +inline void NumorInfo::set_has_sampid() { + _has_bits_[0] |= 0x00000020u; +} +inline void NumorInfo::clear_has_sampid() { + _has_bits_[0] &= ~0x00000020u; +} +inline void NumorInfo::clear_sampid() { + if (sampid_ != &::google::protobuf::internal::kEmptyString) { + sampid_->clear(); + } + clear_has_sampid(); +} +inline const ::std::string& NumorInfo::sampid() const { + return *sampid_; +} +inline void NumorInfo::set_sampid(const ::std::string& value) { + set_has_sampid(); + if (sampid_ == &::google::protobuf::internal::kEmptyString) { + sampid_ = new ::std::string; + } + sampid_->assign(value); +} +inline void NumorInfo::set_sampid(const char* value) { + set_has_sampid(); + if (sampid_ == &::google::protobuf::internal::kEmptyString) { + sampid_ = new ::std::string; + } + sampid_->assign(value); +} +inline void NumorInfo::set_sampid(const char* value, size_t size) { + set_has_sampid(); + if (sampid_ == &::google::protobuf::internal::kEmptyString) { + sampid_ = new ::std::string; + } + sampid_->assign(reinterpret_cast<const char*>(value), size); +} +inline ::std::string* NumorInfo::mutable_sampid() { + set_has_sampid(); + if (sampid_ == &::google::protobuf::internal::kEmptyString) { + sampid_ = new ::std::string; + } + return sampid_; +} +inline ::std::string* NumorInfo::release_sampid() { + clear_has_sampid(); + if (sampid_ == &::google::protobuf::internal::kEmptyString) { + return NULL; + } else { + ::std::string* temp = sampid_; + sampid_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); + return temp; + } +} +inline void NumorInfo::set_allocated_sampid(::std::string* sampid) { + if (sampid_ != &::google::protobuf::internal::kEmptyString) { + delete sampid_; + } + if (sampid) { + set_has_sampid(); + sampid_ = sampid; + } else { + clear_has_sampid(); + sampid_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); + } +} + +// required string sample = 7; +inline bool NumorInfo::has_sample() const { + return (_has_bits_[0] & 0x00000040u) != 0; +} +inline void NumorInfo::set_has_sample() { + _has_bits_[0] |= 0x00000040u; +} +inline void NumorInfo::clear_has_sample() { + _has_bits_[0] &= ~0x00000040u; +} +inline void NumorInfo::clear_sample() { + if (sample_ != &::google::protobuf::internal::kEmptyString) { + sample_->clear(); + } + clear_has_sample(); +} +inline const ::std::string& NumorInfo::sample() const { + return *sample_; +} +inline void NumorInfo::set_sample(const ::std::string& value) { + set_has_sample(); + if (sample_ == &::google::protobuf::internal::kEmptyString) { + sample_ = new ::std::string; + } + sample_->assign(value); +} +inline void NumorInfo::set_sample(const char* value) { + set_has_sample(); + if (sample_ == &::google::protobuf::internal::kEmptyString) { + sample_ = new ::std::string; + } + sample_->assign(value); +} +inline void NumorInfo::set_sample(const char* value, size_t size) { + set_has_sample(); + if (sample_ == &::google::protobuf::internal::kEmptyString) { + sample_ = new ::std::string; + } + sample_->assign(reinterpret_cast<const char*>(value), size); +} +inline ::std::string* NumorInfo::mutable_sample() { + set_has_sample(); + if (sample_ == &::google::protobuf::internal::kEmptyString) { + sample_ = new ::std::string; + } + return sample_; +} +inline ::std::string* NumorInfo::release_sample() { + clear_has_sample(); + if (sample_ == &::google::protobuf::internal::kEmptyString) { + return NULL; + } else { + ::std::string* temp = sample_; + sample_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); + return temp; + } +} +inline void NumorInfo::set_allocated_sample(::std::string* sample) { + if (sample_ != &::google::protobuf::internal::kEmptyString) { + delete sample_; + } + if (sample) { + set_has_sample(); + sample_ = sample; + } else { + clear_has_sample(); + sample_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); + } +} + +// required string cycle = 8; +inline bool NumorInfo::has_cycle() const { + return (_has_bits_[0] & 0x00000080u) != 0; +} +inline void NumorInfo::set_has_cycle() { + _has_bits_[0] |= 0x00000080u; +} +inline void NumorInfo::clear_has_cycle() { + _has_bits_[0] &= ~0x00000080u; +} +inline void NumorInfo::clear_cycle() { + if (cycle_ != &::google::protobuf::internal::kEmptyString) { + cycle_->clear(); + } + clear_has_cycle(); +} +inline const ::std::string& NumorInfo::cycle() const { + return *cycle_; +} +inline void NumorInfo::set_cycle(const ::std::string& value) { + set_has_cycle(); + if (cycle_ == &::google::protobuf::internal::kEmptyString) { + cycle_ = new ::std::string; + } + cycle_->assign(value); +} +inline void NumorInfo::set_cycle(const char* value) { + set_has_cycle(); + if (cycle_ == &::google::protobuf::internal::kEmptyString) { + cycle_ = new ::std::string; + } + cycle_->assign(value); +} +inline void NumorInfo::set_cycle(const char* value, size_t size) { + set_has_cycle(); + if (cycle_ == &::google::protobuf::internal::kEmptyString) { + cycle_ = new ::std::string; + } + cycle_->assign(reinterpret_cast<const char*>(value), size); +} +inline ::std::string* NumorInfo::mutable_cycle() { + set_has_cycle(); + if (cycle_ == &::google::protobuf::internal::kEmptyString) { + cycle_ = new ::std::string; + } + return cycle_; +} +inline ::std::string* NumorInfo::release_cycle() { + clear_has_cycle(); + if (cycle_ == &::google::protobuf::internal::kEmptyString) { + return NULL; + } else { + ::std::string* temp = cycle_; + cycle_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); + return temp; + } +} +inline void NumorInfo::set_allocated_cycle(::std::string* cycle) { + if (cycle_ != &::google::protobuf::internal::kEmptyString) { + delete cycle_; + } + if (cycle) { + set_has_cycle(); + cycle_ = cycle; + } else { + clear_has_cycle(); + cycle_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); + } +} + +// required string imageid = 9; +inline bool NumorInfo::has_imageid() const { + return (_has_bits_[0] & 0x00000100u) != 0; +} +inline void NumorInfo::set_has_imageid() { + _has_bits_[0] |= 0x00000100u; +} +inline void NumorInfo::clear_has_imageid() { + _has_bits_[0] &= ~0x00000100u; +} +inline void NumorInfo::clear_imageid() { + if (imageid_ != &::google::protobuf::internal::kEmptyString) { + imageid_->clear(); + } + clear_has_imageid(); +} +inline const ::std::string& NumorInfo::imageid() const { + return *imageid_; +} +inline void NumorInfo::set_imageid(const ::std::string& value) { + set_has_imageid(); + if (imageid_ == &::google::protobuf::internal::kEmptyString) { + imageid_ = new ::std::string; + } + imageid_->assign(value); +} +inline void NumorInfo::set_imageid(const char* value) { + set_has_imageid(); + if (imageid_ == &::google::protobuf::internal::kEmptyString) { + imageid_ = new ::std::string; + } + imageid_->assign(value); +} +inline void NumorInfo::set_imageid(const char* value, size_t size) { + set_has_imageid(); + if (imageid_ == &::google::protobuf::internal::kEmptyString) { + imageid_ = new ::std::string; + } + imageid_->assign(reinterpret_cast<const char*>(value), size); +} +inline ::std::string* NumorInfo::mutable_imageid() { + set_has_imageid(); + if (imageid_ == &::google::protobuf::internal::kEmptyString) { + imageid_ = new ::std::string; + } + return imageid_; +} +inline ::std::string* NumorInfo::release_imageid() { + clear_has_imageid(); + if (imageid_ == &::google::protobuf::internal::kEmptyString) { + return NULL; + } else { + ::std::string* temp = imageid_; + imageid_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); + return temp; + } +} +inline void NumorInfo::set_allocated_imageid(::std::string* imageid) { + if (imageid_ != &::google::protobuf::internal::kEmptyString) { + delete imageid_; + } + if (imageid) { + set_has_imageid(); + imageid_ = imageid; + } else { + clear_has_imageid(); + imageid_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); + } +} + +// required string numor = 10; +inline bool NumorInfo::has_numor() const { + return (_has_bits_[0] & 0x00000200u) != 0; +} +inline void NumorInfo::set_has_numor() { + _has_bits_[0] |= 0x00000200u; +} +inline void NumorInfo::clear_has_numor() { + _has_bits_[0] &= ~0x00000200u; +} +inline void NumorInfo::clear_numor() { + if (numor_ != &::google::protobuf::internal::kEmptyString) { + numor_->clear(); + } + clear_has_numor(); +} +inline const ::std::string& NumorInfo::numor() const { + return *numor_; +} +inline void NumorInfo::set_numor(const ::std::string& value) { + set_has_numor(); + if (numor_ == &::google::protobuf::internal::kEmptyString) { + numor_ = new ::std::string; + } + numor_->assign(value); +} +inline void NumorInfo::set_numor(const char* value) { + set_has_numor(); + if (numor_ == &::google::protobuf::internal::kEmptyString) { + numor_ = new ::std::string; + } + numor_->assign(value); +} +inline void NumorInfo::set_numor(const char* value, size_t size) { + set_has_numor(); + if (numor_ == &::google::protobuf::internal::kEmptyString) { + numor_ = new ::std::string; + } + numor_->assign(reinterpret_cast<const char*>(value), size); +} +inline ::std::string* NumorInfo::mutable_numor() { + set_has_numor(); + if (numor_ == &::google::protobuf::internal::kEmptyString) { + numor_ = new ::std::string; + } + return numor_; +} +inline ::std::string* NumorInfo::release_numor() { + clear_has_numor(); + if (numor_ == &::google::protobuf::internal::kEmptyString) { + return NULL; + } else { + ::std::string* temp = numor_; + numor_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); + return temp; + } +} +inline void NumorInfo::set_allocated_numor(::std::string* numor) { + if (numor_ != &::google::protobuf::internal::kEmptyString) { + delete numor_; + } + if (numor) { + set_has_numor(); + numor_ = numor; + } else { + clear_has_numor(); + numor_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); + } +} + +// ------------------------------------------------------------------- + +// NumorRequest + +// required .proto.NumorInfo info = 1; +inline bool NumorRequest::has_info() const { + return (_has_bits_[0] & 0x00000001u) != 0; +} +inline void NumorRequest::set_has_info() { + _has_bits_[0] |= 0x00000001u; +} +inline void NumorRequest::clear_has_info() { + _has_bits_[0] &= ~0x00000001u; +} +inline void NumorRequest::clear_info() { + if (info_ != NULL) info_->::proto::NumorInfo::Clear(); + clear_has_info(); +} +inline const ::proto::NumorInfo& NumorRequest::info() const { + return info_ != NULL ? *info_ : *default_instance_->info_; +} +inline ::proto::NumorInfo* NumorRequest::mutable_info() { + set_has_info(); + if (info_ == NULL) info_ = new ::proto::NumorInfo; + return info_; +} +inline ::proto::NumorInfo* NumorRequest::release_info() { + clear_has_info(); + ::proto::NumorInfo* temp = info_; + info_ = NULL; + return temp; +} +inline void NumorRequest::set_allocated_info(::proto::NumorInfo* info) { + delete info_; + info_ = info; + if (info) { + set_has_info(); + } else { + clear_has_info(); + } +} + +// required string content = 2; +inline bool NumorRequest::has_content() const { + return (_has_bits_[0] & 0x00000002u) != 0; +} +inline void NumorRequest::set_has_content() { + _has_bits_[0] |= 0x00000002u; +} +inline void NumorRequest::clear_has_content() { + _has_bits_[0] &= ~0x00000002u; +} +inline void NumorRequest::clear_content() { + if (content_ != &::google::protobuf::internal::kEmptyString) { + content_->clear(); + } + clear_has_content(); +} +inline const ::std::string& NumorRequest::content() const { + return *content_; +} +inline void NumorRequest::set_content(const ::std::string& value) { + set_has_content(); + if (content_ == &::google::protobuf::internal::kEmptyString) { + content_ = new ::std::string; + } + content_->assign(value); +} +inline void NumorRequest::set_content(const char* value) { + set_has_content(); + if (content_ == &::google::protobuf::internal::kEmptyString) { + content_ = new ::std::string; + } + content_->assign(value); +} +inline void NumorRequest::set_content(const char* value, size_t size) { + set_has_content(); + if (content_ == &::google::protobuf::internal::kEmptyString) { + content_ = new ::std::string; + } + content_->assign(reinterpret_cast<const char*>(value), size); +} +inline ::std::string* NumorRequest::mutable_content() { + set_has_content(); + if (content_ == &::google::protobuf::internal::kEmptyString) { + content_ = new ::std::string; + } + return content_; +} +inline ::std::string* NumorRequest::release_content() { + clear_has_content(); + if (content_ == &::google::protobuf::internal::kEmptyString) { + return NULL; + } else { + ::std::string* temp = content_; + content_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); + return temp; + } +} +inline void NumorRequest::set_allocated_content(::std::string* content) { + if (content_ != &::google::protobuf::internal::kEmptyString) { + delete content_; + } + if (content) { + set_has_content(); + content_ = content; + } else { + clear_has_content(); + content_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); + } +} + +// ------------------------------------------------------------------- + +// NumorResponse + +// required .proto.NumorInfo info = 1; +inline bool NumorResponse::has_info() const { + return (_has_bits_[0] & 0x00000001u) != 0; +} +inline void NumorResponse::set_has_info() { + _has_bits_[0] |= 0x00000001u; +} +inline void NumorResponse::clear_has_info() { + _has_bits_[0] &= ~0x00000001u; +} +inline void NumorResponse::clear_info() { + if (info_ != NULL) info_->::proto::NumorInfo::Clear(); + clear_has_info(); +} +inline const ::proto::NumorInfo& NumorResponse::info() const { + return info_ != NULL ? *info_ : *default_instance_->info_; +} +inline ::proto::NumorInfo* NumorResponse::mutable_info() { + set_has_info(); + if (info_ == NULL) info_ = new ::proto::NumorInfo; + return info_; +} +inline ::proto::NumorInfo* NumorResponse::release_info() { + clear_has_info(); + ::proto::NumorInfo* temp = info_; + info_ = NULL; + return temp; +} +inline void NumorResponse::set_allocated_info(::proto::NumorInfo* info) { + delete info_; + info_ = info; + if (info) { + set_has_info(); + } else { + clear_has_info(); + } +} + +// required bytes image = 2; +inline bool NumorResponse::has_image() const { + return (_has_bits_[0] & 0x00000002u) != 0; +} +inline void NumorResponse::set_has_image() { + _has_bits_[0] |= 0x00000002u; +} +inline void NumorResponse::clear_has_image() { + _has_bits_[0] &= ~0x00000002u; +} +inline void NumorResponse::clear_image() { + if (image_ != &::google::protobuf::internal::kEmptyString) { + image_->clear(); + } + clear_has_image(); +} +inline const ::std::string& NumorResponse::image() const { + return *image_; +} +inline void NumorResponse::set_image(const ::std::string& value) { + set_has_image(); + if (image_ == &::google::protobuf::internal::kEmptyString) { + image_ = new ::std::string; + } + image_->assign(value); +} +inline void NumorResponse::set_image(const char* value) { + set_has_image(); + if (image_ == &::google::protobuf::internal::kEmptyString) { + image_ = new ::std::string; + } + image_->assign(value); +} +inline void NumorResponse::set_image(const void* value, size_t size) { + set_has_image(); + if (image_ == &::google::protobuf::internal::kEmptyString) { + image_ = new ::std::string; + } + image_->assign(reinterpret_cast<const char*>(value), size); +} +inline ::std::string* NumorResponse::mutable_image() { + set_has_image(); + if (image_ == &::google::protobuf::internal::kEmptyString) { + image_ = new ::std::string; + } + return image_; +} +inline ::std::string* NumorResponse::release_image() { + clear_has_image(); + if (image_ == &::google::protobuf::internal::kEmptyString) { + return NULL; + } else { + ::std::string* temp = image_; + image_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); + return temp; + } +} +inline void NumorResponse::set_allocated_image(::std::string* image) { + if (image_ != &::google::protobuf::internal::kEmptyString) { + delete image_; + } + if (image) { + set_has_image(); + image_ = image; + } else { + clear_has_image(); + image_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); + } +} + + +// @@protoc_insertion_point(namespace_scope) + +} // namespace proto + +#ifndef SWIG +namespace google { +namespace protobuf { + +template <> +inline const EnumDescriptor* GetEnumDescriptor< ::proto::NumorInfo_Type>() { + return ::proto::NumorInfo_Type_descriptor(); +} + +} // namespace google +} // namespace protobuf +#endif // SWIG + +// @@protoc_insertion_point(global_scope) + +#endif // PROTOBUF_NumorMessages_2eproto__INCLUDED diff --git a/src/controllers/remotetas/NumorMessages.proto b/src/controllers/remotetas/NumorMessages.proto new file mode 100644 index 00000000..d09aca95 --- /dev/null +++ b/src/controllers/remotetas/NumorMessages.proto @@ -0,0 +1,34 @@ +package proto; + +option optimize_for = SPEED; + +message NumorInfo { + + enum Type { + LOG = 1; + LIVE = 2; + } + + required Type type = 1; + + required string propid = 2; + required string proposal = 3; + required string instrid = 4; + required string instrument = 5; + required string sampid = 6; + required string sample = 7; + required string cycle = 8; + required string imageid = 9; + required string numor = 10; + +} + +message NumorRequest { + required NumorInfo info = 1; + required string content = 2; +} + +message NumorResponse { + required NumorInfo info = 1; + required bytes image = 2; +} diff --git a/src/controllers/remotetas/RemoteMatlab.cpp b/src/controllers/remotetas/RemoteMatlab.cpp new file mode 100644 index 00000000..ef6d6277 --- /dev/null +++ b/src/controllers/remotetas/RemoteMatlab.cpp @@ -0,0 +1,345 @@ +/* + * Nomad Instrument Control Software + * + * Copyright 2011 Institut Laue-Langevin + * + * Licensed under the EUPL, Version 1.1 only (the "License"); + * You may not use this work except in compliance with the Licence. + * You may obtain a copy of the Licence at: + * + * http://joinup.ec.europa.eu/software/page/eupl + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the Licence is distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Licence for the specific language governing permissions and + * limitations under the Licence. + */ + +#include "RemoteMatlab.h" +#include <InstrumentManager/InstrumentManager.h> +#include <controllers/common/acquisition/Count.h> +#include <controllers/common/scanlegacy/ScanInfo.h> +#include <ics/Utilities/Calculations.h> +#include <common/connection/RestJsonHttpConnection.h> +#include <boost/lexical_cast.hpp> +#include <boost/property_tree/ptree.hpp> +#include <boost/property_tree/json_parser.hpp> +#include <fstream> +#include <iostream> + +namespace tas { + +using namespace std; +using namespace common; +using namespace boost; +using namespace nappli; +using boost::property_tree::ptree; + +const std::string RemoteMatlab::TYPE = "tas_remote_matlab"; +const std::string RemoteMatlab::MATLAB_APPLICATION = "matlab"; +const std::string RemoteMatlab::NUMOR_PUBLISHER = "tas_numor"; +const std::string RemoteMatlab::IMAGE_PUBLISHER = "tas_image"; +const int32 RemoteMatlab::LOG_TYPE = 1; +const int32 RemoteMatlab::LIVE_TYPE = 2; + +RemoteMatlab::RemoteMatlab(const std::string& name) : + utilities::ImageData(name), + controller::Start(this) { + + serverEndpoint.init(this, SAVE, "nappli_server"); + initialized.init(this, NOSAVE, "initialized"); + test.init(this, SAVE, "test"); + testNumor.init(this, SAVE, "test_numor"); + + scanController.init(this, "scan"); + countSpy.init(this, "acquisition_spy"); + + experimentData.assign(InstrumentManager::getInstance()->getFirstExperimentControllerByType("title")); + + const char* weblog = getenv("NOMAD_SENDDATA"); + if (weblog != 0) { + m_nomadSendData = string(weblog); + to_lower(m_nomadSendData); + } +} + +RemoteMatlab::RemoteMatlab(const RemoteMatlab& controller) : + utilities::ImageData(controller), + controller::Start(this) { +} + +RemoteMatlab::~RemoteMatlab() { + + // Stop the subscriber + m_subscriber->cancel(); + + // The subscriber thread terminates + m_subscriberThread->join(); + + // Notify the application + m_publisher->sendEnd(); + + // Wait for the termination + application::State state = m_matlabApplication->waitFor(); + + cout << "Matlab application terminated with state " << state << endl; +} + +void RemoteMatlab::postConfiguration() { + + registerUpdater(scanController->serializerEvent, &RemoteMatlab::updateNumor, this); + //registerUpdater(scanController->getCount()->statusMessage, &RemoteMatlab::updateCountStatusMessage, this); + registerUpdater(countSpy->statusMessage, &RemoteMatlab::updateCountStatusMessage, this); + + if (serverEndpoint() == "") { + m_server.reset(new Server(application::This::getServer().getEndpoint())); + + } else { + m_server.reset(new Server(serverEndpoint())); + } + + initialized = initApplication(); +} + +bool RemoteMatlab::initApplication() { + + // Do not initialize if it is already done + if (initialized()) { + return true; + } + + // Start the Matlab server + if (!m_server->isAvailable(1000)) { + cout << "Matlab server is not available" << endl; + return false; + } + + cout << "Matlab server is connected" << endl; + + m_matlabApplication = m_server->connect(MATLAB_APPLICATION); + if (m_matlabApplication->exists()) { + // The application exists from a previous server session + m_matlabApplication->kill(); + application::State state = m_matlabApplication->waitFor(); + cout << "Terminated matlab application " << state << endl; + } + + m_matlabApplication = m_server->start(MATLAB_APPLICATION); + + if (!m_matlabApplication->exists()) { + cout << "No matlab application" << endl; + return false; + } + + // Create the publisher after the start of the application, because it is a blocking call + m_publisher = application::Publisher::create(NUMOR_PUBLISHER, 1); + cout << "Publisher " << *m_publisher << endl; + + // Wait for the subscriber + bool sync = m_publisher->waitForSubscribers(); + + // Create the subscriber after the publisher + m_subscriber = application::Subscriber::create(*m_matlabApplication, IMAGE_PUBLISHER); + cout << "subscriber " << *m_subscriber << endl; + + // Start the subscriber loop + m_subscriberThread.reset(new thread(bind(&RemoteMatlab::subscriberLoop, this))); + + // Application initialized + initialized = true; + + return true; +} + +void RemoteMatlab::updateNumor() { + + // Send the numor to be computed if there is something to serialize + if (scanController->serializerEvent()) { + // Send the numor + if (test()) { + sendNumor(testNumor(), false); + } else { + sendNumor(scanController->numor(), false); + } + } +} + +void RemoteMatlab::updateCountStatusMessage() { + + if ((countSpy->statusMessage() == "Close data") && scanController->getScanInfo()->running()) { + + cout << "Send the numor for live refresh" << endl; + + // Send the numor + if (test()) { + sendNumor(testNumor(), true); + } else { + sendNumor(scanController->numor(), true); + } + } +} + +void RemoteMatlab::sendNumor(int32 numor, bool live) { + + if (!initApplication()) { + return; + } + + // Get the content of the numor + string numorName = lexical_cast<string>(numor); + size_t size = numorName.size(); + if (size < 6) { + string prefix(6 - size, '0'); + numorName = prefix + numorName; + } + + + LogStream logStream = log(Level::s_Info).property(scanController->logAcquisitionType) + .property(scanController->logNumor) + .property(scanController->logSubtitle); + + logStream << numorName << " in Q" << image(numor, "q") << endlog; + + + string numorFileName("/users/data/"); + numorFileName += numorName; + + ifstream numorFile; + numorFile.open(numorFileName.c_str()); + + stringstream stream; + stream << numorFile.rdbuf(); + + // Serialize the request + proto::NumorRequest request; + if (live) { + request.mutable_info()->set_type(proto::NumorInfo_Type_LIVE); + } else { + request.mutable_info()->set_type(proto::NumorInfo_Type_LOG); + } + + request.mutable_info()->set_propid(getProposalId()); + request.mutable_info()->set_proposal(getProposalName()); + request.mutable_info()->set_instrid(getInstrumentId()); + request.mutable_info()->set_instrument(getInstrumentName()); + request.mutable_info()->set_sampid(getSampleId()); + request.mutable_info()->set_sample(getSampleName()); + request.mutable_info()->set_cycle(getCycleId()); + request.mutable_info()->set_imageid(getImageName()); + request.mutable_info()->set_numor(lexical_cast<string>(numor)); + + request.set_content(stream.str()); + + // Publish the message + m_publisher->sendBinary(request.SerializeAsString()); + + cout << "Sent numor " << numor << endl; +} + +void RemoteMatlab::start() { + + // Send the numor + sendNumor(testNumor(), true); +} + +void RemoteMatlab::subscriberLoop() { + + // Loop on events + string data; + while (m_subscriber->receiveBinary(data)) { + + proto::NumorResponse response; + response.ParseFromString(data); + + if (response.mutable_info()->type() == proto::NumorInfo_Type_LOG) { + sendImageToFluentd(response); + + } else { + setContentFromBinaryData(response.image()); + } + } +} + +void RemoteMatlab::sendImageToFluentd(const proto::NumorResponse& response) { + + // Encode the JSON message + ptree message; + message.put("id", Date().toString()); + message.put("mt", "acq"); + message.put("name", "numor"); + message.put("type", "number"); + message.put("value", response.info().numor()); + message.put("output", "null"); + message.put("level", "info"); + message.put("propid", response.info().propid()); + message.put("instrid", response.info().instrid()); + message.put("sampleid", response.info().sampid()); + message.put("sample", response.info().sample()); + message.put("cycleid", response.info().cycle()); + message.put("imagefile", response.info().imageid()); + + // The binary content of the image is a string and we encode it in base64 + message.put("imagedata", Calculations::encodeBase64(response.image())); + + stringstream os; + write_json(os, message, false); + + std::string instrumentName = response.info().instrument(); + boost::to_upper(instrumentName); + + RestJsonHttpConnection con; + + try { + con.openUrl("localhost", "8888"); + + //New environment variable + if (m_nomadSendData == "0") { + //if 0 send data to dev database + con.setPath(string("/oracle.forward.") + instrumentName + "_DEV"); + + } else if (m_nomadSendData == "1") { + //if 1 send data to prod database + con.setPath(string("/oracle.forward.") + instrumentName); + } + + con.setData(os.str()); + boost::property_tree::ptree response = con.send(false); + + } catch (const Exception& e) { + // log to server + cerr << e.printStack() << endl; + } + +} + +string RemoteMatlab::getProposalId() { + return experimentData->proposalId(); +} + +string RemoteMatlab::getProposalName() { + //Proposal name = experiment number + return experimentData->experimentNumber(); +} + +string RemoteMatlab::getInstrumentId() { + return experimentData->instrumentId(); +} + +string RemoteMatlab::getInstrumentName() { + return experimentData->instrumentName(); +} + +string RemoteMatlab::getSampleId() { + return experimentData->sampleId(); +} + +string RemoteMatlab::getSampleName() { + return experimentData->chemicalFormula(); +} + +string RemoteMatlab::getCycleId() { + return experimentData->cycleId(); +} + +} diff --git a/src/controllers/remotetas/RemoteMatlab.h b/src/controllers/remotetas/RemoteMatlab.h new file mode 100644 index 00000000..94017940 --- /dev/null +++ b/src/controllers/remotetas/RemoteMatlab.h @@ -0,0 +1,91 @@ +/* + * Nomad Instrument Control Software + * + * Copyright 2011 Institut Laue-Langevin + * + * Licensed under the EUPL, Version 1.1 only (the "License"); + * You may not use this work except in compliance with the Licence. + * You may obtain a copy of the Licence at: + * + * http://joinup.ec.europa.eu/software/page/eupl + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the Licence is distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Licence for the specific language governing permissions and + * limitations under the Licence. + */ + +#ifndef TAS_REMOTEMATLAB_H +#define TAS_REMOTEMATLAB_H + +#include "controllers/common/utilities/imageviewer/ImageData.h" +#include "controllers/common/acquisition/ImageGeneratable.h" +#include "controllers/common/acquisition/ExperimentData.h" +#include "controllers/common/scanlegacy/GenericScan1D.h" +#include "controllers/common/utilities/CountSpy.h" +#include "NumorMessages.pb.h" +#include <nappli/nappli.h> + +namespace tas { + +class RemoteMatlab : public utilities::ImageData, + public acquisition::ImageGeneratable, + public controller::Start { + +public: + //! Type of controller + static const std::string TYPE; + + RemoteMatlab(const std::string& name); + RemoteMatlab(const RemoteMatlab& controller); + virtual ~RemoteMatlab(); + + virtual void postConfiguration(); + + void updateNumor(); + void updateCountStatusMessage(); + + virtual void start(); + + Property<std::string> serverEndpoint; + Property<bool> initialized; + Property<bool> test; + Property<int32> testNumor; + + ControllerPtr<acquisition::ExperimentData> experimentData; + ControllerPtr<scan::GenericScan1D> scanController; + ControllerPtr<utilities::CountSpy> countSpy; + +private: + bool initApplication(); + void sendNumor(int32 numor, bool live); + void subscriberLoop(); + void sendImageToFluentd(const proto::NumorResponse& response); + + std::string getProposalId(); + std::string getProposalName(); + std::string getInstrumentId(); + std::string getInstrumentName(); + std::string getSampleId(); + std::string getSampleName(); + std::string getCycleId(); + + static const std::string MATLAB_APPLICATION; + static const std::string NUMOR_PUBLISHER; + static const std::string IMAGE_PUBLISHER; + static const int32 LOG_TYPE; + static const int32 LIVE_TYPE; + + std::auto_ptr<nappli::Server> m_server; + std::auto_ptr<nappli::application::Instance> m_matlabApplication; + std::auto_ptr<nappli::application::Publisher> m_publisher; + std::auto_ptr<nappli::application::Subscriber> m_subscriber; + std::auto_ptr<boost::thread> m_subscriberThread; + + std::string m_nomadSendData; +}; + +} + +#endif diff --git a/src/controllers/spectrometer/QE65000Controller.cpp b/src/controllers/spectrometer/QE65000Controller.cpp index 8c130d61..e7b68138 100644 --- a/src/controllers/spectrometer/QE65000Controller.cpp +++ b/src/controllers/spectrometer/QE65000Controller.cpp @@ -39,7 +39,7 @@ QE65000Controller::QE65000Controller(const std::string& name) : integrationTime.init(this, SAVE, "integration_time"); xData.init(this, NOSAVE, "x_data"); yData.init(this, NOSAVE, "y_data"); - ySize.init(this, SAVE, "y_size"); + size.init(this, SAVE, "size"); spectroStatus.init(this, SAVE, "spectro_status"); spectroStatusMessage.init(this, SAVE, "spectro_status_message"); mode.init(this, SAVE, "mode"); @@ -61,10 +61,9 @@ void QE65000Controller::postConfiguration() { registerRefresher(integrationTime, &QE65000Controller::refreshIntegrationTime, this); //Get info from driver - registerUpdater(spectroDriver->yData, &QE65000Controller::updateYData, this); registerUpdater(spectroDriver->status, &QE65000Controller::updateStatus, this); + registerUpdater(spectroDriver->size, &QE65000Controller::updateSize, this); - //need to register the progression to see it?? registerProgression(spectroDriver, &QE65000Controller::updateProgression, this); //Set initial property values @@ -72,18 +71,16 @@ void QE65000Controller::postConfiguration() { mode.update(IDLE); //plotName.update(""); //original value = empty + + //Get size from driver + + size = spectroDriver->size(); } void QE65000Controller::refreshIntegrationTime(int32 time) { spectroDriver->integrationTime = time; } -void QE65000Controller::updateYData() { - yData.update(spectroDriver->yData()); - yData.setSize(spectroDriver->yData.getSize()); - -} - void QE65000Controller::updateStatus() { spectroStatus.update(spectroDriver->status()); if (spectroStatus() == 0) { @@ -93,6 +90,10 @@ void QE65000Controller::updateStatus() { } } +void QE65000Controller::updateSize() { + size.update(spectroDriver->size()); +} + void QE65000Controller::updateProgression() { int32 progression = 0; commandProgression = progression; @@ -106,88 +107,88 @@ void QE65000Controller::start() { numor.update(0); } - //Delete current arrays - delete[] xData(); - delete[] yData(); + //Get size from driver + size = spectroDriver->size(); - //Take into account number of scans to average - if (scansToAverage() == 1) { + if (isConnected()) { - commandProgression = 50; - spectroDriver.execute("start", false); - commandProgression = 75; + //Take into account number of scans to average + if (scansToAverage() == 1) { - //x data - int32 xSize = spectroDriver->xData.getSize(); - xData.update(spectroDriver->xData()); - xData.setSize(xSize); + cout << "start " << endl; - //y data - int32 yDataSize = spectroDriver->yData.getSize(); - yData.update(spectroDriver->yData()); - yData.setSize(yDataSize); + commandProgression = 50; + spectroDriver.execute("start", false); + commandProgression = 75; - //New set y data size - ySize.update(yDataSize); + //x data + xData.update(spectroDriver->xData()); + xData.setSize(size()); - //To take those changes into account do the following: - xData.sendEvent(); - yData.sendEvent(); + //y data + yData.update(spectroDriver->yData()); + yData.setSize(size()); - commandProgression = 99; - spectroDriver.execute("stop", false); + //To take those changes into account do the following: + xData.sendEvent(); + yData.sendEvent(); - } else { - int32 ySize; - float64* tempYData; - float64* finalYData; + commandProgression = 99; + spectroDriver.execute("stop", false); - for (int32 i = 0; i < scansToAverage(); i++) { + } else { + //REVISE THE USAGE OF THE ARRAYS HERE + float64* tempYData; + float64* finalYData; - if (!m_StopActivated) { - commandProgression = i * 100 / scansToAverage(); - spectroDriver.execute("start", false); - - //During first scan get size of array and initialize everything - if (i == 0) { - ySize = spectroDriver->yData.getSize(); - tempYData = new float64[ySize]; - finalYData = new float64[ySize]; - - //to avoid problems with incorrect initial values initialize content of both arrays to zero - for (int32 j = 0; j < ySize; j++) { - tempYData[j] = 0; - finalYData[j] = 0; + for (int32 i = 0; i < scansToAverage(); i++) { + + if (!m_StopActivated) { + commandProgression = i * 100 / scansToAverage(); + + spectroDriver.execute("start", false); + cout << "start " << endl; + + //During first scan get size of array and initialize everything + if (i == 0) { + tempYData = new float64[size()]; + finalYData = new float64[size()]; + + //to avoid problems with incorrect initial values initialize content of both arrays to zero + for (int32 j = 0; j < size(); j++) { + tempYData[j] = 0; + finalYData[j] = 0; + } } - } - //y data - tempYData = spectroDriver->yData(); - for (int32 j = 0; j < ySize; j++) { - finalYData[j] = finalYData[j] + tempYData[j]; - if (i == scansToAverage() - 1) { - finalYData[j] = finalYData[j] / scansToAverage(); + //y data + tempYData = spectroDriver->yData(); + for (int32 j = 0; j < size(); j++) { + finalYData[j] = finalYData[j] + tempYData[j]; + if (i == scansToAverage() - 1) { + finalYData[j] = finalYData[j] / scansToAverage(); + } } - } + } } - } - if (!m_StopActivated) { - int32 xSize = spectroDriver->xData.getSize(); - xData.update(spectroDriver->xData()); - xData.setSize(xSize); + if (!m_StopActivated) { + xData.update(spectroDriver->xData()); + xData.setSize(size()); - yData.update(finalYData); - yData.setSize(ySize); + yData.update(finalYData); + yData.setSize(size()); - //To take those changes into account do the following: - xData.sendEvent(); - yData.sendEvent(); + //To take those changes into account do the following: + xData.sendEvent(); + yData.sendEvent(); + } + + commandProgression = 99; + spectroDriver.execute("stop", false); } - commandProgression = 99; - spectroDriver.execute("stop", false); } } @@ -203,12 +204,7 @@ bool QE65000Controller::isConnected() { } void QE65000Controller::setPlotName(int32 plotId) { - stringstream plotNameStream; - plotNameStream << plotId; -// plotName.update(plotNameStream.str()); numor.update(plotId); - - //cout << "setting plotName to: " << plotId << endl; } } diff --git a/src/controllers/spectrometer/QE65000Controller.h b/src/controllers/spectrometer/QE65000Controller.h index 8f59079f..ed95f260 100644 --- a/src/controllers/spectrometer/QE65000Controller.h +++ b/src/controllers/spectrometer/QE65000Controller.h @@ -44,7 +44,7 @@ public: Property<int32> numor; Property<std::string> spectroStatusMessage; Property<int32> scansToAverage; - Property<int32> ySize; + Property<int32> size; ArrayProperty<float64> xData; ArrayProperty<float64> yData; @@ -67,8 +67,8 @@ public: bool isConnected(); void updateProgression(); - void updateYData(); void updateStatus(); + void updateSize(); void setPlotName(int32 plotId); diff --git a/src/drivers/caen_cd/CAENCdDef.h b/src/drivers/caen_cd/CAENCdDef.h new file mode 100644 index 00000000..a504e5da --- /dev/null +++ b/src/drivers/caen_cd/CAENCdDef.h @@ -0,0 +1,45 @@ +/*! + * \brief + * Nomad Instrument Control Software + * + * Copyright 2011 Institut Laue-Langevin + * + * Licensed under the EUPL, Version 1.1 only (the "License"); + * You may not use this work except in compliance with the Licence. + * You may obtain a copy of the Licence at: + * + * http://joinup.ec.europa.eu/software/page/eupl + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the Licence is distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Licence for the specific language governing permissions and + * limitations under the Licence. + */ + +#ifndef CAENCDDEF_H +#define CAENCDDEF_H + +#include <CAENDigitizer.h> + +#include "common/base/BaseTypes.h" + +namespace caen_cd { + +// Board parameters +typedef struct { + CAEN_DGTZ_ConnectionType LinkType; // Type of connection + int32 VMEBaseAddress; // VME address + CAEN_DGTZ_AcqMode_t AcqMode; // Start acquisition mode (SW, S_IN, First trigger) + CAEN_DGTZ_DPP_AcqMode_t DPPAcqMode; // Acquisition mode (Oscilloscope, List, Mixed) + CAEN_DGTZ_DPP_SaveParam_t SaveMode; // Save mode (Energy, Time, Energy&Time, None) + int32 RecordLength; // Nb of samples in oscilloscope mode + CAEN_DGTZ_IOLevel_t IOLevel; // I/O level (NIM, TTL) + CAEN_DGTZ_TriggerMode_t TriggerMode; // Trigger mode (disable, extout, acq_only, acq_extout) + int32 ChannelMask; // Channel enable mask + int32 EventAggr; // Nb of events per aggregate (0=automatic) +} DigitizerParams_t; + +} + +#endif // CAENCDDEF_H diff --git a/src/drivers/caen_cd/CAENCdDriver.cpp b/src/drivers/caen_cd/CAENCdDriver.cpp new file mode 100644 index 00000000..f2332be1 --- /dev/null +++ b/src/drivers/caen_cd/CAENCdDriver.cpp @@ -0,0 +1,223 @@ +/* + * Nomad Instrument Control Software + * + * Copyright 2011 Institut Laue-Langevin + * + * Licensed under the EUPL, Version 1.1 only (the "License"); + * You may not use this work except in compliance with the Licence. + * You may obtain a copy of the Licence at: + * + * http://joinup.ec.europa.eu/software/page/eupl + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the Licence is distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Licence for the specific language governing permissions and + * limitations under the Licence. + */ + +#include "CAENCdDef.h" +#include "CAENCdState.h" +#include "CAENCdDriver.h" +#include "PerfectCAENCdDriver.h" +#include "RealCAENCdDriver.h" +#include "drivers/global/DriversCommands.h" + +namespace caen_cd { + +const std::string CAENCdDriver::TYPE = "caen_cd"; + +const std::string CAENCdDriver::WRITE_PARAMETERS_COMMAND = "writeParam"; +const std::string CAENCdDriver::SET_MODE_COMMAND = "setAcqMode"; +const std::string CAENCdDriver::RESET_COMMAND = "reset"; +const std::string CAENCdDriver::CLEAR_COMMAND = "clear"; + +/* + * Constructor + */ +CAENCdDriver::CAENCdDriver(const string& name) { + + driver::Vme::init(name); + + registerStates(new RealCAENCdDriver(this), new PerfectCAENCdDriver(this), new PerfectCAENCdDriver(this)); + + // Global properties + nbChannels.init(this, SAVE, "nb_channels"); + nbBits.init(this, SAVE, "nb_bits"); + model.init(this, NOSAVE, "model"); + channels.init(this, NOSAVE, "channels"); + serialNumber.init(this, NOSAVE, "serial_number"); + modelName.init(this, NOSAVE, "model_name"); + rocFirmware.init(this, NOSAVE, "roc_firmware"); + amcFirmware.init(this, NOSAVE, "amc_firmware"); + + // Board properties + linkType.init(this, SAVE, "link_type"); + acqMode.init(this, SAVE, "acq_mode"); + dppAcqMode.init(this, SAVE, "dpp_acq_mode"); + dppAcqModeStr.init(this, NOSAVE, "dpp_acq_mode_str"); + saveMode.init(this, SAVE, "save_mode"); + saveModeStr.init(this, NOSAVE, "save_mode_str"); + recordLength.init(this, SAVE, "record_length"); + ioLevel.init(this, SAVE, "io_level"); + triggerMode.init(this, SAVE, "trigger_mode"); + channelMask.init(this, SAVE, "channel_mask"); + + // Channels properties + triggerHoldOff.init(this, SAVE, "trigger_holdoff"); + triggerThreshold.init(this, SAVE, "trigger_threshold"); + selfTrigger.init(this, SAVE, "self_trigger"); + chargeSensitivity.init(this, SAVE, "charge_sensitivity"); + shortGate.init(this, SAVE, "short_gate"); + longGate.init(this, SAVE, "long_gate"); + preGate.init(this, SAVE, "pre_gate"); + triggerValidationWindow.init(this, SAVE, "trigger_validation"); + baselineMean.init(this, SAVE, "base_mean"); + + channelActive.init(this, SAVE, "channel_active"); + channelActiveStr.init(this, NOSAVE, "channel_active_str"); + dcOffset.init(this, SAVE, "dc_offset"); + pulsePolarity.init(this, SAVE, "pulse_polarity"); + pulsePolarityStr.init(this, NOSAVE, "pulse_polarity_str"); + preTrigger.init(this, SAVE, "pre_trigger"); + + // Init the device command list + initCommand(driver::INIT_COMMAND); + initCommand(driver::READ_INFOS_COMMAND); + initCommand(WRITE_PARAMETERS_COMMAND); + initCommand(SET_MODE_COMMAND); + initCommand(RESET_COMMAND); + initCommand(CLEAR_COMMAND); + + // Init functions + registerFunction(NONE_FUNCTION); + + addressType.update(driver::Vme::A32_ACCESS); + deviceType = LEAF_DEVICE_TYPE_DEVICE_CONTAINER; + + registerRefresher(nbChannels, &CAENCdDriver::refreshNbChannelsProperty, this); + registerRefresher(dppAcqMode, &CAENCdDriver::refreshDppAcqModeProperty, this); + registerRefresher(saveMode, &CAENCdDriver::refreshSaveModeProperty, this); + registerRefresher(channelActive, &CAENCdDriver::refreshChannelActiveProperty, this); + registerRefresher(pulsePolarity, &CAENCdDriver::refreshPulsePolarityProperty, this); +} + +/* + * Destructor + */ +CAENCdDriver::~CAENCdDriver() { + +} + +/* + * execute + */ +void CAENCdDriver::execute(const std::string& aCommand) { + + if ((aCommand != driver::STOP_COMMAND) && (aCommand != driver::STATUS_COMMAND) + && (aCommand != driver::READ_COMMAND)) { + commandProgression = PROGRESSION_UNKNOWNSTATE_DEVICE_CONTAINER; + } + + CAENCdState* currentState = dynamic_cast<CAENCdState*>(getCurrentState()); + // Check command + if (aCommand == driver::INIT_COMMAND) { + // Init command + currentState->init(); + } else if (aCommand == WRITE_PARAMETERS_COMMAND) { + // writeParam command + currentState->writeParam(); + commandProgression = PROGRESSION_END_DEVICE_CONTAINER; + } else if (aCommand == SET_MODE_COMMAND) { + // clear command + currentState->setAcqMode(); + commandProgression = PROGRESSION_END_DEVICE_CONTAINER; + } else if (aCommand == CLEAR_COMMAND) { + // clear command + currentState->clear(); + commandProgression = PROGRESSION_END_DEVICE_CONTAINER; + } else if (aCommand == RESET_COMMAND) { + // clear command + currentState->reset(); + commandProgression = PROGRESSION_END_DEVICE_CONTAINER; + } else if (aCommand == driver::READ_INFOS_COMMAND) { + // Info command + currentState->readInfos(); + commandProgression = PROGRESSION_END_DEVICE_CONTAINER; + } else { + //Error bad command + //Todo , normaly it will be detect it device action driver + } +} + +void CAENCdDriver::refreshNbChannelsProperty(int32 aValue) throw (CannotSetValue){ + + triggerThreshold.resize(aValue); + selfTrigger.resize(aValue); + chargeSensitivity.resize(aValue); + shortGate.resize(aValue); + longGate.resize(aValue); + preGate.resize(aValue); + triggerValidationWindow.resize(aValue); + baselineMean.resize(aValue); + + channelActive.resize(aValue); + channelActiveStr.resize(aValue); + dcOffset.resize(aValue); + preTrigger.resize(aValue); + pulsePolarity.resize(aValue); + pulsePolarityStr.resize(aValue); +} + +void CAENCdDriver::refreshDppAcqModeProperty(int32 aValue) throw (CannotSetValue) { + + switch (aValue) { + case 0: + dppAcqModeStr = "Oscilloscope"; + break; + case 1: + dppAcqModeStr = "Histogram"; + break; + } +} + +void CAENCdDriver::refreshSaveModeProperty(int32 aValue) throw (CannotSetValue) { + + switch (aValue) { + case 0: + saveModeStr = "Energy"; + break; + case 1: + saveModeStr = "Time"; + break; + case 2: + saveModeStr = "Energy&Time"; + break; + } +} + +void CAENCdDriver::refreshChannelActiveProperty(int32 index, int32 aValue) throw (CannotSetValue) { + + switch (aValue) { + case 0: + channelActiveStr.set(index, "Inactive"); + break; + case 1: + channelActiveStr.set(index, "Active"); + break; + } +} + +void CAENCdDriver::refreshPulsePolarityProperty(int32 index, int32 aValue) throw (CannotSetValue) { + + switch (aValue) { + case 0: + pulsePolarityStr.set(index, "Positive"); + break; + case 1: + pulsePolarityStr.set(index, "Negative"); + break; + } +} + +} diff --git a/src/drivers/caen_cd/CAENCdDriver.h b/src/drivers/caen_cd/CAENCdDriver.h new file mode 100644 index 00000000..3681aba7 --- /dev/null +++ b/src/drivers/caen_cd/CAENCdDriver.h @@ -0,0 +1,119 @@ +/* + * Nomad Instrument Control Software + * + * Copyright 2011 Institut Laue-Langevin + * + * Licensed under the EUPL, Version 1.1 only (the "License"); + * You may not use this work except in compliance with the Licence. + * You may obtain a copy of the Licence at: + * + * http://joinup.ec.europa.eu/software/page/eupl + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the Licence is distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Licence for the specific language governing permissions and + * limitations under the Licence. + */ + +#ifndef CAENCDDRIVER_H +#define CAENCDDRIVER_H + +#include <Driver.h> +#include "drivers/global/Vme.h" + +namespace caen_cd { + +/*! + * \class CAENCdDriver + * \brief Main class for the CAENCdDriver device driver + * + * \par + * Class for CAENCdDriver driver. Implements DeviceDriver methods. + * \par + * The CAENCdDriver device manages the global functionality of the CAEN V1740 VME Digitiser. + */ + +class CAENCdDriver : public driver::Vme { + +public: + + //! Driver type value + static const std::string TYPE; + + /*! + * \brief Constructor + * \param[in] name the name of the device driver + */ + CAENCdDriver(const std::string& name); + + /*! + * \brief Destructor + */ + virtual ~CAENCdDriver(); + + /*! + * \brief Method called for executing a command + * + * \param[in] command the command to apply on the controller + */ + virtual void execute(const std::string& aCommand); + + // Global properties + Property<int32> nbChannels; + Property<int32> nbBits; + Property<int32> model; + Property<int32> channels; + Property<int32> serialNumber; + Property<std::string> modelName; + Property<std::string> rocFirmware; + Property<std::string> amcFirmware; + + // Board properties + Property<int32> linkType; + Property<int32> acqMode; + Property<int32> dppAcqMode; + Property<std::string> dppAcqModeStr; + Property<int32> saveMode; + Property<std::string> saveModeStr; + Property<int32> recordLength; // Nb samples for oscilloscope mode + Property<int32> ioLevel; + Property<int32> triggerMode; + Property<int32> channelMask; + + // Channels properties in dppParams - PSD + Property<int32>triggerHoldOff; // trgho - same for all channels + DynamicProperty<int32>triggerThreshold; // thr (N x 4 ns) + DynamicProperty<int32>selfTrigger; // selft - range 0:1 (disable - enable) + DynamicProperty<int32>chargeSensitivity; // csens - range 0:3 (40fc/LSB, 160fc/LSB, 640fc/LSB, 2,5pc/LSB) + DynamicProperty<int32>shortGate; // sgate (N x 4 ns) + DynamicProperty<int32>longGate; // lgate (N x 4 ns) + DynamicProperty<int32>preGate; // pgate (N x 4 ns) + DynamicProperty<int32>triggerValidationWindow; // tvalw + DynamicProperty<int32>baselineMean; // nsbl - range 0:6 (no baseline, 4, 8, 16, 32, 64, 128) + + // Channels properties outside dppParam + DynamicProperty<int32> channelActive; + DynamicProperty<std::string> channelActiveStr; + DynamicProperty<int32> dcOffset; + DynamicProperty<int32> pulsePolarity; // invert input - range 0:1 + DynamicProperty<std::string> pulsePolarityStr; + DynamicProperty<int32> preTrigger; // range 0:1023 (nSamples = pre_trig x 2) + + // Commands + static const std::string WRITE_PARAMETERS_COMMAND; + static const std::string SET_MODE_COMMAND; + static const std::string RESET_COMMAND; + static const std::string CLEAR_COMMAND; + +private: + + void refreshNbChannelsProperty(int32 aValue) throw (CannotSetValue); + void refreshDppAcqModeProperty(int32 aValue) throw (CannotSetValue); + void refreshSaveModeProperty(int32 aValue) throw (CannotSetValue); + void refreshChannelActiveProperty(int32 index, int32 aValue) throw (CannotSetValue); + void refreshPulsePolarityProperty(int32 index, int32 aValue) throw (CannotSetValue); +}; + +} +#endif //CAENCDDRIVER_H diff --git a/src/drivers/caen_cd/CAENCdState.h b/src/drivers/caen_cd/CAENCdState.h new file mode 100644 index 00000000..c4307d1b --- /dev/null +++ b/src/drivers/caen_cd/CAENCdState.h @@ -0,0 +1,74 @@ +/* + * Nomad Instrument Control Software + * + * Copyright 2011 Institut Laue-Langevin + * + * Licensed under the EUPL, Version 1.1 only (the "License"); + * You may not use this work except in compliance with the Licence. + * You may obtain a copy of the Licence at: + * + * http://joinup.ec.europa.eu/software/page/eupl + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the Licence is distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Licence for the specific language governing permissions and + * limitations under the Licence. + */ + +#ifndef CAENCDSTATE_H +#define CAENCDSTATE_H + +#include <Driver.h> +#include "CAENCdDriver.h" + +namespace caen_cd { + +/*! + * \class CAENCdState + * \brief Implements State pattern + */ +class CAENCdState: public DriverState<CAENCdDriver> { + +public: + + /*! + * \brief Constructor. + */ + CAENCdState(CAENCdDriver* owner) : + DriverState<CAENCdDriver> (owner) {} + + /*! + * \brief Destructor. + */ + virtual ~CAENCdState() {} + + /*! + * \brief Reset command implementation + */ + virtual void reset() = 0; + + /*! + * \brief Clear command implementation + */ + virtual void clear() = 0; + + /*! + * \brief Write Param command implementation + */ + virtual void writeParam() = 0; + + /*! + * \brief Read Infos command implementation + */ + virtual void readInfos() = 0; + + /*! + * \brief Set acquisition mode command implementation + */ + virtual void setAcqMode() = 0; +}; + +} + +#endif //CAENCDSTATE_H diff --git a/src/drivers/caen_cd/Module.xml b/src/drivers/caen_cd/Module.xml new file mode 100644 index 00000000..1aa34608 --- /dev/null +++ b/src/drivers/caen_cd/Module.xml @@ -0,0 +1,6 @@ +<module name="caen_cd"> + <driver type="caen_cd::CAENCdDriver"/> + + <include path="$(NOMAD_HOME)/../NomadModules/src"/> + <link path="/usr/lib" lib="CAENDigitizer"/> +</module> \ No newline at end of file diff --git a/src/drivers/caen_cd/PerfectCAENCdDriver.cpp b/src/drivers/caen_cd/PerfectCAENCdDriver.cpp new file mode 100644 index 00000000..5e934f16 --- /dev/null +++ b/src/drivers/caen_cd/PerfectCAENCdDriver.cpp @@ -0,0 +1,83 @@ +/* + * Nomad Instrument Control Software + * + * Copyright 2011 Institut Laue-Langevin + * + * Licensed under the EUPL, Version 1.1 only (the "License"); + * You may not use this work except in compliance with the Licence. + * You may obtain a copy of the Licence at: + * + * http://joinup.ec.europa.eu/software/page/eupl + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the Licence is distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Licence for the specific language governing permissions and + * limitations under the Licence. + */ + +#include "PerfectCAENCdDriver.h" +#include "CAENCdDef.h" + +using namespace std; + +namespace caen_cd { + +/* + * Constructor + */ +PerfectCAENCdDriver::PerfectCAENCdDriver(CAENCdDriver* owner) : + CAENCdState(owner) { + /* Empty */ +} + +/* + * Destructor + */ +PerfectCAENCdDriver::~PerfectCAENCdDriver() { + /* Empty */ +} + +/*! + * \brief Init command implementation + */ +void PerfectCAENCdDriver::init() { + +} + +/*! + * \brief Clear command implementation + */ +void PerfectCAENCdDriver::clear() { + +} + +/*! + * \brief Reset command implementation + */ +void PerfectCAENCdDriver::reset() { + +} + +/*! + * \brief Write Param command implementation + */ +void PerfectCAENCdDriver::writeParam() { + +} + +/*! + * \brief Set acquisition mode command implementation + */ +void PerfectCAENCdDriver::setAcqMode() { + +} + +/*! + * \brief Read Infos command implementation + */ +void PerfectCAENCdDriver::readInfos() { + +} + +} diff --git a/src/drivers/caen_cd/PerfectCAENCdDriver.h b/src/drivers/caen_cd/PerfectCAENCdDriver.h new file mode 100644 index 00000000..33b810fb --- /dev/null +++ b/src/drivers/caen_cd/PerfectCAENCdDriver.h @@ -0,0 +1,79 @@ +/* + * Nomad Instrument Control Software + * + * Copyright 2011 Institut Laue-Langevin + * + * Licensed under the EUPL, Version 1.1 only (the "License"); + * You may not use this work except in compliance with the Licence. + * You may obtain a copy of the Licence at: + * + * http://joinup.ec.europa.eu/software/page/eupl + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the Licence is distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Licence for the specific language governing permissions and + * limitations under the Licence. + */ + +#ifndef PERFECTCAENCIDRIVER_H +#define PERFECTCAENCIDRIVER_H + +#include "CAENCdState.h" + +namespace caen_cd { + + +/** + * Perfect implementation of the vme card called Bit3 617,618,620. + */ +class PerfectCAENCdDriver : public CAENCdState { + +public: + + /** + * Constructor. + * + * @param Link to the class which used the state + */ + PerfectCAENCdDriver(CAENCdDriver* owner); + + /** + * Destructor. + * Empty. + */ + virtual ~PerfectCAENCdDriver(); + + /*! + * \brief Init command implementation + */ + virtual void init(); + + /*! + * \brief Clear command implementation + */ + virtual void clear(); + + /*! + * \brief Reset command implementation + */ + virtual void reset(); + + /*! + * \brief Write Param command implementation + */ + virtual void writeParam(); + + /*! + * \brief Set acquisition mode command implementation + */ + virtual void setAcqMode(); + + /*! + * \brief Read Infos command implementation + */ + virtual void readInfos(); +}; + +} +#endif //PERFECTCAENCIDRIVER_H diff --git a/src/drivers/caen_cd/RealCAENCdDriver.cpp b/src/drivers/caen_cd/RealCAENCdDriver.cpp new file mode 100644 index 00000000..b26c9615 --- /dev/null +++ b/src/drivers/caen_cd/RealCAENCdDriver.cpp @@ -0,0 +1,329 @@ +/* + * Nomad Instrument Control Software + * + * Copyright 2011 Institut Laue-Langevin + * + * Licensed under the EUPL, Version 1.1 only (the "License"); + * You may not use this work except in compliance with the Licence. + * You may obtain a copy of the Licence at: + * + * http://joinup.ec.europa.eu/software/page/eupl + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the Licence is distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Licence for the specific language governing permissions and + * limitations under the Licence. + */ + +#include "RealCAENCdDriver.h" +#include "CAENCdDriver.h" +#include <controllers/common/acquisition/mode/DPPAcquisitionCommon.h> + +using namespace std; + +namespace caen_cd { + +/* + * Constructor + */ +RealCAENCdDriver::RealCAENCdDriver(CAENCdDriver* owner) : CAENCdState(owner) { + + m_boardHandle = 0; + ret = CAEN_DGTZ_Success; +} + +/* + * Destructor + */ +RealCAENCdDriver::~RealCAENCdDriver() { + +} + +/*! + * \brief open command implementation + */ +void RealCAENCdDriver::open() { + + boardParams.LinkType = (CAEN_DGTZ_ConnectionType)owner()->linkType(); + cout << "LinkType: " << boardParams.LinkType << endl; + boardParams.VMEBaseAddress = owner()->address(); + cout << "VMEBaseAddress: 0x" << hex << boardParams.VMEBaseAddress << dec << endl; + ret = CAEN_DGTZ_OpenDigitizer(boardParams.LinkType, 0, 0, boardParams.VMEBaseAddress, &m_boardHandle); + if (ret) { + cerr << "Error CAEN_DGTZ_OpenDigitizer: " << ret << endl; + return; + } +} + +/*! + * \brief close command implementation + */ +void RealCAENCdDriver::close() { + + CAEN_DGTZ_CloseDigitizer(m_boardHandle); +} + +/*! + * \brief Init command implementation + */ +void RealCAENCdDriver::init() { + + reset(); + + open(); + + // Channel CTRL register + ret = CAEN_DGTZ_WriteRegister(m_boardHandle, 0x8000, 0x00000010); + if (ret) { + cerr << "Error CAEN_DGTZ_WriteRegister: " << ret << endl; + close(); + return; + } + + // Set acquisition mode + if (owner()->dppAcqMode() == acquisition::DPPAcquisitionCommon::LISTMODE_MODE) { + boardParams.DPPAcqMode = CAEN_DGTZ_DPP_ACQ_MODE_List; + } + else if (owner()->dppAcqMode() == acquisition::DPPAcquisitionCommon::SCOPE_MODE) { + boardParams.DPPAcqMode = CAEN_DGTZ_DPP_ACQ_MODE_Oscilloscope; + } + boardParams.SaveMode = (CAEN_DGTZ_DPP_SaveParam_t)owner()->saveMode(); + ret = CAEN_DGTZ_SetDPPAcquisitionMode(m_boardHandle, boardParams.DPPAcqMode, boardParams.SaveMode); + if (ret) { + cerr << "Error CAEN_DGTZ_SetDPPAcquisitionMode: " << ret << endl; + close(); + return; + } +/* + // Set start acquisition mode + boardParams.AcqMode = (CAEN_DGTZ_AcqMode_t)owner()->acqMode(); + ret = CAEN_DGTZ_SetAcquisitionMode(m_boardHandle, CAEN_DGTZ_S_IN_CONTROLLED); //boardParams.AcqMode); + if (ret) { + cerr << "Error CAEN_DGTZ_SetAcquisitionMode: " << ret << endl; + close(); + return; + } + + // Set I/O level + boardParams.IOLevel = (CAEN_DGTZ_IOLevel_t)owner()->ioLevel(); + ret = CAEN_DGTZ_SetIOLevel(m_boardHandle, boardParams.IOLevel); + if (ret) { + cerr << "Error CAEN_DGTZ_SetIOLevel: " << ret << endl; + close(); + return; + } + + // Set external trigger + boardParams.TriggerMode = (CAEN_DGTZ_TriggerMode_t)owner()->triggerMode(); + ret = CAEN_DGTZ_SetExtTriggerInputMode(m_boardHandle, boardParams.TriggerMode); + if (ret) { + cerr << "Error CAEN_DGTZ_SetExtTriggerInputMode: " << ret << endl; + close(); + return; + } + + // Enable channels + boardParams.ChannelMask = owner()->channelMask(); + ret = CAEN_DGTZ_SetChannelEnableMask(m_boardHandle, boardParams.ChannelMask); + if (ret) { + cerr << "Error CAEN_DGTZ_SetChannelEnableMask: " << ret << endl; + close(); + return; + } + + // Set aggregate size - how many events per output buffer + // 0 = automatic + boardParams.EventAggr = 0; + ret = CAEN_DGTZ_SetDPPEventAggregation(m_boardHandle, boardParams.EventAggr, 0); + if (ret) { + cerr << "Error CAEN_DGTZ_SetDPPEventAggregation: " << ret << endl; + close(); + return; + } + + // Set multi-board synchronization mode + ret = CAEN_DGTZ_SetRunSynchronizationMode(m_boardHandle, CAEN_DGTZ_RUN_SYNC_Disabled); + if (ret) { + cerr << "Error CAEN_DGTZ_SetRunSynchronizationMode: " << ret << endl; + close(); + return; + } + + // Set virtual probe settings + ret = CAEN_DGTZ_SetDPP_PSD_VirtualProbe(m_boardHandle, CAEN_DGTZ_DPP_VIRTUALPROBE_SINGLE, + CAEN_DGTZ_DPP_PSD_VIRTUALPROBE_Baseline, CAEN_DGTZ_DPP_PSD_DIGITALPROBE1_R6_GateLong, + CAEN_DGTZ_DPP_PSD_DIGITALPROBE2_R6_GateShort); + if (ret) { + cerr << "Error CAEN_DGTZ_SetDPP_VirtualProbe: " << ret << endl; + close(); + return; + } + + uint32 data; + ret = CAEN_DGTZ_ReadRegister(m_boardHandle, 0x8000, &data); + cout << " data mode read out " << data << hex << endl; + //data &= 0xFFF8FFFF; + if (owner()->dppAcqMode() == acquisition::DPPAcquisitionCommon::LISTMODE_MODE) { + // data |= 0x000C0000; + data = 0x000C0114; + cout << " data mode " << data << hex << endl; + } + else if (owner()->dppAcqMode() == acquisition::DPPAcquisitionCommon::SCOPE_MODE) { + //data |= 0x00070000; + data = 0x01870114; + cout << " data mode " << data << hex << endl; + } + ret = CAEN_DGTZ_WriteRegister(m_boardHandle, 0x8000, data); + if (ret) { + cerr << "Error CAEN_DGTZ_WriteRegister: " << ret << endl; + close(); + return; + } + ret = CAEN_DGTZ_WriteRegister(m_boardHandle, 0x8100, 0x5); + if (ret) { + cerr << "Error CAEN_DGTZ_WriteRegister: " << ret << endl; + close(); + return; + } +*/ + close(); + + readInfos(); + +// writeParam(); +} + +/*! + * \brief Clear command implementation + */ +void RealCAENCdDriver::clear() { + + open(); + ret = CAEN_DGTZ_ClearData(m_boardHandle); + if (ret) { + cerr << "Error CAEN_DGTZ_ClearData: " << ret << endl; + } + close(); +} + +/*! + * \brief Reset command implementation + */ +void RealCAENCdDriver::reset() { + + open(); + ret = CAEN_DGTZ_Reset(m_boardHandle); + if (ret) { + cerr << "Error CAEN_DGTZ_Reset: " << ret << endl; + } + close(); +} + +/*! + * \brief Write Param command implementation + */ +void RealCAENCdDriver::writeParam() { + + // Load DPP parameters into structure + for (int32 i=0; i<owner()->nbChannels(); ++i) { + dppParams.trgho = owner()->triggerHoldOff(); + dppParams.thr[i] = owner()->triggerThreshold.get(i); + dppParams.selft[i] = owner()->selfTrigger.get(i); + dppParams.csens[i] = owner()->chargeSensitivity.get(i); + dppParams.sgate[i] = owner()->shortGate.get(i); + dppParams.lgate[i] = owner()->longGate.get(i); + dppParams.pgate[i] = owner()->preGate.get(i); + dppParams.tvaw[i] = owner()->triggerValidationWindow.get(i); + dppParams.nsbl[i] = owner()->baselineMean.get(i); + } + + open(); + + // Write channels parameters + ret = CAEN_DGTZ_SetDPPParameters(m_boardHandle, boardParams.ChannelMask, &dppParams); + if (ret) { + cerr << "Error CAEN_DGTZ_SetDPPParameters" << endl; + close(); + return; + } + + for (int32 i=0; i<owner()->channels(); ++i) { + if (owner()->channelMask() & (1 << i)) { + // Set nb of samples for oscilloscope mode (same for all channels) + boardParams.RecordLength = owner()->recordLength(); + ret = CAEN_DGTZ_SetRecordLength(m_boardHandle, boardParams.RecordLength, i); + if (ret) { + cerr << "Error CAEN_DGTZ_SetRecordLength: " << ret << endl; + close(); + return; + } + + // Set DC offset + int32 offset = owner()->dcOffset.get(i); + offset +=50; + offset = offset * 65535 / 100; + ret = CAEN_DGTZ_SetChannelDCOffset(m_boardHandle, i, offset); + if (ret) { + cerr << "Error CAEN_DGTZ_SetChannelDCOffset" << endl; + close(); + return; + } + + // Set Pre-trigger size + int32 ptgrSize = owner()->preTrigger.get(i); + ret = CAEN_DGTZ_SetDPPPreTriggerSize(m_boardHandle, i, ptgrSize); + if (ret) { + cerr << "Error CAEN_DGTZ_SetDPPPreTriggerSize" << endl; + close(); + return; + } + + // Set polarity + CAEN_DGTZ_PulsePolarity_t polarity = (CAEN_DGTZ_PulsePolarity_t)owner()->pulsePolarity.get(i); + ret = CAEN_DGTZ_SetChannelPulsePolarity(m_boardHandle, i, polarity); + if (ret) { + cerr << "Error CAEN_DGTZ_SetChannelPulsePolarity" << endl; + close(); + return; + } + } + } + + close(); +} + +/*! + * \brief Set acquisition mode command implementation + */ +void RealCAENCdDriver::setAcqMode() { + + open(); + boardParams.DPPAcqMode = (CAEN_DGTZ_DPP_AcqMode_t)owner()->dppAcqMode(); + boardParams.SaveMode = (CAEN_DGTZ_DPP_SaveParam_t)owner()->saveMode(); + ret = CAEN_DGTZ_SetDPPAcquisitionMode(m_boardHandle, boardParams.DPPAcqMode, boardParams.SaveMode); + if (ret) { + cerr << "Error CAEN_DGTZ_SetDPPAcquisitionMode: " << ret << endl; + } + close(); +} + +/*! + * \brief Read Infos command implementation + */ +void RealCAENCdDriver::readInfos() { + + open(); + ret = CAEN_DGTZ_GetInfo(m_boardHandle, &boardInfo); + close(); + + owner()->nbBits = boardInfo.ADC_NBits; + owner()->model = boardInfo.Model; + owner()->channels = boardInfo.Channels * 8; // nb of group channels with 8 channels per group + owner()->serialNumber = boardInfo.SerialNumber; + owner()->modelName = boardInfo.ModelName; + owner()->rocFirmware = boardInfo.ROC_FirmwareRel; + owner()->amcFirmware = boardInfo.AMC_FirmwareRel; +} + +} diff --git a/src/drivers/caen_cd/RealCAENCdDriver.h b/src/drivers/caen_cd/RealCAENCdDriver.h new file mode 100644 index 00000000..1d97f6f5 --- /dev/null +++ b/src/drivers/caen_cd/RealCAENCdDriver.h @@ -0,0 +1,96 @@ +/* + * Nomad Instrument Control Software + * + * Copyright 2011 Institut Laue-Langevin + * + * Licensed under the EUPL, Version 1.1 only (the "License"); + * You may not use this work except in compliance with the Licence. + * You may obtain a copy of the Licence at: + * + * http://joinup.ec.europa.eu/software/page/eupl + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the Licence is distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Licence for the specific language governing permissions and + * limitations under the Licence. + */ + +#ifndef REALCAENCDDRIVER_H +#define REALCAENCDDRIVER_H + +#include <CAENDigitizer.h> + +#include "CAENCdState.h" +#include "CAENCdDef.h" + +namespace caen_cd { + +class CAENCdDriver; + +/** + * Real implementation + */ +class RealCAENCdDriver : public CAENCdState { + +public: + + /** + * Constructor. + * + * @param Link to the class which used the state + */ + RealCAENCdDriver(CAENCdDriver* owner); + + /** + * Destructor. + * Empty. + */ + virtual ~RealCAENCdDriver(); + + /*! + * \brief Init command implementation + */ + virtual void init(); + + /*! + * \brief Clear command implementation + */ + virtual void clear(); + + /*! + * \brief Reset command implementation + */ + virtual void reset(); + + /*! + * \brief Write Param command implementation + */ + virtual void writeParam(); + + /*! + * \brief Set acquisition mode command implementation + */ + virtual void setAcqMode(); + + /*! + * \brief Read Infos command implementation + */ + virtual void readInfos(); + +private: + + void open(); + void close(); + + int32 m_boardHandle; + + CAEN_DGTZ_ErrorCode ret; + + CAEN_DGTZ_BoardInfo_t boardInfo; + DigitizerParams_t boardParams; + CAEN_DGTZ_DPP_PSD_Params_t dppParams; +}; + +} +#endif //REALCAENCDDRIVER_H diff --git a/src/drivers/caen_cd/gui/caen_cd.properties b/src/drivers/caen_cd/gui/caen_cd.properties new file mode 100644 index 00000000..2bf42f40 --- /dev/null +++ b/src/drivers/caen_cd/gui/caen_cd.properties @@ -0,0 +1,34 @@ +# Board Info +caen_cd.boardInfoTitle=Board Info +caen_cd.model=Model #: +caen_cd.channels=Channels: +caen_cd.serialNumber=Serial number: +caen_cd.modelName=Model: +caen_cd.rocFirmware=ROC firmware: +caen_cd.amcFirmware=AMC firmware: + +# Board Params +caen_cd.boardParamsTitle=Board Parameters +caen_cd.nbChannels=Nb channels: +caen_cd.nbBits=Nb bit: +caen_cd.acqMode=Acquisition mode: +caen_cd.histogramMode=Histogram mode: + +# Channel Params +caen_cd.channelParamsTitle=Channel Parameters +caen_cd.channelActive=Channel active +caen_cd.pulsePolarity=Pulse polarity +caen_cd.dcOffset=DC offset +caen_cd.threshold=Threshold +caen_cd.triggerSmoothing=Smoothing +caen_cd.triggerHoldOff=Trigger holdoff +caen_cd.signalRiseTime=Rise time +caen_cd.signalDecayTime=Decay time +caen_cd.trapezoidlRiseTime=Trapezoid rise +caen_cd.trapezoidFlatTop=Trapezoid flat-top +caen_cd.baselineMean=Baseline mean +caen_cd.trapezoidGain=Trapezoid gain +caen_cd.flatTopDelay=Peaking +caen_cd.peakMean=Peak mean +caen_cd.baselineHoldOff=Baseline holdoff +caen_cd.peakHoldOff=Peak holdoff diff --git a/src/drivers/caen_cd/gui/caen_cdPlugin.xml b/src/drivers/caen_cd/gui/caen_cdPlugin.xml new file mode 100644 index 00000000..6dc8d7c1 --- /dev/null +++ b/src/drivers/caen_cd/gui/caen_cdPlugin.xml @@ -0,0 +1,7 @@ +<controller_plugin_config type="caen_cd"> + + <image key="HARDWARE_VME_MODULE"/> + + <settings view="caen_cdView.xml"/> + +</controller_plugin_config> diff --git a/src/drivers/caen_cd/gui/caen_cdProperties.xml b/src/drivers/caen_cd/gui/caen_cdProperties.xml new file mode 100644 index 00000000..ef2be776 --- /dev/null +++ b/src/drivers/caen_cd/gui/caen_cdProperties.xml @@ -0,0 +1,82 @@ +<?xml version="1.0" encoding="ISO-8859-1" ?> + +<controller type="caen_cd"> + + <property name="nb_channels" type="int32" max_length="2"> + </property> + + <dynamic_property name="decay_time" size_property="nb_channels" type="int32" max_length="6"> + </dynamic_property> + + <dynamic_property name="trapezoid_flat" size_property="nb_channels" type="int32" max_length="6"> + </dynamic_property> + + <dynamic_property name="trapezoid_rise" size_property="nb_channels" type="int32" max_length="6"> + </dynamic_property> + + <dynamic_property name="flat_top" size_property="nb_channels" type="int32" max_length="6"> + </dynamic_property> + + <dynamic_property name="trigger_smoothing" size_property="nb_channels" type="int32" max_length="6"> + </dynamic_property> + + <dynamic_property name="rise_time" size_property="nb_channels" type="int32" max_length="6"> + </dynamic_property> + + <dynamic_property name="trigger_threshold" size_property="nb_channels" type="int32" max_length="6"> + </dynamic_property> + + <dynamic_property name="base_mean" size_property="nb_channels" type="int32" max_length="6"> + </dynamic_property> + + <dynamic_property name="peak_mean" size_property="nb_channels" type="int32" max_length="6"> + </dynamic_property> + + <dynamic_property name="peak_holdoff" size_property="nb_channels" type="int32" max_length="6"> + </dynamic_property> + + <dynamic_property name="base_holdoff" size_property="nb_channels" type="int32" max_length="6"> + </dynamic_property> + + <dynamic_property name="trigger_holdoff" size_property="nb_channels" type="int32" max_length="6"> + </dynamic_property> + + <dynamic_property name="trigger_window_size" size_property="nb_channels" type="int32" max_length="6"> + </dynamic_property> + + <dynamic_property name="trigger_window_enable" size_property="nb_channels" type="int32" max_length="6"> + </dynamic_property> + + <dynamic_property name="digital_gain" size_property="nb_channels" type="int32" max_length="6"> + </dynamic_property> + + <dynamic_property name="trapezoid_gain" size_property="nb_channels" type="float64"> + <decimal_format nb_decimal_places="2"/> + <strictly_positive/> + </dynamic_property> + + <dynamic_property name="decimation" size_property="nb_channels" type="int32" max_length="6"> + </dynamic_property> + + <dynamic_property name="channel_active" size_property="nb_channels" type="int32"> + </dynamic_property> + + <dynamic_property name="channel_active_str" size_property="nb_channels" type="string" max_length="8"> + </dynamic_property> + + <dynamic_property name="dc_offset" size_property="nb_channels" type="int32"> + </dynamic_property> + + <dynamic_property name="pre_trigger" size_property="nb_channels" type="int32" max_length="6"> + </dynamic_property> + + <dynamic_property name="pulse_polarity" size_property="nb_channels" type="int32"> + </dynamic_property> + + <dynamic_property name="pulse_polarity_str" size_property="nb_channels" type="string" max_length="8"> + </dynamic_property> + + <dynamic_property name="use_first_derivative" size_property="nb_channels" type="int32"> + </dynamic_property> + +</controller> diff --git a/src/drivers/caen_cd/gui/caen_cdView.xml b/src/drivers/caen_cd/gui/caen_cdView.xml new file mode 100644 index 00000000..44bac228 --- /dev/null +++ b/src/drivers/caen_cd/gui/caen_cdView.xml @@ -0,0 +1,68 @@ +<plugin> + <controller type="caen_cd" role="caen_cd1"/> + <group title="caen_cd.boardInfoTitle"> + <table_composite nbColumns="2"> + <label role="caen_cd1" property="model" prefix="caen_cd.model"/> + <label role="caen_cd1" property="channels" prefix="caen_cd.channels"/> + <label role="caen_cd1" property="serial_number" prefix="caen_cd.serialNumber"/> + <label role="caen_cd1" property="model_name" prefix="caen_cd.modelName"/> + </table_composite> + <newLine/> + <label role="caen_cd1" property="roc_firmware" prefix="caen_cd.rocFirmware"/> + <newLine/> + <label role="caen_cd1" property="amc_firmware" prefix="caen_cd.amcFirmware"/> + </group> +<!-- + <newLine/> + <group title="caen_cd.boardParamsTitle"> + <label role="caen_cd1" property="nb_channels" prefix="caen_cd.nbChannels"/> + <label role="caen_cd1" property="nb_bits" prefix="caen_cd.nbBits"/> + <newLine/> + <label role="caen_cd1" property="dpp_acq_mode_str" prefix="caen_cd.acqMode"/> + <newLine/> + <label role="caen_cd1" property="save_mode_str" prefix="caen_cd.histogramMode"/> + </group> + + <newLine/> + <group title="caen_cd.channelParamsTitle"> + <table_composite nbColumns="16"> + <simple_label prefix="caen_cd.channelActive"/> + <simple_label prefix="caen_cd.pulsePolarity"/> + <simple_label prefix="caen_cd.dcOffset"/> + <simple_label prefix="caen_cd.threshold"/> + <simple_label prefix="caen_cd.triggerSmoothing"/> + <simple_label prefix="caen_cd.triggerHoldOff"/> + <simple_label prefix="caen_cd.signalRiseTime"/> + <simple_label prefix="caen_cd.signalDecayTime"/> + <simple_label prefix="caen_cd.trapezoidlRiseTime"/> + <simple_label prefix="caen_cd.trapezoidFlatTop"/> + <simple_label prefix="caen_cd.baselineMean"/> + <simple_label prefix="caen_cd.trapezoidGain"/> + <simple_label prefix="caen_cd.flatTopDelay"/> + <simple_label prefix="caen_cd.peakMean"/> + <simple_label prefix="caen_cd.baselineHoldOff"/> + <simple_label prefix="caen_cd.peakHoldOff"/> + <dynamic_composite role="caen_cd1" properties="channel_active_str,pulse_polarity_str,dc_offset, + trigger_threshold,trigger_smoothing,trigger_holdoff,rise_time,decay_time,trapezoid_rise, + trapezoid_flat,base_mean,trapezoid_gain,flat_top,peak_mean,base_holdoff,peak_holdoff"> + <label role="caen_cd1" property="channel_active_str"/> + <label role="caen_cd1" property="pulse_polarity_str"/> + <label role="caen_cd1" property="dc_offset"/> + <label role="caen_cd1" property="trigger_threshold"/> + <label role="caen_cd1" property="trigger_smoothing"/> + <label role="caen_cd1" property="trigger_holdoff"/> + <label role="caen_cd1" property="rise_time"/> + <label role="caen_cd1" property="decay_time"/> + <label role="caen_cd1" property="trapezoid_rise"/> + <label role="caen_cd1" property="trapezoid_flat"/> + <label role="caen_cd1" property="base_mean"/> + <label role="caen_cd1" property="trapezoid_gain"/> + <label role="caen_cd1" property="flat_top"/> + <label role="caen_cd1" property="peak_mean"/> + <label role="caen_cd1" property="base_holdoff"/> + <label role="caen_cd1" property="peak_holdoff"/> + </dynamic_composite> + </table_composite> + </group> + --> +</plugin> diff --git a/src/drivers/caen_pha/RealCAENPhaDriver.cpp b/src/drivers/caen_pha/RealCAENPhaDriver.cpp index 327c77bb..acc6020c 100644 --- a/src/drivers/caen_pha/RealCAENPhaDriver.cpp +++ b/src/drivers/caen_pha/RealCAENPhaDriver.cpp @@ -50,9 +50,10 @@ void RealCAENPhaDriver::open() { boardParams.VMEBaseAddress = owner()->address(); ret = CAEN_DGTZ_OpenDigitizer(boardParams.LinkType, 0, 0, boardParams.VMEBaseAddress, &m_boardHandle); if (ret) { - cout << "Error CAEN_DGTZ_OpenDigitizer: " << ret << endl; + cerr << "Error CAEN_DGTZ_OpenDigitizer: " << ret << endl; return; } + } /*! @@ -77,7 +78,7 @@ void RealCAENPhaDriver::init() { // Channel CTRL register (individual trigger, sequencial readout) ret = CAEN_DGTZ_WriteRegister(m_boardHandle, 0x8000, 0x01000114); if (ret) { - cout << "Error CAEN_DGTZ_WriteRegister: " << ret << endl; + cerr << "Error CAEN_DGTZ_WriteRegister: " << ret << endl; close(); return; } @@ -90,8 +91,6 @@ void RealCAENPhaDriver::init() { boardParams.DPPAcqMode = CAEN_DGTZ_DPP_ACQ_MODE_Oscilloscope; } boardParams.SaveMode = (CAEN_DGTZ_DPP_SaveParam_t)owner()->saveMode(); - cout << "DPPAcqModeboard: " << boardParams.DPPAcqMode << endl; - cout << "SaveMode: " << boardParams.SaveMode << endl; if (owner()->modelName() == "Pha") { ret = CAEN_DGTZ_SetDPPAcquisitionMode(m_boardHandle, boardParams.DPPAcqMode, boardParams.SaveMode); } else { @@ -100,7 +99,7 @@ void RealCAENPhaDriver::init() { ret = CAEN_DGTZ_SetDPPAcquisitionMode(m_boardHandle, boardParams.DPPAcqMode, boardParams.SaveMode); } if (ret) { - cout << "Error CAEN_DGTZ_SetDPPAcquisitionMode: " << ret << endl; + cerr << "Error CAEN_DGTZ_SetDPPAcquisitionMode: " << ret << endl; close(); return; } @@ -109,7 +108,7 @@ void RealCAENPhaDriver::init() { boardParams.AcqMode = (CAEN_DGTZ_AcqMode_t)owner()->acqMode(); ret = CAEN_DGTZ_SetAcquisitionMode(m_boardHandle, CAEN_DGTZ_S_IN_CONTROLLED); //boardParams.AcqMode); if (ret) { - cout << "Error CAEN_DGTZ_SetAcquisitionMode: " << ret << endl; + cerr << "Error CAEN_DGTZ_SetAcquisitionMode: " << ret << endl; close(); return; } @@ -118,7 +117,7 @@ void RealCAENPhaDriver::init() { boardParams.RecordLength = owner()->recordLength(); ret = CAEN_DGTZ_SetRecordLength(m_boardHandle, boardParams.RecordLength); if (ret) { - cout << "Error CAEN_DGTZ_SetRecordLength: " << ret << endl; + cerr << "Error CAEN_DGTZ_SetRecordLength: " << ret << endl; close(); return; } @@ -127,7 +126,7 @@ void RealCAENPhaDriver::init() { boardParams.IOLevel = (CAEN_DGTZ_IOLevel_t)owner()->ioLevel(); ret = CAEN_DGTZ_SetIOLevel(m_boardHandle, boardParams.IOLevel); if (ret) { - cout << "Error CAEN_DGTZ_SetIOLevel: " << ret << endl; + cerr << "Error CAEN_DGTZ_SetIOLevel: " << ret << endl; close(); return; } @@ -136,7 +135,7 @@ void RealCAENPhaDriver::init() { boardParams.TriggerMode = (CAEN_DGTZ_TriggerMode_t)owner()->triggerMode(); ret = CAEN_DGTZ_SetExtTriggerInputMode(m_boardHandle, boardParams.TriggerMode); if (ret) { - cout << "Error CAEN_DGTZ_SetExtTriggerInputMode: " << ret << endl; + cerr << "Error CAEN_DGTZ_SetExtTriggerInputMode: " << ret << endl; close(); return; } @@ -145,7 +144,7 @@ void RealCAENPhaDriver::init() { boardParams.ChannelMask = owner()->channelMask(); ret = CAEN_DGTZ_SetChannelEnableMask(m_boardHandle, boardParams.ChannelMask); if (ret) { - cout << "Error CAEN_DGTZ_SetChannelEnableMask: " << ret << endl; + cerr << "Error CAEN_DGTZ_SetChannelEnableMask: " << ret << endl; close(); return; } @@ -155,7 +154,7 @@ void RealCAENPhaDriver::init() { boardParams.EventAggr = 0; ret = CAEN_DGTZ_SetDPPEventAggregation(m_boardHandle, boardParams.EventAggr, 0); if (ret) { - cout << "Error CAEN_DGTZ_SetDPPEventAggregation: " << ret << endl; + cerr << "Error CAEN_DGTZ_SetDPPEventAggregation: " << ret << endl; close(); return; } @@ -163,20 +162,17 @@ void RealCAENPhaDriver::init() { // Set multi-board synchronization mode ret = CAEN_DGTZ_SetRunSynchronizationMode(m_boardHandle, CAEN_DGTZ_RUN_SYNC_Disabled); if (ret) { - cout << "Error CAEN_DGTZ_SetRunSynchronizationMode: " << ret << endl; + cerr << "Error CAEN_DGTZ_SetRunSynchronizationMode: " << ret << endl; close(); return; } // Set virtual probe settings - cout << "modelName: " << owner()->modelName() << endl; if (owner()->modelName() == "V1724") { - cout << "probe for 1724" << endl; ret = CAEN_DGTZ_SetDPP_PHA_VirtualProbe(m_boardHandle, CAEN_DGTZ_DPP_VIRTUALPROBE_DUAL, CAEN_DGTZ_DPP_PHA_VIRTUALPROBE1_trapezoid, CAEN_DGTZ_DPP_PHA_VIRTUALPROBE2_Input, CAEN_DGTZ_DPP_PHA_DIGITAL_PROBE_Peaking); } else { - cout << "probe for 1730" << endl; ret = CAEN_DGTZ_SetDPP_VirtualProbe(m_boardHandle, ANALOG_TRACE_1, CAEN_DGTZ_DPP_PHA_VIRTUALPROBE1_trapezoid); ret = CAEN_DGTZ_SetDPP_VirtualProbe(m_boardHandle, ANALOG_TRACE_2, CAEN_DGTZ_DPP_PHA_VIRTUALPROBE2_Input); ret = CAEN_DGTZ_SetDPP_VirtualProbe(m_boardHandle, DIGITAL_TRACE_1, CAEN_DGTZ_DPP_DIGITALPROBE_Peaking); @@ -185,14 +181,14 @@ void RealCAENPhaDriver::init() { // ret = CAEN_DGTZ_SetDPP_VirtualProbe(m_boardHandle, DIGITAL_TRACE_3, CAEN_DGTZ_DPP_PHA_DIGITAL_PROBE_Peaking); } if (ret) { - cout << "Error CAEN_DGTZ_SetDPP_VirtualProbe: " << ret << endl; + cerr << "Error CAEN_DGTZ_SetDPP_VirtualProbe: " << ret << endl; close(); return; } ret = CAEN_DGTZ_WriteRegister(m_boardHandle, 0x8100, 0x5); if (ret) { - cout << "Error CAEN_DGTZ_WriteRegister: " << ret << endl; + cerr << "Error CAEN_DGTZ_WriteRegister: " << ret << endl; close(); return; } @@ -208,10 +204,17 @@ void RealCAENPhaDriver::init() { void RealCAENPhaDriver::clear() { open(); - ret = CAEN_DGTZ_ClearData(m_boardHandle); + boardParams.IOLevel = (CAEN_DGTZ_IOLevel_t)owner()->ioLevel(); + ret = CAEN_DGTZ_SetIOLevel(m_boardHandle, boardParams.IOLevel); + if (ret) { + cerr << "Error CAEN_DGTZ_SetIOLevel: " << ret << endl; + close(); + return; + } + /*ret = CAEN_DGTZ_ClearData(m_boardHandle); if (ret) { - cout << "Error CAEN_DGTZ_ClearData: " << ret << endl; - } + cerr << "Error CAEN_DGTZ_ClearData: " << ret << endl; + }*/ close(); } @@ -223,7 +226,7 @@ void RealCAENPhaDriver::reset() { open(); ret = CAEN_DGTZ_Reset(m_boardHandle); if (ret) { - cout << "Error CAEN_DGTZ_Reset: " << ret << endl; + cerr << "Error CAEN_DGTZ_Reset: " << ret << endl; } close(); } @@ -256,11 +259,10 @@ void RealCAENPhaDriver::writeParam() { } open(); - - // Write channels parameters + // Write channels parameters ret = CAEN_DGTZ_SetDPPParameters(m_boardHandle, boardParams.ChannelMask, &dppParams); if (ret) { - cout << "Error CAEN_DGTZ_SetDPPParameters" << endl; + cerr << "Error CAEN_DGTZ_SetDPPParameters" << endl; close(); return; } @@ -273,7 +275,7 @@ void RealCAENPhaDriver::writeParam() { offset = offset * 65535 / 100; ret = CAEN_DGTZ_SetChannelDCOffset(m_boardHandle, i, offset); if (ret) { - cout << "Error CAEN_DGTZ_SetChannelDCOffset" << endl; + cerr << "Error CAEN_DGTZ_SetChannelDCOffset" << endl; close(); return; } @@ -282,7 +284,7 @@ void RealCAENPhaDriver::writeParam() { int32 ptgrSize = owner()->preTrigger.get(i); ret = CAEN_DGTZ_SetDPPPreTriggerSize(m_boardHandle, i, ptgrSize); if (ret) { - cout << "Error CAEN_DGTZ_SetDPPPreTriggerSize" << endl; + cerr << "Error CAEN_DGTZ_SetDPPPreTriggerSize" << endl; close(); return; } @@ -291,7 +293,7 @@ void RealCAENPhaDriver::writeParam() { CAEN_DGTZ_PulsePolarity_t polarity = (CAEN_DGTZ_PulsePolarity_t)owner()->pulsePolarity.get(i); ret = CAEN_DGTZ_SetChannelPulsePolarity(m_boardHandle, i, polarity); if (ret) { - cout << "Error CAEN_DGTZ_SetChannelPulsePolarity" << endl; + cerr << "Error CAEN_DGTZ_SetChannelPulsePolarity" << endl; close(); return; } @@ -299,17 +301,19 @@ void RealCAENPhaDriver::writeParam() { // Enable Fake Events for TimeTag Rollover (used for low rates applications) uint32_t val; uint32_t addr = PHA_FAKEEVTS_ROLLOVER_REG | (i<<8); - uint32_t bitMask = 0x04000000; // bit 26 + //uint32_t bitMask = 0x04000000; // bit 26 + uint32_t bitMask = 0xFBFFFFFF; // bit 26 Not used in PF1 -- HACk Emilio IFC1210 does the roll over ret = CAEN_DGTZ_ReadRegister(m_boardHandle, addr, &val); if (ret) { - cout << "Error CAEN_DGTZ_ReadRegister" << endl; + cerr << "Error CAEN_DGTZ_ReadRegister" << endl; close(); return; } - val |= bitMask; + //val |= bitMask; + val &= bitMask; ret = CAEN_DGTZ_WriteRegister(m_boardHandle, addr, val); if (ret) { - cout << "Error CAEN_DGTZ_WriteRegister" << endl; + cerr << "Error CAEN_DGTZ_WriteRegister" << endl; close(); return; } @@ -329,7 +333,7 @@ void RealCAENPhaDriver::setAcqMode() { boardParams.SaveMode = (CAEN_DGTZ_DPP_SaveParam_t)owner()->saveMode(); ret = CAEN_DGTZ_SetDPPAcquisitionMode(m_boardHandle, boardParams.DPPAcqMode, boardParams.SaveMode); if (ret) { - cout << "Error CAEN_DGTZ_SetDPPAcquisitionMode: " << ret << endl; + cerr << "Error CAEN_DGTZ_SetDPPAcquisitionMode: " << ret << endl; } close(); } @@ -342,7 +346,6 @@ void RealCAENPhaDriver::readInfos() { open(); ret = CAEN_DGTZ_GetInfo(m_boardHandle, &boardInfo); close(); - owner()->nbBits = boardInfo.ADC_NBits; owner()->model = boardInfo.Model; owner()->channels = boardInfo.Channels; diff --git a/src/drivers/caen_pks/CAENPksDef.h b/src/drivers/caen_pks/CAENPksDef.h new file mode 100644 index 00000000..60dc55c9 --- /dev/null +++ b/src/drivers/caen_pks/CAENPksDef.h @@ -0,0 +1,39 @@ +/*! + * \brief + * Nomad Instrument Control Software + * + * Copyright 2011 Institut Laue-Langevin + * + * Licensed under the EUPL, Version 1.1 only (the "License"); + * You may not use this work except in compliance with the Licence. + * You may obtain a copy of the Licence at: + * + * http://joinup.ec.europa.eu/software/page/eupl + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the Licence is distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Licence for the specific language governing permissions and + * limitations under the Licence. + */ + +#ifndef CAENPKSDEF_H +#define CAENPKSDEF_H + +#include "common/base/BaseTypes.h" + +namespace caen_pks { + +#define PKS_FIRMWARE_REG 0X1000 +#define PKS_BIT2SET_REG 0X1032 +#define PKS_BIT2CLR_REG 0X1034 +#define PKS_VERSION_REG 0X8032 +#define PKS_BOARD_ID_MSB_REG 0X8036 +#define PKS_BOARD_ID_REG 0X803A +#define PKS_BOARD_ID_LSB_REG 0X803E +#define PKS_THRESHOLD_REG 0X1080 +#define PKS_CHANNEL_INCREMENT 0X0002 + +} + +#endif // CAENPKSDEF_H diff --git a/src/drivers/caen_pks/CAENPksDriver.cpp b/src/drivers/caen_pks/CAENPksDriver.cpp new file mode 100644 index 00000000..6db4d654 --- /dev/null +++ b/src/drivers/caen_pks/CAENPksDriver.cpp @@ -0,0 +1,134 @@ +/* + * Nomad Instrument Control Software + * + * Copyright 2011 Institut Laue-Langevin + * + * Licensed under the EUPL, Version 1.1 only (the "License"); + * You may not use this work except in compliance with the Licence. + * You may obtain a copy of the Licence at: + * + * http://joinup.ec.europa.eu/software/page/eupl + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the Licence is distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Licence for the specific language governing permissions and + * limitations under the Licence. + */ + +#include "CAENPksDef.h" +#include "CAENPksState.h" +#include "CAENPksDriver.h" +#include "PerfectCAENPksDriver.h" +#include "RealCAENPksDriver.h" +#include "drivers/global/DriversCommands.h" + +using namespace driver; + +namespace caen_pks { + +const std::string CAENPksDriver::TYPE = "caen_pks"; + +const std::string CAENPksDriver::WRITE_PARAMETERS_COMMAND = "writeParam"; +const std::string CAENPksDriver::RESET_COMMAND = "reset"; +const std::string CAENPksDriver::CLEAR_COMMAND = "clear"; + +/* + * Constructor + */ +CAENPksDriver::CAENPksDriver(const string& name) { + + driver::Vme::init(name); + + registerStates(new RealCAENPksDriver(this), new PerfectCAENPksDriver(this), new PerfectCAENPksDriver(this)); + + // Global properties + nbChannels.init(this, SAVE, "nb_channels"); + model.init(this, NOSAVE, "model"); + modelName.init(this, SAVE, "model_name"); + firmware.init(this, NOSAVE, "firmware"); + triggerThreshold.init(this, SAVE, "trigger_threshold"); + channelActive.init(this, SAVE, "channel_active"); + channelActiveStr.init(this, NOSAVE, "channel_active_str"); + + // Init the device command list + initCommand(driver::INIT_COMMAND); + initCommand(driver::READ_INFOS_COMMAND); + initCommand(WRITE_PARAMETERS_COMMAND); + initCommand(RESET_COMMAND); + initCommand(CLEAR_COMMAND); + + // Init functions + registerFunction(NONE_FUNCTION); + + addressType.update(driver::Vme::A32_ACCESS); + deviceType = LEAF_DEVICE_TYPE_DEVICE_CONTAINER; + + registerRefresher(nbChannels, &CAENPksDriver::refreshNbChannelsProperty, this); + registerRefresher(channelActive, &CAENPksDriver::refreshChannelActiveProperty, this); +} + +/* + * Destructor + */ +CAENPksDriver::~CAENPksDriver() { + +} + +/* + * execute + */ +void CAENPksDriver::execute(const std::string& aCommand) { + + if ((aCommand != driver::STOP_COMMAND) && (aCommand != driver::STATUS_COMMAND) + && (aCommand != driver::READ_COMMAND)) { + commandProgression = PROGRESSION_UNKNOWNSTATE_DEVICE_CONTAINER; + } + + CAENPksState* currentState = dynamic_cast<CAENPksState*>(getCurrentState()); + // Check command + if (aCommand == driver::INIT_COMMAND) { + // Init command + currentState->init(); + } else if (aCommand == WRITE_PARAMETERS_COMMAND) { + // writeParam command + currentState->writeParam(); + commandProgression = PROGRESSION_END_DEVICE_CONTAINER; + } else if (aCommand == CLEAR_COMMAND) { + // clear command + currentState->clear(); + commandProgression = PROGRESSION_END_DEVICE_CONTAINER; + } else if (aCommand == RESET_COMMAND) { + // clear command + currentState->reset(); + commandProgression = PROGRESSION_END_DEVICE_CONTAINER; + } else if (aCommand == driver::READ_INFOS_COMMAND) { + // Info command + currentState->readInfos(); + commandProgression = PROGRESSION_END_DEVICE_CONTAINER; + } else { + //Error bad command + //Todo , normaly it will be detect it device action driver + } +} + +void CAENPksDriver::refreshNbChannelsProperty(int32 aValue) throw (CannotSetValue){ + + triggerThreshold.resize(aValue); + channelActive.resize(aValue); + channelActiveStr.resize(aValue); +} + +void CAENPksDriver::refreshChannelActiveProperty(int32 index, int32 aValue) throw (CannotSetValue) { + + switch (aValue) { + case 0: + channelActiveStr.set(index, "Inactive"); + break; + case 1: + channelActiveStr.set(index, "Active"); + break; + } +} + +} diff --git a/src/drivers/caen_pks/CAENPksDriver.h b/src/drivers/caen_pks/CAENPksDriver.h new file mode 100644 index 00000000..00f52f30 --- /dev/null +++ b/src/drivers/caen_pks/CAENPksDriver.h @@ -0,0 +1,85 @@ +/* + * Nomad Instrument Control Software + * + * Copyright 2011 Institut Laue-Langevin + * + * Licensed under the EUPL, Version 1.1 only (the "License"); + * You may not use this work except in compliance with the Licence. + * You may obtain a copy of the Licence at: + * + * http://joinup.ec.europa.eu/software/page/eupl + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the Licence is distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Licence for the specific language governing permissions and + * limitations under the Licence. + */ + +#ifndef CAENPKSDRIVER_H +#define CAENPKSDRIVER_H + +#include <Driver.h> +#include "drivers/global/Vme.h" + +namespace caen_pks { + +/*! + * \class CAENPksDriver + * \brief Main class for the CAENPksDriver device driver + * + * \par + * Class for CAENPksDriver driver. Implements DeviceDriver methods. + * \par + * The CAENPksDriver device manages the global functionality of the CAEN V785 VME Peak Sensing ADCr. + */ + +class CAENPksDriver : public driver::Vme { + +public: + + //! Driver type value + static const std::string TYPE; + + /*! + * \brief Constructor + * \param[in] name the name of the device driver + */ + CAENPksDriver(const std::string& name); + + /*! + * \brief Destructor + */ + virtual ~CAENPksDriver(); + + /*! + * \brief Method called for executing a command + * + * \param[in] command the command to apply on the controller + */ + virtual void execute(const std::string& aCommand); + + // Global properties + Property<int32> nbChannels; + Property<int32> model; + Property<int32> firmware; + Property<std::string> modelName; + + // Channels properties + DynamicProperty<int32> triggerThreshold; // thr - range 0:16383 + DynamicProperty<int32> channelActive; + DynamicProperty<std::string> channelActiveStr; + + // Commands + static const std::string WRITE_PARAMETERS_COMMAND; + static const std::string RESET_COMMAND; + static const std::string CLEAR_COMMAND; + +private: + + void refreshNbChannelsProperty(int32 aValue) throw (CannotSetValue); + void refreshChannelActiveProperty(int32 index, int32 aValue) throw (CannotSetValue); +}; + +} +#endif //CAENPHADRIVER_H diff --git a/src/drivers/caen_pks/CAENPksState.h b/src/drivers/caen_pks/CAENPksState.h new file mode 100644 index 00000000..45890dd7 --- /dev/null +++ b/src/drivers/caen_pks/CAENPksState.h @@ -0,0 +1,69 @@ +/* + * Nomad Instrument Control Software + * + * Copyright 2011 Institut Laue-Langevin + * + * Licensed under the EUPL, Version 1.1 only (the "License"); + * You may not use this work except in compliance with the Licence. + * You may obtain a copy of the Licence at: + * + * http://joinup.ec.europa.eu/software/page/eupl + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the Licence is distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Licence for the specific language governing permissions and + * limitations under the Licence. + */ + +#ifndef CAENPKSSTATE_H +#define CAENPKSSTATE_H + +#include <Driver.h> +#include "CAENPksDriver.h" + +namespace caen_pks { + +/*! + * \class CAENPhaState + * \brief Implements State pattern + */ +class CAENPksState: public DriverState<CAENPksDriver> { + +public: + + /*! + * \brief Constructor. + */ + CAENPksState(CAENPksDriver* owner) : + DriverState<CAENPksDriver> (owner) {} + + /*! + * \brief Destructor. + */ + virtual ~CAENPksState() {} + + /*! + * \brief Reset command implementation + */ + virtual void reset() = 0; + + /*! + * \brief Clear command implementation + */ + virtual void clear() = 0; + + /*! + * \brief Write Param command implementation + */ + virtual void writeParam() = 0; + + /*! + * \brief Read Infos command implementation + */ + virtual void readInfos() = 0; +}; + +} + +#endif //CAENKSASTATE_H diff --git a/src/drivers/caen_pks/Module.xml b/src/drivers/caen_pks/Module.xml new file mode 100644 index 00000000..b891ce33 --- /dev/null +++ b/src/drivers/caen_pks/Module.xml @@ -0,0 +1,6 @@ +<module name="caen_pks"> + <driver type="caen_pks::CAENPksDriver"/> + + <include path="$(NOMAD_HOME)/../NomadModules/src"/> + <link path="/usr/lib" lib="CAENDigitizer"/> +</module> \ No newline at end of file diff --git a/src/drivers/caen_pks/PerfectCAENPksDriver.cpp b/src/drivers/caen_pks/PerfectCAENPksDriver.cpp new file mode 100644 index 00000000..7b65a2fe --- /dev/null +++ b/src/drivers/caen_pks/PerfectCAENPksDriver.cpp @@ -0,0 +1,76 @@ +/* + * Nomad Instrument Control Software + * + * Copyright 2011 Institut Laue-Langevin + * + * Licensed under the EUPL, Version 1.1 only (the "License"); + * You may not use this work except in compliance with the Licence. + * You may obtain a copy of the Licence at: + * + * http://joinup.ec.europa.eu/software/page/eupl + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the Licence is distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Licence for the specific language governing permissions and + * limitations under the Licence. + */ + +#include "PerfectCAENPksDriver.h" +#include "CAENPksDef.h" + +using namespace std; + +namespace caen_pks { + +/* + * Constructor + */ +PerfectCAENPksDriver::PerfectCAENPksDriver(CAENPksDriver* owner) : + CAENPksState(owner) { + /* Empty */ +} + +/* + * Destructor + */ +PerfectCAENPksDriver::~PerfectCAENPksDriver() { + /* Empty */ +} + +/*! + * \brief Init command implementation + */ +void PerfectCAENPksDriver::init() { + +} + +/*! + * \brief Clear command implementation + */ +void PerfectCAENPksDriver::clear() { + +} + +/*! + * \brief Reset command implementation + */ +void PerfectCAENPksDriver::reset() { + +} + +/*! + * \brief Write Param command implementation + */ +void PerfectCAENPksDriver::writeParam() { + +} + +/*! + * \brief Read Infos command implementation + */ +void PerfectCAENPksDriver::readInfos() { + +} + +} diff --git a/src/drivers/caen_pks/PerfectCAENPksDriver.h b/src/drivers/caen_pks/PerfectCAENPksDriver.h new file mode 100644 index 00000000..e743b783 --- /dev/null +++ b/src/drivers/caen_pks/PerfectCAENPksDriver.h @@ -0,0 +1,74 @@ +/* + * Nomad Instrument Control Software + * + * Copyright 2011 Institut Laue-Langevin + * + * Licensed under the EUPL, Version 1.1 only (the "License"); + * You may not use this work except in compliance with the Licence. + * You may obtain a copy of the Licence at: + * + * http://joinup.ec.europa.eu/software/page/eupl + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the Licence is distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Licence for the specific language governing permissions and + * limitations under the Licence. + */ + +#ifndef PERFECTCAENPKSDRIVER_H +#define PERFECTCAENPKSDRIVER_H + +#include "CAENPksState.h" + +namespace caen_pks { + + +/** + * Perfect implementation of the vme card called Bit3 617,618,620. + */ +class PerfectCAENPksDriver : public CAENPksState { + +public: + + /** + * Constructor. + * + * @param Link to the class which used the state + */ + PerfectCAENPksDriver(CAENPksDriver* owner); + + /** + * Destructor. + * Empty. + */ + virtual ~PerfectCAENPksDriver(); + + /*! + * \brief Init command implementation + */ + virtual void init(); + + /*! + * \brief Clear command implementation + */ + virtual void clear(); + + /*! + * \brief Reset command implementation + */ + virtual void reset(); + + /*! + * \brief Write Param command implementation + */ + virtual void writeParam(); + + /*! + * \brief Read Infos command implementation + */ + virtual void readInfos(); +}; + +} +#endif //PERFECTCAENPKSDRIVER_H diff --git a/src/drivers/caen_pks/RealCAENPksDriver.cpp b/src/drivers/caen_pks/RealCAENPksDriver.cpp new file mode 100644 index 00000000..350a7dd5 --- /dev/null +++ b/src/drivers/caen_pks/RealCAENPksDriver.cpp @@ -0,0 +1,106 @@ +/* + * Nomad Instrument Control Software + * + * Copyright 2011 Institut Laue-Langevin + * + * Licensed under the EUPL, Version 1.1 only (the "License"); + * You may not use this work except in compliance with the Licence. + * You may obtain a copy of the Licence at: + * + * http://joinup.ec.europa.eu/software/page/eupl + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the Licence is distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Licence for the specific language governing permissions and + * limitations under the Licence. + */ + +#include "RealCAENPksDriver.h" +#include "CAENPksDriver.h" +#include <controllers/common/acquisition/mode/DPPAcquisitionCommon.h> + +using namespace std; +using namespace driver; + +namespace caen_pks { + +/* + * Constructor + */ +RealCAENPksDriver::RealCAENPksDriver(CAENPksDriver* owner) : + CAENPksState(owner) { + +} + +/* + * Destructor + */ +RealCAENPksDriver::~RealCAENPksDriver() { + +} + +/*! + * \brief Init command implementation + */ +void RealCAENPksDriver::init() { + + reset(); + + readInfos(); + + writeParam(); +} + +/*! + * \brief Clear command implementation + */ +void RealCAENPksDriver::clear() { + + uint16 value = 0; + owner()->read(PKS_BIT2SET_REG, Vme::WORD_WIDTH, 1, (void*) &value); + cout << "value out: 0x" << hex << value << dec << endl; + value = value | (1<<2); + cout << "value in: 0x" << hex << value << dec << endl; + owner()->write(PKS_BIT2SET_REG, Vme::WORD_WIDTH, 1, (void*) &value); + value = 1<<2; + owner()->write(PKS_BIT2CLR_REG, Vme::WORD_WIDTH, 1, (void*) &value); +} + +/*! + * \brief Reset command implementation + */ +void RealCAENPksDriver::reset() { + + clear(); +} + +/*! + * \brief Write Param command implementation + */ +void RealCAENPksDriver::writeParam() { + // Write threshold and active flag + for (int32 index=0; index<owner()->nbChannels(); ++index) { + uint32 adrs = PKS_THRESHOLD_REG + (PKS_CHANNEL_INCREMENT * index); + uint16 value = owner()->triggerThreshold.get(index); + if (owner()->channelActive.get(index) == 0) { + value += 1<<8; + } + owner()->write(adrs, Vme::WORD_WIDTH, 1, (void*) &value); + } +} + +/*! + * \brief Read Infos command implementation + */ +void RealCAENPksDriver::readInfos() { + + uint16 value = 0; + owner()->read(PKS_FIRMWARE_REG, Vme::WORD_WIDTH, 1, (void*) &value); + owner()->firmware = value; + value = 0; + owner()->read(PKS_VERSION_REG, Vme::WORD_WIDTH, 1, (void*) &value); + owner()->model = value; +} + +} diff --git a/src/drivers/caen_pks/RealCAENPksDriver.h b/src/drivers/caen_pks/RealCAENPksDriver.h new file mode 100644 index 00000000..bcfd6905 --- /dev/null +++ b/src/drivers/caen_pks/RealCAENPksDriver.h @@ -0,0 +1,77 @@ +/* + * Nomad Instrument Control Software + * + * Copyright 2011 Institut Laue-Langevin + * + * Licensed under the EUPL, Version 1.1 only (the "License"); + * You may not use this work except in compliance with the Licence. + * You may obtain a copy of the Licence at: + * + * http://joinup.ec.europa.eu/software/page/eupl + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the Licence is distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Licence for the specific language governing permissions and + * limitations under the Licence. + */ + +#ifndef REALCAENPKSDRIVER_H +#define REALCAENPKSDRIVER_H + +#include "CAENPksState.h" +#include "CAENPksDef.h" + +namespace caen_pks { + +class CAENPhaDriver; + +/** + * Real implementation + */ +class RealCAENPksDriver : public CAENPksState { + +public: + + /** + * Constructor. + * + * @param Link to the class which used the state + */ + RealCAENPksDriver(CAENPksDriver* owner); + + /** + * Destructor. + * Empty. + */ + virtual ~RealCAENPksDriver(); + + /*! + * \brief Init command implementation + */ + virtual void init(); + + /*! + * \brief Clear command implementation + */ + virtual void clear(); + + /*! + * \brief Reset command implementation + */ + virtual void reset(); + + /*! + * \brief Write Param command implementation + */ + virtual void writeParam(); + + /*! + * \brief Read Infos command implementation + */ + virtual void readInfos(); + +}; + +} +#endif //REALCAENPKSDRIVER_H diff --git a/src/drivers/caen_pks/gui/caen_pks.properties b/src/drivers/caen_pks/gui/caen_pks.properties new file mode 100644 index 00000000..a182ab76 --- /dev/null +++ b/src/drivers/caen_pks/gui/caen_pks.properties @@ -0,0 +1,11 @@ +# Board Info +caen_pks.boardInfoTitle=Board Info +caen_pks.model=Model #: +caen_pks.firmware=Firmware #: +caen_pks.channels=Channels: +caen_pks.modelName=Model: + +# Channel Params +caen_pks.channelParamsTitle=Channel Parameters +caen_pks.channelActive=Channel active +caen_pks.threshold=Threshold diff --git a/src/drivers/caen_pks/gui/caen_pksPlugin.xml b/src/drivers/caen_pks/gui/caen_pksPlugin.xml new file mode 100644 index 00000000..3683894c --- /dev/null +++ b/src/drivers/caen_pks/gui/caen_pksPlugin.xml @@ -0,0 +1,7 @@ +<controller_plugin_config type="caen_pks"> + + <image key="HARDWARE_VME_MODULE"/> + + <settings view="caen_pksView.xml"/> + +</controller_plugin_config> diff --git a/src/drivers/caen_pks/gui/caen_pksProperties.xml b/src/drivers/caen_pks/gui/caen_pksProperties.xml new file mode 100644 index 00000000..fe8b8728 --- /dev/null +++ b/src/drivers/caen_pks/gui/caen_pksProperties.xml @@ -0,0 +1,17 @@ +<?xml version="1.0" encoding="ISO-8859-1" ?> + +<controller type="caen_pks"> + + <property name="nb_channels" type="int32" max_length="2"> + </property> + + <dynamic_property name="trigger_threshold" size_property="nb_channels" type="int32" max_length="6"> + </dynamic_property> + + <dynamic_property name="channel_active" size_property="nb_channels" type="int32"> + </dynamic_property> + + <dynamic_property name="channel_active_str" size_property="nb_channels" type="string" max_length="8"> + </dynamic_property> + +</controller> diff --git a/src/drivers/caen_pks/gui/caen_pksView.xml b/src/drivers/caen_pks/gui/caen_pksView.xml new file mode 100644 index 00000000..ad6ecf35 --- /dev/null +++ b/src/drivers/caen_pks/gui/caen_pksView.xml @@ -0,0 +1,25 @@ +<plugin> + <controller type="caen_pks" role="caen_pks1"/> + <group title="caen_pks.boardInfoTitle"> + <table_composite nbColumns="2"> + <label role="caen_pks1" property="model" prefix="caen_pks.model"/> + <label role="caen_pks1" property="nb_channels" prefix="caen_pks.channels"/> + <label role="caen_pks1" property="model_name" prefix="caen_pks.modelName"/> + </table_composite> + <newLine/> + <label role="caen_pks1" property="firmware" prefix="caen_pks.firmware"/> + </group> + + <newLine/> + <group title="caen_pks.channelParamsTitle"> + <table_composite nbColumns="2"> + <simple_label prefix="caen_pks.channelActive"/> + <simple_label prefix="caen_pks.threshold"/> + <dynamic_composite role="caen_pks1" properties="channel_active_str,trigger_threshold"> + <label role="caen_pks1" property="channel_active_str"/> + <label role="caen_pks1" property="trigger_threshold"/> + </dynamic_composite> + </table_composite> + </group> + +</plugin> diff --git a/src/drivers/caen_psd/RealCAENPsdDriver.cpp b/src/drivers/caen_psd/RealCAENPsdDriver.cpp index e842b0af..09a61720 100644 --- a/src/drivers/caen_psd/RealCAENPsdDriver.cpp +++ b/src/drivers/caen_psd/RealCAENPsdDriver.cpp @@ -49,7 +49,7 @@ void RealCAENPsdDriver::open() { boardParams.VMEBaseAddress = owner()->address(); ret = CAEN_DGTZ_OpenDigitizer(boardParams.LinkType, 0, 0, boardParams.VMEBaseAddress, &m_boardHandle); if (ret) { - cout << "Error CAEN_DGTZ_OpenDigitizer: " << ret << endl; + cerr << "Error CAEN_DGTZ_OpenDigitizer: " << ret << endl; return; } } @@ -74,12 +74,11 @@ void RealCAENPsdDriver::init() { // Channel CTRL register (individual trigger, sequencial readout) ret = CAEN_DGTZ_WriteRegister(m_boardHandle, 0x8000, 0x01000114); if (ret) { - cout << "Error CAEN_DGTZ_WriteRegister: " << ret << endl; + cerr << "Error CAEN_DGTZ_WriteRegister: " << ret << endl; close(); return; } - // Set acquisition mode // Set acquisition mode if (owner()->dppAcqMode() == acquisition::DPPAcquisitionCommon::LISTMODE_MODE) { boardParams.DPPAcqMode = CAEN_DGTZ_DPP_ACQ_MODE_List; @@ -90,7 +89,7 @@ void RealCAENPsdDriver::init() { boardParams.SaveMode = (CAEN_DGTZ_DPP_SaveParam_t)owner()->saveMode(); ret = CAEN_DGTZ_SetDPPAcquisitionMode(m_boardHandle, boardParams.DPPAcqMode, boardParams.SaveMode); if (ret) { - cout << "Error CAEN_DGTZ_SetDPPAcquisitionMode: " << ret << endl; + cerr << "Error CAEN_DGTZ_SetDPPAcquisitionMode: " << ret << endl; close(); return; } @@ -99,7 +98,7 @@ void RealCAENPsdDriver::init() { boardParams.AcqMode = (CAEN_DGTZ_AcqMode_t)owner()->acqMode(); ret = CAEN_DGTZ_SetAcquisitionMode(m_boardHandle, CAEN_DGTZ_S_IN_CONTROLLED); //boardParams.AcqMode); if (ret) { - cout << "Error CAEN_DGTZ_SetAcquisitionMode: " << ret << endl; + cerr << "Error CAEN_DGTZ_SetAcquisitionMode: " << ret << endl; close(); return; } @@ -108,7 +107,7 @@ void RealCAENPsdDriver::init() { boardParams.IOLevel = (CAEN_DGTZ_IOLevel_t)owner()->ioLevel(); ret = CAEN_DGTZ_SetIOLevel(m_boardHandle, boardParams.IOLevel); if (ret) { - cout << "Error CAEN_DGTZ_SetIOLevel: " << ret << endl; + cerr << "Error CAEN_DGTZ_SetIOLevel: " << ret << endl; close(); return; } @@ -117,7 +116,7 @@ void RealCAENPsdDriver::init() { boardParams.TriggerMode = (CAEN_DGTZ_TriggerMode_t)owner()->triggerMode(); ret = CAEN_DGTZ_SetExtTriggerInputMode(m_boardHandle, boardParams.TriggerMode); if (ret) { - cout << "Error CAEN_DGTZ_SetExtTriggerInputMode: " << ret << endl; + cerr << "Error CAEN_DGTZ_SetExtTriggerInputMode: " << ret << endl; close(); return; } @@ -126,17 +125,24 @@ void RealCAENPsdDriver::init() { boardParams.ChannelMask = owner()->channelMask(); ret = CAEN_DGTZ_SetChannelEnableMask(m_boardHandle, boardParams.ChannelMask); if (ret) { - cout << "Error CAEN_DGTZ_SetChannelEnableMask: " << ret << endl; + cerr << "Error CAEN_DGTZ_SetChannelEnableMask: " << ret << endl; close(); return; } // Set aggregate size - how many events per output buffer // 0 = automatic - boardParams.EventAggr = 0; + if (owner()->dppAcqMode() == acquisition::DPPAcquisitionCommon::LISTMODE_MODE) { + boardParams.EventAggr = 2;//0; + } + else if (owner()->dppAcqMode() == acquisition::DPPAcquisitionCommon::SCOPE_MODE) { + boardParams.EventAggr = 2;//10 + } + + ret = CAEN_DGTZ_SetDPPEventAggregation(m_boardHandle, boardParams.EventAggr, 0); if (ret) { - cout << "Error CAEN_DGTZ_SetDPPEventAggregation: " << ret << endl; + cerr << "Error CAEN_DGTZ_SetDPPEventAggregation: " << ret << endl; close(); return; } @@ -144,25 +150,47 @@ void RealCAENPsdDriver::init() { // Set multi-board synchronization mode ret = CAEN_DGTZ_SetRunSynchronizationMode(m_boardHandle, CAEN_DGTZ_RUN_SYNC_Disabled); if (ret) { - cout << "Error CAEN_DGTZ_SetRunSynchronizationMode: " << ret << endl; + cerr << "Error CAEN_DGTZ_SetRunSynchronizationMode: " << ret << endl; close(); return; } // Set virtual probe settings - ret = CAEN_DGTZ_SetDPP_VirtualProbe(m_boardHandle, ANALOG_TRACE_1, CAEN_DGTZ_DPP_VIRTUALPROBE_Trapezoid); - ret = CAEN_DGTZ_SetDPP_VirtualProbe(m_boardHandle, ANALOG_TRACE_2, CAEN_DGTZ_DPP_VIRTUALPROBE_Input); - ret = CAEN_DGTZ_SetDPP_VirtualProbe(m_boardHandle, DIGITAL_TRACE_1, CAEN_DGTZ_DPP_DIGITALPROBE_Peaking); - ret = CAEN_DGTZ_SetDPP_VirtualProbe(m_boardHandle, DIGITAL_TRACE_2, CAEN_DGTZ_DPP_DIGITALPROBE_Trigger); + ret = CAEN_DGTZ_SetDPP_PSD_VirtualProbe(m_boardHandle, CAEN_DGTZ_DPP_VIRTUALPROBE_SINGLE, + CAEN_DGTZ_DPP_PSD_VIRTUALPROBE_Baseline, CAEN_DGTZ_DPP_PSD_DIGITALPROBE1_R6_GateLong, + CAEN_DGTZ_DPP_PSD_DIGITALPROBE2_R6_GateShort); if (ret) { - cout << "Error CAEN_DGTZ_SetDPP_VirtualProbe: " << ret << endl; + cerr << "Error CAEN_DGTZ_SetDPP_VirtualProbe: " << ret << endl; close(); return; } + uint32 data; + ret = CAEN_DGTZ_ReadRegister(m_boardHandle, 0x8000, &data); + cout << " data mode read out " << data << hex << endl; + //data &= 0xFFF8FFFF; + if (owner()->dppAcqMode() == acquisition::DPPAcquisitionCommon::LISTMODE_MODE) { + // data |= 0x000C0000; + //data = 0x000C0114; + data = 0x00070110; + cout << " data mode " << data << hex << endl; + } + else if (owner()->dppAcqMode() == acquisition::DPPAcquisitionCommon::SCOPE_MODE) { + //data |= 0x00070000; + //data = 0x040f0110; + //data = 0x01810114; + data = 0x00070110; + cout << " data mode " << data << hex << endl; + } + ret = CAEN_DGTZ_WriteRegister(m_boardHandle, 0x8000, data); + if (ret) { + cerr << "Error CAEN_DGTZ_WriteRegister: " << ret << endl; + close(); + return; + } ret = CAEN_DGTZ_WriteRegister(m_boardHandle, 0x8100, 0x5); if (ret) { - cout << "Error CAEN_DGTZ_WriteRegister: " << ret << endl; + cerr << "Error CAEN_DGTZ_WriteRegister: " << ret << endl; close(); return; } @@ -182,7 +210,7 @@ void RealCAENPsdDriver::clear() { open(); ret = CAEN_DGTZ_ClearData(m_boardHandle); if (ret) { - cout << "Error CAEN_DGTZ_ClearData: " << ret << endl; + cerr << "Error CAEN_DGTZ_ClearData: " << ret << endl; } close(); } @@ -195,7 +223,7 @@ void RealCAENPsdDriver::reset() { open(); ret = CAEN_DGTZ_Reset(m_boardHandle); if (ret) { - cout << "Error CAEN_DGTZ_Reset: " << ret << endl; + cerr << "Error CAEN_DGTZ_Reset: " << ret << endl; } close(); } @@ -210,7 +238,6 @@ void RealCAENPsdDriver::writeParam() { dppParams.trgho = owner()->triggerHoldOff(); dppParams.thr[i] = owner()->triggerThreshold.get(i); dppParams.selft[i] = owner()->selfTrigger.get(i); - cout << "dppParams.selft[" << i << "] = " << dppParams.selft[i] << endl; dppParams.csens[i] = owner()->chargeSensitivity.get(i); dppParams.sgate[i] = owner()->shortGate.get(i); dppParams.lgate[i] = owner()->longGate.get(i); @@ -224,21 +251,18 @@ void RealCAENPsdDriver::writeParam() { // Write channels parameters ret = CAEN_DGTZ_SetDPPParameters(m_boardHandle, boardParams.ChannelMask, &dppParams); if (ret) { - cout << "Error CAEN_DGTZ_SetDPPParameters" << endl; + cerr << "Error CAEN_DGTZ_SetDPPParameters" << endl; close(); return; } - cout << "channels = " << owner()->channels() << endl; - for (int32 i=0; i<owner()->channels(); ++i) { - cout << "channelMask = " << owner()->channelMask() << endl; if (owner()->channelMask() & (1 << i)) { // Set nb of samples for oscilloscope mode (same for all channels) boardParams.RecordLength = owner()->recordLength(); ret = CAEN_DGTZ_SetRecordLength(m_boardHandle, boardParams.RecordLength, i); if (ret) { - cout << "Error CAEN_DGTZ_SetRecordLength: " << ret << endl; + cerr << "Error CAEN_DGTZ_SetRecordLength: " << ret << endl; close(); return; } @@ -249,7 +273,7 @@ void RealCAENPsdDriver::writeParam() { offset = offset * 65535 / 100; ret = CAEN_DGTZ_SetChannelDCOffset(m_boardHandle, i, offset); if (ret) { - cout << "Error CAEN_DGTZ_SetChannelDCOffset" << endl; + cerr << "Error CAEN_DGTZ_SetChannelDCOffset" << endl; close(); return; } @@ -258,17 +282,16 @@ void RealCAENPsdDriver::writeParam() { int32 ptgrSize = owner()->preTrigger.get(i); ret = CAEN_DGTZ_SetDPPPreTriggerSize(m_boardHandle, i, ptgrSize); if (ret) { - cout << "Error CAEN_DGTZ_SetDPPPreTriggerSize" << endl; + cerr << "Error CAEN_DGTZ_SetDPPPreTriggerSize" << endl; close(); return; } // Set polarity CAEN_DGTZ_PulsePolarity_t polarity = (CAEN_DGTZ_PulsePolarity_t)owner()->pulsePolarity.get(i); - cout << "polatity.get[" << i << "] = " << owner()->pulsePolarity.get(i) << endl; ret = CAEN_DGTZ_SetChannelPulsePolarity(m_boardHandle, i, polarity); if (ret) { - cout << "Error CAEN_DGTZ_SetChannelPulsePolarity" << endl; + cerr << "Error CAEN_DGTZ_SetChannelPulsePolarity" << endl; close(); return; } @@ -288,7 +311,7 @@ void RealCAENPsdDriver::setAcqMode() { boardParams.SaveMode = (CAEN_DGTZ_DPP_SaveParam_t)owner()->saveMode(); ret = CAEN_DGTZ_SetDPPAcquisitionMode(m_boardHandle, boardParams.DPPAcqMode, boardParams.SaveMode); if (ret) { - cout << "Error CAEN_DGTZ_SetDPPAcquisitionMode: " << ret << endl; + cerr << "Error CAEN_DGTZ_SetDPPAcquisitionMode: " << ret << endl; } close(); } diff --git a/src/drivers/ioxos/cfd/CfdDef.h b/src/drivers/ioxos/cfd/CfdDef.h new file mode 100644 index 00000000..e2b90583 --- /dev/null +++ b/src/drivers/ioxos/cfd/CfdDef.h @@ -0,0 +1,74 @@ +/* + * Nomad Instrument Control Software + * + * Copyright 2011 Institut Laue-Langevin + * + * Licensed under the EUPL, Version 1.1 only (the "License"); + * You may not use this work except in compliance with the Licence. + * You may obtain a copy of the Licence at: + * + * http://joinup.ec.europa.eu/software/page/eupl + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the Licence is distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Licence for the specific language governing permissions and + * limitations under the Licence. + */ + +#ifndef CFDDEF_H +#define CFDDEF_H + +namespace cfd { + +static const int32 MAX_CHANNELS = 16; + +// A32 base adress initialisaton : 0x1000000. +static const uint32 A24_ROTARY_SWITCHES_REGISTER = 0x400; +static const uint32 ENABLE_VME_SLAVE_REGISTER = 0x408; +static const uint32 A32_INIT_BA_REGISTER = 0x560; +static const uint32 ENABLE_A32_BA_REGISTER = 0x5F8; +static const uint32 MMU_PAGE_ZERO_REGISTER = 0x410; +static const uint32 DESCRIPTOR_FOR_SUSER_REGISTER = 0x414; +// Values. +static const uint32 ENABLE_VME_SLAVE = 0x80000010; +static const uint32 A32_INIT_BA = 0x01; +static const uint32 ENABLE_A32_BA = 0x10; +static const uint32 MMU_PAGE_ZERO = 0x0; +static const uint32 DESCRIPTOR_FOR_SUSER = 0x4803; +static const uint32 DESCRIPTOR_FOR_SUSER_2 = 0x2C03; +// Direction for the P2 lines. +static const uint32 ENABLE_PLL_CLOCK_REGISTER = 0x1090; +static const uint32 ENABLE_SERDES_VMEP2_REGISTER = 0x1090; +// Values. +static const uint32 ENABLE_PLL_CLOCK = 0x1; +static const uint32 ENABLE_SERDES_VMEP2 = 0xC3; + +// Command +static const int32 ADC_RESET_COMMAND_REG = 0x10E8; +static const int32 WRITE_PARAM_COMMAND_REG = 0x1010; +static const int32 START_COMMAND_REG = 0x1000; +static const int32 STOP_COMMAND_REG = 0x1004; +static const int32 RESET_COMMAND_REG = 0x1014; +static const int32 WRITE_DUMMY_COMMAND_REG = 0x1018; + +static const int32 GLOBAL_PARAMETER = 0x1000; + +static const int32 BUFFER_STATUS_REG = 0x1390; +static const int32 BUFFER_0_READY = 1 << 16; +static const int32 BUFFER_1_READY = 1 << 17; +static const int32 BUFFERS_READY = BUFFER_0_READY + BUFFER_1_READY; + +static const int32 BUFFER_0_SIZE = 0x1394; +static const int32 BUFFER_1_SIZE = 0x1398; + +static const int32 BUFFER_0_REG = 0x100000; + +static const int32 CURVES_REG = 0x0; +static const int32 CURVES_READY = 1; + +static const int32 DATA_REG = 0x0; + +} + +#endif //CFDDEF_H diff --git a/src/drivers/ioxos/cfd/CfdDriver.cpp b/src/drivers/ioxos/cfd/CfdDriver.cpp new file mode 100644 index 00000000..e221068e --- /dev/null +++ b/src/drivers/ioxos/cfd/CfdDriver.cpp @@ -0,0 +1,172 @@ +/* + * Nomad Instrument Control Software + * + * Copyright 2011 Institut Laue-Langevin + * + * Licensed under the EUPL, Version 1.1 only (the "License"); + * You may not use this work except in compliance with the Licence. + * You may obtain a copy of the Licence at: + * + * http://joinup.ec.europa.eu/software/page/eupl + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the Licence is distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Licence for the specific language governing permissions and + * limitations under the Licence. + */ + +#include "CfdDriver.h" +#include "CfdState.h" +#include "RealCfdDriver.h" +#include "PerfectCfdDriver.h" +#include "CfdDef.h" +#include "drivers/global/DriversCommands.h" + +namespace cfd { + +const string CfdDriver::TYPE = "cfd"; + +const std::string CfdDriver::WRITE_PARAMETERS_COMMAND = "writeParam"; + +/* + * Constructor + */ +CfdDriver::CfdDriver(const string& aName) { + + driver::Vme::init(aName); + + useScopeStr.init(this, NOSAVE, "use_scope_str"); + useListModeStr.init(this, NOSAVE, "use_listmode_str"); + scopeChannel.init(this, NOSAVE, "scope_channel"); + dppAcqMode.init(this, SAVE, "dpp_acq_mode"); + nbChannels.init(this, SAVE, "nb_channels"); + channels.init(this, SAVE, "channels"); + + // CFD parameters + delay.init(this, SAVE, "delay"); + attenuation.init(this, SAVE, "attenuation"); + + // Energy filter parameters + channelActive.init(this, SAVE, "channel_active"); + channelActiveStr.init(this, NOSAVE, "channel_active_str"); + pulsePolarity.init(this, SAVE, "pulse_polarity"); + pulsePolarityStr.init(this, NOSAVE, "pulse_polarity_str"); + trapezoidRise.init(this, SAVE, "trapezoid_rise"); + trapezoidFlat.init(this, SAVE, "trapezoid_flat"); + decayTime.init(this, SAVE, "decay_time"); + peaking.init(this, SAVE, "peaking"); + bitShift.init(this, SAVE, "bit_shift"); + + registerStates(new RealCfdDriver(this), new PerfectCfdDriver(this), new PerfectCfdDriver(this)); + + // Init command list + initCommand(driver::INIT_COMMAND); + initCommand(driver::READ_INFOS_COMMAND); + initCommand(WRITE_PARAMETERS_COMMAND); + + // Init functions + registerFunction(NONE_FUNCTION); + + addressType.update(driver::Vme::A24_ACCESS); + deviceType = LEAF_DEVICE_TYPE_DEVICE_CONTAINER; + + registerRefresher(channels, &CfdDriver::refreshNbChannelsProperty, this); + registerRefresher(channelActive, &CfdDriver::refreshChannelActiveProperty, this); + registerRefresher(pulsePolarity, &CfdDriver::refreshPulsePolarityProperty, this); + registerRefresher(dppAcqMode, &CfdDriver::refreshDppAcqModeProperty, this); + +} + +/* + * Destructor + */ +CfdDriver::~CfdDriver() { +} + +/* + * execute + */ +void CfdDriver::execute(const string& aCommand) { + + commandProgression = PROGRESSION_UNKNOWNSTATE_DEVICE_CONTAINER; + CfdState* currentState = dynamic_cast<CfdState*>(getCurrentState()); + + // Check command + if (aCommand == driver::INIT_COMMAND) { + currentState->init(); + commandProgression = PROGRESSION_END_DEVICE_CONTAINER; + } else if (aCommand == driver::READ_INFOS_COMMAND) { + // Info command + currentState->readInfos(); + commandProgression = PROGRESSION_END_DEVICE_CONTAINER; + } else if (aCommand == WRITE_PARAMETERS_COMMAND) { + // Write param command + currentState->writeParam(); + commandProgression = PROGRESSION_END_DEVICE_CONTAINER; + } +} + +/* + * refreshTotalChannelsProperty + */ +void CfdDriver::refreshNbChannelsProperty(int32 aValue) throw (CannotSetValue) { + channelActive.resize(aValue); + channelActiveStr.resize(aValue); + pulsePolarity.resize(aValue); + pulsePolarityStr.resize(aValue); + trapezoidRise.resize(aValue); + trapezoidFlat.resize(aValue); + decayTime.resize(aValue); + peaking.resize(aValue); + bitShift.resize(aValue); +} + +/* + * refreshDppAcqModeProperty + */ +void CfdDriver::refreshDppAcqModeProperty(int32 value) throw (CannotSetValue) { + + switch (value) { + case 0: + useScopeStr.update("Inactive"); + useListModeStr.update("Active"); + break; + case 1: + useScopeStr.update("Active"); + useListModeStr.update("Inactive"); + break; + } +} + +/* + * refreshChannelActiveProperty + */ +void CfdDriver::refreshChannelActiveProperty(int32 index, int32 aValue) throw (CannotSetValue) { + + switch (aValue) { + case 0: + channelActiveStr.set(index, "Inactive"); + break; + case 1: + channelActiveStr.set(index, "Active"); + break; + } +} + +/* + * refreshPulsePolarityProperty + */ +void CfdDriver::refreshPulsePolarityProperty(int32 index, int32 aValue) throw (CannotSetValue) { + + switch (aValue) { + case 0: + pulsePolarityStr.set(index, "Positive"); + break; + case 1: + pulsePolarityStr.set(index, "Negative"); + break; + } +} + +} diff --git a/src/drivers/ioxos/cfd/CfdDriver.h b/src/drivers/ioxos/cfd/CfdDriver.h new file mode 100644 index 00000000..b5e6ff4e --- /dev/null +++ b/src/drivers/ioxos/cfd/CfdDriver.h @@ -0,0 +1,103 @@ +/* + * Nomad Instrument Control Software + * + * Copyright 2011 Institut Laue-Langevin + * + * Licensed under the EUPL, Version 1.1 only (the "License"); + * You may not use this work except in compliance with the Licence. + * You may obtain a copy of the Licence at: + * + * http://joinup.ec.europa.eu/software/page/eupl + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the Licence is distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Licence for the specific language governing permissions and + * limitations under the Licence. + */ + +/* Generated by Together */ + +#ifndef CFDDRIVER_H +#define CFDDRIVER_H + +#include "drivers/global/Vme.h" + +namespace cfd { + +/** + * The MotorQclRioDriver class contains the hardware operation to + * apply on a motor which controled by a Rio QCL vme card. + */ +class CfdDriver: public driver::Vme { + + friend class RealCfdDriver; + friend class PerfectCfdDriver; + +public: + + //! Driver type value + static const std::string TYPE; + + /*! + * \brief Constructor + * \param[in] name the name of the device driver + */ + CfdDriver(const string& aName); + + /*! + * \brief Destructor + */ + virtual ~CfdDriver(); + + /*! + * \brief Method called for executing a command + * + * \param[in] command the command to apply on the controller + */ + virtual void execute(const string& aCommand); + + /*! + * Properties + */ + // Global + Property<std::string> useScopeStr; + Property<std::string> useListModeStr; + Property<int32> scopeChannel; + Property<int32> dppAcqMode; + Property<int32> nbChannels; + Property<int32> channels; + + // CFD parameters + Property<int32> delay; + Property<int32> attenuation; + + // Energy filter parameters + DynamicProperty<int32> channelActive; + DynamicProperty<std::string> channelActiveStr; + DynamicProperty<int32> pulsePolarity; + DynamicProperty<std::string> pulsePolarityStr; + DynamicProperty<int32> trapezoidRise; + DynamicProperty<int32> trapezoidFlat; + DynamicProperty<int32> decayTime; + DynamicProperty<int32> peaking; + DynamicProperty<int32> bitShift; + + static const std::string WRITE_PARAMETERS_COMMAND; + +private: + + /*! + * \brief Method called before changing the property value + * \param[in] value the property value + * \throws CannotSetValue the value isn't corrected, or property couldn't be changed + */ + void refreshNbChannelsProperty(int32 aValue) throw (CannotSetValue); + void refreshChannelActiveProperty(int32 index, int32 aValue) throw (CannotSetValue); + void refreshPulsePolarityProperty(int32 index, int32 aValue) throw (CannotSetValue); + void refreshDppAcqModeProperty(int32 value) throw (CannotSetValue); + +}; + +} +#endif //CFDDRIVER_H diff --git a/src/drivers/ioxos/cfd/CfdState.h b/src/drivers/ioxos/cfd/CfdState.h new file mode 100644 index 00000000..1a4cac21 --- /dev/null +++ b/src/drivers/ioxos/cfd/CfdState.h @@ -0,0 +1,64 @@ +/* + * Nomad Instrument Control Software + * + * Copyright 2011 Institut Laue-Langevin + * + * Licensed under the EUPL, Version 1.1 only (the "License"); + * You may not use this work except in compliance with the Licence. + * You may obtain a copy of the Licence at: + * + * http://joinup.ec.europa.eu/software/page/eupl + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the Licence is distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Licence for the specific language governing permissions and + * limitations under the Licence. + */ + +#ifndef CFDSTATE_H +#define CFDSTATE_H + +#include <Driver.h> +#include "CfdDriver.h" + +namespace cfd { + +/*! + * \class CfdState + * \brief Virtual class for implement State pattern + * + * Define all methods that perfect, simulated and real classes have to implement + */ +class CfdState: public DriverState<CfdDriver> { + +public: + + /*! + * \brief Constructor + * \param[in] owner The device driver main class link + */ + CfdState(CfdDriver* owner) : + DriverState<CfdDriver>(owner) { + } + + /*! + * \brief Destructor + */ + virtual ~CfdState() { + } + + /*! + * \brief Write Param command implementation + */ + virtual void writeParam() = 0; + + /*! + * \brief Read Infos command implementation + */ + virtual void readInfos() = 0; + +}; + +} +#endif //CFDSTATE_H diff --git a/src/drivers/ioxos/cfd/Module.xml b/src/drivers/ioxos/cfd/Module.xml new file mode 100644 index 00000000..985044be --- /dev/null +++ b/src/drivers/ioxos/cfd/Module.xml @@ -0,0 +1,4 @@ +<module name="cfd"> + <driver class="cfd::CfdDriver"/> + <include path="$(NOMAD_HOME)/../NomadModules/src"/> +</module> diff --git a/src/drivers/ioxos/cfd/PerfectCfdDriver.cpp b/src/drivers/ioxos/cfd/PerfectCfdDriver.cpp new file mode 100644 index 00000000..6f4c5846 --- /dev/null +++ b/src/drivers/ioxos/cfd/PerfectCfdDriver.cpp @@ -0,0 +1,57 @@ +/* + * Nomad Instrument Control Software + * + * Copyright 2011 Institut Laue-Langevin + * + * Licensed under the EUPL, Version 1.1 only (the "License"); + * You may not use this work except in compliance with the Licence. + * You may obtain a copy of the Licence at: + * + * http://joinup.ec.europa.eu/software/page/eupl + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the Licence is distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Licence for the specific language governing permissions and + * limitations under the Licence. + */ + +#include "PerfectCfdDriver.h" +#include "CfdDef.h" + +namespace cfd { + +/* + * Constructor + */ +PerfectCfdDriver::PerfectCfdDriver(CfdDriver* owner) : + CfdState(owner) { + +} + +/* + * Destructor + */ +PerfectCfdDriver::~PerfectCfdDriver() { + /* Empty */ +} + +/* + * init + */ +void PerfectCfdDriver::init() { +} + +/* + * writeParam + */ +void PerfectCfdDriver::writeParam() { +} + +/* + * readInfos + */ +void PerfectCfdDriver::readInfos() { +} + +} diff --git a/src/drivers/ioxos/cfd/PerfectCfdDriver.h b/src/drivers/ioxos/cfd/PerfectCfdDriver.h new file mode 100644 index 00000000..7afad9d7 --- /dev/null +++ b/src/drivers/ioxos/cfd/PerfectCfdDriver.h @@ -0,0 +1,68 @@ +/* + * Nomad Instrument Control Software + * + * Copyright 2011 Institut Laue-Langevin + * + * Licensed under the EUPL, Version 1.1 only (the "License"); + * You may not use this work except in compliance with the Licence. + * You may obtain a copy of the Licence at: + * + * http://joinup.ec.europa.eu/software/page/eupl + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the Licence is distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Licence for the specific language governing permissions and + * limitations under the Licence. + */ + +/* Generated by Together */ + +#ifndef PERFECTCFDDRIVER_H +#define PERFECTCFDDRIVER_H + +#include "CfdState.h" + +namespace cfd { + +/*! + * \class PerfectCfdDriver + * \brief Perfect implementation class for the rio3 dpp device driver + * + * On start command, all actual values become target's ones. + */ +class PerfectCfdDriver: public CfdState { + +public: + + /*! + * \brief Constructor + * \param[in] owner The device driver main class link + */ + PerfectCfdDriver(CfdDriver* owner); + + /*! + * \brief Destructor + */ + virtual ~PerfectCfdDriver(); + + /*! + * \brief Init command implementation + */ + virtual void init(); + + /*! + * \brief Write Param command implementation + */ + virtual void writeParam(); + + /*! + * \brief Read Infos command implementation + */ + virtual void readInfos(); + +}; + +} + +#endif //PERFECTCFDDRIVER_H diff --git a/src/drivers/ioxos/cfd/RealCfdDriver.cpp b/src/drivers/ioxos/cfd/RealCfdDriver.cpp new file mode 100644 index 00000000..a0b8b614 --- /dev/null +++ b/src/drivers/ioxos/cfd/RealCfdDriver.cpp @@ -0,0 +1,190 @@ +/* + * Nomad Instrument Control Software + * + * Copyright 2011 Institut Laue-Langevin + * + * Licensed under the EUPL, Version 1.1 only (the "License"); + * You may not use this work except in compliance with the Licence. + * You may obtain a copy of the Licence at: + * + * http://joinup.ec.europa.eu/software/page/eupl + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the Licence is distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Licence for the specific language governing permissions and + * limitations under the Licence. + */ + +#include "RealCfdDriver.h" +#include "CfdDriver.h" +#include "CfdDef.h" + +#include "Utilities/Calculations.h" +#include "Utilities/Counter.h" + +using namespace driver; + +namespace cfd { + +/* + * Constructor + */ +RealCfdDriver::RealCfdDriver(CfdDriver* owner) : + CfdState(owner) { + +} + +/* + * Destructor + */ +RealCfdDriver::~RealCfdDriver() { + +} + +/* + * init + */ +void RealCfdDriver::init() { +// //Reset all parameters --> to be done +// // init A32 base adress of the ioxos board. +// uint32 aData; +// // enable VME Slave +// aData = ENABLE_VME_SLAVE; +// owner()->write(ENABLE_VME_SLAVE_REGISTER, Vme::LONGWORD_WIDTH, 1, (void*) &aData); +// +// // Init A32 VME BA +// aData = owner()->address() >> 16; +// owner()->write(A32_INIT_BA_REGISTER, Vme::LONGWORD_WIDTH, 1, (void*) &aData); +// +// // Enable A32 VME BA +// aData = ENABLE_A32_BA; +// owner()->write(ENABLE_A32_BA_REGISTER, Vme::LONGWORD_WIDTH, 1, (void*) &aData); +// +// // MMU Pointer +// aData = MMU_PAGE_ZERO; +// owner()->write(MMU_PAGE_ZERO_REGISTER, Vme::LONGWORD_WIDTH, 1, (void*) &aData); +// +// // Descriptor for SUSER +// aData = DESCRIPTOR_FOR_SUSER; +// owner()->write(DESCRIPTOR_FOR_SUSER_REGISTER, Vme::LONGWORD_WIDTH, 1, (void*) &aData); +// // same address, data = 3 +// aData = 3; +// owner()->write(DESCRIPTOR_FOR_SUSER_REGISTER, Vme::LONGWORD_WIDTH, 1, (void*) &aData); +// // same address, data = 0 (first write) +// aData = 0; +// owner()->write(DESCRIPTOR_FOR_SUSER_REGISTER, Vme::LONGWORD_WIDTH, 1, (void*) &aData); +// // same address, data = 0 (second write) +// aData = 0; +// owner()->write(DESCRIPTOR_FOR_SUSER_REGISTER, Vme::LONGWORD_WIDTH, 1, (void*) &aData); +// +// // MMU Pointer cf Thierry +// aData = 8; +// owner()->write(MMU_PAGE_ZERO_REGISTER, Vme::LONGWORD_WIDTH, 1, (void*) &aData); +// +// // Descriptor for SUSER cf Thierry +// aData = DESCRIPTOR_FOR_SUSER_2; +// owner()->write(DESCRIPTOR_FOR_SUSER_REGISTER, Vme::LONGWORD_WIDTH, 1, (void*) &aData); +// // same address, data = 3 +// aData = 3; +// owner()->write(DESCRIPTOR_FOR_SUSER_REGISTER, Vme::LONGWORD_WIDTH, 1, (void*) &aData); +// // same address, data = 0 (first write) +// aData = 0; +// owner()->write(DESCRIPTOR_FOR_SUSER_REGISTER, Vme::LONGWORD_WIDTH, 1, (void*) &aData); +// // same address, data = 0 (second write) +// aData = 0; +// owner()->write(DESCRIPTOR_FOR_SUSER_REGISTER, Vme::LONGWORD_WIDTH, 1, (void*) &aData); +// +// // Enabling the VMEP2 SerDes +// // Enable PLL Clock Generation. +// aData = ENABLE_PLL_CLOCK; +// owner()->write(ENABLE_PLL_CLOCK_REGISTER, Vme::LONGWORD_WIDTH, 1, (void*) &aData); +// +// // Enable SerDes. +// aData = ENABLE_SERDES_VMEP2; +// owner()->write(ENABLE_SERDES_VMEP2_REGISTER, Vme::LONGWORD_WIDTH, 1, (void*) &aData); + + readInfos(); +} + +/* + * writeParam + */ +void RealCfdDriver::writeParam() { + + int32 value = 1; + + //owner()->write(GLOBAL_PARAMETER + 0x14, Vme::LONGWORD_WIDTH, 1, (void*) &value); + + //value = 0x1000; + // Internal list mode + //owner()->write(GLOBAL_PARAMETER + 0xC0, Vme::LONGWORD_WIDTH, 1, (void*) &value); + + value = owner()->dppAcqMode(); + cout << "dppAcqMode = " << value << endl; + owner()->write(GLOBAL_PARAMETER + 0xC8, Vme::LONGWORD_WIDTH, 1, (void*) &value); + + value = owner()->nbChannels(); + cout << "nbChannels = " << value << endl; + owner()->write(GLOBAL_PARAMETER + 0xCC, Vme::LONGWORD_WIDTH, 1, (void*) &value); + + value = (int32) ceil((float) owner()->nbChannels() / 8.); + cout << "nbChannels 2 = " << value << endl; + owner()->write(GLOBAL_PARAMETER + 0xD0, Vme::LONGWORD_WIDTH, 1, (void*) &value); + + value = 1000; + owner()->write(GLOBAL_PARAMETER + 0xD8, Vme::LONGWORD_WIDTH, 1, (void*) &value); + + cout << "scopeChannel = " << owner()->scopeChannel() << endl; + value = owner()->scopeChannel() & 0xFF; + cout << "scopeChannel = " << value << endl; + for (int32 i = 0; i < owner()->nbChannels(); ++i) { + value += (owner()->pulsePolarity.get(i) & 0x1) << (16 + i); + } + owner()->write(GLOBAL_PARAMETER + 0xD4, Vme::LONGWORD_WIDTH, 1, (void*) &value); + + value = owner()->delay() & 0xFFFF; + cout << "delay = " << value << endl; + value += 3 << 16; + owner()->write(GLOBAL_PARAMETER + 0xF0, Vme::LONGWORD_WIDTH, 1, (void*) &value); + + value = owner()->attenuation(); + cout << "attenuation = " << value << endl; + owner()->write(GLOBAL_PARAMETER + 0xF4, Vme::LONGWORD_WIDTH, 1, (void*) &value); + + for (int32 i = 0; i < owner()->nbChannels(); ++i) { + value = owner()->trapezoidRise.get(i) & 0xFF; + value += (owner()->trapezoidFlat.get(i) & 0xFF) << 8; + value += (owner()->decayTime.get(i) & 0xFF) << 16; + value += (owner()->peaking.get(i) & 0xFF) << 24; + owner()->write(GLOBAL_PARAMETER + 0x240 + i * 0x4, Vme::LONGWORD_WIDTH, 1, (void*) &value); + + value = owner()->bitShift.get(i); + owner()->write(GLOBAL_PARAMETER + 0x280 + i * 0x4, Vme::LONGWORD_WIDTH, 1, (void*) &value); + } +} + +/* + * readInfos + */ +void RealCfdDriver::readInfos() { + +} + +///* +// * pow2roundup +// */ +//int32 RealCfdDriver::pow2roundup(int32 x) { +// +// if (x < 0) +// return 0; +// --x; +// x |= x >> 1; +// x |= x >> 2; +// x |= x >> 4; +// x |= x >> 8; +// x |= x >> 16; +// return x + 1; +//} + +} diff --git a/src/drivers/ioxos/cfd/RealCfdDriver.h b/src/drivers/ioxos/cfd/RealCfdDriver.h new file mode 100644 index 00000000..95e70bae --- /dev/null +++ b/src/drivers/ioxos/cfd/RealCfdDriver.h @@ -0,0 +1,75 @@ +/* + * Nomad Instrument Control Software + * + * Copyright 2011 Institut Laue-Langevin + * + * Licensed under the EUPL, Version 1.1 only (the "License"); + * You may not use this work except in compliance with the Licence. + * You may obtain a copy of the Licence at: + * + * http://joinup.ec.europa.eu/software/page/eupl + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the Licence is distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Licence for the specific language governing permissions and + * limitations under the Licence. + */ + +/* Generated by Together */ + +#ifndef REALCFDDRIVER_H +#define REALCFDDRIVER_H + +#include "CfdState.h" + +namespace cfd { + +/*! + * \class RealCfdDriver + * \brief Real implementation class for the Cfd device driver + * + * This class is a real implementation of Cfd device driver. + */ +class RealCfdDriver: public CfdState { + +public: + + /*! + * \brief Constructor + * \param[in] owner The device driver main class link + */ + RealCfdDriver(CfdDriver* owner); + + /*! + * Destructor. + */ + virtual ~RealCfdDriver(); + + /*! + * \brief Init command implementation + */ + virtual void init(); + + /*! + * \brief Write Param command implementation + */ + virtual void writeParam(); + + /*! + * \brief Read Infos command implementation + */ + virtual void readInfos(); + +private: + +// /* +// * used to calculate the bit_shift in the trpezoidal algorithm (energy) +// */ +// int32 pow2roundup(int32 x); + +}; + +} + +#endif //REALCFDDRIVER_H diff --git a/src/drivers/ioxos/cfd/gui/cfd.properties b/src/drivers/ioxos/cfd/gui/cfd.properties new file mode 100644 index 00000000..7ff31920 --- /dev/null +++ b/src/drivers/ioxos/cfd/gui/cfd.properties @@ -0,0 +1,106 @@ +cfd.timeSuffix=ns + +#Global group +cfd.globalGroup=Global parameters +cfd.versionPrefix=Version +cfd.nbCellsPrefix=Nb. of channels: +cfd.numberOfSamplesPrefix=Nb. of samples: +cfd.listModePrefix=List Mode Activated +cfd.nimValue=false +cfd.nimLabel=NIM +cfd.ttlValue=true +cfd.ttlLabel=TTL + +#Visualization group +cfd.visualizationGroup=Plot +cfd.scopePrefix=Scope mode +cfd.scopeCheckedValue=true +cfd.scopeUncheckedValue=false +cfd.factorPrefix=Factor +cfd.linRegDelayPrefix=Delay +cfd.plotTitle=Signals +cfd.histogramLegend=Input +cfd.trapLegend=Trapezoid +cfd.peakLegend=Peak + +#Channel group +cfd.channelGroup=Channel parameters +cfd.activeCellPrefix=Channel +cfd.activateChannelPrefix=Active +cfd.activateChannelCheckedValue=1 +cfd.activateChannelUncheckedValue=0 + +cfd.trigThresPrefix=Trig Threshold +cfd.bslnThresPrefix=Bsln Threshold +cfd.thresholdSuffix=ch + +cfd.preTriggerPrefix=Pre Trigger + +cfd.chargeSensitivityPrefix=Charge Sensitivity +cfd.chargeSensitivitySuffix=fc/LSB +cfd.1chargeLabel=20 +cfd.1chargeValue=0 +cfd.2chargeLabel=40 +cfd.2chargeValue=1 +cfd.3chargeLabel=80 +cfd.3chargeValue=2 +cfd.4chargeLabel=160 +cfd.4chargeValue=3 +cfd.5chargeLabel=320 +cfd.5chargeValue=4 +cfd.6chargeLabel=640 +cfd.6chargeValue=5 + +cfd.dcOffsetPrefix=DC Offset + +cfd.pulsePolarityPrefix=Invert Polarity +cfd.pulsePolarityCheckedValue=1 +cfd.pulsePolarityUncheckedValue=0 + +cfd.lowRateChannelPrefix=Low Rate Detector +cfd.lowRateChannelCheckedValue=1 +cfd.lowRateChannelUncheckedValue=0 + +cfd.peakAvrgPrefix=Peak Average +cfd.0sampleLabel=0 +cfd.0sampleValue=0 +cfd.8sampleLabel=8 +cfd.8sampleValue=1 +cfd.16sampleLabel=16 +cfd.16sampleValue=2 +cfd.32sampleLabel=32 +cfd.32sampleValue=3 +cfd.64sampleLabel=64 +cfd.64sampleValue=4 +cfd.128sampleLabel=128 +cfd.128sampleValue=5 +cfd.256sampleLabel=256 +cfd.256sampleValue=6 +cfd.512sampleLabel=512 +cfd.512sampleValue=7 +cfd.peakAvrgSuffix=samples +cfd.shiftTrapSuffix=samples + +cfd.display_kTrapPrefix=K +cfd.display_lTrapPrefix=L +cfd.display_decayTimePrefix=Decay time +cfd.display_shiftTrapPrefix=Peak Trap + +# Filter group +cfd.filterGroup=Filters parameters +cfd.shortGatePrefix=Short gate +cfd.longGatPrefix=Long gate +cfd.preGatePrefix=Pre Gate + +cfd.delayPrefix=Delay +cfd.attenuationPrefix=Attenuation +cfd.channelActive=Channel active +cfd.pulsePolarity=Pulse polarity +cfd.trapezoideRise=Trapezoide rise +cfd.decayTime=Decay time +cfd.peaking=Peaking + + +#commands +cfd.readInfosButton=Read infos +cfd.writeParamButton=Write Param diff --git a/src/drivers/ioxos/cfd/gui/cfdPlugin.xml b/src/drivers/ioxos/cfd/gui/cfdPlugin.xml new file mode 100644 index 00000000..8f5f6e84 --- /dev/null +++ b/src/drivers/ioxos/cfd/gui/cfdPlugin.xml @@ -0,0 +1,7 @@ +<controller_plugin_config type="cfd"> + + <image key="HARDWARE_VME_MODULE"/> + + <settings config="cfdConfig.xml" view="cfdView.xml"/> + +</controller_plugin_config> diff --git a/src/drivers/ioxos/cfd/gui/cfdProperties.xml b/src/drivers/ioxos/cfd/gui/cfdProperties.xml new file mode 100644 index 00000000..f47a5b6e --- /dev/null +++ b/src/drivers/ioxos/cfd/gui/cfdProperties.xml @@ -0,0 +1,45 @@ +<?xml version="1.0" encoding="ISO-8859-1" ?> + +<controller type="cfd"> + + <property name="version" type="string"> + </property> + + <property name="listmode_size" type="int32" max_length="5"> + </property> + + <property name="nb_channels" type="int32" max_length="3"> + </property> + + <property name="delay" type="int32" max_length="8"> + </property> + + <property name="attenuation" type="int32" max_length="8"> + </property> + + <!-- Energy filter parameters --> + <dynamic_property name="channel_active" size_property="nb_channels" type="int32" max_length="1"> + </dynamic_property> + + <dynamic_property name="channel_active_str" size_property="nb_channels" type="string" max_length="8"> + </dynamic_property> + + <dynamic_property name="pulse_polarity" size_property="nb_channels" type="int32"> + </dynamic_property> + + <dynamic_property name="pulse_polarity_str" size_property="nb_channels" type="string" max_length="8"> + </dynamic_property> + + <dynamic_property name="trapezoid_flat" size_property="nb_channels" type="int32" max_length="6"> + </dynamic_property> + + <dynamic_property name="trapezoid_rise" size_property="nb_channels" type="int32" max_length="6"> + </dynamic_property> + + <dynamic_property name="decay_time" size_property="nb_channels" type="int32" max_length="6"> + </dynamic_property> + + <dynamic_property name="peaking" size_property="nb_channels" type="int32" max_length="6"> + </dynamic_property> + +</controller> diff --git a/src/drivers/ioxos/cfd/gui/cfdView.xml b/src/drivers/ioxos/cfd/gui/cfdView.xml new file mode 100644 index 00000000..6fa7cf85 --- /dev/null +++ b/src/drivers/ioxos/cfd/gui/cfdView.xml @@ -0,0 +1,56 @@ +<plugin> + <controller type="cfd" role="cfd1"/> + + <property_switcher role="cfd1" property="scope_mode" switcher_key="scopeSwitcher"/> + + <group title="cfd.globalGroupTitle"> + <label role="cfd1" property="version" prefix="cfd.versionPrefix"/> + <newLine/> + <table_composite nbColumns="2"> + <simple_label prefix="cfd.boardIndexPrefix"/> + <label role="cfd1" property="crate_number"/> + <simple_label prefix="cfd.nbChannelsPrefix"/> + <label role="cfd1" property="nb_channels"/> + <simple_label prefix="cfd.resolutionPrefix"/> + <label role="cfd1" property="nb_bits"/> + <simple_label prefix="cfd.recordLengthPrefix"/> + <label role="cfd1" property="record_length"/> + </table_composite> + </group> + + <newLine/> + <group title="cfd.acquisitionGroupTitle"> + <label role="cfd1" property="use_listmode_str" prefix="cfd.listModePrefix"/> + <newLine/> + <label role="cfd1" property="use_scope_str" prefix="cfd.scopeModePrefix"/> + <switchable_composite switcher_key="scopeSwitcher" switch_values="1"> + <label role="cfd1" property="scope_channel" prefix="cfd.scopeChannelPrefix"/> + </switchable_composite> + <newLine/> + <label role="cfd1" property="delay" prefix="cfd.delayPrefix"/> + <newLine/> + <label role="cfd1" property="attenuation" prefix="cfd.attenuationPrefix"/> + </group> + <newLine/> + + <group title="cfd.channelParamsTitle"> + <table_composite nbColumns="5"> + <simple_label prefix="cfd.channelActive"/> + <simple_label prefix="cfd.pulsePolarity"/> + <simple_label prefix="cfd.trapezoideRise"/> + <simple_label prefix="cfd.decayTime"/> + <simple_label prefix="cfd.peaking"/> + <dynamic_composite role="cfd1" properties="channel_active_str,pulse_polarity_str,trapezoid_rise,decay_time,peaking"> + <label role="cfd1" property="channel_active_str"/> + <label role="cfd1" property="pulse_polarity_str"/> + <label role="cfd1" property="trapezoid_rise"/> + <label role="cfd1" property="decay_time"/> + <label role="cfd1" property="peaking"/> + </dynamic_composite> + </table_composite> + </group> + + <newLine/> + <button role="cfd1" command="writeParam" prefix="cfd.writeParamButton"/> + <button role="cfd1" command="readInfos" prefix="cfd.readInfosButton"/> +</plugin> diff --git a/src/drivers/oceanoptics/Module.xml b/src/drivers/oceanoptics/Module.xml index 12332ab0..94e97fb7 100644 --- a/src/drivers/oceanoptics/Module.xml +++ b/src/drivers/oceanoptics/Module.xml @@ -1,7 +1,7 @@ <module name="oceanoptics"> <driver type="oceanoptics::QE65000Driver"/> <include path="$(NOMAD_HOME)/../NomadModules/src"/> - <include path="/users/cocho/seabreeze/include"/> - <link path="/users/cocho/seabreeze/lib" lib="seabreeze"/> + <include path="/usr/local/src/seabreeze/include"/> + <link path="/usr/local/lib" lib="seabreeze"/> <link lib="usb"/> </module> \ No newline at end of file diff --git a/src/drivers/oceanoptics/QE65000Driver.cpp b/src/drivers/oceanoptics/QE65000Driver.cpp index 832eb1e4..cedd2e85 100644 --- a/src/drivers/oceanoptics/QE65000Driver.cpp +++ b/src/drivers/oceanoptics/QE65000Driver.cpp @@ -40,7 +40,7 @@ QE65000Driver::QE65000Driver(const std::string& name) : DeviceDriver(name) { isActive.init(this, SAVE, "isActive"); xData.init(this, SAVE, "x_data"); yData.init(this, SAVE, "y_data"); - + size.init(this, SAVE, "size"); //Init functions registerFunction(NONE_FUNCTION); @@ -69,7 +69,7 @@ void QE65000Driver::execute(const std::string& aCommand) { if (aCommand == driver::START_COMMAND) { //begin reading - currentState->measure(); + currentState->start(); } else if (aCommand == driver::STOP_COMMAND) { currentState->stop(); @@ -77,6 +77,9 @@ void QE65000Driver::execute(const std::string& aCommand) { } else if (aCommand == driver::STATUS_COMMAND) { currentState->readStatus(); + } else if (aCommand == driver::INIT_COMMAND) { + // init command + currentState->init(); } } diff --git a/src/drivers/oceanoptics/QE65000Driver.h b/src/drivers/oceanoptics/QE65000Driver.h index f180d266..7850112b 100644 --- a/src/drivers/oceanoptics/QE65000Driver.h +++ b/src/drivers/oceanoptics/QE65000Driver.h @@ -35,6 +35,7 @@ public: ArrayProperty<float64> yData; ArrayProperty<float64> xData; + Property<int32> size; QE65000Driver(const std::string& name); virtual ~QE65000Driver(); diff --git a/src/drivers/oceanoptics/QE65000State.h b/src/drivers/oceanoptics/QE65000State.h index dc2ec2ba..c2570de9 100644 --- a/src/drivers/oceanoptics/QE65000State.h +++ b/src/drivers/oceanoptics/QE65000State.h @@ -33,7 +33,7 @@ public: virtual ~QE65000State() { } - virtual void measure() = 0; + virtual void start() = 0; virtual void stop() = 0; virtual void readStatus() = 0; diff --git a/src/drivers/oceanoptics/RealQE65000Driver.cpp b/src/drivers/oceanoptics/RealQE65000Driver.cpp index b43d70bf..b8826dbb 100644 --- a/src/drivers/oceanoptics/RealQE65000Driver.cpp +++ b/src/drivers/oceanoptics/RealQE65000Driver.cpp @@ -27,8 +27,11 @@ using namespace std; namespace oceanoptics { -RealQE65000Driver::RealQE65000Driver(QE65000Driver* owner) : QE65000State(owner) { +RealQE65000Driver::RealQE65000Driver(QE65000Driver* owner) : + QE65000State(owner) { + spectrometerId = 0; + deviceId = 0; } RealQE65000Driver::~RealQE65000Driver() { @@ -36,47 +39,61 @@ RealQE65000Driver::~RealQE65000Driver() { } void RealQE65000Driver::init() { + //Get deviceID necessary to use library methods + sbapi_initialize(); + sbapi_probe_devices(); + + //Retrieve necessary ids + getDeviceID(); + getSpectroID(); + int32 error = 0; + int32 result = sbapi_open_device(deviceId, &error); + if (result == 0) { + int32 error = 0; + owner()->size = sbapi_spectrometer_get_formatted_spectrum_length(deviceId, spectrometerId, &error); + } + sbapi_close_device(deviceId, &error); + //compulsory to have! -// m_owner->sendProgressEvent(PROGRESSION_END_DEVICE_CONTAINER); - owner()->commandProgression = PROGRESSION_END_DEVICE_CONTAINER; + owner()->commandProgression = PROGRESSION_END_DEVICE_CONTAINER; } - -void RealQE65000Driver::measure() { +void RealQE65000Driver::start() { int32 error = 0; + //Delete current arrays + delete[] owner()->xData(); + delete[] owner()->yData(); + + //Get deviceID necessary to use library methods sbapi_initialize(); sbapi_probe_devices(); - int32 numberOfDevices = sbapi_get_number_of_device_ids(); //Provides the number of devices that have either been probed or manually specified - if (numberOfDevices != 0) { - int64* deviceIds = (int64 *)calloc(numberOfDevices, sizeof(int64)); - int32 devicesNumber = sbapi_get_device_ids(deviceIds, numberOfDevices); //This provides a unique ID of each device that is detected or specified. The IDs are copied into the buffer deviceIds - - for (int32 i = 0; i < devicesNumber; i++) { - //the first thing we have to do is to open the spectrometer, necessary? - int64 deviceId = deviceIds[i]; - int32 result = sbapi_open_device(deviceId, &error); - if (result == 0) { - - setIntegrationTime(deviceId, owner()->integrationTime()); - getFormattedSpectrum(deviceId); - getWavelength(deviceId); - - owner()->commandProgression = PROGRESSION_END_DEVICE_CONTAINER; - } - sbapi_close_device(deviceId, &error); - } + //Retrieve necessary ids + getDeviceID(); + getSpectroID(); + //Open device + int32 result = sbapi_open_device(deviceId, &error); + if (result == 0) { + //Get size + int32 error = 0; + owner()->size = sbapi_spectrometer_get_formatted_spectrum_length(deviceId, spectrometerId, &error); //needed here?? + //Set integration time + setIntegrationTime(owner()->integrationTime()); + + //Retrieve data + getFormattedSpectrum(); + getWavelength(); - } else { - cout << "no spectrometer found" << endl; - //Do not forget to send end of progression to unblock start owner()->commandProgression = PROGRESSION_END_DEVICE_CONTAINER; + + sbapi_close_device(deviceId, &error); } -} +} + void RealQE65000Driver::stop() { owner()->commandProgression = PROGRESSION_END_DEVICE_CONTAINER; } @@ -90,136 +107,128 @@ void RealQE65000Driver::readStatus() { int32 numberOfDevices = sbapi_get_number_of_device_ids(); if (numberOfDevices != 0) { owner()->status.update(QE65000Driver::PLUGGED); + } else { owner()->status.update(QE65000Driver::UNPLUGGED); } +} +void RealQE65000Driver::getDeviceID() { + //There should be only ONE device + int32 numberOfDevices = sbapi_get_number_of_device_ids(); //Provides the number of devices that have either been probed or manually specified + if (numberOfDevices == 0) { + // error uhuuu + owner()->commandProgression = PROGRESSION_END_DEVICE_CONTAINER; + return; -} + } else if (numberOfDevices > 1) { + // we will only use one by now... + } -void RealQE65000Driver::setIntegrationTime(int64 deviceID, int32 integrationTime) { + sbapi_get_device_ids(&deviceId, 1); //Only one device... + cout << "getting device id " << deviceId << endl; +} +void RealQE65000Driver::getSpectroID() { + //get spectrometer id int32 error = 0; //need to get spectrometer feature IDs --> it is the same that opening it... - int32 spectroNumbers = sbapi_get_number_of_spectrometer_features(deviceID, &error); + int32 spectroNumbers = sbapi_get_number_of_spectrometer_features(deviceId, &error); - if (spectroNumbers != 0) { - int64* spectrometerIds = (int64 *) calloc(spectroNumbers, sizeof(int64)); - int32 numberOfSpectrometers = sbapi_get_spectrometer_features(deviceID, &error, spectrometerIds, spectroNumbers); + if (spectroNumbers == 0) { + // log error + owner()->commandProgression = PROGRESSION_END_DEVICE_CONTAINER; + return; + } else if (spectroNumbers > 1) { + // log warning : only 1 used + } - for (int32 i = 0; i < numberOfSpectrometers; i++) { - //NOTE: integration time must be bigger than minimum integration time - int32 minimumIntegrationTime = sbapi_spectrometer_get_minimum_integration_time_micros(deviceID, spectrometerIds[i], &error); + sbapi_get_spectrometer_features(deviceId, &error, &spectrometerId, 1); //Only one device... +} - if (minimumIntegrationTime > integrationTime) { - integrationTime = minimumIntegrationTime; - } - //api: spectrometerSetIntegrationTimeMicros (long deviceID, long featureID, int *errorCode, unsigned long integrationTimeMicros) - sbapi_spectrometer_set_integration_time_micros(deviceID, spectrometerIds[i], &error, integrationTime); - } +void RealQE65000Driver::setIntegrationTime(int32 integrationTime) { + int32 error = 0; + + //NOTE: integration time must be bigger than minimum integration time + int32 minimumIntegrationTime = sbapi_spectrometer_get_minimum_integration_time_micros(deviceId, spectrometerId, &error); + + if (minimumIntegrationTime > integrationTime) { + integrationTime = minimumIntegrationTime; } + //api: spectrometerSetIntegrationTimeMicros (long deviceID, long featureID, int *errorCode, unsigned long integrationTimeMicros) + sbapi_spectrometer_set_integration_time_micros(deviceId, spectrometerId, &error, integrationTime); } /** * Acquire a spectrum. In this mode, auto-nulling should be automatically performed for devices that support it. */ -void RealQE65000Driver::getFormattedSpectrum(int64 deviceID) { +void RealQE65000Driver::getFormattedSpectrum() { int32 error = 0; - //need to get spectrometer feature IDs --> it is the same than opening it... - int32 spectroNumbers = sbapi_get_number_of_spectrometer_features(deviceID, &error); - - if (spectroNumbers != 0) { - int64* spectrometerIds = (int64 *) calloc(spectroNumbers, sizeof(int64)); - int32 numberOfSpectrometers = sbapi_get_spectrometer_features(deviceID, &error, spectrometerIds, spectroNumbers); - - int32 length; - float64* doubleBuffer; - for (int32 i = 0; i < numberOfSpectrometers; i++) { - length = sbapi_spectrometer_get_formatted_spectrum_length(deviceID, spectrometerIds[i], &error); - doubleBuffer = (float64 *)calloc(length, sizeof(float64)); - sbapi_spectrometer_get_formatted_spectrum(deviceID, spectrometerIds[i], &error, doubleBuffer, length); - } - //Spectrum = Y data - owner()->yData.set(doubleBuffer); - owner()->yData.setSize((int64) length); - } + float64* doubleBuffer = (float64 *) calloc(owner()->size(), sizeof(float64)); + sbapi_spectrometer_get_formatted_spectrum(deviceId, spectrometerId, &error, doubleBuffer, owner()->size()); + + //Spectrum = Y data + owner()->yData.set(doubleBuffer); + owner()->yData.setSize((int64) owner()->size()); } /* - * Acquire a spectrum. Returns the answer in raw, unformatted bytes. NOT USED + * Get Wavelengths or x data */ -void RealQE65000Driver::getUnFormattedSpectrum(int64 deviceID) { +void RealQE65000Driver::getWavelength() { int32 error = 0; - //need to get spectrometer feature IDs --> it is the same than opening it... - int32 spectroNumbers = sbapi_get_number_of_spectrometer_features(deviceID, &error); - if (spectroNumbers != 0) { - int64* spectrometerIds = (int64 *) calloc(spectroNumbers, sizeof(int64)); - int32 numberOfSpectrometers = sbapi_get_spectrometer_features(deviceID, &error, spectrometerIds, spectroNumbers); + int32 length = sbapi_spectrometer_get_formatted_spectrum_length(deviceId, spectrometerId, &error); + float64* valuesBuffer = (float64 *) calloc(owner()->size(), sizeof(float64)); + sbapi_spectrometer_get_wavelengths(deviceId, spectrometerId, &error, valuesBuffer, owner()->size()); - for (int32 i = 0; i < numberOfSpectrometers; i++) { - int32 length = sbapi_spectrometer_get_unformatted_spectrum_length(deviceID, spectrometerIds[i], &error); - unsigned char* byteBuffer = (unsigned char *) calloc(length, sizeof(unsigned char)); - sbapi_spectrometer_get_unformatted_spectrum(deviceID, spectrometerIds[i], &error, byteBuffer, length); - } - } + owner()->xData.set(valuesBuffer); + owner()->xData.setSize((int64) owner()->size()); } +int32 RealQE65000Driver::getSize() { + //Get deviceID necessary to use library methods + sbapi_initialize(); + sbapi_probe_devices(); -/* - * Get Wavelengths or x data - */ -void RealQE65000Driver::getWavelength(int64 deviceID) { + //Retrieve necessary ids + getDeviceID(); + getSpectroID(); int32 error = 0; - //need to get spectrometer feature IDs --> it is the same than opening it... - int32 spectroNumbers = sbapi_get_number_of_spectrometer_features(deviceID, &error); - - if (spectroNumbers != 0) { - int64* spectrometerIds = (int64 *) calloc(spectroNumbers, sizeof(int64)); - int32 numberOfSpectrometers = sbapi_get_spectrometer_features(deviceID, &error, spectrometerIds, spectroNumbers); - - int32 length; - float64* valuesBuffer; - for (int32 i = 0; i < numberOfSpectrometers; i++) { - //The length depends on measuring formatted or unformatted data. UP to now we stick to formatted data - length = sbapi_spectrometer_get_formatted_spectrum_length(deviceID, spectrometerIds[i], &error); - valuesBuffer = (float64 *) calloc(length, sizeof(float64)); - sbapi_spectrometer_get_wavelengths(deviceID, spectrometerIds[i], &error, valuesBuffer, length); - } + int32 result = sbapi_open_device(deviceId, &error); + if (result == 0) { + int32 error = 0; + owner()->size = sbapi_spectrometer_get_formatted_spectrum_length(deviceId, spectrometerId, &error); - owner()->xData.set(valuesBuffer); - owner()->xData.setSize((int64) length); } + sbapi_close_device(deviceId, &error); + return owner()->size(); } /** * Manipulate the shutter. It seems to me that this feature is not available */ -void RealQE65000Driver::setShutter(int64 deviceID) { +void RealQE65000Driver::setShutter() { int32 error = 0; char opened = 0; //If 0 -> shutter closed, if 1 -> shutter opened - int32 numberOfShutters = sbapi_get_number_of_shutter_features(deviceID, &error); + int32 numberOfShutters = sbapi_get_number_of_shutter_features(deviceId, &error); if (numberOfShutters != 0) { - int64* shutterIds = (int64 *)calloc(numberOfShutters, sizeof(int64)); - int32 numberOfShuttersWithFeature = sbapi_get_shutter_features(deviceID, &error, shutterIds, numberOfShutters); + int64* shutterIds = (int64 *) calloc(numberOfShutters, sizeof(int64)); + int32 numberOfShuttersWithFeature = sbapi_get_shutter_features(deviceId, &error, shutterIds, numberOfShutters); //Iterate over the shutter features for (int32 i = 0; i < numberOfShuttersWithFeature; i++) { //open shutter - sbapi_shutter_set_shutter_open(deviceID, shutterIds[i], &error, 1); + sbapi_shutter_set_shutter_open(deviceId, shutterIds[i], &error, 1); cout << "shutter open!" << endl; //close shutter - sbapi_shutter_set_shutter_open(deviceID, shutterIds[i], &error, 0); + sbapi_shutter_set_shutter_open(deviceId, shutterIds[i], &error, 0); cout << "shutter close!" << endl; } } } } - - - - diff --git a/src/drivers/oceanoptics/RealQE65000Driver.h b/src/drivers/oceanoptics/RealQE65000Driver.h index 55f8c58d..a2d166ff 100644 --- a/src/drivers/oceanoptics/RealQE65000Driver.h +++ b/src/drivers/oceanoptics/RealQE65000Driver.h @@ -31,19 +31,23 @@ public: virtual void init(); - virtual void measure(); + virtual void start(); virtual void stop(); virtual void readStatus(); private: - void setIntegrationTime(int64 deviceID, int32 integrationTime); - void getFormattedSpectrum(int64 deviceID); - void getUnFormattedSpectrum(int64 deviceID); - void getWavelength(int64 deviceID); - void setShutter(int64 deviceID); - void test(); + void setIntegrationTime(int32 integrationTime); + void getFormattedSpectrum(); + void getWavelength(); + void setShutter(); + void getSpectroID(); + void getDeviceID(); + int32 getSize(); + + int64 spectrometerId; + int64 deviceId; }; diff --git a/src/drivers/oceanoptics/SimulatedQE65000Driver.cpp b/src/drivers/oceanoptics/SimulatedQE65000Driver.cpp index 700aa212..193e9e21 100644 --- a/src/drivers/oceanoptics/SimulatedQE65000Driver.cpp +++ b/src/drivers/oceanoptics/SimulatedQE65000Driver.cpp @@ -20,7 +20,10 @@ namespace oceanoptics { -SimulatedQE65000Driver::SimulatedQE65000Driver(QE65000Driver* owner) : QE65000State(owner) { +const int32 SimulatedQE65000Driver::DATASIZE = 1044; + +SimulatedQE65000Driver::SimulatedQE65000Driver(QE65000Driver* owner) : + QE65000State(owner) { } @@ -29,28 +32,32 @@ SimulatedQE65000Driver::~SimulatedQE65000Driver() { } void SimulatedQE65000Driver::init() { - + //Assume spectrum length is always the same (1044) + owner()->size = DATASIZE; } -void SimulatedQE65000Driver::measure() { +void SimulatedQE65000Driver::start() { //Simulate integrationTime taken into account usleep(owner()->integrationTime()); - //Assume spectrum length is always the same (1044) - int32 length = 1044; - float64* tempXData = new float64[length]; - float64* tempYData = new float64[length]; + //delete + delete[] owner()->xData(); + delete[] owner()->yData(); - for (int32 j = 0; j < length; j++) { - tempXData[j] = j; - tempYData[j] = j + 100; + float64* m_tempXData = new float64[owner()->size()]; + float64* m_tempYData = new float64[owner()->size()]; + + for (int32 j = 0; j < owner()->size(); j++) { + m_tempXData[j] = j; + m_tempYData[j] = j + 100; } - owner()->xData.set(tempXData); - owner()->xData.setSize(length); + owner()->xData.setSize(owner()->size()); + owner()->xData.set(m_tempXData); + + owner()->yData.set(m_tempYData); + owner()->yData.setSize(owner()->size()); - owner()->yData.set(tempYData); - owner()->yData.setSize(length); } void SimulatedQE65000Driver::stop() { @@ -58,9 +65,8 @@ void SimulatedQE65000Driver::stop() { } void SimulatedQE65000Driver::readStatus() { -// cout << "reading status in perfect mode" << endl; + owner()->status.update(QE65000Driver::PLUGGED); } } - diff --git a/src/drivers/oceanoptics/SimulatedQE65000Driver.h b/src/drivers/oceanoptics/SimulatedQE65000Driver.h index 4decd065..f20ac824 100644 --- a/src/drivers/oceanoptics/SimulatedQE65000Driver.h +++ b/src/drivers/oceanoptics/SimulatedQE65000Driver.h @@ -27,11 +27,14 @@ namespace oceanoptics { class SimulatedQE65000Driver: public QE65000State { public: + + static const int32 DATASIZE; + SimulatedQE65000Driver(QE65000Driver* owner); virtual ~SimulatedQE65000Driver(); virtual void init(); - virtual void measure(); + virtual void start(); virtual void stop(); virtual void readStatus(); diff --git a/src/drivers/oceanoptics/readme.txt b/src/drivers/oceanoptics/readme.txt index 669ec6eb..871ca5f7 100644 --- a/src/drivers/oceanoptics/readme.txt +++ b/src/drivers/oceanoptics/readme.txt @@ -1,5 +1,7 @@ How to install SeaBreeze library: -- unzip seabreeze package (password: ooi-seabreeze) +- unzip seabreeze package (password: ooi-seabreeze) in /usr/local/src/ in root - install library libusb (development): libusb-dev -- run 'make' in seabreeze folder \ No newline at end of file +- run 'make' in seabreeze folder +- cp /usr/local/src/seabreeze/lib/libseabreeze.so /usr/local/lib +- check LD_LIBRARY_PATH if the system cannot find -lseabreeze \ No newline at end of file diff --git a/src/drivers/princeton/usbpvcam/RealUsbPVCamDriver.cpp b/src/drivers/princeton/usbpvcam/RealUsbPVCamDriver.cpp index 3118b0cd..a3e48e90 100644 --- a/src/drivers/princeton/usbpvcam/RealUsbPVCamDriver.cpp +++ b/src/drivers/princeton/usbpvcam/RealUsbPVCamDriver.cpp @@ -125,7 +125,7 @@ void RealUsbPVCamDriver::read() { void RealUsbPVCamDriver::start() { uint32 exp_time = (uint32) (owner()->time.setpoint() * owner()->precision()); - +clear(); unsigned long size; void *region = allocRegion(); -- GitLab