diff --git a/CMakeLists.txt b/CMakeLists.txt deleted file mode 100644 index 68b2b010b..000000000 --- a/CMakeLists.txt +++ /dev/null @@ -1,76 +0,0 @@ -cmake_minimum_required(VERSION 2.8) -set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH}) -set (CALIBRATE OFF) - -# Check if project is being used directly or via add_subdirectory -set(SLS_MASTER_PROJECT OFF) -if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR) - set(SLS_MASTER_PROJECT ON) -endif() - -option (SLS_USE_HDF5 "HDF5 File format" OFF) -option (SLS_USE_TEXTCLIENT "Text Client" OFF) -option (SLS_USE_RECEIVER "Receiver" OFF) -option (SLS_USE_GUI "GUI" OFF) - - -#Flags to always be used -# -Wno-unused-parameter should eventually be removes -# -Wno-overloaded-virtual TODO! remove warnings in refactor -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wno-overloaded-virtual -Wno-unused-parameter -std=c++98") - -if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") - # clang does not support -Wno-misleading-indentation - # add any special clang flags -elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") - if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 6.0) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-misleading-indentation") - endif () -endif() - - -find_package(Qt4) -find_package(Qwt 6) -find_package(CBF) -find_package(Doxygen) -# find_package(PNG REQUIRED) - -if (SLS_USE_HDF5) - find_package(HDF5 1.10 COMPONENTS CXX) -endif (SLS_USE_HDF5) - -set(CMAKE_POSITION_INDEPENDENT_CODE ON) - -set(CMAKE_INSTALL_RPATH "$ORIGIN") -set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE) - - -if (SLS_USE_TEXTCLIENT) - add_subdirectory(slsDetectorSoftware) -endif (SLS_USE_TEXTCLIENT) - -if (SLS_USE_RECEIVER) - add_subdirectory(slsReceiverSoftware) - add_subdirectory(manual/manual-api) -endif (SLS_USE_RECEIVER) - - -if (SLS_USE_GUI) - if (QT4_FOUND AND QWT_FOUND) - add_subdirectory(slsDetectorGui) - endif() -endif (SLS_USE_GUI) - -if (SLS_MASTER_PROJECT) - # Set targets export name (otherwise set by upstream project) - set(TARGETS_EXPORT_NAME "slsdetector-targets") -endif (SLS_MASTER_PROJECT) - -if (CALIBRATE) - if (DEFINED ENV{ROOTSYS}) - find_package(ROOT) - if (ROOT_FOUND) - add_subdirectory(calibrationWizards) - endif() - endif() -endif(CALIBRATE) diff --git a/Makefile b/Makefile deleted file mode 100755 index 8d4849b75..000000000 --- a/Makefile +++ /dev/null @@ -1,235 +0,0 @@ -# do not change below this line# - -# Include common definitions -include Makefile.include - -INSTALLROOT ?= $(PWD) -BINDIR ?= $(INSTALLROOT)/bin -DOCDIR ?= $(INSTALLROOT)/manual/docs -LIBDIR ?= $(INSTALLROOT)/bin -INCDIR ?= $(INSTALLROOT)/include -DETAILDOC ?= $(INSTALLROOT)/docs - -WD = $(shell pwd) -LIBRARYDIR = $(WD)/slsDetectorSoftware -LIBRARYRXRDIR = $(WD)/slsReceiverSoftware -CLIENTDIR = $(LIBRARYDIR)/slsDetectorClient -GUIDIR = $(WD)/slsDetectorGui -RECEIVERDIR = $(LIBRARYRXRDIR) -CALWIZDIR = $(WD)/calibrationWizards -MANDIR = $(WD)/manual -CALIBDIR = $(WD)/slsDetectorCalibration -MANAPIDIR = $(MANDIR)/manual-api - -TABSPACE := "\t" - - -INCLUDES=-I. -I$(LIBRARYDIR)/commonFiles -I$(LIBRARYDIR)/slsDetector -I$(LIBRARYDIR)/usersFunctions -I$(LIBRARYDIR)/multiSlsDetector -I$(LIBRARYDIR)/slsDetectorUtils -I$(LIBRARYDIR)/slsDetectorCommand -I$(LIBRARYDIR)/slsDetectorAnalysis -I$(LIBRARYDIR)/slsReceiverInterface -I$(LIBRARYRXRDIR)/include -I$(LIBRARYDIR)/threadFiles -I$(LIBRARYDIR)/sharedMemory -I$(ASM) - -INCLUDESRXR += -I. -I$(LIBRARYRXRDIR)/include -I$(CALIBDIR) -I$(ASM) -#LIBFLAGRXR += - -$(info ) -$(info #######################################) -$(info # In slsDetectorsPackage Makefile #) -$(info #######################################) -$(info ) - - -.PHONY: all nonstatic static lib libreceiver textclient receiver gui stextclient sreceiver - -#all: lib textclient receiver gui -all: textclient receiver gui - -nonstatic: lib libreceiver textclient receiver gui - -static: lib libreceiver stextclient sreceiver gui - - -lib: - cd $(LIBRARYDIR) && $(MAKE) FLAGS='$(FLAGS)' DESTDIR='$(LIBDIR)' LIBRARYDIR='$(LIBRARYDIR)' LIBS='$(LDFLAGDET)' INCLUDES='$(INCLUDES)' LIBDIR='$(LIBDIR)' - -libreceiver: - cd $(LIBRARYRXRDIR) && $(MAKE) FLAGS='$(FLAGS)' DESTDIR='$(LIBDIR)' LIBS='$(LDFLAGRXR)' INCLUDES='$(INCLUDESRXR)' LIBDIR='$(LIBDIR)' - - -stextclient: slsDetectorClient_static - -slsDetectorClient: textclient - -slsDetectorClient_static: #lib - cd $(CLIENTDIR) && $(MAKE) static_clients FLAGS='$(FLAGS)' DESTDIR='$(BINDIR)' LIBRARYDIR='$(LIBRARYDIR)' LIBS='$(LDFLAGDET)' INCLUDES='$(INCLUDES)' LIBDIR='$(LIBDIR)' - @echo "" - @echo "#######################################" - @echo "# Back in slsDetectorPackage Makefile #" - @echo "#######################################" - @echo "" - -textclient: #lib - cd $(CLIENTDIR) && $(MAKE) FLAGS='$(FLAGS)' DESTDIR='$(BINDIR)' LIBRARYDIR='$(LIBRARYDIR)' LIBS='$(LDFLAGDET)' INCLUDES='$(INCLUDES)' LIBDIR='$(LIBDIR)' - @echo "" - @echo "#######################################" - @echo "# Back in slsDetectorPackage Makefile #" - @echo "#######################################" - @echo "" - -slsReceiver: receiver - -slsReceiver_static: receiver - -receiver: #libreceiver -# cd $(RECEIVERDIR) && $(MAKE) receiver FLAGS='$(FLAGS)' DESTDIR='$(BINDIR)' LIBS='$(LDFLAGRXR)' INCLUDES='$(INCLUDESRXR)' LIBDIR='$(LIBDIR)' - cd $(RECEIVERDIR) && $(MAKE) FLAGS='$(FLAGS)' DESTDIR='$(BINDIR)' LIBS='$(LDFLAGRXR)' INCLUDES='$(INCLUDESRXR)' LIBDIR='$(LIBDIR)' - cd $(MANAPIDIR) && $(MAKE) slsMultiReceiver - @echo "" - @echo "#######################################" - @echo "# Back in slsDetectorPackage Makefile #" - @echo "#######################################" - @echo "" - -sreceiver: #libreceiver - cd $(RECEIVERDIR) && $(MAKE) static_receiver FLAGS='$(FLAGS)' DESTDIR='$(BINDIR)' LIBS='$(LDFLAGRXR)' INCLUDES='$(INCLUDESRXR)' LIBDIR='$(LIBDIR)' - @echo "" - @echo "#######################################" - @echo "# Back in slsDetectorPackage Makefile #" - @echo "#######################################" - @echo "" - -slsDetectorGUI: #lib - cd $(GUIDIR) && $(MAKE) DESTDIR='$(BINDIR)' LIBRARYDIR='$(LIBRARYDIR)' INCLUDES='$(INCLUDES)' LDFLAGDET='$(LDFLAGDETONLY)' LIBDIR='$(LIBDIR)' - @echo "" - @echo "#######################################" - @echo "# Back in slsDetectorPackage Makefile #" - @echo "#######################################" - @echo "" - -calWiz: - cd $(CALWIZDIR) && $(MAKE) DESTDIR=$(BINDIR) #FLAGS=$(FLAGS) LDFLAGDET=$(LDFLAGDET) INCLUDES=$(INCLUDES) - - - -gui: slsDetectorGUI - - -doc: - $(shell test -d $(DOCDIR) || mkdir -p $(DOCDIR)) - cd manual && make all DESTDIR=$(DOCDIR) - -htmldoc: - make doc - $(shell test -d $(DOCDIR) || mkdir -p $(DOCDIR)) - cd manual && make html DESTDIR=$(DOCDIR) - -detaildoc: createdocs docspdf docshtml removedocs - -createdocs: $(LIBRARYDIR)/doxy.config - doxygen $(LIBRARYDIR)/doxy.config - -docspdf: - cd slsDetectorPackageDocs/latex && make - $(shell test -d $(DETAILDOC) || mkdir -p $(DETAILDOC)) - $(shell test -d $(DETAILDOC)/pdf || mkdir -p $(DETAILDOC)/pdf) - mv slsDetectorPackageDocs/latex/refman.pdf $(DETAILDOC)/pdf/slsDetectorPackageDocs.pdf - -docshtml: - $(shell test -d $(DETAILDOC) || mkdir -p $(DETAILDOC)) - $(shell test -d $(DETAILDOC)/html || mkdir -p $(DETAILDOC)/html) - $(shell test -d $(DETAILDOC)/html/slsDetectorPackageDocs && rm -r $(DETAILDOC)/html/slsDetectorPackageDocs) - mv slsDetectorPackageDocs/html $(DETAILDOC)/html/slsDetectorPackageDocs - -removedocs: - rm -rf slsDetectorPackageDocs; - - -clean: - cd $(BINDIR) && rm -rf sls_detector_* slsDetectorGui slsReceiver angularCalibrationWizard energyCalibrationWizard - cd $(LIBDIR) && rm -rf libSlsDetector.so libSlsDetector.a libSlsReceiver.so libSlsReceiver.a - cd $(LIBRARYDIR) && $(MAKE) clean - cd $(LIBRARYRXRDIR) && $(MAKE) clean - cd $(CLIENTDIR) && $(MAKE) clean - cd $(GUIDIR) && $(MAKE) clean - cd $(CALWIZDIR) && $(MAKE) clean - cd manual && $(MAKE) clean - cd $(DOCDIR) && rm -rf * - rm -rf slsDetectorPackageDocs; - rm -rf $(DETAILDOC) - rm -rf $(MANAPIDIR)/slsMultiReceiver - - -#install_lib: -# cd $(LIBRARYDIR) && $(MAKE) install DESTDIR=$(LIBDIR) INCLUDES=$(INCLUDES) -# cd $(LIBRARYDIR) && $(MAKE) install_inc DESTDIR=$(INCDIR) - -mythen_virtual: - cd $(LIBRARYDIR) && $(MAKE) mythenVirtualServer DESTDIR=$(BINDIR) - - -gotthard_virtual: - cd $(LIBRARYDIR) && $(MAKE) gotthardVirtualServer DESTDIR=$(BINDIR) - - -install_client: textclient slsReceiver - -install_gui: gui - -confinstall: - make conf;\ - make install - -install_lib: - make lib;\ - make libreceiver; \ - make textclient; \ - make slsReceiver; \ - make doc; \ - make htmldoc; \ - cd $(LIBRARYDIR) && $(MAKE) install_inc DESTDIR=$(INCDIR); \ - cd $(LIBRARYRXRDIR) && $(MAKE) install_inc DESTDIR=$(INCDIR); - -install: - make install_lib; \ - make gui; \ - make calWiz; \ - cd $(LIBRARYDIR) && $(MAKE) install_inc DESTDIR=$(INCDIR);\ - cd $(LIBRARYRXRDIR) && $(MAKE) install_inc DESTDIR=$(INCDIR); - -conf: - set -e; \ - . ./configure; \ - @echo "INSTALLROOT is $(INSTALLROOT)" - @echo "BINDIR is $(BINDIR)" - @echo "LIBDIR is $(LIBDIR)" - @echo "INCDIR is $(INCDIR)" - @echo "DOCDIR is $(DOCDIR)" - - -help: - @echo "Targets:" - @echo "make all compile library, text clients, data reciever" - @echo "make lib compile library" - @echo "make libreceiver compile receiver library" - @echo "make textclient compile the slsDetectorClient dynamically linking the libraries" - @echo "make stextclient compile slsDetectorClient statically linking the libraries" - @echo "make receiver compile the slsReciever dynamically linking the libraries" - @echo "make sreceiver compile the slsReciever statically linking the libraries" - @echo "make gui compile slsDetectorGUI - requires a working Qt4 and Qwt installation" - @echo "make calWiz compile the calibration wizards - requires a working Root installation" - @echo "make doc compile pdf documentation" - @echo "make htmldoc compile html (and pdf) documentation" - @echo "make install_lib installs the libraries, the text clients, the documentation and the includes for the API" - @echo "make install installs all software, including the gui, the cal wizards and the includes for the API" - @echo "make confinstall installs all software, including the gui, the cal wizards and the includes for the API, prompting for the install paths" - @echo "make clean remove object files and executables" - @echo "make help lists possible targets" - @echo "" - @echo "" - @echo "Makefile variables" - @echo "DEBUG=1,2 set debug level to 1 (VERBOSE) or 2 (VERYVERBOSE)" - @echo "" - @echo "" - @echo "Variables - to change them run :" - @echo "INSTALLROOT=: installation root di r, default $PWD" - @echo "BINDIR=: binary installation dir below INSTALLROOT, default bin" - @echo "LIBDIR=: library installation dir below INSTALLROOT, default lib" - @echo "INCDIR=: header installation dir below INSTALLROOT, default include" - @echo "DOCDIR=: documentation installation dir below INSTALLROOT, default doc" diff --git a/Makefile.include b/Makefile.include deleted file mode 100755 index 71dba3160..000000000 --- a/Makefile.include +++ /dev/null @@ -1,58 +0,0 @@ -############################################################## -# Generic -############################################################## - -CC = g++ -CXX = $(CC) -ASM=$(shell echo "/lib/modules/`uname -r`/build/include") -LDFLAGDETONLY = -L$(LIBDIR) -Wl,-rpath=$(LIBDIR) -lSlsDetector -LDFLAGDET = -L$(LIBDIR) -Wl,-rpath=$(LIBDIR) -lSlsDetector -L/usr/lib64/ -pthread -LDFLAGRXR = -L$(LIBDIR) -Wl,-rpath=$(LIBDIR) -lSlsReceiver -L/usr/lib64/ -pthread -FLAGS= -Wall -pthread #-DEIGER_DEBUG2 -# -DVERBOSE - -# Setting up the verbose flags -ifeq ($(DEBUG),1) - FLAGS = -Wall -DVERBOSE -endif -ifeq ($(DEBUG),2) - FLAGS = -Wall -DVERYVERBOSE -endif - -############################################################## -# HDF5 specific. Set this to yes, if you want to compile -# HDF5 code: in this case, you need HDF5 libraries -############################################################## - -HDF5 = no -HDF5_DIR = /opt/hdf5v1.10.0 - -ifeq ($(HDF5),yes) - LDFLAGRXR = -L$(LIBDIR) -Wl,-rpath=$(LIBDIR) -lSlsReceiver -L$(HDF5_DIR)/lib -Wl,-rpath=$(HDF5_DIR)/lib -lhdf5 -lhdf5_cpp -lsz -lz -DHDF5C -L/usr/lib64/ -pthread - INCLUDESRXR = -I$(HDF5_DIR)/include -endif - - -############################################################## -# ROOTSLS specific. Set this to yes, if you want to compile -# ROOTSLS code: in this case, you need also root libraries -############################################################## - -ROOTSLS = no - -ROOTFLAGS = $(shell root-config --cflags --glibs) -DMYROOT1 #-DALLFILE_DEBUG #-DMYROOT1 - -ifeq ($(ROOTSLS),yes) - LDFLAGRXR = -L$(LIBDIR) -lSlsReceiver $(ROOTFLAGS) -DROOTSLS -endif - - -define colorecho - @tput setaf 6 - @echo $1 - @tput sgr0 -endef - - - - diff --git a/README.md b/README.md deleted file mode 100644 index e142ff84b..000000000 --- a/README.md +++ /dev/null @@ -1,91 +0,0 @@ -### Documentation -Detailed documentation can be found on the [official site.](https://www.psi.ch/detectors/users-support) - -### Binaries -Documentation to obtain the binaries via the conda package is available for [lib](https://github.com/slsdetectorgroup/sls_detector_lib) and [gui](https://github.com/slsdetectorgroup/sls_detector_gui) - -### Source code -One can also obtain the source code from this repository and compile while realizing the setup dependencies as required. -``` -git clone https://github.com/slsdetectorgroup/slsDetectorPackage.git - -``` -#### Setup dependencies -* Gui Client
-Requirements: Qt 4.8 and Qwt 6.0 -``` - export QTDIR=/usr/local/Trolltech/ - export QWTDIR=/usr/local/qwt-6.0.1/ -``` -If either of them does not exist, the GUI client will not be built. - -* Advanced user Calibration wizards
-Requirements: ROOT -``` - export ROOTSYS=/usr/local/root-5.34 -``` - -#### Compilation - -Compiling can be done in two ways. - -**1. Compile using script cmk.sh**
- -After compiling, the libraries and executables will be found in `slsDetectorPackage/build/bin` directory
- -Usage: [-c] [-b] [-h] [-d HDF5 directory] [-j]
- * -[no option]: only make
- * -c: Clean
- * -b: Builds/Rebuilds CMake files normal mode
- * -h: Builds/Rebuilds Cmake files with HDF5 package
- * -d: HDF5 Custom Directory
- * -t: Build/Rebuilds only text client
- * -r: Build/Rebuilds only receiver
- * -g: Build/Rebuilds only gui
- * -j: Number of threads to compile through
- * -e: Debug mode - -Basic Option: -./cmk.sh -b - -For only make: -./cmk.sh - -For make clean;make: -./cmk.sh -c - -For using hdf5 without custom dir /blabla: -./cmk.sh -h -d /blabla - -For rebuilding cmake without hdf5 -./cmk.sh -b - -For using multiple cores to compile faster: -./cmk.sh -j9
- - -For rebuilding only certain sections
-./cmk.sh -tg #only text client and gui
-./cmk.sh -r #only receiver
- - -**2. Compile without script**
-Use cmake to create out-of-source builds, by creating a build folder parallel to source directory. -``` - $ cd .. - $ mkdir slsDetectorPackage-build - $ cd slsDetectorPackage-build - $ cmake ../slsDetectorPackage -DCMAKE_BUILD_TYPE=Debug -DSLS_USE_HDF5=OFF - $ make -``` - -Use the following as an example to compile statically and using specific hdf5 folder -``` - $ HDF5_ROOT=/opt/hdf5v1.10.0 cmake ../slsDetectorPackage -DCMAKE_BUILD_TYPE=Debug -DSLS_USE_HDF5=ON - ``` -After compiling, the libraries and executables will be found at `bin` directory -``` - $ ls bin/ - gui_client libSlsDetector.a libSlsDetector.so libSlsReceiver.a libSlsReceiver.so - sls_detector_acquire sls_detector_get slsDetectorGui sls_detector_help sls_detector_put slsReceiver slsMultiReceiver -``` diff --git a/RELEASE.txt b/RELEASE.txt deleted file mode 100644 index 74e9ca8c6..000000000 --- a/RELEASE.txt +++ /dev/null @@ -1,205 +0,0 @@ -SLS Detector Package 4.0.1 released on 08.02.2018 (Bug Fix Release) -=================================================================== - - -This document describes the differences between 4.0.1 and 4.0.0 releases. - - CONTENTS - -------- - 1. Topics Concerning - 2. Resolved Issues - 3. Known Issues - 4. Firmware Requirements - 5. Download, Documentation & Support - - - -1. Topics Concerning -==================== - - - Jungfrau server (new firmware mapped) - - Eiger server (measuredPeriod, reg) - - Gotthard server(ADC channel shift, ROI, 25um slave packets) - - Receiver (padding, releasing resources segfault, gappixels) - - Users class (detectorSize, ROI, versions, status) - - API (config error, ROI) - - Compile (Options prefix, static libraries, Makefile for API) - - Gui (multi module) - - - -2. Resolved Issues -================== - - Detector Server - --------------- - - 1. (Jungfrau): Latest Jungfrau firmware release mapped. - - 2. (Eiger): Measured subperiod initially wrapped around 4.29s. Now, upto 42.9s. - - Advanced command "reg" was writing only to right FPGA. - - 3. (Gotthard 25/50um): Since Gotthard only sends packet numbers, one had to - remember to take even number of images in ROI mode, if they wanted to - switch back to non ROI mode. - This is fixed now, but temporary fix involves sending an image during - configuration, which will not be captured by the receiver. Hence, it takes - longer to configure. Permanent fix will require a firmware update. - - The detector output is shifted by 1 for every 32 channels. This is fixed now. - - - Receiver - -------- - - 1. Receiver padding was enabled only if deactivated padding was also enabled. - Receiver padding enable and receiver deactivated padding enable are independent now. - - 2. Starting and stopping receiver without listening resulted in seg faults. - - 3. Gappixels in receiver bug fix. - - - Client - ------ - - 1. (Users class): DetectorSize modified to set/get ROI if ROI is only 1 in number. - - Allowed setting/getting ROI at single detector level via API. - (ROI for Gotthard only). Added them to the users class as setROI and getROI. - - Retrieving versions at module level is possible now. - - Added "stopped" as status in getRunStatus list. - - 2. (API): Incorrect mac address in config file will set error flag in API and not just - print the error. - - ROI possible at module level. - - - Compile - ------- - - 1. CMake options now have a prefix 'SLS_'. - - 2. Static libraries removed. - - 2. slsDetectorPackage/manual/manual-api/Makefile modified to use libraries - from slsDetectorPackage/bin as the main Makefile copies the libraries there. - No effect when using CMakeFiles. - - - Gui - --- - - 1. Adding multiple detectors in x and y direction incremented number of detectors - in y direction incorrectly. Effect seen only in GUI (segfault) if - detsizechan has multi detectors in both direction. Fixed. - - - -3. Known Issues -=============== - - Detector Specific - ----------------- - - 1. (Gotthard 25 um): Slave misses or captures an extra frame. Occurs irregularly. - - 2. (Gotthard 25/50um): Using ROI (2 chips, 256 channels) missses last pixel - of that ADC. - - - -4. Firmware Requirements -======================== - - Gotthard - ======== - Minimum compatible version : 11.01.2013 - Latest compatible version : 08.02.2018 (50um and 25um Master) - 09.02.2018 (25 um Slave) - Eiger - ===== - Minimum compatible version : 22 - Latest compatible version : 22 - - Jungfrau - ======== - Minimum compatible version : 26.02.2018 - Latest compatible version : 06.12.2018 - - - Detector Upgrade - ================ - Gotthard Cannot be upgraded remotely. Requires programming via USB blaster - Eiger Can be upgraded remotely via bit files - Jungfrau Can be upgraded remotely using sls_detector_put programfpga - - Instructions available at - https://www.psi.ch/detectors/installation-instructions - under Detector Upgrade -> [Detector Type] -> Firmware. - - - Please refer to the link below for more details on the firmware versions. - https://www.psi.ch/detectors/firmware. - - - -5. Download, Documentation & Support -==================================== - - Download - -------- - - The Source Code (Default C++ API): - https://github.com/slsdetectorgroup/slsDetectorPackage - - The Conda Lib Package: - https://github.com/slsdetectorgroup/sls_detector_lib - - The Conda GUI Package: - https://github.com/slsdetectorgroup/sls_detector_gui - - The Python Interface (including the package): - https://github.com/slsdetectorgroup/sls_detector - - - Documentation - ------------- - - Manual (HTML & PDF): - https://www.psi.ch/detectors/documentation - slsDetectorPackage/manual/docs/ - - Command Line Documentation: - manual/docs/html/slsDetectorClientDocs/index.html - manual/docs/pdf/slsDetectorClientDocs.pdf - - C++ API Documentation: - manual/docs/html/slsDetectorUsersDocs/index.html - manual/docs/pdf/slsDetectorUsersDocs.pdf - - C++ API Example: - manual/manual-api/mainClient.cpp - manual/manual-api/mainReceiver.cpp - - Python API Documentation: - https://slsdetectorgroup.github.io/sls_detector/ - - Further Documentation: - https://www.psi.ch/detectors/users-support - - - Support - ------- - - General Software related: - dhanya.thattil@psi.ch - anna.bergamaschi@psi.ch - - Python related: - erik.frojdh@psi.ch - diff --git a/cleansharedmemory.sh b/cleansharedmemory.sh deleted file mode 100644 index ab6ad287b..000000000 --- a/cleansharedmemory.sh +++ /dev/null @@ -1 +0,0 @@ -rm /dev/shm/slsDetectorPackage*; diff --git a/cmake/FindCBF.cmake b/cmake/FindCBF.cmake deleted file mode 100644 index df358ab79..000000000 --- a/cmake/FindCBF.cmake +++ /dev/null @@ -1,11 +0,0 @@ -FIND_PATH (CBF_INCLUDE_DIR - ${CBF_DIR}/include - ${CBF_DIR}/include/cbflib -) -FIND_LIBRARY (CBF_LIBRARY - NAMES cbf - HINTS ${CBF_DIR}/lib -) -INCLUDE ( FindPackageHandleStandardArgs ) -FIND_PACKAGE_HANDLE_STANDARD_ARGS (CBF DEFAULT_MSG CBF_LIBRARY CBF_INCLUDE_DIR ) - diff --git a/cmake/FindQwt.cmake b/cmake/FindQwt.cmake deleted file mode 100644 index f1e833e27..000000000 --- a/cmake/FindQwt.cmake +++ /dev/null @@ -1,118 +0,0 @@ -# Qt Widgets for Technical Applications -# available at http://www.http://qwt.sourceforge.net/ -# -# The module defines the following variables: -# QWT_FOUND - the system has Qwt -# QWT_INCLUDE_DIR - where to find qwt_plot.h -# QWT_INCLUDE_DIRS - qwt includes -# QWT_LIBRARY - where to find the Qwt library -# QWT_LIBRARIES - aditional libraries -# QWT_MAJOR_VERSION - major version -# QWT_MINOR_VERSION - minor version -# QWT_PATCH_VERSION - patch version -# QWT_VERSION_STRING - version (ex. 5.2.1) -# QWT_ROOT_DIR - root dir (ex. /usr/local) - -#============================================================================= -# Copyright 2010-2013, Julien Schueller -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# -# 1. Redistributions of source code must retain the above copyright notice, this -# list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright notice, -# this list of conditions and the following disclaimer in the documentation -# and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -# The views and conclusions contained in the software and documentation are those -# of the authors and should not be interpreted as representing official policies, -# either expressed or implied, of the FreeBSD Project. -#============================================================================= - - -find_path ( QWT_INCLUDE_DIR - NAMES qwt_plot.h - HINTS $ENV{QWTDIR} $ENV{QWTDIR}/src ${QT_INCLUDE_DIR} - PATH_SUFFIXES qwt qwt-qt3 qwt-qt4 qwt-qt5 -) - -set ( QWT_INCLUDE_DIRS ${QWT_INCLUDE_DIR} ) - -# version -set ( _VERSION_FILE ${QWT_INCLUDE_DIR}/qwt_global.h ) -if ( EXISTS ${_VERSION_FILE} ) - file ( STRINGS ${_VERSION_FILE} _VERSION_LINE REGEX "define[ ]+QWT_VERSION_STR" ) - if ( _VERSION_LINE ) - string ( REGEX REPLACE ".*define[ ]+QWT_VERSION_STR[ ]+\"(.*)\".*" "\\1" QWT_VERSION_STRING "${_VERSION_LINE}" ) - string ( REGEX REPLACE "([0-9]+)\\.([0-9]+)\\.([0-9]+)" "\\1" QWT_MAJOR_VERSION "${QWT_VERSION_STRING}" ) - string ( REGEX REPLACE "([0-9]+)\\.([0-9]+)\\.([0-9]+)" "\\2" QWT_MINOR_VERSION "${QWT_VERSION_STRING}" ) - string ( REGEX REPLACE "([0-9]+)\\.([0-9]+)\\.([0-9]+)" "\\3" QWT_PATCH_VERSION "${QWT_VERSION_STRING}" ) - endif () -endif () - - -# check version -set ( _QWT_VERSION_MATCH TRUE ) -if ( Qwt_FIND_VERSION AND QWT_VERSION_STRING ) - if ( Qwt_FIND_VERSION_EXACT ) - if ( NOT Qwt_FIND_VERSION VERSION_EQUAL QWT_VERSION_STRING ) - set ( _QWT_VERSION_MATCH FALSE ) - endif () - else () - if ( QWT_VERSION_STRING VERSION_LESS Qwt_FIND_VERSION ) - set ( _QWT_VERSION_MATCH FALSE ) - endif () - endif () -endif () - - -find_library ( QWT_LIBRARY - NAMES qwt qwt-qt3 qwt-qt4 qwt-qt5 - HINTS $ENV{QWTDIR}/lib ${QT_LIBRARY_DIR} -) - -set ( QWT_LIBRARIES ${QWT_LIBRARY} ) - - -# try to guess root dir from include dir -if ( QWT_INCLUDE_DIR ) - string ( REGEX REPLACE "(.*)/include.*" "\\1" QWT_ROOT_DIR ${QWT_INCLUDE_DIR} ) -# try to guess root dir from library dir -elseif ( QWT_LIBRARY ) - string ( REGEX REPLACE "(.*)/lib[/|32|64].*" "\\1" QWT_ROOT_DIR ${QWT_LIBRARY} ) -endif () - - -# handle the QUIETLY and REQUIRED arguments -include ( FindPackageHandleStandardArgs ) -if ( CMAKE_VERSION LESS 2.8.3 ) - find_package_handle_standard_args( Qwt DEFAULT_MSG QWT_LIBRARY QWT_INCLUDE_DIR _QWT_VERSION_MATCH ) -else () - find_package_handle_standard_args( Qwt REQUIRED_VARS QWT_LIBRARY QWT_INCLUDE_DIR _QWT_VERSION_MATCH VERSION_VAR QWT_VERSION_STRING ) -endif () - - -mark_as_advanced ( - QWT_LIBRARY - QWT_LIBRARIES - QWT_INCLUDE_DIR - QWT_INCLUDE_DIRS - QWT_MAJOR_VERSION - QWT_MINOR_VERSION - QWT_PATCH_VERSION - QWT_VERSION_STRING - QWT_ROOT_DIR -) diff --git a/cmake/FindROOT.cmake b/cmake/FindROOT.cmake deleted file mode 100644 index 80662ab0e..000000000 --- a/cmake/FindROOT.cmake +++ /dev/null @@ -1,167 +0,0 @@ -# - Finds ROOT instalation -# This module sets up ROOT information -# It defines: -# ROOT_FOUND If the ROOT is found -# ROOT_INCLUDE_DIR PATH to the include directory -# ROOT_LIBRARIES Most common libraries -# ROOT_GUI_LIBRARIES Most common libraries + GUI -# ROOT_LIBRARY_DIR PATH to the library directory - - -find_program(ROOT_CONFIG_EXECUTABLE root-config - PATHS $ENV{ROOTSYS}/bin) - -if(NOT ROOT_CONFIG_EXECUTABLE) - set(ROOT_FOUND FALSE) -else() - set(ROOT_FOUND TRUE) - - execute_process( - COMMAND ${ROOT_CONFIG_EXECUTABLE} --prefix - OUTPUT_VARIABLE ROOTSYS - OUTPUT_STRIP_TRAILING_WHITESPACE) - - execute_process( - COMMAND ${ROOT_CONFIG_EXECUTABLE} --version - OUTPUT_VARIABLE ROOT_VERSION - OUTPUT_STRIP_TRAILING_WHITESPACE) - - execute_process( - COMMAND ${ROOT_CONFIG_EXECUTABLE} --incdir - OUTPUT_VARIABLE ROOT_INCLUDE_DIR - OUTPUT_STRIP_TRAILING_WHITESPACE) - - execute_process( - COMMAND ${ROOT_CONFIG_EXECUTABLE} --libs - OUTPUT_VARIABLE ROOT_LIBRARIES - OUTPUT_STRIP_TRAILING_WHITESPACE) - - execute_process( - COMMAND ${ROOT_CONFIG_EXECUTABLE} --glibs - OUTPUT_VARIABLE ROOT_GUI_LIBRARIES - OUTPUT_STRIP_TRAILING_WHITESPACE) - - #set(ROOT_LIBRARIES ${ROOT_LIBRARIES} -lThread -lMinuit -lHtml -lVMC -lEG -lGeom -lTreePlayer -lXMLIO -lProof) - #set(ROOT_LIBRARIES ${ROOT_LIBRARIES} -lProofPlayer -lMLP -lSpectrum -lEve -lRGL -lGed -lXMLParser -lPhysics) - set(ROOT_LIBRARY_DIR ${ROOTSYS}/lib) - - # Make variables changeble to the advanced user - mark_as_advanced(ROOT_CONFIG_EXECUTABLE) - - if(NOT ROOT_FIND_QUIETLY) - message(STATUS "Found ROOT ${ROOT_VERSION} in ${ROOTSYS}") - endif() -endif() - - -include(CMakeParseArguments) -find_program(ROOTCINT_EXECUTABLE rootcint PATHS $ENV{ROOTSYS}/bin) -find_program(GENREFLEX_EXECUTABLE genreflex PATHS $ENV{ROOTSYS}/bin) -find_package(GCCXML) - -#---------------------------------------------------------------------------- -# function ROOT_GENERATE_DICTIONARY( dictionary -# header1 header2 ... -# LINKDEF linkdef1 ... -# OPTIONS opt1...) -function(ROOT_GENERATE_DICTIONARY dictionary) - CMAKE_PARSE_ARGUMENTS(ARG "" "" "LINKDEF;OPTIONS" "" ${ARGN}) - #---Get the list of header files------------------------- - set(headerfiles) - foreach(fp ${ARG_UNPARSED_ARGUMENTS}) - file(GLOB files ${fp}) - if(files) - foreach(f ${files}) - if(NOT f MATCHES LinkDef) - set(headerfiles ${headerfiles} ${f}) - endif() - endforeach() - else() - set(headerfiles ${headerfiles} ${fp}) - endif() - endforeach() - #---Get the list of include directories------------------ - get_directory_property(incdirs INCLUDE_DIRECTORIES) - set(includedirs) - foreach( d ${incdirs}) - set(includedirs ${includedirs} -I${d}) - endforeach() - #---Get LinkDef.h file------------------------------------ - set(linkdefs) - foreach( f ${ARG_LINKDEF}) - if( IS_ABSOLUTE ${f}) - set(linkdefs ${linkdefs} ${f}) - else() - if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/inc/${f}) - set(linkdefs ${linkdefs} ${CMAKE_CURRENT_SOURCE_DIR}/inc/${f}) - else() - set(linkdefs ${linkdefs} ${CMAKE_CURRENT_SOURCE_DIR}/${f}) - endif() - endif() - endforeach() - #---call rootcint------------------------------------------ - add_custom_command(OUTPUT ${dictionary}.cxx ${dictionary}.h - COMMAND ${ROOTCINT_EXECUTABLE} -cint -f ${dictionary}.cxx - -c ${ARG_OPTIONS} ${includedirs} ${headerfiles} ${linkdefs} - DEPENDS ${headerfiles} ${linkdefs}) -endfunction() - -#---------------------------------------------------------------------------- -# function REFLEX_GENERATE_DICTIONARY(dictionary -# header1 header2 ... -# SELECTION selectionfile ... -# OPTIONS opt1...) -function(REFLEX_GENERATE_DICTIONARY dictionary) - CMAKE_PARSE_ARGUMENTS(ARG "" "" "SELECTION;OPTIONS" "" ${ARGN}) - #---Get the list of header files------------------------- - set(headerfiles) - foreach(fp ${ARG_UNPARSED_ARGUMENTS}) - file(GLOB files ${fp}) - if(files) - foreach(f ${files}) - set(headerfiles ${headerfiles} ${f}) - endforeach() - else() - set(headerfiles ${headerfiles} ${fp}) - endif() - endforeach() - #---Get Selection file------------------------------------ - if(IS_ABSOLUTE ${ARG_SELECTION}) - set(selectionfile ${ARG_SELECTION}) - else() - set(selectionfile ${CMAKE_CURRENT_SOURCE_DIR}/${ARG_SELECTION}) - endif() - #---Get the list of include directories------------------ - get_directory_property(incdirs INCLUDE_DIRECTORIES) - set(includedirs) - foreach( d ${incdirs}) - set(includedirs ${includedirs} -I${d}) - endforeach() - #---Get preprocessor definitions-------------------------- - get_directory_property(defs COMPILE_DEFINITIONS) - foreach( d ${defs}) - set(definitions ${definitions} -D${d}) - endforeach() - #---Nanes and others--------------------------------------- - set(gensrcdict ${dictionary}.cpp) - if(MSVC) - set(gccxmlopts "--gccxmlopt=\"--gccxml-compiler cl\"") - else() - #set(gccxmlopts "--gccxmlopt=\'--gccxml-cxxflags -m64 \'") - set(gccxmlopts) - endif() - #set(rootmapname ${dictionary}Dict.rootmap) - #set(rootmapopts --rootmap=${rootmapname} --rootmap-lib=${libprefix}${dictionary}Dict) - #---Check GCCXML and get path----------------------------- - if(GCCXML) - get_filename_component(gccxmlpath ${GCCXML} PATH) - else() - message(WARNING "GCCXML not found. Install and setup your environment to find 'gccxml' executable") - endif() - #---Actual command---------------------------------------- - add_custom_command(OUTPUT ${gensrcdict} ${rootmapname} - COMMAND ${GENREFLEX_EXECUTABLE} ${headerfiles} -o ${gensrcdict} ${gccxmlopts} ${rootmapopts} --select=${selectionfile} - --gccxmlpath=${gccxmlpath} ${ARG_OPTIONS} ${includedirs} ${definitions} - DEPENDS ${headerfiles} ${selectionfile}) -endfunction() - diff --git a/cmk.sh b/cmk.sh deleted file mode 100755 index d73649f99..000000000 --- a/cmk.sh +++ /dev/null @@ -1,204 +0,0 @@ -#!/bin/bash -BUILDDIR="build" -HDF5DIR="/opt/hdf5v1.10.0" -HDF5=0 -COMPILERTHREADS=0 -TEXTCLIENT=0 -RECEIVER=0 -GUI=0 -DEBUG=0 - - -CLEAN=0 -REBUILD=0 -CMAKE_PRE="" -CMAKE_POST="" - -usage() { echo -e " -Usage: $0 [-c] [-b] [-h] [-d ] [-j] - -[no option]: only make - -c: Clean - -b: Builds/Rebuilds CMake files normal mode - -h: Builds/Rebuilds Cmake files with HDF5 package - -d: HDF5 Custom Directory - -t: Build/Rebuilds only text client - -r: Build/Rebuilds only receiver - -g: Build/Rebuilds only gui - -j: Number of threads to compile through - -e: Debug mode - -For only make: -./cmk.sh - -For make clean;make: -./cmk.sh -c - -For using hdf5 without default dir /opt/hdf5v1.10.0: -./cmk.sh -h - -For using hdf5 without custom dir /blabla: -./cmk.sh -h -d /blabla - -For rebuilding cmake without hdf5 (Use this if you had previously run with hdf5 and now you dont want it) -./cmk.sh -b - -For using multiple cores to compile faster: -(all these options work) -./cmk.sh -j9 -./cmk.sh -cj9 #with clean -./cmk.sh -hj9 #with hdf5 -./cmk.sh -j9 -h #with hdf - -For rebuilding only certain sections -./cmk.sh -tg #only text client and gui -./cmk.sh -r #only receiver - - " ; exit 1; } - -while getopts ":bchd:j:trge" opt ; do - case $opt in - b) - echo "Building of CMake files Required" - REBUILD=1 - ;; - c) - echo "Clean Required" - CLEAN=1 - ;; - h) - echo "Building of CMake files with HDF5 option Required" - HDF5=1 - REBUILD=1 - ;; - d) - echo "New HDF5 directory: $OPTARG" - HDF5DIR=$OPTARG - ;; - j) - echo "Number of compiler threads: $OPTARG" - COMPILERTHREADS=$OPTARG - ;; - t) - echo "Compiling Options: Text Client" - TEXTCLIENT=1 - REBUILD=1 - ;; - r) - echo "Compiling Options: Receiver" - RECEIVER=1 - REBUILD=1 - ;; - g) - echo "Compiling Options: GUI" - GUI=1 - REBUILD=1 - ;; - e) - echo "Compiling Options: Debug" - DEBUG=1 - ;; - \?) - echo "Invalid option: -$OPTARG" - usage - exit 1 - ;; - :) - echo "Option -$OPTARG requires an argument." - usage - exit 1 - ;; - esac -done - - - - - - -if [ $TEXTCLIENT -eq 0 ] && [ $RECEIVER -eq 0 ] && [ $GUI -eq 0 ]; then - CMAKE_POST+=" -DSLS_USE_TEXTCLIENT=ON -DSLS_USE_RECEIVER=ON -DSLS_USE_GUI=ON " - echo "Compile Option: TextClient, Receiver and GUI" -else - if [ $TEXTCLIENT -eq 1 ]; then - CMAKE_POST+=" -DSLS_USE_TEXTCLIENT=ON " - echo "Compile Option: TextClient" - fi - if [ $RECEIVER -eq 1 ]; then - CMAKE_POST+=" -DSLS_USE_RECEIVER=ON " - echo "Compile Option: Receiver" - fi - - if [ $GUI -eq 1 ]; then - CMAKE_POST+=" -DSLS_USE_GUI=ON " - echo "Compile Option: GUI" - fi -fi - - - - - -#build dir doesnt exist -if [ ! -d "$BUILDDIR" ] ; then - echo "No Build Directory. Building of Cmake files required" - mkdir $BUILDDIR; - REBUILD=1 -else - #rebuild not requested, but no makefile - if [ $REBUILD -eq 0 ] && [ ! -f "$BUILDDIR/Makefile" ] ; then - echo "No Makefile. Building of Cmake files required" - REBUILD=1 - fi -fi - -#Debug -if [ $DEBUG -eq 1 ]; then - CMAKE_POST+=" -DCMAKE_BUILD_TYPE=Debug " - echo "Debug Option enabled" -fi - - -#hdf5 rebuild -if [ $HDF5 -eq 1 ]; then - CMAKE_PRE+="HDF5_ROOT="$HDF5DIR - CMAKE_POST+=" -DSLS_USE_HDF5=ON " -#normal mode rebuild -else - CMAKE_POST+=" -DSLS_USE_HDF5=OFF " -fi - - -#enter build dir -cd $BUILDDIR; -echo "in "$PWD - - - -#cmake -if [ $REBUILD -eq 1 ]; then - rm -f CMakeCache.txt - BUILDCOMMAND="$CMAKE_PRE cmake $CMAKE_POST .." - echo $BUILDCOMMAND - eval $BUILDCOMMAND -fi - -#make clean -if [ $CLEAN -eq 1 ]; then - make clean; -fi - - -#make -if [ $COMPILERTHREADS -gt 0 ]; then - BUILDCOMMAND="make -j$COMPILERTHREADS" - echo $BUILDCOMMAND - eval $BUILDCOMMAND -else - make -fi - - - - - - diff --git a/commitVersions.sh b/commitVersions.sh deleted file mode 100644 index a3cbc5f44..000000000 --- a/commitVersions.sh +++ /dev/null @@ -1,15 +0,0 @@ -sh updateSvnVersion.sh - -cd slsDetectorGui -git commit -a -m "updating versions" -git push origin developer:developer - -cd ../slsDetectorSoftware -git commit -a -m "updating versions" -git push origin developer:developer - -cd ../slsReceiverSoftware -git commit -a -m "updating versions" -git push origin developer:developer - -cd .. diff --git a/configure b/configure deleted file mode 100755 index a58728f9f..000000000 --- a/configure +++ /dev/null @@ -1,58 +0,0 @@ -##!/bin/bash - -: ${INSTALLROOT=$PWD} -read -p "Installation directory [default:\"$INSTALLROOT\"]:" -e t3 -if [ -z "$t3" ] -then -echo -else - INSTALLROOT=$t3 -fi -echo "INSTALLROOT will be \"$INSTALLROOT\"" -export INSTALLROOT - -: ${BINDIR="bin"} -read -p "Binaries directory [default:\"$BINDIR\"]:" -e t4 -if [ -z "$t4" ] -then - BINDIR=$INSTALLROOT/$BINDIR -else - BINDIR=$INSTALLROOT/$t4 -fi -echo "BINDIR will be \"$BINDIR\"" -export BINDIR - -: ${LIBDIR="bin"} -read -p "Libraries directory [default:\"$LIBDIR\"]:" -e t5 -if [ -z "$t5" ] -then - LIBDIR=$INSTALLROOT/$LIBDIR -else - LIBDIR=$INSTALLROOT/$t5 -fi -echo "LIBDIR will be \"$LIBDIR\"" -export LIBDIR - -: ${INCDIR="include"} -read -p "Includes directory [default:\"$INCDIR\"]:" -e t6 -if [ -z "$t6" ] -then - INCDIR=$INSTALLROOT/$INCDIR -else - INCDIR=$INSTALLROOT/$t6 -fi -echo "INCDIR will be \"$INCDIR\"" -export INCDIR - -: ${DOCDIR="doc"} -read -p "Documentation directory [default:\"$DOCDIR\"]:" -e t7 -if [ -z "$t7" ] -then - DOCDIR=$INSTALLROOT/$DOCDIR -else - DOCDIR=$INSTALLROOT/$t7 -fi -echo "DOCDIR will be \"$DOCDIR\"" -export DOCDIR - - diff --git a/manual/docs/html/angularCalibrationHowTo/WARNINGS b/docs/html/angularCalibrationHowTo/WARNINGS similarity index 100% rename from manual/docs/html/angularCalibrationHowTo/WARNINGS rename to docs/html/angularCalibrationHowTo/WARNINGS diff --git a/manual/docs/html/angularCalibrationHowTo/angularCalibrationHowTo.css b/docs/html/angularCalibrationHowTo/angularCalibrationHowTo.css similarity index 100% rename from manual/docs/html/angularCalibrationHowTo/angularCalibrationHowTo.css rename to docs/html/angularCalibrationHowTo/angularCalibrationHowTo.css diff --git a/manual/docs/html/angularCalibrationHowTo/angularCalibrationHowTo.html b/docs/html/angularCalibrationHowTo/angularCalibrationHowTo.html similarity index 100% rename from manual/docs/html/angularCalibrationHowTo/angularCalibrationHowTo.html rename to docs/html/angularCalibrationHowTo/angularCalibrationHowTo.html diff --git a/manual/docs/html/angularCalibrationHowTo/images.aux b/docs/html/angularCalibrationHowTo/images.aux similarity index 100% rename from manual/docs/html/angularCalibrationHowTo/images.aux rename to docs/html/angularCalibrationHowTo/images.aux diff --git a/manual/docs/html/angularCalibrationHowTo/images.log b/docs/html/angularCalibrationHowTo/images.log similarity index 100% rename from manual/docs/html/angularCalibrationHowTo/images.log rename to docs/html/angularCalibrationHowTo/images.log diff --git a/manual/docs/html/angularCalibrationHowTo/images.pl b/docs/html/angularCalibrationHowTo/images.pl similarity index 100% rename from manual/docs/html/angularCalibrationHowTo/images.pl rename to docs/html/angularCalibrationHowTo/images.pl diff --git a/manual/docs/html/angularCalibrationHowTo/images.tex b/docs/html/angularCalibrationHowTo/images.tex similarity index 100% rename from manual/docs/html/angularCalibrationHowTo/images.tex rename to docs/html/angularCalibrationHowTo/images.tex diff --git a/manual/docs/html/angularCalibrationHowTo/img1.png b/docs/html/angularCalibrationHowTo/img1.png similarity index 100% rename from manual/docs/html/angularCalibrationHowTo/img1.png rename to docs/html/angularCalibrationHowTo/img1.png diff --git a/manual/docs/html/angularCalibrationHowTo/img10.png b/docs/html/angularCalibrationHowTo/img10.png similarity index 100% rename from manual/docs/html/angularCalibrationHowTo/img10.png rename to docs/html/angularCalibrationHowTo/img10.png diff --git a/manual/docs/html/angularCalibrationHowTo/img11.png b/docs/html/angularCalibrationHowTo/img11.png similarity index 100% rename from manual/docs/html/angularCalibrationHowTo/img11.png rename to docs/html/angularCalibrationHowTo/img11.png diff --git a/manual/docs/html/angularCalibrationHowTo/img12.png b/docs/html/angularCalibrationHowTo/img12.png similarity index 100% rename from manual/docs/html/angularCalibrationHowTo/img12.png rename to docs/html/angularCalibrationHowTo/img12.png diff --git a/manual/docs/html/angularCalibrationHowTo/img13.png b/docs/html/angularCalibrationHowTo/img13.png similarity index 100% rename from manual/docs/html/angularCalibrationHowTo/img13.png rename to docs/html/angularCalibrationHowTo/img13.png diff --git a/manual/docs/html/angularCalibrationHowTo/img14.png b/docs/html/angularCalibrationHowTo/img14.png similarity index 100% rename from manual/docs/html/angularCalibrationHowTo/img14.png rename to docs/html/angularCalibrationHowTo/img14.png diff --git a/manual/docs/html/angularCalibrationHowTo/img15.png b/docs/html/angularCalibrationHowTo/img15.png similarity index 100% rename from manual/docs/html/angularCalibrationHowTo/img15.png rename to docs/html/angularCalibrationHowTo/img15.png diff --git a/manual/docs/html/angularCalibrationHowTo/img16.png b/docs/html/angularCalibrationHowTo/img16.png similarity index 100% rename from manual/docs/html/angularCalibrationHowTo/img16.png rename to docs/html/angularCalibrationHowTo/img16.png diff --git a/manual/docs/html/angularCalibrationHowTo/img17.png b/docs/html/angularCalibrationHowTo/img17.png similarity index 100% rename from manual/docs/html/angularCalibrationHowTo/img17.png rename to docs/html/angularCalibrationHowTo/img17.png diff --git a/manual/docs/html/angularCalibrationHowTo/img18.png b/docs/html/angularCalibrationHowTo/img18.png similarity index 100% rename from manual/docs/html/angularCalibrationHowTo/img18.png rename to docs/html/angularCalibrationHowTo/img18.png diff --git a/manual/docs/html/angularCalibrationHowTo/img2.png b/docs/html/angularCalibrationHowTo/img2.png similarity index 100% rename from manual/docs/html/angularCalibrationHowTo/img2.png rename to docs/html/angularCalibrationHowTo/img2.png diff --git a/manual/docs/html/angularCalibrationHowTo/img3.png b/docs/html/angularCalibrationHowTo/img3.png similarity index 100% rename from manual/docs/html/angularCalibrationHowTo/img3.png rename to docs/html/angularCalibrationHowTo/img3.png diff --git a/manual/docs/html/angularCalibrationHowTo/img4.png b/docs/html/angularCalibrationHowTo/img4.png similarity index 100% rename from manual/docs/html/angularCalibrationHowTo/img4.png rename to docs/html/angularCalibrationHowTo/img4.png diff --git a/manual/docs/html/angularCalibrationHowTo/img5.png b/docs/html/angularCalibrationHowTo/img5.png similarity index 100% rename from manual/docs/html/angularCalibrationHowTo/img5.png rename to docs/html/angularCalibrationHowTo/img5.png diff --git a/manual/docs/html/angularCalibrationHowTo/img6.png b/docs/html/angularCalibrationHowTo/img6.png similarity index 100% rename from manual/docs/html/angularCalibrationHowTo/img6.png rename to docs/html/angularCalibrationHowTo/img6.png diff --git a/manual/docs/html/angularCalibrationHowTo/img7.png b/docs/html/angularCalibrationHowTo/img7.png similarity index 100% rename from manual/docs/html/angularCalibrationHowTo/img7.png rename to docs/html/angularCalibrationHowTo/img7.png diff --git a/manual/docs/html/angularCalibrationHowTo/img8.png b/docs/html/angularCalibrationHowTo/img8.png similarity index 100% rename from manual/docs/html/angularCalibrationHowTo/img8.png rename to docs/html/angularCalibrationHowTo/img8.png diff --git a/manual/docs/html/angularCalibrationHowTo/img9.png b/docs/html/angularCalibrationHowTo/img9.png similarity index 100% rename from manual/docs/html/angularCalibrationHowTo/img9.png rename to docs/html/angularCalibrationHowTo/img9.png diff --git a/manual/docs/html/angularCalibrationHowTo/index.html b/docs/html/angularCalibrationHowTo/index.html similarity index 100% rename from manual/docs/html/angularCalibrationHowTo/index.html rename to docs/html/angularCalibrationHowTo/index.html diff --git a/manual/docs/html/angularCalibrationHowTo/internals.pl b/docs/html/angularCalibrationHowTo/internals.pl similarity index 100% rename from manual/docs/html/angularCalibrationHowTo/internals.pl rename to docs/html/angularCalibrationHowTo/internals.pl diff --git a/manual/docs/html/angularCalibrationHowTo/labels.pl b/docs/html/angularCalibrationHowTo/labels.pl similarity index 100% rename from manual/docs/html/angularCalibrationHowTo/labels.pl rename to docs/html/angularCalibrationHowTo/labels.pl diff --git a/manual/docs/html/angularCalibrationHowTo/node1.html b/docs/html/angularCalibrationHowTo/node1.html similarity index 100% rename from manual/docs/html/angularCalibrationHowTo/node1.html rename to docs/html/angularCalibrationHowTo/node1.html diff --git a/manual/docs/html/angularCalibrationHowTo/node2.html b/docs/html/angularCalibrationHowTo/node2.html similarity index 100% rename from manual/docs/html/angularCalibrationHowTo/node2.html rename to docs/html/angularCalibrationHowTo/node2.html diff --git a/manual/docs/html/angularCalibrationHowTo/node3.html b/docs/html/angularCalibrationHowTo/node3.html similarity index 100% rename from manual/docs/html/angularCalibrationHowTo/node3.html rename to docs/html/angularCalibrationHowTo/node3.html diff --git a/manual/docs/html/angularCalibrationHowTo/node4.html b/docs/html/angularCalibrationHowTo/node4.html similarity index 100% rename from manual/docs/html/angularCalibrationHowTo/node4.html rename to docs/html/angularCalibrationHowTo/node4.html diff --git a/manual/docs/html/angularCalibrationHowTo/node5.html b/docs/html/angularCalibrationHowTo/node5.html similarity index 100% rename from manual/docs/html/angularCalibrationHowTo/node5.html rename to docs/html/angularCalibrationHowTo/node5.html diff --git a/manual/docs/html/energyCalibrationHowTo/WARNINGS b/docs/html/energyCalibrationHowTo/WARNINGS similarity index 100% rename from manual/docs/html/energyCalibrationHowTo/WARNINGS rename to docs/html/energyCalibrationHowTo/WARNINGS diff --git a/manual/docs/html/energyCalibrationHowTo/energyCalibrationHowTo.css b/docs/html/energyCalibrationHowTo/energyCalibrationHowTo.css similarity index 100% rename from manual/docs/html/energyCalibrationHowTo/energyCalibrationHowTo.css rename to docs/html/energyCalibrationHowTo/energyCalibrationHowTo.css diff --git a/manual/docs/html/energyCalibrationHowTo/energyCalibrationHowTo.html b/docs/html/energyCalibrationHowTo/energyCalibrationHowTo.html similarity index 100% rename from manual/docs/html/energyCalibrationHowTo/energyCalibrationHowTo.html rename to docs/html/energyCalibrationHowTo/energyCalibrationHowTo.html diff --git a/manual/docs/html/energyCalibrationHowTo/images.aux b/docs/html/energyCalibrationHowTo/images.aux similarity index 100% rename from manual/docs/html/energyCalibrationHowTo/images.aux rename to docs/html/energyCalibrationHowTo/images.aux diff --git a/manual/docs/html/energyCalibrationHowTo/images.log b/docs/html/energyCalibrationHowTo/images.log similarity index 100% rename from manual/docs/html/energyCalibrationHowTo/images.log rename to docs/html/energyCalibrationHowTo/images.log diff --git a/manual/docs/html/energyCalibrationHowTo/images.pl b/docs/html/energyCalibrationHowTo/images.pl similarity index 100% rename from manual/docs/html/energyCalibrationHowTo/images.pl rename to docs/html/energyCalibrationHowTo/images.pl diff --git a/manual/docs/html/energyCalibrationHowTo/images.tex b/docs/html/energyCalibrationHowTo/images.tex similarity index 100% rename from manual/docs/html/energyCalibrationHowTo/images.tex rename to docs/html/energyCalibrationHowTo/images.tex diff --git a/manual/docs/html/energyCalibrationHowTo/img1.png b/docs/html/energyCalibrationHowTo/img1.png similarity index 100% rename from manual/docs/html/energyCalibrationHowTo/img1.png rename to docs/html/energyCalibrationHowTo/img1.png diff --git a/manual/docs/html/energyCalibrationHowTo/img10.png b/docs/html/energyCalibrationHowTo/img10.png similarity index 100% rename from manual/docs/html/energyCalibrationHowTo/img10.png rename to docs/html/energyCalibrationHowTo/img10.png diff --git a/manual/docs/html/energyCalibrationHowTo/img11.png b/docs/html/energyCalibrationHowTo/img11.png similarity index 100% rename from manual/docs/html/energyCalibrationHowTo/img11.png rename to docs/html/energyCalibrationHowTo/img11.png diff --git a/manual/docs/html/energyCalibrationHowTo/img12.png b/docs/html/energyCalibrationHowTo/img12.png similarity index 100% rename from manual/docs/html/energyCalibrationHowTo/img12.png rename to docs/html/energyCalibrationHowTo/img12.png diff --git a/manual/docs/html/energyCalibrationHowTo/img13.png b/docs/html/energyCalibrationHowTo/img13.png similarity index 100% rename from manual/docs/html/energyCalibrationHowTo/img13.png rename to docs/html/energyCalibrationHowTo/img13.png diff --git a/manual/docs/html/energyCalibrationHowTo/img14.png b/docs/html/energyCalibrationHowTo/img14.png similarity index 100% rename from manual/docs/html/energyCalibrationHowTo/img14.png rename to docs/html/energyCalibrationHowTo/img14.png diff --git a/manual/docs/html/energyCalibrationHowTo/img15.png b/docs/html/energyCalibrationHowTo/img15.png similarity index 100% rename from manual/docs/html/energyCalibrationHowTo/img15.png rename to docs/html/energyCalibrationHowTo/img15.png diff --git a/manual/docs/html/energyCalibrationHowTo/img16.png b/docs/html/energyCalibrationHowTo/img16.png similarity index 100% rename from manual/docs/html/energyCalibrationHowTo/img16.png rename to docs/html/energyCalibrationHowTo/img16.png diff --git a/manual/docs/html/energyCalibrationHowTo/img17.png b/docs/html/energyCalibrationHowTo/img17.png similarity index 100% rename from manual/docs/html/energyCalibrationHowTo/img17.png rename to docs/html/energyCalibrationHowTo/img17.png diff --git a/manual/docs/html/energyCalibrationHowTo/img18.png b/docs/html/energyCalibrationHowTo/img18.png similarity index 100% rename from manual/docs/html/energyCalibrationHowTo/img18.png rename to docs/html/energyCalibrationHowTo/img18.png diff --git a/manual/docs/html/energyCalibrationHowTo/img19.png b/docs/html/energyCalibrationHowTo/img19.png similarity index 100% rename from manual/docs/html/energyCalibrationHowTo/img19.png rename to docs/html/energyCalibrationHowTo/img19.png diff --git a/manual/docs/html/energyCalibrationHowTo/img2.png b/docs/html/energyCalibrationHowTo/img2.png similarity index 100% rename from manual/docs/html/energyCalibrationHowTo/img2.png rename to docs/html/energyCalibrationHowTo/img2.png diff --git a/manual/docs/html/energyCalibrationHowTo/img20.png b/docs/html/energyCalibrationHowTo/img20.png similarity index 100% rename from manual/docs/html/energyCalibrationHowTo/img20.png rename to docs/html/energyCalibrationHowTo/img20.png diff --git a/manual/docs/html/energyCalibrationHowTo/img21.png b/docs/html/energyCalibrationHowTo/img21.png similarity index 100% rename from manual/docs/html/energyCalibrationHowTo/img21.png rename to docs/html/energyCalibrationHowTo/img21.png diff --git a/manual/docs/html/energyCalibrationHowTo/img22.png b/docs/html/energyCalibrationHowTo/img22.png similarity index 100% rename from manual/docs/html/energyCalibrationHowTo/img22.png rename to docs/html/energyCalibrationHowTo/img22.png diff --git a/manual/docs/html/energyCalibrationHowTo/img23.png b/docs/html/energyCalibrationHowTo/img23.png similarity index 100% rename from manual/docs/html/energyCalibrationHowTo/img23.png rename to docs/html/energyCalibrationHowTo/img23.png diff --git a/manual/docs/html/energyCalibrationHowTo/img24.png b/docs/html/energyCalibrationHowTo/img24.png similarity index 100% rename from manual/docs/html/energyCalibrationHowTo/img24.png rename to docs/html/energyCalibrationHowTo/img24.png diff --git a/manual/docs/html/energyCalibrationHowTo/img25.png b/docs/html/energyCalibrationHowTo/img25.png similarity index 100% rename from manual/docs/html/energyCalibrationHowTo/img25.png rename to docs/html/energyCalibrationHowTo/img25.png diff --git a/manual/docs/html/energyCalibrationHowTo/img26.png b/docs/html/energyCalibrationHowTo/img26.png similarity index 100% rename from manual/docs/html/energyCalibrationHowTo/img26.png rename to docs/html/energyCalibrationHowTo/img26.png diff --git a/manual/docs/html/energyCalibrationHowTo/img27.png b/docs/html/energyCalibrationHowTo/img27.png similarity index 100% rename from manual/docs/html/energyCalibrationHowTo/img27.png rename to docs/html/energyCalibrationHowTo/img27.png diff --git a/manual/docs/html/energyCalibrationHowTo/img28.png b/docs/html/energyCalibrationHowTo/img28.png similarity index 100% rename from manual/docs/html/energyCalibrationHowTo/img28.png rename to docs/html/energyCalibrationHowTo/img28.png diff --git a/manual/docs/html/energyCalibrationHowTo/img29.png b/docs/html/energyCalibrationHowTo/img29.png similarity index 100% rename from manual/docs/html/energyCalibrationHowTo/img29.png rename to docs/html/energyCalibrationHowTo/img29.png diff --git a/manual/docs/html/energyCalibrationHowTo/img3.png b/docs/html/energyCalibrationHowTo/img3.png similarity index 100% rename from manual/docs/html/energyCalibrationHowTo/img3.png rename to docs/html/energyCalibrationHowTo/img3.png diff --git a/manual/docs/html/energyCalibrationHowTo/img30.png b/docs/html/energyCalibrationHowTo/img30.png similarity index 100% rename from manual/docs/html/energyCalibrationHowTo/img30.png rename to docs/html/energyCalibrationHowTo/img30.png diff --git a/manual/docs/html/energyCalibrationHowTo/img31.png b/docs/html/energyCalibrationHowTo/img31.png similarity index 100% rename from manual/docs/html/energyCalibrationHowTo/img31.png rename to docs/html/energyCalibrationHowTo/img31.png diff --git a/manual/docs/html/energyCalibrationHowTo/img32.png b/docs/html/energyCalibrationHowTo/img32.png similarity index 100% rename from manual/docs/html/energyCalibrationHowTo/img32.png rename to docs/html/energyCalibrationHowTo/img32.png diff --git a/manual/docs/html/energyCalibrationHowTo/img33.png b/docs/html/energyCalibrationHowTo/img33.png similarity index 100% rename from manual/docs/html/energyCalibrationHowTo/img33.png rename to docs/html/energyCalibrationHowTo/img33.png diff --git a/manual/docs/html/energyCalibrationHowTo/img34.png b/docs/html/energyCalibrationHowTo/img34.png similarity index 100% rename from manual/docs/html/energyCalibrationHowTo/img34.png rename to docs/html/energyCalibrationHowTo/img34.png diff --git a/manual/docs/html/energyCalibrationHowTo/img35.png b/docs/html/energyCalibrationHowTo/img35.png similarity index 100% rename from manual/docs/html/energyCalibrationHowTo/img35.png rename to docs/html/energyCalibrationHowTo/img35.png diff --git a/manual/docs/html/energyCalibrationHowTo/img36.png b/docs/html/energyCalibrationHowTo/img36.png similarity index 100% rename from manual/docs/html/energyCalibrationHowTo/img36.png rename to docs/html/energyCalibrationHowTo/img36.png diff --git a/manual/docs/html/energyCalibrationHowTo/img37.png b/docs/html/energyCalibrationHowTo/img37.png similarity index 100% rename from manual/docs/html/energyCalibrationHowTo/img37.png rename to docs/html/energyCalibrationHowTo/img37.png diff --git a/manual/docs/html/energyCalibrationHowTo/img38.png b/docs/html/energyCalibrationHowTo/img38.png similarity index 100% rename from manual/docs/html/energyCalibrationHowTo/img38.png rename to docs/html/energyCalibrationHowTo/img38.png diff --git a/manual/docs/html/energyCalibrationHowTo/img39.png b/docs/html/energyCalibrationHowTo/img39.png similarity index 100% rename from manual/docs/html/energyCalibrationHowTo/img39.png rename to docs/html/energyCalibrationHowTo/img39.png diff --git a/manual/docs/html/energyCalibrationHowTo/img4.png b/docs/html/energyCalibrationHowTo/img4.png similarity index 100% rename from manual/docs/html/energyCalibrationHowTo/img4.png rename to docs/html/energyCalibrationHowTo/img4.png diff --git a/manual/docs/html/energyCalibrationHowTo/img40.png b/docs/html/energyCalibrationHowTo/img40.png similarity index 100% rename from manual/docs/html/energyCalibrationHowTo/img40.png rename to docs/html/energyCalibrationHowTo/img40.png diff --git a/manual/docs/html/energyCalibrationHowTo/img5.png b/docs/html/energyCalibrationHowTo/img5.png similarity index 100% rename from manual/docs/html/energyCalibrationHowTo/img5.png rename to docs/html/energyCalibrationHowTo/img5.png diff --git a/manual/docs/html/energyCalibrationHowTo/img6.png b/docs/html/energyCalibrationHowTo/img6.png similarity index 100% rename from manual/docs/html/energyCalibrationHowTo/img6.png rename to docs/html/energyCalibrationHowTo/img6.png diff --git a/manual/docs/html/energyCalibrationHowTo/img7.png b/docs/html/energyCalibrationHowTo/img7.png similarity index 100% rename from manual/docs/html/energyCalibrationHowTo/img7.png rename to docs/html/energyCalibrationHowTo/img7.png diff --git a/manual/docs/html/energyCalibrationHowTo/img8.png b/docs/html/energyCalibrationHowTo/img8.png similarity index 100% rename from manual/docs/html/energyCalibrationHowTo/img8.png rename to docs/html/energyCalibrationHowTo/img8.png diff --git a/manual/docs/html/energyCalibrationHowTo/img9.png b/docs/html/energyCalibrationHowTo/img9.png similarity index 100% rename from manual/docs/html/energyCalibrationHowTo/img9.png rename to docs/html/energyCalibrationHowTo/img9.png diff --git a/manual/docs/html/energyCalibrationHowTo/index.html b/docs/html/energyCalibrationHowTo/index.html similarity index 100% rename from manual/docs/html/energyCalibrationHowTo/index.html rename to docs/html/energyCalibrationHowTo/index.html diff --git a/manual/docs/html/energyCalibrationHowTo/internals.pl b/docs/html/energyCalibrationHowTo/internals.pl similarity index 100% rename from manual/docs/html/energyCalibrationHowTo/internals.pl rename to docs/html/energyCalibrationHowTo/internals.pl diff --git a/manual/docs/html/energyCalibrationHowTo/labels.pl b/docs/html/energyCalibrationHowTo/labels.pl similarity index 100% rename from manual/docs/html/energyCalibrationHowTo/labels.pl rename to docs/html/energyCalibrationHowTo/labels.pl diff --git a/manual/docs/html/energyCalibrationHowTo/node1.html b/docs/html/energyCalibrationHowTo/node1.html similarity index 100% rename from manual/docs/html/energyCalibrationHowTo/node1.html rename to docs/html/energyCalibrationHowTo/node1.html diff --git a/manual/docs/html/energyCalibrationHowTo/node2.html b/docs/html/energyCalibrationHowTo/node2.html similarity index 100% rename from manual/docs/html/energyCalibrationHowTo/node2.html rename to docs/html/energyCalibrationHowTo/node2.html diff --git a/manual/docs/html/energyCalibrationHowTo/node3.html b/docs/html/energyCalibrationHowTo/node3.html similarity index 100% rename from manual/docs/html/energyCalibrationHowTo/node3.html rename to docs/html/energyCalibrationHowTo/node3.html diff --git a/manual/docs/html/energyCalibrationHowTo/node4.html b/docs/html/energyCalibrationHowTo/node4.html similarity index 100% rename from manual/docs/html/energyCalibrationHowTo/node4.html rename to docs/html/energyCalibrationHowTo/node4.html diff --git a/manual/docs/html/energyCalibrationHowTo/node5.html b/docs/html/energyCalibrationHowTo/node5.html similarity index 100% rename from manual/docs/html/energyCalibrationHowTo/node5.html rename to docs/html/energyCalibrationHowTo/node5.html diff --git a/manual/docs/html/slsDetectorClientDocs/acquisition.html b/docs/html/slsDetectorClientDocs/acquisition.html similarity index 100% rename from manual/docs/html/slsDetectorClientDocs/acquisition.html rename to docs/html/slsDetectorClientDocs/acquisition.html diff --git a/manual/docs/html/slsDetectorClientDocs/actions.html b/docs/html/slsDetectorClientDocs/actions.html similarity index 100% rename from manual/docs/html/slsDetectorClientDocs/actions.html rename to docs/html/slsDetectorClientDocs/actions.html diff --git a/manual/docs/html/slsDetectorClientDocs/advanced.html b/docs/html/slsDetectorClientDocs/advanced.html similarity index 100% rename from manual/docs/html/slsDetectorClientDocs/advanced.html rename to docs/html/slsDetectorClientDocs/advanced.html diff --git a/manual/docs/html/slsDetectorClientDocs/bc_s.png b/docs/html/slsDetectorClientDocs/bc_s.png similarity index 100% rename from manual/docs/html/slsDetectorClientDocs/bc_s.png rename to docs/html/slsDetectorClientDocs/bc_s.png diff --git a/manual/docs/html/slsDetectorClientDocs/bdwn.png b/docs/html/slsDetectorClientDocs/bdwn.png similarity index 100% rename from manual/docs/html/slsDetectorClientDocs/bdwn.png rename to docs/html/slsDetectorClientDocs/bdwn.png diff --git a/manual/docs/html/slsDetectorClientDocs/closed.png b/docs/html/slsDetectorClientDocs/closed.png similarity index 100% rename from manual/docs/html/slsDetectorClientDocs/closed.png rename to docs/html/slsDetectorClientDocs/closed.png diff --git a/manual/docs/html/slsDetectorClientDocs/config.html b/docs/html/slsDetectorClientDocs/config.html similarity index 100% rename from manual/docs/html/slsDetectorClientDocs/config.html rename to docs/html/slsDetectorClientDocs/config.html diff --git a/manual/docs/html/slsDetectorClientDocs/ctb.html b/docs/html/slsDetectorClientDocs/ctb.html similarity index 100% rename from manual/docs/html/slsDetectorClientDocs/ctb.html rename to docs/html/slsDetectorClientDocs/ctb.html diff --git a/manual/docs/html/slsDetectorClientDocs/data.html b/docs/html/slsDetectorClientDocs/data.html similarity index 100% rename from manual/docs/html/slsDetectorClientDocs/data.html rename to docs/html/slsDetectorClientDocs/data.html diff --git a/manual/docs/html/slsDetectorClientDocs/doxygen.css b/docs/html/slsDetectorClientDocs/doxygen.css similarity index 100% rename from manual/docs/html/slsDetectorClientDocs/doxygen.css rename to docs/html/slsDetectorClientDocs/doxygen.css diff --git a/manual/docs/html/slsDetectorClientDocs/doxygen.png b/docs/html/slsDetectorClientDocs/doxygen.png similarity index 100% rename from manual/docs/html/slsDetectorClientDocs/doxygen.png rename to docs/html/slsDetectorClientDocs/doxygen.png diff --git a/manual/docs/html/slsDetectorClientDocs/dynsections.js b/docs/html/slsDetectorClientDocs/dynsections.js similarity index 100% rename from manual/docs/html/slsDetectorClientDocs/dynsections.js rename to docs/html/slsDetectorClientDocs/dynsections.js diff --git a/manual/docs/html/slsDetectorClientDocs/ftv2blank.png b/docs/html/slsDetectorClientDocs/ftv2blank.png similarity index 100% rename from manual/docs/html/slsDetectorClientDocs/ftv2blank.png rename to docs/html/slsDetectorClientDocs/ftv2blank.png diff --git a/manual/docs/html/slsDetectorClientDocs/ftv2cl.png b/docs/html/slsDetectorClientDocs/ftv2cl.png similarity index 100% rename from manual/docs/html/slsDetectorClientDocs/ftv2cl.png rename to docs/html/slsDetectorClientDocs/ftv2cl.png diff --git a/manual/docs/html/slsDetectorClientDocs/ftv2doc.png b/docs/html/slsDetectorClientDocs/ftv2doc.png similarity index 100% rename from manual/docs/html/slsDetectorClientDocs/ftv2doc.png rename to docs/html/slsDetectorClientDocs/ftv2doc.png diff --git a/manual/docs/html/slsDetectorClientDocs/ftv2folderclosed.png b/docs/html/slsDetectorClientDocs/ftv2folderclosed.png similarity index 100% rename from manual/docs/html/slsDetectorClientDocs/ftv2folderclosed.png rename to docs/html/slsDetectorClientDocs/ftv2folderclosed.png diff --git a/manual/docs/html/slsDetectorClientDocs/ftv2folderopen.png b/docs/html/slsDetectorClientDocs/ftv2folderopen.png similarity index 100% rename from manual/docs/html/slsDetectorClientDocs/ftv2folderopen.png rename to docs/html/slsDetectorClientDocs/ftv2folderopen.png diff --git a/manual/docs/html/slsDetectorClientDocs/ftv2lastnode.png b/docs/html/slsDetectorClientDocs/ftv2lastnode.png similarity index 100% rename from manual/docs/html/slsDetectorClientDocs/ftv2lastnode.png rename to docs/html/slsDetectorClientDocs/ftv2lastnode.png diff --git a/manual/docs/html/slsDetectorClientDocs/ftv2link.png b/docs/html/slsDetectorClientDocs/ftv2link.png similarity index 100% rename from manual/docs/html/slsDetectorClientDocs/ftv2link.png rename to docs/html/slsDetectorClientDocs/ftv2link.png diff --git a/manual/docs/html/slsDetectorClientDocs/ftv2mlastnode.png b/docs/html/slsDetectorClientDocs/ftv2mlastnode.png similarity index 100% rename from manual/docs/html/slsDetectorClientDocs/ftv2mlastnode.png rename to docs/html/slsDetectorClientDocs/ftv2mlastnode.png diff --git a/manual/docs/html/slsDetectorClientDocs/ftv2mnode.png b/docs/html/slsDetectorClientDocs/ftv2mnode.png similarity index 100% rename from manual/docs/html/slsDetectorClientDocs/ftv2mnode.png rename to docs/html/slsDetectorClientDocs/ftv2mnode.png diff --git a/manual/docs/html/slsDetectorClientDocs/ftv2mo.png b/docs/html/slsDetectorClientDocs/ftv2mo.png similarity index 100% rename from manual/docs/html/slsDetectorClientDocs/ftv2mo.png rename to docs/html/slsDetectorClientDocs/ftv2mo.png diff --git a/manual/docs/html/slsDetectorClientDocs/ftv2node.png b/docs/html/slsDetectorClientDocs/ftv2node.png similarity index 100% rename from manual/docs/html/slsDetectorClientDocs/ftv2node.png rename to docs/html/slsDetectorClientDocs/ftv2node.png diff --git a/manual/docs/html/slsDetectorClientDocs/ftv2ns.png b/docs/html/slsDetectorClientDocs/ftv2ns.png similarity index 100% rename from manual/docs/html/slsDetectorClientDocs/ftv2ns.png rename to docs/html/slsDetectorClientDocs/ftv2ns.png diff --git a/manual/docs/html/slsDetectorClientDocs/ftv2plastnode.png b/docs/html/slsDetectorClientDocs/ftv2plastnode.png similarity index 100% rename from manual/docs/html/slsDetectorClientDocs/ftv2plastnode.png rename to docs/html/slsDetectorClientDocs/ftv2plastnode.png diff --git a/manual/docs/html/slsDetectorClientDocs/ftv2pnode.png b/docs/html/slsDetectorClientDocs/ftv2pnode.png similarity index 100% rename from manual/docs/html/slsDetectorClientDocs/ftv2pnode.png rename to docs/html/slsDetectorClientDocs/ftv2pnode.png diff --git a/manual/docs/html/slsDetectorClientDocs/ftv2splitbar.png b/docs/html/slsDetectorClientDocs/ftv2splitbar.png similarity index 100% rename from manual/docs/html/slsDetectorClientDocs/ftv2splitbar.png rename to docs/html/slsDetectorClientDocs/ftv2splitbar.png diff --git a/manual/docs/html/slsDetectorClientDocs/ftv2vertline.png b/docs/html/slsDetectorClientDocs/ftv2vertline.png similarity index 100% rename from manual/docs/html/slsDetectorClientDocs/ftv2vertline.png rename to docs/html/slsDetectorClientDocs/ftv2vertline.png diff --git a/manual/docs/html/slsDetectorClientDocs/index.html b/docs/html/slsDetectorClientDocs/index.html similarity index 100% rename from manual/docs/html/slsDetectorClientDocs/index.html rename to docs/html/slsDetectorClientDocs/index.html diff --git a/manual/docs/html/slsDetectorClientDocs/jquery.js b/docs/html/slsDetectorClientDocs/jquery.js similarity index 100% rename from manual/docs/html/slsDetectorClientDocs/jquery.js rename to docs/html/slsDetectorClientDocs/jquery.js diff --git a/manual/docs/html/slsDetectorClientDocs/nav_f.png b/docs/html/slsDetectorClientDocs/nav_f.png similarity index 100% rename from manual/docs/html/slsDetectorClientDocs/nav_f.png rename to docs/html/slsDetectorClientDocs/nav_f.png diff --git a/manual/docs/html/slsDetectorClientDocs/nav_g.png b/docs/html/slsDetectorClientDocs/nav_g.png similarity index 100% rename from manual/docs/html/slsDetectorClientDocs/nav_g.png rename to docs/html/slsDetectorClientDocs/nav_g.png diff --git a/manual/docs/html/slsDetectorClientDocs/nav_h.png b/docs/html/slsDetectorClientDocs/nav_h.png similarity index 100% rename from manual/docs/html/slsDetectorClientDocs/nav_h.png rename to docs/html/slsDetectorClientDocs/nav_h.png diff --git a/manual/docs/html/slsDetectorClientDocs/network.html b/docs/html/slsDetectorClientDocs/network.html similarity index 100% rename from manual/docs/html/slsDetectorClientDocs/network.html rename to docs/html/slsDetectorClientDocs/network.html diff --git a/manual/docs/html/slsDetectorClientDocs/open.png b/docs/html/slsDetectorClientDocs/open.png similarity index 100% rename from manual/docs/html/slsDetectorClientDocs/open.png rename to docs/html/slsDetectorClientDocs/open.png diff --git a/manual/docs/html/slsDetectorClientDocs/output.html b/docs/html/slsDetectorClientDocs/output.html similarity index 100% rename from manual/docs/html/slsDetectorClientDocs/output.html rename to docs/html/slsDetectorClientDocs/output.html diff --git a/manual/docs/html/slsDetectorClientDocs/pages.html b/docs/html/slsDetectorClientDocs/pages.html similarity index 100% rename from manual/docs/html/slsDetectorClientDocs/pages.html rename to docs/html/slsDetectorClientDocs/pages.html diff --git a/manual/docs/html/slsDetectorClientDocs/receiver.html b/docs/html/slsDetectorClientDocs/receiver.html similarity index 100% rename from manual/docs/html/slsDetectorClientDocs/receiver.html rename to docs/html/slsDetectorClientDocs/receiver.html diff --git a/manual/docs/html/slsDetectorClientDocs/search/all_61.html b/docs/html/slsDetectorClientDocs/search/all_61.html similarity index 100% rename from manual/docs/html/slsDetectorClientDocs/search/all_61.html rename to docs/html/slsDetectorClientDocs/search/all_61.html diff --git a/manual/docs/html/slsDetectorClientDocs/search/all_61.js b/docs/html/slsDetectorClientDocs/search/all_61.js similarity index 100% rename from manual/docs/html/slsDetectorClientDocs/search/all_61.js rename to docs/html/slsDetectorClientDocs/search/all_61.js diff --git a/manual/docs/html/slsDetectorClientDocs/search/all_63.html b/docs/html/slsDetectorClientDocs/search/all_63.html similarity index 100% rename from manual/docs/html/slsDetectorClientDocs/search/all_63.html rename to docs/html/slsDetectorClientDocs/search/all_63.html diff --git a/manual/docs/html/slsDetectorClientDocs/search/all_63.js b/docs/html/slsDetectorClientDocs/search/all_63.js similarity index 100% rename from manual/docs/html/slsDetectorClientDocs/search/all_63.js rename to docs/html/slsDetectorClientDocs/search/all_63.js diff --git a/manual/docs/html/slsDetectorClientDocs/search/all_64.html b/docs/html/slsDetectorClientDocs/search/all_64.html similarity index 100% rename from manual/docs/html/slsDetectorClientDocs/search/all_64.html rename to docs/html/slsDetectorClientDocs/search/all_64.html diff --git a/manual/docs/html/slsDetectorClientDocs/search/all_64.js b/docs/html/slsDetectorClientDocs/search/all_64.js similarity index 100% rename from manual/docs/html/slsDetectorClientDocs/search/all_64.js rename to docs/html/slsDetectorClientDocs/search/all_64.js diff --git a/manual/docs/html/slsDetectorClientDocs/search/all_69.html b/docs/html/slsDetectorClientDocs/search/all_69.html similarity index 100% rename from manual/docs/html/slsDetectorClientDocs/search/all_69.html rename to docs/html/slsDetectorClientDocs/search/all_69.html diff --git a/manual/docs/html/slsDetectorClientDocs/search/all_69.js b/docs/html/slsDetectorClientDocs/search/all_69.js similarity index 100% rename from manual/docs/html/slsDetectorClientDocs/search/all_69.js rename to docs/html/slsDetectorClientDocs/search/all_69.js diff --git a/manual/docs/html/slsDetectorClientDocs/search/all_6e.html b/docs/html/slsDetectorClientDocs/search/all_6e.html similarity index 100% rename from manual/docs/html/slsDetectorClientDocs/search/all_6e.html rename to docs/html/slsDetectorClientDocs/search/all_6e.html diff --git a/manual/docs/html/slsDetectorClientDocs/search/all_6e.js b/docs/html/slsDetectorClientDocs/search/all_6e.js similarity index 100% rename from manual/docs/html/slsDetectorClientDocs/search/all_6e.js rename to docs/html/slsDetectorClientDocs/search/all_6e.js diff --git a/manual/docs/html/slsDetectorClientDocs/search/all_6f.html b/docs/html/slsDetectorClientDocs/search/all_6f.html similarity index 100% rename from manual/docs/html/slsDetectorClientDocs/search/all_6f.html rename to docs/html/slsDetectorClientDocs/search/all_6f.html diff --git a/manual/docs/html/slsDetectorClientDocs/search/all_6f.js b/docs/html/slsDetectorClientDocs/search/all_6f.js similarity index 100% rename from manual/docs/html/slsDetectorClientDocs/search/all_6f.js rename to docs/html/slsDetectorClientDocs/search/all_6f.js diff --git a/manual/docs/html/slsDetectorClientDocs/search/all_72.html b/docs/html/slsDetectorClientDocs/search/all_72.html similarity index 100% rename from manual/docs/html/slsDetectorClientDocs/search/all_72.html rename to docs/html/slsDetectorClientDocs/search/all_72.html diff --git a/manual/docs/html/slsDetectorClientDocs/search/all_72.js b/docs/html/slsDetectorClientDocs/search/all_72.js similarity index 100% rename from manual/docs/html/slsDetectorClientDocs/search/all_72.js rename to docs/html/slsDetectorClientDocs/search/all_72.js diff --git a/manual/docs/html/slsDetectorClientDocs/search/all_74.html b/docs/html/slsDetectorClientDocs/search/all_74.html similarity index 100% rename from manual/docs/html/slsDetectorClientDocs/search/all_74.html rename to docs/html/slsDetectorClientDocs/search/all_74.html diff --git a/manual/docs/html/slsDetectorClientDocs/search/all_74.js b/docs/html/slsDetectorClientDocs/search/all_74.js similarity index 100% rename from manual/docs/html/slsDetectorClientDocs/search/all_74.js rename to docs/html/slsDetectorClientDocs/search/all_74.js diff --git a/manual/docs/html/slsDetectorClientDocs/search/close.png b/docs/html/slsDetectorClientDocs/search/close.png similarity index 100% rename from manual/docs/html/slsDetectorClientDocs/search/close.png rename to docs/html/slsDetectorClientDocs/search/close.png diff --git a/manual/docs/html/slsDetectorClientDocs/search/mag_sel.png b/docs/html/slsDetectorClientDocs/search/mag_sel.png similarity index 100% rename from manual/docs/html/slsDetectorClientDocs/search/mag_sel.png rename to docs/html/slsDetectorClientDocs/search/mag_sel.png diff --git a/manual/docs/html/slsDetectorClientDocs/search/nomatches.html b/docs/html/slsDetectorClientDocs/search/nomatches.html similarity index 100% rename from manual/docs/html/slsDetectorClientDocs/search/nomatches.html rename to docs/html/slsDetectorClientDocs/search/nomatches.html diff --git a/manual/docs/html/slsDetectorClientDocs/search/pages_61.html b/docs/html/slsDetectorClientDocs/search/pages_61.html similarity index 100% rename from manual/docs/html/slsDetectorClientDocs/search/pages_61.html rename to docs/html/slsDetectorClientDocs/search/pages_61.html diff --git a/manual/docs/html/slsDetectorClientDocs/search/pages_61.js b/docs/html/slsDetectorClientDocs/search/pages_61.js similarity index 100% rename from manual/docs/html/slsDetectorClientDocs/search/pages_61.js rename to docs/html/slsDetectorClientDocs/search/pages_61.js diff --git a/manual/docs/html/slsDetectorClientDocs/search/pages_63.html b/docs/html/slsDetectorClientDocs/search/pages_63.html similarity index 100% rename from manual/docs/html/slsDetectorClientDocs/search/pages_63.html rename to docs/html/slsDetectorClientDocs/search/pages_63.html diff --git a/manual/docs/html/slsDetectorClientDocs/search/pages_63.js b/docs/html/slsDetectorClientDocs/search/pages_63.js similarity index 100% rename from manual/docs/html/slsDetectorClientDocs/search/pages_63.js rename to docs/html/slsDetectorClientDocs/search/pages_63.js diff --git a/manual/docs/html/slsDetectorClientDocs/search/pages_64.html b/docs/html/slsDetectorClientDocs/search/pages_64.html similarity index 100% rename from manual/docs/html/slsDetectorClientDocs/search/pages_64.html rename to docs/html/slsDetectorClientDocs/search/pages_64.html diff --git a/manual/docs/html/slsDetectorClientDocs/search/pages_64.js b/docs/html/slsDetectorClientDocs/search/pages_64.js similarity index 100% rename from manual/docs/html/slsDetectorClientDocs/search/pages_64.js rename to docs/html/slsDetectorClientDocs/search/pages_64.js diff --git a/manual/docs/html/slsDetectorClientDocs/search/pages_69.html b/docs/html/slsDetectorClientDocs/search/pages_69.html similarity index 100% rename from manual/docs/html/slsDetectorClientDocs/search/pages_69.html rename to docs/html/slsDetectorClientDocs/search/pages_69.html diff --git a/manual/docs/html/slsDetectorClientDocs/search/pages_69.js b/docs/html/slsDetectorClientDocs/search/pages_69.js similarity index 100% rename from manual/docs/html/slsDetectorClientDocs/search/pages_69.js rename to docs/html/slsDetectorClientDocs/search/pages_69.js diff --git a/manual/docs/html/slsDetectorClientDocs/search/pages_6e.html b/docs/html/slsDetectorClientDocs/search/pages_6e.html similarity index 100% rename from manual/docs/html/slsDetectorClientDocs/search/pages_6e.html rename to docs/html/slsDetectorClientDocs/search/pages_6e.html diff --git a/manual/docs/html/slsDetectorClientDocs/search/pages_6e.js b/docs/html/slsDetectorClientDocs/search/pages_6e.js similarity index 100% rename from manual/docs/html/slsDetectorClientDocs/search/pages_6e.js rename to docs/html/slsDetectorClientDocs/search/pages_6e.js diff --git a/manual/docs/html/slsDetectorClientDocs/search/pages_6f.html b/docs/html/slsDetectorClientDocs/search/pages_6f.html similarity index 100% rename from manual/docs/html/slsDetectorClientDocs/search/pages_6f.html rename to docs/html/slsDetectorClientDocs/search/pages_6f.html diff --git a/manual/docs/html/slsDetectorClientDocs/search/pages_6f.js b/docs/html/slsDetectorClientDocs/search/pages_6f.js similarity index 100% rename from manual/docs/html/slsDetectorClientDocs/search/pages_6f.js rename to docs/html/slsDetectorClientDocs/search/pages_6f.js diff --git a/manual/docs/html/slsDetectorClientDocs/search/pages_72.html b/docs/html/slsDetectorClientDocs/search/pages_72.html similarity index 100% rename from manual/docs/html/slsDetectorClientDocs/search/pages_72.html rename to docs/html/slsDetectorClientDocs/search/pages_72.html diff --git a/manual/docs/html/slsDetectorClientDocs/search/pages_72.js b/docs/html/slsDetectorClientDocs/search/pages_72.js similarity index 100% rename from manual/docs/html/slsDetectorClientDocs/search/pages_72.js rename to docs/html/slsDetectorClientDocs/search/pages_72.js diff --git a/manual/docs/html/slsDetectorClientDocs/search/pages_74.html b/docs/html/slsDetectorClientDocs/search/pages_74.html similarity index 100% rename from manual/docs/html/slsDetectorClientDocs/search/pages_74.html rename to docs/html/slsDetectorClientDocs/search/pages_74.html diff --git a/manual/docs/html/slsDetectorClientDocs/search/pages_74.js b/docs/html/slsDetectorClientDocs/search/pages_74.js similarity index 100% rename from manual/docs/html/slsDetectorClientDocs/search/pages_74.js rename to docs/html/slsDetectorClientDocs/search/pages_74.js diff --git a/manual/docs/html/slsDetectorClientDocs/search/search.css b/docs/html/slsDetectorClientDocs/search/search.css similarity index 100% rename from manual/docs/html/slsDetectorClientDocs/search/search.css rename to docs/html/slsDetectorClientDocs/search/search.css diff --git a/manual/docs/html/slsDetectorClientDocs/search/search.js b/docs/html/slsDetectorClientDocs/search/search.js similarity index 100% rename from manual/docs/html/slsDetectorClientDocs/search/search.js rename to docs/html/slsDetectorClientDocs/search/search.js diff --git a/manual/docs/html/slsDetectorClientDocs/search/search_l.png b/docs/html/slsDetectorClientDocs/search/search_l.png similarity index 100% rename from manual/docs/html/slsDetectorClientDocs/search/search_l.png rename to docs/html/slsDetectorClientDocs/search/search_l.png diff --git a/manual/docs/html/slsDetectorClientDocs/search/search_m.png b/docs/html/slsDetectorClientDocs/search/search_m.png similarity index 100% rename from manual/docs/html/slsDetectorClientDocs/search/search_m.png rename to docs/html/slsDetectorClientDocs/search/search_m.png diff --git a/manual/docs/html/slsDetectorClientDocs/search/search_r.png b/docs/html/slsDetectorClientDocs/search/search_r.png similarity index 100% rename from manual/docs/html/slsDetectorClientDocs/search/search_r.png rename to docs/html/slsDetectorClientDocs/search/search_r.png diff --git a/manual/docs/html/slsDetectorClientDocs/settings.html b/docs/html/slsDetectorClientDocs/settings.html similarity index 100% rename from manual/docs/html/slsDetectorClientDocs/settings.html rename to docs/html/slsDetectorClientDocs/settings.html diff --git a/manual/docs/html/slsDetectorClientDocs/sync_off.png b/docs/html/slsDetectorClientDocs/sync_off.png similarity index 100% rename from manual/docs/html/slsDetectorClientDocs/sync_off.png rename to docs/html/slsDetectorClientDocs/sync_off.png diff --git a/manual/docs/html/slsDetectorClientDocs/sync_on.png b/docs/html/slsDetectorClientDocs/sync_on.png similarity index 100% rename from manual/docs/html/slsDetectorClientDocs/sync_on.png rename to docs/html/slsDetectorClientDocs/sync_on.png diff --git a/manual/docs/html/slsDetectorClientDocs/tab_a.png b/docs/html/slsDetectorClientDocs/tab_a.png similarity index 100% rename from manual/docs/html/slsDetectorClientDocs/tab_a.png rename to docs/html/slsDetectorClientDocs/tab_a.png diff --git a/manual/docs/html/slsDetectorClientDocs/tab_b.png b/docs/html/slsDetectorClientDocs/tab_b.png similarity index 100% rename from manual/docs/html/slsDetectorClientDocs/tab_b.png rename to docs/html/slsDetectorClientDocs/tab_b.png diff --git a/manual/docs/html/slsDetectorClientDocs/tab_h.png b/docs/html/slsDetectorClientDocs/tab_h.png similarity index 100% rename from manual/docs/html/slsDetectorClientDocs/tab_h.png rename to docs/html/slsDetectorClientDocs/tab_h.png diff --git a/manual/docs/html/slsDetectorClientDocs/tab_s.png b/docs/html/slsDetectorClientDocs/tab_s.png similarity index 100% rename from manual/docs/html/slsDetectorClientDocs/tab_s.png rename to docs/html/slsDetectorClientDocs/tab_s.png diff --git a/manual/docs/html/slsDetectorClientDocs/tabs.css b/docs/html/slsDetectorClientDocs/tabs.css similarity index 100% rename from manual/docs/html/slsDetectorClientDocs/tabs.css rename to docs/html/slsDetectorClientDocs/tabs.css diff --git a/manual/docs/html/slsDetectorClientDocs/test.html b/docs/html/slsDetectorClientDocs/test.html similarity index 100% rename from manual/docs/html/slsDetectorClientDocs/test.html rename to docs/html/slsDetectorClientDocs/test.html diff --git a/manual/docs/html/slsDetectorClientDocs/timing.html b/docs/html/slsDetectorClientDocs/timing.html similarity index 100% rename from manual/docs/html/slsDetectorClientDocs/timing.html rename to docs/html/slsDetectorClientDocs/timing.html diff --git a/manual/docs/html/slsDetectorClientHowTo/WARNINGS b/docs/html/slsDetectorClientHowTo/WARNINGS similarity index 100% rename from manual/docs/html/slsDetectorClientHowTo/WARNINGS rename to docs/html/slsDetectorClientHowTo/WARNINGS diff --git a/manual/docs/html/slsDetectorClientHowTo/images.aux b/docs/html/slsDetectorClientHowTo/images.aux similarity index 100% rename from manual/docs/html/slsDetectorClientHowTo/images.aux rename to docs/html/slsDetectorClientHowTo/images.aux diff --git a/manual/docs/html/slsDetectorClientHowTo/images.log b/docs/html/slsDetectorClientHowTo/images.log similarity index 100% rename from manual/docs/html/slsDetectorClientHowTo/images.log rename to docs/html/slsDetectorClientHowTo/images.log diff --git a/manual/docs/html/slsDetectorClientHowTo/images.pl b/docs/html/slsDetectorClientHowTo/images.pl similarity index 100% rename from manual/docs/html/slsDetectorClientHowTo/images.pl rename to docs/html/slsDetectorClientHowTo/images.pl diff --git a/manual/docs/html/slsDetectorClientHowTo/images.tex b/docs/html/slsDetectorClientHowTo/images.tex similarity index 100% rename from manual/docs/html/slsDetectorClientHowTo/images.tex rename to docs/html/slsDetectorClientHowTo/images.tex diff --git a/manual/docs/html/slsDetectorClientHowTo/img1.png b/docs/html/slsDetectorClientHowTo/img1.png similarity index 100% rename from manual/docs/html/slsDetectorClientHowTo/img1.png rename to docs/html/slsDetectorClientHowTo/img1.png diff --git a/manual/docs/html/slsDetectorClientHowTo/img2.png b/docs/html/slsDetectorClientHowTo/img2.png similarity index 100% rename from manual/docs/html/slsDetectorClientHowTo/img2.png rename to docs/html/slsDetectorClientHowTo/img2.png diff --git a/manual/docs/html/slsDetectorClientHowTo/index.html b/docs/html/slsDetectorClientHowTo/index.html similarity index 100% rename from manual/docs/html/slsDetectorClientHowTo/index.html rename to docs/html/slsDetectorClientHowTo/index.html diff --git a/manual/docs/html/slsDetectorClientHowTo/labels.pl b/docs/html/slsDetectorClientHowTo/labels.pl similarity index 100% rename from manual/docs/html/slsDetectorClientHowTo/labels.pl rename to docs/html/slsDetectorClientHowTo/labels.pl diff --git a/manual/docs/html/slsDetectorClientHowTo/node1.html b/docs/html/slsDetectorClientHowTo/node1.html similarity index 100% rename from manual/docs/html/slsDetectorClientHowTo/node1.html rename to docs/html/slsDetectorClientHowTo/node1.html diff --git a/manual/docs/html/slsDetectorClientHowTo/node2.html b/docs/html/slsDetectorClientHowTo/node2.html similarity index 100% rename from manual/docs/html/slsDetectorClientHowTo/node2.html rename to docs/html/slsDetectorClientHowTo/node2.html diff --git a/manual/docs/html/slsDetectorClientHowTo/node3.html b/docs/html/slsDetectorClientHowTo/node3.html similarity index 100% rename from manual/docs/html/slsDetectorClientHowTo/node3.html rename to docs/html/slsDetectorClientHowTo/node3.html diff --git a/manual/docs/html/slsDetectorClientHowTo/node4.html b/docs/html/slsDetectorClientHowTo/node4.html similarity index 100% rename from manual/docs/html/slsDetectorClientHowTo/node4.html rename to docs/html/slsDetectorClientHowTo/node4.html diff --git a/manual/docs/html/slsDetectorClientHowTo/node5.html b/docs/html/slsDetectorClientHowTo/node5.html similarity index 100% rename from manual/docs/html/slsDetectorClientHowTo/node5.html rename to docs/html/slsDetectorClientHowTo/node5.html diff --git a/manual/docs/html/slsDetectorClientHowTo/node6.html b/docs/html/slsDetectorClientHowTo/node6.html similarity index 100% rename from manual/docs/html/slsDetectorClientHowTo/node6.html rename to docs/html/slsDetectorClientHowTo/node6.html diff --git a/manual/docs/html/slsDetectorClientHowTo/slsDetectorClientHowTo.css b/docs/html/slsDetectorClientHowTo/slsDetectorClientHowTo.css similarity index 100% rename from manual/docs/html/slsDetectorClientHowTo/slsDetectorClientHowTo.css rename to docs/html/slsDetectorClientHowTo/slsDetectorClientHowTo.css diff --git a/manual/docs/html/slsDetectorClientHowTo/slsDetectorClientHowTo.html b/docs/html/slsDetectorClientHowTo/slsDetectorClientHowTo.html similarity index 100% rename from manual/docs/html/slsDetectorClientHowTo/slsDetectorClientHowTo.html rename to docs/html/slsDetectorClientHowTo/slsDetectorClientHowTo.html diff --git a/manual/docs/html/slsDetectorGuiHowTo/WARNINGS b/docs/html/slsDetectorGuiHowTo/WARNINGS similarity index 100% rename from manual/docs/html/slsDetectorGuiHowTo/WARNINGS rename to docs/html/slsDetectorGuiHowTo/WARNINGS diff --git a/manual/docs/html/slsDetectorGuiHowTo/index.html b/docs/html/slsDetectorGuiHowTo/index.html similarity index 100% rename from manual/docs/html/slsDetectorGuiHowTo/index.html rename to docs/html/slsDetectorGuiHowTo/index.html diff --git a/manual/docs/html/slsDetectorGuiHowTo/internals.pl b/docs/html/slsDetectorGuiHowTo/internals.pl similarity index 100% rename from manual/docs/html/slsDetectorGuiHowTo/internals.pl rename to docs/html/slsDetectorGuiHowTo/internals.pl diff --git a/manual/docs/html/slsDetectorGuiHowTo/labels.pl b/docs/html/slsDetectorGuiHowTo/labels.pl similarity index 100% rename from manual/docs/html/slsDetectorGuiHowTo/labels.pl rename to docs/html/slsDetectorGuiHowTo/labels.pl diff --git a/manual/docs/html/slsDetectorGuiHowTo/node1.html b/docs/html/slsDetectorGuiHowTo/node1.html similarity index 100% rename from manual/docs/html/slsDetectorGuiHowTo/node1.html rename to docs/html/slsDetectorGuiHowTo/node1.html diff --git a/manual/docs/html/slsDetectorGuiHowTo/node10.html b/docs/html/slsDetectorGuiHowTo/node10.html similarity index 100% rename from manual/docs/html/slsDetectorGuiHowTo/node10.html rename to docs/html/slsDetectorGuiHowTo/node10.html diff --git a/manual/docs/html/slsDetectorGuiHowTo/node11.html b/docs/html/slsDetectorGuiHowTo/node11.html similarity index 100% rename from manual/docs/html/slsDetectorGuiHowTo/node11.html rename to docs/html/slsDetectorGuiHowTo/node11.html diff --git a/manual/docs/html/slsDetectorGuiHowTo/node12.html b/docs/html/slsDetectorGuiHowTo/node12.html similarity index 100% rename from manual/docs/html/slsDetectorGuiHowTo/node12.html rename to docs/html/slsDetectorGuiHowTo/node12.html diff --git a/manual/docs/html/slsDetectorGuiHowTo/node13.html b/docs/html/slsDetectorGuiHowTo/node13.html similarity index 100% rename from manual/docs/html/slsDetectorGuiHowTo/node13.html rename to docs/html/slsDetectorGuiHowTo/node13.html diff --git a/manual/docs/html/slsDetectorGuiHowTo/node14.html b/docs/html/slsDetectorGuiHowTo/node14.html similarity index 100% rename from manual/docs/html/slsDetectorGuiHowTo/node14.html rename to docs/html/slsDetectorGuiHowTo/node14.html diff --git a/manual/docs/html/slsDetectorGuiHowTo/node15.html b/docs/html/slsDetectorGuiHowTo/node15.html similarity index 100% rename from manual/docs/html/slsDetectorGuiHowTo/node15.html rename to docs/html/slsDetectorGuiHowTo/node15.html diff --git a/manual/docs/html/slsDetectorGuiHowTo/node16.html b/docs/html/slsDetectorGuiHowTo/node16.html similarity index 100% rename from manual/docs/html/slsDetectorGuiHowTo/node16.html rename to docs/html/slsDetectorGuiHowTo/node16.html diff --git a/manual/docs/html/slsDetectorGuiHowTo/node17.html b/docs/html/slsDetectorGuiHowTo/node17.html similarity index 100% rename from manual/docs/html/slsDetectorGuiHowTo/node17.html rename to docs/html/slsDetectorGuiHowTo/node17.html diff --git a/manual/docs/html/slsDetectorGuiHowTo/node2.html b/docs/html/slsDetectorGuiHowTo/node2.html similarity index 100% rename from manual/docs/html/slsDetectorGuiHowTo/node2.html rename to docs/html/slsDetectorGuiHowTo/node2.html diff --git a/manual/docs/html/slsDetectorGuiHowTo/node3.html b/docs/html/slsDetectorGuiHowTo/node3.html similarity index 100% rename from manual/docs/html/slsDetectorGuiHowTo/node3.html rename to docs/html/slsDetectorGuiHowTo/node3.html diff --git a/manual/docs/html/slsDetectorGuiHowTo/node4.html b/docs/html/slsDetectorGuiHowTo/node4.html similarity index 100% rename from manual/docs/html/slsDetectorGuiHowTo/node4.html rename to docs/html/slsDetectorGuiHowTo/node4.html diff --git a/manual/docs/html/slsDetectorGuiHowTo/node5.html b/docs/html/slsDetectorGuiHowTo/node5.html similarity index 100% rename from manual/docs/html/slsDetectorGuiHowTo/node5.html rename to docs/html/slsDetectorGuiHowTo/node5.html diff --git a/manual/docs/html/slsDetectorGuiHowTo/node6.html b/docs/html/slsDetectorGuiHowTo/node6.html similarity index 100% rename from manual/docs/html/slsDetectorGuiHowTo/node6.html rename to docs/html/slsDetectorGuiHowTo/node6.html diff --git a/manual/docs/html/slsDetectorGuiHowTo/node7.html b/docs/html/slsDetectorGuiHowTo/node7.html similarity index 100% rename from manual/docs/html/slsDetectorGuiHowTo/node7.html rename to docs/html/slsDetectorGuiHowTo/node7.html diff --git a/manual/docs/html/slsDetectorGuiHowTo/node8.html b/docs/html/slsDetectorGuiHowTo/node8.html similarity index 100% rename from manual/docs/html/slsDetectorGuiHowTo/node8.html rename to docs/html/slsDetectorGuiHowTo/node8.html diff --git a/manual/docs/html/slsDetectorGuiHowTo/node9.html b/docs/html/slsDetectorGuiHowTo/node9.html similarity index 100% rename from manual/docs/html/slsDetectorGuiHowTo/node9.html rename to docs/html/slsDetectorGuiHowTo/node9.html diff --git a/manual/docs/html/slsDetectorGuiHowTo/slsDetectorGuiHowTo.css b/docs/html/slsDetectorGuiHowTo/slsDetectorGuiHowTo.css similarity index 100% rename from manual/docs/html/slsDetectorGuiHowTo/slsDetectorGuiHowTo.css rename to docs/html/slsDetectorGuiHowTo/slsDetectorGuiHowTo.css diff --git a/manual/docs/html/slsDetectorGuiHowTo/slsDetectorGuiHowTo.html b/docs/html/slsDetectorGuiHowTo/slsDetectorGuiHowTo.html similarity index 100% rename from manual/docs/html/slsDetectorGuiHowTo/slsDetectorGuiHowTo.html rename to docs/html/slsDetectorGuiHowTo/slsDetectorGuiHowTo.html diff --git a/manual/docs/html/slsDetectorInstall/WARNINGS b/docs/html/slsDetectorInstall/WARNINGS similarity index 100% rename from manual/docs/html/slsDetectorInstall/WARNINGS rename to docs/html/slsDetectorInstall/WARNINGS diff --git a/manual/docs/html/slsDetectorInstall/index.html b/docs/html/slsDetectorInstall/index.html similarity index 100% rename from manual/docs/html/slsDetectorInstall/index.html rename to docs/html/slsDetectorInstall/index.html diff --git a/manual/docs/html/slsDetectorInstall/labels.pl b/docs/html/slsDetectorInstall/labels.pl similarity index 100% rename from manual/docs/html/slsDetectorInstall/labels.pl rename to docs/html/slsDetectorInstall/labels.pl diff --git a/manual/docs/html/slsDetectorInstall/slsDetectorInstall.css b/docs/html/slsDetectorInstall/slsDetectorInstall.css similarity index 100% rename from manual/docs/html/slsDetectorInstall/slsDetectorInstall.css rename to docs/html/slsDetectorInstall/slsDetectorInstall.css diff --git a/manual/docs/html/slsDetectorInstall/slsDetectorInstall.html b/docs/html/slsDetectorInstall/slsDetectorInstall.html similarity index 100% rename from manual/docs/html/slsDetectorInstall/slsDetectorInstall.html rename to docs/html/slsDetectorInstall/slsDetectorInstall.html diff --git a/manual/docs/html/slsDetectorUsersDocs/annotated.html b/docs/html/slsDetectorUsersDocs/annotated.html similarity index 100% rename from manual/docs/html/slsDetectorUsersDocs/annotated.html rename to docs/html/slsDetectorUsersDocs/annotated.html diff --git a/manual/docs/html/slsDetectorUsersDocs/bc_s.png b/docs/html/slsDetectorUsersDocs/bc_s.png similarity index 100% rename from manual/docs/html/slsDetectorUsersDocs/bc_s.png rename to docs/html/slsDetectorUsersDocs/bc_s.png diff --git a/manual/docs/html/slsDetectorUsersDocs/bdwn.png b/docs/html/slsDetectorUsersDocs/bdwn.png similarity index 100% rename from manual/docs/html/slsDetectorUsersDocs/bdwn.png rename to docs/html/slsDetectorUsersDocs/bdwn.png diff --git a/manual/docs/html/slsDetectorUsersDocs/classes.html b/docs/html/slsDetectorUsersDocs/classes.html similarity index 100% rename from manual/docs/html/slsDetectorUsersDocs/classes.html rename to docs/html/slsDetectorUsersDocs/classes.html diff --git a/manual/docs/html/slsDetectorUsersDocs/classslsDetectorUsers-members.html b/docs/html/slsDetectorUsersDocs/classslsDetectorUsers-members.html similarity index 100% rename from manual/docs/html/slsDetectorUsersDocs/classslsDetectorUsers-members.html rename to docs/html/slsDetectorUsersDocs/classslsDetectorUsers-members.html diff --git a/manual/docs/html/slsDetectorUsersDocs/classslsDetectorUsers.html b/docs/html/slsDetectorUsersDocs/classslsDetectorUsers.html similarity index 100% rename from manual/docs/html/slsDetectorUsersDocs/classslsDetectorUsers.html rename to docs/html/slsDetectorUsersDocs/classslsDetectorUsers.html diff --git a/manual/docs/html/slsDetectorUsersDocs/classslsReceiverUsers-members.html b/docs/html/slsDetectorUsersDocs/classslsReceiverUsers-members.html similarity index 100% rename from manual/docs/html/slsDetectorUsersDocs/classslsReceiverUsers-members.html rename to docs/html/slsDetectorUsersDocs/classslsReceiverUsers-members.html diff --git a/manual/docs/html/slsDetectorUsersDocs/classslsReceiverUsers.html b/docs/html/slsDetectorUsersDocs/classslsReceiverUsers.html similarity index 100% rename from manual/docs/html/slsDetectorUsersDocs/classslsReceiverUsers.html rename to docs/html/slsDetectorUsersDocs/classslsReceiverUsers.html diff --git a/manual/docs/html/slsDetectorUsersDocs/closed.png b/docs/html/slsDetectorUsersDocs/closed.png similarity index 100% rename from manual/docs/html/slsDetectorUsersDocs/closed.png rename to docs/html/slsDetectorUsersDocs/closed.png diff --git a/manual/docs/html/slsDetectorUsersDocs/dir_0188e84ef4beaf9eafc4e93c2b604ff4.html b/docs/html/slsDetectorUsersDocs/dir_0188e84ef4beaf9eafc4e93c2b604ff4.html similarity index 100% rename from manual/docs/html/slsDetectorUsersDocs/dir_0188e84ef4beaf9eafc4e93c2b604ff4.html rename to docs/html/slsDetectorUsersDocs/dir_0188e84ef4beaf9eafc4e93c2b604ff4.html diff --git a/manual/docs/html/slsDetectorUsersDocs/dir_2a81099005c87b10dbd3ab3fe073d08e.html b/docs/html/slsDetectorUsersDocs/dir_2a81099005c87b10dbd3ab3fe073d08e.html similarity index 100% rename from manual/docs/html/slsDetectorUsersDocs/dir_2a81099005c87b10dbd3ab3fe073d08e.html rename to docs/html/slsDetectorUsersDocs/dir_2a81099005c87b10dbd3ab3fe073d08e.html diff --git a/manual/docs/html/slsDetectorUsersDocs/dir_2fe67bc3f7560f250851af45f127d239.html b/docs/html/slsDetectorUsersDocs/dir_2fe67bc3f7560f250851af45f127d239.html similarity index 100% rename from manual/docs/html/slsDetectorUsersDocs/dir_2fe67bc3f7560f250851af45f127d239.html rename to docs/html/slsDetectorUsersDocs/dir_2fe67bc3f7560f250851af45f127d239.html diff --git a/manual/docs/html/slsDetectorUsersDocs/dir_cda5313c19a4ccff8ceebb4444cecd0a.html b/docs/html/slsDetectorUsersDocs/dir_cda5313c19a4ccff8ceebb4444cecd0a.html similarity index 100% rename from manual/docs/html/slsDetectorUsersDocs/dir_cda5313c19a4ccff8ceebb4444cecd0a.html rename to docs/html/slsDetectorUsersDocs/dir_cda5313c19a4ccff8ceebb4444cecd0a.html diff --git a/manual/docs/html/slsDetectorUsersDocs/doxygen.css b/docs/html/slsDetectorUsersDocs/doxygen.css similarity index 100% rename from manual/docs/html/slsDetectorUsersDocs/doxygen.css rename to docs/html/slsDetectorUsersDocs/doxygen.css diff --git a/manual/docs/html/slsDetectorUsersDocs/doxygen.png b/docs/html/slsDetectorUsersDocs/doxygen.png similarity index 100% rename from manual/docs/html/slsDetectorUsersDocs/doxygen.png rename to docs/html/slsDetectorUsersDocs/doxygen.png diff --git a/manual/docs/html/slsDetectorUsersDocs/dynsections.js b/docs/html/slsDetectorUsersDocs/dynsections.js similarity index 100% rename from manual/docs/html/slsDetectorUsersDocs/dynsections.js rename to docs/html/slsDetectorUsersDocs/dynsections.js diff --git a/manual/docs/html/slsDetectorUsersDocs/files.html b/docs/html/slsDetectorUsersDocs/files.html similarity index 100% rename from manual/docs/html/slsDetectorUsersDocs/files.html rename to docs/html/slsDetectorUsersDocs/files.html diff --git a/manual/docs/html/slsDetectorUsersDocs/ftv2blank.png b/docs/html/slsDetectorUsersDocs/ftv2blank.png similarity index 100% rename from manual/docs/html/slsDetectorUsersDocs/ftv2blank.png rename to docs/html/slsDetectorUsersDocs/ftv2blank.png diff --git a/manual/docs/html/slsDetectorUsersDocs/ftv2cl.png b/docs/html/slsDetectorUsersDocs/ftv2cl.png similarity index 100% rename from manual/docs/html/slsDetectorUsersDocs/ftv2cl.png rename to docs/html/slsDetectorUsersDocs/ftv2cl.png diff --git a/manual/docs/html/slsDetectorUsersDocs/ftv2doc.png b/docs/html/slsDetectorUsersDocs/ftv2doc.png similarity index 100% rename from manual/docs/html/slsDetectorUsersDocs/ftv2doc.png rename to docs/html/slsDetectorUsersDocs/ftv2doc.png diff --git a/manual/docs/html/slsDetectorUsersDocs/ftv2folderclosed.png b/docs/html/slsDetectorUsersDocs/ftv2folderclosed.png similarity index 100% rename from manual/docs/html/slsDetectorUsersDocs/ftv2folderclosed.png rename to docs/html/slsDetectorUsersDocs/ftv2folderclosed.png diff --git a/manual/docs/html/slsDetectorUsersDocs/ftv2folderopen.png b/docs/html/slsDetectorUsersDocs/ftv2folderopen.png similarity index 100% rename from manual/docs/html/slsDetectorUsersDocs/ftv2folderopen.png rename to docs/html/slsDetectorUsersDocs/ftv2folderopen.png diff --git a/manual/docs/html/slsDetectorUsersDocs/ftv2lastnode.png b/docs/html/slsDetectorUsersDocs/ftv2lastnode.png similarity index 100% rename from manual/docs/html/slsDetectorUsersDocs/ftv2lastnode.png rename to docs/html/slsDetectorUsersDocs/ftv2lastnode.png diff --git a/manual/docs/html/slsDetectorUsersDocs/ftv2link.png b/docs/html/slsDetectorUsersDocs/ftv2link.png similarity index 100% rename from manual/docs/html/slsDetectorUsersDocs/ftv2link.png rename to docs/html/slsDetectorUsersDocs/ftv2link.png diff --git a/manual/docs/html/slsDetectorUsersDocs/ftv2mlastnode.png b/docs/html/slsDetectorUsersDocs/ftv2mlastnode.png similarity index 100% rename from manual/docs/html/slsDetectorUsersDocs/ftv2mlastnode.png rename to docs/html/slsDetectorUsersDocs/ftv2mlastnode.png diff --git a/manual/docs/html/slsDetectorUsersDocs/ftv2mnode.png b/docs/html/slsDetectorUsersDocs/ftv2mnode.png similarity index 100% rename from manual/docs/html/slsDetectorUsersDocs/ftv2mnode.png rename to docs/html/slsDetectorUsersDocs/ftv2mnode.png diff --git a/manual/docs/html/slsDetectorUsersDocs/ftv2mo.png b/docs/html/slsDetectorUsersDocs/ftv2mo.png similarity index 100% rename from manual/docs/html/slsDetectorUsersDocs/ftv2mo.png rename to docs/html/slsDetectorUsersDocs/ftv2mo.png diff --git a/manual/docs/html/slsDetectorUsersDocs/ftv2node.png b/docs/html/slsDetectorUsersDocs/ftv2node.png similarity index 100% rename from manual/docs/html/slsDetectorUsersDocs/ftv2node.png rename to docs/html/slsDetectorUsersDocs/ftv2node.png diff --git a/manual/docs/html/slsDetectorUsersDocs/ftv2ns.png b/docs/html/slsDetectorUsersDocs/ftv2ns.png similarity index 100% rename from manual/docs/html/slsDetectorUsersDocs/ftv2ns.png rename to docs/html/slsDetectorUsersDocs/ftv2ns.png diff --git a/manual/docs/html/slsDetectorUsersDocs/ftv2plastnode.png b/docs/html/slsDetectorUsersDocs/ftv2plastnode.png similarity index 100% rename from manual/docs/html/slsDetectorUsersDocs/ftv2plastnode.png rename to docs/html/slsDetectorUsersDocs/ftv2plastnode.png diff --git a/manual/docs/html/slsDetectorUsersDocs/ftv2pnode.png b/docs/html/slsDetectorUsersDocs/ftv2pnode.png similarity index 100% rename from manual/docs/html/slsDetectorUsersDocs/ftv2pnode.png rename to docs/html/slsDetectorUsersDocs/ftv2pnode.png diff --git a/manual/docs/html/slsDetectorUsersDocs/ftv2splitbar.png b/docs/html/slsDetectorUsersDocs/ftv2splitbar.png similarity index 100% rename from manual/docs/html/slsDetectorUsersDocs/ftv2splitbar.png rename to docs/html/slsDetectorUsersDocs/ftv2splitbar.png diff --git a/manual/docs/html/slsDetectorUsersDocs/ftv2vertline.png b/docs/html/slsDetectorUsersDocs/ftv2vertline.png similarity index 100% rename from manual/docs/html/slsDetectorUsersDocs/ftv2vertline.png rename to docs/html/slsDetectorUsersDocs/ftv2vertline.png diff --git a/manual/docs/html/slsDetectorUsersDocs/functions.html b/docs/html/slsDetectorUsersDocs/functions.html similarity index 100% rename from manual/docs/html/slsDetectorUsersDocs/functions.html rename to docs/html/slsDetectorUsersDocs/functions.html diff --git a/manual/docs/html/slsDetectorUsersDocs/functions_func.html b/docs/html/slsDetectorUsersDocs/functions_func.html similarity index 100% rename from manual/docs/html/slsDetectorUsersDocs/functions_func.html rename to docs/html/slsDetectorUsersDocs/functions_func.html diff --git a/manual/docs/html/slsDetectorUsersDocs/functions_vars.html b/docs/html/slsDetectorUsersDocs/functions_vars.html similarity index 100% rename from manual/docs/html/slsDetectorUsersDocs/functions_vars.html rename to docs/html/slsDetectorUsersDocs/functions_vars.html diff --git a/manual/docs/html/slsDetectorUsersDocs/globals.html b/docs/html/slsDetectorUsersDocs/globals.html similarity index 100% rename from manual/docs/html/slsDetectorUsersDocs/globals.html rename to docs/html/slsDetectorUsersDocs/globals.html diff --git a/manual/docs/html/slsDetectorUsersDocs/globals_defs.html b/docs/html/slsDetectorUsersDocs/globals_defs.html similarity index 100% rename from manual/docs/html/slsDetectorUsersDocs/globals_defs.html rename to docs/html/slsDetectorUsersDocs/globals_defs.html diff --git a/manual/docs/html/slsDetectorUsersDocs/globals_func.html b/docs/html/slsDetectorUsersDocs/globals_func.html similarity index 100% rename from manual/docs/html/slsDetectorUsersDocs/globals_func.html rename to docs/html/slsDetectorUsersDocs/globals_func.html diff --git a/manual/docs/html/slsDetectorUsersDocs/globals_vars.html b/docs/html/slsDetectorUsersDocs/globals_vars.html similarity index 100% rename from manual/docs/html/slsDetectorUsersDocs/globals_vars.html rename to docs/html/slsDetectorUsersDocs/globals_vars.html diff --git a/manual/docs/html/slsDetectorUsersDocs/index.html b/docs/html/slsDetectorUsersDocs/index.html similarity index 100% rename from manual/docs/html/slsDetectorUsersDocs/index.html rename to docs/html/slsDetectorUsersDocs/index.html diff --git a/manual/docs/html/slsDetectorUsersDocs/jquery.js b/docs/html/slsDetectorUsersDocs/jquery.js similarity index 100% rename from manual/docs/html/slsDetectorUsersDocs/jquery.js rename to docs/html/slsDetectorUsersDocs/jquery.js diff --git a/manual/docs/html/slsDetectorUsersDocs/mainClient_8cpp.html b/docs/html/slsDetectorUsersDocs/mainClient_8cpp.html similarity index 100% rename from manual/docs/html/slsDetectorUsersDocs/mainClient_8cpp.html rename to docs/html/slsDetectorUsersDocs/mainClient_8cpp.html diff --git a/manual/docs/html/slsDetectorUsersDocs/mainClient_8cpp_source.html b/docs/html/slsDetectorUsersDocs/mainClient_8cpp_source.html similarity index 100% rename from manual/docs/html/slsDetectorUsersDocs/mainClient_8cpp_source.html rename to docs/html/slsDetectorUsersDocs/mainClient_8cpp_source.html diff --git a/manual/docs/html/slsDetectorUsersDocs/mainReceiver_8cpp.html b/docs/html/slsDetectorUsersDocs/mainReceiver_8cpp.html similarity index 100% rename from manual/docs/html/slsDetectorUsersDocs/mainReceiver_8cpp.html rename to docs/html/slsDetectorUsersDocs/mainReceiver_8cpp.html diff --git a/manual/docs/html/slsDetectorUsersDocs/mainReceiver_8cpp_source.html b/docs/html/slsDetectorUsersDocs/mainReceiver_8cpp_source.html similarity index 100% rename from manual/docs/html/slsDetectorUsersDocs/mainReceiver_8cpp_source.html rename to docs/html/slsDetectorUsersDocs/mainReceiver_8cpp_source.html diff --git a/manual/docs/html/slsDetectorUsersDocs/nav_f.png b/docs/html/slsDetectorUsersDocs/nav_f.png similarity index 100% rename from manual/docs/html/slsDetectorUsersDocs/nav_f.png rename to docs/html/slsDetectorUsersDocs/nav_f.png diff --git a/manual/docs/html/slsDetectorUsersDocs/nav_g.png b/docs/html/slsDetectorUsersDocs/nav_g.png similarity index 100% rename from manual/docs/html/slsDetectorUsersDocs/nav_g.png rename to docs/html/slsDetectorUsersDocs/nav_g.png diff --git a/manual/docs/html/slsDetectorUsersDocs/nav_h.png b/docs/html/slsDetectorUsersDocs/nav_h.png similarity index 100% rename from manual/docs/html/slsDetectorUsersDocs/nav_h.png rename to docs/html/slsDetectorUsersDocs/nav_h.png diff --git a/manual/docs/html/slsDetectorUsersDocs/open.png b/docs/html/slsDetectorUsersDocs/open.png similarity index 100% rename from manual/docs/html/slsDetectorUsersDocs/open.png rename to docs/html/slsDetectorUsersDocs/open.png diff --git a/manual/docs/html/slsDetectorUsersDocs/search/all_61.html b/docs/html/slsDetectorUsersDocs/search/all_61.html similarity index 100% rename from manual/docs/html/slsDetectorUsersDocs/search/all_61.html rename to docs/html/slsDetectorUsersDocs/search/all_61.html diff --git a/manual/docs/html/slsDetectorUsersDocs/search/all_61.js b/docs/html/slsDetectorUsersDocs/search/all_61.js similarity index 100% rename from manual/docs/html/slsDetectorUsersDocs/search/all_61.js rename to docs/html/slsDetectorUsersDocs/search/all_61.js diff --git a/manual/docs/html/slsDetectorUsersDocs/search/all_64.html b/docs/html/slsDetectorUsersDocs/search/all_64.html similarity index 100% rename from manual/docs/html/slsDetectorUsersDocs/search/all_64.html rename to docs/html/slsDetectorUsersDocs/search/all_64.html diff --git a/manual/docs/html/slsDetectorUsersDocs/search/all_64.js b/docs/html/slsDetectorUsersDocs/search/all_64.js similarity index 100% rename from manual/docs/html/slsDetectorUsersDocs/search/all_64.js rename to docs/html/slsDetectorUsersDocs/search/all_64.js diff --git a/manual/docs/html/slsDetectorUsersDocs/search/all_65.html b/docs/html/slsDetectorUsersDocs/search/all_65.html similarity index 100% rename from manual/docs/html/slsDetectorUsersDocs/search/all_65.html rename to docs/html/slsDetectorUsersDocs/search/all_65.html diff --git a/manual/docs/html/slsDetectorUsersDocs/search/all_65.js b/docs/html/slsDetectorUsersDocs/search/all_65.js similarity index 100% rename from manual/docs/html/slsDetectorUsersDocs/search/all_65.js rename to docs/html/slsDetectorUsersDocs/search/all_65.js diff --git a/manual/docs/html/slsDetectorUsersDocs/search/all_66.html b/docs/html/slsDetectorUsersDocs/search/all_66.html similarity index 100% rename from manual/docs/html/slsDetectorUsersDocs/search/all_66.html rename to docs/html/slsDetectorUsersDocs/search/all_66.html diff --git a/manual/docs/html/slsDetectorUsersDocs/search/all_66.js b/docs/html/slsDetectorUsersDocs/search/all_66.js similarity index 100% rename from manual/docs/html/slsDetectorUsersDocs/search/all_66.js rename to docs/html/slsDetectorUsersDocs/search/all_66.js diff --git a/manual/docs/html/slsDetectorUsersDocs/search/all_67.html b/docs/html/slsDetectorUsersDocs/search/all_67.html similarity index 100% rename from manual/docs/html/slsDetectorUsersDocs/search/all_67.html rename to docs/html/slsDetectorUsersDocs/search/all_67.html diff --git a/manual/docs/html/slsDetectorUsersDocs/search/all_67.js b/docs/html/slsDetectorUsersDocs/search/all_67.js similarity index 100% rename from manual/docs/html/slsDetectorUsersDocs/search/all_67.js rename to docs/html/slsDetectorUsersDocs/search/all_67.js diff --git a/manual/docs/html/slsDetectorUsersDocs/search/all_69.html b/docs/html/slsDetectorUsersDocs/search/all_69.html similarity index 100% rename from manual/docs/html/slsDetectorUsersDocs/search/all_69.html rename to docs/html/slsDetectorUsersDocs/search/all_69.html diff --git a/manual/docs/html/slsDetectorUsersDocs/search/all_69.js b/docs/html/slsDetectorUsersDocs/search/all_69.js similarity index 100% rename from manual/docs/html/slsDetectorUsersDocs/search/all_69.js rename to docs/html/slsDetectorUsersDocs/search/all_69.js diff --git a/manual/docs/html/slsDetectorUsersDocs/search/all_6b.html b/docs/html/slsDetectorUsersDocs/search/all_6b.html similarity index 100% rename from manual/docs/html/slsDetectorUsersDocs/search/all_6b.html rename to docs/html/slsDetectorUsersDocs/search/all_6b.html diff --git a/manual/docs/html/slsDetectorUsersDocs/search/all_6b.js b/docs/html/slsDetectorUsersDocs/search/all_6b.js similarity index 100% rename from manual/docs/html/slsDetectorUsersDocs/search/all_6b.js rename to docs/html/slsDetectorUsersDocs/search/all_6b.js diff --git a/manual/docs/html/slsDetectorUsersDocs/search/all_6d.html b/docs/html/slsDetectorUsersDocs/search/all_6d.html similarity index 100% rename from manual/docs/html/slsDetectorUsersDocs/search/all_6d.html rename to docs/html/slsDetectorUsersDocs/search/all_6d.html diff --git a/manual/docs/html/slsDetectorUsersDocs/search/all_6d.js b/docs/html/slsDetectorUsersDocs/search/all_6d.js similarity index 100% rename from manual/docs/html/slsDetectorUsersDocs/search/all_6d.js rename to docs/html/slsDetectorUsersDocs/search/all_6d.js diff --git a/manual/docs/html/slsDetectorUsersDocs/search/all_70.html b/docs/html/slsDetectorUsersDocs/search/all_70.html similarity index 100% rename from manual/docs/html/slsDetectorUsersDocs/search/all_70.html rename to docs/html/slsDetectorUsersDocs/search/all_70.html diff --git a/manual/docs/html/slsDetectorUsersDocs/search/all_70.js b/docs/html/slsDetectorUsersDocs/search/all_70.js similarity index 100% rename from manual/docs/html/slsDetectorUsersDocs/search/all_70.js rename to docs/html/slsDetectorUsersDocs/search/all_70.js diff --git a/manual/docs/html/slsDetectorUsersDocs/search/all_72.html b/docs/html/slsDetectorUsersDocs/search/all_72.html similarity index 100% rename from manual/docs/html/slsDetectorUsersDocs/search/all_72.html rename to docs/html/slsDetectorUsersDocs/search/all_72.html diff --git a/manual/docs/html/slsDetectorUsersDocs/search/all_72.js b/docs/html/slsDetectorUsersDocs/search/all_72.js similarity index 100% rename from manual/docs/html/slsDetectorUsersDocs/search/all_72.js rename to docs/html/slsDetectorUsersDocs/search/all_72.js diff --git a/manual/docs/html/slsDetectorUsersDocs/search/all_73.html b/docs/html/slsDetectorUsersDocs/search/all_73.html similarity index 100% rename from manual/docs/html/slsDetectorUsersDocs/search/all_73.html rename to docs/html/slsDetectorUsersDocs/search/all_73.html diff --git a/manual/docs/html/slsDetectorUsersDocs/search/all_73.js b/docs/html/slsDetectorUsersDocs/search/all_73.js similarity index 100% rename from manual/docs/html/slsDetectorUsersDocs/search/all_73.js rename to docs/html/slsDetectorUsersDocs/search/all_73.js diff --git a/manual/docs/html/slsDetectorUsersDocs/search/all_7e.html b/docs/html/slsDetectorUsersDocs/search/all_7e.html similarity index 100% rename from manual/docs/html/slsDetectorUsersDocs/search/all_7e.html rename to docs/html/slsDetectorUsersDocs/search/all_7e.html diff --git a/manual/docs/html/slsDetectorUsersDocs/search/all_7e.js b/docs/html/slsDetectorUsersDocs/search/all_7e.js similarity index 100% rename from manual/docs/html/slsDetectorUsersDocs/search/all_7e.js rename to docs/html/slsDetectorUsersDocs/search/all_7e.js diff --git a/manual/docs/html/slsDetectorUsersDocs/search/classes_73.html b/docs/html/slsDetectorUsersDocs/search/classes_73.html similarity index 100% rename from manual/docs/html/slsDetectorUsersDocs/search/classes_73.html rename to docs/html/slsDetectorUsersDocs/search/classes_73.html diff --git a/manual/docs/html/slsDetectorUsersDocs/search/classes_73.js b/docs/html/slsDetectorUsersDocs/search/classes_73.js similarity index 100% rename from manual/docs/html/slsDetectorUsersDocs/search/classes_73.js rename to docs/html/slsDetectorUsersDocs/search/classes_73.js diff --git a/manual/docs/html/slsDetectorUsersDocs/search/close.png b/docs/html/slsDetectorUsersDocs/search/close.png similarity index 100% rename from manual/docs/html/slsDetectorUsersDocs/search/close.png rename to docs/html/slsDetectorUsersDocs/search/close.png diff --git a/manual/docs/html/slsDetectorUsersDocs/search/defines_70.html b/docs/html/slsDetectorUsersDocs/search/defines_70.html similarity index 100% rename from manual/docs/html/slsDetectorUsersDocs/search/defines_70.html rename to docs/html/slsDetectorUsersDocs/search/defines_70.html diff --git a/manual/docs/html/slsDetectorUsersDocs/search/defines_70.js b/docs/html/slsDetectorUsersDocs/search/defines_70.js similarity index 100% rename from manual/docs/html/slsDetectorUsersDocs/search/defines_70.js rename to docs/html/slsDetectorUsersDocs/search/defines_70.js diff --git a/manual/docs/html/slsDetectorUsersDocs/search/files_6d.html b/docs/html/slsDetectorUsersDocs/search/files_6d.html similarity index 100% rename from manual/docs/html/slsDetectorUsersDocs/search/files_6d.html rename to docs/html/slsDetectorUsersDocs/search/files_6d.html diff --git a/manual/docs/html/slsDetectorUsersDocs/search/files_6d.js b/docs/html/slsDetectorUsersDocs/search/files_6d.js similarity index 100% rename from manual/docs/html/slsDetectorUsersDocs/search/files_6d.js rename to docs/html/slsDetectorUsersDocs/search/files_6d.js diff --git a/manual/docs/html/slsDetectorUsersDocs/search/files_73.html b/docs/html/slsDetectorUsersDocs/search/files_73.html similarity index 100% rename from manual/docs/html/slsDetectorUsersDocs/search/files_73.html rename to docs/html/slsDetectorUsersDocs/search/files_73.html diff --git a/manual/docs/html/slsDetectorUsersDocs/search/files_73.js b/docs/html/slsDetectorUsersDocs/search/files_73.js similarity index 100% rename from manual/docs/html/slsDetectorUsersDocs/search/files_73.js rename to docs/html/slsDetectorUsersDocs/search/files_73.js diff --git a/manual/docs/html/slsDetectorUsersDocs/search/functions_61.html b/docs/html/slsDetectorUsersDocs/search/functions_61.html similarity index 100% rename from manual/docs/html/slsDetectorUsersDocs/search/functions_61.html rename to docs/html/slsDetectorUsersDocs/search/functions_61.html diff --git a/manual/docs/html/slsDetectorUsersDocs/search/functions_61.js b/docs/html/slsDetectorUsersDocs/search/functions_61.js similarity index 100% rename from manual/docs/html/slsDetectorUsersDocs/search/functions_61.js rename to docs/html/slsDetectorUsersDocs/search/functions_61.js diff --git a/manual/docs/html/slsDetectorUsersDocs/search/functions_64.html b/docs/html/slsDetectorUsersDocs/search/functions_64.html similarity index 100% rename from manual/docs/html/slsDetectorUsersDocs/search/functions_64.html rename to docs/html/slsDetectorUsersDocs/search/functions_64.html diff --git a/manual/docs/html/slsDetectorUsersDocs/search/functions_64.js b/docs/html/slsDetectorUsersDocs/search/functions_64.js similarity index 100% rename from manual/docs/html/slsDetectorUsersDocs/search/functions_64.js rename to docs/html/slsDetectorUsersDocs/search/functions_64.js diff --git a/manual/docs/html/slsDetectorUsersDocs/search/functions_65.html b/docs/html/slsDetectorUsersDocs/search/functions_65.html similarity index 100% rename from manual/docs/html/slsDetectorUsersDocs/search/functions_65.html rename to docs/html/slsDetectorUsersDocs/search/functions_65.html diff --git a/manual/docs/html/slsDetectorUsersDocs/search/functions_65.js b/docs/html/slsDetectorUsersDocs/search/functions_65.js similarity index 100% rename from manual/docs/html/slsDetectorUsersDocs/search/functions_65.js rename to docs/html/slsDetectorUsersDocs/search/functions_65.js diff --git a/manual/docs/html/slsDetectorUsersDocs/search/functions_66.html b/docs/html/slsDetectorUsersDocs/search/functions_66.html similarity index 100% rename from manual/docs/html/slsDetectorUsersDocs/search/functions_66.html rename to docs/html/slsDetectorUsersDocs/search/functions_66.html diff --git a/manual/docs/html/slsDetectorUsersDocs/search/functions_66.js b/docs/html/slsDetectorUsersDocs/search/functions_66.js similarity index 100% rename from manual/docs/html/slsDetectorUsersDocs/search/functions_66.js rename to docs/html/slsDetectorUsersDocs/search/functions_66.js diff --git a/manual/docs/html/slsDetectorUsersDocs/search/functions_67.html b/docs/html/slsDetectorUsersDocs/search/functions_67.html similarity index 100% rename from manual/docs/html/slsDetectorUsersDocs/search/functions_67.html rename to docs/html/slsDetectorUsersDocs/search/functions_67.html diff --git a/manual/docs/html/slsDetectorUsersDocs/search/functions_67.js b/docs/html/slsDetectorUsersDocs/search/functions_67.js similarity index 100% rename from manual/docs/html/slsDetectorUsersDocs/search/functions_67.js rename to docs/html/slsDetectorUsersDocs/search/functions_67.js diff --git a/manual/docs/html/slsDetectorUsersDocs/search/functions_69.html b/docs/html/slsDetectorUsersDocs/search/functions_69.html similarity index 100% rename from manual/docs/html/slsDetectorUsersDocs/search/functions_69.html rename to docs/html/slsDetectorUsersDocs/search/functions_69.html diff --git a/manual/docs/html/slsDetectorUsersDocs/search/functions_69.js b/docs/html/slsDetectorUsersDocs/search/functions_69.js similarity index 100% rename from manual/docs/html/slsDetectorUsersDocs/search/functions_69.js rename to docs/html/slsDetectorUsersDocs/search/functions_69.js diff --git a/manual/docs/html/slsDetectorUsersDocs/search/functions_6d.html b/docs/html/slsDetectorUsersDocs/search/functions_6d.html similarity index 100% rename from manual/docs/html/slsDetectorUsersDocs/search/functions_6d.html rename to docs/html/slsDetectorUsersDocs/search/functions_6d.html diff --git a/manual/docs/html/slsDetectorUsersDocs/search/functions_6d.js b/docs/html/slsDetectorUsersDocs/search/functions_6d.js similarity index 100% rename from manual/docs/html/slsDetectorUsersDocs/search/functions_6d.js rename to docs/html/slsDetectorUsersDocs/search/functions_6d.js diff --git a/manual/docs/html/slsDetectorUsersDocs/search/functions_70.html b/docs/html/slsDetectorUsersDocs/search/functions_70.html similarity index 100% rename from manual/docs/html/slsDetectorUsersDocs/search/functions_70.html rename to docs/html/slsDetectorUsersDocs/search/functions_70.html diff --git a/manual/docs/html/slsDetectorUsersDocs/search/functions_70.js b/docs/html/slsDetectorUsersDocs/search/functions_70.js similarity index 100% rename from manual/docs/html/slsDetectorUsersDocs/search/functions_70.js rename to docs/html/slsDetectorUsersDocs/search/functions_70.js diff --git a/manual/docs/html/slsDetectorUsersDocs/search/functions_72.html b/docs/html/slsDetectorUsersDocs/search/functions_72.html similarity index 100% rename from manual/docs/html/slsDetectorUsersDocs/search/functions_72.html rename to docs/html/slsDetectorUsersDocs/search/functions_72.html diff --git a/manual/docs/html/slsDetectorUsersDocs/search/functions_72.js b/docs/html/slsDetectorUsersDocs/search/functions_72.js similarity index 100% rename from manual/docs/html/slsDetectorUsersDocs/search/functions_72.js rename to docs/html/slsDetectorUsersDocs/search/functions_72.js diff --git a/manual/docs/html/slsDetectorUsersDocs/search/functions_73.html b/docs/html/slsDetectorUsersDocs/search/functions_73.html similarity index 100% rename from manual/docs/html/slsDetectorUsersDocs/search/functions_73.html rename to docs/html/slsDetectorUsersDocs/search/functions_73.html diff --git a/manual/docs/html/slsDetectorUsersDocs/search/functions_73.js b/docs/html/slsDetectorUsersDocs/search/functions_73.js similarity index 100% rename from manual/docs/html/slsDetectorUsersDocs/search/functions_73.js rename to docs/html/slsDetectorUsersDocs/search/functions_73.js diff --git a/manual/docs/html/slsDetectorUsersDocs/search/functions_7e.html b/docs/html/slsDetectorUsersDocs/search/functions_7e.html similarity index 100% rename from manual/docs/html/slsDetectorUsersDocs/search/functions_7e.html rename to docs/html/slsDetectorUsersDocs/search/functions_7e.html diff --git a/manual/docs/html/slsDetectorUsersDocs/search/functions_7e.js b/docs/html/slsDetectorUsersDocs/search/functions_7e.js similarity index 100% rename from manual/docs/html/slsDetectorUsersDocs/search/functions_7e.js rename to docs/html/slsDetectorUsersDocs/search/functions_7e.js diff --git a/manual/docs/html/slsDetectorUsersDocs/search/mag_sel.png b/docs/html/slsDetectorUsersDocs/search/mag_sel.png similarity index 100% rename from manual/docs/html/slsDetectorUsersDocs/search/mag_sel.png rename to docs/html/slsDetectorUsersDocs/search/mag_sel.png diff --git a/manual/docs/html/slsDetectorUsersDocs/search/nomatches.html b/docs/html/slsDetectorUsersDocs/search/nomatches.html similarity index 100% rename from manual/docs/html/slsDetectorUsersDocs/search/nomatches.html rename to docs/html/slsDetectorUsersDocs/search/nomatches.html diff --git a/manual/docs/html/slsDetectorUsersDocs/search/search.css b/docs/html/slsDetectorUsersDocs/search/search.css similarity index 100% rename from manual/docs/html/slsDetectorUsersDocs/search/search.css rename to docs/html/slsDetectorUsersDocs/search/search.css diff --git a/manual/docs/html/slsDetectorUsersDocs/search/search.js b/docs/html/slsDetectorUsersDocs/search/search.js similarity index 100% rename from manual/docs/html/slsDetectorUsersDocs/search/search.js rename to docs/html/slsDetectorUsersDocs/search/search.js diff --git a/manual/docs/html/slsDetectorUsersDocs/search/search_l.png b/docs/html/slsDetectorUsersDocs/search/search_l.png similarity index 100% rename from manual/docs/html/slsDetectorUsersDocs/search/search_l.png rename to docs/html/slsDetectorUsersDocs/search/search_l.png diff --git a/manual/docs/html/slsDetectorUsersDocs/search/search_m.png b/docs/html/slsDetectorUsersDocs/search/search_m.png similarity index 100% rename from manual/docs/html/slsDetectorUsersDocs/search/search_m.png rename to docs/html/slsDetectorUsersDocs/search/search_m.png diff --git a/manual/docs/html/slsDetectorUsersDocs/search/search_r.png b/docs/html/slsDetectorUsersDocs/search/search_r.png similarity index 100% rename from manual/docs/html/slsDetectorUsersDocs/search/search_r.png rename to docs/html/slsDetectorUsersDocs/search/search_r.png diff --git a/manual/docs/html/slsDetectorUsersDocs/search/variables_6b.html b/docs/html/slsDetectorUsersDocs/search/variables_6b.html similarity index 100% rename from manual/docs/html/slsDetectorUsersDocs/search/variables_6b.html rename to docs/html/slsDetectorUsersDocs/search/variables_6b.html diff --git a/manual/docs/html/slsDetectorUsersDocs/search/variables_6b.js b/docs/html/slsDetectorUsersDocs/search/variables_6b.js similarity index 100% rename from manual/docs/html/slsDetectorUsersDocs/search/variables_6b.js rename to docs/html/slsDetectorUsersDocs/search/variables_6b.js diff --git a/manual/docs/html/slsDetectorUsersDocs/search/variables_72.html b/docs/html/slsDetectorUsersDocs/search/variables_72.html similarity index 100% rename from manual/docs/html/slsDetectorUsersDocs/search/variables_72.html rename to docs/html/slsDetectorUsersDocs/search/variables_72.html diff --git a/manual/docs/html/slsDetectorUsersDocs/search/variables_72.js b/docs/html/slsDetectorUsersDocs/search/variables_72.js similarity index 100% rename from manual/docs/html/slsDetectorUsersDocs/search/variables_72.js rename to docs/html/slsDetectorUsersDocs/search/variables_72.js diff --git a/manual/docs/html/slsDetectorUsersDocs/slsDetectorUsers_8h.html b/docs/html/slsDetectorUsersDocs/slsDetectorUsers_8h.html similarity index 100% rename from manual/docs/html/slsDetectorUsersDocs/slsDetectorUsers_8h.html rename to docs/html/slsDetectorUsersDocs/slsDetectorUsers_8h.html diff --git a/manual/docs/html/slsDetectorUsersDocs/slsDetectorUsers_8h_source.html b/docs/html/slsDetectorUsersDocs/slsDetectorUsers_8h_source.html similarity index 100% rename from manual/docs/html/slsDetectorUsersDocs/slsDetectorUsers_8h_source.html rename to docs/html/slsDetectorUsersDocs/slsDetectorUsers_8h_source.html diff --git a/manual/docs/html/slsDetectorUsersDocs/slsReceiverUsers_8h.html b/docs/html/slsDetectorUsersDocs/slsReceiverUsers_8h.html similarity index 100% rename from manual/docs/html/slsDetectorUsersDocs/slsReceiverUsers_8h.html rename to docs/html/slsDetectorUsersDocs/slsReceiverUsers_8h.html diff --git a/manual/docs/html/slsDetectorUsersDocs/slsReceiverUsers_8h_source.html b/docs/html/slsDetectorUsersDocs/slsReceiverUsers_8h_source.html similarity index 100% rename from manual/docs/html/slsDetectorUsersDocs/slsReceiverUsers_8h_source.html rename to docs/html/slsDetectorUsersDocs/slsReceiverUsers_8h_source.html diff --git a/manual/docs/html/slsDetectorUsersDocs/sync_off.png b/docs/html/slsDetectorUsersDocs/sync_off.png similarity index 100% rename from manual/docs/html/slsDetectorUsersDocs/sync_off.png rename to docs/html/slsDetectorUsersDocs/sync_off.png diff --git a/manual/docs/html/slsDetectorUsersDocs/sync_on.png b/docs/html/slsDetectorUsersDocs/sync_on.png similarity index 100% rename from manual/docs/html/slsDetectorUsersDocs/sync_on.png rename to docs/html/slsDetectorUsersDocs/sync_on.png diff --git a/manual/docs/html/slsDetectorUsersDocs/tab_a.png b/docs/html/slsDetectorUsersDocs/tab_a.png similarity index 100% rename from manual/docs/html/slsDetectorUsersDocs/tab_a.png rename to docs/html/slsDetectorUsersDocs/tab_a.png diff --git a/manual/docs/html/slsDetectorUsersDocs/tab_b.png b/docs/html/slsDetectorUsersDocs/tab_b.png similarity index 100% rename from manual/docs/html/slsDetectorUsersDocs/tab_b.png rename to docs/html/slsDetectorUsersDocs/tab_b.png diff --git a/manual/docs/html/slsDetectorUsersDocs/tab_h.png b/docs/html/slsDetectorUsersDocs/tab_h.png similarity index 100% rename from manual/docs/html/slsDetectorUsersDocs/tab_h.png rename to docs/html/slsDetectorUsersDocs/tab_h.png diff --git a/manual/docs/html/slsDetectorUsersDocs/tab_s.png b/docs/html/slsDetectorUsersDocs/tab_s.png similarity index 100% rename from manual/docs/html/slsDetectorUsersDocs/tab_s.png rename to docs/html/slsDetectorUsersDocs/tab_s.png diff --git a/manual/docs/html/slsDetectorUsersDocs/tabs.css b/docs/html/slsDetectorUsersDocs/tabs.css similarity index 100% rename from manual/docs/html/slsDetectorUsersDocs/tabs.css rename to docs/html/slsDetectorUsersDocs/tabs.css diff --git a/manual/docs/html/slsDetectors-FAQ/WARNINGS b/docs/html/slsDetectors-FAQ/WARNINGS similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/WARNINGS rename to docs/html/slsDetectors-FAQ/WARNINGS diff --git a/manual/docs/html/slsDetectors-FAQ/footnode.html b/docs/html/slsDetectors-FAQ/footnode.html similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/footnode.html rename to docs/html/slsDetectors-FAQ/footnode.html diff --git a/manual/docs/html/slsDetectors-FAQ/images.aux b/docs/html/slsDetectors-FAQ/images.aux similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/images.aux rename to docs/html/slsDetectors-FAQ/images.aux diff --git a/manual/docs/html/slsDetectors-FAQ/images.log b/docs/html/slsDetectors-FAQ/images.log similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/images.log rename to docs/html/slsDetectors-FAQ/images.log diff --git a/manual/docs/html/slsDetectors-FAQ/images.out b/docs/html/slsDetectors-FAQ/images.out similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/images.out rename to docs/html/slsDetectors-FAQ/images.out diff --git a/manual/docs/html/slsDetectors-FAQ/images.pl b/docs/html/slsDetectors-FAQ/images.pl similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/images.pl rename to docs/html/slsDetectors-FAQ/images.pl diff --git a/manual/docs/html/slsDetectors-FAQ/images.tex b/docs/html/slsDetectors-FAQ/images.tex similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/images.tex rename to docs/html/slsDetectors-FAQ/images.tex diff --git a/manual/docs/html/slsDetectors-FAQ/img1.png b/docs/html/slsDetectors-FAQ/img1.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img1.png rename to docs/html/slsDetectors-FAQ/img1.png diff --git a/manual/docs/html/slsDetectors-FAQ/img10.png b/docs/html/slsDetectors-FAQ/img10.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img10.png rename to docs/html/slsDetectors-FAQ/img10.png diff --git a/manual/docs/html/slsDetectors-FAQ/img100.png b/docs/html/slsDetectors-FAQ/img100.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img100.png rename to docs/html/slsDetectors-FAQ/img100.png diff --git a/manual/docs/html/slsDetectors-FAQ/img101.png b/docs/html/slsDetectors-FAQ/img101.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img101.png rename to docs/html/slsDetectors-FAQ/img101.png diff --git a/manual/docs/html/slsDetectors-FAQ/img102.png b/docs/html/slsDetectors-FAQ/img102.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img102.png rename to docs/html/slsDetectors-FAQ/img102.png diff --git a/manual/docs/html/slsDetectors-FAQ/img103.png b/docs/html/slsDetectors-FAQ/img103.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img103.png rename to docs/html/slsDetectors-FAQ/img103.png diff --git a/manual/docs/html/slsDetectors-FAQ/img104.png b/docs/html/slsDetectors-FAQ/img104.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img104.png rename to docs/html/slsDetectors-FAQ/img104.png diff --git a/manual/docs/html/slsDetectors-FAQ/img105.png b/docs/html/slsDetectors-FAQ/img105.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img105.png rename to docs/html/slsDetectors-FAQ/img105.png diff --git a/manual/docs/html/slsDetectors-FAQ/img106.png b/docs/html/slsDetectors-FAQ/img106.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img106.png rename to docs/html/slsDetectors-FAQ/img106.png diff --git a/manual/docs/html/slsDetectors-FAQ/img107.png b/docs/html/slsDetectors-FAQ/img107.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img107.png rename to docs/html/slsDetectors-FAQ/img107.png diff --git a/manual/docs/html/slsDetectors-FAQ/img108.png b/docs/html/slsDetectors-FAQ/img108.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img108.png rename to docs/html/slsDetectors-FAQ/img108.png diff --git a/manual/docs/html/slsDetectors-FAQ/img109.png b/docs/html/slsDetectors-FAQ/img109.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img109.png rename to docs/html/slsDetectors-FAQ/img109.png diff --git a/manual/docs/html/slsDetectors-FAQ/img11.png b/docs/html/slsDetectors-FAQ/img11.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img11.png rename to docs/html/slsDetectors-FAQ/img11.png diff --git a/manual/docs/html/slsDetectors-FAQ/img110.png b/docs/html/slsDetectors-FAQ/img110.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img110.png rename to docs/html/slsDetectors-FAQ/img110.png diff --git a/manual/docs/html/slsDetectors-FAQ/img111.png b/docs/html/slsDetectors-FAQ/img111.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img111.png rename to docs/html/slsDetectors-FAQ/img111.png diff --git a/manual/docs/html/slsDetectors-FAQ/img112.png b/docs/html/slsDetectors-FAQ/img112.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img112.png rename to docs/html/slsDetectors-FAQ/img112.png diff --git a/manual/docs/html/slsDetectors-FAQ/img113.png b/docs/html/slsDetectors-FAQ/img113.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img113.png rename to docs/html/slsDetectors-FAQ/img113.png diff --git a/manual/docs/html/slsDetectors-FAQ/img114.png b/docs/html/slsDetectors-FAQ/img114.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img114.png rename to docs/html/slsDetectors-FAQ/img114.png diff --git a/manual/docs/html/slsDetectors-FAQ/img115.png b/docs/html/slsDetectors-FAQ/img115.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img115.png rename to docs/html/slsDetectors-FAQ/img115.png diff --git a/manual/docs/html/slsDetectors-FAQ/img116.png b/docs/html/slsDetectors-FAQ/img116.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img116.png rename to docs/html/slsDetectors-FAQ/img116.png diff --git a/manual/docs/html/slsDetectors-FAQ/img117.png b/docs/html/slsDetectors-FAQ/img117.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img117.png rename to docs/html/slsDetectors-FAQ/img117.png diff --git a/manual/docs/html/slsDetectors-FAQ/img118.png b/docs/html/slsDetectors-FAQ/img118.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img118.png rename to docs/html/slsDetectors-FAQ/img118.png diff --git a/manual/docs/html/slsDetectors-FAQ/img119.png b/docs/html/slsDetectors-FAQ/img119.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img119.png rename to docs/html/slsDetectors-FAQ/img119.png diff --git a/manual/docs/html/slsDetectors-FAQ/img12.png b/docs/html/slsDetectors-FAQ/img12.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img12.png rename to docs/html/slsDetectors-FAQ/img12.png diff --git a/manual/docs/html/slsDetectors-FAQ/img120.png b/docs/html/slsDetectors-FAQ/img120.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img120.png rename to docs/html/slsDetectors-FAQ/img120.png diff --git a/manual/docs/html/slsDetectors-FAQ/img121.png b/docs/html/slsDetectors-FAQ/img121.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img121.png rename to docs/html/slsDetectors-FAQ/img121.png diff --git a/manual/docs/html/slsDetectors-FAQ/img122.png b/docs/html/slsDetectors-FAQ/img122.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img122.png rename to docs/html/slsDetectors-FAQ/img122.png diff --git a/manual/docs/html/slsDetectors-FAQ/img123.png b/docs/html/slsDetectors-FAQ/img123.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img123.png rename to docs/html/slsDetectors-FAQ/img123.png diff --git a/manual/docs/html/slsDetectors-FAQ/img124.png b/docs/html/slsDetectors-FAQ/img124.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img124.png rename to docs/html/slsDetectors-FAQ/img124.png diff --git a/manual/docs/html/slsDetectors-FAQ/img125.png b/docs/html/slsDetectors-FAQ/img125.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img125.png rename to docs/html/slsDetectors-FAQ/img125.png diff --git a/manual/docs/html/slsDetectors-FAQ/img126.png b/docs/html/slsDetectors-FAQ/img126.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img126.png rename to docs/html/slsDetectors-FAQ/img126.png diff --git a/manual/docs/html/slsDetectors-FAQ/img127.png b/docs/html/slsDetectors-FAQ/img127.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img127.png rename to docs/html/slsDetectors-FAQ/img127.png diff --git a/manual/docs/html/slsDetectors-FAQ/img128.png b/docs/html/slsDetectors-FAQ/img128.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img128.png rename to docs/html/slsDetectors-FAQ/img128.png diff --git a/manual/docs/html/slsDetectors-FAQ/img129.png b/docs/html/slsDetectors-FAQ/img129.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img129.png rename to docs/html/slsDetectors-FAQ/img129.png diff --git a/manual/docs/html/slsDetectors-FAQ/img13.png b/docs/html/slsDetectors-FAQ/img13.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img13.png rename to docs/html/slsDetectors-FAQ/img13.png diff --git a/manual/docs/html/slsDetectors-FAQ/img130.png b/docs/html/slsDetectors-FAQ/img130.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img130.png rename to docs/html/slsDetectors-FAQ/img130.png diff --git a/manual/docs/html/slsDetectors-FAQ/img131.png b/docs/html/slsDetectors-FAQ/img131.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img131.png rename to docs/html/slsDetectors-FAQ/img131.png diff --git a/manual/docs/html/slsDetectors-FAQ/img132.png b/docs/html/slsDetectors-FAQ/img132.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img132.png rename to docs/html/slsDetectors-FAQ/img132.png diff --git a/manual/docs/html/slsDetectors-FAQ/img133.png b/docs/html/slsDetectors-FAQ/img133.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img133.png rename to docs/html/slsDetectors-FAQ/img133.png diff --git a/manual/docs/html/slsDetectors-FAQ/img134.png b/docs/html/slsDetectors-FAQ/img134.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img134.png rename to docs/html/slsDetectors-FAQ/img134.png diff --git a/manual/docs/html/slsDetectors-FAQ/img135.png b/docs/html/slsDetectors-FAQ/img135.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img135.png rename to docs/html/slsDetectors-FAQ/img135.png diff --git a/manual/docs/html/slsDetectors-FAQ/img136.png b/docs/html/slsDetectors-FAQ/img136.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img136.png rename to docs/html/slsDetectors-FAQ/img136.png diff --git a/manual/docs/html/slsDetectors-FAQ/img137.png b/docs/html/slsDetectors-FAQ/img137.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img137.png rename to docs/html/slsDetectors-FAQ/img137.png diff --git a/manual/docs/html/slsDetectors-FAQ/img138.png b/docs/html/slsDetectors-FAQ/img138.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img138.png rename to docs/html/slsDetectors-FAQ/img138.png diff --git a/manual/docs/html/slsDetectors-FAQ/img139.png b/docs/html/slsDetectors-FAQ/img139.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img139.png rename to docs/html/slsDetectors-FAQ/img139.png diff --git a/manual/docs/html/slsDetectors-FAQ/img14.png b/docs/html/slsDetectors-FAQ/img14.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img14.png rename to docs/html/slsDetectors-FAQ/img14.png diff --git a/manual/docs/html/slsDetectors-FAQ/img140.png b/docs/html/slsDetectors-FAQ/img140.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img140.png rename to docs/html/slsDetectors-FAQ/img140.png diff --git a/manual/docs/html/slsDetectors-FAQ/img141.png b/docs/html/slsDetectors-FAQ/img141.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img141.png rename to docs/html/slsDetectors-FAQ/img141.png diff --git a/manual/docs/html/slsDetectors-FAQ/img142.png b/docs/html/slsDetectors-FAQ/img142.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img142.png rename to docs/html/slsDetectors-FAQ/img142.png diff --git a/manual/docs/html/slsDetectors-FAQ/img143.png b/docs/html/slsDetectors-FAQ/img143.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img143.png rename to docs/html/slsDetectors-FAQ/img143.png diff --git a/manual/docs/html/slsDetectors-FAQ/img144.png b/docs/html/slsDetectors-FAQ/img144.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img144.png rename to docs/html/slsDetectors-FAQ/img144.png diff --git a/manual/docs/html/slsDetectors-FAQ/img145.png b/docs/html/slsDetectors-FAQ/img145.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img145.png rename to docs/html/slsDetectors-FAQ/img145.png diff --git a/manual/docs/html/slsDetectors-FAQ/img146.png b/docs/html/slsDetectors-FAQ/img146.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img146.png rename to docs/html/slsDetectors-FAQ/img146.png diff --git a/manual/docs/html/slsDetectors-FAQ/img147.png b/docs/html/slsDetectors-FAQ/img147.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img147.png rename to docs/html/slsDetectors-FAQ/img147.png diff --git a/manual/docs/html/slsDetectors-FAQ/img148.png b/docs/html/slsDetectors-FAQ/img148.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img148.png rename to docs/html/slsDetectors-FAQ/img148.png diff --git a/manual/docs/html/slsDetectors-FAQ/img149.png b/docs/html/slsDetectors-FAQ/img149.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img149.png rename to docs/html/slsDetectors-FAQ/img149.png diff --git a/manual/docs/html/slsDetectors-FAQ/img15.png b/docs/html/slsDetectors-FAQ/img15.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img15.png rename to docs/html/slsDetectors-FAQ/img15.png diff --git a/manual/docs/html/slsDetectors-FAQ/img150.png b/docs/html/slsDetectors-FAQ/img150.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img150.png rename to docs/html/slsDetectors-FAQ/img150.png diff --git a/manual/docs/html/slsDetectors-FAQ/img151.png b/docs/html/slsDetectors-FAQ/img151.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img151.png rename to docs/html/slsDetectors-FAQ/img151.png diff --git a/manual/docs/html/slsDetectors-FAQ/img152.png b/docs/html/slsDetectors-FAQ/img152.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img152.png rename to docs/html/slsDetectors-FAQ/img152.png diff --git a/manual/docs/html/slsDetectors-FAQ/img153.png b/docs/html/slsDetectors-FAQ/img153.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img153.png rename to docs/html/slsDetectors-FAQ/img153.png diff --git a/manual/docs/html/slsDetectors-FAQ/img154.png b/docs/html/slsDetectors-FAQ/img154.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img154.png rename to docs/html/slsDetectors-FAQ/img154.png diff --git a/manual/docs/html/slsDetectors-FAQ/img155.png b/docs/html/slsDetectors-FAQ/img155.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img155.png rename to docs/html/slsDetectors-FAQ/img155.png diff --git a/manual/docs/html/slsDetectors-FAQ/img156.png b/docs/html/slsDetectors-FAQ/img156.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img156.png rename to docs/html/slsDetectors-FAQ/img156.png diff --git a/manual/docs/html/slsDetectors-FAQ/img157.png b/docs/html/slsDetectors-FAQ/img157.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img157.png rename to docs/html/slsDetectors-FAQ/img157.png diff --git a/manual/docs/html/slsDetectors-FAQ/img158.png b/docs/html/slsDetectors-FAQ/img158.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img158.png rename to docs/html/slsDetectors-FAQ/img158.png diff --git a/manual/docs/html/slsDetectors-FAQ/img159.png b/docs/html/slsDetectors-FAQ/img159.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img159.png rename to docs/html/slsDetectors-FAQ/img159.png diff --git a/manual/docs/html/slsDetectors-FAQ/img16.png b/docs/html/slsDetectors-FAQ/img16.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img16.png rename to docs/html/slsDetectors-FAQ/img16.png diff --git a/manual/docs/html/slsDetectors-FAQ/img160.png b/docs/html/slsDetectors-FAQ/img160.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img160.png rename to docs/html/slsDetectors-FAQ/img160.png diff --git a/manual/docs/html/slsDetectors-FAQ/img161.png b/docs/html/slsDetectors-FAQ/img161.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img161.png rename to docs/html/slsDetectors-FAQ/img161.png diff --git a/manual/docs/html/slsDetectors-FAQ/img162.png b/docs/html/slsDetectors-FAQ/img162.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img162.png rename to docs/html/slsDetectors-FAQ/img162.png diff --git a/manual/docs/html/slsDetectors-FAQ/img163.png b/docs/html/slsDetectors-FAQ/img163.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img163.png rename to docs/html/slsDetectors-FAQ/img163.png diff --git a/manual/docs/html/slsDetectors-FAQ/img164.png b/docs/html/slsDetectors-FAQ/img164.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img164.png rename to docs/html/slsDetectors-FAQ/img164.png diff --git a/manual/docs/html/slsDetectors-FAQ/img165.png b/docs/html/slsDetectors-FAQ/img165.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img165.png rename to docs/html/slsDetectors-FAQ/img165.png diff --git a/manual/docs/html/slsDetectors-FAQ/img166.png b/docs/html/slsDetectors-FAQ/img166.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img166.png rename to docs/html/slsDetectors-FAQ/img166.png diff --git a/manual/docs/html/slsDetectors-FAQ/img167.png b/docs/html/slsDetectors-FAQ/img167.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img167.png rename to docs/html/slsDetectors-FAQ/img167.png diff --git a/manual/docs/html/slsDetectors-FAQ/img168.png b/docs/html/slsDetectors-FAQ/img168.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img168.png rename to docs/html/slsDetectors-FAQ/img168.png diff --git a/manual/docs/html/slsDetectors-FAQ/img169.png b/docs/html/slsDetectors-FAQ/img169.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img169.png rename to docs/html/slsDetectors-FAQ/img169.png diff --git a/manual/docs/html/slsDetectors-FAQ/img17.png b/docs/html/slsDetectors-FAQ/img17.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img17.png rename to docs/html/slsDetectors-FAQ/img17.png diff --git a/manual/docs/html/slsDetectors-FAQ/img170.png b/docs/html/slsDetectors-FAQ/img170.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img170.png rename to docs/html/slsDetectors-FAQ/img170.png diff --git a/manual/docs/html/slsDetectors-FAQ/img171.png b/docs/html/slsDetectors-FAQ/img171.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img171.png rename to docs/html/slsDetectors-FAQ/img171.png diff --git a/manual/docs/html/slsDetectors-FAQ/img172.png b/docs/html/slsDetectors-FAQ/img172.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img172.png rename to docs/html/slsDetectors-FAQ/img172.png diff --git a/manual/docs/html/slsDetectors-FAQ/img173.png b/docs/html/slsDetectors-FAQ/img173.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img173.png rename to docs/html/slsDetectors-FAQ/img173.png diff --git a/manual/docs/html/slsDetectors-FAQ/img174.png b/docs/html/slsDetectors-FAQ/img174.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img174.png rename to docs/html/slsDetectors-FAQ/img174.png diff --git a/manual/docs/html/slsDetectors-FAQ/img175.png b/docs/html/slsDetectors-FAQ/img175.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img175.png rename to docs/html/slsDetectors-FAQ/img175.png diff --git a/manual/docs/html/slsDetectors-FAQ/img176.png b/docs/html/slsDetectors-FAQ/img176.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img176.png rename to docs/html/slsDetectors-FAQ/img176.png diff --git a/manual/docs/html/slsDetectors-FAQ/img177.png b/docs/html/slsDetectors-FAQ/img177.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img177.png rename to docs/html/slsDetectors-FAQ/img177.png diff --git a/manual/docs/html/slsDetectors-FAQ/img178.png b/docs/html/slsDetectors-FAQ/img178.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img178.png rename to docs/html/slsDetectors-FAQ/img178.png diff --git a/manual/docs/html/slsDetectors-FAQ/img179.png b/docs/html/slsDetectors-FAQ/img179.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img179.png rename to docs/html/slsDetectors-FAQ/img179.png diff --git a/manual/docs/html/slsDetectors-FAQ/img18.png b/docs/html/slsDetectors-FAQ/img18.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img18.png rename to docs/html/slsDetectors-FAQ/img18.png diff --git a/manual/docs/html/slsDetectors-FAQ/img180.png b/docs/html/slsDetectors-FAQ/img180.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img180.png rename to docs/html/slsDetectors-FAQ/img180.png diff --git a/manual/docs/html/slsDetectors-FAQ/img181.png b/docs/html/slsDetectors-FAQ/img181.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img181.png rename to docs/html/slsDetectors-FAQ/img181.png diff --git a/manual/docs/html/slsDetectors-FAQ/img182.png b/docs/html/slsDetectors-FAQ/img182.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img182.png rename to docs/html/slsDetectors-FAQ/img182.png diff --git a/manual/docs/html/slsDetectors-FAQ/img183.png b/docs/html/slsDetectors-FAQ/img183.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img183.png rename to docs/html/slsDetectors-FAQ/img183.png diff --git a/manual/docs/html/slsDetectors-FAQ/img184.png b/docs/html/slsDetectors-FAQ/img184.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img184.png rename to docs/html/slsDetectors-FAQ/img184.png diff --git a/manual/docs/html/slsDetectors-FAQ/img185.png b/docs/html/slsDetectors-FAQ/img185.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img185.png rename to docs/html/slsDetectors-FAQ/img185.png diff --git a/manual/docs/html/slsDetectors-FAQ/img186.png b/docs/html/slsDetectors-FAQ/img186.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img186.png rename to docs/html/slsDetectors-FAQ/img186.png diff --git a/manual/docs/html/slsDetectors-FAQ/img187.png b/docs/html/slsDetectors-FAQ/img187.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img187.png rename to docs/html/slsDetectors-FAQ/img187.png diff --git a/manual/docs/html/slsDetectors-FAQ/img188.png b/docs/html/slsDetectors-FAQ/img188.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img188.png rename to docs/html/slsDetectors-FAQ/img188.png diff --git a/manual/docs/html/slsDetectors-FAQ/img189.png b/docs/html/slsDetectors-FAQ/img189.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img189.png rename to docs/html/slsDetectors-FAQ/img189.png diff --git a/manual/docs/html/slsDetectors-FAQ/img19.png b/docs/html/slsDetectors-FAQ/img19.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img19.png rename to docs/html/slsDetectors-FAQ/img19.png diff --git a/manual/docs/html/slsDetectors-FAQ/img190.png b/docs/html/slsDetectors-FAQ/img190.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img190.png rename to docs/html/slsDetectors-FAQ/img190.png diff --git a/manual/docs/html/slsDetectors-FAQ/img191.png b/docs/html/slsDetectors-FAQ/img191.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img191.png rename to docs/html/slsDetectors-FAQ/img191.png diff --git a/manual/docs/html/slsDetectors-FAQ/img192.png b/docs/html/slsDetectors-FAQ/img192.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img192.png rename to docs/html/slsDetectors-FAQ/img192.png diff --git a/manual/docs/html/slsDetectors-FAQ/img193.png b/docs/html/slsDetectors-FAQ/img193.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img193.png rename to docs/html/slsDetectors-FAQ/img193.png diff --git a/manual/docs/html/slsDetectors-FAQ/img194.png b/docs/html/slsDetectors-FAQ/img194.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img194.png rename to docs/html/slsDetectors-FAQ/img194.png diff --git a/manual/docs/html/slsDetectors-FAQ/img195.png b/docs/html/slsDetectors-FAQ/img195.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img195.png rename to docs/html/slsDetectors-FAQ/img195.png diff --git a/manual/docs/html/slsDetectors-FAQ/img196.png b/docs/html/slsDetectors-FAQ/img196.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img196.png rename to docs/html/slsDetectors-FAQ/img196.png diff --git a/manual/docs/html/slsDetectors-FAQ/img197.png b/docs/html/slsDetectors-FAQ/img197.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img197.png rename to docs/html/slsDetectors-FAQ/img197.png diff --git a/manual/docs/html/slsDetectors-FAQ/img198.png b/docs/html/slsDetectors-FAQ/img198.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img198.png rename to docs/html/slsDetectors-FAQ/img198.png diff --git a/manual/docs/html/slsDetectors-FAQ/img199.png b/docs/html/slsDetectors-FAQ/img199.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img199.png rename to docs/html/slsDetectors-FAQ/img199.png diff --git a/manual/docs/html/slsDetectors-FAQ/img2.png b/docs/html/slsDetectors-FAQ/img2.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img2.png rename to docs/html/slsDetectors-FAQ/img2.png diff --git a/manual/docs/html/slsDetectors-FAQ/img20.png b/docs/html/slsDetectors-FAQ/img20.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img20.png rename to docs/html/slsDetectors-FAQ/img20.png diff --git a/manual/docs/html/slsDetectors-FAQ/img200.png b/docs/html/slsDetectors-FAQ/img200.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img200.png rename to docs/html/slsDetectors-FAQ/img200.png diff --git a/manual/docs/html/slsDetectors-FAQ/img201.png b/docs/html/slsDetectors-FAQ/img201.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img201.png rename to docs/html/slsDetectors-FAQ/img201.png diff --git a/manual/docs/html/slsDetectors-FAQ/img202.png b/docs/html/slsDetectors-FAQ/img202.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img202.png rename to docs/html/slsDetectors-FAQ/img202.png diff --git a/manual/docs/html/slsDetectors-FAQ/img203.png b/docs/html/slsDetectors-FAQ/img203.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img203.png rename to docs/html/slsDetectors-FAQ/img203.png diff --git a/manual/docs/html/slsDetectors-FAQ/img204.png b/docs/html/slsDetectors-FAQ/img204.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img204.png rename to docs/html/slsDetectors-FAQ/img204.png diff --git a/manual/docs/html/slsDetectors-FAQ/img205.png b/docs/html/slsDetectors-FAQ/img205.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img205.png rename to docs/html/slsDetectors-FAQ/img205.png diff --git a/manual/docs/html/slsDetectors-FAQ/img206.png b/docs/html/slsDetectors-FAQ/img206.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img206.png rename to docs/html/slsDetectors-FAQ/img206.png diff --git a/manual/docs/html/slsDetectors-FAQ/img207.png b/docs/html/slsDetectors-FAQ/img207.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img207.png rename to docs/html/slsDetectors-FAQ/img207.png diff --git a/manual/docs/html/slsDetectors-FAQ/img208.png b/docs/html/slsDetectors-FAQ/img208.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img208.png rename to docs/html/slsDetectors-FAQ/img208.png diff --git a/manual/docs/html/slsDetectors-FAQ/img209.png b/docs/html/slsDetectors-FAQ/img209.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img209.png rename to docs/html/slsDetectors-FAQ/img209.png diff --git a/manual/docs/html/slsDetectors-FAQ/img21.png b/docs/html/slsDetectors-FAQ/img21.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img21.png rename to docs/html/slsDetectors-FAQ/img21.png diff --git a/manual/docs/html/slsDetectors-FAQ/img210.png b/docs/html/slsDetectors-FAQ/img210.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img210.png rename to docs/html/slsDetectors-FAQ/img210.png diff --git a/manual/docs/html/slsDetectors-FAQ/img211.png b/docs/html/slsDetectors-FAQ/img211.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img211.png rename to docs/html/slsDetectors-FAQ/img211.png diff --git a/manual/docs/html/slsDetectors-FAQ/img212.png b/docs/html/slsDetectors-FAQ/img212.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img212.png rename to docs/html/slsDetectors-FAQ/img212.png diff --git a/manual/docs/html/slsDetectors-FAQ/img213.png b/docs/html/slsDetectors-FAQ/img213.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img213.png rename to docs/html/slsDetectors-FAQ/img213.png diff --git a/manual/docs/html/slsDetectors-FAQ/img214.png b/docs/html/slsDetectors-FAQ/img214.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img214.png rename to docs/html/slsDetectors-FAQ/img214.png diff --git a/manual/docs/html/slsDetectors-FAQ/img215.png b/docs/html/slsDetectors-FAQ/img215.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img215.png rename to docs/html/slsDetectors-FAQ/img215.png diff --git a/manual/docs/html/slsDetectors-FAQ/img216.png b/docs/html/slsDetectors-FAQ/img216.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img216.png rename to docs/html/slsDetectors-FAQ/img216.png diff --git a/manual/docs/html/slsDetectors-FAQ/img217.png b/docs/html/slsDetectors-FAQ/img217.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img217.png rename to docs/html/slsDetectors-FAQ/img217.png diff --git a/manual/docs/html/slsDetectors-FAQ/img218.png b/docs/html/slsDetectors-FAQ/img218.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img218.png rename to docs/html/slsDetectors-FAQ/img218.png diff --git a/manual/docs/html/slsDetectors-FAQ/img219.png b/docs/html/slsDetectors-FAQ/img219.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img219.png rename to docs/html/slsDetectors-FAQ/img219.png diff --git a/manual/docs/html/slsDetectors-FAQ/img22.png b/docs/html/slsDetectors-FAQ/img22.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img22.png rename to docs/html/slsDetectors-FAQ/img22.png diff --git a/manual/docs/html/slsDetectors-FAQ/img220.png b/docs/html/slsDetectors-FAQ/img220.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img220.png rename to docs/html/slsDetectors-FAQ/img220.png diff --git a/manual/docs/html/slsDetectors-FAQ/img221.png b/docs/html/slsDetectors-FAQ/img221.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img221.png rename to docs/html/slsDetectors-FAQ/img221.png diff --git a/manual/docs/html/slsDetectors-FAQ/img222.png b/docs/html/slsDetectors-FAQ/img222.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img222.png rename to docs/html/slsDetectors-FAQ/img222.png diff --git a/manual/docs/html/slsDetectors-FAQ/img223.png b/docs/html/slsDetectors-FAQ/img223.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img223.png rename to docs/html/slsDetectors-FAQ/img223.png diff --git a/manual/docs/html/slsDetectors-FAQ/img224.png b/docs/html/slsDetectors-FAQ/img224.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img224.png rename to docs/html/slsDetectors-FAQ/img224.png diff --git a/manual/docs/html/slsDetectors-FAQ/img225.png b/docs/html/slsDetectors-FAQ/img225.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img225.png rename to docs/html/slsDetectors-FAQ/img225.png diff --git a/manual/docs/html/slsDetectors-FAQ/img226.png b/docs/html/slsDetectors-FAQ/img226.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img226.png rename to docs/html/slsDetectors-FAQ/img226.png diff --git a/manual/docs/html/slsDetectors-FAQ/img23.png b/docs/html/slsDetectors-FAQ/img23.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img23.png rename to docs/html/slsDetectors-FAQ/img23.png diff --git a/manual/docs/html/slsDetectors-FAQ/img24.png b/docs/html/slsDetectors-FAQ/img24.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img24.png rename to docs/html/slsDetectors-FAQ/img24.png diff --git a/manual/docs/html/slsDetectors-FAQ/img25.png b/docs/html/slsDetectors-FAQ/img25.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img25.png rename to docs/html/slsDetectors-FAQ/img25.png diff --git a/manual/docs/html/slsDetectors-FAQ/img26.png b/docs/html/slsDetectors-FAQ/img26.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img26.png rename to docs/html/slsDetectors-FAQ/img26.png diff --git a/manual/docs/html/slsDetectors-FAQ/img27.png b/docs/html/slsDetectors-FAQ/img27.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img27.png rename to docs/html/slsDetectors-FAQ/img27.png diff --git a/manual/docs/html/slsDetectors-FAQ/img28.png b/docs/html/slsDetectors-FAQ/img28.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img28.png rename to docs/html/slsDetectors-FAQ/img28.png diff --git a/manual/docs/html/slsDetectors-FAQ/img29.png b/docs/html/slsDetectors-FAQ/img29.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img29.png rename to docs/html/slsDetectors-FAQ/img29.png diff --git a/manual/docs/html/slsDetectors-FAQ/img3.png b/docs/html/slsDetectors-FAQ/img3.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img3.png rename to docs/html/slsDetectors-FAQ/img3.png diff --git a/manual/docs/html/slsDetectors-FAQ/img30.png b/docs/html/slsDetectors-FAQ/img30.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img30.png rename to docs/html/slsDetectors-FAQ/img30.png diff --git a/manual/docs/html/slsDetectors-FAQ/img31.png b/docs/html/slsDetectors-FAQ/img31.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img31.png rename to docs/html/slsDetectors-FAQ/img31.png diff --git a/manual/docs/html/slsDetectors-FAQ/img32.png b/docs/html/slsDetectors-FAQ/img32.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img32.png rename to docs/html/slsDetectors-FAQ/img32.png diff --git a/manual/docs/html/slsDetectors-FAQ/img33.png b/docs/html/slsDetectors-FAQ/img33.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img33.png rename to docs/html/slsDetectors-FAQ/img33.png diff --git a/manual/docs/html/slsDetectors-FAQ/img34.png b/docs/html/slsDetectors-FAQ/img34.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img34.png rename to docs/html/slsDetectors-FAQ/img34.png diff --git a/manual/docs/html/slsDetectors-FAQ/img35.png b/docs/html/slsDetectors-FAQ/img35.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img35.png rename to docs/html/slsDetectors-FAQ/img35.png diff --git a/manual/docs/html/slsDetectors-FAQ/img36.png b/docs/html/slsDetectors-FAQ/img36.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img36.png rename to docs/html/slsDetectors-FAQ/img36.png diff --git a/manual/docs/html/slsDetectors-FAQ/img37.png b/docs/html/slsDetectors-FAQ/img37.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img37.png rename to docs/html/slsDetectors-FAQ/img37.png diff --git a/manual/docs/html/slsDetectors-FAQ/img38.png b/docs/html/slsDetectors-FAQ/img38.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img38.png rename to docs/html/slsDetectors-FAQ/img38.png diff --git a/manual/docs/html/slsDetectors-FAQ/img39.png b/docs/html/slsDetectors-FAQ/img39.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img39.png rename to docs/html/slsDetectors-FAQ/img39.png diff --git a/manual/docs/html/slsDetectors-FAQ/img4.png b/docs/html/slsDetectors-FAQ/img4.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img4.png rename to docs/html/slsDetectors-FAQ/img4.png diff --git a/manual/docs/html/slsDetectors-FAQ/img40.png b/docs/html/slsDetectors-FAQ/img40.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img40.png rename to docs/html/slsDetectors-FAQ/img40.png diff --git a/manual/docs/html/slsDetectors-FAQ/img41.png b/docs/html/slsDetectors-FAQ/img41.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img41.png rename to docs/html/slsDetectors-FAQ/img41.png diff --git a/manual/docs/html/slsDetectors-FAQ/img42.png b/docs/html/slsDetectors-FAQ/img42.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img42.png rename to docs/html/slsDetectors-FAQ/img42.png diff --git a/manual/docs/html/slsDetectors-FAQ/img43.png b/docs/html/slsDetectors-FAQ/img43.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img43.png rename to docs/html/slsDetectors-FAQ/img43.png diff --git a/manual/docs/html/slsDetectors-FAQ/img44.png b/docs/html/slsDetectors-FAQ/img44.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img44.png rename to docs/html/slsDetectors-FAQ/img44.png diff --git a/manual/docs/html/slsDetectors-FAQ/img45.png b/docs/html/slsDetectors-FAQ/img45.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img45.png rename to docs/html/slsDetectors-FAQ/img45.png diff --git a/manual/docs/html/slsDetectors-FAQ/img46.png b/docs/html/slsDetectors-FAQ/img46.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img46.png rename to docs/html/slsDetectors-FAQ/img46.png diff --git a/manual/docs/html/slsDetectors-FAQ/img47.png b/docs/html/slsDetectors-FAQ/img47.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img47.png rename to docs/html/slsDetectors-FAQ/img47.png diff --git a/manual/docs/html/slsDetectors-FAQ/img48.png b/docs/html/slsDetectors-FAQ/img48.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img48.png rename to docs/html/slsDetectors-FAQ/img48.png diff --git a/manual/docs/html/slsDetectors-FAQ/img49.png b/docs/html/slsDetectors-FAQ/img49.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img49.png rename to docs/html/slsDetectors-FAQ/img49.png diff --git a/manual/docs/html/slsDetectors-FAQ/img5.png b/docs/html/slsDetectors-FAQ/img5.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img5.png rename to docs/html/slsDetectors-FAQ/img5.png diff --git a/manual/docs/html/slsDetectors-FAQ/img50.png b/docs/html/slsDetectors-FAQ/img50.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img50.png rename to docs/html/slsDetectors-FAQ/img50.png diff --git a/manual/docs/html/slsDetectors-FAQ/img51.png b/docs/html/slsDetectors-FAQ/img51.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img51.png rename to docs/html/slsDetectors-FAQ/img51.png diff --git a/manual/docs/html/slsDetectors-FAQ/img52.png b/docs/html/slsDetectors-FAQ/img52.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img52.png rename to docs/html/slsDetectors-FAQ/img52.png diff --git a/manual/docs/html/slsDetectors-FAQ/img53.png b/docs/html/slsDetectors-FAQ/img53.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img53.png rename to docs/html/slsDetectors-FAQ/img53.png diff --git a/manual/docs/html/slsDetectors-FAQ/img54.png b/docs/html/slsDetectors-FAQ/img54.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img54.png rename to docs/html/slsDetectors-FAQ/img54.png diff --git a/manual/docs/html/slsDetectors-FAQ/img55.png b/docs/html/slsDetectors-FAQ/img55.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img55.png rename to docs/html/slsDetectors-FAQ/img55.png diff --git a/manual/docs/html/slsDetectors-FAQ/img56.png b/docs/html/slsDetectors-FAQ/img56.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img56.png rename to docs/html/slsDetectors-FAQ/img56.png diff --git a/manual/docs/html/slsDetectors-FAQ/img57.png b/docs/html/slsDetectors-FAQ/img57.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img57.png rename to docs/html/slsDetectors-FAQ/img57.png diff --git a/manual/docs/html/slsDetectors-FAQ/img58.png b/docs/html/slsDetectors-FAQ/img58.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img58.png rename to docs/html/slsDetectors-FAQ/img58.png diff --git a/manual/docs/html/slsDetectors-FAQ/img59.png b/docs/html/slsDetectors-FAQ/img59.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img59.png rename to docs/html/slsDetectors-FAQ/img59.png diff --git a/manual/docs/html/slsDetectors-FAQ/img6.png b/docs/html/slsDetectors-FAQ/img6.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img6.png rename to docs/html/slsDetectors-FAQ/img6.png diff --git a/manual/docs/html/slsDetectors-FAQ/img60.png b/docs/html/slsDetectors-FAQ/img60.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img60.png rename to docs/html/slsDetectors-FAQ/img60.png diff --git a/manual/docs/html/slsDetectors-FAQ/img61.png b/docs/html/slsDetectors-FAQ/img61.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img61.png rename to docs/html/slsDetectors-FAQ/img61.png diff --git a/manual/docs/html/slsDetectors-FAQ/img62.png b/docs/html/slsDetectors-FAQ/img62.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img62.png rename to docs/html/slsDetectors-FAQ/img62.png diff --git a/manual/docs/html/slsDetectors-FAQ/img63.png b/docs/html/slsDetectors-FAQ/img63.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img63.png rename to docs/html/slsDetectors-FAQ/img63.png diff --git a/manual/docs/html/slsDetectors-FAQ/img64.png b/docs/html/slsDetectors-FAQ/img64.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img64.png rename to docs/html/slsDetectors-FAQ/img64.png diff --git a/manual/docs/html/slsDetectors-FAQ/img65.png b/docs/html/slsDetectors-FAQ/img65.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img65.png rename to docs/html/slsDetectors-FAQ/img65.png diff --git a/manual/docs/html/slsDetectors-FAQ/img66.png b/docs/html/slsDetectors-FAQ/img66.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img66.png rename to docs/html/slsDetectors-FAQ/img66.png diff --git a/manual/docs/html/slsDetectors-FAQ/img67.png b/docs/html/slsDetectors-FAQ/img67.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img67.png rename to docs/html/slsDetectors-FAQ/img67.png diff --git a/manual/docs/html/slsDetectors-FAQ/img68.png b/docs/html/slsDetectors-FAQ/img68.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img68.png rename to docs/html/slsDetectors-FAQ/img68.png diff --git a/manual/docs/html/slsDetectors-FAQ/img69.png b/docs/html/slsDetectors-FAQ/img69.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img69.png rename to docs/html/slsDetectors-FAQ/img69.png diff --git a/manual/docs/html/slsDetectors-FAQ/img7.png b/docs/html/slsDetectors-FAQ/img7.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img7.png rename to docs/html/slsDetectors-FAQ/img7.png diff --git a/manual/docs/html/slsDetectors-FAQ/img70.png b/docs/html/slsDetectors-FAQ/img70.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img70.png rename to docs/html/slsDetectors-FAQ/img70.png diff --git a/manual/docs/html/slsDetectors-FAQ/img71.png b/docs/html/slsDetectors-FAQ/img71.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img71.png rename to docs/html/slsDetectors-FAQ/img71.png diff --git a/manual/docs/html/slsDetectors-FAQ/img72.png b/docs/html/slsDetectors-FAQ/img72.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img72.png rename to docs/html/slsDetectors-FAQ/img72.png diff --git a/manual/docs/html/slsDetectors-FAQ/img73.png b/docs/html/slsDetectors-FAQ/img73.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img73.png rename to docs/html/slsDetectors-FAQ/img73.png diff --git a/manual/docs/html/slsDetectors-FAQ/img74.png b/docs/html/slsDetectors-FAQ/img74.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img74.png rename to docs/html/slsDetectors-FAQ/img74.png diff --git a/manual/docs/html/slsDetectors-FAQ/img75.png b/docs/html/slsDetectors-FAQ/img75.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img75.png rename to docs/html/slsDetectors-FAQ/img75.png diff --git a/manual/docs/html/slsDetectors-FAQ/img76.png b/docs/html/slsDetectors-FAQ/img76.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img76.png rename to docs/html/slsDetectors-FAQ/img76.png diff --git a/manual/docs/html/slsDetectors-FAQ/img77.png b/docs/html/slsDetectors-FAQ/img77.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img77.png rename to docs/html/slsDetectors-FAQ/img77.png diff --git a/manual/docs/html/slsDetectors-FAQ/img78.png b/docs/html/slsDetectors-FAQ/img78.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img78.png rename to docs/html/slsDetectors-FAQ/img78.png diff --git a/manual/docs/html/slsDetectors-FAQ/img79.png b/docs/html/slsDetectors-FAQ/img79.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img79.png rename to docs/html/slsDetectors-FAQ/img79.png diff --git a/manual/docs/html/slsDetectors-FAQ/img8.png b/docs/html/slsDetectors-FAQ/img8.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img8.png rename to docs/html/slsDetectors-FAQ/img8.png diff --git a/manual/docs/html/slsDetectors-FAQ/img80.png b/docs/html/slsDetectors-FAQ/img80.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img80.png rename to docs/html/slsDetectors-FAQ/img80.png diff --git a/manual/docs/html/slsDetectors-FAQ/img81.png b/docs/html/slsDetectors-FAQ/img81.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img81.png rename to docs/html/slsDetectors-FAQ/img81.png diff --git a/manual/docs/html/slsDetectors-FAQ/img82.png b/docs/html/slsDetectors-FAQ/img82.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img82.png rename to docs/html/slsDetectors-FAQ/img82.png diff --git a/manual/docs/html/slsDetectors-FAQ/img83.png b/docs/html/slsDetectors-FAQ/img83.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img83.png rename to docs/html/slsDetectors-FAQ/img83.png diff --git a/manual/docs/html/slsDetectors-FAQ/img84.png b/docs/html/slsDetectors-FAQ/img84.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img84.png rename to docs/html/slsDetectors-FAQ/img84.png diff --git a/manual/docs/html/slsDetectors-FAQ/img85.png b/docs/html/slsDetectors-FAQ/img85.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img85.png rename to docs/html/slsDetectors-FAQ/img85.png diff --git a/manual/docs/html/slsDetectors-FAQ/img86.png b/docs/html/slsDetectors-FAQ/img86.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img86.png rename to docs/html/slsDetectors-FAQ/img86.png diff --git a/manual/docs/html/slsDetectors-FAQ/img87.png b/docs/html/slsDetectors-FAQ/img87.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img87.png rename to docs/html/slsDetectors-FAQ/img87.png diff --git a/manual/docs/html/slsDetectors-FAQ/img88.png b/docs/html/slsDetectors-FAQ/img88.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img88.png rename to docs/html/slsDetectors-FAQ/img88.png diff --git a/manual/docs/html/slsDetectors-FAQ/img89.png b/docs/html/slsDetectors-FAQ/img89.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img89.png rename to docs/html/slsDetectors-FAQ/img89.png diff --git a/manual/docs/html/slsDetectors-FAQ/img9.png b/docs/html/slsDetectors-FAQ/img9.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img9.png rename to docs/html/slsDetectors-FAQ/img9.png diff --git a/manual/docs/html/slsDetectors-FAQ/img90.png b/docs/html/slsDetectors-FAQ/img90.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img90.png rename to docs/html/slsDetectors-FAQ/img90.png diff --git a/manual/docs/html/slsDetectors-FAQ/img91.png b/docs/html/slsDetectors-FAQ/img91.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img91.png rename to docs/html/slsDetectors-FAQ/img91.png diff --git a/manual/docs/html/slsDetectors-FAQ/img92.png b/docs/html/slsDetectors-FAQ/img92.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img92.png rename to docs/html/slsDetectors-FAQ/img92.png diff --git a/manual/docs/html/slsDetectors-FAQ/img93.png b/docs/html/slsDetectors-FAQ/img93.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img93.png rename to docs/html/slsDetectors-FAQ/img93.png diff --git a/manual/docs/html/slsDetectors-FAQ/img94.png b/docs/html/slsDetectors-FAQ/img94.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img94.png rename to docs/html/slsDetectors-FAQ/img94.png diff --git a/manual/docs/html/slsDetectors-FAQ/img95.png b/docs/html/slsDetectors-FAQ/img95.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img95.png rename to docs/html/slsDetectors-FAQ/img95.png diff --git a/manual/docs/html/slsDetectors-FAQ/img96.png b/docs/html/slsDetectors-FAQ/img96.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img96.png rename to docs/html/slsDetectors-FAQ/img96.png diff --git a/manual/docs/html/slsDetectors-FAQ/img97.png b/docs/html/slsDetectors-FAQ/img97.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img97.png rename to docs/html/slsDetectors-FAQ/img97.png diff --git a/manual/docs/html/slsDetectors-FAQ/img98.png b/docs/html/slsDetectors-FAQ/img98.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img98.png rename to docs/html/slsDetectors-FAQ/img98.png diff --git a/manual/docs/html/slsDetectors-FAQ/img99.png b/docs/html/slsDetectors-FAQ/img99.png similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/img99.png rename to docs/html/slsDetectors-FAQ/img99.png diff --git a/manual/docs/html/slsDetectors-FAQ/index.html b/docs/html/slsDetectors-FAQ/index.html similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/index.html rename to docs/html/slsDetectors-FAQ/index.html diff --git a/manual/docs/html/slsDetectors-FAQ/internals.pl b/docs/html/slsDetectors-FAQ/internals.pl similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/internals.pl rename to docs/html/slsDetectors-FAQ/internals.pl diff --git a/manual/docs/html/slsDetectors-FAQ/labels.pl b/docs/html/slsDetectors-FAQ/labels.pl similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/labels.pl rename to docs/html/slsDetectors-FAQ/labels.pl diff --git a/manual/docs/html/slsDetectors-FAQ/node1.html b/docs/html/slsDetectors-FAQ/node1.html similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/node1.html rename to docs/html/slsDetectors-FAQ/node1.html diff --git a/manual/docs/html/slsDetectors-FAQ/node10.html b/docs/html/slsDetectors-FAQ/node10.html similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/node10.html rename to docs/html/slsDetectors-FAQ/node10.html diff --git a/manual/docs/html/slsDetectors-FAQ/node11.html b/docs/html/slsDetectors-FAQ/node11.html similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/node11.html rename to docs/html/slsDetectors-FAQ/node11.html diff --git a/manual/docs/html/slsDetectors-FAQ/node12.html b/docs/html/slsDetectors-FAQ/node12.html similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/node12.html rename to docs/html/slsDetectors-FAQ/node12.html diff --git a/manual/docs/html/slsDetectors-FAQ/node13.html b/docs/html/slsDetectors-FAQ/node13.html similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/node13.html rename to docs/html/slsDetectors-FAQ/node13.html diff --git a/manual/docs/html/slsDetectors-FAQ/node14.html b/docs/html/slsDetectors-FAQ/node14.html similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/node14.html rename to docs/html/slsDetectors-FAQ/node14.html diff --git a/manual/docs/html/slsDetectors-FAQ/node15.html b/docs/html/slsDetectors-FAQ/node15.html similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/node15.html rename to docs/html/slsDetectors-FAQ/node15.html diff --git a/manual/docs/html/slsDetectors-FAQ/node16.html b/docs/html/slsDetectors-FAQ/node16.html similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/node16.html rename to docs/html/slsDetectors-FAQ/node16.html diff --git a/manual/docs/html/slsDetectors-FAQ/node17.html b/docs/html/slsDetectors-FAQ/node17.html similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/node17.html rename to docs/html/slsDetectors-FAQ/node17.html diff --git a/manual/docs/html/slsDetectors-FAQ/node18.html b/docs/html/slsDetectors-FAQ/node18.html similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/node18.html rename to docs/html/slsDetectors-FAQ/node18.html diff --git a/manual/docs/html/slsDetectors-FAQ/node19.html b/docs/html/slsDetectors-FAQ/node19.html similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/node19.html rename to docs/html/slsDetectors-FAQ/node19.html diff --git a/manual/docs/html/slsDetectors-FAQ/node2.html b/docs/html/slsDetectors-FAQ/node2.html similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/node2.html rename to docs/html/slsDetectors-FAQ/node2.html diff --git a/manual/docs/html/slsDetectors-FAQ/node20.html b/docs/html/slsDetectors-FAQ/node20.html similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/node20.html rename to docs/html/slsDetectors-FAQ/node20.html diff --git a/manual/docs/html/slsDetectors-FAQ/node21.html b/docs/html/slsDetectors-FAQ/node21.html similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/node21.html rename to docs/html/slsDetectors-FAQ/node21.html diff --git a/manual/docs/html/slsDetectors-FAQ/node22.html b/docs/html/slsDetectors-FAQ/node22.html similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/node22.html rename to docs/html/slsDetectors-FAQ/node22.html diff --git a/manual/docs/html/slsDetectors-FAQ/node23.html b/docs/html/slsDetectors-FAQ/node23.html similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/node23.html rename to docs/html/slsDetectors-FAQ/node23.html diff --git a/manual/docs/html/slsDetectors-FAQ/node24.html b/docs/html/slsDetectors-FAQ/node24.html similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/node24.html rename to docs/html/slsDetectors-FAQ/node24.html diff --git a/manual/docs/html/slsDetectors-FAQ/node25.html b/docs/html/slsDetectors-FAQ/node25.html similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/node25.html rename to docs/html/slsDetectors-FAQ/node25.html diff --git a/manual/docs/html/slsDetectors-FAQ/node26.html b/docs/html/slsDetectors-FAQ/node26.html similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/node26.html rename to docs/html/slsDetectors-FAQ/node26.html diff --git a/manual/docs/html/slsDetectors-FAQ/node27.html b/docs/html/slsDetectors-FAQ/node27.html similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/node27.html rename to docs/html/slsDetectors-FAQ/node27.html diff --git a/manual/docs/html/slsDetectors-FAQ/node28.html b/docs/html/slsDetectors-FAQ/node28.html similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/node28.html rename to docs/html/slsDetectors-FAQ/node28.html diff --git a/manual/docs/html/slsDetectors-FAQ/node29.html b/docs/html/slsDetectors-FAQ/node29.html similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/node29.html rename to docs/html/slsDetectors-FAQ/node29.html diff --git a/manual/docs/html/slsDetectors-FAQ/node3.html b/docs/html/slsDetectors-FAQ/node3.html similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/node3.html rename to docs/html/slsDetectors-FAQ/node3.html diff --git a/manual/docs/html/slsDetectors-FAQ/node30.html b/docs/html/slsDetectors-FAQ/node30.html similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/node30.html rename to docs/html/slsDetectors-FAQ/node30.html diff --git a/manual/docs/html/slsDetectors-FAQ/node31.html b/docs/html/slsDetectors-FAQ/node31.html similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/node31.html rename to docs/html/slsDetectors-FAQ/node31.html diff --git a/manual/docs/html/slsDetectors-FAQ/node32.html b/docs/html/slsDetectors-FAQ/node32.html similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/node32.html rename to docs/html/slsDetectors-FAQ/node32.html diff --git a/manual/docs/html/slsDetectors-FAQ/node33.html b/docs/html/slsDetectors-FAQ/node33.html similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/node33.html rename to docs/html/slsDetectors-FAQ/node33.html diff --git a/manual/docs/html/slsDetectors-FAQ/node34.html b/docs/html/slsDetectors-FAQ/node34.html similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/node34.html rename to docs/html/slsDetectors-FAQ/node34.html diff --git a/manual/docs/html/slsDetectors-FAQ/node35.html b/docs/html/slsDetectors-FAQ/node35.html similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/node35.html rename to docs/html/slsDetectors-FAQ/node35.html diff --git a/manual/docs/html/slsDetectors-FAQ/node36.html b/docs/html/slsDetectors-FAQ/node36.html similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/node36.html rename to docs/html/slsDetectors-FAQ/node36.html diff --git a/manual/docs/html/slsDetectors-FAQ/node37.html b/docs/html/slsDetectors-FAQ/node37.html similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/node37.html rename to docs/html/slsDetectors-FAQ/node37.html diff --git a/manual/docs/html/slsDetectors-FAQ/node38.html b/docs/html/slsDetectors-FAQ/node38.html similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/node38.html rename to docs/html/slsDetectors-FAQ/node38.html diff --git a/manual/docs/html/slsDetectors-FAQ/node39.html b/docs/html/slsDetectors-FAQ/node39.html similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/node39.html rename to docs/html/slsDetectors-FAQ/node39.html diff --git a/manual/docs/html/slsDetectors-FAQ/node4.html b/docs/html/slsDetectors-FAQ/node4.html similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/node4.html rename to docs/html/slsDetectors-FAQ/node4.html diff --git a/manual/docs/html/slsDetectors-FAQ/node40.html b/docs/html/slsDetectors-FAQ/node40.html similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/node40.html rename to docs/html/slsDetectors-FAQ/node40.html diff --git a/manual/docs/html/slsDetectors-FAQ/node41.html b/docs/html/slsDetectors-FAQ/node41.html similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/node41.html rename to docs/html/slsDetectors-FAQ/node41.html diff --git a/manual/docs/html/slsDetectors-FAQ/node42.html b/docs/html/slsDetectors-FAQ/node42.html similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/node42.html rename to docs/html/slsDetectors-FAQ/node42.html diff --git a/manual/docs/html/slsDetectors-FAQ/node43.html b/docs/html/slsDetectors-FAQ/node43.html similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/node43.html rename to docs/html/slsDetectors-FAQ/node43.html diff --git a/manual/docs/html/slsDetectors-FAQ/node44.html b/docs/html/slsDetectors-FAQ/node44.html similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/node44.html rename to docs/html/slsDetectors-FAQ/node44.html diff --git a/manual/docs/html/slsDetectors-FAQ/node45.html b/docs/html/slsDetectors-FAQ/node45.html similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/node45.html rename to docs/html/slsDetectors-FAQ/node45.html diff --git a/manual/docs/html/slsDetectors-FAQ/node46.html b/docs/html/slsDetectors-FAQ/node46.html similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/node46.html rename to docs/html/slsDetectors-FAQ/node46.html diff --git a/manual/docs/html/slsDetectors-FAQ/node47.html b/docs/html/slsDetectors-FAQ/node47.html similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/node47.html rename to docs/html/slsDetectors-FAQ/node47.html diff --git a/manual/docs/html/slsDetectors-FAQ/node48.html b/docs/html/slsDetectors-FAQ/node48.html similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/node48.html rename to docs/html/slsDetectors-FAQ/node48.html diff --git a/manual/docs/html/slsDetectors-FAQ/node49.html b/docs/html/slsDetectors-FAQ/node49.html similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/node49.html rename to docs/html/slsDetectors-FAQ/node49.html diff --git a/manual/docs/html/slsDetectors-FAQ/node5.html b/docs/html/slsDetectors-FAQ/node5.html similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/node5.html rename to docs/html/slsDetectors-FAQ/node5.html diff --git a/manual/docs/html/slsDetectors-FAQ/node50.html b/docs/html/slsDetectors-FAQ/node50.html similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/node50.html rename to docs/html/slsDetectors-FAQ/node50.html diff --git a/manual/docs/html/slsDetectors-FAQ/node51.html b/docs/html/slsDetectors-FAQ/node51.html similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/node51.html rename to docs/html/slsDetectors-FAQ/node51.html diff --git a/manual/docs/html/slsDetectors-FAQ/node52.html b/docs/html/slsDetectors-FAQ/node52.html similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/node52.html rename to docs/html/slsDetectors-FAQ/node52.html diff --git a/manual/docs/html/slsDetectors-FAQ/node53.html b/docs/html/slsDetectors-FAQ/node53.html similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/node53.html rename to docs/html/slsDetectors-FAQ/node53.html diff --git a/manual/docs/html/slsDetectors-FAQ/node54.html b/docs/html/slsDetectors-FAQ/node54.html similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/node54.html rename to docs/html/slsDetectors-FAQ/node54.html diff --git a/manual/docs/html/slsDetectors-FAQ/node55.html b/docs/html/slsDetectors-FAQ/node55.html similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/node55.html rename to docs/html/slsDetectors-FAQ/node55.html diff --git a/manual/docs/html/slsDetectors-FAQ/node56.html b/docs/html/slsDetectors-FAQ/node56.html similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/node56.html rename to docs/html/slsDetectors-FAQ/node56.html diff --git a/manual/docs/html/slsDetectors-FAQ/node57.html b/docs/html/slsDetectors-FAQ/node57.html similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/node57.html rename to docs/html/slsDetectors-FAQ/node57.html diff --git a/manual/docs/html/slsDetectors-FAQ/node58.html b/docs/html/slsDetectors-FAQ/node58.html similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/node58.html rename to docs/html/slsDetectors-FAQ/node58.html diff --git a/manual/docs/html/slsDetectors-FAQ/node59.html b/docs/html/slsDetectors-FAQ/node59.html similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/node59.html rename to docs/html/slsDetectors-FAQ/node59.html diff --git a/manual/docs/html/slsDetectors-FAQ/node6.html b/docs/html/slsDetectors-FAQ/node6.html similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/node6.html rename to docs/html/slsDetectors-FAQ/node6.html diff --git a/manual/docs/html/slsDetectors-FAQ/node60.html b/docs/html/slsDetectors-FAQ/node60.html similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/node60.html rename to docs/html/slsDetectors-FAQ/node60.html diff --git a/manual/docs/html/slsDetectors-FAQ/node61.html b/docs/html/slsDetectors-FAQ/node61.html similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/node61.html rename to docs/html/slsDetectors-FAQ/node61.html diff --git a/manual/docs/html/slsDetectors-FAQ/node62.html b/docs/html/slsDetectors-FAQ/node62.html similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/node62.html rename to docs/html/slsDetectors-FAQ/node62.html diff --git a/manual/docs/html/slsDetectors-FAQ/node63.html b/docs/html/slsDetectors-FAQ/node63.html similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/node63.html rename to docs/html/slsDetectors-FAQ/node63.html diff --git a/manual/docs/html/slsDetectors-FAQ/node64.html b/docs/html/slsDetectors-FAQ/node64.html similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/node64.html rename to docs/html/slsDetectors-FAQ/node64.html diff --git a/manual/docs/html/slsDetectors-FAQ/node65.html b/docs/html/slsDetectors-FAQ/node65.html similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/node65.html rename to docs/html/slsDetectors-FAQ/node65.html diff --git a/manual/docs/html/slsDetectors-FAQ/node66.html b/docs/html/slsDetectors-FAQ/node66.html similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/node66.html rename to docs/html/slsDetectors-FAQ/node66.html diff --git a/manual/docs/html/slsDetectors-FAQ/node7.html b/docs/html/slsDetectors-FAQ/node7.html similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/node7.html rename to docs/html/slsDetectors-FAQ/node7.html diff --git a/manual/docs/html/slsDetectors-FAQ/node8.html b/docs/html/slsDetectors-FAQ/node8.html similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/node8.html rename to docs/html/slsDetectors-FAQ/node8.html diff --git a/manual/docs/html/slsDetectors-FAQ/node9.html b/docs/html/slsDetectors-FAQ/node9.html similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/node9.html rename to docs/html/slsDetectors-FAQ/node9.html diff --git a/manual/docs/html/slsDetectors-FAQ/slsDetectors-FAQ.css b/docs/html/slsDetectors-FAQ/slsDetectors-FAQ.css similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/slsDetectors-FAQ.css rename to docs/html/slsDetectors-FAQ/slsDetectors-FAQ.css diff --git a/manual/docs/html/slsDetectors-FAQ/slsDetectors-FAQ.html b/docs/html/slsDetectors-FAQ/slsDetectors-FAQ.html similarity index 100% rename from manual/docs/html/slsDetectors-FAQ/slsDetectors-FAQ.html rename to docs/html/slsDetectors-FAQ/slsDetectors-FAQ.html diff --git a/manual/docs/pdf/angularCalibrationHowTo.pdf b/docs/pdf/angularCalibrationHowTo.pdf similarity index 100% rename from manual/docs/pdf/angularCalibrationHowTo.pdf rename to docs/pdf/angularCalibrationHowTo.pdf diff --git a/manual/docs/pdf/energyCalibrationHowTo.pdf b/docs/pdf/energyCalibrationHowTo.pdf similarity index 100% rename from manual/docs/pdf/energyCalibrationHowTo.pdf rename to docs/pdf/energyCalibrationHowTo.pdf diff --git a/manual/docs/pdf/slsDetectorClientDocs.pdf b/docs/pdf/slsDetectorClientDocs.pdf similarity index 100% rename from manual/docs/pdf/slsDetectorClientDocs.pdf rename to docs/pdf/slsDetectorClientDocs.pdf diff --git a/manual/docs/pdf/slsDetectorClientHowTo.pdf b/docs/pdf/slsDetectorClientHowTo.pdf similarity index 100% rename from manual/docs/pdf/slsDetectorClientHowTo.pdf rename to docs/pdf/slsDetectorClientHowTo.pdf diff --git a/manual/docs/pdf/slsDetectorGuiHowTo.pdf b/docs/pdf/slsDetectorGuiHowTo.pdf similarity index 100% rename from manual/docs/pdf/slsDetectorGuiHowTo.pdf rename to docs/pdf/slsDetectorGuiHowTo.pdf diff --git a/manual/docs/pdf/slsDetectorInstall.pdf b/docs/pdf/slsDetectorInstall.pdf similarity index 100% rename from manual/docs/pdf/slsDetectorInstall.pdf rename to docs/pdf/slsDetectorInstall.pdf diff --git a/manual/docs/pdf/slsDetectorUsersDocs.pdf b/docs/pdf/slsDetectorUsersDocs.pdf similarity index 100% rename from manual/docs/pdf/slsDetectorUsersDocs.pdf rename to docs/pdf/slsDetectorUsersDocs.pdf diff --git a/manual/docs/pdf/slsDetectors-FAQ.pdf b/docs/pdf/slsDetectors-FAQ.pdf similarity index 100% rename from manual/docs/pdf/slsDetectors-FAQ.pdf rename to docs/pdf/slsDetectors-FAQ.pdf diff --git a/evalVersionVariables.sh b/evalVersionVariables.sh deleted file mode 100644 index 5824ca13c..000000000 --- a/evalVersionVariables.sh +++ /dev/null @@ -1,22 +0,0 @@ -GITREPO1='git remote -v' -GITREPO2=" | grep \"fetch\" | cut -d' ' -f1" -BRANCH1='git branch -v' -BRANCH2=" | grep '*' | cut -d' ' -f2" -REPUID1='git log --pretty=format:"%H" -1' -AUTH1_1='git log --pretty=format:"%cn" -1' -AUTH1_2=" | cut -d' ' -f1" -AUTH2_1='git log --pretty=format:"%cn" -1' -AUTH2_2=" | cut -d' ' -f2" -FOLDERREV1='git log --oneline . ' #used for all the individual server folders -FOLDERREV2=" | wc -l" #used for all the individual server folders -REV1='git log --oneline ' -REV2=" | wc -l" - -GITREPO=`eval $GITREPO1 $GITREPO2` -BRANCH=`eval $BRANCH1 $BRANCH2` -REPUID=`eval $REPUID1` -AUTH1=`eval $AUTH1_1 $AUTH1_2` -AUTH2=`eval $AUTH2_1 $AUTH2_2` -REV=`eval $REV1 $REV2` -FOLDERREV=`eval $FOLDERREV1 $FOLDERREV2` - diff --git a/examples/ang.off b/examples/ang.off deleted file mode 100755 index 819a60667..000000000 --- a/examples/ang.off +++ /dev/null @@ -1,24 +0,0 @@ - module 0 center 6.395E+02 +- 0.00E+00 conversion 6.5660E-05 +- 7.10E-09 offset 0.00000 +- 0.00015 - module 1 center 6.395E+02 +- 0.00E+00 conversion 6.5650E-05 +- 7.09E-09 offset 5.00211 +- 0.00015 - module 2 center 6.395E+02 +- 0.00E+00 conversion 6.5625E-05 +- 7.09E-09 offset 10.00733 +- 0.00015 - module 3 center 6.395E+02 +- 0.00E+00 conversion 6.5618E-05 +- 7.09E-09 offset 15.00742 +- 0.00015 - module 4 center 6.395E+02 +- 0.00E+00 conversion 6.5642E-05 +- 7.15E-09 offset 20.00620 +- 0.00015 - module 5 center 6.395E+02 +- 0.00E+00 conversion 6.5612E-05 +- 7.09E-09 offset 25.00281 +- 0.00015 - module 6 center 6.395E+02 +- 0.00E+00 conversion 6.5623E-05 +- 6.93E-09 offset 30.00704 +- 0.00015 - module 7 center 6.395E+02 +- 0.00E+00 conversion 6.5605E-05 +- 7.10E-09 offset 34.99715 +- 0.00015 - module 8 center 6.395E+02 +- 0.00E+00 conversion 6.5643E-05 +- 7.21E-09 offset 39.99533 +- 0.00015 - module 9 center 6.395E+02 +- 0.00E+00 conversion 6.5638E-05 +- 7.09E-09 offset 44.99969 +- 0.00015 - module 10 center 6.395E+02 +- 0.00E+00 conversion 6.5638E-05 +- 6.94E-09 offset 49.99859 +- 0.00015 - module 11 center 6.395E+02 +- 0.00E+00 conversion 6.5644E-05 +- 7.10E-09 offset 54.99499 +- 0.00015 - module 12 center 6.395E+02 +- 0.00E+00 conversion 6.5618E-05 +- 7.09E-09 offset 59.99120 +- 0.00015 - module 13 center 6.395E+02 +- 0.00E+00 conversion 6.5607E-05 +- 7.11E-09 offset 64.98880 +- 0.00015 - module 14 center 6.395E+02 +- 0.00E+00 conversion 6.5609E-05 +- 7.09E-09 offset 69.98205 +- 0.00015 - module 15 center 6.395E+02 +- 0.00E+00 conversion 6.5611E-05 +- 7.09E-09 offset 74.98379 +- 0.00015 - module 16 center 6.395E+02 +- 0.00E+00 conversion 6.5619E-05 +- 4.72E-09 offset 79.98559 +- 0.00015 - module 17 center 6.395E+02 +- 0.00E+00 conversion 6.5604E-05 +- 7.09E-09 offset 84.98376 +- 0.00015 - module 18 center 6.395E+02 +- 0.00E+00 conversion 6.5605E-05 +- 7.09E-09 offset 89.98307 +- 0.00015 - module 19 center 6.395E+02 +- 0.00E+00 conversion 6.5616E-05 +- 7.09E-09 offset 94.98907 +- 0.00015 - module 20 center 6.395E+02 +- 0.00E+00 conversion 6.5634E-05 +- 7.08E-09 offset 99.97965 +- 0.00015 - module 21 center 6.395E+02 +- 0.00E+00 conversion 6.5608E-05 +- 4.16E-09 offset 104.99732 +- 0.00016 - module 22 center 6.395E+02 +- 0.00E+00 conversion 6.5608E-05 +- 7.09E-09 offset 109.98646 +- 0.00015 - module 23 center 6.395E+02 +- 0.00E+00 conversion 6.5649E-05 +- 7.09E-09 offset 114.98765 +- 0.00015 diff --git a/examples/bad.chans b/examples/bad.chans deleted file mode 100644 index 6e7db22a2..000000000 --- a/examples/bad.chans +++ /dev/null @@ -1,5 +0,0 @@ -15 -1528 -5000 -6513 - diff --git a/examples/config_gen_script/beb_31_25.config_gen b/examples/config_gen_script/beb_31_25.config_gen deleted file mode 100644 index eb4216877..000000000 --- a/examples/config_gen_script/beb_31_25.config_gen +++ /dev/null @@ -1,47 +0,0 @@ -#!/bin/bash - -# local variables -dir=/home/l_msdetect/martin/sls_detectors_package/settingsdir/eiger - -# HOSTNAMES is special -# Beside of the hostname line it also defines the amount of (half) modules -# for the body part -# take care for the last space -HOSTNAMES="beb031 beb025 " - -## header contains constant values at the beginning of the file -header=( -detsizechan="2048 512" -) - -## the body part is for each half module -# counters will count automatically -# the number behind ':' indicates the incrementation value - -counters=( -rx_tcpport="1958:1" -rx_udpport="50001:2" -rx_udpport2="50002:2" -) - -# constant values -constants=( -rx_hostname="mpc1975" -lock=0 -settingsdir=$dir -caldir=$dir -) - -# lists contains space separated lists each value for each half module -lists=( -#detectorip="10.1.1.214 10.1.1.213 10.1.1.216 10.1.1.211 10.1.1.215 10.1.1.210 10.1.1.217 10.1.1.212" -) - - -## footer contains constant values for the end of the file -footer=( -outdir=/home/l_msdetect/martin/out -threaded=1 -clkdivider=2 -) - diff --git a/examples/config_gen_script/config_gen b/examples/config_gen_script/config_gen deleted file mode 100755 index 28f813912..000000000 --- a/examples/config_gen_script/config_gen +++ /dev/null @@ -1,71 +0,0 @@ -#!/bin/bash - -if [ "$1" == "--help" ]; then - echo This tool generates config files. - echo Please edit the variables in the script - echo and run $0 \> output.config. - exit -fi - -if [ "$1" == "" ]; then - echo This script generates config files for slsDetector out of config_gen files - echo Please specify the config_gen file - exit -fi - -. $1 - - -function get_name_value -{ - name=${1%%=*} - value=${1#*=} -} - -function shift_var -{ - shifts=$1 - shift - shift $shifts - value=$1 -} - - -echo hostname ${HOSTNAMES// /+} -for i in "${header[@]}"; do - get_name_value "$i" - echo $name $value -done - -echo - -num=0 -for host in $HOSTNAMES; do - for i in "${counters[@]}"; do - get_name_value "$i" - value2=${value%%:*} - inc=${value#*:} - echo $num:$name $((value2+$((num*$inc)))) - done - - for i in "${lists[@]}"; do - get_name_value "$i" - shift_var $num $value - echo $num:$name $value - done - - for i in "${constants[@]}"; do - get_name_value "$i" - echo $num:$name $value - done - echo - num=$((num+1)) -done - -for i in "${footer[@]}"; do - get_name_value "$i" - echo $name $value -done - -exit - diff --git a/examples/config_gen_script/eiger_2m_1gb.config_gen b/examples/config_gen_script/eiger_2m_1gb.config_gen deleted file mode 100644 index 5a315e23b..000000000 --- a/examples/config_gen_script/eiger_2m_1gb.config_gen +++ /dev/null @@ -1,47 +0,0 @@ -#!/bin/bash - -# local variables -dir=/home/l_msdetect/martin/sls_detectors_package/settingsdir/eiger - -# HOSTNAMES is special -# Beside of the hostname line it also defines the amount of (half) modules -# for the body part -# take care for the last space -HOSTNAMES="beb074 beb071 beb064 beb102 beb087 beb088 beb072 beb073 " - -## header contains constant values at the beginning of the file -header=( -detsizechan="4096 512" -) - -## the body part is for each half module -# counters will count automatically -# the number behind ':' indicates the incrementation value - -counters=( -rx_tcpport="1991:1" -rx_udpport="50011:2" -rx_udpport2="50012:2" -) - -# constant values -constants=( -rx_hostname="10.1.1.100" -rx_udpip="10.1.1.100" -lock=0 -settingsdir=$dir -caldir=$dir -) - -# lists contains space separated lists each value for each half module -lists=( -detectorip="10.1.1.214 10.1.1.213 10.1.1.216 10.1.1.211 10.1.1.215 10.1.1.210 10.1.1.217 10.1.1.212" -) - - -## footer contains constant values for the end of the file -footer=( -outdir=/home/l_msdetect/martin/out -threaded=1 -) - diff --git a/examples/eiger_10Gb.config b/examples/eiger_10Gb.config deleted file mode 100644 index 2635deb3f..000000000 --- a/examples/eiger_10Gb.config +++ /dev/null @@ -1,33 +0,0 @@ -detsizechan 1024 512 -#detetctor geometry, long side of the module first -hostname beb059+beb058+ -#1Gb detector hostname for controls - -0:rx_tcpport 1991 -#tcpport for the first halfmodule -0:rx_udpport 50011 -#udp port first quadrant, first halfmodule -0:rx_udpport2 50012 -#udp port second quadrant, first halfmodule -0:rx_udpip 10.0.30.210 -#udp IP of the receiver over 10Gb -0:detectorip 10.0.30.100 -#first half module 10 Gb IP - -1:rx_tcpport 1992 -#tcpport for the second halfmodule -1:rx_udpport 50013 -#udp port first quadrant, second halfmodule -1:rx_udpport2 50014 -#udp port second quadrant, second halfmodule -1:rx_udpip 10.0.40.210 -#udp IP of the receiver over 10Gb, -#can be the same or different from 0:rx_udpip -1:detectorip 10.0.40.101 -#second half module 10 Gb IP - -rx_hostname x12sa-vcons -#1Gb receiver pc hostname - -outdir /sls/X12SA/data/x12saop/Data10/Eiger0.5M -threaded 1 diff --git a/examples/eiger_1Gb.config b/examples/eiger_1Gb.config deleted file mode 100644 index a36225844..000000000 --- a/examples/eiger_1Gb.config +++ /dev/null @@ -1,24 +0,0 @@ -detsizechan 1024 512 -#detetctor geometry, long side of the module first -hostname beb059+beb058+ -#1Gb detector hostname for controls - -0:rx_tcpport 1991 -#tcpport for the first halfmodule -0:rx_udpport 50011 -#udp port first quadrant, first halfmodule -0:rx_udpport2 50012 -#udp port second quadrant, first halfmodule - -1:rx_tcpport 1992 -#tcpport for the second halfmodule -1:rx_udpport 50013 -#udp port first quadrant, second halfmodule -1:rx_udpport2 50014 -#udp port second quadrant, second halfmodule - -rx_hostname x12sa-vcons -#1Gb receiver pc hostname - -outdir /sls/X12SA/data/x12saop/Data10/Eiger0.5M -threaded 1 diff --git a/examples/gotthard.config b/examples/gotthard.config deleted file mode 100644 index f2c290df0..000000000 --- a/examples/gotthard.config +++ /dev/null @@ -1,27 +0,0 @@ -hostname bchip007 - -#0:port 1952 -#0:stopport 1953 -#0:rx_tcpport 1956 must also have this in receiver config file -0:angdir 1.000000 -0:moveflag 0.000000 -0:extsig:0 off -#0:detectorip 129.129.202.9 -0:detectormac 00:aa:bb:cc:dd:ee -0:rx_udpport 50004 -0:rx_udpip 129.129.202.98 -0:rx_hostname pc6898 -0:outdir /bigRAID/datadir_gotthard/rec_test_data -0:vhighvoltage 120 -master -1 -sync none -outdir /bigRAID/datadir_gotthard/rec_test_data -headerbefore none -headerafter none -headerbeforepar none -headerafterpar none -badchannels none -angconv none -globaloff 0.000000 -binsize 0.001000 - diff --git a/examples/gotthard_setup.det b/examples/gotthard_setup.det deleted file mode 100644 index 518c0ad6c..000000000 --- a/examples/gotthard_setup.det +++ /dev/null @@ -1,32 +0,0 @@ -fname run -index 0 -dr 16 -settings veryhighgain -threshold 0 -exptime 0.000002990 -period 0.000024984 -delay 0.999999968 -gates 1 -frames 300000.000000000 -cycles 1.000000000 -timing auto -fineoff 0.000000 -startscript none -startscriptpar none -stopscript none -stopscriptpar none -scriptbefore none -scriptbeforepar none -scriptafter none -scriptafterpar none -scan0script none -scan0par none -scan0prec 0 -scan0steps 0 -scan1script none -scan1par none -scan1prec 0 -scan1steps 0 -ratecorr 0.000000 -flatfield none -badchannels none diff --git a/examples/jungfrau.config b/examples/jungfrau.config deleted file mode 100644 index b5c8f734e..000000000 --- a/examples/jungfrau.config +++ /dev/null @@ -1,15 +0,0 @@ -hostname bchip038+ - -0:rx_udpport 50004 -0:rx_udpip 10.1.1.100 -0:detectorip 10.1.1.10 -rx_hostname pcmoench01 - -powerchip 1 - -#extsig:0 trigger_in_rising_edge -#timing trigger - -outdir /external_pool/jungfrau_data/softwaretest - - diff --git a/examples/jungfrau_two.config b/examples/jungfrau_two.config deleted file mode 100644 index 16e50e57d..000000000 --- a/examples/jungfrau_two.config +++ /dev/null @@ -1,25 +0,0 @@ -detsizechan 1024 1024 -hostname bchip048+bchip052+ - -0:rx_udpport 50004 -0:rx_udpip 10.1.1.100 -0:rx_udpmac F4:52:14:2F:32:00 -0:detectorip 10.1.1.10 -0:detectormac 00:aa:bb:cc:dd:33 - -1:rx_tcpport 1955 -1:rx_udpport 50005 -1:rx_udpip 10.1.1.100 -1:rx_udpmac F4:52:14:2F:32:00 -1:detectorip 10.1.1.11 -1:detectormac 00:aa:bb:cc:dd:33 - -rx_hostname pcmoench01 - -powerchip 1 -#extsig:0 trigger_in_rising_edge -#timing trigger - -outdir /external_pool/jungfrau_data/softwaretest - - diff --git a/examples/mythen.config b/examples/mythen.config deleted file mode 100644 index 3390c61c8..000000000 --- a/examples/mythen.config +++ /dev/null @@ -1,32 +0,0 @@ -type Mythen+ -0:hostname mcs1x21 -0:port 1952 -0:stopport 1953 -0:settingsdir /afs/psi.ch/user/b/bergamaschi -0:outdir /afs/psi.ch/user/b/bergamaschi -0:angdir 1.000000 -0:moveflag 1.000000 -0:lock 0 -0:caldir /afs/psi.ch/user/b/bergamaschi -0:ffdir /afs/psi.ch/user/b/bergamaschi -0:nmod 1 -0:waitstates 13 -0:setlength 3 -0:clkdivider 6 -0:extsig:0 gate_in_active_high -0:extsig:1 trigger_in_rising_edge -0:extsig:2 off -0:extsig:3 off -master -1 -sync none -outdir /afs/psi.ch/user/b/bergamaschi -ffdir /afs/psi.ch/user/b/bergamaschi -headerbefore none -headerafter none -headerbeforepar none -headerafterpar none -badchannels none -angconv none -globaloff 0.000000 -binsize 0.001000 -threaded 1 diff --git a/examples/receiver.config b/examples/receiver.config deleted file mode 100644 index fa4586e14..000000000 --- a/examples/receiver.config +++ /dev/null @@ -1 +0,0 @@ -dataport 1955 diff --git a/examples/scripts/.parab b/examples/scripts/.parab deleted file mode 100644 index 4aae0c133..000000000 --- a/examples/scripts/.parab +++ /dev/null @@ -1,36 +0,0 @@ -header before -Thu May 31 11:28:55 CEST 2012 -run=-1 -acquisition time = 1.000000 second(s) -mythen gain mode = standard -threshold energy = 6255 eV -bad channel list = /sls/X04SA/data/x04sa/newMythenSoftware/cal/bad_both.chans -angle calibration conversion = /sls/X04SA/data/x04sa/newMythenSoftware/cal/ang_both_20120422_good2.off -beamline offset = 5.088000 deg -fine offset = 0.000000 deg -Flat field corrections = 0.000000 -Dead time corrections tau = 0 ns -X04SA-ES2-TH2:RO.RBV 11.99985 deg -X04SA-OP-MOX2:ROX.RBV 9.17041130 deg -X04SA-OP-MOX1:ROX.RBV 9.17683938 deg -X04SA-DCM:E2 12.4054 keV -X04SA-ID-GAP:READ 5.015 mm -ARIDI-PCT:CURRENT 401 mA -X04SA-ES2-OVEN:TEMP_RBV 1768.00 C -X04SA-ES2-SAM:TR3 0.00000 mm -X04SA-ES2-SAM:TR2 0.00000 mm -X04SA-ES2-SAM:TR1 0.00000 mm -X04SA-ES2-LT1:TR2.RBV 1213.25000 mm -X04SA-ES2-SV1:t2.D 0.090 -X04SA-ES2-SV1:t2.C 1.800 -X04SA-ES2-SH1:t2.D 0.150 -X04SA-ES2-SH1:t2.C 8.300 -X04SA-ES2-FI8:SET "Out" (SEVR:INVALID STAT:UDF) -X04SA-ES2-SC:CH6 46071870 -Thu May 31 11:29:01 CEST 2012 -header after -X04SA-ES2-SC:CH6 46177281 -X04SA-ES2-TH2:RO.RBV 11.99985 deg -X04SA-ID-GAP:READ 5.015 mm -ARIDI-PCT:CURRENT 401 mA -X04SA-ES2-OVEN:TEMP_RBV 1768.00 C diff --git a/examples/scripts/HeaderBeforeAfter.awk b/examples/scripts/HeaderBeforeAfter.awk deleted file mode 100755 index 9b1354471..000000000 --- a/examples/scripts/HeaderBeforeAfter.awk +++ /dev/null @@ -1,142 +0,0 @@ -#! /bin/awk -f - -# this is an awk script to start a run -# you first need to run inimodule.awk to initialize -# the pattern, set Vc and set the trimbits -# - -##################################################################### -# revision history # -##################################################################### -# 31.10.2001 first version # -##################################################################### -# # -# Bernd Schmitt # -# # -# bernd.schmitt@psi.ch # -# # -##################################################################### -# # -# modifications: # -# # -# 1.3.2002 BS adapted for use with DCB # -# # -# 25.5.2002 BS adapted to new convert program # -# # -# 29.5.2002 sleep -> usleep for meas. time , TS # -# # -##################################################################### - -BEGIN { - -# initialize variables - NPAR=3 - - PAR[1]="nrun" - PAR[2]="fn" - PAR[3]="par" - -# initialize default values - - - - PARVAL[1] = 100 - PARVAL[2] = "microstrip_july2007" - PARVAL[3]=0 - - - - - - printf("\n\nnumber of command line arguments: %i (incl. command)\n\n", ARGC); - -# read command line defined variables - if (ARGC>1) { - printf("\n\nnumber of command line arguments: %i (incl. command)\n\n", ARGC); - for (i=1; i<=ARGC; i++) { - printf("%s \n", ARGV[i]); - nsplit=split(ARGV[i],array,"=") - VAR = array[1]; - VAL = array[2]; - - for (j=1; j<=NPAR; j++) { - if ( VAR==PAR[j] ) { - PARVAL[j] = VAL - } - } - } - } - run=PARVAL[1] - fn=PARVAL[2] - par=PARVAL[3] - - -# print command line arguments - for (i=1; i<=NPAR; i++){ - printf("\t... %2i.\t%7s = %s\n", i, PAR[i], PARVAL[i] ); - } - printf("\n\n"); - -# generate parameter file - - fnamep=fn".parab" - printf("header before\n")>> fnamep - system("date >>"fnamep) - printf("run=%i \n", run ) >> fnamep - -#print detector parameters to file - if (par==1) { - - command="sls_detector_get exptime| awk -F \" \" '{print $2}'" - command | getline var - printf("acquisition time = %11.6f second(s)\n", var) >> fnamep - - command="sls_detector_get settings| awk -F \" \" '{print $2}'" - command | getline var - printf("settings = %s\n", var) >> fnamep; - - command="sls_detector_get threshold| awk -F \" \" '{print $2}'" - command | getline var - printf("threshold energy = %d eV\n", var) >> fnamep; - - command="sls_detector_get badchannels| awk -F \" \" '{print $2}'" - command | getline var - printf("bad channel list = %s\n",var) >> fnamep; - - - command="sls_detector_get angconv| awk -F \" \" '{print $2}'" - command | getline var - printf("angle calibration conversion = %s\n",var) >> fnamep; - - - command="sls_detector_get globaloff| awk -F \" \" '{print $2}'" - command | getline var - printf("beamline offset = %f deg\n", var) >> fnamep; - - command="sls_detector_get fineoff| awk -F \" \" '{print $2}'" - command | getline var - printf("fine offset = %f deg\n", var) >> fnamep; - - command="sls_detector_get flatfield| awk -F \" \" '{print $2}'" - command | getline var - printf("Flat field corrections = %s\n",var) >> fnamep; - - command="sls_detector_get ratecorr| awk -F \" \" '{print $2}'" - command | getline var - printf("Dead time corrections tau = %d ns\n",var) >> fnamep; - - } - - -#print beamline parameters to file - -#read detector position - system("caget X04SA-ES2-TH2:RO.RBV >>"fnamep) -#read I0 - system("caget X04SA-ES2-SC:CH6>>"fnamep) -} - - - - - diff --git a/examples/scripts/ScanScript.awk b/examples/scripts/ScanScript.awk deleted file mode 100755 index 7617e340c..000000000 --- a/examples/scripts/ScanScript.awk +++ /dev/null @@ -1,87 +0,0 @@ -#! /bin/awk -f - -# this is an awk script to start a run -# you first need to run inimodule.awk to initialize -# the pattern, set Vc and set the trimbits -# - -##################################################################### -# revision history # -##################################################################### -# 31.10.2001 first version # -##################################################################### -# # -# Bernd Schmitt # -# # -# bernd.schmitt@psi.ch # -# # -##################################################################### -# # -# modifications: # -# # -# 1.3.2002 BS adapted for use with DCB # -# # -# 25.5.2002 BS adapted to new convert program # -# # -# 29.5.2002 sleep -> usleep for meas. time , TS # -# # -##################################################################### - -BEGIN { - -# initialize variables - NPAR=4 - - PAR[1]="nrun" - PAR[2]="fn" - PAR[3]="var" - PAR[4]="par" - - -# initialize default values - PARVAL[1] = 100 - PARVAL[2] = "myfname" - PARVAL[3] = 0 - PARVAL[2] = "none" - - - -# read command line defined variables - if (ARGC>1) { - printf("\n\nnumber of command line arguments: %i (incl. command)\n\n", ARGC); - for (i=1; i<=ARGC; i++) { - - nsplit=split(ARGV[i],array,"=") - VAR = array[1]; - VAL = array[2]; - - for (j=1; j<=NPAR; j++) { - if ( VAR==PAR[j] ) { - PARVAL[j] = VAL - } - } - } - } - - run=PARVAL[1] - fn=PARVAL[2] - var=PARVAL[3] - par=PARVAL[4] - - - - -# print command line arguments - for (i=1; i<=NPAR; i++){ - printf("\t... %2i.\t%7s = %s\n", i, PAR[i], PARVAL[i] ); - } - -#execute you command hereafter e.g. change temperature etc. - - -} - - - - - diff --git a/examples/scripts/ScriptBeforeAfter.awk b/examples/scripts/ScriptBeforeAfter.awk deleted file mode 100755 index 14838e280..000000000 --- a/examples/scripts/ScriptBeforeAfter.awk +++ /dev/null @@ -1,100 +0,0 @@ -#! /bin/awk -f - -# this is an awk script to start a run -# you first need to run inimodule.awk to initialize -# the pattern, set Vc and set the trimbits -# - -##################################################################### -# revision history # -##################################################################### -# 31.10.2001 first version # -##################################################################### -# # -# Bernd Schmitt # -# # -# bernd.schmitt@psi.ch # -# # -##################################################################### -# # -# modifications: # -# # -# 1.3.2002 BS adapted for use with DCB # -# # -# 25.5.2002 BS adapted to new convert program # -# # -# 29.5.2002 sleep -> usleep for meas. time , TS # -# # -##################################################################### - -BEGIN { - -# initialize variables - NPAR=7 - - PAR[1]="nrun" - PAR[2]="fn" - PAR[3]="par" - PAR[4]="sv0" - PAR[5]="sv1" - PAR[6]="p0" - PAR[7]="p1" - -# initialize default values - PARVAL[1] = 100 - PARVAL[2] = "myfname" - PARVAL[3] = 1 - PARVAL[4] = 0 - PARVAL[5] = 0 - PARVAL[6] = "none" - PARVAL[7] = "none" - - - -# read command line defined variables - if (ARGC>1) { - printf("\n\nnumber of command line arguments: %i (incl. command)\n\n", ARGC); - for (i=1; i<=ARGC; i++) { - - nsplit=split(ARGV[i],array,"=") - VAR = array[1]; - VAL = array[2]; - - for (j=1; j<=NPAR; j++) { - if ( VAR==PAR[j] ) { - PARVAL[j] = VAL - } - } - } - } - - run=PARVAL[1] - fn=PARVAL[2] - "par"PAR[3]= - sv0=PAR[4] - sv1=PAR[5] - p0=PAR[6] - p1=PAR[7] - - - -# print command line arguments - for (i=1; i<=NPAR; i++){ - printf("\t... %2i.\t%7s = %s\n", i, PAR[i], PARVAL[i] ); - } -# printf("\n\n"); - # system("close_shutter_g95") - -# execute your actions hereafter - if (par==1) { - #open shutter - } else { - #close shutter - } - -} - - - - - diff --git a/examples/scripts/StartStopScript.awk b/examples/scripts/StartStopScript.awk deleted file mode 100755 index f8e53917c..000000000 --- a/examples/scripts/StartStopScript.awk +++ /dev/null @@ -1,79 +0,0 @@ -#! /bin/awk -f - -# this is an awk script to start a run -# you first need to run inimodule.awk to initialize -# the pattern, set Vc and set the trimbits -# - -##################################################################### -# revision history # -##################################################################### -# 31.10.2001 first version # -##################################################################### -# # -# Bernd Schmitt # -# # -# bernd.schmitt@psi.ch # -# # -##################################################################### -# # -# modifications: # -# # -# 1.3.2002 BS adapted for use with DCB # -# # -# 25.5.2002 BS adapted to new convert program # -# # -# 29.5.2002 sleep -> usleep for meas. time , TS # -# # -##################################################################### - -BEGIN { - -# initialize variables - NPAR=2 - - PAR[1]="nrun" - PAR[2]="par" - - -# initialize default values - PARVAL[1] = 100 - PARVAL[2] = "none" - - - -# read command line defined variables - if (ARGC>1) { - printf("\n\nnumber of command line arguments: %i (incl. command)\n\n", ARGC); - for (i=1; i<=ARGC; i++) { - - nsplit=split(ARGV[i],array,"=") - VAR = array[1]; - VAL = array[2]; - - for (j=1; j<=NPAR; j++) { - if ( VAR==PAR[j] ) { - PARVAL[j] = VAL - } - } - } - } - - run=PARVAL[1] - par=PARVAL[2] - - - - -# print command line arguments - for (i=1; i<=NPAR; i++){ - printf("\t... %2i.\t%7s = %s\n", i, PAR[i], PARVAL[i] ); - } -#execute action hereafter - -} - - - - - diff --git a/examples/scripts/slsReceiverScript b/examples/scripts/slsReceiverScript deleted file mode 100755 index 284552a97..000000000 --- a/examples/scripts/slsReceiverScript +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/bash - -STARTPORT=$1 -AMOUNT=$2 - -if [ "$2" == "" ]; then - echo Syntax: $0 STARTPORT AMOUNT - echo Example: $0 1991 8 gives you 8 receivers starting with port 1991 -fi - -declare -A ARG - -count=0 -for i in `seq $STARTPORT $((STARTPORT+$((AMOUNT-1))))`; do - if [ "$((count%2))" == "0" ]; then - ARG[$count]="slsReceiver --rx_tcpport $i" - else - ARG[$count]="slsReceiver --rx_tcpport $i --mode 1" - fi - count=$((count+1)) -done - -xterms -k "${ARG[@]}" diff --git a/examples/scripts/xterms b/examples/scripts/xterms deleted file mode 100755 index 119597473..000000000 --- a/examples/scripts/xterms +++ /dev/null @@ -1,42 +0,0 @@ -#!/bin/bash - -# This script starts several xterms, one for each argument -# If the first argument is -k the script waits for you pressing Ctr-C and kills all started xterms afterwards. -# -# example: -# xterms "ls -lah; sleep 4" "runprogramm -f 2" - -if [ "$1" == "-k" ]; then - DOKILL=1 - shift -fi - -LINE=0 -COLUMN=-330 -for i in `seq 1 $#`; do - COLUMN=$((COLUMN+$((i%2))*330)) - echo xterm -g 50x20+${COLUMN}+${LINE} -e ${!i} & - xterm -g 50x20+${COLUMN}+${LINE} -e ${!i} & - PID[$i]=$! - LINE=$((i%2*330)) -done - - -#for i in `seq 0 $(($#-1))`; do -# LINES=$(((i-i%4)/4)) -# arg=$((i+1)) -# xterm -g 50x20+$(((i%4)*330))+$((LINES*330)) -e ${!arg} & -# PID[$i]=$! -#done - -if [ "$DOKILL" != "1" ]; then - exit -fi - -while (true); do - read -done - -for i in ${PID[@]}; do - kill $i -done diff --git a/examples/two_gotthard.config b/examples/two_gotthard.config deleted file mode 100644 index 3f9763d57..000000000 --- a/examples/two_gotthard.config +++ /dev/null @@ -1,55 +0,0 @@ -#####Any line with a # is not read###### - -detsizechan 2560 1 - -hostname bchip007+bchip009+ - -#0:hostname bchip007 -#0:port 1952 -#0:stopport 1953 -#0:rx_tcpport 1956 -0:angdir 1.000000 -0:moveflag 0.000000 -0:ffdir /home/l_msdetect -0:extsig:0 off - -0:detectorip 10.1.1.2 -#0:detectormac 00:aa:bb:cc:dd:ee -#0:rx_udpport 50001 -0:rx_udpip 10.1.1.1 -0:rx_hostname 129.129.202.134 -0:outdir /data/speedt -0:vhighvoltage 120 - - -#1:hostname bchip009 -#1:port 1952 -#1:stopport 1953 -1:rx_tcpport 1957 -1:angdir 1.000000 -1:moveflag 0.000000 -1:ffdir /home/l_msdetect -1:extsig:0 off - -1:detectorip 10.1.2.2 -#1:detectormac 00:aa:bb:cc:dd:ee -1:rx_udpport 50004 -1:rx_udpip 10.1.2.1 -1:rx_hostname 129.129.202.134 -1:outdir /data/speedt -1:vhighvoltage 120 - - -master -1 -sync none -outdir /data/speedt -ffdir /home/l_msdetect -headerbefore none -headerafter none -headerbeforepar none -headerafterpar none -badchannels none -angconv none -globaloff 0.000000 -binsize 0.001000 - diff --git a/examples/two_no_receiver.config b/examples/two_no_receiver.config deleted file mode 100644 index 18718ad64..000000000 --- a/examples/two_no_receiver.config +++ /dev/null @@ -1,64 +0,0 @@ -#####Any line with a # is not read###### - -#type Gotthard+ -hostname bchip007+bchip009+ - -#0:hostname bchip007 -#0:port 1952 -#0:stopport 1953 -#0:rx_tcpport 1956 -0:settingsdir /home/l_msdetect/dhanya/slsDetectorsPackage/settingsdir/gotthard -0:angdir 1.000000 -0:moveflag 0.000000 -0:lock 0 -0:caldir /home/l_msdetect/dhanya/slsDetectorsPackage/settingsdir/gotthard -0:ffdir /home/l_msdetect -0:extsig:0 off -0:extsig:1 off -0:extsig:2 off -0:extsig:3 off -#0:detectorip 10.1.1.2 -#0:detectormac 00:aa:bb:cc:dd:ee -#0:rx_udpport 50001 -#0:rx_udpip 10.1.1.1 -#0:rx_hostname 129.129.202.134 -0:outdir /data/speedt -0:vhighvoltage 120 - - -#1:hostname bchip009 -#1:port 1952 -#1:stopport 1953 -1:rx_tcpport 1957 -1:settingsdir /home/l_msdetect/dhanya/slsDetectorsPackage/settingsdir/gotthard -1:angdir 1.000000 -1:moveflag 0.000000 -1:lock 0 -1:caldir /home/l_msdetect/dhanya/slsDetectorsPackage/settingsdir/gotthard -1:ffdir /home/l_msdetect -1:extsig:0 off -1:extsig:1 off -1:extsig:2 off -1:extsig:3 off -#1:detectorip 10.1.2.2 -#1:detectormac 00:aa:bb:cc:dd:ee -#1:rx_udpport 50004 -#1:rx_udpip 10.1.2.1 -#1:rx_hostname 129.129.202.134 -1:outdir /data/speedt -1:vhighvoltage 120 - - -master -1 -sync none -outdir /data/speedt -ffdir /home/l_msdetect -headerbefore none -headerafter none -headerbeforepar none -headerafterpar none -badchannels none -angconv none -globaloff 0.000000 -binsize 0.001000 -threaded 1 diff --git a/genVersionHeader.sh b/genVersionHeader.sh deleted file mode 100755 index 12b5d8c26..000000000 --- a/genVersionHeader.sh +++ /dev/null @@ -1,25 +0,0 @@ -#####! /bin/awk -f - - -if [ $# -lt 3 ] -then - echo "wrong usage" - exit -1 -fi - - -fin=$1 -ftmp=$2 -fout=$3 - - -#dat=echo "date '+%Y%m%d'" - -echo "Updating $fout" -#echo "in: $fin tmp: $ftmp out: $fout" - -#awk 'NR==FNR {if ($3=="Date:") {l[FNR]=$4; gsub("-","",l[FNR]);} else { if (match($0,"Rev")) {l[FNR]=$(NF);} else {l[FNR]="\""$(NF)"\"";};};next} {$0=$1" "$2" "l[FNR]}1' $fin $ftmp > $fout - -awk 'BEGIN {l[0]=0; "date +%Y%m%d" | getline l[1]; l[2]="\"/\""; l[3]="\"nobody\""; l[3]="\"nobody\""; l[4]="\"0000-0000-0000\"";} \ -NR==FNR {if (match($0,"Rev")) {l[0]="0x"$(NF);} else if (match($0,"Date")) {l[1]="0x"$4; gsub("-","",l[1]);} else if (match($0,"URL")) {l[2]="\""$(NF)"\"";} else if (match($0,"Author")) {l[3]="\""$(NF)"\"";} else if (match($0,"UUID")) {l[4]="\""$(NF)"\"";} else if (match($0,"Branch")) {l[5]="\""$(NF)"\"";};next;} -{if (match($2,"REV")) {$0=$1" "$2" "l[0];} else if (match($2,"DATE")) {$0=$1" "$2" "l[1];} else if (match($2,"URL")) {$0=$1" "$2" "l[2];} else if (match($2,"AUTH")) {$0=$1" "$2" "l[3];} else if (match($2,"UUID")) {$0=$1" "$2" "l[4];} else if (match($2,"BRANCH")) {$0=$1" "$2" "l[5];}}1' $fin $ftmp > $fout diff --git a/recipe/build.sh b/recipe/build.sh deleted file mode 100644 index fba3f4626..000000000 --- a/recipe/build.sh +++ /dev/null @@ -1,15 +0,0 @@ -mkdir build -mkdir install -cd build -cmake .. \ - -DCMAKE_PREFIX_PATH=$CONDA_PREFIX \ - -DCMAKE_INSTALL_PREFIX=install \ - -DSLS_USE_TEXTCLIENT=ON \ - -DSLS_USE_RECEIVER=ON \ - -DSLS_USE_GUI=ON \ - -DCMAKE_BUILD_TYPE=Release \ - -DSLS_USE_HDF5=OFF\ - - -cmake --build . -- -j10 -cmake --build . --target install \ No newline at end of file diff --git a/recipe/copy_gui.sh b/recipe/copy_gui.sh deleted file mode 100644 index 26ce29890..000000000 --- a/recipe/copy_gui.sh +++ /dev/null @@ -1,15 +0,0 @@ - -mkdir $PREFIX/lib -mkdir $PREFIX/bin -mkdir $PREFIX/include - -#No libs for gui? - -#Binaries -cp build/bin/gui_client $PREFIX/bin/. -cp build/bin/slsDetectorGui $PREFIX/bin/. - - -#Which headers do we need for development?? - -# cp include/some_lib.h $PREFIX/include/. \ No newline at end of file diff --git a/recipe/copy_lib.sh b/recipe/copy_lib.sh deleted file mode 100644 index 353397418..000000000 --- a/recipe/copy_lib.sh +++ /dev/null @@ -1,23 +0,0 @@ - -mkdir $PREFIX/lib -mkdir $PREFIX/bin -mkdir $PREFIX/include -mkdir $PREFIX/include/slsDetectorPackage - -#Shared and static libraries -cp build/bin/libSlsDetector.so $PREFIX/lib/. -# cp build/bin/libSlsDetector.a $PREFIX/lib/. -cp build/bin/libSlsReceiver.so $PREFIX/lib/. -# cp build/bin/libSlsReceiver.a $PREFIX/lib/. - -#Binaries -cp build/bin/sls_detector_acquire $PREFIX/bin/. -cp build/bin/sls_detector_get $PREFIX/bin/. -cp build/bin/sls_detector_put $PREFIX/bin/. -cp build/bin/sls_detector_help $PREFIX/bin/. -cp build/bin/slsReceiver $PREFIX/bin/. -cp build/bin/slsMultiReceiver $PREFIX/bin/. - -#Which headers do we need for development?? -cp build/install/include/* $PREFIX/include/slsDetectorPackage/ -# cp include/some_lib.h $PREFIX/include/. \ No newline at end of file diff --git a/recipe/meta.yaml b/recipe/meta.yaml deleted file mode 100644 index f795a7142..000000000 --- a/recipe/meta.yaml +++ /dev/null @@ -1,89 +0,0 @@ - -package: - name: sls_detector_software - version: 4.0.1 - -source: - - path: .. - -build: - number: 1 - rpaths: - - lib/ - -requirements: - build: - - {{ compiler('c') }} - - {{compiler('cxx')}} - - cmake - - qwt 6.* - - qt=4.8.7=7 - - zeromq=4.2.5=hfc679d8_5 - - pyzmq - - xorg-libx11 - - xorg-libice - - xorg-libxext - - xorg-libsm - - xorg-libxau - - xorg-libxrender - - xorg-libxfixes - - {{ cdt('mesa-libgl-devel') }} # [linux] - - {{ cdt('mesa-libegl-devel') }} # [linux] - - {{ cdt('mesa-dri-drivers') }} # [linux] - - {{ cdt('libselinux') }} # [linux] - - {{ cdt('libxdamage') }} # [linux] - - {{ cdt('libxxf86vm') }} # [linux] - - host: - - libstdcxx-ng - - libgcc-ng - - libpng >=1.6.32,<1.6.35 - - xorg-libx11 - - xorg-libice - - xorg-libxext - - xorg-libsm - - xorg-libxau - - xorg-libxrender - - xorg-libxfixes - - run: - - libstdcxx-ng - - libgcc-ng - -outputs: - - name: sls_detector_lib - version: 4.0.1 - script: copy_lib.sh - requirements: - build: - - {{ compiler('c') }} - - {{compiler('cxx')}} - - name: sls_detector_gui - version: 4.0.1 - script: copy_gui.sh - requirements: - build: - - {{ compiler('c') }} - - {{compiler('cxx')}} - - cmake - - qwt 6.* - - qt=4.8.7=7 - - zeromq=4.2.5=hfc679d8_5 - - pyzmq - - xorg-libx11 - - xorg-libice - - xorg-libxext - - xorg-libsm - - xorg-libxau - - xorg-libxrender - - xorg-libxfixes - - {{ cdt('mesa-libgl-devel') }} # [linux] - - {{ cdt('mesa-libegl-devel') }} # [linux] - - {{ cdt('mesa-dri-drivers') }} # [linux] - - {{ cdt('libselinux') }} # [linux] - - {{ cdt('libxdamage') }} # [linux] - - {{ cdt('libxxf86vm') }} # [linux] - run: - - sls_detector_lib=4.0.1 - - qwt 6.* - - qt=4.8.7=7 diff --git a/serverBin/eigerDetectorServer_virtualMaster b/serverBin/eigerDetectorServer_virtualMaster deleted file mode 120000 index 8bab52260..000000000 --- a/serverBin/eigerDetectorServer_virtualMaster +++ /dev/null @@ -1 +0,0 @@ -../slsDetectorSoftware/eigerDetectorServer/bin/eigerDetectorServer_virtualMaster \ No newline at end of file diff --git a/serverBin/eigerDetectorServer_virtualSlave b/serverBin/eigerDetectorServer_virtualSlave deleted file mode 120000 index fb644ed5c..000000000 --- a/serverBin/eigerDetectorServer_virtualSlave +++ /dev/null @@ -1 +0,0 @@ -../slsDetectorSoftware/eigerDetectorServer/bin/eigerDetectorServer_virtualSlave \ No newline at end of file diff --git a/serverBin/eigerDetectorServerv4.0.1.22.1 b/serverBin/eigerDetectorServerv4.0.1.22.1 deleted file mode 120000 index 04312328b..000000000 --- a/serverBin/eigerDetectorServerv4.0.1.22.1 +++ /dev/null @@ -1 +0,0 @@ -../slsDetectorSoftware/eigerDetectorServer/bin/eigerDetectorServerv4.0.1.22.1 \ No newline at end of file diff --git a/serverBin/gotthardDetectorServer_virtual b/serverBin/gotthardDetectorServer_virtual deleted file mode 120000 index e0f7013b5..000000000 --- a/serverBin/gotthardDetectorServer_virtual +++ /dev/null @@ -1 +0,0 @@ -../slsDetectorSoftware/gotthardDetectorServer/gotthardDetectorServer_virtual \ No newline at end of file diff --git a/serverBin/gotthardDetectorServerv4.0.1.4 b/serverBin/gotthardDetectorServerv4.0.1.4 deleted file mode 120000 index bfc7b6c24..000000000 --- a/serverBin/gotthardDetectorServerv4.0.1.4 +++ /dev/null @@ -1 +0,0 @@ -../slsDetectorSoftware/gotthardDetectorServer/gotthardDetectorServerv4.0.1.4 \ No newline at end of file diff --git a/serverBin/jungfrauDetectorServer_virtual b/serverBin/jungfrauDetectorServer_virtual deleted file mode 120000 index cbb38b3d6..000000000 --- a/serverBin/jungfrauDetectorServer_virtual +++ /dev/null @@ -1 +0,0 @@ -../slsDetectorSoftware/jungfrauDetectorServer/bin/jungfrauDetectorServer_virtual \ No newline at end of file diff --git a/serverBin/jungfrauDetectorServerv4.0.1.0 b/serverBin/jungfrauDetectorServerv4.0.1.0 deleted file mode 120000 index 807c9b778..000000000 --- a/serverBin/jungfrauDetectorServerv4.0.1.0 +++ /dev/null @@ -1 +0,0 @@ -../slsDetectorSoftware/jungfrauDetectorServer/bin/jungfrauDetectorServerv4.0.1.0 \ No newline at end of file diff --git a/serverBin/mythenDetectorServerv2.0.3 b/serverBin/mythenDetectorServerv2.0.3 deleted file mode 120000 index c9fc9abae..000000000 --- a/serverBin/mythenDetectorServerv2.0.3 +++ /dev/null @@ -1 +0,0 @@ -../slsDetectorSoftware/mythenDetectorServer/mythenDetectorServerv2.0.3 \ No newline at end of file diff --git a/settingsdir/eiger/highgain/calibration.snbeb045 b/settingsdir/eiger/highgain/calibration.snbeb045 deleted file mode 100644 index e5a59be31..000000000 --- a/settingsdir/eiger/highgain/calibration.snbeb045 +++ /dev/null @@ -1 +0,0 @@ -227 5.6 diff --git a/settingsdir/eiger/highgain/highgain.cal b/settingsdir/eiger/highgain/highgain.cal deleted file mode 100644 index bee36aa38..000000000 --- a/settingsdir/eiger/highgain/highgain.cal +++ /dev/null @@ -1,4 +0,0 @@ -3486.22 365.75 -3518.43 368.23 -3519.11 357.62 -3491.49 365.08 diff --git a/settingsdir/eiger/highgain/highgain.trim b/settingsdir/eiger/highgain/highgain.trim deleted file mode 100644 index e0693222f..000000000 Binary files a/settingsdir/eiger/highgain/highgain.trim and /dev/null differ diff --git a/settingsdir/eiger/highgain/settings.snbeb045 b/settingsdir/eiger/highgain/settings.snbeb045 deleted file mode 100644 index 137957115..000000000 Binary files a/settingsdir/eiger/highgain/settings.snbeb045 and /dev/null differ diff --git a/settingsdir/eiger/lowgain/calibration.snbeb045 b/settingsdir/eiger/lowgain/calibration.snbeb045 deleted file mode 100644 index e5a59be31..000000000 --- a/settingsdir/eiger/lowgain/calibration.snbeb045 +++ /dev/null @@ -1 +0,0 @@ -227 5.6 diff --git a/settingsdir/eiger/lowgain/lowgain.cal b/settingsdir/eiger/lowgain/lowgain.cal deleted file mode 100644 index c848f17f3..000000000 --- a/settingsdir/eiger/lowgain/lowgain.cal +++ /dev/null @@ -1,4 +0,0 @@ -3415.26 226.24 -3406.35 223.45 -3407.89 225.60 -3385.72 220.54 diff --git a/settingsdir/eiger/lowgain/lowgain.trim b/settingsdir/eiger/lowgain/lowgain.trim deleted file mode 100644 index a699c3454..000000000 Binary files a/settingsdir/eiger/lowgain/lowgain.trim and /dev/null differ diff --git a/settingsdir/eiger/lowgain/settings.snbeb045 b/settingsdir/eiger/lowgain/settings.snbeb045 deleted file mode 100644 index 137957115..000000000 Binary files a/settingsdir/eiger/lowgain/settings.snbeb045 and /dev/null differ diff --git a/settingsdir/eiger/standard/4500eV/noise.sn031 b/settingsdir/eiger/standard/4500eV/noise.sn031 deleted file mode 100644 index fa8c26055..000000000 Binary files a/settingsdir/eiger/standard/4500eV/noise.sn031 and /dev/null differ diff --git a/settingsdir/eiger/standard/4500eV/noise.sn032 b/settingsdir/eiger/standard/4500eV/noise.sn032 deleted file mode 100644 index 4f333106f..000000000 Binary files a/settingsdir/eiger/standard/4500eV/noise.sn032 and /dev/null differ diff --git a/settingsdir/eiger/standard/5400eV/noise.sn031 b/settingsdir/eiger/standard/5400eV/noise.sn031 deleted file mode 100644 index 787ba5cc8..000000000 Binary files a/settingsdir/eiger/standard/5400eV/noise.sn031 and /dev/null differ diff --git a/settingsdir/eiger/standard/5400eV/noise.sn032 b/settingsdir/eiger/standard/5400eV/noise.sn032 deleted file mode 100644 index 196d6b714..000000000 Binary files a/settingsdir/eiger/standard/5400eV/noise.sn032 and /dev/null differ diff --git a/settingsdir/eiger/standard/6400eV/noise.sn031 b/settingsdir/eiger/standard/6400eV/noise.sn031 deleted file mode 100644 index 33c9f9532..000000000 Binary files a/settingsdir/eiger/standard/6400eV/noise.sn031 and /dev/null differ diff --git a/settingsdir/eiger/standard/6400eV/noise.sn032 b/settingsdir/eiger/standard/6400eV/noise.sn032 deleted file mode 100644 index 26ec9290c..000000000 Binary files a/settingsdir/eiger/standard/6400eV/noise.sn032 and /dev/null differ diff --git a/settingsdir/eiger/standard/calibration.sn031 b/settingsdir/eiger/standard/calibration.sn031 deleted file mode 100644 index 1c934f729..000000000 --- a/settingsdir/eiger/standard/calibration.sn031 +++ /dev/null @@ -1,5 +0,0 @@ -3851.3 517.439 -3850.95 521.812 -3845.29 518.808 -3645.21 484.783 -410 \ No newline at end of file diff --git a/settingsdir/eiger/standard/calibration.sn032 b/settingsdir/eiger/standard/calibration.sn032 deleted file mode 100644 index 1c934f729..000000000 --- a/settingsdir/eiger/standard/calibration.sn032 +++ /dev/null @@ -1,5 +0,0 @@ -3851.3 517.439 -3850.95 521.812 -3845.29 518.808 -3645.21 484.783 -410 \ No newline at end of file diff --git a/settingsdir/eiger/standard/eigernoise.sn049 b/settingsdir/eiger/standard/eigernoise.sn049 deleted file mode 100644 index f2523eb94..000000000 Binary files a/settingsdir/eiger/standard/eigernoise.sn049 and /dev/null differ diff --git a/settingsdir/eiger/standard/noise.sn031 b/settingsdir/eiger/standard/noise.sn031 deleted file mode 100644 index 2daeaebb4..000000000 Binary files a/settingsdir/eiger/standard/noise.sn031 and /dev/null differ diff --git a/settingsdir/eiger/standard/noise.sn032 b/settingsdir/eiger/standard/noise.sn032 deleted file mode 100644 index 2daeaebb4..000000000 Binary files a/settingsdir/eiger/standard/noise.sn032 and /dev/null differ diff --git a/settingsdir/eiger/standard/standard.cal b/settingsdir/eiger/standard/standard.cal deleted file mode 100644 index e5be5608f..000000000 --- a/settingsdir/eiger/standard/standard.cal +++ /dev/null @@ -1,4 +0,0 @@ -3419.26 282.68 -3451.04 285.35 -3451.30 277.63 -3431.27 283.41 diff --git a/settingsdir/eiger/standard/standard.trim b/settingsdir/eiger/standard/standard.trim deleted file mode 100644 index 15d1e1982..000000000 Binary files a/settingsdir/eiger/standard/standard.trim and /dev/null differ diff --git a/settingsdir/eiger/veryhighgain/calibration.sn031 b/settingsdir/eiger/veryhighgain/calibration.sn031 deleted file mode 100644 index 1c934f729..000000000 --- a/settingsdir/eiger/veryhighgain/calibration.sn031 +++ /dev/null @@ -1,5 +0,0 @@ -3851.3 517.439 -3850.95 521.812 -3845.29 518.808 -3645.21 484.783 -410 \ No newline at end of file diff --git a/settingsdir/eiger/veryhighgain/calibration.sn032 b/settingsdir/eiger/veryhighgain/calibration.sn032 deleted file mode 100644 index 1c934f729..000000000 --- a/settingsdir/eiger/veryhighgain/calibration.sn032 +++ /dev/null @@ -1,5 +0,0 @@ -3851.3 517.439 -3850.95 521.812 -3845.29 518.808 -3645.21 484.783 -410 \ No newline at end of file diff --git a/settingsdir/eiger/veryhighgain/noise.sn031 b/settingsdir/eiger/veryhighgain/noise.sn031 deleted file mode 100644 index 2daeaebb4..000000000 Binary files a/settingsdir/eiger/veryhighgain/noise.sn031 and /dev/null differ diff --git a/settingsdir/eiger/veryhighgain/noise.sn032 b/settingsdir/eiger/veryhighgain/noise.sn032 deleted file mode 100644 index 2daeaebb4..000000000 Binary files a/settingsdir/eiger/veryhighgain/noise.sn032 and /dev/null differ diff --git a/settingsdir/eiger/veryhighgain/veryhighgain.cal b/settingsdir/eiger/veryhighgain/veryhighgain.cal deleted file mode 100644 index f37c466c2..000000000 --- a/settingsdir/eiger/veryhighgain/veryhighgain.cal +++ /dev/null @@ -1,4 +0,0 @@ -3381.13 493.21 -3385.45 490.36 -3374.03 492.96 -3363.40 483.72 diff --git a/settingsdir/eiger/veryhighgain/veryhighgain.trim b/settingsdir/eiger/veryhighgain/veryhighgain.trim deleted file mode 100644 index c9ed1eef6..000000000 Binary files a/settingsdir/eiger/veryhighgain/veryhighgain.trim and /dev/null differ diff --git a/settingsdir/eiger/verylowgain/calibration.sn031 b/settingsdir/eiger/verylowgain/calibration.sn031 deleted file mode 100644 index 1c934f729..000000000 --- a/settingsdir/eiger/verylowgain/calibration.sn031 +++ /dev/null @@ -1,5 +0,0 @@ -3851.3 517.439 -3850.95 521.812 -3845.29 518.808 -3645.21 484.783 -410 \ No newline at end of file diff --git a/settingsdir/eiger/verylowgain/calibration.sn032 b/settingsdir/eiger/verylowgain/calibration.sn032 deleted file mode 100644 index 1c934f729..000000000 --- a/settingsdir/eiger/verylowgain/calibration.sn032 +++ /dev/null @@ -1,5 +0,0 @@ -3851.3 517.439 -3850.95 521.812 -3845.29 518.808 -3645.21 484.783 -410 \ No newline at end of file diff --git a/settingsdir/eiger/verylowgain/noise.sn031 b/settingsdir/eiger/verylowgain/noise.sn031 deleted file mode 100644 index 2daeaebb4..000000000 Binary files a/settingsdir/eiger/verylowgain/noise.sn031 and /dev/null differ diff --git a/settingsdir/eiger/verylowgain/noise.sn032 b/settingsdir/eiger/verylowgain/noise.sn032 deleted file mode 100644 index 2daeaebb4..000000000 Binary files a/settingsdir/eiger/verylowgain/noise.sn032 and /dev/null differ diff --git a/settingsdir/eiger/verylowgain/verylowgain.cal b/settingsdir/eiger/verylowgain/verylowgain.cal deleted file mode 100644 index 6a768da00..000000000 --- a/settingsdir/eiger/verylowgain/verylowgain.cal +++ /dev/null @@ -1,4 +0,0 @@ -3323.57 124.58 -3336.87 124.85 -3302.45 123.64 -3338.19 124.44 diff --git a/settingsdir/eiger/verylowgain/verylowgain.trim b/settingsdir/eiger/verylowgain/verylowgain.trim deleted file mode 100644 index ed9907e10..000000000 Binary files a/settingsdir/eiger/verylowgain/verylowgain.trim and /dev/null differ diff --git a/settingsdir/mythen/fast/calibration.snxxx b/settingsdir/mythen/fast/calibration.snxxx deleted file mode 100755 index 326e7f501..000000000 --- a/settingsdir/mythen/fast/calibration.snxxx +++ /dev/null @@ -1 +0,0 @@ -800 10 diff --git a/settingsdir/mythen/fast/fast.cal b/settingsdir/mythen/fast/fast.cal deleted file mode 100755 index 1e0a97fbb..000000000 --- a/settingsdir/mythen/fast/fast.cal +++ /dev/null @@ -1 +0,0 @@ -829 9.3 diff --git a/settingsdir/mythen/fast/fast.trim b/settingsdir/mythen/fast/fast.trim deleted file mode 100755 index be2e8fa45..000000000 --- a/settingsdir/mythen/fast/fast.trim +++ /dev/null @@ -1,1296 +0,0 @@ -Vtrim 824 -Vthresh 560 -Rgsh1 200 -Rgsh2 300 -Rgpr 50 -Vcal 600 -outBuffEnable 0 -0 2 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -outBuffEnable 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -outBuffEnable 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -outBuffEnable 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -outBuffEnable 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -outBuffEnable 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -outBuffEnable 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -outBuffEnable 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -outBuffEnable 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -outBuffEnable 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 diff --git a/settingsdir/mythen/fast/noise.snxxx b/settingsdir/mythen/fast/noise.snxxx deleted file mode 100644 index fda6c5045..000000000 --- a/settingsdir/mythen/fast/noise.snxxx +++ /dev/null @@ -1,1296 +0,0 @@ -Vtrim 800 -Vthresh 700 -Rgsh1 200 -Rgsh2 300 -Rgpr 50 -Vcal 600 -outBuffEnable 0 -36 1 0 0 0 0 -13 1 0 0 0 0 -26 1 0 0 0 0 -17 1 0 0 0 0 -34 1 0 0 0 0 -22 1 0 0 0 0 -30 1 0 0 0 0 -27 1 0 0 0 0 -34 1 0 0 0 0 -32 1 0 0 0 0 -27 1 0 0 0 0 -34 1 0 0 0 0 -24 1 0 0 0 0 -22 1 0 0 0 0 -18 1 0 0 0 0 -29 1 0 0 0 0 -57 1 0 0 0 0 -15 1 0 0 0 0 -31 1 0 0 0 0 -34 1 0 0 0 0 -25 1 0 0 0 0 -31 1 0 0 0 0 -29 1 0 0 0 0 -34 1 0 0 0 0 -33 1 0 0 0 0 -33 1 0 0 0 0 -32 1 0 0 0 0 -22 1 0 0 0 0 -30 1 0 0 0 0 -19 1 0 0 0 0 -33 1 0 0 0 0 -43 1 0 0 0 0 -32 1 0 0 0 0 -31 1 0 0 0 0 -30 1 0 0 0 0 -34 1 0 0 0 0 -28 1 0 0 0 0 -22 1 0 0 0 0 -31 1 0 0 0 0 -14 1 0 0 0 0 -36 1 0 0 0 0 -21 1 0 0 0 0 -29 1 0 0 0 0 -26 1 0 0 0 0 -28 1 0 0 0 0 -30 1 0 0 0 0 -25 1 0 0 0 0 -36 1 0 0 0 0 -21 1 0 0 0 0 -33 1 0 0 0 0 -9 1 0 0 0 0 -30 1 0 0 0 0 -33 1 0 0 0 0 -26 1 0 0 0 0 -37 1 0 0 0 0 -31 1 0 0 0 0 -23 1 0 0 0 0 -27 1 0 0 0 0 -41 1 0 0 0 0 -23 1 0 0 0 0 -34 1 0 0 0 0 -31 1 0 0 0 0 -35 1 0 0 0 0 -28 1 0 0 0 0 -36 1 0 0 0 0 -34 1 0 0 0 0 -28 1 0 0 0 0 -33 1 0 0 0 0 -32 1 0 0 0 0 -36 1 0 0 0 0 -42 1 0 0 0 0 -40 1 0 0 0 0 -22 1 0 0 0 0 -26 1 0 0 0 0 -31 1 0 0 0 0 -39 1 0 0 0 0 -34 1 0 0 0 0 -37 1 0 0 0 0 -27 1 0 0 0 0 -29 1 0 0 0 0 -30 1 0 0 0 0 -37 1 0 0 0 0 -28 1 0 0 0 0 -15 1 0 0 0 0 -29 1 0 0 0 0 -29 1 0 0 0 0 -43 1 0 0 0 0 -25 1 0 0 0 0 -25 1 0 0 0 0 -24 1 0 0 0 0 -29 1 0 0 0 0 -43 1 0 0 0 0 -40 1 0 0 0 0 -23 1 0 0 0 0 -20 1 0 0 0 0 -40 1 0 0 0 0 -26 1 0 0 0 0 -32 1 0 0 0 0 -33 1 0 0 0 0 -38 1 0 0 0 0 -44 1 0 0 0 0 -34 1 0 0 0 0 -31 1 0 0 0 0 -46 1 0 0 0 0 -32 1 0 0 0 0 -44 1 0 0 0 0 -29 1 0 0 0 0 -38 1 0 0 0 0 -32 1 0 0 0 0 -43 1 0 0 0 0 -33 1 0 0 0 0 -33 1 0 0 0 0 -48 1 0 0 0 0 -19 1 0 0 0 0 -26 1 0 0 0 0 -42 1 0 0 0 0 -33 1 0 0 0 0 -27 1 0 0 0 0 -28 1 0 0 0 0 -44 1 0 0 0 0 -21 1 0 0 0 0 -36 1 0 0 0 0 -28 1 0 0 0 0 -36 1 0 0 0 0 -48 1 0 0 0 0 -30 1 0 0 0 0 -43 1 0 0 0 0 -16 1 0 0 0 0 -outBuffEnable 0 -30 1 0 0 0 0 -35 1 0 0 0 0 -30 1 0 0 0 0 -17 1 0 0 0 0 -21 1 0 0 0 0 -24 1 0 0 0 0 -10 1 0 0 0 0 -46 1 0 0 0 0 -27 1 0 0 0 0 -18 1 0 0 0 0 -43 1 0 0 0 0 -31 1 0 0 0 0 -19 1 0 0 0 0 -29 1 0 0 0 0 -40 1 0 0 0 0 -18 1 0 0 0 0 -35 1 0 0 0 0 -35 1 0 0 0 0 -19 1 0 0 0 0 -41 1 0 0 0 0 -29 1 0 0 0 0 -26 1 0 0 0 0 -34 1 0 0 0 0 -22 1 0 0 0 0 -23 1 0 0 0 0 -37 1 0 0 0 0 -33 1 0 0 0 0 -25 1 0 0 0 0 -40 1 0 0 0 0 -35 1 0 0 0 0 -36 1 0 0 0 0 -30 1 0 0 0 0 -30 1 0 0 0 0 -41 1 0 0 0 0 -33 1 0 0 0 0 -22 1 0 0 0 0 -28 1 0 0 0 0 -36 1 0 0 0 0 -24 1 0 0 0 0 -33 1 0 0 0 0 -30 1 0 0 0 0 -34 1 0 0 0 0 -27 1 0 0 0 0 -26 1 0 0 0 0 -31 1 0 0 0 0 -38 1 0 0 0 0 -31 1 0 0 0 0 -33 1 0 0 0 0 -40 1 0 0 0 0 -20 1 0 0 0 0 -41 1 0 0 0 0 -30 1 0 0 0 0 -26 1 0 0 0 0 -34 1 0 0 0 0 -35 1 0 0 0 0 -33 1 0 0 0 0 -27 1 0 0 0 0 -43 1 0 0 0 0 -18 1 0 0 0 0 -29 1 0 0 0 0 -27 1 0 0 0 0 -22 1 0 0 0 0 -27 1 0 0 0 0 -39 1 0 0 0 0 -27 1 0 0 0 0 -23 1 0 0 0 0 -41 1 0 0 0 0 -21 1 0 0 0 0 -29 1 0 0 0 0 -20 1 0 0 0 0 -36 1 0 0 0 0 -35 1 0 0 0 0 -32 1 0 0 0 0 -23 1 0 0 0 0 -30 1 0 0 0 0 -42 1 0 0 0 0 -27 1 0 0 0 0 -36 1 0 0 0 0 -33 1 0 0 0 0 -32 1 0 0 0 0 -26 1 0 0 0 0 -37 1 0 0 0 0 -38 1 0 0 0 0 -38 1 0 0 0 0 -30 1 0 0 0 0 -35 1 0 0 0 0 -36 1 0 0 0 0 -36 1 0 0 0 0 -27 1 0 0 0 0 -28 1 0 0 0 0 -33 1 0 0 0 0 -35 1 0 0 0 0 -34 1 0 0 0 0 -26 1 0 0 0 0 -34 1 0 0 0 0 -32 1 0 0 0 0 -38 1 0 0 0 0 -52 1 0 0 0 0 -38 1 0 0 0 0 -43 1 0 0 0 0 -33 1 0 0 0 0 -26 1 0 0 0 0 -25 1 0 0 0 0 -32 1 0 0 0 0 -32 1 0 0 0 0 -36 1 0 0 0 0 -37 1 0 0 0 0 -29 1 0 0 0 0 -28 1 0 0 0 0 -42 1 0 0 0 0 -36 1 0 0 0 0 -30 1 0 0 0 0 -37 1 0 0 0 0 -29 1 0 0 0 0 -35 1 0 0 0 0 -46 1 0 0 0 0 -33 1 0 0 0 0 -28 1 0 0 0 0 -41 1 0 0 0 0 -39 1 0 0 0 0 -39 1 0 0 0 0 -28 1 0 0 0 0 -28 1 0 0 0 0 -43 1 0 0 0 0 -43 1 0 0 0 0 -32 1 0 0 0 0 -23 1 0 0 0 0 -32 1 0 0 0 0 -outBuffEnable 0 -31 1 0 0 0 0 -22 1 0 0 0 0 -27 1 0 0 0 0 -19 1 0 0 0 0 -32 1 0 0 0 0 -40 1 0 0 0 0 -25 1 0 0 0 0 -25 1 0 0 0 0 -26 1 0 0 0 0 -35 1 0 0 0 0 -26 1 0 0 0 0 -22 1 0 0 0 0 -24 1 0 0 0 0 -24 1 0 0 0 0 -28 1 0 0 0 0 -32 1 0 0 0 0 -35 1 0 0 0 0 -35 1 0 0 0 0 -36 1 0 0 0 0 -25 1 0 0 0 0 -29 1 0 0 0 0 -24 1 0 0 0 0 -20 1 0 0 0 0 -28 1 0 0 0 0 -27 1 0 0 0 0 -29 1 0 0 0 0 -27 1 0 0 0 0 -37 1 0 0 0 0 -28 1 0 0 0 0 -29 1 0 0 0 0 -15 1 0 0 0 0 -41 1 0 0 0 0 -44 1 0 0 0 0 -33 1 0 0 0 0 -21 1 0 0 0 0 -27 1 0 0 0 0 -19 1 0 0 0 0 -35 1 0 0 0 0 -33 1 0 0 0 0 -34 1 0 0 0 0 -29 1 0 0 0 0 -29 1 0 0 0 0 -35 1 0 0 0 0 -38 1 0 0 0 0 -28 1 0 0 0 0 -31 1 0 0 0 0 -22 1 0 0 0 0 -35 1 0 0 0 0 -41 1 0 0 0 0 -16 1 0 0 0 0 -35 1 0 0 0 0 -29 1 0 0 0 0 -38 1 0 0 0 0 -25 1 0 0 0 0 -34 1 0 0 0 0 -27 1 0 0 0 0 -28 1 0 0 0 0 -42 1 0 0 0 0 -34 1 0 0 0 0 -36 1 0 0 0 0 -40 1 0 0 0 0 -34 1 0 0 0 0 -26 1 0 0 0 0 -30 1 0 0 0 0 -22 1 0 0 0 0 -26 1 0 0 0 0 -37 1 0 0 0 0 -24 1 0 0 0 0 -41 1 0 0 0 0 -39 1 0 0 0 0 -32 1 0 0 0 0 -21 1 0 0 0 0 -34 1 0 0 0 0 -20 1 0 0 0 0 -34 1 0 0 0 0 -25 1 0 0 0 0 -26 1 0 0 0 0 -27 1 0 0 0 0 -35 1 0 0 0 0 -40 1 0 0 0 0 -26 1 0 0 0 0 -24 1 0 0 0 0 -25 1 0 0 0 0 -28 1 0 0 0 0 -43 1 0 0 0 0 -34 1 0 0 0 0 -50 1 0 0 0 0 -26 1 0 0 0 0 -24 1 0 0 0 0 -37 1 0 0 0 0 -42 1 0 0 0 0 -29 1 0 0 0 0 -27 1 0 0 0 0 -26 1 0 0 0 0 -34 1 0 0 0 0 -35 1 0 0 0 0 -27 1 0 0 0 0 -25 1 0 0 0 0 -28 1 0 0 0 0 -29 1 0 0 0 0 -34 1 0 0 0 0 -29 1 0 0 0 0 -44 1 0 0 0 0 -30 1 0 0 0 0 -39 1 0 0 0 0 -30 1 0 0 0 0 -26 1 0 0 0 0 -25 1 0 0 0 0 -38 1 0 0 0 0 -41 1 0 0 0 0 -44 1 0 0 0 0 -39 1 0 0 0 0 -34 1 0 0 0 0 -45 1 0 0 0 0 -22 1 0 0 0 0 -34 1 0 0 0 0 -39 1 0 0 0 0 -40 1 0 0 0 0 -44 1 0 0 0 0 -33 1 0 0 0 0 -42 1 0 0 0 0 -30 1 0 0 0 0 -25 1 0 0 0 0 -31 1 0 0 0 0 -39 1 0 0 0 0 -31 1 0 0 0 0 -44 1 0 0 0 0 -47 1 0 0 0 0 -outBuffEnable 0 -29 1 0 0 0 0 -40 1 0 0 0 0 -14 1 0 0 0 0 -14 1 0 0 0 0 -21 1 0 0 0 0 -26 1 0 0 0 0 -17 1 0 0 0 0 -20 1 0 0 0 0 -24 1 0 0 0 0 -22 1 0 0 0 0 -19 1 0 0 0 0 -31 1 0 0 0 0 -32 1 0 0 0 0 -18 1 0 0 0 0 -34 1 0 0 0 0 -19 1 0 0 0 0 -10 1 0 0 0 0 -35 1 0 0 0 0 -33 1 0 0 0 0 -24 1 0 0 0 0 -33 1 0 0 0 0 -33 1 0 0 0 0 -23 1 0 0 0 0 -28 1 0 0 0 0 -32 1 0 0 0 0 -45 1 0 0 0 0 -22 1 0 0 0 0 -21 1 0 0 0 0 -21 1 0 0 0 0 -20 1 0 0 0 0 -22 1 0 0 0 0 -34 1 0 0 0 0 -33 1 0 0 0 0 -21 1 0 0 0 0 -38 1 0 0 0 0 -24 1 0 0 0 0 -32 1 0 0 0 0 -34 1 0 0 0 0 -29 1 0 0 0 0 -44 1 0 0 0 0 -43 1 0 0 0 0 -35 1 0 0 0 0 -16 1 0 0 0 0 -32 1 0 0 0 0 -40 1 0 0 0 0 -31 1 0 0 0 0 -22 1 0 0 0 0 -29 1 0 0 0 0 -33 1 0 0 0 0 -37 1 0 0 0 0 -23 1 0 0 0 0 -38 1 0 0 0 0 -28 1 0 0 0 0 -29 1 0 0 0 0 -46 1 0 0 0 0 -26 1 0 0 0 0 -27 1 0 0 0 0 -56 1 0 0 0 0 -33 1 0 0 0 0 -40 1 0 0 0 0 -41 1 0 0 0 0 -31 1 0 0 0 0 -14 1 0 0 0 0 -27 1 0 0 0 0 -23 1 0 0 0 0 -22 1 0 0 0 0 -35 1 0 0 0 0 -27 1 0 0 0 0 -30 1 0 0 0 0 -31 1 0 0 0 0 -32 1 0 0 0 0 -26 1 0 0 0 0 -16 1 0 0 0 0 -26 1 0 0 0 0 -35 1 0 0 0 0 -31 1 0 0 0 0 -35 1 0 0 0 0 -32 1 0 0 0 0 -29 1 0 0 0 0 -25 1 0 0 0 0 -29 1 0 0 0 0 -33 1 0 0 0 0 -28 1 0 0 0 0 -27 1 0 0 0 0 -25 1 0 0 0 0 -21 1 0 0 0 0 -27 1 0 0 0 0 -31 1 0 0 0 0 -40 1 0 0 0 0 -23 1 0 0 0 0 -33 1 0 0 0 0 -28 1 0 0 0 0 -33 1 0 0 0 0 -39 1 0 0 0 0 -28 1 0 0 0 0 -31 1 0 0 0 0 -27 1 0 0 0 0 -41 1 0 0 0 0 -36 1 0 0 0 0 -23 1 0 0 0 0 -28 1 0 0 0 0 -24 1 0 0 0 0 -25 1 0 0 0 0 -26 1 0 0 0 0 -24 1 0 0 0 0 -33 1 0 0 0 0 -31 1 0 0 0 0 -38 1 0 0 0 0 -25 1 0 0 0 0 -32 1 0 0 0 0 -30 1 0 0 0 0 -46 1 0 0 0 0 -40 1 0 0 0 0 -34 1 0 0 0 0 -26 1 0 0 0 0 -24 1 0 0 0 0 -29 1 0 0 0 0 -28 1 0 0 0 0 -32 1 0 0 0 0 -38 1 0 0 0 0 -41 1 0 0 0 0 -24 1 0 0 0 0 -24 1 0 0 0 0 -37 1 0 0 0 0 -42 1 0 0 0 0 -33 1 0 0 0 0 -26 1 0 0 0 0 -26 1 0 0 0 0 -outBuffEnable 0 -25 1 0 0 0 0 -23 1 0 0 0 0 -39 1 0 0 0 0 -23 1 0 0 0 0 -36 1 0 0 0 0 -26 1 0 0 0 0 -35 1 0 0 0 0 -23 1 0 0 0 0 -27 1 0 0 0 0 -25 1 0 0 0 0 -17 1 0 0 0 0 -36 1 0 0 0 0 -19 1 0 0 0 0 -28 1 0 0 0 0 -29 1 0 0 0 0 -36 1 0 0 0 0 -29 1 0 0 0 0 -9 1 0 0 0 0 -28 1 0 0 0 0 -22 1 0 0 0 0 -26 1 0 0 0 0 -42 1 0 0 0 0 -26 1 0 0 0 0 -33 1 0 0 0 0 -22 1 0 0 0 0 -32 1 0 0 0 0 -36 1 0 0 0 0 -38 1 0 0 0 0 -44 1 0 0 0 0 -23 1 0 0 0 0 -26 1 0 0 0 0 -25 1 0 0 0 0 -30 1 0 0 0 0 -21 1 0 0 0 0 -30 1 0 0 0 0 -23 1 0 0 0 0 -33 1 0 0 0 0 -35 1 0 0 0 0 -34 1 0 0 0 0 -33 1 0 0 0 0 -32 1 0 0 0 0 -35 1 0 0 0 0 -24 1 0 0 0 0 -29 1 0 0 0 0 -44 1 0 0 0 0 -33 1 0 0 0 0 -32 1 0 0 0 0 -29 1 0 0 0 0 -42 1 0 0 0 0 -23 1 0 0 0 0 -32 1 0 0 0 0 -29 1 0 0 0 0 -34 1 0 0 0 0 -38 1 0 0 0 0 -18 1 0 0 0 0 -23 1 0 0 0 0 -52 1 0 0 0 0 -28 1 0 0 0 0 -23 1 0 0 0 0 -35 1 0 0 0 0 -24 1 0 0 0 0 -32 1 0 0 0 0 -32 1 0 0 0 0 -25 1 0 0 0 0 -21 1 0 0 0 0 -31 1 0 0 0 0 -39 1 0 0 0 0 -35 1 0 0 0 0 -32 1 0 0 0 0 -28 1 0 0 0 0 -30 1 0 0 0 0 -22 1 0 0 0 0 -20 1 0 0 0 0 -36 1 0 0 0 0 -43 1 0 0 0 0 -35 1 0 0 0 0 -29 1 0 0 0 0 -16 1 0 0 0 0 -25 1 0 0 0 0 -26 1 0 0 0 0 -35 1 0 0 0 0 -29 1 0 0 0 0 -26 1 0 0 0 0 -39 1 0 0 0 0 -21 1 0 0 0 0 -36 1 0 0 0 0 -43 1 0 0 0 0 -46 1 0 0 0 0 -43 1 0 0 0 0 -41 1 0 0 0 0 -23 1 0 0 0 0 -32 1 0 0 0 0 -17 1 0 0 0 0 -19 1 0 0 0 0 -46 1 0 0 0 0 -38 1 0 0 0 0 -45 1 0 0 0 0 -25 1 0 0 0 0 -26 1 0 0 0 0 -28 1 0 0 0 0 -28 1 0 0 0 0 -24 1 0 0 0 0 -50 1 0 0 0 0 -32 1 0 0 0 0 -30 1 0 0 0 0 -29 1 0 0 0 0 -48 1 0 0 0 0 -44 1 0 0 0 0 -43 1 0 0 0 0 -28 1 0 0 0 0 -43 1 0 0 0 0 -34 1 0 0 0 0 -13 1 0 0 0 0 -41 1 0 0 0 0 -31 1 0 0 0 0 -24 1 0 0 0 0 -46 1 0 0 0 0 -24 1 0 0 0 0 -25 1 0 0 0 0 -30 1 0 0 0 0 -34 1 0 0 0 0 -40 1 0 0 0 0 -28 1 0 0 0 0 -29 1 0 0 0 0 -28 1 0 0 0 0 -29 1 0 0 0 0 -31 1 0 0 0 0 -29 1 0 0 0 0 -outBuffEnable 0 -25 1 0 0 0 0 -24 1 0 0 0 0 -30 1 0 0 0 0 -30 1 0 0 0 0 -26 1 0 0 0 0 -31 1 0 0 0 0 -29 1 0 0 0 0 -28 1 0 0 0 0 -29 1 0 0 0 0 -30 1 0 0 0 0 -21 1 0 0 0 0 -24 1 0 0 0 0 -17 1 0 0 0 0 -39 1 0 0 0 0 -12 1 0 0 0 0 -33 1 0 0 0 0 -20 1 0 0 0 0 -24 1 0 0 0 0 -33 1 0 0 0 0 -30 1 0 0 0 0 -33 1 0 0 0 0 -36 1 0 0 0 0 -18 1 0 0 0 0 -26 1 0 0 0 0 -28 1 0 0 0 0 -22 1 0 0 0 0 -22 1 0 0 0 0 -34 1 0 0 0 0 -31 1 0 0 0 0 -32 1 0 0 0 0 -30 1 0 0 0 0 -31 1 0 0 0 0 -28 1 0 0 0 0 -30 1 0 0 0 0 -27 1 0 0 0 0 -26 1 0 0 0 0 -35 1 0 0 0 0 -27 1 0 0 0 0 -28 1 0 0 0 0 -39 1 0 0 0 0 -29 1 0 0 0 0 -30 1 0 0 0 0 -28 1 0 0 0 0 -16 1 0 0 0 0 -36 1 0 0 0 0 -34 1 0 0 0 0 -19 1 0 0 0 0 -35 1 0 0 0 0 -52 1 0 0 0 0 -25 1 0 0 0 0 -23 1 0 0 0 0 -27 1 0 0 0 0 -25 1 0 0 0 0 -24 1 0 0 0 0 -23 1 0 0 0 0 -32 1 0 0 0 0 -33 1 0 0 0 0 -17 1 0 0 0 0 -32 1 0 0 0 0 -41 1 0 0 0 0 -17 1 0 0 0 0 -50 1 0 0 0 0 -25 1 0 0 0 0 -24 1 0 0 0 0 -23 1 0 0 0 0 -30 1 0 0 0 0 -30 1 0 0 0 0 -22 1 0 0 0 0 -34 1 0 0 0 0 -27 1 0 0 0 0 -25 1 0 0 0 0 -28 1 0 0 0 0 -61 1 0 0 0 0 -38 1 0 0 0 0 -43 1 0 0 0 0 -33 1 0 0 0 0 -39 1 0 0 0 0 -36 1 0 0 0 0 -22 1 0 0 0 0 -25 1 0 0 0 0 -27 1 0 0 0 0 -22 1 0 0 0 0 -26 1 0 0 0 0 -31 1 0 0 0 0 -21 1 0 0 0 0 -34 1 0 0 0 0 -35 1 0 0 0 0 -42 1 0 0 0 0 -33 1 0 0 0 0 -30 1 0 0 0 0 -24 1 0 0 0 0 -30 1 0 0 0 0 -34 1 0 0 0 0 -34 1 0 0 0 0 -33 1 0 0 0 0 -40 1 0 0 0 0 -27 1 0 0 0 0 -26 1 0 0 0 0 -37 1 0 0 0 0 -34 1 0 0 0 0 -27 1 0 0 0 0 -29 1 0 0 0 0 -33 1 0 0 0 0 -36 1 0 0 0 0 -33 1 0 0 0 0 -47 1 0 0 0 0 -28 1 0 0 0 0 -26 1 0 0 0 0 -30 1 0 0 0 0 -27 1 0 0 0 0 -27 1 0 0 0 0 -45 1 0 0 0 0 -27 1 0 0 0 0 -31 1 0 0 0 0 -32 1 0 0 0 0 -30 1 0 0 0 0 -32 1 0 0 0 0 -40 1 0 0 0 0 -31 1 0 0 0 0 -38 1 0 0 0 0 -32 1 0 0 0 0 -37 1 0 0 0 0 -28 1 0 0 0 0 -37 1 0 0 0 0 -32 1 0 0 0 0 -41 1 0 0 0 0 -44 1 0 0 0 0 -36 1 0 0 0 0 -outBuffEnable 0 -20 1 0 0 0 0 -41 1 0 0 0 0 -27 1 0 0 0 0 -12 1 0 0 0 0 -32 1 0 0 0 0 -27 1 0 0 0 0 -18 1 0 0 0 0 -4 1 0 0 0 0 -27 1 0 0 0 0 -35 1 0 0 0 0 -26 1 0 0 0 0 -13 1 0 0 0 0 -30 1 0 0 0 0 -37 1 0 0 0 0 -18 1 0 0 0 0 -26 1 0 0 0 0 -20 1 0 0 0 0 -27 1 0 0 0 0 -15 1 0 0 0 0 -15 1 0 0 0 0 -33 1 0 0 0 0 -31 1 0 0 0 0 -34 1 0 0 0 0 -25 1 0 0 0 0 -37 1 0 0 0 0 -30 1 0 0 0 0 -16 1 0 0 0 0 -24 1 0 0 0 0 -47 1 0 0 0 0 -35 1 0 0 0 0 -16 1 0 0 0 0 -33 1 0 0 0 0 -29 1 0 0 0 0 -38 1 0 0 0 0 -32 1 0 0 0 0 -33 1 0 0 0 0 -18 1 0 0 0 0 -20 1 0 0 0 0 -29 1 0 0 0 0 -27 1 0 0 0 0 -36 1 0 0 0 0 -41 1 0 0 0 0 -28 1 0 0 0 0 -27 1 0 0 0 0 -27 1 0 0 0 0 -16 1 0 0 0 0 -34 1 0 0 0 0 -30 1 0 0 0 0 -46 1 0 0 0 0 -24 1 0 0 0 0 -23 1 0 0 0 0 -18 1 0 0 0 0 -34 1 0 0 0 0 -39 1 0 0 0 0 -29 1 0 0 0 0 -18 1 0 0 0 0 -47 1 0 0 0 0 -30 1 0 0 0 0 -15 1 0 0 0 0 -37 1 0 0 0 0 -33 1 0 0 0 0 -36 1 0 0 0 0 -45 1 0 0 0 0 -33 1 0 0 0 0 -29 1 0 0 0 0 -33 1 0 0 0 0 -23 1 0 0 0 0 -36 1 0 0 0 0 -21 1 0 0 0 0 -21 1 0 0 0 0 -34 1 0 0 0 0 -34 1 0 0 0 0 -37 1 0 0 0 0 -31 1 0 0 0 0 -38 1 0 0 0 0 -33 1 0 0 0 0 -40 1 0 0 0 0 -37 1 0 0 0 0 -34 1 0 0 0 0 -39 1 0 0 0 0 -41 1 0 0 0 0 -20 1 0 0 0 0 -26 1 0 0 0 0 -41 1 0 0 0 0 -21 1 0 0 0 0 -19 1 0 0 0 0 -39 1 0 0 0 0 -35 1 0 0 0 0 -30 1 0 0 0 0 -28 1 0 0 0 0 -26 1 0 0 0 0 -20 1 0 0 0 0 -39 1 0 0 0 0 -36 1 0 0 0 0 -30 1 0 0 0 0 -46 1 0 0 0 0 -25 1 0 0 0 0 -16 1 0 0 0 0 -27 1 0 0 0 0 -29 1 0 0 0 0 -25 1 0 0 0 0 -31 1 0 0 0 0 -31 1 0 0 0 0 -27 1 0 0 0 0 -22 1 0 0 0 0 -38 1 0 0 0 0 -24 1 0 0 0 0 -26 1 0 0 0 0 -29 1 0 0 0 0 -22 1 0 0 0 0 -31 1 0 0 0 0 -26 1 0 0 0 0 -40 1 0 0 0 0 -43 1 0 0 0 0 -35 1 0 0 0 0 -28 1 0 0 0 0 -38 1 0 0 0 0 -9 1 0 0 0 0 -34 1 0 0 0 0 -25 1 0 0 0 0 -38 1 0 0 0 0 -27 1 0 0 0 0 -37 1 0 0 0 0 -34 1 0 0 0 0 -36 1 0 0 0 0 -36 1 0 0 0 0 -36 1 0 0 0 0 -28 1 0 0 0 0 -outBuffEnable 0 -28 1 0 0 0 0 -32 1 0 0 0 0 -38 1 0 0 0 0 -20 1 0 0 0 0 -29 1 0 0 0 0 -29 1 0 0 0 0 -36 1 0 0 0 0 -31 1 0 0 0 0 -27 1 0 0 0 0 -37 1 0 0 0 0 -25 1 0 0 0 0 -36 1 0 0 0 0 -24 1 0 0 0 0 -47 1 0 0 0 0 -25 1 0 0 0 0 -43 1 0 0 0 0 -28 1 0 0 0 0 -29 1 0 0 0 0 -23 1 0 0 0 0 -28 1 0 0 0 0 -26 1 0 0 0 0 -30 1 0 0 0 0 -19 1 0 0 0 0 -35 1 0 0 0 0 -22 1 0 0 0 0 -31 1 0 0 0 0 -30 1 0 0 0 0 -27 1 0 0 0 0 -41 1 0 0 0 0 -39 1 0 0 0 0 -27 1 0 0 0 0 -32 1 0 0 0 0 -23 1 0 0 0 0 -29 1 0 0 0 0 -31 1 0 0 0 0 -23 1 0 0 0 0 -33 1 0 0 0 0 -41 1 0 0 0 0 -23 1 0 0 0 0 -38 1 0 0 0 0 -20 1 0 0 0 0 -26 1 0 0 0 0 -20 1 0 0 0 0 -20 1 0 0 0 0 -35 1 0 0 0 0 -23 1 0 0 0 0 -31 1 0 0 0 0 -23 1 0 0 0 0 -34 1 0 0 0 0 -23 1 0 0 0 0 -25 1 0 0 0 0 -21 1 0 0 0 0 -35 1 0 0 0 0 -25 1 0 0 0 0 -28 1 0 0 0 0 -19 1 0 0 0 0 -30 1 0 0 0 0 -38 1 0 0 0 0 -30 1 0 0 0 0 -32 1 0 0 0 0 -24 1 0 0 0 0 -23 1 0 0 0 0 -29 1 0 0 0 0 -25 1 0 0 0 0 -35 1 0 0 0 0 -29 1 0 0 0 0 -31 1 0 0 0 0 -36 1 0 0 0 0 -32 1 0 0 0 0 -31 1 0 0 0 0 -33 1 0 0 0 0 -28 1 0 0 0 0 -37 1 0 0 0 0 -41 1 0 0 0 0 -32 1 0 0 0 0 -26 1 0 0 0 0 -36 1 0 0 0 0 -42 1 0 0 0 0 -25 1 0 0 0 0 -41 1 0 0 0 0 -36 1 0 0 0 0 -26 1 0 0 0 0 -31 1 0 0 0 0 -22 1 0 0 0 0 -32 1 0 0 0 0 -15 1 0 0 0 0 -47 1 0 0 0 0 -25 1 0 0 0 0 -29 1 0 0 0 0 -29 1 0 0 0 0 -37 1 0 0 0 0 -31 1 0 0 0 0 -46 1 0 0 0 0 -29 1 0 0 0 0 -37 1 0 0 0 0 -19 1 0 0 0 0 -20 1 0 0 0 0 -47 1 0 0 0 0 -27 1 0 0 0 0 -19 1 0 0 0 0 -35 1 0 0 0 0 -28 1 0 0 0 0 -46 1 0 0 0 0 -23 1 0 0 0 0 -30 1 0 0 0 0 -49 1 0 0 0 0 -28 1 0 0 0 0 -31 1 0 0 0 0 -41 1 0 0 0 0 -25 1 0 0 0 0 -14 1 0 0 0 0 -34 1 0 0 0 0 -41 1 0 0 0 0 -29 1 0 0 0 0 -35 1 0 0 0 0 -33 1 0 0 0 0 -22 1 0 0 0 0 -29 1 0 0 0 0 -17 1 0 0 0 0 -28 1 0 0 0 0 -22 1 0 0 0 0 -26 1 0 0 0 0 -33 1 0 0 0 0 -30 1 0 0 0 0 -22 1 0 0 0 0 -26 1 0 0 0 0 -33 1 0 0 0 0 -30 1 0 0 0 0 -outBuffEnable 0 -21 1 0 0 0 0 -13 1 0 0 0 0 -41 1 0 0 0 0 -23 1 0 0 0 0 -26 1 0 0 0 0 -34 1 0 0 0 0 -37 1 0 0 0 0 -32 1 0 0 0 0 -18 1 0 0 0 0 -36 1 0 0 0 0 -27 1 0 0 0 0 -31 1 0 0 0 0 -34 1 0 0 0 0 -29 1 0 0 0 0 -29 1 0 0 0 0 -39 1 0 0 0 0 -27 1 0 0 0 0 -37 1 0 0 0 0 -30 1 0 0 0 0 -22 1 0 0 0 0 -26 1 0 0 0 0 -30 1 0 0 0 0 -30 1 0 0 0 0 -26 1 0 0 0 0 -30 1 0 0 0 0 -16 1 0 0 0 0 -23 1 0 0 0 0 -29 1 0 0 0 0 -40 1 0 0 0 0 -28 1 0 0 0 0 -34 1 0 0 0 0 -28 1 0 0 0 0 -22 1 0 0 0 0 -17 1 0 0 0 0 -45 1 0 0 0 0 -22 1 0 0 0 0 -26 1 0 0 0 0 -23 1 0 0 0 0 -24 1 0 0 0 0 -34 1 0 0 0 0 -26 1 0 0 0 0 -22 1 0 0 0 0 -27 1 0 0 0 0 -36 1 0 0 0 0 -20 1 0 0 0 0 -33 1 0 0 0 0 -35 1 0 0 0 0 -24 1 0 0 0 0 -47 1 0 0 0 0 -37 1 0 0 0 0 -34 1 0 0 0 0 -49 1 0 0 0 0 -27 1 0 0 0 0 -29 1 0 0 0 0 -38 1 0 0 0 0 -38 1 0 0 0 0 -34 1 0 0 0 0 -36 1 0 0 0 0 -31 1 0 0 0 0 -29 1 0 0 0 0 -41 1 0 0 0 0 -31 1 0 0 0 0 -31 1 0 0 0 0 -25 1 0 0 0 0 -46 1 0 0 0 0 -48 1 0 0 0 0 -28 1 0 0 0 0 -44 1 0 0 0 0 -39 1 0 0 0 0 -35 1 0 0 0 0 -34 1 0 0 0 0 -24 1 0 0 0 0 -32 1 0 0 0 0 -26 1 0 0 0 0 -33 1 0 0 0 0 -19 1 0 0 0 0 -19 1 0 0 0 0 -30 1 0 0 0 0 -54 1 0 0 0 0 -19 1 0 0 0 0 -48 1 0 0 0 0 -25 1 0 0 0 0 -29 1 0 0 0 0 -27 1 0 0 0 0 -36 1 0 0 0 0 -37 1 0 0 0 0 -39 1 0 0 0 0 -28 1 0 0 0 0 -33 1 0 0 0 0 -31 1 0 0 0 0 -33 1 0 0 0 0 -33 1 0 0 0 0 -38 1 0 0 0 0 -29 1 0 0 0 0 -25 1 0 0 0 0 -41 1 0 0 0 0 -42 1 0 0 0 0 -31 1 0 0 0 0 -32 1 0 0 0 0 -38 1 0 0 0 0 -52 1 0 0 0 0 -33 1 0 0 0 0 -35 1 0 0 0 0 -53 1 0 0 0 0 -36 1 0 0 0 0 -21 1 0 0 0 0 -44 1 0 0 0 0 -38 1 0 0 0 0 -34 1 0 0 0 0 -30 1 0 0 0 0 -25 1 0 0 0 0 -53 1 0 0 0 0 -37 1 0 0 0 0 -43 1 0 0 0 0 -40 1 0 0 0 0 -35 1 0 0 0 0 -38 1 0 0 0 0 -38 1 0 0 0 0 -45 1 0 0 0 0 -30 1 0 0 0 0 -28 1 0 0 0 0 -26 1 0 0 0 0 -36 1 0 0 0 0 -31 1 0 0 0 0 -33 1 0 0 0 0 -36 1 0 0 0 0 -37 1 0 0 0 0 -35 1 0 0 0 0 -outBuffEnable 0 -20 1 0 0 0 0 -20 1 0 0 0 0 -50 1 0 0 0 0 -28 1 0 0 0 0 -48 1 0 0 0 0 -28 1 0 0 0 0 -39 1 0 0 0 0 -23 1 0 0 0 0 -33 1 0 0 0 0 -32 1 0 0 0 0 -22 1 0 0 0 0 -31 1 0 0 0 0 -29 1 0 0 0 0 -30 1 0 0 0 0 -17 1 0 0 0 0 -26 1 0 0 0 0 -36 1 0 0 0 0 -24 1 0 0 0 0 -20 1 0 0 0 0 -25 1 0 0 0 0 -25 1 0 0 0 0 -19 1 0 0 0 0 -23 1 0 0 0 0 -36 1 0 0 0 0 -31 1 0 0 0 0 -36 1 0 0 0 0 -37 1 0 0 0 0 -44 1 0 0 0 0 -30 1 0 0 0 0 -14 1 0 0 0 0 -45 1 0 0 0 0 -32 1 0 0 0 0 -25 1 0 0 0 0 -29 1 0 0 0 0 -35 1 0 0 0 0 -26 1 0 0 0 0 -27 1 0 0 0 0 -12 1 0 0 0 0 -24 1 0 0 0 0 -28 1 0 0 0 0 -36 1 0 0 0 0 -25 1 0 0 0 0 -28 1 0 0 0 0 -36 1 0 0 0 0 -35 1 0 0 0 0 -33 1 0 0 0 0 -39 1 0 0 0 0 -19 1 0 0 0 0 -27 1 0 0 0 0 -24 1 0 0 0 0 -47 1 0 0 0 0 -27 1 0 0 0 0 -31 1 0 0 0 0 -14 1 0 0 0 0 -34 1 0 0 0 0 -44 1 0 0 0 0 -39 1 0 0 0 0 -32 1 0 0 0 0 -32 1 0 0 0 0 -36 1 0 0 0 0 -26 1 0 0 0 0 -37 1 0 0 0 0 -46 1 0 0 0 0 -19 1 0 0 0 0 -24 1 0 0 0 0 -41 1 0 0 0 0 -35 1 0 0 0 0 -22 1 0 0 0 0 -24 1 0 0 0 0 -26 1 0 0 0 0 -40 1 0 0 0 0 -21 1 0 0 0 0 -26 1 0 0 0 0 -39 1 0 0 0 0 -28 1 0 0 0 0 -38 1 0 0 0 0 -29 1 0 0 0 0 -25 1 0 0 0 0 -27 1 0 0 0 0 -34 1 0 0 0 0 -40 1 0 0 0 0 -19 1 0 0 0 0 -29 1 0 0 0 0 -39 1 0 0 0 0 -19 1 0 0 0 0 -18 1 0 0 0 0 -19 1 0 0 0 0 -37 1 0 0 0 0 -43 1 0 0 0 0 -29 1 0 0 0 0 -46 1 0 0 0 0 -42 1 0 0 0 0 -24 1 0 0 0 0 -14 1 0 0 0 0 -41 1 0 0 0 0 -53 1 0 0 0 0 -42 1 0 0 0 0 -23 1 0 0 0 0 -45 1 0 0 0 0 -24 1 0 0 0 0 -38 1 0 0 0 0 -34 1 0 0 0 0 -31 1 0 0 0 0 -21 1 0 0 0 0 -38 1 0 0 0 0 -29 1 0 0 0 0 -36 1 0 0 0 0 -36 1 0 0 0 0 -37 1 0 0 0 0 -27 1 0 0 0 0 -31 1 0 0 0 0 -27 1 0 0 0 0 -33 1 0 0 0 0 -21 1 0 0 0 0 -40 1 0 0 0 0 -34 1 0 0 0 0 -21 1 0 0 0 0 -25 1 0 0 0 0 -54 1 0 0 0 0 -33 1 0 0 0 0 -26 1 0 0 0 0 -19 1 0 0 0 0 -33 1 0 0 0 0 -32 1 0 0 0 0 -26 1 0 0 0 0 -21 1 0 0 0 0 -33 1 0 0 0 0 -25 1 0 0 0 0 diff --git a/settingsdir/mythen/highgain/calibration.snxxx b/settingsdir/mythen/highgain/calibration.snxxx deleted file mode 100755 index 326e7f501..000000000 --- a/settingsdir/mythen/highgain/calibration.snxxx +++ /dev/null @@ -1 +0,0 @@ -800 10 diff --git a/settingsdir/mythen/highgain/highgain.cal b/settingsdir/mythen/highgain/highgain.cal deleted file mode 100755 index b5f43f83a..000000000 --- a/settingsdir/mythen/highgain/highgain.cal +++ /dev/null @@ -1 +0,0 @@ -804 15.0 diff --git a/settingsdir/mythen/highgain/highgain.trim b/settingsdir/mythen/highgain/highgain.trim deleted file mode 100755 index b15219ff6..000000000 --- a/settingsdir/mythen/highgain/highgain.trim +++ /dev/null @@ -1,1296 +0,0 @@ -Vtrim 843 -Vthresh 770 -Rgsh1 400 -Rgsh2 260 -Rgpr 200 -Vcal 600 -outBuffEnable 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -outBuffEnable 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -outBuffEnable 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -outBuffEnable 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -outBuffEnable 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -outBuffEnable 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -outBuffEnable 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -outBuffEnable 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -outBuffEnable 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -outBuffEnable 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 diff --git a/settingsdir/mythen/highgain/noise.snxxx b/settingsdir/mythen/highgain/noise.snxxx deleted file mode 100644 index 0b8de0d30..000000000 --- a/settingsdir/mythen/highgain/noise.snxxx +++ /dev/null @@ -1,1296 +0,0 @@ -Vtrim 800 -Vthresh 700 -Rgsh1 400 -Rgsh2 260 -Rgpr 200 -Vcal 600 -outBuffEnable 0 -36 1 0 0 0 0 -13 1 0 0 0 0 -26 1 0 0 0 0 -17 1 0 0 0 0 -34 1 0 0 0 0 -22 1 0 0 0 0 -30 1 0 0 0 0 -27 1 0 0 0 0 -34 1 0 0 0 0 -32 1 0 0 0 0 -27 1 0 0 0 0 -34 1 0 0 0 0 -24 1 0 0 0 0 -22 1 0 0 0 0 -18 1 0 0 0 0 -29 1 0 0 0 0 -57 1 0 0 0 0 -15 1 0 0 0 0 -31 1 0 0 0 0 -34 1 0 0 0 0 -25 1 0 0 0 0 -31 1 0 0 0 0 -29 1 0 0 0 0 -34 1 0 0 0 0 -33 1 0 0 0 0 -33 1 0 0 0 0 -32 1 0 0 0 0 -22 1 0 0 0 0 -30 1 0 0 0 0 -19 1 0 0 0 0 -33 1 0 0 0 0 -43 1 0 0 0 0 -32 1 0 0 0 0 -31 1 0 0 0 0 -30 1 0 0 0 0 -34 1 0 0 0 0 -28 1 0 0 0 0 -22 1 0 0 0 0 -31 1 0 0 0 0 -14 1 0 0 0 0 -36 1 0 0 0 0 -21 1 0 0 0 0 -29 1 0 0 0 0 -26 1 0 0 0 0 -28 1 0 0 0 0 -30 1 0 0 0 0 -25 1 0 0 0 0 -36 1 0 0 0 0 -21 1 0 0 0 0 -33 1 0 0 0 0 -9 1 0 0 0 0 -30 1 0 0 0 0 -33 1 0 0 0 0 -26 1 0 0 0 0 -37 1 0 0 0 0 -31 1 0 0 0 0 -23 1 0 0 0 0 -27 1 0 0 0 0 -41 1 0 0 0 0 -23 1 0 0 0 0 -34 1 0 0 0 0 -31 1 0 0 0 0 -35 1 0 0 0 0 -28 1 0 0 0 0 -36 1 0 0 0 0 -34 1 0 0 0 0 -28 1 0 0 0 0 -33 1 0 0 0 0 -32 1 0 0 0 0 -36 1 0 0 0 0 -42 1 0 0 0 0 -40 1 0 0 0 0 -22 1 0 0 0 0 -26 1 0 0 0 0 -31 1 0 0 0 0 -39 1 0 0 0 0 -34 1 0 0 0 0 -37 1 0 0 0 0 -27 1 0 0 0 0 -29 1 0 0 0 0 -30 1 0 0 0 0 -37 1 0 0 0 0 -28 1 0 0 0 0 -15 1 0 0 0 0 -29 1 0 0 0 0 -29 1 0 0 0 0 -43 1 0 0 0 0 -25 1 0 0 0 0 -25 1 0 0 0 0 -24 1 0 0 0 0 -29 1 0 0 0 0 -43 1 0 0 0 0 -40 1 0 0 0 0 -23 1 0 0 0 0 -20 1 0 0 0 0 -40 1 0 0 0 0 -26 1 0 0 0 0 -32 1 0 0 0 0 -33 1 0 0 0 0 -38 1 0 0 0 0 -44 1 0 0 0 0 -34 1 0 0 0 0 -31 1 0 0 0 0 -46 1 0 0 0 0 -32 1 0 0 0 0 -44 1 0 0 0 0 -29 1 0 0 0 0 -38 1 0 0 0 0 -32 1 0 0 0 0 -43 1 0 0 0 0 -33 1 0 0 0 0 -33 1 0 0 0 0 -48 1 0 0 0 0 -19 1 0 0 0 0 -26 1 0 0 0 0 -42 1 0 0 0 0 -33 1 0 0 0 0 -27 1 0 0 0 0 -28 1 0 0 0 0 -44 1 0 0 0 0 -21 1 0 0 0 0 -36 1 0 0 0 0 -28 1 0 0 0 0 -36 1 0 0 0 0 -48 1 0 0 0 0 -30 1 0 0 0 0 -43 1 0 0 0 0 -16 1 0 0 0 0 -outBuffEnable 0 -30 1 0 0 0 0 -35 1 0 0 0 0 -30 1 0 0 0 0 -17 1 0 0 0 0 -21 1 0 0 0 0 -24 1 0 0 0 0 -10 1 0 0 0 0 -46 1 0 0 0 0 -27 1 0 0 0 0 -18 1 0 0 0 0 -43 1 0 0 0 0 -31 1 0 0 0 0 -19 1 0 0 0 0 -29 1 0 0 0 0 -40 1 0 0 0 0 -18 1 0 0 0 0 -35 1 0 0 0 0 -35 1 0 0 0 0 -19 1 0 0 0 0 -41 1 0 0 0 0 -29 1 0 0 0 0 -26 1 0 0 0 0 -34 1 0 0 0 0 -22 1 0 0 0 0 -23 1 0 0 0 0 -37 1 0 0 0 0 -33 1 0 0 0 0 -25 1 0 0 0 0 -40 1 0 0 0 0 -35 1 0 0 0 0 -36 1 0 0 0 0 -30 1 0 0 0 0 -30 1 0 0 0 0 -41 1 0 0 0 0 -33 1 0 0 0 0 -22 1 0 0 0 0 -28 1 0 0 0 0 -36 1 0 0 0 0 -24 1 0 0 0 0 -33 1 0 0 0 0 -30 1 0 0 0 0 -34 1 0 0 0 0 -27 1 0 0 0 0 -26 1 0 0 0 0 -31 1 0 0 0 0 -38 1 0 0 0 0 -31 1 0 0 0 0 -33 1 0 0 0 0 -40 1 0 0 0 0 -20 1 0 0 0 0 -41 1 0 0 0 0 -30 1 0 0 0 0 -26 1 0 0 0 0 -34 1 0 0 0 0 -35 1 0 0 0 0 -33 1 0 0 0 0 -27 1 0 0 0 0 -43 1 0 0 0 0 -18 1 0 0 0 0 -29 1 0 0 0 0 -27 1 0 0 0 0 -22 1 0 0 0 0 -27 1 0 0 0 0 -39 1 0 0 0 0 -27 1 0 0 0 0 -23 1 0 0 0 0 -41 1 0 0 0 0 -21 1 0 0 0 0 -29 1 0 0 0 0 -20 1 0 0 0 0 -36 1 0 0 0 0 -35 1 0 0 0 0 -32 1 0 0 0 0 -23 1 0 0 0 0 -30 1 0 0 0 0 -42 1 0 0 0 0 -27 1 0 0 0 0 -36 1 0 0 0 0 -33 1 0 0 0 0 -32 1 0 0 0 0 -26 1 0 0 0 0 -37 1 0 0 0 0 -38 1 0 0 0 0 -38 1 0 0 0 0 -30 1 0 0 0 0 -35 1 0 0 0 0 -36 1 0 0 0 0 -36 1 0 0 0 0 -27 1 0 0 0 0 -28 1 0 0 0 0 -33 1 0 0 0 0 -35 1 0 0 0 0 -34 1 0 0 0 0 -26 1 0 0 0 0 -34 1 0 0 0 0 -32 1 0 0 0 0 -38 1 0 0 0 0 -52 1 0 0 0 0 -38 1 0 0 0 0 -43 1 0 0 0 0 -33 1 0 0 0 0 -26 1 0 0 0 0 -25 1 0 0 0 0 -32 1 0 0 0 0 -32 1 0 0 0 0 -36 1 0 0 0 0 -37 1 0 0 0 0 -29 1 0 0 0 0 -28 1 0 0 0 0 -42 1 0 0 0 0 -36 1 0 0 0 0 -30 1 0 0 0 0 -37 1 0 0 0 0 -29 1 0 0 0 0 -35 1 0 0 0 0 -46 1 0 0 0 0 -33 1 0 0 0 0 -28 1 0 0 0 0 -41 1 0 0 0 0 -39 1 0 0 0 0 -39 1 0 0 0 0 -28 1 0 0 0 0 -28 1 0 0 0 0 -43 1 0 0 0 0 -43 1 0 0 0 0 -32 1 0 0 0 0 -23 1 0 0 0 0 -32 1 0 0 0 0 -outBuffEnable 0 -31 1 0 0 0 0 -22 1 0 0 0 0 -27 1 0 0 0 0 -19 1 0 0 0 0 -32 1 0 0 0 0 -40 1 0 0 0 0 -25 1 0 0 0 0 -25 1 0 0 0 0 -26 1 0 0 0 0 -35 1 0 0 0 0 -26 1 0 0 0 0 -22 1 0 0 0 0 -24 1 0 0 0 0 -24 1 0 0 0 0 -28 1 0 0 0 0 -32 1 0 0 0 0 -35 1 0 0 0 0 -35 1 0 0 0 0 -36 1 0 0 0 0 -25 1 0 0 0 0 -29 1 0 0 0 0 -24 1 0 0 0 0 -20 1 0 0 0 0 -28 1 0 0 0 0 -27 1 0 0 0 0 -29 1 0 0 0 0 -27 1 0 0 0 0 -37 1 0 0 0 0 -28 1 0 0 0 0 -29 1 0 0 0 0 -15 1 0 0 0 0 -41 1 0 0 0 0 -44 1 0 0 0 0 -33 1 0 0 0 0 -21 1 0 0 0 0 -27 1 0 0 0 0 -19 1 0 0 0 0 -35 1 0 0 0 0 -33 1 0 0 0 0 -34 1 0 0 0 0 -29 1 0 0 0 0 -29 1 0 0 0 0 -35 1 0 0 0 0 -38 1 0 0 0 0 -28 1 0 0 0 0 -31 1 0 0 0 0 -22 1 0 0 0 0 -35 1 0 0 0 0 -41 1 0 0 0 0 -16 1 0 0 0 0 -35 1 0 0 0 0 -29 1 0 0 0 0 -38 1 0 0 0 0 -25 1 0 0 0 0 -34 1 0 0 0 0 -27 1 0 0 0 0 -28 1 0 0 0 0 -42 1 0 0 0 0 -34 1 0 0 0 0 -36 1 0 0 0 0 -40 1 0 0 0 0 -34 1 0 0 0 0 -26 1 0 0 0 0 -30 1 0 0 0 0 -22 1 0 0 0 0 -26 1 0 0 0 0 -37 1 0 0 0 0 -24 1 0 0 0 0 -41 1 0 0 0 0 -39 1 0 0 0 0 -32 1 0 0 0 0 -21 1 0 0 0 0 -34 1 0 0 0 0 -20 1 0 0 0 0 -34 1 0 0 0 0 -25 1 0 0 0 0 -26 1 0 0 0 0 -27 1 0 0 0 0 -35 1 0 0 0 0 -40 1 0 0 0 0 -26 1 0 0 0 0 -24 1 0 0 0 0 -25 1 0 0 0 0 -28 1 0 0 0 0 -43 1 0 0 0 0 -34 1 0 0 0 0 -50 1 0 0 0 0 -26 1 0 0 0 0 -24 1 0 0 0 0 -37 1 0 0 0 0 -42 1 0 0 0 0 -29 1 0 0 0 0 -27 1 0 0 0 0 -26 1 0 0 0 0 -34 1 0 0 0 0 -35 1 0 0 0 0 -27 1 0 0 0 0 -25 1 0 0 0 0 -28 1 0 0 0 0 -29 1 0 0 0 0 -34 1 0 0 0 0 -29 1 0 0 0 0 -44 1 0 0 0 0 -30 1 0 0 0 0 -39 1 0 0 0 0 -30 1 0 0 0 0 -26 1 0 0 0 0 -25 1 0 0 0 0 -38 1 0 0 0 0 -41 1 0 0 0 0 -44 1 0 0 0 0 -39 1 0 0 0 0 -34 1 0 0 0 0 -45 1 0 0 0 0 -22 1 0 0 0 0 -34 1 0 0 0 0 -39 1 0 0 0 0 -40 1 0 0 0 0 -44 1 0 0 0 0 -33 1 0 0 0 0 -42 1 0 0 0 0 -30 1 0 0 0 0 -25 1 0 0 0 0 -31 1 0 0 0 0 -39 1 0 0 0 0 -31 1 0 0 0 0 -44 1 0 0 0 0 -47 1 0 0 0 0 -outBuffEnable 0 -29 1 0 0 0 0 -40 1 0 0 0 0 -14 1 0 0 0 0 -14 1 0 0 0 0 -21 1 0 0 0 0 -26 1 0 0 0 0 -17 1 0 0 0 0 -20 1 0 0 0 0 -24 1 0 0 0 0 -22 1 0 0 0 0 -19 1 0 0 0 0 -31 1 0 0 0 0 -32 1 0 0 0 0 -18 1 0 0 0 0 -34 1 0 0 0 0 -19 1 0 0 0 0 -10 1 0 0 0 0 -35 1 0 0 0 0 -33 1 0 0 0 0 -24 1 0 0 0 0 -33 1 0 0 0 0 -33 1 0 0 0 0 -23 1 0 0 0 0 -28 1 0 0 0 0 -32 1 0 0 0 0 -45 1 0 0 0 0 -22 1 0 0 0 0 -21 1 0 0 0 0 -21 1 0 0 0 0 -20 1 0 0 0 0 -22 1 0 0 0 0 -34 1 0 0 0 0 -33 1 0 0 0 0 -21 1 0 0 0 0 -38 1 0 0 0 0 -24 1 0 0 0 0 -32 1 0 0 0 0 -34 1 0 0 0 0 -29 1 0 0 0 0 -44 1 0 0 0 0 -43 1 0 0 0 0 -35 1 0 0 0 0 -16 1 0 0 0 0 -32 1 0 0 0 0 -40 1 0 0 0 0 -31 1 0 0 0 0 -22 1 0 0 0 0 -29 1 0 0 0 0 -33 1 0 0 0 0 -37 1 0 0 0 0 -23 1 0 0 0 0 -38 1 0 0 0 0 -28 1 0 0 0 0 -29 1 0 0 0 0 -46 1 0 0 0 0 -26 1 0 0 0 0 -27 1 0 0 0 0 -56 1 0 0 0 0 -33 1 0 0 0 0 -40 1 0 0 0 0 -41 1 0 0 0 0 -31 1 0 0 0 0 -14 1 0 0 0 0 -27 1 0 0 0 0 -23 1 0 0 0 0 -22 1 0 0 0 0 -35 1 0 0 0 0 -27 1 0 0 0 0 -30 1 0 0 0 0 -31 1 0 0 0 0 -32 1 0 0 0 0 -26 1 0 0 0 0 -16 1 0 0 0 0 -26 1 0 0 0 0 -35 1 0 0 0 0 -31 1 0 0 0 0 -35 1 0 0 0 0 -32 1 0 0 0 0 -29 1 0 0 0 0 -25 1 0 0 0 0 -29 1 0 0 0 0 -33 1 0 0 0 0 -28 1 0 0 0 0 -27 1 0 0 0 0 -25 1 0 0 0 0 -21 1 0 0 0 0 -27 1 0 0 0 0 -31 1 0 0 0 0 -40 1 0 0 0 0 -23 1 0 0 0 0 -33 1 0 0 0 0 -28 1 0 0 0 0 -33 1 0 0 0 0 -39 1 0 0 0 0 -28 1 0 0 0 0 -31 1 0 0 0 0 -27 1 0 0 0 0 -41 1 0 0 0 0 -36 1 0 0 0 0 -23 1 0 0 0 0 -28 1 0 0 0 0 -24 1 0 0 0 0 -25 1 0 0 0 0 -26 1 0 0 0 0 -24 1 0 0 0 0 -33 1 0 0 0 0 -31 1 0 0 0 0 -38 1 0 0 0 0 -25 1 0 0 0 0 -32 1 0 0 0 0 -30 1 0 0 0 0 -46 1 0 0 0 0 -40 1 0 0 0 0 -34 1 0 0 0 0 -26 1 0 0 0 0 -24 1 0 0 0 0 -29 1 0 0 0 0 -28 1 0 0 0 0 -32 1 0 0 0 0 -38 1 0 0 0 0 -41 1 0 0 0 0 -24 1 0 0 0 0 -24 1 0 0 0 0 -37 1 0 0 0 0 -42 1 0 0 0 0 -33 1 0 0 0 0 -26 1 0 0 0 0 -26 1 0 0 0 0 -outBuffEnable 0 -25 1 0 0 0 0 -23 1 0 0 0 0 -39 1 0 0 0 0 -23 1 0 0 0 0 -36 1 0 0 0 0 -26 1 0 0 0 0 -35 1 0 0 0 0 -23 1 0 0 0 0 -27 1 0 0 0 0 -25 1 0 0 0 0 -17 1 0 0 0 0 -36 1 0 0 0 0 -19 1 0 0 0 0 -28 1 0 0 0 0 -29 1 0 0 0 0 -36 1 0 0 0 0 -29 1 0 0 0 0 -9 1 0 0 0 0 -28 1 0 0 0 0 -22 1 0 0 0 0 -26 1 0 0 0 0 -42 1 0 0 0 0 -26 1 0 0 0 0 -33 1 0 0 0 0 -22 1 0 0 0 0 -32 1 0 0 0 0 -36 1 0 0 0 0 -38 1 0 0 0 0 -44 1 0 0 0 0 -23 1 0 0 0 0 -26 1 0 0 0 0 -25 1 0 0 0 0 -30 1 0 0 0 0 -21 1 0 0 0 0 -30 1 0 0 0 0 -23 1 0 0 0 0 -33 1 0 0 0 0 -35 1 0 0 0 0 -34 1 0 0 0 0 -33 1 0 0 0 0 -32 1 0 0 0 0 -35 1 0 0 0 0 -24 1 0 0 0 0 -29 1 0 0 0 0 -44 1 0 0 0 0 -33 1 0 0 0 0 -32 1 0 0 0 0 -29 1 0 0 0 0 -42 1 0 0 0 0 -23 1 0 0 0 0 -32 1 0 0 0 0 -29 1 0 0 0 0 -34 1 0 0 0 0 -38 1 0 0 0 0 -18 1 0 0 0 0 -23 1 0 0 0 0 -52 1 0 0 0 0 -28 1 0 0 0 0 -23 1 0 0 0 0 -35 1 0 0 0 0 -24 1 0 0 0 0 -32 1 0 0 0 0 -32 1 0 0 0 0 -25 1 0 0 0 0 -21 1 0 0 0 0 -31 1 0 0 0 0 -39 1 0 0 0 0 -35 1 0 0 0 0 -32 1 0 0 0 0 -28 1 0 0 0 0 -30 1 0 0 0 0 -22 1 0 0 0 0 -20 1 0 0 0 0 -36 1 0 0 0 0 -43 1 0 0 0 0 -35 1 0 0 0 0 -29 1 0 0 0 0 -16 1 0 0 0 0 -25 1 0 0 0 0 -26 1 0 0 0 0 -35 1 0 0 0 0 -29 1 0 0 0 0 -26 1 0 0 0 0 -39 1 0 0 0 0 -21 1 0 0 0 0 -36 1 0 0 0 0 -43 1 0 0 0 0 -46 1 0 0 0 0 -43 1 0 0 0 0 -41 1 0 0 0 0 -23 1 0 0 0 0 -32 1 0 0 0 0 -17 1 0 0 0 0 -19 1 0 0 0 0 -46 1 0 0 0 0 -38 1 0 0 0 0 -45 1 0 0 0 0 -25 1 0 0 0 0 -26 1 0 0 0 0 -28 1 0 0 0 0 -28 1 0 0 0 0 -24 1 0 0 0 0 -50 1 0 0 0 0 -32 1 0 0 0 0 -30 1 0 0 0 0 -29 1 0 0 0 0 -48 1 0 0 0 0 -44 1 0 0 0 0 -43 1 0 0 0 0 -28 1 0 0 0 0 -43 1 0 0 0 0 -34 1 0 0 0 0 -13 1 0 0 0 0 -41 1 0 0 0 0 -31 1 0 0 0 0 -24 1 0 0 0 0 -46 1 0 0 0 0 -24 1 0 0 0 0 -25 1 0 0 0 0 -30 1 0 0 0 0 -34 1 0 0 0 0 -40 1 0 0 0 0 -28 1 0 0 0 0 -29 1 0 0 0 0 -28 1 0 0 0 0 -29 1 0 0 0 0 -31 1 0 0 0 0 -29 1 0 0 0 0 -outBuffEnable 0 -25 1 0 0 0 0 -24 1 0 0 0 0 -30 1 0 0 0 0 -30 1 0 0 0 0 -26 1 0 0 0 0 -31 1 0 0 0 0 -29 1 0 0 0 0 -28 1 0 0 0 0 -29 1 0 0 0 0 -30 1 0 0 0 0 -21 1 0 0 0 0 -24 1 0 0 0 0 -17 1 0 0 0 0 -39 1 0 0 0 0 -12 1 0 0 0 0 -33 1 0 0 0 0 -20 1 0 0 0 0 -24 1 0 0 0 0 -33 1 0 0 0 0 -30 1 0 0 0 0 -33 1 0 0 0 0 -36 1 0 0 0 0 -18 1 0 0 0 0 -26 1 0 0 0 0 -28 1 0 0 0 0 -22 1 0 0 0 0 -22 1 0 0 0 0 -34 1 0 0 0 0 -31 1 0 0 0 0 -32 1 0 0 0 0 -30 1 0 0 0 0 -31 1 0 0 0 0 -28 1 0 0 0 0 -30 1 0 0 0 0 -27 1 0 0 0 0 -26 1 0 0 0 0 -35 1 0 0 0 0 -27 1 0 0 0 0 -28 1 0 0 0 0 -39 1 0 0 0 0 -29 1 0 0 0 0 -30 1 0 0 0 0 -28 1 0 0 0 0 -16 1 0 0 0 0 -36 1 0 0 0 0 -34 1 0 0 0 0 -19 1 0 0 0 0 -35 1 0 0 0 0 -52 1 0 0 0 0 -25 1 0 0 0 0 -23 1 0 0 0 0 -27 1 0 0 0 0 -25 1 0 0 0 0 -24 1 0 0 0 0 -23 1 0 0 0 0 -32 1 0 0 0 0 -33 1 0 0 0 0 -17 1 0 0 0 0 -32 1 0 0 0 0 -41 1 0 0 0 0 -17 1 0 0 0 0 -50 1 0 0 0 0 -25 1 0 0 0 0 -24 1 0 0 0 0 -23 1 0 0 0 0 -30 1 0 0 0 0 -30 1 0 0 0 0 -22 1 0 0 0 0 -34 1 0 0 0 0 -27 1 0 0 0 0 -25 1 0 0 0 0 -28 1 0 0 0 0 -61 1 0 0 0 0 -38 1 0 0 0 0 -43 1 0 0 0 0 -33 1 0 0 0 0 -39 1 0 0 0 0 -36 1 0 0 0 0 -22 1 0 0 0 0 -25 1 0 0 0 0 -27 1 0 0 0 0 -22 1 0 0 0 0 -26 1 0 0 0 0 -31 1 0 0 0 0 -21 1 0 0 0 0 -34 1 0 0 0 0 -35 1 0 0 0 0 -42 1 0 0 0 0 -33 1 0 0 0 0 -30 1 0 0 0 0 -24 1 0 0 0 0 -30 1 0 0 0 0 -34 1 0 0 0 0 -34 1 0 0 0 0 -33 1 0 0 0 0 -40 1 0 0 0 0 -27 1 0 0 0 0 -26 1 0 0 0 0 -37 1 0 0 0 0 -34 1 0 0 0 0 -27 1 0 0 0 0 -29 1 0 0 0 0 -33 1 0 0 0 0 -36 1 0 0 0 0 -33 1 0 0 0 0 -47 1 0 0 0 0 -28 1 0 0 0 0 -26 1 0 0 0 0 -30 1 0 0 0 0 -27 1 0 0 0 0 -27 1 0 0 0 0 -45 1 0 0 0 0 -27 1 0 0 0 0 -31 1 0 0 0 0 -32 1 0 0 0 0 -30 1 0 0 0 0 -32 1 0 0 0 0 -40 1 0 0 0 0 -31 1 0 0 0 0 -38 1 0 0 0 0 -32 1 0 0 0 0 -37 1 0 0 0 0 -28 1 0 0 0 0 -37 1 0 0 0 0 -32 1 0 0 0 0 -41 1 0 0 0 0 -44 1 0 0 0 0 -36 1 0 0 0 0 -outBuffEnable 0 -20 1 0 0 0 0 -41 1 0 0 0 0 -27 1 0 0 0 0 -12 1 0 0 0 0 -32 1 0 0 0 0 -27 1 0 0 0 0 -18 1 0 0 0 0 -4 1 0 0 0 0 -27 1 0 0 0 0 -35 1 0 0 0 0 -26 1 0 0 0 0 -13 1 0 0 0 0 -30 1 0 0 0 0 -37 1 0 0 0 0 -18 1 0 0 0 0 -26 1 0 0 0 0 -20 1 0 0 0 0 -27 1 0 0 0 0 -15 1 0 0 0 0 -15 1 0 0 0 0 -33 1 0 0 0 0 -31 1 0 0 0 0 -34 1 0 0 0 0 -25 1 0 0 0 0 -37 1 0 0 0 0 -30 1 0 0 0 0 -16 1 0 0 0 0 -24 1 0 0 0 0 -47 1 0 0 0 0 -35 1 0 0 0 0 -16 1 0 0 0 0 -33 1 0 0 0 0 -29 1 0 0 0 0 -38 1 0 0 0 0 -32 1 0 0 0 0 -33 1 0 0 0 0 -18 1 0 0 0 0 -20 1 0 0 0 0 -29 1 0 0 0 0 -27 1 0 0 0 0 -36 1 0 0 0 0 -41 1 0 0 0 0 -28 1 0 0 0 0 -27 1 0 0 0 0 -27 1 0 0 0 0 -16 1 0 0 0 0 -34 1 0 0 0 0 -30 1 0 0 0 0 -46 1 0 0 0 0 -24 1 0 0 0 0 -23 1 0 0 0 0 -18 1 0 0 0 0 -34 1 0 0 0 0 -39 1 0 0 0 0 -29 1 0 0 0 0 -18 1 0 0 0 0 -47 1 0 0 0 0 -30 1 0 0 0 0 -15 1 0 0 0 0 -37 1 0 0 0 0 -33 1 0 0 0 0 -36 1 0 0 0 0 -45 1 0 0 0 0 -33 1 0 0 0 0 -29 1 0 0 0 0 -33 1 0 0 0 0 -23 1 0 0 0 0 -36 1 0 0 0 0 -21 1 0 0 0 0 -21 1 0 0 0 0 -34 1 0 0 0 0 -34 1 0 0 0 0 -37 1 0 0 0 0 -31 1 0 0 0 0 -38 1 0 0 0 0 -33 1 0 0 0 0 -40 1 0 0 0 0 -37 1 0 0 0 0 -34 1 0 0 0 0 -39 1 0 0 0 0 -41 1 0 0 0 0 -20 1 0 0 0 0 -26 1 0 0 0 0 -41 1 0 0 0 0 -21 1 0 0 0 0 -19 1 0 0 0 0 -39 1 0 0 0 0 -35 1 0 0 0 0 -30 1 0 0 0 0 -28 1 0 0 0 0 -26 1 0 0 0 0 -20 1 0 0 0 0 -39 1 0 0 0 0 -36 1 0 0 0 0 -30 1 0 0 0 0 -46 1 0 0 0 0 -25 1 0 0 0 0 -16 1 0 0 0 0 -27 1 0 0 0 0 -29 1 0 0 0 0 -25 1 0 0 0 0 -31 1 0 0 0 0 -31 1 0 0 0 0 -27 1 0 0 0 0 -22 1 0 0 0 0 -38 1 0 0 0 0 -24 1 0 0 0 0 -26 1 0 0 0 0 -29 1 0 0 0 0 -22 1 0 0 0 0 -31 1 0 0 0 0 -26 1 0 0 0 0 -40 1 0 0 0 0 -43 1 0 0 0 0 -35 1 0 0 0 0 -28 1 0 0 0 0 -38 1 0 0 0 0 -9 1 0 0 0 0 -34 1 0 0 0 0 -25 1 0 0 0 0 -38 1 0 0 0 0 -27 1 0 0 0 0 -37 1 0 0 0 0 -34 1 0 0 0 0 -36 1 0 0 0 0 -36 1 0 0 0 0 -36 1 0 0 0 0 -28 1 0 0 0 0 -outBuffEnable 0 -28 1 0 0 0 0 -32 1 0 0 0 0 -38 1 0 0 0 0 -20 1 0 0 0 0 -29 1 0 0 0 0 -29 1 0 0 0 0 -36 1 0 0 0 0 -31 1 0 0 0 0 -27 1 0 0 0 0 -37 1 0 0 0 0 -25 1 0 0 0 0 -36 1 0 0 0 0 -24 1 0 0 0 0 -47 1 0 0 0 0 -25 1 0 0 0 0 -43 1 0 0 0 0 -28 1 0 0 0 0 -29 1 0 0 0 0 -23 1 0 0 0 0 -28 1 0 0 0 0 -26 1 0 0 0 0 -30 1 0 0 0 0 -19 1 0 0 0 0 -35 1 0 0 0 0 -22 1 0 0 0 0 -31 1 0 0 0 0 -30 1 0 0 0 0 -27 1 0 0 0 0 -41 1 0 0 0 0 -39 1 0 0 0 0 -27 1 0 0 0 0 -32 1 0 0 0 0 -23 1 0 0 0 0 -29 1 0 0 0 0 -31 1 0 0 0 0 -23 1 0 0 0 0 -33 1 0 0 0 0 -41 1 0 0 0 0 -23 1 0 0 0 0 -38 1 0 0 0 0 -20 1 0 0 0 0 -26 1 0 0 0 0 -20 1 0 0 0 0 -20 1 0 0 0 0 -35 1 0 0 0 0 -23 1 0 0 0 0 -31 1 0 0 0 0 -23 1 0 0 0 0 -34 1 0 0 0 0 -23 1 0 0 0 0 -25 1 0 0 0 0 -21 1 0 0 0 0 -35 1 0 0 0 0 -25 1 0 0 0 0 -28 1 0 0 0 0 -19 1 0 0 0 0 -30 1 0 0 0 0 -38 1 0 0 0 0 -30 1 0 0 0 0 -32 1 0 0 0 0 -24 1 0 0 0 0 -23 1 0 0 0 0 -29 1 0 0 0 0 -25 1 0 0 0 0 -35 1 0 0 0 0 -29 1 0 0 0 0 -31 1 0 0 0 0 -36 1 0 0 0 0 -32 1 0 0 0 0 -31 1 0 0 0 0 -33 1 0 0 0 0 -28 1 0 0 0 0 -37 1 0 0 0 0 -41 1 0 0 0 0 -32 1 0 0 0 0 -26 1 0 0 0 0 -36 1 0 0 0 0 -42 1 0 0 0 0 -25 1 0 0 0 0 -41 1 0 0 0 0 -36 1 0 0 0 0 -26 1 0 0 0 0 -31 1 0 0 0 0 -22 1 0 0 0 0 -32 1 0 0 0 0 -15 1 0 0 0 0 -47 1 0 0 0 0 -25 1 0 0 0 0 -29 1 0 0 0 0 -29 1 0 0 0 0 -37 1 0 0 0 0 -31 1 0 0 0 0 -46 1 0 0 0 0 -29 1 0 0 0 0 -37 1 0 0 0 0 -19 1 0 0 0 0 -20 1 0 0 0 0 -47 1 0 0 0 0 -27 1 0 0 0 0 -19 1 0 0 0 0 -35 1 0 0 0 0 -28 1 0 0 0 0 -46 1 0 0 0 0 -23 1 0 0 0 0 -30 1 0 0 0 0 -49 1 0 0 0 0 -28 1 0 0 0 0 -31 1 0 0 0 0 -41 1 0 0 0 0 -25 1 0 0 0 0 -14 1 0 0 0 0 -34 1 0 0 0 0 -41 1 0 0 0 0 -29 1 0 0 0 0 -35 1 0 0 0 0 -33 1 0 0 0 0 -22 1 0 0 0 0 -29 1 0 0 0 0 -17 1 0 0 0 0 -28 1 0 0 0 0 -22 1 0 0 0 0 -26 1 0 0 0 0 -33 1 0 0 0 0 -30 1 0 0 0 0 -22 1 0 0 0 0 -26 1 0 0 0 0 -33 1 0 0 0 0 -30 1 0 0 0 0 -outBuffEnable 0 -21 1 0 0 0 0 -13 1 0 0 0 0 -41 1 0 0 0 0 -23 1 0 0 0 0 -26 1 0 0 0 0 -34 1 0 0 0 0 -37 1 0 0 0 0 -32 1 0 0 0 0 -18 1 0 0 0 0 -36 1 0 0 0 0 -27 1 0 0 0 0 -31 1 0 0 0 0 -34 1 0 0 0 0 -29 1 0 0 0 0 -29 1 0 0 0 0 -39 1 0 0 0 0 -27 1 0 0 0 0 -37 1 0 0 0 0 -30 1 0 0 0 0 -22 1 0 0 0 0 -26 1 0 0 0 0 -30 1 0 0 0 0 -30 1 0 0 0 0 -26 1 0 0 0 0 -30 1 0 0 0 0 -16 1 0 0 0 0 -23 1 0 0 0 0 -29 1 0 0 0 0 -40 1 0 0 0 0 -28 1 0 0 0 0 -34 1 0 0 0 0 -28 1 0 0 0 0 -22 1 0 0 0 0 -17 1 0 0 0 0 -45 1 0 0 0 0 -22 1 0 0 0 0 -26 1 0 0 0 0 -23 1 0 0 0 0 -24 1 0 0 0 0 -34 1 0 0 0 0 -26 1 0 0 0 0 -22 1 0 0 0 0 -27 1 0 0 0 0 -36 1 0 0 0 0 -20 1 0 0 0 0 -33 1 0 0 0 0 -35 1 0 0 0 0 -24 1 0 0 0 0 -47 1 0 0 0 0 -37 1 0 0 0 0 -34 1 0 0 0 0 -49 1 0 0 0 0 -27 1 0 0 0 0 -29 1 0 0 0 0 -38 1 0 0 0 0 -38 1 0 0 0 0 -34 1 0 0 0 0 -36 1 0 0 0 0 -31 1 0 0 0 0 -29 1 0 0 0 0 -41 1 0 0 0 0 -31 1 0 0 0 0 -31 1 0 0 0 0 -25 1 0 0 0 0 -46 1 0 0 0 0 -48 1 0 0 0 0 -28 1 0 0 0 0 -44 1 0 0 0 0 -39 1 0 0 0 0 -35 1 0 0 0 0 -34 1 0 0 0 0 -24 1 0 0 0 0 -32 1 0 0 0 0 -26 1 0 0 0 0 -33 1 0 0 0 0 -19 1 0 0 0 0 -19 1 0 0 0 0 -30 1 0 0 0 0 -54 1 0 0 0 0 -19 1 0 0 0 0 -48 1 0 0 0 0 -25 1 0 0 0 0 -29 1 0 0 0 0 -27 1 0 0 0 0 -36 1 0 0 0 0 -37 1 0 0 0 0 -39 1 0 0 0 0 -28 1 0 0 0 0 -33 1 0 0 0 0 -31 1 0 0 0 0 -33 1 0 0 0 0 -33 1 0 0 0 0 -38 1 0 0 0 0 -29 1 0 0 0 0 -25 1 0 0 0 0 -41 1 0 0 0 0 -42 1 0 0 0 0 -31 1 0 0 0 0 -32 1 0 0 0 0 -38 1 0 0 0 0 -52 1 0 0 0 0 -33 1 0 0 0 0 -35 1 0 0 0 0 -53 1 0 0 0 0 -36 1 0 0 0 0 -21 1 0 0 0 0 -44 1 0 0 0 0 -38 1 0 0 0 0 -34 1 0 0 0 0 -30 1 0 0 0 0 -25 1 0 0 0 0 -53 1 0 0 0 0 -37 1 0 0 0 0 -43 1 0 0 0 0 -40 1 0 0 0 0 -35 1 0 0 0 0 -38 1 0 0 0 0 -38 1 0 0 0 0 -45 1 0 0 0 0 -30 1 0 0 0 0 -28 1 0 0 0 0 -26 1 0 0 0 0 -36 1 0 0 0 0 -31 1 0 0 0 0 -33 1 0 0 0 0 -36 1 0 0 0 0 -37 1 0 0 0 0 -35 1 0 0 0 0 -outBuffEnable 0 -20 1 0 0 0 0 -20 1 0 0 0 0 -50 1 0 0 0 0 -28 1 0 0 0 0 -48 1 0 0 0 0 -28 1 0 0 0 0 -39 1 0 0 0 0 -23 1 0 0 0 0 -33 1 0 0 0 0 -32 1 0 0 0 0 -22 1 0 0 0 0 -31 1 0 0 0 0 -29 1 0 0 0 0 -30 1 0 0 0 0 -17 1 0 0 0 0 -26 1 0 0 0 0 -36 1 0 0 0 0 -24 1 0 0 0 0 -20 1 0 0 0 0 -25 1 0 0 0 0 -25 1 0 0 0 0 -19 1 0 0 0 0 -23 1 0 0 0 0 -36 1 0 0 0 0 -31 1 0 0 0 0 -36 1 0 0 0 0 -37 1 0 0 0 0 -44 1 0 0 0 0 -30 1 0 0 0 0 -14 1 0 0 0 0 -45 1 0 0 0 0 -32 1 0 0 0 0 -25 1 0 0 0 0 -29 1 0 0 0 0 -35 1 0 0 0 0 -26 1 0 0 0 0 -27 1 0 0 0 0 -12 1 0 0 0 0 -24 1 0 0 0 0 -28 1 0 0 0 0 -36 1 0 0 0 0 -25 1 0 0 0 0 -28 1 0 0 0 0 -36 1 0 0 0 0 -35 1 0 0 0 0 -33 1 0 0 0 0 -39 1 0 0 0 0 -19 1 0 0 0 0 -27 1 0 0 0 0 -24 1 0 0 0 0 -47 1 0 0 0 0 -27 1 0 0 0 0 -31 1 0 0 0 0 -14 1 0 0 0 0 -34 1 0 0 0 0 -44 1 0 0 0 0 -39 1 0 0 0 0 -32 1 0 0 0 0 -32 1 0 0 0 0 -36 1 0 0 0 0 -26 1 0 0 0 0 -37 1 0 0 0 0 -46 1 0 0 0 0 -19 1 0 0 0 0 -24 1 0 0 0 0 -41 1 0 0 0 0 -35 1 0 0 0 0 -22 1 0 0 0 0 -24 1 0 0 0 0 -26 1 0 0 0 0 -40 1 0 0 0 0 -21 1 0 0 0 0 -26 1 0 0 0 0 -39 1 0 0 0 0 -28 1 0 0 0 0 -38 1 0 0 0 0 -29 1 0 0 0 0 -25 1 0 0 0 0 -27 1 0 0 0 0 -34 1 0 0 0 0 -40 1 0 0 0 0 -19 1 0 0 0 0 -29 1 0 0 0 0 -39 1 0 0 0 0 -19 1 0 0 0 0 -18 1 0 0 0 0 -19 1 0 0 0 0 -37 1 0 0 0 0 -43 1 0 0 0 0 -29 1 0 0 0 0 -46 1 0 0 0 0 -42 1 0 0 0 0 -24 1 0 0 0 0 -14 1 0 0 0 0 -41 1 0 0 0 0 -53 1 0 0 0 0 -42 1 0 0 0 0 -23 1 0 0 0 0 -45 1 0 0 0 0 -24 1 0 0 0 0 -38 1 0 0 0 0 -34 1 0 0 0 0 -31 1 0 0 0 0 -21 1 0 0 0 0 -38 1 0 0 0 0 -29 1 0 0 0 0 -36 1 0 0 0 0 -36 1 0 0 0 0 -37 1 0 0 0 0 -27 1 0 0 0 0 -31 1 0 0 0 0 -27 1 0 0 0 0 -33 1 0 0 0 0 -21 1 0 0 0 0 -40 1 0 0 0 0 -34 1 0 0 0 0 -21 1 0 0 0 0 -25 1 0 0 0 0 -54 1 0 0 0 0 -33 1 0 0 0 0 -26 1 0 0 0 0 -19 1 0 0 0 0 -33 1 0 0 0 0 -32 1 0 0 0 0 -26 1 0 0 0 0 -21 1 0 0 0 0 -33 1 0 0 0 0 -25 1 0 0 0 0 diff --git a/settingsdir/mythen/standard/calibration.snxxx b/settingsdir/mythen/standard/calibration.snxxx deleted file mode 100755 index 326e7f501..000000000 --- a/settingsdir/mythen/standard/calibration.snxxx +++ /dev/null @@ -1 +0,0 @@ -800 10 diff --git a/settingsdir/mythen/standard/noise.snxxx b/settingsdir/mythen/standard/noise.snxxx deleted file mode 100644 index 3cb00d1b9..000000000 --- a/settingsdir/mythen/standard/noise.snxxx +++ /dev/null @@ -1,1296 +0,0 @@ -Vtrim 824 -Vthresh 560 -Rgsh1 300 -Rgsh2 260 -Rgpr 100 -Vcal 600 -outBuffEnable 0 -0 2 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -outBuffEnable 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -outBuffEnable 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -outBuffEnable 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -outBuffEnable 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -outBuffEnable 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -outBuffEnable 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -outBuffEnable 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -outBuffEnable 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -outBuffEnable 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 diff --git a/settingsdir/mythen/standard/standard.cal b/settingsdir/mythen/standard/standard.cal deleted file mode 100755 index a7522a05a..000000000 --- a/settingsdir/mythen/standard/standard.cal +++ /dev/null @@ -1 +0,0 @@ -817 11.6 diff --git a/settingsdir/mythen/standard/standard.trim b/settingsdir/mythen/standard/standard.trim deleted file mode 100644 index f59047964..000000000 --- a/settingsdir/mythen/standard/standard.trim +++ /dev/null @@ -1,1296 +0,0 @@ -Vtrim 824 -Vthresh 560 -Rgsh1 300 -Rgsh2 260 -Rgpr 100 -Vcal 600 -outBuffEnable 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -outBuffEnable 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -outBuffEnable 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -outBuffEnable 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -outBuffEnable 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -outBuffEnable 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -outBuffEnable 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -outBuffEnable 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -outBuffEnable 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -outBuffEnable 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 -0 1 0 0 0 0 diff --git a/slsDetectorCalibration/.gitignore b/slsDetectorCalibration/.gitignore deleted file mode 100644 index 5f41dcb88..000000000 --- a/slsDetectorCalibration/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -*.o -*.*~ diff --git a/slsDetectorCalibration/MovingStat.h b/slsDetectorCalibration/MovingStat.h deleted file mode 100755 index 35249b1c9..000000000 --- a/slsDetectorCalibration/MovingStat.h +++ /dev/null @@ -1,156 +0,0 @@ -#ifndef MOVINGSTAT_H -#define MOVINGSTAT_H - -#include - - -class MovingStat - { - - /** @short approximated moving average structure */ - public: - - - /** constructor - \param nn number of samples parameter to be used - */ - MovingStat(int nn=1000) : n(nn), m_n(0) {} - - /** - clears the moving average number of samples parameter, mean and standard deviation - */ - void Clear() - { - m_n = 0; - m_newM=0; - m_newM2=0; - } - - /** - clears the moving average number of samples parameter, mean and standard deviation - */ - void Set(double val, double rms=0, int m=-1) - { - if (m>=0) m_n = m; else m_n = n; - m_newM=val*m_n; - SetRMS(rms); - } - /** - clears the moving average number of samples parameter, mean and standard deviation - */ - void SetRMS(double rms) - { - if (rms<=0) { - m_newM2=m_newM*m_newM/n; - m_n=0; - } else { - if (m_n>0) - m_newM2=(m_n*rms*rms+m_newM*m_newM/m_n); - else { - m_newM2=(m_n*rms*rms+m_newM*m_newM/n); - m_n=0; - } - } - } - - /** sets number of samples parameter - \param i number of samples parameter to be set - */ - - int SetN(int i) {if (i>=1) n=i; return n;}; - - /** - gets number of samples parameter - \returns actual number of samples parameter - */ - int GetN() {return m_n;}; - - /** calculates the moving average i.e. adds if number of elements is lower than number of samples parameter, pushes otherwise - \param x value to calculate the moving average - */ - inline void Calc(double x) { - if (m_n 0) ? m_newM/m_n : 0.0; - } - - /** returns the squared mean, 0 if no elements are inside - \returns returns the squared average - */ - double M2() const - { - return ( (m_n > 1) ? m_newM2/m_n : 0.0 ); - } - - /** returns the variance, 0 if no elements are inside - \returns returns the variance - */ - inline double Variance() const - { - return ( (m_n > 1) ? (M2()-Mean()*Mean()) : 0.0 ); - } - - /** returns the standard deviation, 0 if no elements are inside - \returns returns the standard deviation - */ - inline double StandardDeviation() const - { - return ( (Variance() > 0) ? sqrt( Variance() ) : -1 ); - } - - private: - int n; /**< number of samples parameter */ - int m_n; /**< current number of elements */ - double m_newM; /**< accumulated average */ - double m_newM2; /**< accumulated squared average */ - }; -#endif diff --git a/slsDetectorCalibration/RunningStat.h b/slsDetectorCalibration/RunningStat.h deleted file mode 100755 index 1197ffc0f..000000000 --- a/slsDetectorCalibration/RunningStat.h +++ /dev/null @@ -1,55 +0,0 @@ - class RunningStat - { - public: - RunningStat() : m_n(0) {} - - void Clear() - { - m_n = 0; - } - - void Push(double x) - { - m_n++; - - // See Knuth TAOCP vol 2, 3rd edition, page 232 - if (m_n == 1) - { - m_oldM = m_newM = x; - m_oldS = 0.0; - } - else - { - m_newM = m_oldM + (x - m_oldM)/m_n; - m_newS = m_oldS + (x - m_oldM)*(x - m_newM); - - // set up for next iteration - m_oldM = m_newM; - m_oldS = m_newS; - } - } - - int NumDataValues() const - { - return m_n; - } - - double Mean() const - { - return (m_n > 0) ? m_newM : 0.0; - } - - double Variance() const - { - return ( (m_n > 1) ? m_newS/(m_n - 1) : 0.0 ); - } - - double StandardDeviation() const - { - return sqrt( Variance() ); - } - - private: - int m_n; - double m_oldM, m_newM, m_oldS, m_newS; - }; diff --git a/slsDetectorCalibration/analogDetector.h b/slsDetectorCalibration/analogDetector.h deleted file mode 100644 index 1b72e8e7f..000000000 --- a/slsDetectorCalibration/analogDetector.h +++ /dev/null @@ -1,1109 +0,0 @@ -#ifndef ANALOGDETECTOR_H -#define ANALOGDETECTOR_H - -//#include - -#include -#include "slsDetectorData.h" -#include "pedestalSubtraction.h" -#include "commonModeSubtraction.h" -#include "tiffIO.h" - - -#ifdef ROOTSPECTRUM -#include -#include -#include -#include -#include -#include -#include -#include -#endif - -using namespace std; - -#ifndef FRAMEMODE_DEF -#define FRAMEMODE_DEF -/** -enum to define the flags of the data set, which are needed to seect the type of processing it should undergo: frame, pedestal, flat -*/ - enum frameMode { eFrame, ePedestal, eFlat }; -#endif - - -template class analogDetector { - - /** @short class to perform pedestal subtraction etc. for an analog detector */ - - public: - - - - /** - - Constructor (no error checking if datasize and offsets are compatible!) - \param d detector data structure to be used - if null it is assumed that the data are in ordered ip=iy*nx+ix - \param sign is the sign of the data - \param nped number of samples for pedestal averaging - \param cm common mode subtraction algorithm, if any. Defaults to NULL i.e. none - \param nnx detector size in x - must be specified if no data structure is defined, otherwise defaults to the size of the data structure. - \param nny detector size in y - must be specified if no data structure is defined, otherwise defaults to the size of the data structure. - \param gm pointer to tha gain map matrix - - - */ - - - analogDetector(slsDetectorData *d, int sign=1, - commonModeSubtraction *cm=NULL, int nped=1000, int nnx=-1, int nny=-1, double *gm=NULL) : det(d), nx(nnx), ny(nny), stat(NULL), cmSub(cm), iframe(-1), dataSign(sign), gmap(gm), id(0) { - - if (det) - det->getDetectorSize(nx,ny); - - stat=new pedestalSubtraction*[ny]; - for (int i=0; idet; - nx=orig->nx; - ny=orig->ny; - dataSign=orig->dataSign; - iframe=orig->iframe; - gmap=orig->gmap; - cmSub=orig->cmSub; - id=orig->id; - xmin=orig->xmin; - xmax=orig->xmax; - ymin=orig->ymin; - ymax=orig->ymax; - thr=orig->thr; - // nSigma=orig->nSigma; - fMode=orig->fMode; - myFile=orig->myFile; - fm=orig->fm; - - - stat=new pedestalSubtraction*[ny]; - for (int i=0; iSetNPedestals(); - //cout << nped << " " << orig->getPedestal(ix,iy) << orig->getPedestalRMS(ix,iy) << endl; - for (int iy=0; iygetPedestal(ix,iy),orig->getPedestalRMS(ix,iy),orig->GetNPedestals(ix,iy)); - } - } - image=new int[nx*ny]; -#ifdef ROOTSPECTRUM - hs=(TH2F*)(orig->hs)->Clone();//new TH2F("hs","hs",(orig->hs)-getNbins,-500,9500,nx*ny,-0.5,nx*ny-0.5); -#ifdef ROOTCLUST - hs3=(TH2F*)(orig->hs3)->Clone();//new TH2F("hs","hs",(orig->hs)-getNbins,-500,9500,nx*ny,-0.5,nx*ny-0.5); - hs5=(TH2F*)(orig->hs5)->Clone();//new TH2F("hs","hs",(orig->hs)-getNbins,-500,9500,nx*ny,-0.5,nx*ny-0.5); - hs7=(TH2F*)(orig->hs7)->Clone();//new TH2F("hs","hs",(orig->hs)-getNbins,-500,9500,nx*ny,-0.5,nx*ny-0.5); - hs9=(TH2F*)(orig->hs9)->Clone();//new TH2F("hs","hs",(orig->hs)-getNbins,-500,9500,nx*ny,-0.5,nx*ny-0.5); -#endif -#endif - - } - - - /** - clone. Must be virtual! - \returns a clone of the original analog detector - */ - virtual analogDetector *Clone() { - return new analogDetector(this); - } - - /** - Gives an id to the structure. For debugging purposes in case of multithreading. - \param i is to be set - \returns current id - */ - int setId(int i){id=i; return id;}; - - /** - Returns id of the structure. For debugging purposes in case of multithreading. - \returns current id - */ - int getId() {return id; }; - /** - Returns data size of the detector data structure - \returns data size of the detector data structurein bytes - */ - int getDataSize(){return det->getDataSize();}; - /** - Returns data size of the detector image matrix - \param nnx reference to image size in x - \param nny reference to image size in y - \param nns reference to number of subpixels for interpolating detector, will always be 1 in this case - \returns number of pixels of the detector image - */ - virtual int getImageSize(int &nnx, int &nny, int &nns){nnx=nx; nny=ny; nns=1; return nx*ny;}; - /** - Returns data size of the detector image matrix - \param nnx reference to pixel size in x - \param nny reference to pixel size in y - \returns number of pixels of the detector image - */ - virtual int getDetectorSize(int &nnx, int &nny){nnx=nx; nny=ny; return nx*ny;}; - - /** - set gain map - \param gm pointer to gain map matrix to be set - NULL unsets - \returns pointer to current gain map - */ - double *setGainMap(double *gm) {gmap=gm; return gmap;}; - - /** - return gain map - \returns pointer to current gain map - */ - double *getGainMap() {return gmap;}; - /** - reads a 32 bit tiff file of the size of the detector and sets its values as gain map for the detector. If file does not exist returns NULL, but does not change gainmap compared to previous settings. - \param imgname complete name of the file containing the gain map data - \returns pointer to current gain map is file reading succeeded, NULL is file reading didn't work. - */ - double *readGainMap(const char * imgname) { - uint32 nnx, nny; - float *gm=ReadFromTiff( imgname, nny, nnx); - if (gm) { - if (gmap) delete [] gmap; - gmap=new double[nnx*nny]; - for (int ix=0; ixClear(); -#ifdef ROOTSPECTRUM - hs->Reset(); -#ifdef ROOTCLUST - hs3->Reset();//new TH2F("hs","hs",(orig->hs)-getNbins,-500,9500,nx*ny,-0.5,nx*ny-0.5); - hs5->Reset();//new TH2F("hs","hs",(orig->hs)-getNbins,-500,9500,nx*ny,-0.5,nx*ny-0.5); - hs7->Reset();//new TH2F("hs","hs",(orig->hs)-getNbins,-500,9500,nx*ny,-0.5,nx*ny-0.5); - hs9->Reset();//new TH2F("hs","hs",(orig->hs)-getNbins,-500,9500,nx*ny,-0.5,nx*ny-0.5); -#endif -#endif - }; - - /** resets the commonModeSubtraction and increases the frame index */ - virtual void newFrame(){iframe++; if (cmSub) cmSub->newFrame();}; - - - /** sets the commonModeSubtraction algorithm to be used - \param cm commonModeSubtraction algorithm to be used (NULL unsets) - \returns pointer to the actual common mode subtraction algorithm - */ - commonModeSubtraction *setCommonModeSubtraction(commonModeSubtraction *cm) {cmSub=cm; return cmSub;}; -/** - gets the commonModeSubtraction algorithm to be used - \returns pointer to the actual common mode subtraction algorithm - */ - commonModeSubtraction *getCommonModeSubtraction() {return cmSub;}; - - - /** - sets the sign of the data - \param sign 1 means positive values for photons, -1 negative, 0 gets - \returns current sign for the data - */ - int setDataSign(int sign=0) {if (sign==1 || sign==-1) dataSign=sign; return dataSign;}; - - - /** - adds value to pedestal (and common mode) for the given pixel - \param val value to be added - \param ix pixel x coordinate - \param iy pixel y coordinate - \param cm 1 adds the value to common mod, 0 skips it. Defaults to 0. - not properly implemented - */ - virtual void addToPedestal(double val, int ix, int iy=0, int cm=0){ - if (ix>=0 && ix=0 && iy0) { - val-= getCommonMode(ix, iy); - } - stat[iy][ix].addToPedestal(val); - /* if (cmSub && cm>0) { */ - /* if (det) if (det->isGood(ix, iy)==0) return; */ - /* cmSub->addToCommonMode(val, ix, iy); */ - /* }; */ - }; - } - - double getCommonMode(int ix, int iy) { - if (cmSub) return cmSub->getCommonMode(ix, iy); - else return 0; - } - - - virtual void addToCommonMode(char *data){ - if (cmSub) { - for (int ix=xmin; ix0) - addToCommonMode(data, ix, iy); - } - } - //cout << "cm " << getCommonMode(0,0) << " " << getCommonMode(1,0) << endl; - } - } - virtual void addToCommonMode(char *data, int ix, int iy=0){ - if (cmSub) { - if (det) if (det->isGood(ix, iy)==0) return; - if (getNumpedestals(ix,iy)>0){ - cmSub->addToCommonMode(subtractPedestal(data,ix,iy,0), ix, iy); - // cout << ix << " " <=0 && ix=0 && iy0) - return stat[iy][ix].getPedestal()+getCommonMode(ix,iy); - else return stat[iy][ix].getPedestal(); - else return -1; - }; - - - /** - gets pedestal rms (i.e. noise) - \param ix pixel x coordinate - \param iy pixel y coordinate - \returns pedestal rms - */ - virtual double getPedestalRMS(int ix, int iy){ - if (ix>=0 && ix=0 && iy=0 && ix=0 && iy=0 && ix=0 && iy=0 && ix=0 && iySetBinContent(ix+1, iy+1,image[iy*nx+ix]); -#endif - } - } - ret=WriteToTiff(gm, imgname, ny, nx); - delete [] gm; -#ifdef ROOTSPECTRUM - char rootfn[10000]; - sprintf(rootfn,"%s.root",imgname); - TFile *f=new TFile(rootfn,"RECREATE"); - hs->Write("hs"); -#ifdef ROOTCLUST - hs3->Write("hs3"); - hs5->Write("hs5"); - hs7->Write("hs7"); - hs9->Write("hs9"); -#endif - hmap->Write("hmap"); - - - f->Close(); - delete f; - delete hmap; -#endif - return ret; - } -#ifdef ROOTSPECTRUM - TH2F *getSpectrum(){return hs;}; -#endif - /** - write 32bit tiff file containing the pedestals - \param imgname file name to be written - \returns NULL if file writing didn't succed, otherwise a pointer - */ - - virtual void *writePedestals(const char * imgname) { - float *gm=NULL; - void *ret; - gm=new float[nx*ny]; -#ifdef ROOTSPECTRUM - - TH2F *hmap=new TH2F("hmap","hmap",nx, -0.5,nx-0.5, ny, -0.5, ny-0.5); - -#endif - for (int ix=0; ixgetCommonMode(); */ - /* else */ - gm[iy*nx+ix]=stat[iy][ix].getPedestal(); -#ifdef ROOTSPECTRUM - hmap->SetBinContent(ix+1, iy+1,gm[iy*nx+ix]); -#endif - } - } - ret=WriteToTiff(gm, imgname, ny, nx); - delete [] gm; - -#ifdef ROOTSPECTRUM - char rootfn[10000]; - sprintf(rootfn,"%s.root",imgname); - TFile *f=new TFile(rootfn,"RECREATE"); - hs->Write("hs"); -#ifdef ROOTCLUST - hs3->Write("hs3"); - hs5->Write("hs5"); - hs7->Write("hs7"); - hs9->Write("hs9"); -#endif - hmap->Write("hmap"); - f->Close(); - delete f; - delete hmap; -#endif - return ret; - } - - /** - read 32bit tiff file containing the pedestals - \param imgname file name to be read - \returns 0 if file reading didn't succed, otherwise 1 - */ - int readPedestals(const char * imgname) { - uint32 nnx, nny; - float *gm=ReadFromTiff( imgname, nny, nnx); - if (nnx>nx) nnx=nx; - if (nny>ny) nny=ny; - - - - if (gm) { - for (int ix=0; ixnx) nnx=nx; - if (nny>ny) nny=ny; - - - - if (gm) { - for (int ix=0; ixnx) nnx=nx; - if (nny>ny) nny=ny; - if (gm) { - for (int ix=0; ix=0 && xmi<=nx) xmin=xmi; - if (xma>=0 && xma<=nx) xmax=xma; - if (xmax=0 && ymi<=ny) ymin=ymi; - if (yma>=0 && yma<=ny) ymax=yma; - if (ymax=0 && ix=0 && iygetValue(data, ix, iy); - else - val=((double*)data)[iy*nx+ix]; - - /* if (ix==10 && iy==10) */ - /* cout << ix << " " << iy << " " << val ; */ - /* if (ix==100 && iy==100) */ - /* cout << ix << " " << iy << " " << val; */ - addToPedestal(val,ix,iy); - /* if (ix==10 && iy==10) */ - /* cout <<" " << getPedestal(ix,iy)<< endl; */ - /* if (ix==100 && iy==100) */ - /* cout << " " << getPedestal(ix,iy)<< endl; */ - } - return ; - - }; - - - /** - Subtracts pedestal from the data array in the region of interest - \param data pointer to the data - \param val pointer where the pedestal subtracted data should be added. If NULL, the internal image is used - \returns pointer to the pedestal subtracted data - */ - // virtual int *subtractPedestal(char *data, int *val=NULL) { - - virtual int *subtractPedestal(char *data, int *val=NULL, int cm=0) { - - newFrame(); - - if (val==NULL) - val=image;//new double[nx*ny]; - - for (int ix=xmin; ix=0 && ix=0 && iygetValue(data, ix, iy)-getPedestal(ix,iy,cm))/g; - else - val= (((double*)data)[iy*nx+ix]-getPedestal(ix,iy))/g; - -#ifdef ROOTSPECTRUM - hs->Fill(val,(iy-ymin)*(xmax-xmin)+(ix-xmin)); -#ifdef ROOTCLUST - double v3=0,v5=0,v7=0,v9=0; - for (int iix=-4; iix<5; iix++) - for (int iiy=-4; iiy<5; iiy++) { - if (det) - val= (dataSign*det->getValue(data, ix+iix, iy+iiy)-getPedestal(ix+iix,iy+iiy,cm))/g; - else - val= (((double*)data)[(iy+iiy)*nx+ix+iix]-getPedestal(ix+iix,iy+iiy,cm))/g; - - if (iix>-4 && iiy>-4 && iix<4 && iiy<4) { - if (iix>-3 && iiy>-3 && iix<3 && iiy<3){ - if (iix>-2 && iiy>-2 && iix<2 && iiy<2){ - v3+=val; - } - v5+=val; - } - v7+=val; - } - v9+=val; - } - hs3->Fill(v3,(iy-ymin)*(xmax-xmin)+(ix-xmin)); - hs5->Fill(v5,(iy-ymin)*(xmax-xmin)+(ix-xmin)); - hs7->Fill(v7,(iy-ymin)*(xmax-xmin)+(ix-xmin)); - hs9->Fill(v9,(iy-ymin)*(xmax-xmin)+(ix-xmin)); - -#endif -#endif - return val; - } - }; - - - /** - sets threshold value for conversion into number of photons - \param t threshold to be set - \returns threshold value - */ - double setThreshold(double t){thr=t; return thr;}; - - /** - gets threshold value for conversion into number of photons - \returns threshold value - */ - double getThreshold(){return thr;}; - /** - converts the data into number of photons for the selected pixel - \param data pointer to the data - \param ix pixel x coordinate - \param iy pixel y coordinate - \returns converted number of photons. If no threshold is set, returns gain converted pedestal subtracted data. - */ - - virtual int getNPhotons(char *data, int ix, int iy=0) { - int nph=0; - double v; - if (ix>=0 && ix=0 && iyFill(v,(iy-ymin)*(xmax-xmin)+(ix-xmin)); */ -/* #endif */ - if (thr>0) { - v+=0.5*thr; - nph=v/thr; - if (nph>0) - return nph; - return 0; - } - return v; - } - return 0; - }; - - /** - converts the data into number of photons for all pixels - \param data pointer to the data - \param nph pointer where the photons should added. If NULL,the internal image is used - \returns pointer to array containing the number of photons - */ - int *getNPhotons(char *data, int *nph=NULL) { - - double val; - if (nph==NULL) - nph=image; - newFrame(); - - addToCommonMode(data); - - for (int ix=xmin; ixReset(); -#ifdef ROOTCLUST - - if (hs3) - hs3->Reset(); - if (hs5) - hs5->Reset(); - if (hs7) - hs7->Reset(); - if (hs9) - hs9->Reset(); -#endif - //cout << "done " << endl; -#endif - }; - - /** sets/gets number of samples for moving average pedestal calculation - \param i number of samples to be set (0 or negative gets) - \returns actual number of samples - */ - int SetNPedestals(int i=-1) { - int ix=0, iy=0; - if (i>0) - for (ix=0; ix=0 && ix=0 && iy=0 && ix=0 && iy *det; /**< slsDetectorData to be used */ - int nx; /**< Size of the detector in x direction */ - int ny; /**< Size of the detector in y direction */ - pedestalSubtraction **stat; /**< pedestalSubtraction class */ - commonModeSubtraction *cmSub;/**< commonModeSubtraction class */ - int dataSign; /**< sign of the data i.e. 1 if photon is positive, -1 if negative */ - int iframe; /**< frame number (not from file but incremented within the dataset every time newFrame is called */ - double *gmap; - int *image; - int id; - //int xmin, xmax, ymin, ymax; int xmin; /**< minimum x of the region of interest */ - int xmin; /**< minimum x of the region of interest */ - int xmax; /**< maximum x of the region of interest */ - int ymin;/**< minimum y of the region of interest */ - int ymax;/**< maximum y of the region of interest */ - double thr; /**< threshold to be used for conversion into number of photons */ - // int nSigma; /**< number of sigma to be used for conversion into number of photons if threshold is undefined */ - frameMode fMode; /**< current detector frame mode */ - FILE *myFile; /**< file pointer to write to */ -#ifdef ROOTSPECTRUM - TH2F *hs; -#ifdef ROOTCLUST - TH2F *hs3; - TH2F *hs5; - TH2F *hs7; - TH2F *hs9; -#endif -#endif - pthread_mutex_t *fm; -}; - -#endif diff --git a/slsDetectorCalibration/commonModeSubtraction.h b/slsDetectorCalibration/commonModeSubtraction.h deleted file mode 100644 index 0484e6746..000000000 --- a/slsDetectorCalibration/commonModeSubtraction.h +++ /dev/null @@ -1,82 +0,0 @@ -#ifndef COMMONMODESUBTRACTION_H -#define COMMONMODESUBTRACTION_H - -#include "MovingStat.h" - - - - -class commonModeSubtraction { - - /** @short class to calculate the common mode of the pedestals based on an approximated moving average*/ - - public: - - /** constructor - \param nn number of samples for the moving average to calculate the average common mode - \param iroi number of regions on which one can calculate the common mode separately. Defaults to 1 i.e. whole detector - - */ - commonModeSubtraction(int nn=1000, int iroi=1) : cmStat(NULL), cmPed(NULL), nCm(NULL), nROI(iroi) {cmStat=new MovingStat[nROI]; for (int i=0; i0) cmStat[i].Calc(cmPed[i]/nCm[i]); - nCm[i]=0; - cmPed[i]=0; - }}; - - /** adds the pixel to the sum of pedestals -- virtual func must be overloaded to define the regions of interest - \param val value to add - \param ix pixel x coordinate - \param iy pixel y coordinate - */ - virtual void addToCommonMode(double val, int ix=0, int iy=0) { - (void) ix; (void) iy; - - //if (isc>=0 && isc0) return cmPed[0]/nCm[0]-cmStat[0].Mean(); - return 0;}; - - - - - - protected: - MovingStat *cmStat; /** { - - - public: - mythen3_01_jctbData( int nch=64*3,int dr=24, int off=5): slsDetectorData(64*3,1,dr*8*nch,NULL,NULL,NULL), dynamicRange(dr), serialOffset(off), frameNumber(0), numberOfCounters(nch) {}; - - virtual void getPixel(int ip, int &x, int &y) {x=-1; y=-1;}; - - virtual short unsigned int getChannel(char *data, int ix, int iy=0) { - int ret=-1; - short unsigned int *val=mythen03_frame(data,dynamicRange,numberOfCounters,serialOffset); - if (ix>=0 && ix=0) frameNumber=f; return frameNumber; }; - virtual int setDynamicRange(int d=-1) {if (d>0 && d<=24) dynamicRange=d; return dynamicRange;}; - virtual int setSerialOffset(int d=-1) {if (d>=0) serialOffset=d; return serialOffset;}; - virtual int setNumberOfCounters(int d=-1) {if (d>=0) numberOfCounters=d; return numberOfCounters;}; - - - private: - - int dynamicRange; - int serialOffset; - int frameNumber; - int numberOfCounters; - - - - -}; - -#endif diff --git a/slsDetectorCalibration/dataStructures/Mythen3_02_jctbData.h b/slsDetectorCalibration/dataStructures/Mythen3_02_jctbData.h deleted file mode 100644 index 0dd991f56..000000000 --- a/slsDetectorCalibration/dataStructures/Mythen3_02_jctbData.h +++ /dev/null @@ -1,127 +0,0 @@ -#ifndef MYTHEN302JCTBDATA_H -#define MYTHEN302JCTBDATA_H - - -#include "Mythen3_01_jctbData.h" -//class mythen3_02_jctbData : public slsDetectorData { -class mythen3_02_jctbData : public mythen3_01_jctbData { - - - public: - mythen3_02_jctbData( int nch=64*3,int dr=24, int off=5): mythen3_01_jctbData( nch,dr, off) - //slsDetectorData(64*3,1,dr*8*nch,NULL,NULL,NULL), dynamicRange(dr), serialOffset(off), frameNumber(0), numberOfCounters(nch) - {}; - - /* virtual void getPixel(int ip, int &x, int &y) {x=-1; y=-1;}; */ - - /* virtual short unsigned int getChannel(char *data, int ix, int iy=0) { */ - /* int ret=-1; */ - /* short unsigned int *val=mythen03_frame(data,dynamicRange,numberOfCounters,serialOffset); */ - /* if (ix>=0 && ix=0) frameNumber=f; return frameNumber; }; */ - /* virtual int setDynamicRange(int d=-1) {if (d>0 && d<=24) dynamicRange=d; return dynamicRange;}; */ - /* virtual int setSerialOffset(int d=-1) {if (d>=0) serialOffset=d; return serialOffset;}; */ - /* virtual int setNumberOfCounters(int d=-1) {if (d>=0) numberOfCounters=d; return numberOfCounters;}; */ - - - /* private: */ - - /* int dynamicRange; */ - /* int serialOffset; */ - /* int frameNumber; */ - /* int numberOfCounters; */ - - - - -}; - -#endif diff --git a/slsDetectorCalibration/dataStructures/adcSar2_jctbData.h b/slsDetectorCalibration/dataStructures/adcSar2_jctbData.h deleted file mode 100644 index 0b0665aaf..000000000 --- a/slsDetectorCalibration/dataStructures/adcSar2_jctbData.h +++ /dev/null @@ -1,63 +0,0 @@ -#ifndef ADCSAR2_JCTBDATA_H -#define ADCSAR2_JCTBDATA_H - - -class adcSar2_jctbData : public slsDetectorData { - - - public: - adcSar2_jctbData(int nsamples=1000): slsDetectorData(nsamples,1,nsamples*8,NULL,NULL,NULL){}; - - virtual void getPixel(int ip, int &x, int &y) {x=ip/8; y=1;}; - - virtual short unsigned int getChannel(char *data, int ix, int iy=0) { - int adcvalue=0; - int vv1= *((int16_t*) (data+8*ix)); - int vv2= *((int16_t*) (data+8*ix+2)); - for (int jj=0;jj<8;jj++){ - adcvalue=adcvalue+ (((vv1>>(jj*2)) & 0x1)<<(jj)); - } - for (int jj=0;jj<4;jj++){ - adcvalue=adcvalue+ (((vv2>>(jj*2)) & 0x1)<<(jj+8)); - } - return adcvalue; - }; - - virtual int getFrameNumber(char *buff) {return frameNumber;}; - - virtual char *findNextFrame(char *data, int &ndata, int dsize) { - ndata=dsize; - return data; - } - - virtual char *readNextFrame(ifstream &filebin) { - char *data=NULL; - if (filebin.is_open()) { - data=new char[dataSize]; - filebin.read(data,dataSize); - } - return data; - } - - /* virtual int **getData(char *ptr, int dsize=-1) { */ - /* int **val; */ - /* val=new int*[1]; */ - /* val[0]=mythen03_frame(ptr,dynamicRange,nx,serialOffset); */ - /* return val; */ - - /* } */ - - - - virtual int setFrameNumber(int f=0) {if (f>=0) frameNumber=f; return frameNumber; }; - - private: - - int frameNumber; - - - - -}; - -#endif diff --git a/slsDetectorCalibration/dataStructures/chiptestBoardData.h b/slsDetectorCalibration/dataStructures/chiptestBoardData.h deleted file mode 100644 index 0ef633c44..000000000 --- a/slsDetectorCalibration/dataStructures/chiptestBoardData.h +++ /dev/null @@ -1,89 +0,0 @@ -#ifndef CHIPTESTDATA_H -#define CHIPTESTDATA_H - -#include "slsDetectorData.h" - -class chiptestBoardData : public slsDetectorData { - - - public: - - /** - chiptestBoard data structure. Works for data acquired using the chiptestBoard. - Inherits and implements slsDetectorData. - - Constructor (no error checking if datasize and offsets are compatible!) - \param npx number of pixels in the x direction - \param npy number of pixels in the y direction (1 for strips) - \param nadc number of adcs - \param offset offset at the beginning of the pattern - \param dMap array of size nx*ny storing the pointers to the data in the dataset (as offset) - \param dMask Array of size nx*ny storing the polarity of the data in the dataset (should be 0 if no inversion is required, 0xffffffff is inversion is required) - \param dROI Array of size nx*ny. The elements are 1s if the channel is good or in the ROI, 0 is bad or out of the ROI. NULL (default) means all 1s. - - */ - chiptestBoardData(int npx, int npy, int nadc, int offset, int **dMap=NULL, uint16_t **dMask=NULL, int **dROI=NULL): slsDetectorData(npx, npy, nadc*(npx*npy)+offset, dMap, dMask, dROI), nAdc(nadc), offSize(offset), iframe(0) {}; // should be? nadc*(npx*npy+offset) - - - - /** - - Returns the frame number for the given dataset. Virtual func: works for slsDetectorReceiver data (also for each packet), but can be overloaded. - \param buff pointer to the dataset - \returns frame number - - */ - - virtual int getFrameNumber(char *buff){(void)buff; return iframe;}; - - - /** - - Loops over a memory slot until a complete frame is found (i.e. all packets 0 to nPackets, same frame number). Can be overloaded for different kind of detectors! - \param data pointer to the memory to be analyzed - \param ndata size of frame returned - \param dsize size of the memory slot to be analyzed - \returns always return the pointer to data (no frame loss!) - */ - - virtual char *findNextFrame(char *data, int &ndata, int dsize) {ndata=dsize;setDataSize(dsize); return data;}; - - /** - Loops over a file stream until a complete frame is found (i.e. all packets 0 to nPackets, same frame number). Can be overloaded for different kind of detectors! - \param filebin input file stream (binary) - \returns pointer to the first packet of the last good frame, NULL if no frame is found or last frame is incomplete - */ - - virtual char *readNextFrame(ifstream &filebin) { - - int afifo_length=0; - uint16_t *afifo_cont; - - if (filebin.is_open()) { - if (filebin.read((char*)&afifo_length,sizeof(uint32_t))) { - setDataSize(afifo_length*nAdc*sizeof(uint16_t)); - afifo_cont=new uint16_t[afifo_length*nAdc]; - if (filebin.read((char*)afifo_cont,afifo_length*sizeof(uint16_t)*nAdc)) { - iframe++; - return (char*)afifo_cont; - } else { - delete [] afifo_cont; - return NULL; - } - } else { - return NULL; - } - } - return NULL; - }; - - private: - const int nAdc; /** { -public: - - - - - /** - Implements the slsReceiverData structure for the eiger prototype read out by a half module i.e. using the slsReceiver - (256*256 pixels, 512 packets for 16 bit mode, 256 for 8, 128 for 4, 1024 for 32, 1040 etc.) - \param d dynamic range - \param c crosstalk parameter for the output buffer - - */ - - - eigerHalfModuleData(bool t, bool l, int dr, int tg, int psize, int dsize, int npf, int x, int y, double c=0): - slsReceiverData(x, y, npf, psize), - top(t), left(l), - dynamicRange(dr), tenGiga(tg), - packetSize(psize), onepacketdataSize(dsize), numberofPacketsPerFrame(npf), - xtalk(c), - header_t(0), footer_t(0){ - - - int **dMap; - uint32_t **dMask; - - dMap=new int*[ny]; - dMask=new uint32_t*[ny]; - - - for (int i = 0; i < ny; i++) { - dMap[i] = new int[nx]; - dMask[i] = new uint32_t[nx]; - } - - //Map - int totalNumberOfBytes = numberofPacketsPerFrame * packetSize; - int iPacket = 8; - int iData = 0; - int increment = (dynamicRange/8); - int ic_increment = 1; - if (dynamicRange == 4) { - increment = 1; - ic_increment = 2; - } - - if(top){ - for (int ir=0; ir= onepacketdataSize){ - iPacket += 16; - iData = 0; - } - - } - } - } - - //bottom - else{ - iData = 0; - int numbytesperline; - switch(dynamicRange){ - case 4: numbytesperline = 256; break; - case 8: numbytesperline = 512; break; - case 16:numbytesperline = 1024; break; - case 32:numbytesperline = 2048; break; - } - iPacket = totalNumberOfBytes - numbytesperline - 8; - if((dynamicRange == 32) && (!tenGiga)) - iPacket -= 16; - - for (int ir=0; irpacketnum)); - }; - - - - /** - returns the pixel value as double correcting for the output buffer crosstalk - \param data pointer to the memory - \param ix coordinate in the x direction - \param iy coordinate in the y direction - \returns channel value as double - - */ - double getValue(char *data, int ix, int iy=0) { - // cout << "##" << (void*)data << " " << ix << " " <=0 && ix=0 && iy=0 && dataMap[iy][ix]missingpacket); - - if(identifier==deactivatedPacketValue){ - // cprintf(RED,"deactivated packet\n"); - return -2; - } - // -----END OF CHECK ------------------------------------------------------------- - - - }else{ - cprintf(RED,"outside limits\n"); - return -99; - } - - //get proper data - n = ((uint32_t)(*((uint32_t*)(((char*)data)+(dataMap[iy][ix]))))); - - //each byte is shared by 2 pixels for 4 bit mode - if(dynamicRange == 4){ - if(ix != origX) - return ((n & 0xf0)>>4)^m; - return (n & 0xf)^m; - } - else if(dynamicRange == 8) return (n & 0xff)^m; - else if(dynamicRange == 16) return (n & 0xffff)^m; - else return (n & 0xffffffff)^m; - - - }; - - - /** sets the output buffer crosstalk correction parameter - \param c output buffer crosstalk correction parameter to be set - \returns current value for the output buffer crosstalk correction parameter - - */ - double setXTalk(double c) {xtalk=c; return xtalk;} - - - /** gets the output buffer crosstalk parameter - \returns current value for the output buffer crosstalk correction parameter - */ - double getXTalk() {return xtalk;} - - void getChannelArray(double* data, char* buffer){ - for(int iy = 0; iy < ny; iy++){ - for(int ix = 0; ix < nx; ix++){ - data[iy*nx+ix] = getValue((char*)buffer,ix,iy); - //cprintf(BLUE,"%d,%d :%f\n",ix,iy,value); - } - } - } - - - int* decodeData(int *datain) { - - int dataBytes = numberofPacketsPerFrame * onepacketdataSize; - int nch = nx*ny; - int* dataout = new int [nch]; - char *ptr=(char*)datain; - char iptr; - - const int bytesize=8; - int ival=0; - int ipos=0, ichan=0, ibyte; - - switch (dynamicRange) { - case 4: - for (ibyte=0; ibyte>(ipos*4))&0xf; //pick the right 4bit - dataout[ichan]=ival; - ichan++; - } - } - break; - case 8: - for (ichan=0; ichan { - - private: - const int nModules; - const int offset; - int iframe; - - -public: - - - - /** - Implements the slsReceiverData structure for the gotthard read out by a module i.e. using the slsReceiver - (1x1280 pixels, 2 packets 1286 large etc.) - \param c crosstalk parameter for the output buffer - - */ - - - gotthardDoubleModuleDataNew(int off=24*2, int nmod=2): slsDetectorData(1280*nmod, 1, nmod*(1280*2+off)), nModules(nmod), offset(off),iframe(0) { - - - - -#ifdef BCHIP074_BCHIP075 - cout << "This is a bchip074-bchip075 system " << endl; -#endif - - - uint16_t **dMask; - int **dMap; - int ix, iy; - int ypixels=1; - int xpixels=1280*nmod; - int imod, ipix; - dMask=new uint16_t*[1]; - dMap=new int*[1]; - dMap[0] = new int[1280*nmod]; - dMask[0] = new uint16_t[1280*nmod]; - - for(int ix=0; ix=128*4 && ibad<128*5) || (ibad>=9*128 && ibad<10*128) || (ibad>=(1280+128*4) && ibad=(1280+128*6))) - dataROIMask[0][ix]=0; -#endif - } - - setDataMap(dMap); - setDataMask(dMask); - - }; - - - /** - - Returns the frame number for the given dataset. - \param buff pointer to the dataset - \returns frame number - - */ - - - int getFrameNumber(char *buff){if (offset>=sizeof(sls_detector_header)) return ((sls_detector_header*)buff)->frameNumber; return iframe;};//*((int*)(buff+5))&0xffffff;}; - - - - /** - gets the packets number (last packet is labelled with 0 and is replaced with 40) - \param buff pointer to the memory - \returns packet number - - */ - - int getPacketNumber(char *buff){if (offset>=sizeof(sls_detector_header))return ((sls_detector_header*)buff)->packetNumber;}; - - - - - /** - - Loops over a memory slot until a complete frame is found (i.e. all packets 0 to nPackets, same frame number). purely virtual func - \param data pointer to the memory to be analyzed - \param ndata reference to the amount of data found for the frame, in case the frame is incomplete at the end of the memory slot - \param dsize size of the memory slot to be analyzed - \returns pointer to the beginning of the last good frame (might be incomplete if ndata smaller than dataSize), or NULL if no frame is found - - */ - virtual char *findNextFrame(char *data, int &ndata, int dsize){ - if (dsize=0) - fnum=ff; - - if (filebin.is_open()) { - if (filebin.read(data, dataSize) ){ - ff=getFrameNumber(data); - np=getPacketNumber(data); - return data; - } - } - return NULL; - - - - }; - - - - -}; - - - - - -#endif diff --git a/slsDetectorCalibration/dataStructures/gotthardModuleData.h b/slsDetectorCalibration/dataStructures/gotthardModuleData.h deleted file mode 100644 index 3f674af57..000000000 --- a/slsDetectorCalibration/dataStructures/gotthardModuleData.h +++ /dev/null @@ -1,148 +0,0 @@ -#ifndef GOTTHARDMODULEDATA_H -#define GOTTHARDMODULEDATA_H -#include "slsReceiverData.h" - - - - - -#define FRAMEMASK 0xFFFFFFFE -#define PACKETMASK 1 -#define FRAMEOFFSET 0x1 - - -class gotthardModuleData : public slsReceiverData { -public: - - - - - /** - Implements the slsReceiverData structure for the gotthard read out by a module i.e. using the slsReceiver - (1x1280 pixels, 2 packets 1286 large etc.) - \param c crosstalk parameter for the output buffer - - */ - - - gotthardModuleData(double c=0): slsReceiverData(xpixels, ypixels, npackets, buffersize), xtalk(c) { - - uint16_t **dMask; - int **dMap; - int ix, iy; - int initial_offset = 2; - int offset = initial_offset; - - dMask=new uint16_t*[ypixels]; - dMap=new int*[ypixels]; - for (int i = 0; i < ypixels; i++) { - dMap[i] = new int[xpixels]; - dMask[i] = new uint16_t[xpixels]; - } - - for(ix=0; ix>FRAMEOFFSET); - }; - - - - /** - gets the packets number (last packet is labelled with 0 and is replaced with 40) - \param buff pointer to the memory - \returns packet number - - */ - - int getPacketNumber(char *buff){ - int np=(*(int*)buff); - //gotthards frame header must be incremented - ++np; - //packet index should be 1 or 2 - return ((np&PACKETMASK)+1); - }; - - - /** - returns the pixel value as double correcting for the output buffer crosstalk - \param data pointer to the memory - \param ix coordinate in the x direction - \param iy coordinate in the y direction - \returns channel value as double - - */ - double getValue(char *data, int ix, int iy=0) { - //check how it is for gotthard - if (xtalk==0) - return slsDetectorData::getValue(data, ix, iy); - else - return slsDetectorData::getValue(data, ix, iy)-xtalk*slsDetectorData::getValue(data, ix-1, iy); - }; - - - - /** sets the output buffer crosstalk correction parameter - \param c output buffer crosstalk correction parameter to be set - \returns current value for the output buffer crosstalk correction parameter - - */ - double setXTalk(double c) {xtalk=c; return xtalk;} - - - /** gets the output buffer crosstalk parameter - \returns current value for the output buffer crosstalk correction parameter - */ - double getXTalk() {return xtalk;} - - - - - - - -private: - - double xtalk; /** { - - private: - - int iframe; - const int offset; - - -public: - - - - /** - Implements the slsReceiverData structure for the gotthard read out by a module i.e. using the slsReceiver - (1x1280 pixels, 2 packets 1286 large etc.) - \param c crosstalk parameter for the output buffer - - */ - - - gotthardModuleDataNew(int off=24*2, int nch=1280): slsDetectorData(nch, 1, nch*2+off), offset(off) { - - uint16_t **dMask; - int **dMap; - int ix, iy; - int ypixels=1; - int xpixels=nch; - - dMask=new uint16_t*[1]; - dMap=new int*[1]; - dMap[0] = new int[nch]; - dMask[0] = new uint16_t[nch]; - - for(int ix=0; ix=sizeof(sls_detector_header)) return ((sls_detector_header*)buff)->frameNumber; return iframe;};//*((int*)(buff+5))&0xffffff;}; - - - - /** - gets the packets number (last packet is labelled with 0 and is replaced with 40) - \param buff pointer to the memory - \returns packet number - - */ - - int getPacketNumber(char *buff){if (offset>=sizeof(sls_detector_header))return ((sls_detector_header*)buff)->packetNumber;}; - - - - - /** - - Loops over a memory slot until a complete frame is found (i.e. all packets 0 to nPackets, same frame number). purely virtual func - \param data pointer to the memory to be analyzed - \param ndata reference to the amount of data found for the frame, in case the frame is incomplete at the end of the memory slot - \param dsize size of the memory slot to be analyzed - \returns pointer to the beginning of the last good frame (might be incomplete if ndata smaller than dataSize), or NULL if no frame is found - - */ - virtual char *findNextFrame(char *data, int &ndata, int dsize){ - if (dsize=0) - fnum=ff; - - if (filebin.is_open()) { - if (filebin.read(data, dataSize) ){ - ff=getFrameNumber(data); - np=getPacketNumber(data); - return data; - } - } - return NULL; - - - - }; - - - - -}; - - - - - -#endif diff --git a/slsDetectorCalibration/dataStructures/gotthardShortModuleData.h b/slsDetectorCalibration/dataStructures/gotthardShortModuleData.h deleted file mode 100644 index 4d853c7b0..000000000 --- a/slsDetectorCalibration/dataStructures/gotthardShortModuleData.h +++ /dev/null @@ -1,127 +0,0 @@ -#ifndef GOTTHARDSHORTMODULEDATA_H -#define GOTTHARDSHORTMODULEDATA_H -#include "slsReceiverData.h" - - - - - - -class gotthardShortModuleData : public slsReceiverData { -public: - - - - - /** - Implements the slsReceiverData structure for the gotthard short read out by a module i.e. using the slsReceiver - (1x256 pixels, 1 packet 256 large etc.) - \param c crosstalk parameter for the output buffer - - */ - - - gotthardShortModuleData(double c=0): slsReceiverData(xpixels, ypixels, npackets, buffersize), xtalk(c){ - - uint16_t **dMask; - int **dMap; - int ix, iy; - int offset = 2; - - dMask=new uint16_t*[ypixels]; - dMap=new int*[ypixels]; - for (int i = 0; i < ypixels; i++) { - dMap[i] = new int[xpixels]; - dMask[i] = new uint16_t[xpixels]; - } - - for(ix=0; ix::getValue(data, ix, iy); - else - return slsDetectorData::getValue(data, ix, iy)-xtalk*slsDetectorData::getValue(data, ix-1, iy); - }; - - - - /** sets the output buffer crosstalk correction parameter - \param c output buffer crosstalk correction parameter to be set - \returns current value for the output buffer crosstalk correction parameter - - */ - double setXTalk(double c) {xtalk=c; return xtalk;} - - - /** gets the output buffer crosstalk parameter - \returns current value for the output buffer crosstalk correction parameter - */ - double getXTalk() {return xtalk;} - - - - - - - -private: - - double xtalk; /**=0 && ix=0 && iy=0 && dataMap[iy][ix]8000) //exchange if gainBits==2 is returned! - d|=(1<<14); // gain bit 1 - if (*((uint16_t*)(data)+dataMap[iy][ix]+1)>8000) //exchange if gainBits==2 is returned! - d|=(1<<15); // gain bit 0 - - } - - } - return d^m; - }; - - /** - returns the pixel value as double correcting for the output buffer crosstalk - \param data pointer to the memory - \param ix coordinate in the x direction - \param iy coordinate in the y direction - \returns channel value as double - - */ - double getValue(char *data, int ix, int iy=0) { - // cout << "##" << (void*)data << " " << ix << " " < the gain bits are read out the wrong way around (i.e. GB0 and GB1 have to be reversed!) - \param data pointer to the memory - \param ix coordinate in the x direction - \param iy coordinate in the y direction - \returns gain bits as int - */ - int getGainBits(char *data, int ix, int iy=0) { - uint16_t d=getChannel(data, ix, iy); - return ((d&0xc000)>>14); - }; - //*/ - - - - - /** sets the output buffer crosstalk correction parameter - \param c output buffer crosstalk correction parameter to be set - \returns current value for the output buffer crosstalk correction parameter - - */ - double setXTalk(double c) {xtalk=c; return xtalk;} - - - /** gets the output buffer crosstalk parameter - \returns current value for the output buffer crosstalk correction parameter - */ - double getXTalk() {return xtalk;} - - - - - - - - private: - - double xtalk; /** { - - private: - - int iframe; - int nadc; - int sc_width; - int sc_height; - public: - - - - - /** - Implements the slsReceiverData structure for the moench02 prototype read out by a module i.e. using the slsReceiver - (160x160 pixels, 40 packets 1286 large etc.) - \param c crosstalk parameter for the output buffer - - */ - - - jungfrau10ModuleData(int ns=16384): slsDetectorData(256*4, 256*2, 256*256*8*2, NULL, NULL, NULL) , iframe(0), nadc(32), sc_width(64), sc_height(256) { - - - - int row, col; - - int isample; - int iadc; - int ix, iy; - - int ichip; - - // cout << sizeof(uint16_t) << endl; - - for (iadc=0; iadc=ny || col<0 || col>=nx) { - cout << "Wrong row, column " << row << " " << col << " " << iadc << " " << i << endl; - } else - dataMap[row][col]=(nadc*i+iadc)*2; - if (dataMap[row][col]<0 || dataMap[row][col]>=dataSize) - cout << "Error: pointer " << dataMap[row][col] << " out of range " << row << " " << col <<" " << iadc << " " << i << endl; - else { - xmap[nadc*i+iadc]=col; - ymap[nadc*i+iadc]=row; - - } - } - - } - - - - }; - - - - /** - - Returns the frame number for the given dataset. Purely virtual func. - \param buff pointer to the dataset - \returns frame number - - */ - - - int getFrameNumber(char *buff){(void)buff; return iframe;}; - - /** - - Returns the packet number for the given dataset. purely virtual func - \param buff pointer to the dataset - \returns packet number number - - - virtual int getPacketNumber(char *buff)=0; - - */ - - /** - - Loops over a memory slot until a complete frame is found (i.e. all packets 0 to nPackets, same frame number). purely virtual func - \param data pointer to the memory to be analyzed - \param ndata reference to the amount of data found for the frame, in case the frame is incomplete at the end of the memory slot - \param dsize size of the memory slot to be analyzed - \returns pointer to the beginning of the last good frame (might be incomplete if ndata smaller than dataSize), or NULL if no frame is found - - */ - char *findNextFrame(char *data, int &ndata, int dsize){ndata=dsize; setDataSize(dsize); return data;}; - - - /** - - Loops over a file stream until a complete frame is found (i.e. all packets 0 to nPackets, same frame number). Can be overloaded for different kind of detectors! - \param filebin input file stream (binary) - \returns pointer to the begin of the last good frame, NULL if no frame is found or last frame is incomplete - - */ - char *readNextFrame(ifstream &filebin){ - // int afifo_length=0; - uint16_t *afifo_cont; - int ib=0; - if (filebin.is_open()) { - afifo_cont=new uint16_t[dataSize/2]; - while (filebin.read(((char*)afifo_cont)+ib,2)) { - ib+=2; - if (ib==dataSize) break; - } - if (ib>0) { - iframe++; - // cout << ib << "-" << endl; - return (char*)afifo_cont; - } else { - delete [] afifo_cont; - return NULL; - } - } - return NULL; - }; - - - - -}; - - - -#endif diff --git a/slsDetectorCalibration/dataStructures/moench02Ctb10GbData.h b/slsDetectorCalibration/dataStructures/moench02Ctb10GbData.h deleted file mode 100644 index a36090496..000000000 --- a/slsDetectorCalibration/dataStructures/moench02Ctb10GbData.h +++ /dev/null @@ -1,246 +0,0 @@ -#ifndef MOENCH02CTB10GBDATA_H -#define MOENCH02CTB10GBDATA_H -#include -#include "slsDetectorData.h" -#include "slsReceiverData.h" - - -class moench02Ctb10GbData : public slsReceiverData { - - private: - - int iframe; - // int *xmap, *ymap; - int nadc; - int sc_width; - int sc_height; - - int maplength; - - - - public: - - - - - /** - Implements the slsReceiverData structure for the moench02 prototype read out by a module i.e. using the slsReceiver - (160x160 pixels, 40 packets 1286 large etc.) - \param c crosstalk parameter for the output buffer - - */ - - - moench02Ctb10GbData(int ns=6400): slsReceiverData(160, 160, 50, 8208) , nadc(4), sc_width(40), sc_height(160) { - - - int adc_nr[4]={120,0,80,40}; - int row, col; - - int isample; - int iadc; - int ix, iy; - int i; - int npackets=50; - maplength = 8208*npackets; - //this->setDataSize(maplength); - /* maplength=this->getDataSize()/2; */ - - for (int ip=0; ip=8208*npackets) { - cout << "Error: pointer " << dataMap[row][col] << " out of range "<< endl; - } - - } - } - } - } - int ibyte; - int ii=0; - - for (int ipacket=0; ipacket=2 && iadc<=5){ - xmap[i]=adc_nr[iadc-2]+ix; - ymap[i]=iy; - }else{ - xmap[i]=-1; - ymap[i]=-1; - } - ii++; - } - }//end loop on bytes - }//end loop on packets - - iframe=0; - cout << "data struct created" << endl; - }; - - void getPixel(int ip, int &x, int &y) { - if(ip>=0 && ip0) { */ - /* iframe++; */ - /* //cout << ib << "-" << endl; */ - /* return (char*)afifo_cont; */ - /* } else { */ - /* delete [] afifo_cont; */ - /* return NULL; */ - /* } */ - /* } */ - /* return NULL; */ - /* }; */ - virtual char *readNextFrame(ifstream &filebin, int& ff, int &np) { - char *data=new char[packetSize*nPackets]; - char *retval=0; - int nd; - np=0; - int pn; - char aa[8224]={0}; - char *packet=(char *)aa; - int fnum = -1; - if (ff>=0) - fnum=ff; - - if (filebin.is_open()) { - - - cout << "+"; - - while(filebin.read((char*)packet, 8208)){ - - pn=getPacketNumber(packet); - if (fnum<0) - fnum= getFrameNumber(packet); - - - if (fnum>=0) { - if (getFrameNumber(packet) !=fnum) { - - if (np==0){ - cout << "-"; - delete [] data; - return NULL; - } else - filebin.seekg(-8208,ios_base::cur); - return data; - } - - memcpy(data+(pn-1)*packetSize, packet, packetSize); - - np++; - if (np==nPackets) - break; - if (pn==nPackets) - break; - } - } - }else{ - cerr< { - - private: - - int iframe; - // int *xmap, *ymap; - int nadc; - int sc_width; - int sc_height; - - int maplength; - - - - public: - - - - - /** - Implements the slsReceiverData structure for the moench02 prototype read out by a module i.e. using the slsReceiver - (160x160 pixels, 40 packets 1286 large etc.) - \param c crosstalk parameter for the output buffer - - */ - - - moench02CtbData(int ns=6400): slsDetectorData(160, 160, ns*2*32, NULL, NULL) , nadc(32), sc_width(40), sc_height(160) { - - - int adc_off[4]={0,40,80,120}; - int adc_nr[4]={8,10,20,23}; - int row, col; - - int isample; - int iadc, iiadc; - int ix, iy; - maplength=this->getDataSize()/2; - //cout << maplength << endl; - - for (iiadc=0; iiadc<4; iiadc++) { - - iadc=adc_nr[iiadc]; - //cout << iiadc << endl; - for (int i=0; i=dataSize) { - cout << "Error: pointer " << dataMap[row][col] << " out of range "<< endl; - } - - } - } - - for (int i=0; i=0){ - xmap[i]=adc_off[iadc]+ix; - ymap[i]=iy; - }else{ - xmap[i]=-1; - ymap[i]=-1; - } - } - iframe=0; - cout << "data struct created" << endl; - }; - - void getPixel(int ip, int &x, int &y) { - if(ip>=0 && ip0) { - iframe++; - //cout << ib/2 << "-" << endl; - //for (int i=0; i { - public: - - - - - /** - Implements the slsReceiverData structure for the moench02 prototype read out by a module i.e. using the slsReceiver - (160x160 pixels, 40 packets 1286 large etc.) - \param c crosstalk parameter for the output buffer - - */ - - - moench02ModuleData(double c=0): slsReceiverData(160, 160, 40, 1286), - xtalk(c) { - - - - - uint16_t **dMask; - int **dMap; - int ix, iy; - - - - dMask=new uint16_t*[160]; - dMap=new int*[160]; - for (int i = 0; i < 160; i++) { - dMap[i] = new int[160]; - dMask[i] = new uint16_t[160]; - } - - for (int isc=0; isc<4; isc++) { - for (int ip=0; ip<10; ip++) { - - for (int ir=0; ir<16; ir++) { - for (int ic=0; ic<40; ic++) { - - ix=isc*40+ic; - iy=ip*16+ir; - - dMap[iy][ix]=1286*(isc*10+ip)+2*ir*40+2*ic+4; - // cout << ix << " " << iy << " " << dMap[ix][iy] << endl; - } - } - } - } - - for (ix=0; ix<120; ix++) { - for (iy=0; iy<160; iy++) - dMask[iy][ix]=0x3fff; - } - for (ix=120; ix<160; ix++) { - for (iy=0; iy<160; iy++) - dMask[iy][ix]=0x0; - } - - - setDataMap(dMap); - setDataMask(dMask); - - - - - }; - - - - /** - gets the packets number (last packet is labelled with 0 and is replaced with 40) - \param buff pointer to the memory - \returns packet number - - */ - - int getPacketNumber(char *buff){ - int np=(*(int*)buff)&0xff; - if (np==0) - np=40; - return np; - }; - - - /** - returns the pixel value as double correcting for the output buffer crosstalk - \param data pointer to the memory - \param ix coordinate in the x direction - \param iy coordinate in the y direction - \returns channel value as double - - */ - double getValue(char *data, int ix, int iy=0) { - // cout << "##" << (void*)data << " " << ix << " " <::getValue(data, ix, iy); - else - return slsDetectorData::getValue(data, ix, iy)-xtalk*slsDetectorData::getValue(data, ix-1, iy); - }; - - - - /** sets the output buffer crosstalk correction parameter - \param c output buffer crosstalk correction parameter to be set - \returns current value for the output buffer crosstalk correction parameter - - */ - double setXTalk(double c) {xtalk=c; return xtalk;} - - - /** gets the output buffer crosstalk parameter - \returns current value for the output buffer crosstalk correction parameter - */ - double getXTalk() {return xtalk;} - - - - - - - - private: - - double xtalk; /** { - - protected: - - int iframe; - int nadc; - int sc_width; - int sc_height; - - public: - - - - - /** - Implements the slsReceiverData structure for the moench02 prototype read out by a module i.e. using the slsReceiver - (160x160 pixels, 40 packets 1286 large etc.) - \param c crosstalk parameter for the output buffer - - */ - - - // moench03Ctb10GbData(int ns=5000): slsDetectorData(400, 400, 8208*40, NULL, NULL) , nadc(32), sc_width(25), sc_height(200) { - moench03Ctb10GbData(int ns=5000): slsReceiverData(400, 400, 40, 8208), nadc(32), sc_width(25), sc_height(200) { - - int adc_nr[32]={200,225,250,275,300,325,350,375,\ - 0,25,50,75,100,125,150,175,\ - 175,150,125,100,75,50,25,0,\ - 375,350,325,300,275,250,225,200}; - int row, col; - - int isample; - int iadc; - int ix, iy; - - int npackets=40; - int i; - - - for (int ip=0; ip=8208*40) - cout << "Error: pointer " << dataMap[row][col] << " out of range "<< endl; - } - } - } - } - - int ipacket; - int ibyte; - int ii=0; - for (int ipacket=0; ipacket0) { */ -/* iframe++; */ -/* // cout << ib << "-" << endl; */ -/* return (char*)afifo_cont; */ -/* } else { */ -/* delete [] afifo_cont; */ -/* return NULL; */ -/* } */ -/* } */ -/* return NULL; */ -/* }; */ - - - virtual char *readNextFrame(ifstream &filebin, int& fnum, char *data=NULL) { - int dd=0; - if (data==NULL) { - data=new char[packetSize*nPackets]; - dd=1; - } - char *retval=0; - int np=0, nd; - fnum = -1; - int pn; - char aa[8224]; - char *packet=(char *)aa; - int place; - - if (filebin.is_open()) { - - - - place=filebin.tellg(); - while(filebin.read((char*)packet, 8208) && np=0) { - if (getFrameNumber(packet) !=fnum) { - cout << "-"<=0) { */ -/* if (getFrameNumber(packet) !=fnum) { */ - -/* if (np==0){ */ -/* delete [] data; */ -/* return NULL; */ -/* } else */ -/* return data; */ -/* } */ - -/* memcpy(data+(pn-1)*packetSize, packet, packetSize); */ -/* np++; */ - -/* } */ -/* } */ - -/* } */ - -/* if (np==0){ */ -/* delete [] data; */ -/* return NULL; */ -/* } */ - -/* }; */ - -int getPacketNumber(int x, int y) {return dataMap[y][x]/8208;}; - - -}; - - - - -#endif diff --git a/slsDetectorCalibration/dataStructures/moench03Ctb10GbT1Data.h b/slsDetectorCalibration/dataStructures/moench03Ctb10GbT1Data.h deleted file mode 100644 index b1e1932c7..000000000 --- a/slsDetectorCalibration/dataStructures/moench03Ctb10GbT1Data.h +++ /dev/null @@ -1,284 +0,0 @@ -#ifndef MOENCH03CTB10GBT1DATA_H -#define MOENCH03CTB10GBT1DATA_H -#include "slsReceiverData.h" - - - -class moench03Ctb10GbT1Data : public slsReceiverData { - - private: - - int iframe; - int nadc; - int sc_width; - int sc_height; - public: - - - - - /** - Implements the slsReceiverData structure for the moench02 prototype read out by a module i.e. using the slsReceiver - (160x160 pixels, 40 packets 1286 large etc.) - \param c crosstalk parameter for the output buffer - - */ - moench03Ctb10GbT1Data(int ns=5000): slsReceiverData(400, 400, 40, 8208), nadc(32), sc_width(25), sc_height(200) { - - - - int adc_nr[32]={300,325,350,375,300,325,350,375, \ - 200,225,250,275,200,225,250,275,\ - 100,125,150,175,100,125,150,175,\ - 0,25,50,75,0,25,50,75}; - - int row, col; - - int isample; - int iadc; - int ix, iy; - - int npackets=40; - int i; - int adc4(0); - - for (int ip=0; ip=8208*40) - cout << "Error: pointer " << dataMap[row][col] << " out of range "<< endl; - } - } - } - } - - int ipacket; - int ibyte; - int ii=0; - for (int ipacket=0; ipacket0) { */ -/* iframe++; */ -/* // cout << ib << "-" << endl; */ -/* return (char*)afifo_cont; */ -/* } else { */ -/* delete [] afifo_cont; */ -/* return NULL; */ -/* } */ -/* } */ -/* return NULL; */ -/* }; */ - - - virtual char *readNextFrame(ifstream &filebin) { - int ff=-1, np=-1; - return readNextFrame(filebin, ff, np); - }; - - virtual char *readNextFrame(ifstream &filebin, int &ff) { - int np=-1; - return readNextFrame(filebin, ff, np); - }; - - virtual char *readNextFrame(ifstream &filebin, int& ff, int &np) { - char *data=new char[packetSize*nPackets]; - char *d=readNextFrame(filebin, ff, np, data); - if (d==NULL) {delete [] data; data=NULL;} - return data; - - } - - virtual char *readNextFrame(ifstream &filebin, int& ff, int &np, char *data) { - char *retval=0; - int nd; - int fnum = -1; - np=0; - int pn; - char aa[8224]; - char *packet=(char *)aa; - // cout << packetSize*nPackets << endl; - if (ff>=0) - fnum=ff; - - if (filebin.is_open()) { - - - - - while(filebin.read((char*)packet, 8208) ){ - pn=getPacketNumber(packet); - - if (fnum<0) - fnum= getFrameNumber(packet); - - // cout << "fn: " << fnum << "\t pn: " << pn << endl; - if (fnum>=0) { - if (getFrameNumber(packet) !=fnum) { - - if (np==0){ - // delete [] data; - return NULL; - } else - filebin.seekg(-8208,ios_base::cur); - return data; - } - if (pn>nPackets) { - cout << "Bad packet number " << pn << endl; - } - - memcpy(data+(pn-1)*packetSize, packet, packetSize); - np++; - - if (np==nPackets) - break; - - if (pn==nPackets) - break; - - } - } - - } - - if (np==0){ - // delete [] data; - return NULL; - } - - ff=fnum; - return data; - - }; - - - - - - - - - - - - - - - - - - -int getPacketNumber(int x, int y) {return dataMap[y][x]/8208;}; - - -}; - - - - -#endif diff --git a/slsDetectorCalibration/dataStructures/moench03CtbData.h b/slsDetectorCalibration/dataStructures/moench03CtbData.h deleted file mode 100644 index 66ae0cbda..000000000 --- a/slsDetectorCalibration/dataStructures/moench03CtbData.h +++ /dev/null @@ -1,157 +0,0 @@ -#ifndef MOENCH03CTBDATA_H -#define MOENCH03CTBDATA_H -#include "slsDetectorData.h" - - - -class moench03CtbData : public slsDetectorData { - - private: - - int iframe; - int nadc; - int sc_width; - int sc_height; - public: - - - - - /** - Implements the slsReceiverData structure for the moench02 prototype read out by a module i.e. using the slsReceiver - (160x160 pixels, 40 packets 1286 large etc.) - \param c crosstalk parameter for the output buffer - - */ - - - moench03CtbData(int ns=5000): slsDetectorData(400, 400, ns*2*32, NULL, NULL) , nadc(32), sc_width(25), sc_height(200) { - - - int row, col; - - int isample; - int iadc; - int ix, iy; - - int adc_nr[32]={200,225,250,275,300,325,350,375,\ - 0,25,50,75,100,125,150,175,\ - 175,150,125,100,75,50,25,0,\ - 375,350,325,300,275,250,225,200}; - - /* int adc_nr[32]={300,325,350,375,300,325,350,375, \ */ - /* 200,225,250,275,200,225,250,275,\ */ - /* 100,125,150,175,100,125,150,175,\ */ - /* 0,25,50,75,0,25,50,75}; */ - - - for (iadc=0; iadc=2*400*400) - cout << "Error: pointer " << dataMap[row][col] << " out of range "<< endl; - - } - } - for (int i=0; i0) { - iframe++; - // cout << ib << "-" << endl; - return (char*)afifo_cont; - } else { - delete [] afifo_cont; - return NULL; - } - } - return NULL; - }; - - - - -}; - - - -#endif diff --git a/slsDetectorCalibration/dataStructures/moench03T1CtbData.h b/slsDetectorCalibration/dataStructures/moench03T1CtbData.h deleted file mode 100644 index 4a99d3746..000000000 --- a/slsDetectorCalibration/dataStructures/moench03T1CtbData.h +++ /dev/null @@ -1,158 +0,0 @@ -#ifndef MOENCH03T1CTBDATA_H -#define MOENCH03T1CTBDATA_H -#include "slsDetectorData.h" - - - -class moench03T1CtbData : public slsDetectorData { - - private: - - int iframe; - int nadc; - int sc_width; - int sc_height; - public: - - - - - /** - Implements the slsReceiverData structure for the moench02 prototype read out by a module i.e. using the slsReceiver - (160x160 pixels, 40 packets 1286 large etc.) - \param c crosstalk parameter for the output buffer - - */ - - - moench03T1CtbData(int ns=5000): slsDetectorData(400, 400, ns*2*32, NULL, NULL) , nadc(32), sc_width(25), sc_height(200) { - - - int adc_nr[32]={300,325,350,375,300,325,350,375, \ - 200,225,250,275,200,225,250,275,\ - 100,125,150,175,100,125,150,175,\ - 0,25,50,75,0,25,50,75}; - - int row, col; - - int isample; - int iadc; - int ix, iy; - - - - - - for (iadc=0; iadc=2*400*400) - cout << "Error: pointer " << dataMap[row][col] << " out of range "<< endl; - - } - } - int adc4; - for (int i=0; i0) { - iframe++; - // cout << ib << "-" << endl; - return (char*)afifo_cont; - } else { - delete [] afifo_cont; - return NULL; - } - } - return NULL; - }; - - - - -}; - - - -#endif diff --git a/slsDetectorCalibration/dataStructures/moench03T1ReceiverData.h b/slsDetectorCalibration/dataStructures/moench03T1ReceiverData.h deleted file mode 100644 index 855bfb7c4..000000000 --- a/slsDetectorCalibration/dataStructures/moench03T1ReceiverData.h +++ /dev/null @@ -1,285 +0,0 @@ -#ifndef MOENCH03T1ZMQDATA_H -#define MOENCH03T1ZMQDATA_H -#include "slsDetectorData.h" - - /** - @short structure for a Detector Packet or Image Header - @li frameNumber is the frame number - @li expLength is the subframe number (32 bit eiger) or real time exposure time in 100ns (others) - @li packetNumber is the packet number - @li bunchId is the bunch id from beamline - @li timestamp is the time stamp with 10 MHz clock - @li modId is the unique module id (unique even for left, right, top, bottom) - @li xCoord is the x coordinate in the complete detector system - @li yCoord is the y coordinate in the complete detector system - @li zCoord is the z coordinate in the complete detector system - @li debug is for debugging purposes - @li roundRNumber is the round robin set number - @li detType is the detector type see :: detectorType - @li version is the version number of this structure format - */ - typedef struct { - uint64_t frameNumber; /**< is the frame number */ - uint32_t expLength; /**< is the subframe number (32 bit eiger) or real time exposure time in 100ns (others) */ - uint32_t packetNumber; /**< is the packet number */ - uint64_t bunchId; /**< is the bunch id from beamline */ - uint64_t timestamp; /**< is the time stamp with 10 MHz clock */ - uint16_t modId; /**< is the unique module id (unique even for left, right, top, bottom) */ - uint16_t xCoord; /**< is the x coordinate in the complete detector system */ - uint16_t yCoord; /**< is the y coordinate in the complete detector system */ - uint16_t zCoord; /**< is the z coordinate in the complete detector system */ - uint32_t debug; /**< is for debugging purposes */ - uint16_t roundRNumber; /**< is the round robin set number */ - uint8_t detType; /**< is the detector type see :: detectorType */ - uint8_t version; /**< is the version number of this structure format */ - } sls_detector_header; - - - - -class moench03T1ReceiverData : public slsDetectorData { - - private: - - int iframe; - int nadc; - int sc_width; - int sc_height; - const int nPackets; /**(400, 400, ps*npackets+sizeof(sls_detector_header)), packetSize(ps), nPackets(npackets) { - - int nadc=32; - int sc_width=25; - int sc_height=200; - - int adc_nr[32]={300,325,350,375,300,325,350,375, \ - 200,225,250,275,200,225,250,275,\ - 100,125,150,175,100,125,150,175,\ - 0,25,50,75,0,25,50,75}; - - int row, col; - - int isample; - int iadc; - int ix, iy; - - // int npackets=40; - int i; - int adc4(0); - - for (int ip=0; ip=8192*40) - cout << "Error: pointer " << dataMap[row][col] << " out of range "<< endl; - } - } - } - } - - int ipacket; - int ibyte; - int ii=0; - for (ibyte=0; ibyteframeNumber;};//*((int*)(buff+5))&0xffffff;}; - - /** - - Returns the packet number for the given dataset. purely virtual func - \param buff pointer to the dataset - \returns packet number number - - - - */ - int getPacketNumber(char *buff){((sls_detector_header*)buff)->packetNumber;}//((*(((int*)(buff+4))))&0xff)+1;}; - -/* /\** */ - -/* Loops over a memory slot until a complete frame is found (i.e. all packets 0 to nPackets, same frame number). purely virtual func */ -/* \param data pointer to the memory to be analyzed */ -/* \param ndata reference to the amount of data found for the frame, in case the frame is incomplete at the end of the memory slot */ -/* \param dsize size of the memory slot to be analyzed */ -/* \returns pointer to the beginning of the last good frame (might be incomplete if ndata smaller than dataSize), or NULL if no frame is found */ - -/* *\/ */ -/* virtual char *findNextFrame(char *data, int &ndata, int dsize){ndata=dsize; setDataSize(dsize); return data;}; */ - - -/* /\** */ - -/* Loops over a file stream until a complete frame is found (i.e. all packets 0 to nPackets, same frame number). Can be overloaded for different kind of detectors! */ -/* \param filebin input file stream (binary) */ -/* \returns pointer to the begin of the last good frame, NULL if no frame is found or last frame is incomplete */ - -/* *\/ */ -/* virtual char *readNextFrame(ifstream &filebin){ */ -/* // int afifo_length=0; */ -/* uint16_t *afifo_cont; */ -/* int ib=0; */ -/* if (filebin.is_open()) { */ -/* afifo_cont=new uint16_t[dataSize/2]; */ -/* while (filebin.read(((char*)afifo_cont)+ib,2)) { */ -/* ib+=2; */ -/* if (ib==dataSize) break; */ -/* } */ -/* if (ib>0) { */ -/* iframe++; */ -/* // cout << ib << "-" << endl; */ -/* return (char*)afifo_cont; */ -/* } else { */ -/* delete [] afifo_cont; */ -/* return NULL; */ -/* } */ -/* } */ -/* return NULL; */ -/* }; */ - - - virtual char *readNextFrame(ifstream &filebin) { - int ff=-1, np=-1; - return readNextFrame(filebin, ff, np); - }; - - virtual char *readNextFrame(ifstream &filebin, int &ff) { - int np=-1; - return readNextFrame(filebin, ff, np); - }; - - virtual char *readNextFrame(ifstream &filebin, int& ff, int &np) { - char *data=new char[dataSize]; - char *d=readNextFrame(filebin, ff, np, data); - if (d==NULL) {delete [] data; data=NULL;} - return data; - } - - - - - virtual char *readNextFrame(ifstream &filebin, int& ff, int &np, char *data) { - char *retval=0; - int nd; - int fnum = -1; - np=0; - int pn; - - // cout << dataSize << endl; - if (ff>=0) - fnum=ff; - - if (filebin.is_open()) { - if (filebin.read(data, dataSize) ){ - ff=getFrameNumber(data); - np=getPacketNumber(data); - return data; - } - } - return NULL; - - - - }; - - - - /** - - Loops over a memory slot until a complete frame is found (i.e. all packets 0 to nPackets, same frame number). purely virtual func - \param data pointer to the memory to be analyzed - \param ndata reference to the amount of data found for the frame, in case the frame is incomplete at the end of the memory slot - \param dsize size of the memory slot to be analyzed - \returns pointer to the beginning of the last good frame (might be incomplete if ndata smaller than dataSize), or NULL if no frame is found - - */ - virtual char *findNextFrame(char *data, int &ndata, int dsize){ - if (dsize { - - private: - - int iframe; - int nadc; - int sc_width; - int sc_height; - const int nSamples; - - - public: - - - - - /** - Implements the slsReceiverData structure for the moench02 prototype read out by a module i.e. using the slsReceiver - (160x160 pixels, 40 packets 1286 large etc.) - \param c crosstalk parameter for the output buffer - - */ - moench03T1ReceiverDataNew(int ns=5000): slsDetectorData(400, 400, ns*2*32+sizeof(sls_detector_header)), nSamples(ns) { - - int nadc=32; - int sc_width=25; - int sc_height=200; - - int adc_nr[32]={300,325,350,375,300,325,350,375, \ - 200,225,250,275,200,225,250,275,\ - 100,125,150,175,100,125,150,175,\ - 0,25,50,75,0,25,50,75}; - - int row, col; - - int isample; - int iadc; - int ix, iy; - - int npackets=40; - int i; - int adc4(0); - - for (int ip=0; ip=nSamples*2*32) - cout << "Error: pointer " << dataMap[row][col] << " out of range "<< endl; - } - } - } - } - - int ipacket; - int ibyte; - int ii=0; - for (ibyte=0; ibyteframeNumber;};//*((int*)(buff+5))&0xffffff;}; - - /** - - Returns the packet number for the given dataset. purely virtual func - \param buff pointer to the dataset - \returns packet number number - - - - */ - int getPacketNumber(char *buff){return ((sls_detector_header*)buff)->packetNumber;}//((*(((int*)(buff+4))))&0xff)+1;}; - -/* /\** */ - -/* Loops over a memory slot until a complete frame is found (i.e. all packets 0 to nPackets, same frame number). purely virtual func */ -/* \param data pointer to the memory to be analyzed */ -/* \param ndata reference to the amount of data found for the frame, in case the frame is incomplete at the end of the memory slot */ -/* \param dsize size of the memory slot to be analyzed */ -/* \returns pointer to the beginning of the last good frame (might be incomplete if ndata smaller than dataSize), or NULL if no frame is found */ - -/* *\/ */ -/* virtual char *findNextFrame(char *data, int &ndata, int dsize){ndata=dsize; setDataSize(dsize); return data;}; */ - - -/* /\** */ - -/* Loops over a file stream until a complete frame is found (i.e. all packets 0 to nPackets, same frame number). Can be overloaded for different kind of detectors! */ -/* \param filebin input file stream (binary) */ -/* \returns pointer to the begin of the last good frame, NULL if no frame is found or last frame is incomplete */ - -/* *\/ */ -/* virtual char *readNextFrame(ifstream &filebin){ */ -/* // int afifo_length=0; */ -/* uint16_t *afifo_cont; */ -/* int ib=0; */ -/* if (filebin.is_open()) { */ -/* afifo_cont=new uint16_t[dataSize/2]; */ -/* while (filebin.read(((char*)afifo_cont)+ib,2)) { */ -/* ib+=2; */ -/* if (ib==dataSize) break; */ -/* } */ -/* if (ib>0) { */ -/* iframe++; */ -/* // cout << ib << "-" << endl; */ -/* return (char*)afifo_cont; */ -/* } else { */ -/* delete [] afifo_cont; */ -/* return NULL; */ -/* } */ -/* } */ -/* return NULL; */ -/* }; */ - - - virtual char *readNextFrame(ifstream &filebin) { - int ff=-1, np=-1; - return readNextFrame(filebin, ff, np); - }; - - virtual char *readNextFrame(ifstream &filebin, int &ff) { - int np=-1; - return readNextFrame(filebin, ff, np); - }; - - virtual char *readNextFrame(ifstream &filebin, int& ff, int &np) { - char *data=new char[dataSize]; - char *d=readNextFrame(filebin, ff, np, data); - if (d==NULL) {delete [] data; data=NULL;} - return data; - } - - - - - virtual char *readNextFrame(ifstream &filebin, int& ff, int &np, char *data) { - char *retval=0; - int nd; - int fnum = -1; - np=0; - int pn; - - // cout << dataSize << endl; - if (ff>=0) - fnum=ff; - - if (filebin.is_open()) { - if (filebin.read(data, dataSize) ){ - ff=getFrameNumber(data); - np=getPacketNumber(data); - return data; - } - } - return NULL; - - - - }; - - - - /** - - Loops over a memory slot until a complete frame is found (i.e. all packets 0 to nPackets, same frame number). purely virtual func - \param data pointer to the memory to be analyzed - \param ndata reference to the amount of data found for the frame, in case the frame is incomplete at the end of the memory slot - \param dsize size of the memory slot to be analyzed - \returns pointer to the beginning of the last good frame (might be incomplete if ndata smaller than dataSize), or NULL if no frame is found - - */ - virtual char *findNextFrame(char *data, int &ndata, int dsize){ - if (dsize { - - private: - - int iframe; - int nadc; - int sc_width; - int sc_height; - const int nPackets; /**(400, 400, ps*npackets), packetSize(ps), nPackets(npackets) { - - int nadc=32; - int sc_width=25; - int sc_height=200; - - int adc_nr[32]={300,325,350,375,300,325,350,375, \ - 200,225,250,275,200,225,250,275,\ - 100,125,150,175,100,125,150,175,\ - 0,25,50,75,0,25,50,75}; - - int row, col; - - int isample; - int iadc; - int ix, iy; - - // int npackets=40; - int i; - int adc4(0); - - for (int ip=0; ip=8192*40) - cout << "Error: pointer " << dataMap[row][col] << " out of range "<< endl; - } - } - } - } - - int ipacket; - int ibyte; - int ii=0; - for (int ipacket=0; ipacket0) { */ -/* iframe++; */ -/* // cout << ib << "-" << endl; */ -/* return (char*)afifo_cont; */ -/* } else { */ -/* delete [] afifo_cont; */ -/* return NULL; */ -/* } */ -/* } */ -/* return NULL; */ -/* }; */ - - - virtual char *readNextFrame(ifstream &filebin) { - int ff=-1, np=-1; - return readNextFrame(filebin, ff, np); - }; - - virtual char *readNextFrame(ifstream &filebin, int &ff) { - int np=-1; - return readNextFrame(filebin, ff, np); - }; - - virtual char *readNextFrame(ifstream &filebin, int& ff, int &np) { - char *data=new char[packetSize*nPackets]; - char *d=readNextFrame(filebin, ff, np, data); - if (d==NULL) {delete [] data; data=NULL;} - return data; - } - - - - - virtual char *readNextFrame(ifstream &filebin, int& ff, int &np, char *data) { - char *retval=0; - int nd; - int fnum = -1; - np=0; - int pn; - - - if (ff>=0) - fnum=ff; - - if (filebin.is_open()) { - if (filebin.read(data, packetSize*nPackets) ){ - iframe++; - ff=iframe; - return data; - } - } - return NULL; - - - - }; - - - - /** - - Loops over a memory slot until a complete frame is found (i.e. all packets 0 to nPackets, same frame number). purely virtual func - \param data pointer to the memory to be analyzed - \param ndata reference to the amount of data found for the frame, in case the frame is incomplete at the end of the memory slot - \param dsize size of the memory slot to be analyzed - \returns pointer to the beginning of the last good frame (might be incomplete if ndata smaller than dataSize), or NULL if no frame is found - - */ - virtual char *findNextFrame(char *data, int &ndata, int dsize){ - if (dsize { - - private: - - int iframe; - int nadc; - int sc_width; - int sc_height; - const int nSamples; - - public: - - - - - /** - Implements the slsReceiverData structure for the moench02 prototype read out by a module i.e. using the slsReceiver - (160x160 pixels, 40 packets 1286 large etc.) - \param c crosstalk parameter for the output buffer - - */ - moench03T1ZmqDataNew(int ns=5000): slsDetectorData(400, 400, ns*32*2), nSamples(ns) { - - int nadc=32; - int sc_width=25; - int sc_height=200; - - int adc_nr[32]={300,325,350,375,300,325,350,375, \ - 200,225,250,275,200,225,250,275,\ - 100,125,150,175,100,125,150,175,\ - 0,25,50,75,0,25,50,75}; - - int row, col; - - int isample; - int iadc; - int ix, iy; - - int npackets=40; - int i; - int adc4(0); - - for (int ip=0; ip=nSamples*2*32) - cout << "Error: pointer " << dataMap[row][col] << " out of range "<< endl; - } - } - } - } - - int ipacket; - int ibyte; - int ii=0; - for (int ipacket=0; ipacket0) { */ -/* iframe++; */ -/* // cout << ib << "-" << endl; */ -/* return (char*)afifo_cont; */ -/* } else { */ -/* delete [] afifo_cont; */ -/* return NULL; */ -/* } */ -/* } */ -/* return NULL; */ -/* }; */ - - - virtual char *readNextFrame(ifstream &filebin) { - int ff=-1, np=-1; - return readNextFrame(filebin, ff, np); - }; - - virtual char *readNextFrame(ifstream &filebin, int &ff) { - int np=-1; - return readNextFrame(filebin, ff, np); - }; - - virtual char *readNextFrame(ifstream &filebin, int& ff, int &np) { - char *data=new char[32*2*nSamples]; - char *d=readNextFrame(filebin, ff, np, data); - if (d==NULL) {delete [] data; data=NULL;} - return data; - } - - - - - virtual char *readNextFrame(ifstream &filebin, int& ff, int &np, char *data) { - char *retval=0; - int nd; - int fnum = -1; - np=0; - int pn; - - - if (ff>=0) - fnum=ff; - - if (filebin.is_open()) { - if (filebin.read(data, 32*2*nSamples) ){ - iframe++; - ff=iframe; - return data; - } - } - return NULL; - - - - }; - - - - /** - - Loops over a memory slot until a complete frame is found (i.e. all packets 0 to nPackets, same frame number). purely virtual func - \param data pointer to the memory to be analyzed - \param ndata reference to the amount of data found for the frame, in case the frame is incomplete at the end of the memory slot - \param dsize size of the memory slot to be analyzed - \returns pointer to the beginning of the last good frame (might be incomplete if ndata smaller than dataSize), or NULL if no frame is found - - */ - virtual char *findNextFrame(char *data, int &ndata, int dsize){ - if (dsize<32*2*nSamples) ndata=dsize; - else ndata=32*2*nSamples; - return data; - - } - - - - - - - - - - - - - - - -int getPacketNumber(int x, int y) {return 0;}; - -}; - - - - -#endif diff --git a/slsDetectorCalibration/dataStructures/moench03TCtb10GbData.h b/slsDetectorCalibration/dataStructures/moench03TCtb10GbData.h deleted file mode 100644 index 989012991..000000000 --- a/slsDetectorCalibration/dataStructures/moench03TCtb10GbData.h +++ /dev/null @@ -1,285 +0,0 @@ -#ifndef MOENCH03TCTB10GBDATA_H -#define MOENCH03TCTB10GBDATA_H -#include "moench03Ctb10GbData.h" - - - -class moench03TCtb10GbData : public moench03Ctb10GbData { //slsReceiverData { - - - public: - - - - - /** - Implements the slsReceiverData structure for the moench02 prototype read out by a module i.e. using the slsReceiver - (160x160 pixels, 40 packets 1286 large etc.) - \param c crosstalk parameter for the output buffer - - */ - - - // moench03TCtb10GbData(int ns=5000): slsDetectorData(400, 400, 8208*40, NULL, NULL) , nadc(32), sc_width(25), sc_height(200) { - moench03TCtb10GbData(int ns=5000): moench03Ctb10GbData(ns) {//slsReceiverData(400, 400, 40, 8208), nadc(32), sc_width(25), sc_height(200) { - // cout <<"constructor"<< endl; - // nadc=32; - int adc_nr[32]={300,325,350,375,300,325,350,375, \ - 200,225,250,275,200,225,250,275,\ - 100,125,150,175,100,125,150,175,\ - 0,25,50,75,0,25,50,75}; - int row, col; - - int isample; - int iadc; - int ix, iy; - - int npackets=40; - int i; - int adc4(0); - - for (int ip=0; ip=8208*40) - cout << "Error: pointer " << dataMap[row][col] << " out of range "<< endl; - } - } - } - } - // cout <<"map"<< endl; - int ipacket; - int ibyte; - int ii=0; - for (int ipacket=0; ipacket0) { *\/ */ -/* /\* iframe++; *\/ */ -/* /\* // cout << ib << "-" << endl; *\/ */ -/* /\* return (char*)afifo_cont; *\/ */ -/* /\* } else { *\/ */ -/* /\* delete [] afifo_cont; *\/ */ -/* /\* return NULL; *\/ */ -/* /\* } *\/ */ -/* /\* } *\/ */ -/* /\* return NULL; *\/ */ -/* /\* }; *\/ */ - - -/* virtual char *readNextFrame(ifstream &filebin, int& ff, int &np) { */ -/* char *data=new char[packetSize*nPackets]; */ -/* char *retval=0; */ -/* int nd; */ -/* np=0; */ -/* int pn; */ -/* char aa[8224]={0}; */ -/* char *packet=(char *)aa; */ -/* int fnum = -1; */ - -/* if (ff>=0) */ -/* fnum=ff; */ - -/* if (filebin.is_open()) { */ - - -/* cout << "+"; */ - -/* while(filebin.read((char*)packet, 8208)){ */ - -/* pn=getPacketNumber(packet); */ - -/* if (fnum<0) */ -/* fnum= getFrameNumber(packet); */ - -/* if (fnum>=0) { */ -/* if (getFrameNumber(packet) !=fnum) { */ - -/* if (np==0){ */ -/* cout << "-"; */ -/* delete [] data; */ -/* return NULL; */ -/* } else */ -/* filebin.seekg(-8208,ios_base::cur); */ - -/* return data; */ -/* } */ - -/* memcpy(data+(pn-1)*packetSize, packet, packetSize); */ -/* np++; */ -/* if (np==nPackets) */ -/* break; */ -/* if (pn==nPackets) */ -/* break; */ -/* } */ -/* } */ - -/* } */ - -/* if (np==0){ */ -/* cout << "?"; */ -/* delete [] data; */ -/* return NULL; */ -/* }// else if (np { - - private: - - int iframe; - int nadc; - int sc_width; - int sc_height; - public: - - - - - /** - Implements the slsReceiverData structure for the moench02 prototype read out by a module i.e. using the slsReceiver - (160x160 pixels, 40 packets 1286 large etc.) - \param c crosstalk parameter for the output buffer - - */ - - - moench03TCtbData(int ns=5000): slsDetectorData(400, 400, ns*2*32, NULL, NULL) , nadc(32), sc_width(25), sc_height(200) { - - - int row, col; - - int isample; - int iadc; - int ix, iy; - - - - int adc_nr[32]={300,325,350,375,300,325,350,375, \ - 200,225,250,275,200,225,250,275,\ - 100,125,150,175,100,125,150,175,\ - 0,25,50,75,0,25,50,75}; - - - - /* int adc_nr[32]={200,225,250,275,300,325,350,375,\ */ - /* 0,25,50,75,100,125,150,175,\ */ - /* 175,150,125,100,75,50,25,0,\ */ - /* 375,350,325,300,275,250,225,200}; */ - - - for (iadc=0; iadc=2*400*400) - cout << "Error: pointer " << dataMap[row][col] << " out of range "<< endl; - - } - } - int adc4; - for (int i=0; i0) { - iframe++; - // cout << ib << "-" << endl; - return (char*)afifo_cont; - } else { - delete [] afifo_cont; - return NULL; - } - } - return NULL; - }; - - - - -}; - - - -#endif diff --git a/slsDetectorCalibration/doxy.config b/slsDetectorCalibration/doxy.config deleted file mode 100644 index 7f1241be0..000000000 --- a/slsDetectorCalibration/doxy.config +++ /dev/null @@ -1,85 +0,0 @@ -# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in -# documentation are documented, even if no documentation was available. -# Private class members and static file members will be hidden unless -# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES - -EXTRACT_ALL = YES - -# If the EXTRACT_PRIVATE tag is set to YES all private members of a class -# will be included in the documentation. - -EXTRACT_PRIVATE = NO - - - -# If the EXTRACT_STATIC tag is set to YES all static members of a file -# will be included in the documentation. - -EXTRACT_STATIC = YES - -# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) -# defined locally in source files will be included in the documentation. -# If set to NO only classes defined in header files are included. - -EXTRACT_LOCAL_CLASSES = YES - -# This flag is only useful for Objective-C code. When set to YES local -# methods, which are defined in the implementation section but not in -# the interface are included in the documentation. -# If set to NO (the default) only methods in the interface are included. - -EXTRACT_LOCAL_METHODS = YES - -# If this flag is set to YES, the members of anonymous namespaces will be -# extracted and appear in the documentation as a namespace called -# 'anonymous_namespace{file}', where file will be replaced with the base -# name of the file that contains the anonymous namespace. By default -# anonymous namespace are hidden. - -EXTRACT_ANON_NSPACES = NO - -# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all -# undocumented members of documented classes, files or namespaces. -# If set to NO (the default) these members will be included in the -# various overviews, but no documentation section is generated. -# This option has no effect if EXTRACT_ALL is enabled. - -HIDE_UNDOC_MEMBERS = NO - -# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all -# undocumented classes that are normally visible in the class hierarchy. -# If set to NO (the default) these classes will be included in the various -# overviews. This option has no effect if EXTRACT_ALL is enabled. - -HIDE_UNDOC_CLASSES = NO - -# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all -# friend (class|struct|union) declarations. -# If set to NO (the default) these declarations will be included in the -# documentation. - -HIDE_FRIEND_COMPOUNDS = NO - -INTERNAL_DOCS = NO - -SHOW_INCLUDE_FILES = NO - -SHOW_FILES = NO - -SHOW_NAMESPACES = NO - -COMPACT_LATEX = YES - -PAPER_TYPE = a4 - -PDF_HYPERLINKS = YES - -USE_PDFLATEX = YES - -LATEX_HIDE_INDICES = YES - -PREDEFINED = __cplusplus - -INPUT = MovingStat.h slsDetectorData.h slsReceiverData.h moench02ModuleData.h pedestalSubtraction.h commonModeSubtraction.h moenchCommonMode.h singlePhotonDetector.h energyCalibration.h moenchReadData.C single_photon_hit.h chiptestBoardData.h jungfrau02Data.h jungfrauReadData.C jungfrau02CommonMode.h -OUTPUT_DIRECTORY = docs - diff --git a/slsDetectorCalibration/energyCalibration.cpp b/slsDetectorCalibration/energyCalibration.cpp deleted file mode 100644 index 596d9a0e4..000000000 --- a/slsDetectorCalibration/energyCalibration.cpp +++ /dev/null @@ -1,534 +0,0 @@ -#include "energyCalibration.h" - -#ifdef __CINT -#define MYROOT -#endif - - -#ifdef MYROOT -#include -#include -#include -#include -#endif - -#include - -#define max(a,b) ((a) > (b) ? (a) : (b)) -#define min(a,b) ((a) < (b) ? (a) : (b)) -#define ELEM_SWAP(a,b) { register int t=(a);(a)=(b);(b)=t; } - - -using namespace std; - -#ifdef MYROOT - -Double_t energyCalibrationFunctions::pedestal(Double_t *x, Double_t *par) { - return par[0]-par[1]*sign*x[0]; -} - - -Double_t energyCalibrationFunctions::gaussChargeSharing(Double_t *x, Double_t *par) { - Double_t f, arg=0; - if (par[3]!=0) arg=sign*(x[0]-par[2])/par[3]; - f=TMath::Exp(-1*arg*arg/2.); - f=f+par[5]/2.*(TMath::Erfc(arg/(TMath::Sqrt(2.)))); - return par[4]*f+pedestal(x,par); -} - -Double_t energyCalibrationFunctions::gaussChargeSharingPixel(Double_t *x, Double_t *par) { - Double_t f; - if (par[3]<=0 || par[2]*(*x)<=0 || par[5]<0 || par[4]<=0) return 0; - - Double_t pp[3]; - - pp[0]=0; - pp[1]=par[2]; - pp[2]=par[3]; - - - f=(par[5]-par[6]*(TMath::Log(*x/par[2])))*erfBox(x,pp); - f+=par[4]*TMath::Gaus(*x, par[2], par[3], kTRUE); - return f+pedestal(x,par); -} - -Double_t energyCalibrationFunctions::erfBox(Double_t *z, Double_t *par) { - - - - Double_t m=par[0]; - Double_t M=par[1]; - - if (par[0]>par[1]) { - m=par[1]; - M=par[0]; - } - - if (m==M) - return 0; - - - if (par[2]<=0) { - if (*z>=m && *z<=M) - return 1./(M-m); - else - return 0; - - } - - return (TMath::Erfc((z[0]-M)/par[2])-TMath::Erfc((z[0]-m)/par[2]))*0.5/(M-m); - -} - - -// basic erf function -Double_t energyCalibrationFunctions::erfFunction(Double_t *x, Double_t *par) { - double arg=0; - if (par[1]!=0) arg=(par[0]-x[0])/par[1]; - return ((par[2]/2.*(1+TMath::Erf(sign*arg/(TMath::Sqrt(2)))))); -}; - - -Double_t energyCalibrationFunctions::erfFunctionChargeSharing(Double_t *x, Double_t *par) { - Double_t f; - - f=erfFunction(x, par+2)*(1+par[5]*(par[2]-x[0]))+par[0]-par[1]*x[0]*sign; - return f; -}; - - -Double_t energyCalibrationFunctions::erfFuncFluo(Double_t *x, Double_t *par) { - Double_t f; - f=erfFunctionChargeSharing(x, par)+erfFunction(x, par+6)*(1+par[9]*(par[6]-x[0])); - return f; -}; -#endif - -double energyCalibrationFunctions::median(double *x, int n){ - // sorts x into xmed array and returns median - // n is number of values already in the xmed array - double xmed[n]; - int k,i,j; - - for (i=0; i*(x+j)) - k++; - if (*(x+i)==*(x+j)) { - if (i>j) - k++; - } - } - xmed[k]=*(x+i); - } - k=n/2; - return xmed[k]; -} - - -int energyCalibrationFunctions::quick_select(int arr[], int n){ - int low, high ; - int median; - int middle, ll, hh; - - low = 0 ; high = n-1 ; median = (low + high) / 2; - for (;;) { - if (high <= low) /* One element only */ - return arr[median] ; - - if (high == low + 1) { /* Two elements only */ - if (arr[low] > arr[high]) - ELEM_SWAP(arr[low], arr[high]) ; - return arr[median] ; - } - - /* Find median of low, middle and high items; swap into position low */ - middle = (low + high) / 2; - if (arr[middle] > arr[high]) ELEM_SWAP(arr[middle], arr[high]) ; - if (arr[low] > arr[high]) ELEM_SWAP(arr[low], arr[high]) ; - if (arr[middle] > arr[low]) ELEM_SWAP(arr[middle], arr[low]) ; - - /* Swap low item (now in position middle) into position (low+1) */ - ELEM_SWAP(arr[middle], arr[low+1]) ; - - /* Nibble from each end towards middle, swapping items when stuck */ - ll = low + 1; - hh = high; - for (;;) { - do ll++; while (arr[low] > arr[ll]) ; - do hh--; while (arr[hh] > arr[low]) ; - - if (hh < ll) - break; - - ELEM_SWAP(arr[ll], arr[hh]) ; - } - - /* Swap middle item (in position low) back into correct position */ - ELEM_SWAP(arr[low], arr[hh]) ; - - /* Re-set active partition */ - if (hh <= median) - low = ll; - if (hh >= median) - high = hh - 1; - } -} - -int energyCalibrationFunctions::kth_smallest(int *a, int n, int k){ - register int i,j,l,m ; - register double x ; - - l=0 ; m=n-1 ; - while (lSetParNames("Background Offset","Background Slope","Inflection Point","Noise RMS", "Number of Photons","Charge Sharing Slope"); - - fspectrum=new TF1("fspectrum",funcs,&energyCalibrationFunctions::spectrum,0,1000,6,"energyCalibrationFunctions","spectrum"); - fspectrum->SetParNames("Background Pedestal","Background slope", "Peak position","Noise RMS", "Number of Photons","Charge Sharing Pedestal"); - - fspixel=new TF1("fspixel",funcs,&energyCalibrationFunctions::spectrumPixel,0,1000,7,"energyCalibrationFunctions","spectrumPixel"); - fspixel->SetParNames("Background Pedestal","Background slope", "Peak position","Noise RMS", "Number of Photons","Charge Sharing Pedestal","Corner"); - -#endif - - -} - - - -void energyCalibration::fixParameter(int ip, Double_t val){ - - fscurve->FixParameter(ip, val); - fspectrum->FixParameter(ip, val); -} - - -void energyCalibration::releaseParameter(int ip){ - - fscurve->ReleaseParameter(ip); - fspectrum->ReleaseParameter(ip); -} - - - - - - - -energyCalibration::~energyCalibration(){ -#ifdef MYROOT - delete fscurve; - delete fspectrum; -#endif - -} - -#ifdef MYROOT - - - - - -TH1F* energyCalibration::createMedianHistogram(TH2F* h2, int ch0, int nch, int direction) { - - if (h2==NULL || nch==0) - return NULL; - - double *x=new double[nch]; - TH1F *h1=NULL; - - double val=-1; - - if (direction==0) { - h1=new TH1F("median","Median",h2->GetYaxis()->GetNbins(),h2->GetYaxis()->GetXmin(),h2->GetYaxis()->GetXmax()); - for (int ib=0; ibGetXaxis()->GetNbins(); ib++) { - for (int ich=0; ichGetBinContent(ch0+ich+1,ib+1); - } - val=energyCalibrationFunctions::median(x, nch); - h1->SetBinContent(ib+1,val); - } - } else if (direction==1) { - h1=new TH1F("median","Median",h2->GetXaxis()->GetNbins(),h2->GetXaxis()->GetXmin(),h2->GetXaxis()->GetXmax()); - for (int ib=0; ibGetYaxis()->GetNbins(); ib++) { - for (int ich=0; ichGetBinContent(ib+1,ch0+ich+1); - } - val=energyCalibrationFunctions::median(x, nch); - h1->SetBinContent(ib+1,val); - } - } - delete [] x; - - return h1; - -} - - - - - - - - - - - - - - -void energyCalibration::setStartParameters(Double_t *par){ - bg_offset=par[0]; - bg_slope=par[1]; - flex=par[2]; - noise=par[3]; - ampl=par[4]; - cs_slope=par[5]; -} - - -void energyCalibration::getStartParameters(Double_t *par){ - par[0]=bg_offset; - par[1]=bg_slope; - par[2]=flex; - par[3]=noise; - par[4]=ampl; - par[5]=cs_slope; -} - -#endif -int energyCalibration::setChargeSharing(int p) { - if (p>=0) { - cs_flag=p; -#ifdef MYROOT - if (p) { - fscurve->ReleaseParameter(5); - fspectrum->ReleaseParameter(1); - } else { - fscurve->FixParameter(5,0); - fspectrum->FixParameter(1,0); - } -#endif - } - - return cs_flag; -} - - -#ifdef MYROOT -void energyCalibration::initFitFunction(TF1 *fun, TH1 *h1) { - - Double_t min=fit_min, max=fit_max; - - Double_t mypar[6]; - - if (max==-1) - max=h1->GetXaxis()->GetXmax(); - - if (min==-1) - min=h1->GetXaxis()->GetXmin(); - - - if (bg_offset==-1) - mypar[0]=0; - else - mypar[0]=bg_offset; - - - if (bg_slope==-1) - mypar[1]=0; - else - mypar[1]=bg_slope; - - - if (flex==-1) - mypar[2]=(min+max)/2.; - else - mypar[2]=flex; - - - if (noise==-1) - mypar[3]=0.1; - else - mypar[3]=noise; - - if (ampl==-1) - mypar[4]=h1->GetBinContent(h1->GetXaxis()->FindBin(0.5*(max+min))); - else - mypar[4]=ampl; - - if (cs_slope==-1) - mypar[5]=0; - else - mypar[5]=cs_slope; - - fun->SetParameters(mypar); - - fun->SetRange(min,max); - -} - - -TF1* energyCalibration::fitFunction(TF1 *fun, TH1 *h1, Double_t *mypar, Double_t *emypar) { - - - TF1* fitfun; - - char fname[100]; - - strcpy(fname, fun->GetName()); - - if (plot_flag) { - h1->Fit(fname,"R0Q"); - } else - h1->Fit(fname,"R0Q"); - - - fitfun= h1->GetFunction(fname); - fitfun->GetParameters(mypar); - for (int ip=0; ip<6; ip++) { - emypar[ip]=fitfun->GetParError(ip); - } - return fitfun; -} - -TF1* energyCalibration::fitSCurve(TH1 *h1, Double_t *mypar, Double_t *emypar) { - initFitFunction(fscurve,h1); - return fitFunction(fscurve, h1, mypar, emypar); -} - - - - - -TF1* energyCalibration::fitSpectrum(TH1 *h1, Double_t *mypar, Double_t *emypar) { - initFitFunction(fspectrum,h1); - return fitFunction(fspectrum, h1, mypar, emypar); -} - - - -TF1* energyCalibration::fitSpectrumPixel(TH1 *h1, Double_t *mypar, Double_t *emypar) { - initFitFunction(fspixel,h1); - return fitFunction(fspixel, h1, mypar, emypar); -} - - - -TGraphErrors* energyCalibration::linearCalibration(int nscan, Double_t *en, Double_t *een, Double_t *fl, Double_t *efl, Double_t &gain, Double_t &off, Double_t &egain, Double_t &eoff) { - - TGraphErrors *gr; - - Double_t mypar[2]; - - gr = new TGraphErrors(nscan,en,fl,een,efl); - - if (plot_flag) { - gr->Fit("pol1"); - gr->SetMarkerStyle(20); - } else - gr->Fit("pol1","0Q"); - - TF1 *fitfun= gr->GetFunction("pol1"); - fitfun->GetParameters(mypar); - - egain=fitfun->GetParError(1); - eoff=fitfun->GetParError(0); - - gain=funcs->setScanSign()*mypar[1]; - - off=mypar[0]; - - return gr; -} - - -TGraphErrors* energyCalibration::calibrate(int nscan, Double_t *en, Double_t *een, TH1F **h1, Double_t &gain, Double_t &off, Double_t &egain, Double_t &eoff, int integral) { - - TH1F *h; - - Double_t mypar[6], emypar[6]; - Double_t fl[nscan], efl[nscan]; - - - for (int ien=0; ien -#include -class TH1F; -class TH2F; -class TGraphErrors; -#endif - - -using namespace std; - - - - -const double conven=1000./3.6; /**< electrons/keV */ -const double el=1.67E-4; /**< electron charge in fC */ - - - -/** - \mainpage Common Root library for SLS detectors data analysis - * - * \section intro_sec Introduction - We know very well s-curves etc. but at the end everybody uses different functions ;-). - - * \subsection mot_sec Motivation - It would be greate to use everybody the same functions... - -*/ - - -/** - * - * -@libdoc The energiCalibration class contains all the necessary functions for s-curve fitting and linear calibration of the threshold. - * - * @short Energy calibration functions - * @author Anna Bergamaschi - * @version 0.1alpha - - - */ - -/** - class containing all the possible energy calibration functions (scurves with and without charge sharing, gaussian spectrum with and without charge sharing, possibility of chosing the sign of the X-axis) - -*/ -class energyCalibrationFunctions { - - public: - - energyCalibrationFunctions(int s=-1) {setScanSign(s);}; - - /** sets scan sign - \param s can be 1 (energy and x-axis have the same direction) or -1 (energy and x-axis have opposite directions) otherwise gets - \returns current scan sign can be 1 (energy and x-axis have the same direction) or -1 (energy and x-axis have opposite directions) - */ - int setScanSign(int s=0) {if (s==1 || s==-1) sign=s; return sign;};; - - -#ifdef MYROOT - /** - Gaussian Function with charge sharing pedestal - par[0] is the absolute height of the background pedestal - par[1] is the slope of the background pedestal - */ - Double_t pedestal(Double_t *x, Double_t *par); - - /** - Gaussian Function with charge sharing pedestal - par[0] is the absolute height of the background pedestal - par[1] is the slope of the background pedestal - par[2] is the gaussian peak position - par[3] is the RMS of the gaussian (and of the pedestal) - par[4] is the height of the function - par[5] is the fractional height of the charge sharing pedestal (scales with par[3]) - */ - Double_t gaussChargeSharing(Double_t *x, Double_t *par); - /** - Gaussian Function with charge sharing pedestal - par[0] is the absolute height of the background pedestal - par[1] is the slope of the background pedestal - par[2] is the gaussian peak position - par[3] is the RMS of the gaussian (and of the pedestal) - par[4] is the height of the function - par[5] is the fractional height of the charge sharing pedestal (scales with par[3]) - */ - Double_t gaussChargeSharingPixel(Double_t *x, Double_t *par); - - /** - Basic erf function - par[0] is the inflection point - par[1] is the RMS - par[2] is the amplitude - */ -Double_t erfFunction(Double_t *x, Double_t *par) ; - Double_t erfBox(Double_t *z, Double_t *par); - /** Erf function with charge sharing slope - par[0] is the pedestal - par[1] is the slope of the pedestal - par[2] is the inflection point - par[3] is the RMS - par[4] is the amplitude - par[5] is the angual coefficient of the charge sharing slope (scales with par[3]) - */ -Double_t erfFunctionChargeSharing(Double_t *x, Double_t *par); - - /** Double Erf function with charge sharing slope - par[0] is the pedestal - par[1] is the slope of the pedestal - par[2] is the inflection point of the first energy - par[3] is the RMS of the first energy - par[4] is the amplitude of the first energy - par[5] is the angual coefficient of the charge sharing slope of the first energy (scales with par[3]) - par[6] is the inflection point of the second energy - par[7] is the RMS of the second energy - par[8] is the amplitude of the second energy - par[9] is the angual coefficient of the charge sharing slope of the second energy (scales with par[8]) - */ - -Double_t erfFuncFluo(Double_t *x, Double_t *par); - - - /** - static function Gaussian with charge sharing pedestal with the correct scan sign - par[0] is the absolute height of the background pedestal - par[1] is the slope of the pedestal - par[2] is the gaussian peak position - par[3] is the RMS of the gaussian (and of the pedestal) - par[4] is the height of the function - par[5] is the fractional height of the charge sharing pedestal (scales with par[4] - */ - Double_t spectrum(Double_t *x, Double_t *par); - - /** - static function Gaussian with charge sharing pedestal with the correct scan sign - par[0] is the absolute height of the background pedestal - par[1] is the slope of the pedestal - par[2] is the gaussian peak position - par[3] is the RMS of the gaussian (and of the pedestal) - par[4] is the height of the function - par[5] is the fractional height of the charge sharing pedestal (scales with par[4] - */ - Double_t spectrumPixel(Double_t *x, Double_t *par); - - - /** Erf function with charge sharing slope with the correct scan sign - par[0] is the pedestal - par[1] is the slope of the pedestal - par[2] is the inflection point - par[3] is the RMS - par[4] is the amplitude - par[5] is the angual coefficient of the charge sharing slope (scales with par[3]) - */ - Double_t scurve(Double_t *x, Double_t *par); - - - - /** Double Erf function with charge sharing slope - par[0] is the pedestal - par[1] is the slope of the pedestal - par[2] is the inflection point of the first energy - par[3] is the RMS of the first energy - par[4] is the amplitude of the first energy - par[5] is the angual coefficient of the charge sharing slope of the first energy (scales with par[3]) - par[6] is the inflection point of the second energy - par[7] is the RMS of the second energy - par[8] is the amplitude of the second energy - par[9] is the angual coefficient of the charge sharing slope of the second energy (scales with par[8]) - */ - Double_t scurveFluo(Double_t *x, Double_t *par); - -#endif - -/** Calculates the median of an array of n elements */ - static double median(double *x, int n); -/** Calculates the median of an array of n elements (swaps the arrays!)*/ - static int quick_select(int arr[], int n); -/** Calculates the median of an array of n elements (swaps the arrays!)*/ - static int kth_smallest(int *a, int n, int k); - - private: - int sign; - - -}; - -/** - class alowing the energy calibration of photon counting and anlogue detectors - -*/ - -class energyCalibration { - - - public: - /** - default constructor - creates the function with which the s-curves will be fitted - */ - energyCalibration(); - - /** - default destructor - deletes the function with which the s-curves will be fitted - */ - ~energyCalibration(); - - /** sets plot flag - \param p plot flag (-1 gets, 0 unsets, >0 plot) - \returns current plot flag - */ - int setPlotFlag(int p=-1) {if (p>=0) plot_flag=p; return plot_flag;}; - - /** sets scan sign - \param s can be 1 (energy and x-axis have the same direction) or -1 (energy and x-axis have opposite directions) otherwise gets - \returns current scan sign can be 1 (energy and x-axis have the same direction) or -1 (energy and x-axis have opposite directions) - */ - int setScanSign(int s=0) {return funcs->setScanSign(s);}; - - /** sets plot flag - \param p plot flag (-1 gets, 0 unsets, >0 plot) - \returns current plot flag - */ - int setChargeSharing(int p=-1); - - - void fixParameter(int ip, Double_t val); - - void releaseParameter(int ip); - -#ifdef MYROOT - - /** - Creates an histogram with the median of nchannels starting from a specified one. the direction on which it is mediated can be selected (defaults to x=0) - \param h2 2D histogram on which the median will be calculated - \param ch0 starting channel - \param nch number of channels to be mediated - \param direction can be either 0 (x, default) or 1 (y) - \returns a TH1F histogram with the X-axis as a clone of the h2 Y (if direction=0) or X (if direction=0) axis, and on the Y axis the median of the counts of the mediated channels f h2 - */ - static TH1F* createMedianHistogram(TH2F* h2, int ch0, int nch, int direction=0); - - - /** sets the s-curve fit range - \param mi minimum of the fit range (-1 is histogram x-min) - \param ma maximum of the fit range (-1 is histogram x-max) - */ - void setFitRange(Double_t mi, Double_t ma){fit_min=mi; fit_max=ma;}; - - /** gets the s-curve fit range - \param mi reference for minimum of the fit range (-1 is histogram x-min) - \param ma reference for maximum of the fit range (-1 is histogram x-max) - */ - void getFitRange(Double_t &mi, Double_t &ma){mi=fit_min; ma=fit_max;}; - - -/** set start parameters for the s-curve function - \param par parameters, -1 sets to auto-calculation - par[0] is the pedestal - par[1] is the slope of the pedestal - par[2] is the inflection point - par[3] is the RMS - par[4] is the amplitude - par[5] is the angual coefficient of the charge sharing slope (scales with par[3]) -- always positive - */ - void setStartParameters(Double_t *par); - -/** get start parameters for the s-curve function - \param par parameters, -1 means auto-calculated - par[0] is the pedestal - par[1] is the slope of the pedestal - par[2] is the inflection point - par[3] is the RMS - par[4] is the amplitude - par[5] is the angual coefficient of the charge sharing slope (scales with par[3]) -- always positive - */ - void getStartParameters(Double_t *par); - - /** - fits histogram with the s-curve function - \param h1 1d-histogram to be fitted - \param mypar pointer to fit parameters array - \param emypar pointer to fit parameter errors - \returns the fitted function - can be used e.g. to get the Chi2 or similar - */ - TF1 *fitSCurve(TH1 *h1, Double_t *mypar, Double_t *emypar); - - - /** - fits histogram with the spectrum - \param h1 1d-histogram to be fitted - \param mypar pointer to fit parameters array - \param emypar pointer to fit parameter errors - \returns the fitted function - can be used e.g. to get the Chi2 or similar - */ - TF1 *fitSpectrum(TH1 *h1, Double_t *mypar, Double_t *emypar); - - - /** - fits histogram with the spectrum - \param h1 1d-histogram to be fitted - \param mypar pointer to fit parameters array - \param emypar pointer to fit parameter errors - \returns the fitted function - can be used e.g. to get the Chi2 or similar - */ - TF1 *fitSpectrumPixel(TH1 *h1, Double_t *mypar, Double_t *emypar); - - - /** - calculates gain and offset for the set of inflection points - \param nscan number of energy scans - \param en array of energies (nscan long) - \param een array of errors on energies (nscan long) - can be NULL! - \param fl array of inflection points (nscan long) - \param efl array of errors on the inflection points (nscan long) - \param gain reference to gain resulting from the fit - \param off reference to offset resulting from the fit - \param egain reference to error on the gain resulting from the fit - \param eoff reference to the error on the offset resulting from the fit - \returns graph energy vs inflection point - */ - TGraphErrors* linearCalibration(int nscan, Double_t *en, Double_t *een, Double_t *fl, Double_t *efl, Double_t &gain, Double_t &off, Double_t &egain, Double_t &eoff); - - /** - calculates gain and offset for the set of energy scans - \param nscan number of energy scans - \param en array of energies (nscan long) - \param een array of errors on energies (nscan long) - can be NULL! - \param h1 array of TH1 - \param gain reference to gain resulting from the fit - \param off reference to offset resulting from the fit - \param egain reference to error on the gain resulting from the fit - \param eoff reference to the error on the offset resulting from the fit - \returns graph energy vs inflection point - */ - TGraphErrors* calibrateScurves(int nscan, Double_t *en, Double_t *een, TH1F **h1, Double_t &gain, Double_t &off, Double_t &egain, Double_t &eoff){return calibrate(nscan, en, een, h1, gain, off, egain, eoff, 1);}; - - /** - calculates gain and offset for the set of energy spectra - \param nscan number of energy scans - \param en array of energies (nscan long) - \param een array of errors on energies (nscan long) - can be NULL! - \param h1 array of TH1 - \param gain reference to gain resulting from the fit - \param off reference to offset resulting from the fit - \param egain reference to error on the gain resulting from the fit - \param eoff reference to the error on the offset resulting from the fit - \returns graph energy vs peak - */ - TGraphErrors* calibrateSpectra(int nscan, Double_t *en, Double_t *een, TH1F **h1, Double_t &gain, Double_t &off, Double_t &egain, Double_t &eoff){return calibrate(nscan, en, een, h1, gain, off, egain, eoff, 0);}; - - -#endif - private: - -#ifdef MYROOT - /** - calculates gain and offset for the set of energies - \param nscan number of energy scans - \param en array of energies (nscan long) - \param een array of errors on energies (nscan long) - can be NULL! - \param h1 array of TH1 - \param gain reference to gain resulting from the fit - \param off reference to offset resulting from the fit - \param egain reference to error on the gain resulting from the fit - \param eoff reference to the error on the offset resulting from the fit - \param integral 1 is an s-curve set (default), 0 spectra - \returns graph energy vs peak/inflection point - */ - TGraphErrors* calibrate(int nscan, Double_t *en, Double_t *een, TH1F **h1, Double_t &gain, Double_t &off, Double_t &egain, Double_t &eoff, int integral=1); - - - /** - Initializes the start parameters and the range of the fit depending on the histogram characteristics and/or on the start parameters specified by the user - \param fun pointer to function to be initialized - \param h1 histogram from which to extract the range and start parameters, if not already specified by the user - -*/ - - void initFitFunction(TF1 *fun, TH1 *h1); - - - /** - Performs the fit according to the flags specified and returns the fitted function - \param fun function to fit - \param h1 histogram to fit - \param mypar pointer to fit parameters array - \param emypar pointer to fit parameter errors - \returns the fitted function - can be used e.g. to get the Chi2 or similar - */ - TF1 *fitFunction(TF1 *fun, TH1 *h1, Double_t *mypar, Double_t *emypar); - -#endif - -#ifdef MYROOT - Double_t fit_min; /**< minimum of the s-curve fitting range, -1 is histogram x-min */ - Double_t fit_max; /**< maximum of the s-curve fitting range, -1 is histogram x-max */ - - Double_t bg_offset; /**< start value for the background pedestal */ - Double_t bg_slope; /**< start value for the background slope */ - Double_t flex; /**< start value for the inflection point */ - Double_t noise; /**< start value for the noise */ - Double_t ampl; /**< start value for the number of photons */ - Double_t cs_slope; /**< start value for the charge sharing slope */ - - - TF1 *fscurve; /**< function with which the s-curve will be fitted */ - - TF1 *fspectrum; /**< function with which the spectrum will be fitted */ - - TF1 *fspixel; /**< function with which the spectrum will be fitted */ - -#endif - - energyCalibrationFunctions *funcs; - int plot_flag; /**< 0 does not plot, >0 plots (flags?) */ - - int cs_flag; /**< 0 functions without charge sharing contribution, >0 with charge sharing contribution */ - -}; - -#endif - - - - - - - - - - - - - - - - - - - diff --git a/slsDetectorCalibration/gotthardDoubleModuleCommonModeSubtractionNew.h b/slsDetectorCalibration/gotthardDoubleModuleCommonModeSubtractionNew.h deleted file mode 100644 index 2960cabd4..000000000 --- a/slsDetectorCalibration/gotthardDoubleModuleCommonModeSubtractionNew.h +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef GOTTHARDDOUBLECOMMONMODESUBTRACTION_H -#define GOTTHARDDOUBLECOMMONMODESUBTRACTION_H - - -#include "commonModeSubtractionNew.h" - -class gotthardDoubleModuleCommonModeSubtraction : public commonModeSubtraction { - - /** @short class to calculate the common mode of the pedestals based on an approximated moving average*/ - - public: - - /** constructor - \param nn number of samples for the moving average to calculate the average common mode - \param iroi number of regions on which one can calculate the common mode separately. Defaults to 1 i.e. whole detector - - */ - gotthardDoubleModuleCommonModeSubtraction(int ns=3) : commonModeSubtraction(2, ns) {}; - - /** - gets the common mode ROI for pixel ix, iy - */ - virtual int getROI(int ix, int iy){return ix%2;}; - - -}; - - - -#endif diff --git a/slsDetectorCalibration/gotthardExecutables/Makefile.onTheFly b/slsDetectorCalibration/gotthardExecutables/Makefile.onTheFly deleted file mode 100644 index da6e994ef..000000000 --- a/slsDetectorCalibration/gotthardExecutables/Makefile.onTheFly +++ /dev/null @@ -1,22 +0,0 @@ - -CBFLIBDIR=/afs/psi.ch/project/sls_det_software/CBFlib-0.9.5 -LIBRARYCBF=$(CBFLIBDIR)/lib/*.o ../tiffIO.cpp -ZMQLIB=../../slsReceiverSoftware/include -INCDIR=-I.. -I../../slsReceiverSoftware/include -I$(CBFLIBDIR)/include/ -I. -I../interpolations -I../dataStructures -LIBHDF5=-L$(CBFLIBDIR)/lib/ -lhdf5 -LDFLAG= -L/usr/lib64/ -lpthread -#-L../../bin -MAIN=gotthard25umZmqAnalysis.C - -#DESTDIR?=../bin - -all: gotthard25umOnTheFlyAnalysis gotthard25umZmq - -gotthard25umOnTheFlyAnalysis: $(MAIN) $(INCS) clean - g++ -o gotthard25umOnTheAnalysis $(MAIN) -lm -ltiff -lstdc++ $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) - -gotthard25umZmq: $(MAIN) $(INCS) clean - g++ -o gotthard25umZmq $(MAIN) -lm -ltiff -lstdc++ $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DZMQ -L$(ZMQLIB) -lzmq - -clean: - rm -f gotthard25umOnTheFlyAnalysis diff --git a/slsDetectorCalibration/gotthardExecutables/gotthard25umZmqAnalysis.C b/slsDetectorCalibration/gotthardExecutables/gotthard25umZmqAnalysis.C deleted file mode 100644 index 49987b07b..000000000 --- a/slsDetectorCalibration/gotthardExecutables/gotthard25umZmqAnalysis.C +++ /dev/null @@ -1,517 +0,0 @@ -#include "sls_receiver_defs.h" -//#ifdef ZMQ -#include "ZmqSocket.h" -//#endif -#include -#include -#include -#include -#include -#include -//#include -//#include -//#include -#include -#include - -//#define BCHIP074_BCHIP075 - -#include "gotthardModuleDataNew.h" -#include "gotthardDoubleModuleDataNew.h" -#include "gotthardDoubleModuleCommonModeSubtractionNew.h" - -#include "singlePhotonDetector.h" -//#include "interpolatingDetector.h" -//#include "linearInterpolation.h" -#include "multiThreadedAnalogDetector.h" - -#include - -#define NC 1280 -#define NR 1 - -//#include "tiffIO.h" - - - - - -#define SLS_DETECTOR_JSON_HEADER_VERSION 0x2 -int main(int argc, char *argv[]){ - //void *gotthardProcessFrame() { - - - - int fifosize=1000; - int nthreads=1; - int nph, nph1; - int etabins=550; - double etamin=-1, etamax=2; - int nsubpix=1; - float *etah=new float[etabins*etabins]; - int *heta, *himage; - int offset=48; - #ifdef ZMQ - offset=0; - #endif - #ifndef ZMQ - offset=48; - #endif - - //commonModeSubtraction *cm=NULL; - - gotthardDoubleModuleCommonModeSubtraction *cm=new gotthardDoubleModuleCommonModeSubtraction(); - gotthardModuleDataNew *decoder=new gotthardModuleDataNew(); - gotthardDoubleModuleDataNew *det=new gotthardDoubleModuleDataNew(offset); - singlePhotonDetector *filter=new singlePhotonDetector(det,3, 5, 1, cm, 1000, 100); - // analogDetector *filter=new analogDetector(det, 1, cm, 1000); - // analogDetector *filter_nocm=new analogDetector(det, 1, NULL, 1000); - filter->setROI(0,2560,0,1); - char *buff;//[2*(48+1280*2)]; - char *buff0; - char *buff1; - multiThreadedAnalogDetector *mt=new multiThreadedAnalogDetector(filter,nthreads,fifosize); - mt->setFrameMode(eFrame); - // mt->setFrameMode(eFrame); - // mt->setFrameMode(ePedestal); - mt->StartThreads(); - mt->popFree(buff); - buff0=buff; - buff1=buff+offset*2+1280*2; - int photons[1280*2]; - int nf=0; - int ok=0; - std::time_t end_time; - //int16_t dout[1280*2]; - int iFrame=-1; - int np=-1; - nph=0; - nph1=0; - //int np; - int iph; - int data_ready=1; - int *image; - - - - int length; - int nnx, nny,nns; - int nix, niy,nis; - // infinite loop - int ix, iy, isx, isy; - - filter->getImageSize(nnx, nny,nns); - int16_t *dout=new int16_t [nnx*nny]; - - - -#ifdef ZMQ - if (argc < 3 ) { - cprintf(RED, "Help: %s [receive socket ip] [receive starting port number] [send_socket ip] [send starting port number]\n",argv[0]); - return EXIT_FAILURE; - } - - // receive parameters - bool send = false; - char* socketip=argv[1]; - uint32_t portnum = atoi(argv[2]); - int size = nnx*nny*2; - - // send parameters if any - char* socketip2 = 0; - uint32_t portnum2 = 0; - if (argc > 3) { - send = true; - socketip2 = argv[3]; - portnum2 = atoi(argv[4]); - } - cout << "\nrx socket ip : " << socketip << - "\nrx port num : " << portnum ; - if (send) { - cout << "\nsd socket ip : " << socketip2 << - "\nsd port num : " << portnum2; - } - cout << endl; - - - - // receive socket - ZmqSocket* zmqsocket0 = new ZmqSocket(socketip,portnum); - if (zmqsocket0->IsError()) { - cprintf(RED, "Error: Could not create Zmq socket on port %d with ip %s\n", portnum, socketip); - delete zmqsocket0; - return EXIT_FAILURE; - } - - ZmqSocket* zmqsocket1 = new ZmqSocket(socketip,portnum+1); - if (zmqsocket1->IsError()) { - cprintf(RED, "Error: Could not create Zmq socket on port %d with ip %s\n", portnum+1, socketip); - delete zmqsocket1; - delete zmqsocket0; - return EXIT_FAILURE; - } - - - zmqsocket0->Connect(); - printf("Zmq Client 0 at %s\n", zmqsocket0->GetZmqServerAddress()); - zmqsocket1->Connect(); - printf("Zmq Client 1 at %s\n", zmqsocket1->GetZmqServerAddress()); - - // send socket - ZmqSocket* zmqsocket2 = 0; - ZmqSocket* zmqsocket3 = 0; - if (send) { - zmqsocket2 = new ZmqSocket(portnum2, socketip2); - if (zmqsocket2->IsError()) { - bprintf(RED, "Error: Could not create Zmq socket server on port %d and ip %s\n", portnum2, socketip2); - delete zmqsocket2; - delete zmqsocket1; - delete zmqsocket0; - return EXIT_FAILURE; - } - - zmqsocket3 = new ZmqSocket(portnum2+1, socketip2); - if (zmqsocket3->IsError()) { - bprintf(RED, "Error: Could not create Zmq socket server on port %d and ip %s\n", portnum2+1, socketip2); - delete zmqsocket3; - delete zmqsocket2; - delete zmqsocket1; - delete zmqsocket0; - return EXIT_FAILURE; - } - - zmqsocket2->Connect(); - printf("Zmq Server 0 started at %s\n", zmqsocket2->GetZmqServerAddress()); - zmqsocket3->Connect(); - printf("Zmq Server 1 started at %s\n", zmqsocket3->GetZmqServerAddress()); - } - - - - - - - - uint64_t acqIndex1 = -1; - uint64_t frameIndex1 = -1; - uint32_t subframeIndex1 = -1; - uint64_t fileindex1 = -1; - string filename1 = ""; - - uint64_t acqIndex0 = -1; - uint64_t frameIndex0 = -1; - uint32_t subframeIndex0 = -1; - uint64_t fileindex0 = -1; - string filename0 = ""; - - - int eoa0=0; - int eoa1=0; - - - - - - #endif - - - - - - - - - - - - - char ofname[10000]; - char fn0[10000], fn1[10000]; - FILE *fout=NULL; - FILE *fclust=NULL; - for (int i=0; ireadNextFrame(filebin0, iFrame, np, buff0)) && (decoder->readNextFrame(filebin1, iFrame, np, buff1))) { -#endif - - - - - -#ifdef ZMQ - - int end_of_acquisition; - while(1) { - end_of_acquisition=0; - eoa0=0; - eoa1=0; - - // cout << "Receive header " << nf << endl; - if (!zmqsocket0->ReceiveHeader(0, acqIndex0, frameIndex0, subframeIndex0, filename0, fileindex0)) { - - // cout << "************************************************************************** packet0!*****************************"<< endl; - eoa0=1; - end_of_acquisition++; - } - if (!zmqsocket1->ReceiveHeader(0, acqIndex1, frameIndex1, subframeIndex1, filename1, fileindex1)) { - //cout << "************************************************************************** packet1!*****************************"<< endl; - eoa1=1; - end_of_acquisition++; - } - - - - - - // if ((!zmqsocket0->ReceiveHeader(0, acqIndex0, frameIndex0, subframeIndex0, filename0, fileindex0)) && (!zmqsocket1->ReceiveHeader(0, acqIndex1, frameIndex1, subframeIndex1, filename1, fileindex1))){ - if (end_of_acquisition==0) { - - if (acqIndex0!=acqIndex1) - cout << "different acquisition indexes " << acqIndex0 << " and " << acqIndex1 << endl; - if (frameIndex0!=frameIndex1) - cout << "different frame indexes " << frameIndex0 << " and " << frameIndex1 << endl; - - - while (frameIndex0ReceiveData(0, buff0, size/2); - if (!zmqsocket0->ReceiveHeader(0, acqIndex0, frameIndex0, subframeIndex0, filename0, fileindex0)) { - end_of_acquisition++; - eoa0=1; - break; - } - } - - while (frameIndex1ReceiveData(0, buff1, size/2); - if (!zmqsocket1->ReceiveHeader(0, acqIndex1, frameIndex1, subframeIndex1, filename1, fileindex1)) { - end_of_acquisition++; - eoa1=1; - break; - } - } - } - - - - if (eoa0!=eoa1) { - - while (eoa0<1) { - length = zmqsocket0->ReceiveData(0, buff0, size/2); - if (!zmqsocket0->ReceiveHeader(0, acqIndex0, frameIndex0, subframeIndex0, filename0, fileindex0)) { - end_of_acquisition++; - eoa0=1; - } - } - - - while (eoa1<1) { - length = zmqsocket1->ReceiveData(0, buff1, size/2); - if (!zmqsocket1->ReceiveHeader(0, acqIndex1, frameIndex1, subframeIndex1, filename1, fileindex1)) { - end_of_acquisition++; - eoa1=1; - } - } - } - - - - - - - if (end_of_acquisition) { - // cout << "************************************************************************** END OF FRAME" << end_of_acquisition << " !*****************************"<< endl; - // return 0; - - sprintf(ofname,"%s_%d.ph",fn0,irun); - while (mt->isBusy()) {;} - image=filter->getImage(); - if (image) { - fout=fopen(ofname,"w"); - cout << nf << "*****************" << endl; - for (int i=0; i<2560; i++) { - fprintf(fout,"%d %d\n",i,image[i]); - dout[i]=image[i]; - if (dout[i]<0) - dout[i]=0; - } - fclose(fout); - } - - - if (send) { - - zmqsocket2->SendHeaderData(0, false, SLS_DETECTOR_JSON_HEADER_VERSION,0,0,0,0,0, 0,0,fn0, 0, 0,0,0,0,0,0,0,0,0,0,0,1); - zmqsocket3->SendHeaderData(0, false, SLS_DETECTOR_JSON_HEADER_VERSION,0,0,0,0,0, 0,0,fn1, 0, 0,0,0,0,0,0,0,0,0,0,0,1); - - zmqsocket2->SendData((char*)dout,size/2); - zmqsocket3->SendData(((char*)dout)+size/2,size/2); - // // cprintf(GREEN, "Sent Data\n"); - - - zmqsocket2->SendHeaderData(0, true, SLS_DETECTOR_JSON_HEADER_VERSION); - zmqsocket3->SendHeaderData(0, true, SLS_DETECTOR_JSON_HEADER_VERSION); - } - - - //mt->setFrameMode(eFrame); - filter->clearImage(); - // std::time(&end_time); - // cout << std::ctime(&end_time) << " " << nf << endl; - fclose(fclust); - fclust=NULL; - - - - continue; - } - - if (fclust==NULL) { - - strcpy(fn0,filename0.c_str()); - strcpy(fn1,filename1.c_str()); - sprintf(ofname,"%s_%d.clust",fn0,irun); - fclust=fopen(ofname,"w"); - while (mt->isBusy()) {;} - mt->setFilePointer(fclust); - } - - // strcpy(fn0,filename0.c_str()); - // strcpy(fn1,filename1.c_str()); - - // cout << "Receive data " << nf << endl; - length = zmqsocket0->ReceiveData(0, buff0, size/2); - length += zmqsocket1->ReceiveData(0, buff1, size/2); - - irun=fileindex0; - - - - // // if (nf>100) - // // mt->setFrameMode(eFrame); - // //filter->clearImage(); - - -#endif - - - mt->pushData(buff); - mt->nextThread(); - // cout << "==" << nf << endl; - - // while (mt->isBusy()) {;} - // image=filter->getImage(); - // if (image) { - // for (int i=0; i<2560; i++) { - // // if (i<512) - - // // fprintf(fout,"%d %d\n",i,image[i]); - // dout[i]=filter->subtractPedestal(buff,i,0,1);//image[i];//filter->getPedestal(i,0);// - // if (dout[i]<0) - // dout[i]=0; - // // cout << i << " " << image[i] << " " << dout[i] << endl; - // } - // } - - - // if (send) { - // strcpy(fname0,filename0.c_str()); - // strcpy(fname1,filename1.c_str()); - // // zmqsocket2->SendHeaderData(0, false, SLS_DETECTOR_JSON_HEADER_VERSION,16,fileindex,400,400,400*400, acqIndex,frameIndex,fname, acqIndex, 0,0,0,0,0,0,0,0,0,0,0,1); - // zmqsocket2->SendHeaderData(0, false, SLS_DETECTOR_JSON_HEADER_VERSION,0,0,0,0,0, 0,0,fname0, 0, 0,0,0,0,0,0,0,0,0,0,0,1); - // zmqsocket3->SendHeaderData(0, false, SLS_DETECTOR_JSON_HEADER_VERSION,0,0,0,0,0, 0,0,fname1, 0, 0,0,0,0,0,0,0,0,0,0,0,1); - - // zmqsocket2->SendData((char*)dout,size/2); - // zmqsocket3->SendData(((char*)dout)+size/2,size/2); - // // cprintf(GREEN, "Sent Data\n"); - - - // // zmqsocket2->SendHeaderData(0, true, SLS_DETECTOR_JSON_HEADER_VERSION); - // // zmqsocket3->SendHeaderData(0, true, SLS_DETECTOR_JSON_HEADER_VERSION); - - // // cprintf(RED, "Received %d frames\n", nf); - - // } - - - mt->popFree(buff); - buff0=buff; - buff1=buff+offset*2+1280*2; - - - - nf++; - - - - -#ifndef ZMQ - - - - - while (mt->isBusy()) {;} - image=filter->getImage(); - if (image) { - fout=fopen(ofname,"w"); - //cout << nf << "*****************" << endl; - for (int i=0; i<512; i++) { - fprintf(fout,"%d %d\n",i,image[i]); - } - fclose(fout); - } - filter->clearImage(); - - - - iFrame=-1; - } - - filebin0.close(); - filebin1.close(); - } - else - cout << "Could not open file " << fname0<< " or " << fname1 << endl; -#endif - - } - return NULL; - - - -} diff --git a/slsDetectorCalibration/interpolatingDetector.h b/slsDetectorCalibration/interpolatingDetector.h deleted file mode 100644 index ded09d419..000000000 --- a/slsDetectorCalibration/interpolatingDetector.h +++ /dev/null @@ -1,653 +0,0 @@ -#ifndef INTERPOLATINGDETECTOR_H -#define INTERPOLATINGDETECTOR_H - - -#include "singlePhotonDetector.h" - -#include "slsInterpolation.h" - -//#define M015 - -#ifdef MYROOT1 -#include - -#endif - - -#include - -using namespace std; - - -class interpolatingDetector : public singlePhotonDetector { - - /** @short class to perform pedestal subtraction etc. and find single photon clusters for an analog detector */ - - public: - - - /** - - Constructor (no error checking if datasize and offsets are compatible!) - \param d detector data structure to be used - \param csize cluster size (should be an odd number). Defaults to 3 - \param nsigma number of rms to discriminate from the noise. Defaults to 5 - \param sign 1 if photons are positive, -1 if negative - \param cm common mode subtraction algorithm, if any. Defaults to NULL i.e. none - \param nped number of samples for pedestal averaging - \param nd number of dark frames to average as pedestals without photon discrimination at the beginning of the measurement - - - */ - - - interpolatingDetector(slsDetectorData *d, slsInterpolation *inte, - double nsigma=5, - int sign=1, - commonModeSubtraction *cm=NULL, - int nped=1000, - int nd=100, int nnx=-1, int nny=-1) : - singlePhotonDetector(d, 3,nsigma,sign, cm, nped, nd, nnx, nny) , interp(inte), id(0) { - //cout << "**"<< xmin << " " << xmax << " " << ymin << " " << ymax << endl; - -}; - - - - interpolatingDetector(interpolatingDetector *orig) : singlePhotonDetector(orig) { - interp=(orig->interp)->Clone(); - id=orig->id; - /* xmin=orig->xmin; */ - /* xmax=orig->xmax; */ - /* ymin=orig->ymin; */ - /* ymax=orig->ymax; */ - - } - - - virtual interpolatingDetector *Clone() { - return new interpolatingDetector(this); - } - - virtual int setId(int i) {id=i; interp->setId(id); return id;}; - - virtual void prepareInterpolation(int &ok) { - cout << "*"<< endl; -#ifdef SAVE_ALL - char tit[1000]; - sprintf(tit,"/scratch/ped_%d.tiff",id); - writePedestals(tit); - sprintf(tit,"/scratch/ped_rms_%d.tiff",id); - writePedestalRMS(tit); - if (gmap) { - sprintf(tit,"/scratch/gmap_%d.tiff",id); - writeGainMap(tit); - } -#endif - if (interp) - interp->prepareInterpolation(ok); - } - - - void clearImage() {if (interp) interp->clearInterpolatedImage(); else singlePhotonDetector::clearImage();}; - - int getImageSize(int &nnx, int &nny, int &ns) {if (interp) return interp->getImageSize(nnx, nny, ns); else return analogDetector::getImageSize(nnx, nny, ns);}; - #ifdef MYROOT1 - virtual TH2F *getImage() -#endif -#ifndef MYROOT1 - virtual int *getImage() -#endif - { - // cout << "image " << endl; - if (interp) - return interp->getInterpolatedImage(); - else - return analogDetector::getImage(); - //cout << "null " << endl; - } - -#ifdef MYROOT1 - virtual TH2F *addToInterpolatedImage(char *data, int *val, int &nph) -#endif -#ifndef MYROOT1 - virtual int *addToInterpolatedImage(char *data, int *val, int &nph) -#endif - { - nph=addFrame(data,val,0); - if (interp) - return interp->getInterpolatedImage(); - else - singlePhotonDetector::getImage(); - //return NULL; - }; - - -#ifdef MYROOT1 - virtual TH2F *addToFlatField(char *data, int *val, int &nph) -#endif -#ifndef MYROOT1 - virtual int *addToFlatField(char *data, int *val, int &nph) -#endif - { - nph=addFrame(data,val,1); - if (interp) - return interp->getFlatField(); - else - return NULL; - }; - - void *writeImage(const char * imgname) { - // cout << id << "=" << imgname<< endl; - if (interp) - interp->writeInterpolatedImage(imgname); - else - analogDetector::writeImage(imgname); - return NULL; - } - -int addFrame(char *data, int *ph=NULL, int ff=0) { - - - int nph=0; - double val[ny][nx]; - int cy=(clusterSizeY+1)/2; - int cs=(clusterSize+1)/2; - int ir, ic; - double rms; - double int_x,int_y, eta_x, eta_y; - double max=0, tl=0, tr=0, bl=0,br=0, *v, vv; - // cout << "********** Add frame "<< iframe << endl; - if (ph==NULL) - ph=image; - - if (iframerms=rms; - - - - for (int ir=-(clusterSizeY/2); ir<(clusterSizeY/2)+1; ir++) { - for (int ic=-(clusterSize/2); ic<(clusterSize/2)+1; ic++) { - - if ((iy+ir)>=iy && (iy+ir)=ix && (ix+ic)=0) - br+=*v; - if (ir>=0 && ic<=0) - tl+=*v; - if (ir>=0 && ic>=0) - tr+=*v; - if (*v>max) { - max=*v; - } - - - if (ir==0 && ic==0) { - if (*v<-nSigma*rms) - eventMask[iy][ix]=NEGATIVE_PEDESTAL; - } - - } - } - - if (bl>=br && bl>=tl && bl>=tr) { - (clusters+nph)->quad=BOTTOM_LEFT; - (clusters+nph)->quadTot=bl; - } else if (br>=bl && br>=tl && br>=tr) { - (clusters+nph)->quad=BOTTOM_RIGHT; - (clusters+nph)->quadTot=br; - } else if (tl>=br && tl>=bl && tl>=tr) { - (clusters+nph)->quad=TOP_LEFT; - (clusters+nph)->quadTot=tl; - } else if (tr>=bl && tr>=tl && tr>=br) { - (clusters+nph)->quad=TOP_RIGHT; - (clusters+nph)->quadTot=tr; - } - - if (max>nSigma*rms || tot>sqrt(clusterSizeY*clusterSize)*nSigma*rms || ((clusters+nph)->quadTot)>sqrt(cy*cs)*nSigma*rms) { - if (val[iy][ix]>=max) { - eventMask[iy][ix]=PHOTON_MAX; - (clusters+nph)->tot=tot; - (clusters+nph)->x=ix; - (clusters+nph)->y=iy; - (clusters+nph)->iframe=det->getFrameNumber(data); - (clusters+nph)->ped=getPedestal(ix,iy,0); - for (int ir=-(clusterSizeY/2); ir<(clusterSizeY/2)+1; ir++) { - for (int ic=-(clusterSize/2); ic<(clusterSize/2)+1; ic++) { - (clusters+nph)->set_data(val[iy+ir][ix+ic],ic,ir); - } - } - - - - - if (interp) { - if (ff) { - interp->addToFlatField((clusters+nph)->quadTot,(clusters+nph)->quad,(clusters+nph)->get_cluster(),eta_x, eta_y); - } else { - interp->getInterpolatedPosition(ix, iy, (clusters+nph)->quadTot,(clusters+nph)->quad,(clusters+nph)->get_cluster(),int_x, int_y); - interp->addToImage(int_x, int_y); - } - } else - image[ix+nx*iy]++; - - - - - - - - - - - nph++; - image[iy*nx+ix]++; - - } else { - eventMask[iy][ix]=PHOTON; - } - } else if (eventMask[iy][ix]==PEDESTAL) { - addToPedestal(data,ix,iy); - } - - - } - } - nphFrame=nph; - nphTot+=nph; - //cout << nphFrame << endl; - // cout <<"**********************************"<< endl; - writeClusters(); - return nphFrame; - -}; - - /********************************************************* - int addFrame(char *data, int ff=0) { - - double g=1; - - single_photon_hit *cl; - single_photon_hit clust; - if (clusters) - cl=clusters; - else - cl=&clust; - - - int ccs=clusterSize; - int ccy=clusterSizeY; - - double int_x,int_y, eta_x, eta_y; - int nph=0; - double rest[ny][nx]; - int cy=(clusterSizeY+1)/2; - int cs=(clusterSize+1)/2; - int ir, ic; - double cc[2][2]; - double max=0, tl=0, tr=0, bl=0,br=0, v, vv; - int xoff,yoff; - int skip=0; - // cout <<"fr"<< endl; - double tthr; - if (iframe=ymin && (iy+ir)=xmin && (ix+ic)set_data(rest[iy+ir][ix+ic], ic, ir); - - if (ir>=0 && ic>=0 ) - rest[iy+ir][ix+ic]=subtractPedestal(data,ix+ic,iy+ir); - - v=rest[iy+ir][ix+ic];//cluster->get_data(ic,ir); - tot+=v; - - if (ir<=0 && ic<=0) - bl+=v; - if (ir<=0 && ic>=0) - br+=v; - if (ir>=0 && ic<=0) - tl+=v; - if (ir>=0 && ic>=0) - tr+=v; - - if (v>max) { - max=v; - } - // if (ir==0 && ic==0) { - if (v>tthr) { - eventMask[iy][ix]=NEIGHBOUR; - } - //} - } - } - } - if (rest[iy][ix]<=-tthr) { - eventMask[iy][ix]=NEGATIVE_PEDESTAL; - //if (cluster->get_data(0,0)>=max) { - } else if (max>tthr || tot>sqrt(ccy*ccs)*tthr || quadTot>sqrt(cy*cs)*tthr) { - if (rest[iy][ix]>=max) { - if (bl>=br && bl>=tl && bl>=tr) { - cl->quad=BOTTOM_LEFT; - cl->quadTot=bl; - } else if (br>=bl && br>=tl && br>=tr) { - cl->quad=BOTTOM_RIGHT; - cl->quadTot=br; - } else if (tl>=br && tl>=bl && tl>=tr) { - cl->quad=TOP_LEFT; - cl->quadTot=tl; - } else if (tr>=bl && tr>=tl && tr>=br) { - cl->quad=TOP_RIGHT; - cl->quadTot=tr; - } - - - eventMask[iy][ix]=PHOTON_MAX; - cl->tot=tot; - cl->x=ix; - cl->y=iy; - cl->ped=getPedestal(ix,iy, 0); - cl->rms=getPedestalRMS(ix,iy); - - for (int ir=-(clusterSizeY/2); ir<(clusterSizeY/2)+1; ir++) { - for (int ic=-(clusterSize/2); ic<(clusterSize/2)+1; ic++) { - if ((iy+ir)>=ymin && (iy+ir)=xmin && (ix+ic)set_data(rest[iy+ir][ix+ic],ic,ir); - } - } - } - - - if (interp) { - if (ff) { -#ifdef M015 - if (iy>100) -#endif - interp->addToFlatField(cl->quadTot,cl->quad,cl->get_cluster(),eta_x, eta_y); - // if ((eta_x<0.1 || eta_x>0.9)&&(eta_y<0.1 || eta_y>0.9)) - // cout << ix << " " << iy << " " << eta_x <<" " << eta_y << endl; - - } else { - interp->getInterpolatedPosition(ix, iy, cl->quadTot,cl->quad,cl->get_cluster(),int_x, int_y); - interp->addToImage(int_x, int_y); - } - - } else - image[ix+nx*iy]++; - - nph++; - - if (clusters) cl=(clusters+nph); - - - // rest[iy][ix]-=tthr; - } else - eventMask[iy][ix]=PHOTON; - //else if (thr<=0 ) { - //addToPedestal(data,ix,iy); - // } - } - if (eventMask[iy][ix]==PEDESTAL) { - addToPedestal(data,ix,iy); - } - } - } - return nph; - } - - ******************************************/ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - /* for (int ix=0; ixrms=getPedestalRMS(ix,iy); */ - /* //(clusters+nph)->rms=getPedestalRMS(ix,iy); */ - - /* // cout << iframe << " " << nph << " " << ix << " " << iy << endl; */ - /* if (ix==0 || iy==0) */ - /* val[iy][ix]=subtractPedestal(data,ix,iy); */ - - /* if (val[iy][ix]<-nSigma*cl->rms) { */ - /* eventMask[iy][ix]=NEGATIVE_PEDESTAL; */ - /* // cout << "neg ped" << endl; */ - /* } else { */ - /* for (int ir=-(clusterSizeY/2); ir<(clusterSizeY/2)+1; ir++) { */ - /* for (int ic=-(clusterSize/2); ic<(clusterSize/2)+1; ic++) { */ - - - /* if ((iy+ir)>=0 && (iy+ir)=0 && (ix+ic)=0 && ic>=0) { */ - /* val[iy+ir][ix+ic]=subtractPedestal(data,ix+ic,iy+ir); */ - /* eventMask[iy+ir][ix+ic]=PEDESTAL; */ - /* } */ - - /* // cout << ir << " " << ic << " " << val[iy+ir][ix+ic] << endl; */ - /* v=&(val[iy+ir][ix+ic]); */ - /* // if (skip==0) { */ - /* tot+=*v; */ - /* if (ir<=0 && ic<=0) */ - /* bl+=*v; */ - /* if (ir<=0 && ic>=0) */ - /* br+=*v; */ - /* if (ir>=0 && ic<=0) */ - /* tl+=*v; */ - /* if (ir>=0 && ic>=0) */ - /* tr+=*v; */ - /* if (*v>max) { */ - /* max=*v; */ - /* } */ - - /* } */ - /* } */ - /* } */ - - /* if (bl>=br && bl>=tl && bl>=tr) { */ - /* cl->quad=BOTTOM_LEFT; */ - /* cl->quadTot=bl; */ - /* } else if (br>=bl && br>=tl && br>=tr) { */ - /* cl->quad=BOTTOM_RIGHT; */ - /* cl->quadTot=br; */ - /* } else if (tl>=br && tl>=bl && tl>=tr) { */ - /* cl->quad=TOP_LEFT; */ - /* cl->quadTot=tl; */ - /* } else if (tr>=bl && tr>=tl && tr>=br) { */ - /* cl->quad=TOP_RIGHT; */ - /* cl->quadTot=tr; */ - /* } */ - - /* if (max>nSigma*cl->rms || tot>sqrt(clusterSizeY*clusterSize)*nSigma*cl->rms || (cl->quadTot)>sqrt(cy*cs)*nSigma*cl->rms) { */ - /* if (val[iy][ix]>=max) { */ - /* eventMask[iy][ix]=PHOTON_MAX; */ - /* cl->tot=tot; */ - /* cl->x=ix; */ - /* cl->y=iy; */ - /* cl->ped=getPedestal(ix,iy, 0); */ - - /* if (interp) { */ - /* if (ff) { */ - /* interp->addToFlatField(cl->quadTot,cl->quad,cl->get_cluster(),eta_x, eta_y); */ - /* // if ((eta_x<0.1 || eta_x>0.9)&&(eta_y<0.1 || eta_y>0.9)) */ - /* // cout << ix << " " << iy << " " << eta_x <<" " << eta_y << endl; */ - /* } else { */ - /* interp->getInterpolatedPosition(ix, iy, cl->quadTot,cl->quad,cl->get_cluster(),int_x, int_y); */ - /* interp->addToImage(int_x, int_y); */ - /* } */ - /* } else */ - /* image[ix+nx*iy]++; */ - - /* if (clusters) cl=(clusters+nph); */ - - /* nph++; */ - - /* } else { */ - /* eventMask[iy][ix]=PHOTON; */ - /* } */ - /* } else if (eventMask[iy][ix]==PEDESTAL) { */ - /* addToPedestal(data,ix,iy); */ - /* } */ - - /* } */ - /* } */ - /* } */ - /* return nph; */ - - /* }; */ - - - - - - - - - - virtual void processData(char *data, int *val=NULL) { - if (interp){ - switch(fMode) { - case ePedestal: - addToPedestal(data); - break; - case eFlat: - addFrame(data,val,1); - break; - default: - addFrame(data,val,0); - } - } else - singlePhotonDetector::processData(data,val); - - - }; - - virtual char *getInterpolation(){return (char*)interp;}; - - protected: - - - slsInterpolation *interp; - int id; -}; - - - - - -#endif diff --git a/slsDetectorCalibration/interpolations/.__afs3A48 b/slsDetectorCalibration/interpolations/.__afs3A48 deleted file mode 100755 index efa6b3d16..000000000 Binary files a/slsDetectorCalibration/interpolations/.__afs3A48 and /dev/null differ diff --git a/slsDetectorCalibration/interpolations/eta2InterpolationBase.h b/slsDetectorCalibration/interpolations/eta2InterpolationBase.h deleted file mode 100644 index 55ed32e2a..000000000 --- a/slsDetectorCalibration/interpolations/eta2InterpolationBase.h +++ /dev/null @@ -1,436 +0,0 @@ -#ifndef ETA2_INTERPOLATION_BASE_H -#define ETA2_INTERPOLATION_BASE_H - -#ifdef MYROOT1 -#include -#include -#include -#include -#endif - -#include "etaInterpolationBase.h" - -class eta2InterpolationBase : public virtual etaInterpolationBase { - - public: - eta2InterpolationBase(int nx=400, int ny=400, int ns=25, int nb=-1, double emin=1, double emax=0) : etaInterpolationBase(nx,ny, ns, nb, emin, emax) { - // cout << "e2ib " << nb << " " << emin << " " << emax << endl; - - if (nbeta<=0) { - nbeta=nSubPixels*10; - } - if (etamin>=etamax) { - etamin=-1; - etamax=2; - cout << ":" <2) - calcEta(totquad, sDum, etax, etay); - getInterpolatedPosition(x,y,etax,etay,corner,int_x,int_y); - - return; - }; - - - virtual void getInterpolatedPosition(int x, int y, double *data, double &int_x, double &int_y) - { - double sDum[2][2]; - double tot, totquad; - double etax,etay; - - int corner; - corner=calcQuad(data, tot, totquad, sDum); - if (nSubPixels>2) - calcEta(totquad, sDum, etax, etay); - getInterpolatedPosition(x,y,etax,etay,corner,int_x,int_y); - - return; - }; - - - - - - - - - - virtual void getInterpolatedPosition(int x, int y, double totquad,int quad,double *cl,double &int_x, double &int_y) { - - double cc[2][2]; - double *cluster[3]; - int xoff, yoff; - cluster[0]=cl; - cluster[1]=cl+3; - cluster[2]=cl+6; - - switch (quad) { - case BOTTOM_LEFT: - xoff=0; - yoff=0; - break; - case BOTTOM_RIGHT: - xoff=1; - yoff=0; - break; - case TOP_LEFT: - xoff=0; - yoff=1; - break; - case TOP_RIGHT: - xoff=1; - yoff=1; - break; - default: - ; - } - double etax, etay; - if (nSubPixels>2) { - cc[0][0]=cluster[yoff][xoff]; - cc[1][0]=cluster[yoff+1][xoff]; - cc[0][1]=cluster[yoff][xoff+1]; - cc[1][1]=cluster[yoff+1][xoff+1]; - calcEta(totquad,cc,etax,etay); - } - return getInterpolatedPosition(x,y,etax, etay,quad,int_x,int_y); - - } - - - - virtual void getInterpolatedPosition(int x, int y, double totquad,int quad,int *cl,double &int_x, double &int_y) { - - double cc[2][2]; - int *cluster[3]; - int xoff, yoff; - cluster[0]=cl; - cluster[1]=cl+3; - cluster[2]=cl+6; - - switch (quad) { - case BOTTOM_LEFT: - xoff=0; - yoff=0; - break; - case BOTTOM_RIGHT: - xoff=1; - yoff=0; - break; - case TOP_LEFT: - xoff=0; - yoff=1; - break; - case TOP_RIGHT: - xoff=1; - yoff=1; - break; - default: - ; - } - double etax, etay; - if (nSubPixels>2) { - cc[0][0]=cluster[yoff][xoff]; - cc[1][0]=cluster[yoff+1][xoff]; - cc[0][1]=cluster[yoff][xoff+1]; - cc[1][1]=cluster[yoff+1][xoff+1]; - calcEta(totquad,cc,etax,etay); - } - return getInterpolatedPosition(x,y,etax, etay,quad,int_x,int_y); - - } - - - - - - - virtual void getInterpolatedPosition(int x, int y, double etax, double etay, int corner, double &int_x, double &int_y) - { - - - double xpos_eta=0,ypos_eta=0; - double dX,dY; - int ex,ey; - switch (corner) - { - case TOP_LEFT: - dX=-1.; - dY=0; - break; - case TOP_RIGHT: - ; - dX=0; - dY=0; - break; - case BOTTOM_LEFT: - dX=-1.; - dY=-1.; - break; - case BOTTOM_RIGHT: - dX=0; - dY=-1.; - break; - default: - cout << "bad quadrant" << endl; - dX=0.; - dY=0.; - } - - - if (nSubPixels>2) { - -#ifdef MYROOT1 - xpos_eta=(hhx->GetBinContent(hhx->GetXaxis()->FindBin(etax),hhy->GetYaxis()->FindBin(etay)))/((double)nSubPixels); - ypos_eta=(hhy->GetBinContent(hhx->GetXaxis()->FindBin(etax),hhy->GetYaxis()->FindBin(etay)))/((double)nSubPixels); -#endif -#ifndef MYROOT1 - ex=(etax-etamin)/etastep; - ey=(etay-etamin)/etastep; - if (ex<0) { - cout << "x*"<< ex << endl; - ex=0; - } - if (ex>=nbeta) { - cout << "x?"<< ex << endl; - ex=nbeta-1; - - } - if (ey<0) { - cout << "y*"<< ey << endl; - ey=0; - } - if (ey>=nbeta) { - cout << "y?"<< ey << endl; - ey=nbeta-1; - - } - - - - xpos_eta=(((double)hhx[(ey*nbeta+ex)]))+dX ;///((double)nSubPixels); - ypos_eta=(((double)hhy[(ey*nbeta+ex)]))+dY ;///((double)nSubPixels); - //else - //return 0; - -#endif - } else { - xpos_eta=0.5*dX+0.25; - ypos_eta=0.5*dY+0.25; - } - - int_x=((double)x) + xpos_eta+0.5; - int_y=((double)y) + ypos_eta+0.5; - - - } - - - - virtual int addToFlatField(double totquad,int quad,int *cl,double &etax, double &etay) { - double cc[2][2]; - int *cluster[3]; - int xoff, yoff; - cluster[0]=cl; - cluster[1]=cl+3; - cluster[2]=cl+6; - - switch (quad) { - case BOTTOM_LEFT: - xoff=0; - yoff=0; - break; - case BOTTOM_RIGHT: - xoff=1; - yoff=0; - break; - case TOP_LEFT: - xoff=0; - yoff=1; - break; - case TOP_RIGHT: - xoff=1; - yoff=1; - break; - default: - ; - } - cc[0][0]=cluster[yoff][xoff]; - cc[1][0]=cluster[yoff+1][xoff]; - cc[0][1]=cluster[yoff][xoff+1]; - cc[1][1]=cluster[yoff+1][xoff+1]; - - /* cout << cl[0] << " " << cl[1] << " " << cl[2] << endl; */ - /* cout << cl[3] << " " << cl[4] << " " << cl[5] << endl; */ - /* cout << cl[6] << " " << cl[7] << " " << cl[8] << endl; */ - /* cout <<"******"<Fill(etax,etay); -#endif -#ifndef MYROOT1 - int ex,ey; - ex=(etax-etamin)/etastep; - ey=(etay-etamin)/etastep; - if (ey=0 && ey>=0) - heta[ey*nbeta+ex]++; -#endif - return 0; - }; - -/* protected: */ - -/* #ifdef MYROOT1 */ -/* TH2D *heta; */ -/* TH2D *hhx; */ -/* TH2D *hhy; */ -/* #endif */ -/* #ifndef MYROOT1 */ -/* int *heta; */ -/* float *hhx; */ -/* float *hhy; */ -/* #endif */ -/* int nbeta; */ -/* double etamin, etamax, etastep; */ - -}; - -#endif diff --git a/slsDetectorCalibration/interpolations/eta3InterpolationBase.h b/slsDetectorCalibration/interpolations/eta3InterpolationBase.h deleted file mode 100644 index 7264dd95e..000000000 --- a/slsDetectorCalibration/interpolations/eta3InterpolationBase.h +++ /dev/null @@ -1,294 +0,0 @@ -#ifndef ETA3_INTERPOLATION_BASE_H -#define ETA3_INTERPOLATION_BASE_H - -#ifdef MYROOT1 -#include -#include -#include -#include -#endif - -#include "etaInterpolationBase.h" - -class eta3InterpolationBase : public virtual etaInterpolationBase { - - public: - eta3InterpolationBase(int nx=400, int ny=400, int ns=25, int nb=-1, double emin=1, double emax=0) : etaInterpolationBase(nx, ny, ns, nb, emin, emax) { - // cout << "e3ib " << nb << " " << emin << " " << emax << endl; - if (nbeta<=0) { - nbeta=nSubPixels*10; - } - if (etamin>=etamax) { - etamin=-1; - etamax=1; - } - - etastep=(etamax-etamin)/nbeta; -#ifdef MYROOT1 - delete heta; - delete hhx; - delete hhy; - heta=new TH2D("heta","heta",nbeta,etamin,etamax,nbeta,etamin,etamax); - hhx=new TH2D("hhx","hhx",nbeta,etamin,etamax,nbeta,etamin,etamax); - hhy=new TH2D("hhy","hhy",nbeta,etamin,etamax,nbeta,etamin,etamax); -#endif -#ifndef MYROOT1 - delete [] heta; - delete [] hhx; - delete [] hhy; - - heta=new int[nbeta*nbeta]; - hhx=new float[nbeta*nbeta]; - hhy=new float[nbeta*nbeta]; - -#endif - // cout << nbeta << " " << etamin << " " << etamax << endl; -}; - - eta3InterpolationBase(eta3InterpolationBase *orig): etaInterpolationBase(orig){ }; - - virtual eta3InterpolationBase* Clone()=0; - - - - - // virtual void prepareInterpolation(int &ok){}; - - - ////////////////////////////////////////////////////////////////////////////// - //////////// /*It return position hit for the event in input */ ////////////// - virtual void getInterpolatedPosition(int x, int y, int *data, double &int_x, double &int_y) - { - double tot, totquad; - double etax,etay; - - int corner=calcEta3(data,etax,etay, totquad); - - getInterpolatedPosition(x,y,etax,etay,corner,int_x,int_y); - - return; - }; - - - virtual void getInterpolatedPosition(int x, int y, double *data, double &int_x, double &int_y) - { - double sDum[2][2]; - double tot, totquad; - double etax,etay; - - int corner=calcEta3(data,etax,etay, totquad); - - getInterpolatedPosition(x,y,etax,etay,corner,int_x,int_y); - - return; - }; - - - virtual void getInterpolatedPosition(int x, int y, double totquad,int quad,double *cl,double &int_x, double &int_y) { - - - double etax, etay; - if (nSubPixels>2) { - calcEta3(cl,etax,etay, totquad); - } - return getInterpolatedPosition(x,y,etax, etay,quad,int_x,int_y); - - } - - - - virtual void getInterpolatedPosition(int x, int y, double totquad,int quad,int *cl,double &int_x, double &int_y) { - - - double etax, etay; - if (nSubPixels>2) { - calcEta3(cl,etax,etay, totquad); - } - return getInterpolatedPosition(x,y,etax, etay,quad,int_x,int_y); - - } - - - - virtual void getInterpolatedPosition(int x, int y, double etax, double etay, int corner, double &int_x, double &int_y) - { - - - double xpos_eta=0,ypos_eta=0; - int ex,ey; - - if (nSubPixels>2) { - -#ifdef MYROOT1 - xpos_eta=(hhx->GetBinContent(hhx->GetXaxis()->FindBin(etax),hhy->GetYaxis()->FindBin(etay)))/((double)nSubPixels); - ypos_eta=(hhy->GetBinContent(hhx->GetXaxis()->FindBin(etax),hhy->GetYaxis()->FindBin(etay)))/((double)nSubPixels); -#endif -#ifndef MYROOT1 - ex=(etax-etamin)/etastep; - ey=(etay-etamin)/etastep; - if (ex<0) { - /* cout << etax << " " << etamin << " "; */ - /* cout << "3x*"<< ex << endl; */ - ex=0; - } - if (ex>=nbeta) { - /* cout << etax << " " << etamin << " "; */ - /* cout << "3x?"<< ex << endl; */ - ex=nbeta-1; - } - if (ey<0) { - /* cout << etay << " " << etamin << " "; */ - /* cout << "3y*"<< ey << endl; */ - ey=0; - } - if (ey>=nbeta) { - /* cout << etay << " " << etamin << " "; */ - /* cout << "3y?"<< ey << endl; */ - ey=nbeta-1; - - } - xpos_eta=(((double)hhx[(ey*nbeta+ex)]));///((double)nSubPixels); - ypos_eta=(((double)hhy[(ey*nbeta+ex)]));///((double)nSubPixels); - -#endif - - } else { - switch (corner) { - case BOTTOM_LEFT: - xpos_eta=-0.25; - ypos_eta=-0.25; - break; - case BOTTOM_RIGHT: - xpos_eta=0.25; - ypos_eta=-0.25; - break; - case TOP_LEFT: - xpos_eta=-0.25; - ypos_eta=0.25; - break; - case TOP_RIGHT: - xpos_eta=0.25; - ypos_eta=0.25; - break; - default: - xpos_eta=0; - ypos_eta=0; - } - - } - int_x=((double)x) + xpos_eta; - int_y=((double)y) + ypos_eta; - // int_x=5. + xpos_eta; - // int_y=5. + ypos_eta; - - - } - - - - - - -/* ///////////////////////////////////////////////////////////////////////////////////////////////// */ -/* virtual void getPositionETA3(int x, int y, double *data, double &int_x, double &int_y) */ -/* { */ -/* double sDum[2][2]; */ -/* double tot, totquad; */ -/* double eta3x,eta3y; */ -/* double ex,ey; */ - -/* calcQuad(data, tot, totquad, sDum); */ -/* calcEta3(data,eta3x, eta3y,tot); */ - -/* double xpos_eta,ypos_eta; */ - -/* #ifdef MYROOT1 */ -/* xpos_eta=((hhx->GetBinContent(hhx->GetXaxis()->FindBin(eta3x),hhy->GetYaxis()->FindBin(eta3y))))/((double)nSubPixels); */ -/* ypos_eta=((hhy->GetBinContent(hhx->GetXaxis()->FindBin(eta3x),hhy->GetYaxis()->FindBin(eta3y))))/((double)nSubPixels); */ - -/* #endif */ -/* #ifndef MYROOT1 */ -/* ex=(eta3x-etamin)/etastep; */ -/* ey=(eta3y-etamin)/etastep; */ - -/* if (ex<0) ex=0; */ -/* if (ex>=nbeta) ex=nbeta-1; */ -/* if (ey<0) ey=0; */ -/* if (ey>=nbeta) ey=nbeta-1; */ - -/* xpos_eta=(((double)hhx[(int)(ey*nbeta+ex)]))/((double)nSubPixels); */ -/* ypos_eta=(((double)hhy[(int)(ey*nbeta+ex)]))/((double)nSubPixels); */ -/* #endif */ - -/* int_x=((double)x) + xpos_eta; */ -/* int_y=((double)y) + ypos_eta; */ - -/* return; */ -/* }; */ - - virtual int addToFlatField(double totquad,int quad,int *cl,double &etax, double &etay) { - - calcEta3(cl, etax, etay, totquad); - return addToFlatField(etax,etay); - } - - virtual int addToFlatField(double totquad,int quad,double *cl,double &etax, double &etay) { - - - calcEta3(cl, etax, etay, totquad); - return addToFlatField(etax,etay); - } - - - - ////////////////////////////////////////////////////////////////////////////////////// - virtual int addToFlatField(double *cluster, double &etax, double &etay){ - double totquad; - calcEta3(cluster, etax, etay, totquad); - return addToFlatField(etax,etay); - - }; - - virtual int addToFlatField(int *cluster, double &etax, double &etay){ - - double totquad; - - calcEta3(cluster, etax, etay, totquad); - return addToFlatField(etax,etay); - - }; - - - virtual int addToFlatField(double etax, double etay){ -#ifdef MYROOT1 - heta->Fill(etax,etay); -#endif -#ifndef MYROOT1 - int ex,ey; - ex=(etax-etamin)/etastep; - ey=(etay-etamin)/etastep; - if (ey=0 && ey>=0) - heta[ey*nbeta+ex]++; -#endif - return 0; - }; - - -/* protected: */ - -/* #ifdef MYROOT1 */ -/* TH2D *heta; */ -/* TH2D *hhx; */ -/* TH2D *hhy; */ -/* #endif */ -/* #ifndef MYROOT1 */ -/* int *heta; */ -/* float *hhx; */ -/* float *hhy; */ -/* #endif */ -/* int nbeta; */ -/* double etamin, etamax, etastep; */ - -}; - -#endif diff --git a/slsDetectorCalibration/interpolations/etaInterpolationAdaptiveBins.h b/slsDetectorCalibration/interpolations/etaInterpolationAdaptiveBins.h deleted file mode 100644 index 3a785f8f2..000000000 --- a/slsDetectorCalibration/interpolations/etaInterpolationAdaptiveBins.h +++ /dev/null @@ -1,281 +0,0 @@ -#ifndef ETA_INTERPOLATION_ADAPTIVEBINS_H -#define ETA_INTERPOLATION_ADAPTIVEBINS_H - - -#include "tiffIO.h" -//#include "etaInterpolationBase.h" -#include "etaInterpolationPosXY.h" - -class etaInterpolationAdaptiveBins : public etaInterpolationPosXY { - - private: - double calcDiff(double avg, float *hx, float *hy) { - double p_tot=0; - double diff=0; - double bsize=1./nSubPixels; - - for (int ipx=0; ipx=((ipx)*bsize) && hx[ibx+iby*nbeta]<((ipx+1)*bsize) && hy[ibx+iby*nbeta]>=((ipy)*bsize) && hy[ibx+iby*nbeta]<((ipy+1)*bsize)) { - p_tot+=heta[ibx+iby*nbeta]; - } - } - } - - cout << p_tot << " \t "; - - - - diff+=(p_tot-avg)*(p_tot-avg); - - } - cout << "\n"; - } - return diff; - } - - void iterate(float *newhhx, float *newhhy) { - - double bsize=1./nSubPixels; - - double hy[nbeta]; //profile y - double hx[nbeta]; //profile x - double hix[nbeta]; //integral of projection x - double hiy[nbeta]; //integral of projection y - - double tot_eta_x=0; - double tot_eta_y=0; - for (int ipy=0; ipy=((ipy)*bsize) && hhy[ibx+iby*nbeta]<=((ipy+1)*bsize)) { - hx[ibx]+=heta[ibx+iby*nbeta]; - tot_eta_x+=heta[ibx+iby*nbeta]; - } - - - if (hhx[ibx+iby*nbeta]>=((ipy)*bsize) && hhx[ibx+iby*nbeta]<=((ipy+1)*bsize)) { - hy[iby]+=heta[ibx+iby*nbeta]; - tot_eta_y+=heta[ibx+iby*nbeta]; - } - } - } - - - hix[0]=hx[0]; - hiy[0]=hy[0]; - for (int ib=1; ib=((ipy)*bsize) && hhy[ibx+iby*nbeta]<=((ipy+1)*bsize)) { - newhhx[ibx+iby*nbeta]=hix[ibx]/((double)tot_eta_x); - if (newhhx[ibx+iby*nbeta]>1) cout << "***"<< ibx << " " << iby << newhhx[ibx+iby*nbeta] << endl; - // if (ipy==3 && ibx==10) cout << newhhx[ibx+iby*nbeta] << " " << hix[ibx] << " " << ibx+iby*nbeta << endl; - } - if (hhx[ibx+iby*nbeta]>=((ipy)*bsize) && hhx[ibx+iby*nbeta]<=((ipy+1)*bsize)) { - newhhy[ibx+iby*nbeta]=hiy[iby]/((double)tot_eta_y); - if (newhhy[ibx+iby*nbeta]>1) cout << "***"<< ibx << " " << iby << newhhy[ibx+iby*nbeta] << endl; - // if (ipy==3 && iby==10) cout << newhhy[ibx+iby*nbeta] << " " << hiy[iby] << " " << ibx+iby*nbeta << endl; - } - } - } - } - - - } - - - public: - etaInterpolationAdaptiveBins(int nx=400, int ny=400, int ns=25, int nb=-1, double emin=1, double emax=0) : etaInterpolationPosXY(nx,ny,ns, nb, emin,emax){}; - - etaInterpolationAdaptiveBins(etaInterpolationAdaptiveBins *orig): etaInterpolationPosXY(orig){}; - - virtual etaInterpolationAdaptiveBins* Clone() { - - return new etaInterpolationAdaptiveBins(this); - - }; - - - - virtual void prepareInterpolation(int &ok) - { - ok=1; - cout << "Adaptive bins" << endl; - - ///*Eta Distribution Rebinning*/// - double bsize=1./nSubPixels; //precision - // cout<<"nPixelsX = "<1 || etah[ii]<0 ) cout << "***"<< ii << etah[ii] << endl; */ -/* } */ -/* sprintf(tit,"/scratch/neweta_hhy_%d.tiff",iint); */ -/* WriteToTiff(etah, tit, etabins, etabins); */ -/* #endif */ - if (new_diff -#include -#include -#include -#endif - -#include "slsInterpolation.h" -#include "tiffIO.h" - -class etaInterpolationBase : public slsInterpolation { - - public: - - etaInterpolationBase(int nx=400, int ny=400, int ns=25, int nb=-1, double emin=1, double emax=0) : slsInterpolation(nx,ny,ns), hhx(NULL), hhy(NULL), heta(NULL), nbeta(nb), etamin(emin), etamax(emax) { - // cout << "eb " << nb << " " << emin << " " << emax << endl; - // cout << nb << " " << etamin << " " << etamax << endl; - if (nbeta<=0) { - cout << "aaa:" <=etamax) { - cout << "aaa:" <nbeta; - etamin=orig->etamin; - etamax=orig->etamax; - - etastep=(etamax-etamin)/nbeta; -#ifdef MYROOT1 - heta=(TH2D*)(orig->heta)->Clone("heta"); - hhx=(TH2D*)(orig->hhx)->Clone("hhx"); - hhy=(TH2D*)(orig->hhy)->Clone("hhy"); -#endif - -#ifndef MYROOT1 - heta=new int[nbeta*nbeta]; - memcpy(heta,orig->heta,nbeta*nbeta*sizeof(int)); - hhx=new float[nbeta*nbeta]; - memcpy(hhx,orig->hhx,nbeta*nbeta*sizeof(float)); - hhy=new float[nbeta*nbeta]; - memcpy(hhy,orig->hhy,nbeta*nbeta*sizeof(float)); - -#endif - - - }; - - virtual etaInterpolationBase* Clone()=0;/*{ - return new etaInterpolationBase(this); - }; - */ - - - -#ifdef MYROOT1 - TH2D *setEta(TH2D *h, int nb=-1, double emin=1, double emax=0) - { - if (h) { heta=h; - nbeta=heta->GetNbinsX(); - etamin=heta->GetXaxis()->GetXmin(); - etamax=heta->GetXaxis()->GetXmax(); - etastep=(etamax-etamin)/nbeta; - } - return heta; - }; - TH2D *setFlatField(TH2D *h, int nb=-1, double emin=1, double emax=0) - { - return setEta(h, nb, emin, emax); - }; - - TH2D *getFlatField(){return setEta(NULL);}; -#endif - -#ifndef MYROOT1 - int *setEta(int *h, int nb=-1, double emin=1, double emax=0) - { - if (h) { - if (heta) delete [] heta; - heta=h; - nbeta=nb; - if (nb<=0) nbeta=nSubPixels*10; - etamin=emin; - etamax=emax; - if (etamin>=etamax) { - etamin=-1; - etamax=2; - } - etastep=(etamax-etamin)/nbeta; - } - return heta; - }; - - int *setFlatField(int *h, int nb=-1, double emin=1, double emax=0) - { - return setEta(h, nb, emin, emax); - }; - int *getFlatField(){return setEta(NULL);}; - - int *getFlatField(int &nb, double &emin, double &emax){ - nb=nbeta; - //cout << "igff* ff has " << nb << " bins " << endl; - emin=etamin; - emax=etamax; - return getFlatField(); - }; - - - void *writeFlatField(const char * imgname) { - float *gm=NULL; - gm=new float[nbeta*nbeta]; - for (int ix=0; ix=1) etamax=emax; - if (emin<=0) etamin=emin; - - if (etamin>=etamax) { - etamin=-1; - etamax=2; - } - - etastep=(etamax-etamin)/nbeta; - uint32 nnx; - uint32 nny; - float *gm=ReadFromTiff(imgname, nnx, nny); - if (nnx!=nny) { - cout << "different number of bins in x " << nnx << " and y " << nny<< " !"<< endl; - cout << "Aborting read"<< endl; - return 0; - } - nbeta=nnx; - if (gm) { - if (heta) { - delete [] heta; - delete [] hhx; - delete [] hhy; - } - - heta=new int[nbeta*nbeta]; - hhx=new float[nbeta*nbeta]; - hhy=new float[nbeta*nbeta]; - - for (int ix=0; ixScale((double)nSubPixels); - return hhx; - }; - - TH2D *gethhy() - { - hhy->Scale((double)nSubPixels); - return hhy; - }; -#endif - -#ifndef MYROOT1 -float *gethhx() - { - // hhx->Scale((double)nSubPixels); - return hhx; - }; - - float *gethhy() - { - // hhy->Scale((double)nSubPixels); - return hhy; - }; -#endif - - ////////////////////////////////////////////////////////////////////////////// - //////////// /*It return position hit for the event in input */ ////////////// - /* virtual void getInterpolatedPosition(int x, int y, int *data, double &int_x, double &int_y)=0; */ - /* virtual void getInterpolatedPosition(int x, int y, double *data, double &int_x, double &int_y)=0; */ - /* virtual void getInterpolatedPosition(int x, int y, double totquad,int quad,double *cl,double &int_x, double &int_y)=0; */ - /* virtual void getInterpolatedPosition(int x, int y, double totquad,int quad,int *cl,double &int_x, double &int_y)=0; */ - /* virtual void getInterpolatedPosition(int x, int y, double etax, double etay, int corner, double &int_x, double &int_y)=0; */ - - - /* virtual int addToFlatField(double totquad,int quad,int *cl,double &etax, double &etay)=0; */ - /* virtual int addToFlatField(double totquad,int quad,double *cl,double &etax, double &etay)=0; */ - /* virtual int addToFlatField(double *cluster, double &etax, double &etay)=0; */ - /* virtual int addToFlatField(int *cluster, double &etax, double &etay)=0; */ - - virtual int addToFlatField(double etax, double etay){ -#ifdef MYROOT1 - heta->Fill(etax,etay); -#endif -#ifndef MYROOT1 - int ex,ey; - ex=(etax-etamin)/etastep; - ey=(etay-etamin)/etastep; - if (ey=0 && ey>=0) - heta[ey*nbeta+ex]++; -#endif - return 0; - }; - - - // virtual void prepareInterpolation(int &ok)=0; - - protected: - -#ifdef MYROOT1 - TH2D *heta; - TH2D *hhx; - TH2D *hhy; -#endif -#ifndef MYROOT1 - int *heta; - float *hhx; - float *hhy; -#endif - int nbeta; - double etamin, etamax, etastep; - -}; - -#endif diff --git a/slsDetectorCalibration/interpolations/etaInterpolationGlobal.h b/slsDetectorCalibration/interpolations/etaInterpolationGlobal.h deleted file mode 100644 index 615b7c04b..000000000 --- a/slsDetectorCalibration/interpolations/etaInterpolationGlobal.h +++ /dev/null @@ -1,85 +0,0 @@ -#ifndef ETA_INTERPOLATION_GLOBAL_H -#define ETA_INTERPOLATION_GLOBAL_H - - -#include "etaInterpolationBase.h" - -class etaInterpolationGlobal : public etaInterpolationBase{ - public: - globalEtaInterpolation(int nx=400, int ny=400, int ns=25, int nb=-1, double emin=1, double emax=0) : etaInterpolationBase(nx,ny,ns, nb, emin,emax){}; - - - - virtual void prepareInterpolation(int &ok) - { - ok=1; -#ifdef MYROOT1 - if (hhx) delete hhx; - if (hhy) delete hhy; - - hhx=new TH2D("hhx","hhx",heta->GetNbinsX(),heta->GetXaxis()->GetXmin(),heta->GetXaxis()->GetXmax(), heta->GetNbinsY(),heta->GetYaxis()->GetXmin(),heta->GetYaxis()->GetXmax()); - hhy=new TH2D("hhy","hhy",heta->GetNbinsX(),heta->GetXaxis()->GetXmin(),heta->GetXaxis()->GetXmax(), heta->GetNbinsY(),heta->GetYaxis()->GetXmin(),heta->GetYaxis()->GetXmax()); - -#endif - - - ///*Eta Distribution Rebinning*/// - double bsize=1./nSubPixels; //precision - // cout<<"nPixelsX = "<(ib+1)*tot_eta*bsize) ib++; - for (int iby=0; ibySetBinContent(ibx+1,iby+1,ib); -#endif -#ifndef MYROOT1 - hhx[ibx+iby*nbeta]=ib; -#endif - } - } - ib=0; - for (int iby=0; iby(ib+1)*tot_eta*bsize) ib++; - for (int ibx=0; ibxSetBinContent(ibx+1,iby+1,ib); -#endif -#ifndef MYROOT1 - hhy[ibx+iby*nbeta]=ib; -#endif - } - } - - return ; - }; - -}; - -#endif diff --git a/slsDetectorCalibration/interpolations/etaInterpolationPosXY.h b/slsDetectorCalibration/interpolations/etaInterpolationPosXY.h deleted file mode 100644 index 7730771cd..000000000 --- a/slsDetectorCalibration/interpolations/etaInterpolationPosXY.h +++ /dev/null @@ -1,173 +0,0 @@ -#ifndef ETA_INTERPOLATION_POSXY_H -#define ETA_INTERPOLATION_POSXY_H - - -//#include "tiffIO.h" -#include "etaInterpolationBase.h" -#include "eta2InterpolationBase.h" -#include "eta3InterpolationBase.h" - -class etaInterpolationPosXY : public virtual etaInterpolationBase{ - public: - etaInterpolationPosXY(int nx=400, int ny=400, int ns=25, int nb=-1, double emin=1, double emax=0) : etaInterpolationBase(nx,ny,ns, nb, emin,emax){ - // cout << "epxy " << nb << " " << emin << " " << emax << endl; cout << nbeta << " " << etamin << " " << etamax << endl; - }; - - etaInterpolationPosXY(etaInterpolationPosXY *orig): etaInterpolationBase(orig) {}; - - virtual etaInterpolationPosXY* Clone()=0; /* { */ - - /* return new etaInterpolationPosXY(this); */ - - /* }; */ - - virtual void prepareInterpolation(int &ok) - { - ok=1; -#ifdef MYROOT1 - if (hhx) delete hhx; - if (hhy) delete hhy; - - hhx=new TH2D("hhx","hhx",heta->GetNbinsX(),heta->GetXaxis()->GetXmin(),heta->GetXaxis()->GetXmax(), heta->GetNbinsY(),heta->GetYaxis()->GetXmin(),heta->GetYaxis()->GetXmax()); - hhy=new TH2D("hhy","hhy",heta->GetNbinsX(),heta->GetXaxis()->GetXmin(),heta->GetXaxis()->GetXmax(), heta->GetNbinsY(),heta->GetYaxis()->GetXmin(),heta->GetYaxis()->GetXmax()); - -#endif - - - ///*Eta Distribution Rebinning*/// - double bsize=1./nSubPixels; //precision - // cout<<"nPixelsX = "<(ii+1)*tot_eta_x*bsize) - { - //ii++; - // cout << ib << " x " << ibx << " " << tot_eta_x << " " << (ii)*tot_eta_x*bsize << " " << ii << endl; - // } -#ifdef MYROOT1 - hhx->SetBinContent(ibx+1,ib+1,ii); -#endif -#ifndef MYROOT1 - hhx[ibx+ib*nbeta]=hix[ibx]/((float)tot_eta_x);//ii; -#endif - } - } - /* if (ii!=(nSubPixels-1)) */ - /* cout << ib << " x " << tot_eta_x << " " << (ii+1)*tot_eta_x*bsize << " " << ii << " " << hix[nbeta-1]<< endl; */ - - ii=0; - - for (int ibx=0; ibx(ii+1)*tot_eta_y*bsize) - { - //ii++; - //cout << ib << " y " << ibx << " " << tot_eta_y << " "<< (ii)*tot_eta_y*bsize << " " << ii << endl; - //} -#ifdef MYROOT1 - hhy->SetBinContent(ib+1,ibx+1,ii); -#endif -#ifndef MYROOT1 - hhy[ib+ibx*nbeta]=hiy[ibx]/((float)tot_eta_y);//ii; -#endif - } - } - /* if (ii!=(nSubPixels-1)) */ - /* cout << ib << " y " << tot_eta_y << " " << (ii+1)*tot_eta_y*bsize << " " << ii << " " << hiy[nbeta-1]<< endl; */ - - // cout << "y " << nbeta << " " << (ii+1)*tot_eta_x*bsize << " " << ii << endl; - - } - -#ifdef SAVE_ALL - char tit[10000]; - - float *etah=new float[nbeta*nbeta]; - int etabins=nbeta; - - for (int ii=0; ii -#include -//#include -#include // std::abs - -#define PI 3.14159265 -#define TWOPI 2.*PI - -using namespace std; - -class etaInterpolationRandomBins : public etaInterpolationPosXY { - - private: - double calcDiff(double avg, float *hx, float *hy) { - double p_tot=0; - double diff=0; - double bsize=1./nSubPixels; - - for (int ipx=0; ipx=((ipx)*bsize) && hx[ibx+iby*nbeta]<((ipx+1)*bsize) && hy[ibx+iby*nbeta]>=((ipy)*bsize) && hy[ibx+iby*nbeta]<((ipy+1)*bsize)) { - p_tot+=heta[ibx+iby*nbeta]; - } - } - } - - // cout << p_tot << " \t "; - - - - diff+=(p_tot-avg)*(p_tot-avg); - - } - // cout << "\n"; - } - return diff; - } - - double iterate(float *newhhx, float *newhhy, double avg) { - - double bsize=1./nSubPixels; - - double hy[nbeta]; //profile y - double hx[nbeta]; //profile x - double hix[nbeta]; //integral of projection x - double hiy[nbeta]; //integral of projection y - - double tot_eta_x=0; - double tot_eta_y=0; - - int p0; - int vx[(nSubPixels+1)*(nSubPixels+1)], vy[(nSubPixels+1)*(nSubPixels+1)]; - - int arrx[nSubPixels+1], arry[nSubPixels+1]; - - int bad=1; - - - int isby, isbx; - int ii=0; - - - // using default comparison (operator <): - // std::sort (myvector.begin(), myvector.begin()+4); //(12 32 45 71)26 80 53 33 - - for (isby=0; isby<(nSubPixels+1)/2+1; isby++) { - - for (isbx=0; isbx<(nSubPixels+1)/2+1; isbx++) { - p0=isby*(nSubPixels+1)+isbx; - // for (int iv=0; iv<(nSubPixels+1)*(nSubPixels+1); iv++) { - if (isbx==0) { - vy[p0]=isby*nbeta/nSubPixels; - vx[p0]=0; - } else if ( isby==0 ) { - vy[p0]=0; - vx[p0]=isbx*nbeta/nSubPixels; - } - else { - vy[p0]=rand()%(nbeta/2); - vx[p0]=rand()%(nbeta/2); - if (nSubPixels%2==0 && isbx==nSubPixels/2) - vx[p0]=nbeta/2; - if (nSubPixels%2==0 && isby==nSubPixels/2 ) - vy[p0]=nbeta/2; - } - // cout << "(" << vx[p0] << " , " << vy[p0] << " ) \t" ; - // } - } - //cout << endl; - } - // cout << "rand" << endl; - - - while (bad) { - - for (isby=0; isby<(nSubPixels+1)/2+1; isby++) { - - - for (isbx=0; isbx<(nSubPixels+1)/2+1; isbx++) { - arrx[isbx]=vx[isby*(nSubPixels+1)+isbx]; - arry[isbx]=vy[isbx*(nSubPixels+1)+isby]; - //cout << isbx << " " << arrx[isbx] << " " << isby << " " << arry[isbx] << endl; - } - - sort(arrx,arrx+(nSubPixels+1)/2+1); - sort(arry,arry+(nSubPixels+1)/2+1); - - // cout << "*****"<< endl; - // cout << endl; - - for (int isbx=0; isbx<(nSubPixels+1)/2+1; isbx++) { - vx[isby*(nSubPixels+1)+isbx]=arrx[isbx]; - vy[isbx*(nSubPixels+1)+isby]=arry[isbx]; - - - vx[(nSubPixels-isby)*(nSubPixels+1)+(nSubPixels-isbx)]=nbeta-arrx[isbx]; - vy[(nSubPixels-isbx)*(nSubPixels+1)+(nSubPixels-isby)]=nbeta-arry[isbx]; - - vx[isby*(nSubPixels+1)+(nSubPixels-isbx)]=nbeta-arrx[isbx]; - vy[isbx*(nSubPixels+1)+(nSubPixels-isby)]=arry[isbx]; - - - vx[(nSubPixels-isby)*(nSubPixels+1)+(isbx)]=arrx[isbx]; - vy[(nSubPixels-isbx)*(nSubPixels+1)+(isby)]=nbeta-arry[isbx]; - - - } - - - - } - - /* for (isby=0; isbynSubPixels-1) isbx=nSubPixels-1; */ - - /* if (iby==0) */ - /* isby=0; */ - /* else */ - /* isby= (newhhx[ibx+(iby-1)*nbeta])/bsize-1; */ - - /* if (isby<0) isbx=0; */ - /* if (isby>nSubPixels-1) isby=nSubPixels-1; */ - /* // cout << isbx << " " << isby << endl; */ - - for (isby=0; isby PI) - dtheta -= TWOPI; - while (dtheta < -PI) - dtheta += TWOPI; - - angle += dtheta; - } - - if (abs((double)angle) < PI) - in_quad=0; - else - in_quad=1; - - if (in_quad) { - newhhx[ibx+iby*nbeta]=bsize*((double)isbx); - newhhy[ibx+iby*nbeta]=bsize*((double)isby); - break; - } - - - - - } - if (in_quad) break; - } - - } - } - - // cout << "hist" << endl; - return calcDiff(avg, newhhx, newhhy); - } - - - public: - etaInterpolationRandomBins(int nx=400, int ny=400, int ns=25, int nb=-1, double emin=1, double emax=0) : etaInterpolationPosXY(nx,ny,ns, nb, emin,emax){}; - - etaInterpolationRandomBins(etaInterpolationRandomBins *orig): etaInterpolationPosXY(orig){}; - - virtual etaInterpolationRandomBins* Clone() { - - return new etaInterpolationRandomBins(this); - - }; - - - - virtual void prepareInterpolation(int &ok) - { - ok=1; - cout << "Adaptive bins" << endl; - - ///*Eta Distribution Rebinning*/// - double bsize=1./nSubPixels; //precision - // cout<<"nPixelsX = "<1 || etah[ii]<0 ) cout << "***"<< ii << etah[ii] << endl; */ -/* } */ -/* sprintf(tit,"/scratch/randeta_hhx_%d.tiff",iint); */ -/* WriteToTiff(etah, tit, etabins, etabins); */ - -/* for (int ii=0; ii1 || etah[ii]<0 ) cout << "***"<< ii << etah[ii] << endl; */ -/* } */ -/* sprintf(tit,"/scratch/randeta_hhy_%d.tiff",iint); */ -/* WriteToTiff(etah, tit, etabins, etabins); */ -/* #endif */ - - if (new_diff -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "EtaVEL.h" -#include "EtaVEL.cpp" -/* -Zum erstellen der correction map ist createGainAndEtaFile(...) in EVELAlg.C der entry point. -Zum erstellen des HR images ist createImage(...) der entry point. -*/ -int etabins = 25; -int nEtas = 25; -Double_t dum[3][3]; -Int_t x,y,f,q; - -int counter[5]; -int remoteCounter[5]; - -//TH2D *sum = new TH2D("sum","sum",3,-0.1,2.1,3,-0.1,2.1); -//TH2F *subPos = new TH2F("subPos","subPos", 100, -1.,1. ,100, -1.,1.); -TH2D *subPosAEta = new TH2D("subPosAEta","subPosAEta", 50, -.5,1.5 ,50, -.5,1.5); -TH2D *subPosBEta = new TH2D("subPosBEta","subPosBEta", 50, -.5,1.5 ,50, -.5,1.5); - - - -TH1D *cE = new TH1D("clusterEnergy","clusterEnergy",400, 0.,4000.); -//TH1D *cES = new TH1D("clusterEnergyS","clusterEnergyS",400, 0.,4000.); - - -TH2D *cES3vs2 = new TH2D("clusterEnergy3vs2","clusterEnergy3vs2",800, 0.,8000.,600,0.,6000.); -TH2D *cES3vs2S = new TH2D("clusterEnergy3vs2S","clusterEnergy3vs2S",800, 0.,8000.,600,0.,6000.); - -double th = 0.99; -double sigmas = 1.0; - -TH2D *imgRLR = new TH2D("imgRLR","imgRLR",160,0.0,160.0 ,160 ,0.0,160.0); -TH2D *imgLR = new TH2D("imgLR","imgLR",160*2,0.0,160.0 ,160*2 ,0.0,160.0); - -TH2D *clusHist= new TH2D("clusHist","clusHist",3,-0.5,2.5,3,-0.5,2.5); -TH2D *clusHistC= new TH2D("clusHistC","clusHistC",3,-0.5,2.5,3,-0.5,2.5); - -int **imgArray; - -int findShape(Double_t cluster[3][3], double sDum[2][2]){ - int corner = -1; - - double sum = cluster[0][0] + cluster[1][0] + cluster[2][0] + cluster[0][1] + cluster[1][1] + cluster[2][1] + cluster[0][2] + cluster[1][2] + cluster[2][2]; - - double sumTL = cluster[0][0] + cluster[1][0] + cluster[0][1] + cluster[1][1]; //2 ->BL - double sumTR = cluster[1][0] + cluster[2][0] + cluster[2][1] + cluster[1][1]; //0 ->TL - double sumBL = cluster[0][1] + cluster[0][2] + cluster[1][2] + cluster[1][1]; //3 ->BR - double sumBR = cluster[1][2] + cluster[2][1] + cluster[2][2] + cluster[1][1]; //1 ->TR - double sumMax = 0; - - - //double **sDum = subCluster; - Double_t ssDum[2][2]; - - // if(sumTL >= sumMax){ - sDum[0][0] = cluster[0][0]; sDum[1][0] = cluster[1][0]; - sDum[0][1] = cluster[0][1]; sDum[1][1] = cluster[1][1]; - - ssDum[0][0] = cluster[0][0]; ssDum[1][0] = cluster[0][1]; - ssDum[0][1] = cluster[1][0]; ssDum[1][1] = cluster[1][1]; - - corner = 2; - sumMax=sumTL; - // } - - if(sumTR >= sumMax){ - sDum[0][0] = cluster[1][0]; sDum[1][0] = cluster[2][0]; - sDum[0][1] = cluster[1][1]; sDum[1][1] = cluster[2][1]; - - ssDum[0][0] = cluster[2][0]; ssDum[1][0] = cluster[2][1]; - ssDum[0][1] = cluster[1][0]; ssDum[1][1] = cluster[1][1]; - - corner = 0; - sumMax=sumTR; - } - - if(sumBL >= sumMax){ - sDum[0][0] = cluster[0][1]; sDum[1][0] = cluster[1][1]; - sDum[0][1] = cluster[0][2]; sDum[1][1] = cluster[1][2]; - - ssDum[0][0] = cluster[0][2]; ssDum[1][0] = cluster[0][1]; - ssDum[0][1] = cluster[1][2]; ssDum[1][1] = cluster[1][1]; - - corner = 3; - sumMax=sumBL; - } - - if(sumBR >= sumMax){ - sDum[0][0] = cluster[1][1]; sDum[1][0] = cluster[2][1]; - sDum[0][1] = cluster[1][2]; sDum[1][1] = cluster[2][2]; - - ssDum[0][0] = cluster[2][2]; ssDum[1][0] = cluster[2][1]; - ssDum[0][1] = cluster[1][2]; ssDum[1][1] = cluster[1][1]; - - corner = 1; - sumMax=sumBR; - } - - switch(corner){ - case 0: - cES3vs2->Fill(sum,sumTR); break; - case 1: - cES3vs2->Fill(sum,sumBR); break; - case 2: - cES3vs2->Fill(sum,sumTL); break; - case 3: - cES3vs2->Fill(sum,sumBL); break; - } - - counter[corner]++; - remoteCounter[q]++; - - // cout << "local corner is: " << corner << " remote corner is: " << q << endl; - - return corner; -} - - - - -int placePhoton( TH2D *img, double subCluster[2][2], int cX, int cY, int corner, double *sX, double *sY, double *scX, double *scY){ - double tot = subCluster[0][0] + subCluster[0][1] + subCluster[1][0] + subCluster[1][1]; - double t = subCluster[1][0] + subCluster[1][1]; - double r = subCluster[0][1] + subCluster[1][1]; - - double xHitC = r/tot; - double yHitC = t/tot; - - imgRLR->Fill(cX,cY); - - cE->Fill(tot); - - double dX, dY; - - //before looking at annas code - /* if(corner == 0){ dX=-1.; dY=-1.; } - if(corner == 1){ dX=-1.; dY=+1.; } - if(corner == 2){ dX=+1.; dY=-1.; } - if(corner == 3){ dX=+1.; dY=+1.; }*/ - - if(corner == 0){ dX=-1.; dY=+1.; } //top left - if(corner == 1){ dX=+1.; dY=+1.; } //top right - if(corner == 2){ dX=-1.; dY=-1.; } //bottom left - if(corner == 3){ dX=+1.; dY=-1.; } //bottom right - - imgLR->Fill(cX+0.25*dX,cY+0.25*dY); - - double posX = ((double)cX) + 0.5*dX + xHitC; - double posY = ((double)cY) + 0.5*dY + yHitC; - - subPosBEta->Fill(xHitC ,yHitC); - if(img){ - img->Fill(posX,posY); - } - - if(xHitC < 0.02&& yHitC < 0.02){ - - cES3vs2S->Fill(dum[0][0]+dum[0][1]+dum[0][2]+dum[1][0]+dum[1][1]+dum[1][2]+dum[2][0]+dum[2][1]+dum[2][2],subCluster[0][0]+subCluster[0][1]+subCluster[1][0]+subCluster[1][1]); - } - - - if(sX && sY && scX && scY){ - *sX = xHitC; //0.5 + 0.5*dX + xHitC; - *sY = yHitC; //0.5 + 0.5*dY + yHitC; - *scX = ((double)cX) + 0.5*dX; - *scY = ((double)cY) + 0.5*dY; - } - return 1; -} - - - -void placePhotonCorr(TH2D *img, EtaVEL *e,double sX, double sY, double scX, double scY){ - int bin = e->findBin(sX,sY); - if(bin <= 0) return; - double subX = ((double)(e->getXBin(bin))+.5)/((double)e->getNPixels()); - double subY = ((double)(e->getYBin(bin))+.5)/((double)e->getNPixels()); - - if(img!=NULL){ - img->Fill(scX+ subX , scY+ subY); - } - subPosAEta->Fill(subX,subY); - - int iscx = scX; - int iscy = scY; - if(iscx >=nx || iscx<0 || iscy >=ny || iscy<0) return; - //cout << iscx*e->getNPixels()+e->getXBin(bin) << " " << iscy*e->getNPixels()+e->getXBin(bin) << endl; - if(img==NULL) return; - imgArray[iscx*e->getNPixels()+e->getXBin(bin)][iscy*e->getNPixels()+e->getYBin(bin)]++; -} - -void gainCorrection(Double_t corrected[3][3], TH2D *gainMap){ - - for(int xx = 0; xx < 3; xx++) - for(int yy = 0; yy < 3; yy++){ - if(gainMap && gainMap->GetBinContent(x+xx+2,y+yy+2) != 0){ - corrected[xx][yy] = dum[xx][yy] / gainMap->GetBinContent(x+xx+2,y+yy+2); - clusHistC->Fill(xx,yy,corrected[xx][yy]); - } - else - corrected[xx][yy] = dum[xx][yy]; - - clusHist->Fill(xx,yy,dum[xx][yy]); - } -} - - -EtaVEL *plotEtaDensity(TChain* tree2, TEntryList *el, EtaVEL *oldEta = NULL, TH2D **img = NULL, TH2D *gainMap=NULL, int nPixels=25) { - - - - EtaVEL *newEta = new EtaVEL(25,-0.02,1.02); - - Long64_t listEntries=el->GetN(); - Long64_t treeEntry; - Long64_t chainEntry; - - Int_t treenum=0; - tree2->SetEntryList(el); - - double gainCorrC[3][3]; - double subCluster[2][2]; - double sX, sY, scX, scY; - - cout << "Events: " << listEntries << endl; - if(oldEta == NULL){ cout << "Old Eta is NULL " << endl; } - for(int i = 0; i<4; i++){ counter[i] = 0; remoteCounter[i] = 0; } - - for (Long64_t il =0; ilGetEntryAndTree(il,treenum); - - chainEntry = treeEntry+tree2->GetTreeOffset()[treenum]; - if (tree2->GetEntry(chainEntry)) { - - gainCorrection(gainCorrC,gainMap); - //cout << gainCorrC[1][1] << endl; - - //finds corner - int corner = findShape(gainCorrC,subCluster); - - int validEvent; - - - if(img){ - validEvent = placePhoton(img[0],subCluster,x,y, corner, &sX, &sY, &scX, &scY); - }else{ - //calc etaX, etaY - validEvent = placePhoton(NULL,subCluster,x,y, corner, &sX, &sY, &scX, &scY); - } - - //fill etavel - newEta->fill(sX,sY); - - - - - if(oldEta && img && img[1]){ - placePhotonCorr(img[1],oldEta, sX,sY, scX, scY); - }else{ - placePhotonCorr(NULL,newEta,sX,sY,scX,scY); - } - - - } - //cout << il << endl; - int ssize = 500000; - if(il % ssize == 0 && il != 0 && oldEta==NULL){ - - cout << " -------------- "<< endl; - newEta->updatePixelPos(); - - - //newEta->resolveSelfIntersect(); - char tit[1000]; - /* TFile *ff = new TFile("/scratch/Spider.root","UPDATE"); - sprintf(tit,"subPosAEta%i",newEta->getIt()); subPosAEta->SetName(tit); - subPosAEta->Write(); subPosAEta->Reset(); - sprintf(tit,"subPosBEta%i",newEta->getIt()); subPosBEta->SetName(tit); - subPosBEta->Write(); subPosBEta->Reset(); - sprintf(tit,"Eta%i",newEta->getIt()); newEta->Write(tit); - ff->Close(); */ - //il = 0; - } - - if(il % ssize == ssize-1){ - double prog = (double)il/(double)listEntries*100.; - cout << prog << "%" << endl; - //if(prog > 19.) return newEta; - if(newEta->converged == 1){ cout << "converged ... " << endl; return newEta; } - } - - } - - cout << "local corners: " ; - for(int i = 0; i<4; i++) cout << i << ": " << counter[i] << " || " ; - cout << endl; - - //cout << "remote corners: " ; - //for(int i = 0; i<4; i++) cout << i << ": " << remoteCounter[i] << " || " ; - //cout << endl; - - return newEta; -} - - - - -TChain *openTree(char *tname, char *fname,double lEc, double hEc, double rms=5., char *chainName=">>thischan"){ - TChain *tree2; - // TH1D **etaDI; - char cut[1000]; - - tree2=new TChain(tname); - tree2->Add(fname); - tree2->Print(); - - //sprintf(cut,"(x<=40) && (data[%d][%d]>%f*rms) && Sum$(data)<%f && Sum$(data)>%f",1,1,rms, hEc, lEc); - // sprintf(cut,"(x<=40) && (data[%d][%d]>%f*rms)",1,1,rms);// && Sum$(data)<%f && Sum$(data)>%f",1,1,rms, hEc, lEc); - sprintf(cut,"(x<=40) && Sum$(data)<%f && Sum$(data)>%f", hEc, lEc); - // sprintf(cut,""); - cout << cut << endl; - - tree2->Draw(chainName, cut, "entrylist"); - - - tree2->SetBranchAddress("iFrame",&f); - tree2->SetBranchAddress("x",&x); - tree2->SetBranchAddress("y",&y); - tree2->SetBranchAddress("data",dum); - //tree2->SetBranchAddress("q",&q); - - cout << "openTree : end" << endl; - return tree2; -} - -EtaVEL *etaDensity(char *tname, char *fname, double lEc = 1000, double hEc=3000, TH2D *gainMap=NULL, int nPixels=25) { - /** open tree and make selection */ - TChain *tree2 = openTree(tname,fname,lEc,hEc); - TEntryList *elist = (TEntryList*)gDirectory->Get("thischan"); - if(elist == NULL) { cout << "could not open tree " << endl; return NULL; } - - EtaVEL *etaDen = plotEtaDensity(tree2,elist,NULL,NULL,gainMap,nPixels); - - - //etaDen->Draw("colz"); - cout << "done" << endl; - - return etaDen; -} - -void interpolate(char *tname, char *fname, EtaVEL *etaDI, double lEc = 1000, double hEc=3000, TH2D *gainMap=NULL) { - - TChain *tree2 = openTree(tname,fname,lEc,hEc,5.,">>intChain"); - TEntryList *elist = (TEntryList*)gDirectory->Get("intChain"); - if(elist == NULL) { cout << "could not open tree " << endl; return; } - - double nPixels = (double)etaDI->getNPixels(); - - TH2D **img = new TH2D*[3]; - img[0] = new TH2D("img","img",nPixels*160,0.0,160.0 ,nPixels*160 ,0.0,160.0); - img[1] = new TH2D("imgE","imgE",nPixels*160,0.0,160.0 ,nPixels*160 ,0.0,160.0); - - int inPixels = etaDI->getNPixels(); - - imgArray = new int*[inPixels*160]; - for(int i = 0; i < inPixels*160; i++){ - imgArray[i] = new int[inPixels*160]; - for(int j = 0; j < inPixels*160; j++){ - imgArray[i][j] = 0; - } - } - - cout << "starting" << endl; - plotEtaDensity(tree2,elist, etaDI,img,gainMap); - - //img->Draw("colz"); -} - - -TH2D *createGainMap(char *tname, char *fname, double lEc = 0,double hEc=10000){ - char name[100]; - TH1D *avgSpec3 = new TH1D("avgSpec3", "avgSpec3",hEc/20,0,hEc); - TH1D ***specs3 = new TH1D**[160]; - TH1D ***specs1 = new TH1D**[160]; - for(int xx = 0; xx < 160; xx++){ - specs3[xx] = new TH1D*[160]; - specs1[xx] = new TH1D*[160]; - for(int yy = 0; yy < 160; yy++){ - sprintf(name,"S3x%iy%i",xx,yy); - specs3[xx][yy] = new TH1D(name,name,hEc/20,0,hEc); - sprintf(name,"S1x%iy%i",xx,yy); - specs1[xx][yy] = new TH1D(name,name,hEc/20,0,hEc); - } - } - - - TChain *tree2 = openTree(tname,fname,0,hEc,5.,">>gainChan"); - TEntryList *elist = (TEntryList*)gDirectory->Get("gainChan"); - if(elist == NULL) { cout << "could not open tree " << endl; return NULL; } - - Long64_t listEntries=elist->GetN(); - Long64_t treeEntry; - Long64_t chainEntry; - - Int_t treenum=0; - tree2->SetEntryList(elist); - - cout << "Events: " << listEntries << endl; - for(int i = 0; i<4; i++) counter[i] = 0; - for (Long64_t il =0; ilGetEntryAndTree(il,treenum); - chainEntry = treeEntry+tree2->GetTreeOffset()[treenum]; - - if (tree2->GetEntry(chainEntry)) { - double sum = 0; - for(int xx = 0; xx < 3; xx++) - for(int yy = 0; yy < 3; yy++) - sum += dum[xx][yy]; - specs3[x][y]->Fill(sum); - specs1[x][y]->Fill(dum[1][1]); - avgSpec3->Fill(sum); - } - } - - TH2D *gainMap3 = new TH2D("gainMap3","gainMap3",160,-0.5,160.-0.5,160,-.5,160.-.5); - TH2D *gainMap1 = new TH2D("gainMap1","gainMap1",160,-0.5,160.-0.5,160,-.5,160.-.5); - for(int xx = 0; xx < 160; xx++){ - for(int yy = 0; yy < 160; yy++){ - TF1 *gf3 = new TF1("gf3","gaus", lEc, hEc); - specs3[xx][yy]->Fit(gf3,"Q"); - double e3 = gf3->GetParameter(1); - gainMap3->Fill(xx,yy,e3); - - TF1 *gf1 = new TF1("gf1","gaus", lEc, hEc); - specs1[xx][yy]->Fit(gf1,"Q"); - double e1 = gf1->GetParameter(1); - gainMap1->Fill(xx,yy,e1); - - } - } - - return gainMap3; -} - -void writeMatlab2DHisto(int xx, int yy,char *outFileName){ - ofstream outFile; - outFile.open (outFileName); - - cout << "create matlab file with " << xx << " xbins and " << yy << " ybins" << endl; - - for(int y = 0; y < yy; y++){ - for(int x = 0; x < xx; x++){ - outFile << imgArray[x][y] << "\t"; - } - outFile << endl; - } - - outFile.close(); -} - -//COMPLETE STUFF - -void createImage(char *tdir, char *tname, char *ftname, char *ifname = NULL, int useGM=0, double lEth=-1., double hEth=-1.){ - imgRLR->Reset(); - imgLR->Reset(); - - char fname[1000]; - char inFName[1000]; - char outFName[1000]; - char moutFName[1000]; - if(ifname == NULL){ - sprintf(fname,"%s/%s_*.root",tdir,tname); - }else{ - sprintf(fname,"%s",ifname); - } - - if(useGM) sprintf(inFName,"%s/%s-PlotsWGMVEL.root",tdir,ftname); - else sprintf(inFName,"%s/%s-PlotsVEL.root",tdir,ftname); - - sprintf(outFName,"%s/%s-ImgVEL.root",tdir,tname); - sprintf(moutFName,"%s/%s-ImgVEL.mf",tdir,tname); - - TFile *inFile = new TFile(inFName,"READ"); - - cout << "Image Tree File Name: " << fname << endl; - cout << "Eta File Name: " << inFName << endl; - cout << "Out File Name: " << outFName << endl; - cout << "Matlab Out File Name: " << moutFName << endl; - - TH2D *gm = NULL; - if(useGM){ - cout << "Load gain map" << endl; - gm = (TH2D *)gDirectory->Get("gainMap"); - if(gm == NULL){ cout << "can not find gainMap in file" << endl; return; } - } - - cout << "Load eta" << endl; - EtaVEL *ee = (EtaVEL *)gDirectory->Get("etaDist"); - - cout << "Select Energy BW" << endl; - TH1D *spec = (TH1D *)gDirectory->Get("avgSpec3"); - if(spec == NULL){ cout << "can not find avgSpec3" << endl; return; } - - TF1 *gf3 = new TF1("gf3","gaus", 0, 10000); - spec->Fit(gf3,"Q"); - double avgE = gf3->GetParameter(1); - double sigE = gf3->GetParameter(2); - cout << "avgE: " << avgE << " sigE: " << sigE << endl; - cout << endl; - - if(lEth == -1.) lEth = avgE-5.*sigE; - if(hEth == -1.) hEth = avgE+5.*sigE; - cout << lEth << " < E < " << hEth << " (eV)" << endl; - - cout << "start with interpolation" << endl; - interpolate( tname, fname, ee,lEth,hEth ,gm); - - - TH2D *img = (TH2D *)gDirectory->Get("img"); - if(img == NULL){ cout << "could not find 2d-histogram: img " << endl; return; } - - - TH2D *imgE = (TH2D *)gDirectory->Get("imgE"); - if(imgE == NULL){ cout << "could not find 2d-histogram: imgE " << endl; return; } - - - //TH2D *imgEOM = (TH2D *)gDirectory->Get("imgEOM"); - //if(imgEOM == NULL){ cout << "could not find 2d-histogram: imgEOM " << endl; return; } - - TFile *outFile = new TFile(outFName,"UPDATE"); - imgLR->Write(); - imgRLR->Write(); - imgE->Write(); - //imgEOM->Write(); - img->Write(); - outFile->Close(); - inFile->Close(); - cout << "writing matlab file: " << moutFName << endl; - writeMatlab2DHisto(160*ee->getNPixels(),160*ee->getNPixels(),moutFName); - cout << "Done : " << outFName << endl; - -} - -/** - \par tdir input tree directory - \par tname input tree name - \par ifname input file name if different than tdir/tname_*.root - \par useGM use gain map - \par maxExpEinEv spectrum maximum - \par nPixels sub-pixels bins - \par lEth low threshold - \par hEth high threshold - - */ - - -EtaVEL *createGainAndEtaFile(char *tdir, char *tname, char *ifname=NULL, int useGM=0, double maxExpEinEv=25000., int nPixels =25, double lEth=-1., double hEth=-1.){ - char fname[1000]; - char outFName[1000]; - - - if(ifname == NULL){ - sprintf(fname,"%s/%s_*.root",tdir,tname); - }else{ - sprintf(fname,"%s",ifname); - } - - if(useGM) sprintf(outFName,"%s/%s-PlotsWGVEL.root",tdir,tname); - else sprintf(outFName,"%s/%s-PlotsVEL.root",tdir,tname); - - - cout << "Tree File Name: " << fname << endl; - cout << "Output File Name: " << outFName << endl; - - /** creates gain map and 3x3 spectrum */ - cout << "Creating gain map: " << endl; - TH2D *gm = createGainMap(tname,fname,0,maxExpEinEv/10.); - gm->SetName("gainMap"); - - - /** gets average 3x3 spectrum and fits it with a gaus */ - TH1D *spec = (TH1D *)gDirectory->Get("avgSpec3"); - if(spec == NULL){ cout << "can not find avgSpec3" << endl; return NULL; } - TF1 *gf3 = new TF1("gf3","gaus", 0, maxExpEinEv/10.); - spec->Fit(gf3,"Q"); - double avgE = gf3->GetParameter(1); - double sigE = gf3->GetParameter(2); - cout << "avgE: " << avgE << " sigE: " << sigE << endl; - cout << endl; - - - /** sets high and low threshold if not given by the user */ - if(lEth == -1.) lEth = avgE-5.*sigE; - if(hEth == -1.) hEth = avgE+5.*sigE; - cout << lEth << " < E < " << hEth << " (eV)" << endl; - - - - - cout << "calculating eta stuff" << endl; - - EtaVEL *newEta; - if(useGM) newEta = etaDensity(tname,fname,lEth,hEth,gm,nPixels); - else newEta = etaDensity(tname,fname,lEth,hEth,NULL,nPixels); - - cout << "writing to file " << outFName << endl; - - TFile *outFile = new TFile(outFName,"UPDATE"); - - newEta->Write("etaDist"); - - gm->Write(); - spec->Write(); - subPosAEta->Write(); - cES3vs2->Write(); - - outFile->Close(); - cout << "Done : " << outFName << endl; - return newEta; -} - -void exportSpec(char *tdir, char *tname){ - char tfname[1000]; - char ofname[1000]; - char cleanName[1000]; - - for(int p = 0; p < strlen(tname);p++){ - cleanName[p+1] = '\0'; - cleanName[p] = tname[p]; - - if(tname[p] == '-') cleanName[p] = '_'; - } - - sprintf(tfname,"%s/%s-PlotsVEL.root",tdir,tname); - sprintf(ofname,"%s/%s_SpecVEL.m",tdir,cleanName); - TFile *tf = new TFile(tfname); - TH1D *spec = (TH1D *)gDirectory->Get("avgSpec3"); - - ofstream outFile; - outFile.open (ofname); - - if(outFile.fail()){ - cout << "Could not open file : " << ofname << endl; - return; - } - - cout << "create matlab file with with spec " << ofname << endl; - - - outFile << cleanName << " = [ " << endl; - for(int i = 0; i < spec->GetNbinsX(); i++){ - outFile << i << " " << spec->GetBinCenter(i) << " " << spec->GetBinContent(i) << " ; " << endl; - } - - outFile << " ] ; " << endl; - - outFile.close(); -} diff --git a/slsDetectorCalibration/interpolations/etaVEL/EtaVEL.cpp b/slsDetectorCalibration/interpolations/etaVEL/EtaVEL.cpp deleted file mode 100644 index 922c91d4f..000000000 --- a/slsDetectorCalibration/interpolations/etaVEL/EtaVEL.cpp +++ /dev/null @@ -1,679 +0,0 @@ -#include "EtaVEL.h" -#include - - -// ClassImp(EtaVEL); - -// double Median(const TH1D * histo1) { - -// int numBins = histo1->GetXaxis()->GetNbins(); -// Double_t *x = new Double_t[numBins]; -// Double_t* y = new Double_t[numBins]; -// for (int i = 0; i < numBins; i++) { -// x[i] = histo1->GetBinCenter(i); -// y[i] = histo1->GetBinContent(i); -// } -// return TMath::Median(numBins, x, y); -// } - - -double *EtaVEL::getPixelCorners(int x, int y){ - double tlX,tlY,trX,trY,blX,blY,brX,brY; - tlX = xPPos[getCorner(x,y+1)]; - tlY = yPPos[getCorner(x,y+1)]; - trX = xPPos[getCorner(x+1,y+1)]; - trY = yPPos[getCorner(x+1,y+1)]; - blX = xPPos[getCorner(x,y)]; - blY = yPPos[getCorner(x,y)]; - brX = xPPos[getCorner(x+1,y)]; - brY = yPPos[getCorner(x+1,y)]; - - //cout << "gPC: TL: " << getCorner(x,y+1) << " TR: " << getCorner(x+1,y+1) << " BL " << getCorner(x,y) << " BR " << getCorner(x+1,y) << endl; - - double *c = new double[8]; - c[0] = tlX; c[1] = trX; c[2] = brX; c[3] = blX; - c[4] = tlY; c[5] = trY; c[6] = brY; c[7] = blY; - return c; -} - - -int EtaVEL::findBin(double xx, double yy){ - - double tlX,tlY,trX,trY,blX,blY,brX,brY; - /********Added by anna ******/ - // if (xxmax) xx=max-1E-6; - // if (yymax) yy=max-1E-6; - /**************/ - - - int bin = -1; - for(int x = 0; x < nPixels; x++){ - for(int y = 0; y < nPixels; y++){ - double *c = getPixelCorners(x,y); - tlX = c[0]; trX = c[1]; brX = c[2]; blX = c[3]; - tlY = c[4]; trY = c[5]; brY = c[6]; blY = c[7]; - - ///if(y == 0){ - // cout << "x: " << x << " blY " << blY << " brY " << brY << endl; - //} - - int out = 0; - - double tb = 0; - double bb = 0; - double lb = 0; - double rb = 0; - - if((trX-tlX)>0.) - tb = (trY - tlY)/(trX-tlX); - - if((brX-blX)>0.) - bb = (brY - blY)/(brX-blX); - - if((tlY-blY)>0.) - lb = (tlX - blX)/(tlY-blY); - - if((trY-brY)>0.) - rb = (trX - brX)/(trY-brY); - - double ty = tlY + tb * (xx - tlX); - double by = blY + bb * (xx - blX); - - double lx = blX + lb * (yy - blY); - double rx = brX + rb * (yy - brY); - - - - - if(yy >= ty) out++; - if(yy < by) out++; - if(xx < lx) out++; - if(xx >= rx) out++; - - //cout << "ty " << ty << endl; - //cout << "by " << by << endl; - //cout << "lx " << lx << endl; - //cout << "rx " << rx << endl; - - //double dist = (xx - xPPos[getBin(x,y)]) * (xx - xPPos[getBin(x,y)]) + (yy - yPPos[getBin(x,y)]) * (yy - yPPos[getBin(x,y)]); - //cout << "x " << x << " y " << y << " out " << out << " ty " << ty << endl; - //cout << "tl " << tlX << "/" << tlY << " tr " << trX << "/" << trY << endl; - //cout << "bl " << blX << "/" << blY << " br " << brX << "/" << brY << endl; - - //cout << " tb " << tb << endl; - - - delete[] c; - if(out == 0){ return getBin(x,y); } - } - } - - return -1; -} - -void EtaVEL::createLogEntry(){ - if(it >= nIterations){ - cerr << "log full" << endl; - } - log[it].itN = it; - log[it].xPos = new double[nPixels*nPixels+1]; - log[it].yPos = new double[nPixels*nPixels+1]; - log[it].binCont = new double[nPixels*nPixels+1]; - for(int x = 0; x < nPixels; x++) - for(int y = 0; y < nPixels; y++){ - log[it].xPos[getBin(x,y)] = xPPos[getBin(x,y)]; - log[it].yPos[getBin(x,y)] = yPPos[getBin(x,y)]; - log[it].binCont[getBin(x,y)] = binCont[getBin(x,y)]; - } - it++; -} - -void EtaVEL::updatePixelCorner(){ - double w = 20; - int rows = (nPixels+1)*(nPixels+1) + 4 + 4 * 4;//(4*(nPixels+1))-4; - int cols = (nPixels+1)*(nPixels+1); - - double *rVx = new double[rows]; - double *rVy = new double[rows]; - - double *posMat = new double[rows*cols]; - for(int i = 0 ; i < rows*cols; i++) posMat[i] = 0; - int boundaryPoint = 0; - - cout << "linear sys stuff" << endl; - - double minELength = 100000000000000; int minX=-1, minY=-1; - - for(int y = 0; y < nPixels+1; y++){ - for(int x = 0; x < nPixels+1; x++){ - double bx = 0, by = 0; - - //boundary conditions - - if((x == 0 && y % 5 == 0) || - (x == nPixels && y % 5 == 0) || - (y == 0 && x % 5 == 0) || - (y == nPixels && x % 5 == 0)){ - - bx = xPPos[getCorner(x,y)]; - //cout << "bP " << boundaryPoint << " bx " << bx << endl; - by = yPPos[getCorner(x,y)]; - rVx[(nPixels+1)*(nPixels+1) + boundaryPoint] = bx*w; - rVy[(nPixels+1)*(nPixels+1) + boundaryPoint] = by*w; - posMat[(nPixels+1)*(nPixels+1)*cols + boundaryPoint * cols + getCorner(x,y)-1] = w; - boundaryPoint++; - } - - double tot = 4 - (x == 0) - (y == 0) - (x == nPixels) - (y == nPixels); - //cout << "totW: " << tot << endl; - //tot = 4.; - double eLength = 0; - if(x != 0) eLength += edgeL[getEdgeX(x-1,y)]; - if(y != 0) eLength += edgeL[getEdgeY(x,y-1)]; - if(x != nPixels) eLength += edgeL[getEdgeX(x,y)]; - if(y != nPixels) eLength += edgeL[getEdgeY(x,y)]; - - /*cout << "Corner X:" <Print(); - k->SetMatrixArray(posMat); - // k->Print(); - - - //solve linear system - - Bool_t ok; - TDecompSVD *s = new TDecompSVD(*k); - s->Solve(*fx); - s->Solve(*fy); - - double *fxA = fx->GetMatrixArray(); - double *fyA = fy->GetMatrixArray(); - - - for(int y = 0; y < nPixels+1; y++){ - for(int x = 0; x < nPixels+1; x++){ - //do not update boundaries - - if(!(x == 0 || - x == nPixels|| - y == 0 || - y == nPixels)){ - xPPos[getCorner(x,y)] = fxA[getCorner(x,y)-1]; - yPPos[getCorner(x,y)] = fyA[getCorner(x,y)-1]; - } - } - } -} - -void EtaVEL::updatePixelPos(){ - double xMov, yMov, d1Mov, d2Mov; - createLogEntry(); - double *chMap = getChangeMap(); - int ch =0; - - cout << "update edge lengths" << endl; - for(int x = 0; x < nPixels; x++) - for(int y = 0; y < nPixels; y++){ - - - /*cout << "Pixel X:" < 0. & totCont > 0.){ - dd=sqrt(r/avg); - /**Added by Anna */ - if (dd>2.) dd=1.5; - if (dd<0.5) dd=0.75; - chMap[getBin(x,y)] = dd; - /** */ - //if( chMap[getBin(x,y)] < 1.){ chMap[getBin(x,y)] = 1/1.2; } - //if( chMap[getBin(x,y)] > 1.){ chMap[getBin(x,y)] = 1.2; } - //if( chMap[getBin(x,y)] < 1/1.2){ chMap[getBin(x,y)] = 1/1.2; } - //if( chMap[getBin(x,y)] > 1.2){ chMap[getBin(x,y)] = 1.2; } - }else if(totCont > 0.){ - chMap[getBin(x,y)] =0.5; //1/1.2; - }else{ - chMap[getBin(x,y)] = 1.; - } - - //if(r < avg + 2*acc && r > avg - 2*acc){ totInRange++;}// chMap[getBin(x,y)] = 1.; } - - /** Commente away by Anna - if(converged == 0 && r < med+20*acc){ chMap[getBin(x,y)] = 1.; } - if(converged == 2 && r < med+20*acc && r > med-03*acc){ chMap[getBin(x,y)] = 1.; } - if(r < med+03*acc){ totInRange03s++; } - if(r < med+07*acc){ totInRange07s++; } - if(r < med+12*acc){ totInRange12s++; } - if(r < med+20*acc){ totInRange20s++; } - if(r < med+25*acc){ totInRange25s++; } - */ - - //cout << "x " << x << " y " << y << " r " << r << " ch " << chMap[getBin(x,y)] << endl; - // if(r - avg > acc){ totOffAcc += r-avg;} - //if(r - avg < -acc){ totOffAcc += avg-r;} - totOffAcc += (avg-r)*(avg-r); - chi_sq+=(avg-r)*(avg-r)/r; - //cout << " x " << x << " y " << y << " bC " << binCont[x*nPixels+y] << " r " << r << endl; - - if(r > maxC){ maxC = r; maxX = x; maxY = y; } - if(r < minC){minC = r; minX = x; minY = y; } - - } - } - // cout << "totInBins " << totInBins << " zero Bin " << binCont[0] << endl; - cout << "AvgOffAcc: " << sqrt(totOffAcc/(double)(nPixels*nPixels)) << endl; - cout << "***********Reduced Chi Square: " << chi_sq/((double)(nPixels*nPixels)) << endl; - // cout << "totInRange03 (<" << med+03*acc << "): " << totInRange03s << endl; - // cout << "totInRange07 (<" << med+07*acc << "): " << totInRange07s << endl; - // cout << "totInRange12 (<" << med+12*acc << "): " << totInRange12s << endl; - // cout << "totInRange20 (<" << med+20*acc << "): " << totInRange20s << endl; - // cout << "totInRange25 (<" << med+25*acc << "): " << totInRange25s << endl; - double maxSig = (maxC - avg)*(maxC - avg) / avg;//acc; - double minSig = (avg - minC)*(avg - minC) / avg;//acc; - cout << "Max Pixel X: " << maxX << " Y: " << maxY << " P# " << getBin(maxX,maxY) << " count: " << maxC << " sig: "<< maxSig << endl; - cout << "Min Pixel X: " << minX << " Y: " << minY << " P# " << getBin(minX,minY) << " count: " << minC << " sig: "<< minSig << endl; - - // if(maxSig <= 25){ converged = 2; cout << "reached first converstion step!!!" << endl; } - //if(minSig <= 7 && converged == 2) { converged = 1; } - if (chi_sq<3) converged=2; - if (chi_sq<1) converged=1; - cout << "Conversion step "<< converged << endl; - return chMap; -} - -TH2D *EtaVEL::getContent(int it, int changeType){ - TH2D *cont = new TH2D("cont","cont",nPixels,min,max,nPixels,min,max); - double *chMap = NULL; - if(changeType ==1) chMap = getChangeMap(); - double *szMap = getSizeMap(); - for(int x = 0; x < nPixels; x++) - for(int y = 0; y < nPixels; y++){ - if(changeType ==2 ){ - cont->SetBinContent(x+1,y+1,szMap[getBin(x,y)]); - } - if(changeType ==1 ){ - cont->SetBinContent(x+1,y+1,chMap[getBin(x,y)]); - } - if(changeType ==0 ){ - if(it == -1){ - cont->SetBinContent(x+1,y+1,binCont[getBin(x,y)]); - //cout << "x " << x << " y " << y << " cont " << binCont[getBin(x,y)] << endl; - } - else{cont->SetBinContent(x+1,y+1,log[it].binCont[getBin(x,y)]);} - } - } - return cont; -} - -TH1D *EtaVEL::getCounts(){ - TH1D *ch = new TH1D("ch","ch",500,0,totCont/(nPixels*nPixels)*4); - for(int x = 0; x < nPixels; x++) - for(int y = 0; y < nPixels; y++){ - ch->Fill(binCont[getBin(x,y)]); - } - return ch; - -} - -void EtaVEL::printGrid(){ - - double *colSum = new double[nPixels+1]; - double *rowSum = new double[nPixels+1]; - - for(int i = 0; i < nPixels+1; i++){ - colSum[i] = 0.; - rowSum[i] = 0.; - for(int j = 0; j < nPixels; j++){ - rowSum[i] += edgeL[getEdgeX(j,i)]; - colSum[i] += edgeL[getEdgeY(i,j)]; - } - } - - cout << endl; - - cout.precision(3); cout << fixed; - cout << " "; - for(int x = 0; x < nPixels+1; x++){ - cout << setw(2) << x << " (" << colSum[x] << ") "; - } - cout << endl; - for(int y = 0; y < nPixels+1; y++){ - cout << setw(2) << y << " "; - for(int x = 0; x < nPixels+1; x++){ - cout << "(" << xPPos[getCorner(x,y)] << "/" << yPPos[getCorner(x,y)] << ") " ; - if(x < nPixels) cout << " -- " << edgeL[getEdgeX(x,y)]/rowSum[y]*(max-min) << " -- "; - } - cout << " | " << rowSum[y] << endl; - - if(y < nPixels){ - cout << " "; - for(int x = 0; x < nPixels+1; x++){ - cout << edgeL[getEdgeY(x,y)]/colSum[x]*(max-min) << " "; - } - cout << endl; - } - - } - delete[] colSum; - delete[] rowSum; - -} - -TMultiGraph *EtaVEL::plotPixelBorder(int plotCenters){ - TMultiGraph *mg = new TMultiGraph(); - double cx[5], cy[5]; - for(int x = 0; x < nPixels; x++) - for(int y = 0; y < nPixels; y++){ - double *c = getPixelCorners(x,y); - cx[0]=c[0]; cx[1]=c[1]; cx[2]=c[2]; cx[3]=c[3]; cx[4]=c[0]; - cy[0]=c[4]; cy[1]=c[5]; cy[2]=c[6]; cy[3]=c[7]; cy[4]=c[4]; - - - TGraph *g = new TGraph(5,cx,cy); - mg->Add(g); - if(plotCenters){ - g = new TGraph(1,&(xPPos[getBin(x,y)]),&(yPPos[getBin(x,y)])); - mg->Add(g); - } - delete[] c; - } - return mg; -} - -TMultiGraph *EtaVEL::plotLog(int stepSize, int maxIt){ - int mIt; - TMultiGraph *mg = new TMultiGraph(); - double **xposl = new double*[nPixels*nPixels+1]; - double **yposl = new double*[nPixels*nPixels+1]; - if(maxIt==-1){ mIt = it; } else{ mIt = maxIt; }; - cout << "mIt " << mIt << " steps " << mIt/stepSize << endl; - for(int x = 0; x < nPixels; x++){ - for(int y = 0; y < nPixels; y++){ - xposl[getBin(x,y)] = new double[mIt/stepSize]; - yposl[getBin(x,y)] = new double[mIt/stepSize]; - for(int i = 0; i < mIt/stepSize; i++){ - xposl[getBin(x,y)][i] = log[i*stepSize].xPos[getBin(x,y)]; - yposl[getBin(x,y)][i] = log[i*stepSize].yPos[getBin(x,y)]; - } - TGraph *g = new TGraph(mIt/stepSize,xposl[getBin(x,y)],yposl[getBin(x,y)]); - g->SetLineColor((x*y % 9) + 1); - - if(x == 0) g->SetLineColor(2); - if(y == 0) g->SetLineColor(3); - if(x == nPixels-1) g->SetLineColor(4); - if(y == nPixels-1) g->SetLineColor(5); - mg->Add(g); - } - } - return mg; -} - -void EtaVEL::serialize(ostream &o){ - // b.WriteVersion(EtaVEL::IsA()); - char del = '|'; - o << min << del; - o << max << del; - o << ds << del; - o << nPixels << del; - o << it << del; - o << totCont << del; - for(int i = 0; i < (nPixels+1)*(nPixels+1)+1; i++){ - o << xPPos[i] << del; - o << yPPos[i] << del; - } - for(int i = 0; i < nPixels*nPixels+1; i++){ - o << binCont[i] << del; - } - - for(int i = 0; i < it; i++){ - o << log[i].itN << del; - for(int j = 0; j < (nPixels+1)*(nPixels+1)+1; j++){ - o << log[i].xPos[j] << del; - o << log[i].yPos[j] << del; - } - for(int j = 0; j < nPixels*nPixels+1; j++){ - o << log[i].binCont[j] << del; - } - } -} - -void EtaVEL::deserialize(istream &is){ - delete[] xPPos; - delete[] yPPos; - delete[] binCont; - - char del; - - is >> min >> del; - is >> max >> del; - is >> ds >> del; - is >> nPixels >> del; - is >> it >> del; - is >> totCont >> del; - - xPPos = new double[(nPixels+1)*(nPixels+1)+1]; - yPPos = new double[(nPixels+1)*(nPixels+1)+1]; - binCont = new double[nPixels*nPixels+1]; - - cout << "d"; - - for(int i = 0; i < (nPixels+1)*(nPixels+1)+1; i++){ - is >> xPPos[i] >> del; - is >> yPPos[i] >> del; - } - - cout << "d"; - - for(int i = 0; i < nPixels*nPixels+1; i++){ - is >> binCont[i] >> del; - } - - cout << "d"; - - for(int i = 0; i < it; i++){ - is >> log[i].itN >> del; - log[i].xPos = new double[(nPixels+1)*(nPixels+1)+1]; - log[i].yPos = new double[(nPixels+1)*(nPixels+1)+1]; - log[i].binCont = new double[nPixels*nPixels+1]; - - for(int j = 0; j < (nPixels+1)*(nPixels+1)+1; j++){ - is >> log[i].xPos[j] >> del; - is >> log[i].yPos[j] >> del; - } - for(int j = 0; j < nPixels*nPixels+1; j++){ - is >> log[i].binCont[j] >> del; - } - cout << "d"; - } - cout << endl; -} - -void EtaVEL::Streamer(TBuffer &b){ - if (b.IsReading()) { - Version_t v = b.ReadVersion(); - - delete[] xPPos; - delete[] yPPos; - delete[] binCont; - - b >> min; - b >> max; - b >> ds; - b >> nPixels; - b >> it; - b >> totCont; - - xPPos = new double[(nPixels+1)*(nPixels+1)+1]; - yPPos = new double[(nPixels+1)*(nPixels+1)+1]; - binCont = new double[nPixels*nPixels+1]; - - for(int i = 0; i < (nPixels+1)*(nPixels+1)+1; i++){ - b >> xPPos[i]; - b >> yPPos[i]; - } - for(int i = 0; i < nPixels*nPixels+1; i++){ - b >> binCont[i]; - } - - for(int i = 0; i < it; i++){ - b >> log[i].itN; - log[i].xPos = new double[(nPixels+1)*(nPixels+1)+1]; - log[i].yPos = new double[(nPixels+1)*(nPixels+1)+1]; - log[i].binCont = new double[nPixels*nPixels+1]; - - for(int j = 0; j < (nPixels+1)*(nPixels+1)+1; j++){ - b >> log[i].xPos[j]; - b >> log[i].yPos[j]; - } - for(int j = 0; j < nPixels*nPixels+1; j++){ - b >> log[i].binCont[j]; - } - } - - } else { - b.WriteVersion(EtaVEL::IsA()); - b << min; - b << max; - b << ds; - b << nPixels; - b << it; - b << totCont; - for(int i = 0; i < (nPixels+1)*(nPixels+1)+1; i++){ - b << xPPos[i]; - b << yPPos[i]; - } - for(int i = 0; i < nPixels*nPixels+1; i++){ - b << binCont[i]; - } - - for(int i = 0; i < it; i++){ - b << log[i].itN; - for(int j = 0; j < (nPixels+1)*(nPixels+1)+1; j++){ - b << log[i].xPos[j]; - b << log[i].yPos[j]; - } - for(int j = 0; j < nPixels*nPixels+1; j++){ - b << log[i].binCont[j]; - } - } - } -} - diff --git a/slsDetectorCalibration/interpolations/etaVEL/EtaVEL.h b/slsDetectorCalibration/interpolations/etaVEL/EtaVEL.h deleted file mode 100644 index 5c73d8a83..000000000 --- a/slsDetectorCalibration/interpolations/etaVEL/EtaVEL.h +++ /dev/null @@ -1,164 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -//#include - - -#include -#include -#include - -#include -#include - -using namespace std; - -#ifndef ETAVPS -#define ETAVPS - -typedef struct { - int itN; - double *xPos; - double *yPos; - double *binCont; -} itLog; - - - -class EtaVEL : public TObject{ - - public: - EtaVEL(int numberOfPixels = 25, double minn=0., double maxx=1., int nnx=160, int nny=160) : nPixels(numberOfPixels), min(minn), max(maxx), converged(0), nx(nnx), ny(nny), chi_sq(0){ - //acc = 0.02; - ds = 0.005; - - init(); - } - void init(){ - double pOffset = (max-min)/(double)nPixels; - xPPos = new double[(nPixels+1)*(nPixels+1)+1]; - yPPos = new double[(nPixels+1)*(nPixels+1)+1]; - binCont = new double[nPixels*nPixels+1]; - totCont = 0.; - edgeL = new double[2*nPixels*(nPixels+1)+1]; - - for(int ii = 0; ii < 2*nPixels*(nPixels+1)+1; ii++){ - edgeL[ii] = 1.0; - //cout << "ii " << ii << endl; - } - - for(int x = 0; x < nPixels+1; x++){ - for(int y = 0; y < nPixels+1; y++){ - xPPos[getCorner(x,y)] = min + (double)x * pOffset; - yPPos[getCorner(x,y)] = min + (double)y * pOffset; - - if(x < nPixels && y < nPixels) binCont[getBin(x,y)] = 0; - } - } - // edgeL[1] = 3.0; - updatePixelCorner(); - it = 0; - - log = new itLog[nIterations]; - } - - void fill(double x, double y, double amount = 1.){ - totCont+=amount; - int bin = findBin(x,y); - if(bin < 0) { - //cout << "can not find bin x: " << x << " y: " << y << endl; - totCont-=amount; - } - binCont[bin]+=amount; - - } - - int getBin(int x, int y){ - if(x < 0 || x >= nPixels || y < 0 || y >= nPixels){ - //cout << "getBin: out of bounds : x " << x << " y " << y << endl; - return 0; - } - return y*nPixels+x+1; - } - - int getXBin(int bin){ - return (bin-1)%nPixels; - } - - int getYBin(int bin){ - return (bin-1)/nPixels; - } - - int getCorner(int x, int y){ - return y*(nPixels+1)+x+1; - } - - int getEdgeX(int x,int row){ - int ret = row*nPixels+x+1; - //cout << "| edge X x " << x << " row " << row << ": "<< ret << " | "; - return ret; - } - - int getEdgeY(int col, int y){ - int ret = nPixels*(nPixels+1)+col*nPixels+y+1; - //cout << "| edge Y col " << col << " y " << y << ": "<< ret << " | "; - return ret; - } - - - int getIt(){ return it; }; - - int getNPixels(){ return nPixels; } - double *getXPPos(){ return xPPos; } - double *getYPPos(){ return yPPos; } - - void updatePixelCorner(); - double *getPixelCorners(int x, int y); - int findBin(double xx, double yy); - void createLogEntry(); - - void updatePixelPos(); - double *getSizeMap(); - double *getChangeMap(); - TH2D *getContent(int it=-1, int changeType = 0); - TMultiGraph *plotPixelBorder(int plotCenters=0); - TMultiGraph *plotLog(int stepSize=1, int maxIt=-1); - void printGrid(); - TH1D *getCounts(); - - void serialize(ostream &o); - void deserialize(istream &is); - - int converged ; - double getChiSq(){return chi_sq;}; - - private: - itLog *log; - int it; - const static int nIterations =10000; - int nx, ny; - int nPixels; - double *xPPos; - double *yPPos; - double *binCont; - double totCont; - double *edgeL; - // double acc; - double ds; - double min,max; - double chi_sq; - - ClassDefNV(EtaVEL,1); - #pragma link C++ class EtaVEL-; -}; - -#endif diff --git a/slsDetectorCalibration/interpolations/etaVEL/EtaVELTr.py b/slsDetectorCalibration/interpolations/etaVEL/EtaVELTr.py deleted file mode 100644 index ebb152737..000000000 --- a/slsDetectorCalibration/interpolations/etaVEL/EtaVELTr.py +++ /dev/null @@ -1,393 +0,0 @@ -import numpy as np -import math - -maxf = 2 -minf = 0.5 - -class EtaVELTr: - def __init__(self, numberOfPixels = 25, minn=0., maxx=1.): - self.nPixels = numberOfPixels - self.nCorners = self.nPixels + 1 - self.minEta = minn - self.maxEta = maxx - #self.corners = [] - self.edgesX = [] - self.edgesY = [] - self.edgesE = [] - self.edgesF = [] - self.edgesG = [] - self.edgesH = [] - self.counts = [] - self.pOffset = (self.maxEta-self.minEta)/self.nPixels - - self.cPosX = [] - self.cPosY = [] - self.zPosX = [] - self.zPosY = [] - - self.sqSums = [] - self.cIteration = 0 - self.bSqSum = 0 - - self.initGrid() - #self.calculatePixelCorners() - self.update() - - def initGrid(self): - dd = 1 / math.sqrt(2) - - #self.corners = [ [self.minEta + x * pOffset, self.minEta + y * pOffset] for y in range(self.nPixels)] for x in range(self.nPixels) - self.cPosX = [ [self.minEta + x * self.pOffset for x in range(self.nCorners)] for y in range(self.nCorners) ] - self.cPosY = [ [self.minEta + y * self.pOffset for x in range(self.nCorners)] for y in range(self.nCorners) ] - self.counts = [ [ [0,0,0,0] for x in range(self.nPixels) ] for y in range(self.nPixels) ] - self.edgesX = [ [ 1 for x in range(self.nCorners) ] for y in range(self.nCorners + 1) ] - self.edgesY = [ [ 1 for x in range(self.nCorners+1) ] for y in range(self.nCorners) ] - self.edgesE = [ [ dd for x in range(self.nPixels) ] for y in range(self.nPixels) ] - self.edgesF = [ [ dd for x in range(self.nPixels) ] for y in range(self.nPixels) ] - self.edgesG = [ [ dd for x in range(self.nPixels) ] for y in range(self.nPixels) ] - self.edgesH = [ [ dd for x in range(self.nPixels) ] for y in range(self.nPixels) ] - - - - def update(self): - self.normalizeEdgeLengths() - self.calculateEdgeLengths2() - self.calculatePixelCorners2() - conv = False - out = 0 - outList = [] - tot = self.nPixels*self.nPixels*4 - sqSum = 0 - avg = self.getAvgCounts() - avgPS = self.getAvgCounts() + 1*math.sqrt(self.getAvgCounts()) - avgMS = self.getAvgCounts() - 1*math.sqrt(self.getAvgCounts()) - for y in range(self.nPixels): - for x in range(self.nPixels): - for t in range(4): - sqSum += (avg -self.counts[y][x][t]) * (avg -self.counts[y][x][t]) - if self.counts[y][x][t] > avgPS or self.counts[y][x][t] < avgMS: - - out += 1 - outList.append([y,x,t,self.counts[y][x][t]]) - - outList = sorted(outList,key=lambda t: abs(self.counts[t[0]][t[1]][t[2]]/self.getAvgCounts())) - self.counts = [ [ [0,0,0,0] for x in range(self.nPixels) ] for y in range(self.nPixels) ] - print("There are {} of {} triangles out of 1 std ({} %)".format(out,tot,out/tot*100)) - print("Total Sq Err: {}".format(sqSum)) - - self.sqSums.append(sqSum) - - if len(self.sqSums) > 2 and np.diff(self.sqSums)[-1] > 0: - print("converged after {} steps: sqSums {} diff(sqSums) {}".format(self.cIteration,self.sqSums,np.diff(self.sqSums))) - conv = True - self.bSqSum = self.sqSums[-2] - - self.cIteration += 1 - return [conv,outList,sqSum] - - def normalizeEdgeLengths(self): - sumL = 0 - sumL += sum(map(sum,zip(*self.edgesX))) - sumL += sum(map(sum,zip(*self.edgesY))) - sumL += sum(map(sum,zip(*self.edgesE))) - sumL += sum(map(sum,zip(*self.edgesF))) - sumL += sum(map(sum,zip(*self.edgesG))) - sumL += sum(map(sum,zip(*self.edgesH))) - avgL = sumL/(4*self.nPixels*self.nPixels+2*self.nCorners*(self.nCorners+1)) - print("total Sum is {} avg: {}".format(sumL,avgL)) - self.edgesX = [ [ x/avgL for x in y ] for y in self.edgesX ] - self.edgesY = [ [ x/avgL for x in y ] for y in self.edgesY ] - self.edgesE = [ [ x/avgL for x in y ] for y in self.edgesE ] - self.edgesF = [ [ x/avgL for x in y ] for y in self.edgesF ] - self.edgesG = [ [ x/avgL for x in y ] for y in self.edgesG ] - self.edgesH = [ [ x/avgL for x in y ] for y in self.edgesH ] - - def _shapeF(self,f): - f = (f - 1) * 0.6 + 1 - if f > maxf: - return maxf - if f < minf: - return minf - return f - - def calculateEdgeLengths2(self): - if self.getTotalCounts() == 0: - return - avg = self.getAvgCounts() - - for y in range(self.nPixels): - for x in range(self.nPixels): - for t in range(4): - pc = self.counts[y][x][t] - if pc == 0: - f = maxf - else: - f = math.sqrt(avg/pc) - if pc > avg-math.sqrt(avg) and pc < avg+math.sqrt(avg): - f = 1. - sf = self._shapeF(f) - if t == 0: - self.edgesX[y][x] = self.edgesX[y][x] / sf - self.edgesE[y][x] = self.edgesE[y][x] / sf - self.edgesF[y][x] = self.edgesF[y][x] / sf - if t == 1: - self.edgesY[y][x+1] = self.edgesY[y][x+1] / sf - self.edgesF[y][x] = self.edgesF[y][x] / sf - self.edgesH[y][x] = self.edgesH[y][x] / sf - if t == 2: - self.edgesX[y+1][x] = self.edgesX[y+1][x] / sf - self.edgesH[y][x] = self.edgesH[y][x] / sf - self.edgesG[y][x] = self.edgesG[y][x] / sf - if t == 3: - self.edgesY[y][x] = self.edgesY[y][x] / sf - self.edgesG[y][x] = self.edgesG[y][x] / sf - self.edgesE[y][x] = self.edgesE[y][x] / sf - - - def calculatePixelCorners2(self): - w = 20 - posMat = [] - CrVx = np.zeros((self.nCorners,self.nCorners)) - CrVy = np.zeros((self.nCorners,self.nCorners)) - ZrVx = np.zeros((self.nPixels,self.nPixels)) - ZrVy = np.zeros((self.nPixels,self.nPixels)) - - #boundary conditions matrix/vectors - BCposMatX = [] - BCposMatY = [] - BCrVx = [] - BCrVy = [] - - for y in range(self.nCorners): - for x in range(self.nCorners): - BClineX = np.zeros((self.nCorners,self.nCorners)) - BClineY = np.zeros((self.nCorners,self.nCorners)) - if (x == 0 and y == 0) or \ - (x == 0 and y == self.nPixels) or \ - (x == self.nPixels and y == 0) or \ - (x == self.nPixels and y == self.nPixels): - BClineX[y][x] = w - BClineY[y][x] = w - BCrVx.append(self.getCornerPos(y,x)[0] * w) - BCrVy.append(self.getCornerPos(y,x)[1] * w) - #print("bclinex shape {} zeros shape {}".format( BClineX.reshape((self.nCorners*self.nCorners,)).shape , np.zeros((self.nPixels*self.nPixels)).shape )) - BCposMatX.append(np.hstack((BClineX.reshape((self.nCorners*self.nCorners,)),np.zeros((self.nPixels*self.nPixels,)) )) ) - BCposMatY.append(np.hstack((BClineY.reshape((self.nCorners*self.nCorners,)),np.zeros((self.nPixels*self.nPixels,)) )) ) - - elif x == 0 or x == self.nPixels: - BClineX[y][x] = w - #BClineY[y][x] = 1 - BCrVx.append(self.getCornerPos(y,x)[0] * w) - #BCrVy.append(self.getCornerPos(y,x)[1]) - BCposMatX.append(np.hstack((BClineX.reshape((self.nCorners*self.nCorners,)),np.zeros((self.nPixels*self.nPixels,)) )) ) - #BCposMatY.append(np.hstack((BClineY.reshape((self.nCorners*self.nCorners,)),np.zeros((self.nPixels*self.nPixels,)) )) ) - elif y == 0 or y == self.nPixels: - #BClineX[y][x] = 1 - BClineY[y][x] = w - #BCrVx.append(self.getCornerPos(y,x)[0]) - BCrVy.append(self.getCornerPos(y,x)[1] * w) - #BCposMatX.append(np.hstack((BClineX.reshape((self.nCorners*self.nCorners,)),np.zeros((self.nPixels*self.nPixels,)) )) ) - BCposMatY.append(np.hstack((BClineY.reshape((self.nCorners*self.nCorners,)),np.zeros((self.nPixels*self.nPixels,)) )) ) - - - eLength = 0 - - if x != 0: - eLength += self.edgesX[y][x-1] - if y != 0: - eLength += self.edgesY[y-1][x] - if x != self.nPixels: - eLength += self.edgesX[y][x] - if y != self.nPixels: - eLength += self.edgesY[y][x] - - if y != 0 and x != 0: - eLength += self.edgesH[y-1][x-1] - if y != self.nPixels and x != 0: - eLength += self.edgesF[y][x-1] - if y != 0 and x != self.nPixels: - eLength += self.edgesG[y-1][x] - if y != self.nPixels and x != self.nPixels: - eLength += self.edgesE[y][x] - - line = np.zeros((self.nCorners,self.nCorners)) - lineZ = np.zeros((self.nPixels,self.nPixels)) - - - if x != 0: - line[y][x-1] = - self.edgesX[y][x-1]/eLength - if y != 0: - line[y-1][x] = - self.edgesY[y-1][x]/eLength - if x != self.nPixels: - line[y][x+1] = - self.edgesX[y][x]/eLength - if y != self.nPixels: - line[y+1][x] = - self.edgesY[y][x]/eLength - - if y != 0 and x != 0: - lineZ[y-1][x-1] = -self.edgesH[y-1][x-1]/eLength - if y != self.nPixels and x != 0: - lineZ[y][x-1] = -self.edgesF[y][x-1]/eLength - if y != 0 and x != self.nPixels: - lineZ[y-1][x] = -self.edgesG[y-1][x]/eLength - if y != self.nPixels and x != self.nPixels: - lineZ[y][x] = -self.edgesE[y][x]/eLength - - - line[y][x] = 1 - CrVx[y][x] = 0 - CrVy[y][x] = 0 - posMat.append( \ - np.hstack(( \ - line.reshape((self.nCorners*self.nCorners,)), \ - lineZ.reshape((self.nPixels*self.nPixels,)) \ - )) \ - ) - - for y in range(self.nPixels): - for x in range(self.nPixels): - line = np.zeros((self.nCorners,self.nCorners)) - lineZ = np.zeros((self.nPixels,self.nPixels)) - - eLength = self.edgesE[y][x] + self.edgesF[y][x] +self.edgesG[y][x] +self.edgesH[y][x] - line[y][x] = -self.edgesE[y][x] / eLength - line[y][x+1] = -self.edgesF[y][x] / eLength - line[y+1][x] = -self.edgesG[y][x] / eLength - line[y+1][x+1] = -self.edgesH[y][x] / eLength - - lineZ[y][x] = 1 - ZrVx[y][x] = 0 - ZrVy[y][x] = 0 - posMat.append( \ - np.hstack(( \ - line.reshape((self.nCorners*self.nCorners,)), \ - lineZ.reshape((self.nPixels*self.nPixels,)) \ - )) \ - ) - - CrVxFlat = CrVx.reshape((self.nCorners*self.nCorners,)) - CrVyFlat = CrVy.reshape((self.nCorners*self.nCorners,)) - ZrVxFlat = ZrVx.reshape((self.nPixels*self.nPixels,)) - ZrVyFlat = ZrVy.reshape((self.nPixels*self.nPixels,)) - posMat = np.asarray(posMat) - - BCrVyFlat = np.asarray(BCrVy) - BCrVxFlat = np.asarray(BCrVx) - BCposMatX = np.asarray(BCposMatX) - BCposMatY = np.asarray(BCposMatY) - - print ("BCposMatY vy {} shape posMat {}".format(BCposMatY.shape,posMat.shape)) - - FinalrVy = np.hstack((CrVyFlat,ZrVyFlat,BCrVyFlat)) - FinalrVx = np.hstack((CrVxFlat,ZrVxFlat,BCrVxFlat)) - FinalposMatX = np.vstack((posMat,BCposMatX)) - FinalposMatY = np.vstack((posMat,BCposMatY)) - - print("posMat shape {}".format(posMat.shape)) - print("posMatX shape {}".format(FinalposMatX.shape)) - print("rVxFlat shape {}".format(FinalrVx.shape)) - - #print("posMat {}".format(FinalposMat)) - #print("rVxFlat {}".format(FinalrVx)) - - xPos = np.linalg.lstsq(FinalposMatX,FinalrVx)[0] - yPos = np.linalg.lstsq(FinalposMatY,FinalrVy)[0] - - print("xPosShape {} cutXPosShape {}".format(xPos.shape,xPos[:self.nCorners][:self.nCorners].shape)) - - self.cPosX = xPos[:self.nCorners*self.nCorners].reshape((self.nCorners,self.nCorners)) - self.cPosY = yPos[:self.nCorners*self.nCorners].reshape((self.nCorners,self.nCorners)) - - self.zPosX = xPos[self.nCorners*self.nCorners:].reshape((self.nPixels,self.nPixels)) - self.zPosY = yPos[self.nCorners*self.nCorners:].reshape((self.nPixels,self.nPixels)) - - - - def fill(self,yy,xx,count = 1): - [y,x,t] = self.getPixel(yy,xx) - self.counts[y][x][t] += count - - def getCountDist(self): - c = [] - for y in range(self.nPixels): - for x in range(self.nPixels): - c.append(self.counts[y][x]) - return c - - def getPixel(self,yy,xx, debug = False): - for y in range(self.nPixels): - for x in range(self.nPixels): - for t in range(4): - [v1x,v1y,v2x,v2y,v3x,v3y] = self.getTriangleCorner(y,x,t) - if self.pointInTriangle([xx,yy],[v1x,v1y],[v2x,v2y],[v3x,v3y]): - return [y,x,t] - - if not debug: - raise Exception("not inside a pixel") - else: - print("no pixel found") - return [0,0] - - #http://stackoverflow.com/questions/2049582/how-to-determine-a-point-in-a-2d-triangle - def trSign (self, p1, p2, p3): - return (p1[0] - p3[0]) * (p2[1] - p3[1]) - (p2[0] - p3[0]) * (p1[1] - p3[1]); - - def pointInTriangle (self,pt, v1, v2, v3): - b1 = self.trSign(pt, v1, v2) < 0.0 - b2 = self.trSign(pt, v2, v3) < 0.0 - b3 = self.trSign(pt, v3, v1) < 0.0 - return ((b1 == b2) and (b2 == b3)); - - def getAvgCounts(self): - return self.getTotalCounts() / self.nPixels/self.nPixels/4. - - def getTotalCounts(self): - tot = 0 - for y in range(self.nPixels): - for x in range(self.nPixels): - for t in range(4): - tot += self.counts[y][x][t] - return tot - - #tl tr bl br - def getPixelCorners(self,iy,ix): - return self.getCornerPos(iy,ix) + self.getCornerPos(iy,ix+1) + self.getCornerPos(iy+1,ix) + self.getCornerPos(iy+1,ix+1) - - def getTriangleCorner(self,iy,ix,tr): - if tr == 0: - return self.getCornerPos(iy,ix) + self.getCornerPos(iy,ix+1) + [self.zPosX[iy][ix],self.zPosY[iy][ix]] - if tr == 1: - return self.getCornerPos(iy,ix+1) + self.getCornerPos(iy+1,ix+1) + [self.zPosX[iy][ix],self.zPosY[iy][ix]] - if tr == 2: - return self.getCornerPos(iy+1,ix+1) + self.getCornerPos(iy+1,ix) + [self.zPosX[iy][ix],self.zPosY[iy][ix]] - if tr == 3: - return self.getCornerPos(iy+1,ix) + self.getCornerPos(iy,ix) + [self.zPosX[iy][ix],self.zPosY[iy][ix]] - - def getCornerPos(self,iy,ix): - return [self.cPosX[iy][ix],self.cPosY[iy][ix]] - - def getXEdgePos(self,iy,ix): - p1 = self.getCornerPos(iy,ix) - p2 = self.getCornerPos(iy,ix+1) - return [p1[0],p1[1],p2[0],p2[1]] - - def getYEdgePos(self,iy,ix): - p1 = self.getCornerPos(iy,ix) - p2 = self.getCornerPos(iy+1,ix) - return [p1[0],p1[1],p2[0],p2[1]] - - def getEEdgePos(self,iy,ix): - p1 = self.getCornerPos(iy,ix) - return [p1[0],p1[1],self.zPosX[iy][ix],self.zPosY[iy][ix]] - - def getFEdgePos(self,iy,ix): - p1 = self.getCornerPos(iy,ix+1) - return [p1[0],p1[1],self.zPosX[iy][ix],self.zPosY[iy][ix]] - - def getGEdgePos(self,iy,ix): - p1 = self.getCornerPos(iy+1,ix) - return [p1[0],p1[1],self.zPosX[iy][ix],self.zPosY[iy][ix]] - - def getHEdgePos(self,iy,ix): - p1 = self.getCornerPos(iy+1,ix+1) - return [p1[0],p1[1],self.zPosX[iy][ix],self.zPosY[iy][ix]] - diff --git a/slsDetectorCalibration/interpolations/etaVEL/etaVELInterpolation.cpp b/slsDetectorCalibration/interpolations/etaVEL/etaVELInterpolation.cpp deleted file mode 100644 index 1cdd3c718..000000000 --- a/slsDetectorCalibration/interpolations/etaVEL/etaVELInterpolation.cpp +++ /dev/null @@ -1,134 +0,0 @@ -#include "interpolation_EtaVEL.h" -#include "TH2F.h" -#include "TCanvas.h" -#include "TROOT.h" -//#include "EtaVEL.h" -#include "EtaVEL.cpp" -/* -Zum erstellen der correction map ist createGainAndEtaFile(...) in EVELAlg.C der entry point. -Zum erstellen des HR images ist createImage(...) der entry point. -*/ -interpolation_EtaVEL::interpolation_EtaVEL(int nx, int ny, int ns, double etamin, double etamax, int p) : slsInterpolation(nx, ny, ns), newEta(NULL), heta(NULL), plot(p) { - newEta = new EtaVEL(nSubPixels,etamin,etamax,nPixelsX, nPixelsY); - heta= new TH2F("heta","heta",50*nSubPixels, etamin,etamax,50*nSubPixels, etamin,etamax); - heta->SetStats(kFALSE); -} - -interpolation_EtaVEL::~interpolation_EtaVEL() { - delete newEta; - delete heta; -} - - -void interpolation_EtaVEL::prepareInterpolation(int &ok, int maxit) { - int nit=0; - while ((newEta->converged != 1) && nit++Modified(); - gPad->Update(); - } - if (newEta->converged==1) ok=1; else ok=0; -} - -int interpolation_EtaVEL::addToFlatField(Double_t *cluster, Double_t &etax, Double_t &etay) { - Double_t sum, totquad, sDum[2][2]; - int corner =calcEta(cluster, etax, etay, sum, totquad, sDum); - //check if it's OK...should redo it every time? - //or should we fill a finer histogram and afterwards re-fill the newEta? - addToFlatField(etax, etay); - return corner; -} - -int interpolation_EtaVEL::addToFlatField(Double_t etax, Double_t etay) { - // newEta->fill(etaX,etaY); - heta->Fill(etax,etay); - return 0; -} - -void interpolation_EtaVEL::iterate() { - cout << " -------------- newEta refilled"<< endl; - for (int ibx=0; ibxGetNbinsX(); ibx++) { - for (int iby=0; ibyGetNbinsY(); iby++) { - newEta->fill(heta->GetXaxis()->GetBinCenter(ibx+1),heta->GetYaxis()->GetBinCenter(iby+1),heta->GetBinContent(ibx+1,iby+1)); - } - } - newEta->updatePixelPos(); - cout << " -------------- pixelPosition updated"<< endl; -} - -void interpolation_EtaVEL::DrawH() { - heta->Draw("col"); - (newEta->plotPixelBorder())->Draw(); -} - - -void interpolation_EtaVEL::getInterpolatedPosition(Int_t x, Int_t y, Double_t *cluster, Double_t &int_x, Double_t &int_y) { - - Double_t etax, etay, sum, totquad, sDum[2][2]; - - int corner =calcEta(cluster, etax, etay, sum, totquad, sDum); - - int bin = newEta->findBin(etax,etay); - if (bin<=0) { - int_x=-1; - int_y=-1; - return; - } - double subX = ((double)(newEta->getXBin(bin))+.5)/((double)newEta->getNPixels()); - double subY = ((double)(newEta->getYBin(bin))+.5)/((double)newEta->getNPixels()); - - double dX, dY; - switch (corner) { - case TOP_LEFT: - dX=-1.; - dY=+1.; - break; - case TOP_RIGHT: - dX=+1.; - dY=+1.; - break; - case BOTTOM_LEFT: - dX=-1.; - dY=-1.; - break; - case BOTTOM_RIGHT: - dX=+1.; - dY=-1.; - break; - default: - dX=0; - dY=0; - } - - int_x=((double)x)+ subX+0.5*dX; - int_y=((double)y)+ subY+0.5*dY; - - // cout << corner << " " << subX<< " " << subY << " " << dX << " " << dY << " " << int_x << " " << int_y << endl; - -}; - - -// void interpolation_EtaVEL::Streamer(TBuffer &b){newEta->Streamer(b);}; -void interpolation_EtaVEL::getInterpolatedBin(Double_t *cluster, Int_t &int_x, Int_t &int_y) { - - Double_t etax, etay, sum, totquad, sDum[2][2]; - - int corner =calcEta(cluster, etax, etay, sum, totquad, sDum); - - int bin = newEta->findBin(etax,etay); - if (bin<0) { - int_x=-1; - int_y=-1; - return; - } - int_x=newEta->getXBin(bin); - int_y=newEta->getYBin(bin); - - - -}; - diff --git a/slsDetectorCalibration/interpolations/etaVEL/etaVELInterpolation.h b/slsDetectorCalibration/interpolations/etaVEL/etaVELInterpolation.h deleted file mode 100644 index 8fbacf96d..000000000 --- a/slsDetectorCalibration/interpolations/etaVEL/etaVELInterpolation.h +++ /dev/null @@ -1,55 +0,0 @@ -#ifndef INTERPOLATION_ETAVEL_H -#define INTERPOLATION_ETAVEL_H - -#include -#include "EtaVEL.h" -//#include "TH2F.h" -//#include "EtaVEL.cpp" -//class EtaVEL; - -class etaVELInterpolation: public etaInterpolationBase { - - public: - interpolation_EtaVEL(int nx=40, int ny=160, int ns=25, double etamin=-0.02, double etamax=1.02, int p=0); - ~interpolation_EtaVEL(); - - - //create eta distribution, eta rebinnining etc. - //returns flat field image - void prepareInterpolation(int &ok){prepareInterpolation(ok,10000);}; - void prepareInterpolation(int &ok, int maxit); - - //create interpolated image - //returns interpolated image - - //return position inside the pixel for the given photon - void getInterpolatedPosition(Int_t x, Int_t y, Double_t *data, Double_t &int_x, Double_t &int_y); - void getInterpolatedBin(Double_t *cluster, Int_t &int_x, Int_t &int_y); - - - - int addToFlatField(Double_t *cluster, Double_t &etax, Double_t &etay); - int addToFlatField(Double_t etax, Double_t etay); - int setPlot(int p=-1) {if (p>=0) plot=p; return plot;}; - // int WriteH(){newEta->Write("newEta"); heta->Write("heta");}; - EtaVEL *setEta(EtaVEL *ev){if (ev) {delete newEta; newEta=ev;} return newEta;}; - - - - // TH2F *setEta(TH2F *ev){if (ev) {delete heta; heta=ev;} return heta;}; - void iterate(); - // void DrawH(); - double getChiSq(){return newEta->getChiSq();}; - - - - protected: - EtaVEL *newEta; - // TH2F *heta; - int plot; - - // ClassDefNV(interpolation_EtaVEL,1); - // #pragma link C++ class interpolation_EtaVEL-; -}; - -#endif diff --git a/slsDetectorCalibration/interpolations/linearInterpolation.h b/slsDetectorCalibration/interpolations/linearInterpolation.h deleted file mode 100644 index 605de4c93..000000000 --- a/slsDetectorCalibration/interpolations/linearInterpolation.h +++ /dev/null @@ -1,234 +0,0 @@ -#ifndef LINEAR_INTERPOLATION_H -#define LINEAR_INTERPOLATION_H - -//#include -//#include -//#include - -#include "slsInterpolation.h" - -class linearInterpolation : public slsInterpolation{ - - public: - linearInterpolation(int nx=400, int ny=400, int ns=25) : slsInterpolation(nx,ny,ns) {}; - linearInterpolation(linearInterpolation *orig) : slsInterpolation(orig) {}; - - virtual void prepareInterpolation(int &ok){ok=1;}; - - virtual linearInterpolation* Clone() { - - return new linearInterpolation(this); - - }; - - - ////////////////////////////////////////////////////////////////////////////// - //////////// /*It return position hit for the event in input */ ////////////// - virtual void getInterpolatedPosition(int x, int y, double *data, double &int_x, double &int_y) - { - double sDum[2][2]; - double tot, totquad; - double etax,etay; - - int corner; - corner=calcQuad(data, tot, totquad, sDum); - if (nSubPixels>2) { - calcEta(totquad, sDum, etax, etay); - } - getInterpolatedPosition(x, y, etax,etay, corner, int_x, int_y); - - return; - }; - - virtual void getInterpolatedPosition(int x, int y, int *data, double &int_x, double &int_y) - { - double sDum[2][2]; - double tot, totquad; - double etax,etay; - - int corner; - corner=calcQuad(data, tot, totquad, sDum); - if (nSubPixels>2) - calcEta(totquad, sDum, etax, etay); - getInterpolatedPosition(x,y,etax,etay,corner,int_x,int_y); - - return; - }; - - virtual void getInterpolatedPosition(int x, int y, double totquad,int quad,double *cl,double &int_x, double &int_y) { - - double eta_x, eta_y; - if (nSubPixels>2) { - double cc[2][2]; - double *cluster[3]; - cluster[0]=cl; - cluster[1]=cl+3; - cluster[2]=cl+6; - int xoff, yoff; - - switch (quad) { - case BOTTOM_LEFT: - xoff=0; - yoff=0; - break; - case BOTTOM_RIGHT: - xoff=1; - yoff=0; - break; - case TOP_LEFT: - xoff=0; - yoff=1; - break; - case TOP_RIGHT: - xoff=1; - yoff=1; - break; - default: - ; - } - cc[0][0]=cluster[yoff][xoff]; - cc[1][0]=cluster[yoff+1][xoff]; - cc[0][1]=cluster[yoff][xoff+1]; - cc[1][1]=cluster[yoff+1][xoff+1]; - calcEta(totquad,cc,eta_x,eta_y); - } - // cout << x << " " << y << " " << eta_x << " " << eta_y << " " << int_x << " " << int_y << endl; - return getInterpolatedPosition(x,y,eta_x, eta_y,quad,int_x,int_y); - - - - - - - - } - - - virtual void getInterpolatedPosition(int x, int y, double totquad,int quad,int *cl,double &int_x, double &int_y) { - - double cc[2][2]; - int *cluster[3]; - int xoff, yoff; - cluster[0]=cl; - cluster[1]=cl+3; - cluster[2]=cl+6; - - switch (quad) { - case BOTTOM_LEFT: - xoff=0; - yoff=0; - break; - case BOTTOM_RIGHT: - xoff=1; - yoff=0; - break; - case TOP_LEFT: - xoff=0; - yoff=1; - break; - case TOP_RIGHT: - xoff=1; - yoff=1; - break; - default: - ; - } - double etax, etay; - if (nSubPixels>2) { - cc[0][0]=cluster[yoff][xoff]; - cc[1][0]=cluster[yoff+1][xoff]; - cc[0][1]=cluster[yoff][xoff+1]; - cc[1][1]=cluster[yoff+1][xoff+1]; - calcEta(totquad,cc,etax,etay); - } - // cout << x << " " << y << " " << etax << " " << etay << " " << int_x << " " << int_y << endl; - return getInterpolatedPosition(x,y,etax, etay,quad,int_x,int_y); - - } - - - - virtual void getInterpolatedPosition(int x, int y, double etax, double etay, int corner, double &int_x, double &int_y) - { - - double xpos_eta,ypos_eta; - double dX,dY; - switch (corner) - { - case TOP_LEFT: - dX=-1.; - dY=0; - break; - case TOP_RIGHT: - dX=0; - dY=0; - break; - case BOTTOM_LEFT: - dX=-1.; - dY=-1.; - break; - case BOTTOM_RIGHT: - dX=0; - dY=-1.; - break; - default: - cout << "bad quadrant" << endl; - dX=0.; - dY=0.; - } - - - if (nSubPixels>2) { - xpos_eta=(etax)+dX; - ypos_eta=(etay)+dY; - } else { - xpos_eta=0.5*dX+0.25; - ypos_eta=0.5*dY+0.25; - } - int_x=((double)x) + xpos_eta; - int_y=((double)y) + ypos_eta; - // cout <<"**"<< x << " " << y << " " << xpos_eta << " " << ypos_eta << " " << corner << endl; - return; - }; - - - - - - - - //////////////////////////////////////////////////////////////////////////////////////////////////////// - virtual void getPositionETA3(int x, int y, double *data, double &int_x, double &int_y) - { - double sDum[2][2]; - double tot, totquad; - double eta3x,eta3y; - - calcQuad(data, tot, totquad, sDum); - calcEta3(data,eta3x, eta3y,tot); - - double xpos_eta,ypos_eta; - - xpos_eta=eta3x; - ypos_eta=eta3y; - - int_x=((double)x) + xpos_eta; - int_y=((double)y) + ypos_eta; - - return; - }; - //////////////////////////////////////////////////////////////////////////////////////////////////////// - - virtual int addToFlatField(double *cluster, double &etax, double &etay){}; - virtual int addToFlatField(int *cluster, double &etax, double &etay){}; - virtual int addToFlatField(double etax, double etay){}; - virtual int addToFlatField(double totquad,int quad,double *cl,double &etax, double &etay) {}; - virtual int addToFlatField(double totquad,int quad,int *cl,double &etax, double &etay) {}; - - protected: - ; - - -}; - -#endif diff --git a/slsDetectorCalibration/interpolations/noInterpolation.h b/slsDetectorCalibration/interpolations/noInterpolation.h deleted file mode 100644 index 6c199399f..000000000 --- a/slsDetectorCalibration/interpolations/noInterpolation.h +++ /dev/null @@ -1,104 +0,0 @@ -#ifndef NO_INTERPOLATION_H -#define NO_INTERPOLATION_H - -/* #ifdef MYROOT1 */ -/* #include */ -/* #include */ -/* #include */ -/* #include */ -/* #include */ -/* #endif */ - -#include -#include "slsInterpolation.h" - - - -class noInterpolation : public slsInterpolation{ - public: - noInterpolation(int nx=400, int ny=400, int ns=25) : slsInterpolation(nx,ny,ns) {};// {eventGenerator=new TRandom();}; - noInterpolation(noInterpolation *orig) : slsInterpolation(orig){}; - virtual void prepareInterpolation(int &ok){ok=1;}; - - ////////////////////////////////////////////////////////////////////////////// - //////////// /*It return position hit for the event in input */ ////////////// - - virtual noInterpolation* Clone() { - - return new noInterpolation(this); - - }; - - - virtual void getInterpolatedPosition(int x, int y, double *data, double &int_x, double &int_y) - { - //Random coordinate in the Pixel reference - int_x = x + ((double)rand())/((double)RAND_MAX) -0.5;//eventGenerator->Uniform(-0.5,0.5); - int_y = y + ((double)rand())/((double)RAND_MAX) -0.5;//eventGenerator->Uniform(-0.5,0.5); - - return ; - }; - - virtual void getInterpolatedPosition(int x, int y, int *data, double &int_x, double &int_y) - { - return getInterpolatedPosition(x, y, (double*)NULL, int_x, int_y); - } - - - virtual void getInterpolatedPosition(int x, int y, double etax, double etay, int corner, double &int_x, double &int_y) - { - getInterpolatedPosition(x, y, (double*)NULL, int_x, int_y); - }; - - - - - virtual void getInterpolatedPosition(int x, int y, double totquad,int quad,double *cl,double &etax, double &etay){ - getInterpolatedPosition(x, y, (double*)NULL, etax, etay); - }; - - - virtual void getInterpolatedPosition(int x, int y, double totquad,int quad,int *cl,double &etax, double &etay){ - getInterpolatedPosition(x, y, (double*)NULL, etax, etay); - }; - - - - ////////////////////////////////////////////////////////////////////////////////////// - virtual void getPositionETA3(int x, int y, double *data, double &int_x, double &int_y) - { - //Random coordinate in the Pixel reference - int_x = x + ((double)rand())/((double)RAND_MAX) -0.5;//eventGenerator->Uniform(-0.5,0.5); - int_y = y + ((double)rand())/((double)RAND_MAX) -0.5;//eventGenerator->Uniform(-0.5,0.5); - - return ; - }; - - virtual void getPositionETA3(int x, int y, int *data, double &int_x, double &int_y) - { - return getPositionETA3(x, y, (double*)NULL, int_x, int_y); - }; - - - - ////////////////////////////////////////////////////////////////////////////////////// - virtual int addToFlatField(double *cluster, double &etax, double &etay){return 0;}; - - virtual int addToFlatField(int *cluster, double &etax, double &etay){return 0;}; - - virtual int addToFlatField(double etax, double etay){return 0;}; - - virtual int addToFlatField(double totquad,int quad,double *cl,double &etax, double &etay){return 0;}; - - - virtual int addToFlatField(double totquad,int quad,int *cl,double &etax, double &etay){return 0;}; - - - protected: - ; - // TRandom *eventGenerator; - // ClassDefNV(slsInterpolation,1); - // #pragma link C++ class slsInterpolation-; -}; - -#endif diff --git a/slsDetectorCalibration/interpolations/slsInterpolation.h b/slsDetectorCalibration/interpolations/slsInterpolation.h deleted file mode 100644 index 8059ddcc9..000000000 --- a/slsDetectorCalibration/interpolations/slsInterpolation.h +++ /dev/null @@ -1,534 +0,0 @@ -#ifndef SLS_INTERPOLATION_H -#define SLS_INTERPOLATION_H - -#ifdef MYROOT1 -#include -#include -#include -#endif - -#include -#ifndef MY_TIFF_IO_H -#include "tiffIO.h" -#endif - -#ifndef DEF_QUAD -#define DEF_QUAD - enum quadrant { - TOP_LEFT=0, - TOP_RIGHT=1, - BOTTOM_LEFT=2, - BOTTOM_RIGHT=3, - UNDEFINED_QUADRANT=-1 - }; -#endif -#include - -#include -#include -using namespace std; - -//#ifdef MYROOT1 -//: public TObject -//#endif -class slsInterpolation -{ - - public: - slsInterpolation(int nx=400, int ny=400, int ns=25) :nPixelsX(nx), nPixelsY(ny), nSubPixels(ns), id(0) { - -#ifdef MYROOT1 -hint=new TH2F("hint","hint",ns*nx, 0, nx, ns*ny, 0, ny); -#endif - -#ifndef MYROOT1 - hint=new int[ns*nx*ns*ny]; -#endif - -}; - - slsInterpolation(slsInterpolation *orig){ - nPixelsX=orig->nPixelsX; - nPixelsY=orig->nPixelsY; - nSubPixels=orig->nSubPixels; -#ifdef MYROOT1 - hint=(TH2F*)(orig->hint)->Clone("hint"); -#endif - -#ifndef MYROOT1 - hint=new int[nSubPixels*nPixelsX*nSubPixels*nPixelsY]; - memcpy(hint, orig->hint,nSubPixels*nPixelsX*nSubPixels*nPixelsY*sizeof(int)); -#endif - - }; - - virtual int setId(int i) {id=i; return id;}; - - virtual slsInterpolation* Clone() = 0; - - int getNSubPixels() {return nSubPixels;}; - - int getImageSize(int &nnx, int &nny, int &ns) { - nnx=nSubPixels*nPixelsX; - nny=nSubPixels*nPixelsY; - ns=nSubPixels; - return nSubPixels*nSubPixels*nPixelsX*nPixelsY; - }; - - - //create eta distribution, eta rebinnining etc. - //returns flat field image - virtual void prepareInterpolation(int &ok)=0; - - //create interpolated image - //returns interpolated image -#ifdef MYROOT1 - virtual TH2F *getInterpolatedImage(){return hint;}; -#endif - -#ifndef MYROOT1 - virtual int *getInterpolatedImage(){ - // cout << "return interpolated image " << endl; - /* for (int i=0; iReset(); -#endif -#ifndef MYROOT1 - for (int ix=0; ixFill(int_x, int_y); return hint;}; -#endif - -#ifndef MYROOT1 - virtual int *addToImage(double int_x, double int_y){ - int iy=((double)nSubPixels)*int_y; - int ix=((double)nSubPixels)*int_x; - if (ix>=0 && ix<(nPixelsX*nSubPixels) && iy<(nSubPixels*nPixelsY) && iy>=0 ){ - // cout << int_x << " " << int_y << " " << " " << ix << " " << iy << " " << ix+iy*nPixelsX*nSubPixels << " " << hint[ix+iy*nPixelsX*nSubPixels]; - (*(hint+ix+iy*nPixelsX*nSubPixels))+=1; - // cout << " " << hint[ix+iy*nPixelsX*nSubPixels] << endl; - }// else - // cout << "bad! "<< int_x << " " << int_y << " " << " " << ix << " " << iy << " " << ix+iy*nPixelsX*nSubPixels << endl; - - return hint; - }; -#endif - - - virtual int addToFlatField(double *cluster, double &etax, double &etay)=0; - virtual int addToFlatField(int *cluster, double &etax, double &etay)=0; - virtual int addToFlatField(double totquad,int quad,int *cl,double &etax, double &etay)=0; - virtual int addToFlatField(double totquad,int quad,double *cluster,double &etax, double &etay)=0; - virtual int addToFlatField(double etax, double etay)=0; - -#ifdef MYROOT1 - virtual TH2D *getFlatField(){return NULL;}; - virtual TH2D *setFlatField(TH2D *h, int nb=-1, double emin=-1, double emax=-1){return NULL;}; - virtual TH2D *getFlatField(int &nb, double &emin, double &emax){nb=0; emin=0; emax=0; return getFlatField();}; -#endif - -#ifndef MYROOT1 - virtual int *getFlatField(){return NULL;}; - virtual int *setFlatField(int *h, int nb=-1, double emin=-1, double emax=-1){return NULL;}; - void *writeFlatField(const char * imgname){return NULL;}; - void *readFlatField(const char * imgname, int nb=-1, double emin=1, double emax=0){return NULL;}; - virtual int *getFlatField(int &nb, double &emin, double &emax){nb=0; emin=0; emax=0; return getFlatField();}; -#endif - - //virtual void Streamer(TBuffer &b); - - static int calcQuad(int *cl, double &sum, double &totquad, double sDum[2][2]){ - double cli[3*3];//=new int[3*3]; - for (int i=0; i<9; i++) - cli[i]=cl[i]; - return calcQuad(cli, sum, totquad, sDum); - - } - - - static int calcQuad(double *cl, double &sum, double &totquad, double sDum[2][2]){ - - int corner = UNDEFINED_QUADRANT; - double *cluster[3]; - cluster[0]=cl; - cluster[1]=cl+3; - cluster[2]=cl+6; - - sum=0; - double sumBL=0; - double sumTL=0; - double sumBR=0; - double sumTR=0; - int xoff=0, yoff=0; - for (int ix=0; ix<3; ix++) { - for (int iy=0; iy<3; iy++) { - sum+=cluster[iy][ix]; - if (ix<=1 && iy<=1) sumBL+=cluster[iy][ix]; - if (ix<=1 && iy>=1) sumTL+=cluster[iy][ix]; - if (ix>=1 && iy<=1) sumBR+=cluster[iy][ix]; - if (ix>=1 && iy>=1) sumTR+=cluster[iy][ix]; - } - } - - /* sDum[0][0] = cluster[0][0]; sDum[1][0] = cluster[1][0]; */ - /* sDum[0][1] = cluster[0][1]; sDum[1][1] = cluster[1][1]; */ - corner = BOTTOM_LEFT; - totquad=sumBL; - - - if(sumTL >= totquad){ - /* sDum[0][0] = cluster[1][0]; sDum[1][0] = cluster[2][0]; */ - /* sDum[0][1] = cluster[1][1]; sDum[1][1] = cluster[2][1]; */ - - corner = TOP_LEFT; - totquad=sumTL; - xoff=0; - yoff=1; - } - - if(sumBR >= totquad){ - /* sDum[0][0] = cluster[0][1]; sDum[1][0] = cluster[1][1]; */ - /* sDum[0][1] = cluster[0][2]; sDum[1][1] = cluster[1][2]; */ - - xoff=1; - yoff=0; - corner = BOTTOM_RIGHT; - totquad=sumBR; - } - - if(sumTR >= totquad){ - xoff=1; - yoff=1; - /* sDum[0][0] = cluster[1][1]; sDum[1][0] = cluster[2][1]; */ - /* sDum[0][1] = cluster[1][2]; sDum[1][1] = cluster[2][2]; */ - corner = TOP_RIGHT; - totquad=sumTR; - } - - - for (int ix=0; ix<2; ix++) { - for (int iy=0; iy<2; iy++) { - sDum[iy][ix] = cluster[iy+yoff][ix+xoff]; - } - } - - return corner; - - } - - static int calcEta(double totquad, double sDum[2][2], double &etax, double &etay){ - double t,r; - - if (totquad>0) { - t = sDum[1][0] + sDum[1][1]; - r = sDum[0][1] + sDum[1][1]; - etax=r/totquad; - etay=t/totquad; - } - return 0; - - } - - static int calcEta(double *cl, double &etax, double &etay, double &sum, double &totquad, double sDum[2][2]) { - int corner = calcQuad(cl,sum,totquad,sDum); - calcEta(totquad, sDum, etax, etay); - - return corner; - } - - - static int calcEta(int *cl, double &etax, double &etay, double &sum, double &totquad, double sDum[2][2]) { - int corner = calcQuad(cl,sum,totquad,sDum); - calcEta(totquad, sDum, etax, etay); - - return corner; - } - - - static int calcEtaL(double totquad, int corner, double sDum[2][2], double &etax, double &etay){ - double t,r, toth, totv; - if (totquad>0) { - switch(corner) { - case TOP_LEFT: - t = sDum[1][1]; - r = sDum[0][1] ; - toth=sDum[0][1]+sDum[0][0]; - totv=sDum[0][1]+sDum[1][1]; - break; - case TOP_RIGHT: - t = sDum[1][0] ; - r = sDum[0][1] ; - toth=sDum[0][1]+sDum[0][0]; - totv=sDum[1][0]+sDum[0][0]; - break; - case BOTTOM_LEFT: - r = sDum[1][1] ; - t = sDum[1][1] ; - toth=sDum[1][0]+sDum[1][1]; - totv=sDum[0][1]+sDum[1][1]; - break; - case BOTTOM_RIGHT: - t = sDum[1][0] ; - r = sDum[1][1] ; - toth=sDum[1][0]+sDum[1][1]; - totv=sDum[1][0]+sDum[0][0]; - break; - default: - etax=-1000; - etay=-1000; - return 0; - } - //etax=r/totquad; - //etay=t/totquad; - etax=r/toth; - etay=t/totv; - } - return 0; - } - - - - static int calcEtaL(double *cl, double &etax, double &etay, double &sum, double &totquad, double sDum[2][2]) { - int corner = calcQuad(cl,sum,totquad,sDum); - calcEtaL(totquad, corner, sDum, etax, etay); - - return corner; - } - - static int calcEtaL(int *cl, double &etax, double &etay, double &sum, double &totquad, double sDum[2][2]) { - int corner = calcQuad(cl,sum,totquad,sDum); - calcEtaL(totquad, corner, sDum, etax, etay); - - return corner; - } - - - - static int calcEtaC3(double *cl, double &etax, double &etay, double &sum, double &totquad, double sDum[2][2]){ - - int corner = calcQuad(cl,sum,totquad,sDum); - calcEta(sum, sDum, etax, etay); - return corner; - - } - - - - static int calcEtaC3(int *cl, double &etax, double &etay, double &sum, double &totquad, double sDum[2][2]){ - - int corner = calcQuad(cl,sum,totquad,sDum); - calcEta(sum, sDum, etax, etay); - return corner; - - } - - - - static int calcEta3(double *cl, double &etax, double &etay, double &sum) { - double l=0,r=0,t=0,b=0, val; - sum=0; - // int quad; - for (int ix=0; ix<3; ix++) { - for (int iy=0; iy<3; iy++) { - val=cl[iy+3*ix]; - sum+=val; - if (iy==0) l+=val; - if (iy==2) r+=val; - if (ix==0) b+=val; - if (ix==2) t+=val; - } - } - if (sum>0) { - etax=(-l+r)/sum; - etay=(-b+t)/sum; - } - /* if (etax<-1 || etax>1 || etay<-1 || etay>1) { */ - /* cout << "**********" << etax << " " << etay << endl; */ - /* for (int ix=0; ix<3; ix++) { */ - /* for (int iy=0; iy<3; iy++) { */ - /* cout << cl[iy+3*ix] << "\t" ; */ - - /* } */ - /* cout << endl; */ - /* } */ - /* cout << sum << " " << l << " " << r << " " << t << " " << b << endl; */ - - /* } */ - - - if (etax>=0 && etay>=0) - return TOP_RIGHT; - if (etax<0 && etay>=0) - return TOP_LEFT; - if (etax<0 && etay<0) - return BOTTOM_LEFT; - return BOTTOM_RIGHT; - } - - - static int calcEta3(int *cl, double &etax, double &etay, double &sum) { - double cli[9]; - for (int ix=0; ix<9; ix++) cli[ix]=cl[ix]; - - return calcEta3(cli, etax, etay, sum); - } - - - static int calcMyEta(double totquad, int quad, double *cl, double &etax, double &etay) { - double l,r,t,b, sum; - int yoff; - switch (quad) { - case BOTTOM_LEFT: - case BOTTOM_RIGHT: - yoff=0; - break; - case TOP_LEFT: - case TOP_RIGHT: - yoff=1; - break; - default: - ; - } - l=cl[0+yoff*3]+cl[0+yoff*3+3]; - r=cl[2+yoff*3]+cl[2+yoff*3+3]; - b=cl[0+yoff*3]+cl[1+yoff*3]*cl[2+yoff*3]; - t=cl[0+yoff*3+3]+cl[1+yoff*3+3]*cl[0+yoff*3+3]; - sum=t+b; - if (sum>0) { - etax=(-l+r)/sum; - etay=(+t)/sum; - } - - return -1; - } - - static int calcMyEta(double totquad, int quad, int *cl, double &etax, double &etay) { - double l,r,t,b, sum; - int yoff; - switch (quad) { - case BOTTOM_LEFT: - case BOTTOM_RIGHT: - yoff=0; - break; - case TOP_LEFT: - case TOP_RIGHT: - yoff=1; - break; - default: - ; - } - l=cl[0+yoff*3]+cl[0+yoff*3+3]; - r=cl[2+yoff*3]+cl[2+yoff*3+3]; - b=cl[0+yoff*3]+cl[1+yoff*3]*cl[2+yoff*3]; - t=cl[0+yoff*3+3]+cl[1+yoff*3+3]*cl[0+yoff*3+3]; - sum=t+b; - if (sum>0) { - etax=(-l+r)/sum; - etay=(+t)/sum; - } - - return -1; - } - - - - static int calcEta3X(double *cl, double &etax, double &etay, double &sum) { - double l,r,t,b; - sum=cl[0]+cl[1]+cl[2]+cl[3]+cl[4]+cl[5]+cl[6]+cl[7]+cl[8]; - if (sum>0) { - l=cl[3]; - r=cl[5]; - b=cl[1]; - t=cl[7]; - etax=(-l+r)/sum; - etay=(-b+t)/sum; - } - return -1; - } - - - static int calcEta3X(int *cl, double &etax, double &etay, double &sum) { - double l,r,t,b; - sum=cl[0]+cl[1]+cl[2]+cl[3]+cl[4]+cl[5]+cl[6]+cl[7]+cl[8]; - if (sum>0) { - l=cl[3]; - r=cl[5]; - b=cl[1]; - t=cl[7]; - etax=(-l+r)/sum; - etay=(-b+t)/sum; - } - return -1; - } - - - - - - - protected: - int nPixelsX, nPixelsY; - int nSubPixels; -#ifdef MYROOT1 - TH2F *hint; -#endif -#ifndef MYROOT1 - int *hint; -#endif - int id; - -}; - -#endif diff --git a/slsDetectorCalibration/moench03CommonMode.h b/slsDetectorCalibration/moench03CommonMode.h deleted file mode 100644 index 7c950a9e4..000000000 --- a/slsDetectorCalibration/moench03CommonMode.h +++ /dev/null @@ -1,45 +0,0 @@ -#ifndef MOENCH03COMMONMODE_H -#define MOENCH03COMMONMODE_H - -#include "commonModeSubtraction.h" - -class moench03CommonMode : public commonModeSubtraction { - /** @short class to calculate the common mode noise for moench02 i.e. on 4 supercolumns separately */ - public: - /** constructor - initalizes a commonModeSubtraction with 4 different regions of interest - \param nn number of samples for the moving average - */ - moench03CommonMode(int nn=1000) : commonModeSubtraction(nn,32){} ; - - - /** add value to common mode as a function of the pixel value, subdividing the region of interest in the 4 supercolumns of 40 columns each; - \param val value to add to the common mode - \param ix pixel coordinate in the x direction - \param iy pixel coordinate in the y direction - */ - virtual void addToCommonMode(double val, int ix=0, int iy=0) { - // (void) iy; - int isc=ix/25+(iy/200)*16; - if (isc>=0 && isc=0 && isc0) return cmPed[isc]/nCm[isc]-cmStat[isc].Mean(); - } - return 0; - }; - -}; - - -#endif diff --git a/slsDetectorCalibration/moenchCommonMode.h b/slsDetectorCalibration/moenchCommonMode.h deleted file mode 100644 index dba0df2b7..000000000 --- a/slsDetectorCalibration/moenchCommonMode.h +++ /dev/null @@ -1,45 +0,0 @@ -#ifndef MOENCHCOMMONMODE_H -#define MOENCHCOMMONMODE_H - -#include "commonModeSubtraction.h" - -class moenchCommonMode : public commonModeSubtraction { - /** @short class to calculate the common mode noise for moench02 i.e. on 4 supercolumns separately */ - public: - /** constructor - initalizes a commonModeSubtraction with 4 different regions of interest - \param nn number of samples for the moving average - */ - moenchCommonMode(int nn=1000) : commonModeSubtraction(nn,4){} ; - - - /** add value to common mode as a function of the pixel value, subdividing the region of interest in the 4 supercolumns of 40 columns each; - \param val value to add to the common mode - \param ix pixel coordinate in the x direction - \param iy pixel coordinate in the y direction - */ - virtual void addToCommonMode(double val, int ix=0, int iy=0) { - (void) iy; - int isc=ix/40; - if (isc>=0 && isc=0 && isc0) return cmPed[isc]/nCm[isc]-cmStat[isc].Mean(); - } - return 0; - }; - -}; - - -#endif diff --git a/slsDetectorCalibration/moenchExecutables/Makefile.cluster_finder b/slsDetectorCalibration/moenchExecutables/Makefile.cluster_finder deleted file mode 100644 index b8414b77f..000000000 --- a/slsDetectorCalibration/moenchExecutables/Makefile.cluster_finder +++ /dev/null @@ -1,39 +0,0 @@ - -CBFLIBDIR= /afs/psi.ch/project/sls_det_software/CBFlib-0.9.5/ -#ZMQLIB=../slsReceiverSoftware/include -#LIBRARYCBF=$(CBFLIBDIR)/lib/*.o -INCDIR=-I. -I../ -I../interpolations -I../interpolations/etaVEL -I../dataStructures -I../../slsReceiverSoftware/include -I$(CBFLIBDIR)/include/ -#LIBHDF5= -LDFLAG= ../tiffIO.cpp -L/usr/lib64/ -lpthread -lm -lstdc++ -L. -pthread -lrt -L$(CBFLIBDIR)/lib/ -ltiff -#-L$(ZMQLIB) -lzmq -#-L../../bin -MAIN=moench03ClusterFinder.cpp -#-lhdf5 -#DESTDIR?=../bin - -all: moenchClusterFinder moenchMakeEta moenchInterpolation moenchNoInterpolation moenchPhotonCounter moenchAnalog - - - -moenchClusterFinder: $(MAIN) $(INCS) clean - g++ -o moenchClusterFinder $(MAIN) $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DSAVE_ALL -DOLDDATA #-DNEWRECEIVER - -moenchMakeEta: moench03MakeEta.cpp $(INCS) clean - g++ -o moenchMakeEta moench03MakeEta.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DSAVE_ALL - -moenchInterpolation: moench03Interpolation.cpp $(INCS) clean - g++ -o moenchInterpolation moench03Interpolation.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DSAVE_ALL - -moenchNoInterpolation: moench03NoInterpolation.cpp $(INCS) clean - g++ -o moenchNoInterpolation moench03NoInterpolation.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DSAVE_ALL - -moenchPhotonCounter: moenchPhotonCounter.cpp $(INCS) clean - g++ -o moenchPhotonCounter moenchPhotonCounter.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DSAVE_ALL -DNEWRECEIVER - -moenchAnalog: moenchPhotonCounter.cpp $(INCS) clean - g++ -o moenchAnalog moenchPhotonCounter.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DSAVE_ALL -DNEWRECEIVER -DANALOG - -clean: - rm -f moenchClusterFinder moenchMakeEta moenchInterpolation moenchNoInterpolation moenchPhotonCounter - - diff --git a/slsDetectorCalibration/moenchExecutables/Makefile.moench b/slsDetectorCalibration/moenchExecutables/Makefile.moench deleted file mode 100644 index b49a76212..000000000 --- a/slsDetectorCalibration/moenchExecutables/Makefile.moench +++ /dev/null @@ -1,20 +0,0 @@ - -CBFLIBDIR=/afs/psi.ch/project/sls_det_software/CBFlib-0.9.5 -LIBRARYCBF=$(CBFLIBDIR)/lib/*.o -INCDIR=-IslsDetectorCalibration -I../slsReceiverSoftware/include -I$(CBFLIBDIR)/include/ -I. -IetaVEL -LIBHDF5=-L$(CBFLIBDIR)/lib/ -lhdf5 -LDFLAG= -L/usr/lib64/ -lpthread -#-L../../bin -MAIN=moench03OnTheFlyAnalysis.C - -#DESTDIR?=../bin - -all: moench03OnTheFlyAnalysis - - - -moench03OnTheFlyAnalysis: $(MAIN) $(INCS) clean - g++ -o moench03OnTheFlyAnalysis $(MAIN) -lm -ltiff -lstdc++ $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DSAVE_ALL - -clean: - rm -f moench03OnTheFlyAnalysis diff --git a/slsDetectorCalibration/moenchExecutables/Makefile.moench_eta b/slsDetectorCalibration/moenchExecutables/Makefile.moench_eta deleted file mode 100644 index 7f575d6cb..000000000 --- a/slsDetectorCalibration/moenchExecutables/Makefile.moench_eta +++ /dev/null @@ -1,23 +0,0 @@ - -CBFLIBDIR= /home/l_msdetect/CBFlib-0.9.5 -ZMQLIB=../slsReceiverSoftware/include -LIBRARYCBF=$(CBFLIBDIR)/lib/*.o -INCDIR=-IslsDetectorCalibration -I../slsReceiverSoftware/include -I$(CBFLIBDIR)/include/ -I. -#-IetaVEL -LIBHDF5= -LDFLAG= -L/usr/lib64/ -lpthread -lm -lstdc++ -L. -lzmq -pthread -lrt -L$(CBFLIBDIR)/lib/ -lhdf5 -ltiff -L$(ZMQLIB) -#-L../../bin -MAIN=moench03ClusterFinder.cpp - -#DESTDIR?=../bin - -all: moench03ClusterFinder - - - -moench03ClusterFinder: $(MAIN) $(INCS) clean - g++ -o moenchClusterFinder $(MAIN) $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) tiffIO.cpp -DSAVE_ALL - -clean: - rm -f moench03ClusterFinder - diff --git a/slsDetectorCalibration/moenchExecutables/Makefile.moench_zmq b/slsDetectorCalibration/moenchExecutables/Makefile.moench_zmq deleted file mode 100644 index 1a6732a53..000000000 --- a/slsDetectorCalibration/moenchExecutables/Makefile.moench_zmq +++ /dev/null @@ -1,28 +0,0 @@ - -CBFLIBDIR=/afs/psi.ch/project/sls_det_software/CBFlib-0.9.5 -ZMQLIB=../../slsReceiverSoftware/include -LIBRARYCBF=$(CBFLIBDIR)/lib/*.o -INCDIR=-I../../slsReceiverSoftware/include -I$(CBFLIBDIR)/include/ -I. -I../dataStructures ../tiffIO.cpp -I../ -I../interpolations/ -LIBHDF5= -#-I../interpolations/etaVEL -LDFLAG= -L/usr/lib64/ -lpthread -lm -lstdc++ -L. -lzmq -pthread -lrt -lhdf5 -ltiff -L$(ZMQLIB) -L$(CBFLIBDIR)/lib/ -#-L../../bin - -#DESTDIR?=../bin - -all: moenchZmqClusterFinder moenchZmqInterpolating moenchZmqAnalog - - -moenchZmqInterpolating: $(MAIN) $(INCS) clean - g++ -o moenchZmqInterpolating moenchZmqInterpolating.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DSAVE_ALL - -moenchZmqClusterFinder: $(MAIN) $(INCS) clean - g++ -o moenchZmqClusterFinder moenchZmqClusterFinder.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DSAVE_ALL - -moenchZmqAnalog: $(MAIN) $(INCS) clean - g++ -o moenchZmqAnalog moenchZmqAnalog.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DSAVE_ALL - -clean: - rm -f moench03ZmqInterpolating moench03ZmqClusterFinder moenchZmqAnalog - - diff --git a/slsDetectorCalibration/moenchExecutables/Makefile.phoenix b/slsDetectorCalibration/moenchExecutables/Makefile.phoenix deleted file mode 100644 index 7379db1a7..000000000 --- a/slsDetectorCalibration/moenchExecutables/Makefile.phoenix +++ /dev/null @@ -1,24 +0,0 @@ - -CBFLIBDIR= /afs/psi.ch/project/sls_det_software/CBFlib-0.9.5/ -#ZMQLIB=../slsReceiverSoftware/include -LIBRARYCBF=$(CBFLIBDIR)/lib/*.o -INCDIR=-I.. -I. -I../interpolations -I../interpolations/etaVEL -I../../slsReceiverSoftware/include -I$(CBFLIBDIR)/include/ ../tiffIO.cpp -I../dataStructures -#LIBHDF5= -LDFLAG= -L/usr/lib64/ -lpthread -lm -lstdc++ -L. -pthread -lrt -L$(CBFLIBDIR)/lib/ -ltiff -lhdf5 -#-L$(ZMQLIB) -lzmq -#-L../../bin -MAIN=moench03ClusterFinderPhoenix.cpp -# -#DESTDIR?=../bin - -all: moenchClusterFinderPhoenix -#moenchMakeEtaPhoenix moenchInterpolationPhoenix - - - -moenchClusterFinderPhoenix: $(MAIN) $(INCS) clean - g++ -o moenchClusterFinderPhoenix $(MAIN) $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) - -clean: - rm -f moenchClusterFinderPhoenix - diff --git a/slsDetectorCalibration/moenchExecutables/Makefile.reoder_image b/slsDetectorCalibration/moenchExecutables/Makefile.reoder_image deleted file mode 100644 index 2ad256370..000000000 --- a/slsDetectorCalibration/moenchExecutables/Makefile.reoder_image +++ /dev/null @@ -1,22 +0,0 @@ - -CBFLIBDIR= /afs/psi.ch/project/sls_det_software/CBFlib-0.9.5/ -#ZMQLIB=../slsReceiverSoftware/include -INCDIR=-I. -I../ -I../interpolations -I../interpolations/etaVEL -I../dataStructures -I../../slsReceiverSoftware/include -I$(CBFLIBDIR)/include/ -LDFLAG= ../tiffIO.cpp -L/usr/lib64/ -lpthread -lm -lstdc++ -L. -pthread -lrt -L$(CBFLIBDIR)/lib/ -ltiff -MAIN=moench03ReorderImage.cpp - -all: moenchReorderImage moenchClusterFinder - - - -moenchReorderImage: $(MAIN) $(INCS) clean - g++ -o moenchReorderImage $(MAIN) $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DSAVE_ALL -DNEWRECEIVER - -moenchClusterFinder: moench03ClusterFinder.cpp - g++ -o moenchClusterFinder $(MAIN) $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DSAVE_ALL -DNEWRECEIVER - - -clean: - rm -f moenchReorderImage moenchClusterFinder - - diff --git a/slsDetectorCalibration/moenchExecutables/Makefile.tiff_to_th2f b/slsDetectorCalibration/moenchExecutables/Makefile.tiff_to_th2f deleted file mode 100644 index db51710b7..000000000 --- a/slsDetectorCalibration/moenchExecutables/Makefile.tiff_to_th2f +++ /dev/null @@ -1,27 +0,0 @@ -#INCSROOT= receiverGui.h -#INCS= $(INCSROOT) moench03_receiver.h -#LINKDEF=receiverGuiLinkDef.h - -#CBFLIBDIR= /afs/psi.ch/project/sls_det_software/CBFlib-0.9.5/ -#ZMQLIB=../slsReceiverSoftware/include -#LIBRARYCBF=$(CBFLIBDIR)/lib/*.o -INCDIR=-I. -I../ -I../interpolations -I../interpolations/etaVEL -I../dataStructures -I../../slsReceiverSoftware/include -I$(ROOTSYS)/include -#-I$(CBFLIBDIR)/include/ -#LIBHDF5= -LDFLAG= -L/usr/lib64/ -lpthread -lm -lstdc++ -L. -pthread -lrt -ltiff -#-L$(CBFLIBDIR)/lib/ -lhdf5 - -MAIN=tiff_to_th2f.cpp - - -all: tiff_to_th2f - - - -tiff_to_th2f: $(MAIN) $(INCS) - - g++ -o tiff_to_th2f $(MAIN) `root-config --cflags --glibs` -lMinuit -lm -ltiff -lstdc++ $(LDFLAG) $(INCDIR) ../tiffIO.cpp -#$(LIBRARYCBF) $(LIBHDF5) -clean: - rm -f tiff_to_th2f - diff --git a/slsDetectorCalibration/moenchExecutables/moench03ClusterFinder.cpp b/slsDetectorCalibration/moenchExecutables/moench03ClusterFinder.cpp deleted file mode 100644 index 0246c0c1a..000000000 --- a/slsDetectorCalibration/moenchExecutables/moench03ClusterFinder.cpp +++ /dev/null @@ -1,206 +0,0 @@ -//#include "ansi.h" -#include - - - -//#include "moench03T1ZmqData.h" -#ifdef NEWRECEIVER -#include "moench03T1ReceiverDataNew.h" -#endif -#ifdef CSAXS_FP -#include "moench03T1ReceiverData.h" -#endif -#ifdef OLDDATA -#include "moench03Ctb10GbT1Data.h" -#endif - -// #include "interpolatingDetector.h" -//#include "etaInterpolationPosXY.h" -// #include "linearInterpolation.h" -// #include "noInterpolation.h" -#include "multiThreadedAnalogDetector.h" -#include "singlePhotonDetector.h" -//#include "interpolatingDetector.h" - -#include -#include -#include -#include - -#include -using namespace std; - - -int main(int argc, char *argv[]) { - - - if (argc<6) { - cout << "Usage is " << argv[0] << "indir outdir fname runmin runmax " << endl; - return 1; - } - int p=10000; - int fifosize=1000; - int nthreads=1; - int nsubpix=25; - int etabins=nsubpix*10; - double etamin=-1, etamax=2; - int csize=3; - int nx=400, ny=400; - int save=1; - int nsigma=5; - int nped=1000; - int ndark=100; - int ok; - int iprog=0; - - - - - -#ifdef NEWRECEIVER - moench03T1ReceiverDataNew *decoder=new moench03T1ReceiverDataNew(); - cout << "RECEIVER DATA WITH ONE HEADER!"<readPedestals("/scratch/ped_100.tiff"); - // interp->readFlatField("/scratch/eta_100.tiff",etamin,etamax); - // cout << "filter "<< endl; - - - int size = 327680;////atoi(argv[3]); - - int* image; - //int* image =new int[327680/sizeof(int)]; - filter->newDataSet(); - - - int ff, np; - int dsize=decoder->getDataSize(); - cout << " data size is " << dsize; - - - char data[dsize]; - - ifstream filebin; - char *indir=argv[1]; - char *outdir=argv[2]; - char *fformat=argv[3]; - int runmin=atoi(argv[4]); - int runmax=atoi(argv[5]); - - char fname[10000]; - char outfname[10000]; - char imgfname[10000]; - char pedfname[10000]; - // strcpy(pedfname,argv[6]); - char fn[10000]; - - std::time_t end_time; - - FILE *of=NULL; - cout << "input directory is " << indir << endl; - cout << "output directory is " << outdir << endl; - cout << "fileformat is " << fformat << endl; - - - std::time(&end_time); - cout << std::ctime(&end_time) << endl; - - - - - - - - - char* buff; - multiThreadedAnalogDetector *mt=new multiThreadedAnalogDetector(filter,nthreads,fifosize); - - - mt->setFrameMode(eFrame); - mt->StartThreads(); - mt->popFree(buff); - - - cout << "mt " << endl; - - int ifr=0; - - - for (int irun=runmin; irunsetFilePointer(of); - // cout << "file pointer set " << endl; - } else { - cout << "Could not open "<< outfname << " for writing " << endl; - mt->setFilePointer(NULL); - return 1; - } - // //while read frame - ff=-1; - while (decoder->readNextFrame(filebin, ff, np,buff)) { - // cout << "*"<pushData(buff); - // // //pop - mt->nextThread(); - // // // cout << " " << (void*)buff; - mt->popFree(buff); - ifr++; - if (ifr%10000==0) cout << ifr << " " << ff << endl; - ff=-1; - } - cout << "--" << endl; - filebin.close(); - // //close file - // //join threads - while (mt->isBusy()) {;}//wait until all data are processed from the queues - if (of) - fclose(of); - - mt->writeImage(imgfname); - mt->clearImage(); - - std::time(&end_time); - cout << std::ctime(&end_time) << endl; - - } else - cout << "Could not open "<< fname << " for reading " << endl; - - - } - - - return 0; -} - diff --git a/slsDetectorCalibration/moenchExecutables/moench03ClusterFinderPhoenix.cpp b/slsDetectorCalibration/moenchExecutables/moench03ClusterFinderPhoenix.cpp deleted file mode 100644 index 7ae1f4559..000000000 --- a/slsDetectorCalibration/moenchExecutables/moench03ClusterFinderPhoenix.cpp +++ /dev/null @@ -1,201 +0,0 @@ -//#include "ansi.h" -#include - -//#include "moench03T1ZmqData.h" -//#include "moench03T1ReceiverData.h" - -#include "moench03Ctb10GbT1Data.h" - -// #include "interpolatingDetector.h" -//#include "etaInterpolationPosXY.h" -// #include "linearInterpolation.h" -// #include "noInterpolation.h" -#include "multiThreadedAnalogDetector.h" -#include "singlePhotonDetector.h" -//#include "interpolatingDetector.h" - -#include -#include -#include -#include - -#include -using namespace std; - - -int main(int argc, char *argv[]) { - - - if (argc<6) { - cout << "Usage is " << argv[0] << "indir outdir fname runmin runmax " << endl; - return 0; - } - int ii=0; - int p=10000; - int fifosize=1000; - int nthreads=5; - int nsubpix=25; - int etabins=nsubpix*10; - double etamin=-1, etamax=2; - int csize=3; - int nx=400, ny=400; - int save=1; - int nsigma=5; - int nped=1000; - int ndark=100; - int ok; - int iprog=0; - moench03Ctb10GbT1Data *decoder=new moench03Ctb10GbT1Data(); - cout << "decoder" << endl; - //moench03T1ReceiverData *decoder=new moench03T1ReceiverData(); - //moench03T1ZmqData *decoder=new moench03T1ZmqData(); - singlePhotonDetector *filter=new singlePhotonDetector(decoder,csize, nsigma, 1, 0, nped, 100); - // char tit[10000]; - cout << "filter" << endl; - - - - - // filter->readPedestals("/scratch/ped_100.tiff"); - // interp->readFlatField("/scratch/eta_100.tiff",etamin,etamax); - // cout << "filter "<< endl; - - - int size = 327680;////atoi(argv[3]); - - int* image; - //int* image =new int[327680/sizeof(int)]; - filter->newDataSet(); - - cout << "dataset" << endl; - - int ff, np; - int dsize=decoder->getDataSize(); - cout << " data size is " << dsize << endl; - - - char data[dsize]; - - ifstream filebin; - char *indir=argv[1]; - cout << "input directory is " << indir << endl; - char *outdir=argv[2]; - cout << "output directory is " << outdir << endl; - char *fformat=argv[3]; - cout << "fileformat is " << fformat << endl; - int runmin=atoi(argv[4]); - cout << "runmin : " << runmin << endl; - int runmax=atoi(argv[5]); - cout << "runmax : " << runmax << endl; - - char fname[10000]; - char outfname[10000]; - char imgfname[10000]; - char pedfname[10000]; - char fn[10000]; - - std::time_t end_time; - - FILE *of=NULL; - - - cout << "time " << endl; - std::time(&end_time); - cout << std::ctime(&end_time) << endl; - filter->setFrameMode(eFrame); - // mt->setFrameMode(ePedestal); - - - // for (int ix=0; ix<400; ix++) - // for (int iy=0; iy<400; iy++) - // cout << ix << " " << iy << " " << filter->getPedestal(ix,iy) << " " << filter->getPedestalRMS(ix,iy) << endl; - - - char* buff; - cout << "aa " << endl; - multiThreadedAnalogDetector *mt=new multiThreadedAnalogDetector(filter,nthreads,fifosize); - cout << "mt " << endl; - - // mt->setFrameMode(eFrame); //need to find a way to switch between flat and frames! - // mt->prepareInterpolation(ok); - mt->setFrameMode(eFrame); - mt->StartThreads(); - mt->popFree(buff); - - - - int ifr=0; - // //loop on files - // mt->setFrameMode(eFrame); - //mt->setFrameMode(eFlat); - - - - - - for (int irun=runmin; irunsetFilePointer(of); - // cout << "file pointer set " << endl; - } else { - cout << "Could not open "<< outfname << " for writing " << endl; - mt->setFilePointer(NULL); - return 1; - } - // //while read frame - ff=-1; - while (decoder->readNextFrame(filebin, ff, np,buff)) { - //cout << "*"<pushData(buff); - // // //pop - mt->nextThread(); - // // // cout << " " << (void*)buff; - mt->popFree(buff); - - ff=-1; - ii++; - if (ii%10000==0) { - - cout << ii << endl; - - while (mt->isBusy()) {;}//wait until all data are processed from the queues - mt->writeImage("/scratch/tmp.tiff"); - } - } - // cout << "--" << endl; - filebin.close(); - // //close file - // //join threads - while (mt->isBusy()) {;}//wait until all data are processed from the queues - if (of) - fclose(of); - - mt->writeImage(imgfname); - mt->clearImage(); - - std::time(&end_time); - cout << std::ctime(&end_time) << endl; - - } else - cout << "Could not open "<< fname << " for reading " << endl; - - - } - - - return 0; -} - diff --git a/slsDetectorCalibration/moenchExecutables/moench03Interpolation.cpp b/slsDetectorCalibration/moenchExecutables/moench03Interpolation.cpp deleted file mode 100644 index 2d852a164..000000000 --- a/slsDetectorCalibration/moenchExecutables/moench03Interpolation.cpp +++ /dev/null @@ -1,322 +0,0 @@ - -#include "ansi.h" -#include - -//#include "moench03T1ZmqData.h" -//#define DOUBLE_SPH -//#define MANYFILES - -#ifdef DOUBLE_SPH -#include "single_photon_hit_double.h" -#endif - -#ifndef DOUBLE_SPH -#include "single_photon_hit.h" -#endif - -#include "etaInterpolationPosXY.h" -#include "noInterpolation.h" -//#include "etaInterpolationAdaptiveBins.h" -//#include "etaInterpolationRandomBins.h" -using namespace std; -#define NC 400 -#define NR 400 - - -#define XTALK - -int main(int argc, char *argv[]) { -/** - * trial.o [socket ip] [starting port number] [outfname] - * - */ - - if (argc<9) { - cout << "Wrong usage! Should be: "<< argv[0] << " infile " << " etafile outfile runmin runmax ns cmin cmax" << endl; - return 1; - } - - char infname[10000]; - char fname[10000]; - char outfname[10000]; - int runmin=atoi(argv[4]); - int runmax=atoi(argv[5]); - int nsubpix=atoi(argv[6]); - float cmin=atof(argv[7]); - float cmax=atof(argv[8]); - - int etabins=1000;//nsubpix*2*100; - double etamin=-1, etamax=2; - double eta3min=-2, eta3max=2; - int quad; - double sum, totquad; - double sDum[2][2]; - double etax, etay, int_x, int_y; - double eta3x, eta3y, int3_x, int3_y, noint_x, noint_y; - int ok; - int f0=-1; - int ix, iy, isx, isy; - int nframes=0, lastframe=-1; - double d_x, d_y, res=5, xx, yy; -#ifdef MANYFILES - int ff=1000; -#endif - int nph=0, badph=0, totph=0; - FILE *f=NULL; - -#ifdef DOUBLE_SPH - single_photon_hit_double cl(3,3); -#endif - -#ifndef DOUBLE_SPH - single_photon_hit cl(3,3); -#endif - -#ifdef XTALK - int old_val[3][3]; - int new_val[3][3]; - double xcorr=0.04; - - // int ix=0; -#endif - - - eta2InterpolationPosXY *interp=new eta2InterpolationPosXY(NC, NR, nsubpix, etabins, etamin, etamax); - eta3InterpolationPosXY *interp3=new eta3InterpolationPosXY(NC, NR, nsubpix, etabins, eta3min, eta3max); - noInterpolation *dummy=new noInterpolation(NC, NR, nsubpix); - noInterpolation *nointerp=new noInterpolation(NC, NR, nsubpix); - noInterpolation *mult=new noInterpolation(NC, NR, nsubpix); - //etaInterpolationAdaptiveBins *interp=new etaInterpolationAdaptiveBins (NC, NR, nsubpix, etabins, etamin, etamax); - //etaInterpolationRandomBins *interp=new etaInterpolationRandomBins (NC, NR, nsubpix, etabins, etamin, etamax); - //#ifndef FF - cout << "read ff " << argv[2] << endl; - sprintf(fname,"%s_eta2.tiff",argv[2]); - interp->readFlatField(fname); - interp->prepareInterpolation(ok); - - sprintf(fname,"%s_eta3.tiff",argv[2]); - interp3->readFlatField(fname); - interp3->prepareInterpolation(ok); - //#endif - - int *img; - float *totimg=new float[NC*NR*nsubpix*nsubpix]; - for (ix=0; ixwriteInterpolatedImage(outfname); - interp->clearInterpolatedImage(); - } -#endif - - } -#ifdef XTALK - if ((cl.x+1)%25!=0) { - for (int ix=-1; ix<2; ix++) { - for (int iy=-1; iy<2; iy++) { - old_val[iy+1][ix+1]=cl.get_data(ix,iy); - if (ix>=0) { - new_val[iy+1][ix+1]=old_val[iy+1][ix+1]-old_val[iy+1][ix]*xcorr; - cl.set_data(new_val[iy+1][ix+1],ix,iy); - } - } - } - } -#endif - quad=interp->calcQuad(cl.get_cluster(), sum, totquad, sDum); - if (sum>cmin && totquad/sum>0.8 && totquad/sum<1.2 && totquad200 && sum<580) { - // interp->getInterpolatedPosition(cl.x,cl.y, totquad,quad,cl.get_cluster(),int_x, int_y); - interp->getInterpolatedPosition(cl.x,cl.y, cl.get_cluster(),int_x, int_y); - interp->addToImage(int_x, int_y); - interp3->getInterpolatedPosition(cl.x,cl.y, cl.get_cluster(),int3_x, int3_y); - interp3->addToImage(int3_x, int3_y); - nointerp->getInterpolatedPosition(cl.x,cl.y, cl.get_cluster(),noint_x, noint_y); - nointerp->addToImage(noint_x, noint_y); - - - d_x= (int_x-int3_x)*25.; - d_y= (int_y-int3_y)*25.; - dummy->calcEta(totquad, sDum, etax, etay); - xx=int_x; - yy=int_y; - if (etax<0.1 || etax>0.9) xx=int3_x; - if (etay<0.1 || etay>0.9) yy=int3_y; - dummy->addToImage(xx,yy); - - if (d_x>res || d_x<-res || d_y>res || d_y<-res) { - badph++; - // cout << "delta (um): "<< d_x << " " << d_y << " " << cl.x << " " << cl.y << endl; - // cout << sum << " " << totquad << " " << etax << " "<< etay << endl; - // //cout<< int_x << " " << int_y << " " << int3_x << " " << int3_y << endl; - } - mult->addToImage(noint_x, noint_y); - - if (nph%1000000==0) cout << nph << endl; - if (nph%100000000==0) { - sprintf(outfname,"%s_inteta2.tiff", argv[3]); - interp->writeInterpolatedImage(outfname); - sprintf(outfname,"%s_inteta3.tiff", argv[3]); - interp3->writeInterpolatedImage(outfname); - sprintf(outfname,"%s_mix.tiff", argv[3]); - dummy->writeInterpolatedImage(outfname); - sprintf(outfname,"%s_noint.tiff", argv[3]); - nointerp->writeInterpolatedImage(outfname); - sprintf(outfname,"%s_mult.tiff", argv[3]); - mult->writeInterpolatedImage(outfname); - } - - } else { - mult->getInterpolatedPosition(cl.x,cl.y, cl.get_cluster(),int_x, int_y); - for (int imult=0; imult<2.*sum/(cmax+cmin); imult++) mult->addToImage(int_x, int_y); - } - - - } - fclose(f); -#ifdef FF - img=interp->getInterpolatedImage(); - for (isx=0; isxwriteInterpolatedImage(outfname); - sprintf(outfname,"%s_inteta3.tiff", argv[3]); - interp3->writeInterpolatedImage(outfname); - sprintf(outfname,"%s_mix.tiff", argv[3]); - dummy->writeInterpolatedImage(outfname); - sprintf(outfname,"%s_mult.tiff", argv[3]); - mult->writeInterpolatedImage(outfname); - -#ifndef MANYFILES - img=interp->getInterpolatedImage(); - for (ix=0; ixclearInterpolatedImage(); - interp3->clearInterpolatedImage(); - dummy->clearInterpolatedImage(); - mult->clearInterpolatedImage(); - - } else - cout << "could not open file " << infname << endl; - } - cout << irun << " " << runmax << endl; -#ifndef MANYFILES - sprintf(outfname,argv[3],11111); - WriteToTiff(totimg, outfname,NC*nsubpix,NR*nsubpix); -#endif - cout << "Filled " << nph << " (/"<< totph <<") of which " << badph << " badly interpolated " << endl; - return 0; -} - diff --git a/slsDetectorCalibration/moenchExecutables/moench03MakeEta.cpp b/slsDetectorCalibration/moenchExecutables/moench03MakeEta.cpp deleted file mode 100644 index c2f2f92cd..000000000 --- a/slsDetectorCalibration/moenchExecutables/moench03MakeEta.cpp +++ /dev/null @@ -1,114 +0,0 @@ - -#include "ansi.h" -#include - -#include "moench03T1ZmqData.h" -#include "single_photon_hit.h" - - #include "etaInterpolationPosXY.h" - -using namespace std; -#define NC 400 -#define NR 400 - -#define XTALK - -int main(int argc, char *argv[]) { -/** - * trial.o [socket ip] [starting port number] [outfname] - * - */ - int nsubpix=10; - int etabins=nsubpix*100; - double etamin=-1, etamax=2; - double eta3min=-2, eta3max=2; - int quad; - double sum, totquad; - double sDum[2][2]; - char fname[10000]; - double etax, etay; - int runmin, runmax; - single_photon_hit cl(3,3); -int iph=0; - - if (argc<7) { - cout << "Wrong usage! Should be: "<< argv[0] << " infile " << " outfile runmin runmax cmin cmax" << endl; - return 1; - } - - eta2InterpolationPosXY *interp2=new eta2InterpolationPosXY(NR, NC, nsubpix, etabins, etamin, etamax); - cout << "###########"<< endl; - eta3InterpolationPosXY *interp3=new eta3InterpolationPosXY(NR, NC, nsubpix, etabins, eta3min, eta3max); - // cout << eta3min << " " << eta3max << endl; - runmin=atoi(argv[3]); - runmax=atoi(argv[4]); - double cmin=atof(argv[5]); //200 - double cmax=atof(argv[6]); //3000 - -#ifdef XTALK - int old_val[3][3]; - int new_val[3][3]; - double xcorr=0.04; - - // int ix=0; -#endif - - FILE *f; - for (int i=runmin; i=0) { - new_val[iy+1][ix+1]=old_val[iy+1][ix+1]-old_val[iy+1][ix]*xcorr; - cl.set_data(new_val[iy+1][ix+1],ix,iy); - } - } - } - } -#endif - quad=interp2->calcQuad(cl.get_cluster(), sum, totquad, sDum); - - if (sum>cmin && totquad/sum>0.8 && totquad/sum<1.2 && totquadaddToFlatField(cl.get_cluster(),etax, etay); - // if (etax>0.49 && etax<0.51 && etay>0.49 && etay<0.51 ) { - // cout << cl.y << " " << cl.x << " " << quad << " "<< totquad << " " <addToFlatField(cl.get_cluster(),etax, etay); - iph++; - if (iph%1000000==0) cout << iph << endl; - if (iph%100000000==0) { - sprintf(fname,"%s_eta2.tiff",argv[2]); - interp2->writeFlatField(fname); - sprintf(fname,"%s_eta3.tiff",argv[2]); - interp3->writeFlatField(fname); - } - // if (iph>1E8) break; - } - // } - - } - fclose(f); - - } - else cout << "could not open file " << fname << endl; - } - - sprintf(fname,"%s_eta2.tiff",argv[2]); - interp2->writeFlatField(fname); - sprintf(fname,"%s_eta3.tiff",argv[2]); - interp3->writeFlatField(fname); - return 0; -} - diff --git a/slsDetectorCalibration/moenchExecutables/moench03NoInterpolation.cpp b/slsDetectorCalibration/moenchExecutables/moench03NoInterpolation.cpp deleted file mode 100644 index 9ff0ea900..000000000 --- a/slsDetectorCalibration/moenchExecutables/moench03NoInterpolation.cpp +++ /dev/null @@ -1,171 +0,0 @@ - -#include "ansi.h" -#include - -#include "moench03T1ZmqData.h" -#include "single_photon_hit.h" - -#include "noInterpolation.h" - -using namespace std; -#define NC 400 -#define NR 400 - - -int main(int argc, char *argv[]) { -/** - * trial.o [socket ip] [starting port number] [outfname] - * - */ - - if (argc<7) { - cout << "Wrong usage! Should be: "<< argv[0] << " infile " << " etafile outfile runmin runmax ns" << endl; - return 1; - } - - char infname[10000]; - char outfname[10000]; - int runmin=atoi(argv[4]); - int runmax=atoi(argv[5]); - int nsubpix=atoi(argv[6]); - - int etabins=1000;//nsubpix*2*100; - double etamin=-1, etamax=2; - int quad; - double sum, totquad; - double sDum[2][2]; - double etax, etay, int_x, int_y; - int ok; - - int ix, iy, isx, isy; - - - FILE *f=NULL; - - single_photon_hit cl(3,3); - // etaInterpolationPosXY *interp=new etaInterpolationPosXY(NC, NR, nsubpix, etabins, etamin, etamax); - noInterpolation *interp=new noInterpolation(NC, NR, nsubpix); - // interp->readFlatField(argv[2]); - // interp->prepareInterpolation(ok); - - int *img; - float *totimg=new float[NC*NR*nsubpix*nsubpix]; - for (ix=0; ixcalcQuad(cl.get_cluster(), sum, totquad, sDum); - if (sum>200 && sum<580) { - interp->getInterpolatedPosition(cl.x,cl.y, totquad,quad,cl.get_cluster(),int_x, int_y); - interp->addToImage(int_x, int_y); - } - } - fclose(f); -#ifdef FF - img=interp->getInterpolatedImage(); - for (isx=0; isxwriteInterpolatedImage(outfname); - img=interp->getInterpolatedImage(); - for (ix=0; ixclearInterpolatedImage(); - - } - } - - sprintf(outfname,argv[3],11111); - WriteToTiff(totimg, outfname,NC*nsubpix,NR*nsubpix); - - return 0; -} - diff --git a/slsDetectorCalibration/moenchExecutables/moench03ReorderImage.cpp b/slsDetectorCalibration/moenchExecutables/moench03ReorderImage.cpp deleted file mode 100644 index 69b9b20c8..000000000 --- a/slsDetectorCalibration/moenchExecutables/moench03ReorderImage.cpp +++ /dev/null @@ -1,163 +0,0 @@ -//#include "ansi.h" -#include - - - -//#include "moench03T1ZmqData.h" - -#include "moench03T1ReceiverDataNew.h" - -// #include "interpolatingDetector.h" -//#include "etaInterpolationPosXY.h" -// #include "linearInterpolation.h" -// #include "noInterpolation.h" -//#include "interpolatingDetector.h" - -#include -#include -#include -#include - -#include - -#include -using namespace std; - -#define NX 400 //number of x pixels -#define NY 400 //number of y pixels - -int main(int argc, char *argv[]) { - - - if (argc<6) { - cout << "Usage is " << argv[0] << "indir outdir fname runmin runmax " << endl; - return 1; - } - int p=10000; - int fifosize=1000; - int nthreads=8; - int nsubpix=25; - int etabins=nsubpix*10; - double etamin=-1, etamax=2; - int csize=3; - int nx=400, ny=400; - int save=1; - int nsigma=5; - int nped=1000; - int ndark=100; - int ok; - int iprog=0; - - - - - moench03T1ReceiverDataNew *decoder=new moench03T1ReceiverDataNew(); - - - uint16_t data[NY*NX]; - - - int size = 327680;////atoi(argv[3]); - - int* image; - - int ff, np; - int dsize=decoder->getDataSize(); - - - //char data[dsize]; - - ifstream filebin; - char *indir=argv[1]; - char *outdir=argv[2]; - char *fformat=argv[3]; - int runmin=atoi(argv[4]); - int runmax=atoi(argv[5]); - - char fname[10000]; - char outfname[10000]; - char imgfname[10000]; - char pedfname[10000]; - // strcpy(pedfname,argv[6]); - char fn[10000]; - - std::time_t end_time; - - FILE *of=NULL; - cout << "input directory is " << indir << endl; - cout << "output directory is " << outdir << endl; - cout << "fileformat is " << fformat << endl; - - - std::time(&end_time); - cout << std::ctime(&end_time) << endl; - - - - - - - - char* buff; - - - - - int ifr=0; - - - for (int irun=runmin; irunreadNextFrame(filebin, ff, np,buff)) { - for (int ix=0; ix<400; ix++) - for (int iy=0; iy<400; iy++) - data[iy*NX+ix]=decoder->getChannel(buff,ix,iy); - - ifr++; - - fwrite(&ff, 8, 1,of);//write detector frame number - fwrite(&ifr, 8, 1,of);//write datset frame number - fwrite(data,2,NX*NY,of);//write reordered data - - if (ifr%10000==0) cout << ifr << " " << ff << endl; - ff=-1; - - } - cout << "--" << endl; - filebin.close(); - // //close file - // //join threads - - if (of) - fclose(of); - - std::time(&end_time); - cout << std::ctime(&end_time) << endl; - - } else - cout << "Could not open "<< fname << " for reading " << endl; - - - } - - - return 0; -} - diff --git a/slsDetectorCalibration/moenchExecutables/moenchZmqAnalog.cpp b/slsDetectorCalibration/moenchExecutables/moenchZmqAnalog.cpp deleted file mode 100644 index 4cbee47d0..000000000 --- a/slsDetectorCalibration/moenchExecutables/moenchZmqAnalog.cpp +++ /dev/null @@ -1,394 +0,0 @@ -//#define ROOTSPECTRUM - -#include "multiThreadedAnalogDetector.h" - -#include "sls_receiver_defs.h" -#include "ZmqSocket.h" -#include "moench03T1ZmqDataNew.h" - -#ifdef ROOTSPECTRUM -#include -#include -#include -#include -#include -#include -#include -#include -#endif - -#include -#include -#include -#include -#include -#include "tiffIO.h" - -#include - -//#include "analogDetector.h" -#include "singlePhotonDetector.h" -#include "ansi.h" -#include -using namespace std; - - -#define SLS_DETECTOR_JSON_HEADER_VERSION 0x2 - - -int main(int argc, char *argv[]) { -/** - * trial.o [socket ip] [starting port number] [send_socket ip] [send port number] - * - */ - int fifosize=1000; - int nthreads=20; - char* buff; - char tit[10000]; - // help - if (argc < 3 ) { - cprintf(RED, "Help: ./trial [receive socket ip] [receive starting port number] [send_socket ip] [send starting port number]\n"); - return EXIT_FAILURE; - } - - // receive parameters - bool send = false; - char* socketip=argv[1]; - uint32_t portnum = atoi(argv[2]); - int size = 32*2*5000;//atoi(argv[3]); - - // send parameters if any - char* socketip2 = 0; - uint32_t portnum2 = 0; - if (argc > 3) { - send = true; - socketip2 = argv[3]; - portnum2 = atoi(argv[4]); - } - cout << "\nrx socket ip : " << socketip << - "\nrx port num : " << portnum ; - if (send) { - cout << "\nsd socket ip : " << socketip2 << - "\nsd port num : " << portnum2; - } - cout << endl; - - //slsDetectorData *det=new moench03T1ZmqDataNew(); - moench03T1ZmqDataNew *det=new moench03T1ZmqDataNew(); - analogDetector *filter=new analogDetector(det,1,NULL,1000); - //singlePhotonDetector *filter=new singlePhotonDetector(det,3, 5, 1, 0, 1000, 10); - //filter->setROI(250, 400, 30, 150); - float threshold=1; - if (argc > 5) { - threshold=atof(argv[5]); - filter->setThreshold(threshold); - cout << "Threshold set to " << threshold << endl; - } - - int nnx, nny, nns; - int imsize=filter->getImageSize(nnx,nny,nns); - - multiThreadedAnalogDetector *mt=new multiThreadedAnalogDetector(filter,nthreads,fifosize); - - - - // mt->prepareInterpolation(ok); - mt->StartThreads(); - mt->popFree(buff); - - - - cout << "det " << endl; - int16_t dout[400*400]; - double ddark[400*400]; - cout << "dout " << endl; - - // receive socket - ZmqSocket* zmqsocket = new ZmqSocket(socketip,portnum); -#ifdef ROOTSPECTRUM - TH2F *h2=NULL; - TH2F *hmap=NULL; - TFile *froot=NULL; - - h2=new TH2F("hs","hs",500,-500,500,400*400,-0.5,400*400-0.5); - hmap=new TH2F("hmap","hmap",400,-0.5,400-0.5,400,-0.5,400-0.5); -#endif - cout << "zmq1 " << endl; - - if (zmqsocket->IsError()) { - cprintf(RED, "Error: Could not create Zmq socket on port %d with ip %s\n", portnum, socketip); - delete zmqsocket; - return EXIT_FAILURE; - } - zmqsocket->Connect(); - printf("Zmq Client at %s\n", zmqsocket->GetZmqServerAddress()); - - // send socket - ZmqSocket* zmqsocket2 = 0; - cout << "zmq2 " << endl; - if (send) { - zmqsocket2 = new ZmqSocket(portnum2, socketip2); - if (zmqsocket2->IsError()) { - bprintf(RED, "Error: Could not create Zmq socket server on port %d and ip %s\n", portnum2, socketip2); - delete zmqsocket2; - delete zmqsocket; - return EXIT_FAILURE; - } - zmqsocket2->Connect(); - printf("Zmq Server started at %s\n", zmqsocket2->GetZmqServerAddress()); - // zmqsocket2->Disconnect(); - } - - - // header variables - uint64_t acqIndex = -1; - uint64_t frameIndex = -1; - uint32_t subframeIndex = -1; - uint64_t fileindex = -1; - string filename = ""; - //char* image = new char[size]; - //int* image = new int[(size/sizeof(int))](); - - int *nph;//[400*400]; - int iframe=0; - char rootfname[10000]; - - char fname[10000]; - char ff[10000]; - int fi; - int length; - char newped=-1, ped=-1, dat=-1, isdark=-1; - - double *peds; - int *im; - int fnumber; - float *gm=new float[400*400]; - // infinite loop - while(1) { - - - // cout << "+++++++++++++++++++++++++++++++LOOP" << endl; - // get header, (if dummy, fail is on parse error or end of acquisition) - if (!zmqsocket->ReceiveHeader(0, acqIndex, frameIndex, subframeIndex, filename, fileindex)){ - // if (!zmqsocket->ReceiveHeader(0, acqIndex, frameIndex, subframeIndex, filename, fileindex)) { - cprintf(RED, "Got Dummy\n"); - while (mt->isBusy()) {;}//wait until all data are processed from the queues - if (dat==1) { - - sprintf(tit,"%s_%lld.tiff",filename.c_str(),fi); - cout << tit << endl; - im=mt->getImage(nnx,nny,nns); - if (isdark) cout << "getting dark "<< endl; - else cout << "subtracting dark"<< endl; - if (gm) { - for (int ii=0; ii<400*400; ii++) { - // if (image[ix]>0) cout << ix << " " << image[ix]<< endl; - if (isdark) { - ddark[ii]=(double)im[ii]/((double)iframe); - if (ddark[ii]>0) cout << "*" ; - gm[ii]=im[ii]; - if (send) dout[ii]=im[ii]; - } else { - gm[ii]=im[ii];//-ddark[ii]*iframe; - if (gm[ii]<0) gm[ii]=0; - if (send) dout[ii]=gm[ii]; - } - //cout << endl; - - } - cout << endl; - //cout << "image " << nnx << " " << nny << endl; - WriteToTiff(gm,tit ,nnx, nny); - // delete [] gm; - } else cout << "Could not allocate float image " << endl; - - - - } else { - - sprintf(tit,"%s_%lld.tiff",filename.c_str(),fi); - cout << tit << endl; - mt->writePedestal(tit); - - } - - // mt->writeImage(tit); - // cout << "wrote" << endl; - - - - - - - - - if (send) { - if (dat==1) { - //im=mt->getImage(nnx,nny,nns); - - //if (im) - // cout << "got image" << endl; - //else - // cout << "could not get image" << endl; - - - //for (int ii=0; ii<400*400; ii++) { - //if (im[ii]>0) - //cout << im[ii] << endl; - // if (im[ii]>=0) - - // if (isdark) { - //ddark[ii]=im[ii]; - // dout[ii]=im[ii]; - // } else { - // dout[ii]=im[ii]-ddark[ii]; - // if (dout[ii]<0) dout[ii]=0; - // } - // else - // dout[ii]=0; - //else - //dout[ii]=0; - // cout << im[ii] << " " << dout[ii] << endl; - // } - //for (int iiy=49; iiy<52; iiy++) - // for (int iix=80; iix<83; iix++) - // dout[iiy*400+iix]=0; - ; - } else { - peds=mt->getPedestal(); - // sprintf(tit,"%s_%lld.tiff",filename.c_str(),fi); - //cout << tit << endl; - //mt->writePedestal(tit); - if (peds) - cout << "got peds" << endl; - else - cout << "could not get peds" << endl; - for (int ii=0; ii<400*400; ii++) { - dout[ii]=peds[ii]; - // if (ii%400==10 && ii/400==10) - // cout << ii/400 << " " << ii%400 << " " << peds[ii] << " " << dout[ii] << endl; - // if (ii%400==100 && ii/400==100) - // cout << ii/400 << " " << ii%400 << " " << peds[ii] << " " << dout[ii] << endl; - } - - } - - - // zmqsocket2 = new ZmqSocket(portnum2, socketip2); - // if (zmqsocket2->IsError()) { - // bprintf(RED, "Error: Could not create Zmq socket server on port %d and ip %s\n", portnum2, socketip2); - // delete zmqsocket2; - // delete zmqsocket; - // return EXIT_FAILURE; - // } - // zmqsocket2->Connect(); - // printf("Zmq Server started at %s\n", zmqsocket2->GetZmqServerAddress()); - //zmqsocket2->Connect(); - - - zmqsocket2->SendHeaderData(0, false, SLS_DETECTOR_JSON_HEADER_VERSION,0,0,0,0,0, 0,0,ff, 0, 0,0,0,0,0,0,0,0,0,0,0,1); - - - zmqsocket2->SendData((char*)dout,length); - cprintf(GREEN, "Sent Data %d \n",length); - - zmqsocket2->SendHeaderData(0, true, SLS_DETECTOR_JSON_HEADER_VERSION); - cprintf(RED, "Sent Dummy\n"); - // zmqsocket2->Disconnect(); - - // delete zmqsocket2; - } - cout << "Acquired "<< iframe << " frames " << endl; - iframe=0; - newped=-1; - ped=-1; - dat=-1; - mt->clearImage(); - isdark=0; - continue; //continue to not get out - } - // cprintf(GREEN, "Got Header \n"); - - strcpy(ff,filename.c_str()); - fi=fileindex; - //isdark=0; - if (newped<0) { - if (filename.find("newped")!=std::string::npos) { - cout << "NEWPED" << endl; - if (newped<=0) { - newped=1; - ped=1; - while (mt->isBusy()) {;} - mt->newDataSet(); //resets pedestal - mt->setFrameMode(ePedestal); - cout << "New data set"<< endl; - } - } else { - newped=0; - } - } - if (ped<0) { - if (filename.find("ped")!=std::string::npos) { - ped=1; - dat=0; - while (mt->isBusy()) {;} - mt->setFrameMode(ePedestal); - cout << "pedestal!"<< endl; - } else { - ped=0; - dat=1; - while (mt->isBusy()) {;} - mt->setFrameMode(eFrame); - cout << "data!"<< endl; - if (filename.find("dark")!=std::string::npos) { - isdark=1; - cout << "this is a dark image" << endl; - } - - } - } - - // get data - length = zmqsocket->ReceiveData(0, buff, size); - // cprintf(GREEN, "Got Data\n"); - - //processing with image - //... - // if (iframe<10) { - // filter->addToPedestal(image); - //} else { - //SLOW!!! - //*** - //filter->getNPhotons(image); - //nph=filter->getImage(); - //filter->addToPedestal(image); - //***** - - // cprintf(BLUE, "Data processed\n"); - - - mt->pushData(buff); - mt->nextThread(); - // cout << " " << (void*)buff; - mt->popFree(buff); - - - - //stream data from socket 2 - - iframe++; - } - - // }// exiting infinite loop - - - - delete zmqsocket; - if (send) - delete zmqsocket2; - - - cout<<"Goodbye"<< endl; - return 0; -} - diff --git a/slsDetectorCalibration/moenchExecutables/moenchZmqClusterFinder.cpp b/slsDetectorCalibration/moenchExecutables/moenchZmqClusterFinder.cpp deleted file mode 100644 index 4fe7c20b9..000000000 --- a/slsDetectorCalibration/moenchExecutables/moenchZmqClusterFinder.cpp +++ /dev/null @@ -1,201 +0,0 @@ -#include "sls_receiver_defs.h" -#include "ZmqSocket.h" -#include "moench03T1ZmqDataNew.h" -#include -#include -#include -#include -#include -#include "tiffIO.h" - -#include - -//#include "analogDetector.h" -#include "singlePhotonDetector.h" -#include "multiThreadedAnalogDetector.h" -#include "ansi.h" -#include -using namespace std; - - -#define SLS_DETECTOR_JSON_HEADER_VERSION 0x2 - - -int main(int argc, char *argv[]) { -/** - * trial.o [socket ip] [starting port number] [send_socket ip] [send port number] - * - */ - FILE *of=NULL; - int fifosize=1000; - int nthreads=20; - // help - if (argc < 3 ) { - cprintf(RED, "Help: ./trial [receive socket ip] [receive starting port number] [send_socket ip] [send starting port number]\n"); - return EXIT_FAILURE; - } - - // receive parameters - bool send = false; - char* socketip=argv[1]; - uint32_t portnum = atoi(argv[2]); - int size = 32*2*5000;//atoi(argv[3]); - - // send parameters if any - char* socketip2 = 0; - uint32_t portnum2 = 0; - if (argc > 3) { - send = true; - socketip2 = argv[3]; - portnum2 = atoi(argv[4]); - } - cout << "\nrx socket ip : " << socketip << - "\nrx port num : " << portnum ; - if (send) { - cout << "\nsd socket ip : " << socketip2 << - "\nsd port num : " << portnum2; - } - cout << endl; - - //slsDetectorData *det=new moench03T1ZmqDataNew(); - moench03T1ZmqDataNew *det=new moench03T1ZmqDataNew(); - //analogDetector *filter=new analogDetector(det,1,NULL,1000); - singlePhotonDetector *filter=new singlePhotonDetector(det,3, 5, 1, 0, 1000, 10); - - - char* buff; - multiThreadedAnalogDetector *mt=new multiThreadedAnalogDetector(filter,nthreads,fifosize); - mt->setFrameMode(eFrame); - mt->StartThreads(); - mt->popFree(buff); - - - - - - // receive socket - ZmqSocket* zmqsocket = new ZmqSocket(socketip,portnum); - - - - if (zmqsocket->IsError()) { - cprintf(RED, "Error: Could not create Zmq socket on port %d with ip %s\n", portnum, socketip); - delete zmqsocket; - return EXIT_FAILURE; - } - zmqsocket->Connect(); - printf("Zmq Client at %s\n", zmqsocket->GetZmqServerAddress()); - - // send socket - ZmqSocket* zmqsocket2 = 0; - cout << "zmq2 " << endl; - if (send) { - zmqsocket2 = new ZmqSocket(portnum2, socketip2); - if (zmqsocket2->IsError()) { - bprintf(RED, "Error: Could not create Zmq socket server on port %d and ip %s\n", portnum2, socketip2); - delete zmqsocket2; - delete zmqsocket; - return EXIT_FAILURE; - } - zmqsocket2->Connect(); - printf("Zmq Server started at %s\n", zmqsocket2->GetZmqServerAddress()); - } - - - // header variables - uint64_t acqIndex = -1; - uint64_t frameIndex = -1; - uint32_t subframeIndex = -1; - uint64_t fileindex = -1; - string filename = ""; - char* image = new char[size]; - //int* image = new int[(size/sizeof(int))](); - - int *nph; - int iframe=0; - char ofname[10000]; - - char fname[10000]; - int length; - int *detimage; - int nnx, nny,nns; - filter->getImageSize(nnx, nny,nns); - int16_t *dout=new int16_t [nnx*nny]; - // infinite loop - while(1) { - - - // cout << "+++++++++++++++++++++++++++++++LOOP" << endl; - // get header, (if dummy, fail is on parse error or end of acquisition) - if (!zmqsocket->ReceiveHeader(0, acqIndex, frameIndex, subframeIndex, filename, fileindex)){ - // if (!zmqsocket->ReceiveHeader(0, acqIndex, frameIndex, subframeIndex, filename, fileindex)) { - cprintf(RED, "Got Dummy\n"); - while (mt->isBusy()) {;}//wait until all data are processed from the queues - - - detimage=mt->getImage(nnx,nny,nns); - for (int ix=0; ixSendHeaderData(0, false, SLS_DETECTOR_JSON_HEADER_VERSION,16,fileindex,400,400,400*400, acqIndex,frameIndex,fname, acqIndex, 0,0,0,0,0,0,0,0,0,0,0,1); - zmqsocket2->SendHeaderData(0, false, SLS_DETECTOR_JSON_HEADER_VERSION,0,0,0,0,0, 0,0,fname, 0, 0,0,0,0,0,0,0,0,0,0,0,1); - - zmqsocket2->SendData((char*)dout,length); - cprintf(GREEN, "Sent Data\n"); - } - - - // stream dummy to socket2 to signal end of acquisition - if (send) { - zmqsocket2->SendHeaderData(0, true, SLS_DETECTOR_JSON_HEADER_VERSION); - cprintf(RED, "Sent Dummy\n"); - } - mt->clearImage(); - if (of) { - fclose(of); - of=NULL; - } - - continue; //continue to not get out - } - - - if (of==NULL) { - sprintf(ofname,"%s_%d.clust",filename.c_str(),fileindex); - of=fopen(ofname,"w"); - if (of) { - mt->setFilePointer(of); - }else { - cout << "Could not open "<< ofname << " for writing " << endl; - mt->setFilePointer(NULL); - } - } - - // get data - length = zmqsocket->ReceiveData(0, buff, size); - mt->pushData(buff); - mt->nextThread(); - mt->popFree(buff); - - - - - iframe++; - } // exiting infinite loop - - - - delete zmqsocket; - if (send) - delete zmqsocket2; - - - cout<<"Goodbye"<< endl; - return 0; -} - diff --git a/slsDetectorCalibration/moenchExecutables/moenchZmqInterpolating.cpp b/slsDetectorCalibration/moenchExecutables/moenchZmqInterpolating.cpp deleted file mode 100644 index 2bd7e48f2..000000000 --- a/slsDetectorCalibration/moenchExecutables/moenchZmqInterpolating.cpp +++ /dev/null @@ -1,292 +0,0 @@ -#include "sls_receiver_defs.h" -#include "ZmqSocket.h" -#include "moench03T1ZmqDataNew.h" -#include -#include -#include -#include -#include -#include "tiffIO.h" - -#include - -//#include "analogDetector.h" -#include "interpolatingDetector.h" -#include "linearInterpolation.h" -#include "multiThreadedAnalogDetector.h" -#include "ansi.h" -#include -using namespace std; - - -#define SLS_DETECTOR_JSON_HEADER_VERSION 0x2 - - - - -int main(int argc, char *argv[]) { -/** - * trial.o [socket ip] [starting port number] [send_socket ip] [send port number] - * - */ - - int nthreads=20; - int nsigma=5; - int xmin=0; - int xmax=400; - int ymin=0; - int ymax=400; - int nsubpixels=2; - - - FILE *of=NULL; - int fifosize=1000; - int int_ready=0; - int ok; - // help - if (argc < 3 ) { - cprintf(RED, "Help: %s [receive socket ip] [receive starting port number] [send_socket ip] [send starting port number] [nsubpixels] [nthreads] [nsigma] [xmin xmax ymin ymax]\n", argv[0]); - return EXIT_FAILURE; - } - - char* socketip2 = 0; - uint32_t portnum2 = 0; - // receive parameters - int size = 32*2*5000;//atoi(argv[3]); - bool send = false; - - - - char* socketip=argv[1]; - uint32_t portnum = atoi(argv[2]); - if (argc > 3) { - send = true; - socketip2 = argv[3]; - portnum2 = atoi(argv[4]); - } - if (argc > 5) { - nsubpixels=atoi(argv[5]); - } - if (argc>6) { - nthreads=atoi(argv[6]); - } - if (argc>7) { - nsigma=atoi(argv[7]); - } - if (argc>11) { - xmin=atoi(argv[8]); - xmax=atoi(argv[8]); - ymin=atoi(argv[10]); - ymax=atoi(argv[11]); - } - - cout << "\nrx socket ip : " << socketip << - "\nrx port num : " << portnum ; - if (send) { - cout << "\nsd socket ip : " << socketip2 << - "\nsd port num : " << portnum2; - } - cout << endl; - - //slsDetectorData *det=new moench03T1ZmqDataNew(); - int npx, npy; - moench03T1ZmqDataNew *det=new moench03T1ZmqDataNew(); - det->getDetectorSize(npx, npy); - linearInterpolation *interp=new linearInterpolation(npx,npy,nsubpixels); - interpolatingDetector *filter=new interpolatingDetector(det,interp, nsigma, 1, 0, 1000, 100,npx,npy); - cout << "Setting noise cut to " << nsigma << " sigma"<< endl; - filter->setROI(xmin,xmax,ymin,ymax); - cout << "Setting ROI to "<< xmin << " " << xmax << " " << ymin << " " << ymax << endl; - - char* buff; - multiThreadedAnalogDetector *mt=new multiThreadedAnalogDetector(filter,nthreads,fifosize); - int frameMode=eFrame; - mt->setFrameMode(frameMode); - mt->StartThreads(); - mt->popFree(buff); - - - - - - // receive socket - ZmqSocket* zmqsocket = new ZmqSocket(socketip,portnum); - if (zmqsocket->IsError()) { - cprintf(RED, "Error: Could not create Zmq socket on port %d with ip %s\n", portnum, socketip); - delete zmqsocket; - return EXIT_FAILURE; - } - zmqsocket->Connect(); - printf("Zmq Client at %s\n", zmqsocket->GetZmqServerAddress()); - - // send socket - ZmqSocket* zmqsocket2 = 0; - if (send) { - zmqsocket2 = new ZmqSocket(portnum2, socketip2); - if (zmqsocket2->IsError()) { - bprintf(RED, "Error: Could not create Zmq socket server on port %d and ip %s\n", portnum2, socketip2); - delete zmqsocket2; - delete zmqsocket; - return EXIT_FAILURE; - } - zmqsocket2->Connect(); - printf("Zmq Server started at %s\n", zmqsocket2->GetZmqServerAddress()); - } - - - // header variables - uint64_t acqIndex = -1; - uint64_t frameIndex = -1; - uint32_t subframeIndex = -1; - uint64_t fileindex = -1; - string filename = ""; - char ffname[10000]; - int ffindex; - - char* image = new char[size]; - //int* image = new int[(size/sizeof(int))](); - - int *nph; - int iframe=0; - char ofname[10000]; - - char fname[10000]; - int length; - int *detimage; - int nnx, nny,nns; - int nix, niy,nis; - filter->getImageSize(nnx, nny,nns); - int16_t *dout=new int16_t [nnx*nny]; - // infinite loop - int ix, iy, isx, isy; - while(1) { - - - // cout << "+++++++++++++++++++++++++++++++LOOP" << endl; - // get header, (if dummy, fail is on parse error or end of acquisition) - if (!zmqsocket->ReceiveHeader(0, acqIndex, frameIndex, subframeIndex, filename, fileindex)){ - // if (!zmqsocket->ReceiveHeader(0, acqIndex, frameIndex, subframeIndex, filename, fileindex)) { - // cprintf(RED, "Got Dummy\n"); - while (mt->isBusy()) {;}//wait until all data are processed from the queues - if (frameMode==ePedestal) { - detped=mt->getPedestal(); - if (detped) { - - for (ix=0; ix<400; ix++) { - for (iy=0; iy<400; iy++) { - dout[iy*400+ix]+=detped[iy*400+ix]; - } - } - } - - } else { - detimage=mt->getImage(nix,niy,nis); - if (detimage) { - for (ix=0; ixSendHeaderData(0, false, SLS_DETECTOR_JSON_HEADER_VERSION,16,fileindex,400,400,400*400, acqIndex,frameIndex,fname, acqIndex, 0,0,0,0,0,0,0,0,0,0,0,1); - zmqsocket2->SendHeaderData(0, false, SLS_DETECTOR_JSON_HEADER_VERSION,0,0,0,0,0, 0,0,fname, 0, 0,0,0,0,0,0,0,0,0,0,0,1); - - zmqsocket2->SendData((char*)dout,length); - cprintf(GREEN, "Sent Data\n"); - } - - sprintf(ofname,"%s_%d.tiff",ffname,ffindex); - if (frameMode==eFlat) - mt->writeFlatField(ofname); - else if (frameMode==ePedestal) - mt->writePedestal(ofname); - else - mt->writeImage(ofname); - - - // stream dummy to socket2 to signal end of acquisition - if (send) { - zmqsocket2->SendHeaderData(0, true, SLS_DETECTOR_JSON_HEADER_VERSION); - // cprintf(RED, "Sent Dummy\n"); - cprintf(RED, "Received %d frames\n", iframe); - } - mt->clearImage(); - if (of) { - fclose(of); - of=NULL; - } - iframe=0; - continue; //continue to not get out - } - - - if (of==NULL) { - while (mt->isBusy()) {;} - sprintf(ofname,"%s_%d.clust",filename.c_str(),fileindex); - of=fopen(ofname,"w"); - if (of) { - mt->setFilePointer(of); - }else { - cout << "Could not open "<< ofname << " for writing " << endl; - mt->setFilePointer(NULL); - } - ffindex=fileindex; - strcpy(ffname,filename.c_str()); - if (filename.find("flat")!=std::string::npos) { - cout << "add to ff" << endl; - frameMode=eFlat;//ePedestal; - int_ready=0; - - } else if (filename.find("newped")!=std::string::npos) { - frameMode=ePedestal; - cout << "new pedestal" << endl; - - mt->newDataSet(); - } else if (filename.find("ped")!=std::string::npos){ - frameMode=ePedestal; - cout << "pedestal" << endl; - } else { - frameMode=eFrame; - cout << "data" << endl; - if (int_ready==0) { - mt->prepareInterpolation(ok); - cout << "prepare interpolation " << endl; - int_ready=1; - } - } - - mt->setFrameMode(frameMode); - } - - // get data - length = zmqsocket->ReceiveData(0, buff, size); - mt->pushData(buff); - mt->nextThread(); - mt->popFree(buff); - - iframe++; - } // exiting infinite loop - - - - delete zmqsocket; - if (send) - delete zmqsocket2; - - - // cout<<"Goodbye"<< endl; - return 0; -} - diff --git a/slsDetectorCalibration/moenchExecutables/tiff_to_th2f.cpp b/slsDetectorCalibration/moenchExecutables/tiff_to_th2f.cpp deleted file mode 100644 index 3e248feaa..000000000 --- a/slsDetectorCalibration/moenchExecutables/tiff_to_th2f.cpp +++ /dev/null @@ -1,57 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "tiffIO.h" - -#include - -using namespace std; - - -int main(int argc, char *argv[]) { -/** - * trial.o [socket ip] [starting port number] [outfname] - * - */ - - if (argc<3) { - cout << "Wrong usage! Should be: "<< argv[0] << " infile " << " outfile " << endl; - return 1; - } - - uint32 nx, ny; - - float *data=ReadFromTiff(argv[1],nx, ny); - - TH2F *h2=NULL; - if (data) { - TFile *fout=new TFile(argv[2],"RECREATE"); - if (fout) { - h2=new TH2F("h2",argv[1],nx,0,nx,ny,0, ny); - for (int ix=0; ixSetBinContent(ix+1, iy+1, data[ix+iy*nx]); - } - } - h2->Write(); - fout->Close(); - } - delete [] data; - } - - - - return 0; -} - diff --git a/slsDetectorCalibration/multiThreadedAnalogDetector.h b/slsDetectorCalibration/multiThreadedAnalogDetector.h deleted file mode 100644 index 1395a53e3..000000000 --- a/slsDetectorCalibration/multiThreadedAnalogDetector.h +++ /dev/null @@ -1,574 +0,0 @@ -#ifndef MULTITHREADED_ANALOG_DETECTOR_H -#define MULTITHREADED_ANALOG_DETECTOR_H - -#include -#include -#include -#include -#include -#include -//#include -//#include -//#include -#include -#include -#include - -//#include "analogDetector.h" -#include "singlePhotonDetector.h" -//#include "interpolatingDetector.h" -#include "circularFifo.h" -#include "slsInterpolation.h" -#include -#include -#include -//#include - - -using namespace std; - - -class threadedAnalogDetector -{ -public: - threadedAnalogDetector(analogDetector *d, int fs=10000) { - char *mem, *mm; - det=d; - fifoFree=new CircularFifo(fs); - fifoData=new CircularFifo(fs); - mem=(char*)malloc(fs*det->getDataSize()); - // cout << "data size is " << det->getDataSize()*fs << endl; - for (int i=0; igetDataSize(); - fifoFree->push(mm); - } - busy=0; - stop=1; - fMode=eFrame; - ff=NULL; - } - - - virtual int setFrameMode(int fm) {fMode=fm; if (fMode>=0) det->setFrameMode((frameMode)fMode);}; - virtual void newDataSet(){det->newDataSet();}; - //fMode=fm; return fMode;} - - /* void prepareInterpolation(int &ok) { */ - /* cout << "-" << endl; */ - /* det->prepareInterpolation(ok); */ - /* }; */ - - virtual int *getImage() { - return det->getImage(); - } - virtual int getImageSize(int &nnx, int &nny, int &ns) {return det->getImageSize(nnx, nny, ns);}; - virtual int getDetectorSize(int &nnx, int &nny) {return det->getDetectorSize(nnx, nny);}; - - ~threadedAnalogDetector() {StopThread(); free(mem); delete fifoFree; delete fifoData;} - - /** Returns true if the thread was successfully started, false if there was an error starting the thread */ - virtual bool StartThread() - { stop=0; - return (pthread_create(&_thread, NULL, processData, this) == 0); - } - - virtual void StopThread() - { stop=1; - (void) pthread_join(_thread, NULL); - } - - - virtual bool pushData(char* &ptr) { - fifoData->push(ptr); - } - - virtual bool popFree(char* &ptr) { - fifoFree->pop(ptr); - } - - virtual int isBusy() {return busy;} - - //protected: - /** Implement this method in your subclass with the code you want your thread to run. */ - //virtual void InternalThreadEntry() = 0; - virtual void *writeImage(const char * imgname) {cout << "a" <writeImage(imgname);}; - - virtual void clearImage(){det->clearImage();}; - - virtual void prepareInterpolation(int &ok){ - slsInterpolation *interp=(slsInterpolation*)det->getInterpolation(); - if (interp) - interp->prepareInterpolation(ok); - } - - virtual int *getFlatField(){ - slsInterpolation *interp=(slsInterpolation*)det->getInterpolation(); - if (interp) - return interp->getFlatField(); - else - return NULL; - } - - virtual int *setFlatField(int *ff, int nb, double emin, double emax){ - slsInterpolation *interp=(slsInterpolation*)det->getInterpolation(); - if (interp) - return interp->setFlatField(ff, nb, emin, emax); - else - return NULL; - } - - virtual int *getFlatField(int &nb, double emi, double ema){ - slsInterpolation *interp=(slsInterpolation*)det->getInterpolation(); - int *ff; - if (interp) { - ff=interp->getFlatField(nb,emi,ema); - // cout << "tdgff* ff has " << nb << " bins " << endl; - return ff; - } else - return NULL; - } - - virtual char *getInterpolation() { - return det->getInterpolation(); - } - - virtual void setPedestal(double *ped, double *rms=NULL, int m=-1){det->setPedestal(ped,rms,m);}; - - - virtual void setPedestalRMS(double *rms){ det->setPedestalRMS(rms);}; - - virtual double *getPedestal(double *ped=NULL){return det->getPedestal(ped);}; - - - virtual double *getPedestalRMS(double *rms=NULL){ return det->getPedestalRMS(rms);}; - - - - -/** sets file pointer where to write the clusters to - \param f file pointer - \returns current file pointer -*/ - FILE *setFilePointer(FILE *f){return det->setFilePointer(f); }; - -/** gets file pointer where to write the clusters to - \returns current file pointer -*/ -FILE *getFilePointer(){return det->getFilePointer();}; - - - void setMutex(pthread_mutex_t *fmutex){det->setMutex(fmutex);}; - -private: - analogDetector *det; - int fMode; - int *dataSize; - pthread_t _thread; - char *mem; - CircularFifo *fifoFree; - CircularFifo *fifoData; - int stop; - int busy; - char *data; - int *ff; - - static void * processData(void * ptr) { - threadedAnalogDetector *This=((threadedAnalogDetector *)ptr); - return This->processData(); - } - void * processData() { - busy=1; - while (!stop) { - if (fifoData->isEmpty()) { - busy=0; - usleep(100); - } else { - busy=1; - fifoData->pop(data); //blocking! - det->processData(data); - fifoFree->push(data); - } - } - return NULL; - } - - - -}; - - - -class multiThreadedAnalogDetector -{ -public: - multiThreadedAnalogDetector(analogDetector *d, int n, int fs=1000) : nThreads(n), ithread(0) { - dd[0]=d; - if (nThreads==1) - dd[0]->setId(100); - else - dd[0]->setId(0); - for (int i=1; iClone(); - dd[i]->setId(i); - } - - for (int i=0; igetImageSize(nnx, nny,ns); - image=new int[nn]; - ff=NULL; - ped=NULL; - } - - ~multiThreadedAnalogDetector() { - StopThreads(); - for (int i=0; isetFrameMode(fm); return ret;}; - - void newDataSet(){for (int i=0; inewDataSet();}; - int *getImage(int &nnx, int &nny, int &ns) { - int *img; - // int nnx, nny, ns; - int nn=dets[0]->getImageSize(nnx, nny, ns); - //for (i=0; igetImage(); - for (int i=0; iclearImage(); - } - - } - - virtual void *writeImage(const char * imgname) { -/* #ifdef SAVE_ALL */ -/* for (int ii=0; iiwriteImage(tit); */ -/* } */ -/* #endif */ - int nnx, nny, ns; - getImage(nnx, nny, ns); - //int nnx, nny, ns; - int nn=dets[0]->getImageSize(nnx, nny, ns); - float *gm=new float[nn]; - if (gm) { - for (int ix=0; ix0 && ix/nnx<350) cout << ix/nnx << " " << ix%nnx << " " << image[ix]<< " " << gm[ix] << endl; - } - //cout << "image " << nnx << " " << nny << endl; - WriteToTiff(gm,imgname ,nnx, nny); - delete [] gm; - } else cout << "Could not allocate float image " << endl; - return NULL; - } - - - virtual void StartThreads() { - for (int i=0; iStartThread(); - - } - - - - virtual void StopThreads() { - for (int i=0; iStopThread(); - - } - - - int isBusy() { - int ret=0, ret1; - for (int i=0; iisBusy(); - ret|=ret1; - // if (ret1) cout << "thread " << i <<" still busy " << endl; - } - return ret; - } - - - bool pushData(char* &ptr) { - dets[ithread]->pushData(ptr); - } - - bool popFree(char* &ptr) { - dets[ithread]->popFree(ptr); - } - - int nextThread() { - ithread++; - if (ithread==nThreads) ithread=0; - return ithread; - } - - virtual void prepareInterpolation(int &ok){ - getFlatField(); //sum up all etas - setFlatField(); //set etas to all detectors - for (int i=0; iprepareInterpolation(ok); - } - } - - virtual int *getFlatField(){ - int nb=0; - double emi, ema; - int *f0; - slsInterpolation* inte=(slsInterpolation*)dets[0]->getInterpolation(); - if (inte) { - if (inte->getFlatField(nb,emi,ema)) { - if (ff) delete [] ff; - ff=new int[nb*nb]; - for (int i=0; igetInterpolation(); - f0=inte->getFlatField(); - if (f0) { - // cout << "ff " << i << endl; - for (int ib=0; ib0) */ - /* cout << i << " " << ib << " " << f0[ib] << " " << ff[ib] << endl; */ - - } - } - } - return ff; - } - } - return NULL; - } - - - virtual int *setFlatField(int *h=NULL, int nb=-1, double emin=1, double emax=0){ - //int nb=0; - double emi, ema; - slsInterpolation* inte=(slsInterpolation*)dets[0]->getFlatField(nb,emi,ema); - if (inte) { - if (h==NULL) h=ff; - for (int i=0; isetFlatField(h, nb, emin, emax); - } - } - return NULL; - }; - - void *writeFlatField(const char * imgname){ - - int nb=0; - double emi, ema; - slsInterpolation* inte=(slsInterpolation*)dets[0]->getFlatField(nb,emi,ema); - if (inte) { - if (getFlatField()) { - // cout << "mtwff* ff has " << nb << " bins " << endl; - float *gm=new float[nb*nb]; - if (gm) { - for (int ix=0; ixgetFlatField(nb,emin,emax); - if (inte) { - uint32 nnx; - uint32 nny; - float *gm=ReadFromTiff(imgname, nnx, nny); - if (ff) delete [] ff; - if (nnx>nb) nb=nnx; - if (nny>nb) nb=nny; - ff=new int[nb*nb]; - - for (int ix=0; ixgetDetectorSize(nx,ny); - if (ped) delete [] ped; - ped=new double[nx*ny]; - double *p0=new double[nx*ny]; - - for (int i=0; igetInterpolation(nb,emi,ema); - p0=dets[i]->getPedestal(p0); - if (p0) { - for (int ib=0; ibgetDetectorSize(nx,ny); - if (h==NULL) h=ped; - for (int i=0; isetPedestal(h); - } - - return NULL; - }; - - - - - void *writePedestal(const char * imgname){ - - int nx, ny; - dets[0]->getDetectorSize(nx,ny); - - getPedestal(); - float *gm=new float[nx*ny]; - if (gm) { - for (int ix=0; ixgetDetectorSize(nx,ny); - uint32 nnx; - uint32 nny; - float *gm=ReadFromTiff(imgname, nnx, nny); - if (ped) delete [] ped; - if (nnx>nx) nx=nnx; - if (nny>ny) ny=nny; - ped=new double[nx*ny]; - - for (int ix=0; ixsetFilePointer(f); - //dets[i]->setMutex(&fmutex); - } - return dets[0]->getFilePointer(); - }; - -/** gets file pointer where to write the clusters to - \returns current file pointer -*/ -FILE *getFilePointer(){return dets[0]->getFilePointer();}; - - - - private: - bool stop; - const int nThreads; - threadedAnalogDetector *dets[20]; - analogDetector *dd[20]; - int ithread; - int *image; - int *ff; - double *ped; - pthread_mutex_t fmutex; -}; - -#endif - - - - - - - - - - - - - - - - - - diff --git a/slsDetectorCalibration/pedestalSubtraction.h b/slsDetectorCalibration/pedestalSubtraction.h deleted file mode 100644 index 062b0d84e..000000000 --- a/slsDetectorCalibration/pedestalSubtraction.h +++ /dev/null @@ -1,63 +0,0 @@ -#ifndef PEDESTALSUBTRACTION_H -#define PEDESTALSUBTRACTION_H - -#include "MovingStat.h" - -class pedestalSubtraction { - /** @short class defining the pedestal subtraction based on an approximated moving average */ - public: - /** constructor - \param nn number of samples to calculate the moving average (defaults to 1000) - */ - pedestalSubtraction (int nn=1000) : stat(nn) {}; - - /** virtual destructorr - */ - virtual ~pedestalSubtraction() {}; - - /** clears the moving average */ - virtual void Clear() {stat.Clear();} - - /** adds the element to the moving average - \param val value to be added - */ - virtual void addToPedestal(double val){stat.Calc(val);}; - - /** returns the average value of the pedestal - \returns mean of the moving average - */ - virtual double getPedestal(){return stat.Mean();}; - - /** returns the standard deviation of the moving average - \returns standard deviation of the moving average - */ - virtual double getPedestalRMS(){return stat.StandardDeviation();}; - - /**sets/gets the number of samples for the moving average - \param i number of elements for the moving average. If -1 (default) or negative, gets. - \returns actual number of samples for the moving average - */ - virtual int SetNPedestals(int i=-1) {return stat.SetN(i);}; - - /**sets/gets the number of samples for the moving average - \returns actual number of samples for the moving average - */ - virtual int GetNPedestals() {return stat.GetN();}; - - /** sets the moving average */ - virtual void setPedestal(double val, double rms=0, int m=-1) {stat.Set(val, rms, m);} - - - /** sets the moving average */ - virtual void setPedestalRMS(double rms) {stat.SetRMS(rms);} - - /**sets/gets the number of samples for the moving average - \returns actual number of samples for the moving average - */ - virtual int getNumpedestals() {return stat.NumDataValues();}; - - private: - MovingStat stat; /**< approximated moving average struct */ - -}; -#endif diff --git a/slsDetectorCalibration/singlePhotonDetector.h b/slsDetectorCalibration/singlePhotonDetector.h deleted file mode 100644 index f8b0f7577..000000000 --- a/slsDetectorCalibration/singlePhotonDetector.h +++ /dev/null @@ -1,685 +0,0 @@ -#ifndef SINGLEPHOTONDETECTOR_H -#define SINGLEPHOTONDETECTOR_H - -#include "analogDetector.h" - -#include "single_photon_hit.h" - - - -//#define MYROOT1 - -#ifdef MYROOT1 -#include -#endif - - -#ifndef EVTYPE_DEF -#define EVTYPE_DEF -/** enum to define the even types */ -enum eventType { - PEDESTAL=0, /** pedestal */ - NEIGHBOUR=1, /** neighbour i.e. below threshold, but in the cluster of a photon */ - PHOTON=2, /** photon i.e. above threshold */ - PHOTON_MAX=3, /** maximum of a cluster satisfying the photon conditions */ - NEGATIVE_PEDESTAL=4, /** negative value, will not be accounted for as pedestal in order to avoid drift of the pedestal towards negative values */ - UNDEFINED_EVENT=-1 /** undefined */ -}; -#endif - -//template class singlePhotonDetector : -//public analogDetector { -class singlePhotonDetector : -public analogDetector { - - /** @short class to perform pedestal subtraction etc. and find single photon clusters for an analog detector */ - - public: - - - /** - - Constructor (no error checking if datasize and offsets are compatible!) - \param d detector data structure to be used - \param csize cluster size (should be an odd number). Defaults to 3 - \param nsigma number of rms to discriminate from the noise. Defaults to 5 - \param sign 1 if photons are positive, -1 if negative - \param cm common mode subtraction algorithm, if any. Defaults to NULL i.e. none - \param nped number of samples for pedestal averaging - \param nd number of dark frames to average as pedestals without photon discrimination at the beginning of the measurement - - - */ - - - singlePhotonDetector(slsDetectorData *d, - int csize=3, - double nsigma=5, - int sign=1, - commonModeSubtraction *cm=NULL, - int nped=1000, - int nd=100, int nnx=-1, int nny=-1, double *gm=NULL) : analogDetector(d, sign, cm, nped, nnx, nny, gm), nDark(nd), eventMask(NULL),nSigma (nsigma), clusterSize(csize), clusterSizeY(csize), clusters(NULL), quad(UNDEFINED_QUADRANT), tot(0), quadTot(0) { - - - - - eventMask=new eventType*[ny]; - for (int i=0; i(orig) { - - nDark=orig->nDark; - myFile=orig->myFile; - - eventMask=new eventType*[ny]; - for (int i=0; inSigma; - clusterSize=orig->clusterSize; - clusterSizeY=orig->clusterSizeY; - // cluster=new single_photon_hit(clusterSize,clusterSizeY); - clusters=new single_photon_hit[nx*ny]; - - // cluster=clusters; - - setClusterSize(clusterSize); - - quad=UNDEFINED_QUADRANT; - tot=0; - quadTot=0; - gmap=orig->gmap; - nphTot=0; - nphFrame=0; - - } - - - - /** - duplicates the detector structure - \returns new single photon detector with same parameters - - */ - virtual singlePhotonDetector *Clone() { - return new singlePhotonDetector(this); - } - /** sets/gets number of rms threshold to detect photons - \param n number of sigma to be set (0 or negative gets) - \returns actual number of sigma parameter - */ - double setNSigma(double n=-1){if (n>0) nSigma=n; return nSigma;} - - /** sets/gets cluster size - \param n cluster size to be set, (0 or negative gets). If even is incremented by 1. - \returns actual cluster size - */ - int setClusterSize(int n=-1){ - if (n>0 && n!=clusterSize) { - if (n%2==0) - n+=1; - clusterSize=n; - // if (clusters) - // delete [] clusters; - if (ny>clusterSize) - clusterSizeY=clusterSize; - else - clusterSizeY=1; - for (int ip=0; ipset_cluster_size(clusterSize,clusterSizeY); - //cluster=new single_photon_hit(clusterSize,clusterSizeY); - } - return clusterSize; - } - - - - /** - converts the image into number of photons - \param data pointer to data - \param nph pointer where to add the calculated photons. If NULL, the internal image will be used - \returns array with data converted into number of photons. - */ - - virtual int *getNPhotons(char *data, int *nph=NULL) { - - nphFrame=0; - double val; - if (nph==NULL) - nph=image; - //nph=new int[nx*ny]; - - double rest[ny][nx]; - int cy=(clusterSizeY+1)/2; - int cs=(clusterSize+1)/2; - - int ccs=clusterSize; - int ccy=clusterSizeY; - - double g=1.; - - - double tthr=thr, tthr1, tthr2; - int nn=0; - double max=0, tl=0, tr=0, bl=0,br=0, v; - double rms=0; - - int cm=0; - if (cmSub) cm=1; - - if (thr>0) { - cy=1; - cs=1; - ccs=1; - ccy=1; - } - if (iframe0) { - newFrame(); - if (cmSub) { - addToCommonMode(data); - } - for (int ix=xmin; ix::getNPhotons(data,ix,iy); - nph[ix+nx*iy]+=nn; - rest[iy][ix]=(val-nn*tthr); - - nphFrame+=nn; - nphTot+=nn; - } - } - // } - for (int ix=xmin; ix0.25*tthr) { - eventMask[iy][ix]=NEIGHBOUR; - for (int ir=-(clusterSizeY/2); ir<(clusterSizeY/2)+1; ir++) { - for (int ic=-(clusterSize/2); ic<(clusterSize/2)+1; ic++) { - if ((iy+ir)>=0 && (iy+ir)=0 && (ix+ic)set_data(rest[iy+ir][ix+ic], ic, ir); - - - v=rest[iy+ir][ix+ic];//clusters->get_data(ic,ir); - tot+=v; - - if (ir<=0 && ic<=0) - bl+=v; - if (ir<=0 && ic>=0) - br+=v; - if (ir>=0 && ic<=0) - tl+=v; - if (ir>=0 && ic>=0) - tr+=v; - - if (v>max) { - max=v; - } - // if (ir==0 && ic==0) { - //} - } - } - } - - if (rest[iy][ix]>=max) { - if (bl>=br && bl>=tl && bl>=tr) { - quad=BOTTOM_LEFT; - quadTot=bl; - } else if (br>=bl && br>=tl && br>=tr) { - quad=BOTTOM_RIGHT; - quadTot=br; - } else if (tl>=br && tl>=bl && tl>=tr) { - quad=TOP_LEFT; - quadTot=tl; - } else if (tr>=bl && tr>=tl && tr>=br) { - quad=TOP_RIGHT; - quadTot=tr; - } - rms=getPedestalRMS(ix,iy); - tthr1=tthr-sqrt(ccy*ccs)*rms; - tthr2=tthr-sqrt(cy*cs)*rms; - if (tthr>sqrt(ccy*ccs)*rms) tthr1=tthr-sqrt(ccy*ccs)*rms; else tthr1=sqrt(ccy*ccs)*rms; - if (tthr>sqrt(cy*cs)*rms) tthr2=tthr-sqrt(cy*cs)*rms; else tthr2=sqrt(cy*cs)*rms; - if (tot>tthr1 || quadTot>tthr2) { - eventMask[iy][ix]=PHOTON; - nph[ix+nx*iy]++; - nphFrame++; - nphTot++; - - } - } - } - } - } - // cout << iframe << " " << nphFrame << " " << nphTot << endl; - //cout << iframe << " " << nph << endl; - } else return getClusters(data, nph); - } - return NULL; - }; - - - /** finds event type for pixel and fills cluster structure. The algorithm loops only if the evenMask for this pixel is still undefined. - if pixel or cluster around it are above threshold (nsigma*pedestalRMS) cluster is filled and pixel mask is PHOTON_MAX (if maximum in cluster) or NEIGHBOUR; If PHOTON_MAX, the elements of the cluster are also set as NEIGHBOURs in order to speed up the looping - if below threshold the pixel is either marked as PEDESTAL (and added to the pedestal calculator) or NEGATIVE_PEDESTAL is case it's lower than -threshold, otherwise the pedestal average would drift to negative values while it should be 0. - - /param data pointer to the data - /param ix pixel x coordinate - /param iy pixel y coordinate - /param cm enable(1)/disable(0) common mode subtraction (if defined). - /returns event type for the given pixel - */ - eventType getEventType(char *data, int ix, int iy, int cm=0) { - - // eventType ret=PEDESTAL; - double max=0, tl=0, tr=0, bl=0,br=0, v; - // cout << iframe << endl; - - int cy=(clusterSizeY+1)/2; - int cs=(clusterSize+1)/2; - double val; - tot=0; - quadTot=0; - quad=UNDEFINED_QUADRANT; - - if (iframex=ix; - clusters->y=iy; - clusters->rms=getPedestalRMS(ix,iy); - clusters->ped=getPedestal(ix,iy, cm); - - - for (int ir=-(clusterSizeY/2); ir<(clusterSizeY/2)+1; ir++) { - for (int ic=-(clusterSize/2); ic<(clusterSize/2)+1; ic++) { - if ((iy+ir)>=0 && (iy+ir)=0 && (ix+ic)set_data(v, ic, ir); - // v=clusters->get_data(ic,ir); - tot+=v; - if (ir<=0 && ic<=0) - bl+=v; - if (ir<=0 && ic>=0) - br+=v; - if (ir>=0 && ic<=0) - tl+=v; - if (ir>=0 && ic>=0) - tr+=v; - - if (v>max) { - max=v; - } - if (ir==0 && ic==0) { - if (v<-nSigma*clusters->rms) - eventMask[iy][ix]=NEGATIVE_PEDESTAL; - } - } - } - } - - if (bl>=br && bl>=tl && bl>=tr) { - quad=BOTTOM_LEFT; - quadTot=bl; - } else if (br>=bl && br>=tl && br>=tr) { - quad=BOTTOM_RIGHT; - quadTot=br; - } else if (tl>=br && tl>=bl && tl>=tr) { - quad=TOP_LEFT; - quadTot=tl; - } else if (tr>=bl && tr>=tl && tr>=br) { - quad=TOP_RIGHT; - quadTot=tr; - } - - if (max>nSigma*clusters->rms || tot>sqrt(clusterSizeY*clusterSize)*nSigma*clusters->rms || quadTot>cy*cs*nSigma*clusters->rms) { - if (clusters->get_data(0,0)>=max) { - eventMask[iy][ix]=PHOTON_MAX; - } else { - eventMask[iy][ix]=PHOTON; - } - } else if (eventMask[iy][ix]==PEDESTAL) { - if (cm==0) { - if (det) - val=dataSign*det->getValue(data, ix, iy); - else - val=((double**)data)[iy][ix]; - addToPedestal(val,ix,iy); - } - } - - - - return eventMask[iy][ix]; - - }; - - - - -/** - Loops in the region of interest to find the clusters - \param data pointer to the data structure - \returns number of clusters found - - */ - -int *getClusters(char *data, int *ph=NULL) { - - - int nph=0; - double val[ny][nx]; - int cy=(clusterSizeY+1)/2; - int cs=(clusterSize+1)/2; - int ir, ic; - - double max=0, tl=0, tr=0, bl=0,br=0, *v, vv; - int cm=0; - if (cmSub) cm=1; - if (ph==NULL) - ph=image; - - if (iframerms=getPedestalRMS(ix,iy); - // cluster=clusters+nph; - - - for (int ir=-(clusterSizeY/2); ir<(clusterSizeY/2)+1; ir++) { - for (int ic=-(clusterSize/2); ic<(clusterSize/2)+1; ic++) { - - if ((iy+ir)>=iy && (iy+ir)=ix && (ix+ic)=0) - br+=*v; - if (ir>=0 && ic<=0) - tl+=*v; - if (ir>=0 && ic>=0) - tr+=*v; - if (*v>max) { - max=*v; - } - - - if (ir==0 && ic==0) { - if (*v<-nSigma*(clusters+nph)->rms) - eventMask[iy][ix]=NEGATIVE_PEDESTAL; - } - - } - } - - if (bl>=br && bl>=tl && bl>=tr) { - (clusters+nph)->quad=BOTTOM_LEFT; - (clusters+nph)->quadTot=bl; - } else if (br>=bl && br>=tl && br>=tr) { - (clusters+nph)->quad=BOTTOM_RIGHT; - (clusters+nph)->quadTot=br; - } else if (tl>=br && tl>=bl && tl>=tr) { - (clusters+nph)->quad=TOP_LEFT; - (clusters+nph)->quadTot=tl; - } else if (tr>=bl && tr>=tl && tr>=br) { - (clusters+nph)->quad=TOP_RIGHT; - (clusters+nph)->quadTot=tr; - } - - if (max>nSigma*(clusters+nph)->rms || tot>sqrt(clusterSizeY*clusterSize)*nSigma*(clusters+nph)->rms || ((clusters+nph)->quadTot)>sqrt(cy*cs)*nSigma*(clusters+nph)->rms) { - if (val[iy][ix]>=max) { - eventMask[iy][ix]=PHOTON_MAX; - (clusters+nph)->tot=tot; - (clusters+nph)->x=ix; - (clusters+nph)->y=iy; - (clusters+nph)->iframe=det->getFrameNumber(data); - (clusters+nph)->ped=getPedestal(ix,iy,0); - for (int ir=-(clusterSizeY/2); ir<(clusterSizeY/2)+1; ir++) { - for (int ic=-(clusterSize/2); ic<(clusterSize/2)+1; ic++) { - (clusters+nph)->set_data(val[iy+ir][ix+ic],ic,ir); - } - } - // cout << (clusters+nph)->iframe << " " << ix << " " << nph << " " << tot << " " << (clusters+nph)->quadTot << endl; - nph++; - image[iy*nx+ix]++; - - } else { - eventMask[iy][ix]=PHOTON; - } - } else if (eventMask[iy][ix]==PEDESTAL) { - addToPedestal(data,ix,iy,cm); - } - - - } - } - nphFrame=nph; - nphTot+=nph; - //cout << nphFrame << endl; - // cout <<"**********************************"<< endl; - writeClusters(); - return image; - -}; - - - /**< - returns the total signal in a cluster - \param size cluser size should be 1,2 or 3 - \returns cluster center if size=1, sum of the maximum quadrant if size=2, total of the cluster if size=3 or anything else - */ - - double getClusterTotal(int size) { - switch (size) { - case 1: - return getClusterElement(0,0); - case 2: - return quadTot; - default: - return tot; - }; - }; - - /**< - retrurns the quadrant with maximum signal - \returns quadrant where the cluster is located */ - - quadrant getQuadrant() {return quad;}; - - - /** returns value for cluster element in relative coordinates - \param ic x coordinate (center is (0,0)) - \param ir y coordinate (center is (0,0)) - \returns cluster element - */ - double getClusterElement(int ic, int ir=0){return clusters->get_data(ic,ir);}; - - /** returns event mask for the given pixel - \param ic x coordinate (center is (0,0)) - \param ir y coordinate (center is (0,0)) - \returns event mask enum for the given pixel - */ - eventType getEventMask(int ic, int ir=0){return eventMask[ir][ic];}; - - -#ifdef MYROOT1 - /** generates a tree and maps the branches - \param tname name for the tree - \param iFrame pointer to the frame number - \returns returns pointer to the TTree - */ - TTree *initEventTree(char *tname, int *iFrame=NULL) { - TTree* tall=new TTree(tname,tname); - - if (iFrame) - tall->Branch("iFrame",iFrame,"iframe/I"); - else - tall->Branch("iFrame",&(clusters->iframe),"iframe/I"); - - tall->Branch("x",&(clusters->x),"x/I"); - tall->Branch("y",&(clusters->y),"y/I"); - char tit[100]; - sprintf(tit,"data[%d]/D",clusterSize*clusterSizeY); - tall->Branch("data",clusters->data,tit); - tall->Branch("pedestal",&(clusters->ped),"pedestal/D"); - tall->Branch("rms",&(clusters->rms),"rms/D"); - tall->Branch("tot",&(clusters->tot),"tot/D"); - tall->Branch("quadTot",&(clusters->quadTot),"quadTot/D"); - tall->Branch("quad",&(clusters->quad),"quad/I"); - return tall; - }; -#else -/** write cluster to filer - \param f file pointer -*/ - void writeCluster(FILE* f){clusters->write(f);}; - -/** - write clusters to file - \param f file pointer - \param clusters array of clusters structures - \param nph number of clusters to be written to file - -*/ - -static void writeClusters(FILE *f, single_photon_hit *clusters, int nph){for (int i=0; iwrite(f);}; -void writeClusters(FILE *f){for (int i=0; iwrite(f);}; - void writeClusters(){if (myFile) { - //cout << "++" << endl; - pthread_mutex_lock(fm); - for (int i=0; iwrite(myFile); - pthread_mutex_unlock(fm); - //cout << "--" << endl; - } - }; -#endif - - virtual void processData(char *data, int *val=NULL) { - // cout << "sp" << endl; - switch(fMode) { - case ePedestal: - addToPedestal(data); - break; - default: - getNPhotons(data,val); - } - iframe++; - // cout << "done" << endl; - }; - int getPhFrame(){return nphFrame;}; - int getPhTot(){return nphTot;}; - protected: - - int nDark; /**< number of frames to be used at the beginning of the dataset to calculate pedestal without applying photon discrimination */ - eventType **eventMask; /**< matrix of event type or each pixel */ - double nSigma; /**< number of sigma parameter for photon discrimination */ - int clusterSize; /**< cluster size in the x direction */ - int clusterSizeY; /**< cluster size in the y direction i.e. 1 for strips, clusterSize for pixels */ - // single_photon_hit *cluster; /**< single photon hit data structure */ - single_photon_hit *clusters; /**< single photon hit data structure */ - quadrant quad; /**< quadrant where the photon is located */ - double tot; /**< sum of the 3x3 cluster */ - double quadTot; /**< sum of the maximum 2x2cluster */ - int nphTot; - int nphFrame; - - - }; - - - - - -#endif diff --git a/slsDetectorCalibration/single_photon_hit.h b/slsDetectorCalibration/single_photon_hit.h deleted file mode 100644 index 696868b87..000000000 --- a/slsDetectorCalibration/single_photon_hit.h +++ /dev/null @@ -1,94 +0,0 @@ -#ifndef SINGLE_PHOTON_HIT_H -#define SINGLE_PHOTON_HIT_H -#include -#include - -typedef double double32_t; -typedef float float32_t; -typedef int int32_t; - -#ifndef DEF_QUAD -#define DEF_QUAD - enum quadrant { - TOP_LEFT=0, - TOP_RIGHT=1, - BOTTOM_LEFT=2, - BOTTOM_RIGHT=3, - UNDEFINED_QUADRANT=-1 - }; -#endif - - -class single_photon_hit { - - /** @short Structure for a single photon hit */ - - public: - /** constructor, instantiates the data array -- all class elements are public! - \param nx cluster size in x direction - \param ny cluster size in y direction (defaults to 1 for 1D detectors) - */ - single_photon_hit(int nx=3, int ny=3): dx(nx), dy(ny) {data=new int[dx*dy];}; - - ~single_photon_hit(){delete [] data;}; /**< destructor, deletes the data array */ - - /** binary write to file of all elements of the structure, except size of the cluster - \param myFile file descriptor - */ - size_t write(FILE *myFile) { - //fwrite((void*)this, 1, 3*sizeof(int)+4*sizeof(double)+sizeof(quad), myFile); - - if (fwrite((void*)this, 1, sizeof(int)+2*sizeof(int16_t), myFile)) - return fwrite((void*)data, 1, dx*dy*sizeof(int), myFile); - return 0; - }; - - /** - binary read from file of all elements of the structure, except size of the cluster. The structure is then filled with those args - \param myFile file descriptor - */ - size_t read(FILE *myFile) { - //fread((void*)this, 1, 3*sizeof(int)+4*sizeof(double)+sizeof(quad), myFile); - - if (fread((void*)this, 1, sizeof(int)+2*sizeof(int16_t), myFile)) - return fread((void*)data, 1, dx*dy*sizeof(int), myFile); - return 0; - }; - - /** - assign the value to the element of the cluster matrix, with relative coordinates where the center of the cluster is (0,0) - \param v value to be set - \param ix coordinate x within the cluster (center is (0,0)) - \param iy coordinate y within the cluster (center is (0,0)) - */ - void set_data(double v, int ix, int iy=0){data[(iy+dy/2)*dx+ix+dx/2]=v;}; - - void set_cluster_size(int nx, int ny) {if (nx>0) dx=nx; if (ny>0) dy=ny; delete [] data; data=new int[dx*dy];}; - void get_cluster_size(int &nx, int &ny) {nx=dx; ny=dy;}; - void get_pixel(int &x1, int &y1) {x1=x; y1=y;}; - - /** - gets the value to the element of the cluster matrix, with relative coordinates where the center of the cluster is (0,0) - \param ix coordinate x within the cluster (center is (0,0)) - \param iy coordinate y within the cluster (center is (0,0)) - \returns value of the cluster element - */ - double get_data(int ix, int iy=0){return data[(iy+dy/2)*dx+ix+dx/2];}; - int *get_cluster() {return data;}; - - int iframe; /**< frame number */ - int16_t x; /**< x-coordinate of the center of hit */ - int16_t y; /**< x-coordinate of the center of hit */ - double rms; /**< noise of central pixel l -- at some point it can be removed*/ - double ped; /**< pedestal of the central pixel -- at some point it can be removed*/ - double tot; /**< sum of the 3x3 cluster */ - quadrant quad; /**< quadrant where the photon is located */ - double quadTot; /**< sum of the maximum 2x2cluster */ - int dx; /**< size of data cluster in x */ - int dy; /**< size of data cluster in y */ - int *data; /**< pointer to data */ -}; - - - -#endif diff --git a/slsDetectorCalibration/single_photon_hit_double.h b/slsDetectorCalibration/single_photon_hit_double.h deleted file mode 100644 index 7019b4149..000000000 --- a/slsDetectorCalibration/single_photon_hit_double.h +++ /dev/null @@ -1,98 +0,0 @@ -#ifndef SINGLE_PHOTON_HIT_H -#define SINGLE_PHOTON_HIT_H -#include -#include - -typedef double double32_t; -typedef float float32_t; -typedef int int32_t; - -#ifndef DEF_QUAD -#define DEF_QUAD - enum quadrant { - TOP_LEFT=0, - TOP_RIGHT=1, - BOTTOM_LEFT=2, - BOTTOM_RIGHT=3, - UNDEFINED_QUADRANT=-1 - }; -#endif - - -class single_photon_hit_double { - - /** @short Structure for a single photon hit */ - - public: - /** constructor, instantiates the data array -- all class elements are public! - \param nx cluster size in x direction - \param ny cluster size in y direction (defaults to 1 for 1D detectors) - */ - single_photon_hit_double(int nx=3, int ny=3): dx(nx), dy(ny) { - data=new double[dx*dy]; - }; - - ~single_photon_hit_double(){delete [] data;}; /**< destructor, deletes the data array */ - - /** binary write to file of all elements of the structure, except size of the cluster - \param myFile file descriptor - */ - size_t write(FILE *myFile) { - //fwrite((void*)this, 1, 3*sizeof(int)+4*sizeof(double)+sizeof(quad), myFile); - if (fwrite((void*)this, 1, sizeof(int)+2*sizeof(int), myFile)) - return fwrite((void*)data, 1, dx*dy*sizeof(double), myFile); - return 0; - }; - - /** - binary read from file of all elements of the structure, except size of the cluster. The structure is then filled with those args - \param myFile file descriptor - */ - size_t read(FILE *myFile) { - //fread((void*)this, 1, 3*sizeof(int)+4*sizeof(double)+sizeof(quad), myFile); - - if (fread((void*)this, 1, sizeof(int)+2*sizeof(int), myFile)) - return fread((void*)data, 1, dx*dy*sizeof(double), myFile); - return 0; - }; - - /** - assign the value to the element of the cluster matrix, with relative coordinates where the center of the cluster is (0,0) - \param v value to be set - \param ix coordinate x within the cluster (center is (0,0)) - \param iy coordinate y within the cluster (center is (0,0)) - */ - void set_data(double v, int ix, int iy=0){data[(iy+dy/2)*dx+ix+dx/2]=v;}; - - void set_cluster_size(int nx, int ny) { - - if (nx>0) dx=nx; if (ny>0) dy=ny; delete [] data; data=new double[dx*dy]; - }; - void get_cluster_size(int &nx, int &ny) {nx=dx; ny=dy;}; - void get_pixel(int &x1, int &y1) {x1=x; y1=y;}; - - /** - gets the value to the element of the cluster matrix, with relative coordinates where the center of the cluster is (0,0) - \param ix coordinate x within the cluster (center is (0,0)) - \param iy coordinate y within the cluster (center is (0,0)) - \returns value of the cluster element - */ - double get_data(int ix, int iy=0){return data[(iy+dy/2)*dx+ix+dx/2];}; - double *get_cluster() {return data;}; - - int iframe; /**< frame number */ - int x; /**< x-coordinate of the center of hit */ - int y; /**< x-coordinate of the center of hit */ - double rms; /**< noise of central pixel l -- at some point it can be removed*/ - double ped; /**< pedestal of the central pixel -- at some point it can be removed*/ - double tot; /**< sum of the 3x3 cluster */ - quadrant quad; /**< quadrant where the photon is located */ - double quadTot; /**< sum of the maximum 2x2cluster */ - int dx; /**< size of data cluster in x */ - int dy; /**< size of data cluster in y */ - double *data; /**< pointer to data */ -}; - - - -#endif diff --git a/slsDetectorCalibration/single_photon_hit_old.h b/slsDetectorCalibration/single_photon_hit_old.h deleted file mode 100644 index 587a09c1f..000000000 --- a/slsDetectorCalibration/single_photon_hit_old.h +++ /dev/null @@ -1,93 +0,0 @@ -#ifndef SINGLE_PHOTON_HIT_H -#define SINGLE_PHOTON_HIT_H -#include -#include - -typedef double double32_t; -typedef float float32_t; -typedef int int32_t; - -#ifndef DEF_QUAD -#define DEF_QUAD - enum quadrant { - TOP_LEFT=0, - TOP_RIGHT=1, - BOTTOM_LEFT=2, - BOTTOM_RIGHT=3, - UNDEFINED_QUADRANT=-1 - }; -#endif - - -class single_photon_hit { - - /** @short Structure for a single photon hit */ - - public: - /** constructor, instantiates the data array -- all class elements are public! - \param nx cluster size in x direction - \param ny cluster size in y direction (defaults to 1 for 1D detectors) - */ - single_photon_hit(int nx=3, int ny=3): dx(nx), dy(ny) {data=new int[dx*dy];}; - - ~single_photon_hit(){delete [] data;}; /**< destructor, deletes the data array */ - - /** binary write to file of all elements of the structure, except size of the cluster - \param myFile file descriptor - */ - size_t write(FILE *myFile) { - //fwrite((void*)this, 1, 3*sizeof(int)+4*sizeof(double)+sizeof(quad), myFile); - if (fwrite((void*)this, 1, sizeof(int)+2*sizeof(int16_t), myFile)) - return fwrite((void*)data, 1, dx*dy*sizeof(int), myFile); - return 0; - }; - - /** - binary read from file of all elements of the structure, except size of the cluster. The structure is then filled with those args - \param myFile file descriptor - */ - size_t read(FILE *myFile) { - //fread((void*)this, 1, 3*sizeof(int)+4*sizeof(double)+sizeof(quad), myFile); - - if (fread((void*)this, 1, sizeof(int)+2*sizeof(int16_t), myFile)) - return fread((void*)data, 1, dx*dy*sizeof(int), myFile); - return 0; - }; - - /** - assign the value to the element of the cluster matrix, with relative coordinates where the center of the cluster is (0,0) - \param v value to be set - \param ix coordinate x within the cluster (center is (0,0)) - \param iy coordinate y within the cluster (center is (0,0)) - */ - void set_data(double v, int ix, int iy=0){data[(iy+dy/2)*dx+ix+dx/2]=v;}; - - void set_cluster_size(int nx, int ny) {if (nx>0) dx=nx; if (ny>0) dy=ny; delete [] data; data=new int[dx*dy];}; - void get_cluster_size(int &nx, int &ny) {nx=dx; ny=dy;}; - void get_pixel(int &x1, int &y1) {x1=x; y1=y;}; - - /** - gets the value to the element of the cluster matrix, with relative coordinates where the center of the cluster is (0,0) - \param ix coordinate x within the cluster (center is (0,0)) - \param iy coordinate y within the cluster (center is (0,0)) - \returns value of the cluster element - */ - double get_data(int ix, int iy=0){return data[(iy+dy/2)*dx+ix+dx/2];}; - int *get_cluster() {return data;}; - - int iframe; /**< frame number */ - int16_t x; /**< x-coordinate of the center of hit */ - int16_t y; /**< x-coordinate of the center of hit */ - double rms; /**< noise of central pixel l -- at some point it can be removed*/ - double ped; /**< pedestal of the central pixel -- at some point it can be removed*/ - double tot; /**< sum of the 3x3 cluster */ - quadrant quad; /**< quadrant where the photon is located */ - double quadTot; /**< sum of the maximum 2x2cluster */ - int dx; /**< size of data cluster in x */ - int dy; /**< size of data cluster in y */ - int *data; /**< pointer to data */ -}; - - - -#endif diff --git a/slsDetectorCalibration/slsDetectorCalibration.doxy b/slsDetectorCalibration/slsDetectorCalibration.doxy deleted file mode 100644 index 4ea3784d3..000000000 --- a/slsDetectorCalibration/slsDetectorCalibration.doxy +++ /dev/null @@ -1,103 +0,0 @@ -# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in -# documentation are documented, even if no documentation was available. -# Private class members and static file members will be hidden unless -# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES - -EXTRACT_ALL = YES - -# If the EXTRACT_PRIVATE tag is set to YES all private members of a class -# will be included in the documentation. - -EXTRACT_PRIVATE = NO - - - -# If the EXTRACT_STATIC tag is set to YES all static members of a file -# will be included in the documentation. - -EXTRACT_STATIC = YES - -# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) -# defined locally in source files will be included in the documentation. -# If set to NO only classes defined in header files are included. - -EXTRACT_LOCAL_CLASSES = YES - -# This flag is only useful for Objective-C code. When set to YES local -# methods, which are defined in the implementation section but not in -# the interface are included in the documentation. -# If set to NO (the default) only methods in the interface are included. - -EXTRACT_LOCAL_METHODS = YES - -# If this flag is set to YES, the members of anonymous namespaces will be -# extracted and appear in the documentation as a namespace called -# 'anonymous_namespace{file}', where file will be replaced with the base -# name of the file that contains the anonymous namespace. By default -# anonymous namespace are hidden. - -EXTRACT_ANON_NSPACES = NO - -# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all -# undocumented members of documented classes, files or namespaces. -# If set to NO (the default) these members will be included in the -# various overviews, but no documentation section is generated. -# This option has no effect if EXTRACT_ALL is enabled. - -HIDE_UNDOC_MEMBERS = NO - -# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all -# undocumented classes that are normally visible in the class hierarchy. -# If set to NO (the default) these classes will be included in the various -# overviews. This option has no effect if EXTRACT_ALL is enabled. - -HIDE_UNDOC_CLASSES = NO - -# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all -# friend (class|struct|union) declarations. -# If set to NO (the default) these declarations will be included in the -# documentation. - -HIDE_FRIEND_COMPOUNDS = NO - -INTERNAL_DOCS = NO - -SHOW_INCLUDE_FILES = NO - -SHOW_FILES = NO - -SHOW_NAMESPACES = NO - -COMPACT_LATEX = YES - -PAPER_TYPE = a4 - -PDF_HYPERLINKS = YES - -USE_PDFLATEX = YES - -LATEX_HIDE_INDICES = YES - -PREDEFINED = __cplusplus - -INPUT = analogDetector.h \ - pedestalSubtraction.h \ - MovingStat.h \ - singlePhotonDetector.h \ - interpolatingDetector.h tiffIO.h \ - single_photon_hit.h \ - dataStructures/slsDetectorData.h \ - commonModeSubtraction.h \ - RunningStat.h \ - interpolations/etaInterpolationBase.h \ - interpolations/slsInterpolation.h \ - interpolations/etaInterpolationPosXY.h \ - interpolations/linearInterpolation.h \ - interpolations/noInterpolation.h \ - interpolations/etaInterpolationGlobal.h \ - multiThreadedAnalogDetector.h - - -OUTPUT_DIRECTORY = slsDetectorCalibrationDocs - -#moench03Ctb10GbT1Data.h moench03TCtbData.h moench03T1CtbData.h moench03CtbData.h moench03Ctb10GbData.h moench03TCtb10GbData.h Mythen3_01_jctbData.h adcSar2_jctbData.h eigerHalfModuleData.h energyCalibration.h slsReceiverData.h gotthardModuleData.h gotthardShortModuleData.h jungfrau02Data.h jungfrau10ModuleData.h moench02Ctb10GbData.h moench02CtbData.h moench02ModuleData.h moench03CommonMode.h moenchCommonMode.h chiptestBoardData.h interpolation/etaVEL/interpolation_EtaVEL.h interpolation/etaVEL/EtaVEL.h etaVEL/iterativeEtaInterpolation.h dataStructures/moench03T1ZmqData.h \ No newline at end of file diff --git a/slsDetectorCalibration/slsDetectorData.h b/slsDetectorCalibration/slsDetectorData.h deleted file mode 100644 index 16b1c9767..000000000 --- a/slsDetectorCalibration/slsDetectorData.h +++ /dev/null @@ -1,340 +0,0 @@ -#ifndef SLSDETECTORDATA_H -#define SLSDETECTORDATA_H - -#include -#include -#include - -using namespace std; - - -template -class slsDetectorData { - - protected: - const int nx; /**< Number of pixels in the x direction */ - const int ny; /**< Number of pixels in the y direction */ - int dataSize; /**=0 && ix=0 && iy=0 && ix=0 && iydataSize) dsize=dataSize; - for (int ip=0; ip<(dsize/sizeof(dataType)); ip++) { - getPixel(ip,ix,iy); - if (ix>=0 && ix=0 && iydataSize) dsize=dataSize; - for (int ip=0; ip<(dsize/sizeof(dataType)); ip++) { - getPixel(ip,ix,iy); - if (ix>=0 && ix=0 && iy=0 && ix=0 && iy=0 && dataMap[iy][ix] -#include // exit() -template -class slsReceiverData : public slsDetectorData { - - -public: - - /** - slsReceiver data structure. Works for data acquired using the slsDetectorReceiver subdivided in different packets with headers and footers. - Inherits and implements slsDetectorData. - - Constructor (no error checking if datasize and offsets are compatible!) - \param npx number of pixels in the x direction - \param npy number of pixels in the y direction (1 for strips) - \param np number of packets - \param psize packets size - \param dMap array of size nx*ny storing the pointers to the data in the dataset (as offset) - \param dMask Array of size nx*ny storing the polarity of the data in the dataset (should be 0 if no inversion is required, 0xffffffff is inversion is required) - \param dROI Array of size nx*ny. The elements are 1s if the channel is good or in the ROI, 0 is bad or out of the ROI. NULL (default) means all 1s. - - */ - slsReceiverData(int npx, int npy, int np, int psize, int **dMap=NULL, dataType **dMask=NULL, int **dROI=NULL): slsDetectorData(npx, npy, np*psize, dMap, dMask, dROI), nPackets(np), packetSize(psize) {}; - - - /** - - Returns the frame number for the given dataset. Virtual func: works for slsDetectorReceiver data (also for each packet), but can be overloaded. - \param buff pointer to the dataset - \returns frame number - - */ - - virtual int getFrameNumber(char *buff){return ((*(int*)buff)&(0xffffff00))>>8;}; - - /** - - Returns the packet number for the given dataset. Virtual func: works for slsDetectorReceiver packets, but can be overloaded. - \param buff pointer to the dataset - \returns packet number number - - */ - - virtual int getPacketNumber(char *buff){return (*(int*)buff)&0xff;}; - - - - /** - - Loops over a memory slot until a complete frame is found (i.e. all packets 0 to nPackets, same frame number). Can be overloaded for different kind of detectors! - \param data pointer to the memory to be analyzed - \param ndata size of frame returned - \param dsize size of the memory slot to be analyzed - \returns pointer to the first packet of the last good frame (might be incomplete if npackets lower than the number of packets), or NULL if no frame is found - - */ - - virtual char *findNextFrame(char *data, int &ndata, int dsize) { - char *retval=NULL, *p=data; - int dd=0; - int fn, fnum=-1, np=0, pnum=-1; - while (dd<=(dsize-packetSize)) { - pnum=getPacketNumber(p); - fn=getFrameNumber(p); - //cout <<"fnum:"<nPackets) { - //cout << "Bad packet number " << pnum << " frame "<< fn << endl; - retval=NULL; - np=0; - } else if (pnum==1) { - retval=p; - if (np>0) - /*cout << "*Incomplete frame number " << fnum << endl;*/ - np=0; - fnum=fn; - } else if (fn!=fnum) { - if (fnum!=-1) { - /* cout << " **Incomplete frame number " << fnum << " pnum " << pnum << " " << getFrameNumber(p) << endl;*/ - retval=NULL; - } - np=0; - } - p+=packetSize; - dd+=packetSize; - np++; - //cout <<"fnum:"<0){ - //cprintf(BG_RED, "Too few packets for this frame! fnum:%d, pnum:%d np:%d\n",fnum,pnum,np); - cout << "Too few packets for this frame! "<< fnum << " " << pnum << " " << np <nPackets) { - cout << "too many packets!!!!!!!!!!" << endl; - delete [] data; - return NULL; - } else if (retval!=NULL) { - // cout << "+" << endl;; - for (int ip=0; ipnPackets) { - cout << "*******too many packets!!!!!!!!!!" << endl; - delete [] data; - return NULL; - } else { - // cout << "." << endl;; - np++; - } - } - } - delete [] data; - return NULL; - }; - - - /** - - Loops over a file stream until a complete frame is found (i.e. all packets 0 to nPackets, same frame number). Can be overloaded for different kind of detectors! - \param filebin input file stream (binary) - \param fnum frame number of frame returned - \returns pointer to the first packet of the last good frame, NULL if no frame is found or last frame is incomplete - - */ - - virtual char *readNextFrame(ifstream &filebin, int& fnum) { - char *data=new char[packetSize*nPackets]; - char *retval=0; - int np=0, nd; - fnum = -1; - - if (filebin.is_open()) { - while (filebin.read(data+np*packetSize,packetSize)) { - - if (np==(nPackets-1)) { - - fnum=getFrameNumber(data); //cout << "fnum:"<nPackets) { - cout << "too many packets!!!!!!!!!!" << endl; - delete [] data; - return NULL; - } else if (retval!=NULL) { - // cout << "+" << endl;; - for (int ip=0; ipnPackets) { - cout << "*******too many packets!!!!!!!!!!" << endl; - delete [] data; - return NULL; - } else { - // cout << "." << endl;; - np++; - //cout<<"np:"< -using namespace std; -// #undef cbf_failnez -// #define cbf_failnez(x) \ -// { \ -// int err; \ -// err = (x); \ -// if (err) { \ -// fprintf(stderr,"\nCBFlib fatal error %x \n",err); \ -// exit(-1); \ -// } \ -// } - -void *WriteToTiff(float * imgData, const char * imgname, int nrow, int ncol){ - int sampleperpixel=1; - // unsigned char * buff=NULL; - tsize_t linebytes; - cout << "--" < -#include -#include -#include -#include -#include -#include - - -/*****************************************************************************/ -// -//CBFlib must be installed to use this program -// -/*****************************************************************************/ -#include "tiffio.h" - -#undef cbf_failnez -#define cbf_failnez(x) \ - { \ - int err; \ - err = (x); \ - if (err) { \ - fprintf(stderr,"\nCBFlib fatal error %x \n",err); \ - exit(-1); \ - } \ - } - -void *WriteToTiff(float * imgData, const char * imgname, int nrow, int ncol); - -float *ReadFromTiff( const char * imgname, uint32 &nrow, uint32 &ncol); - -#endif diff --git a/slsDetectorGui/.gitignore b/slsDetectorGui/.gitignore deleted file mode 100644 index 509e7b512..000000000 --- a/slsDetectorGui/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -Makefile.gui -forms/include/ -mocs/ -objs/ -qrc_icons.cpp -.project diff --git a/slsDetectorGui/CMakeLists.txt b/slsDetectorGui/CMakeLists.txt deleted file mode 100644 index bad299e19..000000000 --- a/slsDetectorGui/CMakeLists.txt +++ /dev/null @@ -1,133 +0,0 @@ - -set(CMAKE_AUTOMOC ON) - -set(SOURCES - slsDetectorPlotting/src/SlsQt1DPlot.cxx - slsDetectorPlotting/src/SlsQt1DZoomer.cxx - slsDetectorPlotting/src/SlsQt2DHist.cxx - slsDetectorPlotting/src/SlsQt2DPlot.cxx - slsDetectorPlotting/src/SlsQt2DPlotLayout.cxx - slsDetectorPlotting/src/SlsQtNumberEntry.cxx - src/qDetectorMain.cpp - src/qDrawPlot.cpp - src/qCloneWidget.cpp - src/qTabMeasurement.cpp - src/qTabDataOutput.cpp - src/qTabPlot.cpp - src/qTabActions.cpp - src/qActionsWidget.cpp - src/qScanWidget.cpp - src/qTabAdvanced.cpp - src/qTabSettings.cpp - src/qTabDebugging.cpp - src/qTabDeveloper.cpp - src/qTabMessages.cpp - src/qServer.cpp -) - -set(FORMS - forms/form_detectormain.ui - forms/form_tab_measurement.ui - forms/form_tab_dataoutput.ui - forms/form_tab_plot.ui - forms/form_tab_advanced.ui - forms/form_tab_settings.ui - forms/form_tab_debugging.ui - forms/form_action.ui - forms/form_scan.ui -) - -qt4_wrap_ui(FORMS_H ${FORMS}) - -set(HEADERS - slsDetectorPlotting/include/SlsQt1DPlot.h - slsDetectorPlotting/include/SlsQt1DZoomer.h - slsDetectorPlotting/include/SlsQt2DHist.h - slsDetectorPlotting/include/SlsQt2DPlot.h - slsDetectorPlotting/include/SlsQt2DPlotLayout.h - slsDetectorPlotting/include/SlsQt2DZoomer.h - slsDetectorPlotting/include/SlsQtValidators.h - slsDetectorPlotting/include/SlsQtNumberEntry.h - include/qDefs.h - include/qDebugStream.h - include/qDetectorMain.h - include/qDrawPlot.h - include/qCloneWidget.h - include/qTabMeasurement.h - include/qTabDataOutput.h - include/qTabPlot.h - include/qTabActions.h - include/qActionsWidget.h - include/qScanWidget.h - include/qTabAdvanced.h - include/qTabSettings.h - include/qTabDebugging.h - include/qTabDeveloper.h - include/qTabMessages.h - include/gitInfoGui.h - include/qServer.h -) -set(RESOURCES - include/icons.qrc -) -qt4_add_resources(RESOURCES_SRCS ${RESOURCES}) - -include_directories( - include - slsDetectorPlotting/include - ../slsDetectorSoftware/commonFiles - ../slsDetectorSoftware/slsReceiverInterface - ../slsDetectorSoftware/slsDetector - ../slsDetectorSoftware/slsDetectorAnalysis - ../slsDetectorSoftware/multiSlsDetector - ../slsDetectorSoftware/usersFunctions - ../slsReceiverSoftware/include - ${QT_INCLUDE_DIR} - ${QT_QTCORE_INCLUDE_DIR} - ${QT_QTGUI_INCLUDE_DIR} - ${QWT_INCLUDE_DIR} - ${CMAKE_CURRENT_BINARY_DIR} -) - -add_definitions( - -DDACS_INT -DVERBOSE -DPRINT_LOG -) - -add_executable(slsDetectorGui - ${SOURCES} - ${HEADERS} - ${FORMS_H} - ${RESOURCES_SRCS} -) - -set_target_properties(slsDetectorGui PROPERTIES - LINKER_LANGUAGE CXX - RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin -) - - -target_link_libraries(slsDetectorGui - slsDetectorShared - ${QT_QTCORE_LIBRARIES} - ${QT_QTGUI_LIBRARIES} - ${QWT_LIBRARIES} - pthread - zmq - rt - png - z - Qt4::QtOpenGL - Qt4::QtSvg - -) - -add_executable(gui_client - client/qClient.h - client/qClient.cpp -) -set_target_properties(gui_client PROPERTIES - RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin -) - -install(TARGETS slsDetectorGui gui_client - RUNTIME DESTINATION bin) diff --git a/slsDetectorGui/Makefile b/slsDetectorGui/Makefile deleted file mode 100644 index d91ea4f7d..000000000 --- a/slsDetectorGui/Makefile +++ /dev/null @@ -1,68 +0,0 @@ -# LEO: Won't compile without libSlsDetector - -include ../Makefile.include - -$(info ) -$(info ##################################) -$(info # In slsDetectorGui Makefile #) -$(info ##################################) -$(info ) - - -DESTDIR ?= ../bin -LIBDIR ?= ../bin -PROG = $(DESTDIR)/slsDetectorGui -DOCDIR ?= docs - -LIBRARYDIR ?= ../slsDetectorSoftware -LIBRARYRXRDIR ?= ../slsReceiverSoftware -INCLUDES ?= $(LIBRARYDIR)/commonFiles -I$(LIBRARYRXRDIR)/MySocketTCP -I$(LIBRARYDIR)/slsReceiverInterface -I$(LIBRARYDIR)/slsDetector -I$(LIBRARYDIR)/slsDetectorAnalysis -I$(LIBRARYDIR)/multiSlsDetector -I$(LIBRARYDIR)/usersFunctions -I$(LIBRARYRXRDIR)/includes - -LDFLAGDET ?= -L$(LIBDIR) -Wl,-rpath=$(LIBDIR) -lSlsDetector - - - -#ifeq ( $(EIGERSLS), yes) -# LDFLAG += $(EIGERFLAGS) -#else ifeq ( $(ROOTSLS), yes) -# LDFLAG += $(ROOTFLAGS) -#endif - -.PHONY: all lib clean mm doc htmldoc guiclient - - -all: lib Makefile.gui $(PROG) guiclient - -lib: - cd $(LIBRARYDIR) && $(MAKE) DESTDIR=$(DESTDIR) - @echo "" - @echo "#######################################" - @echo "# Back in slsDetectorGui Makefile #" - @echo "#######################################" - @echo "" - - -clean: - if test -e Makefile.gui; then $(MAKE) -f Makefile.gui clean; $(MAKE) -f Makefile.gui mocclean; rm Makefile.gui; rm $(DESTDIR)/slsDetectorGui; else $(MAKE) Makefile.gui; $(MAKE) -f Makefile.gui clean; $(MAKE) -f Makefile.gui mocclean; rm $(DESTDIR)/slsDetectorGui; fi - cd client && $(MAKE) clean -# cd manual && make clean - - -Makefile.gui: mm - -mm: - qmake -set QT_INSTALL_PREFIX $(QTDIR) && qmake -o Makefile.gui INCLUDES='$(INCLUDES)' DESTDIR=$(DESTDIR) SLSDETLIB=$(DESTDIR) SUBLIBS='$(LDFLAGDET)' LIBDIR='$(LIBDIR)' - -doc: - cd manual && $(MAKE) DESTDIR=$(DOCDIR) - -htmldoc: - cd manual && $(MAKE) html DESTDIR=$(DOCDIR) - -$(PROG): Makefile $(DIR) src/*.cpp include/*.h slsDetectorPlotting/include/*.h slsDetectorPlotting/src/*.cxx # forms/include/*.h - $(MAKE) -f Makefile.gui SLSDETLIB=$(DESTDIR) DESTDIR=$(DESTDIR) SUBLIBS='$(LDFLAGDET)' INCLUDES='$(INCLUDES)' LIBDIR='$(LIBDIR)' - -guiclient: -# echo $(WD) - cd client && $(MAKE) DESTDIR=$(DESTDIR) - diff --git a/slsDetectorGui/client/Makefile b/slsDetectorGui/client/Makefile deleted file mode 100644 index 60f412844..000000000 --- a/slsDetectorGui/client/Makefile +++ /dev/null @@ -1,31 +0,0 @@ -CC = g++ -CLAGS += -DVERBOSE #VERYBOSE -LDLIBS += -lm -lstdc++ -pthread - -LDIR = ../../slsDetectorSoftware -RDIR = ../../slsReceiverSoftware -DDIR = ../../bin -INCLUDES = -I $(LDIR)/commonFiles -I $(LDIR)/slsDetector -I ../include -I $(RDIR)/include -SRC_CLNT = qClient.cpp $(RDIR)/src/MySocketTCP.cpp -DEPSINCLUDES= qClient.h $(RDIR)/include/MySocketTCP.h $(LDIR)/slsDetector/slsDetectorBase.h $(LDIR)/commonFiles/sls_detector_defs.h - - -all: client - -client: $(OBJS) $(DDIR)/gui_client - -OBJS = $(SRC_CLNT:%.cpp=%.o) - - -$(DDIR)/gui_client : $(SRC_CLNT) $(DEPSINCLUDES) Makefile - $(CXX) -o $@ -c $< $(INCLUDES) $(FLAGS) $(LDLIBS) - - - -clean: - rm -rf $(DDIR)/gui_client *.o - - - - - diff --git a/slsDetectorGui/client/qClient.cpp b/slsDetectorGui/client/qClient.cpp deleted file mode 100644 index f12ced4e1..000000000 --- a/slsDetectorGui/client/qClient.cpp +++ /dev/null @@ -1,237 +0,0 @@ -/* - * qClient.cpp - * - * Created on: Feb 27, 2013 - * Author: Dhanya Maliakal - */ -// Qt Project Class Headers -#include "qClient.h" -// Project Class Headers -#include "MySocketTCP.h" -#include "slsDetectorBase.h" - -// C++ Include Headers -#include -#include -using namespace std; - - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -int main(int argc, char *argv[]){ - qClient* cl = 0; - try { - cl = new qClient(argv[1]); - } catch(...) { - return 0; - } - cl->executeLine(argc-2, argv+2); - delete cl; - - return 0; -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -qClient::qClient(char* hostname): - mySocket(0), - myStopSocket(0){ - - try { - // control socket - mySocket = new MySocketTCP(hostname, DEFAULT_GUI_PORTNO); - // stop socket - myStopSocket = new MySocketTCP(hostname, DEFAULT_GUI_PORTNO+1); - } catch(...) { - if (mySocket == 0) - cout << "Error: could not connect to control server:" << - hostname << " with port " << DEFAULT_GUI_PORTNO << endl; - else - cout << "Error: could not connect to stop server:" << - hostname << " with port " << DEFAULT_GUI_PORTNO + 1 << endl; - throw; - } -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - -qClient::~qClient() { - if(mySocket) delete mySocket; - if(myStopSocket) delete myStopSocket; -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -int qClient::executeLine(int narg, char *args[]){ - - string retval = ""; - string cmd = args[0]; - string argument; - - - //validate command structure - if(narg<1){ - cout << "Error: no command parsed" << endl; - return FAIL; - } - - - //help - if (cmd == "help"){ - retval = printCommands(); - } - - //file name - else if (cmd == "status"){ - - if(narg>1){ - argument = args[1]; - //start acquisition - if(argument == "start") - startAcquisition(); - else if (argument == "stop") - stopAcquisition(); - else{ - cprintf(RED,"Error: could not parse arguments: %s\n", argument.c_str()); - printCommands(); - return FAIL; - } - } - retval = getStatus(); - } - - - else if (cmd == "acquire"){ - startAcquisition(true); - retval = getStatus(); - } - - - else if (cmd == "exit"){ - return exitServer(); - } - - - //unrecognized command - else{ - cout << "Error: unrecognized command" << endl; - return FAIL; - } - - - //print result - cout << cmd << ": " << retval << endl; - - return OK; -} - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -string qClient::printCommands(){ - ostringstream os; - os << "\nexit \t exits servers in gui" << std::endl; - os << "status \t gets status of acquisition in gui. - can be running or idle" << std::endl; - os << "status i starts/stops acquistion in gui-non blocking. i is start or stop" << std::endl; - os << "acquire starts acquistion in gui-blocking" << std::endl; - return os.str(); -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -string qClient::getStatus(){ - int fnum = F_GET_RUN_STATUS; - int ret = FAIL; - runStatus retval=ERROR; - int progress = 0; - char answer[100]; - - if (myStopSocket->Connect() >= 0) { - myStopSocket->SendDataOnly(&fnum,sizeof(fnum)); - myStopSocket->ReceiveDataOnly(&ret,sizeof(ret)); - myStopSocket->ReceiveDataOnly(&retval,sizeof(retval)); - myStopSocket->ReceiveDataOnly(&progress,sizeof(progress)); - myStopSocket->Disconnect(); - }else - exit(-1); - - - sprintf(answer,"%d%% ",progress); - strcat(answer,slsDetectorBase::runStatusType((runStatus)retval).c_str()); - - return string(answer); -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -int qClient::startAcquisition(bool blocking){ - int fnum = F_START_ACQUISITION; - if(blocking) fnum = F_START_AND_READ_ALL; - int ret = FAIL; - - if (mySocket->Connect() >= 0) { - mySocket->SendDataOnly(&fnum,sizeof(fnum)); - mySocket->ReceiveDataOnly(&ret,sizeof(ret)); - if (ret == FAIL){ - mySocket->ReceiveDataOnly(mess,sizeof(mess)); - std::cout<< "Gui returned error: " << mess << std::endl; - } - mySocket->Disconnect(); - }else - exit(-1); - - return ret; -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -int qClient::stopAcquisition(){ - int fnum = F_STOP_ACQUISITION; - int ret = FAIL; - - if (myStopSocket->Connect() >= 0) { - myStopSocket->SendDataOnly(&fnum,sizeof(fnum)); - myStopSocket->ReceiveDataOnly(&ret,sizeof(ret)); - if (ret == FAIL){ - myStopSocket->ReceiveDataOnly(mess,sizeof(mess)); - std::cout<< "Gui returned error: " << mess << std::endl; - } - myStopSocket->Disconnect(); - }else - exit(-1); - - return ret; -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -int qClient::exitServer(){ - int fnum = F_EXIT_SERVER; - int ret = FAIL; - - if (myStopSocket->Connect() >= 0) { - myStopSocket->SendDataOnly(&fnum,sizeof(fnum)); - myStopSocket->ReceiveDataOnly(&ret,sizeof(ret)); - myStopSocket->ReceiveDataOnly(mess,sizeof(mess)); - cout << mess << endl; - myStopSocket->Disconnect(); - }else - exit(-1); - - return ret; -} diff --git a/slsDetectorGui/client/qClient.h b/slsDetectorGui/client/qClient.h deleted file mode 100644 index fbec87a95..000000000 --- a/slsDetectorGui/client/qClient.h +++ /dev/null @@ -1,65 +0,0 @@ -/* - * qClient.h - * - * Created on: Feb 27, 2013 - * Author: Dhanya Maliakal - */ -#ifndef QCLIENT_H -#define QCLIENT_H - - -/** Qt Project Class Headers */ -/** Project Class Headers */ -class MySocketTCP; -#include "sls_detector_defs.h" -/** C++ Include Headers */ -#include -#include -using namespace std; - -/** - *@short Sets up the gui server - */ -class qClient: public virtual slsDetectorDefs{ - - -public: - /** \short The constructor*/ - qClient(char* hostname); - /** Destructor */ - virtual ~qClient(); - - /**Execute command*/ - int executeLine(int narg, char *args[]); - -private: - /** Print list of commands */ - string printCommands(); - - /** Start Acquisition - * @param blocking true if its a blocking acquistion - */ - int startAcquisition(bool blocking = false); - - /** Stops Acquisition */ - int stopAcquisition(); - - /** Gets run status */ - string getStatus(); - - /** Exits Server */ - int exitServer(); - - /** client socket */ - MySocketTCP *mySocket; - - /** client socket */ - MySocketTCP *myStopSocket; - - char mess[MAX_STR_LENGTH]; - -}; - - - -#endif /* QCLIENT_H */ diff --git a/slsDetectorGui/doxy.config b/slsDetectorGui/doxy.config deleted file mode 100644 index 877d4c456..000000000 --- a/slsDetectorGui/doxy.config +++ /dev/null @@ -1,106 +0,0 @@ -# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in -# documentation are documented, even if no documentation was available. -# Private class members and static file members will be hidden unless -# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES - -EXTRACT_ALL = YES - -# If the EXTRACT_PRIVATE tag is set to YES all private members of a class -# will be included in the documentation. - -EXTRACT_PRIVATE = YES - -# If the EXTRACT_STATIC tag is set to YES all static members of a file -# will be included in the documentation. - -EXTRACT_STATIC = YES - -# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) -# defined locally in source files will be included in the documentation. -# If set to NO only classes defined in header files are included. - -EXTRACT_LOCAL_CLASSES = YES - -# This flag is only useful for Objective-C code. When set to YES local -# methods, which are defined in the implementation section but not in -# the interface are included in the documentation. -# If set to NO (the default) only methods in the interface are included. - -EXTRACT_LOCAL_METHODS = YES - -# If this flag is set to YES, the members of anonymous namespaces will be -# extracted and appear in the documentation as a namespace called -# 'anonymous_namespace{file}', where file will be replaced with the base -# name of the file that contains the anonymous namespace. By default -# anonymous namespace are hidden. - -EXTRACT_ANON_NSPACES = NO - -# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all -# undocumented members of documented classes, files or namespaces. -# If set to NO (the default) these members will be included in the -# various overviews, but no documentation section is generated. -# This option has no effect if EXTRACT_ALL is enabled. - -HIDE_UNDOC_MEMBERS = NO - -# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all -# undocumented classes that are normally visible in the class hierarchy. -# If set to NO (the default) these classes will be included in the various -# overviews. This option has no effect if EXTRACT_ALL is enabled. - -HIDE_UNDOC_CLASSES = NO - -# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all -# friend (class|struct|union) declarations. -# If set to NO (the default) these declarations will be included in the -# documentation. - -HIDE_FRIEND_COMPOUNDS = NO - -INPUT = \ - slsDetectorPlotting/include/SlsQt1DPlot.h\ - slsDetectorPlotting/src/SlsQt1DPlot.cxx - slsDetectorPlotting/include/SlsQt1DZoomer.h\ - slsDetectorPlotting/src/SlsQt1DZoomer.cxx\ - slsDetectorPlotting/include/SlsQt2DHist.h\ - slsDetectorPlotting/src/SlsQt2DHist.cxx\ - slsDetectorPlotting/include/SlsQt2DPlot.h\ - slsDetectorPlotting/src/SlsQt2DPlot.cxx\ - slsDetectorPlotting/include/SlsQt2DPlotLayout.h\ - slsDetectorPlotting/src/SlsQt2DPlotLayout.cxx\ - slsDetectorPlotting/include/SlsQtNumberEntry.h\ - slsDetectorPlotting/src/SlsQtNumberEntry.cxx\ - slsDetectorPlotting/include/SlsQt2DZoomer.h\ - slsDetectorPlotting/include/SlsQtValidators.h\ - include/qDetectorMain.h\ - src/qDetectorMain.cpp\ - include/qDrawPlot.h\ - src/qDrawPlot.cpp\ - include/qCloneWidget.h\ - src/qCloneWidget.cpp\ - include/qTabMeasurement.h\ - src/qTabMeasurement.cpp\ - include/qTabDataOutput.h\ - src/qTabDataOutput.cpp\ - include/qTabPlot.h\ - src/qTabPlot.cpp\ - include/qTabActions.h\ - src/qTabActions.cpp\ - include/qActionsWidget.h\ - src/qActionsWidget.cpp\ - include/qScanWidget.h\ - src/qScanWidget.cpp\ - include/qTabAdvanced.h\ - src/qTabAdvanced.cpp\ - include/qTabSettings.h\ - src/qTabSettings.cpp\ - include/qTabDebugging.h\ - src/qTabDebugging.cpp\ - include/qTabDeveloper.h\ - src/qTabDeveloper.cpp\ - include/qDefs.h - - -OUTPUT_DIRECTORY = docs - diff --git a/slsDetectorGui/forms/form_action.ui b/slsDetectorGui/forms/form_action.ui deleted file mode 100644 index 33d93c35e..000000000 --- a/slsDetectorGui/forms/form_action.ui +++ /dev/null @@ -1,169 +0,0 @@ - - - ActionsObject - - - - 0 - 0 - 680 - 25 - - - - - 0 - 0 - - - - - 0 - 0 - - - - - 1000 - 1000 - - - - Form - - - - 0 - - - 0 - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 20 - 20 - - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 40 - 20 - - - - - - - - - None - - - - - Custom Script - - - - - - - - false - - - - - - - false - - - Additional Parameter: - - - - - - - false - - - Browse - - - - :/icons/images/browse.png:/icons/images/browse.png - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 5 - 20 - - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 5 - 20 - - - - - - - - false - - - - 0 - 0 - - - - - - - - - - - diff --git a/slsDetectorGui/forms/form_detectormain.ui b/slsDetectorGui/forms/form_detectormain.ui deleted file mode 100644 index 1cdc2001b..000000000 --- a/slsDetectorGui/forms/form_detectormain.ui +++ /dev/null @@ -1,521 +0,0 @@ - - - DetectorMainObject - - - true - - - - 0 - 0 - 800 - 848 - - - - - 0 - 0 - - - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - - - 185 - 185 - 185 - - - - - - - 185 - 185 - 185 - - - - - - - 185 - 185 - 185 - - - - - - - 89 - 89 - 89 - - - - - - - - - 9 - - - - SLS Detector GUI - - - Qt::ImhNone - - - false - - - QTabWidget::Rounded - - - false - - - - - 0 - 0 - - - - - 0 - 395 - - - - - 524287 - 395 - - - - - - - 0 - 0 - 800 - 25 - - - - - 0 - 0 - - - - - 0 - 25 - - - - - 16777215 - 25 - - - - - 9 - - - - Qt::StrongFocus - - - false - - - true - - - - - 9 - - - - &Utilities - - - - - - - - - - - - - - - - &Modes - - - - - - - - - &Help - - - - - - - - - - true - - - - 0 - 0 - - - - - 36 - 422 - - - - - 524287 - 524287 - - - - - Sans Serif - 11 - 50 - false - - - - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> -<html><head><meta name="qrichtext" content="1" /><style type="text/css"> -p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> -<table border="0" style="-qt-table-type: root; margin-top:4px; margin-bottom:4px; margin-left:4px; margin-right:4px;"> -<tr> -<td style="border: none;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#00007f;">Left Click :zoom in</span></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#00007f;">Righ</span><span style=" color:#00007f;">t Click </span><span style=" color:#00007f;">: zoom out by 1</span></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#00007f;">Middle Click : panning</span></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#00007f;">Ctrl+Right Click : zoom out to full size</span></p></td></tr></table></body></html> - - - - - - Qt::LeftToRight - - - QDockWidget::NoDockWidgetFeatures - - - Qt::BottomDockWidgetArea - - - SLS Detector Plot - - - 8 - - - - - 0 - 0 - - - - - 0 - 400 - - - - - 16777215 - 16777215 - - - - - - - - - 0 - 0 - 0 - - - - - - - - - 0 - 0 - 0 - - - - - - - - - 119 - 119 - 119 - - - - - - - - - 9 - 50 - false - - - - - - - &Load &Setup - - - - - - - - &Save &Setup - - - - - - - - &Measurement Wizard - - - - - &Load &Configuration - - - - - &Save &Configuration - - - - - &Energy Calibration - - - - - &Angular Calibration - - - - - true - - - false - - - &Debug - - - - - true - - - false - - - &Beamline - - - - - true - - - false - - - &Expert - - - - - true - - - false - - - &Configuration - - - - - &Version - - - - - &About - - - - - true - - - D&ockable Windows - - - - - &Load &Trimbits - - - - - &Save &Trimbits - - - - - &Load C&alibration - - - - - &Save C&alibration - - - - - true - - - &Listen to Gui Client - - - - - - diff --git a/slsDetectorGui/forms/form_scan.ui b/slsDetectorGui/forms/form_scan.ui deleted file mode 100644 index bd00b8c6e..000000000 --- a/slsDetectorGui/forms/form_scan.ui +++ /dev/null @@ -1,488 +0,0 @@ - - - ScanObject - - - - 0 - 0 - 724 - 125 - - - - - 0 - 0 - - - - - 0 - 0 - - - - - 1000 - 1000 - - - - Form - - - - 0 - - - 5 - - - 0 - - - - - false - - - - 0 - 0 - - - - - 180 - 0 - - - - - - - - 0 - - - 5 - - - 0 - - - 2 - - - 0 - - - 5 - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 10 - 20 - - - - - - - - <nobr> -Defines scan range for a <b>Constant Step Size</b> with the following constraints: -</nobr><br><nobr> -1. <b>Number of Steps</b> >=2. -</nobr><br><nobr> -2. <b>Size</b> not equal to 0. -</nobr><br><nobr> -3. <b>From</b> not equal to <b>To</b>. -</nobr><br> - - - Constant Step Size - - - true - - - - - - - <nobr>Measures only at specific values listed by the user.</nobr><br> -<nobr>Number of entries is restricted to <b>Number of Steps</b> field.</nobr> - - - Specific Values - - - false - - - - - - - - 0 - 0 - - - - <nobr>Measures only at the specific values listed in a file.</nobr><br> -<nobr>Select the file, where these values are listed.</nobr> - - - Values from File - - - false - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 10 - 20 - - - - - - - - - - - - - - - - - - - - 0 - - - - - false - - - - 0 - 0 - - - - Precision: - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 5 - 20 - - - - - - - - false - - - - 0 - 0 - - - - 0 - - - 10 - - - 0 - - - - - - - - - 0 - - - - - false - - - - 0 - 0 - - - - Additional Parameter: - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 5 - 20 - - - - - - - - false - - - - 0 - 0 - - - - - - - - - - 0 - - - - - false - - - - 0 - 0 - - - - Number of Steps: - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 5 - 20 - - - - - - - - false - - - - 0 - 0 - - - - false - - - 0 - - - 1000000 - - - 0 - - - - - - - - - - None - - - - - Energy Scan (eV) - - - - - Threshold Scan - - - - - Trimbits Scan - - - - - Position Scan - - - - - Custom Script - - - - - - - - 0 - - - - - false - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 5 - 20 - - - - - - - - false - - - Browse - - - - :/icons/images/browse.png:/icons/images/browse.png - - - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 30 - 20 - - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 40 - 20 - - - - - - - - comboScript - dispScript - btnBrowse - dispParameter - spinSteps - spinPrecision - radioRange - radioCustom - radioFile - - - - - - diff --git a/slsDetectorGui/forms/form_tab_advanced.ui b/slsDetectorGui/forms/form_tab_advanced.ui deleted file mode 100644 index 0e980a746..000000000 --- a/slsDetectorGui/forms/form_tab_advanced.ui +++ /dev/null @@ -1,2109 +0,0 @@ - - - TabAdvancedObject - - - - 0 - 0 - 775 - 351 - - - - - 0 - 0 - - - - - 0 - 0 - - - - - 1000 - 1000 - - - - Form - - - - :/icons/images/refresh.png:/icons/images/refresh.png - - - - - 5 - 3 - 761 - 343 - - - - - - - QTabWidget::North - - - 3 - - - Qt::ElideLeft - - - - Logs - - - - - 5 - 10 - 746 - 66 - - - - Calibration Logs - - - - - 25 - 20 - 345 - 31 - - - - - 42 - - - - - - 0 - 0 - - - - Energy Calibration - - - - - - - - 0 - 0 - - - - Angular Calibration - - - - - - - - - - Trimming - - - - - 5 - 10 - 495 - 66 - - - - Trimbits Plot - - - true - - - false - - - - - 230 - 15 - 259 - 44 - - - - - 17 - - - - - <nobr> -Updates plot with Trimbits from Shared Memory, not from Detector. -</nobr> - - - false - - - Refresh - - - - :/icons/images/refresh.png:/icons/images/refresh.png - - - - 24 - 16 - - - - - - - - <nobr> -Plots Trimbits from Detector. This will take time. -</nobr> - - - Get Trimbits - - - - :/icons/images/download.png:/icons/images/download.png - - - - - - - - - 25 - 20 - 211 - 31 - - - - - - - Data Graph - - - true - - - - - - - Histogram - - - - - - - - - true - - - - 5 - 85 - 746 - 226 - - - - Trimming - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - false - - - true - - - true - - - - - 25 - 25 - 696 - 208 - - - - - 12 - - - - - - 0 - 0 - - - - Trimming Method: - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 20 - 20 - - - - - - - - - 0 - 0 - - - - Exposure Time: - - - - - - - true - - - - 0 - 0 - - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - Exposure time of each frame. - #exptime# - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - false - - - 9 - - - -1.000000000000000 - - - 2000000000.000000000000000 - - - 1.000000000000000 - - - - - - - true - - - - 0 - 0 - - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - Qt::LeftToRight - - - 2 - - - - hr - - - - - min - - - - - s - - - - - ms - - - - - us - - - - - ns - - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 20 - 20 - - - - - - - - Qt::Horizontal - - - QSizePolicy::Expanding - - - - 50 - 20 - - - - - - - - - 0 - 0 - - - - <nobr> -Trimfile to which the resulting trimbits will be written. -</nobr><br><nobr> -An extension given by the modules serial number will be attached. -</nobr> - - - Output Trim File: - - - - - - - <nobr> -Trimfile to which the resulting trimbits will be written. -</nobr><br><nobr> -An extension given by the modules serial number will be attached. -</nobr> - - - - - - - - 0 - 0 - - - - <nobr> -Trimfile to which the resulting trimbits will be written. -</nobr><br><nobr> -An extension given by the modules serial number will be attached. -</nobr> - - - Browse - - - - :/icons/images/browse.png:/icons/images/browse.png - - - - - - - 0 - - - - - - - - 0 - 0 - - - - Start Trimming - - - - :/icons/images/start.png:/icons/images/start.png - - - - - - - true - - - - 0 - 0 - - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - Exposure time of each frame. - #exptime# - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - false - - - 3 - - - -1.000000000000000 - - - 10000.000000000000000 - - - 560.000000000000000 - - - - - - - - 0 - 0 - - - - Sets the Threshold DAC - - - Threshold (DACu): - - - - - - - true - - - - 0 - 0 - - - - - 0 - 0 - - - - Optimize Settings - - - - - - - - 0 - 0 - - - - Resolution (a.u.): - - - - - - - - 0 - 0 - - - - Number of measurements (not in real time) that will be acquired. - #frames# - - - - - - - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - false - - - - - - 1 - - - 9 - - - 4 - - - - - - - - 0 - 0 - - - - - 0 - 0 - - - - - Adjust to Fix Count Level - - - - - Equalize to Median - - - - - - - - - 0 - 0 - - - - Counts/ Channel: - - - - - - - - 0 - 0 - - - - Number of measurements (not in real time) that will be acquired. - #frames# - - - - - - - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - false - - - - - - 0 - - - 16000000 - - - 500 - - - - - - - - - false - - - - 518 - 10 - 233 - 66 - - - - Developer Option - - - false - - - false - - - - - 12 - 28 - 94 - 16 - - - - Set All trimbits: - - - - - - 121 - 24 - 86 - 25 - - - - -1 - - - 63 - - - - - - - Region of Interest - - - - - 10 - 50 - 736 - 246 - - - - QFrame::NoFrame - - - true - - - - - 0 - 0 - 736 - 246 - - - - - 1 - - - 15 - - - - - - - - 10 - 5 - 736 - 41 - - - - - - - - 0 - 0 - - - - - 150 - 0 - - - - Get ROI - - - - :/icons/images/download.png:/icons/images/download.png - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - 0 - 0 - - - - - 150 - 0 - - - - Set ROI - - - - :/icons/images/upload.png:/icons/images/upload.png - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - 0 - 0 - - - - - 150 - 0 - - - - Clear ROI - - - - :/icons/images/erase.png:/icons/images/erase.png - - - - - - - - - Network - - - - - 10 - 132 - 736 - 171 - - - - Receiver Parameters - - - - - 420 - 140 - 291 - 29 - - - - Setup Receiver - - - - :/icons/images/setup.png:/icons/images/setup.png - - - - - - 25 - 21 - 686 - 119 - - - - - 6 - - - - - - 0 - 0 - - - - TCP Port: - - - - - - - - 0 - 0 - - - - - 180 - 0 - - - - Sets the Receiver UDP IP -#rx_udpip# - - - none - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - 0 - 0 - - - - - 127 - 0 - - - - Sets Receiver UDP Port -#rx_udpport# - - - - - - - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - false - - - - - - 0 - - - 2000000000 - - - 0 - - - - - - - - 0 - 0 - - - - UDP IP: - - - - - - - - 0 - 0 - - - - Hostname / IP: - - - - - - - - 0 - 0 - - - - <nobr>If the receiver is online<br>#r_online#</nobr>< - - - - Offline - - - - - Online - - - - - - - - - 0 - 0 - - - - - 180 - 0 - - - - Sets the Receiver UDP MAC -#rx_udpmac# - - - none - - - - - - - - 0 - 0 - - - - - 127 - 0 - - - - Sets Receiver TCP Port -#rx_tcpport# - - - - - - - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - false - - - - - - 0 - - - 2000000000 - - - 0 - - - - - - - - 0 - 0 - - - - Online: - - - - - - - - 0 - 0 - - - - UDP Port: - - - - - - - - 0 - 0 - - - - - 180 - 0 - - - - Sets the Receiver Hostname, connects to it and gets the receiver mac address and eth. Sets some receiver parameters like file name, file dir, file index in receiver. -#rx_hostname# - - - none - - - - - - - - 0 - 0 - - - - UDP MAC: - - - - - - - - 0 - 0 - - - - ZMQ Port: - - - - - - - - 0 - 0 - - - - - 127 - 0 - - - - Sets Receiver UDP Port -#rx_udpport# - - - - - - - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - false - - - - - - 0 - - - 2000000000 - - - 0 - - - - - - - - 0 - 0 - - - - ZMQ IP: - - - - - - - - 0 - 0 - - - - - 180 - 0 - - - - Sets the Receiver UDP IP -#rx_udpip# - - - - - - - - - - - - - 35 - 10 - 686 - 123 - - - - - 6 - - - - - - 0 - 0 - - - - - 180 - 0 - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - 0 - 0 - - - - - 180 - 0 - - - - <nobr>If the detector is online<br>#online#</nobr>< - - - - Offline - - - - - Online - - - - - - - - - 0 - 0 - - - - Stop Port: - - - - - - - - 0 - 0 - - - - Control Port: - - - - - - - - 0 - 0 - - - - - 180 - 0 - - - - Sets the detector IP to send packets to receiver -#detectorip# - - - - - - - - - - - 0 - 0 - - - - - 180 - 0 - - - - Sets the detector MAC to send packets to receiver -#detectormac# - - - - - - - - - - - 0 - 0 - - - - MAC: - - - - - - - - 0 - 0 - - - - - 108 - 0 - - - - Online: - - - - - - - - 0 - 0 - - - - - 108 - 0 - - - - Detector: - - - - - - - - 0 - 0 - - - - IP: - - - - - - - - 0 - 0 - - - - - 180 - 0 - - - - - 16777215 - 16777215 - - - - Sets Control Port -#port# - - - - - - - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - false - - - - - - 0 - - - 2000000000 - - - 0 - - - - - - - - 0 - 0 - - - - - 180 - 0 - - - - Sets Stop Port -#stopport# - - - - - - - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - false - - - - - - 0 - - - 2000000000 - - - 0 - - - - - - - - 0 - 0 - - - - ZMQ Port (GUI): - - - - - - - - 0 - 0 - - - - - 180 - 0 - - - - Sets Stop Port -#stopport# - - - - - - - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - false - - - - - - 0 - - - 2000000000 - - - 0 - - - - - - - - 0 - 0 - - - - Client ZMQ IP: - - - - - - - - 0 - 0 - - - - - 180 - 0 - - - - Sets the detector IP to send packets to receiver -#detectorip# - - - - - - - - - - - - Acquisition - - - - - 14 - 13 - 367 - 110 - - - - - - - false - - - - 0 - 0 - - - - <nobr> -Exposure Time of a sub frame. Only for Eiger in 32 bit mode -</nobr><br><nobr> - #subexptime# -</nobr> - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - false - - - 9 - - - -1.000000000000000 - - - 2000000000.000000000000000 - - - 1.000000000000000 - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 10 - 20 - - - - - - - - false - - - <html><head/><body><p>Number of storage cells. For Jungfrau only. </p><p>Default: 0. </p><p>Number of Images received: #frames * #cycles * (#storagecells+1) </p><p> #storagecells#</p><p><br/></p></body></html> - - - Number of Storage cells: - - - - - - - false - - - <nobr> -Exposure Time of a sub frame. Only for Eiger in 32 bit mode -</nobr><br><nobr> - #subexptime# -</nobr> - - - Sub Frame Exposure Time: - - - - - - - false - - - - 0 - 0 - - - - <nobr> -Exposure Time of a sub frame. Only for Eiger in 32 bit mode -</nobr><br><nobr> - #subexptime# -</nobr> - - - Qt::LeftToRight - - - 2 - - - - hr - - - - - min - - - - - s - - - - - ms - - - - - us - - - - - ns - - - - - - - - false - - - - 0 - 0 - - - - <html><head/><body><p>Number of storage cells. For Jungfrau only. </p><p>Default: 0. </p><p>Number of Images received: #frames * #cycles * (#storagecells+1) </p><p> #storagecells#</p><p><br/></p></body></html> - - - - - - - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - false - - - - - - -1 - - - 15 - - - 0 - - - - - - - false - - - <nobr> -Dead time between sub frames. Only for Eiger in 32 bit mode. -</nobr><br><nobr> -Default value is 0. A value less than the required minimum is ignored. -</nobr><br><nobr> - #subdeadtime# -</nobr> - - - Sub Frame Dead Time: - - - - - - - false - - - - 0 - 0 - - - - <nobr> -Period between sub frames. Only for Eiger in 32 bit mode. -</nobr><br><nobr> -Default value is 0. A value less than the required minimum is ignored. -</nobr><br><nobr> - #subperiod# -</nobr> - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - false - - - 9 - - - -1.000000000000000 - - - 2000000000.000000000000000 - - - 1.000000000000000 - - - - - - - false - - - - 0 - 0 - - - - <nobr> -Period between sub frames. Only for Eiger in 32 bit mode. -</nobr><br><nobr> -Default value is 0. A value less than the required minimum is ignored. -</nobr><br><nobr> - #subperiod# -</nobr> - - - Qt::LeftToRight - - - 2 - - - - hr - - - - - min - - - - - s - - - - - ms - - - - - us - - - - - ns - - - - - - - - - - - tabAdvancedSettings - chkEnergyLog - chkAngularLog - boxPlot - radioDataGraph - radioHistogram - btnRefresh - btnGetTrimbits - boxTrimming - comboMethod - chkOptimize - spinResolution - spinCounts - spinExpTime - comboExpUnit - spinThreshold - dispFile - btnFile - btnStart - btnGetRoi - btnSetRoi - btnClearRoi - scrollArea - comboDetector - comboOnline - spinControlPort - dispIP - spinStopPort - dispMAC - dispRxrHostname - comboRxrOnline - spinTCPPort - dispUDPIP - spinUDPPort - dispUDPMAC - btnRxr - - - - - - diff --git a/slsDetectorGui/forms/form_tab_dataoutput.ui b/slsDetectorGui/forms/form_tab_dataoutput.ui deleted file mode 100644 index 0ebfddfe9..000000000 --- a/slsDetectorGui/forms/form_tab_dataoutput.ui +++ /dev/null @@ -1,897 +0,0 @@ - - - TabDataOutputObject - - - - 0 - 0 - 775 - 345 - - - - - 0 - 0 - - - - - 0 - 0 - - - - - 1000 - 1000 - - - - Form - - - - - 15 - 170 - 746 - 170 - - - - Options - - - - - 17 - 21 - 192 - 137 - - - - - 6 - - - - - false - - - <nobr> -Compression using Root. Available only for Gotthard in Expert Mode. -</nobr><br><nobr> - #r_compression# -</nobr> - - - Unused - - - - - - - false - - - Angular Conversion - - - - - - - Discard Bad Channels - - - - - - - false - - - <nobr> -Compression using Root. Available only for Gotthard in Expert Mode. -</nobr><br><nobr> - #r_compression# -</nobr> - - - 10GbE - - - - - - - - - 255 - 21 - 476 - 76 - - - - - 6 - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 10 - 20 - - - - - - - - false - - - Rate: - - - - - - - false - - - - 0 - 0 - - - - Flat field corrections. - #flatfield# filename - - - Browse - - - - :/icons/images/browse.png:/icons/images/browse.png - - - - - - - false - - - Qt::ClickFocus - - - Flat field corrections. - #flatfield# filename - - - - - - - Flat field corrections. - #flatfield# filename - - - Flat Field File: - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 10 - 20 - - - - - - - - false - - - - 0 - 0 - - - - - - - - - 2 - 2 - 2 - - - - - - - - - 0 - 0 - 0 - - - - - - - - - 119 - 119 - 119 - - - - - - - - <nobr> -Directory where one saves the data. -</nobr><br> - #outdir# -<br> - - - - Dead Time: - - - - - - - - 0 - 0 - - - - ns - - - -1 - - - 200000000 - - - - - - - false - - - - 0 - 0 - - - - - 16777215 - 30 - - - - <nobr> -Directory where one saves the data. -</nobr><br> - #outdir# -<br> - - - - Default - - - - :/icons/images/calculate.png:/icons/images/calculate.png - - - - - - - - - 230 - 21 - 20 - 134 - - - - QFrame::Raised - - - Qt::Vertical - - - - - - 244 - 92 - 491 - 72 - - - - - - 11 - 4 - 475 - 62 - - - - - - - - 200 - 16777215 - - - - - Continous - - - - - Store in RAM - - - - - - - - - 105 - 16777215 - - - - Clock Divider: - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 10 - 20 - - - - - - - - - 200 - 16777215 - - - - - Full Speed - - - - - Half Speed - - - - - Quarter Speed - - - - - Super Slow Speed - - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 10 - 20 - - - - - - - - - 105 - 16777215 - - - - Flags: - - - - - - - - Parallel - - - - - Non Parallel - - - - - Safe - - - - - - - - - - - - 20 - 40 - 735 - 100 - - - - File - - - - - 12 - 20 - 714 - 68 - - - - - 4 - - - - - - 0 - 0 - - - - <nobr> -Directory where one saves the data. -</nobr><br> - #outdir# -<br> -Disabled if a receiver is utilized in acquisition. -<br> - - - - Browse - - - - :/icons/images/browse.png:/icons/images/browse.png - - - - - - - - 0 - 0 - - - - - 105 - 0 - - - - <html><head/><body><p>File Format<br/>#fileformat# <br/></p></body></html> - - - - Binary - - - - - ASCII - - - - - HDF5 - - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 10 - 20 - - - - - - - - - 0 - 0 - - - - - 105 - 0 - - - - - - - - - 0 - 0 - - - - - 70 - 16777215 - - - - - - - - - 2 - 2 - 2 - - - - - - - - - 0 - 0 - 0 - - - - - - - - - 119 - 119 - 119 - - - - - - - - <nobr> -Directory where one saves the data. -</nobr><br> - #outdir# -<br> - - - - Path: - - - - - - - - 0 - 0 - - - - - 70 - 16777215 - - - - - - - - - 2 - 2 - 2 - - - - - - - - - 0 - 0 - 0 - - - - - - - - - 119 - 119 - 119 - - - - - - - - <html><head/><body><p>File Format<br/>#fileformat# <br/></p></body></html> - - - Format: - - - - - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - Overwrite Enable - #overwrite# - - - Overwrite - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 10 - 20 - - - - - - - - - 0 - 0 - - - - - 75 - 16777215 - - - - - - - - - 2 - 2 - 2 - - - - - - - - - 0 - 0 - 0 - - - - - - - - - 119 - 119 - 119 - - - - - - - - <html><head/><body><p>Name of file. Can be modified in Measurement tab.<br/>#fname# <br/></p></body></html> - - - Name Prefix: - - - - - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - Qt::NoFocus - - - <html><head/><body><p>Name of file. Can be modified in Measurement tab.<br/>#fname# <br/></p></body></html> - - - false - - - QLineEdit::Normal - - - true - - - - - - - Qt::StrongFocus - - - <nobr> -Directory where one saves the data. -</nobr><br> - #outdir# -<br> - - - - - - - - - - chkFlatField - dispFlatField - btnFlatField - chkRate - - - - - - diff --git a/slsDetectorGui/forms/form_tab_debugging.ui b/slsDetectorGui/forms/form_tab_debugging.ui deleted file mode 100644 index e8ebcd632..000000000 --- a/slsDetectorGui/forms/form_tab_debugging.ui +++ /dev/null @@ -1,471 +0,0 @@ - - - TabDebuggingObject - - - - 0 - 0 - 775 - 345 - - - - - 0 - 0 - - - - - 0 - 0 - - - - - 1000 - 1000 - - - - Form - - - - - 45 - 75 - 686 - 231 - - - - Qt::NoFocus - - - Tests - - - - - 15 - 110 - 141 - 51 - - - - - - - Qt::NoFocus - - - Readout Firmware - - - - - - - Qt::NoFocus - - - Readout Software - - - - - - - - - 15 - 185 - 656 - 36 - - - - - - - - 0 - 0 - - - - Run Test - - - - :/icons/images/start.png:/icons/images/start.png - - - - - - - - - 415 - 30 - 256 - 31 - - - - - - - - 0 - 0 - - - - - 0 - 0 - - - - - 100 - 16777215 - - - - Module: - - - - - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - true - - - - All Modules - - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 10 - 20 - - - - - - - - - - 280 - 110 - 141 - 51 - - - - - - - Qt::NoFocus - - - Readout Bus - - - - - - - Qt::NoFocus - - - Readout Memory - - - - - - - - - 530 - 110 - 141 - 26 - - - - - - - Qt::NoFocus - - - Chip - - - - - - - - - 15 - 30 - 276 - 31 - - - - - - - - 0 - 0 - - - - - 0 - 0 - - - - - 150 - 16777215 - - - - Readout: - - - - - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 10 - 20 - - - - - - - - - - 15 - 60 - 276 - 31 - - - - - - - - 0 - 0 - - - - - 150 - 16777215 - - - - Status: - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 10 - 20 - - - - - - - - - 0 - 0 - - - - IDLE - - - - - - - - - 530 - 135 - 141 - 26 - - - - - - - Qt::NoFocus - - - Module Firmware - - - - - - - - - 5 - 95 - 676 - 16 - - - - Qt::Horizontal - - - - - - 5 - 165 - 676 - 16 - - - - Qt::Horizontal - - - - - - - 45 - 25 - 686 - 31 - - - - - - - - 0 - 0 - - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - Get ID Information - - - - :/icons/images/download.png:/icons/images/download.png - - - - - - - - btnGetInfo - comboDetector - comboModule - btnTest - - - - - - diff --git a/slsDetectorGui/forms/form_tab_measurement.ui b/slsDetectorGui/forms/form_tab_measurement.ui deleted file mode 100644 index f8a6853cf..000000000 --- a/slsDetectorGui/forms/form_tab_measurement.ui +++ /dev/null @@ -1,1084 +0,0 @@ - - - TabMeasurementObject - - - - 0 - 0 - 775 - 345 - - - - - 0 - 0 - - - - - 0 - 0 - - - - - 1000 - 345 - - - - Form - - - - - 30 - 153 - 319 - 116 - - - - - 0 - 0 - - - - Progress Monitor - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - - - 10 - 75 - 300 - 23 - - - - 24 - - - - - - 10 - 25 - 91 - 16 - - - - Current Frame: - - - - - - 101 - 25 - 101 - 16 - - - - 0 - - - - - - 150 - 45 - 76 - 16 - - - - - 0 - 0 - - - - - 60 - 0 - - - - 0 - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - - - - 10 - 45 - 136 - 16 - - - - Current Measurement: - - - - - - - 390 - 8 - 362 - 342 - - - - QFrame::NoFrame - - - QFrame::Plain - - - - - 0 - 10 - 357 - 321 - - - - - - - false - - - Number of Triggers to be expected. - #cycles# - - - Number of Triggers: - - - - - - - false - - - - 0 - 0 - - - - Number of Triggers to be expected. - #cycles# - - - - - - - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - false - - - - - - -1 - - - 2000000000 - - - 1 - - - - - - - false - - - The Delay between Trigger Edge and Start of Exposure ( or Readout). -#delay# - - - Delay After Trigger: - - - - - - - false - - - - 0 - 0 - - - - The Delay between Trigger Edge and Start of Exposure ( or Readout). -#delay# - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - false - - - 9 - - - -1.000000000000000 - - - 2000000000.000000000000000 - - - 0.000000000000000 - - - - - - - false - - - - 0 - 0 - - - - The Delay between Trigger Edge and Start of Exposure ( or Readout). -#delay# - - - Qt::LeftToRight - - - 2 - - - - hr - - - - - min - - - - - s - - - - - ms - - - - - us - - - - - ns - - - - - - - - false - - - - 0 - 0 - - - - Number of Gate Signals per Frame. - #gates# - - - Number of Gates: - - - - - - - false - - - - 0 - 0 - - - - Number of Gate Signals per Frame. - #gates# - - - - - - - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - false - - - - - - -1 - - - 2000000000 - - - 1 - - - - - - - false - - - - 0 - 0 - - - - <nobr> -The data are accumulated over several (frames) pump cycles. -</nobr> -<br> -<nobr> -Enabled only in <b>Expert Mode</b> and if<b> Number of Frames</b> > 1. -</nobr> -<br> -<nobr>Setting <b>Number of Probes</b> will reset <b>Number of Triggers</b> to 1. -</nobr> -<br> -Maximum value is 3. <br> -#probes# - - - - Number of Probes: - - - - - - - false - - - - 0 - 0 - - - - <nobr> -The data are accumulated over several (frames) pump cycles. -</nobr> -<br> -<nobr> -Enabled only in <b>Expert Mode</b> and if<b> Number of Frames</b> > 1. -</nobr> -<br> -<nobr>Setting <b>Number of Probes</b> will reset <b>Number of Triggers</b> to 1. -</nobr> -<br> -Maximum value is 3. <br> -#probes# - - - - - - - - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - false - - - - - - -1 - - - 3 - - - 1 - - - - - - - - 0 - 0 - - - - Timing Mode of the detector. - #timing# - - - - None - - - - - Auto - - - - - Trigger Exposure Series - - - - - Trigger Readout - - - - - Gated with Fixed Number - - - - - Gated with Start Trigger - - - - - Burst Trigger - - - - - - - - false - - - Number of Frames: - - - - - - - false - - - - 0 - 0 - - - - Number of measurements (not in real time) that will be acquired. - #frames# - - - - - - - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - false - - - - - - -1 - - - 2000000000 - - - 1 - - - - - - - true - - - <nobr> -Exposure Time of a frame. -</nobr><br><nobr> - #exptime# -</nobr> - - - Exposure Time: - - - - - - - true - - - - 0 - 0 - - - - <nobr> -Exposure Time of a frame. -</nobr><br><nobr> - #exptime# -</nobr> - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - false - - - 9 - - - -1.000000000000000 - - - 2000000000.000000000000000 - - - 1.000000000000000 - - - - - - - true - - - - 0 - 0 - - - - <nobr> -Exposure Time of a frame. -</nobr><br><nobr> - #exptime# -</nobr> - - - Qt::LeftToRight - - - 2 - - - - hr - - - - - min - - - - - s - - - - - ms - - - - - us - - - - - ns - - - - - - - - false - - - <nobr> -Frame period between exposures. -</nobr><br><nobr> - #period# -</nobr> - - - Acquisition Period: - - - - - - - false - - - - 0 - 0 - - - - <nobr> -Frame period between exposures. -</nobr><br><nobr> - #period# -</nobr> - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - false - - - 9 - - - -1.000000000000000 - - - 2000000000.000000000000000 - - - 0.000000000000000 - - - - - - - false - - - - 0 - 0 - - - - <nobr> -Frame period between exposures. -</nobr><br><nobr> - #period# -</nobr> - - - Qt::LeftToRight - - - 2 - - - - hr - - - - - min - - - - - s - - - - - ms - - - - - us - - - - - ns - - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 10 - 20 - - - - - - - - Timing Mode: - - - - - - - - - - 20 - 5 - 336 - 159 - - - - QFrame::NoFrame - - - QFrame::Plain - - - - - 10 - 13 - 321 - 130 - - - - - 6 - - - - - Number of Measurements: - - - - - - - - 0 - 0 - - - - Number of measurements (not in real time) that will be acquired. - #frames# - - - - - - - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - false - - - - - - 1 - - - 2000000000 - - - 1 - - - - - - - - 0 - 0 - - - - Root of the file name - please check that the output directory is correctly set and select the file name format. - #fname# - - - - - - - - - - Run Index: - - - - - - - - 0 - 0 - - - - Run index (automatically incremented) - #index# - - - - - - - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - false - - - - - - -1 - - - 2000000000 - - - 0 - - - - - - - <nobr>Sets output file name prefix</nobr><br> -<nobr>Check the box to enable write to file. </nobr> - - - File Name: - - - true - - - - - - - - - - 30 - 298 - 318 - 31 - - - - - - - - 0 - 0 - - - - Qt::NoFocus - - - Starts Acquisition - - - Start - - - - :/icons/images/start.png:/icons/images/start.png - - - Shift+Space - - - false - - - false - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 10 - 20 - - - - - - - - true - - - - 0 - 0 - - - - - 70 - 16777215 - - - - Qt::NoFocus - - - Stops Acquisition - - - Stop - - - - :/icons/images/stop.png:/icons/images/stop.png - - - false - - - false - - - - - - - - spinNumMeasurements - chkFile - dispFileName - spinIndex - comboTimingMode - spinNumFrames - spinExpTime - comboExpUnit - spinPeriod - comboPeriodUnit - spinNumTriggers - spinDelay - comboDelayUnit - spinNumGates - spinNumProbes - - - - - - diff --git a/slsDetectorGui/forms/form_tab_messages.ui b/slsDetectorGui/forms/form_tab_messages.ui deleted file mode 100644 index 1f75475e5..000000000 --- a/slsDetectorGui/forms/form_tab_messages.ui +++ /dev/null @@ -1,82 +0,0 @@ - - - TabMessagesObject - - - - 0 - 0 - 775 - 345 - - - - - 0 - 0 - - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - Form - - - - - - - - TextLabel - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 20 - 20 - - - - - - - - - - - TextLabel - - - - - - - - - - - - - - - - diff --git a/slsDetectorGui/forms/form_tab_plot.ui b/slsDetectorGui/forms/form_tab_plot.ui deleted file mode 100644 index e16c6ae46..000000000 --- a/slsDetectorGui/forms/form_tab_plot.ui +++ /dev/null @@ -1,3028 +0,0 @@ - - - TabPlotObject - - - - 0 - 0 - 775 - 345 - - - - - 0 - 0 - - - - - 0 - 0 - - - - - 1000 - 1000 - - - - - - - - - 0 - 0 - 30 - - - - - - - - - 0 - 0 - 30 - - - - - - - - - 0 - 0 - 30 - - - - - - - - Form - - - - true - - - - 15 - 70 - 371 - 51 - - - - 2D Plot Options 1 - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - false - - - - - 5 - 15 - 361 - 31 - - - - 4 - - - - - - 20 - 5 - 336 - 26 - - - - - - - - 0 - 0 - - - - Interpolate - - - - - - - - 0 - 0 - - - - Contour - - - - - - - - 0 - 0 - - - - Log Scale (Z) - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 15 - 20 - - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 20 - 20 - - - - - - - - - - - - 25 - 5 - 100 - 26 - - - - - 0 - - - - - true - - - - 0 - 0 - - - - Accumulate - - - - - - - - - 175 - 3 - 156 - 26 - - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - - - - - - 20 - 20 - 20 - - - - - - - - - 20 - 20 - 20 - - - - - - - - - 20 - 20 - 20 - - - - - - - - Qt::NoFocus - - - Reset Accumulation - - - - :/icons/images/calculate.png:/icons/images/calculate.png - - - - 16 - 16 - - - - - - - - - 20 - 5 - 81 - 26 - - - - - 0 - - - - - true - - - - 0 - 0 - - - - Pedestal - - - - - - - - - 160 - 3 - 171 - 26 - - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - - - - - - 20 - 20 - 20 - - - - - - - - - 20 - 20 - 20 - - - - - - - - - 20 - 20 - 20 - - - - - - - - Qt::NoFocus - - - Recalculate Pedestal - - - - :/icons/images/calculate.png:/icons/images/calculate.png - - - - 16 - 16 - - - - - - - - - 25 - 5 - 311 - 26 - - - - - 1 - - - - - - 0 - 0 - - - - Binary - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 20 - 20 - - - - - - - - false - - - - 0 - 0 - - - - from - - - - - - - false - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - -16777215 - - - 16777215 - - - 0 - - - - - - - false - - - - 0 - 0 - - - - to - - - - - - - false - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - -16777215 - - - 16777215 - - - 0 - - - - - - - - - - - 25 - 5 - 335 - 26 - - - - - 0 - - - - - true - - - - 0 - 0 - - - - <nobr> -Displays minimum, maximum and sum of values for each plot. -<nobr> - - - Display Statistics - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 10 - 10 - - - - - - - - false - - - - 0 - 0 - - - - <nobr> -Displays minimum, maximum and sum of values for each plot. -<nobr> - - - Gain Plot - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 10 - 10 - - - - - - - - false - - - - 0 - 0 - - - - <nobr> -Displays minimum, maximum and sum of values for each plot. -<nobr> - - - Gap Pixels - - - - - - - - - true - - - - - 25 - 5 - 311 - 26 - - - - - 1 - - - - - true - - - - 0 - 0 - - - - from - - - - - - - true - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - -16777215 - - - 16777215 - - - 0 - - - - - - - true - - - - 0 - 0 - - - - to - - - - - - - true - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - -16777215 - - - 16777215 - - - 10000 - - - - - - - true - - - - 0 - 0 - - - - size - - - - - - - true - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - -16777215 - - - 16777215 - - - 1000 - - - - - - - - - - - - 15 - 70 - 371 - 51 - - - - 1D Plot Options 1 - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - false - - - - - 4 - 15 - 366 - 31 - - - - 5 - - - - - - 25 - 5 - 108 - 26 - - - - - - - - 0 - 0 - - - - Superimpose - - - false - - - - - - - - - 210 - 5 - 128 - 26 - - - - - 1 - - - - - false - - - - 0 - 0 - - - - Persistency: - - - - - - - false - - - - 0 - 0 - - - - - 40 - 16777215 - - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - 1 - - - 10 - - - 1 - - - - - - - - - - - 25 - 5 - 321 - 26 - - - - - - - - 0 - 0 - - - - Log Scale (Y) - - - - - - - Qt::Horizontal - - - QSizePolicy::Expanding - - - - 95 - 20 - - - - - - - - true - - - - 0 - 0 - - - - Points - - - - - - - true - - - - 0 - 0 - - - - Lines - - - true - - - - - - - - - - - 175 - 3 - 161 - 26 - - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - - - - - - 20 - 20 - 20 - - - - - - - - - 20 - 20 - 20 - - - - - - - - - 20 - 20 - 20 - - - - - - - - Qt::NoFocus - - - Reset Accumulation - - - - :/icons/images/calculate.png:/icons/images/calculate.png - - - - 16 - 16 - - - - - - - 25 - 5 - 100 - 26 - - - - - 0 - - - - - true - - - - 0 - 0 - - - - Accumulate - - - - - - - - - - - 25 - 5 - 81 - 26 - - - - - 0 - - - - - true - - - - 0 - 0 - - - - Pedestal - - - - - - - - - 165 - 3 - 171 - 26 - - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - - - - - - 20 - 20 - 20 - - - - - - - - - 20 - 20 - 20 - - - - - - - - - 20 - 20 - 20 - - - - - - - - Qt::NoFocus - - - Recalculate Pedestal - - - - :/icons/images/calculate.png:/icons/images/calculate.png - - - - 16 - 16 - - - - - - - <nobr> -All values between <b>from</b> and <b>to</b> will be reset to 1, others to 0. -</nobr> - - - - - 25 - 5 - 311 - 26 - - - - - 1 - - - - - - 0 - 0 - - - - <nobr> -All values between <b>from</b> and <b>to</b> will be reset to 1, others to 0. -</nobr> - - - Binary - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 20 - 20 - - - - - - - - false - - - - 0 - 0 - - - - from - - - - - - - false - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - -16777215 - - - 16777215 - - - 0 - - - - - - - false - - - - 0 - 0 - - - - to - - - - - - - false - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - -16777215 - - - 16777215 - - - 0 - - - - - - - - - - - 25 - 5 - 132 - 26 - - - - - 0 - - - - - true - - - - 0 - 0 - - - - <nobr> -Displays minimum, maximum and sum of values for each plot. -<nobr> - - - Display Statistics - - - - - - - - - true - - - - - 25 - 5 - 311 - 26 - - - - - 1 - - - - - true - - - - 0 - 0 - - - - from - - - - - - - true - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - 0 - - - 16777215 - - - 0 - - - - - - - true - - - - 0 - 0 - - - - to - - - - - - - true - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - -16777215 - - - 16777215 - - - 10000 - - - - - - - true - - - - 0 - 0 - - - - size - - - - - - - true - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - -16777215 - - - 16777215 - - - 1000 - - - - - - - - - - - - 410 - 70 - 351 - 51 - - - - Save Image - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - false - - - - - 10 - 20 - 233 - 26 - - - - - 0 - - - - - true - - - - 0 - 0 - - - - Save All with Automatic File Name - - - - - - - - - 264 - 19 - 76 - 25 - - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - - - - - - 20 - 20 - 20 - - - - - - - - - 20 - 20 - 20 - - - - - - - - - 20 - 20 - 20 - - - - - - - - Qt::NoFocus - - - Save - - - - :/icons/images/save.png:/icons/images/save.png - - - - 16 - 16 - - - - - - - - 410 - 5 - 351 - 51 - - - - 2D Scan - Y Axis Values - - - true - - - false - - - - - 10 - 20 - 357 - 26 - - - - - 0 - - - - - - 0 - 0 - - - - <nobr>Enabled only when there is a Scan Level 0</nobr> - - - Level 0 - - - true - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 7 - 10 - - - - - - - - - 0 - 0 - - - - <nobr>Enabled only when there is a Scan Level 1</nobr> - - - Level 1 - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 7 - 10 - - - - - - - - - 0 - 0 - - - - <nobr>Enabled only when there is a Scan Level 0 or a Scan Level 1, not both</nobr> - - - Frame Index - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 7 - 10 - - - - - - - - - 0 - 0 - - - - <nobr>Disabled only for Angle Plots, Moench and Eiger Detectors</nobr> - - - All Frames - - - false - - - - - - - - - - 15 - 200 - 746 - 141 - - - - Plot Axis - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - false - - - - - 10 - 15 - 726 - 121 - - - - - QLayout::SetNoConstraint - - - 0 - - - - - Title Prefix: - - - - - - - true - - - - 0 - 0 - - - - - 50 - 0 - - - - - - - - - 0 - 0 - - - - Z Max: - - - - - - - - 0 - 0 - - - - - 50 - 0 - - - - - - - - - 0 - 0 - - - - Y Max: - - - - - - - - 0 - 0 - - - - X Max: - - - - - - - - 0 - 0 - - - - - 50 - 0 - - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 40 - 20 - - - - - - - - - 0 - 0 - - - - Z Min: - - - - - - - - 0 - 0 - - - - - 50 - 0 - - - - - - - - - 0 - 0 - - - - X Min: - - - - - - - - 0 - 0 - - - - - 50 - 0 - - - - Qt::ImhDigitsOnly - - - - - - - - 0 - 0 - - - - Y Min: - - - - - - - - 0 - 0 - - - - - 50 - 0 - - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 40 - 20 - - - - - - - - - 0 - 0 - - - - X Axis: - - - - - - - - 0 - 0 - - - - - 250 - 0 - - - - Qt::ImhDigitsOnly - - - - - - - - 0 - 0 - - - - Y Axis: - - - - - - - - 0 - 0 - - - - - 20 - 0 - - - - Qt::ImhDigitsOnly - - - - - - - - 0 - 0 - - - - Z Axis: - - - - - - - - 0 - 0 - - - - - 20 - 0 - - - - Qt::ImhDigitsOnly - - - - - - - - 0 - 0 - - - - - 250 - 0 - - - - QLineEdit::Normal - - - false - - - - - - - - 0 - 0 - - - - Keep Aspect Ratio - - - - - - - - - true - - - - 15 - 5 - 371 - 51 - - - - Plot Arguments - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - false - - - - - 10 - 20 - 355 - 26 - - - - - - - - 0 - 0 - - - - No Plot - - - - - - - - 0 - 0 - - - - Data Graph - - - true - - - - - - - true - - - - 0 - 0 - - - - Histogram - - - - - - - Qt::Horizontal - - - QSizePolicy::Preferred - - - - 40 - 10 - - - - - - - - Qt::Horizontal - - - QSizePolicy::Preferred - - - - 40 - 10 - - - - - - - - - - - 15 - 135 - 371 - 49 - - - - <nobr> -Interval between plots has 2 modes. A condition to be satisfied, in order to avoid losing images: -</nobr><br><br><nobr> -<b>Time Interval</b>: (Acquisition Period) * (nth Image) >= 250ms. -</nobr><br><nobr> -<b>Every nth Image</b>: minimum of 250ms. -</nobr> - - - Interval between Plots - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - false - - - - - 10 - 16 - 351 - 26 - - - - - 0 - - - - - - 0 - 0 - - - - - 150 - 0 - - - - - 16777215 - 16777215 - - - - - - - - - 11 - 11 - 11 - - - - - - - 20 - 20 - 20 - - - - - - - - - 11 - 11 - 11 - - - - - - - 20 - 20 - 20 - - - - - - - - - 119 - 119 - 119 - - - - - - - 20 - 20 - 20 - - - - - - - - 0 - - - - Time Interval - - - - - Every nth Image - - - - - - - - Qt::Horizontal - - - QSizePolicy::Preferred - - - - 80 - 20 - - - - - - - - - 0 - 0 - - - - - 140 - 21 - - - - - - - - - - true - - - - 410 - 135 - 351 - 51 - - - - Snapshot - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - false - - - - - 10 - 12 - 365 - 36 - - - - - - - - 0 - 0 - - - - - - - - - 20 - 20 - 20 - - - - - - - - - 20 - 20 - 20 - - - - - - - - - 20 - 20 - 20 - - - - - - - - Qt::NoFocus - - - Create - - - - :/icons/images/new.png:/icons/images/new.png - - - false - - - - - - - - 0 - 0 - - - - - - - - - 20 - 20 - 20 - - - - - - - - - 20 - 20 - 20 - - - - - - - - - 20 - 20 - 20 - - - - - - - - Qt::NoFocus - - - Close All - - - - :/icons/images/close.png:/icons/images/close.png - - - false - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 20 - 20 - - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 20 - 20 - - - - - - - - true - - - - 0 - 0 - - - - - - - - - 20 - 20 - 20 - - - - - - - - - 20 - 20 - 20 - - - - - - - - - 20 - 20 - 20 - - - - - - - - Qt::NoFocus - - - Save All - - - - :/icons/images/saveAll.png:/icons/images/saveAll.png - - - false - - - - - - - - - - 362 - 95 - 16 - 16 - - - - - 0 - 0 - - - - Qt::NoFocus - - - - - - - :/icons/images/rightArrow.png:/icons/images/rightArrow.png - - - - 16 - 16 - - - - true - - - - - - 23 - 94 - 16 - 16 - - - - - 0 - 0 - - - - Qt::NoFocus - - - - - - - :/icons/images/leftArrow.png:/icons/images/leftArrow.png - - - - 16 - 16 - - - - true - - - - - - 410 - 5 - 351 - 51 - - - - Histogram - X Axis Values - - - false - - - false - - - - - 10 - 20 - 331 - 26 - - - - - 0 - - - - - - 0 - 0 - - - - <nobr>Enabled only when there is a Scan Level 0</nobr> - - - Intensity - - - true - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 7 - 10 - - - - - - - - - 0 - 0 - - - - <nobr>Enabled only when there is a Scan Level 1</nobr> - - - Level 0 - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 7 - 10 - - - - - - - - - 0 - 0 - - - - <nobr>Enabled only when there is a Scan Level 0 or a Scan Level 1, not both</nobr> - - - Level 1 - - - - - - - box1D - box2D - boxSave - boxScan - boxPlotAxis - groupBox_3 - boxFrequency - boxSnapshot - btnRight - btnLeft - boxHistogram - - - radioNoPlot - radioHistogram - radioDataGraph - boxScan - radioLevel0 - radioLevel1 - radioFileIndex - radioAllFrames - chkInterpolate - chkContour - chkLogz - chkSaveAll - comboFrequency - chkTitle - dispTitle - chkXAxis - dispXAxis - chkXMin - dispXMin - chkXMax - dispXMax - chkYAxis - dispYAxis - chkYMin - dispYMin - chkYMax - dispYMax - chkZAxis - dispZAxis - chkZMin - dispZMin - chkZMax - dispZMax - spinPersistency - chk1DLog - chkPoints - chkLines - chkSuperimpose - - - - - - diff --git a/slsDetectorGui/forms/form_tab_settings.ui b/slsDetectorGui/forms/form_tab_settings.ui deleted file mode 100644 index 7c9f8f3ed..000000000 --- a/slsDetectorGui/forms/form_tab_settings.ui +++ /dev/null @@ -1,248 +0,0 @@ - - - TabSettingsObject - - - - 0 - 0 - 775 - 345 - - - - - 0 - 0 - - - - - 0 - 0 - - - - - 1000 - 1000 - - - - Form - - - - - 30 - 20 - 316 - 171 - - - - - - - Settings: - - - - - - - - 0 - 0 - - - - Settings of the detector. - #settings# - - - - Standard - - - - - Fast - - - - - High Gain - - - - - Dynamic Gain - - - - - Low Gain - - - - - Medium Gain - - - - - Very High Gain - - - - - Low Noise - - - - - Dynamic HG0 - - - - - Fix Gain 1 - - - - - Fix Gain 2 - - - - - Force Switch G1 - - - - - Force Switch G2 - - - - - Very Low Gain - - - - - Undefined - - - - - Uninitialized - - - - - - - - false - - - eV - - - -100000 - - - 100000 - - - 100 - - - -1 - - - - - - - Number of Modules: - - - - - - - Dynamic Range: - - - - - - - - 1.67772e+07 - - - - - 65535 - - - - - 255 - - - - - 7 - - - - - - - - 1 - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 20 - 20 - - - - - - - - Threshold: - - - - - - - - comboSettings - spinThreshold - spinNumModules - comboDynamicRange - - - - - - diff --git a/slsDetectorGui/gitInfo.txt b/slsDetectorGui/gitInfo.txt deleted file mode 100644 index cbfb0a084..000000000 --- a/slsDetectorGui/gitInfo.txt +++ /dev/null @@ -1,9 +0,0 @@ -Path: slsDetectorsPackage/slsDetectorGui -URL: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git -Repository Root: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git -Repsitory UUID: e998226bce91a0d82ca0bb38c202d404357cf1ff -Revision: 525 -Branch: gh-pages -Last Changed Author: Dhanya_Thattil -Last Changed Rev: 4092 -Last Changed Date: 2019-04-08 11:25:39.000000002 +0200 ./src/qTabSettings.cpp diff --git a/slsDetectorGui/images/add.png b/slsDetectorGui/images/add.png deleted file mode 100644 index 41058cb95..000000000 Binary files a/slsDetectorGui/images/add.png and /dev/null differ diff --git a/slsDetectorGui/images/browse.png b/slsDetectorGui/images/browse.png deleted file mode 100644 index e9404d3c7..000000000 Binary files a/slsDetectorGui/images/browse.png and /dev/null differ diff --git a/slsDetectorGui/images/calculate.png b/slsDetectorGui/images/calculate.png deleted file mode 100644 index 49ac1f4b1..000000000 Binary files a/slsDetectorGui/images/calculate.png and /dev/null differ diff --git a/slsDetectorGui/images/close.png b/slsDetectorGui/images/close.png deleted file mode 100644 index 7173b4e90..000000000 Binary files a/slsDetectorGui/images/close.png and /dev/null differ diff --git a/slsDetectorGui/images/download.png b/slsDetectorGui/images/download.png deleted file mode 100644 index 5962012d8..000000000 Binary files a/slsDetectorGui/images/download.png and /dev/null differ diff --git a/slsDetectorGui/images/erase.png b/slsDetectorGui/images/erase.png deleted file mode 100644 index 4c70f0847..000000000 Binary files a/slsDetectorGui/images/erase.png and /dev/null differ diff --git a/slsDetectorGui/images/leftArrow.png b/slsDetectorGui/images/leftArrow.png deleted file mode 100644 index 34165b715..000000000 Binary files a/slsDetectorGui/images/leftArrow.png and /dev/null differ diff --git a/slsDetectorGui/images/mountain.png b/slsDetectorGui/images/mountain.png deleted file mode 100644 index 3962d0fbc..000000000 Binary files a/slsDetectorGui/images/mountain.png and /dev/null differ diff --git a/slsDetectorGui/images/new.png b/slsDetectorGui/images/new.png deleted file mode 100644 index 7ef7b0b08..000000000 Binary files a/slsDetectorGui/images/new.png and /dev/null differ diff --git a/slsDetectorGui/images/refresh.png b/slsDetectorGui/images/refresh.png deleted file mode 100644 index 822f5bfc4..000000000 Binary files a/slsDetectorGui/images/refresh.png and /dev/null differ diff --git a/slsDetectorGui/images/refresher.png b/slsDetectorGui/images/refresher.png deleted file mode 100644 index df73f0121..000000000 Binary files a/slsDetectorGui/images/refresher.png and /dev/null differ diff --git a/slsDetectorGui/images/remove.png b/slsDetectorGui/images/remove.png deleted file mode 100644 index a3f5d74de..000000000 Binary files a/slsDetectorGui/images/remove.png and /dev/null differ diff --git a/slsDetectorGui/images/rightArrow.png b/slsDetectorGui/images/rightArrow.png deleted file mode 100644 index 74ac7f795..000000000 Binary files a/slsDetectorGui/images/rightArrow.png and /dev/null differ diff --git a/slsDetectorGui/images/save.png b/slsDetectorGui/images/save.png deleted file mode 100644 index ff544b86d..000000000 Binary files a/slsDetectorGui/images/save.png and /dev/null differ diff --git a/slsDetectorGui/images/saveAll.png b/slsDetectorGui/images/saveAll.png deleted file mode 100644 index 04bba11bc..000000000 Binary files a/slsDetectorGui/images/saveAll.png and /dev/null differ diff --git a/slsDetectorGui/images/setup.png b/slsDetectorGui/images/setup.png deleted file mode 100644 index f0323e56d..000000000 Binary files a/slsDetectorGui/images/setup.png and /dev/null differ diff --git a/slsDetectorGui/images/start.png b/slsDetectorGui/images/start.png deleted file mode 100644 index afe837e75..000000000 Binary files a/slsDetectorGui/images/start.png and /dev/null differ diff --git a/slsDetectorGui/images/stop.png b/slsDetectorGui/images/stop.png deleted file mode 100644 index 316926dee..000000000 Binary files a/slsDetectorGui/images/stop.png and /dev/null differ diff --git a/slsDetectorGui/images/upload.png b/slsDetectorGui/images/upload.png deleted file mode 100644 index d493327db..000000000 Binary files a/slsDetectorGui/images/upload.png and /dev/null differ diff --git a/slsDetectorGui/include/gitInfoGui.h b/slsDetectorGui/include/gitInfoGui.h deleted file mode 100644 index cb066ae47..000000000 --- a/slsDetectorGui/include/gitInfoGui.h +++ /dev/null @@ -1,6 +0,0 @@ -#define GITURL "git@github.com:slsdetectorgroup/slsDetectorPackage.git" -#define GITREPUUID "e998226bce91a0d82ca0bb38c202d404357cf1ff" -#define GITAUTH "Dhanya_Thattil" -#define GITREV 0x4092 -#define GITDATE 0x20190408 -#define GITBRANCH "gh-pages" diff --git a/slsDetectorGui/include/gitInfoGuiTmp.h b/slsDetectorGui/include/gitInfoGuiTmp.h deleted file mode 100644 index dfd9bb246..000000000 --- a/slsDetectorGui/include/gitInfoGuiTmp.h +++ /dev/null @@ -1,6 +0,0 @@ -#define GITURL "" -#define GITREPUUID "" -#define GITAUTH "" -#define GITREV "" -#define GITDATE "" -#define GITBRANCH "" diff --git a/slsDetectorGui/include/icons.qrc b/slsDetectorGui/include/icons.qrc deleted file mode 100644 index 26f0b5da7..000000000 --- a/slsDetectorGui/include/icons.qrc +++ /dev/null @@ -1,22 +0,0 @@ - - - ../images/mountain.png - ../images/refresh.png - ../images/save.png - ../images/saveAll.png - ../images/close.png - ../images/add.png - ../images/new.png - ../images/download.png - ../images/browse.png - ../images/start.png - ../images/erase.png - ../images/remove.png - ../images/stop.png - ../images/leftArrow.png - ../images/rightArrow.png - ../images/upload.png - ../images/setup.png - ../images/calculate.png - - diff --git a/slsDetectorGui/include/qActionsWidget.h b/slsDetectorGui/include/qActionsWidget.h deleted file mode 100644 index 2e024c8a1..000000000 --- a/slsDetectorGui/include/qActionsWidget.h +++ /dev/null @@ -1,85 +0,0 @@ -/* - * qActionsWidget.h - * - * Created on: May 10, 2012 - * Author: l_maliakal_d - */ - -#ifndef QACTIONSWIDGET_H_ -#define QACTIONSWIDGET_H_ - -#include "qDefs.h" - -/** Form Header */ -#include "ui_form_action.h" -/** Project Class Headers */ -class multiSlsDetector; -/** Qt Include Headers */ - -/** C++ Include Headers */ -#include -using namespace std; - - - -class qActionsWidget : public QWidget,private Ui::ActionsObject{ - Q_OBJECT - -public: - /** \short The constructor - * @param parent is the parent tab widget - * @param detector is the detector returned from the detector tab - */ - qActionsWidget(QWidget *parent, multiSlsDetector*& detector); - - ~qActionsWidget(); - - /**to update the widgets*/ - void Refresh(); - - - /**number of action widgets*/ - static int NUM_ACTION_WIDGETS; - - - -private: - /** The sls detector object */ - multiSlsDetector *myDet; - /**id of the action widget*/ - int id; - - /** Sets up the widget - */ - void SetupWidgetWindow(); - - /** Sets up all the slots and signals - * */ - void Initialization(); - - -private slots: -/** Sets the scan or script. Accordingly enables, disables other widgets - * @param mode value chosen - * */ -void SetMode(int mode); - -/** Browse for the script - * */ -void BrowsePath(); - -/** Sets the script file - * */ -void SetScriptFile(); - -/** Set Parameter - * */ -void SetParameter(); - -}; - - - - -#endif /* QACTIONSWIDGET_H_ */ - diff --git a/slsDetectorGui/include/qCloneWidget.h b/slsDetectorGui/include/qCloneWidget.h deleted file mode 100644 index 07d4cff4c..000000000 --- a/slsDetectorGui/include/qCloneWidget.h +++ /dev/null @@ -1,164 +0,0 @@ -/* - * qCloneWidget.h - * - * Created on: May 18, 2012 - * Author: l_maliakal_d - */ - -#ifndef QCLONEWIDGET_H_ -#define QCLONEWIDGET_H_ - -#include "qDefs.h" - - -/** Qt Project Class Headers */ -class SlsQtH1D; -#include "SlsQt1DPlot.h" -#include "SlsQt2DPlotLayout.h" -/** Qt Include Headers */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -/** C++ Include Headers */ -#include -#include -using namespace std; - -/** - *@short Sets up the clone plot widget - */ -class qCloneWidget:public QMainWindow{ - Q_OBJECT - -public: - /** \short The constructor - */ - qCloneWidget(QWidget *parent,int id,QString title,QString xTitle, QString yTitle, QString zTitle, int numDim,string FilePath, - bool displayStats, QString min, QString max, QString sum); - - /** Destructor - */ - ~qCloneWidget(); - - /** Sets up the widget window - * @param title title of the image with frame number - * @param xTitle title of x axis - * @param yTitle title of y axis - * @param zTitle title of z axis - * @param numDim 1D or 2D - * */ - void SetupWidgetWindow(QString title, QString xTitle, QString yTitle, QString zTitle, int numDim); - - - - /** Get the 1D hist values to plot - * @param nHists Number of graphs in 1D - * @param histNBins Total Number of X axis values/channels in 1D - * @param histXAxis X Axis value in 1D - * @param histYAxis Y Axis value in 1D - * @param histTitle Title for all the graphs in 1D - * @param lines style of plot if lines or dots - * @param markers style of plot markers or not - * */ - void SetCloneHists(int nHists,int histNBins,double* histXAxis,double* histYAxis[],string histTitle[],bool lines,bool markers); - - /** Get the 1D hist values to plot for angle plotting - * @param nHists Number of graphs in 1D - * @param histNBins Total Number of X axis values/channels in 1D - * @param histXAxis X Axis value in 1D - * @param histYAxis Y Axis value in 1D - * @param histTitle Title for all the graphs in 1D - * @param lines style of plot if lines or dots - * @param markers style of plot markers or not - * */ - void SetCloneHists(int nHists,int histNBins,double* histXAxis,double* histYAxis,string histTitle[],bool lines,bool markers); - - /** Get the 1D hist values to plot for angle plotting - * @param nbinsx number of bins in x axis - * @param xmin minimum in x axis - * @param xmax maximum in x axis - * @param nbinsy number of bins in y axis - * @param ymin minimum in y axis - * @param ymax maximum in y axis - * @param d data - * */ - void SetCloneHists2D(int nbinsx,double xmin,double xmax,int nbinsy, double ymin, double ymax, double *d); - - /**Set the range of the 1d plot - * @param IsXYRange array of x,y,min,max if these values are set - * @param XYRangeValues array of set values of x,y, min, max - */ - void SetRange(bool IsXYRange[], double XYRangeValues[]); - - /** Returns the 1d plot - */ - SlsQt1DPlot* Get1dPlot(){return cloneplot1D;}; - -public slots: -/** Save Plots automatically by save all clones - * returns -1 if fail*/ -int SavePlotAutomatic(); - - -private: - /** clone window id*/ - int id; - /** Default Save file path */ - string filePath; - /** clone 1D Plot */ - SlsQt1DPlot* cloneplot1D; - /** clone 2D Plot */ - SlsQt2DPlotLayout* cloneplot2D; - /** vector of 1D hist values */ - QVector cloneplot1D_hists; - - /** markers for the plot*/ - QwtSymbol *marker; - QwtSymbol *nomarker; - - QMenuBar *menubar; - QAction *actionSave; - - QGridLayout *mainLayout; - QGroupBox *cloneBox; - QGridLayout *gridClone; - - QLabel *lblHistTitle; - - /** Gets the current time stamp for the window title*/ - char* GetCurrentTimeStamp(); - - /** Display Statistics */ - void DisplayStats(bool enable, QString min, QString max, QString sum); - - -private slots: -/** Save Plot */ -void SavePlot(); - -protected: - void closeEvent(QCloseEvent* event); - -signals: -void CloneClosedSignal(int); - -}; - - - - -#endif /* QCLONEWIDGET_H_ */ diff --git a/slsDetectorGui/include/qDebugStream.h b/slsDetectorGui/include/qDebugStream.h deleted file mode 100644 index 4335dbd0a..000000000 --- a/slsDetectorGui/include/qDebugStream.h +++ /dev/null @@ -1,119 +0,0 @@ -/* - * qDebugStream.h - * - * Created on: Jun 28, 2012 - * Author: Anna Bergamaschi - */ - -#ifndef QDEBUGSTREAM_H_ -#define QDEBUGSTREAM_H_ - - -#include "qDefs.h" - - -#include -#include -#include -#include - - -#include -#include -#include -using namespace std; - -#define STREAMEVENT 60001 - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - -class qStreamEvent:public QEvent{ -public: - qStreamEvent(QString s):QEvent(static_cast(STREAMEVENT)),str(s){ -#ifdef PRINT_LOG - printf("%s\n",str.toAscii().constData()); -#endif - } - /** \returns the progress index */ - QString getString() {return str;} -private: - QString str; - -}; - -//------------------------------------------------------------------------------------------------------------------------------------------------- - -class qDebugStream : public basic_streambuf { - -public: - qDebugStream(ostream &stream, QWidget* w) : m_stream(stream), log_window(w) { - pthread_mutex_init(&mutex, NULL); - m_old_buf = stream.rdbuf(); - stream.rdbuf(this); - } - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - ~qDebugStream(){ - // output anything that is left - if (!m_string.empty()) { - pthread_mutex_lock(&mutex); - const char* c_string = m_string.c_str(); - QApplication::postEvent(log_window, new qStreamEvent(c_string)); - pthread_mutex_unlock(&mutex); - } - m_stream.rdbuf(m_old_buf); - } - -//------------------------------------------------------------------------------------------------------------------------------------------------- - -protected: - virtual int_type overflow(int_type v){ - if (v == '\n'){ - pthread_mutex_lock(&mutex); - const char* c_string = m_string.c_str(); - QApplication::postEvent(log_window, new qStreamEvent(c_string)); - m_string.erase(m_string.begin(), m_string.end()); - pthread_mutex_unlock(&mutex); - } - else - m_string += v; - return v; - } - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - virtual streamsize xsputn(const char *p, streamsize n) { - pthread_mutex_lock(&mutex); - m_string.append(p, p + n); - - //changed from uint because of 64 bit - size_t pos = 0; - - while (pos != string::npos){ - pos = m_string.find('\n'); - if (pos != string::npos){ - string tmp(m_string.begin(), m_string.begin() + pos); - const char* c_tmp = tmp.c_str(); - QApplication::postEvent(log_window, new qStreamEvent(c_tmp)); - m_string.erase(m_string.begin(), m_string.begin() + pos + 1); - } - } - pthread_mutex_unlock(&mutex); - return n; - } - -//------------------------------------------------------------------------------------------------------------------------------------------------- - -private: - pthread_mutex_t mutex; - ostream &m_stream; - streambuf *m_old_buf; - string m_string; - QWidget* log_window; -}; - -//------------------------------------------------------------------------------------------------------------------------------------------------- - -#endif /* QDEBUGSTREAM_H_ */ diff --git a/slsDetectorGui/include/qDefs.h b/slsDetectorGui/include/qDefs.h deleted file mode 100644 index f1b7d2b51..000000000 --- a/slsDetectorGui/include/qDefs.h +++ /dev/null @@ -1,301 +0,0 @@ -/* - * qDefs.h - * - * Created on: May 4, 2012 - * Author: l_maliakal_d - */ - -#ifndef QDEFS_H -#define QDEFS_H - -#include "ansi.h" -#include "sls_detector_defs.h" -#include "slsDetector.h" -#include "multiSlsDetector.h" -#include -#include -#include -#include -#include -using namespace std; - -class qDefs:public QWidget{ -public: -//------------------------------------------------------------------------------------------------------------------------------------------------- - - /** Empty Constructor - */ - qDefs(){}; -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -#define GOODBYE -200 -//------------------------------------------------------------------------------------------------------------------------------------------------- - - enum{ - OK, - FAIL - }; - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - enum MessageIndex{ - WARNING, - CRITICAL, - INFORMATION, - QUESTION - }; - -//------------------------------------------------------------------------------------------------------------------------------------------------- - /** unit of time - */ - enum timeUnit{ - HOURS, /** hr */ - MINUTES, /** min */ - SECONDS, /** s */ - MILLISECONDS, /** ms */ - MICROSECONDS, /** us */ - NANOSECONDS /** ns */ - }; - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - /** returns the unit in words - * @param unit is the time unit - */ - static string getUnitString(timeUnit unit){ - switch(unit){ - case HOURS: return string("hrs"); - case MINUTES: return string("min"); - case SECONDS: return string("sec"); - case MILLISECONDS: return string("msec"); - case MICROSECONDS: return string("usec"); - case NANOSECONDS: return string("nsec"); - default: return string("error"); - } - }; -//------------------------------------------------------------------------------------------------------------------------------------------------- - - /** returns the value in ns to send to server as the - * server class slsdetector accepts in ns. - * @param unit unit of time - * @param value time - * returns time value in ns - */ - static double getNSTime(timeUnit unit, double value){ - double valueNS=value; - switch(unit){ - case HOURS: valueNS*=60; - case MINUTES: valueNS*=60; - case SECONDS: valueNS*=1000; - case MILLISECONDS: valueNS*=1000; - case MICROSECONDS: valueNS*=1000; - case NANOSECONDS: - default:; - } - return valueNS; - }; - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - /** returns the time in the appropriate time unit - * @param unit unit of time - * @param value time in seconds - * returns the corresponding time value - */ - static double getCorrectTime(timeUnit& unit, double value){ - int intUnit = (int)SECONDS; - - /**0 ms*/ - if(!value){ - unit = MILLISECONDS; - return value; - } - - /** hr, min, sec */ - if(value>=1){ - double newVal = value; - while((newVal>=1)&&(intUnit>=(int)HOURS)){ - /** value retains the old value */ - value = newVal; - newVal = value/(double)60; - intUnit--; - } - /** returning the previous value*/ - unit = (timeUnit)(intUnit+1); - return value; - } - /** ms, us, ns */ - else{ - while((value<1)&&(intUnit<(int)NANOSECONDS)){ - value = value*(double)1000; - intUnit++; - } - unit = (timeUnit)(intUnit); - return value; - } - }; - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - /**displays an warning,error,info message - * @param message the message to be displayed - * @param source is the tab or the source of the message - * */ - static int Message(MessageIndex index, string message,string source) - { - static QMessageBox* msgBox; - size_t pos; - - //replace all \n with
- pos = 0; - while((pos = message.find("\n", pos)) != string::npos){ - message.replace(pos, 1, "
"); - pos += 1; - } - message.append(string("

Source:   ") + source + string("

")); - - switch(index){ - case WARNING: - msgBox= new QMessageBox(QMessageBox::Warning,"WARNING",tr(message.c_str()),QMessageBox::Ok, msgBox); - break; - case CRITICAL: - msgBox= new QMessageBox(QMessageBox::Critical,"CRITICAL",tr(message.c_str()),QMessageBox::Ok, msgBox); - break; - case INFORMATION: - msgBox= new QMessageBox(QMessageBox::Information,"INFORMATION",tr(message.c_str()),QMessageBox::Ok, msgBox); - break; - default: - msgBox= new QMessageBox(QMessageBox::Question,"QUESTION",tr(message.c_str()),QMessageBox::Ok| QMessageBox::Cancel, msgBox); - break; - } - //msgBox->setDetailedText(QString(source.c_str())); //close button doesnt work with this static function and this - if(msgBox->exec()==QMessageBox::Ok) return OK; else return FAIL; - } - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - /** range of x and y axes - */ - enum range{ - XMINIMUM, - XMAXIMUM, - YMINIMUM, - YMAXIMUM - }; - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - /**gets error mask and displays the message if it exists - * @param myDet is the multidetector object - /returns error message else an empty string - * */ - static string checkErrorMessage(multiSlsDetector*& myDet, string title = "Main"){ - - - int errorLevel= (int)WARNING; - string retval=""; - size_t pos; - - - retval = myDet->getErrorMessage(errorLevel); - - if(!retval.empty()){ - //replace all \n with
- pos = 0; - while((pos = retval.find("\n", pos)) != string::npos){ - retval.replace(pos, 1, "
"); - pos += 1; - } - - //get rid of the last \n - if(retval.find_last_of("
")==retval.length()-1) - retval.erase((int)retval.find_last_of("
")-3,4); - - retval.insert(0,""); - retval.append(""); - - //display message - qDefs::Message((MessageIndex)errorLevel,retval,title); - } - - myDet->clearAllErrorMask(); - return retval; - }; - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - /**gets error mask and displays the message if it exists - * @param myDet is the slsdetector object - * @param show to display the error message - /returns error message else an empty string - * */ - static string checkErrorMessage(slsDetector*& myDet, string title = "Main", bool show = true){ - - - int errorLevel= (int)WARNING; - string retval=""; - size_t pos; - int64_t emask=0; - - emask = myDet->getErrorMask(); - retval = myDet->getErrorMessage(emask); - - if(!retval.empty()){ - //replace all \n with
- pos = 0; - while((pos = retval.find("\n", pos)) != string::npos){ - retval.replace(pos, 1, "
"); - pos += 1; - } - - //get rid of the last \n - if(retval.find_last_of("
")==retval.length()-1) - retval.erase((int)retval.find_last_of("
")-3,4); - - retval.insert(0,""); - retval.append(""); - - //display message - if(show) - qDefs::Message((MessageIndex)errorLevel,retval,title); - } - - myDet->clearErrorMask(); - - return retval; - }; - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - - /** scan arguments*/ - enum scanArgumentList{ - None, - Level0, - Level1, - FileIndex, - AllFrames - }; - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - - /** histogram arguments*/ - enum histogramArgumentList{ - Intensity, - histLevel0, - histLevel1 - }; - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -}; - - -#endif /* QDEFS_H */ diff --git a/slsDetectorGui/include/qDetectorMain.h b/slsDetectorGui/include/qDetectorMain.h deleted file mode 100644 index 0af189fc0..000000000 --- a/slsDetectorGui/include/qDetectorMain.h +++ /dev/null @@ -1,202 +0,0 @@ -/* - * qDetectorMain.h - * Main Window of the GUI - * Created on: Apr 30, 2012 - * Author: l_maliakal_d - */ -#ifndef QDETECTORMAIN_H -#define QDETECTORMAIN_H - -#include "qDefs.h" - -/** Form Header */ -#include "ui_form_detectormain.h" -/** Qt Project Class Headers */ -#include "qDrawPlot.h" -#include "qTabMeasurement.h" -#include "qTabDataOutput.h" -class qTabPlot; -class qTabActions; -class qTabAdvanced; -class qTabSettings; -class qTabDebugging; -class qTabDeveloper; -class qTabMessages; -class qServer; -/** Project Class Headers */ -class multiSlsDetector; -/** Qt Include Headers */ -#include -#include -#include -#include - -#include -using namespace std; - -/** To Over-ride the QTabWidget class to get the tabBar */ -class MyTabWidget:public QTabWidget{ -public: - MyTabWidget(QWidget* parent = 0) {setParent(parent);} - /** Overridden method from QTabWidget */ - QTabBar* tabBar(){return QTabWidget::tabBar();} -}; - - -/** - *@short Main window of the GUI. - */ -class qDetectorMain:public QMainWindow, private Ui::DetectorMainObject{ - Q_OBJECT - - -public: - /** \short Main Window constructor. - * This is mainly used to create detector object and all the tabs - * @param argc number of command line arguments for server options - * @param argv server options - * @param app the qapplication3 - * @param ret OK or FAIL of constructor (from command line arguments) - * @param parent makes the parent window 0 by default - * */ - qDetectorMain(int argc, char **argv, QApplication *app, int& ret, QWidget *parent = 0); - - /**Destructor - * */ - ~qDetectorMain(); - - /** Starts or stops Acquisition From gui client - * @param start 1 for start and 0 to stop - /returns success or fail - */ - int StartStopAcquisitionFromClient(bool start); - - /** Returns if plot is running - */ - bool isPlotRunning(){return myPlot->isRunning();}; - - /** Returns progress bar value */ - int GetProgress(){return tab_measurement->GetProgress();}; - - /** Returns file path */ - QString GetFilePath(){QString s = QString(myDet->getFilePath().c_str());qDefs::checkErrorMessage(myDet); return s;}; - - /** Verifies if output directories for all the receivers exist */ - int DoesOutputDirExist(){return tab_dataoutput->VerifyOutputDirectory();}; - - bool isCurrentlyTabDeveloper(); - -private: - /** The Qt Application */ - QApplication *theApp; - /** The sls detector object */ - multiSlsDetector *myDet; - /** sls detector id */ - int detID; - /** true for mythen and eiger */ - bool digitalDetector; - /** The Plot widget */ - qDrawPlot *myPlot; - /**Tab Widget */ - MyTabWidget *tabs; - /**Layout of the central Widget */ - QGridLayout *layoutTabs; - /** default height of Plot Window when docked */ - int heightPlotWindow; - /** default height of central widgetwhen plot Window when docked */ - int heightCentralWidget; - /** The default zooming tool tip */ - QString zoomToolTip; - - /** The default tab heading color */ - QColor defaultTabColor; - /** enumeration of the tabs */ - enum {Measurement, Settings, DataOutput, Plot, Actions, Advanced, Debugging, Developer, Messages, NumberOfTabs }; - /* Scroll Area for the tabs**/ - QScrollArea *scroll[NumberOfTabs]; - /**Measurement tab */ - qTabMeasurement *tab_measurement; - /**DataOutput tab */ - qTabDataOutput *tab_dataoutput; - /**Plot tab */ - qTabPlot *tab_plot; - /**Actions tab */ - qTabActions *tab_actions; - /**Settings tab */ - qTabSettings *tab_settings; - /**Advanced tab */ - qTabAdvanced *tab_advanced; - /**Debugging tab */ - qTabDebugging *tab_debugging; - /**Developer tab */ - qTabDeveloper *tab_developer; - /**Messages tab */ - qTabMessages *tab_messages; - - /** server object*/ - qServer *myServer; - - /**if the developer tab should be enabled,known from command line */ - int isDeveloper; - - /**Sets up the layout of the widget - * */ - void SetUpWidgetWindow(); - - /**Sets up detector - * @param fName file name of the config file at start up - * */ - void SetUpDetector(const string fName); - - /**Sets up the signals and the slots - * */ - void Initialization(); - - /** Loads config file at start up - * */ - void LoadConfigFile(const string fName); - - -private slots: -/** Enables modes as selected -Debug, Expert, Dockable(calls setdockablemode()) - * */ -void EnableModes(QAction *action); - -/** Executes actions in the utilities menu as selected - * */ -void ExecuteUtilities(QAction *action); - -/** Executes actions in the utilities menu as selected - * */ -void ExecuteHelp(QAction *action); - -/** Refreshes the tab each time the tab is changed. Also displays the next enabled tab - * */ -void Refresh(int index); - -/** Resizes the main window if the plot is docked/undocked - * @param b bool TRUE if undocked(outside main window), FALSE docked - * */ -void ResizeMainWindow(bool b); - -/** Enables/disables tabs depending on if acquisition is currently in progress - * */ -void EnableTabs(); - -/** Set the tool tip of mouse controlled zooming depening on if its enabled/disabled - * */ -void SetZoomToolTip(bool disable); - -/** Uncheck the Listen to gui client mode when the server has exited - */ -void UncheckServer(); - -protected: -/** Adjust the resizing to resize plot, except for actions tab - * */ -void resizeEvent(QResizeEvent* event); - - -}; - -#endif /* QDETECTORMAIN_H */ diff --git a/slsDetectorGui/include/qDrawPlot.h b/slsDetectorGui/include/qDrawPlot.h deleted file mode 100644 index 54a4a2542..000000000 --- a/slsDetectorGui/include/qDrawPlot.h +++ /dev/null @@ -1,624 +0,0 @@ -/* - * qDrawPlot.h - * - * Created on: May 7, 2012 - * Author: Dhanya Maliakal - */ -#ifndef QDRAWPLOT_H -#define QDRAWPLOT_H - - -#include "qDefs.h" - -/** Project Class Headers */ -class multiSlsDetector; -#include "detectorData.h" -/** Qt Project Class Headers */ -#include "SlsQt1DPlot.h" -#include "SlsQt2DPlotLayout.h" -class qCloneWidget; -/** Qt Include Headers */ -#include -#include -#include -#include -#include -#include "qwt_symbol.h" - - -#include -#include -#include -#include -#include -#include - -/** C++ Include Headers */ - - -#define MAX_1DPLOTS 10 - - -/** - *@short Sets up the plot widget - */ -class qDrawPlot:public QWidget{ - Q_OBJECT - - - - -public: - /** \short The constructor */ - qDrawPlot(QWidget *parent,multiSlsDetector*& detector); - /** Destructor */ - ~qDrawPlot(); - - /**is an acquisition running , need it to prevent measurement tab - * from being refreshed when switching tabs during acquisition */ - bool isRunning(){return running;}; - /** gets the progress of acquisition to the measurement tab*/ - int GetProgress(){return progress;}; - /** gets the file index to the measurement tab*/ - int GetFileIndex(){return currentFileIndex;}; - /** gets the frame index to the measurement tab*/ - int GetFrameIndex(){return currentFrameIndex;}; - /** sets file write enable , if not enabled, - * file index wont increase and so you need secondary titles to differentitate between plots*/ - void SetEnableFileWrite(bool enable){fileSaveEnable = enable;}; - - /** sets plot Title prefix*/ - void SetPlotTitlePrefix(QString title) {plotTitle_prefix = title;} - /** sets 1D X Axis Title */ - void SetHistXAxisTitle(QString title) {histXAxisTitle = title;} - /** sets 1D Y Axis Title */ - void SetHistYAxisTitle(QString title) {histYAxisTitle = title;} - /** sets 2D X Axis Title */ - void SetImageXAxisTitle(QString title) {imageXAxisTitle = title;} - /** sets 2D Y Axis Title */ - void SetImageYAxisTitle(QString title) {imageYAxisTitle = title;} - /** sets 2D Z Axis Title */ - void SetImageZAxisTitle(QString title) {imageZAxisTitle = title;} - /** Disables zoom if any of the axes range are checked and fixed with a value */ - void DisableZoom(bool disable); - /** Enables plot from the plot tab*/ - void EnablePlot(bool enable); - /** Enable angle plot */ - void EnableAnglePlot(bool enable){anglePlot = enable;}; - - /** Its a reminder to update plot to set the xy range - * This is done only when there is a plot to update */ - void SetXYRange(bool changed){XYRangeChanged = changed;}; - /**Sets the min/max for x/y - * @param val is the value to be set - * @param xy is xmin,xmax,ymin or ymax */ - void SetXYRangeValues(double val,qDefs::range xy){XYRangeValues[xy]=val;}; - /**Sets if min/max for x/y is enabled - * @param changed is if this has been changed - * @param xy is xmin,xmax,ymin or ymax */ - void IsXYRangeValues(bool changed,qDefs::range xy){IsXYRange[xy]=changed;}; - - /** Get minimum Plot timer - between plots */ - double GetMinimumPlotTimer(){return PLOT_TIMER_MS;}; - /** Set Plot timer - between plots in ms*/ - void SetPlotTimer(double time); - /** Set Plot frame factor - between plots, also for receiver if exists */ - void SetFrameFactor(int frame); - - /** Starts or stop acquisition - * Calls startDaq() function - * @param stop_if_running is 0 to stop acquisition and 1 to start acquisition - */ - void StartStopDaqToggle(bool stop_if_running=0); - /** Set frame enabled - * @param enable enable*/ - void setFrameEnabled(bool enable){isFrameEnabled = enable;}; - /** Set trigger enabled - * @param enable enable */ - void setTriggerEnabled(bool enable){isTriggerEnabled = enable;}; - - /** Updates the trimbit plot - * @param fromDetector is true if the trimbits should be loaded from detector - * @param Histogram true if histogram, else data graph - * returns ok/fail - * */ - int UpdateTrimbitPlot(bool fromDetector,bool Histogram); - - /** This is set once client initiates start/stop acquisition - * and this is reset when the gui really starts/stops- to know when to return - */ - void SetClientInitiated(){clientInitiated = true;}; - - /** Get client intiated variable. This is set once client initiates start/stop acquisition - * and this is reset when the gui really starts/stops- to know when to return - */ - bool GetClientInitiated(){return clientInitiated;}; - - /** Update all ranges, interpolate etc after cloning - * parameters are if they are checked or not - */ - void UpdateAfterCloning(bool points, bool logy, bool interpolate, bool contour, bool logz); - - /** set binary range */ - void SetBinary(bool enable, int from=0, int to=0); - - /** Enable/Disable Histogram */ - void SetHistogram(bool enable,int histArg, int min=0, int max=0, double size=0){histogram = enable;histogramArgument = histArg; histFrom=min;histTo=max;histSize=size;}; - - /** Get X Minimum value from plot */ - double GetXMinimum() { if(plot_in_scope==1) return plot1D->GetXMinimum(); else return plot2D->GetPlot()->GetXMinimum();}; - /** Get X Maximum value from plot */ - double GetXMaximum() { if(plot_in_scope==1) return plot1D->GetXMaximum(); else return plot2D->GetPlot()->GetXMaximum();}; - /** Get Y Minimum value from plot */ - double GetYMinimum() { if(plot_in_scope==1) return plot1D->GetYMinimum(); else return plot2D->GetPlot()->GetYMinimum();}; - /** Get Y Maximum value from plot */ - double GetYMaximum() { if(plot_in_scope==1) return plot1D->GetYMaximum(); else return plot2D->GetPlot()->GetYMaximum();}; - -public slots: -/** To select 1D or 2D plot - @param i is 1 for 1D, else 2D plot */ -void SelectPlot(int i=2); -/** To select 1D plot */ -void Select1DPlot() {SelectPlot(1);} -/** To select 2D plot */ -void Select2DPlot() {SelectPlot(2);} -/** To clear plot */ -void Clear1DPlot(); -/** Creates a clone of the plot */ -void ClonePlot(); -/** Closes all the clone plots */ -void CloseClones(); -/** Saves all the clone plots */ -void SaveClones(); -/** To Save plot */ -void SavePlot(); -/** Save all plots **/ -void SaveAll(bool enable){saveAll = enable;}; -/** Sets persistency from plot tab */ -void SetPersistency(int val); -/** sets style of plot to lines*/ -void SetLines(bool enable){lines = enable;}; -/** sets markers */ -void SetMarkers(bool enable){markers = enable;}; -/** sets the scan argument to prepare the plot*/ -void SetScanArgument(int scanArg); -/** sets stop_signal to true */ -void StopAcquisition(){ stop_signal = true; }; -/** Set/unset pedestal */ -void SetPedestal(bool enable); -/** Recalculate Pedestal */ -void RecalculatePedestal(); -/** Set/unset accumulate */ -void SetAccumulate(bool enable); -/** Reset accumulation */ -void ResetAccumulate(); -/** Display Statistics */ -void DisplayStatistics(bool enable); - - - - - - -private: -/** Initializes all its members and the thread */ -void Initialization(); -/** Sets up the widget */ -void SetupWidgetWindow(); - - -/** Gets the image title */ -const char* GetImageTitle() {return imageTitle.c_str();} -/** Gets the hist title for a 1D plot */ -const char* GetHistTitle(int i) {return (i>=0&&i=0&&isetStyle(QwtPlotCurve::Lines); else h->setStyle(QwtPlotCurve::Dots); -#if QWT_VERSION<0x060000 - if(markers) h->setSymbol(*marker); else h->setSymbol(*noMarker); -#else - if(markers) h->setSymbol(marker); else h->setSymbol(noMarker); -#endif -}; - - -/** Find Statistics - * @param min is the minimum value - * @param max is the maximum value - * @param sum is the sum of all values - * @param array is the array to get statistics from - * @param size is the size of the array */ -void GetStatistics(double &min, double &max, double &sum, double* array, int size); - - -/** - * Convert data from char* to double based on bit mode (get gain data from plot if enabled for jungfrau - * @param dest destination double array - * @param source source char array - * @param size number of pixels - * @param databytes number of data bytes - * @param dr dynamic range - * @param gaindest NULL if not required, points to a double array to be filled up if gain data enabled - * - */ -void toDoublePixelData(double* dest, char* source,int size, int databytes, int dr, double* gaindest = NULL); - -private slots: -/** To update plot - * */ -void UpdatePlot(); -/** To start or stop acquisition - * @param start is 1 to start and 0 to stop acquisition - * */ -void StartDaq(bool start); -/** To set the reference to zero after closing a clone - * @param id is the id of the clone - * */ -void CloneCloseEvent(int id); -/**After a pause, the gui is allowed to collect the data - * this is called when it is over - * */ -void UpdatePause(){data_pause_over=true;}; -/** Shows the first save error message while automatic saving - * @param fileName file name of the first file that it tried to save. - * */ -void ShowSaveErrorMessage(QString fileName); -/**Shows an error message when acquisition stopped unexpectedly - * @param status is the status of the detector - * */ -void ShowAcquisitionErrorMessage(QString status); -/** - * Enable Gain Plot - * @param e true for enable, false for disable - */ -void EnableGainPlot(bool e); - - -private: -/** The sls detector object */ -multiSlsDetector *myDet; - -/** detectot type */ -slsDetectorDefs::detectorType detType; - - -/** Widgets needed to plot the clone */ -/** Max Number of Clone Windows */ -static const int MAXCloneWindows = 50; -/** Array of clone window widget pointers */ -qCloneWidget *winClone[MAXCloneWindows]; - -/** Widgets needed to set up plot*/ -QGroupBox *boxPlot; -QGridLayout *layout; -QGridLayout *plotLayout; -/** Timer to update plot */ -QTimer* plot_update_timer; - -/** Timer to pause getting data from client */ -QTimer* data_pause_timer; -bool data_pause_over; - - -/** 1D object */ -SlsQt1DPlot* plot1D; -/** 2D object */ -SlsQt2DPlotLayout* plot2D; -/** vector of 1D hist values */ -QVector plot1D_hists; - -/**label with frame index for those with many frames per file*/ -QLabel *histFrameIndexTitle; - - -/** Current Measurement */ -int currentMeasurement; -/** currentFrame */ -int currentFrame; -/** variable to check if its the nth frame */ -int numFactor; -/** current Scan Division Level */ -int currentScanDivLevel; -/** current scan Value */ -double currentScanValue; -/** Number of Exposures */ -int number_of_exposures; -/** Number of Frames Per Measurement */ -int number_of_frames; -/** Duration between Exposures */ -double acquisitionPeriod; -/** Acquisition Time */ -double exposureTime; -/** Current file index*/ -int currentFileIndex; -/** Current frame index*/ -int currentFrameIndex; - -/**variables for threads */ -/** */ -volatile bool stop_signal; -/** */ -pthread_mutex_t last_image_complete_mutex; - -/**variables for histograms */ -/** X Axis Title in 2D */ -QString imageXAxisTitle; -/** Y Axis Title in 2D */ -QString imageYAxisTitle; -/** Z Axis Title in 2D */ -QString imageZAxisTitle; -/** X Axis Title in 1D */ -QString histXAxisTitle; -/** Y Axis Title in 1D */ -QString histYAxisTitle; -/** Title for all the graphs in 1D */ -std::string histTitle[MAX_1DPLOTS]; -/** Title in 2D */ -std::string imageTitle; -/** plot Title */ -QString plotTitle; -/** plot Title prefix */ -QString plotTitle_prefix; -/** 1D or 2D */ -unsigned int plot_in_scope; -/** Number of Pixels in X Axis */ -unsigned int nPixelsX; -/** Number of angle Pixels in X Axis */ -int nAnglePixelsX; -/** Number of pixel bins in Y Axis */ -unsigned int nPixelsY; -/** Min Pixel number for Y Axis*/ -double minPixelsY; -/** Max Pixel number for Y Axis*/ -double maxPixelsY; -/** starting pixel */ -double startPixel; -/** end Pixel*/ -double endPixel; -/** pixel width */ -double pixelWidth; - -/** Current Image Number */ -unsigned int lastImageNumber; - -/** Number of graphs in 1D */ -unsigned int nHists; -/** Total Number of X axis values/channels in 1D */ -int histNBins; -/** X Axis value in 1D */ -double* histXAxis; -/** Y Axis value in 1D */ -double* histYAxis[MAX_1DPLOTS]; -/** X Axis for angles in 1D */ -double* histXAngleAxis; -/** Y Axis for angles in 1D (no persistency) */ -double* histYAngleAxis; -/** X Axis for trimbits in 1D */ -double* histTrimbits; - - -/** Current Image Values in 2D */ -double* lastImageArray; - -/**persistency to be reached*/ -int persistency; -/** persistency takes time to reach as it increases per frame - * this is the current one */ -int currentPersistency; -/** to update the progress for each getData() so that - * measurement tab can request on a timer basis*/ -int progress; -/**If plot is enabled from plot tab*/ -bool plotEnable; -/**If plot is dotted */ -bool lines; -bool markers; -/** Plot marker */ -QwtSymbol *marker; -QwtSymbol *noMarker; -/** Save all plots */ -bool saveAll; -/** If error, while automatically saving plots, checks this at the end of an acquistion */ -bool saveError; -/** index of last saved image for automatic saving*/ -int lastSavedFrame; -/** index of measurement number of last saved image for automatic saving*/ -int lastSavedMeasurement; -/**if an acquisition is running, so as not to refresh tab - * and also to update plot only if running (while creating clones)*/ -bool running; - -/** if the min/max of x and y has been changed, - * to notify while plotting */ -bool XYRangeChanged; -/**the specific min/max of x/y*/ -double XYRangeValues[4]; -/**if the specific min/max of x/y is enabled */ -bool IsXYRange[4]; - -/** Default timer between plots*/ -static const double PLOT_TIMER_MS; - -/** Specific timer value between plots */ -double timerValue; -/** every nth frame when to plot */ -int frameFactor; -/**if frame is enabled in measurement tab */ -bool isFrameEnabled; -/**if trigger is enabled in measurement tab */ -bool isTriggerEnabled; - -/** scan arguments*/ -int scanArgument; - -/** histogram arguments*/ -int histogramArgument; - -/** enable angle plot */ -bool anglePlot; -/** prevents err msg displaying twice when detector stopped, "transmitting" */ -bool alreadyDisplayed; - -/**saves the file path and file name, not to access shared memory while running*/ -QString filePath; -QString fileName; - -/** Max Number of Clone Windows */ -static const int TRIM_HISTOGRAM_XMAX = 63; - -/**if the values increment backwards*/ -bool backwardScanPlot; - -/**if files will be saved and index increased*/ -bool fileSaveEnable; - - -/** true of originally 2d */ -bool originally2D; - - -//pedstal -/** Number of pedestal frames*/ -static const int NUM_PEDESTAL_FRAMES = 20; -/** set/unset pedestal*/ -bool pedestal; -/** pedestal values */ -double* pedestalVals; -/** temporary pedestal values to hide while recalculating*/ -double* tempPedestalVals; -/** count for 20 frames to calculate the pedestal */ -int pedestalCount; -/** start pedestal calculation */ -bool startPedestalCal; - -//accumulation -/** set/unset accumulation */ -bool accumulate; -/** to reset accumulation */ -bool resetAccumulate; - -/** range for binary plot output */ -bool binary; -int binaryFrom; -int binaryTo; - -/** this is set when client starts/stops acquisition - * and is reset once the gui really starts/stops */ -bool clientInitiated; - - -/** display statistics widgets */ -QWidget *widgetStatistics; -QLabel *lblMinDisp; -QLabel *lblMaxDisp; -QLabel *lblSumDisp; - -bool displayStatistics; - - -/* histogram */ -bool histogram; -int histFrom; -int histTo; -double histSize; -QwtPlotGrid *grid; -QwtPlotHistogram *plotHistogram; -QVector histogramSamples; - - -bool plotRequired; - - -/** 2D object second plot */ -SlsQt2DPlotLayout* gainplot2D; -/** Current Image Values in 2D gain plot */ -double* gainImageArray; -/** gain plot enable, enabled if gain data has been extracted and is available */ -bool gainPlotEnable; -/** gain data enable, enabled if gain data to be extracted from normal data */ -bool gainDataEnable; - -const static int npixelsx_jctb = 400; -int npixelsy_jctb; - -signals: -void UpdatingPlotFinished(); -void InterpolateSignal(bool); -void ContourSignal(bool); -void LogzSignal(bool); -void LogySignal(bool); -void ResetZMinZMaxSignal(bool,bool,double,double); -void SetCurrentMeasurementSignal(int); -void saveErrorSignal(QString); -void AcquisitionErrorSignal(QString); -void UpdatePlotSignal(); -void GainPlotSignal(bool); -}; - - - -#endif /* QDRAWPLOT_H */ diff --git a/slsDetectorGui/include/qScanWidget.h b/slsDetectorGui/include/qScanWidget.h deleted file mode 100644 index 329a211da..000000000 --- a/slsDetectorGui/include/qScanWidget.h +++ /dev/null @@ -1,193 +0,0 @@ -/* - * qScanWidget.h - * - * Created on: May 10, 2012 - * Author: l_maliakal_d - */ - -#ifndef QSCANWIDGET_H_ -#define QSCANWIDGET_H_ - -#include "qDefs.h" - -/** Form Header */ -#include "ui_form_scan.h" -/** Project Class Headers */ -class multiSlsDetector; -/** Qt Include Headers */ -#include -/** C++ Include Headers */ -#include -#include -using namespace std; - - -class qScanWidget : public QWidget,private Ui::ScanObject{ - Q_OBJECT - -public: - /** \short The constructor - * @param parent is the parent tab widget - * @param detector is the detector returned from the detector tab - */ - qScanWidget(QWidget *parent, multiSlsDetector*& detector); - - ~qScanWidget(); - - /**to update the widgets*/ - void Refresh(); - - - /**number of scan widgets*/ - static int NUM_SCAN_WIDGETS; - -private: - /** The sls detector object */ - multiSlsDetector *myDet; - /**id of the scan widget*/ - int id; - /**type of steps*/ - enum sizeIndex{RangeValues, CustomValues, FileValues}; - enum modes{None,EnergyScan,ThresholdScan,TrimbitsScan,PositionScan,CustomScript,NumModes}; - static const string modeNames[NumModes]; - - /**values*/ - int actualNumSteps; - vector positions; - - /**non error font*/ - QPalette normal; - QPalette red; - QString customTip; - QString fileTip; - QString rangeTip; - - /**widgets needed for diff size types*/ - QButtonGroup *btnGroup; - QStackedLayout *stackedLayout; - QLabel *lblFrom; - QDoubleSpinBox *spinFrom; - QLabel *lblTo; - QDoubleSpinBox *spinTo; - QLabel *lblSize; - QDoubleSpinBox *spinSize; - QComboBox *comboCustom; - QPushButton *btnCustom; - QLineEdit *dispFile; - QPushButton *btnFile; - - - /** Sets up the widget - */ - void SetupWidgetWindow(); - - /** Sets up all the slots and signals */ - void Initialization(); - - /** Sets up all the parameters from server/client */ - void LoadPositions(); - - /** Sets up the scan parameters - * returns if it was set - */ - int SetScan(int mode); - -private slots: -/** Enables widgets depending on which size is clicked. - * Options: constant size,specific values,values from file - * */ -void EnableSizeWidgets(); - -/** Sets the scan or script. Accordingly enables, disables other widgets - * @param mode value chosen*/ -void SetMode(int mode); - -/** Browse for the script - * */ -void BrowsePath(); - -/** Sets the script file - * */ -void SetScriptFile(); - -/** Set Parameter - * */ -void SetParameter(); - -/** Set precision - * @param value value of precision to be set - * */ -void SetPrecision(int value); - -/** Set number of steps - * */ -void SetNSteps(); - -/**Checks if size is zero and return FAIL if it does - * */ -int RangeCheckSizeZero(); - -/**returns ok and number of steps if valid - * @param number of steps - * */ -int RangeCheckNumValid(int &num); - -/**returns fail if to is not exact - * */ -int RangeCheckToValid(); - -/** Sets number of steps if from changed - * */ -void RangeFromChanged(); - -/** Sets number of steps if to changed - * */ -void RangeToChanged(); - -/** Sets s of steps if size changed - * */ -void RangeSizeChanged(); - -/** Set range for scan - * */ -void SetRangeSteps(); - - -/** Range type: If size is changed, - * the Number of steps is calculated - * */ -//void RangeCalculateNumSteps(); - -/** Range type: If size is changed, the To is calculated - * */ -//void RangeCalculateTo(); - - -/** Set custom steps - * returns OK if set properly - * */ -int SetCustomSteps(); - -/** Delete custom steps - * */ -void DeleteCustomSteps(); - -/** Reads the file to get the steps - * */ -void SetFileSteps(); - -/** Browses for the file path for steps - * */ -void BrowseFileStepsPath(); - - - -signals: -void EnableScanBox(); -}; - - - - -#endif /* QSCANWIDGET_H_ */ - diff --git a/slsDetectorGui/include/qServer.h b/slsDetectorGui/include/qServer.h deleted file mode 100644 index bd26080c6..000000000 --- a/slsDetectorGui/include/qServer.h +++ /dev/null @@ -1,137 +0,0 @@ -/* - * qServer.h.h - * - * Created on: Feb 27, 2013 - * Author: Dhanya Maliakal - */ -#ifndef QSERVER_H -#define QSERVER_H - - -/** Qt Project Class Headers */ -#include "sls_detector_defs.h" -#include "qDefs.h" -class qDetectorMain; -/** Project Class Headers */ -class multiSlsDetector; -class MySocketTCP; -/** Qt Include Headers */ -#include -/** C++ Include Headers */ - - -/** - *@short Sets up the gui server - */ -class qServer: public QWidget, public virtual slsDetectorDefs{ - Q_OBJECT - - -public: - /** \short The constructor */ - qServer(qDetectorMain *t); - /** Destructor */ - ~qServer(); - - /** Start or Stop Gui Server - * @param start is 1 to start and 0 to stop - */ - int StartStopServer(int start); - -private: - /** assigns functions to the fnum enum */ - int FunctionTable(); - - /** Decodes Function */ - int DecodeFunction(MySocketTCP* sock); - - /** Exit Server */ - int ExitServer(); - - - /** - * Static function - Thread started which listens to client gui. - * Called by StartStopServer() - * @param this_pointer pointer to this object - */ - static void* StartServerThread(void *this_pointer); - - /** - * Thread started which listens to client gui. - * Called by startServerThread() - * - */ - int StartServer(); - - /** - * Static function - Thread started which listens to client gui to stop acquisition - * Called by StartStopServer() - * @param this_pointer pointer to this object - */ - static void* StopServerThread(void *this_pointer); - - /** - * Thread started which listens to client gui to stop acquisition. - * Called by startServerThread() - * - */ - int StopServer(); - - - - /** Get Detector Status */ - int GetStatus(); - - /** Starts Acquisition */ - int StartAcquisition(); - - /** Stops Acquisition */ - int StopsAcquisition(); - - /** Acquire - blocking */ - int Acquire(); - - - - /**The measurement tab object*/ - qDetectorMain *myMainTab; - - /** tcp socket to gui client */ - MySocketTCP *mySocket; - /** tcp socket to gui client to stop or get status */ - MySocketTCP *myStopSocket; - - /** server port number*/ - int port_no; - - /** Lock Status if server locked to a client */ - int lockStatus; - - /** Function List */ - static const int NUMBER_OF_FUNCTIONS = 256; - int (qServer::*flist[NUMBER_OF_FUNCTIONS])(); - - - /** if the gui server thread is running*/ - static int gui_server_thread_running; - /** thread listening to gui client*/ - pthread_t gui_server_thread; - /** thread also listening to gui client to stop acquisition*/ - pthread_t gui_stop_server_thread; - - /** server started */ - int checkStarted; - int checkStopStarted; - - /** Message */ - char mess[MAX_STR_LENGTH]; - - -signals: - void ServerStoppedSignal(); - -}; - - - -#endif /* QSERVER_H */ diff --git a/slsDetectorGui/include/qTabActions.h b/slsDetectorGui/include/qTabActions.h deleted file mode 100644 index d5d497fde..000000000 --- a/slsDetectorGui/include/qTabActions.h +++ /dev/null @@ -1,150 +0,0 @@ -/* - * qTabActions.h - * - * Created on: May 10, 2012 - * Author: l_maliakal_d - */ - -#ifndef QTABACTIONS_H_ -#define QTABACTIONS_H_ - -#include "qDefs.h" - - -/* Qt Project Class Headers */ -#include "qActionsWidget.h" -#include "qScanWidget.h" -/** C++ Project Class Headers */ -class multiSlsDetector; -/** Qt Include Headers */ -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -/** - *@short sets up the acions parameters - */ -class qTabActions:public QWidget{ - Q_OBJECT - -public: - /** \short The constructor - * @param parent is the parent tab widget - * @param detector is the detector returned from the detector tab - */ - qTabActions(QWidget *parent,multiSlsDetector*& detector); - - /** Destructor - */ - ~qTabActions(); - - /** To refresh and update widgets - */ - void Refresh(); - - -public slots: - /** Disable Positions - * @param enable true if to disable - * */ - void EnablePositions(bool enable); - - -private: - /** The sls detector object */ - multiSlsDetector *myDet; - - slsDetectorDefs::detectorType detType; - - - enum actionIndex{ - ActionStart, - Scan0, - Scan1, - ActionBefore, - NumPositions, - HeaderBefore, - HeaderAfter, - ActionAfter, - ActionStop, - NumTotalActions}; - - QGridLayout *gridLayout; - QButtonGroup *group; - QPalette *palette; - - /** all action widget objects */ - qActionsWidget *actionWidget[6]; - qScanWidget *scanWidget[2]; - QWidget *positionWidget; - QPushButton *btnExpand[NumTotalActions]; - QLabel *lblName[NumTotalActions]; - - - /** NumPositions widget */ - QLabel *lblNumPos; - QLabel *lblPosList; - QSpinBox *spinNumPos; - QComboBox *comboPos; - QPushButton *btnDelete; - QCheckBox *chkInvert; - QCheckBox *chkSeparate; - QCheckBox *chkReturn; - - double *positions; - QPalette normal; - QIcon *iconPlus; - QIcon *iconMinus; - - - /** Sets up the widget */ - void SetupWidgetWindow(); - - /** Sets up all the slots and signals */ - void Initialization(); - - /** creates the Num Positions object */ - void CreatePositionsWidget(); - - /** Returns the index in each of the classes - * of actionwidget and scanwidget - * @param index the index in the list of all widgets - * returns actual index of the class - */ - int GetActualIndex(int index); - - /** Updates to green color if collapsed and mode not none - */ - void UpdateCollapseColors(); - - - - -private slots: - /** To Expand the Action Widget - * */ - void Expand(QAbstractButton *button); - - /** Sets the positions list and the number of positions - * */ - void SetPosition(); - - /** Deletes current position - * */ - void DeletePosition(); - - -signals: - void EnableScanBox(); - -}; - -#endif /* QTABACTIONS_H_ */ - diff --git a/slsDetectorGui/include/qTabAdvanced.h b/slsDetectorGui/include/qTabAdvanced.h deleted file mode 100644 index e07305d77..000000000 --- a/slsDetectorGui/include/qTabAdvanced.h +++ /dev/null @@ -1,266 +0,0 @@ -/* - * qTabAdvanced.h - * - * Created on: May 10, 2012 - * Author: l_maliakal_d - */ - -#ifndef QTABADVANCED_H_ -#define QTABADVANCED_H_ - -#include "qDefs.h" -#include "sls_detector_defs.h" - -/** Form Header */ -#include "ui_form_tab_advanced.h" -/** Project Class Headers */ -class multiSlsDetector; -class slsDetector; -/** Qt Project Class Headers */ -class qDrawPlot; -/** Qt Include Header */ -#include -#include -/** - *@short sets up the advanced parameters - */ -class qTabAdvanced:public QWidget, private Ui::TabAdvancedObject{ - Q_OBJECT - -public: - /** \short The constructor - * @param parent is the parent tab widget - * @param detector is the detector returned from the detector tab - * @param plot plot object reference - */ - qTabAdvanced(QWidget *parent,multiSlsDetector*& detector, qDrawPlot*& plot); - - /** Destructor - */ - ~qTabAdvanced(); - -public slots: - /** To refresh and update widgets - */ - void Refresh(); - -private: - /** Sets up the widget - */ - void SetupWidgetWindow(); - - /** Sets up all the slots and signals - */ - void Initialization(); - - /** Add ROI Input - * @param num number of inputs to add - */ - void AddROIInput(int num); - - /** Checks for a few conditions before trimming - /returns OK or FAIL - */ - int validateBeforeTrimming(); - - /** update the setalltrimbits value from server - */ - void updateAllTrimbitsFromServer(); - - -private slots: - - /** Enable/Disable Energy and Calibration Logs - */ - void SetLogs(); - - /** Set acquisition time - */ - void SetExposureTime(); - - /** Set the Threshold dac value - */ - void SetThreshold(); - - /** Set output directory for trimming - */ - void SetOutputFile(); - - /** Browse output directory for trimming - */ - void BrowseOutputFile(); - - /** Enables trimming method and calls SetTrimmingMethod if enabled - * @param enable to enable trimming - */ - void EnableTrimming(bool enable); - - /** Enabling resolution and Counts if this is enabled - * @param enable to enable - */ - void SetOptimize(bool enable); - - /** Sets the trimming method - * @param mode trimming method - */ - void SetTrimmingMethod(int mode); - - /** Ensures the right trimming mode and Executes Trimming - */ - void StartTrimming(); - - /** Updates the plot with trimbits from detector/shared memory - */ - void UpdateTrimbitPlot(int id); - - /** Sets control port - * @param port control port - */ - void SetControlPort(int port); - - /** Sets stop port - * @param port stop port - */ - void SetStopPort(int port); - - /** Sets receiver tcp port - * @param port receiver tcp port - */ - void SetRxrTCPPort(int port); - - /** Sets receiver udp port - * @param port receiver udp port - */ - void SetRxrUDPPort(int port); - - /** Sets client zmq receiver port - * @param port client zmq receiver port - */ - void SetCltZmqPort(int port); - - /** Sets receiver zmq transmitting port - * @param port receiver zmq transmitting port - */ - void SetRxrZmqPort(int port); - - /** Sets receiver online - * @param index 1 for online and 0 for offline - */ - void SetReceiverOnline(int index); - - /** Sets detector online - * @param index 1 for online and 0 for offline - */ - void SetOnline(int index); - - /** Sets network parameters like receiver udp ip, - * receiver udp mac, detector ip and detector mac - */ - void SetNetworkParameters(); - - /** Sets client zmq ip to listen to - */ - void SetClientZMQIP(); - - /** Sets receiver zmq ip to stream from - */ - void SetReceiverZMQIP(); - - /** Sets the receiver. which also sets the receiver parameters - */ - void SetReceiver(); - - /** Add ROI Input if the value changed in the last slot - */ - void AddROIInputSlot(){AddROIInput(1);}; - - /** Clears all the ROI inputs - */ - void clearROI(); - - /** Gets ROIs from detector and updates it - */ - void updateROIList(); - - /** Sets ROI in detector - */ - void setROI(); - - /** Clears ROI in detector - */ - void clearROIinDetector(); - - /** Clears ROI in detector - */ - void SetDetector(int index); - - /** Set all trimbits to a value - */ - void SetAllTrimbits(); - - /** Set storage cells */ - void SetNumStoragecells(int value); - - /** Set sub frame exposure time */ - void SetSubExposureTime(); - - /** Set sub frame period */ - void SetSubPeriod(); - - -private: - /** The multi detector object */ - multiSlsDetector *myDet; - - /** The sls detector object */ - slsDetector *det; - - /** detector type */ - slsDetectorDefs::detectorType detType; - - /** The Plot widget */ - qDrawPlot *myPlot; - - QButtonGroup *btnGroup; - - /** Tool Tip for the output dir */ - QString outputDirTip; - QString errOutputTip; - QString errOnlineTip; - QString detOnlineTip; - QString rxrOnlineTip; - QPalette red; - - /** Trimming mode */ - slsDetectorDefs::trimMode trimmingMode; - static const int TRIMMING_DYNAMIC_RANGE = 32; - static const int TRIMMING_FRAME_NUMBER = 1; - static const int TRIMMING_TRIGGER_NUMBER = 1; - static const int TRIMMING_PROBE_NUMBER = 0; - - bool isEnergy; - bool isAngular; - - /** ROI */ - vector lblFromX; - vector spinFromX; - vector lblFromY; - vector spinFromY; - vector lblToX; - vector spinToX; - vector lblToY; - vector spinToY; - int numRois; - - /** sub period tool tip variables*/ - QString acqSubPeriodTip; - QString errSubPeriodTip; - - void CheckAcqPeriodGreaterThanExp(); - - -}; - - - -#endif /* QTABADVANCED_H_ */ diff --git a/slsDetectorGui/include/qTabDataOutput.h b/slsDetectorGui/include/qTabDataOutput.h deleted file mode 100644 index 9f0957cd8..000000000 --- a/slsDetectorGui/include/qTabDataOutput.h +++ /dev/null @@ -1,156 +0,0 @@ -/* - * qTabDataOutput.h - * - * Created on: May 10, 2012 - * Author: l_maliakal_d - */ - -#ifndef QTABDATAOUTPUT_H_ -#define QTABDATAOUTPUT_H_ - -#include "qDefs.h" - - -/** Form Header */ -#include "ui_form_tab_dataoutput.h" -/** Project Class Headers */ -class multiSlsDetector; -/** Qt Include Headers */ -#include - - -/** - *@short sets up the DataOutput parameters - */ -class qTabDataOutput:public QWidget, private Ui::TabDataOutputObject{ - Q_OBJECT - -public: - /** \short The constructor - * @param parent is the parent tab widget - * @param detector is the detector returned from the detector tab - */ - qTabDataOutput(QWidget *parent,multiSlsDetector*& detector); - - /** Destructor - */ - ~qTabDataOutput(); - - /** To refresh and update widgets - */ - void Refresh(); - - /** verify output directories - * /returns success or fail - */ - int VerifyOutputDirectory(); - -private: - /** The sls detector object */ - multiSlsDetector *myDet; - - /** detector type */ - slsDetectorDefs::detectorType detType; - - - QString flatFieldTip; - QString errFlatFieldTip; - QString outDirTip; - QPalette red; - QPalette black; - QPalette *red1; - QPalette *black1; - - /** enum for the Eiger clock divider */ - enum {FullSpeed, HalfSpeed, QuarterSpeed, SuperSlowSpeed, NumberofSpeeds}; - /** enum for the Eiger readout flags1 */ - enum {Continous, Storeinram}; - /** enum for the Eiger readout flags2 */ - enum {Parallel, NonParallel, Safe}; - - -/** methods */ - /** Sets up the widget */ - void SetupWidgetWindow(); - - /** Sets up all the slots and signals */ - void Initialization(); - - /** Populate the readouts - */ - void PopulateDetectors(); - - /** update speed */ - void UpdateSpeedFromServer(); - - /** update flags */ - void UpdateFlagsFromServer(); - - /** update flags */ - void SetupFileFormat(); - - /** update file format */ - void UpdateFileFormatFromServer(); - - /** update overwrite enable */ - void UpdateFileOverwriteFromServer(); - - -private slots: - -/** Open dialog to choose the output directory */ -void BrowseOutputDir(); - -/**set flat field file*/ -void SetFlatField(); - -/** update flat field correction from server */ -void UpdateFlatFieldFromServer(); - -/**browse flat field*/ -void BrowseFlatFieldPath(); - -/**rate correction*/ -void SetRateCorrection(int deadtime=0); - -/** default rate correction */ -void SetDefaultRateCorrection(); - -/** update rate correction from server */ -void UpdateRateCorrectionFromServer(); - -/**angular correction*/ -void SetAngularCorrection(); - -/**discard bad channels*/ -void DiscardBadChannels(); - -/** set output directory*/ -void SetOutputDir(); - -/** set output directory*/ -void GetOutputDir(); - -/** enable 10GbE */ -void EnableTenGigabitEthernet(bool enable, int get=0); - -/** set speed */ -void SetSpeed(); - -/** set flags */ -void SetFlags(); - -/** set file format */ -void SetFileFormat(int format); - -/** set overwrite enable */ -void SetOverwriteEnable(bool enable); - -signals: -/**signal to enable/disable positions in Actions*/ -void AngularConversionSignal(bool); -}; - - - -#endif /* QTABDATAOUTPUT_H_ */ diff --git a/slsDetectorGui/include/qTabDebugging.h b/slsDetectorGui/include/qTabDebugging.h deleted file mode 100644 index 484dfa87d..000000000 --- a/slsDetectorGui/include/qTabDebugging.h +++ /dev/null @@ -1,103 +0,0 @@ -/* - * qTabDebugging.h - * - * Created on: May 10, 2012 - * Author: l_maliakal_d - */ - -#ifndef QTABDEBUGGING_H_ -#define QTABDEBUGGING_H_ - -#include "qDefs.h" - - -/** Form Header */ -#include "ui_form_tab_debugging.h" -/** Project Class Headers */ -class multiSlsDetector; -class slsDetector; -/** Qt Include Headers */ -#include - - - -/** - *@short sets up the Debugging parameters - */ -class qTabDebugging:public QWidget, private Ui::TabDebuggingObject{ - Q_OBJECT - -public: - /** \short The constructor - * @param parent is the parent tab widget - * @param detector is the detector returned from the detector tab - */ - qTabDebugging(QWidget *parent,multiSlsDetector*& detector); - - /** Destructor - */ - ~qTabDebugging(); - - /** To refresh and update widgets - */ - void Refresh(); - -private: - /** Sets up the widget - */ - void SetupWidgetWindow(); - - /** Sets up all the slots and signals - */ - void Initialization(); - - - -private slots: - /** Updates the module list depending on current detector - */ - void UpdateModuleList(); - - /** Updates the status depending on current detector - */ - void UpdateStatus(); - - /** Gets id and versions etc - */ - void GetInfo(); - - /** Sets id and versions on the display widget - */ - void SetParameters(QTreeWidgetItem *item); - - /** Test detector and module - */ - void TestDetector(); - -private: - /** The multi sls detector object */ - multiSlsDetector *myDet; - - /** detector type */ - slsDetectorDefs::detectorType detType; - - /**sls detecctor object */ - slsDetector *det; - - /** Tree Widget displaying the detectors, modules */ - QTreeWidget *treeDet; - /** Widget displaying the serial numbers, mac addresses etc */ - QFrame *dispFrame; - QLabel *lblDetectorId; - QLabel *lblDetectorSerial; - QLabel *lblDetectorFirmware; - QLabel *lblDetectorSoftware; - QLabel *lblModuleId; - QLabel *lblModuleFirmware; - QLabel *lblModuleSerial; - QPalette *blue; -}; - - - -#endif /* QTABDEBUGGING_H_ */ diff --git a/slsDetectorGui/include/qTabDeveloper.h b/slsDetectorGui/include/qTabDeveloper.h deleted file mode 100644 index 10fc334aa..000000000 --- a/slsDetectorGui/include/qTabDeveloper.h +++ /dev/null @@ -1,158 +0,0 @@ -/* - * qTabDeveloper.h - * - * Created on: May 10, 2012 - * Author: l_maliakal_d - */ - -#ifndef QTABDEVELOPER_H_ -#define QTABDEVELOPER_H_ - -#include "qDefs.h" - -/** Project Class Headers */ -class multiSlsDetector; -/** Qt Include Headers */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -class qDetectorMain; - -/** C++ Include Headers */ -#include -#include -using namespace std; - - -/**To override the spin box class to have an id and emit it*/ -class MyDoubleSpinBox:public QDoubleSpinBox{ -Q_OBJECT -private: - int myId; - private slots: - void valueChangedWithID() {emit editingFinished(myId);}; - public: - /** Overridden constructor from QDoubleSpinBox */ - MyDoubleSpinBox(int id,QWidget* parent = 0) - :QDoubleSpinBox(parent),myId(id){ - //setParent(parent); - connect(this,SIGNAL(editingFinished()), - this,SLOT(valueChangedWithID())); - } - signals: - void editingFinished(int myId); -}; - - -/** - *@short sets up the Developer parameters - */ -class qTabDeveloper:public QWidget { - Q_OBJECT - -public: - /** \short The constructor - * @param parent is the parent tab widget - * @param detector is the detector returned from the detector tab - */ - qTabDeveloper(qDetectorMain *parent,multiSlsDetector*& detector); - - /** Destructor - */ - ~qTabDeveloper(); - - /** To stop ADC Timer when starting acquisition - */ - void StopADCTimer(){if(adcTimer) adcTimer->stop();}; - -private: - /** parent widget */ - qDetectorMain *thisParent; - /** The sls detector object */ - multiSlsDetector *myDet; - /** The sls detector object */ - slsDetector *det; - /** detector type */ - slsDetectorDefs::detectorType detType; - /**number of dac widgets*/ - static int NUM_DAC_WIDGETS; - /**number of adc widgets*/ - static int NUM_ADC_WIDGETS; - - static const int ADC_TIMEOUT = 5000; - - vectordacNames; - vectoradcNames; - - - /**widgets needed*/ - QGridLayout *layout; - QScrollArea *scroll; - QGroupBox *boxDacs; - QGroupBox *boxAdcs; - QLabel *lblDacs[20]; - QLabel *lblAdcs[20]; - MyDoubleSpinBox *spinDacs[20]; - QLabel *lblDacsmV[20]; - QLineEdit *spinAdcs[20]; - QLabel *lblHV; - QComboBox *comboHV; - QTimer *adcTimer; - QGridLayout *dacLayout; - QString tipHV; - QPalette red; - QComboBox *comboDetector; - /** Sets up the widget - */ - void SetupWidgetWindow(); - - /** Sets up all the slots and signals - */ - void Initialization(); - - /** Sets up the DAC Widgets - */ - void CreateDACWidgets(); - - /** Sets up the ADC Widgets - */ - void CreateADCWidgets(); - - /** Gets the sls index to set/get dac/adc - * @param index is the gui dac/adc index - * returns the sls index - */ - slsDetectorDefs::dacIndex getSLSIndex(int index); - -public slots: - - /** To refresh and update widgets - */ - void Refresh(); - -private slots: - /** Refreshes the adcs - */ - void RefreshAdcs(); - - /** Set Dac values - * @param id id of dac - */ - void SetDacValues(int id); - - /** Set High Voltage - */ - void SetHighVoltage(); -}; - - - -#endif /* QTABDEVELOPER_H_ */ diff --git a/slsDetectorGui/include/qTabMeasurement.h b/slsDetectorGui/include/qTabMeasurement.h deleted file mode 100644 index 362fba590..000000000 --- a/slsDetectorGui/include/qTabMeasurement.h +++ /dev/null @@ -1,207 +0,0 @@ -/* - * qTabMeasurement.h - * - * Created on: May 2, 2012 - * Author: l_maliakal_d - */ -#ifndef QTABMEASUREMENT -#define QTABMEASUREMENT - -#include "qDefs.h" - - -/** Form Header */ -#include "ui_form_tab_measurement.h" -/** Project Class Headers */ -class multiSlsDetector; -/** Qt Project Class Headers */ -#include -#include "qDrawPlot.h" -class qDetectorMain; - -/** - *@short sets up the measurement parameters - */ -class qTabMeasurement:public QWidget, private Ui::TabMeasurementObject{ - Q_OBJECT - -public: - /** \short The constructor - * This tab allows to change the detector settings, the threshold, the number of (non real time) measurements, - * the acquisition time, the file name, the start run index and shows the current progress of the measurement - * via a progress bar and labels inidicating the current position, scan variable, frame number etc. - * Contains the start and stop acquisition button - * @param parent is the parent tab widget - * @param detector is the detector returned from the detector tab - * @param plot plot object reference - */ - qTabMeasurement(qDetectorMain *parent,multiSlsDetector*& detector, qDrawPlot*& plot); - - /** Destructor - */ - ~qTabMeasurement(); - - /** To refresh and update widgets - */ - void Refresh(); - - /** To enable expert mode - * @param enable to enable if true - */ - void SetExpertMode(bool enable); - - /** Returns the status of the acquisition in gui - */ - bool GetStartStatus(){return (!btnStart->isEnabled());}; - - /** Click the Start/Stop Acquisition button - * This is used if this command came from gui client - */ - void ClickStartStop(){startAcquisition();myPlot->SetClientInitiated();}; - - /** Returns progress bar value */ - int GetProgress(){return progressBar->value();}; - - -public slots: - - /** update plot is finished, - * changes start/stop text and enables/disables all widgets - */ - void UpdateFinished(); - - /** updates the current measurement - * @param val the value to be updated - */ - void SetCurrentMeasurement(int val); - - - - -private: - /** Sets up the widget - */ - void SetupWidgetWindow(); - - /** Sets up the timing mode - */ - void SetupTimingMode(); - - /** Sets up all the slots and signals - */ - void Initialization(); - - /** Enables/Disables all the widgets - */ - void Enable(bool enable); - - /** Validates before enabling or disabling probes */ - void EnableProbes(); - - /** Get timing mode from detector - * @param startup is true when gui has just started up*/ - void GetModeFromDetector(bool startup = false); - - /** Checks if acquisition period is greater than exposure time - * and dsplays in red as a warning */ - void CheckAcqPeriodGreaterThanExp(); - - -private slots: - /** Sets the timing mode - * @ param mode cane be None, Auto, Gated, Trigger Exposure Series, - * Trigger Frame, Trigger Readout, External Trigger Window - */ - void SetTimingMode(int mode); - - /** Set number of measurements - * @param num number of measurements to be set */ - void setNumMeasurements(int num); - - /** Set file name - */ - void setFileName(); - - /** Set index of file name - * @param index index of selection - */ - void setRunIndex(int index); - - /** starts Acquisition - */ - void startAcquisition(); - - /** stops Acquisition - */ - void stopAcquisition(); - - /** Set number of frames - * @param val number of frames to be set - */ - void setNumFrames(int val); - - /** Set acquisition time - */ - void setExposureTime(); - - /** Set frame period between exposures - */ - void setAcquisitionPeriod(); - - /** Set number of triggers - * @param val number of triggers to be set - */ - void setNumTriggers(int val); - - /** Set delay - */ - void setDelay(); - - /** Set number of gates - * @param val number of gates to be set - */ - void setNumGates(int val); - - /** Set number of probes - * @param val number of probes to be set - */ - void setNumProbes(int val); - - /** Update progress*/ - void UpdateProgress(); - - /** Enable write to file */ - void EnableFileWrite(bool enable); - - -private: - /** parent widget */ - qDetectorMain *thisParent; - /** The sls detector object */ - multiSlsDetector *myDet; - /** The Plot widget */ - qDrawPlot *myPlot; - /** detector type */ - slsDetectorDefs::detectorType detType; - /** enum for the timing mode */ - enum{None, Auto, Trigger_Exp_Series, Trigger_Readout, Gated, Gated_Start, Burst_Trigger, NumTimingModes}; - /** timer to update the progress*/ - QTimer *progressTimer; - /** tool tip variables*/ - QString acqPeriodTip; - QString errPeriodTip; - QPalette red; - /** expert mode */ - bool expertMode; - /** to access items in settings combobox */ - QStandardItemModel* model; - -signals: - void StartSignal(); - void StopSignal(); - void CheckPlotIntervalSignal(); -}; - - - -#endif /* QTABMEASUREMENT */ diff --git a/slsDetectorGui/include/qTabMessages.h b/slsDetectorGui/include/qTabMessages.h deleted file mode 100644 index 8dd7f611b..000000000 --- a/slsDetectorGui/include/qTabMessages.h +++ /dev/null @@ -1,86 +0,0 @@ -/* - * qTabMessages.h - * - * Created on: Jun 26, 2012 - * Author: l_maliakal_d - */ - -#ifndef QTABMESSAGES_H_ -#define QTABMESSAGES_H_ - - -#include "qDefs.h" - - - -/** Project Class Headers */ -class qDetectorMain; -/** Qt Include Headers */ -#include -#include -#include -#include -#include "qDebugStream.h" - -/** - *@short sets up the Messages parameters - */ -class qTabMessages:public QWidget{ - Q_OBJECT - -public: - /** \short The constructor - * @param det the qDetectorMain class reference - */ - qTabMessages(qDetectorMain* m); - - /** Destructor - */ - ~qTabMessages(); - - -private: - /** The qDetectorMain object */ - qDetectorMain *myMainTab; - - /** Log of executed commands */ - QTextEdit *dispLog; - - /** To save the log to file */ - QPushButton *btnSave; - - /** To clear the log to file */ - QPushButton *btnClear; - - /** This class creates the log */ - qDebugStream *qout; - qDebugStream *qerr; - - string errMsg; - -/** methods */ - /** Sets up the widget */ - void SetupWidgetWindow(); - - /** Sets up all the slots and signals */ - void Initialization(); - -private slots: -/** Stream log to textedit in GUI */ -void customEvent(QEvent *e); - -/** Save Log to File*/ -void SaveLog(); - -/** Clear Log to File*/ -void ClearLog(); - - - -}; - - - - - -#endif /* QTABMESSAGES_H_ */ diff --git a/slsDetectorGui/include/qTabPlot.h b/slsDetectorGui/include/qTabPlot.h deleted file mode 100644 index b2dbbd208..000000000 --- a/slsDetectorGui/include/qTabPlot.h +++ /dev/null @@ -1,188 +0,0 @@ -/* - * qTabPlot.h - * - * Created on: May 10, 2012 - * Author: l_maliakal_d - */ - -#ifndef QTABPLOT_H_ -#define QTABPLOT_H_ - -#include "qDefs.h" - - -/** Form Header */ -#include "ui_form_tab_plot.h" -/** Project Class Headers */ -class multiSlsDetector; -/** Qt Project Class Headers */ -class qDrawPlot; -/** Qt Include Headers */ -#include -#include -#include - - -/** - *@short sets up the Plot parameters - */ -class qTabPlot:public QWidget, private Ui::TabPlotObject{ - Q_OBJECT - -public: - /** \short The constructor - * @param parent is the parent tab widget - * @param detector is the detector returned from the detector tab - * @param plot plot object reference - */ - qTabPlot(QWidget *parent,multiSlsDetector*& detector, qDrawPlot*& plot); - - /** Destructor - */ - ~qTabPlot(); - - /** Sets the scan argument of the plot - */ - void SetScanArgument(); - - /** To refresh and update widgets - */ - void Refresh(); - - -private: - /** The sls detector object */ - multiSlsDetector *myDet; - - /** The Plot widget */ - qDrawPlot *myPlot; - - - /** 1d/2d plot */ - bool isOneD; - bool isOriginallyOneD; - - /**is set if its a possible wrong interval between plots*/ - bool wrongInterval; - - QStackedLayout *stackedLayout; - QSpinBox *spinNthFrame; - QDoubleSpinBox *spinTimeGap; - QComboBox *comboTimeGapUnit; - QButtonGroup *btnGroupScan; - QButtonGroup *btnGroupPlotType; - QButtonGroup *btnGroupHistogram; - - /** some Default Values */ - static QString defaultPlotTitle; - static QString defaultHistXAxisTitle; - static QString defaultHistYAxisTitle; - static QString defaultImageXAxisTitle; - static QString defaultImageYAxisTitle; - static QString defaultImageZAxisTitle; - - /** scans */ - static const QString modeNames[5]; - - /** error palette*/ - QPalette *red; - QString intervalTip; - - - - - /** Sets up the widget - */ - void SetupWidgetWindow(); - - /** Sets up all the slots and signals - */ - void Initialization(); - - -public slots: - /** Set frequency between plots*/ - void SetFrequency(); - - /** Enable Scan box - */ - void EnableScanBox(); - - -private slots: - /** Selects the plot to display, enables/disables widgets - * @param b true to select plot dimension 1, else false to select 2D - */ - void Select1DPlot(bool b); - - /**Enables Persistency depending on Superimpose checkbox */ - void EnablePersistency(bool enable); - - /**Sets the titles in plot axis */ - void SetTitles(); - - /** Enables/Sets default Titles to default */ - void EnableTitles(); - - /** check aspect ratio */ - void checkAspectRatio(); - - /** maintain aspect ratio - * @param axis axis to be changed: 0 for x(y axis values changed), 1 for y (xaxis values changes), -1 for the larger one (aspect ratio checked) - */ - void maintainAspectRatio(int axis); - - /** Enables range of the X axis */ - void EnableXRange(); - - /** Enables range of the Y axis */ - void EnableYRange(); - - /** Enables range of all axes, called by EnableXRange and EnableYRange */ - void EnableRange(); - - /** Sets the range of the x axis */ - void SetXAxisRange(); - - /** Sets the range of the y axis */ - void SetYAxisRange(); - - /** Sets the range of both axes, called by SetXAxisRange and SetYAxisRange */ - void SetAxesRange(); - - /** Sets the range of the z axis */ - void SetZRange(); - - /** Enables the range of the z axis */ - void EnableZRange(); - - /** Return true if valid */ - bool CheckZRange(QString value); - - /** Set Plot to none, data graph, histogram*/ - void SetPlot(); - - /** Change pages in plot options box to the right*/ - void SetPlotOptionsRightPage(); - - /** Change pages in plot options box to the left*/ - void SetPlotOptionsLeftPage(); - - /** Plot binary plot */ - void SetBinary(); - - /** Set histogram options */ - void SetHistogramOptions(); - - /** Enable Gap pixels */ - void EnableGapPixels(bool enable); - -signals: - void DisableZoomSignal(bool); - void ResetZMinZMaxSignal(bool,bool,double,double); - -}; - - - -#endif /* QTABPLOT_H_ */ diff --git a/slsDetectorGui/include/qTabSettings.h b/slsDetectorGui/include/qTabSettings.h deleted file mode 100644 index ddb0d4da6..000000000 --- a/slsDetectorGui/include/qTabSettings.h +++ /dev/null @@ -1,116 +0,0 @@ -/* - * qTabSettings.h - * - * Created on: May 10, 2012 - * Author: l_maliakal_d - */ - -#ifndef QTABSETTINGS_H_ -#define QTABSETTINGS_H_ - -#include "qDefs.h" - - -/** Form Header */ -#include "ui_form_tab_settings.h" -/** Project Class Headers */ -class multiSlsDetector; -/** Qt Include Headers */ -#include - -/** - *@short sets up the Settings parameters - */ -class qTabSettings:public QWidget, private Ui::TabSettingsObject{ - Q_OBJECT - -public: - /** \short The constructor - * @param parent is the parent tab widget - * @param detector is the detector returned from the detector tab - */ - qTabSettings(QWidget *parent,multiSlsDetector*& detector); - - /** Destructor - */ - ~qTabSettings(); - - /** To refresh and update widgets - */ - void Refresh(); - - /** To enable expert mode - * @param enable to enable if true - */ - void SetExpertMode(bool enable){expertMode = enable;}; - - - - -private: - /** The sls detector object */ - multiSlsDetector *myDet; - - /** detector type */ - slsDetectorDefs::detectorType detType; - - /** expert mode */ - bool expertMode; - - enum{Standard,Fast,HighGain,DynamicGain,LowGain,MediumGain,VeryHighGain,LowNoise, - DynamicHG0,FixGain1,FixGain2,ForceSwitchG1,ForceSwitchG2, VeryLowGain, - Undefined,Uninitialized,NumSettings}; - - /** To be able to index items on a combo box */ - QStandardItemModel* model; - QModelIndex index[NumSettings]; - QStandardItem* item[NumSettings]; - - /** Sets up the widget - */ - void SetupWidgetWindow(); - - /** Sets up the detector settings - */ - void SetupDetectorSettings(); - - /** Sets up all the slots and signals - */ - void Initialization(); - - /** Gets the dynamic range and sets it on the gui - * @param setvalue the value set by the gui when used as a check - */ - void GetDynamicRange(int setvalue = -1); - - - -private slots: -/** Set settings according to selection - * @param index index of selection - */ -void setSettings(int index); - -/** Set number of modules if possible - * @param index number of modules - */ -void SetNumberOfModules(int index); - -/** Set dynamic range if possible - * @param index selection - */ -void SetDynamicRange(int index); - -/** Set threshold energy - */ -void SetEnergy(); - - -signals: -/**Update Trimbits after Set Settings */ -void UpdateTrimbitSignal(int); -}; - - - -#endif /* QTABSETTINGS_H_ */ diff --git a/slsDetectorGui/slsDetectorGui.pro b/slsDetectorGui/slsDetectorGui.pro deleted file mode 100644 index 753da18f6..000000000 --- a/slsDetectorGui/slsDetectorGui.pro +++ /dev/null @@ -1,162 +0,0 @@ -#When using yum for qt, comment out all lines with $(QTDIR) or $(QWTDIR), but export QWTDIR = /usr/include/qwt/ -#and leave "$(QWTDIR) \"uncommented in the INCLUDEPATH - -#When using epics, uncomment epics defines, libs and a line in INCLUDEPATH - - - -QT_INSTALL_PREFIX = $(QTDIR) -QMAKE_UIC = $(QTDIR)/bin/uic -QMAKE_MOC = $(QTDIR)/bin/moc -QMAKE_RCC = $(QTDIR)/bin/rcc -QMAKE_INCDIR_QT = $(QTDIR)/include/ -QMAKE_LIBS_QT = -L$(QTDIR)/lib -QMAKE_LIBS = -L$(QTDIR)/lib - - - - -#epics -#DEFINES += EPICS VERBOSE DACS_INT PRINT_LOG #VERYVERBOSE -#LIBS = -L$(QWTDIR)/lib -lqwt -L$(QWT3D)/lib -Wl,-R$(QWTDIR)/lib -L /usr/local/epics/base/lib/$(EPICS_HOST_ARCH)/ -Wl,-R/usr/local/epics/base/lib/$(EPICS_HOST_ARCH) -lca -lCom - -#default -DEFINES += VERBOSE DACS_INT PRINT_LOG #VERYVERBOSE CHECKINFERROR -LIBS = -L$(QWTDIR)/lib -lqwt -L$(QWT3D)/lib $(LDFLAGDET) - -CXXFLAGS += -g - - -QMAKE_CXXFLAGS_WARN_ON = -w -QMAKE_CFLAGS_WARN_ON = -w - - - - -DESTDIR ?= bin -MOC_DIR = mocs -OBJECTS_DIR = objs -UI_HEADERS_DIR = forms/include -SLSDETLIB ?= ../slsDetectorSoftware -RESOURCES += icons.qrc -CONFIG += debug no_include_pwd - - - -target.path += $(DESTDIR) -documentation.path = /$(DOCPATH) -documentation.files = docs/* -INSTALLS += target -INSTALLS += documentation -QMAKE_CLEAN += docs/*/* - - - -extralib.target = extra -extralib.commands = echo `tput setaf 6`; \ - echo 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'; \ - echo 'x Compiling slsDetectorGui x'; \ - echo 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'; \ - echo `./updateGitVersion.sh; tput sgr0` -extralib.depends = $(target) - -QMAKE_EXTRA_TARGETS += extralib -PRE_TARGETDEPS = extra - - - - -DEPENDPATH += \ - slsDetectorPlotting/include\ - include\ - forms/include - - -INCLUDEPATH += \ - $(QWTDIR)/include\ - $(QWTDIR) \ - $(QWTDIR)/src\ - $(QWT3D)/include\ - slsDetectorPlotting/include\ - ../slsReceiverSoftware/include\ - include\ - forms/include\ - /usr/include/qwt\ #these are not included for standard installations, also bin path should include qt4 bin, not qt3 bin - /usr/include/qt4\ - /usr/include/Qt\ - /usr/include/QtCore\ - /usr/include/QtGui\ - $(INCLUDES) - -#epics -# $(INCLUDES) /usr/local/epics/base/include/ -I /usr/local/epics/base/include/os/Linux/ - - - - - - -SOURCES = \ - slsDetectorPlotting/src/SlsQt1DPlot.cxx\ - slsDetectorPlotting/src/SlsQt1DZoomer.cxx\ - slsDetectorPlotting/src/SlsQt2DHist.cxx\ - slsDetectorPlotting/src/SlsQt2DPlot.cxx\ - slsDetectorPlotting/src/SlsQt2DPlotLayout.cxx\ - slsDetectorPlotting/src/SlsQtNumberEntry.cxx\ - src/qDetectorMain.cpp\ - src/qDrawPlot.cpp\ - src/qCloneWidget.cpp\ - src/qTabMeasurement.cpp\ - src/qTabDataOutput.cpp\ - src/qTabPlot.cpp\ - src/qTabActions.cpp\ - src/qActionsWidget.cpp\ - src/qScanWidget.cpp\ - src/qTabAdvanced.cpp\ - src/qTabSettings.cpp\ - src/qTabDebugging.cpp\ - src/qTabDeveloper.cpp\ - src/qTabMessages.cpp\ - src/qServer.cpp - -HEADERS = \ - slsDetectorPlotting/include/SlsQt1DPlot.h\ - slsDetectorPlotting/include/SlsQt1DZoomer.h\ - slsDetectorPlotting/include/SlsQt2DHist.h\ - slsDetectorPlotting/include/SlsQt2DPlot.h\ - slsDetectorPlotting/include/SlsQt2DPlotLayout.h\ - slsDetectorPlotting/include/SlsQt2DZoomer.h\ - slsDetectorPlotting/include/SlsQtValidators.h\ - slsDetectorPlotting/include/SlsQtNumberEntry.h\ - include/qDefs.h\ - include/qDebugStream.h\ - include/qDetectorMain.h\ - include/qDrawPlot.h\ - include/qCloneWidget.h\ - include/qTabMeasurement.h\ - include/qTabDataOutput.h\ - include/qTabPlot.h\ - include/qTabActions.h\ - include/qActionsWidget.h\ - include/qScanWidget.h\ - include/qTabAdvanced.h\ - include/qTabSettings.h\ - include/qTabDebugging.h\ - include/qTabDeveloper.h\ - include/qTabMessages.h\ - include/gitInfoGui.h\ - ../slsDetectorSoftware/commonFiles/sls_detector_defs.h\ - ../slsReceiverSoftware/include/sls_receiver_defs.h\ - include/qServer.h - - -FORMS = \ - forms/form_detectormain.ui\ - forms/form_tab_measurement.ui\ - forms/form_tab_dataoutput.ui\ - forms/form_tab_plot.ui\ - forms/form_tab_advanced.ui\ - forms/form_tab_settings.ui\ - forms/form_tab_debugging.ui\ - forms/form_action.ui\ - forms/form_scan.ui diff --git a/slsDetectorGui/slsDetectorPlotting/include/SlsQt1DPlot.h b/slsDetectorGui/slsDetectorPlotting/include/SlsQt1DPlot.h deleted file mode 100644 index 554a17fab..000000000 --- a/slsDetectorGui/slsDetectorPlotting/include/SlsQt1DPlot.h +++ /dev/null @@ -1,173 +0,0 @@ - -/** - * @author Ian Johnson - * @version 1.0 - * Modifications: - * 19.06.2012: {Some functions have been added by Dhanya to enable zooming in and out - * without using mouse control: - * DisableZoom, - * SetXMinMax,SetYMinMax, - * GetXMinimum,GetXMaximum,GetYMinimum,GetYMaximum} - * */ - -#ifndef SLSQT1DPLOT_H -#define SLSQT1DPLOT_H - -typedef double double32_t; -typedef float float32_t; -typedef int int32_t; -#include "ansi.h" - - -#include -#include -#include -#include -#include "SlsQt1DZoomer.h" -#include -using namespace std; - -class QPen; -class SlsQt1DPlot; - -class SlsQtH1D:public QwtPlotCurve{ - - public: - SlsQtH1D(QString title, int n, double xmin, double xmax, double* data=0); - SlsQtH1D(QString title, int n, double* data_x, double* data_y); - ~SlsQtH1D(); - - void Attach(SlsQt1DPlot* p); - void Detach(SlsQt1DPlot* p); - - int SetLineColor(int c=-1); - int SetLineWidth(int w=1); - void SetLineStyle(int s=0); - - void SetData(int n, double xmin, double xmax, double* d=0); - void SetData(int n, double* dx, double* dy); - - double* GetX() {return x;} - double* GetY() {return y;} - int GetNBinsX() {return ndata;} - - double FillBin(int bx, double v=1); - double Fill(double x, double v=1); - double SetBinContent(int bx,double v); - double SetContent(double x,double v); - int FindBinIndex(double px); - - double GetXMin() {return x[0];} - double GetFirstXgtZero() {return firstXgt0;} - double GetXMax() {return x[ndata-1];} - double GetYMin() {return ymin;} - double GetFirstYgtZero() {return firstYgt0;} - double GetYMax() {return ymax;} - - SlsQtH1D* Add(double v); - - - - private: - int ndata; - int n_array; - double dx; - double *x,*y; - double ymin,ymax; - double firstXgt0,firstYgt0; - - void Initailize(); - int SetUpArrays(int n); - int CheckIndex(int bx); - - QPen* pen_ptr; -}; - - -class SlsQtH1DList{ - public: - SlsQtH1DList(SlsQtH1D* hist=0); - ~SlsQtH1DList(); - - SlsQtH1D* Add(SlsQtH1D* h); - void Remove(SlsQtH1D* h); - void Print(); - - SlsQtH1D* Hist() {return the_hist;} //if no hist returns 0 - SlsQtH1DList* Next() {return the_next;} - - -private: - SlsQtH1DList* the_next; - SlsQtH1D* the_hist; -}; - - -class SlsQt1DPlot:public QwtPlot{ - Q_OBJECT - - public: - SlsQt1DPlot(QWidget* = NULL); - ~SlsQt1DPlot(); - - void SetTitle(const char *t); - void SetXTitle(const char* title); - void SetYTitle(const char* title); - - void InsertHLine(double y); - void RemoveHLine(); - void InsertVLine(double v); - void RemoveVLine(); - - - /** This group of functions have been added by Dhanya on 19.06.2012 to be able to - use zooming functionality without mouse control*/ - void DisableZoom(bool disableZoom); - void SetXMinMax(double min,double max){setAxisScale(QwtPlot::xBottom,min,max);}; - void SetYMinMax(double min,double max){setAxisScale(QwtPlot::yLeft,min,max);}; - double GetXMinimum(){return hist_list->Hist()->GetXMin();}; - double GetXMaximum(){return hist_list->Hist()->GetXMax();}; - double GetYMinimum(){return hist_list->Hist()->GetYMin();}; - double GetYMaximum(){return hist_list->Hist()->GetYMax();}; - /**---*/ - - - void SetZoom(double xmin,double ymin,double x_width,double y_width); - void SetZoomBase(double xmin,double ymin,double x_width, double y_width){ zoomer->SetZoomBase(xmin,ymin,x_width,y_width);} - - void alignScales(); - private: - - SlsQtH1DList* hist_list; - SlsQt1DZoomer* zoomer; - QwtPlotPanner* panner; - - QwtPlotMarker *hline; - QwtPlotMarker *vline; - - void SetupZoom(); - void UnknownStuff(); - //void alignScales(); - - void CalculateNResetZoomBase(); - void NewHistogramAttached(SlsQtH1D* h); - void HistogramDetached(SlsQtH1D* h); - - void SetLog(int axisId, bool yes); - - friend void SlsQtH1D::Attach(SlsQt1DPlot* p); - friend void SlsQtH1D::Detach(SlsQt1DPlot* p); - - - public slots: - void UnZoom(); - void Update(); - - void SetLogX(bool yes=1); - void SetLogY(bool yes=1); - - protected: - -}; - -#endif diff --git a/slsDetectorGui/slsDetectorPlotting/include/SlsQt1DZoomer.h b/slsDetectorGui/slsDetectorPlotting/include/SlsQt1DZoomer.h deleted file mode 100644 index 3bcb35ee7..000000000 --- a/slsDetectorGui/slsDetectorPlotting/include/SlsQt1DZoomer.h +++ /dev/null @@ -1,81 +0,0 @@ - -/** - * @author Ian Johnson - * @version 1.0 - */ - -#ifndef SLSQT1DZOOMER_H -#define SLSQT1DZOOMER_H - -#ifndef IAN -typedef double double32_t; -typedef float float32_t; -typedef int int32_t; -#endif - - -#include -#include -#include - -class SlsQtH1D; - -class SlsQt1DZoomer:public QwtPlotZoomer{ - private: - double x0,x1,y0,y1; - double firstXgt0,firstYgt0; - bool xIsLog,yIsLog; - - public: -#if QWT_VERSION < 0x060100 - SlsQt1DZoomer(QwtPlotCanvas *canvas):QwtPlotZoomer(canvas){ -#else - SlsQt1DZoomer(QWidget *canvas):QwtPlotZoomer(canvas){ -#endif - setTrackerMode(AlwaysOn); - xIsLog=yIsLog=0; - } - - double x() {return x0;} - double x_firstGreaterThan0() {return firstXgt0;} - double w() {return x1-x0;} - - double y() {return y0;} - double y_firstGreaterThan0() {return firstYgt0;} - double h() {return y1-y0;} - - void SetZoomBase(double xmin,double ymin,double x_width, double y_width); - void SetZoomBase(SlsQtH1D* h); - void ExtendZoomBase(SlsQtH1D* h); - void ResetZoomBase(); - - bool IsLogX(){ return xIsLog;} - bool IsLogY(){ return yIsLog;} - bool SetLogX(bool yes) { return xIsLog=yes;} - bool SetLogY(bool yes) { return yIsLog=yes;} - - -#if QWT_VERSION<0x060000 - virtual QwtText trackerText(const QwtDoublePoint &pos) const{ -#else - virtual QwtText trackerText(const QPointF &pos) const{ -#endif - QColor bg(Qt::white); - -#if QT_VERSION >= 0x040300 - bg.setAlpha(200); -#endif - -#if QWT_VERSION<0x060000 - QwtText text = QwtPlotZoomer::trackerText(pos); -#else - QPoint p=pos.toPoint(); - QwtText text = QwtPlotZoomer::trackerText(p); -#endif - text.setBackgroundBrush( QBrush( bg )); - return text; - } - -}; - -#endif diff --git a/slsDetectorGui/slsDetectorPlotting/include/SlsQt2DHist.h b/slsDetectorGui/slsDetectorPlotting/include/SlsQt2DHist.h deleted file mode 100644 index a71a32676..000000000 --- a/slsDetectorGui/slsDetectorPlotting/include/SlsQt2DHist.h +++ /dev/null @@ -1,145 +0,0 @@ - -/** - * @author Ian Johnson - * @version 1.0 - */ - - -#ifndef SLSQT2DHIST_H -#define SLSQT2DHIST_H - - -#ifndef IAN -typedef double double32_t; -typedef float float32_t; -typedef int int32_t; -#endif - - - -#if QT_VERSION >= 0x040000 -#include -#endif -#include -#include -#include -#include - - -class SlsQt2DHist: public QwtRasterData{ - - private: - - double x_min,x_max,y_min,y_max; - double x_width,y_width; - - int nx,ny,nb; - double *data; - double z_min,z_mean,z_max; - bool z_mean_has_been_calculated; - - int nx_array,ny_array; - - bool interp; - - static double value_between_points(double p1,double v1,double p2,double v2,double p){ //linear extrap - return (v2-v1)/(p2-p1)*(p-p1)+v1; - } - - public: - SlsQt2DHist(int nbinsx=10, double xmin=0, double xmax=10, int nbinsy=10, double ymin=0, double ymax=10, double* d=0,double zmin=0,double zmax=-1); - virtual ~SlsQt2DHist(); - - double GetXMin() {return x_min;} - double GetXMax() {return x_max;} - double GetXBinWidth() {return x_width;} - double GetYMin() {return y_min;} - double GetYMax() {return y_max;} - double GetYBinWidth() {return y_width;} - double GetMinimum() {return z_min;} - double GetMaximum() {return z_max;} - double GetMean(); - - int GetNBinsX(){return nx;} - int GetNBinsY(){return ny;} - double GetBinValue(int bx,int by); - int GetBinIndex(int bx,int by); - double* GetDataPtr(){return data;} - - void Interpolate(bool on=1) {interp=on;} - void SetBinValue(int bx,int by,double v); - void SetData(int nbinsx, double xmin, double xmax, int nbinsy,double ymin, double ymax,double *d,double zmin=0, double zmax=-1); - - double SetMinimumToFirstGreaterThanZero(); - void SetMinimum(double zmin) {z_min=zmin;} - void SetMaximum(double zmax) {z_max=zmax;} - void SetMinMax(double zmin=0,double zmax=-1); - - int FindBinIndex(double x, double y); - - - - virtual QwtRasterData *copy() const{ - //this function does not create a new SlsQt2DHistData instance, - //just passes a pointer so that data is common to both the copy and the original instance - return (QwtRasterData*) this; - } - -#if QWT_VERSION<0x060000 - virtual QwtDoubleInterval range() const{ return QwtDoubleInterval(z_min,z_max);} -#else - virtual QwtInterval range() const{ return QwtInterval(z_min,z_max);} - virtual QwtInterval interval(Qt::Axis axis) const { - switch (axis){ - case Qt::ZAxis: - return QwtInterval(z_min,z_max); - case Qt::XAxis: - return QwtInterval(x_min,x_max); - case Qt::YAxis: - return QwtInterval(y_min,y_max); - default: - return QwtInterval(z_min,z_max); - }; - }; -#endif - - - - virtual double value(double x, double y) const{ - //if(!interp){ //default is box like plot - int index = int((x-x_min)/x_width) + int((y-y_min)/y_width)*nx; - if(index<0||index>nb) index = nb; - if(!interp) return data[index]; - //} - - - int x_int = int((x-x_min)/x_width-0.5); - if(x_int<0) x_int = 0; else if(x_int>nx-2) x_int = nx-2; - int y_int = int((y-y_min)/y_width-0.5); - if(y_int<0) y_int = 0; else if(y_int>ny-2) y_int = ny-2; - - int b00 = x_int*ny + y_int; - int b01 = x_int*ny + y_int+1; - int b10 = (x_int+1)*ny + y_int; - int b11 = (x_int+1)*ny + y_int+1; - - //vertical extrap - double y0 = y_min+(y_int+0.5)*y_width; - double y1 = y_min+(y_int+1.5)*y_width; - double left_v = value_between_points(y0,data[b00],y1,data[b01],y); - double right_v = value_between_points(y0,data[b10],y1,data[b11],y); - //horazontal extrap - - - - return 0.5; - - - return value_between_points(x_min+(x_int+0.5)*x_width,left_v, - x_min+(x_int+1.5)*x_width,right_v,x); - } - -}; - - -#endif diff --git a/slsDetectorGui/slsDetectorPlotting/include/SlsQt2DPlot.h b/slsDetectorGui/slsDetectorPlotting/include/SlsQt2DPlot.h deleted file mode 100644 index 8b1944392..000000000 --- a/slsDetectorGui/slsDetectorPlotting/include/SlsQt2DPlot.h +++ /dev/null @@ -1,118 +0,0 @@ - -/** - * @author Ian Johnson - * @version 1.0 - * Modifications: - * 19.06.2012: {Some functions have been added by Dhanya to enable zooming in and out - * without using mouse control: - * DisableZoom, - * SetXMinMax,SetYMinMax, - * GetXMinimum,GetXMaximum,GetYMinimum,GetYMaximum} - */ - - -#ifndef SLSQT2DPLOT_H -#define SLSQT2DPLOT_H - -#ifndef IAN -typedef double double32_t; -typedef float float32_t; -typedef int int32_t; -#endif - - - -#include -#include -#include - -#include "SlsQt2DZoomer.h" -#include "SlsQt2DHist.h" - - -class QwtPlotPanner; -class QwtScaleWidget; -class QwtLinearColorMap; - - -class SlsQt2DPlot: public QwtPlot{ - Q_OBJECT - -private: - QwtPlotSpectrogram *d_spectrogram; - SlsQt2DHist* hist; - SlsQt2DZoomer* zoomer; - QwtPlotPanner* panner; - QwtScaleWidget *rightAxis; - - QwtLinearColorMap* colorMapLinearScale; - QwtLinearColorMap* colorMapLogScale; -#if QWT_VERSION<0x060000 - QwtValueList* contourLevelsLinear; - QwtValueList* contourLevelsLog; -#else - QList contourLevelsLinear; - QList contourLevelsLog; -#endif - - void SetupZoom(); - void SetupColorMap(); - - QwtLinearColorMap* myColourMap(QVector colourStops); - QwtLinearColorMap* myColourMap(int log=0); - - int isLog; - - -public: - SlsQt2DPlot(QWidget * = NULL); - - // SlsQt2DHist *GetHistogram(){ return hist; } - void UnZoom(bool replot=true); - void SetZoom(double xmin,double ymin,double x_width,double y_width); - - - /** This group of functions have been added by Dhanya on 19.06.2012 to be able to - use zooming functionality without mouse control*/ - void DisableZoom(bool disableZoom); - void SetXMinMax(double min,double max){setAxisScale(QwtPlot::xBottom,min,max);}; - void SetYMinMax(double min,double max){setAxisScale(QwtPlot::yLeft,min,max);}; - double GetXMinimum(){return hist->GetXMin();}; - double GetXMaximum(){return hist->GetXMax();}; - double GetYMinimum(){return hist->GetYMin();}; - double GetYMaximum(){return hist->GetYMax();}; - /**---*/ - - - double GetZMinimum(){ return hist->GetMinimum();} - double GetZMaximum(){ return hist->GetMaximum();} - void SetZMinMax(double zmin=0,double zmax=-1); - void SetZMinimumToFirstGreaterThanZero(){hist->SetMinimumToFirstGreaterThanZero();} - double GetZMean() { return hist->GetMean();} - - void SetData(int nbinsx, double xmin, double xmax, int nbinsy,double ymin, double ymax,double *d,double zmin=0, double zmax=-1){ - hist->SetData(nbinsx,xmin,xmax,nbinsy,ymin,ymax,d,zmin,zmax); - } - - - - double* GetDataPtr() {return hist->GetDataPtr();} - int GetBinIndex(int bx,int by) {return hist->GetBinIndex(bx,by);} - int FindBinIndex(double x,double y) {return hist->FindBinIndex(x,y);} - void SetBinValue(int bx,int by,double v) { hist->SetBinValue(bx,by,v);} - double GetBinValue(int bx,int by) {return hist->GetBinValue(bx,by);} - - - void FillTestPlot(int i=0); - void Update(); - -public slots: - void LogZ(bool on=1); - void InterpolatedPlot(bool on); - void showContour(bool on); - void showSpectrogram(bool on); - // void printPlot(); - -}; - -#endif diff --git a/slsDetectorGui/slsDetectorPlotting/include/SlsQt2DPlotLayout.h b/slsDetectorGui/slsDetectorPlotting/include/SlsQt2DPlotLayout.h deleted file mode 100644 index 2d2315f77..000000000 --- a/slsDetectorGui/slsDetectorPlotting/include/SlsQt2DPlotLayout.h +++ /dev/null @@ -1,82 +0,0 @@ -/** - * @author Ian Johnson - * @version 1.0 - * @comments - * 19.06.2012 All modifications with the Ian flag has been made since - * z_range_ne and the buttons are defined in another class. - * Logz button and z_range_ne have wrappers to connect them - * 05.05.2013 Added ResetZMinZMax - */ - - -#ifndef SLSQT2DPLOTLAYOUT_H -#define SLSQT2DPLOTLAYOUT_H - -#ifndef IAN -typedef double double32_t; -typedef float float32_t; -typedef int int32_t; -#endif - - -#include -#include - -#include "SlsQtNumberEntry.h" -#include "SlsQt2DPlot.h" - -class QGridLayout; -class QString; -class QToolButton; - - -class SlsQt2DPlotLayout: public QGroupBox{ - Q_OBJECT - -public: - - SlsQt2DPlotLayout(QWidget * = NULL); - ~SlsQt2DPlotLayout(); - - SlsQt2DPlot* GetPlot(){return the_plot;} - void SetXTitle(QString st); - void SetYTitle(QString st); - void SetZTitle(QString st); - void UpdateNKeepSetRangeIfSet(); - - -private: - QGridLayout* the_layout; - QToolButton* btnInterpolate; - QToolButton* btnContour; - QToolButton* btnLogz; - SlsQt2DPlot* the_plot; - SlsQtNumberEntry* z_range_ne; - -#ifndef IAN - bool zRangeChecked; -#endif - - void CreateTheButtons(); - void ConnectSignalsAndSlots(); - void Layout(); - -public slots: -void SetZScaleToLog(bool yes); -void ResetRange(); - -#ifndef IAN -void SetZRange(double,double); -void EnableZRange(bool enable); -void ResetZMinZMax(bool zmin, bool zmax, double min, double max); - -#endif - -signals: -void InterpolateSignal(bool); -void ContourSignal(bool); - -}; - -#endif - diff --git a/slsDetectorGui/slsDetectorPlotting/include/SlsQt2DZoomer.h b/slsDetectorGui/slsDetectorPlotting/include/SlsQt2DZoomer.h deleted file mode 100644 index 5fed37f1a..000000000 --- a/slsDetectorGui/slsDetectorPlotting/include/SlsQt2DZoomer.h +++ /dev/null @@ -1,78 +0,0 @@ - -/** - * @author Ian Johnson - * @version 1.0 - * Dhanya-05.12.2012- included an additional header - */ - - -#ifndef SLSQT2DZOOMER_H -#define SLSQT2DZOOMER_H - -#ifndef IAN -typedef double double32_t; -typedef float float32_t; -typedef int int32_t; -#endif - - -/**included by Dhanya on 05.12.2012 to avoid compile time errors with the latest gcc*/ -#include -/**end of Change by Dhanya*/ - -#include -#include - -#include "SlsQt2DHist.h" - -class SlsQt2DZoomer:public QwtPlotZoomer{ - private: - SlsQt2DHist* hist; - - public: -#if QWT_VERSION < 0x060100 - SlsQt2DZoomer(QwtPlotCanvas *canvas):QwtPlotZoomer(canvas){ -#else - SlsQt2DZoomer(QWidget *canvas):QwtPlotZoomer(canvas){ -#endif - setTrackerMode(AlwaysOn); - } - - void SetHist(SlsQt2DHist* h){ - hist=h; - } - - -#if QWT_VERSION<0x060000 - virtual QwtText trackerText(const QwtDoublePoint &pos) const{ -#else - virtual QwtText trackerTextF(const QPointF &pos) const{ -#endif - QColor bg(Qt::white); -#if QT_VERSION >= 0x040300 - bg.setAlpha(200); -#endif - - - //QwtText text = QwtPlotZoomer::trackerText(pos); - - static QwtText text; - if(hist){ - static char t[200]; - sprintf(t,"%3.2f, %3.2f, %3.2f",pos.x(),pos.y(),hist->value(pos.x(),pos.y())); - text.setText(t); - }else { -#if QWT_VERSION<0x060000 - QwtText text = QwtPlotZoomer::trackerText(pos); -#else - QPoint p=pos.toPoint(); - QwtText text = QwtPlotZoomer::trackerText(p); -#endif - - } - text.setBackgroundBrush( QBrush( bg )); - return text; - } -}; - -#endif diff --git a/slsDetectorGui/slsDetectorPlotting/include/SlsQtNumberEntry.h b/slsDetectorGui/slsDetectorPlotting/include/SlsQtNumberEntry.h deleted file mode 100644 index dbeb0a31e..000000000 --- a/slsDetectorGui/slsDetectorPlotting/include/SlsQtNumberEntry.h +++ /dev/null @@ -1,147 +0,0 @@ - -/** - * @author Ian Johnson - * @version 1.0 - */ - -#ifndef SLSQTNUMBERENTRY_H -#define SLSQTNUMBERENTRY_H - -#ifndef IAN -typedef double double32_t; -typedef float float32_t; -typedef int int32_t; -#endif - - -#include -#include - -class QGridLayout; - -class QLabel; -class QLineEdit; -class QIntValidator; -class QDoubleValidator; -class QCheckBox; -class QComboBox; -class QSpinBox; - -#include "SlsQtValidators.h" - -class SlsQtNumberEntry:public QWidget{ - Q_OBJECT - - public: - //type=0->units only, type=1->int,type=2->double, type=3->spinbox - //adding middle text will automatically add a second number field - SlsQtNumberEntry(QWidget *parent,int with_checkbox=0, char *start_string=0, int num_type=0, char *middle_string=0, int num2_type=0, int n_units=0, char** units=0, double* unit_factors=0, char* end_string=0); - //without unit box - SlsQtNumberEntry(QWidget *parent,int with_checkbox, char *start_strin, int num_type, char *middle_string, int num2_type, char* end_string); - - - ~SlsQtNumberEntry(); - - void Enable(bool en_flag=1); - void Disable(); - void EnableNumberField(int which_number_field,bool en_flag=1); //which_number_field is 0 or 1 - void DisableNumberField(int which_number_field); - - void AddCheckBox(); - void SetFrontText(char* s); - void SetMiddleText(char* s); - void SetBackText(char* s); - void SetupNumberField(int type,int which_number_field=0); - void SetUnits(int n_units,char** units,double* unit_factors); - - void SetMinimumNumberWidth(int nchar_width,int which_number_field=0); - void SetNDecimalsOfDoubleValidators(int ndecimals); - void SetNDecimalsOfDoubleValidator(int ndecimals,int which_number_field=0); - void SetMinimumUnitWidth(int nchar_width); - - bool Enabled(); - bool CheckBoxState(); - bool IsValueOk(int which_number_field=0); - - const char* GetFrontText(); - const char* GetMiddleText(); - const char* GetBackText(); - - int GetNumberInt(int which_number_field=0,bool* ok=0); - double GetNumber(int which_number_field=0,bool *ok=0); - - int GetValueInt(int which_number_field=0,bool* ok=0); - double GetValue(int which_number_field=0,bool *ok=0); - - int GetComboBoxIndex(); - double GetComboBoxValue(); - - private: - void SetupNumberEntry(int with_checkbox=0, char *start_string=0, int num_type=0, char *middle_string=0, int num2_type=0, int n_units=0, char** units=0, double* unit_factors=0, char* end_string=0); - - QGridLayout* layout; //default layout - - QCheckBox* check_box; - QLabel* front_text; - QLabel* middle_text; - QLineEdit* num_field[2]; - QSpinBox* spin_box[2]; - bool num_field_enabled[2]; - - SlsQtIntValidator* validator_int[2]; - SlsQtDoubleValidator* validator_double[2]; - QComboBox* unit_cbb; - double* factors; - QLabel* back_text; - - void SetText(char* s, QLabel** pp); - void SetLayout(); - - - public slots: - void FirstValueEntered(); - void SecondValueEntered(); - void UnitSelected(); - - void SetRange(int min, int max, int which_number_field=0); - void SetRange(double min, double max, int which_number_field=0); - void SetFirstRange(int min, int max) {SetRange(min,max,0);} - void SetSecondRange(int min, int max) {SetRange(min,max,1);} - - double SetValue(double v, int which_number_field=0); - void SetFirstValue(int v) {SetValue(v,0);} - void SetSecondValue(int v) {SetValue(v,1);} - void SetFirstValue(double v) {SetValue(v,0);} - void SetSecondValue(double v) {SetValue(v,1);} - - // double SetNumber(int v, int which_number_field=0); - double SetNumber(double v, int which_number_field=0); - void SetFirstNumber(int v) {SetNumber(v,0);} - void SetSecondNumber(int v) {SetNumber(v,1);} - void SetFirstNumber(double v) {SetNumber(v,0);} - void SetSecondNumber(double v) {SetNumber(v,1);} - - int SetComboBoxIndex(int index); - - void CheckBoxClicked(); - void PrintTheValue(); - - void RefreshFirstNumberEntry(); - void RefreshSecondNumberEntry(); - void RefreshNumberEntery(int number_field=0); - - signals: - void CheckBoxChanged(bool state); - void CheckBoxChanged(SlsQtNumberEntry* ptr); - void AValueChanged(SlsQtNumberEntry* ptr); - void FirstValueChanged(int value); - void FirstValueChanged(double value); - void FirstValueChanged(SlsQtNumberEntry* ptr); - void SecondValueChanged(int value); - void SecondValueChanged(double value); - void SecondValueChanged(SlsQtNumberEntry* ptr); - void UnitChanged(double); - void UnitChanged(SlsQtNumberEntry* ptr); -}; - -#endif diff --git a/slsDetectorGui/slsDetectorPlotting/include/SlsQtValidators.h b/slsDetectorGui/slsDetectorPlotting/include/SlsQtValidators.h deleted file mode 100644 index bd2d70efd..000000000 --- a/slsDetectorGui/slsDetectorPlotting/include/SlsQtValidators.h +++ /dev/null @@ -1,79 +0,0 @@ - -/** - * @author Ian Johnson - * @version 1.0 - */ - -#ifndef SLSQTVALIDATORS_H -#define SLSQTVALIDATORS_H - -#ifndef IAN -typedef double double32_t; -typedef float float32_t; -typedef int int32_t; -#endif - -#include -#include - -#include -#include - -using std::cout; -using std::endl; - -class SlsQtIntValidator:public QIntValidator{ - - public: - SlsQtIntValidator(QWidget *parent):QIntValidator(parent){} - - virtual void fixup (QString& text) const { - bool ok = 1; - int v = text.toInt(&ok); - - if(!ok){ - v = text.toDouble(&ok); - if(ok) text = QString::number(v); - else text = QString::number(0); - fixup(text); - } - - if(vtop()) text = QString::number(top()); - } - -}; - -class SlsQtDoubleValidator:public QDoubleValidator{ - - public: - SlsQtDoubleValidator(QWidget *parent):QDoubleValidator(parent){} - - virtual void fixup (QString& text) const { - - bool ok = 1; - double v = text.toDouble(&ok); - - if(!ok){ - text = QString::number(0); - fixup(text); - } - - int nd = this->decimals(); //ndigest behind zero - if(vtop()){ - v = floor(top()*pow(10,nd))/pow(10,nd); - text = QString::number(v,'g'); - }else{ - v = round(v*pow(10,nd))/pow(10,nd); - text = QString::number(v,'g'); - } - } - } - -}; - -#endif diff --git a/slsDetectorGui/slsDetectorPlotting/src/SlsQt1DPlot.cxx b/slsDetectorGui/slsDetectorPlotting/src/SlsQt1DPlot.cxx deleted file mode 100644 index 1382e0e50..000000000 --- a/slsDetectorGui/slsDetectorPlotting/src/SlsQt1DPlot.cxx +++ /dev/null @@ -1,517 +0,0 @@ - -/** - * @author Ian Johnson - * @version 1.0 - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "SlsQt1DPlot.h" - -#if QWT_VERSION >= 0x060100 -#define QwtLog10ScaleEngine QwtLogScaleEngine -#endif - -using namespace std; - -SlsQtH1D::SlsQtH1D(QString title,int n, double min, double max, double* data):QwtPlotCurve(title){ - Initailize(); - SetData(n,min,max,data); -} - -SlsQtH1D::SlsQtH1D(QString title,int n, double* data_x, double* data_y):QwtPlotCurve(title){ - Initailize(); - SetData(n,data_x,data_y); -} - -void SlsQtH1D::Initailize(){ - ndata=n_array=0; - x=y=0; - pen_ptr = new QPen(); - SetLineColor(); -} - -SlsQtH1D::~SlsQtH1D(){delete x;delete y;delete pen_ptr;} - -void SlsQtH1D::Attach(SlsQt1DPlot* p){ - attach((QwtPlot*) p); - p->NewHistogramAttached(this); -} - -void SlsQtH1D::Detach(SlsQt1DPlot* p){ - detach(); - p->HistogramDetached(this); -} - - -int SlsQtH1D::SetLineColor(int c){ - static int last_color = 1; - if(c<0) c=(last_color+1)%3; - - switch(c){ - case 0: pen_ptr->setColor(Qt::black); break; - case 1: pen_ptr->setColor(Qt::red); break; - case 2: pen_ptr->setColor(Qt::blue); break; - case 3: pen_ptr->setColor(Qt::green); break; - case 4: pen_ptr->setColor(Qt::magenta); break; - case 5: pen_ptr->setColor(Qt::cyan); break; - case 6: pen_ptr->setColor(Qt::darkYellow); break; - case 7: pen_ptr->setColor(Qt::gray); break; - case 8: pen_ptr->setColor(Qt::darkBlue); break; - case 9: pen_ptr->setColor(Qt::darkGreen); break; - case 10: pen_ptr->setColor(Qt::darkMagenta); break; - } -/* if(c==0) pen_ptr->setColor(Qt::black); - else if(c==1) pen_ptr->setColor(Qt::red); - else pen_ptr->setColor(Qt::blue);*/ - - setPen(*pen_ptr); - - return last_color=c; -} - -int SlsQtH1D::SetLineWidth(int w){ - pen_ptr->setWidth(w); - setPen(*pen_ptr); - return w; -} - -void SlsQtH1D::SetLineStyle(int s){ - if(s==1) pen_ptr->setStyle(Qt::DashLine); - else if(s==2) pen_ptr->setStyle(Qt::DotLine); - else if(s==3) pen_ptr->setStyle(Qt::DashDotLine); - else if(s==4) pen_ptr->setStyle(Qt::DashDotDotLine); - else if(s==5) pen_ptr->setStyle(Qt::CustomDashLine); - else pen_ptr->setStyle(Qt::SolidLine); - setPen(*pen_ptr); -} - - -void SlsQtH1D::SetData(int n, double xmin, double xmax, double *data){ - n = SetUpArrays(n); - - ndata=n; - if(xmin>xmax){ - double t=xmin; - xmin=xmax; - xmax=t; - } - - dx = (xmax-xmin)/n; - ymin=ymax= data ? data[0]:0; - firstXgt0=-1; - firstYgt0=-1; - - for(int i=0;iy[i]) ymin = y[i]; - if(data&&ymax0&&(firstXgt0<0||firstXgt0>x[i])) firstXgt0=x[i]; - if(y[i]>0&&(firstYgt0<0||firstYgt0>y[i])) firstYgt0=y[i]; - } - - // cout<0&&data_x[0]>data_x[n-1]) ? 1:0; - n = SetUpArrays(n); - - ndata=n; - dx=-1; //signifies not regular intervals - - ymin=ymax= data_y ? data_y[0]:0; - - firstXgt0=-1; - firstYgt0=-1; - - for(int i=0;iy[b]) ymin = y[b]; - if(data_y&&ymax0&&(firstXgt0<0||firstXgt0>x[b])) firstXgt0=x[b]; - if(y[b]>0&&(firstYgt0<0||firstYgt0>y[b])) firstYgt0=y[b]; - } - -#if QWT_VERSION<0x060000 - setRawData(x,y,ndata); -#else - setRawSamples(x,y,ndata); -#endif -} - -int SlsQtH1D::SetUpArrays(int n){ - n = n<1 ? 1 : n; //overflow bin - - if(n+1>n_array){ - n_array = n+1; - if(x) delete x; - if(y) delete y; - x = new double [n_array]; - y = new double [n_array]; - } - - return n; -} - -double SlsQtH1D::FillBin(int bx, double v) { - bx = CheckIndex(bx); - return SetBinContent(bx,y[bx]+v); -} -double SlsQtH1D::Fill(double x, double v){return FillBin(FindBinIndex(x),v);} - -double SlsQtH1D::SetBinContent(int bx,double v){ - bx = CheckIndex(bx); - y[bx]=v; - if(bx0&&(firstYgt0<=0||y[bx]ymax) ymax = y[bx]; - } - return y[bx]; -} - -double SlsQtH1D::SetContent(double x,double v) {return SetBinContent(FindBinIndex(x),v); } - -int SlsQtH1D::FindBinIndex(double px){ - if(dx>0) CheckIndex(int((px-x[0])/dx)); - - //find closest bin - int b=0; for(;bpx) break; - - if(b==0) return 0; - else if(fabs(px-x[b-1])ndata) ? ndata : bx;}//ndata is the overflow bin - -SlsQtH1D* SlsQtH1D::Add(double v){ for(int bx=0;bxthe_hist) return hist; //already added - if(!hl->the_next) break; - hl=hl->the_next; - } - if(hl->the_hist) hl->the_next = new SlsQtH1DList(hist); - else hl->the_hist = hist; - - // Print(); - - return hist; -} - -void SlsQtH1DList::Print(){ - // cout<<"Printing List"<the_hist<<" "<the_next<the_next; - if(i>10) break; - } -} - -void SlsQtH1DList::Remove(SlsQtH1D* hist){ - // cout<<"Removing: "<the_hist!=hist) hl = hl->the_next; - else{ //match - if(!hl->the_next) hl->the_hist=0; // first the_hist is zero when there's no next - else{ - SlsQtH1DList* t = hl->the_next; - hl->the_hist = t->the_hist; - hl->the_next = t->the_next; - t->the_next = 0; - delete t; - } - } - } - // Print(); -} - - - -//1d plot stuff -SlsQt1DPlot::SlsQt1DPlot(QWidget *parent):QwtPlot(parent){ - // n_histograms_attached=0; - hline=vline=0; - hist_list = new SlsQtH1DList(); - - UnknownStuff(); - alignScales(); - SetupZoom(); - - // Assign a title -#ifndef IAN - insertLegend(new QwtLegend(), QwtPlot::BottomLegend); -#else - insertLegend(new QwtLegend(), QwtPlot::RightLegend); -#endif - - axisScaleEngine(QwtPlot::yLeft)->setAttribute(QwtScaleEngine::Floating); - axisScaleEngine(QwtPlot::xBottom)->setAttribute(QwtScaleEngine::Floating); -} - -SlsQt1DPlot::~SlsQt1DPlot(){ - delete hist_list; - - if(hline) delete hline; - if(vline) delete vline; -} - -void SlsQt1DPlot::CalculateNResetZoomBase(){ - if(hist_list->Hist()) zoomer->SetZoomBase(hist_list->Hist()); - SlsQtH1DList* hl = hist_list->Next(); - while(hl){ - if(hl->Hist()) zoomer->ExtendZoomBase(hl->Hist()); - hl=hl->Next(); - } -} - -void SlsQt1DPlot::NewHistogramAttached(SlsQtH1D* h){ - hist_list->Add(h); - CalculateNResetZoomBase(); - //commented out by dhanya to take off zooming every hist in 1d plots - //if(!hist_list->Next()) UnZoom(); - Update(); -} - -void SlsQt1DPlot::HistogramDetached(SlsQtH1D* h){ - hist_list->Remove(h); - CalculateNResetZoomBase(); - Update(); -} - -void SlsQt1DPlot::Update(){ - replot(); -} - -void SlsQt1DPlot::SetTitle(const char* title){ - setTitle(title); -} - -void SlsQt1DPlot::SetXTitle(const char* title){ - QwtText t(title); - t.setFont(QFont("Sans Serif",11,QFont::Normal)); - setAxisTitle(QwtPlot::xBottom,t); -} -void SlsQt1DPlot::SetYTitle(const char* title){ - QwtText t(title); - t.setFont(QFont("Sans Serif",11,QFont::Normal)); - setAxisTitle(QwtPlot::yLeft,t); -} - -void SlsQt1DPlot::SetLogX(bool yes){ SetLog(QwtPlot::xBottom,yes);} -void SlsQt1DPlot::SetLogY(bool yes){ SetLog(QwtPlot::yLeft,yes);} -void SlsQt1DPlot::SetLog(int axisId, bool yes){ - if(axisId==QwtPlot::xBottom) zoomer->SetLogX(yes); - if(axisId==QwtPlot::yLeft) zoomer->SetLogY(yes); - - zoomer->ResetZoomBase(); //needs to be done before setting Engine - - //the old ones are deleted by in the setAxisScaleFunction() function see: 128 of file qwt_plot_axis.cpp - if(yes) setAxisScaleEngine(axisId,new QwtLog10ScaleEngine()); - else setAxisScaleEngine(axisId,new QwtLinearScaleEngine()); - - axisScaleEngine(QwtPlot::yLeft)->setAttribute(QwtScaleEngine::Floating); - axisScaleEngine(QwtPlot::xBottom)->setAttribute(QwtScaleEngine::Floating); - - Update(); -} - -void SlsQt1DPlot::UnZoom(){ - setAxisScale(QwtPlot::xBottom,zoomer->x(),zoomer->x()+zoomer->w()); - setAxisScale(QwtPlot::yLeft,zoomer->y(),zoomer->y()+zoomer->h()); - - zoomer->setZoomBase();//Call replot for the attached plot before initializing the zoomer with its scales. - Update(); -} - -void SlsQt1DPlot::SetZoom(double xmin,double ymin,double x_width,double y_width){ - setAxisScale(QwtPlot::xBottom,xmin,xmin+x_width); - setAxisScale(QwtPlot::yLeft ,ymin,ymin+y_width); - Update(); -} - -void SlsQt1DPlot::RemoveHLine(){ - if(hline) hline->detach(); - delete hline; - hline=0; -} - -void SlsQt1DPlot::InsertHLine(double y){ - if(!hline){ - hline = new QwtPlotMarker(); - hline->setLabelAlignment(Qt::AlignRight|Qt::AlignTop); - hline->setLineStyle(QwtPlotMarker::HLine); - hline->attach(this); - } - hline->setYValue(y); -} - -void SlsQt1DPlot::RemoveVLine(){ - if(vline) vline->detach(); - delete vline; - vline=0; -} - -void SlsQt1DPlot::InsertVLine(double x){ - if(!vline){ - vline = new QwtPlotMarker(); - vline->setLabelAlignment(Qt::AlignRight|Qt::AlignTop); - vline->setLineStyle(QwtPlotMarker::VLine); - vline->attach(this); - } - vline->setXValue(x); -} - - - - -void SlsQt1DPlot::SetupZoom(){ - // LeftButton for the zooming - // MidButton for the panning - // RightButton: zoom out by 1 - // Ctrl+RighButton: zoom out to full size - - zoomer = new SlsQt1DZoomer(canvas()); - -#if QT_VERSION < 0x040000 - zoomer->setMousePattern(QwtEventPattern::MouseSelect2,Qt::RightButton, Qt::ControlButton); -#else - zoomer->setMousePattern(QwtEventPattern::MouseSelect2,Qt::RightButton, Qt::ControlModifier); -#endif - zoomer->setMousePattern(QwtEventPattern::MouseSelect3,Qt::RightButton); - - panner = new QwtPlotPanner((QwtPlotCanvas*)canvas()); - panner->setAxisEnabled(QwtPlot::yRight, false); - panner->setMouseButton(Qt::MidButton); - - // Avoid jumping when labels with more/less digits - // appear/disappear when scrolling vertically - - const QFontMetrics fm(axisWidget(QwtPlot::yLeft)->font()); - QwtScaleDraw *sd = axisScaleDraw(QwtPlot::yLeft); - sd->setMinimumExtent( fm.width("100.00") ); - - const QColor c(Qt::darkBlue); - zoomer->setRubberBandPen(c); - zoomer->setTrackerPen(c); -} - - -// Set a plain canvas frame and align the scales to it -void SlsQt1DPlot::alignScales(){ - // The code below shows how to align the scales to - // the canvas frame, but is also a good example demonstrating - // why the spreaded API needs polishing. - - ((QwtPlotCanvas*)canvas())->setFrameStyle(QFrame::Box | QFrame::Plain ); - ((QwtPlotCanvas*)canvas())->setLineWidth(1); - - for(int i = 0; i < QwtPlot::axisCnt; i++ ){ - QwtScaleWidget *scaleWidget = (QwtScaleWidget *)axisWidget(i); - if(scaleWidget) scaleWidget->setMargin(0); - QwtScaleDraw *scaleDraw = (QwtScaleDraw *)axisScaleDraw(i); - if(scaleDraw) scaleDraw->enableComponent(QwtAbstractScaleDraw::Backbone, false); - } -} - -void SlsQt1DPlot::UnknownStuff(){ -#if QWT_VERSION<0x060000 - // Disable polygon clipping - //not supported for version 6 - QwtPainter::setDeviceClipping(false); - canvas()->setPaintAttribute(QwtPlotCanvas::PaintCached, false); - canvas()->setPaintAttribute(QwtPlotCanvas::PaintPacked, false); -#else - // We don't need the cache here - ((QwtPlotCanvas*)canvas())->setPaintAttribute(QwtPlotCanvas::BackingStore, false); - -#endif - - - -#if QT_VERSION >= 0x040000 -#ifdef Q_WS_X11 - // Qt::WA_PaintOnScreen is only supported for X11, but leads - // to substantial bugs with Qt 4.2.x/Windows - canvas()->setAttribute(Qt::WA_PaintOnScreen, true); -#endif -#endif -} - - - -//Added by Dhanya on 19.06.2012 to disable zooming when any of the axes range has been set -void SlsQt1DPlot::DisableZoom(bool disableZoom){ -#ifdef VERBOSE - if(disableZoom) cout<<"Disabling zoom"<setMousePattern(QwtEventPattern::MouseSelect1,Qt::NoButton); -#if QT_VERSION < 0x040000 - zoomer->setMousePattern(QwtEventPattern::MouseSelect2,Qt::NoButton, Qt::ControlButton); -#else - zoomer->setMousePattern(QwtEventPattern::MouseSelect2,Qt::NoButton, Qt::ControlModifier); -#endif - zoomer->setMousePattern(QwtEventPattern::MouseSelect3,Qt::NoButton); - } - if(panner) panner->setMouseButton(Qt::NoButton); - }else { - if(zoomer){ - zoomer->setMousePattern(QwtEventPattern::MouseSelect1,Qt::LeftButton); -#if QT_VERSION < 0x040000 - zoomer->setMousePattern(QwtEventPattern::MouseSelect2,Qt::RightButton, Qt::ControlButton); -#else - zoomer->setMousePattern(QwtEventPattern::MouseSelect2,Qt::RightButton, Qt::ControlModifier); -#endif - zoomer->setMousePattern(QwtEventPattern::MouseSelect3,Qt::RightButton); - } - if(panner) panner->setMouseButton(Qt::MidButton); - } -} - - - - diff --git a/slsDetectorGui/slsDetectorPlotting/src/SlsQt1DZoomer.cxx b/slsDetectorGui/slsDetectorPlotting/src/SlsQt1DZoomer.cxx deleted file mode 100644 index 31386094e..000000000 --- a/slsDetectorGui/slsDetectorPlotting/src/SlsQt1DZoomer.cxx +++ /dev/null @@ -1,109 +0,0 @@ - -/** - * @author Ian Johnson - * @version 1.0 - */ - - -#include - -#include -#include - -#include "SlsQt1DPlot.h" -#include "SlsQt1DZoomer.h" - -using namespace std; - -void SlsQt1DZoomer::ResetZoomBase(){ - SetZoomBase(x0,y0,x1-x0,y1-y0); //for going between log and nonlog plots -} - -void SlsQt1DZoomer::SetZoomBase(double xmin,double ymin,double x_width, double y_width){ - if(xIsLog&&xmin<=0){ - double xmax = xmin+x_width; - xmin = firstXgt0*0.98; - if(xmax<=xmin) x_width=firstXgt0; - else x_width=xmax-xmin; - } - if(yIsLog&&ymin<=0){ - double ymax = ymin+y_width; - ymin = firstYgt0*0.98; - if(ymax<=ymin) y_width=firstYgt0; - else y_width=ymax-ymin; - } - - if(plot()){ - if(xIsLog){ - #if QWT_VERSION < 0x50200 - float xmin_curr = plot()->axisScaleDiv(QwtPlot::xBottom)->lBound(); - float xmax_curr = plot()->axisScaleDiv(QwtPlot::xBottom)->hBound(); - #elif QWT_VERSION < 0x060100 - float xmin_curr = plot()->axisScaleDiv(QwtPlot::xBottom)->lowerBound(); - float xmax_curr = plot()->axisScaleDiv(QwtPlot::xBottom)->upperBound(); - #else - float xmin_curr = plot()->axisScaleDiv(QwtPlot::xBottom).lowerBound(); - float xmax_curr = plot()->axisScaleDiv(QwtPlot::xBottom).upperBound(); - #endif - if(xmin_currxmin+x_width) xmax_curr=xmin+x_width; - plot()->setAxisScale(QwtPlot::xBottom,xmin_curr,xmax_curr); - } - if(yIsLog){ - #if QWT_VERSION < 0x50200 - float ymin_curr = plot()->axisScaleDiv(QwtPlot::yLeft)->lBound(); - float ymax_curr = plot()->axisScaleDiv(QwtPlot::yLeft)->hBound(); - #elif QWT_VERSION < 0x060100 - float ymin_curr = plot()->axisScaleDiv(QwtPlot::yLeft)->lowerBound(); - float ymax_curr = plot()->axisScaleDiv(QwtPlot::yLeft)->upperBound(); - #else - float ymin_curr = plot()->axisScaleDiv(QwtPlot::yLeft).lowerBound(); - float ymax_curr = plot()->axisScaleDiv(QwtPlot::yLeft).upperBound(); - #endif - if(ymin_currymin+y_width) ymax_curr=ymin+y_width; - plot()->setAxisScale(QwtPlot::yLeft,ymin_curr,ymax_curr); - } - plot()->replot(); - } - -#if QWT_VERSION<0x060000 - setZoomBase(QwtDoubleRect(xmin,ymin,x_width,y_width)); -#else - setZoomBase(QRectF(xmin,ymin,x_width,y_width)); -#endif -} - -void SlsQt1DZoomer::SetZoomBase(SlsQtH1D* h){ - x0 = h->GetXMin()<0 ? h->GetXMin()*1.02 : h->GetXMin()/1.02; - x1 = h->GetXMax()<0 ? h->GetXMax()/1.02 : h->GetXMax()*1.02; - y0 = h->GetYMin()<0 ? h->GetYMin()*1.02 : h->GetYMin()/1.02; - y1 = h->GetYMax()<0 ? h->GetYMax()/1.02 : h->GetYMax()*1.02; - - firstXgt0 = h->GetFirstXgtZero(); //for log plots - firstYgt0 = h->GetFirstYgtZero(); //for log plots - - ResetZoomBase(); -} - -void SlsQt1DZoomer::ExtendZoomBase(SlsQtH1D* h){ - double h_x0 = h->GetXMin()<0 ? h->GetXMin()*1.02 : h->GetXMin()/1.02; - double h_x1 = h->GetXMax()<0 ? h->GetXMax()/1.02 : h->GetXMax()*1.02; - double h_y0 = h->GetYMin()<0 ? h->GetYMin()*1.02 : h->GetYMin()/1.02; - double h_y1 = h->GetYMax()<0 ? h->GetYMax()/1.02 : h->GetYMax()*1.02; - - if(h_x0x1) x1 = h_x1; - if(h_y0y1) y1 = h_y1; - - if(h->GetFirstXgtZero()GetFirstXgtZero(); - if(h->GetFirstYgtZero()GetFirstYgtZero(); - - // cout<<"extend "< -#include -#include "SlsQt2DHist.h" - -using std::cout; -using std::endl; - -SlsQt2DHist::SlsQt2DHist(int nbinsx, double xmin, double xmax, int nbinsy, double ymin, double ymax, double* d,double zmin,double zmax):QwtRasterData(){ - x_min=0;x_max=0;y_min=0;y_max=0; - interp=0; - nx_array=ny_array=0;data=0; - SetData(nbinsx,xmin,xmax,nbinsy,ymin,ymax,d,zmin,zmax); -} - - -SlsQt2DHist::~SlsQt2DHist(){if(data) delete [] data;} - -int SlsQt2DHist::GetBinIndex(int bx, int by){ - int b = bx*ny+by; - if(b<0 || b>=nb){ - cout<<"GetBinIndex:: Incorrect indicies bx and by returning overflow bin;"<nx_array*ny_array){ - if(data) delete [] data; - data = new double [nbinsx*nbinsy+1]; //one for under/overflow bin - nx_array = nbinsx; - ny_array = nbinsy; - } - nx=nbinsx; - ny=nbinsy; - nb=nx*ny; - data[nb]=0;//set over flow to zero - if(d){ - memcpy(data,d,nb*sizeof(double)); - SetMinMax(zmin,zmax); - } -} - -void SlsQt2DHist::SetMinMax(double zmin,double zmax){ - if(zminz_max) z_max=data[i]; - z_mean+=data[i]; - } - z_mean/=nb; - if(z_min>0) z_min/=1.02; else z_min*=1.02; - if(z_max>0) z_max*=1.02; else z_max/=1.02; - } -#if QWT_VERSION<0x060000 - ; -#else - setInterval( Qt::ZAxis,QwtInterval(z_min,z_max)); -#endif - -} - -double SlsQt2DHist::GetMean(){ - if(!z_mean_has_been_calculated){ - z_mean_has_been_calculated = 1; - z_mean=0; - for(int i=0;i0 && data[i] -#include -#include -#include -#include - -#if QT_VERSION >= 0x040000 -#include -#endif -#include -#include -#include -#include -#include -#include -#include -#include - -#include "SlsQt2DPlot.h" - -#if QWT_VERSION >= 0x060100 -#define QwtLog10ScaleEngine QwtLogScaleEngine -#endif - -using namespace std; - -SlsQt2DPlot::SlsQt2DPlot(QWidget *parent):QwtPlot(parent){ - isLog=0; - - axisScaleEngine(QwtPlot::yLeft)->setAttribute(QwtScaleEngine::Floating); - axisScaleEngine(QwtPlot::xBottom)->setAttribute(QwtScaleEngine::Floating); - - d_spectrogram = new QwtPlotSpectrogram(); - - hist = new SlsQt2DHist(); - SetupZoom(); - SetupColorMap(); - - -#if QWT_VERSION<0x060000 - d_spectrogram->setData(*hist); -#else - d_spectrogram->setData(hist); -#endif - - - d_spectrogram->attach(this); - - plotLayout()->setAlignCanvasToScales(true); - - FillTestPlot(); - Update(); - -} - - -void SlsQt2DPlot::SetupColorMap(){ - - - - - colorMapLinearScale = myColourMap(0); -#if QWT_VERSION<0x060000 - d_spectrogram->setColorMap(*colorMapLinearScale ); -#else - d_spectrogram->setColorMap(colorMapLinearScale ); -#endif - - colorMapLogScale = myColourMap(1); -#if QWT_VERSION<0x060000 - contourLevelsLinear = new QwtValueList(); - for(double level=0.5;level<10.0;level+=1.0 ) (*contourLevelsLinear) += level; - d_spectrogram->setContourLevels(*contourLevelsLinear); -#else - ; - - for(double level=0.5;level<10.0;level+=1.0 ) (contourLevelsLinear) += level; - d_spectrogram->setContourLevels(contourLevelsLinear); -#endif - - - // -#if QWT_VERSION<0x060000 - contourLevelsLog = new QwtValueList(); - for(double level=0.5;level<10.0;level+=1.0 ) (*contourLevelsLog) += (pow(10,2*level/10.0)-1)/99.0 * 10; - -#else - ; - - for(double level=0.5;level<10.0;level+=1.0 ) (contourLevelsLog) += (pow(10,2*level/10.0)-1)/99.0 * 10; -#endif - - - // A color bar on the right axis - rightAxis = axisWidget(QwtPlot::yRight); - - rightAxis->setTitle("Intensity"); - rightAxis->setColorBarEnabled(true); - enableAxis(QwtPlot::yRight); -} - -void SlsQt2DPlot::FillTestPlot(int mode){ - static int nx = 50; - static int ny = 50; - static double *the_data=0; - if(the_data==0) the_data = new double [nx*ny]; - - double dmax = sqrt(pow(nx/2.0-0.5,2) + pow(ny/2.0-0.5,2)); - for(int i=0;iSetData(nx,200,822,ny,-0.5,ny-0.5,the_data); -} - -void SlsQt2DPlot::SetupZoom(){ - // LeftButton for the zooming - // MidButton for the panning - // RightButton: zoom out by 1 - // Ctrl+RighButton: zoom out to full size - - zoomer = new SlsQt2DZoomer(canvas()); - zoomer->SetHist(hist); - -#if QT_VERSION < 0x040000 - zoomer->setMousePattern(QwtEventPattern::MouseSelect2,Qt::RightButton, Qt::ControlButton); -#else - zoomer->setMousePattern(QwtEventPattern::MouseSelect2,Qt::RightButton, Qt::ControlModifier); -#endif - zoomer->setMousePattern(QwtEventPattern::MouseSelect3,Qt::RightButton); - - panner = new QwtPlotPanner(canvas()); - panner->setAxisEnabled(QwtPlot::yRight, false); - panner->setMouseButton(Qt::MidButton); - - // Avoid jumping when labels with more/less digits - // appear/disappear when scrolling vertically - - const QFontMetrics fm(axisWidget(QwtPlot::yLeft)->font()); - QwtScaleDraw *sd = axisScaleDraw(QwtPlot::yLeft); - sd->setMinimumExtent( fm.width("100.00") ); - - const QColor c(Qt::darkBlue); - zoomer->setRubberBandPen(c); - zoomer->setTrackerPen(c); -} - -/*void SlsQt2DPlot::CompletelyUnZoom(){ - setAxisScale(QwtPlot::xBottom,hist->GetXMin(),hist->GetXMin()+(hist->GetXMax()-hist->GetXMin())); - setAxisScale(QwtPlot::yLeft,hist->GetYMin(),hist->GetYMin()+(hist->GetYMax()-hist->GetYMin())); - zoomer->setZoomBase(); - //replot(); -}*/ - -void SlsQt2DPlot::UnZoom(bool replot){ -#if QWT_VERSION<0x060000 - zoomer->setZoomBase(QwtDoubleRect(hist->GetXMin(),hist->GetYMin(),hist->GetXMax()-hist->GetXMin(),hist->GetYMax()-hist->GetYMin())); -#else - zoomer->setZoomBase(QRectF(hist->GetXMin(),hist->GetYMin(),hist->GetXMax()-hist->GetXMin(),hist->GetYMax()-hist->GetYMin())); -#endif - zoomer->setZoomBase(replot);//Call replot for the attached plot before initializing the zoomer with its scales. - // zoomer->zoom(0); -} - -void SlsQt2DPlot::SetZoom(double xmin,double ymin,double x_width,double y_width){ - -#if QWT_VERSION<0x060000 - zoomer->setZoomBase(QwtDoubleRect(xmin,ymin,x_width,y_width)); - -#else - zoomer->setZoomBase(QRectF(xmin,ymin,x_width,y_width)); -#endif -} - -void SlsQt2DPlot::SetZMinMax(double zmin,double zmax){ - hist->SetMinMax(zmin,zmax); -} - - -QwtLinearColorMap* SlsQt2DPlot::myColourMap(QVector colourStops) { - -int ns=5; - -double r[]={0.00, 0.00, 0.87, 1.00, 0.51}; -double g[]={0.00, 0.81, 1.00, 0.20, 0.00}; - double b[] = { 0.51, 1.00, 0.12, 0.00, 0.00 }; - - QColor c1,c2,c; - c1.setRgbF(r[0],g[0],b[0],0); - c2.setRgbF(r[ns-1],g[ns-1],b[ns-1]); - QwtLinearColorMap* copyMap = new QwtLinearColorMap(Qt::lightGray, c2); - - for (int is=0; isaddColorStop(colourStops.value(is),c ); - } - - return copyMap; - - -} -QwtLinearColorMap* SlsQt2DPlot::myColourMap(int log) { - -int ns=5; - - - QVector cs1(0); - QVector lcs1(0); - - - cs1.append(0.); - cs1.append(0.34); - cs1.append(0.61); - cs1.append(0.84); - cs1.append(1.); -if (log) { - for (int is=0; issetColorMap(d_spectrogram->data().range(),d_spectrogram->colorMap()); -#else - if (isLog) - hist->SetMinimumToFirstGreaterThanZero(); - - const QwtInterval zInterval = d_spectrogram->data()->interval( Qt::ZAxis ); - - rightAxis->setColorMap(zInterval,myColourMap(isLog)); - -#endif - - if(!zoomer->zoomRectIndex()) UnZoom(); - -#if QWT_VERSION<0x060000 - - - setAxisScale(QwtPlot::yRight,d_spectrogram->data().range().minValue(), - d_spectrogram->data().range().maxValue()); -#else - - - setAxisScale(QwtPlot::yRight,zInterval.minValue(), zInterval.maxValue()); -#ifdef VERYVERBOSE - cout << "axis scale set" << endl; -#endif - plotLayout()->setAlignCanvasToScales(true); -#ifdef VERYVERBOSE - cout << "layout" << endl; -#endif -#endif -#ifdef VERYVERBOSE - cout << "going to replot" << endl; -#endif - replot(); -#ifdef VERYVERBOSE - cout << "done" << endl; -#endif -} - - - -void SlsQt2DPlot::showContour(bool on){ - d_spectrogram->setDisplayMode(QwtPlotSpectrogram::ContourMode,on); - Update(); -} - -void SlsQt2DPlot::showSpectrogram(bool on){ - // static int io=0; - // FillTestPlot(io++); - d_spectrogram->setDisplayMode(QwtPlotSpectrogram::ImageMode, on); - d_spectrogram->setDefaultContourPen(on ? QPen() : QPen(Qt::NoPen)); - Update(); -} - -void SlsQt2DPlot::InterpolatedPlot(bool on){ - hist->Interpolate(on); - Update(); -} - - -void SlsQt2DPlot::LogZ(bool on){ - if(on){ -isLog=1; - //if(hist->GetMinimum()<=0) hist->SetMinimumToFirstGreaterThanZero(); -#if QWT_VERSION<0x060000 - d_spectrogram->setColorMap(*colorMapLogScale); -#else - d_spectrogram->setColorMap(myColourMap(isLog)); -#endif - setAxisScaleEngine(QwtPlot::yRight,new QwtLog10ScaleEngine); -#if QWT_VERSION<0x060000 - d_spectrogram->setContourLevels(*contourLevelsLog); -#else - d_spectrogram->setContourLevels(contourLevelsLog); -#endif - }else{ -isLog=0; - -#if QWT_VERSION<0x060000 - d_spectrogram->setColorMap(*colorMapLinearScale); -#else - d_spectrogram->setColorMap(myColourMap(isLog)); -#endif - - - - setAxisScaleEngine(QwtPlot::yRight,new QwtLinearScaleEngine); - -#if QWT_VERSION<0x060000 - d_spectrogram->setContourLevels(*contourLevelsLinear); -#else - d_spectrogram->setContourLevels(contourLevelsLinear); -#endif - - } - Update(); - -} - -//Added by Dhanya on 19.06.2012 to disable zooming when any of the axes range has been set -void SlsQt2DPlot::DisableZoom(bool disableZoom){ -#ifdef VERBOSE - if(disableZoom) cout<<"Disabling zoom"<setMousePattern(QwtEventPattern::MouseSelect1,Qt::NoButton); -#if QT_VERSION < 0x040000 - zoomer->setMousePattern(QwtEventPattern::MouseSelect2,Qt::NoButton, Qt::ControlButton); -#else - zoomer->setMousePattern(QwtEventPattern::MouseSelect2,Qt::NoButton, Qt::ControlModifier); -#endif - zoomer->setMousePattern(QwtEventPattern::MouseSelect3,Qt::NoButton); - } - if(panner) panner->setMouseButton(Qt::NoButton); - }else { - if(zoomer){ - zoomer->setMousePattern(QwtEventPattern::MouseSelect1,Qt::LeftButton); -#if QT_VERSION < 0x040000 - zoomer->setMousePattern(QwtEventPattern::MouseSelect2,Qt::RightButton, Qt::ControlButton); -#else - zoomer->setMousePattern(QwtEventPattern::MouseSelect2,Qt::RightButton, Qt::ControlModifier); -#endif - zoomer->setMousePattern(QwtEventPattern::MouseSelect3,Qt::RightButton); - } - if(panner) panner->setMouseButton(Qt::MidButton); - } -} - - -/* -void SlsQt2DPlot::printPlot(){ - QPrinter printer; - printer.setOrientation(QPrinter::Landscape); -#if QT_VERSION < 0x040000 - printer.setColorMode(QPrinter::Color); - printer.setOutputFileName("spectrogram.ps"); - if (printer.setup()) -#else - printer.setOutputFileName("spectrogram.pdf"); - QPrintDialog dialog(&printer); - if ( dialog.exec() ) -#endif - { - print(printer); - } -} - -*/ diff --git a/slsDetectorGui/slsDetectorPlotting/src/SlsQt2DPlotLayout.cxx b/slsDetectorGui/slsDetectorPlotting/src/SlsQt2DPlotLayout.cxx deleted file mode 100644 index 220bf0f2c..000000000 --- a/slsDetectorGui/slsDetectorPlotting/src/SlsQt2DPlotLayout.cxx +++ /dev/null @@ -1,239 +0,0 @@ -/** - * @author Ian Johnson - * @version 1.0 - */ - - -#include - -#include -#include -#include -#include -#include - -#include "SlsQt2DPlotLayout.h" - -using namespace std; - -SlsQt2DPlotLayout::SlsQt2DPlotLayout(QWidget *parent):QGroupBox(parent){ - the_layout=0; - the_plot = new SlsQt2DPlot(this); - - z_range_ne = new SlsQtNumberEntry(this,1,(char*)"Set the z axis range from",2,(char*)"to",2); - z_range_ne->setFixedWidth(402); -#ifndef IAN - zRangeChecked = false; - z_range_ne->hide(); -#endif - - CreateTheButtons(); - Layout(); - ConnectSignalsAndSlots(); -} - -SlsQt2DPlotLayout::~SlsQt2DPlotLayout(){ - - if(the_layout) delete the_layout; - - - delete the_plot; - delete z_range_ne; -} - - -void SlsQt2DPlotLayout::CreateTheButtons(){ - /** Dhanya: All these buttons are already in another class, logz is used and a wrapper around it*/ -#ifdef IAN - btnInterpolate = new QToolButton(this); - btnInterpolate->setText("Interpolate"); - btnInterpolate->setCheckable(true); - btnInterpolate->setToolButtonStyle(Qt::ToolButtonTextUnderIcon); - - btnContour = new QToolButton(this); - btnContour->setText("Contour"); - btnContour->setCheckable(true); - btnContour->setToolButtonStyle(Qt::ToolButtonTextUnderIcon); -#endif - btnLogz = new QToolButton(this); - btnLogz->setText("Log Scale (Z)"); - btnLogz->setCheckable(true); - btnLogz->setToolButtonStyle(Qt::ToolButtonTextUnderIcon); -#ifndef IAN - btnLogz->hide(); -#endif -} - - -void SlsQt2DPlotLayout::Layout(){ - if(the_layout) delete the_layout; - the_layout = new QGridLayout(this); -#ifdef IAN - the_layout->addWidget(btnInterpolate,1,1); - the_layout->addWidget(btnContour,1,2); - the_layout->addWidget(btnLogz,1,3); - the_layout->addWidget(the_plot,2,1,3,3); - the_layout->addWidget(z_range_ne,5,1,1,3); - the_layout->setMargin(12); -#else - the_layout->addWidget(the_plot,2,0,3,3); - the_layout->addWidget(z_range_ne,5,0,1,3); -#endif -} - -void SlsQt2DPlotLayout::ConnectSignalsAndSlots(){ -#ifndef IAN - connect(this, SIGNAL(InterpolateSignal(bool)), the_plot, SLOT(InterpolatedPlot(bool))); - connect(this, SIGNAL(ContourSignal(bool)), the_plot, SLOT(showContour(bool))); -#else - connect(btnInterpolate, SIGNAL(toggled(bool)),the_plot, SLOT(InterpolatedPlot(bool))); - connect(btnContour, SIGNAL(toggled(bool)),the_plot, SLOT(showContour(bool))); - connect(btnLogz, SIGNAL(toggled(bool)),this,SLOT(SetZScaleToLog(bool))); - btnInterpolate->setChecked(false); - btnContour->setChecked(false); -#endif - connect(z_range_ne, SIGNAL(CheckBoxChanged(bool)), this, SLOT(ResetRange())); - connect(z_range_ne, SIGNAL(AValueChanged(SlsQtNumberEntry*)), this, SLOT(ResetRange())); - btnLogz->setChecked(false); -} - -void SlsQt2DPlotLayout::UpdateNKeepSetRangeIfSet(){ -#ifdef IAN - if(z_range_ne->CheckBoxState()){ -#endif - //just reset histogram range before update - the_plot->SetZMinMax(z_range_ne->GetValue(0),z_range_ne->GetValue(1)); -#ifdef IAN - } -#endif - the_plot->Update(); -} - -void SlsQt2DPlotLayout::ResetRange(){ - //refind z limits - the_plot->SetZMinMax(); - if(btnLogz->isChecked()) the_plot->SetZMinimumToFirstGreaterThanZero(); -#ifdef IAN - if(z_range_ne->CheckBoxState()){ -#else - if(zRangeChecked){ -#endif - //first time check validity - bool same = (z_range_ne->GetValue(0)==z_range_ne->GetValue(1)) ? 1:0; - if(!z_range_ne->IsValueOk(0)||same) z_range_ne->SetValue(the_plot->GetZMinimum(),0); - if(!z_range_ne->IsValueOk(1)||same) z_range_ne->SetValue(the_plot->GetZMaximum(),1); - z_range_ne->SetRange(the_plot->GetZMinimum(),z_range_ne->GetValue(1),0); - z_range_ne->SetRange(z_range_ne->GetValue(0),the_plot->GetZMaximum(),1); - - //set histogram range - the_plot->SetZMinMax(z_range_ne->GetValue(0),z_range_ne->GetValue(1)); - } - the_plot->Update(); -} - - -void SlsQt2DPlotLayout::ResetZMinZMax(bool zmin, bool zmax, double min, double max){ - - if(zmin || zmax) zRangeChecked = true; - else zRangeChecked = false; - - if(zmin) z_range_ne->SetNumber(min,0); - if(zmax) z_range_ne->SetNumber(max,1); - - - //refind z limits - the_plot->SetZMinMax(); - //finds zmin value from hist - if(btnLogz->isChecked()) - the_plot->SetZMinimumToFirstGreaterThanZero(); - - if(zRangeChecked){ - - //if value not given, take max or min of plot - if(zmax) z_range_ne->SetValue(max,0); - else z_range_ne->SetValue(the_plot->GetZMaximum(),1); - - if(zmin) z_range_ne->SetValue(min,0); - else z_range_ne->SetValue(the_plot->GetZMinimum(),0); - - //check if zmin and zmax is same or not a proper double value - //if(zmin && zmax){ - bool same = (z_range_ne->GetValue(0)==z_range_ne->GetValue(1)) ? 1:0; - if(!z_range_ne->IsValueOk(0)||same) z_range_ne->SetValue(the_plot->GetZMinimum(),0); - if(!z_range_ne->IsValueOk(1)||same) z_range_ne->SetValue(the_plot->GetZMaximum(),1); - //} - - z_range_ne->SetRange(the_plot->GetZMinimum(),z_range_ne->GetValue(1),0); - z_range_ne->SetRange(z_range_ne->GetValue(0),the_plot->GetZMaximum(),1); - - //set histogram range - the_plot->SetZMinMax(z_range_ne->GetValue(0),z_range_ne->GetValue(1)); - - } - the_plot->Update(); -} - - -void SlsQt2DPlotLayout::SetZScaleToLog(bool yes){ -#ifndef IAN -#ifdef VERBOSE - cout<<"Setting ZScale to log:"<setChecked(yes); -#endif - the_plot->LogZ(yes); - ResetRange(); -} - - -void SlsQt2DPlotLayout::SetXTitle(QString st){ -#ifndef IAN - QwtText title(st); - title.setFont(QFont("Sans Serif",11,QFont::Normal)); - GetPlot()->axisWidget(QwtPlot::xBottom)->setTitle(title); -#else - GetPlot()->axisWidget(QwtPlot::xBottom)->setTitle(st); -#endif -} - -void SlsQt2DPlotLayout::SetYTitle(QString st){ -#ifndef IAN - QwtText title(st); - title.setFont(QFont("Sans Serif",11,QFont::Normal)); - GetPlot()->axisWidget(QwtPlot::yLeft)->setTitle(title); -#else - GetPlot()->axisWidget(QwtPlot::yLeft)->setTitle(st); -#endif -} - -void SlsQt2DPlotLayout::SetZTitle(QString st){ -#ifndef IAN - QwtText title(st); - title.setFont(QFont("Sans Serif",11,QFont::Normal)); - GetPlot()->axisWidget(QwtPlot::yRight)->setTitle(title); -#else - GetPlot()->axisWidget(QwtPlot::yRight)->setTitle(st); -#endif -} - - -#ifndef IAN -void SlsQt2DPlotLayout::SetZRange(double zmin, double zmax){ -#ifdef VERBOSE - cout<<"zmin:"<SetNumber(zmin,0); - z_range_ne->SetNumber(zmax,1); - ResetRange(); -} - - -void SlsQt2DPlotLayout::EnableZRange(bool enable){ -#ifdef VERBOSE - cout<<"Setting Z Range Enable to "< -#include - -#include -#include -#include - -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include - -#include "SlsQtNumberEntry.h" - -using namespace std; - -SlsQtNumberEntry::SlsQtNumberEntry(QWidget *parent, int with_checkbox, char *start_string, int num_type, char* middle_string, int num2_type, int n_units, char** units, double* unit_factors,char* end_string):QWidget(parent){ - SetupNumberEntry(with_checkbox,start_string,num_type,middle_string,num2_type,n_units,units,unit_factors,end_string); -} - -//without unit drop box -SlsQtNumberEntry::SlsQtNumberEntry(QWidget *parent,int with_checkbox, char *start_string, int num_type, char* middle_string, int num2_type,char* end_string):QWidget(parent){ - SetupNumberEntry(with_checkbox,start_string,num_type,middle_string,num2_type,0,0,0,end_string); -} - -void SlsQtNumberEntry::SetupNumberEntry(int with_checkbox, char *start_string, int num_type, char* middle_string, int num2_type, int n_units, char** units, double* unit_factors,char* end_string){ - - layout = 0; - - check_box = 0; - front_text = 0; - num_field[0] = 0; - spin_box[0] = 0; - validator_int[0] = 0; - validator_double[0] = 0; - middle_text = 0; - num_field[1] = 0; - spin_box[1] = 0; - validator_int[1] = 0; - validator_double[1] = 0; - unit_cbb = 0; - factors = 0; - back_text = 0; - if(with_checkbox) AddCheckBox(); - SetFrontText(start_string); - - SetupNumberField(num_type,0); - SetMiddleText(middle_string); - SetupNumberField(num2_type,1); - SetUnits(n_units,units,unit_factors); - SetBackText(end_string); - - SetLayout(); - -} - - -SlsQtNumberEntry::~SlsQtNumberEntry(){ - - if(check_box) delete check_box; - if(front_text) delete front_text; - if(middle_text) delete middle_text; - if(validator_int[0]) delete validator_int[0]; - if(validator_double[0]) delete validator_double[0]; - if(num_field[0]) delete num_field[0]; - if(spin_box[0]) delete spin_box[0]; - if(validator_int[1]) delete validator_int[1]; - if(validator_double[1]) delete validator_double[1]; - if(num_field[1]) delete num_field[1]; - if(spin_box[1]) delete spin_box[1]; - if(unit_cbb) delete unit_cbb; - if(factors) delete factors; - if(back_text) delete back_text; - -} - -void SlsQtNumberEntry::AddCheckBox(){ - if(check_box) delete check_box; - check_box = new QCheckBox(this); - connect(check_box,SIGNAL(clicked()),this,SLOT(CheckBoxClicked())); - SetLayout(); -} - -void SlsQtNumberEntry::SetFrontText(char* s) {SetText(s,&front_text); SetLayout();} -void SlsQtNumberEntry::SetMiddleText(char* s) {SetText(s,&middle_text); SetLayout();} -void SlsQtNumberEntry::SetBackText(char* s) {SetText(s,&back_text); SetLayout();}; -void SlsQtNumberEntry::SetText(char* s, QLabel** pp){ - if(*pp){delete *pp; *pp=0;} - if(s){ - *pp = new QLabel(this); - (*pp)->setText(s); - } - SetLayout(); -} - - -void SlsQtNumberEntry::SetupNumberField(int type, int which_number_field){ - int i = (which_number_field<0||which_number_field>1) ? 0:which_number_field; - - num_field_enabled[i]=1; - if(spin_box[i]) { delete spin_box[i]; spin_box[i]=0;} - if(validator_int[i]) { delete validator_int[i]; validator_int[i]=0;} - if(validator_double[i]) { delete validator_double[i]; validator_double[i]=0;} - if(num_field[i]) { delete num_field[i]; num_field[i]=0;} - - if(type>0&&type<3){ - num_field[i] = new QLineEdit(this); - num_field[i]->setAlignment(Qt::AlignRight); - SetMinimumNumberWidth(3,i); - if(type==1){ - validator_int[i] = new SlsQtIntValidator(num_field[i]); - num_field[i]->setValidator(validator_int[i]); - SetNumber(0,i); - }else{ - validator_double[i] = new SlsQtDoubleValidator(num_field[i]); - num_field[i]->setValidator(validator_double[i]); - //default settings - SetNDecimalsOfDoubleValidator(3,i); //defalut value - SetNumber(0,i); - } - - num_field[i]->setAlignment(Qt::AlignRight); - - if(i==0){ - connect(num_field[i],SIGNAL(editingFinished()),this,SLOT(RefreshFirstNumberEntry())); - connect(num_field[i],SIGNAL(returnPressed()),this,SLOT(FirstValueEntered())); - connect(num_field[i],SIGNAL(editingFinished()),this,SLOT(FirstValueEntered())); - }else{ - connect(num_field[i],SIGNAL(editingFinished()),this,SLOT(RefreshSecondNumberEntry())); - connect(num_field[i],SIGNAL(returnPressed()),this,SLOT(SecondValueEntered())); - connect(num_field[i],SIGNAL(editingFinished()),this,SLOT(SecondValueEntered())); - } - }else if(type==3){ - spin_box[i] = new QSpinBox(); - if(i==0) connect(spin_box[i],SIGNAL(editingFinished()),this,SLOT(FirstValueEntered())); - else connect(spin_box[i],SIGNAL(editingFinished()),this,SLOT(SecondValueEntered())); - spin_box[i]->setAlignment(Qt::AlignRight); - } - - SetLayout(); -} - -void SlsQtNumberEntry::SetUnits(int n_units, char** units, double* unit_factors){ - if(unit_cbb){ delete unit_cbb; unit_cbb=0;} - if(factors) { delete factors; factors=0;} - - if(n_units>0&&units&&unit_factors){ - unit_cbb = new QComboBox(this); - factors = new double [n_units]; - - for(int i=0;iinsertItem(i,units[i]); - factors[i] = unit_factors[i]; - } - - connect(unit_cbb,SIGNAL(activated(int)),this,SLOT(UnitSelected())); - } - - SetLayout(); -} - -void SlsQtNumberEntry::SetLayout(){ - if(layout) delete layout; - layout = new QGridLayout(this); - - int i = 0; - if(check_box) layout->addWidget(check_box,1,i++); - if(front_text) layout->addWidget(front_text,1,i++); - if(num_field[0]) layout->addWidget(num_field[0],1,i++); - if(spin_box[0]) layout->addWidget(spin_box[0],1,i++); - if(middle_text) layout->addWidget(middle_text,1,i++); - if(num_field[1]) layout->addWidget(num_field[1],1,i++); - if(spin_box[1]) layout->addWidget(spin_box[1],1,i++); - if(unit_cbb) layout->addWidget(unit_cbb,1,i++); - if(back_text) layout->addWidget(back_text,1,i++); - - CheckBoxClicked(); -} - - -void SlsQtNumberEntry::SetMinimumNumberWidth(int nchar_width,int which_number_field){ - if(num_field[which_number_field]) num_field[which_number_field] - ->setMinimumWidth(nchar_width*num_field[which_number_field]->minimumSizeHint().width()); - if(spin_box[which_number_field]) spin_box[which_number_field] - ->setMinimumWidth(nchar_width*spin_box[which_number_field]->minimumSizeHint().width()); -} - -void SlsQtNumberEntry::SetNDecimalsOfDoubleValidators(int ndecimals){ - SetNDecimalsOfDoubleValidator(ndecimals,0); - SetNDecimalsOfDoubleValidator(ndecimals,1); -} - -void SlsQtNumberEntry::SetNDecimalsOfDoubleValidator(int ndecimals, int which_number_field){ - //0 -> standard, 1->scientific - int i = (which_number_field<0||which_number_field>1) ? 0:which_number_field; - if(validator_double[i]){ - validator_double[i]->setDecimals(ndecimals); - SetNumber(GetNumber(i),i); - } -} - -void SlsQtNumberEntry::SetMinimumUnitWidth(int nchar_width){ - if(unit_cbb) unit_cbb->setMinimumWidth(nchar_width*unit_cbb->minimumSizeHint().width()); -} - - -/* -double SlsQtNumberEntry::SetNumber(int v,int which_number_field){ - int i = (which_number_field<0||which_number_field>1) ? 0:which_number_field; - - if(num_field[i]){ - if(validator_int[i]){ - QString s = QString::number(v); - validator_int[i]->fixup(s); - num_field[i]->setText(s); - } - if(validator_double[i]){ - QString s = QString::number(v); - validator_double[i]->fixup(s); - num_field[i]->setText(s); - } - }else if(spin_box[i]){ - spin_box[i]->setValue(v); - }else return 0; - - return GetNumber(i); -} -*/ - -double SlsQtNumberEntry::SetNumber(double v,int which_number_field){ - int i = (which_number_field<0||which_number_field>1) ? 0:which_number_field; - - if(num_field[i]){ - if(validator_int[i]){ - QString s = QString::number(v); - validator_int[i]->fixup(s); - num_field[i]->setText(s); - } - if(validator_double[i]){ - QString s = QString::number(v); - //validator_double[i]->fixup(s);//commented out as it ignores the zmax values - num_field[i]->setText(s); - } - }else if(spin_box[i]){ - spin_box[i]->setValue(round(v)); - }else return 0; - - return GetNumber(i); -} - - -void SlsQtNumberEntry::SetRange(int min, int max,int which_number_field){ - int i = (which_number_field<0||which_number_field>1) ? 0:which_number_field; - if(min>max){ - cout<<"Warning: SetRange(int,int) no effect min > max"<setRange(min,max); - if(validator_double[i]) validator_double[i]->setRange(min,max,validator_double[i]->decimals()); - if(spin_box[i]) spin_box[i]->setRange(min,max); - SetNumber(GetNumber(i),i); - } -} - - -void SlsQtNumberEntry::SetRange(double min, double max,int which_number_field){ - int i = (which_number_field<0||which_number_field>1) ? 0:which_number_field; - if(min>max){ - cout<<"Warning: SetRange(double,double) no effect min("<= max("<setRange(min,max,validator_double[i]->decimals()); - if(spin_box[i]) spin_box[i]->setRange(min,max); - SetNumber(GetNumber(i),i); - } - -} - -bool SlsQtNumberEntry::CheckBoxState(){ - if(check_box&&check_box->checkState()) return 1; - return 0; -} - -void SlsQtNumberEntry::CheckBoxClicked(){ - if(check_box){ - if(check_box->checkState()) Enable(); - else Disable(); - - emit CheckBoxChanged(check_box->checkState()); - emit CheckBoxChanged(this); - } - -} - -void SlsQtNumberEntry::Disable(){ Enable(0); } -void SlsQtNumberEntry::Enable(bool en_flag){ - if(check_box) check_box->setChecked(en_flag); - if(front_text) front_text->setEnabled(en_flag); - if(num_field[0]) num_field[0]->setEnabled(en_flag&&num_field_enabled[0]); - if(spin_box[0]) spin_box[0]->setEnabled(en_flag&&num_field_enabled[0]); - if(middle_text) middle_text->setEnabled(en_flag); - if(num_field[1]) num_field[1]->setEnabled(en_flag&&num_field_enabled[1]); - if(spin_box[1]) spin_box[1]->setEnabled(en_flag&&num_field_enabled[1]); - if(unit_cbb) unit_cbb->setEnabled(en_flag); - if(back_text) back_text->setEnabled(en_flag); -} - -void SlsQtNumberEntry::DisableNumberField(int which_number_field){ EnableNumberField(which_number_field,0); } -void SlsQtNumberEntry::EnableNumberField(int which_number_field,bool en_flag){ - if(which_number_field>=0||which_number_field<=1){ - num_field_enabled[which_number_field]=en_flag; - if(num_field[which_number_field]) num_field[which_number_field]->setEnabled(num_field_enabled[which_number_field]); - if(spin_box[which_number_field]) spin_box[which_number_field]->setEnabled(num_field_enabled[which_number_field]); - } -} - -void SlsQtNumberEntry::UnitSelected(){ - emit UnitChanged(GetComboBoxValue()); - emit UnitChanged(this); - emit AValueChanged(this); - emit FirstValueChanged(GetValueInt(0)); - emit FirstValueChanged(GetValue(0)); - emit FirstValueChanged(this); - emit SecondValueChanged(GetValueInt(1)); - emit SecondValueChanged(GetValue(1)); - emit SecondValueChanged(this); -} - -void SlsQtNumberEntry::RefreshFirstNumberEntry() { RefreshNumberEntery(0);} -void SlsQtNumberEntry::RefreshSecondNumberEntry() { RefreshNumberEntery(1);} -void SlsQtNumberEntry::RefreshNumberEntery(int which_number_field){ - //does not apply to spin boxes - if(num_field[which_number_field]){ - SetNumber(GetNumber(which_number_field),which_number_field); - } - //refreshes the entery in a general format for ints and fixes doubles, - //for example removes leading zeros - //However, also moves curser position -} - -void SlsQtNumberEntry::FirstValueEntered(){ - emit AValueChanged(this); - emit FirstValueChanged(GetValue(0)); - emit FirstValueChanged(GetValueInt(0)); - emit FirstValueChanged(this); -} - -void SlsQtNumberEntry::SecondValueEntered(){ - emit AValueChanged(this); - emit SecondValueChanged(GetValue(1)); - emit SecondValueChanged(GetValueInt(1)); - emit SecondValueChanged(this); -} - - -bool SlsQtNumberEntry::Enabled(){ - if(check_box && !check_box->checkState()) return 0; - return 1; -} - -bool SlsQtNumberEntry::IsValueOk(int which_number_field){ - int i = (which_number_field<0||which_number_field>1) ? 0:which_number_field; - - bool ok=0; - if(validator_int[i]) num_field[i]->text().toInt(&ok); - if(validator_double[i]) num_field[i]->text().toDouble(&ok); - if(spin_box[i]) ok=true; - - return ok; -} - -const char* SlsQtNumberEntry::GetFrontText(){ - if(front_text) return front_text->text().toStdString().c_str(); - return 0; -} -const char* SlsQtNumberEntry::GetMiddleText(){ - if(middle_text) return middle_text->text().toStdString().c_str(); - return 0; -} -const char* SlsQtNumberEntry::GetBackText(){ - if(back_text) back_text->text().toStdString().c_str(); - return 0; -} - -int SlsQtNumberEntry::GetNumberInt(int which_number_field,bool* ok){ - return round(GetNumber(which_number_field,ok)); -} - -double SlsQtNumberEntry::GetNumber(int which_number_field,bool* ok){ - int i = (which_number_field<0||which_number_field>1) ? 0:which_number_field; - - if(ok) *ok = 1; - - if(num_field[i]){ - if(validator_int[i]) return num_field[i]->text().toInt(ok); - else return num_field[i]->text().toDouble(ok); - } - else if(spin_box[i]) return spin_box[i]->value(); - else {if(ok) *ok=0;} - - return 0; -} - - - -double SlsQtNumberEntry::SetValue(double v,int which_number_field){ - if(unit_cbb) SetNumber(round(v/GetComboBoxValue()),which_number_field); - else SetNumber(v,which_number_field); - - return GetValue(which_number_field); -} - - -int SlsQtNumberEntry::GetValueInt(int which_number_field,bool* ok){ - return round(GetValue(which_number_field,ok)); -} - -double SlsQtNumberEntry::GetValue(int which_number_field,bool* ok){ - int i = (which_number_field<0||which_number_field>1) ? 0:which_number_field; - - double v; - if(ok) *ok = 1; - - if(num_field[i]){ - if(validator_int[i]) v = num_field[i]->text().toInt(ok); - else v = num_field[i]->text().toDouble(ok); - } - else if(spin_box[i]) v = spin_box[i]->value(); - else v = 1; //incase there is only a unit pulldown - - - if(unit_cbb) v *= GetComboBoxValue(); - - if(!num_field[i]&&!spin_box[i]&&!unit_cbb){v=0; if(ok) *ok=0;} - - return v; -} - - -int SlsQtNumberEntry::SetComboBoxIndex(int index){ - if(unit_cbb){ - if(index<0||index>=unit_cbb->count()){ - cout<<"usage error : can not set combo box index, index out of range."<setCurrentIndex(index); - } - } - else cout<<"usage error : can not set combo box index, no combo box."<currentIndex(); - - cout<<"usage error : can not get combo box index, no combo box."<currentIndex()]; - - cout<<"usage error : can not get combo box value, no combo box."< -// C++ Include Headers -#include -using namespace std; - -//------------------------------------------------------------------------------------------------------------------------------------------------- -int qActionsWidget::NUM_ACTION_WIDGETS(0); -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -qActionsWidget::qActionsWidget(QWidget *parent,multiSlsDetector*& detector): - QWidget(parent),myDet(detector){ - setupUi(this); - SetupWidgetWindow(); - Initialization(); -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -qActionsWidget::~qActionsWidget(){ - delete myDet; -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qActionsWidget::SetupWidgetWindow(){ - id = NUM_ACTION_WIDGETS; - NUM_ACTION_WIDGETS++; - - setFixedHeight(25); - -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qActionsWidget::Initialization(){ - //mode - connect(comboScript, SIGNAL(currentIndexChanged(int)), this,SLOT(SetMode(int))); - //file - connect(dispScript, SIGNAL(editingFinished()), this, SLOT(SetScriptFile())); - connect(btnBrowse, SIGNAL(clicked()), this, SLOT(BrowsePath())); - //parameter - connect(dispParameter, SIGNAL(editingFinished()), this, SLOT(SetParameter())); -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qActionsWidget::SetMode(int mode){ -#ifdef VERBOSE - cout << "Setting\taction:" << id << "\tmode:" << mode << endl; -#endif - //enabling/disabling - dispScript->setEnabled(mode); - btnBrowse->setEnabled(mode); - lblParameter->setEnabled(mode); - dispParameter->setEnabled(mode); - - QString fName = dispScript->text(); - //set the mode - if(mode) myDet->setActionScript(id,fName.toAscii().constData()); - else myDet->setActionScript(id,""); - //mode is not set when fname is blank - - if(!fName.isEmpty()){ - //check if mode didnt get set - if(mode!=myDet->getActionMode(id)){ - qDefs::Message(qDefs::WARNING,"The mode could not be changed.","qActionsWidget::SetMode"); - comboScript->setCurrentIndex(myDet->getActionMode(id)); - }//if mode got set and its custom script - else if(mode){ - //when the file name did not get set correctly - if(fName.compare(QString(myDet->getActionScript(id).c_str()))){ - qDefs::Message(qDefs::WARNING,"The file path could not be set.","qActionsWidget::SetMode"); - dispScript->setText(QString(myDet->getActionScript(id).c_str())); - SetScriptFile(); - } - } - } - qDefs::checkErrorMessage(myDet,"qActionsWidget::SetMode"); -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - -void qActionsWidget::BrowsePath(){ -#ifdef VERBOSE - cout << "Browsing Script File Path" << endl; -#endif - QString fName = dispScript->text(); - QString dir = fName.section('/',0,-2,QString::SectionIncludeLeadingSep); - if(dir.isEmpty()) dir = "/home"; - //dialog - fName = QFileDialog::getOpenFileName(this, - tr("Load Script File"),dir, - tr("Script Files(*.awk);;All Files(*)")); - //if empty, set the file name and it calls setscriptfile, else ignore - if (!fName.isEmpty()){ - dispScript->setText(fName); - SetScriptFile(); - } -} - -//------------------------------------------------------------------------------------------------------------------------------------------------- - -void qActionsWidget::SetScriptFile(){ - QString fName = dispScript->text(); -#ifdef VERBOSE - cout << "Setting\taction:" << id << "\tscript:" << fName.toAscii().constData() << endl; -#endif - bool set = false; - struct stat st_buf; - - //blank - if(fName.isEmpty()) - set = true; - else if(!fName.compare("none")) - set = true; - //not blank - else{ - //path doesnt exist - if(stat(fName.toAscii().constData(),&st_buf)){ - qDefs::Message(qDefs::WARNING,"The script file entered does not exist","qActionsWidget::SetScriptFile"); - dispScript->setText(QString(myDet->getActionScript(id).c_str())); - } - //if its not a file - else if (!S_ISREG (st_buf.st_mode)) { - qDefs::Message(qDefs::WARNING,"The script file path entered is not a file","qActionsWidget::SetScriptFile"); - dispScript->setText(QString(myDet->getActionScript(id).c_str())); - } - else - set=true; - } - - - //if blank or valid file - if(set){ - //scan and positions wouldnt get here - myDet->setActionScript(id,fName.toAscii().constData()); - if(fName.compare(QString(myDet->getActionScript(id).c_str()))){ - //did not get set, write what is was before - if(!fName.isEmpty()) - qDefs::Message(qDefs::WARNING,"The script file could not be set. Reverting to previous file.","qActionsWidget::SetScriptFile"); - dispScript->setText(QString(myDet->getActionScript(id).c_str())); - } - } - - //dont display if theres a none - if(!dispScript->text().compare("none")) dispScript->setText(""); - - qDefs::checkErrorMessage(myDet,"qActionsWidget::SetScriptFile"); - -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qActionsWidget::SetParameter(){ - QString parameter = dispParameter->text(); -#ifdef VERBOSE - cout << "Setting\taction:" << id << "\tparameter:" << parameter.toAscii().constData() << endl; -#endif - myDet->setActionParameter(id,parameter.toAscii().constData()); - //dont display if theres a none - if(!dispParameter->text().compare("none")) dispParameter->setText(""); - - qDefs::checkErrorMessage(myDet,"qActionsWidget::SetParameter"); -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qActionsWidget::Refresh(){ - int mode = (myDet->getActionMode(id)>0?1:0); - string script = myDet->getActionScript(id); - string parameter = myDet->getActionParameter(id); - - - //settings values and checking for none - if(QString(script.c_str()).compare("none")) - dispScript->setText(QString(script.c_str())); - if(mode)SetScriptFile(); - dispParameter->setText(QString(parameter.c_str())); - SetParameter(); - //set mode which also checks everything - comboScript->setCurrentIndex(mode); -#ifdef VERBOSE - cout << "Updated\taction:" << id << "\t" - "mode:"< -#include -#include -#include "qwt_symbol.h" -/** C++ Include Headers */ - - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - -qCloneWidget::qCloneWidget(QWidget *parent,int id,QString title,QString xTitle, QString yTitle, QString zTitle, - int numDim,string FilePath,bool displayStats, QString min, QString max, QString sum): - QMainWindow(parent),id(id),filePath(FilePath),cloneplot1D(0),cloneplot2D(0) - { - // Window title - char winTitle[300],currTime[50]; - strcpy(currTime,GetCurrentTimeStamp()); - sprintf(winTitle,"Snapshot:%d - %s",id,currTime); - setWindowTitle(QString(winTitle)); - - marker = new QwtSymbol(); - nomarker = new QwtSymbol(); - marker->setStyle(QwtSymbol::Cross); - marker->setSize(5,5); - - // Set up widget - SetupWidgetWindow(title,xTitle, yTitle, zTitle, numDim); - DisplayStats(displayStats,min,max,sum); -} - -//------------------------------------------------------------------------------------------------------------------------------------------------- - -qCloneWidget::~qCloneWidget(){ - delete cloneplot1D; - delete cloneplot2D; - delete cloneBox; -} - -//------------------------------------------------------------------------------------------------------------------------------------------------- - -void qCloneWidget::SetupWidgetWindow(QString title, QString xTitle, QString yTitle, QString zTitle, int numDim){ - - menubar = new QMenuBar(this); - actionSave = new QAction("&Save",this); - menubar->addAction(actionSave); - setMenuBar(menubar); - - - //Main Window Layout - QWidget *centralWidget = new QWidget(this); - mainLayout = new QGridLayout(centralWidget); - centralWidget->setLayout(mainLayout); - - //plot group box - cloneBox = new QGroupBox(this); - gridClone = new QGridLayout(cloneBox); - cloneBox->setLayout(gridClone); - cloneBox->setContentsMargins(0,0,0,0); - cloneBox->setAlignment(Qt::AlignHCenter); - cloneBox->setFont(QFont("Sans Serif",11,QFont::Normal)); - cloneBox->setTitle(title); - // According to dimensions, create appropriate 1D or 2Dplot - if(numDim==1){ - cloneplot1D = new SlsQt1DPlot(cloneBox); - - cloneplot1D->setFont(QFont("Sans Serif",9,QFont::Normal)); - cloneplot1D->SetXTitle(xTitle.toAscii().constData()); - cloneplot1D->SetYTitle(yTitle.toAscii().constData()); - - - cloneBox->setFlat(false); - cloneBox->setContentsMargins(0,30,0,0); - gridClone->addWidget(cloneplot1D,0,0); - - lblHistTitle = new QLabel(""); - mainLayout->addWidget(lblHistTitle,0,0); - - }else{ - cloneplot2D = new SlsQt2DPlotLayout(cloneBox); - cloneplot2D->setFont(QFont("Sans Serif",9,QFont::Normal)); - cloneplot2D->SetXTitle(xTitle); - cloneplot2D->SetYTitle(yTitle); - cloneplot2D->SetZTitle(zTitle); - cloneplot2D->setAlignment(Qt::AlignLeft); - - cloneBox->setFlat(true); - cloneBox->setContentsMargins(0,20,0,0); - gridClone->addWidget(cloneplot2D,0,0); - } - - // main window widgets - mainLayout->addWidget(cloneBox,1,0); - setCentralWidget(centralWidget); - - // Save - connect(actionSave,SIGNAL(triggered()),this,SLOT(SavePlot())); - - setMinimumHeight(300); - resize(500,350); -} - -//------------------------------------------------------------------------------------------------------------------------------------------------- - -void qCloneWidget::SetCloneHists(int nHists,int histNBins,double* histXAxis,double* histYAxis[],string histTitle[],bool lines,bool markers){ - //for each plot, create hists - for(int hist_num=0;hist_numcloneplot1D_hists.size()){ - cloneplot1D_hists.append(k=new SlsQtH1D("1d plot",histNBins,histXAxis,histYAxis[hist_num])); - k->SetLineColor(0); - }else{ - k=cloneplot1D_hists.at(hist_num); - k->SetData(histNBins,histXAxis,histYAxis[hist_num]); - } - - - //style of plot - if(lines) k->setStyle(QwtPlotCurve::Lines); - else k->setStyle(QwtPlotCurve::Dots); -#if QWT_VERSION<0x060000 - if(markers) k->setSymbol(*marker); - else k->setSymbol(*nomarker); -#else - if(markers) k->setSymbol(marker); - else k->setSymbol(nomarker); -#endif - - //set title and attach plot - lblHistTitle->setText(QString(histTitle[0].c_str())); - - k->Attach(cloneplot1D); - } - -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qCloneWidget::SetCloneHists(int nHists,int histNBins,double* histXAxis,double* histYAxis,string histTitle[],bool lines,bool markers){ - // for each plot create hists - for(int hist_num=0;hist_numcloneplot1D_hists.size()){ - cloneplot1D_hists.append(k=new SlsQtH1D("1d plot",histNBins,histXAxis,histYAxis)); - k->SetLineColor(hist_num+1); - }else{ - k=cloneplot1D_hists.at(hist_num); - k->SetData(histNBins,histXAxis,histYAxis); - } - //style of plot - if(lines) k->setStyle(QwtPlotCurve::Lines); - else k->setStyle(QwtPlotCurve::Dots); - if(markers) { - QwtSymbol *marker = new QwtSymbol(); - marker->setStyle(QwtSymbol::Cross); - marker->setSize(5,5); -#if QWT_VERSION<0x060000 - k->setSymbol(*marker); -#else - k->setSymbol(marker); -#endif - }else { - QwtSymbol *noMarker = new QwtSymbol(); -#if QWT_VERSION<0x060000 - k->setSymbol(*noMarker); -#else - k->setSymbol(noMarker); -#endif - } - //set title and attach plot - lblHistTitle->setText(QString(histTitle[0].c_str())); - k->Attach(cloneplot1D); - } -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qCloneWidget::SetCloneHists2D(int nbinsx,double xmin,double xmax,int nbinsy, double ymin, double ymax, double *d){ - cloneplot2D->GetPlot()->SetData(nbinsx,xmin,xmax,nbinsy,ymin,ymax,d); - cloneplot2D->UpdateNKeepSetRangeIfSet(); -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - - -void qCloneWidget::SetRange(bool IsXYRange[],double XYRangeValues[]){ - double XYCloneRangeValues[4]; - - if(!IsXYRange[qDefs::XMINIMUM]){ - if(cloneplot1D) XYCloneRangeValues[qDefs::XMINIMUM]= cloneplot1D->GetXMinimum(); - else XYCloneRangeValues[qDefs::XMINIMUM]= cloneplot2D->GetPlot()->GetXMinimum(); - }else XYCloneRangeValues[qDefs::XMINIMUM]= XYRangeValues[qDefs::XMINIMUM]; - - if(!IsXYRange[qDefs::XMAXIMUM]){ - if(cloneplot1D) XYCloneRangeValues[qDefs::XMAXIMUM]= cloneplot1D->GetXMaximum(); - else XYCloneRangeValues[qDefs::XMINIMUM]= cloneplot2D->GetPlot()->GetXMaximum(); - }else XYCloneRangeValues[qDefs::XMAXIMUM]= XYRangeValues[qDefs::XMAXIMUM]; - - if(!IsXYRange[qDefs::YMINIMUM]){ - if(cloneplot1D) XYCloneRangeValues[qDefs::YMINIMUM]= cloneplot1D->GetYMinimum(); - else XYCloneRangeValues[qDefs::XMINIMUM]= cloneplot2D->GetPlot()->GetYMinimum(); - }else XYCloneRangeValues[qDefs::YMINIMUM]= XYRangeValues[qDefs::YMINIMUM]; - - if(!IsXYRange[qDefs::YMAXIMUM]){ - if(cloneplot1D) XYCloneRangeValues[qDefs::YMAXIMUM]= cloneplot1D->GetYMaximum(); - else XYCloneRangeValues[qDefs::XMINIMUM]= cloneplot2D->GetPlot()->GetYMaximum(); - }else XYCloneRangeValues[qDefs::YMAXIMUM]= XYRangeValues[qDefs::YMAXIMUM]; - - if(cloneplot1D){ - cloneplot1D->SetXMinMax(XYCloneRangeValues[qDefs::XMINIMUM],XYCloneRangeValues[qDefs::XMAXIMUM]); - cloneplot1D->SetYMinMax(XYCloneRangeValues[qDefs::YMINIMUM],XYCloneRangeValues[qDefs::YMAXIMUM]); - }else{ - cloneplot2D->GetPlot()->SetXMinMax(XYRangeValues[qDefs::XMINIMUM],XYRangeValues[qDefs::XMAXIMUM]); - cloneplot2D->GetPlot()->SetYMinMax(XYRangeValues[qDefs::YMINIMUM],XYRangeValues[qDefs::YMAXIMUM]); - cloneplot2D->GetPlot()->Update(); - } -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -char* qCloneWidget::GetCurrentTimeStamp(){ - char output[30]; - char *result; - - //using sys cmds to get output or str - FILE* sysFile = popen("date", "r"); - fgets(output, sizeof(output), sysFile); - pclose(sysFile); - - result = output + 0; - return result; -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - -void qCloneWidget::SavePlot(){ - char cID[10]; - sprintf(cID,"%d",id); - //title - QString fName = QString(filePath.c_str()); - if(cloneBox->title().contains('.')){ - fName.append(QString('/')+cloneBox->title()); - fName.replace(".dat",".png"); - fName.replace(".raw",".png"); - }else fName.append(QString("/Snapshot_unknown_title.png")); - //save - QImage img(cloneBox->size().width(),cloneBox->size().height(),QImage::Format_RGB32); - QPainter painter(&img); - cloneBox->render(&painter); - - fName = QFileDialog::getSaveFileName(this,tr("Save Snapshot "),fName,tr("PNG Files (*.png);;XPM Files(*.xpm);;JPEG Files(*.jpg)"),0,QFileDialog::ShowDirsOnly); - if (!fName.isEmpty()) { - if((img.save(fName))) - qDefs::Message(qDefs::INFORMATION,"The SnapShot has been successfully saved","qCloneWidget::SavePlot"); - else - qDefs::Message(qDefs::WARNING,"Attempt to save snapshot failed.\n" - "Formats: .png, .jpg, .xpm.","qCloneWidget::SavePlot"); - } -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -int qCloneWidget::SavePlotAutomatic(){ - char cID[10]; - sprintf(cID,"%d",id); - //title - QString fName = QString(filePath.c_str()); - if(cloneBox->title().contains('.')){ - fName.append(QString('/')+cloneBox->title()); - fName.replace(".dat",".png"); - fName.replace(".raw",".png"); - }else fName.append(QString("/Snapshot_unknown_title.png")); - cout<<"fname:"<size().width(),cloneBox->size().height(),QImage::Format_RGB32); - QPainter painter(&img); - cloneBox->render(&painter); - if(img.save(fName)) - return 0; - else return -1; - -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qCloneWidget::closeEvent(QCloseEvent* event){ - emit CloneClosedSignal(id); - event->accept(); -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qCloneWidget::DisplayStats(bool enable, QString min, QString max, QString sum){ - if(enable){ - QWidget *widgetStatistics = new QWidget(this); - widgetStatistics->setFixedHeight(15); - QHBoxLayout *hl1 = new QHBoxLayout; - hl1->setSpacing(0); - hl1->setContentsMargins(0, 0, 0, 0); - QLabel *lblMin = new QLabel("Min: "); - lblMin->setFixedWidth(40); - lblMin->setAlignment(Qt::AlignRight); - QLabel *lblMax = new QLabel("Max: "); - lblMax->setFixedWidth(40); - lblMax->setAlignment(Qt::AlignRight); - QLabel *lblSum = new QLabel("Sum: "); - lblSum->setFixedWidth(40); - lblSum->setAlignment(Qt::AlignRight); - QLabel *lblMinDisp = new QLabel(min); - lblMinDisp->setAlignment(Qt::AlignLeft); - QLabel *lblMaxDisp = new QLabel(max); - lblMaxDisp->setAlignment(Qt::AlignLeft); - QLabel *lblSumDisp = new QLabel(sum); - lblSumDisp->setAlignment(Qt::AlignLeft); - hl1->addItem(new QSpacerItem(20,20,QSizePolicy::Fixed,QSizePolicy::Fixed)); - hl1->addWidget(lblMin); - hl1->addWidget(lblMinDisp); - hl1->addItem(new QSpacerItem(20,20,QSizePolicy::Expanding,QSizePolicy::Fixed)); - hl1->addWidget(lblMax); - hl1->addWidget(lblMaxDisp); - hl1->addItem(new QSpacerItem(20,20,QSizePolicy::Expanding,QSizePolicy::Fixed)); - hl1->addWidget(lblSum); - hl1->addWidget(lblSumDisp); - hl1->addItem(new QSpacerItem(20,20,QSizePolicy::Fixed,QSizePolicy::Fixed)); - widgetStatistics->setLayout(hl1); - mainLayout->addWidget(widgetStatistics,2,0); - widgetStatistics->show(); - - } -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - diff --git a/slsDetectorGui/src/qDetectorMain.cpp b/slsDetectorGui/src/qDetectorMain.cpp deleted file mode 100644 index c2f6013a3..000000000 --- a/slsDetectorGui/src/qDetectorMain.cpp +++ /dev/null @@ -1,908 +0,0 @@ -/********************************************************************** - * TO DO - * 1. settcpsocket is done with slsdetector.maybe do for all detectors connected: mythen - * ********************************************************************/ -// Qt Project Class Headers -#include "qDetectorMain.h" -#include "qTabDataOutput.h" -#include "qTabPlot.h" -#include "qTabActions.h" -#include "qTabAdvanced.h" -#include "qTabSettings.h" -#include "qTabDebugging.h" -#include "qTabDeveloper.h" -#include "qTabMessages.h" -#include "qServer.h" -// Project Class Headers -#include "slsDetector.h" -#include "multiSlsDetector.h" -#include "sls_detector_defs.h" -#include "gitInfoGui.h" -// Qt Include Headers -#include -#include -#include -// C++ Include Headers -#include -#include -#include -using namespace std; - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - -int main (int argc, char **argv) { - QApplication *theApp = new QApplication(argc, argv); - // QApplication *theApp = new QApplication(argc, argv); - theApp->setStyle(new QPlastiqueStyle);//not default when desktop is windows - theApp->setWindowIcon(QIcon( ":/icons/images/mountain.png" )); - int ret = 1; - qDetectorMain *det=new qDetectorMain(argc, argv, theApp,ret,0); - if (ret == 1) - return EXIT_FAILURE; - det->show(); - //theApp->connect( theApp, SIGNAL(lastWindowClosed()), theApp, SLOT(quit())); - return theApp->exec(); -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -qDetectorMain::qDetectorMain(int argc, char **argv, QApplication *app, int& ret, QWidget *parent) : - QMainWindow(parent), theApp(app),myDet(0),detID(0),myPlot(0),tabs(0),isDeveloper(0){ - - // options - string fname = ""; - int64_t tempval = 0; - - //parse command line for config - static struct option long_options[] = { - // These options set a flag. - //{"verbose", no_argument, &verbose_flag, 1}, - // These options don’t set a flag. We distinguish them by their indices. - { "developer", no_argument, 0, 'd' }, - { "config", required_argument, 0, 'f' }, - { "id", required_argument, 0, 'i' }, - {"version", no_argument, 0, 'v'}, - { "help", no_argument, 0, 'h' }, - { 0, 0, 0, 0 } - }; - - - // getopt_long stores the option index here. - int option_index = 0; - int c = 0; - - while ( c != -1 ){ - c = getopt_long (argc, argv, "hvdf:i:", long_options, &option_index); - - // Detect the end of the options. - if (c == -1) - break; - - switch(c){ - - case 'f': - fname=string(optarg); -#ifdef VERYVERBOSE - cout << long_options[option_index].name << " " << optarg << endl; -#endif - break; - - case 'd' : - isDeveloper = 1; - break; - - case 'i' : - detID=atoi(optarg); - break; - - case 'v': - tempval = GITDATE; - cout << "SLS Detector GUI " << GITBRANCH << " (0x" << hex << tempval << ")" << endl; - return; - - case 'h': - default: - string help_message = "\n" - + string(argv[0]) + "\n" - + "Usage: " + string(argv[0]) + " [arguments]\n" - + "Possible arguments are:\n" - + "\t-d, --developer : Enables the developer tab\n" - + "\t-f, --config : Loads config from file\n" - + "\t-i, --id : Sets the multi detector id to i. Default: 0. Required \n" - + "\t only when more than one multi detector object is needed.\n\n"; - cout << help_message << endl; - return; - - } - } - - setupUi(this); - SetUpDetector(fname); - SetUpWidgetWindow(); - Initialization(); - ret = 0; -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -qDetectorMain::~qDetectorMain(){ - if(myDet) delete myDet; - if (menubar) delete menubar; - if (centralwidget) delete centralwidget; -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qDetectorMain::SetUpWidgetWindow(){ - -// Layout - layoutTabs= new QGridLayout; - centralwidget->setLayout(layoutTabs); - -//plot setup - myPlot = new qDrawPlot(dockWidgetPlot,myDet); cout<<"DockPlot ready"<setWidget(myPlot); - -//tabs setup - tabs = new MyTabWidget(this); - layoutTabs->addWidget(tabs); - - -// creating all the other tab widgets - tab_measurement = new qTabMeasurement (this, myDet,myPlot); cout<<"Measurement ready"<setFrameShape(QFrame::NoFrame); - } - // setting the tab widgets to the scrollareas - scroll[Measurement] ->setWidget(tab_measurement); - scroll[DataOutput] ->setWidget(tab_dataoutput); - scroll[Plot] ->setWidget(tab_plot); - scroll[Actions] ->setWidget(tab_actions); - scroll[Settings] ->setWidget(tab_settings); - scroll[Advanced] ->setWidget(tab_advanced); - scroll[Debugging] ->setWidget(tab_debugging); - scroll[Developer] ->setWidget(tab_developer); - // inserting all the tabs - tabs->insertTab(Measurement, scroll[Measurement], "Measurement"); - tabs->insertTab(DataOutput, scroll[DataOutput], "Data Output"); - tabs->insertTab(Plot, scroll[Plot], "Plot"); - tabs->insertTab(Actions, scroll[Actions], "Actions"); - tabs->insertTab(Settings, scroll[Settings], "Settings"); - tabs->insertTab(Advanced, scroll[Advanced], "Advanced"); - tabs->insertTab(Debugging, scroll[Debugging], "Debugging"); - tabs->insertTab(Developer, scroll[Developer], "Developer"); - //no scroll buttons this way - tabs->insertTab(Messages, tab_messages, "Messages"); - -//swap tabs so that messages is last tab - tabs->tabBar()->moveTab(tabs->indexOf(tab_measurement), Measurement); - tabs->tabBar()->moveTab(tabs->indexOf(tab_settings), Settings); - tabs->tabBar()->moveTab(tabs->indexOf(tab_dataoutput), DataOutput); - tabs->tabBar()->moveTab(tabs->indexOf(tab_plot), Plot); - tabs->tabBar()->moveTab(tabs->indexOf(tab_actions), Actions); - tabs->tabBar()->moveTab(tabs->indexOf(tab_advanced), Advanced); - tabs->tabBar()->moveTab(tabs->indexOf(tab_debugging), Debugging); - tabs->tabBar()->moveTab(tabs->indexOf(tab_developer), Developer); - tabs->tabBar()->moveTab(tabs->indexOf(tab_messages), Messages); - tabs->setCurrentIndex(Measurement); - -//other tab properties - // Default tab color - defaultTabColor = tabs->tabBar()->tabTextColor(DataOutput); - //Set the current tab(measurement) to blue as it is the current one - tabs->tabBar()->setTabTextColor(0,QColor(0,0,200,255)); - // increase the width so it uses all the empty space for the tab titles - tabs->tabBar()->setFixedWidth(width()+61); - - // mode setup - to set up the tabs initially as disabled, not in form so done here -#ifdef VERBOSE - cout << "Setting Debug Mode to 0\nSetting Expert Mode to 0\nSetting Developer Mode to " << isDeveloper << "\nSetting Dockable Mode to false\n" << endl; -#endif - tabs->setTabEnabled(Debugging,false); - tabs->setTabEnabled(Advanced,false); - tabs->setTabEnabled(Developer,isDeveloper); - actionLoadTrimbits->setVisible(false); - actionSaveTrimbits->setVisible(false); - actionLoadCalibration->setVisible(false); - actionSaveCalibration->setVisible(false); - - dockWidgetPlot->setFloating(false); - dockWidgetPlot->setFeatures(QDockWidget::NoDockWidgetFeatures); - -// Other setup - //Height of plot and central widget - heightPlotWindow = dockWidgetPlot->size().height(); - heightCentralWidget = centralwidget->size().height(); - // Default zoom Tool Tip - zoomToolTip = dockWidgetPlot->toolTip(); - - -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qDetectorMain::SetUpDetector(const string fName){ - - - //instantiate detector and set window title - myDet = new multiSlsDetector(detID); - - //create messages tab to capture config file loading logs - tab_messages = new qTabMessages (this); cout<<"Messages ready"<getHostname(); - qDefs::checkErrorMessage(myDet,"qDetectorMain::SetUpDetector"); - - //if hostname doesnt exist even in shared memory - if(!host.length()){ - cout << endl << "No Detector Connected." << endl; - qDefs::Message(qDefs::CRITICAL,"No Detectors Connected. ","qDetectorMain::SetUpDetector"); - exit(-1); - } - - //check if the detector is not even connected - string offline = myDet->checkOnline(); - qDefs::checkErrorMessage(myDet,"qDetectorMain::SetUpDetector"); - - if(!offline.empty()){ - qDefs::Message(qDefs::CRITICAL,string("The detector(s) ")+offline+string(" is/are not connected. Exiting GUI."),"qDetectorMain::SetUpDetector"); - cout << "The detector(s) " << host << " is/are not connected. Exiting GUI." << endl; - exit(-1); - } - - // Check if type valid. If not, exit - slsDetectorDefs::detectorType detType = myDet->getDetectorsType(); - qDefs::checkErrorMessage(myDet,"qDetectorMain::SetUpDetector"); - - switch(detType){ - case slsDetectorDefs::MYTHEN: break; - case slsDetectorDefs::EIGER: break; - case slsDetectorDefs::GOTTHARD: - case slsDetectorDefs::AGIPD: - case slsDetectorDefs::PROPIX: - case slsDetectorDefs::MOENCH: - case slsDetectorDefs::JUNGFRAU: - case slsDetectorDefs::JUNGFRAUCTB: - actionLoadTrimbits->setText("Load Settings"); actionSaveTrimbits->setText("Save Settings"); - break; - default: - string detName = myDet->slsDetectorBase::getDetectorType(detType); - qDefs::checkErrorMessage(myDet,"qDetectorMain::SetUpDetector"); - cout << "ERROR: " + host + " has unknown detector type \"" + detName + "\". Exiting GUI." << endl; - string errorMess = host+string(" has unknown detector type \"")+ - detName+string("\". Exiting GUI."); - qDefs::Message(qDefs::CRITICAL,errorMess,"qDetectorMain::SetUpDetector"); - exit(-1); - } - setWindowTitle("SLS Detector GUI : "+ - QString(slsDetectorBase::getDetectorType(detType).c_str())+ " - "+QString(host.c_str())); -//#ifdef VERBOSE - cout << endl << "Type : " << slsDetectorBase::getDetectorType(detType) << "\nDetector : " << host << endl; -//#endif - myDet->setOnline(slsDetectorDefs::ONLINE_FLAG); - if(detType != slsDetectorDefs::MYTHEN) - myDet->setReceiverOnline(slsDetectorDefs::ONLINE_FLAG); - qDefs::checkErrorMessage(myDet,"qDetectorMain::SetUpDetector"); -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qDetectorMain::Initialization(){ -// Dockable Plot - connect(dockWidgetPlot, SIGNAL(topLevelChanged(bool)), this,SLOT(ResizeMainWindow(bool))); -// tabs - connect(tabs, SIGNAL(currentChanged(int)), this, SLOT(Refresh(int)));//( QWidget*))); - // Measurement tab - connect(tab_measurement, SIGNAL(StartSignal()), this,SLOT(EnableTabs())); - connect(tab_measurement, SIGNAL(StopSignal()), myPlot,SLOT(StopAcquisition())); - connect(tab_measurement, SIGNAL(CheckPlotIntervalSignal()), tab_plot,SLOT(SetFrequency())); - // Data Output Tab - connect(tab_dataoutput, SIGNAL(AngularConversionSignal(bool)), tab_actions,SLOT(EnablePositions(bool))); - //enable scanbox( for angles) - connect(tab_dataoutput, SIGNAL(AngularConversionSignal(bool)), tab_plot,SLOT(EnableScanBox())); - // Plot tab - connect(tab_plot, SIGNAL(DisableZoomSignal(bool)), this,SLOT(SetZoomToolTip(bool))); - // Actions tab (only for scan) - connect(tab_actions, SIGNAL(EnableScanBox()), tab_plot,SLOT(EnableScanBox())); - //settings to advanced tab(int is always 0 to only refresh) - connect(tab_settings, SIGNAL(UpdateTrimbitSignal(int)), tab_advanced,SLOT(UpdateTrimbitPlot(int))); -// Plotting - // When the acquisition is finished, must update the meas tab - connect(myPlot, SIGNAL(UpdatingPlotFinished()), this, SLOT(EnableTabs())); - connect(myPlot, SIGNAL(UpdatingPlotFinished()), tab_measurement, SLOT(UpdateFinished())); - //This should not be called as it will change file name to measurement when run finished - //connect(myPlot, SIGNAL(UpdatingPlotFinished()), tab_plot, SLOT(Refresh())); - connect(myPlot, SIGNAL(SetCurrentMeasurementSignal(int)), tab_measurement, SLOT(SetCurrentMeasurement(int))); - - -// menubar - // Modes Menu - connect(menuModes, SIGNAL(triggered(QAction*)), this,SLOT(EnableModes(QAction*))); - // Utilities Menu - connect(menuUtilities, SIGNAL(triggered(QAction*)), this,SLOT(ExecuteUtilities(QAction*))); - // Help Menu - connect(menuHelp, SIGNAL(triggered(QAction*)), this,SLOT(ExecuteHelp(QAction*))); - - -//server - connect(myServer, SIGNAL(ServerStoppedSignal()), this,SLOT(UncheckServer())); -} - - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qDetectorMain::LoadConfigFile(const string fName){ -#ifdef VERBOSE - cout << "Loading config file at start up:" << fName << endl; -#endif - struct stat st_buf; - QString file = QString(fName.c_str()); - - //path doesnt exist - if(stat(fName.c_str(),&st_buf)) - qDefs::Message(qDefs::WARNING,string("Start up configuration failed to load. The following file does not exist:
")+fName,"qDetectorMain::LoadConfigFile"); - - //not a file - else if (!S_ISREG (st_buf.st_mode)) - qDefs::Message(qDefs::WARNING,string("Start up configuration failed to load. The following file is not a recognized file format:
")+fName,"qDetectorMain::LoadConfigFile"); - - else{ - //could not load config file - if(myDet->readConfigurationFile(fName)==slsDetectorDefs::FAIL) - qDefs::Message(qDefs::WARNING,string("Could not load all the Configuration Parameters from file:
")+fName,"qDetectorMain::LoadConfigFile"); - //successful - else - qDefs::Message(qDefs::INFORMATION,"
The Configuration Parameters have been loaded successfully at start up.","qDetectorMain::LoadConfigFile"); - - qDefs::checkErrorMessage(myDet,"qDetectorMain::LoadConfigFile"); - } -} - - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qDetectorMain::EnableModes(QAction *action){ - bool enable; - - //listen to gui client - if(action==actionListenGuiClient){ - - myServer->StartStopServer(actionListenGuiClient->isChecked()); - - //disconnect(menuModes, SIGNAL(triggered(QAction*)), this,SLOT(EnableModes(QAction*))); - //actionListenGuiClient->setChecked(myServer->StartStopServer(actionListenGuiClient->isChecked())); - //connect(menuModes, SIGNAL(triggered(QAction*)), this,SLOT(EnableModes(QAction*))); - } - //Set DebugMode - else if(action==actionDebug){ - enable = actionDebug->isChecked(); - tabs->setTabEnabled(Debugging,enable); -#ifdef VERBOSE - cout << "Setting Debug Mode to " << enable << endl; -#endif - } - - //Set ExpertMode(comes here only if its a digital detector) - else if(action==actionExpert){ - enable = actionExpert->isChecked(); - - tabs->setTabEnabled(Advanced,enable); - actionLoadTrimbits->setVisible(enable); - actionSaveTrimbits->setVisible(enable); - actionLoadCalibration->setVisible(enable); - actionSaveCalibration->setVisible(enable); - tab_measurement->SetExpertMode(enable); - tab_settings->SetExpertMode(enable); -#ifdef VERBOSE - cout << "Setting Expert Mode to " << enable << endl; -#endif - } - - //Set DockableMode - else{ - enable = actionDockable->isChecked(); - if(enable) - dockWidgetPlot->setFeatures(QDockWidget::DockWidgetFloatable); - else{ - dockWidgetPlot->setFloating(false); - dockWidgetPlot->setFeatures(QDockWidget::NoDockWidgetFeatures); - } -#ifdef VERBOSE - cout << "Setting Dockable Mode to " << enable << endl; -#endif - } -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qDetectorMain::ExecuteUtilities(QAction *action){ - bool refreshTabs = false; - if(action==actionOpenSetup){ -#ifdef VERBOSE - cout << "Loading Setup" << endl; -#endif - QString fName = QString(myDet->getFilePath().c_str()); - qDefs::checkErrorMessage(myDet,"qDetectorMain::ExecuteUtilities"); - fName = QFileDialog::getOpenFileName(this, - tr("Load Detector Setup"),fName, - tr("Detector Setup files (*.det);;All Files(*)")); - // Gets called when cancelled as well - if (!fName.isEmpty()){ - if(myDet->retrieveDetectorSetup(string(fName.toAscii().constData()))!=slsDetectorDefs::FAIL){ - qDefs::Message(qDefs::INFORMATION,"The Setup Parameters have been loaded successfully.","qDetectorMain::ExecuteUtilities"); - refreshTabs=true; - }else qDefs::Message(qDefs::WARNING,string("Could not load the Setup Parameters from file:\n")+fName.toAscii().constData(),"qDetectorMain::ExecuteUtilities"); - qDefs::checkErrorMessage(myDet,"qDetectorMain::ExecuteUtilities"); - } - } - else if(action==actionSaveSetup){ -#ifdef VERBOSE - cout << "Saving Setup" << endl; -#endif - QString fName = QString(myDet->getFilePath().c_str()); - qDefs::checkErrorMessage(myDet,"qDetectorMain::ExecuteUtilities"); - fName = QFileDialog::getSaveFileName(this, - tr("Save Current Detector Setup"),fName, - tr("Detector Setup files (*.det);;All Files(*) ")); - // Gets called when cancelled as well - if (!fName.isEmpty()){ - if(myDet->dumpDetectorSetup(string(fName.toAscii().constData()))!=slsDetectorDefs::FAIL) - qDefs::Message(qDefs::INFORMATION,"The Setup Parameters have been saved successfully.","qDetectorMain::ExecuteUtilities"); - else qDefs::Message(qDefs::WARNING,string("Could not save the Setup Parameters from file:\n")+fName.toAscii().constData(),"qDetectorMain::ExecuteUtilities"); - qDefs::checkErrorMessage(myDet,"qDetectorMain::ExecuteUtilities"); - } - } - else if(action==actionOpenConfiguration){ -#ifdef VERBOSE - cout << "Loading Configuration" << endl; -#endif - QString fName = QString(myDet->getFilePath().c_str()); - qDefs::checkErrorMessage(myDet,"qDetectorMain::ExecuteUtilities"); - fName = QFileDialog::getOpenFileName(this, - tr("Load Detector Configuration"),fName, - tr("Configuration files (*.config);;All Files(*)")); - // Gets called when cancelled as well - if (!fName.isEmpty()){ - if(myDet->readConfigurationFile(string(fName.toAscii().constData()))!=slsDetectorDefs::FAIL){ - qDefs::Message(qDefs::INFORMATION,"The Configuration Parameters have been configured successfully.","qDetectorMain::ExecuteUtilities"); - refreshTabs=true; - }else qDefs::Message(qDefs::WARNING,string("Could not load all the Configuration Parameters from file:\n")+fName.toAscii().constData(),"qDetectorMain::ExecuteUtilities"); - qDefs::checkErrorMessage(myDet,"qDetectorMain::ExecuteUtilities"); - } - } - else if(action==actionSaveConfiguration){ -#ifdef VERBOSE - cout << "Saving Configuration" << endl; -#endif - QString fName = QString(myDet->getFilePath().c_str()); - qDefs::checkErrorMessage(myDet,"qDetectorMain::ExecuteUtilities"); - fName = QFileDialog::getSaveFileName(this, - tr("Save Current Detector Configuration"),fName, - tr("Configuration files (*.config) ;;All Files(*)")); - // Gets called when cancelled as well - if (!fName.isEmpty()){ - if(myDet->writeConfigurationFile(string(fName.toAscii().constData()))!=slsDetectorDefs::FAIL) - qDefs::Message(qDefs::INFORMATION,"The Configuration Parameters have been saved successfully.","qDetectorMain::ExecuteUtilities"); - else qDefs::Message(qDefs::WARNING,string("Could not save the Configuration Parameters from file:\n")+fName.toAscii().constData(),"qDetectorMain::ExecuteUtilities"); - qDefs::checkErrorMessage(myDet,"qDetectorMain::ExecuteUtilities"); - } - } - else if(action==actionLoadTrimbits){ - QString fName = QString( (myDet->getSettingsDir()).c_str()); - qDefs::checkErrorMessage(myDet,"qDetectorMain::ExecuteUtilities"); - //gotthard - if(actionLoadTrimbits->text().contains("Settings")){ -#ifdef VERBOSE - cout << "Loading Settings" << endl; -#endif - fName = QFileDialog::getOpenFileName(this, - tr("Load Detector Settings"),fName, - tr("Settings files (*.settings settings.sn*);;All Files(*)")); - // Gets called when cancelled as well - if (!fName.isEmpty()){ - if(myDet->loadSettingsFile(string(fName.toAscii().constData()),-1)!=slsDetectorDefs::FAIL) - qDefs::Message(qDefs::INFORMATION,"The Settings have been loaded successfully.","qDetectorMain::ExecuteUtilities"); - else qDefs::Message(qDefs::WARNING,string("Could not load the Settings from file:\n")+fName.toAscii().constData(),"qDetectorMain::ExecuteUtilities"); - qDefs::checkErrorMessage(myDet,"qDetectorMain::ExecuteUtilities"); - } - - }//mythen and eiger - else{ -#ifdef VERBOSE - cout << "Loading Trimbits" << endl; -#endif - //so that even nonexisting files can be selected - QFileDialog *fileDialog = new QFileDialog(this, - tr("Load Detector Trimbits"),fName, - tr("Trimbit files (*.trim noise.sn*);;All Files(*)")); - fileDialog->setFileMode(QFileDialog::AnyFile ); - if ( fileDialog->exec() == QDialog::Accepted ) - fName = fileDialog->selectedFiles()[0]; - - // Gets called when cancelled as well - if (!fName.isEmpty()){ - if(myDet->loadSettingsFile(string(fName.toAscii().constData()),-1)!=slsDetectorDefs::FAIL) - qDefs::Message(qDefs::INFORMATION,"The Trimbits have been loaded successfully.","qDetectorMain::ExecuteUtilities"); - else qDefs::Message(qDefs::WARNING,string("Could not load the Trimbits from file:\n")+fName.toAscii().constData(),"qDetectorMain::ExecuteUtilities"); - qDefs::checkErrorMessage(myDet,"qDetectorMain::ExecuteUtilities"); - } - } - } - else if(action==actionSaveTrimbits){ - //gotthard - if(actionLoadTrimbits->text().contains("Settings")){ -#ifdef VERBOSE - cout << "Saving Settings" << endl; -#endif - //different output directory so as not to overwrite - QString fName = QString( (myDet->getSettingsDir()).c_str() ); - qDefs::checkErrorMessage(myDet,"qDetectorMain::ExecuteUtilities"); - fName = QFileDialog::getSaveFileName(this, - tr("Save Current Detector Settings"),fName, - tr("Settings files (*.settings settings.sn*);;All Files(*) ")); - // Gets called when cancelled as well - if (!fName.isEmpty()){ - if(myDet->saveSettingsFile(string(fName.toAscii().constData()),-1)!=slsDetectorDefs::FAIL) - qDefs::Message(qDefs::INFORMATION,"The Settings have been saved successfully.","qDetectorMain::ExecuteUtilities"); - else qDefs::Message(qDefs::WARNING,string("Could not save the Settings to file:\n")+fName.toAscii().constData(),"qDetectorMain::ExecuteUtilities"); - qDefs::checkErrorMessage(myDet,"qDetectorMain::ExecuteUtilities"); - } - }//mythen and eiger - else{ -#ifdef VERBOSE - cout << "Saving Trimbits" << endl; -#endif//different output directory so as not to overwrite - QString fName = QString( (myDet->getSettingsDir()).c_str() ); - qDefs::checkErrorMessage(myDet,"qDetectorMain::ExecuteUtilities"); - fName = QFileDialog::getSaveFileName(this, - tr("Save Current Detector Trimbits"),fName, - tr("Trimbit files (*.trim noise.sn*) ;;All Files(*)")); - // Gets called when cancelled as well - if (!fName.isEmpty()){ - if(myDet->saveSettingsFile(string(fName.toAscii().constData()),-1)!=slsDetectorDefs::FAIL) - qDefs::Message(qDefs::INFORMATION,"The Trimbits have been saved successfully.","qDetectorMain::ExecuteUtilities"); - else qDefs::Message(qDefs::WARNING,string("Could not save the Trimbits to file:\n")+fName.toAscii().constData(),"qDetectorMain::ExecuteUtilities"); - qDefs::checkErrorMessage(myDet,"qDetectorMain::ExecuteUtilities"); - } - } - } - else if(action==actionLoadCalibration){ -#ifdef VERBOSE - cout << "Loading Calibration Data" << endl; -#endif - QString fName = QString( (myDet->getCalDir()).c_str() ); - qDefs::checkErrorMessage(myDet); - - //so that even nonexisting files can be selected - QFileDialog *fileDialog = new QFileDialog(this, - tr("Load Detector Calibration Data"),fName, - tr("Calibration files (*.cal calibration.sn*);;All Files(*)")); - fileDialog->setFileMode(QFileDialog::AnyFile ); - if ( fileDialog->exec() == QDialog::Accepted ) - fName = fileDialog->selectedFiles()[0]; - - // Gets called when cancelled as well - if (!fName.isEmpty()){ - if(myDet->loadCalibrationFile(string(fName.toAscii().constData()),-1)!=slsDetectorDefs::FAIL) - qDefs::Message(qDefs::INFORMATION,"The Calibration Data have been loaded successfully.","qDetectorMain::ExecuteUtilities"); - else qDefs::Message(qDefs::WARNING,string("Could not load the Calibration data from file:\n")+ fName.toAscii().constData(),"qDetectorMain::ExecuteUtilities"); - qDefs::checkErrorMessage(myDet,"qDetectorMain::ExecuteUtilities"); - } - } - else if(action==actionSaveCalibration){ -#ifdef VERBOSE - cout << "Saving Calibration Data" << endl; -#endif//different output directory so as not to overwrite - QString fName = QString( (myDet->getCalDir()).c_str() ); - qDefs::checkErrorMessage(myDet); - fName = QFileDialog::getSaveFileName(this, - tr("Save Current Detector Calibration Data"),fName, - tr("Calibration files (*.cal calibration.sn*);;All Files(*) ")); - // Gets called when cancelled as well - if (!fName.isEmpty()){ - if(myDet->saveCalibrationFile(string(fName.toAscii().constData()),-1)!=slsDetectorDefs::FAIL) - qDefs::Message(qDefs::INFORMATION,"The Calibration Data have been saved successfully.","qDetectorMain::ExecuteUtilities"); - else qDefs::Message(qDefs::WARNING,string("Could not save the Calibration data to file:\n")+fName.toAscii().constData(),"qDetectorMain::ExecuteUtilities"); - qDefs::checkErrorMessage(myDet,"qDetectorMain::ExecuteUtilities"); - } - } - - Refresh(tabs->currentIndex()); - if(refreshTabs){ - tab_actions->Refresh(); - tab_measurement->Refresh(); - tab_settings->Refresh(); - tab_dataoutput->Refresh(); - if(tab_advanced->isEnabled()) tab_advanced->Refresh(); - if(tab_debugging->isEnabled()) tab_debugging->Refresh(); - if(tab_developer->isEnabled()) tab_developer->Refresh(); - - tab_plot->Refresh(); - } -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qDetectorMain::ExecuteHelp(QAction *action){ - if(action==actionAbout){ -#ifdef VERBOSE - cout << "About: Common GUI for Mythen, Eiger, Gotthard, Jungfrau, Moench and Propix detectors" << endl; -#endif - char version[200]; - long long unsigned int retval= GITDATE; - sprintf(version,"%llx",retval); - string thisGUIVersion = string(version); - - sprintf(version,"%llx",(long long unsigned int)myDet->getId(slsDetectorDefs::THIS_SOFTWARE_VERSION)); - qDefs::checkErrorMessage(myDet,"qDetectorMain::ExecuteHelp"); - string thisClientVersion = string(version); - - //

A heading

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Sub Frame Period " - "should be greater than or equal to " - "Sub Frame Exposure Time.
"); - - - - detType = myDet->getDetectorsType(); - switch(detType){ - case slsDetectorDefs::MYTHEN: - isEnergy = true; - isAngular = true; - spinZmqPort->setEnabled(false); - spinZmqPort2->setEnabled(false); - dispZMQIP->setEnabled(false); - dispZMQIP2->setEnabled(false); - break; - case slsDetectorDefs::EIGER: - isEnergy = true; - isAngular = false; - lblIP->setEnabled(true); - lblMAC->setEnabled(true); - dispIP->setEnabled(true); - dispMAC->setEnabled(true); - boxRxr->setEnabled(true); - boxSetAllTrimbits->setEnabled(true); - lblSubExpTime->setEnabled(true); - spinSubExpTime->setEnabled(true); - comboSubExpTimeUnit->setEnabled(true); - lblSubPeriod->setEnabled(true); - spinSubPeriod->setEnabled(true); - comboSubPeriodUnit->setEnabled(true); - break; - case slsDetectorDefs::MOENCH: - isEnergy = false; - isAngular = false; - lblIP->setEnabled(true); - lblMAC->setEnabled(true); - dispIP->setEnabled(true); - dispMAC->setEnabled(true); - boxRxr->setEnabled(true); - break; - case slsDetectorDefs::GOTTHARD: - isEnergy = false; - isAngular = true; - lblIP->setEnabled(true); - lblMAC->setEnabled(true); - dispIP->setEnabled(true); - dispMAC->setEnabled(true); - boxRxr->setEnabled(true); - break; - case slsDetectorDefs::JUNGFRAU: - case slsDetectorDefs::JUNGFRAUCTB: - isEnergy = false; - isAngular = false; - lblIP->setEnabled(true); - lblMAC->setEnabled(true); - dispIP->setEnabled(true); - dispMAC->setEnabled(true); - boxRxr->setEnabled(true); - break; - default: break; - } - - - //logs and trimming - if(!isAngular && !isEnergy) boxLogs->setEnabled(false); - else{ - if(!isAngular) chkAngularLog->setEnabled(false); - if(!isEnergy){ - chkEnergyLog->setEnabled(false); - boxPlot->setEnabled(false); - boxTrimming->setEnabled(false); - }else{ - boxTrimming->setChecked(false); - SetOptimize(false); - - btnGroup = new QButtonGroup(this); - btnGroup->addButton(btnRefresh,0); - btnGroup->addButton(btnGetTrimbits,1); - } - } - trimmingMode = slsDetectorDefs::NOISE_TRIMMING; - - //network - - //add detectors - for(int i=0;igetNumberOfDetectors();i++) - comboDetector->addItem(QString(myDet->getHostname(i).c_str())); - - comboDetector->setCurrentIndex(0); - - det = myDet->getSlsDetector(comboDetector->currentIndex()); - - qDefs::checkErrorMessage(myDet,"qTabAdvanced::SetupWidgetWindow"); - cout << "Getting ports" << endl; - spinControlPort->setValue(det->getControlPort()); - spinStopPort->setValue(det->getStopPort()); - spinTCPPort->setValue(det->getReceiverPort()); - spinUDPPort->setValue(atoi(det->getReceiverUDPPort().c_str())); - spinZmqPort->setValue(atoi(det->getClientStreamingPort().c_str())); - spinZmqPort2->setValue(atoi(det->getReceiverStreamingPort().c_str())); - - cout << "Getting network information" << endl; - dispIP->setText(det->getDetectorIP().c_str()); - dispMAC->setText(det->getDetectorMAC().c_str()); - dispRxrHostname->setText(det->getReceiver().c_str()); - dispUDPIP->setText(det->getReceiverUDPIP().c_str()); - dispUDPMAC->setText(det->getReceiverUDPMAC().c_str()); - dispZMQIP->setText(det->getClientStreamingIP().c_str()); - dispZMQIP2->setText(det->getReceiverStreamingIP().c_str()); - - //check if its online and set it to red if offline -#ifdef VERYVERBOSE - cout << "online" << endl; -#endif - if(det->setOnline()==slsDetectorDefs::ONLINE_FLAG) - det->checkOnline(); - if(det->setReceiverOnline()==slsDetectorDefs::ONLINE_FLAG) - det->checkReceiverOnline(); - comboOnline->setCurrentIndex(det->setOnline()); - comboRxrOnline->setCurrentIndex(det->setReceiverOnline()); - if(!comboOnline->currentIndex()){ - comboOnline->setToolTip(detOnlineTip + errOnlineTip); - lblOnline->setToolTip(detOnlineTip + errOnlineTip); - lblOnline->setPalette(red); - lblOnline->setText("Online:*"); - } - if((comboRxrOnline->isEnabled())&&(!comboRxrOnline->currentIndex())){ - comboRxrOnline->setToolTip(rxrOnlineTip + errOnlineTip); - lblRxrOnline->setToolTip(rxrOnlineTip + errOnlineTip); - lblRxrOnline->setPalette(red); - lblRxrOnline->setText("Online:*"); - } - - - //updates roi - cout << "Getting ROI" << endl; - if (detType == slsDetectorDefs::GOTTHARD) - updateROIList(); -#ifdef VERYVERBOSE - // print receiver configurations - if(detType != slsDetectorDefs::MYTHEN){ - cout << endl; - myDet->printReceiverConfiguration(); - } -#endif - - // jungfrau - if (detType == slsReceiverDefs::JUNGFRAU) { - lblNumStoragecells->setEnabled(true); - spinNumStoragecells->setEnabled(true); - spinNumStoragecells->setValue((int)myDet->setTimer(slsDetectorDefs::STORAGE_CELL_NUMBER,-1)); - } else if (detType == slsDetectorDefs::EIGER) { - //subexptime - qDefs::timeUnit unit; - double time = qDefs::getCorrectTime(unit,((double)(myDet->setTimer(slsDetectorDefs::SUBFRAME_ACQUISITION_TIME,-1)*(1E-9)))); - spinSubExpTime->setValue(time); - comboSubExpTimeUnit->setCurrentIndex((int)unit); - //period - time = qDefs::getCorrectTime(unit,((double)(myDet->setTimer(slsDetectorDefs::SUBFRAME_DEADTIME,-1)*(1E-9)))); - spinSubPeriod->setValue(time); - comboSubPeriodUnit->setCurrentIndex((int)unit); - - CheckAcqPeriodGreaterThanExp(); - } - - Initialization(); - - qDefs::checkErrorMessage(det,"qTabAdvanced::SetupWidgetWindow"); - -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qTabAdvanced::Initialization(){ - - connect(tabAdvancedSettings,SIGNAL(currentChanged(int)), this, SLOT(Refresh())); - - //energy/angular logs - if(isAngular) - connect(chkEnergyLog, SIGNAL(toggled(bool)), this, SLOT(SetLogs())); - - if(isEnergy){ - connect(chkAngularLog, SIGNAL(toggled(bool)), this, SLOT(SetLogs())); - - //exptime - connect(spinExpTime, SIGNAL(valueChanged(double)), this, SLOT(SetExposureTime())); - connect(comboExpUnit, SIGNAL(currentIndexChanged(int)), this, SLOT(SetExposureTime())); - - //threshold dac - connect(spinThreshold, SIGNAL(valueChanged(double)), this, SLOT(SetThreshold())); - - //output directory - connect(dispFile, SIGNAL(editingFinished()), this, SLOT(SetOutputFile())); - connect(btnFile, SIGNAL(clicked()), this, SLOT(BrowseOutputFile())); - - //setalltrimbits - if(boxSetAllTrimbits->isEnabled()) - connect(spinSetAllTrimbits, SIGNAL(editingFinished()), this, SLOT(SetAllTrimbits())); - - //enable trimming method group box - connect(boxTrimming, SIGNAL(toggled(bool)), this, SLOT(EnableTrimming(bool))); - - //trimming method combo - connect(comboMethod, SIGNAL(currentIndexChanged(int)), this, SLOT(SetTrimmingMethod(int))); - - //method options - connect(chkOptimize, SIGNAL(toggled(bool)), this, SLOT(SetOptimize(bool))); - - //start Trimming - connect(btnStart, SIGNAL(clicked()), this, SLOT(StartTrimming())); - - //refresh - connect(btnGroup, SIGNAL(buttonClicked(int)), this, SLOT(UpdateTrimbitPlot(int))); - } - - //network - connect(comboDetector, SIGNAL(currentIndexChanged(int)), this, SLOT(SetDetector(int))); - connect(spinControlPort, SIGNAL(valueChanged(int)), this, SLOT(SetControlPort(int))); - connect(spinStopPort, SIGNAL(valueChanged(int)), this, SLOT(SetStopPort(int))); - connect(comboOnline, SIGNAL(currentIndexChanged(int)), this, SLOT(SetOnline(int))); - - if(detType!=slsDetectorDefs::MYTHEN){ - - //network - connect(spinTCPPort, SIGNAL(valueChanged(int)), this, SLOT(SetRxrTCPPort(int))); - connect(spinUDPPort, SIGNAL(valueChanged(int)), this, SLOT(SetRxrUDPPort(int))); - connect(spinZmqPort, SIGNAL(valueChanged(int)), this, SLOT(SetCltZmqPort(int))); - connect(spinZmqPort2, SIGNAL(valueChanged(int)), this, SLOT(SetRxrZmqPort(int))); - connect(comboRxrOnline, SIGNAL(currentIndexChanged(int)), this, SLOT(SetReceiverOnline(int))); - - connect(dispIP, SIGNAL(editingFinished()), this, SLOT(SetNetworkParameters())); - connect(dispMAC, SIGNAL(editingFinished()), this, SLOT(SetNetworkParameters())); - connect(dispUDPIP, SIGNAL(editingFinished()), this, SLOT(SetNetworkParameters())); - connect(dispUDPMAC, SIGNAL(editingFinished()), this, SLOT(SetNetworkParameters())); - - connect(dispZMQIP, SIGNAL(editingFinished()), this, SLOT(SetClientZMQIP())); - connect(dispZMQIP2, SIGNAL(editingFinished()), this, SLOT(SetReceiverZMQIP())); - - connect(btnRxr, SIGNAL(clicked()), this, SLOT(SetReceiver())); - } - - - //roi - - if (detType == slsDetectorDefs::GOTTHARD) { - connect(btnClearRoi, SIGNAL(clicked()), this, SLOT(clearROIinDetector())); - connect(btnGetRoi, SIGNAL(clicked()), this, SLOT(updateROIList())); - connect(btnSetRoi, SIGNAL(clicked()), this, SLOT(setROI())); - } - - if(detType == slsReceiverDefs::JUNGFRAU) { - connect(spinNumStoragecells, SIGNAL(valueChanged(int)), this, SLOT(SetNumStoragecells(int))); - } else if (detType == slsDetectorDefs::EIGER) { - //Exposure Time - connect(spinSubExpTime,SIGNAL(valueChanged(double)), this, SLOT(SetSubExposureTime())); - connect(comboSubExpTimeUnit,SIGNAL(currentIndexChanged(int)), this, SLOT(SetSubExposureTime())); - //Frame Period between exposures - connect(spinSubPeriod,SIGNAL(valueChanged(double)), this, SLOT(SetSubPeriod())); - connect(comboSubPeriodUnit,SIGNAL(currentIndexChanged(int)),this, SLOT(SetSubPeriod())); - - } -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qTabAdvanced::SetLogs(){ - QCheckBox *checkedBox = qobject_cast(sender()); - int index = ((!checkedBox->text().compare("Energy Calibration"))?slsDetectorDefs::enCalLog:slsDetectorDefs::angCalLog); - bool enable = checkedBox->isChecked(); -#ifdef VERBOSE - if(index==slsDetectorDefs::enCalLog) - cout << "Setting Energy Calibration Logs to " << enable << endl; - else - cout << "Setting Angular Calibration Logs to " << enable << endl; -#endif - //set/unset the log - myDet->setAction(index,(enable?"set":"none")); - //verify - if(myDet->getActionMode(index)!=(enable)){ -#ifdef VERBOSE - cout << "Could not set/reset Log." << endl; -#endif - qDefs::Message(qDefs::WARNING,"Could not set/reset Log.","qTabAdvanced::SetLogs"); - checkedBox->setChecked(!enable); - } - - qDefs::checkErrorMessage(myDet,"qTabAdvanced::SetLogs"); -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qTabAdvanced::SetExposureTime(){ - //Get the value of timer in ns - double exptimeNS = qDefs::getNSTime((qDefs::timeUnit)comboExpUnit->currentIndex(),spinExpTime->value()); -#ifdef VERBOSE - cout << "Setting Exposure Time to " << exptimeNS << " clocks" << "/" << spinExpTime->value() << qDefs::getUnitString((qDefs::timeUnit)comboExpUnit->currentIndex()) << endl; -#endif - myDet->setTimer(slsDetectorDefs::ACQUISITION_TIME,(int64_t)exptimeNS); - - qDefs::checkErrorMessage(myDet,"qTabAdvanced::SetExposureTime"); -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qTabAdvanced::SetThreshold(){ -#ifdef VERBOSE - cout << "Setting Threshold DACu:" << spinThreshold->value() << endl; -#endif - spinThreshold->setValue((double)myDet->setDAC((dacs_t)spinThreshold->value(),slsDetectorDefs::THRESHOLD,0)); - qDefs::checkErrorMessage(myDet,"qTabAdvanced::SetThreshold"); -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qTabAdvanced::SetOutputFile(){ -#ifdef VERBOSE - cout << "Setting Output File for Trimming:" << endl; -#endif - QString dirPath = dispFile->text().section('/',0,-2,QString::SectionIncludeLeadingSep); - cout << "Directory:" << dirPath.toAscii().constData() << "." << endl; - QString fName = dispFile->text().section('/',-1); - cout << "File Name:" << fName.toAscii().constData() << "." << endl; - //checks if directory exists and file name is not empty - if((QFile::exists(dirPath))&&(!fName.isEmpty())){ - - dispFile->setToolTip(outputDirTip); - lblFile->setToolTip(outputDirTip); - lblFile->setPalette(lblExpTime->palette()); - lblFile->setText("Output Trim File: "); - btnStart->setEnabled(true); - - - //check if you're overwriting original trimsettings - QDir dir; - //gets the clean absolute path - dirPath = dir.absoluteFilePath(dirPath); - dirPath = dir.cleanPath(dirPath); - QString trimdir = QString::fromStdString(myDet->getSettingsFile()).section('/',0,-2,QString::SectionIncludeLeadingSep); - trimdir = dir.absoluteFilePath(trimdir); - trimdir = dir.cleanPath(trimdir); - if(!dirPath.compare(trimdir)){ - int ret = qDefs::Message(qDefs::QUESTION,string("This will possibly overwrite your original trimbits.
" - "Proposed file path:") + string(dirPath.toAscii().constData())+ - string("
Do you still want to continue?"),"qTabAdvanced::SetOutputFile"); - if(ret==qDefs::FAIL){ - dispFile->setText(""); - dispFile->setToolTip(outputDirTip + errOutputTip); - lblFile->setToolTip(outputDirTip + errOutputTip); - lblFile->setPalette(red); - lblFile->setText("Output Trim File:*"); - btnStart->setEnabled(false); - } - } - - }//if the directory doesnt exist or if file name is empty - else{ - cout<<"Invalid Trimming output File"<setToolTip(outputDirTip + errOutputTip); - lblFile->setToolTip(outputDirTip + errOutputTip); - lblFile->setPalette(red); - lblFile->setText("Output Trim File:*"); - btnStart->setEnabled(false); - } - - qDefs::checkErrorMessage(myDet,"qTabAdvanced::SetOutputFile"); -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qTabAdvanced::BrowseOutputFile(){ -#ifdef VERBOSE - cout << "Browsing Output Dir for Trimming" << endl; -#endif - QString fName = dispFile->text(); - //dialog - QFileDialog *fileDialog = new QFileDialog(this, - tr("Save Trimbits"),fName, - tr("Trimbit files (*.trim noise.sn*);;All Files(*) ")); - fileDialog->setFileMode(QFileDialog::AnyFile ); - if ( fileDialog->exec() == QDialog::Accepted ) - fName = fileDialog->selectedFiles()[0]; - - //if empty, set the file name and it calls SetFileSteps, else ignore - if (!fName.isEmpty()){ - dispFile->setText(fName); - SetOutputFile(); - } -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qTabAdvanced::EnableTrimming(bool enable){ -#ifdef VERBOSE - cout << "Enable Trimming set to:" << enable << endl; -#endif - if(enable){ - //show error label if invalid output dir - SetOutputFile(); - SetTrimmingMethod(comboMethod->currentIndex()); - }else{ - //error label shouldnt show when disabled - dispFile->setToolTip(outputDirTip); - lblFile->setToolTip(outputDirTip); - lblFile->setPalette(lblExpTime->palette()); - lblFile->setText("Output Trim File: "); - } -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- -void qTabAdvanced::SetOptimize(bool enable){ -#ifdef VERBOSE - cout << "Setting Optimize to:" << enable << endl; -#endif - //trimming method is adjust to count - if(!comboMethod->currentIndex()){ - lblCounts->setEnabled(true); - spinCounts->setEnabled(true); - lblResolution->setEnabled(enable); - spinResolution->setEnabled(enable); - }//trimming method is equalize to median - else{ - lblCounts->setEnabled(false); - spinCounts->setEnabled(false); - lblResolution->setEnabled(true); - spinResolution->setEnabled(true); - } -} - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qTabAdvanced::SetTrimmingMethod(int mode){ -#ifdef VERBOSE - cout << "Setting Trimming method to :" << mode << endl; -#endif - //make sure the right resolution/Counts is enabled - SetOptimize(chkOptimize->isChecked()); - - //set mode - switch(mode){ - case 0: trimmingMode = slsDetectorDefs::NOISE_TRIMMING; break; - case 1: trimmingMode = slsDetectorDefs::IMPROVE_TRIMMING; break; - } -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -int qTabAdvanced::validateBeforeTrimming(){ -#ifdef VERBOSE - cout << "Validating conditions before Trimming" << endl; -#endif - char temp[100]; - string message = "All conditions satisfied for Trimming.
"; - switch(detType){ - case slsDetectorDefs::MYTHEN: - - //dynamic range - if(myDet->setDynamicRange(-1) != TRIMMING_DYNAMIC_RANGE){ - sprintf(temp,"%d",TRIMMING_DYNAMIC_RANGE); - if(myDet->setDynamicRange(TRIMMING_DYNAMIC_RANGE) != TRIMMING_DYNAMIC_RANGE){ - qDefs::Message(qDefs::WARNING, - string("Trimming Pre-condition not satisfied:
" - "Could not set dynamic range to ") + string(temp)+string(".
" - "Trimming Aborted."),"qTabAdvanced::validateBeforeTrimming"); - return slsDetectorDefs::FAIL; - }else - message.append(string("Dynamic Range has been changed to ") + string(temp) + string(".
")); - } - //frames - if((int)myDet->setTimer(slsDetectorDefs::FRAME_NUMBER,-1) != TRIMMING_FRAME_NUMBER){ - sprintf(temp,"%d",TRIMMING_FRAME_NUMBER); - if((int)myDet->setTimer(slsDetectorDefs::FRAME_NUMBER,TRIMMING_FRAME_NUMBER) != TRIMMING_FRAME_NUMBER){ - qDefs::Message(qDefs::WARNING, - string("
Trimming Pre-condition not satisfied:
" - "Could not set Number of Frames to ") + string(temp)+string(".
" - "Trimming Aborted."),"qTabAdvanced::validateBeforeTrimming"); - return slsDetectorDefs::FAIL; - }else - message.append(string("Number of Frames has been changed to ") + string(temp) + string(".
")); - } - //trigger - if((int)myDet->setTimer(slsDetectorDefs::CYCLES_NUMBER,-1) != TRIMMING_TRIGGER_NUMBER){ - sprintf(temp,"%d",TRIMMING_TRIGGER_NUMBER); - if((int)myDet->setTimer(slsDetectorDefs::CYCLES_NUMBER,TRIMMING_TRIGGER_NUMBER) != TRIMMING_TRIGGER_NUMBER){ - qDefs::Message(qDefs::WARNING, - string("
Trimming Pre-condition not satisfied:
" - "Could not set Number of Triggers to ") + string(temp)+string(".
" - "Trimming Aborted."),"qTabAdvanced::validateBeforeTrimming"); - return slsDetectorDefs::FAIL; - }else - message.append(string("Number of Triggers has been changed to ") + string(temp) + string(".
")); - } - //probes - if((int)myDet->setTimer(slsDetectorDefs::PROBES_NUMBER,-1) != TRIMMING_PROBE_NUMBER){ - sprintf(temp,"%d",TRIMMING_PROBE_NUMBER); - if((int)myDet->setTimer(slsDetectorDefs::PROBES_NUMBER,TRIMMING_PROBE_NUMBER) != TRIMMING_PROBE_NUMBER){ - qDefs::Message(qDefs::WARNING, - string("
Trimming Pre-condition not satisfied:
" - "Could not set Number of Probes to ") + string(temp)+string(".
" - "Trimming Aborted."),"qTabAdvanced::validateBeforeTrimming"); - return slsDetectorDefs::FAIL; - }else - message.append(string("Number of Probes has been changed to ") + string(temp) + string(".
")); - } - //Setting - if(myDet->getSettings() == slsDetectorDefs::UNINITIALIZED){ - if(qDefs::Message(qDefs::QUESTION, - string("
Trimming Pre-condition not satisfied:
")+ - string("Settings cannot be Uninitialized to start Trimming.
" - "Change it to Standard and proceed?"),"qTabAdvanced::validateBeforeTrimming") == slsDetectorDefs::FAIL){ - qDefs::Message(qDefs::INFORMATION, - "Please change the Settings in the Settings tab to your choice.
" - "Aborting Trimming.","qTabAdvanced::validateBeforeTrimming"); - return slsDetectorDefs::FAIL; - } - //user asked to change settings to standard - else{ - if((int)myDet->setSettings(slsDetectorDefs::STANDARD) != slsDetectorDefs::STANDARD){ - qDefs::Message(qDefs::WARNING, - string("Trimming Pre-condition not satisfied:
" - "Could not change Settings to Standard
" - "Trimming Aborted."),"qTabAdvanced::validateBeforeTrimming"); - return slsDetectorDefs::FAIL; - }else - message.append(string("Settings has been changed to Standard.
")); - } - } - break; - default: - return slsDetectorDefs::FAIL; - - } - - message.append("
Initiating Trimming..."); - qDefs::Message(qDefs::INFORMATION,message,"qTabAdvanced::validateBeforeTrimming"); - return slsDetectorDefs::OK; - -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qTabAdvanced::StartTrimming(){ - //check a few conditions before trimming - if(validateBeforeTrimming() == slsDetectorDefs::FAIL) - return; - -#ifdef VERBOSE - cout << "Starting Trimming" << endl; -#endif - int parameter1=0, parameter2=0; - //optimize - bool optimize = chkOptimize->isChecked(); - - //set the mode again and also set resolution, counts - switch(trimmingMode){ - - case slsDetectorDefs::NOISE_TRIMMING: - //define parameters - parameter1 = spinCounts->value(); - parameter2 = spinResolution->value(); - if(!optimize){ - parameter2 = -1; - trimmingMode = slsDetectorDefs::FIXEDSETTINGS_TRIMMING; -#ifdef VERBOSE - cout << "Trimming Mode: FIXEDSETTINGS_TRIMMING" << endl; -#endif - }else{ -#ifdef VERBOSE - cout << "Trimming Mode: NOISE_TRIMMING" << endl; -#endif - } - break; - - case slsDetectorDefs::IMPROVE_TRIMMING: -#ifdef VERBOSE - cout << "Trimming Mode: IMPROVE_TRIMMING" << endl; -#endif - //define parameters - parameter1 = spinResolution->value(); - parameter2 = 1; - if(!optimize) parameter2 = 0; - break; - default: - cout << "Should never come here. Start Trimming will have only 2 methods. Trimming Method:" << trimmingMode << endl; - return; - } - - //execute - int ret = myDet->executeTrimming(trimmingMode,parameter1,parameter2,-1); - - if((ret!=slsDetectorDefs::FAIL)&&(ret!=-1)); - else - qDefs::Message(qDefs::WARNING,"Atleast 1 channel could not be trimmed.","qTabAdvanced::StartTrimming"); - //save trim file - ret = myDet->saveSettingsFile(string(dispFile->text().toAscii().constData()),-1); - if((ret!=slsDetectorDefs::FAIL)&&(ret!=-1)){ - qDefs::Message(qDefs::INFORMATION,"The Trimbits have been saved successfully.","qTabAdvanced::StartTrimming"); - //updates plots - myPlot->UpdateTrimbitPlot(false,radioHistogram->isChecked()); - } - else qDefs::Message(qDefs::WARNING,string("Could not Save the Trimbits to file:\n")+dispFile->text().toAscii().constData(),"qTabAdvanced::StartTrimming"); - - qDefs::checkErrorMessage(myDet,"qTabAdvanced::StartTrimming"); -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qTabAdvanced::UpdateTrimbitPlot(int id){ - if(boxPlot->isChecked()){ - //refresh - if(!id) myPlot->UpdateTrimbitPlot(false,radioHistogram->isChecked()); - //from detector - else myPlot->UpdateTrimbitPlot(true,radioHistogram->isChecked()); - } -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qTabAdvanced::SetControlPort(int port){ -#ifdef VERBOSE - cout << "Setting Control Port:" << port << endl; -#endif - disconnect(spinControlPort, SIGNAL(valueChanged(int)), this, SLOT(SetControlPort(int))); - spinControlPort->setValue(det->setPort(slsDetectorDefs::CONTROL_PORT,port)); - qDefs::checkErrorMessage(det,"qTabAdvanced::SetControlPort"); - connect(spinControlPort, SIGNAL(valueChanged(int)), this, SLOT(SetControlPort(int))); -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qTabAdvanced::SetStopPort(int port){ -#ifdef VERBOSE - cout << "Setting Stop Port:" << port << endl; -#endif - disconnect(spinStopPort, SIGNAL(valueChanged(int)), this, SLOT(SetStopPort(int))); - spinStopPort->setValue(det->setPort(slsDetectorDefs::STOP_PORT,port)); - qDefs::checkErrorMessage(det,"qTabAdvanced::SetStopPort"); - connect(spinStopPort, SIGNAL(valueChanged(int)), this, SLOT(SetStopPort(int))); - -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qTabAdvanced::SetRxrTCPPort(int port){ -#ifdef VERBOSE - cout << "Setting Receiver TCP Port:" << port << endl; -#endif - disconnect(spinTCPPort, SIGNAL(valueChanged(int)), this, SLOT(SetRxrTCPPort(int))); - spinTCPPort->setValue(det->setPort(slsDetectorDefs::DATA_PORT,port)); - qDefs::checkErrorMessage(det,"qTabAdvanced::SetRxrTCPPort"); - connect(spinTCPPort, SIGNAL(valueChanged(int)), this, SLOT(SetRxrTCPPort(int))); -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qTabAdvanced::SetRxrUDPPort(int port){ -#ifdef VERBOSE - cout << "Setting Receiver UDP Port:" << port << endl; -#endif - - disconnect(spinUDPPort, SIGNAL(valueChanged(int)), this, SLOT(SetRxrUDPPort(int))); - spinUDPPort->setValue(det->setReceiverUDPPort(port)); - qDefs::checkErrorMessage(det,"qTabAdvanced::SetRxrUDPPort"); - connect(spinUDPPort, SIGNAL(valueChanged(int)), this, SLOT(SetRxrUDPPort(int))); -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qTabAdvanced::SetCltZmqPort(int port){ -#ifdef VERBOSE - cout << "Setting Client UDP Port:" << port << endl; -#endif - ostringstream ss; ss << port; string sport = ss.str(); - - disconnect(spinZmqPort, SIGNAL(valueChanged(int)), this, SLOT(SetCltZmqPort(int))); - spinZmqPort->setValue(atoi(det->setClientStreamingPort(sport).c_str())); - qDefs::checkErrorMessage(det,"qTabAdvanced::SetCltZmqPort"); - myDet->enableDataStreamingToClient(false); - myDet->enableDataStreamingToClient(true); - qDefs::checkErrorMessage(myDet,"qTabAdvanced::SetCltZmqPort"); - connect(spinZmqPort, SIGNAL(valueChanged(int)), this, SLOT(SetCltZmqPort(int))); -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qTabAdvanced::SetRxrZmqPort(int port){ -#ifdef VERBOSE - cout << "Setting Receiver UDP Port:" << port << endl; -#endif - ostringstream ss; ss << port; string sport = ss.str(); - - disconnect(spinZmqPort2, SIGNAL(valueChanged(int)), this, SLOT(SetRxrZmqPort(int))); - spinZmqPort2->setValue(atoi(det->setReceiverStreamingPort(sport).c_str())); - qDefs::checkErrorMessage(det,"qTabAdvanced::SetRxrZmqPort"); - myDet->enableDataStreamingFromReceiver(false); - myDet->enableDataStreamingFromReceiver(true); - qDefs::checkErrorMessage(myDet,"qTabAdvanced::SetRxrZmqPort"); - connect(spinZmqPort2, SIGNAL(valueChanged(int)), this, SLOT(SetRxrZmqPort(int))); -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qTabAdvanced::SetReceiverOnline(int index){ -#ifdef VERBOSE - cout << "Setting Reciever Online to :" << index << endl; -#endif - disconnect(comboRxrOnline, SIGNAL(currentIndexChanged(int)), this, SLOT(SetReceiverOnline(int))); - if(index) - SetReceiver(); - else - comboRxrOnline->setCurrentIndex(det->setReceiverOnline(index)); - qDefs::checkErrorMessage(det,"qTabAdvanced::SetReceiverOnline"); - connect(comboRxrOnline, SIGNAL(currentIndexChanged(int)), this, SLOT(SetReceiverOnline(int))); - //highlight in red if offline - if(!comboRxrOnline->currentIndex()){ - comboRxrOnline->setToolTip(rxrOnlineTip + errOnlineTip); - lblRxrOnline->setToolTip(rxrOnlineTip + errOnlineTip); - lblRxrOnline->setPalette(red); - lblRxrOnline->setText("Online:*"); - }else{ - comboRxrOnline->setToolTip(rxrOnlineTip); - lblRxrOnline->setToolTip(rxrOnlineTip); - lblRxrOnline->setPalette(lblHostname->palette()); - lblRxrOnline->setText("Online:"); - } -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qTabAdvanced::SetOnline(int index){ -#ifdef VERBOSE - cout << "Setting Detector Online to " << index << endl; -#endif - disconnect(comboOnline, SIGNAL(currentIndexChanged(int)), this, SLOT(SetOnline(int))); - comboOnline->setCurrentIndex(det->setOnline(index)); - qDefs::checkErrorMessage(det,"qTabAdvanced::SetOnline"); - connect(comboOnline, SIGNAL(currentIndexChanged(int)), this, SLOT(SetOnline(int))); - //highlight in red if offline - if(!comboOnline->currentIndex()){ - comboOnline->setToolTip(detOnlineTip + errOnlineTip); - lblOnline->setToolTip(detOnlineTip + errOnlineTip); - lblOnline->setPalette(red); - lblOnline->setText("Online:*"); - }else{ - comboOnline->setToolTip(detOnlineTip); - lblOnline->setToolTip(detOnlineTip); - lblOnline->setPalette(lblHostname->palette()); - lblOnline->setText("Online:"); - } - -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qTabAdvanced::SetNetworkParameters(){ -#ifdef VERBOSE - cout << "Setting Network Parametrs" << endl; -#endif - disconnect(dispIP, SIGNAL(editingFinished()), this, SLOT(SetNetworkParameters())); - disconnect(dispMAC, SIGNAL(editingFinished()), this, SLOT(SetNetworkParameters())); - disconnect(dispUDPIP, SIGNAL(editingFinished()), this, SLOT(SetNetworkParameters())); - disconnect(dispUDPMAC, SIGNAL(editingFinished()), this, SLOT(SetNetworkParameters())); - - dispIP->setText(QString(det->setDetectorIP(dispIP->text().toAscii().constData()).c_str())); - dispMAC->setText(QString(det->setDetectorMAC(dispMAC->text().toAscii().constData()).c_str())); - dispUDPIP->setText(QString(det->setReceiverUDPIP(dispUDPIP->text().toAscii().constData()).c_str())); - dispUDPMAC->setText(QString(det->setReceiverUDPMAC(dispUDPMAC->text().toAscii().constData()).c_str())); - qDefs::checkErrorMessage(det,"qTabAdvanced::SetNetworkParameters"); - - connect(dispIP, SIGNAL(editingFinished()), this, SLOT(SetNetworkParameters())); - connect(dispMAC, SIGNAL(editingFinished()), this, SLOT(SetNetworkParameters())); - connect(dispUDPIP, SIGNAL(editingFinished()), this, SLOT(SetNetworkParameters())); - connect(dispUDPMAC, SIGNAL(editingFinished()), this, SLOT(SetNetworkParameters())); -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qTabAdvanced::SetClientZMQIP(){ -#ifdef VERBOSE - cout << "Setting Client ZMQ IP" << endl; -#endif - disconnect(dispZMQIP, SIGNAL(editingFinished()), this, SLOT(SetClientZMQIP())); - - dispZMQIP->setText(QString(det->setClientStreamingIP(dispZMQIP->text().toAscii().constData()).c_str())); - myDet->enableDataStreamingToClient(false); - myDet->enableDataStreamingToClient(true); - qDefs::checkErrorMessage(det,"qTabAdvanced::SetClientZMQIP"); - - connect(dispZMQIP, SIGNAL(editingFinished()), this, SLOT(SetClientZMQIP())); -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qTabAdvanced::SetReceiverZMQIP(){ -#ifdef VERBOSE - cout << "Setting Receiver ZMQ IP" << endl; -#endif - disconnect(dispZMQIP2, SIGNAL(editingFinished()), this, SLOT(SetReceiverZMQIP())); - - dispZMQIP2->setText(QString(det->setReceiverStreamingIP(dispZMQIP2->text().toAscii().constData()).c_str())); - myDet->enableDataStreamingFromReceiver(false); - myDet->enableDataStreamingFromReceiver(true); - qDefs::checkErrorMessage(det,"qTabAdvanced::SetReceiverZMQIP"); - - connect(dispZMQIP2, SIGNAL(editingFinished()), this, SLOT(SetReceiverZMQIP())); -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qTabAdvanced::SetReceiver(){ -#ifdef VERBOSE - cout << "Setting Receiver" << endl; -#endif - string outdir = myDet->getFilePath(); - dispRxrHostname->setText(QString(det->setReceiver(dispRxrHostname->text().toAscii().constData()).c_str())); - qDefs::checkErrorMessage(det,"qTabAdvanced::SetReceiver"); - det->setFilePath(outdir); - qDefs::checkErrorMessage(det,"qTabAdvanced::SetReceiver"); - Refresh(); -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qTabAdvanced::updateROIList(){ -#ifdef VERYVERBOSE - cout<<"in updateROIList() " << endl; -#endif - clearROI(); - - int n,i; - slsDetectorDefs::ROI* temp = myDet->getROI(n); - qDefs::checkErrorMessage(myDet,"qTabAdvanced::updateROIList"); - - if((temp!=NULL)&&(n>0)){ - //assign into array, else it loses values cuz of memory - slsDetectorDefs::ROI allroi[n]; - for(i=0;isetValue(allroi[i].xmin); - spinFromY[i]->setValue(allroi[i].ymin); - spinToX[i]->setValue(allroi[i].xmax); - spinToY[i]->setValue(allroi[i].ymax); - } - cout << "ROIs populated: " << n << endl; - } - - -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qTabAdvanced::AddROIInput(int num){ -#ifdef VERVERBOSE - cout<<"in AddROIInput() " << num << endl; -#endif - if((int)lblFromX.size()){ - disconnect(spinFromX[numRois], SIGNAL(valueChanged(int)), this, SLOT(AddROIInputSlot())); - disconnect(spinFromY[numRois], SIGNAL(valueChanged(int)), this, SLOT(AddROIInputSlot())); - disconnect(spinToX[numRois], SIGNAL(valueChanged(int)), this, SLOT(AddROIInputSlot())); - disconnect(spinToY[numRois], SIGNAL(valueChanged(int)), this, SLOT(AddROIInputSlot())); - } - - int exists = numRois+1; - int total = exists+num; - //if cleared, addding just one - if ((num==0) && (numRois==0)){ - exists = 0; - total = 1; - }/*else{ - gridRoi->removeWidget - }*/ - - for (int i=exists;i= ((int)lblFromX.size())){ - lblFromX.resize(i+1); spinFromX.resize(i+1); - lblFromY.resize(i+1); spinFromY.resize(i+1); - lblToX.resize(i+1); spinToX.resize(i+1); - lblToY.resize(i+1); spinToY.resize(i+1); - - lblFromX[i] = new QLabel("x min:"); - lblFromY[i] = new QLabel("y min:"); - lblToX[i] = new QLabel("x max:"); - lblToY[i] = new QLabel("y max:"); - spinFromX[i] = new QSpinBox(); - spinFromY[i] = new QSpinBox(); - spinToX[i] = new QSpinBox(); - spinToY[i] = new QSpinBox(); - - - lblFromX[i]->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed); lblFromX[i]->setFixedWidth(50); - lblFromY[i]->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed); lblFromY[i]->setFixedWidth(50); - lblToX[i]->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed); lblToX[i]->setFixedWidth(50); - lblToY[i]->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed); lblToY[i]->setFixedWidth(50); - spinFromX[i]->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed); spinFromX[i]->setFixedWidth(80); - spinFromY[i]->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed); spinFromY[i]->setFixedWidth(80); - spinToX[i]->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed); spinToX[i]->setFixedWidth(80); - spinToY[i]->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed); spinToY[i]->setFixedWidth(80); - spinFromX[i]->setFixedHeight(19); - spinFromY[i]->setFixedHeight(19); - spinToX[i]->setFixedHeight(19); - spinToY[i]->setFixedHeight(19); - - spinFromX[i]->setMaximum(myDet->getMaxNumberOfChannels(slsDetectorDefs::X)-1); - spinToX[i]->setMaximum(myDet->getMaxNumberOfChannels(slsDetectorDefs::X)-1); - spinFromY[i]->setMaximum(myDet->getMaxNumberOfChannels(slsDetectorDefs::Y)-1); - spinToY[i]->setMaximum(myDet->getMaxNumberOfChannels(slsDetectorDefs::Y)-1); - spinFromX[i]->setMinimum(-1); - spinToX[i]->setMinimum(-1); - spinFromY[i]->setMinimum(-1); - spinToY[i]->setMinimum(-1); - spinFromX[i]->setValue(-1); - spinFromY[i]->setValue(-1); - spinToX[i]->setValue(-1); - spinToY[i]->setValue(-1); - } - - gridRoi->addWidget(lblFromX[i], i,0,Qt::AlignTop); - gridRoi->addWidget(spinFromX[i],i,1,Qt::AlignTop); - gridRoi->addItem(new QSpacerItem(40,20,QSizePolicy::Expanding,QSizePolicy::Fixed), i,2,Qt::AlignTop); - gridRoi->addWidget(lblToX[i], i,3,Qt::AlignTop); - gridRoi->addWidget(spinToX[i], i,4,Qt::AlignTop); - gridRoi->addItem(new QSpacerItem(40,20,QSizePolicy::Expanding,QSizePolicy::Fixed), i,5,Qt::AlignTop); - gridRoi->addWidget(lblFromY[i], i,6,Qt::AlignTop); - gridRoi->addWidget(spinFromY[i],i,7,Qt::AlignTop); - gridRoi->addItem(new QSpacerItem(40,20,QSizePolicy::Expanding,QSizePolicy::Fixed), i,8,Qt::AlignTop); - gridRoi->addWidget(lblToY[i], i,9,Qt::AlignTop); - gridRoi->addWidget(spinToY[i], i,10,Qt::AlignTop); - - lblFromX[i]->show(); - spinFromX[i]->show(); - lblToX[i]->show(); - spinToX[i]->show(); - lblFromY[i]->show(); - spinFromY[i]->show(); - lblToY[i]->show(); - spinToY[i]->show(); - } - - numRois += num; - - connect(spinFromX[numRois], SIGNAL(valueChanged(int)), this, SLOT(AddROIInputSlot())); - connect(spinFromY[numRois], SIGNAL(valueChanged(int)), this, SLOT(AddROIInputSlot())); - connect(spinToX[numRois], SIGNAL(valueChanged(int)), this, SLOT(AddROIInputSlot())); - connect(spinToY[numRois], SIGNAL(valueChanged(int)), this, SLOT(AddROIInputSlot())); - -#ifdef VERYVERBOSE - cout<<"ROI Inputs added " << num << endl; -#endif - - qDefs::checkErrorMessage(myDet,"qTabAdvanced::AddROIInput"); -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qTabAdvanced::clearROI(){ -#ifdef VERYVERBOSE - cout<<"in clearROI() " << endl; -#endif - if((int)lblFromX.size()){ - disconnect(spinFromX[numRois], SIGNAL(valueChanged(int)), this, SLOT(AddROIInputSlot())); - disconnect(spinFromY[numRois], SIGNAL(valueChanged(int)), this, SLOT(AddROIInputSlot())); - disconnect(spinToX[numRois], SIGNAL(valueChanged(int)), this, SLOT(AddROIInputSlot())); - disconnect(spinToY[numRois], SIGNAL(valueChanged(int)), this, SLOT(AddROIInputSlot())); - - } - - - for (int i=0;isetValue(-1); - spinFromY[i]->setValue(-1); - spinToX[i]->setValue(-1); - spinToY[i]->setValue(-1); - } - - - //hide widget because they are still visible even when removed and layout deleted - QLayoutItem *item; - while((item = gridRoi->takeAt(0))) { - if (item->widget()){ - item->widget()->hide(); - gridRoi->removeWidget(item->widget()); - } - //if (item->spacerItem()) - } - - numRois = 0; - AddROIInput(0); - -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qTabAdvanced::setROI(){ -#ifdef VERYVERBOSE - cout<<"in setROI() " << endl; -#endif - - slsDetectorDefs::ROI allroi[MAX_ROIS]; - - for (int i=0;ivalue(); - allroi[i].ymin = spinFromY[i]->value(); - allroi[i].xmax = spinToX[i]->value(); - allroi[i].ymax = spinToY[i]->value(); - } - - myDet->setROI(numRois,allroi); - //qDefs::checkErrorMessage(myDet); - cout<<"ROIs set" << endl; - //get the correct list back - updateROIList(); - //configuremac - myDet->configureMAC(); - - qDefs::checkErrorMessage(myDet,"qTabAdvanced::setROI"); -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qTabAdvanced::clearROIinDetector(){ -#ifdef VERYVERBOSE - cout<<"in clearROIinDetector() " << endl; -#endif - - if (QMessageBox::warning(this, "Clear ROI", - "Are you sure you want to clear all the ROI in detector?", - QMessageBox::Yes | QMessageBox::No, QMessageBox::No) == QMessageBox::Yes){ - - clearROI(); - setROI(); -#ifdef VERBOSE - cout << "ROIs cleared" << endl; -#endif - } -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qTabAdvanced::SetDetector(int index){ -#ifdef VERYVERBOSE - cout<<"in SetDetector: " << index << endl; -#endif - det = myDet->getSlsDetector(comboDetector->currentIndex()); - - - spinControlPort->setValue(det->getControlPort()); - spinStopPort->setValue(det->getStopPort()); - spinTCPPort->setValue(det->getReceiverPort()); - spinUDPPort->setValue(atoi(det->getReceiverUDPPort().c_str())); - spinZmqPort->setValue(atoi(det->getClientStreamingPort().c_str())); - spinZmqPort2->setValue(atoi(det->getReceiverStreamingPort().c_str())); - - dispIP->setText(det->getDetectorIP().c_str()); - dispMAC->setText(det->getDetectorMAC().c_str()); - dispRxrHostname->setText(det->getReceiver().c_str()); - dispUDPIP->setText(det->getReceiverUDPIP().c_str()); - dispUDPMAC->setText(det->getReceiverUDPMAC().c_str()); - dispZMQIP->setText(det->getClientStreamingIP().c_str()); - dispZMQIP2->setText(det->getReceiverStreamingIP().c_str()); - - - //check if its online and set it to red if offline - if(det->setOnline()==slsDetectorDefs::ONLINE_FLAG) - det->checkOnline(); - if(det->setReceiverOnline()==slsDetectorDefs::ONLINE_FLAG) - det->checkReceiverOnline(); - comboOnline->setCurrentIndex(det->setOnline()); - comboRxrOnline->setCurrentIndex(det->setReceiverOnline()); - //highlight in red if detector or receiver is offline - if(!comboOnline->currentIndex()){ - comboOnline->setToolTip(detOnlineTip + errOnlineTip); - lblOnline->setToolTip(detOnlineTip + errOnlineTip); - lblOnline->setPalette(red); - lblOnline->setText("Online:*"); - }else{ - comboOnline->setToolTip(detOnlineTip); - lblOnline->setToolTip(detOnlineTip); - lblOnline->setPalette(lblHostname->palette()); - lblOnline->setText("Online:"); - } - if(comboRxrOnline->isEnabled()){ - if(!comboRxrOnline->currentIndex()){ - comboRxrOnline->setToolTip(rxrOnlineTip + errOnlineTip); - lblRxrOnline->setToolTip(rxrOnlineTip + errOnlineTip); - lblRxrOnline->setPalette(red); - lblRxrOnline->setText("Online:*"); - }else{ - comboRxrOnline->setToolTip(rxrOnlineTip); - lblRxrOnline->setToolTip(rxrOnlineTip); - lblRxrOnline->setPalette(lblHostname->palette()); - lblRxrOnline->setText("Online:"); - } - } - - qDefs::checkErrorMessage(det,"qTabAdvanced::SetDetector"); -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qTabAdvanced::SetAllTrimbits(){ -#ifdef VERBOSE - cout<<"Set all trimbits to " << spinSetAllTrimbits->value() << endl; -#endif - myDet->setAllTrimbits(spinSetAllTrimbits->value()); - qDefs::checkErrorMessage(myDet,"qTabAdvanced::SetAllTrimbits"); - updateAllTrimbitsFromServer(); - -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qTabAdvanced::updateAllTrimbitsFromServer(){ -#ifdef VERBOSE - cout<<"Getting all trimbits value" << endl; -#endif - disconnect(spinSetAllTrimbits, SIGNAL(editingFinished()), this, SLOT(SetAllTrimbits())); - - int ret = myDet->setAllTrimbits(-1); - qDefs::checkErrorMessage(myDet,"qTabAdvanced::updateAllTrimbitsFromServer"); - spinSetAllTrimbits->setValue(ret); - - connect(spinSetAllTrimbits, SIGNAL(editingFinished()), this, SLOT(SetAllTrimbits())); -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qTabAdvanced::SetNumStoragecells(int value) { -#ifdef VERBOSE - cout << "Setting number of stoarge cells to " << value << endl; -#endif - myDet->setTimer(slsDetectorDefs::STORAGE_CELL_NUMBER,value); - - disconnect(spinNumStoragecells,SIGNAL(valueChanged(int)),this, SLOT(SetNumStoragecells(int))); - spinNumStoragecells->setValue((int)myDet->setTimer(slsDetectorDefs::STORAGE_CELL_NUMBER,-1)); - connect(spinNumStoragecells,SIGNAL(valueChanged(int)), this, SLOT(SetNumStoragecells(int))); - - qDefs::checkErrorMessage(myDet,"qTabAdvanced::SetNumStoragecells"); -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qTabAdvanced::SetSubExposureTime() { - disconnect(spinSubExpTime,SIGNAL(valueChanged(double)), this, SLOT(SetSubExposureTime())); - disconnect(comboSubExpTimeUnit,SIGNAL(currentIndexChanged(int)),this, SLOT(SetSubExposureTime())); - - //Get the value of timer in ns - double timeNS = qDefs::getNSTime( - (qDefs::timeUnit)comboSubExpTimeUnit->currentIndex(), - spinSubExpTime->value()); - - // set value -#ifdef VERBOSE - cout << "Setting sub frame acquisition time to " << timeNS << " clocks" << - "/" << spinSubExpTime->value() << - qDefs::getUnitString((qDefs::timeUnit)comboSubExpTimeUnit->currentIndex()) << endl; -#endif - myDet->setTimer(slsDetectorDefs::SUBFRAME_ACQUISITION_TIME,(int64_t)timeNS); - qDefs::checkErrorMessage(myDet,"qTabAdvanced::SetSubExposureTime"); - - // update value in gui - qDefs::timeUnit unit; - double time = qDefs::getCorrectTime(unit,((double)( - myDet->setTimer(slsDetectorDefs::SUBFRAME_ACQUISITION_TIME,-1)*(1E-9)))); - spinSubExpTime->setValue(time); - comboSubExpTimeUnit->setCurrentIndex((int)unit); - - - // highlight if period < exptime - CheckAcqPeriodGreaterThanExp(); - - connect(spinSubExpTime,SIGNAL(valueChanged(double)), this, SLOT(SetSubExposureTime())); - connect(comboSubExpTimeUnit,SIGNAL(currentIndexChanged(int)), this, SLOT(SetSubExposureTime())); - - - qDefs::checkErrorMessage(myDet,"qTabAdvanced::SetSubExposureTime"); -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qTabAdvanced::SetSubPeriod() { - disconnect(spinSubPeriod,SIGNAL(valueChanged(double)), this, SLOT(SetSubPeriod())); - disconnect(comboSubPeriodUnit,SIGNAL(currentIndexChanged(int)),this, SLOT(SetSubPeriod())); - - //Get the value of timer in ns - double timeNS = qDefs::getNSTime( - (qDefs::timeUnit)comboSubPeriodUnit->currentIndex(), - spinSubPeriod->value()); - - // set value -#ifdef VERBOSE - cout << "Setting sub frame period to " << timeNS << " clocks" << - "/" << spinSubPeriod->value() << - qDefs::getUnitString((qDefs::timeUnit)comboSubPeriodUnit->currentIndex()) << endl; -#endif - myDet->setTimer(slsDetectorDefs::SUBFRAME_DEADTIME,(int64_t)timeNS); - qDefs::checkErrorMessage(myDet,"qTabAdvanced::SetSubPeriod"); - - // update value in gui - qDefs::timeUnit unit; - double time = qDefs::getCorrectTime(unit,((double)( - myDet->setTimer(slsDetectorDefs::SUBFRAME_DEADTIME,-1)*(1E-9)))); - spinSubPeriod->setValue(time); - comboSubPeriodUnit->setCurrentIndex((int)unit); - - // highlight if period < exptime - CheckAcqPeriodGreaterThanExp(); - - connect(spinSubPeriod,SIGNAL(valueChanged(double)), this, SLOT(SetSubPeriod())); - connect(comboSubPeriodUnit,SIGNAL(currentIndexChanged(int)),this, SLOT(SetSubPeriod())); - - - qDefs::checkErrorMessage(myDet,"qTabAdvanced::SetSubPeriod"); -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qTabAdvanced::CheckAcqPeriodGreaterThanExp(){ - double exptimeNS = qDefs::getNSTime( - (qDefs::timeUnit)comboSubExpTimeUnit->currentIndex(), - spinSubExpTime->value()); - double acqtimeNS = qDefs::getNSTime( - (qDefs::timeUnit)comboSubPeriodUnit->currentIndex(), - spinSubPeriod->value()); - if(exptimeNS>acqtimeNS && acqtimeNS > 0) { - spinSubPeriod->setToolTip(errSubPeriodTip); - lblSubPeriod->setToolTip(errSubPeriodTip); - lblSubPeriod->setPalette(red); - lblSubPeriod->setText("Sub Frame Period:*"); - } - else { - spinSubPeriod->setToolTip(acqSubPeriodTip); - lblSubPeriod->setToolTip(acqSubPeriodTip); - lblSubPeriod->setPalette(lblExpTime->palette()); - lblSubPeriod->setText("Sub Frame Period:"); - } -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qTabAdvanced::Refresh(){ - - -#ifdef VERBOSE - cout << endl << "**Updating Advanced Tab" << endl; -#endif - //setting color of tab - //void setTabBar ( QTabBar * tb ) - //QTabBar * tabBar () const - /* - for(int i=0;itabBar()->setTabTextColor(i,defaultTabColor); - tabAdvancedSettings->tabBar()->setTabTextColor(index,QColor(0,0,200,255)); - */ - - if(isAngular){ -#ifdef VERBOSE - cout << "Angular Calibration Log set to " << chkAngularLog->isChecked() << endl; -#endif - - disconnect(chkAngularLog, SIGNAL(toggled(bool)), this, SLOT(SetLogs())); - - chkAngularLog->setChecked(myDet->getActionMode(slsDetectorDefs::angCalLog)); - - connect(chkAngularLog, SIGNAL(toggled(bool)), this, SLOT(SetLogs())); - } - - - if(isEnergy){ - //disconnect - disconnect(chkEnergyLog, SIGNAL(toggled(bool)), this, SLOT(SetLogs())); - disconnect(spinExpTime, SIGNAL(valueChanged(double)), this, SLOT(SetExposureTime())); - disconnect(comboExpUnit, SIGNAL(currentIndexChanged(int)), this, SLOT(SetExposureTime())); - disconnect(spinThreshold, SIGNAL(valueChanged(double)), this, SLOT(SetThreshold())); - - - //energy/angular logs - chkEnergyLog->setChecked(myDet->getActionMode(slsDetectorDefs::enCalLog)); -#ifdef VERBOSE - cout << "Energy Calibration Log set to " << chkEnergyLog->isChecked() << endl; -#endif - - - //exptime - qDefs::timeUnit unit; - double time = qDefs::getCorrectTime(unit,((double)(myDet->setTimer(slsDetectorDefs::ACQUISITION_TIME,-1)*(1E-9)))); -#ifdef VERBOSE - cout << "Getting acquisition time : " << time << qDefs::getUnitString(unit) << endl; -#endif - spinExpTime->setValue(time); - comboExpUnit->setCurrentIndex((int)unit); - - - //threshold - double threshold = (double)myDet->setDAC(-1,slsDetectorDefs::THRESHOLD,0); -#ifdef VERBOSE - cout << "Getting Threshold DACu : " << threshold << endl; -#endif - spinThreshold->setValue(threshold); - - - //connect - connect(chkEnergyLog, SIGNAL(toggled(bool)), this, SLOT(SetLogs())); - connect(spinExpTime, SIGNAL(valueChanged(double)), this, SLOT(SetExposureTime())); - connect(comboExpUnit, SIGNAL(currentIndexChanged(int)), this, SLOT(SetExposureTime())); - connect(spinThreshold, SIGNAL(valueChanged(double)), this, SLOT(SetThreshold())); - } - - - //network - det = myDet->getSlsDetector(comboDetector->currentIndex()); - - qDefs::checkErrorMessage(myDet,"qTabAdvanced::Refresh"); - - - -#ifdef VERBOSE - cout << "Getting Detector Ports" << endl; -#endif - //disconnect - disconnect(spinControlPort, SIGNAL(valueChanged(int)), this, SLOT(SetControlPort(int))); - disconnect(spinStopPort, SIGNAL(valueChanged(int)), this, SLOT(SetStopPort(int))); - disconnect(comboOnline, SIGNAL(currentIndexChanged(int)), this, SLOT(SetOnline(int))); - - //so that updated status - if(det->setOnline()==slsDetectorDefs::ONLINE_FLAG) - det->checkOnline(); - comboOnline->setCurrentIndex(det->setOnline()); - spinControlPort->setValue(det->getControlPort()); - spinStopPort->setValue(det->getStopPort()); - - //connect - connect(spinControlPort, SIGNAL(valueChanged(int)), this, SLOT(SetControlPort(int))); - connect(spinStopPort, SIGNAL(valueChanged(int)), this, SLOT(SetStopPort(int))); - connect(comboOnline, SIGNAL(currentIndexChanged(int)), this, SLOT(SetOnline(int))); - - -#ifdef VERBOSE - cout << "Getting Receiver Network Information" << endl; -#endif - if (detType!=slsDetectorDefs::MYTHEN){ - //disconnect - disconnect(spinTCPPort, SIGNAL(valueChanged(int)), this, SLOT(SetRxrTCPPort(int))); - disconnect(spinUDPPort, SIGNAL(valueChanged(int)), this, SLOT(SetRxrUDPPort(int))); - disconnect(spinZmqPort, SIGNAL(valueChanged(int)), this, SLOT(SetCltZmqPort(int))); - disconnect(spinZmqPort2, SIGNAL(valueChanged(int)), this, SLOT(SetRxrZmqPort(int))); - disconnect(comboRxrOnline, SIGNAL(currentIndexChanged(int)), this, SLOT(SetReceiverOnline(int))); - disconnect(dispIP, SIGNAL(editingFinished()), this, SLOT(SetNetworkParameters())); - disconnect(dispMAC, SIGNAL(editingFinished()), this, SLOT(SetNetworkParameters())); - disconnect(dispUDPIP, SIGNAL(editingFinished()), this, SLOT(SetNetworkParameters())); - disconnect(dispUDPMAC, SIGNAL(editingFinished()), this, SLOT(SetNetworkParameters())); - disconnect(btnRxr, SIGNAL(clicked()), this, SLOT(SetReceiver())); - - dispIP->setText(det->getDetectorIP().c_str()); - dispMAC->setText(det->getDetectorMAC().c_str()); - - //so that updated status - if(det->setReceiverOnline()==slsDetectorDefs::ONLINE_FLAG) - det->checkReceiverOnline(); - comboRxrOnline->setCurrentIndex(det->setReceiverOnline()); - - dispRxrHostname->setText(det->getReceiver().c_str()); - spinTCPPort->setValue(det->getReceiverPort()); - spinUDPPort->setValue(atoi(det->getReceiverUDPPort().c_str())); - spinZmqPort->setValue(atoi(det->getClientStreamingPort().c_str())); - spinZmqPort2->setValue(atoi(det->getReceiverStreamingPort().c_str())); - - dispUDPIP->setText(det->getReceiverUDPIP().c_str()); - dispUDPMAC->setText(det->getReceiverUDPMAC().c_str()); - - //connect - connect(spinTCPPort, SIGNAL(valueChanged(int)), this, SLOT(SetRxrTCPPort(int))); - connect(spinUDPPort, SIGNAL(valueChanged(int)), this, SLOT(SetRxrUDPPort(int))); - connect(spinZmqPort, SIGNAL(valueChanged(int)), this, SLOT(SetCltZmqPort(int))); - connect(spinZmqPort2, SIGNAL(valueChanged(int)), this, SLOT(SetRxrZmqPort(int))); - connect(comboRxrOnline, SIGNAL(currentIndexChanged(int)), this, SLOT(SetReceiverOnline(int))); - connect(dispIP, SIGNAL(editingFinished()), this, SLOT(SetNetworkParameters())); - connect(dispMAC, SIGNAL(editingFinished()), this, SLOT(SetNetworkParameters())); - connect(dispUDPIP, SIGNAL(editingFinished()), this, SLOT(SetNetworkParameters())); - connect(dispUDPMAC, SIGNAL(editingFinished()), this, SLOT(SetNetworkParameters())); - connect(btnRxr, SIGNAL(clicked()), this, SLOT(SetReceiver())); - - // zmq parameters - disconnect(dispZMQIP, SIGNAL(editingFinished()), this, SLOT(SetClientZMQIP())); - dispZMQIP->setText(det->getClientStreamingIP().c_str()); - connect(dispZMQIP, SIGNAL(editingFinished()), this, SLOT(SetClientZMQIP())); - - disconnect(dispZMQIP2, SIGNAL(editingFinished()), this, SLOT(SetReceiverZMQIP())); - dispZMQIP2->setText(det->getReceiverStreamingIP().c_str()); - connect(dispZMQIP2, SIGNAL(editingFinished()), this, SLOT(SetReceiverZMQIP())); - } - - //highlight in red if detector or receiver is offline - if(!comboOnline->currentIndex()){ - comboOnline->setToolTip(detOnlineTip + errOnlineTip); - lblOnline->setToolTip(detOnlineTip + errOnlineTip); - lblOnline->setPalette(red); - lblOnline->setText("Online:*"); - }else{ - comboOnline->setToolTip(detOnlineTip); - lblOnline->setToolTip(detOnlineTip); - lblOnline->setPalette(lblHostname->palette()); - lblOnline->setText("Online:"); - } - if(comboRxrOnline->isEnabled()){ - if(!comboRxrOnline->currentIndex()){ - comboRxrOnline->setToolTip(rxrOnlineTip + errOnlineTip); - lblRxrOnline->setToolTip(rxrOnlineTip + errOnlineTip); - lblRxrOnline->setPalette(red); - lblRxrOnline->setText("Online:*"); - }else{ - comboRxrOnline->setToolTip(rxrOnlineTip); - lblRxrOnline->setToolTip(rxrOnlineTip); - lblRxrOnline->setPalette(lblHostname->palette()); - lblRxrOnline->setText("Online:"); - } - } - - //roi -#ifdef VERBOSE - cout << "Getting ROI" << endl; -#endif - if (detType == slsDetectorDefs::GOTTHARD) - updateROIList(); - - //update alltirmbits from server - if(boxSetAllTrimbits->isEnabled()) - updateAllTrimbitsFromServer(); - - // storage cells - if (detType == slsReceiverDefs::JUNGFRAU) { - disconnect(spinNumStoragecells,SIGNAL(valueChanged(int)),this, SLOT(SetNumStoragecells(int))); - spinNumStoragecells->setValue((int)myDet->setTimer(slsDetectorDefs::STORAGE_CELL_NUMBER,-1)); - connect(spinNumStoragecells,SIGNAL(valueChanged(int)), this, SLOT(SetNumStoragecells(int))); - } - - // sub exptime and sub period - else if (detType == slsReceiverDefs::EIGER) { - disconnect(spinSubExpTime,SIGNAL(valueChanged(double)), this, SLOT(SetSubExposureTime())); - disconnect(comboSubExpTimeUnit,SIGNAL(currentIndexChanged(int)),this, SLOT(SetSubExposureTime())); - disconnect(spinSubPeriod,SIGNAL(valueChanged(double)), this, SLOT(SetSubPeriod())); - disconnect(comboSubPeriodUnit,SIGNAL(currentIndexChanged(int)),this, SLOT(SetSubPeriod())); - -#ifdef VERBOSE - cout << "Getting Sub Exposure time and Sub Period" << endl; -#endif - // subexptime - qDefs::timeUnit unit; - double time = qDefs::getCorrectTime(unit,((double)( - myDet->setTimer(slsDetectorDefs::SUBFRAME_ACQUISITION_TIME,-1)*(1E-9)))); - spinSubExpTime->setValue(time); - comboSubExpTimeUnit->setCurrentIndex((int)unit); - - // subperiod - time = qDefs::getCorrectTime(unit,((double)(myDet->setTimer(slsDetectorDefs::SUBFRAME_DEADTIME,-1)*(1E-9)))); - spinSubPeriod->setValue(time); - comboSubPeriodUnit->setCurrentIndex((int)unit); - - - // highlight if period < exptime - CheckAcqPeriodGreaterThanExp(); - - connect(spinSubExpTime,SIGNAL(valueChanged(double)), this, SLOT(SetSubExposureTime())); - connect(comboSubExpTimeUnit,SIGNAL(currentIndexChanged(int)), this, SLOT(SetSubExposureTime())); - connect(spinSubPeriod,SIGNAL(valueChanged(double)), this, SLOT(SetSubPeriod())); - connect(comboSubPeriodUnit,SIGNAL(currentIndexChanged(int)),this, SLOT(SetSubPeriod())); - } - -#ifdef VERBOSE - cout << "**Updated Advanced Tab" << endl << endl; -#endif - - qDefs::checkErrorMessage(det,"qTabAdvanced::Refresh"); -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - diff --git a/slsDetectorGui/src/qTabDataOutput.cpp b/slsDetectorGui/src/qTabDataOutput.cpp deleted file mode 100644 index 1f38edb5e..000000000 --- a/slsDetectorGui/src/qTabDataOutput.cpp +++ /dev/null @@ -1,1102 +0,0 @@ -/* - * qTabDataOutput.cpp - * - * Created on: May 10, 2012 - * Author: l_maliakal_d - */ -/********************************************************************** - * ********************************************************************/ - -#include "qTabDataOutput.h" -// Project Class Headers -#include "slsDetector.h" -#include "multiSlsDetector.h" -// Qt Include Headers -#include -#include -// C++ Include Headers -#include -#include -using namespace std; - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - - -qTabDataOutput::qTabDataOutput(QWidget *parent,multiSlsDetector*& detector): - QWidget(parent),myDet(detector){ - setupUi(this); - SetupWidgetWindow(); - Refresh(); -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -qTabDataOutput::~qTabDataOutput(){ - delete myDet; -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qTabDataOutput::SetupWidgetWindow(){ - // Detector Type - detType=myDet->getDetectorsType(); - widgetEiger->setVisible(false); - - //rate correction - not for charge integrating detectors - if((detType == slsDetectorDefs::MYTHEN)||(detType == slsDetectorDefs::EIGER)) - chkRate->setEnabled(true); - - if((detType == slsDetectorDefs::MYTHEN)||(detType == slsDetectorDefs::GOTTHARD)) - chkAngular->setEnabled(true); - - if(detType == slsDetectorDefs::EIGER){ - chkRate->setEnabled(true); - chkTenGiga->setEnabled(true); - widgetEiger->setVisible(true); - } - - /** error message **/ - red = QPalette(); - red.setColor(QPalette::Active,QPalette::WindowText,Qt::red); - black = QPalette(); - black.setColor(QPalette::Active,QPalette::WindowText,Qt::black); - - red1 = new QPalette(); - red1->setColor(QPalette::Text,Qt::red); - black1 = new QPalette(); - black1->setColor(QPalette::Text,Qt::black); - - flatFieldTip = dispFlatField->toolTip(); - errFlatFieldTip = QString("Flat field corrections.
" - " #flatfield# filename

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

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

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

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

"); - chkRate->setToolTip(normalTip); - spinDeadTime->setToolTip(normalTip); - chkRate->setPalette(chkDiscardBad->palette()); - chkRate->setText("Rate:"); - } - - connect(chkRate, SIGNAL(toggled(bool)), this, SLOT(SetRateCorrection())); - connect(btnDefaultRate, SIGNAL(clicked()), this, SLOT(SetDefaultRateCorrection())); - connect(spinDeadTime, SIGNAL(editingFinished()), this, SLOT(SetRateCorrection())); -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qTabDataOutput::SetAngularCorrection(){ - disconnect(chkAngular, SIGNAL(toggled(bool)), this, SLOT(SetAngularCorrection())); -#ifdef VERYVERBOSE - cout << "Entering Set Angular Correction function" << endl; -#endif - bool enabled = chkAngular->isChecked(); - //set - if(myDet->setAngularCorrectionMask(enabled) == enabled){ -#ifdef VERBOSE - cout << "Angular Conversion mask:" << enabled << endl; -#endif - } - //error - else{ -#ifdef VERBOSE - cout << "Could not set angular conversion to default" << endl; -#endif - qDefs::Message(qDefs::WARNING,"Angular Conversion could not be set/reset. Please set the default file name using the command line, if you want to set it.","qTabDataOutput::SetAngularCorrection"); - chkAngular->setChecked(!enabled); - } - - emit AngularConversionSignal(chkAngular->isChecked()); - connect(chkAngular, SIGNAL(toggled(bool)), this, SLOT(SetAngularCorrection())); - qDefs::checkErrorMessage(myDet,"qTabDataOutput::SetAngularCorrection"); -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qTabDataOutput::DiscardBadChannels(){ -#ifdef VERBOSE - cout << "Entering Discard bad channels function" << endl; -#endif - if(chkDiscardBad->isChecked()){ -#ifdef VERBOSE - cout << "Setting bad channel correction to default" << endl; -#endif - myDet->setBadChannelCorrection("default"); - }else{ -#ifdef VERBOSE - cout << "Unsetting bad channel correction" << endl; -#endif - myDet->setBadChannelCorrection(""); - } - - qDefs::checkErrorMessage(myDet,"qTabDataOutput::DiscardBadChannels"); -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qTabDataOutput::PopulateDetectors(){ -#ifdef VERBOSE - cout << "Populating detectors" << endl; -#endif - comboDetector->clear(); - comboDetector->addItem("All"); - lblOutputDir->setText("Path:"); - //add specific detector options only if more than 1 detector - if(myDet->getNumberOfDetectors()>1){ - for(int i=0;igetNumberOfDetectors();i++) - comboDetector->addItem(QString(myDet->getHostname(i).c_str())); - } - GetOutputDir(); -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qTabDataOutput::GetOutputDir(){ -#ifdef VERBOSE - cout << "Getting output directory" << endl; -#endif - - disconnect(dispOutputDir, SIGNAL(editingFinished()), this, SLOT(SetOutputDir())); - //all - if(!comboDetector->currentIndex()) { - dispOutputDir->setText(QString(myDet->getFilePath().c_str())); - //multi file path blank means sls file paths are different - if (dispOutputDir->text().isEmpty()) { -#ifdef VERYVERBOSE - qDefs::Message(qDefs::INFORMATION,"The file path for individual units are different.\n" - "Hence, leaving the common field blank.","qTabDataOutput::GetOutputDir"); -#endif -#ifdef VERBOSE - cout << "The file path for individual units are different.\n" - "Hence, leaving the common field blank." << endl; -#endif - QString errTip = QString("
" - "Output Directory Information only: The file path for individual units are different.
" - "Hence, leaving the common field blank.
"); - lblOutputDir->setText("Path*:"); - lblOutputDir->setPalette(red); - lblOutputDir->setToolTip(errTip); - btnOutputBrowse->setToolTip(errTip); - dispOutputDir->setToolTip(errTip); - } else { - lblOutputDir->setText("Path:"); - lblOutputDir->setPalette(*black1); - lblOutputDir->setToolTip(outDirTip); - btnOutputBrowse->setToolTip(outDirTip); - dispOutputDir->setToolTip(outDirTip); - } - } - - //specific - else{ - slsDetector *det = myDet->getSlsDetector(comboDetector->currentIndex()-1); - qDefs::checkErrorMessage(myDet,"qTabDataOutput::GetOutputDir"); - dispOutputDir->setText(QString(det->getFilePath().c_str())); - } - - connect(dispOutputDir, SIGNAL(editingFinished()), this, SLOT(SetOutputDir())); -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -int qTabDataOutput::VerifyOutputDirectory(){ -#ifdef VERBOSE - cout << "Verifying output directory" << endl; -#endif - - GetOutputDir(); - - bool error = false; - string detName = ""; - string mess = ""; - - //common - myDet->setFilePath(myDet->getFilePath()); - if(!qDefs::checkErrorMessage(myDet,"qTabDataOutput::VerifyOutputDirectory").empty()) - error = true; - - //for each detector - for(int i=0;igetNumberOfDetectors();i++){ - slsDetector *det = myDet->getSlsDetector(i); - qDefs::checkErrorMessage(myDet,"qTabDataOutput::VerifyOutputDirectory"); - detName = string("\n - ") + string(comboDetector->itemText(i+1).toAscii().constData()); - det->setFilePath(det->getFilePath()); - if(!qDefs::checkErrorMessage(det,"qTabDataOutput::VerifyOutputDirectory").empty()) { - mess. append(detName); - error = true; - } - } - - //invalid - if(error){ - qDefs::Message(qDefs::WARNING,string("Invalid Output Directory ")+ mess ,"qTabDataOutput::VerifyOutputDirectory"); -#ifdef VERBOSE - cout << "The output path doesnt exist anymore" << endl; -#endif - //replace all \n with
- size_t pos = 0; - while((pos = mess.find("\n", pos)) != string::npos){ - mess.replace(pos, 1, "
"); - pos += 1; - } - QString errTip = outDirTip + - QString("
" - "Invalid Output Directory") + - QString(mess.c_str()) + - QString( "."); - lblOutputDir->setText("Path*:"); - lblOutputDir->setPalette(red); - lblOutputDir->setToolTip(errTip); - btnOutputBrowse->setToolTip(errTip); - dispOutputDir->setToolTip(errTip); - - return slsDetectorDefs::FAIL; - } - - //valid - else{ -#ifdef VERBOSE - cout << "The output pathid valid" << endl; -#endif - lblOutputDir->setText("Path:"); - lblOutputDir->setPalette(*black1); - lblOutputDir->setToolTip(outDirTip); - btnOutputBrowse->setToolTip(outDirTip); - dispOutputDir->setToolTip(outDirTip); - } - - return slsDetectorDefs::OK; -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qTabDataOutput::SetOutputDir(){ - -#ifdef VERBOSE - cout << "Setting output directory" << endl; -#endif - - disconnect(dispOutputDir, SIGNAL(editingFinished()), this, SLOT(SetOutputDir())); - - - bool error = false; - QString path = dispOutputDir->text(); - - //empty - if(path.isEmpty()) { - qDefs::Message(qDefs::WARNING,"Invalid Output Path. Must not be empty.","qTabDataOutput::SetOutputDir"); -#ifdef VERBOSE - cout << "Invalid Output Path. Must not be empty." << endl; -#endif - error = true; - } - //gets rid of the end '/'s - else if (path.endsWith('/')){ - while(path.endsWith('/')) - path.chop(1); - dispOutputDir->setText(path); - } - - //specific - if(comboDetector->currentIndex()){ - slsDetector *det = myDet->getSlsDetector(comboDetector->currentIndex()-1); - qDefs::checkErrorMessage(myDet,"qTabDataOutput::SetOutputDir"); - det->setFilePath(string(dispOutputDir->text().toAscii().constData())); - if(!qDefs::checkErrorMessage(det,"qTabDataOutput::SetOutputDir").empty()) - error = true; - } - - //multi - else{ - myDet->setFilePath(string(path.toAscii().constData())); - if(!qDefs::checkErrorMessage(myDet,"qTabDataOutput::SetOutputDir").empty()) - error = true; - } - - - if(error){ -#ifdef VERBOSE - cout << "The output path could not be set" << endl; -#endif - QString errTip = outDirTip + QString("
" - "Invalid File Path"); - - lblOutputDir->setText("Path*:"); - lblOutputDir->setPalette(red); - lblOutputDir->setToolTip(errTip); - btnOutputBrowse->setToolTip(errTip); - dispOutputDir->setToolTip(errTip); - } - else{ -#ifdef VERBOSE - cout << "The output path has been modified" << endl; -#endif - lblOutputDir->setText("Path:"); - lblOutputDir->setPalette(*black1); - lblOutputDir->setToolTip(outDirTip); - btnOutputBrowse->setToolTip(outDirTip); - dispOutputDir->setToolTip(outDirTip); - - } - - - connect(dispOutputDir, SIGNAL(editingFinished()), this, SLOT(SetOutputDir())); - -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qTabDataOutput::EnableTenGigabitEthernet(bool enable,int get){ -#ifdef VERBOSE - cout << endl << "Enabling/Disabling 10GbE" << endl; -#endif - disconnect(chkTenGiga, SIGNAL(toggled(bool)), this, SLOT(EnableTenGigabitEthernet(bool))); - int ret; - if(get) - ret = myDet->enableTenGigabitEthernet(-1); - else - ret = myDet->enableTenGigabitEthernet(enable); - if(ret > 0) chkTenGiga->setChecked(true); - else chkTenGiga->setChecked(false); - connect(chkTenGiga, SIGNAL(toggled(bool)), this, SLOT(EnableTenGigabitEthernet(bool))); - - qDefs::checkErrorMessage(myDet,"qTabDataOutput::EnableTenGigabitEthernet"); -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qTabDataOutput::SetSpeed(){ -#ifdef VERBOSE - cout << endl << "Setting Speed" << endl; -#endif - if(widgetEiger->isVisible()){ - myDet->setSpeed(slsDetectorDefs::CLOCK_DIVIDER,comboEigerClkDivider->currentIndex()); - qDefs::checkErrorMessage(myDet,"qTabDataOutput::SetSpeed"); - UpdateSpeedFromServer(); - } - -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qTabDataOutput::SetFlags(){ -#ifdef VERBOSE - cout << endl << "Setting Readout Flags" << endl; -#endif - slsDetectorDefs::readOutFlags val = slsDetectorDefs::GET_READOUT_FLAGS; - if(widgetEiger->isVisible()){ - - //set to continous or storeinram - switch(comboEigerFlags1->currentIndex()){ - case Storeinram: val = slsDetectorDefs::STORE_IN_RAM; break; - default: val = slsDetectorDefs::CONTINOUS_RO; break; - } - myDet->setReadOutFlags(val); - qDefs::checkErrorMessage(myDet,"qTabDataOutput::setFlags"); - - //set to parallel, nonparallel or safe - switch(comboEigerFlags2->currentIndex()){ - case Parallel: val = slsDetectorDefs::PARALLEL; break; - case Safe: val = slsDetectorDefs::SAFE; break; - default: val = slsDetectorDefs::NONPARALLEL; break; - } - myDet->setReadOutFlags(val); - qDefs::checkErrorMessage(myDet,"qTabDataOutput::setFlags"); - - //update flags - UpdateFlagsFromServer(); - } - -} - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qTabDataOutput::UpdateSpeedFromServer(){ - int ret; - if(widgetEiger->isVisible()){ - disconnect(comboEigerClkDivider, SIGNAL(currentIndexChanged(int)), this, SLOT(SetSpeed())); - - //get speed - ret = myDet->setSpeed(slsDetectorDefs::CLOCK_DIVIDER, -1); - qDefs::checkErrorMessage(myDet,"qTabDataOutput::updateSpeedFromServer"); - - //valid speed - if(ret >= 0 && ret < NumberofSpeeds) - comboEigerClkDivider->setCurrentIndex(ret); - - //invalid speed - else{ - qDefs::Message(qDefs::WARNING,"Inconsistent value from clock divider.\n" - "Setting it for all detectors involved to half speed.","qTabDataOutput::updateSpeedFromServer"); - //set to default - comboEigerClkDivider->setCurrentIndex(HalfSpeed); - myDet->setSpeed(slsDetectorDefs::CLOCK_DIVIDER,HalfSpeed); - qDefs::checkErrorMessage(myDet,"qTabDataOutput::updateSpeedFromServer"); - - } - connect(comboEigerClkDivider, SIGNAL(currentIndexChanged(int)), this, SLOT(SetSpeed())); - } -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qTabDataOutput::UpdateFlagsFromServer(){ - int ret; - if(widgetEiger->isVisible()){ - disconnect(comboEigerFlags1, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFlags())); - disconnect(comboEigerFlags2, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFlags())); - - //get speed - ret = myDet->setReadOutFlags(slsDetectorDefs::GET_READOUT_FLAGS); - qDefs::checkErrorMessage(myDet,"qTabDataOutput::updateFlagsFromServer"); - - //invalid flags - if(ret==-1){ - qDefs::Message(qDefs::WARNING,"Inconsistent value for readout flags.\n" - "Setting it for all detectors involved to continous nonparallel mode.", - "qTabDataOutput::updateFlagsFromServer"); - //set to default - comboEigerFlags1->setCurrentIndex(Continous); - myDet->setReadOutFlags(slsDetectorDefs::CONTINOUS_RO); - qDefs::checkErrorMessage(myDet,"qTabDataOutput::updateFlagsFromServer"); - comboEigerFlags2->setCurrentIndex(NonParallel); - myDet->setReadOutFlags(slsDetectorDefs::NONPARALLEL); - qDefs::checkErrorMessage(myDet,"qTabDataOutput::updateFlagsFromServer"); - } - - //valid flags - else{ - if(ret & slsDetectorDefs::STORE_IN_RAM) - comboEigerFlags1->setCurrentIndex(Storeinram); - else if(ret & slsDetectorDefs::CONTINOUS_RO) - comboEigerFlags1->setCurrentIndex(Continous); - if(ret & slsDetectorDefs::PARALLEL) - comboEigerFlags2->setCurrentIndex(Parallel); - else if(ret & slsDetectorDefs::NONPARALLEL) - comboEigerFlags2->setCurrentIndex(NonParallel); - else if(ret & slsDetectorDefs::SAFE) - comboEigerFlags2->setCurrentIndex(Safe); - } - - connect(comboEigerFlags1, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFlags())); - connect(comboEigerFlags2, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFlags())); - } -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qTabDataOutput::SetupFileFormat(){ - - - //To be able to index items on a combo box - QStandardItemModel* model = qobject_cast(comboFileFormat->model()); - QModelIndex index[slsReceiverDefs::NUM_FILE_FORMATS]; - QStandardItem* item[slsReceiverDefs::NUM_FILE_FORMATS]; - if (model) { - for(int i=0;iindex(i, comboFileFormat->modelColumn(), comboFileFormat->rootModelIndex()); - item[i] = model->itemFromIndex(index[i]); - } - //Enabling/Disabling depending on the detector type - switch(detType){ - case slsDetectorDefs::MYTHEN: - item[(int)slsReceiverDefs::BINARY]->setEnabled(false); - item[(int)slsReceiverDefs::ASCII]->setEnabled(true); - item[(int)slsReceiverDefs::HDF5]->setEnabled(false); - break; - case slsDetectorDefs::EIGER: - case slsDetectorDefs::MOENCH: - case slsDetectorDefs::PROPIX: - case slsDetectorDefs::GOTTHARD: - case slsDetectorDefs::JUNGFRAU: - case slsDetectorDefs::JUNGFRAUCTB: - item[(int)slsReceiverDefs::BINARY]->setEnabled(true); - item[(int)slsReceiverDefs::ASCII]->setEnabled(false); - item[(int)slsReceiverDefs::HDF5]->setEnabled(true); - break; - default: - cout << "Unknown detector type " << endl; - qDefs::Message(qDefs::CRITICAL,"Unknown detector type.","qTabDataOutput::SetupFileFormat"); - exit(-1); - break; - } - } - - comboFileFormat->setCurrentIndex((int)myDet->getFileFormat()); -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qTabDataOutput::UpdateFileFormatFromServer(){ -#ifdef VERBOSE - cout << endl << "Getting File Format" << endl; -#endif - disconnect(comboFileFormat, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFileFormat(int))); - - comboFileFormat->setCurrentIndex((int)myDet->getFileFormat()); - - connect(comboFileFormat, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFileFormat(int))); -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qTabDataOutput::SetFileFormat(int format){ -#ifdef VERBOSE - cout << endl << "Setting File Format" << endl; -#endif - disconnect(comboFileFormat, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFileFormat(int))); - - int ret = (int)myDet->setFileFormat((slsReceiverDefs::fileFormat)comboFileFormat->currentIndex()); - if (ret != comboFileFormat->currentIndex()) { - qDefs::Message(qDefs::WARNING,"Could not set file format.","qTabDataOutput::SetFileFormat"); - comboFileFormat->setCurrentIndex((int)ret); - } - - connect(comboFileFormat, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFileFormat(int))); -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qTabDataOutput::UpdateFileOverwriteFromServer(){ -#ifdef VERBOSE - cout << endl << "Getting File Over Write Enable" << endl; -#endif - disconnect(chkOverwriteEnable, SIGNAL(toggled(bool)), this, SLOT(SetOverwriteEnable(bool))); - - chkOverwriteEnable->setChecked(myDet->overwriteFile()); - - connect(chkOverwriteEnable, SIGNAL(toggled(bool)), this, SLOT(SetOverwriteEnable(bool))); -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qTabDataOutput::SetOverwriteEnable(bool enable){ -#ifdef VERBOSE - cout << endl << "Setting File Over Write Enable" << endl; -#endif - disconnect(chkOverwriteEnable, SIGNAL(toggled(bool)), this, SLOT(SetOverwriteEnable(bool))); - - int valid = (enable?1:0); - if (myDet->overwriteFile(enable) != valid) - qDefs::Message(qDefs::WARNING,"Could not over write enable.","qTabDataOutput::SetOverwriteEnable"); - - connect(chkOverwriteEnable, SIGNAL(toggled(bool)), this, SLOT(SetOverwriteEnable(bool))); - - UpdateFileOverwriteFromServer(); -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qTabDataOutput::Refresh(){ -#ifdef VERBOSE - cout << endl << "**Updating DataOutput Tab" << endl; -#endif - - if (!myDet->enableWriteToFile()) - boxFileWriteEnabled->setEnabled(false); - else - boxFileWriteEnabled->setEnabled(true); - - // output dir -#ifdef VERBOSE - cout << "Getting output directory" << endl; -#endif - - disconnect(comboDetector, SIGNAL(currentIndexChanged(int)), this, SLOT(GetOutputDir())); - PopulateDetectors(); - connect(comboDetector, SIGNAL(currentIndexChanged(int)), this, SLOT(GetOutputDir())); - - //file format - UpdateFileFormatFromServer(); - - //overwrite - UpdateFileOverwriteFromServer(); - - //file name - dispFileName->setText(QString(myDet->getFileName().c_str())); - - //flat field correction from server -#ifdef VERBOSE - cout << "Getting flat field" << endl; -#endif - UpdateFlatFieldFromServer(); - - - //rate correction - not for charge integrating detectors - if((detType == slsDetectorDefs::MYTHEN)||(detType == slsDetectorDefs::EIGER)){ -#ifdef VERBOSE - cout << "Getting rate correction" << endl; -#endif - UpdateRateCorrectionFromServer(); - } - - - //update angular conversion from server - if((detType == slsDetectorDefs::MYTHEN)||(detType == slsDetectorDefs::GOTTHARD)){ -#ifdef VERBOSE - cout << "Getting angular conversion" << endl; -#endif - int ang; - if(myDet->getAngularConversion(ang)) - chkAngular->setChecked(true); - emit AngularConversionSignal(chkAngular->isChecked()); - } - - - //discard bad channels from server -#ifdef VERBOSE - cout << "Getting bad channel correction" << endl;//cout << "ff " << myDet->getBadChannelCorrection() << endl; -#endif - - - disconnect(chkDiscardBad, SIGNAL(toggled(bool))); - if(myDet->getBadChannelCorrection()) - chkDiscardBad->setChecked(true); - else - chkDiscardBad->setChecked(false); - connect(chkDiscardBad, SIGNAL(toggled(bool)), this, SLOT(DiscardBadChannels())); - - if(myDet->setReceiverOnline()==slsDetectorDefs::ONLINE_FLAG){ - btnOutputBrowse->setEnabled(false); - btnOutputBrowse->setToolTip("This button is disabled as receiver PC is different from " - "client PC and hence different directory structures.

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

").arg(comboDetector->currentText(),comboModule->currentText()); - break; - case slsDetectorDefs::EIGER: Detector = "Half Module"; break; - case slsDetectorDefs::JUNGFRAU: - case slsDetectorDefs::JUNGFRAUCTB: - case slsDetectorDefs::MOENCH: - case slsDetectorDefs::PROPIX: - case slsDetectorDefs::GOTTHARD: Detector = "Module"; break; - default: break; - } - - - if(detType==slsDetectorDefs::MYTHEN) - message = QString("Test Results for %1 and %2:

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

").arg(comboDetector->currentText()); - - //get sls det object - det = myDet->getSlsDetector(comboDetector->currentIndex()); - qDefs::checkErrorMessage(myDet,"qTabDebugging::TestDetector"); - - //detector firmware - if(chkDetectorFirmware->isChecked()){ - retval = det->digitalTest(slsDetectorDefs::DETECTOR_FIRMWARE_TEST); - if(retval== slsDetectorDefs::FAIL) message.append(QString("%1 Firmware: FAIL
").arg(Detector)); - else message.append(QString("%1 Firmware: %2
").arg(Detector,QString::number(retval))); -#ifdef VERBOSE - cout<<"Detector Firmware: "<isChecked()){ - retval = det->digitalTest(slsDetectorDefs::DETECTOR_SOFTWARE_TEST); - if(retval== slsDetectorDefs::FAIL) message.append(QString("%1 Software: FAIL
").arg(Detector)); - else message.append(QString("%1 Software: %2
").arg(Detector,QString::number(retval))); -#ifdef VERBOSE - cout<<"Detector Software: "<isChecked()){ - retval = det->digitalTest(slsDetectorDefs::DETECTOR_BUS_TEST); - if(retval== slsDetectorDefs::FAIL) message.append(QString("%1 Bus:     FAIL
").arg(Detector)); - else message.append(QString("%1 Bus:     %2
").arg(Detector,QString::number(retval))); -#ifdef VERBOSE - cout<<"Detector Bus: "<isChecked()){ - retval = det->digitalTest(slsDetectorDefs::DETECTOR_MEMORY_TEST); - if(retval== slsDetectorDefs::FAIL) message.append(QString("%1 Memory:  FAIL
").arg(Detector)); - else message.append(QString("%1 Memory:  %2
").arg(Detector,QString::number(retval))); -#ifdef VERBOSE - cout<<"Detector Memory: "<isChecked()){ - retval = det->digitalTest(slsDetectorDefs::CHIP_TEST,comboModule->currentIndex()); - if(retval== slsDetectorDefs::FAIL) message.append("
Chip: FAIL
"); - else message.append(QString("Chip: %1
").arg(retval)); -#ifdef VERBOSE - cout<<"Chip: "<isChecked()){ - retval = det->digitalTest(slsDetectorDefs::MODULE_FIRMWARE_TEST,comboModule->currentIndex()); - if(retval== slsDetectorDefs::FAIL) message.append("Module Firmware: FAIL
"); - else message.append(QString("Module Firmware: %1
").arg(retval)); -#ifdef VERBOSE - cout<<"Module Firmware: "< -#include -#include -//C++ Include Headers -#include - -using namespace std; - -//------------------------------------------------------------------------------------------------------------------------------------------------- - -int qTabDeveloper::NUM_DAC_WIDGETS(0); -int qTabDeveloper::NUM_ADC_WIDGETS(0); - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -qTabDeveloper::qTabDeveloper(qDetectorMain *parent,multiSlsDetector*& detector): - thisParent(parent), - myDet(detector), - det(0), - boxDacs(0), - boxAdcs(0), - lblHV(0), - comboHV(0), - adcTimer(0), - dacLayout(0){ - for(int i=0;i<20;i++) { - lblDacs[i]=0; - lblAdcs[i]=0; - spinDacs[i]=0; - spinAdcs[i]=0; - lblDacsmV[i]=0; - } - SetupWidgetWindow(); - Initialization(); -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -qTabDeveloper::~qTabDeveloper() { - delete myDet; - if(det) delete det; - if(thisParent) delete thisParent; -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qTabDeveloper::SetupWidgetWindow() { - //Detector Type - detType=myDet->getDetectorsType(); - - //palette - red = QPalette(); - red.setColor(QPalette::Active,QPalette::WindowText,Qt::red); - - - //the number of dacs and adcs - switch(detType){ - case slsDetectorDefs::MYTHEN: - NUM_DAC_WIDGETS = 6; - NUM_ADC_WIDGETS = 0; - dacNames.push_back("v Trimbit:"); - dacNames.push_back("v Threshold:"); - dacNames.push_back("v Shaper1:"); - dacNames.push_back("v Shaper2:"); - dacNames.push_back("v Calibration:"); - dacNames.push_back("v Preamp:"); - break; - case slsDetectorDefs::EIGER: - NUM_DAC_WIDGETS = 17; - NUM_ADC_WIDGETS = 6; - - dacNames.push_back("v SvP:"); - dacNames.push_back("v SvN"); - dacNames.push_back("v Vrf:"); - dacNames.push_back("v Vrs:"); - dacNames.push_back("v Vtr:"); - dacNames.push_back("v Vtgstv:"); - dacNames.push_back("v cal:"); - dacNames.push_back("v Vcp"); - dacNames.push_back("v Vcn:"); - dacNames.push_back("v Vis:"); - dacNames.push_back("v rxb_lb:"); - dacNames.push_back("v rxb_rb:"); - dacNames.push_back("v Vcmp_ll:"); - dacNames.push_back("v Vcmp_lr:"); - dacNames.push_back("v Vcmp_rl:"); - dacNames.push_back("v Vcmp_rr:"); - dacNames.push_back("v threshold:"); - - adcNames.push_back("Temperature FPGA Ext:"); - adcNames.push_back("Temperature 10GE:"); - adcNames.push_back("Temperature DCDC:"); - adcNames.push_back("Temperature SODL:"); - adcNames.push_back("Temperature SODR:"); - adcNames.push_back("Temperature FPGA:"); - - break; - case slsDetectorDefs::PROPIX: - case slsDetectorDefs::GOTTHARD: - NUM_DAC_WIDGETS = 8; - NUM_ADC_WIDGETS = 2; - dacNames.push_back("v Reference:"); - dacNames.push_back("v Cascode n:"); - dacNames.push_back("v Cascode p:"); - dacNames.push_back("v Comp. Output:"); - dacNames.push_back("v Cascode out"); - dacNames.push_back("v Comp. Input:"); - dacNames.push_back("v Comp. Ref:"); - dacNames.push_back("i Base Test:"); - - adcNames.push_back("Temperature ADC:"); - adcNames.push_back("Temperature FPGA:"); - - break; - case slsDetectorDefs::MOENCH: - NUM_DAC_WIDGETS = 8; - NUM_ADC_WIDGETS = 2; - dacNames.push_back("v Dac 0:"); - dacNames.push_back("v Dac 1:"); - dacNames.push_back("v Dac 2:"); - dacNames.push_back("v Dac 3:"); - dacNames.push_back("v Dac 4:"); - dacNames.push_back("v Dac 5:"); - dacNames.push_back("v Dac 6:"); - dacNames.push_back("i Dac 7:"); - - adcNames.push_back("Temperature ADC:"); - adcNames.push_back("Temperature FPGA:"); - - break; - - - case slsDetectorDefs::JUNGFRAU: - case slsDetectorDefs::JUNGFRAUCTB: - NUM_DAC_WIDGETS = 8; - NUM_ADC_WIDGETS = 1; - dacNames.push_back("v vb comp:"); - dacNames.push_back("v vdd prot:"); - dacNames.push_back("v vin com:"); - dacNames.push_back("v vref prech:"); - dacNames.push_back("v vb pixbuf:"); - dacNames.push_back("v vb ds:"); - dacNames.push_back("v vref ds:"); - dacNames.push_back("i vref comp:"); - - adcNames.push_back("Temperature ADC/FPGA:"); - - break; - - default: - cout << "ERROR: Unknown detector type: " + myDet->slsDetectorBase::getDetectorType(detType) << endl; - qDefs::Message(qDefs::CRITICAL,string("Unknown detector type:")+myDet->slsDetectorBase::getDetectorType(detType),"qTabDeveloper::SetupWidgetWindow"); - exit(-1); - break; - } - - - //layout - setFixedWidth(765); - setFixedHeight(20+50+(NUM_DAC_WIDGETS/2)*35); - //setHeight(340); - - scroll = new QScrollArea; - //scroll->setFrameShape(QFrame::NoFrame); - scroll->setWidget(this); - scroll->setWidgetResizable(true); - - layout = new QGridLayout(scroll); - layout->setContentsMargins(20,10,10,5); - setLayout(layout); - - //readout - comboDetector = new QComboBox(this); - //comboDetector->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed); - comboDetector->addItem("All"); - //add detectors - for(int i=1;igetNumberOfDetectors()+1;i++) - comboDetector->addItem(QString(myDet->getHostname(i-1).c_str())); - comboDetector->setCurrentIndex(0); - - - //dacs - boxDacs = new QGroupBox("Dacs",this); - boxDacs->setFixedHeight(25+(NUM_DAC_WIDGETS/2)*35); - CreateDACWidgets(); - - //HV for gotthard - if ((detType==slsDetectorDefs::GOTTHARD) || - (detType==slsDetectorDefs::PROPIX) || - (detType==slsDetectorDefs::MOENCH)){ - boxDacs->setFixedHeight(boxDacs->height()+35); - - lblHV = new QLabel("High Voltage",boxDacs); - comboHV = new QComboBox(boxDacs); - comboHV->addItem("0"); - comboHV->addItem("90"); - comboHV->addItem("110"); - comboHV->addItem("120"); - comboHV->addItem("150"); - comboHV->addItem("180"); - comboHV->addItem("200"); - tipHV = "Set high voltage to 0, 90, 110, 120, 150 or 200V."; - lblHV->setToolTip(tipHV); - comboHV->setToolTip(tipHV); - dacLayout->addWidget(lblHV,(int)(NUM_DAC_WIDGETS/2),1); - dacLayout->addWidget(comboHV,(int)(NUM_DAC_WIDGETS/2),2); - connect(comboHV, SIGNAL(currentIndexChanged(int)), this, SLOT(SetHighVoltage())); - } - layout->addWidget(comboDetector,0,0); - layout->addWidget(boxDacs,1,0); - - //adcs - if(NUM_ADC_WIDGETS) { - int rows = NUM_ADC_WIDGETS/2; - if (NUM_ADC_WIDGETS%2)rows++; - setFixedHeight(20+(50+(NUM_DAC_WIDGETS/2)*35)+(50+rows*35)); - boxAdcs = new QGroupBox("ADCs",this); - boxAdcs->setFixedHeight(25+rows*35); - layout->addWidget(boxAdcs,2,0); - CreateADCWidgets(); - //to make the adcs at the bottom most - if (detType!=slsDetectorDefs::EIGER) { - int diff = 340-height(); - setFixedHeight(340); - layout->setVerticalSpacing(diff/2); - } - //timer to check adcs - /*adcTimer = new QTimer(this); adc timer disabled, display adcs only when refreshing developer tab */ - } - - qDefs::checkErrorMessage(myDet,"qTabDeveloper::SetupWidgetWindow"); -} - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qTabDeveloper::Initialization(){ - /*if(NUM_ADC_WIDGETS) connect(adcTimer, SIGNAL(timeout()), this, SLOT(RefreshAdcs()));*/ - - for(int i=0;isetMinimum(-1); - spinDacs[i]->setMaximum(10000); - lblDacsmV[i]= new QLabel("",boxDacs); - - - dacLayout->addWidget(lblDacs[i],(int)(i/2),((i%2)==0)?1:5); - dacLayout->addWidget(spinDacs[i],(int)(i/2),((i%2)==0)?2:6); - dacLayout->addWidget(lblDacsmV[i],(int)(i/2),((i%2)==0)?3:7); - if(!(i%2)){ - dacLayout->addItem(new QSpacerItem(20,20,QSizePolicy::Fixed,QSizePolicy::Fixed),(int)(i/2),0); - dacLayout->addItem(new QSpacerItem(60,20,QSizePolicy::Fixed,QSizePolicy::Fixed),(int)(i/2),4); - dacLayout->addItem(new QSpacerItem(20,20,QSizePolicy::Fixed,QSizePolicy::Fixed),(int)(i/2),8); - } - } -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qTabDeveloper::CreateADCWidgets(){ - QGridLayout *adcLayout = new QGridLayout(boxAdcs); - - for(int i=0;isetReadOnly(true); - - adcLayout->addWidget(lblAdcs[i],(int)(i/2),((i%2)==0)?1:4); - adcLayout->addWidget(spinAdcs[i],(int)(i/2),((i%2)==0)?2:5); - if(!(i%2)){ - adcLayout->addItem(new QSpacerItem(20,20,QSizePolicy::Fixed,QSizePolicy::Fixed),(int)(i/2),0); - adcLayout->addItem(new QSpacerItem(60,20,QSizePolicy::Fixed,QSizePolicy::Fixed),(int)(i/2),3); - adcLayout->addItem(new QSpacerItem(20,20,QSizePolicy::Fixed,QSizePolicy::Fixed),(int)(i/2),6); - } - } -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qTabDeveloper::SetDacValues(int id){ -#ifdef VERBOSE - cout << "Setting dac:" << dacNames[id] << " : " << spinDacs[id]->value() << endl; -#endif - - int detid = comboDetector->currentIndex(); - if(detid) - det = myDet->getSlsDetector(detid-1); - - //all detectors - if(!detid){ - myDet->setDAC((dacs_t)spinDacs[id]->value(),getSLSIndex(id),0); - lblDacsmV[id]->setText(QString("%1mV").arg(myDet->setDAC(-1,getSLSIndex(id),1),-10)); - qDefs::checkErrorMessage(myDet,"qTabDeveloper::SetDacValues"); - } - //specific detector - else{ - det->setDAC((dacs_t)spinDacs[id]->value(),getSLSIndex(id),0); - lblDacsmV[id]->setText(QString("%1mV").arg(det->setDAC(-1,getSLSIndex(id),1),-10)); - qDefs::checkErrorMessage(det,"qTabDeveloper::SetDacValues"); - } - -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qTabDeveloper::SetHighVoltage(){ -#ifdef VERBOSE - cout << "Setting high voltage:" << comboHV->currentText().toAscii().constData() << endl; -#endif - - int detid = comboDetector->currentIndex(); - if(detid) - det = myDet->getSlsDetector(detid-1); - - int highvoltage = comboHV->currentText().toInt(); - int ret; - - //all detectors - if(!detid){ - ret = myDet->setDAC(highvoltage,slsDetectorDefs::HV_POT,0); - qDefs::checkErrorMessage(myDet,"qTabDeveloper::SetHighVoltage"); - } - //specific detector - else{ - ret = det->setDAC(highvoltage,slsDetectorDefs::HV_POT,0); - qDefs::checkErrorMessage(det,"qTabDeveloper::SetHighVoltage"); - } - - - //error - if(ret != highvoltage){ - qDefs::Message(qDefs::CRITICAL,"High Voltage could not be set to this value.","qTabDeveloper::SetHighVoltage"); - lblHV->setPalette(red); - lblHV->setText("High Voltage:*"); - QString errTip = tipHV+QString("

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

High Voltage could not be set. The return value is ")+ - QString::number(ret)+ QString(""); - lblHV->setToolTip(errTip); - comboHV->setToolTip(errTip); - break; - } - - connect(comboHV, SIGNAL(currentIndexChanged(int)), this, SLOT(SetHighVoltage())); - } - -#ifdef VERBOSE - cout << "**Updated Developer Tab" << endl << endl; -#endif - - qDefs::checkErrorMessage(myDet,"qTabDeveloper::Refresh"); -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- diff --git a/slsDetectorGui/src/qTabMeasurement.cpp b/slsDetectorGui/src/qTabMeasurement.cpp deleted file mode 100644 index caa3995c9..000000000 --- a/slsDetectorGui/src/qTabMeasurement.cpp +++ /dev/null @@ -1,926 +0,0 @@ -/* - * qTabMeasurement.cpp - * - * Created on: May 2, 2012 - * Author: l_maliakal_d - */ - -//Qt Project Class Headers -#include "qTabMeasurement.h" -#include "qDetectorMain.h" -//Project Class Headers -#include "slsDetector.h" -#include "multiSlsDetector.h" -//C++ Include Headers -#include -using namespace std; - - - - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -qTabMeasurement::qTabMeasurement(qDetectorMain *parent,multiSlsDetector*& detector, qDrawPlot*& plot): - thisParent(parent),myDet(detector),myPlot(plot),expertMode(false){ - setupUi(this); - SetupWidgetWindow(); - Initialization(); - SetupTimingMode(); -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -qTabMeasurement::~qTabMeasurement(){ - delete myDet; - delete myPlot; - delete thisParent; -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qTabMeasurement::SetupWidgetWindow(){ - - detType = myDet->getDetectorsType(); - - //Number of measurements - spinNumMeasurements->setValue((int)myDet->setTimer(slsDetectorDefs::MEASUREMENTS_NUMBER,-1)); - //Number of frames - spinNumFrames->setValue((int)myDet->setTimer(slsDetectorDefs::FRAME_NUMBER,-1)); - //Exp Time - qDefs::timeUnit unit; - double time = qDefs::getCorrectTime(unit,((double)(myDet->setTimer(slsDetectorDefs::ACQUISITION_TIME,-1)*(1E-9)))); - spinExpTime->setValue(time); - comboExpUnit->setCurrentIndex((int)unit); - //period - time = qDefs::getCorrectTime(unit,((double)(myDet->setTimer(slsDetectorDefs::FRAME_PERIOD,-1)*(1E-9)))); - spinPeriod->setValue(time); - comboPeriodUnit->setCurrentIndex((int)unit); - //Number of Triggers - spinNumTriggers->setValue((int)myDet->setTimer(slsDetectorDefs::CYCLES_NUMBER,-1)); - //delay - if (detType == slsDetectorDefs::EIGER) { - lblDelay->setEnabled(false); - spinDelay->setEnabled(false); - comboDelayUnit->setEnabled(false); - } else { - time = qDefs::getCorrectTime(unit,((double)(myDet->setTimer(slsDetectorDefs::DELAY_AFTER_TRIGGER,-1)*(1E-9)))); - spinDelay->setValue(time); - comboDelayUnit->setCurrentIndex((int)unit); - } - //gates - if ((detType == slsDetectorDefs::EIGER) || (detType == slsDetectorDefs::JUNGFRAU) || (detType == slsDetectorDefs::JUNGFRAUCTB)) { - lblNumGates->setEnabled(false); - spinNumGates->setEnabled(false); - } else - spinNumGates->setValue((int)myDet->setTimer(slsDetectorDefs::GATES_NUMBER,-1)); - //probes - if(detType == slsDetectorDefs::MYTHEN) - spinNumProbes->setValue((int)myDet->setTimer(slsDetectorDefs::PROBES_NUMBER,-1)); - //File Name - dispFileName->setText(QString(myDet->getFileName().c_str())); - //File Index - spinIndex->setValue(myDet->getFileIndex()); - //only initially - lblProgressIndex->setText(QString::number(0)); - //ly initially - progressBar->setValue(0); - //file write enabled/disabled - chkFile->setChecked(myDet->enableWriteToFile()); - dispFileName->setEnabled(myDet->enableWriteToFile()); - - //Timer to update the progress bar - progressTimer = new QTimer(this); - - //Hide the error message - red = QPalette(); - red.setColor(QPalette::Active,QPalette::WindowText,Qt::red); - acqPeriodTip = spinPeriod->toolTip(); - errPeriodTip = QString("Frame period between exposures.
" - " #period#

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

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

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

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

" - "Every nth Image Condition: min nth Image for this time period: ")+QString("%1").arg(minFrame)+ - QString(".
You might be losing images!
"); - boxFrequency->setToolTip(errTip); - }else{ - boxFrequency->setPalette(boxSnapshot->palette()); - boxFrequency->setTitle("Interval between Plots"); - boxFrequency->setToolTip(intervalTip); - } - - // Setting the timer value (nth frames) between plots - myPlot->SetFrameFactor(spinNthFrame->value()); - - -#ifdef VERBOSE - cout << "Plotting Frequency: Nth Frame - " << spinNthFrame->value() << endl; -#endif - break; - } - - connect(comboTimeGapUnit,SIGNAL(currentIndexChanged(int)), this, SLOT(SetFrequency())); - connect(spinTimeGap, SIGNAL(editingFinished()), this, SLOT(SetFrequency())); - connect(spinNthFrame, SIGNAL(editingFinished()), this, SLOT(SetFrequency())); - connect(comboFrequency, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFrequency())); - qDefs::checkErrorMessage(myDet,"qTabPlot::SetFrequency"); -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - -void qTabPlot::EnableScanBox(){ -#ifdef VERBOSE - cout << "Entering Enable Scan Box"<< endl; -#endif - disconnect(btnGroupPlotType,SIGNAL(buttonClicked(int)),this, SLOT(SetPlot())); - disconnect(boxScan, SIGNAL(toggled(bool)), this, SLOT(EnableScanBox())); - - int oldfreqvalue = myDet->setReadReceiverFrequency(); - - int mode0 = myDet->getScanMode(0); - int mode1 = myDet->getScanMode(1); - - radioHistLevel0->setEnabled(mode0); - radioHistLevel1->setEnabled(mode1); - int ang; - bool angConvert = myDet->getAngularConversion(ang); - myPlot->EnableAnglePlot(angConvert); - - radioDataGraph->setEnabled(true); - radioHistogram->setEnabled(true); - chkSuperimpose->setEnabled(true); - pageAccumulate->setEnabled(true); - pageAccumulate_2->setEnabled(true); - if((myDet->getDetectorsType() == slsDetectorDefs::GOTTHARD) || - (myDet->getDetectorsType() == slsDetectorDefs::PROPIX) || - (myDet->getDetectorsType() == slsDetectorDefs::JUNGFRAU) || - (myDet->getDetectorsType() == slsDetectorDefs::JUNGFRAUCTB) || - (myDet->getDetectorsType() == slsDetectorDefs::MOENCH)){ - pagePedestal->setEnabled(true); - pagePedestal_2->setEnabled(true); - chkBinary->setEnabled(true); - chkBinary_2->setEnabled(true); - } - - - - - //if angle plot or originally 2d, uncheck and disable scanbox - if ((angConvert) || (!isOriginallyOneD)){ - boxScan->setChecked(false); - boxScan->setEnabled(false); - - /**Newly added*/ - // To remind the updateplot in qdrawplot to set range after updating plot - if(!isOriginallyOneD) - myPlot->SetXYRange(true); - - //2d scans read every frame, not compulsory, but for historgrams - if((!isOriginallyOneD) && (mode0 || mode1)){ - //read every frame - disconnect(spinNthFrame, SIGNAL(editingFinished()), this, SLOT(SetFrequency())); - disconnect(comboFrequency, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFrequency())); - comboFrequency->setCurrentIndex(1); - spinNthFrame->setValue(1); - SetFrequency(); - connect(spinNthFrame, SIGNAL(editingFinished()), this, SLOT(SetFrequency())); - connect(comboFrequency, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFrequency())); - } - - //persistency, accumulate, pedestal, binary - if(angConvert){ - if(chkSuperimpose->isChecked()) chkSuperimpose->setChecked(false); - if(chkPedestal->isChecked()) chkPedestal->setChecked(false); - if(chkPedestal_2->isChecked()) chkPedestal_2->setChecked(false); - if(chkAccumulate->isChecked()) chkAccumulate->setChecked(false); - if(chkAccumulate_2->isChecked())chkAccumulate_2->setChecked(false); - if(chkBinary->isChecked()) chkBinary->setChecked(false); - if(chkBinary_2->isChecked()) chkBinary_2->setChecked(false); - pagePedestal->setEnabled(false); - pagePedestal_2->setEnabled(false); - chkBinary->setEnabled(false); - chkBinary_2->setEnabled(false); - pageAccumulate->setEnabled(false); - pageAccumulate_2->setEnabled(false); - } - - if(angConvert){ - boxScan->setToolTip("Only 1D Plots enabled for Angle Plots"); - //disable histogram - if(radioHistogram->isChecked()){ - radioDataGraph->setChecked(true); - radioHistogram->setEnabled(false); - // To remind the updateplot in qdrawplot to set range after updating plot - myPlot->SetXYRange(true); - boxScan->show(); - boxHistogram->hide(); - } - } - } - - - - - //originally1d && not angle plot - else{ - boxScan->setToolTip(""); - boxScan->setEnabled(true); - /*if(mode0 || mode1) - boxScan->setChecked(true);*/ - - //2d enabled with boxscan - if(boxScan->isChecked()){ - - //2d for 1d detctors and histogram dont go - if(radioHistogram->isChecked()){ - radioDataGraph->setChecked(true); - // To remind the updateplot in qdrawplot to set range after updating plot - myPlot->SetXYRange(true); - boxScan->show(); - boxHistogram->hide(); - } - - //read every frame - disconnect(spinNthFrame, SIGNAL(editingFinished()), this, SLOT(SetFrequency())); - disconnect(comboFrequency, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFrequency())); - comboFrequency->setCurrentIndex(1); - spinNthFrame->setValue(1); - SetFrequency(); - connect(spinNthFrame, SIGNAL(editingFinished()), this, SLOT(SetFrequency())); - connect(comboFrequency, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFrequency())); - - //enabling options - radioFileIndex->setEnabled(mode0||mode1); - if(mode0 && mode1){ - radioLevel0->setEnabled(false); - radioLevel1->setEnabled(false); - }else{ - radioLevel0->setEnabled(mode0); - radioLevel1->setEnabled(mode1); - } - //default is allframes if checked button is disabled - if(!btnGroupScan->checkedButton()->isEnabled()) - radioAllFrames->setChecked(true); - } - } - - - //histogram - if(radioHistogram->isChecked()){ - if(radioHistIntensity->isChecked()){ - pageHistogram->setEnabled(true); - pageHistogram_2->setEnabled(true); - }else{ - pageHistogram->setEnabled(false); - pageHistogram_2->setEnabled(false); - } - stackedWidget->setCurrentIndex(stackedWidget->count()-1); - stackedWidget_2->setCurrentIndex(stackedWidget_2->count()-1); - box1D->setTitle(QString("1D Plot Options %1 - Histogram").arg(stackedWidget->currentIndex()+1)); - box2D->setTitle(QString("2D Plot Options %1 - Histogram").arg(stackedWidget_2->currentIndex()+1)); - - if(chkSuperimpose->isChecked()) chkSuperimpose->setChecked(false); - if(chkPedestal->isChecked()) chkPedestal->setChecked(false); - if(chkPedestal_2->isChecked()) chkPedestal_2->setChecked(false); - if(chkAccumulate->isChecked()) chkAccumulate->setChecked(false); - if(chkAccumulate_2->isChecked())chkAccumulate_2->setChecked(false); - if(chkBinary->isChecked()) chkBinary->setChecked(false); - if(chkBinary_2->isChecked()) chkBinary_2->setChecked(false); - pagePedestal->setEnabled(false); - pagePedestal_2->setEnabled(false); - chkBinary->setEnabled(false); - chkBinary_2->setEnabled(false); - pageAccumulate->setEnabled(false); - pageAccumulate_2->setEnabled(false); - - //read every frame - disconnect(spinNthFrame, SIGNAL(editingFinished()), this, SLOT(SetFrequency())); - disconnect(comboFrequency, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFrequency())); - comboFrequency->setCurrentIndex(1); - spinNthFrame->setValue(1); - SetFrequency(); - connect(spinNthFrame, SIGNAL(editingFinished()), this, SLOT(SetFrequency())); - connect(comboFrequency, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFrequency())); - - - }else{ - pageHistogram->setEnabled(false); - pageHistogram_2->setEnabled(false); - } - - - // if it was set to read every frame - if (oldfreqvalue != 0 && (comboFrequency->currentIndex() != 1 || spinNthFrame->value() != oldfreqvalue)) { - disconnect(spinNthFrame, SIGNAL(editingFinished()), this, SLOT(SetFrequency())); - disconnect(comboFrequency, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFrequency())); - comboFrequency->setCurrentIndex(1); - spinNthFrame->setValue(1); - SetFrequency(); - connect(spinNthFrame, SIGNAL(editingFinished()), this, SLOT(SetFrequency())); - connect(comboFrequency, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFrequency())); - } - - connect(btnGroupPlotType,SIGNAL(buttonClicked(int)),this, SLOT(SetPlot())); - connect(boxScan, SIGNAL(toggled(bool)), this, SLOT(EnableScanBox())); - -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - -void qTabPlot::SetScanArgument(){ -#ifdef VERYVERBOSE - cout << "Entering qTabPlot::SetScanArgument()" << endl; -#endif - - //1d - if(isOriginallyOneD){ - dispXAxis->setText(defaultHistXAxisTitle); - dispYAxis->setText(defaultHistYAxisTitle); - myPlot->SetHistXAxisTitle(defaultHistXAxisTitle); - myPlot->SetHistYAxisTitle(defaultHistYAxisTitle); - Select1DPlot(true); - } - //2d - else{ - dispXAxis->setText(defaultImageXAxisTitle); - dispYAxis->setText(defaultImageYAxisTitle); - dispZAxis->setText(defaultImageZAxisTitle); - myPlot->SetImageXAxisTitle(defaultImageXAxisTitle); - myPlot->SetImageYAxisTitle(defaultImageYAxisTitle); - myPlot->SetImageZAxisTitle(defaultImageZAxisTitle); - Select1DPlot(false); - } - - - //histogram default - set before setscanargument - int min = spinHistFrom->value(); - int max = spinHistTo->value(); - double size = spinHistSize->value(); - int histArg = qDefs::Intensity; - if(radioHistogram->isChecked()){ - if(!radioHistIntensity->isChecked()){ - - int mode = 0; - histArg = qDefs::histLevel0; - if(radioHistLevel1->isChecked()){ - mode = 1; - histArg = qDefs::histLevel1; - } - - - int numSteps = myDet->getScanSteps(mode); - double *values = NULL; - min = 0;max = 1;size = 1; - - if(numSteps > 0){ - values = new double[numSteps]; - myDet->getScanSteps(mode,values); - min = values[0]; - max = values[numSteps - 1]; - size = (max - min)/(numSteps - 1); - } - } - - } - - //cout <<"min:"<SetHistogram(radioHistogram->isChecked(),histArg,min,max,size); - - - if(radioHistogram->isChecked()){ - if(radioHistIntensity->isChecked()) - dispXAxis->setText("Intensity"); - else if (radioHistLevel0->isChecked()) - dispXAxis->setText("Level 0"); - else - dispXAxis->setText("Level 1"); - dispYAxis->setText("Frequency"); - myPlot->SetHistXAxisTitle("Intensity"); - myPlot->SetHistYAxisTitle("Frequency"); - Select1DPlot(true); - } - - //angles (1D) - int ang; - if(myDet->getAngularConversion(ang)){ - dispXAxis->setText("Angles"); - myPlot->SetHistXAxisTitle("Angles"); - Select1DPlot(true); - } - - - //1d with scan - if(boxScan->isChecked()){ - myPlot->SetScanArgument(btnGroupScan->checkedId()+1); - - switch(btnGroupScan->checkedId()){ - case 0://level0 - dispYAxis->setText("Scan Level 0"); - myPlot->SetImageYAxisTitle("Scan Level 0"); - break; - case 1://level1 - dispYAxis->setText("Scan Level 1"); - myPlot->SetImageYAxisTitle("Scan Level 1"); - break; - break; - case 2://file index - dispYAxis->setText("Frame Index"); - myPlot->SetImageYAxisTitle("Frame Index"); - break; - case 3://all frames - dispYAxis->setText("All Frames"); - myPlot->SetImageYAxisTitle("All Frames"); - break; - } - Select1DPlot(false); - }else - myPlot->SetScanArgument(qDefs::None); - - //update the from and to labels to be enabled - SetBinary(); - - qDefs::checkErrorMessage(myDet,"qTabPlot::SetScanArgument"); - -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qTabPlot::SetBinary(){ - //1d - if(isOneD){ - if(chkBinary->isChecked()){ -#ifdef VERBOSE - cout << endl << "Enabling Binary" << endl; -#endif - lblFrom->setEnabled(true); - lblTo->setEnabled(true); - spinFrom->setEnabled(true); - spinTo->setEnabled(true); - myPlot->SetBinary(true,spinFrom->value(),spinTo->value()); - }else{ -#ifdef VERBOSE - cout << endl << "Disabling Binary" << endl; -#endif - lblFrom->setEnabled(false); - lblTo->setEnabled(false); - spinFrom->setEnabled(false); - spinTo->setEnabled(false); - myPlot->SetBinary(false); - } - } - //2d - else{ - if(chkBinary_2->isChecked()){ -#ifdef VERBOSE - cout << endl << "Enabling Binary" << endl; -#endif - lblFrom_2->setEnabled(true); - lblTo_2->setEnabled(true); - spinFrom_2->setEnabled(true); - spinTo_2->setEnabled(true); - myPlot->SetBinary(true,spinFrom_2->value(),spinTo_2->value()); - - }else{ -#ifdef VERBOSE - cout << endl << "Disabling Binary" << endl; -#endif - - lblFrom_2->setEnabled(false); - lblTo_2->setEnabled(false); - spinFrom_2->setEnabled(false); - spinTo_2->setEnabled(false); - myPlot->SetBinary(false); - } - } -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qTabPlot::SetHistogramOptions(){ - if(radioHistIntensity->isChecked()){ - pageHistogram->setEnabled(true); - pageHistogram_2->setEnabled(true); - }else { - pageHistogram->setEnabled(false); - pageHistogram_2->setEnabled(false); - } -} - - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qTabPlot::EnableGapPixels(bool enable) { -#ifdef VERBOSE - cout << "Setting Gap pixels to " << enable << endl; -#endif - disconnect(chkGapPixels, SIGNAL(toggled(bool)),this, SLOT(EnableGapPixels(bool))); - - myDet->enableGapPixels(enable); - int ret = myDet->enableGapPixels(-1); - qDefs::checkErrorMessage(myDet,"qTabPlot::SetScanArgument"); - chkGapPixels->setChecked((ret == 1) ? true : false); - - connect(chkGapPixels, SIGNAL(toggled(bool)),this, SLOT(EnableGapPixels(bool))); -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qTabPlot::Refresh(){ -#ifdef VERBOSE - cout << endl << "**Updating Plot Tab" << endl; -#endif - if(!myPlot->isRunning()){ - if (!radioNoPlot->isChecked()) - boxFrequency->setEnabled(true); - connect(boxScan, SIGNAL(toggled(bool)), this, SLOT(EnableScanBox())); - EnableScanBox(); - /*if(myDet->getDetectorsType() == slsDetectorDefs::EIGER) - comboFrequency->setCurrentIndex(1);*/ - SetFrequency(); - - if (chkGapPixels->isEnabled()) { - disconnect(chkGapPixels, SIGNAL(toggled(bool)),this, SLOT(EnableGapPixels(bool))); - int ret = myDet->enableGapPixels(-1); - qDefs::checkErrorMessage(myDet,"qTabPlot::Refresh"); - chkGapPixels->setChecked((ret == 1) ? true : false); - connect(chkGapPixels, SIGNAL(toggled(bool)),this, SLOT(EnableGapPixels(bool))); - } - - }else{ - boxFrequency->setEnabled(false); - disconnect(boxScan, SIGNAL(toggled(bool)), this, SLOT(EnableScanBox())); - boxScan->setEnabled(false); - pageHistogram->setEnabled(false); - pageHistogram_2->setEnabled(false); - if(radioHistogram->isChecked()) - radioDataGraph->setEnabled(false); - else - radioHistogram->setEnabled(false); - } -#ifdef VERBOSE - cout << "**Updated Plot Tab" << endl << endl; -#endif -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - diff --git a/slsDetectorGui/src/qTabSettings.cpp b/slsDetectorGui/src/qTabSettings.cpp deleted file mode 100644 index aa3849f4e..000000000 --- a/slsDetectorGui/src/qTabSettings.cpp +++ /dev/null @@ -1,385 +0,0 @@ -/* - * qTabSettings.cpp - * - * Created on: May 10, 2012 - * Author: l_maliakal_d - */ - -#include "qTabSettings.h" -// Project Class Headers -#include "slsDetector.h" -#include "multiSlsDetector.h" -// C++ Include Headers -#include -#include -using namespace std; - -//------------------------------------------------------------------------------------------------------------------------------------------------- - -qTabSettings::qTabSettings(QWidget *parent,multiSlsDetector*& detector): - QWidget(parent),myDet(detector),expertMode(false){ - - for(int i=0;igetDetectorsType(); - - // Settings - if (detType != slsReceiverDefs::JUNGFRAUCTB) { - SetupDetectorSettings(); - } else - comboSettings->setEnabled(false); - - //threshold - if((detType == slsDetectorDefs::MYTHEN) || (detType == slsDetectorDefs::EIGER)) - spinThreshold->setValue(myDet->getThresholdEnergy()); - - //expert mode is not enabled initially - lblThreshold->setEnabled(false); - spinThreshold->setEnabled(false); - - // Number of Modules - spinNumModules->setMaximum(myDet->getMaxNumberOfModules()); - spinNumModules->setValue(myDet->setNumberOfModules()); - - Initialization(); - - // Dynamic Range - GetDynamicRange(); - - qDefs::checkErrorMessage(myDet,"qTabSettings::SetupWidgetWindow"); -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qTabSettings::GetDynamicRange(int setvalue){ -#ifdef VERBOSE - cout << "Getting dynamic range" << endl; -#endif - int ret = myDet->setDynamicRange(-1); - if(detType == slsDetectorDefs::MYTHEN) { - if(ret==24) - ret=32; - else if(ret==24) - cout<<"ret:"<setCurrentIndex(0); break; - case 16: comboDynamicRange->setCurrentIndex(1); break; - case 8: comboDynamicRange->setCurrentIndex(2); break; - case 4: comboDynamicRange->setCurrentIndex(3); break; - default: comboDynamicRange->setCurrentIndex(0); break; - } - connect(comboDynamicRange, SIGNAL(activated(int)), this, SLOT(SetDynamicRange(int))); -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qTabSettings::SetupDetectorSettings(){ - // Get detector settings from detector - int sett = (int)myDet->getSettings();cout<<"sett:"<(comboSettings->model()); - if (model) { - for(int i=0;iindex(i, comboSettings->modelColumn(), comboSettings->rootModelIndex()); - item[i] = model->itemFromIndex(index[i]); - } - - switch(detType){ - case slsDetectorDefs::MYTHEN: - item[(int)Standard]->setEnabled(true); - item[(int)Fast]->setEnabled(true); - item[(int)HighGain]->setEnabled(true); - item[(int)DynamicGain]->setEnabled(false); - item[(int)LowGain]->setEnabled(false); - item[(int)MediumGain]->setEnabled(false); - item[(int)VeryHighGain]->setEnabled(false); - item[(int)LowNoise]->setEnabled(false); - item[(int)DynamicHG0]->setEnabled(false); - item[(int)FixGain1]->setEnabled(false); - item[(int)FixGain2]->setEnabled(false); - item[(int)ForceSwitchG1]->setEnabled(false); - item[(int)ForceSwitchG2]->setEnabled(false); - item[(int)VeryLowGain]->setEnabled(false); - break; - case slsDetectorDefs::EIGER: - item[(int)Standard]->setEnabled(true); - item[(int)Fast]->setEnabled(false); - item[(int)HighGain]->setEnabled(true); - item[(int)DynamicGain]->setEnabled(false); - item[(int)LowGain]->setEnabled(true); - item[(int)MediumGain]->setEnabled(false); - item[(int)VeryHighGain]->setEnabled(true); - item[(int)LowNoise]->setEnabled(false); - item[(int)DynamicHG0]->setEnabled(false); - item[(int)FixGain1]->setEnabled(false); - item[(int)FixGain2]->setEnabled(false); - item[(int)ForceSwitchG1]->setEnabled(false); - item[(int)ForceSwitchG2]->setEnabled(false); - item[(int)VeryLowGain]->setEnabled(true); - break; - case slsDetectorDefs::MOENCH: - case slsDetectorDefs::PROPIX: - case slsDetectorDefs::GOTTHARD: - item[(int)Standard]->setEnabled(false); - item[(int)Fast]->setEnabled(false); - item[(int)HighGain]->setEnabled(true); - item[(int)DynamicGain]->setEnabled(true); - item[(int)LowGain]->setEnabled(true); - item[(int)MediumGain]->setEnabled(true); - item[(int)VeryHighGain]->setEnabled(true); - item[(int)LowNoise]->setEnabled(false); - item[(int)DynamicHG0]->setEnabled(false); - item[(int)FixGain1]->setEnabled(false); - item[(int)FixGain2]->setEnabled(false); - item[(int)ForceSwitchG1]->setEnabled(false); - item[(int)ForceSwitchG2]->setEnabled(false); - item[(int)VeryLowGain]->setEnabled(false); - break; - case slsDetectorDefs::JUNGFRAU: - item[(int)Standard]->setEnabled(false); - item[(int)Fast]->setEnabled(false); - item[(int)HighGain]->setEnabled(false); - item[(int)DynamicGain]->setEnabled(true); - item[(int)LowGain]->setEnabled(false); - item[(int)MediumGain]->setEnabled(false); - item[(int)VeryHighGain]->setEnabled(false); - item[(int)LowNoise]->setEnabled(false); - item[(int)DynamicHG0]->setEnabled(true); - item[(int)FixGain1]->setEnabled(true); - item[(int)FixGain2]->setEnabled(true); - item[(int)ForceSwitchG1]->setEnabled(true); - item[(int)ForceSwitchG2]->setEnabled(true); - item[(int)VeryLowGain]->setEnabled(false); - break; - default: - cout << "Unknown detector type. Exiting GUI." << endl; - qDefs::Message(qDefs::CRITICAL,"Unknown detector type. Exiting GUI.","qTabSettings::SetupDetectorSettings"); - exit(-1); - break; - } - // detector settings selected NOT ENABLED. - // This should not happen -only if the server and gui has a mismatch - // on which all modes are allowed in detectors - if(!(item[sett]->isEnabled())){ - qDefs::Message(qDefs::CRITICAL,"Unknown Detector Settings retrieved from detector. Exiting GUI.","qTabSettings::SetupDetectorSettings"); -#ifdef VERBOSE - cout << "ERROR: Unknown Detector Settings retrieved from detector." << endl; -#endif - sett= Undefined; - // exit(-1); - } - // Setting the detector settings - else comboSettings->setCurrentIndex(sett); - } -} - -//------------------------------------------------------------------------------------------------------------------------------------------------- - -void qTabSettings::Initialization(){ - // Settings - if (detType != slsReceiverDefs::JUNGFRAUCTB) - connect(comboSettings, SIGNAL(currentIndexChanged(int)), this, SLOT(setSettings(int))); - // Number of Modules - connect(spinNumModules, SIGNAL(valueChanged(int)), this, SLOT(SetNumberOfModules(int))); - // Dynamic Range - connect(comboDynamicRange, SIGNAL(activated(int)), this, SLOT(SetDynamicRange(int))); - // Threshold - connect(spinThreshold, SIGNAL(valueChanged(int)), this, SLOT(SetEnergy())); -} - -//------------------------------------------------------------------------------------------------------------------------------------------------- - -void qTabSettings::setSettings(int index){ - //dont set it if settings is set to undefined or uninitialized - if((index==Undefined)||(index==Uninitialized)){ - qDefs::Message(qDefs::WARNING,"Cannot change settings to Undefined or Uninitialized.","qTabSettings::setSettings"); - disconnect(comboSettings, SIGNAL(currentIndexChanged(int)), this, SLOT(setSettings(int))); - int sett = (int)myDet->getSettings(); - if(sett==-1) sett = Undefined; - if(sett == slsDetectorDefs::UNDEFINED) sett = Undefined; - else if(sett == slsDetectorDefs::UNINITIALIZED) sett = Uninitialized; - comboSettings->setCurrentIndex(sett); - connect(comboSettings, SIGNAL(currentIndexChanged(int)), this, SLOT(setSettings(int))); - } - - else{ - slsDetectorDefs::detectorSettings sett = myDet->setSettings((slsDetectorDefs::detectorSettings)index); - #ifdef VERBOSE - cout << endl << "Settings have been set to " << myDet->slsDetectorBase::getDetectorSettings(sett) << endl; - #endif - - //threshold - if((detType==slsDetectorDefs::MYTHEN)||(detType==slsDetectorDefs::EIGER)){ - lblThreshold->setEnabled(true); - spinThreshold->setEnabled(true); - SetEnergy(); - //also update trimbits plot - if(expertMode) emit UpdateTrimbitSignal(0); - } - } - - qDefs::checkErrorMessage(myDet,"qTabSettings::setSettings"); -} - -//------------------------------------------------------------------------------------------------------------------------------------------------- - -void qTabSettings::SetNumberOfModules(int index){ -#ifdef VERBOSE - cout << "Setting number of modules to "<< index << endl; -#endif - int i = myDet->setNumberOfModules(index); - if(index!=i) - qDefs::Message(qDefs::WARNING,"Number of modules cannot be set for this value.","qTabSettings::SetNumberOfModules"); -#ifdef VERBOSE - cout << "ERROR: Setting number of modules to "<< i << endl; -#endif - spinNumModules->setValue(i); - - qDefs::checkErrorMessage(myDet,"qTabSettings::SetNumberOfModules"); -} - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qTabSettings::SetDynamicRange(int index){ - int dr; - switch (index) { - case 0: dr=32; break; - case 1: dr=16; break; - case 2: dr=8; break; - case 3: dr=4; break; - default: dr=32; break; - } - myDet->setDynamicRange(dr); -#ifdef VERBOSE - cout << "Setting dynamic range to "<< dr << endl; -#endif - //check - GetDynamicRange(dr); - qDefs::checkErrorMessage(myDet,"qTabSettings::SetDynamicRange"); -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qTabSettings::SetEnergy(){ - int index = spinThreshold->value(); -#ifdef VERBOSE - cout << "Settings threshold energy to "<< index << endl; -#endif - myDet->setThresholdEnergy(index); - int ret = (int)myDet->getThresholdEnergy(); - if((ret-index)>200){ - qDefs::Message(qDefs::WARNING,"Threshold energy could not be set. The difference is greater than 200.","qTabSettings::SetEnergy"); - } - disconnect(spinThreshold, SIGNAL(valueChanged(int)), this, SLOT(SetEnergy())); - spinThreshold->setValue(ret); - connect(spinThreshold, SIGNAL(valueChanged(int)), this, SLOT(SetEnergy())); - - qDefs::checkErrorMessage(myDet,"qTabSettings::SetEnergy"); -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - -void qTabSettings::Refresh(){ -#ifdef VERBOSE - cout << endl << "**Updating Settings Tab" << endl; -#endif - - if (detType != slsReceiverDefs::JUNGFRAUCTB) - disconnect(comboSettings, SIGNAL(currentIndexChanged(int)), this, SLOT(setSettings(int))); - disconnect(spinNumModules, SIGNAL(valueChanged(int)), this, SLOT(SetNumberOfModules(int))); - disconnect(spinThreshold, SIGNAL(valueChanged(int)), this, SLOT(SetEnergy())); - - - // Number of Modules -#ifdef VERBOSE - cout << "Getting number of modules:" ; -#endif - int numMod = myDet->setNumberOfModules(); -#ifdef VERBOSE - cout << numMod << endl; -#endif - spinNumModules->setValue(numMod); - - // Dynamic Range - GetDynamicRange(); - - // Settings - if (detType != slsReceiverDefs::JUNGFRAUCTB) { -#ifdef VERBOSE - cout << "Getting settings" << endl; -#endif - int sett = (int)myDet->getSettings(); - if(sett==-1) sett = Undefined;//slsDetectorDefs::UNDEFINED; - if(sett == slsDetectorDefs::UNDEFINED) sett = Undefined; - else if(sett == slsDetectorDefs::UNINITIALIZED) sett = Uninitialized; - comboSettings->setCurrentIndex(sett); - - //threshold - sett = comboSettings->currentIndex(); - if((detType==slsDetectorDefs::MYTHEN)||(detType==slsDetectorDefs::EIGER)){ - if((sett==Undefined)||(sett==Uninitialized)){ - lblThreshold->setEnabled(false); - spinThreshold->setEnabled(false); - }else{ - lblThreshold->setEnabled(true); - spinThreshold->setEnabled(true); -#ifdef VERBOSE - cout << "Getting threshold energy" << endl; -#endif - spinThreshold->setValue(myDet->getThresholdEnergy()); - } - } -} - - if (detType != slsReceiverDefs::JUNGFRAUCTB) - connect(comboSettings, SIGNAL(currentIndexChanged(int)), this, SLOT(setSettings(int))); - connect(spinNumModules, SIGNAL(valueChanged(int)), this, SLOT(SetNumberOfModules(int))); - connect(spinThreshold, SIGNAL(valueChanged(int)), this, SLOT(SetEnergy())); - -#ifdef VERBOSE - cout << "**Updated Settings Tab" << endl << endl; -#endif - - qDefs::checkErrorMessage(myDet,"qTabSettings::Refresh"); -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- diff --git a/slsDetectorGui/updateGitVersion.sh b/slsDetectorGui/updateGitVersion.sh deleted file mode 100755 index f82322712..000000000 --- a/slsDetectorGui/updateGitVersion.sh +++ /dev/null @@ -1,26 +0,0 @@ -MAINDIR=slsDetectorsPackage -SPECDIR=slsDetectorGui -TMPFILE=include/gitInfoGuiTmp.h -INCLFILE=include/gitInfoGui.h -WD=$PWD - -#evaluate the variables -EVALFILE=../evalVersionVariables.sh -source $EVALFILE - -#get modified date -#RDATE1='git log --pretty=format:"%ci" -1' -RDATE1="find . -type f -exec stat --format '%Y :%y %n' '{}' \; | sort -nr | cut -d: -f2- | egrep -v 'gitInfo|build|.git|updateGitVersion|ui*.h|*.o|Makefile.gui' | head -n 1" -RDATE=`eval $RDATE1` -NEWDATE=$(sed "s/-//g" <<< $RDATE | awk '{print $1;}') -NEWDATE=${NEWDATE/#/0x} - -#get old date from INCLFILE -OLDDATE=$(more $INCLFILE | grep '#define GITDATE' | awk '{print $3}') -#update INCLFILE if changes -#if [ "$OLDDATE" != "$NEWDATE" ]; then - echo Path: ${MAINDIR}/${SPECDIR} $'\n'URL: ${GITREPO} $'\n'Repository Root: ${GITREPO} $'\n'Repsitory UUID: ${REPUID} $'\n'Revision: ${FOLDERREV} $'\n'Branch: ${BRANCH} $'\n'Last Changed Author: ${AUTH1}_${AUTH2} $'\n'Last Changed Rev: ${REV} $'\n'Last Changed Date: ${RDATE} > gitInfo.txt - cd .. - ./genVersionHeader.sh $SPECDIR/gitInfo.txt $SPECDIR/$TMPFILE $SPECDIR/$INCLFILE - cd $WD -#fi diff --git a/slsDetectorSoftware/.gitignore b/slsDetectorSoftware/.gitignore deleted file mode 100644 index 825dda897..000000000 --- a/slsDetectorSoftware/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -*.o -*~ -#*# -.project diff --git a/slsDetectorSoftware/CMakeLists.txt b/slsDetectorSoftware/CMakeLists.txt deleted file mode 100644 index 7834e25e3..000000000 --- a/slsDetectorSoftware/CMakeLists.txt +++ /dev/null @@ -1,98 +0,0 @@ -set(SOURCES - multiSlsDetector/multiSlsDetector.cpp - sharedMemory/SharedMemory.cpp - slsDetector/slsDetectorUsers.cpp - slsDetector/slsDetectorUtils.cpp - slsDetector/slsDetectorCommand.cpp - slsDetector/slsDetectorActions.cpp - slsDetector/slsDetector.cpp - slsDetectorAnalysis/angularConversion.cpp - slsDetectorAnalysis/angularConversionStatic.cpp - slsDetectorAnalysis/energyConversion.cpp - slsDetectorAnalysis/fileIO.cpp - slsDetectorAnalysis/postProcessing.cpp - slsDetectorAnalysis/postProcessingFuncs.cpp - slsReceiverInterface/receiverInterface.cpp - threadFiles/CondVar.cpp - threadFiles/Mutex.cpp - threadFiles/ThreadPool.cpp - usersFunctions/usersFunctions.cpp -) - -set(HEADERS -) - -include_directories( - commonFiles - multiSlsDetector - sharedMemory - slsDetector - slsDetectorUtils - slsDetectorCommand - slsDetectorAnalysis - slsReceiverInterface - threadFiles - usersFunctions - ../slsReceiverSoftware/include - ../slsReceiverSoftware/MySocketTCP -) - -add_definitions( - -DDACS_INT -) - -add_library(slsDetectorShared SHARED - ${SOURCES} - ${HEADERS} -) - -set(PUBLICHEADERS - commonFiles/sls_detector_defs.h - commonFiles/sls_detector_funcs.h - commonFiles/error_defs.h - commonFiles/versionAPI.h - sharedMemory/SharedMemory.h - slsDetector/slsDetectorUtils.h - slsDetector/slsDetector.h - slsDetector/slsDetectorActions.h - slsDetector/slsDetectorBase.h - slsDetector/slsDetectorUsers.h - slsDetectorAnalysis/postProcessing.h - slsDetectorAnalysis/detectorData.h - slsDetectorAnalysis/angularConversion.h - slsDetectorAnalysis/angularConversionStatic.h - slsDetectorAnalysis/angleConversionConstant.h - slsDetectorAnalysis/badChannelCorrections.h - slsDetectorAnalysis/energyConversion.h - slsDetectorAnalysis/fileIO.h - slsDetectorAnalysis/fileIOStatic.h - multiSlsDetector/multiSlsDetector.h - slsReceiverInterface/receiverInterface.h - ../slsReceiverSoftware/include/sls_receiver_exceptions.h - slsDetector/slsDetectorUsers.h - ../slsReceiverSoftware/include/slsReceiverUsers.h -) -set_target_properties(slsDetectorShared PROPERTIES - LIBRARY_OUTPUT_NAME SlsDetector - LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin - PUBLIC_HEADER "${PUBLICHEADERS}" -) - - - -add_subdirectory(slsDetectorClient) - -if(DOXYGEN_FOUND) - add_custom_target(doc - ${DOXYGEN_EXECUTABLE} - ${CMAKE_CURRENT_SOURCE_DIR}/slsDetectorUsers.doxy - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - COMMENT "Generating API documentation with Doxygen" VERBATIM - ) -endif() - -install(TARGETS slsDetectorShared - EXPORT "${TARGETS_EXPORT_NAME}" - LIBRARY DESTINATION lib - PUBLIC_HEADER DESTINATION include - ARCHIVE DESTINATION lib) diff --git a/slsDetectorSoftware/Makefile b/slsDetectorSoftware/Makefile deleted file mode 100644 index 1be7ccc6f..000000000 --- a/slsDetectorSoftware/Makefile +++ /dev/null @@ -1,82 +0,0 @@ -include ../Makefile.include - -DESTDIR ?= ../bin -LIBDIR ?= $(DESTDIR) - - -CFLAGS= -g -DC_ONLY -fPIC -#FLAGS+= #-DVERBOSE -DVERYVERBOSE - -DFLAGS= -g -DDACS_INT - -INCLUDES?= -IcommonFiles -IslsDetector -I../slsReceiverSoftware/MySocketTCP -IusersFunctions -ImultiSlsDetector -IslsDetectorUtils -IslsDetectorCommand -IslsDetectorAnalysis -IslsReceiverInterface -I../slsReceiverSoftware/include -IthreadFiles -IsharedMemory -I$(ASM) - -#EPICSFLAGS=-D EPICS -I/usr/local/epics/base/include/ -I /usr/local/epics/base/include/os/Linux/ -L /usr/local/epics/base/lib/$(EPICS_HOST_ARCH) -Wl,-R/usr/local/epics/base/lib/$(EPICS_HOST_ARCH) -lca -lCom - -LIBZMQDIR = ../slsReceiverSoftware/include -LIBZMQ = -L$(LIBZMQDIR) -Wl,-rpath=$(LIBZMQDIR) -lzmq - -SRC_CLNT=slsDetectorAnalysis/fileIO.cpp usersFunctions/usersFunctions.cpp slsDetector/slsDetectorUtils.cpp slsDetector/slsDetectorCommand.cpp slsDetectorAnalysis/angularConversion.cpp slsDetectorAnalysis/angularConversionStatic.cpp slsDetectorAnalysis/energyConversion.cpp slsDetector/slsDetectorActions.cpp slsDetectorAnalysis/postProcessing.cpp slsDetector/slsDetector.cpp multiSlsDetector/multiSlsDetector.cpp slsDetectorAnalysis/postProcessingFuncs.cpp slsReceiverInterface/receiverInterface.cpp slsDetector/slsDetectorUsers.cpp threadFiles/CondVar.cpp threadFiles/Mutex.cpp threadFiles/ThreadPool.cpp sharedMemory/SharedMemory.cpp #../slsReceiverSoftware/MySocketTCP/MySocketTCP.cpp -DEPSINCLUDES = $(LIBZMQDIR)/sls_receiver_defs.h $(LIBZMQDIR)/sls_receiver_funcs.h $(LIBZMQDIR)/ansi.h commonFiles/sls_detector_defs.h commonFiles/sls_detector_funcs.h commonFiles/error_defs.h slsDetector/slsDetectorBase.h slsDetectorAnalysis/angCalLogClass.h slsDetectorAnalysis/angleConversionConstant.h slsDetectorAnalysis/badChannelCorrections.h slsDetectorAnalysis/detectorData.h slsDetectorAnalysis/enCalLogClass.h slsDetectorAnalysis/fileIOStatic.h slsDetectorAnalysis/movingStat.h slsDetectorAnalysis/runningStat.h slsDetectorAnalysis/single_photon_hit.h threadFiles/Global.h threadFiles/Task.h usersFunctions/angleFunction.h sharedMemory/SharedMemory.h $(LIBZMQDIR)/sls_receiver_exceptions.h commonFiles/versionAPI.h - - - -$(info ) -$(info #######################################) -$(info # In slsDetectorSoftware Makefile #) -$(info #######################################) -$(info ) - - - - -OBJS = $(SRC_CLNT:%.cpp=%.o) - -.PHONY: all package clean - -all: package $(SRC_CLNT) - -mythenVirtualServer: $(SRC_MYTHEN_SVC) - cd mythenDetectorServer && make -f Makefile.virtual DESTDIR=$(DESTDIR) - -gotthardVirtualServer: $(SRC_MYTHEN_SVC) - cd gotthardDetectorServer && make -f Makefile.virtual DESTDIR=$(DESTDIR) - - -%.o : %.cpp %.h $(DEPSINCLUDES) Makefile - $(CXX) -o $@ -c $< $(INCLUDES) $(DFLAGS) -fPIC $(EPICSFLAGS) -pthread -lrt $(LIBZMQ) $(FLAGS) - - -package: versioning $(OBJS) $(DESTDIR)/libSlsDetector.so $(DESTDIR)/libSlsDetector.a - -versioning: - $(call colorecho,`./updateGitVersion.sh`) - -$(DESTDIR)/libSlsDetector.so: $(OBJS) - $(call colorecho,"#######################################") - $(call colorecho,"# Compiling slsDetector Library #") - $(call colorecho,"#######################################") - $(CXX) -shared -Wl,-soname,libSlsDetector.so -o libSlsDetector.so $(OBJS) -lc $(INCLUDES) $(DFLAGS) $(FLAGS) $(EPICSFLAGS) -L/usr/lib64 -pthread -lrt $(LIBZMQ) - $(shell test -d $(DESTDIR) || mkdir -p $(DESTDIR)) - mv libSlsDetector.so $(DESTDIR) - -$(DESTDIR)/libSlsDetector.a: $(OBJS) - ar rcs libSlsDetector.a $(OBJS) - mv libSlsDetector.a $(DESTDIR) - -clean: - rm -rf $(DESTDIR)/libSlsDetector.a $(DESTDIR)/libSlsDetector.so core $(OBJS) - cd - - - - -#------------------------------------------------------------------------------- - -install: package - -install_inc: - $(shell test -d $(DESTDIR) || mkdir -p $(DESTDIR)) - cp -P slsDetector/slsDetectorUsers.h slsDetectorAnalysis/detectorData.h $(DESTDIR) - - diff --git a/slsDetectorSoftware/Makefile.Standalone b/slsDetectorSoftware/Makefile.Standalone deleted file mode 100644 index d9a7c0868..000000000 --- a/slsDetectorSoftware/Makefile.Standalone +++ /dev/null @@ -1,68 +0,0 @@ -CFLAGS= -DC_ONLY -#FLAGS= -DVERBOSE -DVERYVERBOSE -INCLUDES= -IcommonFiles -IslsDetector -IMySocketTCP -IusersFunctions -ImultiSlsDetector -IslsDetectorUtils -IslsDetectorCommand -IslsDetectorAnalysis - -#EPICSFLAGS=-D EPICS -I/usr/local/epics/base/include/ -I /usr/local/epics/base/include/os/Linux/ -L /usr/local/epics/base/lib/SL5-x86/ -Wl,-R/usr/local/epics/base/lib/SL5-x86 -lca -lCom -CC=gcc -CXX=g++ - -SRC_CLNT= slsDetectorAnalysis/FileIO_Standalone.cpp MySocketTCP/MySocketTCP.cpp usersFunctions/usersFunctions.cpp slsDetector/slsDetectorUtils.cpp slsDetector/slsDetectorCommand.cpp slsDetectorAnalysis/AngularConversion_Standalone.cpp slsDetectorAnalysis/energyConversion.cpp slsDetector/slsDetectorActions.cpp slsDetectorAnalysis/postProcessingFileIO_Standalone.cpp slsDetector/slsDetector.cpp multiSlsDetector/multiSlsDetector.cpp - -OBJS = $(SRC_CLNT:.cpp=.o) - -HEADERS = $(SRC_CLNT:.cpp=.h) commonFiles/sls_detector_defs.h slsDetectorAnalysis/detectorData.h slsDetector/slsDetectorBase.h slsDetector/slsDetectorUsers.h multiSlsDetector/multiSlsDetectorCommand.h - - - -SRC_MYTHEN_SVC = mythenDetectorServer/server.c mythenDetectorServer/server_funcs.c mythenDetectorServer/communication_funcs.c mythenDetectorServer/firmware_funcs.c mythenDetectorServer/mcb_funcs.c mythenDetectorServer/trimming_funcs.c - -all: package $(SRC_CLNT) - echo "compiling all" - -doc: $(SRC_H) $(SRC_CLNT) - doxygen doxy.config - - - -mythenServer: $(SRC_MYTHEN_SVC) - $(CC) $(SRC_MYTHEN_SVC) $(CFLAGS) $(FLAGS) $(INCLUDES) -ImythenDetectorServer -DVIRTUAL -lm -D MCB_FUNCS -DC_ONLY -DVERBOSE - mv a.out mythenServer - - -picassoServer: $(SRC_MYTHEN_SVC) - $(CC) $(SRC_MYTHEN_SVC) $(CFLAGS) $(FLAGS) $(INCLUDES) -ImythenDetectorServer -D VIRTUAL -lm -DMCB_FUNCS -DPICASSOD -DC_ONLY - mv a.out picassoServer - - - - - -%.o : %.cpp %.h - $(CXX) -Wall -o $@ -c $< $(INCLUDES) $(FLAGS) $(EPICSFLAGS) - - -package: $(OBJS) - $(CXX) -shared -Wl,-soname,libSlsDetector.so -o libSlsDetector.so $(OBJS) -lc $(INCLUDES) $(FLAGS) $(EPICSFLAGS) - ar rcs libSlsDetector.a $(OBJS) - -clean: - rm -rf libSlsDetector.a libSlsDetector.so core docs/* $(OBJS) - - -#------------------------------------------------------------------------------- -lib: package - - -# added install target, HBl -install_lib: lib - $(shell test -d $(DESTDIR) || mkdir -p $(DESTDIR)) - cp -P libSlsDetector.so $(DESTDIR) - -install_inc: - $(shell test -d $(DESTDIR) || mkdir -p $(DESTDIR)) - cp -P $(HEADERS) $(DESTDIR) - - -install_doc: doc - $(shell test -d $(DESTDIR) || mkdir -p $(DESTDIR)) - cp -Pr docs/* $(DESTDIR) diff --git a/slsDetectorSoftware/Makefile.x04sa b/slsDetectorSoftware/Makefile.x04sa deleted file mode 100644 index 59755550f..000000000 --- a/slsDetectorSoftware/Makefile.x04sa +++ /dev/null @@ -1,87 +0,0 @@ -CFLAGS= -DC_ONLY -fPIC -#FLAGS+= #-DVERBOSE -DVERYVERBOSE - -DFLAGS= -DDACS_INT -DTHIS_PATH='"$(shell pwd)"' -DSLS_RECEIVER_FUNCTION_LIST - -#ASM=$(shell echo "/lib/modules/`uname -r`/build/include") - -INCLUDES?= -IcommonFiles -IslsDetector -IMySocketTCP -IusersFunctions -ImultiSlsDetector -IslsDetectorUtils -IslsDetectorCommand -IslsDetectorAnalysis -IslsReceiverInterface -IslsReceiver -I$(ASM) - -EPICSFLAGS=-D EPICS -I/usr/local/epics/base/include/ -I /usr/local/epics/base/include/os/Linux/ -L /usr/local/epics/base/lib/SL5-x86/ -Wl,-R/usr/local/epics/base/lib/SL5-x86 -lca -lCom -CC=g++ - - -SRC_CLNT= slsDetectorAnalysis/fileIO.cpp MySocketTCP/MySocketTCP.cpp usersFunctions/usersFunctions.cpp slsDetector/slsDetectorUtils.cpp slsDetector/slsDetectorCommand.cpp slsDetectorAnalysis/angularConversion.cpp slsDetectorAnalysis/angularConversionStatic.cpp slsDetectorAnalysis/energyConversion.cpp slsDetector/slsDetectorActions.cpp slsDetectorAnalysis/postProcessing.cpp slsDetector/slsDetector.cpp multiSlsDetector/multiSlsDetector.cpp slsDetector/slsDetectorUsers.cpp slsDetectorAnalysis/postProcessingFuncs.cpp slsReceiverInterface/receiverInterface.cpp slsReceiver/slsReceiverFunctionList.cpp slsReceiver/slsReceiver_funcs.cpp slsReceiver/slsReceiverUsers.cpp - -OBJS = $(SRC_CLNT:.cpp=.o) - -HEADERS = $(SRC_CLNT:.cpp=.h) commonFiles/sls_detector_defs.h slsDetectorAnalysis/detectorData.h slsDetector/slsDetectorBase.h multiSlsDetector/multiSlsDetectorCommand.h slsDetectorAnalysis/enCalLogClass.h slsDetectorAnalysis/angCalLogClass.h slsDetectorAnalysis/angleConversionConstant.h usersFunctions/angleFunction.h slsReceiverInterface/receiverInterface.h slsDetector/svnInfoLib.h slsReceiver/circularFifo.h slsReceiver/slsReceiver_funcs.h slsReceiver/svnInfoReceiverTmp.h slsReceiver/receiver_defs.h slsReceiver/slsReceiverFunctionList.h slsReceiver/slsReceiverUsers.h slsReceiver/svnInfoReceiver.h - - - -DESTDIR ?= bin -DOCDIR ?= docs - - -all: package $(SRC_CLNT) - echo "compiling all" - -intdoc: $(SRC_H) $(SRC_CLNT) - doxygen doxy.config - -doc: $(DOCDIR)/pdf/slsDetectorUsersDocs.pdf - -$(DOCDIR)/pdf/slsDetectorUsersDocs.pdf: slsDetectorUsersDocs - cd slsDetectorUsersDocs/latex && make - $(shell test -d $(DOCDIR) || mkdir -p $(DOCDIR)) - $(shell test -d $(DOCDIR)/pdf || mkdir -p $(DOCDIR)/pdf) - cp slsDetectorUsersDocs/latex/refman.pdf $(DOCDIR)/pdf/slsDetectorUsersDocs.pdf - - -htmldoc: $(DOCDIR)/html/slsDetectorUsersDocs - -$(DOCDIR)/html/slsDetectorUsersDocs: slsDetectorUsersDocs - $(shell test -d $(DOCDIR) || mkdir -p $(DOCDIR)) - $(shell test -d $(DOCDIR)/html || mkdir -p $(DOCDIR)/html) - $(shell test -d $(DOCDIR)/html/slsDetectorUsersDocs && rm -r $(DOCDIR)/html/slsDetectorUsersDocs) - cp -r slsDetectorUsersDocs/html $(DOCDIR)/html/slsDetectorUsersDocs - -slsDetectorUsersDocs: slsDetectorUsers.doxy slsDetector/slsDetectorUsers.h slsDetector/slsDetectorUsers.cpp slsDetectorAnalysis/detectorData.h - doxygen slsDetectorUsers.doxy - - -mythenVirtualServer: $(SRC_MYTHEN_SVC) - cd mythenDetectorServer && make -f Makefile.virtual DESTDIR=$(DESTDIR) - -gotthardVirtualServer: $(SRC_MYTHEN_SVC) - cd gotthardDetectorServer && make -f Makefile.virtual DESTDIR=$(DESTDIR) - - - -%.o : %.cpp %.h Makefile - $(CXX) -Wall -o $@ -c $< $(INCLUDES) $(DFLAGS) $(FLAGS) -fPIC $(EPICSFLAGS) -L/usr/lib64/ - -package: $(OBJS) $(DESTDIR)/libSlsDetector.so $(DESTDIR)/libSlsDetector.a - -$(DESTDIR)/libSlsDetector.so: $(OBJS) - $(CXX) -shared -Wl,-soname,libSlsDetector.so -o libSlsDetector.so $(OBJS) -lc $(INCLUDES) $(DFLAGS) $(FLAGS) $(EPICSFLAGS) -L/usr/lib64/ - $(shell test -d $(DESTDIR) || mkdir -p $(DESTDIR)) - mv libSlsDetector.so $(DESTDIR) - -$(DESTDIR)/libSlsDetector.a: $(OBJS) - ar rcs libSlsDetector.a $(OBJS) - mv libSlsDetector.a $(DESTDIR) - -clean: - rm -rf libSlsDetector.a libSlsDetector.so core docs/* slsDetectorUsersDocs $(OBJS) - - -#------------------------------------------------------------------------------- - -install: package - -install_inc: - $(shell test -d $(DESTDIR) || mkdir -p $(DESTDIR)) - cp -P slsDetector/slsDetectorUsers.h slsDetectorAnalysis/detectorData.h $(DESTDIR) slsReceiver/slsReceiverUsers.h - - diff --git a/slsDetectorSoftware/README b/slsDetectorSoftware/README deleted file mode 100644 index b1cfea7a7..000000000 --- a/slsDetectorSoftware/README +++ /dev/null @@ -1,19 +0,0 @@ -This subversion repository contains - -Common directories -Please inform Anna or Dhanya if you make modifications to these directories -- MySocketTCP : socket class -- commonFiles : header file common to server and client -- slsDetector : base class with all main detector functionalities (client side) - - -Mythen specific directories -Please inform Anna if you make modifications to these directories -- mythenDetector : mythen specific funcs (mainly files I/O and angular conversion) -- mythenDetectorServer : mythen server (for etrax compiler) -- firmware lib might be added in the future - -Other Detector specific directories -Please inform Dhanya if you make modifications to these directories - -make doc diff --git a/slsDetectorSoftware/commonFiles/communication_funcs.c b/slsDetectorSoftware/commonFiles/communication_funcs.c deleted file mode 100755 index 487b2c66e..000000000 --- a/slsDetectorSoftware/commonFiles/communication_funcs.c +++ /dev/null @@ -1,676 +0,0 @@ - - -#include "communication_funcs.h" -//#include -#include /* for TCP_NODELAY */ -#include -#include -#include -#include - -#include -char lastClientIP[INET_ADDRSTRLEN]; -char thisClientIP[INET_ADDRSTRLEN]; -int lockStatus; -int differentClients; - -//int socketDescriptor, file_des; -const int send_rec_max_size=SEND_REC_MAX_SIZE; -extern int errno; - - -char dummyClientIP[INET_ADDRSTRLEN]; - - -fd_set readset, tempset; -int isock=0, maxfd; - - -int myport=-1; - -//struct sockaddr_in address; -//#define VERBOSE - - -int bindSocket(unsigned short int port_number) { - int i; - - struct sockaddr_in addressS; - int socketDescriptor; - //int file_des; - - //file_des= -1; - - - - - - - - - - - if (myport==port_number) - return -10; - - - - - - socketDescriptor = socket(AF_INET, SOCK_STREAM,0); //tcp - - //socketDescriptor = socket(PF_INET, SOCK_STREAM, 0); - - - - if (socketDescriptor < 0) { - printf("Can not create socket\n"); - } else { - - i = 1; - setsockopt(socketDescriptor, SOL_SOCKET, SO_REUSEADDR, &i, sizeof(i)); - // setsockopt(socketDescriptor, IPPROTO_TCP, TCP_NODELAY, (char *) &i, sizeof(i)); - // TCP_CORK - - // Set some fields in the serverAddress structure. - addressS.sin_family = AF_INET; - addressS.sin_addr.s_addr = htonl(INADDR_ANY); - addressS.sin_port = htons(port_number); - - // memset(&address.sin_addr, 0, sizeof(address.sin_addr)); - - - if(bind(socketDescriptor,(struct sockaddr *) &addressS,sizeof(addressS))<0){ - - printf("Can not create socket\n"); - - socketDescriptor=-1; - } else { - if (listen(socketDescriptor, 5)==0) { - - if (isock==0) { - FD_ZERO(&readset); - } - - - FD_SET(socketDescriptor, &readset); - isock++; - maxfd = socketDescriptor; - printf ("%d port %d fd %d\n",isock, port_number,socketDescriptor); - myport=port_number; - } else - printf("error on listen"); - } - } - - - - //int getrlimit(int resource, struct rlimit *rlim); - - - - return socketDescriptor; - -} - - - - - -int getServerError(int socketDescriptor) -{ - if (socketDescriptor<0) return 1; - else return 0; -}; - - -int acceptConnection(int socketDescriptor) { - - - int j; - - - struct sockaddr_in addressC; - int file_des=-1; - struct timeval tv; - int result; - - - //socklen_t address_length; - socklen_t address_length=sizeof(struct sockaddr_in); - - if (socketDescriptor<0) - return -1; - - memcpy(&tempset, &readset, sizeof(tempset)); - tv.tv_sec = 10000000; - tv.tv_usec = 0; - result = select(maxfd + 1, &tempset, NULL, NULL, &tv); - - if (result == 0) { - printf("select() timed out!\n"); - } else if (result < 0 && errno != EINTR) { - printf("Error in select(): %s\n", strerror(errno)); - } else if (result > 0) { -#ifdef VERBOSE - printf("select returned!\n"); -#endif - for (j=0; j=0) - close(file_des); - FD_CLR(file_des, &readset); -} - -void exitServer(int socketDescriptor) { - if (socketDescriptor>=0) - close(socketDescriptor); -#ifdef VERY_VERBOSE - printf("Closing server\n"); -#endif - FD_CLR(socketDescriptor, &readset); - socketDescriptor=-1; - isock--; -} - - - - -void swapData(void* val,int length,intType itype){ - int i; - int16_t* c= (int16_t*)val; - int32_t* a= (int32_t*)val; - int64_t* b= (int64_t*)val; - for(i=0; length > 0; i++){ - switch(itype){ - case INT16: - c[i] = ((c[i] & 0x00FF) << 8) | ((c[i] & 0xFF00) >> 8); - length -= sizeof(int16_t); - break; - case INT32: - a[i]=((a[i] << 8) & 0xFF00FF00) | ((a[i] >> 8) & 0xFF00FF ); - a[i]=(a[i] << 16) | ((a[i] >> 16) & 0xFFFF); - length -= sizeof(int32_t); - break; - case INT64: - b[i] = ((b[i] << 8) & 0xFF00FF00FF00FF00ULL ) | ((b[i] >> 8) & 0x00FF00FF00FF00FFULL ); - b[i] = ((b[i] << 16) & 0xFFFF0000FFFF0000ULL ) | ((b[i] >> 16) & 0x0000FFFF0000FFFFULL ); - b[i] = (b[i] << 32) | ((b[i] >> 32) & 0xFFFFFFFFULL); - length -= sizeof(int64_t); - break; - default: - length = 0; - break; - } - } -} - -int sendData(int file_des, void* buf,int length, intType itype){ -#ifndef PCCOMPILE -#ifdef EIGERD - swapData(buf, length, itype); -#endif -#endif - return sendDataOnly(file_des, buf, length); -} - - -int receiveData(int file_des, void* buf,int length, intType itype){ - int ret = receiveDataOnly(file_des, buf, length); -#ifndef PCCOMPILE -#ifdef EIGERD - if (ret >= 0) swapData(buf, length, itype); -#endif -#endif - return ret; -} - - - int sendDataOnly(int file_des, void* buf,int length) { - if (!length) - return 0; - int ret = write(file_des, buf, length); //value of -1 is other end socket crash as sigpipe is ignored - if (ret < 0) cprintf(BG_RED, "Error writing to socket. Possible socket crash\n"); - return ret; -} - - - int receiveDataOnly(int file_des, void* buf,int length) { - - int total_received=0; - int nreceiving; - int nreceived; - if (file_des<0) return -1; -#ifdef VERY_VERBOSE - printf("want to receive %d Bytes\n", length); -#endif - - while(length > 0) { - nreceiving = (length>send_rec_max_size) ? send_rec_max_size:length; // (condition) ? if_true : if_false - nreceived = read(file_des,(char*)buf+total_received,nreceiving); - if(!nreceived){ - if(!total_received) { - return -1; //to handle it - } - break; - } - length-=nreceived; - total_received+=nreceived; - } - - if (total_received>0) - strcpy(thisClientIP,dummyClientIP); - - if (strcmp(lastClientIP,thisClientIP)) - differentClients=1; - else - differentClients=0; - - return total_received; -} - - - - - - - - - - - - - - - -int sendChannel(int file_des, sls_detector_channel *myChan) { - int ts=0; - //sendDataOnly(file_des,myChan, sizeof(sls_detector_channel)); - ts+=sendData(file_des,&(myChan->chan),sizeof(myChan->chan),INT32); - ts+=sendData(file_des,&(myChan->chip),sizeof(myChan->chip),INT32); - ts+=sendData(file_des,&(myChan->module),sizeof(myChan->module),INT32); - ts+=sendData(file_des,&(myChan->reg),sizeof(myChan->reg),INT64); - return ts; -} - -int sendChip(int file_des, sls_detector_chip *myChip) { - int ts=0; - //ts+=sendDataOnly(file_des,myChip,sizeof(sls_detector_chip)); - ts+=sendData(file_des,&(myChip->chip),sizeof(myChip->chip),INT32); - ts+=sendData(file_des,&(myChip->module),sizeof(myChip->module),INT32); - ts+=sendData(file_des,&(myChip->nchan),sizeof(myChip->nchan),INT32); - ts+=sendData(file_des,&(myChip->reg),sizeof(myChip->reg),INT32); - ts+=sendData(file_des,(myChip->chanregs),sizeof(myChip->chanregs),INT32); - ts+=sendData(file_des,myChip->chanregs,myChip->nchan*sizeof(int),INT32); - return ts; -} - - -int sendModule(int file_des, sls_detector_module *myMod) { - return sendModuleGeneral(file_des, myMod, 1); -} - - -int sendModuleGeneral(int file_des, sls_detector_module *myMod, int sendAll) { - int ts=0; -#ifdef VERBOSE - int idac; -#endif - int nChips=myMod->nchip; - int nChans=myMod->nchan; - int nAdcs=myMod->nadc; - int nDacs=myMod->ndac; - //ts+= sendDataOnly(file_des,myMod,sizeof(sls_detector_module)); - ts+=sendData(file_des,&(myMod->module),sizeof(myMod->module),INT32); - ts+=sendData(file_des,&(myMod->serialnumber),sizeof(myMod->serialnumber),INT32); - ts+=sendData(file_des,&(myMod->nchan),sizeof(myMod->nchan),INT32); - ts+=sendData(file_des,&(myMod->nchip),sizeof(myMod->nchip),INT32); - ts+=sendData(file_des,&(myMod->ndac),sizeof(myMod->ndac),INT32); - ts+=sendData(file_des,&(myMod->nadc),sizeof(myMod->nadc),INT32); - ts+=sendData(file_des,&(myMod->reg),sizeof(myMod->reg),INT32); - -#ifdef MYTHEND - ts+=sendData(file_des,myMod->dacs,sizeof(myMod->ndac),OTHER); - ts+=sendData(file_des,myMod->adcs,sizeof(myMod->nadc),OTHER); - ts+=sendData(file_des,myMod->chipregs,sizeof(myMod->nchip),OTHER); - ts+=sendData(file_des,myMod->chanregs,sizeof(myMod->nchan),OTHER); - } -#endif - ts+=sendData(file_des,&(myMod->gain), sizeof(myMod->gain),OTHER); - ts+=sendData(file_des,&(myMod->offset), sizeof(myMod->offset),OTHER); - -#ifdef VERBOSE - printf("module %d of size %d sent\n",myMod->module, ts); -#endif - ts+= sendData(file_des,myMod->dacs,sizeof(dacs_t)*nDacs,INT32); -#ifdef VERBOSE - printf("dacs %d of size %d sent\n",myMod->module, ts); - int idac; - for (idac=0; idac< nDacs; idac++) - printf("dac %d is %d\n",idac,(int)myMod->dacs[idac]); -#endif - ts+= sendData(file_des,myMod->adcs,sizeof(dacs_t)*nAdcs,INT32); -#ifdef VERBOSE - printf("adcs %d of size %d sent\n",myMod->module, ts); -#endif - - /*some detectors dont require sending all trimbits etc.*/ - if(sendAll){ - ts+=sendData(file_des,myMod->chipregs,sizeof(int)*nChips,INT32); -#ifdef VERBOSE - printf("chips %d of size %d sent\n",myMod->module, ts); -#endif - ts+=sendData(file_des,myMod->chanregs,sizeof(int)*nChans,INT32); -#ifdef VERBOSE - printf("chans %d of size %d sent - %d\n",myMod->module, ts, myMod->nchan); -#endif - } - -#ifdef VERBOSE - printf("module %d of size %d sent register %x\n",myMod->module, ts, myMod->reg); -#endif - return ts; -} - -int receiveChannel(int file_des, sls_detector_channel *myChan) { - int ts=0; - //receiveDataOnly(file_des,myChan,sizeof(sls_detector_channel)); - ts+=receiveData(file_des,&(myChan->chan),sizeof(myChan->chan),INT32); - ts+=receiveData(file_des,&(myChan->chip),sizeof(myChan->chip),INT32); - ts+=receiveData(file_des,&(myChan->module),sizeof(myChan->module),INT32); - ts+=receiveData(file_des,&(myChan->reg),sizeof(myChan->reg),INT32); - return ts; -} - -int receiveChip(int file_des, sls_detector_chip* myChip) { - - int *ptr=myChip->chanregs; - int ts=0; - int nChans, nchanold=myChip->nchan, chdiff; - - //ts+= receiveDataOnly(file_des,myChip,sizeof(sls_detector_chip)); - ts+=receiveData(file_des,&(myChip->chip),sizeof(myChip->chip),INT32); - ts+=receiveData(file_des,&(myChip->module),sizeof(myChip->module),INT32); - ts+=receiveData(file_des,&(myChip->nchan),sizeof(myChip->nchan),INT32); - ts+=receiveData(file_des,&(myChip->reg),sizeof(myChip->reg),INT32); - ts+=receiveData(file_des,(myChip->chanregs),sizeof(myChip->chanregs),INT32); - - myChip->chanregs=ptr; - nChans=myChip->nchan; - chdiff=nChans-nchanold; - if (nchanold!=nChans) { - printf("wrong number of channels received!\n"); - } - - -#ifdef VERBOSE - printf("chip structure received\n"); - printf("now receiving %d channels\n", nChans); -#endif - - if (chdiff<=0) - ts+=receiveData(file_des,myChip->chanregs, sizeof(int)*nChans,INT32); - else { - ptr=(int*)malloc(chdiff*sizeof(int)); - myChip->nchan=nchanold; - ts+=receiveData(file_des,myChip->chanregs, sizeof(int)*nchanold,INT32); - ts+=receiveData(file_des,ptr, sizeof(int)*chdiff,INT32); - free(ptr); - return FAIL; - } - -#ifdef VERBOSE - printf("chip's channels received\n"); -#endif - return ts; -} - - -int receiveModule(int file_des, sls_detector_module* myMod) { - return receiveModuleGeneral(file_des,myMod,1); -} - -int receiveModuleGeneral(int file_des, sls_detector_module* myMod, int receiveAll) { - int ts=0; - dacs_t *dacptr=myMod->dacs; - dacs_t *adcptr=myMod->adcs; - int *chipptr=myMod->chipregs, *chanptr=myMod->chanregs; - int nChips, nchipold=myMod->nchip, nchipdiff; - int nChans, nchanold=myMod->nchan, nchandiff; - int nDacs, ndold=myMod->ndac, ndacdiff; - int nAdcs, naold=myMod->nadc, nadcdiff; -#ifdef VERBOSE - int id=0; -#endif - // ts+= receiveDataOnly(file_des,myMod,sizeof(sls_detector_module)); - ts+=receiveData(file_des,&(myMod->module),sizeof(myMod->module),INT32); - ts+=receiveData(file_des,&(myMod->serialnumber),sizeof(myMod->serialnumber),INT32); - ts+=receiveData(file_des,&(myMod->nchan),sizeof(myMod->nchan),INT32); - ts+=receiveData(file_des,&(myMod->nchip),sizeof(myMod->nchip),INT32); - ts+=receiveData(file_des,&(myMod->ndac),sizeof(myMod->ndac),INT32); - ts+=receiveData(file_des,&(myMod->nadc),sizeof(myMod->nadc),INT32); - ts+=receiveData(file_des,&(myMod->reg),sizeof(myMod->reg),INT32); -#ifdef MYTHEND - ts+=receiveData(file_des,myMod->dacs,sizeof(myMod->ndac),INT32); - ts+=receiveData(file_des,myMod->adcs,sizeof(myMod->nadc),INT32); - ts+=receiveData(file_des,myMod->chipregs,sizeof(myMod->nchip),INT32); - ts+=receiveData(file_des,myMod->chanregs,sizeof(myMod->nchan),INT32); -#endif - ts+=receiveData(file_des,&(myMod->gain), sizeof(myMod->gain),OTHER); - ts+=receiveData(file_des,&(myMod->offset), sizeof(myMod->offset),OTHER); - - myMod->dacs=dacptr; - myMod->adcs=adcptr; - myMod->chipregs=chipptr; - myMod->chanregs=chanptr; - -#ifdef EIGERD - //feature to exclude sending of trimbtis, nchips=0,nchans=0 in that case - if(myMod->nchip == 0 && myMod->nchan == 0) { - receiveAll=0; - nchipold=0; - nchanold=0; - } -#endif - - - nChips=myMod->nchip; - nchipdiff=nChips-nchipold; - if (nchipold!=nChips) { - printf("received wrong number of chips\n"); - } -#ifdef VERBOSE - else - printf("received %d chips\n",nChips); -#endif - - nChans=myMod->nchan; - nchandiff=nChans-nchanold; - if (nchanold!=nChans) { - printf("received wrong number of channels\n"); - } -#ifdef VERBOSE - else - printf("received %d chans\n",nChans); -#endif - - - nDacs=myMod->ndac; - ndacdiff=nDacs-ndold; - if (ndold!=nDacs) { - printf("received wrong number of dacs\n"); - } -#ifdef VERBOSE - else - printf("received %d dacs\n",nDacs); -#endif - - nAdcs=myMod->nadc; - nadcdiff=nAdcs-naold; - if (naold!=nAdcs) { - printf("received wrong number of adcs\n"); - } -#ifdef VERBOSE - else - printf("received %d adcs\n",nAdcs); -#endif - if (ndacdiff<=0) { - ts+=receiveData(file_des,myMod->dacs, sizeof(dacs_t)*nDacs,INT32); -#ifdef VERBOSE - printf("dacs received\n"); - int id; - for (id=0; iddacs[id]); - - -#endif - } else { - dacptr=(dacs_t*)malloc(ndacdiff*sizeof(dacs_t)); - myMod->ndac=ndold; - ts+=receiveData(file_des,myMod->dacs, sizeof(dacs_t)*ndold,INT32); - ts+=receiveData(file_des,dacptr, sizeof(dacs_t)*ndacdiff,INT32); - free(dacptr); - return FAIL; - } - - if (nadcdiff<=0) { - ts+=receiveData(file_des,myMod->adcs, sizeof(dacs_t)*nAdcs,INT32); -#ifdef VERBOSE - printf("adcs received\n"); -#endif - } else { - adcptr=(dacs_t*)malloc(nadcdiff*sizeof(dacs_t)); - myMod->nadc=naold; - ts+=receiveData(file_des,myMod->adcs, sizeof(dacs_t)*naold,INT32); - ts+=receiveData(file_des,adcptr, sizeof(dacs_t)*nadcdiff,INT32); - free(adcptr); - return FAIL; - } - - - /*some detectors dont require sending all trimbits etc.*/ - if(receiveAll){ - - if (nchipdiff<=0) { - ts+=receiveData(file_des,myMod->chipregs, sizeof(int)*nChips,INT32); -#ifdef VERBOSE - printf("chips received\n"); -#endif - } else { - chipptr=(int*)malloc(nchipdiff*sizeof(int)); - myMod->nchip=nchipold; - ts+=receiveData(file_des,myMod->chipregs, sizeof(int)*nchipold,INT32); - ts+=receiveData(file_des,chipptr, sizeof(int)*nchipdiff,INT32); - free(chipptr); - return FAIL; - } - - if (nchandiff<=0) { - ts+=receiveData(file_des,myMod->chanregs, sizeof(int)*nChans,INT32); -#ifdef VERBOSE - printf("chans received\n"); -#endif - } else { - chanptr=(int*)malloc(nchandiff*sizeof(int)); - myMod->nchan=nchanold; - ts+=receiveData(file_des,myMod->chanregs, sizeof(int)*nchanold,INT32); - ts+=receiveData(file_des,chanptr, sizeof(int)*nchandiff,INT32); - free(chanptr); - return FAIL; - } - } -#ifdef VERBOSE - printf("received module %d of size %d register %x\n",myMod->module,ts,myMod->reg); -#endif - - return ts; -} diff --git a/slsDetectorSoftware/commonFiles/communication_funcs.h b/slsDetectorSoftware/commonFiles/communication_funcs.h deleted file mode 100755 index e4e3fac27..000000000 --- a/slsDetectorSoftware/commonFiles/communication_funcs.h +++ /dev/null @@ -1,51 +0,0 @@ -#ifndef COMMUNICATION_FUNCS_H -#define COMMUNICATION_FUNCS_H - -#define SEND_REC_MAX_SIZE 4096 -#define DEFAULT_PORTNO 1952 -#include -#include - - -#include -#include -#include -#include - -#include "sls_detector_defs.h" - - - -typedef enum{ - INT16, - INT32, - INT64, - OTHER -}intType; - - - - -int bindSocket(unsigned short int port_number); -int acceptConnection(int socketDescriptor); -void closeConnection(int file_Des); -void exitServer(int socketDescriptor); - -void swapData(void* val,int length,intType itype); -int sendData(int file_des, void* buf,int length, intType itype); -int receiveData(int file_des, void* buf,int length, intType itype); -int sendDataOnly(int file_des, void* buf,int length); -int receiveDataOnly(int file_des, void* buf,int length); - - -int getServerError(int socketDescriptor); -int sendChannel(int file_des, sls_detector_channel *myChan); -int sendChip(int file_des, sls_detector_chip *myChip); -int sendModule(int file_des, sls_detector_module *myMod); -int sendModuleGeneral(int file_des, sls_detector_module *myMod, int sendAll); -int receiveChannel(int file_des, sls_detector_channel *myChan); -int receiveChip(int file_des, sls_detector_chip* myChip); -int receiveModule(int file_des, sls_detector_module* myMod); -int receiveModuleGeneral(int file_des, sls_detector_module* myMod, int receiveAll); - -#endif diff --git a/slsDetectorSoftware/commonFiles/error_defs.h b/slsDetectorSoftware/commonFiles/error_defs.h deleted file mode 100644 index dc733c2d7..000000000 --- a/slsDetectorSoftware/commonFiles/error_defs.h +++ /dev/null @@ -1,351 +0,0 @@ -/* - * error_defs.h - * - * Created on: Jan 18, 2013 - * Author: l_maliakal_d - */ - -#ifndef ERROR_DEFS_H_ -#define ERROR_DEFS_H_ - -#include "ansi.h" -#include "sls_detector_defs.h" - -#include -#include -#include -#include -// - -/** Error flags */ -/*Assumption: Only upto 63 detectors */ - -// multi errors -// 0xFFF0000000000000ULL -#define MULTI_DETECTORS_NOT_ADDED 0x8000000000000000ULL -#define MULTI_HAVE_DIFFERENT_VALUES 0x4000000000000000ULL -#define MULTI_CONFIG_FILE_ERROR 0x2000000000000000ULL - -// sls errors -#define CRITICAL_ERROR_MASK 0xFFFFFFF - -// 0xFFFFFFF000000000ULL -#define CANNOT_CONNECT_TO_DETECTOR 0x4000000000000000ULL -#define CANNOT_CONNECT_TO_RECEIVER 0x2000000000000000ULL -#define COULDNOT_SET_CONTROL_PORT 0x1000000000000000ULL -#define COULDNOT_SET_STOP_PORT 0x0800000000000000ULL -#define COULDNOT_SET_DATA_PORT 0x0400000000000000ULL -#define FILE_PATH_DOES_NOT_EXIST 0x0200000000000000ULL -#define COULDNOT_CREATE_UDP_SOCKET 0x0100000000000000ULL -#define COULDNOT_CREATE_FILE 0x0080000000000000ULL -#define COULDNOT_ENABLE_COMPRESSION 0x0040000000000000ULL -#define RECEIVER_DET_HOSTNAME_NOT_SET 0x0020000000000000ULL -#define RECEIVER_DET_HOSTTYPE_NOT_SET 0x0010000000000000ULL -#define DETECTOR_TEN_GIGA 0x0008000000000000ULL -#define DETECTOR_ACTIVATE 0x0004000000000000ULL -#define COULD_NOT_CONFIGURE_MAC 0x0002000000000000ULL -#define COULDNOT_START_RECEIVER 0x0001000000000000ULL // default error like starting threads -#define COULDNOT_STOP_RECEIVER 0x0000800000000000ULL -#define RECEIVER_DET_POSID_NOT_SET 0x0000400000000000ULL -#define RECEIVER_MULTI_DET_SIZE_NOT_SET 0x0000200000000000ULL -#define PREPARE_ACQUISITION 0x0000100000000000ULL -#define CLEANUP_ACQUISITION 0x0000080000000000ULL -#define REGISER_WRITE_READ 0x0000040000000000ULL -#define VERSION_COMPATIBILITY 0x0000020000000000ULL -// 0xFFFFFF0000000000ULL - -// 0x000000FFFFFFFFFFULL -#define COULDNOT_SET_NETWORK_PARAMETER 0x0000000000000001ULL -#define COULDNOT_SET_ROI 0x0000000000000002ULL -#define RECEIVER_READ_FREQUENCY 0x0000000000000004ULL -#define SETTINGS_NOT_SET 0x0000000000000008ULL -#define SETTINGS_FILE_NOT_OPEN 0x0000000000000010ULL -#define DETECTOR_TIMER_VALUE_NOT_SET 0x0000000000000020ULL -#define RECEIVER_ACQ_PERIOD_NOT_SET 0x0000000000000040ULL -#define RECEIVER_FRAME_NUM_NOT_SET 0x0000000000000080ULL -#define RECEIVER_DYNAMIC_RANGE 0x0000000000000100ULL -#define RECEIVER_TEN_GIGA 0x0000000000000200ULL -#define ALLTIMBITS_NOT_SET 0x0000000000000400ULL -#define COULD_NOT_SET_SPEED_PARAMETERS 0x0000000000000800ULL -#define COULD_NOT_SET_READOUT_FLAGS 0x0000000000001000ULL -#define COULD_NOT_SET_FIFO_DEPTH 0x0000000000002000ULL -#define COULD_NOT_SET_COUNTER_BIT 0x0000000000004000ULL -#define COULD_NOT_PULSE_PIXEL 0x0000000000008000ULL -#define COULD_NOT_PULSE_PIXEL_NMOVE 0x0000000000010000ULL -#define COULD_NOT_PULSE_CHIP 0x0000000000020000ULL -#define COULD_NOT_SET_RATE_CORRECTION 0x0000000000040000ULL -#define DETECTOR_NETWORK_PARAMETER 0x0000000000080000ULL -#define RATE_CORRECTION_NOT_32or16BIT 0x0000000000100000ULL -#define RATE_CORRECTION_NO_TAU_PROVIDED 0x0000000000200000ULL -#define PROGRAMMING_ERROR 0x0000000000400000ULL -#define RECEIVER_ACTIVATE 0x0000000000800000ULL -#define DATA_STREAMING 0x0000000001000000ULL -#define RESET_ERROR 0x0000000002000000ULL -#define POWER_CHIP 0x0000000004000000ULL -#define RECEIVER_READ_TIMER 0x0000000008000000ULL -#define RECEIVER_ACQ_TIME_NOT_SET 0x0000000010000000ULL -#define RECEIVER_FLIPPED_DATA_NOT_SET 0x0000000020000000ULL -#define THRESHOLD_NOT_SET 0x0000000040000000ULL -#define RECEIVER_FILE_FORMAT 0x0000000080000000ULL -#define RECEIVER_PARAMETER_NOT_SET 0x0000000100000000ULL -#define RECEIVER_TIMER_NOT_SET 0x0000000200000000ULL -#define RECEIVER_ENABLE_GAPPIXELS_NOT_SET 0x0000000400000000ULL -#define RESTREAM_STOP_FROM_RECEIVER 0x0000000800000000ULL -#define TEMPERATURE_CONTROL 0x0000001000000000ULL -#define AUTO_COMP_DISABLE 0x0000002000000000ULL -#define CONFIG_FILE 0x0000004000000000ULL -#define STORAGE_CELL_START 0x0000008000000000ULL -// 0x000000FFFFFFFFFFULL - - -/** @short class returning all error messages for error mask */ -class errorDefs { - - -public: - - /** Constructor */ - errorDefs():errorMask(0){ - strcpy(notAddedList,""); - }; - - /** Gets the error message - * param errorMask error mask - /returns error message from error mask - */ - static std::string getErrorMessage(int64_t slsErrorMask){ - - std::string retval = ""; - - if(slsErrorMask&CANNOT_CONNECT_TO_DETECTOR) - retval.append("Cannot connect to Detector\n"); - - if(slsErrorMask&CANNOT_CONNECT_TO_RECEIVER) - retval.append("Cannot connect to Receiver\n"); - - if(slsErrorMask&COULDNOT_SET_CONTROL_PORT) - retval.append("Could not set control port\n"); - - if(slsErrorMask&COULDNOT_SET_STOP_PORT) - retval.append("Could not set stop port\n"); - - if(slsErrorMask&COULDNOT_SET_DATA_PORT) - retval.append("Could not set receiver port\n"); - - if(slsErrorMask&FILE_PATH_DOES_NOT_EXIST) - retval.append("Path to Output Directory does not exist\n"); - - if(slsErrorMask&COULDNOT_CREATE_UDP_SOCKET) - retval.append("Could not create UDP socket to start receiver\n"); - - if(slsErrorMask&COULDNOT_CREATE_FILE) - retval.append("Could not create file to start receiver.\nCheck permissions of output directory or the overwrite flag\n"); - - if(slsErrorMask&COULDNOT_ENABLE_COMPRESSION) - retval.append("Could not enable/disable data compression in receiver.\nThread creation failed or recompile code with MYROOT1 flag.\n"); - - if(slsErrorMask&RECEIVER_DET_HOSTNAME_NOT_SET) - retval.append("Could not send the detector hostname to the receiver.\n"); - - if(slsErrorMask&RECEIVER_DET_HOSTTYPE_NOT_SET) - retval.append("Could not send the detector type to the receiver.\n"); - - if(slsErrorMask&DETECTOR_TEN_GIGA) - retval.append("Could not enable/disable 10GbE in the detector.\n"); - - if(slsErrorMask&DETECTOR_ACTIVATE) - retval.append("Could not activate/deactivate detector\n"); - - if(slsErrorMask&RECEIVER_DET_POSID_NOT_SET) - retval.append("Could not set detector position id\n"); - - if(slsErrorMask&RECEIVER_MULTI_DET_SIZE_NOT_SET) - retval.append("Could not set multi detector size\n"); - - if(slsErrorMask&PREPARE_ACQUISITION) - retval.append("Could not prepare acquisition in detector\n"); - - if(slsErrorMask&CLEANUP_ACQUISITION) - retval.append("Could not clean up after acquisition in detector\n"); - - if(slsErrorMask®ISER_WRITE_READ) - retval.append("Could not read/write register in detector\n"); - - if(slsErrorMask&VERSION_COMPATIBILITY) - retval.append("Incompatible versions with detector or receiver. Please check log for more details.\n"); - - - - if(slsErrorMask&COULD_NOT_CONFIGURE_MAC) - retval.append("Could not configure mac\n"); - - if(slsErrorMask&COULDNOT_SET_NETWORK_PARAMETER) - retval.append("Could not set network parameter.\n"); - - if(slsErrorMask&COULDNOT_SET_ROI) - retval.append("Could not set the exact region of interest. Verify ROI set by detector.\n"); - - if(slsErrorMask&RECEIVER_READ_FREQUENCY) - retval.append("Could not set receiver read frequency.\n"); - - if(slsErrorMask&SETTINGS_NOT_SET) - retval.append("Could not set settings.\n"); - - if(slsErrorMask&SETTINGS_FILE_NOT_OPEN) - retval.append("Could not open settings file. Verify if it exists.\n"); - - if(slsErrorMask&COULDNOT_START_RECEIVER) - retval.append("Could not start receiver.\n"); - - if(slsErrorMask&COULDNOT_STOP_RECEIVER) - retval.append("Could not stop receiver.\n"); - - if(slsErrorMask&DETECTOR_TIMER_VALUE_NOT_SET) - retval.append("Could not set one of timer values in detector.\n"); - - if(slsErrorMask&RECEIVER_ACQ_PERIOD_NOT_SET) - retval.append("Could not set acquisition period in receiver.\n"); - - if(slsErrorMask&RECEIVER_FRAME_NUM_NOT_SET) - retval.append("Could not set frame number in receiver.\n"); - - if(slsErrorMask&RECEIVER_DYNAMIC_RANGE) - retval.append("Could not set dynamic range in receiver.\n"); - - if(slsErrorMask&RECEIVER_TEN_GIGA) - retval.append("Could not enable/disable 10GbE in the receiver.\n"); - - if(slsErrorMask&ALLTIMBITS_NOT_SET) - retval.append("Could not set all trimbits to value.\n"); - - if(slsErrorMask&COULD_NOT_SET_SPEED_PARAMETERS) - retval.append("Could not set the speed parameter value\n"); - - if(slsErrorMask&COULD_NOT_SET_READOUT_FLAGS) - retval.append("Could not set the readout flag\n"); - - if(slsErrorMask&COULD_NOT_SET_FIFO_DEPTH) - retval.append("Could not set receiver fifo depth\n"); - - if(slsErrorMask&COULD_NOT_SET_COUNTER_BIT) - retval.append("Could not set/reset counter bit\n"); - - if(slsErrorMask&COULD_NOT_PULSE_PIXEL) - retval.append("Could not pulse pixel\n"); - - if(slsErrorMask&COULD_NOT_PULSE_PIXEL_NMOVE) - retval.append("Could not pulse pixel and move\n"); - - if(slsErrorMask&COULD_NOT_PULSE_CHIP) - retval.append("Could not pulse chip\n"); - - if(slsErrorMask&COULD_NOT_SET_RATE_CORRECTION) - retval.append("Could not set rate correction\n"); - - if(slsErrorMask&DETECTOR_NETWORK_PARAMETER) - retval.append("Could not set/get detector network parameter\n"); - - if(slsErrorMask&RATE_CORRECTION_NOT_32or16BIT) - retval.append("Rate correction Deactivated, must be in 32 or 16 bit mode\n"); - - if(slsErrorMask&RATE_CORRECTION_NO_TAU_PROVIDED) - retval.append("Rate correction Deactivated. No default tau provided in file\n"); - - if(slsErrorMask&PROGRAMMING_ERROR) - retval.append("Could not program FPGA\n"); - - if(slsErrorMask&RECEIVER_ACTIVATE) - retval.append("Could not activate/deactivate receiver\n"); - - if(slsErrorMask&DATA_STREAMING) - retval.append("Could not enable/disable Data Streaming\n"); - - if(slsErrorMask&RESET_ERROR) - retval.append("Could not reset the FPGA\n"); - - if(slsErrorMask&POWER_CHIP) - retval.append("Could not power on/off/get the chip\n"); - - if(slsErrorMask&RECEIVER_READ_TIMER) - retval.append("Could not set receiver read timer\n"); - - if(slsErrorMask&RECEIVER_FLIPPED_DATA_NOT_SET) - retval.append("Could not set receiver flipped data/bottom\n"); - - if(slsErrorMask&THRESHOLD_NOT_SET) - retval.append("Could not set threshold\n"); - - if(slsErrorMask&RECEIVER_FILE_FORMAT) - retval.append("Could not set receiver file format\n"); - - if(slsErrorMask&RECEIVER_TIMER_NOT_SET) - retval.append("Could not set timer in receiver.\n"); - - if(slsErrorMask&RECEIVER_PARAMETER_NOT_SET) - retval.append("Could not set a paramater in receiver.\n"); - - if(slsErrorMask&RECEIVER_ENABLE_GAPPIXELS_NOT_SET) - retval.append("Could not enable/disable gap pixels in receiver.\n"); - - if(slsErrorMask&RESTREAM_STOP_FROM_RECEIVER) - retval.append("Could not restream stop from receiver.\n"); - - if(slsErrorMask&TEMPERATURE_CONTROL) - retval.append("Could not set/get threshold temperature, temp control or temp event.\n"); - - if(slsErrorMask&AUTO_COMP_DISABLE) - retval.append("Could not set/get auto comparator disable\n"); - - if(slsErrorMask&CONFIG_FILE) - retval.append("Could not load/write config file\n"); - - //------------------------------------------------------ length of message - - - return retval; - - } - - - /** Sets multi error mask - @param multi error mask to be set to - /returns multi error mask - */ - int64_t setErrorMask(int64_t i){errorMask=i;return getErrorMask();}; - - /**returns multi error mask */ - int64_t getErrorMask(){return errorMask;}; - - /** Clears error mask - /returns error mask - */ - int64_t clearErrorMask(){errorMask=0;return errorMask;}; - - /** Gets the not added detector list - /returns list - */ - char* getNotAddedList(){return notAddedList;}; - - /** Append the detector to not added detector list - * @param name append to the list - /returns list - */ - void appendNotAddedList(const char* name){strcat(notAddedList,name);strcat(notAddedList,"+");}; - - /** Clears not added detector list - /returns error mask - */ - void clearNotAddedList(){strcpy(notAddedList,"");}; - - -protected: - - /** Error Mask */ - int64_t errorMask; - - /** Detectors Not added List */ - char notAddedList[MAX_STR_LENGTH]; - -}; - -#endif /* ERROR_DEFS_H_ */ diff --git a/slsDetectorSoftware/commonFiles/sls_detector_defs.h b/slsDetectorSoftware/commonFiles/sls_detector_defs.h deleted file mode 100755 index 0e3a388c0..000000000 --- a/slsDetectorSoftware/commonFiles/sls_detector_defs.h +++ /dev/null @@ -1,599 +0,0 @@ -#ifndef SLS_DETECTOR_DEFS_H -#define SLS_DETECTOR_DEFS_H - - -#ifdef __CINT__ -#define MYROOT -#define __cplusplus -#endif - -//#include -#include "sls_receiver_defs.h" - -/** default maximum string length */ -#define MAX_SCAN_STEPS 2000 -/** maxmimum number of modules per controller*/ -#define MAXMODS 24 -/** maxmimum number of detectors ina multidetector structure*/ -#define MAXDET 100 -/** header length for data :gotthard*/ -#define HEADERLENGTH 12 - -/** maximum rois */ -#define MAX_ROIS 100 - -/** maximum trim en */ -#define MAX_TRIMEN 100 - -/** maximum unit size of program sent to detector */ -#define MAX_FPGAPROGRAMSIZE (2 * 1024 *1024) - - - -#define MAX_SCAN_LEVELS 2 - -typedef char mystring[MAX_STR_LENGTH]; -typedef double mysteps[MAX_SCAN_STEPS]; - - - -#ifndef DACS_FLOAT -typedef int dacs_t; -#else -typedef float dacs_t; -#endif - -#define DEFAULT_DET_MAC "00:aa:bb:cc:dd:ee" -#define DEFAULT_DET_IP "129.129.202.46" - - -/** - \file sls_detector_defs.h -This file contains all the basic definitions common to the slsDetector class -and to the server programs running on the detector - - - * @author Anna Bergamaschi - * @version 0.1alpha (any string) - * @see slsDetector - -$Revision: 824 $ - -*/ - - -/** get flag form most functions */ -#define GET_FLAG -1 - - -#ifdef __cplusplus - -/** @short class containing all the structures, constants and enum definitions */ -class slsDetectorDefs: public virtual slsReceiverDefs{ - public: - - slsDetectorDefs(){}; - -#endif - - - enum {startScript, scriptBefore, headerBefore, headerAfter,scriptAfter, stopScript, enCalLog, angCalLog, MAX_ACTIONS}; - - - -/** - @short structure for a detector channel - - should not be used by unexperienced users - - \see ::channelRegisterBit -*/ - typedef struct { - int chan; /**< is the channel number */ - int chip; /**< is the chip number */ - int module; /**< is the module number */ - int64_t reg; /**< is the is the channel register (e.g. trimbits, calibration enable, comparator enable...) */ - } sls_detector_channel; - - /** - @short structure for a detector chip - - should not be used by unexperienced users - \see ::chipRegisterBit ::channelRegisterBit -*/ - typedef struct { - int chip; /**< is the chip number */ - int module; /**< is the module number */ - int nchan; /**< is the number of channels in the chip */ - int reg; /***/ - M_vIbias, /**< mythen 3 >*/ - M_vIinSh, /**< mythen 3 >*/ - M_VdcSh, /**< mythen 3 >*/ - M_Vth2, /**< mythen 3 >*/ - M_VPL, /**< mythen 3 >*/ - M_Vth3, /**< mythen 3 >*/ - M_casSh, /**< mythen 3 >*/ - M_cas, /**< mythen 3 >*/ - M_vIbiasSh, /**< mythen 3 >*/ - M_vIcin, /**< mythen 3 >*/ - M_vIpreOut, /**< mythen 3 >*/ - V_POWER_A = 100, /**new chiptest board */ - V_POWER_B = 101, /**new chiptest board */ - V_POWER_C = 102, /**new chiptest board */ - V_POWER_D = 103, /**new chiptest board */ - V_POWER_IO =104, /**new chiptest board */ - V_POWER_CHIP=105 ,/**new chiptest board */ - I_POWER_A=106 , /**new chiptest board */ - I_POWER_B=107 , /**new chiptest board */ - I_POWER_C=108 , /**new chiptest board */ - I_POWER_D=109 , /**new chiptest board */ - I_POWER_IO=110 , /**new chiptest board */ - V_LIMIT=111 /**new chiptest board */ -}; - -/** - detector settings indexes -*/ -enum detectorSettings{ - GET_SETTINGS=-1, /**< return current detector settings */ - STANDARD, /**< standard settings */ - FAST, /**< fast settings */ - HIGHGAIN, /**< highgain settings */ - DYNAMICGAIN, /**< dynamic gain settings */ - LOWGAIN, /**< low gain settings */ - MEDIUMGAIN, /**< medium gain settings */ - VERYHIGHGAIN, /**< very high gain settings */ - LOWNOISE, /**< low noise settings */ - DYNAMICHG0, /**< dynamic high gain 0 */ - FIXGAIN1, /**< fix gain 1 */ - FIXGAIN2, /**< fix gain 2 */ - FORCESWITCHG1, /**< force switch gain 1 */ - FORCESWITCHG2, /**< force switch gain 2 */ - VERYLOWGAIN, /**< very low gain settings */ - UNDEFINED=200, /**< undefined or custom settings */ - UNINITIALIZED /**< uninitialiazed (status at startup) */ -}; -/** - meaning of the channel register bits - \see ::sls_detector_channel -*/ -enum channelRegisterBit { - TRIMBIT_OFF=0, /**< offset of trimbit value in the channel register */ - COMPARATOR_ENABLE=0x100, /**< mask of the comparator enable bit */ - ANALOG_SIGNAL_ENABLE=0x200, /**< mask of the analogue output enable bit */ - CALIBRATION_ENABLE=0x300, /**< mask of the calibration input enable bit */ -}; - -#define TRIMBITMASK 0x3f -/** - meaning of the chip register bits - \see ::sls_detector_chip -*/ -enum chipRegisterBit { - ENABLE_ANALOG_OUTPUT=0x1, /**< mask of the analogue output enable bit */ - CHIP_OUTPUT_WIDTH=0x2 /**< mask of the chip output width */ -}; -/** - meaning of the module register bits -*/ -enum moduleRegisterBit { - MY_MODULE_REGISTER_BIT, /**< possible module register bit meaning */ - MODULE_OUTPUT_WIDTH /**< possibly module dynamic range */ -}; - - -/** - important speed parameters -*/ -enum speedVariable { - CLOCK_DIVIDER, /**< readout clock divider */ - WAIT_STATES, /**< wait states for bus read */ - TOT_CLOCK_DIVIDER, /**< wait states for bus read */ - TOT_DUTY_CYCLE, /**< wait states for bus read */ - SET_SIGNAL_LENGTH, /**< set/clear signal length */ - PHASE_SHIFT, /**< adds phase shift */ - OVERSAMPLING, /**< oversampling for analog detectors */ - ADC_CLOCK, /**< adc clock divider */ - ADC_PHASE, /**< adc clock phase */ - ADC_PIPELINE, /**< adc pipeline */ - DBIT_CLOCK, /**< adc clock divider */ - DBIT_PHASE, /**< adc clock phase */ - DBIT_PIPELINE /**< adc pipeline */ -}; - - -/** - readout flags -*/ -enum readOutFlags { - GET_READOUT_FLAGS=-1, /**< return readout flags */ - NORMAL_READOUT=0, /**< no flag */ - STORE_IN_RAM=0x1, /**< data are stored in ram and sent only after end of acquisition for faster frame rate */ - READ_HITS=0x2, /**< return only the number of the channel which counted ate least one */ - ZERO_COMPRESSION=0x4,/**< returned data are 0-compressed */ - PUMP_PROBE_MODE=0x8,/**

API for SLS detectors data acquisition

-
-*/ -/** - \mainpage - - -

API for SLS detectors data acquisition

- -
- - Although the SLS detectors group delvelops several types of detectors (1/2D, counting/integrating etc.) it is common interest of the group to use a common platfor for data acquisition - - The architecture of the acquisitions system is intended as follows: - \li A socket server running on the detector (or more than one in some special cases) - \li C++ classes common to all detectors for client-server communication. These can be supplied to users as libraries and embedded also in acquisition systems which are not developed by the SLS - \li the possibility of using a Qt-based graphical user interface (with eventually root analisys capabilities) - \li the possibility of running all commands from command line. In order to ensure a fast operation of this so called "text client" the detector parameters should not be re-initialized everytime. For this reason a shared memory block is allocated where the main detector flags and parameters are stored - \li a Root library for data postprocessing and detector calibration (energy, angle). - - -slsDetectorUsers is a class to control the detector which should be instantiated by the users in their acquisition software (EPICS, spec etc.). A callback for dislaying the data can be registered. -More advanced configuration functions are not implemented and can be written in a configuration file tha can be read/written. - -slsReceiverUsers is a class to receive the data for detectors with external data receiver (e.g. GOTTHARD). Callbacks can be registered to process the data or save them in specific formats. - -detectorData is a structure containing the data and additional information which is used to return the data e.g. to the GUI for displaying them. - - -You can find examples of how this classes can be instatiated in mainClient.cpp and mainReceiver.cpp - - - \authors Anna Bergamaschi, Dhanya Thattil - @version 3.0 -

Currently supported detectors

-\li MYTHEN -\li GOTTHARD controls -\li GOTTHARD data receiver -\li EIGER -\li JUNGFRAU - - - -*/ - -/** - @short The slsDetectorUsers class is a minimal interface class which should be instantiated by the users in their acquisition software (EPICS, spec etc.). More advanced configuration functions are not implemented and can be written in a configuration or parameters file that can be read/written. - - Class for detector functionalities to embed the detector controls in the users custom interface e.g. EPICS, Lima etc. - -*/ - - -class slsDetectorUsers - { - - public: - - /** @short default constructor - * @param ret address of return value. It will be set to 0 for success, else 1 for failure - * @param id multi detector id - * in creating multidetector object - */ - slsDetectorUsers(int& ret, int id=0); - - /** @short virtual destructor */ - virtual ~slsDetectorUsers(); - - /** - @short useful to define subset of working functions - \returns "PSI" or "Dectris" - */ - std::string getDetectorDeveloper(); - - /** @short sets the onlineFlag - \param online can be: -1 returns wether the detector is in online (1) or offline (0) state; 0 detector in offline state; 1 detector in online state - \returns 0 (offline) or 1 (online) - */ - int setOnline(int const online=-1); - - /** @short sets the receivers onlineFlag - \param online can be: -1 returns wether the receiver is in online (1) or offline (0) state; 0 receiver in offline state; 1 receiver in online state - \returns 0 (offline) or 1 (online) - */ - int setReceiverOnline(int const online=-1); - - - /** - @short start measurement and acquires - \returns OK/FAIL - */ - void startMeasurement(); - - /** - @short stop measurement - \returns OK/FAIL - */ - int stopMeasurement(); - - /** - @short get run status - \returns status mask - */ - int getDetectorStatus(); - - /** - @short returns the default output files path - */ - std::string getFilePath(); - - /** - @short sets the default output files path - \param s file path - \returns file path - */ - std::string setFilePath(std::string s); - - /** - @short - \returns the default output files root name - */ - std::string getFileName(); - - /** - @short sets the default output files path - \param s file name - \returns the default output files root name - - */ - std::string setFileName(std::string s); - - /** - @short - \returns the default output file index - */ - int getFileIndex(); - - /** - @short sets the default output file index - \param i file index - \returns the default output file index - */ - int setFileIndex(int i); - - /** - @short get flat field corrections file directory - \returns flat field correction file directory - */ - std::string getFlatFieldCorrectionDir(); - - /** - @short set flat field corrections file directory - \param dir flat field correction file directory - \returns flat field correction file directory - */ - std::string setFlatFieldCorrectionDir(std::string dir); - - /** - @short get flat field corrections file name - \returns flat field correction file name - */ - std::string getFlatFieldCorrectionFile(); - - /** - @short set flat field correction file - \param fname name of the flat field file (or "" if disable) - \returns 0 if disable (or file could not be read), >0 otherwise - */ - int setFlatFieldCorrectionFile(std::string fname=""); - - - - /** - @short enable/disable flat field corrections (without changing file name) - \param i 0 disables, 1 enables, -1 gets - \returns 0 if ff corrections disabled, 1 if enabled - */ - int enableFlatFieldCorrection(int i=-1); - - /** - @short enable/disable count rate corrections - \param i 0 disables, 1 enables with default values, -1 gets - \returns 0 if count corrections disabled, 1 if enabled - */ - int enableCountRateCorrection(int i=-1); - - /** - @short enable/disable bad channel corrections - \param i 0 disables, 1 enables, -1 gets - \returns 0 if bad channels corrections disabled, 1 if enabled - */ - int enablePixelMaskCorrection(int i=-1); - - /** - @short enable/disable angular conversion - \param i 0 disables, 1 enables, -1 gets - \returns 0 if angular conversion disabled, 1 if enabled - */ - int enableAngularConversion(int i=-1); - - /**Enable write file function included*/ - - int enableWriteToFile(int i=-1); - - /** - @short set positions for the acquisition - \param nPos number of positions - \param pos array with the encoder positions - \returns number of positions - */ - int setPositions(int nPos, double *pos); - - /** - @short get positions for the acquisition - \param pos array which will contain the encoder positions - \returns number of positions - */ - int getPositions(double *pos=NULL); - - /** - @short sets the detector size (only 1 ROI) - \param x0 horizontal position origin in channel number (-1 unchanged) - \param y0 vertical position origin in channel number (-1 unchanged) - \param nx number of channels in horiziontal (-1 unchanged) - \param ny number of channels in vertical (-1 unchanged) - \returns OK/FAIL - */ - int setDetectorSize(int x0=-1, int y0=-1, int nx=-1, int ny=-1); - - /** - @short gets detector size (roi size if only one roi) - \param x0 horizontal position origin in channel number - \param y0 vertical position origin in channel number - \param nx number of channels in horiziontal - \param ny number of channels in vertical - \returns total number of channels - */ - int getDetectorSize(int &x0, int &y0, int &nx, int &ny); - /** - @short gets the maximum detector size - \param nx number of channels in horiziontal - \param ny number of channels in vertical - \returns OK/FAIL - */ - int getMaximumDetectorSize(int &nx, int &ny); - - - /** - @short set/get dynamic range - \param i dynamic range (-1 get) - \returns current dynamic range - */ - int setBitDepth(int i=-1); - - - - /** - @short set detector settings - \param isettings settings index (-1 gets) - \returns current settings - */ - int setSettings(int isettings=-1); - - /** - @short get threshold energy - \returns current threshold value for imod in ev (-1 failed) - */ - int getThresholdEnergy(); - - - /** - @short set threshold energy - \param e_eV threshold in eV - \returns current threshold value for imod in ev (-1 failed) - */ - int setThresholdEnergy(int e_eV); - - /** - @short set threshold energy with choice to load trimbits (eiger only) - \param e_ev threshold in ev - \param tb 1 loads trimbits, 0 does not load trimbits - \param isettings settings index (-1 uses current setting) - \param id module index (-1 for all) - \returns current threshold value in ev (-1 failed) - */ - int setThresholdEnergy(int e_ev, int tb, int isettings = -1, int id = -1); - - - /** - @short set/get exposure time value - \param t time in sn (-1 gets) - \param inseconds true if the value is in s, else ns - \param imod module number (-1 for all) - \returns timer set value in ns, or s if specified - */ - - double setExposureTime(double t=-1, bool inseconds=false, int imod = -1); - - /** - @short set/get exposure period - \param t time in ns (-1 gets) - \param inseconds true if the value is in s, else ns - \param imod module number (-1 for all) - \returns timer set value in ns, or s if specified - */ - double setExposurePeriod(double t=-1, bool inseconds=false, int imod = -1); - - /** - @short set/get delay after trigger - \param t time in ns (-1 gets) - \param inseconds true if the value is in s, else ns - \param imod module number (-1 for all) - \returns timer set value in ns, or s if specified - */ - double setDelayAfterTrigger(double t=-1, bool inseconds=false, int imod = -1); - - /** - @short set/get number of gates - \param t number of gates (-1 gets) - \param imod module number (-1 for all) - \returns number of gates - */ - int64_t setNumberOfGates(int64_t t=-1, int imod = -1); - - /** - @short set/get number of frames i.e. number of exposure per trigger - \param t number of frames (-1 gets) - \param imod module number (-1 for all) - \returns number of frames - */ - int64_t setNumberOfFrames(int64_t t=-1, int imod = -1); - - /** - @short set/get number of cycles i.e. number of triggers - \param t number of frames (-1 gets) - \param imod module number (-1 for all) - \returns number of frames - */ - int64_t setNumberOfCycles(int64_t t=-1, int imod = -1); - - /** - @short set/get the external communication mode - \param pol value to be set \sa getTimingMode - \returns current external communication mode - */ - int setTimingMode(int pol=-1); - - /** - @short Reads the configuration file -- will contain all the informations needed for the configuration (e.g. for a PSI detector caldir, settingsdir, angconv, badchannels, hostname etc.) - \param fname file name - \returns OK or FAIL - */ - int readConfigurationFile(std::string const fname); - - - /** - @short Reads the parameters from the detector and writes them to file - \param fname file to write to - \returns OK or FAIL - - */ - int dumpDetectorSetup(std::string const fname); - /** - @short Loads the detector setup from file - \param fname file to read from - \returns OK or FAIL - - */ - int retrieveDetectorSetup(std::string const fname); - - /** - @short useful for data plotting etc. - \returns Mythen, Eiger, Gotthard etc. - */ - std::string getDetectorType(); - - /** - @short sets the mode by which gui requests data from receiver - \param n is 0 for random requests for fast acquisitions and greater than 0 for nth read requests - \returns the mode set in the receiver - */ - int setReceiverMode(int n=-1); - - /** - @short register calbback for accessing detector final data, also enables data streaming in client and receiver (if receiver exists) - \param userCallback function for plotting/analyzing the data. Its arguments are the data structure d and the frame number f, s is for subframe number for eiger for 32 bit mode - \param pArg argument - */ - - void registerDataCallback(int( *userCallback)(detectorData* d, int f, int s, void*), void *pArg); - - /** - @short register callback for accessing raw data - if the rawDataCallback is registered, no filewriting/postprocessing will be carried on automatically by the software - the raw data are deleted by the software - \param userCallback function for postprocessing and saving the data - p is the pointer to the data, n is the number of channels - \param pArg argument - */ - - void registerRawDataCallback(int( *userCallback)(double* p, int n, void*), void *pArg); - - /** - @short function to initalize a set of measurements (reset binning if angular conversion, reset summing otherwise) - can be overcome by the user's functions thanks to the virtual property - \param refresh if 1, all parameters like ffcoefficients, badchannels, ratecorrections etc. are reset (should be called at least onece with this option), if 0 simply reset merging/ summation - */ - - virtual void initDataset(int refresh); - - - /** - @short adds frame to merging/summation - can be overcome by the user's functions thanks to the virtual property - \param data pointer to the raw data - \param pos encoder position - \param i0 beam monitor readout for intensity normalization (if 0 not performed) - \param t exposure time in seconds, required only if rate corrections - \param fname file name (unused since filewriting would be performed by the user) - \param var optional parameter - unused. - */ - - virtual void addFrame(double *data, double pos, double i0, double t, std::string fname, double var); - - /** - @short finalizes the data set returning the array of angles, values and errors to be used as final data - can be overcome by the user's functions thanks to the virtual property - \param a pointer to the array of angles - can be null if no angular coversion is required - \param v pointer to the array of values - \param e pointer to the array of errors - \param np reference returning the number of points - */ - - virtual void finalizeDataset(double *a, double *v, double *e, int &np); - - - /** Enable or disable streaming data from receiver (creates transmitting sockets) - * @param i 0 to disable 1 to enable -1 to only get the value - * @returns data streaming from receiver enable - */ - int enableDataStreamingFromReceiver(int i=-1); - - /** - * Enable data streaming to client (creates receiving sockets) - * @param i 0 to disable, 1 to enable, -1 to get the value - * @returns data streaming to client enable - */ - int enableDataStreamingToClient(int i=-1); - - /** (for expert users) - * Set/Get receiver streaming out ZMQ port - * For multi modules, it calculates (increments), sets the ports and restarts the sockets - * @param i sets, -1 gets - * @returns receiver streaming out ZMQ port (if multiple, of first receiver socket) - */ - int setReceiverDataStreamingOutPort(int i=-1); - - /** (for expert users) - * Set/Get client streaming in ZMQ port - * For multi modules, it calculates (increments), sets the ports and restarts the sockets - * @param i sets, -1 gets - * @returns client streaming in ZMQ port (if multiple, of first client socket) - */ - int setClientDataStreamingInPort(int i=-1); - - /** (for expert users) - * Set/Get receiver streaming out ZMQ IP - * By default, it is the IP of receiver hostname - * @param ip sets, empty std::string gets - * @returns receiver streaming out ZMQ IP - */ - std::string setReceiverDataStreamingOutIP(std::string ip=""); - - /** (for expert users) - * Set/Get client streaming in ZMQ IP - * By default, it is the IP of receiver hostname - * @param ip sets, empty std::string gets - * @returns client streaming in ZMQ IP - */ - std::string setClientDataStreamingInIP(std::string ip=""); - - /** - get get Module Firmware Version - @param imod module number - \returns id - */ - int64_t getModuleFirmwareVersion(int imod=-1); - - /** - get get Module Serial Number (only mythen) - @param imod module number - \returns id - */ - int64_t getModuleSerialNumber(int imod=-1); - - /** - get get Detector Firmware Version - @param imod module number - \returns id - */ - int64_t getDetectorFirmwareVersion(int imod=-1); - - /** - get get Detector Serial Number - @param imod module number - \returns id - */ - int64_t getDetectorSerialNumber(int imod=-1); - - /** - get get Detector Software Version - @param imod module number - \returns id - */ - int64_t getDetectorSoftwareVersion(int imod=-1); - - /** - get this Software Version - \returns id - */ - int64_t getThisSoftwareVersion(); - - /** - * Enable gap pixels, only for Eiger and for 8,16 and 32 bit mode. - * 4 bit mode gap pixels only in gui call back (registerDataCallback) - * @param enable 1 sets, 0 unsets, -1 gets - * @return gap pixel enable or -1 for error - */ - int enableGapPixels(int enable=-1); - - /** - * Sets the frames discard policy in receiver - * frame discard policy options: - * @param f nodiscard (default),discardempty, discardpartial (fastest), get to get the value - * @returns f nodiscard (default),discardempty, discardpartial (fastest) - */ - std::string setReceiverFramesDiscardPolicy(std::string f="get"); - - /** - * Sets the frame padding in receiver - * @param f 0 does not partial frames, 1 pads partial frames (-1 gets) - * @returns partial frames padding enable - */ - int setReceiverPartialFramesPadding(int f = -1); - - /** - * Sets the frames per file in receiver - * @param f frames per file, 0 is infinite ie. every frame in same file (-1 gets) - * @returns frames per file - */ - int setReceiverFramesPerFile(int f = -1); - - /** - * Sends a software internal trigger (EIGER only) - * @returns 0 for success, 1 for fail - */ - int sendSoftwareTrigger(); - - /** - * get measured period between previous two frames(EIGER only) - * @param inseconds true if the value is in s, else ns - * @param imod module number (-1 for all) - * @returns measured period - */ - double getMeasuredPeriod(bool inseconds=false, int imod = -1); - - /** - * get measured sub period between previous two sub frames in 32 bit mode (EIGER only) - * @param inseconds true if the value is in s, else ns - * @param imod module number (-1 for all) - * @returns measured sub period - */ - double getMeasuredSubFramePeriod(bool inseconds=false, int imod = -1); - - /** - @short register calbback for accessing detector final data - \param func function to be called at the end of the acquisition. gets detector status and progress index as arguments - \param pArg argument - */ - void registerAcquisitionFinishedCallback(int( *func)(double,int, void*), void *pArg); - - /** - @short register calbback for reading detector position - \param func function for reading the detector position - \param arg argument - */ - - void registerGetPositionCallback( double (*func)(void*),void *arg); - /** - @short register callback for connecting to the epics channels - \param func function for connecting to the epics channels - \param arg argument - */ - void registerConnectChannelsCallback( int (*func)(void*),void *arg); - /** - @short register callback to disconnect the epics channels - \param func function to disconnect the epics channels - \param arg argument - */ - void registerDisconnectChannelsCallback( int (*func)(void*),void *arg); - /** - @short register callback for moving the detector - \param func function for moving the detector - \param arg argument - */ - void registerGoToPositionCallback( int (*func)(double,void*),void *arg); - /** - @short register callback for moving the detector without waiting - \param func function for moving the detector - \param arg argument - */ - void registerGoToPositionNoWaitCallback( int (*func)(double,void*),void *arg); - /** - @short register calbback reading to I0 - \param func function for reading the I0 (called with parameter 0 before the acquisition, 1 after and the return value used as I0) - \param arg argument - */ - void registerGetI0Callback( double (*func)(int,void*),void *arg); - - /** - @short sets parameters in command interface http://www.psi.ch/detectors/UsersSupportEN/slsDetectorClientHowTo.pdf - \param narg value to be set - \param args value to be set - \param pos position of detector in multislsdetector list - \returns answer std::string - */ - std::string putCommand(int narg, char *args[], int pos=-1); - - /** - @short gets parameters in command interface http://www.psi.ch/detectors/UsersSupportEN/slsDetectorClientHowTo.pdf - \param narg value to be set - \param args value to be set - \param pos position of detector in multislsdetector list - \returns answer std::string - */ - std::string getCommand(int narg, char *args[], int pos=-1); - - /************************************************************************ - - ADVANCED FUNCTIONS - - *********************************************************************/ - /** - @short sets clock divider of detector - \param value value to be set (-1 gets) - \returns speed of detector - */ - int setClockDivider(int value); - - /** - @short sets parallel mode - \param value 0 for non parallel, 1 for parallel, 2 for safe mode (-1 gets) - \returns gets parallel mode - */ - int setParallelMode(int value); - - /** - * @short show saturated for overflow in subframes in 32 bit mode (eiger only) - * \param value 0 for do not show saturatd, 1 for show saturated (-1 gets) - * \returns overflow mode enable in 32 bit mode - */ - int setOverflowMode(int value); - - /** - @short sets all trimbits to value (only available for eiger) - \param val value to be set (-1 gets) - \param id module index (-1 for all) - \returns value set - */ - int setAllTrimbits(int val, int id = -1); - - /** - @short set dac value - \param dac dac as std::string. can be vcmp_ll, vcmp_lr, vcmp_rl, vcmp_rr, vthreshold, vrf, vrs, vtr, vcall, vcp. others not supported - \param val value to be set (-1 gets) - \param id module index (-1 for all) - \returns dac value or -1 (if id=-1 & dac value is different for all modules) or -9999 if dac std::string does not match - */ - int setDAC(std::string dac, int val, int id = -1); - - /** - @short get adc value - \param adc adc as std::string. can be temp_fpga, temp_fpgaext, temp_10ge, temp_dcdc, temp_sodl, temp_sodr, temp_fpgafl, temp_fpgafr. others not supported - \param id module index (-1 for all) - \returns adc value in millidegree Celsius or -1 (if id=-1 & adc value is different for all modules) or -9999 if adc std::string does not match - */ - int getADC(std::string adc, int id = -1); - - /** - @short start receiver listening mode - \returns returns OK or FAIL - */ - int startReceiver(); - - /** - @short stop receiver listening mode - \returns returns OK or FAIL - */ - int stopReceiver(); - - /** - start detector real time acquisition in non blocking mode - does not include scans, scripts, incrementing file index, s - tarting/stopping receiver, resetting frames caught in receiver - \returns OK if all detectors are properly started, FAIL otherwise - */ - int startAcquisition(); - - /** - stop detector real time acquisition - \returns OK if all detectors are properly started, FAIL otherwise - */ - int stopAcquisition(); - - /** - * set receiver in silent mode - * @param i 1 sets, 0 unsets (-1 gets) - * @returns silent mode of receiver - */ - int setReceiverSilentMode(int i); - - /** - * set high voltage - * @param i > 0 sets, 0 unsets, (-1 gets) - * @returns high voltage - */ - int setHighVoltage(int i); - - /** - * reset frames caught in receiver - * should be called before startReceiver() - * @returns OK or FAIL - */ - int resetFramesCaughtInReceiver(); - - /** - * set receiver fifo depth - * @param i number of images in fifo depth (-1 gets) - * @returns receiver fifo depth - */ - int setReceiverFifoDepth(int i = -1); - - /** - * set flow control for 10Gbe (Eiger only) - * @param i 1 sets, 0 unsets (-1 gets) - * @return flow control enable for 10 Gbe - */ - int setFlowControl10G(int i = -1); - - /** - * enable/disable 10GbE (Eiger only) - * @param i 1 sets, 0 unsets (-1 gets) - * @return 10GbE enable - */ - int setTenGigabitEthernet(int i = -1); - - /** - * returns total number of detector modules - * @returns the total number of detector modules - */ - int getNMods(); - - /** - * Set sub frame exposure time (only for Eiger) - * @param t sub frame exposure time (-1 gets) - * @param inseconds true if the value is in s, else ns - * @param imod module number (-1 for all) - * @returns sub frame exposure time in ns, or s if specified - */ - double setSubFrameExposureTime(double t=-1, bool inseconds=false, int imod = -1); - - /** - * Set sub frame dead time (only for Eiger) - * Very advanced feature. Meant to be a constant in config file by an expert for each individual module - * @param t sub frame dead time (-1 gets) - * @param inseconds true if the value is in s, else ns - * @param imod module number (-1 for all) - * @returns sub frame dead time in ns, or s if specified - */ - double setSubFrameExposureDeadTime(double t=-1, bool inseconds=false, int imod = -1); - - /** - * set/get number of additional storage cells (Jungfrau) - * @param t number of additional storage cells. Default is 0. (-1 gets) - * @param imod module number (-1 for all) - * @returns number of additional storage cells - */ - int64_t setNumberOfStorageCells(int64_t t=-1, int imod = -1); - - /** - * Set storage cell that stores first acquisition of the series (Jungfrau) - * @param pos storage cell index. Value can be 0 to 15. Default is 15. (-1 gets) - * @returns the storage cell that stores the first acquisition of the series - */ - int setStoragecellStart(int pos=-1); - - /** - * Set ROI (Gotthard) (>= 1 roi, but max 1 roi per module) - * At the moment only one set allowed - * @param n number of rois - * @param roiLimits array of roi - * @param imod module number (-1 for all) - * @returns OK or FAIL - */ - int setROI(int n=-1, slsDetectorDefs::ROI roiLimits[]=NULL, int imod = -1); - - /** - * Get ROI from each detector and convert it to the multi detector scale (Gotthard) - * >= 1 roi, but max 1 roi per module - * @param n number of rois - * @param imod module number (ignored) - * @returns pointer to array of ROI structure - */ - slsDetectorDefs::ROI* getROI(int &n, int imod = -1); - - /************************************************************************ - - STATIC FUNCTIONS - - *********************************************************************/ - - /** @short returns std::string from run status index - \param s run status index - \returns std::string error, waiting, running, data, finished or unknown when wrong index - */ - static std::string runStatusType(int s){ \ - switch (s) { \ - case 0: return std::string("idle"); \ - case 1: return std::string("error"); \ - case 2: return std::string("waiting"); \ - case 3: return std::string("finished"); \ - case 4: return std::string("data"); \ - case 5: return std::string("running"); \ - case 6: return std::string("stoppped"); \ - default: return std::string("unknown"); \ - }}; - - - - /** @short returns detector settings std::string from index - \param s can be standard, fast, highgain, dynamicgain, lowgain, mediumgain, veryhighgain - \returns setting index (-1 unknown std::string) - */ - - static int getDetectorSettings(std::string s){ \ - if (s=="standard") return 0; \ - if (s=="fast") return 1; \ - if (s=="highgain") return 2; \ - if (s=="dynamicgain") return 3; \ - if (s=="lowgain") return 4; \ - if (s=="mediumgain") return 5; \ - if (s=="veryhighgain") return 6; \ - return -1; }; - - /** @short returns detector settings std::string from index - \param s settings index - \returns standard, fast, highgain, dynamicgain, lowgain, mediumgain, veryhighgain, undefined when wrong index - */ - static std::string getDetectorSettings(int s){\ - switch(s) { \ - case 0: return std::string("standard");\ - case 1: return std::string("fast");\ - case 2: return std::string("highgain");\ - case 3: return std::string("dynamicgain"); \ - case 4: return std::string("lowgain"); \ - case 5: return std::string("mediumgain"); \ - case 6: return std::string("veryhighgain"); \ - default: return std::string("undefined"); \ - }}; - - - - /** - @short returns external communication mode std::string from index - \param f index for communication mode - \returns auto, trigger, ro_trigger, gating, triggered_gating, unknown when wrong mode - */ - - static std::string getTimingMode(int f){ \ - switch(f) { \ - case 0: return std::string( "auto"); \ - case 1: return std::string("trigger"); \ - case 2: return std::string("ro_trigger"); \ - case 3: return std::string("gating"); \ - case 4: return std::string("triggered_gating"); \ - case 5: return std::string("burst_trigger"); \ - default: return std::string( "unknown"); \ - } }; - - /** - @short returns external communication mode std::string from index - \param s index for communication mode - \returns auto, trigger, ro_trigger, gating, triggered_gating, unknown when wrong mode - */ - - static int getTimingMode(std::string s){ \ - if (s== "auto") return 0; \ - if (s== "trigger") return 1; \ - if (s== "ro_trigger") return 2; \ - if (s== "gating") return 3; \ - if (s== "triggered_gating") return 4; \ - return -1; }; - - - private: - multiSlsDetector *myDetector; - multiSlsDetectorCommand *myCmd; - }; - -#endif diff --git a/slsDetectorSoftware/slsDetector/slsDetectorUtils.cpp b/slsDetectorSoftware/slsDetector/slsDetectorUtils.cpp deleted file mode 100644 index e81ee57f5..000000000 --- a/slsDetectorSoftware/slsDetector/slsDetectorUtils.cpp +++ /dev/null @@ -1,950 +0,0 @@ -#include "slsDetectorUtils.h" -#include "usersFunctions.h" -#include "slsDetectorCommand.h" -#include "postProcessing.h" -#include "enCalLogClass.h" -#include "angCalLogClass.h" - -#include -#include -#include -#include //clock() -#include -using namespace std; - -slsDetectorUtils::slsDetectorUtils() { - - -#ifdef VERBOSE - cout << "setting callbacks" << endl; -#endif - acquisition_finished=NULL; - acqFinished_p=NULL; - measurement_finished=NULL; - measFinished_p=NULL; - progress_call=0; - pProgressCallArg=0; - registerGetPositionCallback(&defaultGetPosition, NULL); - registerConnectChannelsCallback(&defaultConnectChannels,NULL); - registerDisconnectChannelsCallback(&defaultDisconnectChannels,NULL); - registerGoToPositionCallback(&defaultGoToPosition,NULL); - registerGoToPositionNoWaitCallback(&defaultGoToPositionNoWait,NULL); - registerGetI0Callback(&defaultGetI0,NULL); -#ifdef VERBOSE - - registerAcquisitionFinishedCallback(&dummyAcquisitionFinished,this); - registerMeasurementFinishedCallback(&dummyMeasurementFinished,this); - cout << "done " << endl; -#endif - -}; - - - - - -int slsDetectorUtils::acquire(int delflag){ - - //ensure acquire isnt started multiple times by same client - if (isAcquireReady() == FAIL) - return FAIL; - -#ifdef VERBOSE - struct timespec begin,end; - clock_gettime(CLOCK_REALTIME, &begin); -#endif - - //in the real time acquisition loop, processing thread will wait for a post each time - sem_init(&sem_newRTAcquisition,1,0); - //in the real time acquistion loop, main thread will wait for processing thread to be done each time (which in turn waits for receiver/ext process) - sem_init(&sem_endRTAcquisition,1,0); - - - bool receiver = (setReceiverOnline()==ONLINE_FLAG); - if(!receiver){ - setDetectorIndex(-1); - } - - int nc=setTimer(CYCLES_NUMBER,-1); - int nf=setTimer(FRAME_NUMBER,-1); - if (nc==0) nc=1; - if (nf==0) nf=1; - int multiframe = nc*nf; - - progressIndex=0; - *stoppedFlag=0; - - angCalLogClass *aclog=NULL; - enCalLogClass *eclog=NULL; - int connectChannels=0; - -#ifdef VERBOSE - cout << "Acquire function "<< delflag << endl; - cout << "Stopped flag is "<< stoppedFlag << delflag << endl; -#endif - - void *status; - if ((*correctionMask&(1<< ANGULAR_CONVERSION)) || (*correctionMask&(1<< I0_NORMALIZATION)) || getActionMode(angCalLog) || (getScanMode(0)==positionScan)|| (getScanMode(1)==positionScan)) { - if (connectChannels==0) - if (connect_channels) { - connect_channels(CCarg); - connectChannels=1; - } - } - if (getActionMode(angCalLog)) { - aclog=new angCalLogClass(this); - } - if (getActionMode(enCalLog)) { - eclog=new enCalLogClass(this); - - } - - - setJoinThread(0); - positionFinished(0); - - - int nm=timerValue[MEASUREMENTS_NUMBER]; - if (nm<1) - nm=1; - - - int np=getNumberOfPositions(); - if (np<1) - np=1; - - - int ns0=1; - if (*actionMask & (1 << MAX_ACTIONS)) { - ns0=getScanSteps(0); - if (ns0<1) - ns0=1; - } - - int ns1=1; - if (*actionMask & (1 << (MAX_ACTIONS+1))) { - ns1=getScanSteps(1); - if (ns1<1) - ns1=1; - } - - // verify receiver is idle - if(receiver){ - pthread_mutex_lock(&mg); - if(getReceiverStatus()!=IDLE) - if(stopReceiver() == FAIL) - *stoppedFlag=1; - pthread_mutex_unlock(&mg); - } - - - if (*threadedProcessing) - startThread(delflag); -#ifdef VERBOSE - cout << " starting thread " << endl; -#endif - - //resets frames caught in receiver - if(receiver){ - pthread_mutex_lock(&mg); - if (resetFramesCaught() == FAIL) - *stoppedFlag=1; - pthread_mutex_unlock(&mg); - } - - - for(int im=0;im0) { - moveDetector(detPositions[ip]); - IncrementPositionIndex(); -#ifdef VERBOSE - std::cout<< "moving to position" << std::endl; -#endif - } - } else - break; - - - pthread_mutex_lock(&mp); - createFileName(); - pthread_mutex_unlock(&mp); - - // script before - if (*stoppedFlag==0) { - executeAction(scriptBefore); - } else - break; - - - // header before - if (*stoppedFlag==0) { - executeAction(headerBefore); - - if (*correctionMask&(1<< ANGULAR_CONVERSION) || aclog){ - positionFinished(0); - setCurrentPosition(getDetectorPosition()); - } - - if (aclog) - aclog->addStep(getCurrentPosition(), getCurrentFileName()); - - if (eclog) - eclog->addStep(setDAC(-1,THRESHOLD,0), getCurrentFileName()); - - - if (*correctionMask&(1<< I0_NORMALIZATION)) { - if (get_i0) - get_i0(0, IOarg); - } - - setCurrentFrameIndex(0); - - if (multiframe>1) - setFrameIndex(0); - else - setFrameIndex(-1); - - // file name and start receiver - if(receiver){ - pthread_mutex_lock(&mp); - createFileName(); - pthread_mutex_unlock(&mp); - //send receiver file name - pthread_mutex_lock(&mg); - setFileName(fileIO::getFileName()); - - if(startReceiver() == FAIL) { - cout << "Start receiver failed " << endl; - stopReceiver(); - *stoppedFlag=1; - pthread_mutex_unlock(&mg); - break; - } -#ifdef VERBOSE - cout << "Receiver started " << endl; -#endif - pthread_mutex_unlock(&mg); - - //let processing thread listen to these packets - sem_post(&sem_newRTAcquisition); - } -#ifdef VERBOSE - cout << "Acquiring " << endl; -#endif - startAndReadAll(); -#ifdef VERBOSE - cout << "detector finished" << endl; - cout << "returned! " << endl; -#endif - - - if (*correctionMask&(1<< I0_NORMALIZATION)) { - if (get_i0) - currentI0=get_i0(1,IOarg); - } -#ifdef VERBOSE - cout << "pos finished? " << endl; -#endif - - positionFinished(1); - -#ifdef VERBOSE - cout << "done! " << endl; -#endif - - - if (*threadedProcessing==0){ -#ifdef VERBOSE - cout << "start unthreaded process data " << endl; -#endif - processData(delflag); - } - - } else - break; - - while (dataQueueSize()) usleep(100000); - - // close file - if(!receiver){ - detectorType type = getDetectorsType(); - if ((type==GOTTHARD) || (type==MOENCH) || (type==JUNGFRAUCTB) ){ - if((*correctionMask)&(1<0) - nc=timerValue[CYCLES_NUMBER]; - - if (timerValue[MEASUREMENTS_NUMBER]>0) - nm=timerValue[MEASUREMENTS_NUMBER]; - - if (*numberOfPositions>0) - npos=*numberOfPositions; - - if ((nScanSteps[0]>0) && (*actionMask & (1 << MAX_ACTIONS))) - nscan[0]=nScanSteps[0]; - - if ((nScanSteps[1]>0) && (*actionMask & (1 << (MAX_ACTIONS+1)))) - nscan[1]=nScanSteps[1]; - - totalProgress=nm*nf*nc*npos*nscan[0]*nscan[1]; - -#ifdef VERBOSE - cout << "nc " << nc << endl; - cout << "nm " << nm << endl; - cout << "nf " << nf << endl; - cout << "npos " << npos << endl; - cout << "nscan[0] " << nscan[0] << endl; - cout << "nscan[1] " << nscan[1] << endl; - - cout << "Set total progress " << totalProgress << endl; -#endif - return totalProgress; -} - - - - - - - - - -int slsDetectorUtils::setBadChannelCorrection(string fname, int &nbadtot, int *badchanlist, int off){ - - int nbad; - int badlist[MAX_BADCHANS]; - - ifstream infile; - string str; - //int interrupt=0; - //int ich; - //int chmin,chmax; -#ifdef VERBOSE - std::cout << "utils: Setting bad channel correction to " << fname << std::endl; -#endif - // int modmi=0; - int modma=1; - int singlefile=0; - - string fn; - int offset=off; - - - nbadtot=0; - - if (fname=="" || fname=="none") { - ; - } else { - - if (fname.find(".sn")==string::npos && fname.find(".chans")==string::npos) { - modma=setNumberOfModules(); - singlefile=1; - } - - for (int im=0; im0 && nbadtot> sargname; - // if (ssstr.good()) { - strcpy(myargs[iargval],sargname.c_str()); - args[iargval]=myargs[iargval]; -#ifdef VERBOSE - std::cout<< args[iargval] << std::endl; -#endif - iargval++; - // } - skip=0; - } - - if (level!=2) { - if (string(args[0])==string("flatfield")) - skip=1; - else if (string(args[0])==string("badchannels")) - skip=1; - else if (string(args[0])==string("trimbits")) - skip=1; - } - if (skip==0) - cmd->executeLine(iargval,args,PUT_ACTION); - } - iline++; - } - delete cmd; - infile.close(); - - } else { - std::cout<< "Error opening " << fname << " for reading" << std::endl; - return FAIL; - } -#ifdef VERBOSE - std::cout<< "Read " << iline << " lines" << std::endl; -#endif - - if (getErrorMask()) - return FAIL; - - return OK; - - -} - - -int slsDetectorUtils::dumpDetectorSetup(string const fname, int level){ - - slsDetectorCommand *cmd; - detectorType type = getDetectorsType(); - string names[100]; - int nvar=0; - - // common config - names[nvar++]="fname"; - names[nvar++]="index"; - names[nvar++]="enablefwrite"; - names[nvar++]="overwrite"; - names[nvar++]="dr"; - names[nvar++]="settings"; - names[nvar++]="exptime"; - names[nvar++]="period"; - names[nvar++]="frames"; - names[nvar++]="cycles"; - names[nvar++]="measurements"; - names[nvar++]="timing"; - names[nvar++]="flatfield"; - names[nvar++]="badchannels"; - - switch (type) { - case EIGER: - names[nvar++]="flags"; - names[nvar++]="clkdivider"; - names[nvar++]="threshold"; - names[nvar++]="ratecorr"; - names[nvar++]="trimbits"; - break; - case GOTTHARD: - case PROPIX: - names[nvar++]="flags"; - names[nvar++]="delay"; - names[nvar++]="gates"; - names[nvar++]="ratecorr"; - break; - case JUNGFRAU: - names[nvar++]="flags"; - names[nvar++]="delay"; - names[nvar++]="gates"; - names[nvar++]="ratecorr"; - names[nvar++]="clkdivider"; - break; - case MYTHEN: - names[nvar++]="flags"; - names[nvar++]="threshold"; - names[nvar++]="delay"; - names[nvar++]="gates"; - names[nvar++]="probes"; - names[nvar++]="fineoff"; - names[nvar++]="ratecorr"; - names[nvar++]="trimbits"; - break; - case JUNGFRAUCTB: - names[nvar++]="dac:0"; - names[nvar++]="dac:1"; - names[nvar++]="dac:2"; - names[nvar++]="dac:3"; - names[nvar++]="dac:4"; - names[nvar++]="dac:5"; - names[nvar++]="dac:6"; - names[nvar++]="dac:7"; - names[nvar++]="dac:8"; - names[nvar++]="dac:9"; - names[nvar++]="dac:10"; - names[nvar++]="dac:11"; - names[nvar++]="dac:12"; - names[nvar++]="dac:13"; - names[nvar++]="dac:14"; - names[nvar++]="dac:15"; - names[nvar++]="adcvpp"; - - - - names[nvar++]="adcclk"; - names[nvar++]="clkdivider"; - names[nvar++]="adcphase"; - names[nvar++]="adcpipeline"; - names[nvar++]="adcinvert"; // - names[nvar++]="adcdisable"; - names[nvar++]="patioctrl"; - names[nvar++]="patclkctrl"; - names[nvar++]="patlimits"; - names[nvar++]="patloop0"; - names[nvar++]="patnloop0"; - names[nvar++]="patwait0"; - names[nvar++]="patwaittime0"; - names[nvar++]="patloop1"; - names[nvar++]="patnloop1"; - names[nvar++]="patwait1"; - names[nvar++]="patwaittime1"; - names[nvar++]="patloop2"; - names[nvar++]="patnloop2"; - names[nvar++]="patwait2"; - names[nvar++]="patwaittime2"; - break; - default: - break; - } - - - names[nvar++]="startscript"; - names[nvar++]="startscriptpar"; - names[nvar++]="stopscript"; - names[nvar++]="stopscriptpar"; - names[nvar++]="scriptbefore"; - names[nvar++]="scriptbeforepar"; - names[nvar++]="scriptafter"; - names[nvar++]="scriptafterpar"; - names[nvar++]="scan0script"; - names[nvar++]="scan0par"; - names[nvar++]="scan0prec"; - names[nvar++]="scan0steps"; - names[nvar++]="scan1script"; - names[nvar++]="scan1par"; - names[nvar++]="scan1prec"; - names[nvar++]="scan1steps"; - - - int iv=0; - string fname1; - - - - ofstream outfile; - char *args[4]; - for (int ia=0; ia<4; ia++) { - args[ia]=new char[1000]; - } - - - int nargs; - if (level==2) - nargs=2; - else - nargs=1; - - - if (level==2) { - fname1=fname+string(".config"); - writeConfigurationFile(fname1); - fname1=fname+string(".det"); - } else - fname1=fname; - - - - outfile.open(fname1.c_str(),ios_base::out); - if (outfile.is_open()) { - cmd=new slsDetectorCommand(this); - for (iv=0; ivexecuteLine(1,args,GET_ACTION) << std::endl; - } - - - strcpy(args[0],names[iv].c_str()); - if (level==2) { - fname1=fname+string(".ff"); - strcpy(args[1],fname1.c_str()); - } - outfile << names[iv] << " " << cmd->executeLine(nargs,args,GET_ACTION) << std::endl; - iv++; - - strcpy(args[0],names[iv].c_str()); - if (level==2) { - fname1=fname+string(".bad"); - strcpy(args[1],fname1.c_str()); - } - outfile << names[iv] << " " << cmd->executeLine(nargs,args,GET_ACTION) << std::endl; - iv++; - - - - if (level==2) { - strcpy(args[0],names[iv].c_str()); - size_t c=fname.rfind('/'); - if (cexecuteLine(nargs,args,GET_ACTION) << std::endl; - iv++; - - - } - - - delete cmd; - - outfile.close(); - } - else { - std::cout<< "Error opening parameters file " << fname1 << " for writing" << std::endl; - return FAIL; - } - -#ifdef VERBOSE - std::cout<< "wrote " < -} - -#include -#include -#include -#include -#include - - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - - - -//#include "slsDetectorActions_Standalone.h" -#include "slsDetectorActions.h" -#include "postProcessing.h" - -//#define MAX_TIMERS 11 -#define MAXPOS 50 - -#define DEFAULT_HOSTNAME "localhost" -#define DEFAULT_SHM_KEY 5678 -#define THIS_REVISION "$Rev: 822 $" - -//test - -/** - @short class containing all the possible detector functionalities - - (used in the PSi command line interface) -*/ - - -class slsDetectorUtils : public slsDetectorActions, public postProcessing { - - - public: - - slsDetectorUtils(); - - virtual ~slsDetectorUtils(){}; - - /** - * Used when reference is slsDetectorUtils and to determine if command can be implemented as slsDetector/multiSlsDetector object/ - */ - virtual bool isMultiSlsDetectorClass()=0; - - virtual int getNumberOfDetectors(){return 1; }; - - - virtual int getMaxNumberOfChannelsPerDetector(dimension d){return -1;}; - - virtual int setMaxNumberOfChannelsPerDetector(dimension d,int i){return -1;}; - - /** sets the enable which determines if data will be flipped across x or y axis - * \param d axis across which data is flipped - * \param value 0 or 1 to reset/set or -1 to get value - * \return enable flipped data across x or y axis - */ - virtual int setFlippedData(dimension d=X, int value=-1)=0; - - /** - * Enable gap pixels, only for Eiger and for 8,16 and 32 bit mode. 4 bit mode gap pixels only in gui call back - * @param val 1 sets, 0 unsets, -1 gets - * @return gap pixel enable or -1 for error - */ - virtual int enableGapPixels(int val=-1) = 0; - - //int setPositions(int nPos, double *pos){return angularConversion::setPositions(nPos, pos);}; - - // int getPositions(double *pos=NULL){return angularConversion::getPositions(pos);}; - - using slsDetectorBase::setFlatFieldCorrection; - using slsDetectorBase::getDetectorsType; - using postProcessing::setBadChannelCorrection; - - int enableFlatFieldCorrection(int i=-1) {if (i>0) setFlatFieldCorrectionFile("default"); else if (i==0) setFlatFieldCorrectionFile(""); return getFlatFieldCorrection();}; - int enablePixelMaskCorrection(int i=-1) {if (i>0) setBadChannelCorrection("default"); else if (i==0) setBadChannelCorrection(""); return getBadChannelCorrection();}; - int enableCountRateCorrection(int i=-1) {if (i>0) setRateCorrection(-1); else if (i==0) setRateCorrection(0); return getRateCorrection();}; - - - /** - * Set/Get receiver streaming out ZMQ port - * For multi modules, it calculates (increments) and sets the ports - * @param i sets, -1 gets - * @returns receiver streaming out ZMQ port - */ - int setReceiverDataStreamingOutPort(int i) { \ - if (i >= 0) { \ - std::ostringstream ss; ss << i; std::string s = ss.str(); \ - int prev_streaming = enableDataStreamingFromReceiver(); \ - setNetworkParameter(RECEIVER_STREAMING_PORT, s); \ - if (prev_streaming) { \ - enableDataStreamingFromReceiver(0); \ - enableDataStreamingFromReceiver(1);}} \ - return atoi(getNetworkParameter(RECEIVER_STREAMING_PORT).c_str());}; \ - - /** - * Set/Get client streaming in ZMQ port - * For multi modules, it calculates (increments) and sets the ports - * @param i sets, -1 gets - * @returns client streaming in ZMQ port - */ - int setClientDataStreamingInPort(int i){ \ - if (i >= 0) { \ - std::ostringstream ss; ss << i; std::string s = ss.str(); \ - int prev_streaming = enableDataStreamingToClient(); \ - setNetworkParameter(CLIENT_STREAMING_PORT, s); \ - if (prev_streaming) { \ - enableDataStreamingToClient(0); \ - enableDataStreamingToClient(1);}} \ - return atoi(getNetworkParameter(CLIENT_STREAMING_PORT).c_str());}; \ - - /** - * Set/Get receiver streaming out ZMQ port - * For multi modules, it calculates (increments) and sets the ports - * @param i sets, -1 gets - * @returns receiver streaming out ZMQ port - */ - std::string setReceiverDataStreamingOutIP(std::string ip) { \ - if (ip.length()) { \ - int prev_streaming = enableDataStreamingFromReceiver(); \ - setNetworkParameter(RECEIVER_STREAMING_SRC_IP, ip); \ - if (prev_streaming) { \ - enableDataStreamingFromReceiver(0); \ - enableDataStreamingFromReceiver(1);}} \ - return getNetworkParameter(RECEIVER_STREAMING_SRC_IP);}; \ - - /** - * Set/Get client streaming in ZMQ port - * For multi modules, it calculates (increments) and sets the ports - * @param i sets, -1 gets - * @returns client streaming in ZMQ port - */ - std::string setClientDataStreamingInIP(std::string ip){ \ - if (ip.length()) { \ - int prev_streaming = enableDataStreamingToClient(); \ - setNetworkParameter(CLIENT_STREAMING_SRC_IP, ip); \ - if (prev_streaming) { \ - enableDataStreamingToClient(0); \ - enableDataStreamingToClient(1);}} \ - return getNetworkParameter(CLIENT_STREAMING_SRC_IP);}; \ - -// string getFilePath(){return fileIO::getFilePath();};; - // string setFilePath(string s){return fileIO::setFilePath(s);}; - - // string getFileName(){return fileIO::getFileName();}; - // string setFileName(string s){return fileIO::setFileName(s);}; - - // int getFileIndex(){return fileIO::getFileIndex();}; - // int setFileIndex(int s){return fileIO::setFileIndex(s);}; - - /* - int getScanPrecision(int i){return slsDetectorActions::getScanPrecision(i);}; - - int getActionMask() {return slsDetectorActions::getActionMask();}; - float getCurrentScanVariable(int i) {return slsDetectorActions::getCurrentScanVariable(i);}; - int getCurrentPositionIndex(){return angularConversion::getCurrentPositionIndex();}; - int getNumberOfPositions(){return angularConversion::getNumberOfPositions();}; - */ - - // int getActionMask() {return slsDetectorActions::getActionMask();}; - // double getCurrentScanVariable(int i) {return slsDetectorActions::getCurrentScanVariable(i);}; - // int getCurrentPositionIndex(){return angularConversion::getCurrentPositionIndex();}; - // int getNumberOfPositions(){return angularConversion::getNumberOfPositions();}; - - - // string getFlatFieldCorrectionDir(){return postProcessing::getFlatFieldCorrectionDir();}; - // string setFlatFieldCorrectionDir(string s){return postProcessing::setFlatFieldCorrectionDir(s);}; - // string getFlatFieldCorrectionFile(){return postProcessing::getFlatFieldCorrectionFile();}; - // int enableBadChannelCorrection(int i){return postProcessing::enableBadChannelCorrection(i);}; - // int enableAngularConversion(int i){return postProcessing::enableAngularConversion(i);}; - - - /** returns the detector hostname - \param pos position in the multi detector structure (is -1 returns concatenated hostnames divided by a +) - \returns hostname - */ - virtual std::string getHostname(int pos=-1)=0; - - - /** sets the detector hostname - \param name hostname - */ - virtual void setHostname(const char* name)=0; - - /** adds the detector hostnames to the end of the list - \param name hostname - */ - virtual void addMultipleDetectors(const char* name)=0; - - /** returns the detector type - \param pos position in the multi detector structure (is -1 returns type of detector with id -1) - \returns type - */ - virtual std::string sgetDetectorsType(int pos=-1)=0; - - /** - gets the network parameters (implemented for gotthard) - \param i network parameter type can be RECEIVER_IP, RECEIVER_MAC, SERVER_MAC - \returns parameter - - */ - virtual std::string getNetworkParameter(networkParameter i)=0; - - /** - sets the network parameters - must restart streaming in client/receiver if to do with zmq after calling this function - \param i network parameter type - \param s value to be set - \returns parameter - - */ - virtual std::string setNetworkParameter(networkParameter i, std::string s)=0; - - int setFlowControl10G(int i = -1) { - std::string sret=""; - if (i != -1) { - std::ostringstream o; - o << ((i >= 1) ? 1 : 0); - std::string sval = o.str(); - sret = setNetworkParameter(FLOW_CONTROL_10G, sval); - } else - sret = getNetworkParameter(FLOW_CONTROL_10G); - - return atoi(sret.c_str()); - } - - /** - changes/gets the port number - \param t type port type can be CONTROL_PORT, DATA_PORT, STOP_PORT - \param i new port number (<1024 gets) - \returns actual port number - */ - virtual int setPort(portType t, int i=-1)=0; - - /** - checks if the detector(s) are online/offline - \returns hostname if offline - */ - virtual std::string checkOnline()=0; - - /** - Digital test of the modules - \param mode test mode - \param imod module number for chip test or module firmware test - \returns OK or error mask - */ - virtual int digitalTest(digitalTestMode mode, int imod=0)=0; - - /** - execute trimming - \param mode trim mode - \param par1 if noise, beam or fixed setting trimming it is count limit, if improve maximum number of iterations - \param par2 if noise or beam nsigma, if improve par2!=means vthreshold will be optimized, if fixed settings par2<0 trimwith median, par2>=0 trim with level - \param imod module number (-1 all) - \returns OK or FAIl (FAIL also if some channel are 0 or 63 - */ - virtual int executeTrimming(trimMode mode, int par1, int par2, int imod=-1)=0; - - - /** - returns currently the loaded trimfile/settingsfile name - */ - virtual std::string getSettingsFile()=0; - - - /** - get current timer value - \param index timer index - \param imod module number - \returns elapsed time value in ns or number of...(e.g. frames, gates, probes) - */ - virtual int64_t getTimeLeft(timerIndex index, int imod = -1)=0; - - /** - * set storage cell that stores first acquisition of the series (Jungfrau only) - * \param value storage cell index. Value can be 0 to 15. (-1 gets) - * \returns the storage cell that stores the first acquisition of the series - */ - virtual int setStoragecellStart(int pos=-1)=0; - - - - /** sets the number of trim energies and their value \sa sharedSlsDetector - \param nen number of energies - \param en array of energies - \returns number of trim energies - - unused! - - */ - virtual int setTrimEn(int nen, int *en=NULL)=0; - - /** returns the number of trim energies and their value \sa sharedSlsDetector - \param en pointer to the array that will contain the trim energies (in ev) - \returns number of trim energies - - unused! - */ - virtual int getTrimEn(int *en=NULL)=0; - - - - /** - set/get the use of an external signal - \param pol meaning of the signal \sa externalSignalFlag - \param signalindex index of the signal - \returns current meaning of signal signalIndex - */ - virtual externalSignalFlag setExternalSignalFlags(externalSignalFlag pol=GET_EXTERNAL_SIGNAL_FLAG , int signalindex=0)=0; - - - - - /** sets/gets the value of important readout speed parameters - \param sp is the parameter to be set/get - \param value is the value to be set, if -1 get value - \returns current value for the specified parameter - \sa speedVariable - */ - virtual int setSpeed(speedVariable sp, int value=-1)=0; - - - - - - - /** - set/get readout flags - \param flag readout flag to be set - \returns current flag - */ - virtual int setReadOutFlags(readOutFlags flag=GET_READOUT_FLAGS)=0; - - - - - - int setBadChannelCorrection(std::string fname, int &nbadtot, int *badchanlist, int off=0); - - - - - - /** sets/gets position of the master in a multi detector structure - \param i position of the detector in the multidetector structure - \returns position of the master in a multi detector structure (-1 no master or always in slsDetector) - */ - virtual int setMaster(int i=-1){return -1;}; - - /** - Sets/gets the synchronization mode of the various detectors - \param sync syncronization mode - \returns current syncronization mode - */ - virtual synchronizationMode setSynchronization(synchronizationMode sync=GET_SYNCHRONIZATION_MODE)=0; - - - /** - returns the detector trimbit/settings directory - */ - virtual std::string getSettingsDir()=0; - - /** sets the detector trimbit/settings directory */ - virtual std::string setSettingsDir(std::string s)=0; - - /** - returns the location of the calibration files - */ - virtual std::string getCalDir()=0; - - /** - sets the location of the calibration files - */ - virtual std::string setCalDir(std::string s)=0; - - /** Frees the shared memory - should not be used except for debugging*/ - virtual void freeSharedMemory()=0; - - /** - * Get user details of shared memory - * @returns string with user details - */ - virtual std::string getUserDetails() = 0; - - /** adds the detector name in position pos - \param name of the detector to be added (should already exist in shared memory or at least be online) - \param pos position where it should be added (normally at the end of the list (default to -1) - \return the actual number of detectors or -1 if it failed (always for slsDetector) - */ - virtual int addSlsDetector(char* name, int pos=-1){return -1;}; - - - /** - Turns off the server - do not use except for debugging! - */ - virtual int exitServer()=0; - - - - - /** - Loads dark image or gain image to the detector - \param index can be DARK_IMAGE or GAIN_IMAGE - \fname file name to load data from - \returns OK or FAIL - */ - virtual int loadImageToDetector(imageType index,std::string const fname)=0; - - - /** - writes the counter memory block from the detector - \param startACQ is 1 to start acquisition after reading counter - \fname file fname to load data from - \returns OK or FAIL - */ - virtual int writeCounterBlockFile(std::string const fname,int startACQ=0)=0; - - - /** - Resets counter memory block in detector - \param startACQ is 1 to start acquisition after resetting counter - \returns OK or FAIL - */ - virtual int resetCounterBlock(int startACQ=0)=0; - - /** set/get counter bit in detector - * @param i is -1 to get, 0 to reset and any other value to set the counter bit - /returns the counter bit in detector - */ - virtual int setCounterBit(int i = -1)=0; - - - /** - asks and receives all data from the detector and puts them in a data queue - \returns pointer to the front of the queue or NULL. - */ - virtual int* readAll()=0; - - - - - /** performs a complete acquisition including scansand data processing - moves the detector to next position
- starts and reads the detector
- reads the IC (if required)
- reads the encoder (iof required for angualr conversion)
- processes the data (flat field, rate, angular conversion and merging ::processData()) - \param delflag 0 leaves the data in the final data queue - \returns OK or FAIL depending on if it already started - */ - - int acquire(int delflag=1); - - /** - * Give an internal software trigger to the detector (Eiger only) - * @return OK or FAIL - */ - virtual int sendSoftwareTrigger()=0; - - - - // double* convertAngles(){return convertAngles(currentPosition);}; - // virtual double* convertAngles(double pos)=0; - - virtual int setThresholdEnergy(int, int im=-1, detectorSettings isettings=GET_SETTINGS, int tb=1)=0; - virtual int setChannel(int64_t, int ich=-1, int ichip=-1, int imod=-1)=0; - - virtual double getRateCorrectionTau()=0; - virtual int* startAndReadAll()=0; - - virtual int getTotalNumberOfChannels()=0; - virtual int getTotalNumberOfChannels(dimension d)=0; - virtual int getMaxNumberOfChannels()=0; - virtual int getMaxNumberOfChannels(dimension d)=0; - - /** returns the enable if data will be flipped across x or y axis - * \param d axis across which data is flipped - * returns 1 or 0 - */ - virtual int getFlippedData(dimension d=X)=0; - - // virtual int getParameters(); - - - - - int setTotalProgress(); - - double getCurrentProgress(); - - - void incrementProgress(); - void setCurrentProgress(int i=0); - - - /** - write register - \param addr address - \param val value - \returns current register value - - DO NOT USE!!! ONLY EXPERT USER!!! - */ - virtual uint32_t writeRegister(uint32_t addr, uint32_t val)=0; - - - /** - write ADC register - \param addr address - \param val value - \returns current register value - - DO NOT USE!!! ONLY EXPERT USER!!! - */ - virtual int writeAdcRegister(int addr, int val)=0; - - - /** - read register - \param addr address - \returns current register value - - DO NOT USE!!! ONLY EXPERT USER!!! - */ - virtual uint32_t readRegister(uint32_t addr)=0; - - - /** - sets a bit in a register - \param addr address - \param n nth bit ranging from 0 to 31 - \returns current register value - - DO NOT USE!!! ONLY EXPERT USER!!! - */ - virtual uint32_t setBit(uint32_t addr, int n)=0; - - - /** - clear a bit in a register - \param addr address - \param n nth bit ranging from 0 to 31 - \returns current register value - - DO NOT USE!!! ONLY EXPERT USER!!! - */ - virtual uint32_t clearBit(uint32_t addr, int n)=0; - - - /** - Returns the IP of the last client connecting to the detector - */ - virtual std::string getLastClientIP()=0; - - - - /** - configures mac for gotthard readout - \returns OK or FAIL - */ - - virtual int configureMAC()=0; - - - /** loads the modules settings/trimbits reading from a file - \param fname file name . If not specified, extension is automatically generated! - \param imod module number, -1 means all modules - \returns OK or FAIL - */ - virtual int loadSettingsFile(std::string fname, int imod=-1)=0; - - /** programs FPGA with pof file - \param fname file name - \returns OK or FAIL - */ - virtual int programFPGA(std::string fname)=0; - - /** resets FPGA - \returns OK or FAIL - */ - virtual int resetFPGA()=0; - - /** power on/off the chip - \param ival on is 1, off is 0, -1 to get - \returns OK or FAIL - */ - virtual int powerChip(int ival= -1)=0; - - /** automatic comparator disable for Jungfrau only - \param ival on is 1, off is 0, -1 to get - \returns OK or FAIL - */ - virtual int setAutoComparatorDisableMode(int ival= -1)=0; - - /** saves the modules settings/trimbits writing to a file - \param fname file name . Axtension is automatically generated! - \param imod module number, -1 means all modules - \returns OK or FAIL - */ - virtual int saveSettingsFile(std::string fname, int imod=-1)=0; - - /** sets all the trimbits to a particular value - \param val trimbit value - \param imod module number, -1 means all modules - \returns OK or FAIL - */ - virtual int setAllTrimbits(int val, int imod=-1)=0; - - - - - /** - set dacs value - \param val value (in V) - \param index DAC index - \param mV 0 in dac units or 1 in mV - \param imod module number (if -1 alla modules) - \returns current DAC value - */ - virtual dacs_t setDAC(dacs_t val, dacIndex index , int mV, int imod=-1)=0; - - - /** - gets ADC value - \param index ADC index - \param imod module number - \returns current ADC value - */ - virtual dacs_t getADC(dacIndex index, int imod=-1)=0; - - /** - set/gets threshold temperature (Jungfrau only) - \param val value in millidegrees, -1 gets - \param imod module number, -1 is all - \returns threshold temperature in millidegrees - */ - virtual int setThresholdTemperature(int val=-1, int imod=-1)=0; - - /** - enables/disables temperature control (Jungfrau only) - \param val value, -1 gets - \param imod module number, -1 is all - \returns temperature control enable - */ - virtual int setTemperatureControl(int val=-1, int imod=-1)=0; - - /** - Resets/ gets over-temperature event (Jungfrau only) - \param val value, -1 gets - \param imod module number, -1 is all - \returns over-temperature event - */ - virtual int setTemperatureEvent(int val=-1, int imod=-1)=0; - - /** - get the maximum size of the detector - \param d dimension - \returns maximum number of modules that can be installed in direction d - */ - virtual int getMaxNumberOfModules(dimension d=X)=0; - - double moveDetector(double pos){if (go_to_position) go_to_position (pos,GTarg); else cout << "no move detector callback registered" << endl; return getDetectorPosition();}; - double getDetectorPosition(){double pos=-1; if (get_position) pos=get_position(POarg); else cout << "no get position callback registered" << endl; return pos;}; - - /** - Writes the configuration file -- will contain all the informations needed for the configuration (e.g. for a PSI detector caldir, settingsdir, angconv, badchannels etc.) - \param fname file name - \returns OK or FAIL - */ - virtual int writeConfigurationFile(std::string const fname)=0; - - - void registerGetPositionCallback( double (*func)(void*),void *arg){get_position=func; POarg=arg;}; - void registerConnectChannelsCallback( int (*func)(void*),void *arg){connect_channels=func; CCarg=arg;}; - void registerDisconnectChannelsCallback(int (*func)(void*),void*arg){disconnect_channels=func;DCarg=arg;}; - - void registerGoToPositionCallback( int (*func)(double, void*),void *arg){go_to_position=func;GTarg=arg;}; - void registerGoToPositionNoWaitCallback(int (*func)(double, void*),void*arg){go_to_position_no_wait=func;GTNarg=arg;}; - void registerGetI0Callback( double (*func)(int, void*),void *arg){get_i0=func;IOarg=arg;}; - - void registerAcquisitionFinishedCallback(int( *func)(double,int, void*), void *pArg){acquisition_finished=func; acqFinished_p=pArg;}; - void registerMeasurementFinishedCallback(int( *func)(int,int, void*), void *pArg){measurement_finished=func; measFinished_p=pArg;}; - - void registerProgressCallback(int( *func)(double,void*), void *pArg){progress_call=func; pProgressCallArg=pArg;}; - - - /** - Saves the detector setup to file - \param fname file to write to - \param level if 2 reads also trimbits, flat field, angular correction etc. and writes them to files with automatically added extension - \returns OK or FAIL - - */ - int dumpDetectorSetup(std::string const fname, int level=0); - - - /** - Loads the detector setup from file - \param fname file to read from - \param level if 2 reads also reads trimbits, angular conversion coefficients etc. from files with default extensions as generated by dumpDetectorSetup - \returns OK or FAIL - - */ - int retrieveDetectorSetup(std::string const fname, int level=0); - - static int dummyAcquisitionFinished(double prog,int status,void* p){cout <<"Acquisition finished callback! " << prog << " " << status << endl; return 0;} - static int dummyMeasurementFinished(int im,int findex,void* p){cout <<"Measurement finished callback! " << im << " " << findex << endl; return 0;} - - - - - //receiver - - - /** - Checks if the receiver is really online - */ - virtual std::string checkReceiverOnline()=0; - - /** - Returns the IP of the last client connecting to the receiver - */ - virtual std::string getReceiverLastClientIP()=0; - - - /** - Sets up the file directory - @param fileName fileDir file directory - \returns file dir - */ - virtual std::string setFilePath(std::string s="")=0; - - /** - Sets up the file name - @param fileName file name - \returns file name - */ - virtual std::string setFileName(std::string s="")=0; - - /** - Sets the max frames per file in receiver - @param f max frames per file - \returns max frames per file in receiver - */ - virtual int setReceiverFramesPerFile(int f = -1) = 0; - - /** - Sets the frames discard policy in receiver - @param f frames discard policy - \returns frames discard policy set in receiver - */ - virtual frameDiscardPolicy setReceiverFramesDiscardPolicy(frameDiscardPolicy f = GET_FRAME_DISCARD_POLICY) = 0; - - /** - Sets the partial frames padding enable in receiver - @param f partial frames padding enable - \returns partial frames padding enable in receiver - */ - virtual int setReceiverPartialFramesPadding(int f = -1) = 0; - - /** - Sets up the file format - @param f file format - \returns file format - */ - virtual fileFormat setFileFormat(fileFormat f=GET_FILE_FORMAT)=0; - - /** - \returns file dir - */ - virtual std::string getFilePath()=0; - - /** - \returns file name - */ - virtual std::string getFileName()=0; - - /** - \returns file name - */ - virtual fileFormat getFileFormat()=0; - - /** - \returns frames caught by receiver - */ - virtual int getFramesCaughtByReceiver()=0; - - /** gets the number of frames caught by any one receiver (to avoid using threadpool) - \returns number of frames caught by any one receiver (master receiver if exists) - */ - virtual int getFramesCaughtByAnyReceiver()=0; - - /** - \returns current frame index of receiver - */ -virtual int getReceiverCurrentFrameIndex()=0; - -/** - * resets framescaught - * @param index frames caught by receiver -*/ -virtual int resetFramesCaught()=0; - -/** - * Create Receiving Data Sockets - * @param destroy is true to destroy all the sockets - * @return OK or FAIL - */ -virtual int createReceivingDataSockets(const bool destroy = false){return -1;}; - - -/** Reads frames from receiver through a constant socket -*/ - -virtual void readFrameFromReceiver(){}; - -/** - Turns off the receiver server! -*/ -virtual int exitReceiver()=0; - -/** - Sets/Gets file overwrite enable - @param enable 1 or 0 to set/reset file overwrite enable - /returns file overwrite enable -*/ -virtual int overwriteFile(int enable=-1)=0; - - -/** - Sets/Gets receiver file write enable - @param enable 1 or 0 to set/reset file write enable - /returns file write enable -*/ -virtual int enableWriteToFile(int enable=-1)=0; - -/** Starts acquisition, calibrates pedestal and writes to fpga - /returns number of frames -*/ -virtual int calibratePedestal(int frames = 0)=0; - - -/** - set roi - \param n number of rois - \param roiLimits array of roi - \param imod module number (-1 for all) - \returns success or failure -*/ -virtual int setROI(int n=-1,ROI roiLimits[]=NULL, int imod = -1)=0; - -/** - get roi from each detector and convert it to the multi detector scale - \param n number of rois - \param imod module number (-1 for all) - \returns pointer to array of ROI structure -*/ -virtual ROI* getROI(int &n, int imod = -1)=0; - -/** Sets the read receiver frequency - if data required from receiver randomly readRxrFrequency=0, - else every nth frame to be sent to gui - @param freq is the receiver read frequency - /returns read receiver frequency - */ -virtual int setReadReceiverFrequency(int freq=-1)=0; - -/** - * Enable data streaming to client - * @param enable 0 to disable, 1 to enable, -1 to get the value - * @returns data streaming to client enable - */ -virtual int enableDataStreamingToClient(int enable=-1)=0; - -/** Enable or disable streaming data from receiver to client - * @param enable 0 to disable 1 to enable -1 to only get the value - * @returns data streaming from receiver enable -*/ -virtual int enableDataStreamingFromReceiver(int enable=-1)=0; - - -/** enable/disable or get data compression in receiver - * @param i is -1 to get, 0 to disable and 1 to enable - /returns data compression in receiver - */ -virtual int enableReceiverCompression(int i = -1)=0; - -/** enable/disable or 10Gbe - * @param i is -1 to get, 0 to disable and 1 to enable - /returns if 10Gbe is enabled - */ -virtual int enableTenGigabitEthernet(int i = -1)=0; - -/** set/get receiver fifo depth - * @param i is -1 to get, any other value to set the fifo deph - /returns the receiver fifo depth - */ -virtual int setReceiverFifoDepth(int i = -1)=0; - -/** set/get receiver silent mode - * @param i is -1 to get, 0 unsets silent mode, 1 sets silent mode - /returns the receiver silent mode enable - */ -virtual int setReceiverSilentMode(int i = -1)=0; - - /******** CTB funcs */ - - /** opens pattern file and sends pattern to CTB - @param fname pattern file to open - @returns OK/FAIL - */ - virtual int setCTBPattern(std::string fname)=0; - - - /** Writes a pattern word to the CTB - @param addr address of the word, -1 is I/O control register, -2 is clk control register - @param word 64bit word to be written, -1 gets - @returns actual value - */ - virtual uint64_t setCTBWord(int addr,uint64_t word=-1)=0; - - /** Sets the pattern or loop limits in the CTB - @param level -1 complete pattern, 0,1,2, loop level - @param start start address if >=0 - @param stop stop address if >=0 - @param n number of loops (if level >=0) - @returns OK/FAIL - */ - virtual int setCTBPatLoops(int level,int &start, int &stop, int &n)=0; - - - /** Sets the wait address in the CTB - @param level 0,1,2, wait level - @param addr wait address, -1 gets - @returns actual value - */ - virtual int setCTBPatWaitAddr(int level, int addr=-1)=0; - - /** Sets the wait time in the CTB - @param level 0,1,2, wait level - @param t wait time, -1 gets - @returns actual value - */ - virtual int setCTBPatWaitTime(int level, uint64_t t=-1)=0; - - /** - Pulse Pixel - \param n is number of times to pulse - \param x is x coordinate - \param y is y coordinate - \returns OK or FAIL - */ - virtual int pulsePixel(int n=0,int x=0,int y=0)=0; - - /** - Pulse Pixel and move by a relative value - \param n is number of times to pulse - \param x is relative x value - \param y is relative y value - \returns OK or FAIL - */ - virtual int pulsePixelNMove(int n=0,int x=0,int y=0)=0; - - /** - Pulse Chip - \param n is number of times to pulse - \returns OK or FAIL - */ - virtual int pulseChip(int n=0)=0; - - /** - Set acquiring flag in shared memory - \param b acquiring flag - */ - virtual void setAcquiringFlag(bool b=false)=0; - - /** - Get acquiring flag from shared memory - \returns acquiring flag - */ - virtual bool getAcquiringFlag() = 0; - - - /** - * Check if acquiring flag is set, set error if set - * \returns FAIL if not ready, OK if ready - */ - virtual bool isAcquireReady() = 0; - - - /** - * Check version compatibility with detector/receiver software - * (if hostname/rx_hostname has been set/ sockets created) - * \param p port type control port or data (receiver) port - * \returns FAIL for incompatibility, OK for compatibility - */ - virtual int checkVersionCompatibility(portType t) = 0; - - protected: - - - static const int64_t thisSoftwareVersion=0x20141013; - - - - //protected: - int *stoppedFlag; - int64_t *timerValue; - detectorSettings *currentSettings; - int *currentThresholdEV; - - - int totalProgress; - - int progressIndex; - - double (*get_position)(void*); - int (*go_to_position)(double, void*); - int (*go_to_position_no_wait)(double, void*); - int (*connect_channels)(void*); - int (*disconnect_channels)(void*); - double (*get_i0)(int, void*); - void *POarg,*CCarg,*DCarg,*GTarg,*GTNarg,*IOarg; - int (*acquisition_finished)(double,int,void*); - int (*measurement_finished)(int,int,void*); - void *acqFinished_p, *measFinished_p; - int (*progress_call)(double,void*); - void *pProgressCallArg; - - /** semaphore to let postprocessing thread continue for next scan/measurement */ - sem_t sem_newRTAcquisition; - /** semaphore to let main thread know it got all the dummy packets (also from ext. process) */ - sem_t sem_endRTAcquisition; - - -}; - - - -#endif diff --git a/slsDetectorSoftware/slsDetectorAnalysis/AngularConversion_Standalone.cpp b/slsDetectorSoftware/slsDetectorAnalysis/AngularConversion_Standalone.cpp deleted file mode 100644 index 36f40e2bd..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/AngularConversion_Standalone.cpp +++ /dev/null @@ -1,527 +0,0 @@ -#include "AngularConversion_Standalone.h" - -#include -#include -#include -#include -#include "usersFunctions.h" - -using namespace std; - -angularConversion::angularConversion( int *np, double *pos, double *bs, double *fo, double *go): currentPosition(0), - currentPositionIndex(0), - numberOfPositions(np), - detPositions(pos), - binSize(bs), - fineOffset(fo), - globalOffset(go) - -{ - //angleFunctionPointer=0; - registerAngleFunctionCallback(&defaultAngleFunction,NULL); - registerCallBackGetChansPerMod(&defaultGetChansPerMod,this); - registerCallBackGetNumberofChannel(&defaultGetNumberofChannel,this); -} - -angularConversion::~angularConversion(){ - -} - -// int angularConversion::setAngularConversionPointer(angleConversionConstant *p, int *nm, int nch, int idet) { -// if (p) { -// angOff[idet]=p; -// nMods[idet]=nm; -// nCh[idet]=nch; -// } else { -// angOff[idet]=NULL; -// nMods[idet]=NULL; -// } - -// return OK; -// } - - - - -double* angularConversion::convertAngles(double pos) { - int imod=0; - double *ang=new double[totalNumberOfChannels]; - double enc=pos; - angleConversionConstant *p=NULL; - - int ch0=0; - int chlast=getChansPerMods(imod); - int nchmod=getChansPerMods(imod); - p=angConvs+imod; - if (moveFlag[imod]==0) - enc=0; - else - enc=pos; - - for (int ip=0; ip=chlast) { - imod++; - p=angConvs+imod; - if (moveFlag[imod]==0) - enc=0; - else - enc=pos; - - ch0=chlast; - nchmod=getChansPerMods(imod); - if (nchmod>0) - chlast+=nchmod; - } - - if (p) - ang[ip]=angle(ip-ch0, \ - enc, \ - (*fineOffset)+(*globalOffset), \ - p->r_conversion, \ - p->center, \ - p->offset, \ - p->tilt, \ - *angDirection ); - } - return ang; -} - - - -//static! -int angularConversion::readAngularConversion(string fname, int nmod, angleConversionConstant *angOff) { - - ifstream infile; - string ss; - -#ifdef VERBOSE - std::cout<< "Opening file "<< fname << std::endl; -#endif - infile.open(fname.c_str(), ios_base::in); - if (infile.is_open()) { - readAngularConversion(infile, nmod, angOff); - infile.close(); - } else { - std::cout<< "Could not open calibration file "<< fname << std::endl; - return -1; - } - return 0; -} - - -//static -int angularConversion::readAngularConversion( ifstream& infile, int nmod, angleConversionConstant *angOff) { - string str; - int mod; - double center, ecenter; - double r_conv, er_conv; - double off, eoff; - string ss; - int interrupt=0; - int nm=0; - //" module %i center %E +- %E conversion %E +- %E offset %f +- %f \n" - while (infile.good() and interrupt==0) { - getline(infile,str); -#ifdef VERBOSE - cout << "** mod " << nm << " " ; - std::cout<< str << std::endl; -#endif - istringstream ssstr(str); - ssstr >> ss >> mod; - ssstr >> ss >> center; - ssstr >> ss >> ecenter; - ssstr >> ss >> r_conv; - ssstr >> ss >> er_conv; - ssstr >> ss >> off; - ssstr >> ss >> eoff; - if (nm=0 ) { - angOff[nm].center=center; - angOff[nm].r_conversion=r_conv; - angOff[nm].offset=off; - angOff[nm].ecenter=ecenter; - angOff[nm].er_conversion=er_conv; - angOff[nm].eoffset=eoff; - } else - break; - //cout << nm<<" " << angOff[nm].offset << endl; - nm++; - if (nm>=nmod) - break; - - } - return nm; - } - -//static -int angularConversion:: writeAngularConversion(string fname, int nmod, angleConversionConstant *angOff) { - - ofstream outfile; - outfile.open (fname.c_str(),ios_base::out); - if (outfile.is_open()) - { - writeAngularConversion(outfile, nmod, angOff); - outfile.close(); - } else { - std::cout<< "Could not open file " << fname << "for writing"<< std::endl; - return -1; - } - //" module %i center %E +- %E conversion %E +- %E offset %f +- %f \n" - return 0; -} - - - -//static -int angularConversion:: writeAngularConversion(ofstream& outfile, int nmod, angleConversionConstant *angOff) { - - for (int imod=0; imod0) { - -#ifdef VERBOSE - cout << "finalize " << ibin << " "<< mm[ibin] << " " << mp[ibin]<< mv[ibin] << me[ibin] << endl; -#endif - mp[np]=mp[ibin]/mm[ibin]; - mv[np]=mv[ibin]/mm[ibin]; - me[np]=me[ibin]/mm[ibin]; - me[np]=sqrt(me[ibin]); - mm[np]=mm[ibin]; - np++; - } - } - return np; -} - -//static -int angularConversion::addToMerging(double *p1, double *v1, double *e1, double *mp, double *mv,double *me, int *mm, int nchans, double binsize,int nbins, int *badChanMask ) { - - - double binmi=-180.; - int ibin=0; - - if (p1==NULL) - return 0; - if (v1==NULL) - return FAIL; - - if (mp==NULL) //can be changed if we want to use a fixed bin algorithm! - return FAIL; - - if (mv==NULL) - return FAIL; - if (me==NULL) - return FAIL; - if (mm==NULL) - return FAIL; - if (nchans==0) - return FAIL; - - if (binsize<=0) - return FAIL; - - if (nbins<=0) - return FAIL; - - for (int ip=0; ip=0) { - mp[ibin]+=p1[ip]; - mv[ibin]+=v1[ip]; - if (e1) - me[ibin]+=(e1[ip]*e1[ip]); - else - me[ibin]+=v1[ip]; - mm[ibin]++; - -#ifdef VERBOSE - cout << "add " << ibin << " "<< mm[ibin] << " " << mp[ibin]<< mv[ibin] << me[ibin] << endl; -#endif - } else - return FAIL; - } - - - return OK; - -} - -int angularConversion::deleteMerging() { - - if (mergingBins) - delete [] mergingBins; - - if (mergingCounts) - delete [] mergingCounts; - - if (mergingErrors) - delete [] mergingErrors; - -} - - -int angularConversion::resetMerging() { - getAngularConversionParameter(BIN_SIZE); - - mergingBins=new double[nBins]; - - - mergingCounts=new double[nBins]; - - - mergingErrors=new double[nBins]; - - - mergingMultiplicity=new int[nBins]; - - return resetMerging(mergingBins, mergingCounts, mergingErrors, mergingMultiplicity); - -} - -int angularConversion::resetMerging(double *mp, double *mv, double *me, int *mm) { - getAngularConversionParameter(BIN_SIZE); - if (nBins) - return resetMerging(mp, mv, me, mm,nBins); - else - return FAIL; -} - - - - -int angularConversion::finalizeMerging() { - int np=finalizeMerging(mergingBins, mergingCounts, mergingErrors, mergingMultiplicity); - - if (mergingMultiplicity) - delete [] mergingMultiplicity; - - return np; - -} - - - - -int angularConversion::finalizeMerging(double *mp, double *mv, double *me, int *mm) { - if (nBins) - return finalizeMerging(mp, mv, me, mm, nBins); - else - return FAIL; -} - -int angularConversion::addToMerging(double *p1, double *v1, double *e1, int *badChanMask ) { - - return addToMerging(p1,v1,e1,mergingBins,mergingCounts, mergingErrors, mergingMultiplicity, badChanMask); - - -} - - -int angularConversion::addToMerging(double *p1, double *v1, double *e1, double *mp, double *mv,double *me, int *mm, int *badChanMask ) { - - int del=0; - - if (getAngularConversionParameter(BIN_SIZE)==0){ - cout << "no bin size " << endl; - return FAIL; - } - - if (nBins==0) { - cout << "no bins " << endl; - return FAIL; - } - - if (p1==NULL) { - del=1; - p1=convertAngles(); - } - - - int ret=addToMerging(p1, v1, e1, mp, mv,me, mm,getTotalNumberofChannels(), *binSize,nBins, badChanMask ); - - - if (del) { - delete [] p1; - p1=NULL; - } - return ret; -} - - - - /** - sets the value of s angular conversion parameter - \param c can be ANGULAR_DIRECTION, GLOBAL_OFFSET, FINE_OFFSET, BIN_SIZE - \param v the value to be set - \returns the actual value - */ - -double angularConversion::setAngularConversionParameter(angleConversionParameter c, double v){ - - - switch (c) { - case ANGULAR_DIRECTION: - if (v<0) - *angDirection=-1; - else - *angDirection=1; - return *angDirection; - case GLOBAL_OFFSET: - *globalOffset=v; - return *globalOffset; - case FINE_OFFSET: - *fineOffset=v; - return *fineOffset; - case BIN_SIZE: - if (v>0) { - *binSize=v; - nBins=360./(*binSize); - } - return *binSize; - case MOVE_FLAG: - if (moveFlag) { - if (v>0) - *moveFlag=1; - else if (v==0) - *moveFlag=0; - return *moveFlag; - } - return -1; - default: - return 0; - } -} - - /** - returns the value of an angular conversion parameter - \param c can be ANGULAR_DIRECTION, GLOBAL_OFFSET, FINE_OFFSET, BIN_SIZE - \returns the actual value - - */ - -double angularConversion::getAngularConversionParameter(angleConversionParameter c) { - - switch (c) { - case ANGULAR_DIRECTION: - return *angDirection; - case GLOBAL_OFFSET: - return *globalOffset; - case FINE_OFFSET: - return *fineOffset; - case BIN_SIZE: - if (*binSize>0) - nBins=360./(*binSize); - else - nBins=0; - return *binSize; - case MOVE_FLAG: - if (moveFlag) - return *moveFlag; - else - return -1; - default: - return 0; - } -} - - - -/** -int angularConversion::setAngularConversionFile(string fname) { - if (fname=="") { - setAngularCorrectionMask(0); -#ifdef VERBOSE - std::cout << "Unsetting angular conversion" << std::endl; -#endif - } else { - if (fname=="default") { - fname=string(angConvFile); - } - -#ifdef VERBOSE - std::cout << "Setting angular conversion to " << fname << std:: endl; -#endif - if (readAngularConversionFile(fname)>=0) { - setAngularCorrectionMask(1); - strcpy(angConvFile,fname.c_str()); - } - } - return setAngularCorrectionMask(); -} - - -*/ - - - /* - set positions for the acquisition - \param nPos number of positions - \param pos array with the encoder positions - \returns number of positions - */ -int angularConversion::setPositions(int nPos, double *pos){ - if (nPos>=0) - *numberOfPositions=nPos; - for (int ip=0; ip -#include - - - - //double angle(int ichan, double encoder, double totalOffset, double conv_r, double center, double offset, double tilt, int direction) - - -using namespace std; - -/** - @short Angular conversion constants needed for a detector module - */ -typedef struct { - double center; /**< center of the module (channel at which the radius is perpendicular to the module surface) */ - double ecenter; /**< error in the center determination */ - double r_conversion; /**< detector pixel size (or strip pitch) divided by the diffractometer radius */ - double er_conversion; /**< error in the r_conversion determination */ - double offset; /**< the module offset i.e. the position of channel 0 with respect to the diffractometer 0 */ - double eoffset; /**< error in the offset determination */ - double tilt; /**< ossible tilt in the orthogonal direction (unused)*/ - double etilt; /**< error in the tilt determination */ -} angleConversionConstant; - - -/** - -@short methods to set/unset the angular conversion and merge the data -class containing the methods to set/unset the angular conversion and merge the data - - -The angular conversion itself is defined by the angle() function defined in usersFunctions.cpp - -*/ -class angularConversion : public virtual slsDetectorDefs { //: public virtual slsDetectorBase { - - public: - /** default constructor */ - angularConversion(int*, double*, double*, double*, double*); - /** virtual destructor */ - virtual ~angularConversion(); - - - - //virtual int readAngularConversion(string fname)=0; - - - - - /** - - reads an angular conversion file - \param fname file to be read - \param nmod number of modules (maximum) to be read - \param angOff pointer to array of angleConversionConstants - \returns OK or FAIL - */ - static int readAngularConversion(string fname, int nmod, angleConversionConstant *angOff); - - /** - reads an angular conversion file - \param ifstream input file stream to be read - \param nmod number of modules (maximum) to be read - \param angOff pointer to array of angleConversionConstants - \returns OK or FAIL - - */ - static int readAngularConversion(ifstream& ifs, int nmod, angleConversionConstant *angOff); - /** - writes an angular conversion file - \param fname file to be written - \param nmod number of modules to be written - \param angOff pointer to array of angleConversionConstants - \returns OK or FAIL - */ - static int writeAngularConversion(string fname, int nmod, angleConversionConstant *angOff); - - /** - writes an angular conversion file - \param ofstream output file stream - \param nmod number of modules to be written - \param angOff pointer to array of angleConversionConstants - \returns OK or FAIL - */ - static int writeAngularConversion(ofstream& ofs, int nmod, angleConversionConstant *angOff); - - /** - sets the arrays of the merged data to 0. NB The array should be created with size nbins >= 360./getBinSize(); - \param mp already merged postions - \param mv already merged data - \param me already merged errors (squared sum) - \param mm multiplicity of merged arrays - \param nbins number of bins - \returns OK or FAIL - */ - static int resetMerging(double *mp, double *mv,double *me, int *mm, int nbins); - /** - sets the arrays of the merged data to 0. NB The array should be created with size >= 360./getBinSize(); - \param mp already merged postions - \param mv already merged data - \param me already merged errors (squared sum) - \param mm multiplicity of merged arrays - \returns OK or FAIL - */ - int resetMerging(double *mp, double *mv,double *me, int *mm); - - /** - creates the arrays for merging the data and sets them to 0. - */ - int resetMerging(); - - /** - merge dataset - \param p1 angular positions of dataset - \param v1 data - \param e1 errors - \param mp already merged postions - \param mv already merged data - \param me already merged errors (squared sum) - \param mm multiplicity of merged arrays - \param nchans number of channels - \param binsize size of angular bin - \param nb number of angular bins - \param badChanMask badchannelmask (if NULL does not correct for bad channels) - \returns OK or FAIL - */ - - static int addToMerging(double *p1, double *v1, double *e1, double *mp, double *mv,double *me, int *mm, int nchans, double binsize,int nb, int *badChanMask ); - - /** - merge dataset - \param p1 angular positions of dataset - \param v1 data - \param e1 errors - \param mp already merged postions - \param mv already merged data - \param me already merged errors (squared sum) - \param mm multiplicity of merged arrays - \param badChanMask badchannelmask (if NULL does not correct for bad channels) - \returns OK or FAIL - */ - - int addToMerging(double *p1, double *v1, double *e1, double *mp, double *mv,double *me, int *mm, int *badChanMask); - /** - merge dataset - \param p1 angular positions of dataset - \param v1 data - \param e1 errors - \param badChanMask badchannelmask (if NULL does not correct for bad channels) - \returns OK or FAIL - */ - - int addToMerging(double *p1, double *v1, double *e1,int *badChanMask); - - /** - calculates the "final" positions, data value and errors for the merged data - \param mp already merged postions - \param mv already merged data - \param me already merged errors (squared sum) - \param mm multiplicity of merged arrays - \param nb number of bins - \returns FAIL or the number of non empty bins (i.e. points belonging to the pattern) - */ - - static int finalizeMerging(double *mp, double *mv,double *me, int *mm, int nb); - /** - calculates the "final" positions, data value and errors for the merged data - \param mp already merged postions - \param mv already merged data - \param me already merged errors (squared sum) - \param mm multiplicity of merged arrays - \returns FAIL or the number of non empty bins (i.e. points belonging to the pattern) - */ - - int finalizeMerging(double *mp, double *mv,double *me, int *mm); - -/** - calculates the "final" positions, data value and errors for the merged data - \returns FAIL or the number of non empty bins (i.e. points belonging to the pattern) - */ - - int finalizeMerging(); - - - /** - set detector global offset - \param f global offset to be set - \returns actual global offset - */ - double setGlobalOffset(double f){return setAngularConversionParameter(GLOBAL_OFFSET,f);}; - - - /** - set detector fine offset - \param f global fine to be set - \returns actual fine offset - */ - double setFineOffset(double f){return setAngularConversionParameter(FINE_OFFSET,f);}; - - /** - get detector fine offset - \returns actual fine offset - */ - double getFineOffset(){return getAngularConversionParameter(FINE_OFFSET);}; - - /** - get detector global offset - \returns actual global offset - */ - double getGlobalOffset(){return getAngularConversionParameter(GLOBAL_OFFSET);}; - - /** - - set detector bin size - \param bs bin size to be set - \returns actual bin size - */ - double setBinSize(double bs){if (bs>0) nBins=360/bs; return setAngularConversionParameter(BIN_SIZE,bs);}; - - /** - get detector bin size - \returns detector bin size used for merging (approx angular resolution) - */ - double getBinSize() {return getAngularConversionParameter(BIN_SIZE);}; - - - - /** - - get angular direction - \returns actual angular direction (1 is channel number increasing with angle, -1 decreasing) - */ - int getAngularDirection(){return (int)getAngularConversionParameter(ANGULAR_DIRECTION);}; - - - /** - - set angular direction - \param d angular direction to be set (1 is channel number increasing with angle, -1 decreasing) - \returns actual angular direction (1 is channel number increasing with angle, -1 decreasing) - */ - int setAngularDirection(int d){return (int)setAngularConversionParameter(ANGULAR_DIRECTION, (double)d);}; - - /** - \returns number of angular bins in the merging (360./binsize) - */ - int getNumberOfAngularBins(){return nBins;}; - - - - /** - set angular conversion parameter - \param c parameter type (globaloffset, fineoffset, binsize, angular direction, move flag) - \param v value to be set - \returns actual value - */ - double setAngularConversionParameter(angleConversionParameter c, double v); - /** - get angular conversion parameter - \param c parameter type (globaloffset, fineoffset, binsize, angular direction, move flag) - \returns actual value - */ - double getAngularConversionParameter(angleConversionParameter c); - - - - - /** - set positions for the acquisition - \param nPos number of positions - \param pos array with the encoder positions - \returns number of positions - */ - virtual int setPositions(int nPos, double *pos); - /** - get positions for the acquisition - \param pos array which will contain the encoder positions - \returns number of positions - */ - virtual int getPositions(double *pos=NULL); - - /** - deletes the array of merged data - \returns OK - */ - int deleteMerging(); - - /** - \returns pointer to the array o merged positions - */ - double *getMergedPositions(){return mergingBins;}; - /** - \returns pointer to the array of merged counts - */ - double *getMergedCounts(){return mergingCounts;}; - /** - \returns pointer to the array of merged errors - */ - double *getMergedErrors(){return mergingErrors;}; - - - - -/* /\** */ -/* reads teh angular conversion file for the (multi)detector and writes it to shared memory */ -/* *\/ */ -/* virtual int readAngularConversionFile(string fname="")=0; */ - -/* /\** */ -/* get angular conversion */ -/* \param direction reference to diffractometer direction */ -/* \param angconv array that will be filled with the angular conversion constants */ -/* \returns 0 if angular conversion disabled, >0 otherwise */ -/* *\/ */ - virtual int getAngularConversion(int &direction, angleConversionConstant *angoff=NULL); - -/* /\** */ -/* pure virtual function */ -/* \param file name to be written (nmod and array of angular conversion constants default to the ones ot the slsDetector */ -/* *\/ */ -/* virtual int writeAngularConversion(string fname)=0; */ - - - - -/* /\** */ -/* \returns number of modules of the (multi)detector */ -/* *\/ */ -/* virtual int getNMods()=0; */ - -/* /\** */ -/* returns number of channels in the module */ -/* \param imod module number */ -/* \returns number of channels in the module */ -/* *\/ */ - - - static int defaultGetNumberofChannel(int nch, void *p=NULL ) { ((angularConversion*)p)->setTotalNumberOfChannels(nch); return 0;}; - static int defaultGetChansPerMod(int imod=0, void *p=NULL){ ((angularConversion*)p)->setChansPerMod(0,imod); return 0;}; - - int setChansPerMod(int nch, int imod=0){if (nch<0) return -1; if (imod>=0 && imod=0){ totalNumberOfChannels=i; return totalNumberOfChannels;} else return -1;}; - - -/* /\** */ -/* get the angular conversion contant of one modules */ -/* \param imod module number */ -/* \returns pointer to the angular conversion constant */ -/* *\/ */ -/* virtual angleConversionConstant *getAngularConversionPointer(int imod=0)=0; */ -/* /\** */ -/* \param imod module number */ -/* \returns move flag of the module (1 encoder is added to the angle, 0 not) */ -/* *\/ */ -/* virtual int getMoveFlag(int imod)=0; */ - -/* /\** */ -/* enables/disable the angular conversion */ -/* \param i 1 sets, 0 unsets,, -1 gets */ -/* \returns actual angular conversion flag */ -/* *\/ */ -/* virtual int setAngularCorrectionMask(int i=-1)=0; */ - - - - /** - converts channel number to angle - \param pos encoder position - \returns array of angles corresponding to the channels - */ - double* convertAngles(double pos); - /** - converts channel number to angle for the current encoder position - \returns array of angles corresponding to the channels - */ - double *convertAngles(){return convertAngles(currentPosition);}; - - - /** - returns number of positions - */ - int getNumberOfPositions() {return *numberOfPositions;}; - - int getChansPerMods(int imod) { return chansPerMod[imod];}; - int getTotalNumberofChannels(){ return totalNumberOfChannels;}; - - - void incrementPositionIndex() {currentPositionIndex++;}; - - void registerCallBackGetChansPerMod(int (*func)(int, void *),void *arg){ getChansPerModule=func;pChpermod=arg;}; - void registerCallBackGetNumberofChannel(int (*func)(int, void *),void *arg){ getNumberofChannel=func;pNumberofChannel=arg;}; - - protected: - - - - private: - - - int (*getChansPerModule)(int, void*); - int (*getNumberofChannel)(int, void*); - - void *pChpermod,*angPtr,*pNumberofChannel; - - - /** merging bins */ - double *mergingBins; - - /** merging counts */ - double *mergingCounts; - - /** merging errors */ - double *mergingErrors; - - /** merging multiplicity */ - int *mergingMultiplicity; - - double (*angle)(double, double, double, double, double, double, double, int); - - - - int totalNumberOfChannels; - - int moveFlag[MAXMODS*MAXDET]; - - /** pointer to number of positions for the acquisition*/ - int *numberOfPositions; - - /** pointer to the detector positions for the acquisition*/ - double *detPositions; - - - /** pointer to angular bin size*/ - double *binSize; - - int *correctionMask; - int chansPerMod[MAXMODS*MAXDET]; - int nMod; - angleConversionConstant angConvs[MAXMODS*MAXDET]; - int directions[MAXMODS*MAXDET]; - - - /** pointer to beamline fine offset*/ - double *fineOffset; - /** pointer to beamline global offset*/ - double *globalOffset; - /** pointer to beamline angular direction*/ - int *angDirection; - - /** pointer to detector move flag (1 moves with encoder, 0 not)*/ - // int *moveFlag; - - /** number of bins for angular conversion (360./binsize)*/ - int nBins; - - - - /** - current position of the detector - */ - double currentPosition; - /** - current position index of the detector - */ - int currentPositionIndex; - - - /** - returns current position index - */ - int getCurrentPositionIndex() {return currentPositionIndex;}; - - - - - - void registerAngleFunctionCallback(double( *fun)(double, double, double, double, double, double, double, int),void* arg) {angle = fun; angPtr=arg;}; - - -}; - -#endif diff --git a/slsDetectorSoftware/slsDetectorAnalysis/FileIO_Standalone.cpp b/slsDetectorSoftware/slsDetectorAnalysis/FileIO_Standalone.cpp deleted file mode 100644 index 27bee95b3..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/FileIO_Standalone.cpp +++ /dev/null @@ -1,650 +0,0 @@ -#include "FileIO_Standalone.h" - - - - - -string fileIO::createFileName(char *filepath, char *filename, int aMask, double sv0, int prec0, double sv1, int prec1, int pindex, int npos, int findex) { - ostringstream osfn; - // string fn; - /*directory name +root file name */ - osfn << filepath << "/" << filename; - - // cout << osfn.str() << endl; - - // scan level 0 - if ( aMask& (1 << (MAX_ACTIONS))) - osfn << "_S" << fixed << setprecision(prec0) << sv0; - - //cout << osfn.str() << endl; - - //scan level 1 - if (aMask & (1 << (MAX_ACTIONS+1))) - osfn << "_s" << fixed << setprecision(prec1) << sv1; - - //cout << osfn.str() << endl; - - - //position - if (pindex>0 && pindex<=npos) - osfn << "_p" << pindex; - - //cout << osfn.str() << endl; - - // file index - osfn << "_" << findex; - - //cout << osfn.str() << endl; - - -#ifdef VERBOSE - cout << "created file name " << osfn.str() << endl; -#endif - - //cout << osfn.str() << endl; - //fn=oosfn.str()sfn.str(); - return osfn.str(); - -} - - - /* I/O */ - -/* generates file name without extension*/ - -string fileIO::createFileName(int aMask, double sv0, int prec0, double sv1, int prec1, int pindex, int npos) { - currentFileName=createFileName(filePath, \ - fileName, \ - aMask, \ - sv0, \ - prec0, \ - sv1, \ - prec1, \ - pindex, \ - npos, \ - *fileIndex \ - ); - return currentFileName; - -} - - -int fileIO::getFileIndexFromFileName(string fname) { - int i; - size_t dot=fname.rfind("."); - if (dot==string::npos) - return -1; - size_t uscore=fname.rfind("_"); - if (uscore==string::npos) - return -1; - - if (sscanf( fname.substr(uscore+1,dot-uscore-1).c_str(),"%d",&i)) { - - return i; - } - //#ifdef VERBOSE - cout << "******************************** cannot parse file index" << endl; - //#endif - return 0; -} - -int fileIO::getVariablesFromFileName(string fname, int &index, int &p_index, double &sv0, double &sv1) { - - int i; - double f; - string s; - - - index=-1; - p_index=-1; - sv0=-1; - sv1=-1; - - - // size_t dot=fname.rfind("."); - //if (dot==string::npos) - // return -1; - size_t uscore=fname.rfind("_"); - if (uscore==string::npos) - return -1; - s=fname; - - //if (sscanf(s.substr(uscore+1,dot-uscore-1).c_str(),"%d",&i)) { - if (sscanf(s.substr(uscore+1,s.size()-uscore-1).c_str(),"%d",&i)) { - index=i; -#ifdef VERBOSE - cout << "******************************** file index is " << index << endl; -#endif - //return i; - s=fname.substr(0,uscore); - } - else - cout << "******************************** cannot parse file index" << endl; - -#ifdef VERBOSE - cout << s << endl; -#endif - - - uscore=s.rfind("_"); - - - - - if (sscanf( s.substr(uscore+1,s.size()-uscore-1).c_str(),"p%d",&i)) { - p_index=i; -#ifdef VERBOSE - cout << "******************************** position index is " << p_index << endl; -#endif - s=fname.substr(0,uscore); - } - else - cout << "******************************** cannot parse position index" << endl; - -#ifdef VERBOSE - cout << s << endl; -#endif - - - - - uscore=s.rfind("_"); - - - - - if (sscanf( s.substr(uscore+1,s.size()-uscore-1).c_str(),"s%f",&f)) { - sv1=f; -#ifdef VERBOSE - cout << "******************************** scan variable 1 is " << sv1 << endl; -#endif - s=fname.substr(0,uscore); - } - else - cout << "******************************** cannot parse scan varable 1" << endl; - -#ifdef VERBOSE - cout << s << endl; - - -#endif - - uscore=s.rfind("_"); - - - - - if (sscanf( s.substr(uscore+1,s.size()-uscore-1).c_str(),"S%f",&f)) { - sv0=f; -#ifdef VERBOSE - cout << "******************************** scan variable 0 is " << sv0 << endl; -#endif - } - else - cout << "******************************** cannot parse scan varable 0" << endl; - -#ifdef VERBOSE -#endif - - - - return index; -} - - - - - -int fileIO::writeDataFile(string fname, int nch, double *data, double *err, double *ang, char dataformat){ - - - ofstream outfile; - // int idata; - if (data==NULL) - return FAIL; - - // args|=0x10; // one line per channel! - - outfile.open (fname.c_str(),ios_base::out); - if (outfile.is_open()) - { - writeDataFile(outfile, nch, data, err, ang, dataformat, 0); - outfile.close(); - return OK; - } else { - std::cout<< "Could not open file " << fname << "for writing"<< std::endl; - return FAIL; - } -}; - - -int fileIO::writeDataFile(ofstream &outfile, int nch, double *data, double *err, double *ang, char dataformat, int offset){ - - - int idata; - if (data==NULL) - return FAIL; - - // args|=0x10; // one line per channel! - - cout << "Static file " << endl; - - - for (int ichan=0; ichan> ichan >> fdata; - //ich=ichan; - if (ssstr.fail() || ssstr.bad()) { - interrupt=1; - break; - } - // if (ich!=iline) - // std::cout<< "Channel number " << ichan << " does not match with line number " << iline << " " << dataformat << std::endl; - ich=iline; - if (ichan> fang >> fdata; - ich=iline; - } - if (ssstr.fail() || ssstr.bad()) { - interrupt=1; - break; - } - if (err) - ssstr >> ferr; - if (ssstr.fail() || ssstr.bad()) { - interrupt=1; - break; - } - if (ich=nch) { - interrupt=1; - break; - } - } - return iline; -}; - - - -int fileIO::readDataFile(string fname, int *data, int nch){ - - ifstream infile; - int iline=0;//ichan, idata, - //int interrupt=0; - string str; - -#ifdef VERBOSE - std::cout<< "Opening file "<< fname << std::endl; -#endif - infile.open(fname.c_str(), ios_base::in); - if (infile.is_open()) { - iline=readDataFile(infile, data, nch, 0); - infile.close(); - } else { - std::cout<< "Could not read file " << fname << std::endl; - return -1; - } - return iline; -}; - -int fileIO::readDataFile(ifstream &infile, int *data, int nch, int offset){ - - int ichan, idata, iline=0; - int interrupt=0; - string str; - - - while (infile.good() and interrupt==0) { - getline(infile,str); -#ifdef VERBOSE - std::cout<< str << std::endl; -#endif - istringstream ssstr(str); - ssstr >> ichan >> idata; - if (ssstr.fail() || ssstr.bad()) { - interrupt=1; - break; - } - // if (ichan!=iline) { -// std::cout<< " Expected channel "<< iline <<" but read channel "<< ichan << std::endl; -// interrupt=1; -// break; -// } else { - if (iline=offset) { - data[iline]=idata; - iline++; - } - } else { - interrupt=1; - break; - } - // } - } - return iline; -}; - - -int fileIO::readDataFile(string fname, short int *data, int nch){ - - ifstream infile; - int iline=0;//ichan, - //int interrupt=0; - string str; - -#ifdef VERBOSE - std::cout<< "Opening file "<< fname << std::endl; -#endif - infile.open(fname.c_str(), ios_base::in); - if (infile.is_open()) { - iline=readDataFile(infile, data, nch, 0); - infile.close(); - } else { - std::cout<< "Could not read file " << fname << std::endl; - return -1; - } - return iline; -}; - -int fileIO::readDataFile(ifstream &infile, short int *data, int nch, int offset){ - - int ichan, iline=0; - short int idata; - int interrupt=0; - string str; - while (infile.good() and interrupt==0) { - getline(infile,str); -#ifdef VERBOSE - ;//std::cout<< str << std::endl; -#endif - istringstream ssstr(str); - ssstr >> ichan >> idata; - if (ssstr.fail() || ssstr.bad()) { - interrupt=1; - break; - } - // if (ichan!=iline) { -// std::cout<< " Expected channel "<< iline <<" but read channel "<< ichan << std::endl; -// interrupt=1; -// break; -// } else { - if (iline=offset) { - data[iline]=idata; - iline++; - } - } else { - interrupt=1; - break; - } - // } -#ifdef VERBOSE - ;//std::cout<< "read " << iline <<" channels " << std::endl; -#endif - } - return iline; -} - - - -/*writes raw data file */ - -int fileIO::writeDataFile(string fname, double *data, double *err, double *ang, char dataformat, int nch){ - if (nch==-1) - nch=getTotalNumberofChannels();//getTotalNumberOfChannels(); - - return writeDataFile(fname, nch, data, err, ang, dataformat); - -} -int fileIO::writeDataFile(ofstream &outfile, double *data, double *err, double *ang, char dataformat, int nch, int offset){ - if (nch==-1) - nch=getTotalNumberofChannels(); - - return writeDataFile(outfile, nch, data, err, ang, dataformat, offset); - -} - - - - -int fileIO::writeDataFile(string fname, int *data){ - - return writeDataFile(fname, getTotalNumberofChannels(), data); -} - -int fileIO::writeDataFile(ofstream &outfile, int *data, int offset){ - - return writeDataFile(outfile, getTotalNumberofChannels(), data, offset); -} - - - - - -int fileIO::writeDataFile(string fname, short int *data){ - - return writeDataFile(fname, getTotalNumberofChannels(), data); -} - -int fileIO::writeDataFile(ofstream &outfile, short int *data, int offset){ - - return writeDataFile(outfile,getTotalNumberofChannels() , data, offset); -} - - - - -int fileIO::readDataFile(string fname, double *data, double *err, double *ang, char dataformat) { - return readDataFile(getTotalNumberofChannels(), fname, data, err, ang, dataformat); - -} - -int fileIO::readDataFile(ifstream &infile, double *data, double *err, double *ang, char dataformat, int offset) { - return readDataFile(getTotalNumberofChannels(), infile, data, err, ang, dataformat, offset); - -} - - - -int fileIO::readDataFile(string fname, int *data){ - - return readDataFile(fname, data, getTotalNumberofChannels()); -}; - - -int fileIO::readDataFile(ifstream &infile, int *data, int offset){ - - return readDataFile(infile, data, getTotalNumberofChannels(), offset); -}; - - - - - -int fileIO::readDataFile(string fname, short int *data){ - - return readDataFile(fname, data, getTotalNumberofChannels()); -}; - - -int fileIO::readDataFile(ifstream &infile, short int *data, int offset){ - - return readDataFile(infile, data, getTotalNumberofChannels(),offset); -}; - diff --git a/slsDetectorSoftware/slsDetectorAnalysis/FileIO_Standalone.h b/slsDetectorSoftware/slsDetectorAnalysis/FileIO_Standalone.h deleted file mode 100644 index b94f6366f..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/FileIO_Standalone.h +++ /dev/null @@ -1,410 +0,0 @@ -#ifndef FILEIOSTD_H -#define FILEIOSTD_H - -//#include "slsDetectorBase.h" -#include "sls_detector_defs.h" -#include -#include -#include -#include -#include -#include -#include -#include - -; -/** - @short class handling the data file I/O flags -*/ - -class fileIO : public virtual slsDetectorDefs {//public virtual slsDetectorBase { - - - - public: - /** default constructor */ - fileIO(){}; - /** virtual destructor */ - virtual ~fileIO(){}; - - int setTotalNumberofChannels(int i){ if (i>=0) {totalNumberofChannels=i; return totalNumberofChannels;} else return -1;}; - int getTotalNumberofChannels(){ return totalNumberofChannels; }; - /** - sets the default output files path - \param s file path - \return actual file path - */ - string setFilePath(string s) {sprintf(filePath, s.c_str()); return string(filePath);}; - - /** - sets the default output files root name - \param s file name to be set - \returns actual file name - */ - string setFileName(string s) {sprintf(fileName, s.c_str()); return string(fileName);}; - - /** - sets the default output file index - \param i start file index to be set - \returns actual file index - */ - int setFileIndex(int i) {*fileIndex=i; return *fileIndex;}; - - - - /** - \returns the output files path - - */ - string getFilePath() {return string(filePath);}; - - /** - \returns the output files root name - */ - string getFileName() {return string(fileName);}; - - /** - \returns the output file index - */ - int getFileIndex() {return *fileIndex;}; - - - - - - - /** generates file name without extension - - always appends to file path and file name the run index. - - in case also appends the position index and the two level of scan varaibles with the specified precision - - Filenames will be of the form: filepath/filename(_Sy_sw_px)_i - where y is the scan0 variable, W is the scan 1 variable, x is the position index and i is the run index - \param filepath outdir - \param filename file root name - \param aMask action mask (scans, positions) - \param sv0 scan variable 0 - \param prec0 scan precision 0 - \param sv1 scan variable 1 - \param prec1 scan precision 1 - \param pindex position index - \param number of positions - \param findex file index - \returns file name without extension - */ - static string createFileName(char *filepath, char *filename, int aMask, double sv0, int prec0, double sv1, int prec1, int pindex, int npos, int findex); - - - string createFileName(int aMask, double sv0, int prec0, double sv1, int prec1, int pindex, int npos); - - - /** static function that returns the file index from the file name - \param fname file name - \returns file index - */ - int getFileIndexFromFileName(string fname); - - /** static function that returns the variables from the file name - \param fname file name - \param index reference to index - \param p_index reference to position index - \param sv0 reference to scan variable 0 - \param sv1 reference to scan variable 1 - \returns file index - */ - static int getVariablesFromFileName(string fname, int &index, int &p_index, double &sv0, double &sv1); - - - - - /** - - writes a data file - \param fname of the file to be written - \param data array of data values - \param err array of arrors on the data. If NULL no errors will be written - - \param ang array of angular values. If NULL data will be in the form chan-val(-err) otherwise ang-val(-err) - \param dataformat format of the data: can be 'i' integer or 'f' double (default) - \param nch number of channels to be written to file. if -1 defaults to the number of installed channels of the detector - \returns OK or FAIL if it could not write the file or data=NULL - - */ - virtual int writeDataFile(string fname, double *data, double *err=NULL, double *ang=NULL, char dataformat='f', int nch=-1); - - - /** - - writes a data file - \paramoutfile output file stream - \param data array of data values - \param err array of arrors on the data. If NULL no errors will be written - - \param ang array of angular values. If NULL data will be in the form chan-val(-err) otherwise ang-val(-err) - \param dataformat format of the data: can be 'i' integer or 'f' double (default) - \param nch number of channels to be written to file. if -1 defaults to the number of installed channels of the detector - \param offset start channel number - \returns OK or FAIL if it could not write the file or data=NULL - - */ - int writeDataFile(ofstream &outfile, double *data, double *err=NULL, double *ang=NULL, char dataformat='f', int nch=-1, int offset=0); - - - /** - writes a data file - \param fname of the file to be written - \param data array of data values - \returns OK or FAIL if it could not write the file or data=NULL - */ - virtual int writeDataFile(string fname, int *data); - - /** - writes a data file - \param outfile output file stream - \param data array of data values - \param offset start channel number - \returns OK or FAIL if it could not write the file or data=NULL - */ - int writeDataFile(ofstream &outfile, int *data, int offset=0); - - - - /** - writes a data file of short ints - \param fname of the file to be written - \param data array of data values - \returns OK or FAIL if it could not write the file or data=NULL - */ - virtual int writeDataFile(string fname, short int *data); - - /** - writes a data file of short ints - \param outfile output file stream - \param data array of data values - \param offset start channel number - \returns OK or FAIL if it could not write the file or data=NULL - */ - int writeDataFile(ofstream &outfile, short int *data, int offset=0); - - - /** - reads a data file - \param fname of the file to be read - \param data array of data values to be filled - \param err array of arrors on the data. If NULL no errors are expected on the file - - \param ang array of angular values. If NULL data are expected in the form chan-val(-err) otherwise ang-val(-err) - \param dataformat format of the data: can be 'i' integer or 'f' double (default) - \returns OK or FAIL if it could not read the file or data=NULL - */ - virtual int readDataFile(string fname, double *data, double *err=NULL, double *ang=NULL, char dataformat='f'); - - /** - reads a data file - \param ifstream input file stream - \param data array of data values to be filled - \param err array of arrors on the data. If NULL no errors are expected on the file - - \param ang array of angular values. If NULL data are expected in the form chan-val(-err) otherwise ang-val(-err) - \param offset start channel number to be expected - \returns OK or FAIL if it could not read the file or data=NULL - */ - int readDataFile(ifstream& infile, double *data, double *err=NULL, double *ang=NULL, char dataformat='f', int offset=0); - - /** - reads a raw data file - \param fname of the file to be read - \param data array of data values - \returns OK or FAIL if it could not read the file or data=NULL - */ - virtual int readDataFile(string fname, int *data); /** - reads a raw data file - \param infile input file stream - \param data array of data values - \param offset first channel number to be expected - \returns OK or FAIL if it could not read the file or data=NULL - */ - int readDataFile(ifstream &infile, int *data, int offset=0); - - /** - - reads a short int raw data file - \param fname of the file to be read - \param data array of data values - \returns OK or FAIL if it could not read the file or data=NULL - */ - virtual int readDataFile(string fname, short int *data); - /** - reads a short int raw data file - \param infile input file stream - \param data array of data values - \param offset first channel number to be expected - \returns OK or FAIL if it could not read the file or data=NULL - */ - int readDataFile(ifstream &infile, short int *data, int offset=0); - - /** - - writes a data file - \param fname of the file to be written - \param nch number of channels to be written - \param data array of data values - \param err array of arrors on the data. If NULL no errors will be written - \param ang array of angular values. If NULL data will be in the form chan-val(-err) otherwise ang-val(-err) - \param dataformat format of the data: can be 'i' integer or 'f' double (default) - \returns OK or FAIL if it could not write the file or data=NULL - - */ - - static int writeDataFile(string fname, int nch, double *data, double *err=NULL, double *ang=NULL, char dataformat='f'); - /** - writes a data file - \param outfile output file stream - \param nch number of channels to be written - \param data array of data values - \param err array of arrors on the data. If NULL no errors will be written - \param ang array of angular values. If NULL data will be in the form chan-val(-err) otherwise ang-val(-err) - \param dataformat format of the data: can be 'i' integer or 'f' double (default) - \param offset start channel number - \returns OK or FAIL if it could not write the file or data=NULL - */ - static int writeDataFile(ofstream &outfile, int nch, double *data, double *err=NULL, double *ang=NULL, char dataformat='f', int offset=0); - - /** - writes a raw data file - \param fname of the file to be written - \param nch number of channels - \param data array of data values - \returns OK or FAIL if it could not write the file or data=NULL - */ - static int writeDataFile(string fname,int nch, int *data); - - /** - writes a raw data file - \param outfile output file stream - \param nch number of channels - \param data array of data values - \param offset start channel number - \returns OK or FAIL if it could not write the file or data=NULL - */ - static int writeDataFile(ofstream &outfile,int nch, int *data, int offset=0); - - - /** - - writes a short int raw data file - \param fname of the file to be written - \param nch number of channels - \param data array of data values - \returns OK or FAIL if it could not write the file or data=NULL - */ - static int writeDataFile(string fname,int nch, short int *data); - - /** - writes a short int raw data file - \param outfile output file stream - \param nch number of channels - \param data array of data values - \param offset start channel number - \returns OK or FAIL if it could not write the file or data=NULL - */ - static int writeDataFile(ofstream &outfile,int nch, short int *data, int offset=0); - - - /** - reads a data file - \param nch number of channels - \param fname of the file to be read - \param data array of data values to be filled - \param err array of arrors on the data. If NULL no errors are expected on the file - \param ang array of angular values. If NULL data are expected in the form chan-val(-err) otherwise ang-val(-err) - \param dataformat format of the data: can be 'i' integer or 'f' double (default) - \returns number of channels read or -1 if it could not read the file or data=NULL - - */ - static int readDataFile(int nch, string fname, double *data, double *err=NULL, double *ang=NULL, char dataformat='f'); - /** - reads a data file - \param nch number of channels - \param infile input file stream - \param data array of data values to be filled - \param err array of arrors on the data. If NULL no errors are expected on the file - \param ang array of angular values. If NULL data are expected in the form chan-val(-err) otherwise ang-val(-err) - \param dataformat format of the data: can be 'i' integer or 'f' double (default) - \param offset start channel number - \returns number of channels read or -1 if it could not read the file or data=NULL - - */ - static int readDataFile(int nch, ifstream &infile, double *data, double *err=NULL, double *ang=NULL, char dataformat='f', int offset=0); - - /** - reads a raw data file - \param fname of the file to be read - \param data array of data values - \param nch number of channels - \returns OK or FAIL if it could not read the file or data=NULL - */ - static int readDataFile(string fname, int *data, int nch); - - /** - reads a raw data file - \param infile input file stream - \param data array of data values - \param nch number of channels - \param offset start channel value - \returns OK or FAIL if it could not read the file or data=NULL - */ - static int readDataFile(ifstream &infile, int *data, int nch, int offset); - - /** - reads a short int rawdata file - \param name of the file to be read - \param data array of data values - \param nch number of channels - \returns OK or FAIL if it could not read the file or data=NULL - */ - static int readDataFile(string fname, short int *data, int nch); - /** - reads a short int raw data file - \param infile input file stream - \param data array of data values - \param nch number of channels - \param offset start channel value - \returns OK or FAIL if it could not read the file or data=NULL - */ - static int readDataFile(ifstream &infile, short int *data, int nch, int offset); - - - - - - void incrementFileIndex() { (*fileIndex)++;}; - - string getCurrentFileName(){return currentFileName;}; - - protected: - string currentFileName; - - - int mask_action; - double currentscan_variable[1]; - int scan_precision[1]; - int currentpostion_i; - int noposition; - - /** output directory */ - char *filePath; - /** file root name */ - char *fileName; - /** file index */ - int *fileIndex; - - private: - - int totalNumberofChannels; - - -}; - -#endif diff --git a/slsDetectorSoftware/slsDetectorAnalysis/Makefile b/slsDetectorSoftware/slsDetectorAnalysis/Makefile deleted file mode 100644 index 1b137d512..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/Makefile +++ /dev/null @@ -1,87 +0,0 @@ -#--------------------------------------------------- - - -include Makefile.arch - -#------------------------------------------------------------------------------ - -SLSDETO = TSlsDetectorDict.$(ObjSuf) energyCalibration.$(ObjSuf) angularCalibration.$(ObjSuf) - -SLSDETSO = libTSlsDetector.$(DllSuf) - -CXXFLAGS += -Wno-deprecated -#LIBS += -L../slsDetectorSoftware -lSlsDetector -pthread - -CXXFLAGS += -I ../usersFunctions - -HEADERS= energyCalibration.h angularCalibration.h -#------------------------------------------------------------------------------- - -#----------- do the shared library -$(SLSDETSO): $(SLSDETO) - @echo "Generating shared library $@..." - $(LD) $(SOFLAGS) $(LDFLAGS) -o $@ $(LIBS) $^ - - -# ---------- Default rule - -%.$(ObjSuf): %.cpp - @echo "Compiling source $@..." - $(CXX) $(CXXFLAGS) -c $< - - -#----------- do the dictionary -TSlsDetectorDict.$(SrcSuf): $(HEADERS) - @echo "Generating dictionary $@..." - rootcint -f $@ -c -p $^ - -#------------------------------------------------------------------------------- -all: $(SLSDETSO) - -clean: - @rm -f $(SLSDETO) core - -distclean: clean - @rm -f *Dict.* *.so *.o - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/slsDetectorSoftware/slsDetectorAnalysis/Makefile.arch b/slsDetectorSoftware/slsDetectorAnalysis/Makefile.arch deleted file mode 100644 index 707a4e35b..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/Makefile.arch +++ /dev/null @@ -1,575 +0,0 @@ -# -*- mode: makefile -*- -# -# Makefile containing platform dependencies for ROOT based projects. -# -# Copyright (c) 2000 Rene Brun and Fons Rademakers -# -# Author: Fons Rademakers, 29/2/2000 - -ROOTCONFIG := root-config - -ARCH := $(shell $(ROOTCONFIG) --arch) -PLATFORM := $(shell $(ROOTCONFIG) --platform) -ALTCC := $(shell $(ROOTCONFIG) --cc) -ALTCXX := $(shell $(ROOTCONFIG) --cxx) -ALTF77 := $(shell $(ROOTCONFIG) --f77) -ALTLD := $(shell $(ROOTCONFIG) --ld) - -#CXX = -ObjSuf = o -SrcSuf = cpp -ExeSuf = -DllSuf = so -OutPutOpt = -o # keep whitespace after "-o" - -ifeq (debug,$(findstring debug,$(ROOTBUILD))) -OPT = -g -OPT2 = -g -else -ifneq ($(findstring debug, $(strip $(shell $(ROOTCONFIG) --config))),) -OPT = -g -OPT2 = -g -else -OPT = -O -OPT2 = -O2 -endif -endif - -ROOTCFLAGS := $(shell $(ROOTCONFIG) --cflags) -ROOTLDFLAGS := $(shell $(ROOTCONFIG) --ldflags) -ROOTLIBS := $(shell $(ROOTCONFIG) --libs) -ROOTGLIBS := $(shell $(ROOTCONFIG) --glibs) -HASTHREAD := $(shell $(ROOTCONFIG) --has-thread) -ROOTDICTTYPE := $(shell $(ROOTCONFIG) --dicttype) -NOSTUBS := $(shell $(ROOTCONFIG) --nostubs) -ROOTCINT := rootcint - -# Stub Functions Generation -ifeq ($(NOSTUBS),yes) - ROOTCINT = export CXXFLAGS="$(CXXFLAGS)"; $(ROOTSYS)/core/utils/src/rootcint_nostubs.sh -$(ROOTDICTTYPE) -endif - -ifeq ($(ARCH),hpuxacc) -# HP-UX 10.x with aCC -CXX = aCC -CXXFLAGS = $(OPT) +Z -LD = aCC -LDFLAGS = $(OPT) -z -SOFLAGS = -b -endif - -ifeq ($(ARCH),hpuxia64acc) -# HP-UX 11i 1.5 (IA-64) with aCC -CXX = aCC -CXXFLAGS = +DD64 $(OPT) +Z -LD = aCC -LDFLAGS = +DD64 $(OPT) -z -SOFLAGS = -b -endif - -ifeq ($(ARCH),hpuxgcc) -# HP-UX 10.x with g++ -CXXFLAGS = $(OPT) -fPIC -CXX = g++ -LD = g++ -LDFLAGS = $(OPT) -SOFLAGS = -fPIC -shared -endif - -ifeq ($(ARCH),hurddeb) -# GNU/Hurd -CXX = g++ -CXXFLAGS = $(OPT2) -Wall -fPIC -LD = g++ -LDFLAGS = $(OPT2) -SOFLAGS = -shared -endif - -ifeq ($(ARCH),aix) -# IBM AIX xlC 4.x -CXX = xlC -CXXFLAGS = $(OPT) -LD = xlC -LDFLAGS = $(OPT) -SOFLAGS = -DllSuf = a -endif - -ifeq ($(ARCH),aix5) -# IBM AIX xlC 5.x -CXX = xlC -CXXFLAGS = $(OPT) -LD = xlC -LDFLAGS = $(OPT) -SOFLAGS = -DllSuf = a -endif - -ifeq ($(ARCH),aixgcc) -# IBM AIX with GCC -CXX = g++ -CXXFLAGS = $(OPT) -LD = g++ -LDFLAGS = $(OPT) -SOFLAGS = -shared -DllSuf = a -EXPLLINKLIBS = $(ROOTLIBS) $(ROOTGLIBS) -endif - -ifeq ($(ARCH),solaris) -# Solaris CC -CXX = /opt/SUNWspro/bin/CC -CXXFLAGS = $(OPT) -KPIC -LD = /opt/SUNWspro/bin/CC -LDFLAGS = $(OPT) -SOFLAGS = -G -endif - -ifeq ($(ARCH),solarisCC5) -# Solaris CC 5.0 -CXX = CC -CXXFLAGS = $(OPT) -KPIC -LD = CC -LDFLAGS = $(OPT) -SOFLAGS = -G -endif - -ifeq ($(ARCH),solarisgcc) -# Solaris gcc -CXX = g++ -CXXFLAGS = $(OPT) -fPIC -LD = g++ -LDFLAGS = $(OPT) -SOFLAGS = -shared -endif - -ifeq ($(ARCH),solariskcc) -# Solaris kcc -CXX = KCC --one_instantiation_per_object -CXXFLAGS = -O4 -KPIC -LD = KCC -LDFLAGS = -O4 -SOFLAGS = -endif - -ifeq ($(ARCH),solarisx86) -# Solaris CC on Intel -CXX = CC -CXXFLAGS = $(OPT) -KPIC -LD = CC -LDFLAGS = $(OPT) -SOFLAGS = -G -endif - -ifeq ($(ARCH),sgicc) -# SGI -CXX = CC -n32 -I/usr/include/CC.sgi -CXXFLAGS = $(OPT) -LD = CC -n32 -LANG:std -I/usr/include/CC.sgi -LDFLAGS = $(OPT) -SOFLAGS = -shared -endif - -ifeq ($(ARCH),sgicc64) -# SGI -CXX = CC -64 -I/usr/include/CC.sgi -CXXFLAGS = $(OPT) -LD = CC -64 -LANG:std -I/usr/include/CC.sgi -LDFLAGS = $(OPT) -SOFLAGS = -shared -endif - -ifeq ($(ARCH),sgigcc) -# SGI 6.x with gcc -CXX = g++ -CXXFLAGS = $(OPT) -Wall -fPIC -LD = g++ -LDFLAGS = $(OPT) -Wl,-u,__builtin_new -Wl,-u,__builtin_delete -Wl,-u,__nw__FUiPv -SOFLAGS = -shared -endif - -ifeq ($(ARCH),sgin32gcc) -# SGI 6.x with gcc for n32 ABI -CXX = g++ -CXXFLAGS = $(OPT) -Wall -fPIC -LD = g++ -LDFLAGS = $(OPT) -L/usr/lib32 -Wl,-woff,134 -lgen -SOFLAGS = -shared -endif - -ifeq ($(ARCH),sgikcc) -# SGI with KCC -CXX = KCC -n32 --one_instantiation_per_object -CXXFLAGS = $(OPT) -LD = KCC -n32 -LDFLAGS = $(OPT) -SOFLAGS = -endif - -ifeq ($(ARCH),alphagcc) -# Alpha/OSF with gcc -CXX = g++ -CXXFLAGS = $(OPT2) -Wall -fPIC -LD = g++ -LDFLAGS = $(OPT2) -SOFLAGS = -Wl,-expect_unresolved,* -shared -endif - -ifeq ($(ARCH),alphakcc) -# Alpha/OSF with kai compiler (not yet valid) -CXX = KCC --one_instantiation_per_object -CXXFLAGS = $(OPT) -fPIC -LD = KCC -LDFLAGS = $(OPT) -SOFLAGS = -Wl,-expect_unresolved,* -shared -endif - -ifeq ($(ARCH),alphacxx6) -# Alpha/OSF with cxx6 -CXX = cxx -CXXFLAGS = $(OPT) -LD = cxx -LDFLAGS = $(OPT) -SOFLAGS = -shared -nocxxstd -Wl,-expect_unresolved,*,-msym -endif - -ifeq ($(ARCH),linuxdeb2ppc) -# Debian/Linux on the PowerPC -CXX = g++ -CXXFLAGS = $(OPT2) -Wall -fPIC -LD = g++ -LDFLAGS = $(OPT2) -SOFLAGS = -shared -endif - -ifeq ($(ARCH),linux) -# Linux with egcs, gcc 2.9x, gcc 3.x -CXX = g++ -CXXFLAGS = $(OPT2) -Wall -fPIC -LD = g++ -LDFLAGS = $(OPT2) -SOFLAGS = -shared -endif - -ifeq ($(ARCH),linuxkcc) -# Linux with the KAI compiler -CXX = KCC --one_instantiation_per_object -CXXFLAGS = $(OPT) -fPIC +K0 -LD = KCC -LDFLAGS = $(OPT) $(shell $(ROOTCONFIG) --cflags) -SOFLAGS = -endif - -ifeq ($(ARCH),linuxicc) -# Linux with Intel icc compiler -ICC_MAJOR := $(shell icc -v 2>&1 | awk '{ if (NR==1) print $$2 }' | \ - cut -d'.' -f1) -ICC_MINOR := $(shell icc -v 2>&1 | awk '{ if (NR==1) print $$2 }' | \ - cut -d'.' -f2) -CXX = icc -CXXFLAGS = $(OPT) -fPIC -wd1476 -LD = icpc -LDFLAGS = $(OPT) -SOFLAGS = -shared -endif - -ifeq ($(ARCH),linuxppcgcc) -# PPC Linux with gcc and glibc -CXX = g++ -CXXFLAGS = $(OPT2) -Wall -fPIC -LD = g++ -LDFLAGS = $(OPT2) -SOFLAGS = -shared -endif - -ifeq ($(ARCH),linuxia64gcc) -# Itanium Linux with gcc 2.9x -CXX = g++ -CXXFLAGS = $(OPT2) -Wall -fPIC -LD = g++ -LDFLAGS = $(OPT2) -SOFLAGS = -shared -endif - -ifeq ($(ARCH),linuxia64sgi) -# Itanium Linux with sgiCC -CXX = sgiCC -CXXFLAGS = $(OPT) -Wall -fPIC -LD = gsgiCC -LDFLAGS = $(OPT) -SOFLAGS = -shared -endif - -ifeq ($(ARCH),linuxia64ecc) -# Itanium Linux with Intel icc (was ecc) -ICC_MAJOR := $(shell icc -v 2>&1 | awk '{ if (NR==1) print $$2 }' | \ - cut -d'.' -f1) -ICC_MINOR := $(shell icc -v 2>&1 | awk '{ if (NR==1) print $$2 }' | \ - cut -d'.' -f2) -CXX = icc -CXXFLAGS = $(OPT) -fPIC -wd1476 -ftz -LD = icpc -LDFLAGS = $(OPT) -SOFLAGS = -shared -endif - -ifeq ($(ARCH),linuxx8664gcc) -# AMD Opteron and Intel EM64T (64 bit mode) Linux with gcc 3.x -CXX = g++ -CXXFLAGS = $(OPT2) -Wall -fPIC -LD = g++ -LDFLAGS = $(OPT2) -SOFLAGS = -shared -endif - -ifeq ($(ARCH),linuxppc64gcc) -# PPC64 Linux with gcc 3.x -CXX = g++ -CXXFLAGS = $(OPT) -Wall -fPIC -LD = g++ -LDFLAGS = $(OPT) -SOFLAGS = -shared -endif - -ifeq ($(ARCH),linuxx8664icc) -# AMD Opteron and Intel EM64T (64 bit mode) Linux with Intel icc compiler -CXX = icc -CXXFLAGS = $(OPT) -fPIC -wd1476 -wd1572 -LD = icpc -LDFLAGS = $(OPT) -SOFLAGS = -shared -endif - -ifeq ($(ARCH),linuxalphagcc) -# Alpha Linux with gcc -CXX = g++ -CXXFLAGS = $(OPT2) -Wall -fPIC -LD = g++ -LDFLAGS = $(OPT2) -SOFLAGS = -shared -endif - -ifeq ($(ARCH),linuxmips) -# GNU/Linux on mips (BE/LE, O32/N32/N64) with gcc -CXX = g++ -CXXFLAGS = $(OPT2) -Wall -fPIC -LD = g++ -LDFLAGS = $(OPT2) -SOFLAGS = -shared -endif - -ifeq ($(ARCH),linuxhppa) -# GNU/Linux on hppa with gcc -CXX = g++ -CXXFLAGS = $(OPT2) -Wall -fPIC -LD = g++ -LDFLAGS = $(OPT2) -SOFLAGS = -shared -endif - -ifeq ($(ARCH),linuxarm) -# ARM Linux with egcs -CXX = g++ -CXXFLAGS = $(OPT) -Wall -fPIC -LD = g++ -LDFLAGS = $(OPT) -SOFLAGS = -shared -endif - -ifeq ($(ARCH),freebsd4) -# FreeBSD with glibc -CXX = g++ -CXXFLAGS = $(OPT) -W -Wall -fPIC -LD = $(CXX) -LDFLAGS = $(OPT) -SOFLAGS = -shared -Wl,-x -endif - -ifeq ($(ARCH),freebsd5) -# FreeBSD with glibc -CXX = g++ -CXXFLAGS = $(OPT) -W -Wall -fPIC -LD = $(CXX) -LDFLAGS = $(OPT) -SOFLAGS = -shared -Wl,-x -endif - -ifeq ($(ARCH),freebsd7) -# FreeBSD with libc -CXX = g++ -CXXFLAGS = $(OPT) -W -Wall -fPIC -LD = $(CXX) -LDFLAGS = $(OPT) -SOFLAGS = -shared -Wl,-x -endif - -ifeq ($(ARCH),openbsd) -# OpenBSD with libc -CXX = g++ -CXXFLAGS = $(OPT) -pipe -W -Wall -fPIC -LD = g++ -LDFLAGS = $(OPT) -SOFLAGS = -shared -Wl,-x -endif - -ifeq ($(ARCH),macosx) -# MacOS X with cc (GNU cc 2.95.2 and gcc 3.3) -MACOSX_MINOR := $(shell sw_vers | sed -n 's/ProductVersion://p' | cut -d . -f 2) -MACOSXTARGET := MACOSX_DEPLOYMENT_TARGET=10.$(MACOSX_MINOR) -CXX = g++ -CXXFLAGS = $(OPT2) -pipe -Wall -W -Woverloaded-virtual -LD = $(MACOSXTARGET) g++ -LDFLAGS = $(OPT2) -# The SOFLAGS will be used to create the .dylib, -# the .so will be created separately -ifeq ($(subst $(MACOSX_MINOR),,1234),1234) -DllSuf = so -else -DllSuf = dylib -endif -UNDEFOPT = dynamic_lookup -ifneq ($(subst $(MACOSX_MINOR),,12),12) -UNDEFOPT = suppress -LD = g++ -endif -SOFLAGS = -dynamiclib -single_module -undefined $(UNDEFOPT) -install_name $(CURDIR)/ -endif - -ifeq ($(ARCH),macosxicc) -# MacOS X with Intel icc compiler -MACOSX_MINOR := $(shell sw_vers | sed -n 's/ProductVersion://p' | cut -d . -f 2) -MACOSXTARGET := MACOSX_DEPLOYMENT_TARGET=10.$(MACOSX_MINOR) -ifeq ($(MACOSX_MINOR),5) -MACOSX_MINOR := 4 -endif -CXX = icc -CXXFLAGS = $(OPT) -fPIC -wd1476 -LD = $(MACOSXTARGET) icpc -LDFLAGS = $(OPT) -# The SOFLAGS will be used to create the .dylib, -# the .so will be created separately -ifeq ($(subst $(MACOSX_MINOR),,1234),1234) -DllSuf = so -else -DllSuf = dylib -endif -SOFLAGS = -dynamiclib -single_module -undefined dynamic_lookup -install_name $(CURDIR)/ -endif - -ifeq ($(ARCH),macosx64) -# MacOS X >= 10.4 with gcc 64 bit mode (GNU gcc 4.*) -# Only specific option (-m64) comes from root-config -MACOSX_MINOR := $(shell sw_vers | sed -n 's/ProductVersion://p' | cut -d . -f 2) -MACOSXTARGET := MACOSX_DEPLOYMENT_TARGET=10.$(MACOSX_MINOR) -CXX = g++ -CXXFLAGS = $(OPT2) -pipe -Wall -W -Woverloaded-virtual -LD = $(MACOSXTARGET) g++ -LDFLAGS = $(OPT2) -# The SOFLAGS will be used to create the .dylib, -# the .so will be created separately -ifeq ($(subst $(MACOSX_MINOR),,1234),1234) -DllSuf = so -else -DllSuf = dylib -endif -SOFLAGS = -dynamiclib -single_module -undefined dynamic_lookup -install_name $(CURDIR)/ -endif - -ifeq ($(ARCH),macosxxlc) -# MacOS X with IBM xlC compiler -MACOSX_MINOR := $(shell sw_vers | sed -n 's/ProductVersion://p' | cut -d . -f 2) -MACOSXTARGET := MACOSX_DEPLOYMENT_TARGET=10.$(MACOSX_MINOR) -CXX = xlC -CXXFLAGS = $(OPT) -LD = $(MACOSXTARGET) xlC -LDFLAGS = $(OPT) -Wl,-bind_at_load -# The SOFLAGS will be used to create the .dylib, -# the .so will be created separately -DllSuf = dylib -UNDEFOPT = dynamic_lookup -ifneq ($(subst $(MACOSX_MINOR),,12),12) -UNDEFOPT = suppress -LD = xlC -endif -SOFLAGS = -qmkshrobj -single_module -undefined $(UNDEFOPT) -install_name $(CURDIR)/ -endif - -ifeq ($(ARCH),win32) -# Windows with the VC++ compiler -VC_MAJOR := $(shell unset VS_UNICODE_OUTPUT; cl.exe 2>&1 | awk '{ if (NR==1) print $$8 }' | \ - cut -d'.' -f1) -ObjSuf = obj -SrcSuf = cxx -ExeSuf = .exe -DllSuf = dll -OutPutOpt = -out: -CXX = cl -ifeq (debug,$(findstring debug,$(ROOTBUILD))) -CXXOPT = -Z7 -LDOPT = -debug -else -ifneq ($(findstring debug, $(strip $(shell $(ROOTCONFIG) --config))),) -CXXOPT = -Z7 -LDOPT = -debug -else -CXXOPT = -O2 -LDOPT = -opt:ref -endif -endif -ROOTINCDIR := -I$(shell cygpath -m `$(ROOTCONFIG) --incdir`) -CXXFLAGS = $(CXXOPT) -nologo $(ROOTINCDIR) -FIw32pragma.h -LD = link -LDFLAGS = $(LDOPT) -nologo -SOFLAGS = -DLL - -EXPLLINKLIBS = $(ROOTLIBS) $(ROOTGLIBS) -ifneq (,$(findstring $(VC_MAJOR),14 15)) -MT_EXE = mt -nologo -manifest $@.manifest -outputresource:$@\;1; rm -f $@.manifest -MT_DLL = mt -nologo -manifest $@.manifest -outputresource:$@\;2; rm -f $@.manifest -else -MT_EXE = -MT_DLL = -endif -endif - -ifeq ($(ARCH),win32gcc) -# Windows with gcc -DllSuf = dll -ExeSuf = .exe -CXX = g++ -CXXFLAGS = $(OPT) -pipe -Wall -Woverloaded-virtual -I/usr/X11R6/include -LD = g++ -LDFLAGS = $(OPT) -Wl,--enable-auto-import \ - -Wl,--enable-runtime-pseudo-reloc \ - -L/usr/X11R6/lib -SOFLAGS = -shared -Wl,--enable-auto-image-base \ - -Wl,--export-all-symbols -EXPLLINKLIBS = $(ROOTLIBS) $(ROOTGLIBS) -endif - -ifeq ($(CXX),) -$(error $(ARCH) invalid architecture) -endif - -CXXFLAGS += $(ROOTCFLAGS) -LDFLAGS += $(ROOTLDFLAGS) -LIBS = $(ROOTLIBS) $(SYSLIBS) -GLIBS = $(ROOTGLIBS) $(SYSLIBS) - -ifneq ($(ALTCC),) - CC = $(ALTCC) -endif -ifneq ($(ALTCXX),) - CXX = $(ALTCXX) -endif -ifneq ($(ALTF77),) - F77 = $(ALTF77) -endif -ifneq ($(ALTLD),) - LD = $(ALTLD) -endif - -ifneq ($(findstring g++, $(CXX)),) -GCC_MAJOR := $(shell $(CXX) -dumpversion 2>&1 | cut -d'.' -f1) -GCC_MINOR := $(shell $(CXX) -dumpversion 2>&1 | cut -d'.' -f2) -endif diff --git a/slsDetectorSoftware/slsDetectorAnalysis/TSlsDetectorDict.cpp b/slsDetectorSoftware/slsDetectorAnalysis/TSlsDetectorDict.cpp deleted file mode 100644 index 67c907790..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/TSlsDetectorDict.cpp +++ /dev/null @@ -1,691 +0,0 @@ -// -// File generated by rootcint at Thu Mar 29 16:09:00 2012 - -// Do NOT change. Changes will be lost next time file is generated -// - -#include "RConfig.h" //rootcint 4834 -#if !defined(R__ACCESS_IN_SYMBOL) -//Break the privacy of classes -- Disabled for the moment -#define private public -#define protected public -#endif - -// Since CINT ignores the std namespace, we need to do so in this file. -namespace std {} using namespace std; -#include "TSlsDetectorDict.h" - -#include "TClass.h" -#include "TBuffer.h" -#include "TMemberInspector.h" -#include "TError.h" - -#ifndef G__ROOT -#define G__ROOT -#endif - -#include "RtypesImp.h" -#include "TIsAProxy.h" - -// START OF SHADOWS - -namespace ROOT { - namespace Shadow { - } // of namespace Shadow -} // of namespace ROOT -// END OF SHADOWS - -namespace ROOT { - void energyCalibration_ShowMembers(void *obj, TMemberInspector &R__insp, char *R__parent); - static void energyCalibration_Dictionary(); - static void *new_energyCalibration(void *p = 0); - static void *newArray_energyCalibration(Long_t size, void *p); - static void delete_energyCalibration(void *p); - static void deleteArray_energyCalibration(void *p); - static void destruct_energyCalibration(void *p); - - // Function generating the singleton type initializer - static TGenericClassInfo *GenerateInitInstanceLocal(const ::energyCalibration*) - { - ::energyCalibration *ptr = 0; - static ::TVirtualIsAProxy* isa_proxy = new ::TIsAProxy(typeid(::energyCalibration),0); - static ::ROOT::TGenericClassInfo - instance("energyCalibration", "./energyCalibration.h", 168, - typeid(::energyCalibration), DefineBehavior(ptr, ptr), - 0, &energyCalibration_Dictionary, isa_proxy, 0, - sizeof(::energyCalibration) ); - instance.SetNew(&new_energyCalibration); - instance.SetNewArray(&newArray_energyCalibration); - instance.SetDelete(&delete_energyCalibration); - instance.SetDeleteArray(&deleteArray_energyCalibration); - instance.SetDestructor(&destruct_energyCalibration); - return &instance; - } - TGenericClassInfo *GenerateInitInstance(const ::energyCalibration*) - { - return GenerateInitInstanceLocal((::energyCalibration*)0); - } - // Static variable to force the class initialization - static ::ROOT::TGenericClassInfo *_R__UNIQUE_(Init) = GenerateInitInstanceLocal((const ::energyCalibration*)0x0); R__UseDummy(_R__UNIQUE_(Init)); - - // Dictionary for non-ClassDef classes - static void energyCalibration_Dictionary() { - ::ROOT::GenerateInitInstanceLocal((const ::energyCalibration*)0x0)->GetClass(); - } - -} // end of namespace ROOT - -namespace ROOT { - void angularCalibration_ShowMembers(void *obj, TMemberInspector &R__insp, char *R__parent); - static void angularCalibration_Dictionary(); - static void *new_angularCalibration(void *p = 0); - static void *newArray_angularCalibration(Long_t size, void *p); - static void delete_angularCalibration(void *p); - static void deleteArray_angularCalibration(void *p); - static void destruct_angularCalibration(void *p); - - // Function generating the singleton type initializer - static TGenericClassInfo *GenerateInitInstanceLocal(const ::angularCalibration*) - { - ::angularCalibration *ptr = 0; - static ::TVirtualIsAProxy* isa_proxy = new ::TIsAProxy(typeid(::angularCalibration),0); - static ::ROOT::TGenericClassInfo - instance("angularCalibration", "./angularCalibration.h", 35, - typeid(::angularCalibration), DefineBehavior(ptr, ptr), - 0, &angularCalibration_Dictionary, isa_proxy, 0, - sizeof(::angularCalibration) ); - instance.SetNew(&new_angularCalibration); - instance.SetNewArray(&newArray_angularCalibration); - instance.SetDelete(&delete_angularCalibration); - instance.SetDeleteArray(&deleteArray_angularCalibration); - instance.SetDestructor(&destruct_angularCalibration); - return &instance; - } - TGenericClassInfo *GenerateInitInstance(const ::angularCalibration*) - { - return GenerateInitInstanceLocal((::angularCalibration*)0); - } - // Static variable to force the class initialization - static ::ROOT::TGenericClassInfo *_R__UNIQUE_(Init) = GenerateInitInstanceLocal((const ::angularCalibration*)0x0); R__UseDummy(_R__UNIQUE_(Init)); - - // Dictionary for non-ClassDef classes - static void angularCalibration_Dictionary() { - ::ROOT::GenerateInitInstanceLocal((const ::angularCalibration*)0x0)->GetClass(); - } - -} // end of namespace ROOT - -namespace ROOT { - // Wrappers around operator new - static void *new_energyCalibration(void *p) { - return p ? ::new((::ROOT::TOperatorNewHelper*)p) ::energyCalibration : new ::energyCalibration; - } - static void *newArray_energyCalibration(Long_t nElements, void *p) { - return p ? ::new((::ROOT::TOperatorNewHelper*)p) ::energyCalibration[nElements] : new ::energyCalibration[nElements]; - } - // Wrapper around operator delete - static void delete_energyCalibration(void *p) { - delete ((::energyCalibration*)p); - } - static void deleteArray_energyCalibration(void *p) { - delete [] ((::energyCalibration*)p); - } - static void destruct_energyCalibration(void *p) { - typedef ::energyCalibration current_t; - ((current_t*)p)->~current_t(); - } -} // end of namespace ROOT for class ::energyCalibration - -namespace ROOT { - // Wrappers around operator new - static void *new_angularCalibration(void *p) { - return p ? ::new((::ROOT::TOperatorNewHelper*)p) ::angularCalibration : new ::angularCalibration; - } - static void *newArray_angularCalibration(Long_t nElements, void *p) { - return p ? ::new((::ROOT::TOperatorNewHelper*)p) ::angularCalibration[nElements] : new ::angularCalibration[nElements]; - } - // Wrapper around operator delete - static void delete_angularCalibration(void *p) { - delete ((::angularCalibration*)p); - } - static void deleteArray_angularCalibration(void *p) { - delete [] ((::angularCalibration*)p); - } - static void destruct_angularCalibration(void *p) { - typedef ::angularCalibration current_t; - ((current_t*)p)->~current_t(); - } -} // end of namespace ROOT for class ::angularCalibration - -/******************************************************** -* TSlsDetectorDict.cpp -* CAUTION: DON'T CHANGE THIS FILE. THIS FILE IS AUTOMATICALLY GENERATED -* FROM HEADER FILES LISTED IN G__setup_cpp_environmentXXX(). -* CHANGE THOSE HEADER FILES AND REGENERATE THIS FILE. -********************************************************/ - -#ifdef G__MEMTEST -#undef malloc -#undef free -#endif - -#if defined(__GNUC__) && (__GNUC__ > 3) && (__GNUC_MINOR__ > 1) -#pragma GCC diagnostic ignored "-Wstrict-aliasing" -#endif - -extern "C" void G__cpp_reset_tagtableTSlsDetectorDict(); - -extern "C" void G__set_cpp_environmentTSlsDetectorDict() { - G__add_compiledheader("TObject.h"); - G__add_compiledheader("TMemberInspector.h"); - G__add_compiledheader("energyCalibration.h"); - G__add_compiledheader("angularCalibration.h"); - G__cpp_reset_tagtableTSlsDetectorDict(); -} -#include -extern "C" int G__cpp_dllrevTSlsDetectorDict() { return(30051515); } - -/********************************************************* -* Member function Interface Method -*********************************************************/ - -/* energyCalibration */ -static int G__TSlsDetectorDict_85_0_1(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash) -{ - energyCalibration* p = NULL; - char* gvp = (char*) G__getgvp(); - int n = G__getaryconstruct(); - if (n) { - if ((gvp == (char*)G__PVOID) || (gvp == 0)) { - p = new energyCalibration[n]; - } else { - p = new((void*) gvp) energyCalibration[n]; - } - } else { - if ((gvp == (char*)G__PVOID) || (gvp == 0)) { - p = new energyCalibration; - } else { - p = new((void*) gvp) energyCalibration; - } - } - result7->obj.i = (long) p; - result7->ref = (long) p; - result7->type = 'u'; - result7->tagnum = G__get_linked_tagnum(&G__TSlsDetectorDictLN_energyCalibration); - return(1 || funcname || hash || result7 || libp) ; -} - -static int G__TSlsDetectorDict_85_0_2(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash) -{ - switch (libp->paran) { - case 1: - G__letint(result7, 105, (long) ((energyCalibration*) G__getstructoffset())->setPlotFlag((int) G__int(libp->para[0]))); - break; - case 0: - G__letint(result7, 105, (long) ((energyCalibration*) G__getstructoffset())->setPlotFlag()); - break; - } - return(1 || funcname || hash || result7 || libp) ; -} - -static int G__TSlsDetectorDict_85_0_3(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash) -{ - switch (libp->paran) { - case 1: - G__letint(result7, 105, (long) ((energyCalibration*) G__getstructoffset())->setScanSign((int) G__int(libp->para[0]))); - break; - case 0: - G__letint(result7, 105, (long) ((energyCalibration*) G__getstructoffset())->setScanSign()); - break; - } - return(1 || funcname || hash || result7 || libp) ; -} - -static int G__TSlsDetectorDict_85_0_4(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash) -{ - switch (libp->paran) { - case 1: - G__letint(result7, 105, (long) ((energyCalibration*) G__getstructoffset())->setChargeSharing((int) G__int(libp->para[0]))); - break; - case 0: - G__letint(result7, 105, (long) ((energyCalibration*) G__getstructoffset())->setChargeSharing()); - break; - } - return(1 || funcname || hash || result7 || libp) ; -} - -// automatic copy constructor -static int G__TSlsDetectorDict_85_0_5(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash) - -{ - energyCalibration* p; - void* tmp = (void*) G__int(libp->para[0]); - p = new energyCalibration(*(energyCalibration*) tmp); - result7->obj.i = (long) p; - result7->ref = (long) p; - result7->type = 'u'; - result7->tagnum = G__get_linked_tagnum(&G__TSlsDetectorDictLN_energyCalibration); - return(1 || funcname || hash || result7 || libp) ; -} - -// automatic destructor -typedef energyCalibration G__TenergyCalibration; -static int G__TSlsDetectorDict_85_0_6(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash) -{ - char* gvp = (char*) G__getgvp(); - long soff = G__getstructoffset(); - int n = G__getaryconstruct(); - // - //has_a_delete: 0 - //has_own_delete1arg: 0 - //has_own_delete2arg: 0 - // - if (!soff) { - return(1); - } - if (n) { - if (gvp == (char*)G__PVOID) { - delete[] (energyCalibration*) soff; - } else { - G__setgvp((long) G__PVOID); - for (int i = n - 1; i >= 0; --i) { - ((energyCalibration*) (soff+(sizeof(energyCalibration)*i)))->~G__TenergyCalibration(); - } - G__setgvp((long)gvp); - } - } else { - if (gvp == (char*)G__PVOID) { - delete (energyCalibration*) soff; - } else { - G__setgvp((long) G__PVOID); - ((energyCalibration*) (soff))->~G__TenergyCalibration(); - G__setgvp((long)gvp); - } - } - G__setnull(result7); - return(1 || funcname || hash || result7 || libp) ; -} - -// automatic assignment operator -static int G__TSlsDetectorDict_85_0_7(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash) -{ - energyCalibration* dest = (energyCalibration*) G__getstructoffset(); - *dest = *(energyCalibration*) libp->para[0].ref; - const energyCalibration& obj = *dest; - result7->ref = (long) (&obj); - result7->obj.i = (long) (&obj); - return(1 || funcname || hash || result7 || libp) ; -} - - -/* angularCalibration */ -static int G__TSlsDetectorDict_87_0_1(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash) -{ - angularCalibration* p = NULL; - char* gvp = (char*) G__getgvp(); - int n = G__getaryconstruct(); - if (n) { - if ((gvp == (char*)G__PVOID) || (gvp == 0)) { - p = new angularCalibration[n]; - } else { - p = new((void*) gvp) angularCalibration[n]; - } - } else { - if ((gvp == (char*)G__PVOID) || (gvp == 0)) { - p = new angularCalibration; - } else { - p = new((void*) gvp) angularCalibration; - } - } - result7->obj.i = (long) p; - result7->ref = (long) p; - result7->type = 'u'; - result7->tagnum = G__get_linked_tagnum(&G__TSlsDetectorDictLN_angularCalibration); - return(1 || funcname || hash || result7 || libp) ; -} - -static int G__TSlsDetectorDict_87_0_2(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash) -{ - switch (libp->paran) { - case 1: - G__letint(result7, 105, (long) ((angularCalibration*) G__getstructoffset())->setDirection((int) G__int(libp->para[0]))); - break; - case 0: - G__letint(result7, 105, (long) ((angularCalibration*) G__getstructoffset())->setDirection()); - break; - } - return(1 || funcname || hash || result7 || libp) ; -} - -static int G__TSlsDetectorDict_87_0_3(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash) -{ - G__letdouble(result7, 102, (double) ((angularCalibration*) G__getstructoffset())->setEncoder((double) G__double(libp->para[0]))); - return(1 || funcname || hash || result7 || libp) ; -} - -static int G__TSlsDetectorDict_87_0_4(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash) -{ - G__letdouble(result7, 102, (double) ((angularCalibration*) G__getstructoffset())->getEncoder()); - return(1 || funcname || hash || result7 || libp) ; -} - -static int G__TSlsDetectorDict_87_0_5(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash) -{ - G__letdouble(result7, 102, (double) ((angularCalibration*) G__getstructoffset())->setTotalOffset((double) G__double(libp->para[0]))); - return(1 || funcname || hash || result7 || libp) ; -} - -static int G__TSlsDetectorDict_87_0_6(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash) -{ - G__letdouble(result7, 102, (double) ((angularCalibration*) G__getstructoffset())->getTotalOffset()); - return(1 || funcname || hash || result7 || libp) ; -} - -static int G__TSlsDetectorDict_87_0_7(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash) -{ - ((angularCalibration*) G__getstructoffset())->setAngularRange((double) G__double(libp->para[0]), (double) G__double(libp->para[1])); - G__setnull(result7); - return(1 || funcname || hash || result7 || libp) ; -} - -static int G__TSlsDetectorDict_87_0_8(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash) -{ - ((angularCalibration*) G__getstructoffset())->getAngularRange(*(double*) G__doubleref(&libp->para[0]), *(double*) G__doubleref(&libp->para[1])); - G__setnull(result7); - return(1 || funcname || hash || result7 || libp) ; -} - -// automatic copy constructor -static int G__TSlsDetectorDict_87_0_9(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash) - -{ - angularCalibration* p; - void* tmp = (void*) G__int(libp->para[0]); - p = new angularCalibration(*(angularCalibration*) tmp); - result7->obj.i = (long) p; - result7->ref = (long) p; - result7->type = 'u'; - result7->tagnum = G__get_linked_tagnum(&G__TSlsDetectorDictLN_angularCalibration); - return(1 || funcname || hash || result7 || libp) ; -} - -// automatic destructor -typedef angularCalibration G__TangularCalibration; -static int G__TSlsDetectorDict_87_0_10(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash) -{ - char* gvp = (char*) G__getgvp(); - long soff = G__getstructoffset(); - int n = G__getaryconstruct(); - // - //has_a_delete: 0 - //has_own_delete1arg: 0 - //has_own_delete2arg: 0 - // - if (!soff) { - return(1); - } - if (n) { - if (gvp == (char*)G__PVOID) { - delete[] (angularCalibration*) soff; - } else { - G__setgvp((long) G__PVOID); - for (int i = n - 1; i >= 0; --i) { - ((angularCalibration*) (soff+(sizeof(angularCalibration)*i)))->~G__TangularCalibration(); - } - G__setgvp((long)gvp); - } - } else { - if (gvp == (char*)G__PVOID) { - delete (angularCalibration*) soff; - } else { - G__setgvp((long) G__PVOID); - ((angularCalibration*) (soff))->~G__TangularCalibration(); - G__setgvp((long)gvp); - } - } - G__setnull(result7); - return(1 || funcname || hash || result7 || libp) ; -} - -// automatic assignment operator -static int G__TSlsDetectorDict_87_0_11(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash) -{ - angularCalibration* dest = (angularCalibration*) G__getstructoffset(); - *dest = *(angularCalibration*) libp->para[0].ref; - const angularCalibration& obj = *dest; - result7->ref = (long) (&obj); - result7->obj.i = (long) (&obj); - return(1 || funcname || hash || result7 || libp) ; -} - - -/* Setting up global function */ - -/********************************************************* -* Member function Stub -*********************************************************/ - -/* energyCalibration */ - -/* angularCalibration */ - -/********************************************************* -* Global function Stub -*********************************************************/ - -/********************************************************* -* Get size of pointer to member function -*********************************************************/ -class G__Sizep2memfuncTSlsDetectorDict { - public: - G__Sizep2memfuncTSlsDetectorDict(): p(&G__Sizep2memfuncTSlsDetectorDict::sizep2memfunc) {} - size_t sizep2memfunc() { return(sizeof(p)); } - private: - size_t (G__Sizep2memfuncTSlsDetectorDict::*p)(); -}; - -size_t G__get_sizep2memfuncTSlsDetectorDict() -{ - G__Sizep2memfuncTSlsDetectorDict a; - G__setsizep2memfunc((int)a.sizep2memfunc()); - return((size_t)a.sizep2memfunc()); -} - - -/********************************************************* -* virtual base class offset calculation interface -*********************************************************/ - - /* Setting up class inheritance */ - -/********************************************************* -* Inheritance information setup/ -*********************************************************/ -extern "C" void G__cpp_setup_inheritanceTSlsDetectorDict() { - - /* Setting up class inheritance */ -} - -/********************************************************* -* typedef information setup/ -*********************************************************/ -extern "C" void G__cpp_setup_typetableTSlsDetectorDict() { - - /* Setting up typedef entry */ -} - -/********************************************************* -* Data Member information setup/ -*********************************************************/ - - /* Setting up class,struct,union tag member variable */ - - /* energyCalibration */ -static void G__setup_memvarenergyCalibration(void) { - G__tag_memvar_setup(G__get_linked_tagnum(&G__TSlsDetectorDictLN_energyCalibration)); - { energyCalibration *p; p=(energyCalibration*)0x1000; if (p) { } - G__memvar_setup((void*)0,85,0,0,G__get_linked_tagnum(&G__TSlsDetectorDictLN_energyCalibrationFunctions),-1,-1,4,"funcs=",0,(char*)NULL); - G__memvar_setup((void*)0,105,0,0,-1,-1,-1,4,"plot_flag=",0,"*< 0 does not plot, >0 plots (flags?) */"); - G__memvar_setup((void*)0,105,0,0,-1,-1,-1,4,"cs_flag=",0,"*< 0 functions without charge sharing contribution, >0 with charge sharing contribution */"); - } - G__tag_memvar_reset(); -} - - - /* angularCalibration */ -static void G__setup_memvarangularCalibration(void) { - G__tag_memvar_setup(G__get_linked_tagnum(&G__TSlsDetectorDictLN_angularCalibration)); - { angularCalibration *p; p=(angularCalibration*)0x1000; if (p) { } - G__memvar_setup((void*)0,105,0,0,-1,-1,-1,4,"direction=",0,"*< angulat direction of the detector -can be +1 or -1 */"); - G__memvar_setup((void*)0,102,0,0,-1,-1,-1,4,"encoder=",0,"*< position of the detector encoder */"); - G__memvar_setup((void*)0,102,0,0,-1,-1,-1,4,"totalOffset=",0,"*< total offset of the detector */"); - G__memvar_setup((void*)0,102,0,0,-1,-1,-1,4,"ang_min=",0,"*< minimum of the angular range for peak fitting*/"); - G__memvar_setup((void*)0,102,0,0,-1,-1,-1,4,"ang_max=",0,"*< maximum of the angular range for peak fitting */"); - } - G__tag_memvar_reset(); -} - -extern "C" void G__cpp_setup_memvarTSlsDetectorDict() { -} -/*********************************************************** -************************************************************ -************************************************************ -************************************************************ -************************************************************ -************************************************************ -************************************************************ -***********************************************************/ - -/********************************************************* -* Member function information setup for each class -*********************************************************/ -static void G__setup_memfuncenergyCalibration(void) { - /* energyCalibration */ - G__tag_memfunc_setup(G__get_linked_tagnum(&G__TSlsDetectorDictLN_energyCalibration)); - G__memfunc_setup("energyCalibration",1778,G__TSlsDetectorDict_85_0_1, 105, G__get_linked_tagnum(&G__TSlsDetectorDictLN_energyCalibration), -1, 0, 0, 1, 1, 0, "", (char*)NULL, (void*) NULL, 0); - G__memfunc_setup("setPlotFlag",1125,G__TSlsDetectorDict_85_0_2, 105, -1, -1, 0, 1, 1, 1, 0, "i - - 0 '-1' p", (char*)NULL, (void*) NULL, 0); - G__memfunc_setup("setScanSign",1122,G__TSlsDetectorDict_85_0_3, 105, -1, -1, 0, 1, 1, 1, 0, "i - - 0 '0' s", (char*)NULL, (void*) NULL, 0); - G__memfunc_setup("setChargeSharing",1634,G__TSlsDetectorDict_85_0_4, 105, -1, -1, 0, 1, 1, 1, 0, "i - - 0 '-1' p", (char*)NULL, (void*) NULL, 0); - // automatic copy constructor - G__memfunc_setup("energyCalibration", 1778, G__TSlsDetectorDict_85_0_5, (int) ('i'), G__get_linked_tagnum(&G__TSlsDetectorDictLN_energyCalibration), -1, 0, 1, 1, 1, 0, "u 'energyCalibration' - 11 - -", (char*) NULL, (void*) NULL, 0); - // automatic destructor - G__memfunc_setup("~energyCalibration", 1904, G__TSlsDetectorDict_85_0_6, (int) ('y'), -1, -1, 0, 0, 1, 1, 0, "", (char*) NULL, (void*) NULL, 0); - // automatic assignment operator - G__memfunc_setup("operator=", 937, G__TSlsDetectorDict_85_0_7, (int) ('u'), G__get_linked_tagnum(&G__TSlsDetectorDictLN_energyCalibration), -1, 1, 1, 1, 1, 0, "u 'energyCalibration' - 11 - -", (char*) NULL, (void*) NULL, 0); - G__tag_memfunc_reset(); -} - -static void G__setup_memfuncangularCalibration(void) { - /* angularCalibration */ - G__tag_memfunc_setup(G__get_linked_tagnum(&G__TSlsDetectorDictLN_angularCalibration)); - G__memfunc_setup("angularCalibration",1874,G__TSlsDetectorDict_87_0_1, 105, G__get_linked_tagnum(&G__TSlsDetectorDictLN_angularCalibration), -1, 0, 0, 1, 1, 0, "", (char*)NULL, (void*) NULL, 0); - G__memfunc_setup("setDirection",1261,G__TSlsDetectorDict_87_0_2, 105, -1, -1, 0, 1, 1, 1, 0, "i - - 0 '0' d", (char*)NULL, (void*) NULL, 0); - G__memfunc_setup("setEncoder",1036,G__TSlsDetectorDict_87_0_3, 102, -1, -1, 0, 1, 1, 1, 0, "f - - 0 - f", (char*)NULL, (void*) NULL, 0); - G__memfunc_setup("getEncoder",1024,G__TSlsDetectorDict_87_0_4, 102, -1, -1, 0, 0, 1, 1, 0, "", (char*)NULL, (void*) NULL, 0); - G__memfunc_setup("setTotalOffset",1463,G__TSlsDetectorDict_87_0_5, 102, -1, -1, 0, 1, 1, 1, 0, "f - - 0 - f", (char*)NULL, (void*) NULL, 0); - G__memfunc_setup("getTotalOffset",1451,G__TSlsDetectorDict_87_0_6, 102, -1, -1, 0, 0, 1, 1, 0, "", (char*)NULL, (void*) NULL, 0); - G__memfunc_setup("setAngularRange",1539,G__TSlsDetectorDict_87_0_7, 121, -1, -1, 0, 2, 1, 1, 0, -"f - - 0 - mi f - - 0 - ma", (char*)NULL, (void*) NULL, 0); - G__memfunc_setup("getAngularRange",1527,G__TSlsDetectorDict_87_0_8, 121, -1, -1, 0, 2, 1, 1, 0, -"f - - 1 - mi f - - 1 - ma", (char*)NULL, (void*) NULL, 0); - // automatic copy constructor - G__memfunc_setup("angularCalibration", 1874, G__TSlsDetectorDict_87_0_9, (int) ('i'), G__get_linked_tagnum(&G__TSlsDetectorDictLN_angularCalibration), -1, 0, 1, 1, 1, 0, "u 'angularCalibration' - 11 - -", (char*) NULL, (void*) NULL, 0); - // automatic destructor - G__memfunc_setup("~angularCalibration", 2000, G__TSlsDetectorDict_87_0_10, (int) ('y'), -1, -1, 0, 0, 1, 1, 0, "", (char*) NULL, (void*) NULL, 0); - // automatic assignment operator - G__memfunc_setup("operator=", 937, G__TSlsDetectorDict_87_0_11, (int) ('u'), G__get_linked_tagnum(&G__TSlsDetectorDictLN_angularCalibration), -1, 1, 1, 1, 1, 0, "u 'angularCalibration' - 11 - -", (char*) NULL, (void*) NULL, 0); - G__tag_memfunc_reset(); -} - - -/********************************************************* -* Member function information setup -*********************************************************/ -extern "C" void G__cpp_setup_memfuncTSlsDetectorDict() { -} - -/********************************************************* -* Global variable information setup for each class -*********************************************************/ -static void G__cpp_setup_global0() { - - /* Setting up global variables */ - G__resetplocal(); - - - G__resetglobalenv(); -} -extern "C" void G__cpp_setup_globalTSlsDetectorDict() { - G__cpp_setup_global0(); -} - -/********************************************************* -* Global function information setup for each class -*********************************************************/ -static void G__cpp_setup_func0() { - G__lastifuncposition(); - -} - -static void G__cpp_setup_func1() { -} - -static void G__cpp_setup_func2() { - - G__resetifuncposition(); -} - -extern "C" void G__cpp_setup_funcTSlsDetectorDict() { - G__cpp_setup_func0(); - G__cpp_setup_func1(); - G__cpp_setup_func2(); -} - -/********************************************************* -* Class,struct,union,enum tag information setup -*********************************************************/ -/* Setup class/struct taginfo */ -G__linked_taginfo G__TSlsDetectorDictLN_energyCalibrationFunctions = { "energyCalibrationFunctions" , 99 , -1 }; -G__linked_taginfo G__TSlsDetectorDictLN_energyCalibration = { "energyCalibration" , 99 , -1 }; -G__linked_taginfo G__TSlsDetectorDictLN_angularCalibration = { "angularCalibration" , 99 , -1 }; - -/* Reset class/struct taginfo */ -extern "C" void G__cpp_reset_tagtableTSlsDetectorDict() { - G__TSlsDetectorDictLN_energyCalibrationFunctions.tagnum = -1 ; - G__TSlsDetectorDictLN_energyCalibration.tagnum = -1 ; - G__TSlsDetectorDictLN_angularCalibration.tagnum = -1 ; -} - - -extern "C" void G__cpp_setup_tagtableTSlsDetectorDict() { - - /* Setting up class,struct,union tag entry */ - G__get_linked_tagnum_fwd(&G__TSlsDetectorDictLN_energyCalibrationFunctions); - G__tagtable_setup(G__get_linked_tagnum(&G__TSlsDetectorDictLN_energyCalibration),sizeof(energyCalibration),-1,1280,(char*)NULL,G__setup_memvarenergyCalibration,G__setup_memfuncenergyCalibration); - G__tagtable_setup(G__get_linked_tagnum(&G__TSlsDetectorDictLN_angularCalibration),sizeof(angularCalibration),-1,1280,(char*)NULL,G__setup_memvarangularCalibration,G__setup_memfuncangularCalibration); -} -extern "C" void G__cpp_setupTSlsDetectorDict(void) { - G__check_setup_version(30051515,"G__cpp_setupTSlsDetectorDict()"); - G__set_cpp_environmentTSlsDetectorDict(); - G__cpp_setup_tagtableTSlsDetectorDict(); - - G__cpp_setup_inheritanceTSlsDetectorDict(); - - G__cpp_setup_typetableTSlsDetectorDict(); - - G__cpp_setup_memvarTSlsDetectorDict(); - - G__cpp_setup_memfuncTSlsDetectorDict(); - G__cpp_setup_globalTSlsDetectorDict(); - G__cpp_setup_funcTSlsDetectorDict(); - - if(0==G__getsizep2memfunc()) G__get_sizep2memfuncTSlsDetectorDict(); - return; -} -class G__cpp_setup_initTSlsDetectorDict { - public: - G__cpp_setup_initTSlsDetectorDict() { G__add_setup_func("TSlsDetectorDict",(G__incsetup)(&G__cpp_setupTSlsDetectorDict)); G__call_setup_funcs(); } - ~G__cpp_setup_initTSlsDetectorDict() { G__remove_setup_func("TSlsDetectorDict"); } -}; -G__cpp_setup_initTSlsDetectorDict G__cpp_setup_initializerTSlsDetectorDict; - diff --git a/slsDetectorSoftware/slsDetectorAnalysis/TSlsDetectorDict.h b/slsDetectorSoftware/slsDetectorAnalysis/TSlsDetectorDict.h deleted file mode 100644 index 0d2cea9fb..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/TSlsDetectorDict.h +++ /dev/null @@ -1,42 +0,0 @@ -/******************************************************************** -* TSlsDetectorDict.h -* CAUTION: DON'T CHANGE THIS FILE. THIS FILE IS AUTOMATICALLY GENERATED -* FROM HEADER FILES LISTED IN G__setup_cpp_environmentXXX(). -* CHANGE THOSE HEADER FILES AND REGENERATE THIS FILE. -********************************************************************/ -#ifdef __CINT__ -#error TSlsDetectorDict.h/C is only for compilation. Abort cint. -#endif -#include -#include -#include -#include -#include -#define G__ANSIHEADER -#define G__DICTIONARY -#include "cint/G__ci.h" -extern "C" { -extern void G__cpp_setup_tagtableTSlsDetectorDict(); -extern void G__cpp_setup_inheritanceTSlsDetectorDict(); -extern void G__cpp_setup_typetableTSlsDetectorDict(); -extern void G__cpp_setup_memvarTSlsDetectorDict(); -extern void G__cpp_setup_globalTSlsDetectorDict(); -extern void G__cpp_setup_memfuncTSlsDetectorDict(); -extern void G__cpp_setup_funcTSlsDetectorDict(); -extern void G__set_cpp_environmentTSlsDetectorDict(); -} - - -#include "TObject.h" -#include "TMemberInspector.h" -#include "energyCalibration.h" -#include "angularCalibration.h" - -#ifndef G__MEMFUNCBODY -#endif - -extern G__linked_taginfo G__TSlsDetectorDictLN_energyCalibrationFunctions; -extern G__linked_taginfo G__TSlsDetectorDictLN_energyCalibration; -extern G__linked_taginfo G__TSlsDetectorDictLN_angularCalibration; - -/* STUB derived class for protected member access */ diff --git a/slsDetectorSoftware/slsDetectorAnalysis/angCalLogClass.h b/slsDetectorSoftware/slsDetectorAnalysis/angCalLogClass.h deleted file mode 100644 index b366b58a1..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/angCalLogClass.h +++ /dev/null @@ -1,153 +0,0 @@ -#ifndef ANGCALLOGCLASS_H -#define ANGCALLOGCLASS_H - -#include -#include -#ifdef __CINT__ -#define MYROOT -#endif - -#ifndef MYROOT -#include "slsDetectorCommand.h" -#include "slsDetectorUtils.h" -#include "sls_detector_defs.h" -#endif - -; - -class angCalLogClass { - - - public: - - -#ifndef MYROOT - angCalLogClass(slsDetectorUtils *det){ createVars(); - char cmd[1000]; \ - char *argv[2]; \ - argv[0]=cmd; \ - sprintf(cmd,"_%d.angcal",det->getFileIndex()); \ - outfile.open( std::string(det->getFilePath()+ std::string("/")+det->getFileName()+ std::string(cmd)).c_str()); \ - outfile.precision(8); - myDet=new slsDetectorCommand(det); \ - if (outfile.is_open()) { \ - for (int iv=0; ivexecuteLine(1,argv,slsDetectorDefs::GET_ACTION) << endl; \ - }; \ - }; \ - }; - ~angCalLogClass(){delete myDet; outfile.close();}; -#else - angCalLogClass() { createVars(); }; - ~angCalLogClass(){}; -#endif - - - int addStep(double pos, std::string fname) {std::cout.precision(5); outfile << pos << " " << fname << endl; return 0;}; - - - // - - int readHeader(std::ifstream &infile, int &maxmod, int &nmod, int &chanspermod, char *angconvfile, double &globaloff, double &fineoff, int &angdir, char *ffdir, char *fffile, char *badfile ) { \ - nmod=0; chanspermod=0; globaloff=0; fineoff=0; angdir=1; \ - strcpy(angconvfile,"none"); strcpy(ffdir,"none"); strcpy(fffile,"none"); strcpy(badfile,"none"); \ - char line[1000], myvar[100], myarg[100]; \ - float v; \ - for (int iv=0; ivcenter; \ - ecenter=acc->ecenter; \ - r_conversion=acc->r_conversion; \ - er_conversion=acc->er_conversion; \ - offset=acc->offset; \ - eoffset=acc->eoffset; \ - tilt=acc->tilt; \ - etilt=acc->etilt; \ - }; - - - -}; - -#endif diff --git a/slsDetectorSoftware/slsDetectorAnalysis/angularCalibration.cpp b/slsDetectorSoftware/slsDetectorAnalysis/angularCalibration.cpp deleted file mode 100644 index 08fa890a3..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/angularCalibration.cpp +++ /dev/null @@ -1,471 +0,0 @@ -#include "angularCalibration.h" - -#include -#ifdef ROOT -#include -#include -#endif - -#include "usersFunctions.h" - -#ifdef __CINT -#include "usersFunctions.cpp" -#endif - -using namespace std; - -angularCalibration::angularCalibration(int nm): direction(1), -#ifdef ROOT - fpeak(NULL), - fangle(NULL), -#endif - encoder(0), - totalOffset(0), - ang_min(-180), - ang_max(180), - nmod(nm), - nchmod(1280), - angConv(NULL) -{ - -#ifdef ROOT -// Creates a Root function based on function peakfunction - TF1 *fpeak = new TF1("fpeak",this,&angularCalibration::peakFunction,ang_min,ang_max,5,"angularCalibration","peakFunction"); - -// Sets initial values and parameter names - // func->SetParameters((Double_t) PEAKHEIGHT, (Double_t) maxch,(Double_t) PEAKWIDTH,(Double_t) PEAKBACK); - fpeak->SetParNames("Number of Photons","Peak Position","Peak Width RMS","Background Offset", "Background Slope"); - - - TF1 *fangle = new TF1("fangle",this,&angularCalibration::angleFunction,0,1280,3,"angularCalibration","angleFunction"); - fangle->SetParNames("Center","Conversion Radius","Offset"); - -#endif - - angConv=new angleConversionConstant[nmod]; - -} - -angularCalibration::~angularCalibration(){ -#ifdef ROOT - delete fpeak; - delete fangle; - -#endif -} - - - -angleConversionConstant* angularCalibration::getAngularConversionConstant(int imod) { - if (imod>=0 && imod=0 && imodcenter; - angConv[imod].ecenter=a->ecenter; - angConv[imod].r_conversion=a->r_conversion; - angConv[imod].er_conversion=a->er_conversion; - angConv[imod].offset=a->offset; - angConv[imod].eoffset=a->eoffset; - angConv[imod].tilt=a->tilt; - angConv[imod].etilt=a->etilt; - - return angConv+imod; - } - return NULL; - - -} - - - - - -#ifdef ROOT - -Double_t angularCalibration::peakFunction(Double_t *x, Double_t *par) { - Double_t arg = 0; - if (par[2] != 0) arg = (x[0] - par[1])/par[2]; - return par[0]*TMath::Exp(-0.5*arg*arg)+par[3]+par[4]*(x[0]-par[1]); - -} - -Double_t angularCalibration::angleFunction(Double_t *x, Double_t *par) { - return par[2]-angle((int)x[0],0,0,par[1],par[0],0,0,direction); -} - - - - - - - -TF1 *fitPeak(TH1 *h) { - - TF1 *fitfun=NULL; - int chmod, imod; - double ang; - -// reads in a run and fits a gaussian to the peak as function -// of channel number also reads optical encoder - - -// find angular range in channels - -// is it necessary to discard fit with too many points? - for (int i=0;iGetNbinsX();i++) { - imod=i/nchmod; - chmod=i%(imod*nchmod); - ang=angle(chmod,encoder,totalOffset,angConv[imod].r_conversion, angConv[imod].center, angConv[imod].offset, angConv[imod].tilt, direction); - if ((ang>ang_min) && (angminang) && (angle(i)MAXINPEAK) { -// printf("too many points in angular range !\n"); -// return -1; // too many points in range -// } -// if ( data[i]> max) { -// max = (int) data[i]; -// maxch = i; -// } -// } -// } -// } else -// return -1; - -// npoints--; -// chmin= (int) x[0]; -// chmax= (int) x[npoints]; - -// printf("number of points in range %f-%f: %i \n",minang,maxang,npoints); -// printf("channel from minang to maxang %i - %i \n",chmin,chmax); -// printf("channel with max intensity %i \n",maxch); - -// TCanvas *c1; - -// TGraph *gr1 = new TGraph(npoints,anglefit,y); -// TGraph *gr2 = new TGraph(npoints,x,y); -// if (plotflag) { -// /* create canvas */ - -// c1 = new TCanvas(); -// c1->SetTitle("Si calibration data"); -// c1->Divide(1,2); - -// /* create graph */ - -// sprintf(name,"run number %i",nr); -// gr1->SetTitle(name); -// gr2->SetTitle(name); - -// c1->cd(1); -// gr1->Draw("AL*"); -// c1->cd(2); -// gr2->Draw("AL*"); -// } - -// /* do not fit if peak is close to edge of module */ -// if (abs(modfromchannel(maxch)*NCHMOD-maxch)Fit("fitpeak","B"); -// else -// gr2->Fit("fitpeak","B0"); - -// TF1 *fit = gr2->GetFunction("fitpeak"); - -// // writes the fit results into the par array -// fit->GetParameters(mypar); - -// printf("\n"); -// for (i=0;i<4;i++) { -// myerr[i] = fit->GetParError(i); // obtain fit parameter errors -// printf("parameter %i: %f +- %f \n",i,mypar[i],myerr[i]); -// } - -// chi2=fit->GetChisquare(); -// printf("chi2: %e\n",chi2); -// printf("\n\n"); - -// if (chi2>CHIMAX) { -// printf("chi2 too large!\n"); -// return -1; -// } - -// if (plotflag) -// c1->Update(); // necessary for axis titles! -// // c1->WaitPrimitive(); - -// return 0; - - return fitfun; - -} - - -#endif - - - -// // -// // for detector angular calibration -// // -// // loops over runs fits a peak in each run and then fits the parameters for -// // the angular calibration to the fitted peak and optical encoder values -// // -// // -// // note: -// // setting global offset is important to find peak in peak fitting! -// // also set peak height,width and background in defines at beginning -// // - -// void fitangle(char fname[80],char extension[10], int start, int stop, double startangle, double stopangle) { - -// int i,nfit,mod,npoints,nnpoints; -// double x[MAXINMODULE],y[MAXINMODULE],ex[MAXINMODULE],ey[MAXINMODULE],min,max; -// double xx[MAXINMODULE],yy[MAXINMODULE],exx[MAXINMODULE],eyy[MAXINMODULE]; - -// double channelfit[MAXRUN], channelerror[MAXRUN], encoderfit[MAXRUN]; -// int runnrfit[MAXRUN], modulenr[MAXRUN]; - - -// FILE *fp; -// char name[80]; -// TCanvas *c1,*c2; -// gROOT->Reset(); // reset root -// // gStyle->SetOptFit(1110); - -// nfit=0; -// for (i=start;iSetTitle("Si calibration data"); -// /* create graph for angle vs fitted channel number */ -// gr3->Draw("AL*"); - -// c1->Update(); // necessary for axis titles! -// c1->WaitPrimitive(); - -// delete c1; -// } -// TH1F *herr=new TH1F("herr","",100,0,0.002); - - -// for (mod=0;mod5) { - -// // create canvas -// if (plotflag) { -// TCanvas *c2 = new TCanvas(); -// c2->SetTitle("Si calibration data"); -// c2->Divide(1,3); -// } -// // create graph -// TGraphErrors *gr1 = new TGraphErrors(npoints,x,y,ex,ey); -// sprintf(name,"module number %i",mod); -// gr1->SetTitle(name); -// if (plotflag) { -// c2->cd(1); -// gr1->Draw("ALP"); -// } - - -// // Creates a Root function based on function anglefunction -// if (x[0]>x[npoints-1]) { -// min=x[npoints-1]; -// max=x[0]; -// } else { -// max=x[npoints-1]; -// min=x[0]; -// } - - -// TF1 *func = new TF1("fitangle",anglefunction,min,max,3); - -// // Sets initial values and parameter names -// func->SetParameters(640,0.0000656,-mod*5.0); -// func->SetParNames("center","conversion","offset"); -// func->FixParameter(0,640.0); -// if (plotflag) { -// gr1->Fit("fitangle"); // fit the function -// } else -// gr1->Fit("fitangle","0"); // fit the function - - -// // calculate the deviations of data points from fitted function and plot them -// for (i=0;iEval(x[i])-y[i]; -// } -// TGraph *gr4 = new TGraph(npoints,x,ey); -// sprintf(name,"module number %i deviations from fit",mod); -// gr4->SetTitle(name); - -// if (plotflag) { -// gr4->SetMarkerStyle(24); -// c2->cd(2); -// gr4->Draw("ALP"); -// } - - -// // iterate fit with outlying points excluded -// nnpoints=0; -// for (i=0;iFit("fitangle"); // fit the function -// } else -// gr3->Fit("fitangle","0"); // fit the function - - -// // calculate the deviations of data points from fitted function and plot them -// for (i=0;iEval(xx[i])-yy[i]; -// herr->Fill(eyy[i]); -// } - -// TGraph *gr5 = new TGraph(nnpoints,xx,eyy); -// sprintf(name,"module number %i deviations from fit second iteration",mod); -// if (plotflag) { -// c2->cd(3); -// gr5->SetTitle(name); -// gr5->SetMarkerStyle(24); - -// gr5->Draw("ALP"); - - -// c2->Update(); // necessary for axis titles? -// c2->WaitPrimitive(); - -// } - -// // writes the fit results into the par array -// // -// // get fit parameter -// func->GetParameters(mypar); - -// for (i=0;i<3;i++) { -// myerr[i] = func->GetParError(i); // obtain fit parameter errors -// printf("parameter %i: %E +- %E \n",i,mypar[i],myerr[i]); -// } -// printf("\n\n"); - -// center[mod]=mypar[0]; -// errcenter[mod]=myerr[0]; -// conversion[mod]=mypar[1]; -// errconversion[mod]=myerr[1]; -// moffset[mod]=mypar[2]; -// erroff[mod]=myerr[2]; - -// delete gr1; -// delete gr4; -// delete gr5; -// delete func; -// delete c2; -// } -// } -// //herr->GetXaxis()->SetMaxDigits(3); -// herr->GetXaxis()->SetTitle("Deviations from fit (deg)"); -// herr->Draw(); - - -// printf("\n\n\n"); -// for (mod=0;mod -#include -class TH1; -#endif - - //double angle(int ichan, double encoder, double totalOffset, double conv_r, double center, double offset, double tilt, int direction) - - - -class angularCalibration { - - public: - angularCalibration(int nm=48); - ~angularCalibration(); - - /** - sets the angular direction of the detector - \par d 1 or -1 set the angular direction, other valuse simply get - \returns the angular direction of the detector - */ - int setDirection(int d=0){if (d==-1 || d==1) direction=d; return direction;}; - - /** - sets the encoder position - \param f encoder position to be set - \returns current encoder position - */ - double setEncoder(double f) {encoder=f; return encoder;}; - - /** - gets the encoder position - \returns encoder position - */ - double getEncoder() {return encoder;}; - - /** - sets the totalOffset of the detector - \param f total offset to be set - \returns current total offset - */ - double setTotalOffset(double f) {totalOffset=f; return totalOffset;}; - - /** - gets the encoder position - \returns encoder position - */ - double getTotalOffset() {return totalOffset;}; - - - - - /** - sets the angular range for peak fitting - \param mi minimum of the angular range - \param ma maximum of the angular range - */ - void setAngularRange(double mi, double ma){ang_min=mi; ang_max=ma;}; - - - /** - gets the angular range for peak fitting - \param mi reference to the minimum of the angular range - \param ma reference to the maximum of the angular range - */ - void getAngularRange(double &mi, double &ma){mi=ang_min; ma=ang_max;}; - - - /** sets and returns the number of modules - \param nm number of modules to be set (<0 gets) - \return current number of modules - */ - int setNumberOfModules(int nm=-1) {if (nm>=0) nmod=nm; return nmod;}; - - /** sets and returns the number of channels per module - \param n number of channels per module to be set (<0 gets) - \return current number of channels per module - */ - int setChannelsPerModule(int n=-1) {if (n>0) nchmod=n; return nchmod;}; - - angleConversionConstant *getAngularConversionConstant(int imod=0); - angleConversionConstant *setAngularConversionConstant(angleConversionConstant *a, int imod=0); - - -#ifdef ROOT - - /** - Gaussian with pedestal describing a peak - par[0] is the heigh of the pean - par[1] is the peak position - par[2] is the peak width - par[3] is the background offset - par[4] is the background slope - */ - Double_t peakFunction(Double_t *x, Double_t *par); - - - /** - Angular conversion function - par[0] is the module center - par[1] is the conversion radius (pitch/radius) - par[2] is the module offset - */ - Double_t angleFunction(Double_t *x, Double_t *par); - - /** - Fits a peak for the angular calibration - \param h histogram channels versus intensity - \returns fitted function or NULL if fit failed - */ - TF1 *fitPeak(TH1 *h); - -#endif - - - private: - - int direction; /**< angular direction of the detector -can be +1 or -1 */ - -#ifdef ROOT - TF1 *fpeak; /**< Root function based on function peakFunction */ - - TF1 *fangle; /**< Root function based on function angleFunction */ - -#endif - double encoder; /**< position of the detector encoder */ - double totalOffset; /**< total offset of the detector */ - double ang_min; /**< minimum of the angular range for peak fitting*/ - double ang_max; /**< maximum of the angular range for peak fitting */ - - int nmod; - int nchmod; - - angleConversionConstant angConv[MAXMOD*MAXDET]; - - - - - -/* void fitangle(char fname[80],char extension[10], int start, int stop, double startangle, double stopangle); //fits all datasets and extracts the constants */ -/* int fitpeak(char fname[80],char extension[10], int nr, double minang, double maxang); // fits a peak from a pattern using nominal calibration constant */ - - -}; - -#endif diff --git a/slsDetectorSoftware/slsDetectorAnalysis/angularConversion.cpp b/slsDetectorSoftware/slsDetectorAnalysis/angularConversion.cpp deleted file mode 100644 index 226e2dbc0..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/angularConversion.cpp +++ /dev/null @@ -1,308 +0,0 @@ -#include "angularConversion.h" - -#include -#include -#include -#include -#include - - -using namespace std; - -angularConversion::angularConversion(): angularConversionStatic(), currentPosition(0), - currentPositionIndex(0) - -{ - //angleFunctionPointer=0; - // registerAngleFunctionCallback(&defaultAngleFunction); - -} - -angularConversion::~angularConversion(){ - -} - - - - -double* angularConversion::convertAngles(double pos) { - - int nmod=getNMods(); - int *chansPerMod=new int[nmod]; - angleConversionConstant **angOff=new angleConversionConstant*[nmod]; - int *mF=new int[nmod]; - double fo=*fineOffset; - double go=*globalOffset; - int angdir=*angDirection; - - - - for (int im=0; im0) { - *binSize=v; - nBins=(int)(360./(*binSize))+1; - } - return *binSize; - case MOVE_FLAG: - if (moveFlag) { - if (v>0) - *moveFlag=1; - else if (v==0) - *moveFlag=0; - return *moveFlag; - } - return -1; - case SAMPLE_X: - if (sampleDisplacement) { - sampleDisplacement[X]=v; - return sampleDisplacement[X]; - } - return 0; - case SAMPLE_Y: - if (sampleDisplacement) { - sampleDisplacement[Y]=v; - return sampleDisplacement[Y]; - } - return 0; - default: - return 0; - } -} - - /** - returns the value of an angular conversion parameter - \param c can be ANGULAR_DIRECTION, GLOBAL_OFFSET, FINE_OFFSET, BIN_SIZE - \returns the actual value - - */ - -double angularConversion::getAngularConversionParameter(angleConversionParameter c) { - - switch (c) { - case ANGULAR_DIRECTION: - return *angDirection; - case GLOBAL_OFFSET: - return *globalOffset; - case FINE_OFFSET: - return *fineOffset; - case BIN_SIZE: - if (*binSize>0) - nBins=(int)(360./(*binSize))+1; - else - nBins=0; - return *binSize; - case MOVE_FLAG: - if (moveFlag) - return *moveFlag; - else - return -1; - default: - return 0; - } -} - - - - -int angularConversion::setAngularConversionFile(string fname) { - if (fname=="") { - setAngularCorrectionMask(0); -#ifdef VERBOSE - std::cout << "Unsetting angular conversion" << std::endl; -#endif - } else { - if (fname=="default") { - fname=string(angConvFile); - } - -#ifdef VERBOSE - std::cout << "Setting angular conversion to " << fname << std:: endl; -#endif - if (readAngularConversionFile(fname)>=0) { - setAngularCorrectionMask(1); - strcpy(angConvFile,fname.c_str()); - } - } - return setAngularCorrectionMask(); -} - - - - - - /* - set positions for the acquisition - \param nPos number of positions - \param pos array with the encoder positions - \returns number of positions - */ -int angularConversion::setPositions(int nPos, double *pos){ - if (nPos>=0) - *numberOfPositions=nPos; - for (int ip=0; ip -#include - -#include "angularConversionStatic.h" - - //double angle(int ichan, double encoder, double totalOffset, double conv_r, double center, double offset, double tilt, int direction) - - -// - -/** - @short Angular conversion constants needed for a detector module - */ - - -/** - -@short methods to set/unset the angular conversion and merge the data -class containing the methods to set/unset the angular conversion and merge the data - - -The angular conversion itself is defined by the angle() function defined in usersFunctions.cpp - -*/ -class angularConversion : public virtual slsDetectorBase, public angularConversionStatic - -{ - - public: - /** default constructor */ - angularConversion(); - /** virtual destructor */ - virtual ~angularConversion(); - - - - //virtual int readAngularConversion(string fname)=0; - - using angularConversionStatic::writeAngularConversion; - using angularConversionStatic::readAngularConversion; - - - - /** - pure virtual function - \param file name to be written (nmod and array of angular conversion constants default to the ones ot the slsDetector - */ - virtual int writeAngularConversion(std::string fname)=0; - /** - sets the arrays of the merged data to 0. NB The array should be created with size >= 360./getBinSize(); - \param mp already merged postions - \param mv already merged data - \param me already merged errors (squared sum) - \param mm multiplicity of merged arrays - \returns OK or FAIL - */ - int resetMerging(double *mp, double *mv,double *me, int *mm); - - /** - creates the arrays for merging the data and sets them to 0. - */ - int resetMerging(); - - - /** - merge dataset - \param p1 angular positions of dataset - \param v1 data - \param e1 errors - \param mp already merged postions - \param mv already merged data - \param me already merged errors (squared sum) - \param mm multiplicity of merged arrays - \param badChanMask badchannelmask (if NULL does not correct for bad channels) - \returns OK or FAIL - */ - - int addToMerging(double *p1, double *v1, double *e1, double *mp, double *mv,double *me, int *mm, int *badChanMask); - /** - merge dataset - \param p1 angular positions of dataset - \param v1 data - \param e1 errors - \param badChanMask badchannelmask (if NULL does not correct for bad channels) - \returns OK or FAIL - */ - - int addToMerging(double *p1, double *v1, double *e1,int *badChanMask); - - /** - calculates the "final" positions, data value and errors for the merged data - \param mp already merged postions - \param mv already merged data - \param me already merged errors (squared sum) - \param mm multiplicity of merged arrays - \returns FAIL or the number of non empty bins (i.e. points belonging to the pattern) - */ - - int finalizeMerging(double *mp, double *mv,double *me, int *mm); - -/** - calculates the "final" positions, data value and errors for the merged data - \returns FAIL or the number of non empty bins (i.e. points belonging to the pattern) - */ - - int finalizeMerging(); - - - /** - set detector global offset - \param f global offset to be set - \returns actual global offset - */ - double setGlobalOffset(double f){return setAngularConversionParameter(GLOBAL_OFFSET,f);}; - - - /** - set detector fine offset - \param f global fine to be set - \returns actual fine offset - */ - double setFineOffset(double f){return setAngularConversionParameter(FINE_OFFSET,f);}; - - /** - get detector fine offset - \returns actual fine offset - */ - double getFineOffset(){return getAngularConversionParameter(FINE_OFFSET);}; - - /** - get detector global offset - \returns actual global offset - */ - double getGlobalOffset(){return getAngularConversionParameter(GLOBAL_OFFSET);}; - - /** - - set detector bin size - \param bs bin size to be set - \returns actual bin size - */ - double setBinSize(double bs){if (bs>0) nBins=(int)(360./bs); return setAngularConversionParameter(BIN_SIZE,bs);}; - - /** - get detector bin size - \returns detector bin size used for merging (approx angular resolution) - */ - double getBinSize() {return getAngularConversionParameter(BIN_SIZE);}; - - - - /** - - get angular direction - \returns actual angular direction (1 is channel number increasing with angle, -1 decreasing) - */ - int getAngularDirection(){return (int)getAngularConversionParameter(ANGULAR_DIRECTION);}; - - - /** - - set angular direction - \param d angular direction to be set (1 is channel number increasing with angle, -1 decreasing) - \returns actual angular direction (1 is channel number increasing with angle, -1 decreasing) - */ - int setAngularDirection(int d){return (int)setAngularConversionParameter(ANGULAR_DIRECTION, (double)d);}; - - /** - \returns number of angular bins in the merging (360./binsize) - */ - int getNumberOfAngularBins(){return nBins;}; - - /** - get angular conversion - \param direction reference to diffractometer direction - \param angconv array that will be filled with the angular conversion constants - \returns 0 if angular conversion disabled, >0 otherwise - */ - virtual int getAngularConversion(int &direction, angleConversionConstant *angconv=NULL)=0; - - - /** - set angular conversion parameter - \param c parameter type (globaloffset, fineoffset, binsize, angular direction, move flag) - \param v value to be set - \returns actual value - */ - double setAngularConversionParameter(angleConversionParameter c, double v); - /** - get angular conversion parameter - \param c parameter type (globaloffset, fineoffset, binsize, angular direction, move flag) - \returns actual value - */ - double getAngularConversionParameter(angleConversionParameter c); - - - - - /** - set positions for the acquisition - \param nPos number of positions - \param pos array with the encoder positions - \returns number of positions - */ - virtual int setPositions(int nPos, double *pos); - /** - get positions for the acquisition - \param pos array which will contain the encoder positions - \returns number of positions - */ - virtual int getPositions(double *pos=NULL); - - /** - deletes the array of merged data - \returns OK - */ - int deleteMerging(); - - /** - \returns pointer to the array o merged positions - */ - double *getMergedPositions(){return mergingBins;}; - /** - \returns pointer to the array of merged counts - */ - double *getMergedCounts(){return mergingCounts;}; - /** - \returns pointer to the array of merged errors - */ - double *getMergedErrors(){return mergingErrors;}; - - - - /** - sets the angular conversion file - \param fname file to read - \returns angular conversion flag - */ - - int setAngularConversionFile(std::string fname); - - - /** - returns the angular conversion file - */ - std::string getAngularConversionFile(){if (setAngularCorrectionMask()) return std::string(angConvFile); else return std::string("none");}; - - - /** - reads teh angular conversion file for the (multi)detector and writes it to shared memory - */ - virtual int readAngularConversionFile(std::string fname="")=0; - - - - - - /** - \returns number of modules of the (multi)detector - */ - virtual int getNMods()=0; - - /** - returns number of channels in the module - \param imod module number - \returns number of channels in the module - */ - virtual int getChansPerMod(int imod=0)=0; - - /** - get the angular conversion contant of one modules - \param imod module number - \returns pointer to the angular conversion constant - */ - virtual angleConversionConstant *getAngularConversionPointer(int imod=0)=0; - - /** - converts channel number to angle - \param pos encoder position - \returns array of angles corresponding to the channels - */ - double* convertAngles(double pos); - - - - /** - converts channel number to angle for the current encoder position - \returns array of angles corresponding to the channels - */ - double *convertAngles(){return convertAngles(currentPosition);}; - - /** - \param imod module number - \returns move flag of the module (1 encoder is added to the angle, 0 not) - Shold be module dependent! - */ - virtual int getMoveFlag(int imod)=0; - - /** - returns number of positions - */ - int getNumberOfPositions() {return *numberOfPositions;}; - - - - protected: - - - /** pointer to number of positions for the acquisition*/ - int *numberOfPositions; - - /** pointer to the detector positions for the acquisition*/ - double *detPositions; - - /** pointer to angular conversion file name*/ - char *angConvFile; - - /** pointer to angular bin size*/ - double *binSize; - - /** pointer to beamlien fine offset*/ - double *fineOffset; - /** pointer to beamlien global offset*/ - double *globalOffset; - /** pointer to beamlien angular direction*/ - int *angDirection; - /** pointer to detector move flag (1 moves with encoder, 0 not)*/ - int *moveFlag; - - /** number of bins for angular conversion (360./binsize)*/ - int nBins; - - - - double *sampleDisplacement; - - /** - current position of the detector - */ - double currentPosition; - /** - current position index of the detector - */ - int currentPositionIndex; - - - /** - enables/disable the angular conversion - \param i 1 sets, 0 unsets,, -1 gets - \returns actual angular conversion flag - */ - virtual int setAngularCorrectionMask(int i=-1)=0; - - /** - returns current position index - */ - int getCurrentPositionIndex() {return currentPositionIndex;}; - void incrementPositionIndex() {currentPositionIndex++;}; - void resetPositionIndex() {currentPositionIndex=0;}; - - - - - - - private: - - - - - // int nChans; - // int nMods; - // int chansPerMod; - // int moveFlag; - - - - - /** merging bins */ - double *mergingBins; - - /** merging counts */ - double *mergingCounts; - - /** merging errors */ - double *mergingErrors; - - /** merging multiplicity */ - int *mergingMultiplicity; - -}; - -#endif diff --git a/slsDetectorSoftware/slsDetectorAnalysis/angularConversionStatic.cpp b/slsDetectorSoftware/slsDetectorAnalysis/angularConversionStatic.cpp deleted file mode 100644 index 0e9df564b..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/angularConversionStatic.cpp +++ /dev/null @@ -1,461 +0,0 @@ -#include "angularConversionStatic.h" - -#include -#include -#include -#include -#include "angleConversionConstant.h" - -#include "sls_detector_defs.h" -#include "angleFunction.h" -using namespace std; - -angularConversionStatic::angularConversionStatic() -{ - //angleFunctionPointer=0; - registerAngleFunctionCallback(&defaultAngleFunction); - -} - -angularConversionStatic::~angularConversionStatic(){ - -} - - - -double* angularConversionStatic::convertAngles(double pos, int nch, int *chansPerMod, angleConversionConstant **angOff, int *mF, double fo, double go, int angdir) { - - // cout << "PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP convert angles " << endl; - - int imod=0; - double *ang=new double[nch]; - double enc=pos; - angleConversionConstant *p=NULL; - - int ch0=0; - int chlast=chansPerMod[0]-1; - int nchmod=chansPerMod[0]; - p=angOff[imod]; - if (mF[imod]==0) - enc=0; - else - enc=pos; - - for (int ip=0; ipchlast) { - imod++; - p=angOff[imod]; - if (mF[imod]==0) - enc=0; - else - enc=pos; - -#ifdef VERBOSE - if (p) - cout << enc << endl << fo+go << endl << p->r_conversion << endl << p->center << endl << p->offset << endl << p->tilt << angdir << endl; - else - cout << "no ang conv " << endl; -#endif - - ch0=chlast+1; - nchmod=chansPerMod[imod]; - if (nchmod>0) - chlast=ch0+nchmod-1; - } - - if (p) - ang[ip]=angle(ip-ch0, \ - enc, \ - fo+go, \ - p->r_conversion, \ - p->center, \ - p->offset, \ - p->tilt, \ - angdir ); -#ifdef VERBOSE - cout << "ip " << ip << " ch0 " << ch0 << " chlast " << chlast << " imod " << imod << endl; -#endif - } - return ang; -} - - - - - - -double angularConversionStatic::convertAngle(double pos, int ich, angleConversionConstant *p, int mF, double fo, double go, int angdir) { - - // cout << "PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP convert angle " << endl; - // if (p) - // cout << pos << endl << fo+go << endl << p->r_conversion << endl << p->center << endl << p->offset << endl << mF << endl << angdir << endl; - // else - // cout << "no ang conv " << endl; - - double enc=0, trans=0; - double ang=0; - - switch (mF) { - case 0: - enc=0; - trans=0; - break; - case 1: - enc=pos; - trans=0; - break; - case -1: - enc=-pos; - trans=0; - break; - case 2: - enc=0; - trans=pos; - break; - case -2: - enc=0; - trans=-pos; - break; - default: - enc=0; - trans=0; - } - - if (p) - ang=angle(ich, \ - enc, \ - fo+go, \ - p->r_conversion, \ - p->center, \ - p->offset, \ - trans, \ - angdir ); - // cout << ich << " " << ang << endl << endl; - return ang; - - - -} - - - - - - - - - - - -double angularConversionStatic::convertAngle(double pos, int ich, int *chansPerMod, angleConversionConstant **angOff, int *mF, double fo, double go, int angdir) { - - // cout << "PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP convert angles xx" << endl; - int imod=0; - double ang; - // double enc=0, trans=0; - angleConversionConstant *p=NULL; - - int ch0=0; - int chlast=chansPerMod[0]-1; - int nchmod=chansPerMod[0]; - - - - while (ich>chlast) { - imod++; - ch0=chlast+1; - nchmod=chansPerMod[imod]; - chlast=ch0+nchmod-1; - } - - p=angOff[imod]; - - - ang=convertAngle(pos, ich-ch0, p, mF[imod], fo, go, angdir); - - return ang; - -} - - - -//static! -int angularConversionStatic::readAngularConversion(string fname, int nmod, angleConversionConstant *angOff) { - - ifstream infile; - string ss; - -#ifdef VERBOSE - std::cout<< "Opening file "<< fname << std::endl; -#endif - infile.open(fname.c_str(), ios_base::in); - if (infile.is_open()) { - readAngularConversion(infile, nmod, angOff); - infile.close(); - } else { - std::cout<< "Could not open calibration file "<< fname << std::endl; - return -1; - } - return 0; -} - - -//static -int angularConversionStatic::readAngularConversion( ifstream& infile, int nmod, angleConversionConstant *angOff) { - string str; - int mod; - double center, ecenter, pitch, epitch; - double r_conv, er_conv; - double off, eoff; - string ss; - int interrupt=0; - int nm=0; - int newangconv=0; - //" module %i center %E +- %E conversion %E +- %E offset %f +- %f \n" - while (infile.good() and interrupt==0) { - getline(infile,str); -#ifdef VERBOSE - cout << "** mod " << nm << " " ; - std::cout<< str << std::endl; -#endif - istringstream ssstr(str); - ssstr >> ss >> mod; - ssstr >> ss >> center; - if (ss==string("center")) - newangconv=0; - else - newangconv=1; - ssstr >> ss >> ecenter; - if (newangconv) { - ssstr >> ss >> pitch; - ssstr >> ss >> epitch; - } - ssstr >> ss >> r_conv; - ssstr >> ss >> er_conv; - ssstr >> ss >> off; - ssstr >> ss >> eoff; -#ifdef VERBOSE - cout << nm << " " << nmod << endl; -#endif - if (nm=0 ) { - angOff[nm].center=center; - angOff[nm].r_conversion=r_conv; - angOff[nm].offset=off; - angOff[nm].ecenter=ecenter; - angOff[nm].er_conversion=er_conv; - angOff[nm].eoffset=eoff; - - if (newangconv!=0) { - // } else { - - angOff[nm].tilt=pitch; - angOff[nm].etilt=epitch; - - } - // cout << angOff[nm].center << " " << - // angOff[nm].r_conversion << " " << - // angOff[nm].offset << endl; - - } else - break; -#ifdef VERBOSE - cout << nm<<" " << angOff[nm].offset << endl; -#endif - nm++; - if (nm>=nmod) - break; - - - - - } - return nm; - } - -//static -int angularConversionStatic:: writeAngularConversion(string fname, int nmod, angleConversionConstant *angOff) { - - ofstream outfile; - outfile.open (fname.c_str(),ios_base::out); - if (outfile.is_open()) - { - writeAngularConversion(outfile, nmod, angOff); - outfile.close(); - } else { - std::cout<< "Could not open file " << fname << "for writing"<< std::endl; - return -1; - } - //" module %i center %E +- %E conversion %E +- %E offset %f +- %f \n" - return 0; -} - - - -//static -int angularConversionStatic:: writeAngularConversion(ofstream& outfile, int nmod, angleConversionConstant *angOff) { - - for (int imod=0; imod0) { - #ifdef VERBOSE - cout << "finalize " << ibin << " "<< mm[ibin] << " " << mp[ibin]<< " " << mv[ibin] << " " << me[ibin] << endl; - #endif - mp[np]=mp[ibin]/mm[ibin]; - mv[np]=mv[ibin]/mm[ibin]; - me[np]=me[ibin]/mm[ibin]; - me[np]=sqrt(me[ibin]); - mm[np]=mm[ibin]; - np++; - } - } - // cout << endl ; - return np; -} - -//static -int angularConversionStatic::addToMerging(double *p1, double *v1, double *e1, double *mp, double *mv,double *me, int *mm, int nchans, double binsize,int nbins, int *badChanMask ) { - - - // cout << "PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP add to merging " << endl; - double binmi=-180.; - int ibin=0; - - if (p1==NULL) - return 0; - if (v1==NULL) - return slsDetectorDefs::FAIL; - - if (mp==NULL) //can be changed if we want to use a fixed bin algorithm! - return slsDetectorDefs::FAIL; - - if (mv==NULL) - return slsDetectorDefs::FAIL; - if (me==NULL) - return slsDetectorDefs::FAIL; - if (mm==NULL) - return slsDetectorDefs::FAIL; - if (nchans==0) - return slsDetectorDefs::FAIL; - - if (binsize<=0) - return slsDetectorDefs::FAIL; - - if (nbins<=0) - return slsDetectorDefs::FAIL; - - for (int ip=0; ip=0) { - mp[ibin]+=p1[ip]; - mv[ibin]+=v1[ip]; - if (e1) - me[ibin]+=(e1[ip]*e1[ip]); - else - me[ibin]+=v1[ip]; - mm[ibin]++; - -// #ifdef VERBOSE -// cout << "add " << ibin << " "<< mm[ibin] << " " << mp[ibin]<< mv[ibin] << me[ibin] << endl; -// #endif - } else - return slsDetectorDefs::FAIL; - } - - - return slsDetectorDefs::OK; - -} - -int angularConversionStatic::addPointToMerging(double p1, double v1, double e1, double *mp, double *mv,double *me, int *mm, double binsize,int nbins) { - - - // cout << "PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP add point to merging "<< v1 << " " << e1 << endl; - double binmi=-180.; - int ibin=0; - - - if (mp==NULL) //can be changed if we want to use a fixed bin algorithm! - return slsDetectorDefs::FAIL; - - if (mv==NULL) - return slsDetectorDefs::FAIL; - if (me==NULL) - return slsDetectorDefs::FAIL; - if (mm==NULL) - return slsDetectorDefs::FAIL; - - if (binsize<=0) - return slsDetectorDefs::FAIL; - - if (nbins<=0) - return slsDetectorDefs::FAIL; - - - ibin=(int)((p1-binmi)/binsize); - - - if (ibin=0) { - // cout << "before " << ibin << " " << mp[ibin] << " " << mv[ibin] << " " << me[ibin] << endl; - mp[ibin]+=p1; - mv[ibin]+=v1; - if (e1) - me[ibin]+=(e1*e1); - else - me[ibin]+=v1; - mm[ibin]++; - // cout << "after " << ibin << " " << mp[ibin] << " " << mv[ibin] << " " << me[ibin] << endl; - -// #ifdef VERBOSE -// cout << "add " << ibin << " "<< mm[ibin] << " " << mp[ibin]<< mv[ibin] << me[ibin] << endl; -// #endif - } else { - cout << "Bin out of range! " << ibin << endl; - return slsDetectorDefs::FAIL; - } - - return slsDetectorDefs::OK; - -} diff --git a/slsDetectorSoftware/slsDetectorAnalysis/angularConversionStatic.h b/slsDetectorSoftware/slsDetectorAnalysis/angularConversionStatic.h deleted file mode 100644 index ec1b47d6b..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/angularConversionStatic.h +++ /dev/null @@ -1,184 +0,0 @@ - -#ifndef ANGULARCONVERSIONSTATIC_H -#define ANGULARCONVERSIONSTATIC_H - -#ifdef __CINT -#define MYROOT -#endif - - - - -#include -#include - -//#include "angleConversionConstant.h" - - - //double angle(int ichan, double encoder, double totalOffset, double conv_r, double center, double offset, double tilt, int direction) - -class angleConversionConstant; - -; - -/** - @short Angular conversion constants needed for a detector module - */ - - -/** - -@short methods to set/unset the angular conversion and merge the data -class containing the methods to set/unset the angular conversion and merge the data - - -The angular conversion itself is defined by the angle() function defined in usersFunctions.cpp - -*/ -class angularConversionStatic -// : public virtual slsDetectorDefs -{ - - public: - /** default constructor */ - angularConversionStatic(); - /** virtual destructor */ - virtual ~angularConversionStatic(); - - - - //virtual int readAngularConversion(std::string fname)=0; - - - - - /** - - reads an angular conversion file - \param fname file to be read - \param nmod number of modules (maximum) to be read - \param angOff pointer to array of angleConversionConstants - \returns OK or FAIL - */ - static int readAngularConversion(std::string fname, int nmod, angleConversionConstant *angOff); - - /** - reads an angular conversion file - \param ifstream input file stream to be read - \param nmod number of modules (maximum) to be read - \param angOff pointer to array of angleConversionConstants - \returns OK or FAIL - - */ - static int readAngularConversion(std::ifstream& ifs, int nmod, angleConversionConstant *angOff); - /** - writes an angular conversion file - \param fname file to be written - \param nmod number of modules to be written - \param angOff pointer to array of angleConversionConstants - \returns OK or FAIL - */ - static int writeAngularConversion(std::string fname, int nmod, angleConversionConstant *angOff); - - /** - writes an angular conversion file - \param ofstream output file stream - \param nmod number of modules to be written - \param angOff pointer to array of angleConversionConstants - \returns OK or FAIL - */ - static int writeAngularConversion(std::ofstream& ofs, int nmod, angleConversionConstant *angOff); - - /** - sets the arrays of the merged data to 0. NB The array should be created with size nbins >= 360./getBinSize(); - \param mp already merged postions - \param mv already merged data - \param me already merged errors (squared sum) - \param mm multiplicity of merged arrays - \param nbins number of bins - \returns OK or FAIL - */ - static int resetMerging(double *mp, double *mv,double *me, int *mm, int nbins); - - /** - merge dataset - \param p1 angular positions of dataset - \param v1 data - \param e1 errors - \param mp already merged postions - \param mv already merged data - \param me already merged errors (squared sum) - \param mm multiplicity of merged arrays - \param nchans number of channels - \param binsize size of angular bin - \param nb number of angular bins - \param badChanMask badchannelmask (if NULL does not correct for bad channels) - \returns OK or FAIL - */ - - static int addToMerging(double *p1, double *v1, double *e1, double *mp, double *mv,double *me, int *mm, int nchans, double binsize,int nb, int *badChanMask=NULL); - - - /** - merge dataset - \param p1 angular positions of dataset - \param v1 data - \param e1 errors - \param mp already merged postions - \param mv already merged data - \param me already merged errors (squared sum) - \param mm multiplicity of merged arrays - \param nchans number of channels - \param binsize size of angular bin - \param nb number of angular bins - \param badChanMask badchannelmask (if NULL does not correct for bad channels) - \returns OK or FAIL - */ - - static int addPointToMerging(double p1, double v1, double e1, double *mp, double *mv,double *me, int *mm, double binsize, int nb); - - - /** - calculates the "final" positions, data value and errors for the merged data - \param mp already merged postions - \param mv already merged data - \param me already merged errors (squared sum) - \param mm multiplicity of merged arrays - \param nb number of bins - \returns FAIL or the number of non empty bins (i.e. points belonging to the pattern) - */ - - static int finalizeMerging(double *mp, double *mv,double *me, int *mm, int nb); - - /** - converts channel number to angle - \param pos encoder position - \returns array of angles corresponding to the channels - */ - - double* convertAngles(double pos, int nch, int *chansPerMod, angleConversionConstant **angOff, int *mF, double fo, double go, int angdir); - - double convertAngle(double pos, int ich, int *chansPerMod, angleConversionConstant **angOff, int *mF, double fo, double go, int angdir); - - - double convertAngle(double pos, int ich, angleConversionConstant *angOff, int mF, double fo, double go, int angdir); - - - - protected: - - - - - int registerAngleFunctionCallback(double (*fun)(double, double, double, double, double, double, double, int)) {angle = fun; return 0;}; - - - double (*angle)(double, double, double, double, double, double, double, int); - - - // private: - - -}; - -#endif diff --git a/slsDetectorSoftware/slsDetectorAnalysis/badChannelCorrections.h b/slsDetectorSoftware/slsDetectorAnalysis/badChannelCorrections.h deleted file mode 100644 index 5cc290e1c..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/badChannelCorrections.h +++ /dev/null @@ -1,69 +0,0 @@ -#ifndef BAD_CHANNEL_CORRECTIONS_H -#define BAD_CHANNEL_CORRECTIONS_H - - -#include -#include -#include -#include - -// -class badChannelCorrections{ - - public: - - static int readBadChannelCorrectionFile(std::string fname, int &nbad, int *badlist){ std::ifstream infile(fname.c_str()); int nb=-1; if (infile.is_open()) {nb=readBadChannelCorrectionFile(infile,nbad,badlist); infile.close();}; return nb;}; - - - - static int readBadChannelCorrectionFile(std::ifstream &infile, int &nbad, int *badlist, int moff=0){ \ - int interrupt=0; \ - int ich; \ - int chmin,chmax; \ - std::string str; \ - nbad=0; \ - while (infile.good() and interrupt==0) { \ - getline(infile,str); \ - std::istringstream ssstr; \ - ssstr.str(str); \ - if (ssstr.bad() || ssstr.fail() || infile.eof()) { \ - interrupt=1; \ - break; \ - } \ - if (str.find('-')!=std::string::npos) { \ - ssstr >> chmin ; \ - ssstr.str(str.substr(str.find('-')+1,str.size())); \ - ssstr >> chmax; \ - for (ich=chmin; ich<=chmax; ich++) { \ - badlist[nbad]=ich; \ - nbad++; \ - } \ - } else { \ - ssstr >> ich; \ - badlist[nbad]=ich; \ - nbad++; \ - } \ - } \ - return nbad; }; - - - static int setBadChannelCorrection(std::ifstream &infile, int &nbad, int *badlist, int moff){ \ - int retval=readBadChannelCorrectionFile(infile,nbad,badlist); \ - for (int ich=0; ich -#include -#ifndef DETECTOR_DATA_H -#define DETECTOR_DATA_H -/** - @short data structure to hold the detector data after postprocessing (e.g. to plot, store in a root tree etc.) - */ -class detectorData { - public: - /** @short The constructor - \param val pointer to the data in double data type(valid only for MYTHEN) - \param err pointer to errors - \param ang pointer to the angles - \param f_ind file index - \param fname file name to which the data are saved - \param np number of points in x coordinate defaults to the number of detector channels (1D detector) or dimension in x (2D detector) - \param ny dimension in y (2D detector) - \param cval pointer to data in char* format (valid only for non MYTHEN detectors) - \param dbytes number of bytes of image pointed to by cval pointer (valid only for non MYTHEN detectors) - \param dr dynamic range or bits per pixel (valid only for non MYTHEN detectors) - \param file_ind file index - */ - detectorData(double *val=NULL, double *err=NULL, double *ang=NULL, double f_ind=-1, - const char *fname="", int np=-1, int ny=1, char *cval=NULL, int dbytes=0, int dr=0, - long long int file_ind=-1) : - values(val), errors(err), angles(ang), progressIndex(f_ind), - npoints(np), npy(ny), cvalues(cval), databytes(dbytes), - dynamicRange(dr), dgainvalues(NULL), fileIndex(file_ind) { - strcpy(fileName,fname); - }; - - /** - @short The destructor - deletes also the arrays pointing to data/errors/angles if not NULL - cvalues are deleted by caller - */ - ~detectorData() {if (values) delete [] values; if (errors) delete [] errors; - if (angles) delete [] angles; if(dgainvalues) delete [] dgainvalues;}; - //private: - double *values; /**< @short pointer to the data as double array (MYTHEN only) */ - double *errors; /**< @short pointer to the errors */ - double *angles;/**< @short pointer to the angles (NULL if no angular conversion) */ - double progressIndex;/**< @short file index */ - char fileName[1000];/**< @short file name */ - int npoints;/**< @short number of points */ - int npy;/**< @short dimensions in y coordinate*/ - char* cvalues; /**< @short pointer to the data as char arary (non MYTHEN detectors) */ - int databytes; /**< @short number of bytes of data. Used with cvalues */ - int dynamicRange; /**< @short dynamic range */ - double* dgainvalues; /**< @short pointer to gain data as double array */ - long long int fileIndex; /**< @short file index */ -}; - - -#endif diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/annotated.html b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/annotated.html deleted file mode 100644 index 0af77f9f8..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/annotated.html +++ /dev/null @@ -1,28 +0,0 @@ - - -Class List - - - - - - -

Class List

Here are the classes, structs, unions and interfaces with brief descriptions: - - -
energyCalibration
energyCalibrationFunctionsEnergy calibration functions
-
Generated on Tue Mar 27 16:32:29 2012 by  - -doxygen 1.4.7
- - diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/classenergyCalibration-members.html b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/classenergyCalibration-members.html deleted file mode 100644 index 4923725d9..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/classenergyCalibration-members.html +++ /dev/null @@ -1,55 +0,0 @@ - - -Member List - - - - - - -

energyCalibration Member List

This is the complete list of members for energyCalibration, including all inherited members.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
amplenergyCalibration [private]
bg_offsetenergyCalibration [private]
bg_slopeenergyCalibration [private]
calibrate(int nscan, Double_t *en, Double_t *een, TH1F **h1, Double_t &gain, Double_t &off, Double_t &egain, Double_t &eoff, int integral=1)energyCalibration [private]
calibrateScurves(int nscan, Double_t *en, Double_t *een, TH1F **h1, Double_t &gain, Double_t &off, Double_t &egain, Double_t &eoff)energyCalibration [inline]
calibrateSpectra(int nscan, Double_t *en, Double_t *een, TH1F **h1, Double_t &gain, Double_t &off, Double_t &egain, Double_t &eoff)energyCalibration [inline]
cs_flagenergyCalibration [private]
cs_slopeenergyCalibration [private]
energyCalibration()energyCalibration
fit_maxenergyCalibration [private]
fit_minenergyCalibration [private]
fitFunction(TF1 *fun, TH1 *h1, Double_t *mypar, Double_t *emypar)energyCalibration [private]
fitSCurve(TH1 *h1, Double_t *mypar, Double_t *emypar)energyCalibration
fitSpectrum(TH1 *h1, Double_t *mypar, Double_t *emypar)energyCalibration
flexenergyCalibration [private]
fscurveenergyCalibration [private]
fspectrumenergyCalibration [private]
funcsenergyCalibration [private]
getFitRange(Double_t &mi, Double_t &ma)energyCalibration [inline]
getStartParameters(Double_t *par)energyCalibration
initFitFunction(TF1 *fun, TH1 *h1)energyCalibration [private]
linearCalibration(int nscan, Double_t *en, Double_t *een, Double_t *fl, Double_t *efl, Double_t &gain, Double_t &off, Double_t &egain, Double_t &eoff)energyCalibration
noiseenergyCalibration [private]
plot_flagenergyCalibration [private]
setChargeSharing(int p=-1)energyCalibration
setFitRange(Double_t mi, Double_t ma)energyCalibration [inline]
setPlotFlag(int p=-1)energyCalibration [inline]
setScanSign(int s=0)energyCalibration [inline]
setStartParameters(Double_t *par)energyCalibration
~energyCalibration()energyCalibration


Generated on Tue Mar 27 16:32:29 2012 by  - -doxygen 1.4.7
- - diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/classenergyCalibration.html b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/classenergyCalibration.html deleted file mode 100644 index 5ad0b2776..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/classenergyCalibration.html +++ /dev/null @@ -1,1026 +0,0 @@ - - -energyCalibration Class Reference - - - - - - -

energyCalibration Class Reference

#include <energyCalibration.h> -

-List of all members. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Public Member Functions

 energyCalibration ()
 ~energyCalibration ()
int setPlotFlag (int p=-1)
int setScanSign (int s=0)
int setChargeSharing (int p=-1)
void setFitRange (Double_t mi, Double_t ma)
void getFitRange (Double_t &mi, Double_t &ma)
void setStartParameters (Double_t *par)
void getStartParameters (Double_t *par)
TF1 * fitSCurve (TH1 *h1, Double_t *mypar, Double_t *emypar)
TF1 * fitSpectrum (TH1 *h1, Double_t *mypar, Double_t *emypar)
TGraphErrors * linearCalibration (int nscan, Double_t *en, Double_t *een, Double_t *fl, Double_t *efl, Double_t &gain, Double_t &off, Double_t &egain, Double_t &eoff)
TGraphErrors * calibrateScurves (int nscan, Double_t *en, Double_t *een, TH1F **h1, Double_t &gain, Double_t &off, Double_t &egain, Double_t &eoff)
TGraphErrors * calibrateSpectra (int nscan, Double_t *en, Double_t *een, TH1F **h1, Double_t &gain, Double_t &off, Double_t &egain, Double_t &eoff)

Private Member Functions

TGraphErrors * calibrate (int nscan, Double_t *en, Double_t *een, TH1F **h1, Double_t &gain, Double_t &off, Double_t &egain, Double_t &eoff, int integral=1)
void initFitFunction (TF1 *fun, TH1 *h1)
TF1 * fitFunction (TF1 *fun, TH1 *h1, Double_t *mypar, Double_t *emypar)

Private Attributes

int plot_flag
int cs_flag
Double_t fit_min
Double_t fit_max
Double_t bg_offset
Double_t bg_slope
Double_t flex
Double_t noise
Double_t ampl
Double_t cs_slope
energyCalibrationFunctionsfuncs
TF1 * fscurve
TF1 * fspectrum
-


Detailed Description

-class alowing the energy calibration of photon counting and anlogue detectors -

-


Constructor & Destructor Documentation

- -
-
- - - - - - - - -
energyCalibration::energyCalibration (  ) 
-
-
- -

-default constructor - creates the function with which the s-curves will be fitted -

-

- -

-
- - - - - - - - -
energyCalibration::~energyCalibration (  ) 
-
-
- -

-default destructor - deletes the function with which the s-curves will be fitted -

-

-


Member Function Documentation

- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
TGraphErrors* energyCalibration::calibrate (int  nscan,
Double_t *  en,
Double_t *  een,
TH1F **  h1,
Double_t &  gain,
Double_t &  off,
Double_t &  egain,
Double_t &  eoff,
int  integral = 1 
) [private]
-
-
- -

-calculates gain and offset for the set of energies

Parameters:
- - - - - - - - -
nscan number of energy scans
en array of energies (nscan long)
een array of errors on energies (nscan long) - can be NULL!
h1 array of TH1
gain reference to gain resulting from the fit
offset reference to offset resulting from the fit
integral 1 is an s-curve set (default), 0 spectra
-
-
Returns:
graph energy vs peak/inflection point
- -
-

- -

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
TGraphErrors* energyCalibration::calibrateScurves (int  nscan,
Double_t *  en,
Double_t *  een,
TH1F **  h1,
Double_t &  gain,
Double_t &  off,
Double_t &  egain,
Double_t &  eoff 
) [inline]
-
-
- -

-calculates gain and offset for the set of energy scans

Parameters:
- - - - - - - - - -
nscan number of energy scans
en array of energies (nscan long)
een array of errors on energies (nscan long) - can be NULL!
h1 array of TH1
gain reference to gain resulting from the fit
off reference to offset resulting from the fit
egain reference to error on the gain resulting from the fit
eoff reference to the error on the offset resulting from the fit
-
-
Returns:
graph energy vs inflection point
- -
-

- -

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
TGraphErrors* energyCalibration::calibrateSpectra (int  nscan,
Double_t *  en,
Double_t *  een,
TH1F **  h1,
Double_t &  gain,
Double_t &  off,
Double_t &  egain,
Double_t &  eoff 
) [inline]
-
-
- -

-calculates gain and offset for the set of energy spectra

Parameters:
- - - - - - - - - -
nscan number of energy scans
en array of energies (nscan long)
een array of errors on energies (nscan long) - can be NULL!
h1 array of TH1
gain reference to gain resulting from the fit
off reference to offset resulting from the fit
egain reference to error on the gain resulting from the fit
eoff reference to the error on the offset resulting from the fit
-
-
Returns:
graph energy vs peak
- -
-

- -

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
TF1* energyCalibration::fitFunction (TF1 *  fun,
TH1 *  h1,
Double_t *  mypar,
Double_t *  emypar 
) [private]
-
-
- -

-Perfors the fit according to the flags specified and returns the fitted function

Parameters:
- - - - - -
fun function to fit
h1 histogram to fit
mypar pointer to fit parameters array
emypar pointer to fit parameter errors
-
-
Returns:
the fitted function - can be used e.g. to get the Chi2 or similar
- -
-

- -

-
- - - - - - - - - - - - - - - - - - - - - - - - -
TF1* energyCalibration::fitSCurve (TH1 *  h1,
Double_t *  mypar,
Double_t *  emypar 
)
-
-
- -

-fits histogram with the s-curve function

Parameters:
- - - - -
h1 1d-histogram to be fitted
mypar pointer to fit parameters array
emypar pointer to fit parameter errors
-
-
Returns:
the fitted function - can be used e.g. to get the Chi2 or similar
- -
-

- -

-
- - - - - - - - - - - - - - - - - - - - - - - - -
TF1* energyCalibration::fitSpectrum (TH1 *  h1,
Double_t *  mypar,
Double_t *  emypar 
)
-
-
- -

-fits histogram with the spectrum

Parameters:
- - - - -
h1 1d-histogram to be fitted
mypar pointer to fit parameters array
emypar pointer to fit parameter errors
-
-
Returns:
the fitted function - can be used e.g. to get the Chi2 or similar
- -
-

- -

-
- - - - - - - - - - - - - - - - - - -
void energyCalibration::getFitRange (Double_t &  mi,
Double_t &  ma 
) [inline]
-
-
- -

-gets the s-curve fit range

Parameters:
- - - -
mi reference for minimum of the fit range (-1 is histogram x-min)
ma reference for maximum of the fit range (-1 is histogram x-max)
-
- -
-

- -

-
- - - - - - - - - -
void energyCalibration::getStartParameters (Double_t *  par  ) 
-
-
- -

-get start parameters for the s-curve function

Parameters:
- - -
par parameters, -1 means auto-calculated par[0] is the pedestal par[1] is the slope of the pedestal par[2] is the inflection point par[3] is the RMS par[4] is the amplitude par[5] is the angual coefficient of the charge sharing slope (scales with par[3]) -- always positive
-
- -
-

- -

-
- - - - - - - - - - - - - - - - - - -
void energyCalibration::initFitFunction (TF1 *  fun,
TH1 *  h1 
) [private]
-
-
- -

-Initializes the start parameters and the range of the fit depending on the histogram characteristics and/or on the start parameters specified by the user

Parameters:
- - - -
fun pointer to function to be initialized
h1 histogram from which to extract the range and start parameters, if not already specified by the user
-
- -
-

- -

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
TGraphErrors* energyCalibration::linearCalibration (int  nscan,
Double_t *  en,
Double_t *  een,
Double_t *  fl,
Double_t *  efl,
Double_t &  gain,
Double_t &  off,
Double_t &  egain,
Double_t &  eoff 
)
-
-
- -

-calculates gain and offset for the set of inflection points

Parameters:
- - - - - - - - - - -
nscan number of energy scans
en array of energies (nscan long)
een array of errors on energies (nscan long) - can be NULL!
fl array of inflection points (nscan long)
efl array of errors on the inflection points (nscan long)
gain reference to gain resulting from the fit
off reference to offset resulting from the fit
egain reference to error on the gain resulting from the fit
eoff reference to the error on the offset resulting from the fit
-
-
Returns:
graph energy vs inflection point
- -
-

- -

-
- - - - - - - - - -
int energyCalibration::setChargeSharing (int  p = -1  ) 
-
-
- -

-sets plot flag

Parameters:
- - -
p plot flag (-1 gets, 0 unsets, >0 plot)
-
-
Returns:
current plot flag
- -
-

- -

-
- - - - - - - - - - - - - - - - - - -
void energyCalibration::setFitRange (Double_t  mi,
Double_t  ma 
) [inline]
-
-
- -

-sets the s-curve fit range

Parameters:
- - - -
mi minimum of the fit range (-1 is histogram x-min)
ma maximum of the fit range (-1 is histogram x-max)
-
- -
-

- -

-
- - - - - - - - - -
int energyCalibration::setPlotFlag (int  p = -1  )  [inline]
-
-
- -

-sets plot flag

Parameters:
- - -
p plot flag (-1 gets, 0 unsets, >0 plot)
-
-
Returns:
current plot flag
- -
-

- -

-
- - - - - - - - - -
int energyCalibration::setScanSign (int  s = 0  )  [inline]
-
-
- -

-sets scan sign

Parameters:
- - -
s can be 1 (energy and x-axis have the same direction) or -1 (energy and x-axis have opposite directions) otherwise gets
-
-
Returns:
current scan sign can be 1 (energy and x-axis have the same direction) or -1 (energy and x-axis have opposite directions)
- -
-

- -

-
- - - - - - - - - -
void energyCalibration::setStartParameters (Double_t *  par  ) 
-
-
- -

-set start parameters for the s-curve function

Parameters:
- - -
par parameters, -1 sets to auto-calculation par[0] is the pedestal par[1] is the slope of the pedestal par[2] is the inflection point par[3] is the RMS par[4] is the amplitude par[5] is the angual coefficient of the charge sharing slope (scales with par[3]) -- always positive
-
- -
-

-


Member Data Documentation

- -
-
- - - - -
Double_t energyCalibration::ampl [private]
-
-
- -

-start value for the number of photons -

-

- -

-
- - - - -
Double_t energyCalibration::bg_offset [private]
-
-
- -

-start value for the background pedestal -

-

- -

-
- - - - -
Double_t energyCalibration::bg_slope [private]
-
-
- -

-start value for the background slope -

-

- -

-
- - - - -
int energyCalibration::cs_flag [private]
-
-
- -

-0 functions without charge sharing contribution, >0 with charge sharing contribution -

-

- -

-
- - - - -
Double_t energyCalibration::cs_slope [private]
-
-
- -

-start value for the charge sharing slope -

-

- -

-
- - - - -
Double_t energyCalibration::fit_max [private]
-
-
- -

-maximum of the s-curve fitting range, -1 is histogram x-max -

-

- -

-
- - - - -
Double_t energyCalibration::fit_min [private]
-
-
- -

-minimum of the s-curve fitting range, -1 is histogram x-min -

-

- -

-
- - - - -
Double_t energyCalibration::flex [private]
-
-
- -

-start value for the inflection point -

-

- -

-
- - - - -
TF1* energyCalibration::fscurve [private]
-
-
- -

-function with which the s-curve will be fitted -

-

- -

-
- - - - -
TF1* energyCalibration::fspectrum [private]
-
-
- -

-function with which the spectrum will be fitted -

-

- -

- -
- -

- -

-

- -

-
- - - - -
Double_t energyCalibration::noise [private]
-
-
- -

-start value for the noise -

-

- -

-
- - - - -
int energyCalibration::plot_flag [private]
-
-
- -

-0 does not plot, >0 plots (flags?) -

-

-


The documentation for this class was generated from the following file: -
Generated on Tue Mar 27 16:32:29 2012 by  - -doxygen 1.4.7
- - diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/classenergyCalibrationFunctions-members.html b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/classenergyCalibrationFunctions-members.html deleted file mode 100644 index 6e87b92ca..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/classenergyCalibrationFunctions-members.html +++ /dev/null @@ -1,38 +0,0 @@ - - -Member List - - - - - - -

energyCalibrationFunctions Member List

This is the complete list of members for energyCalibrationFunctions, including all inherited members.

- - - - - - - - - - - - - -
energyCalibrationFunctions(int s=-1)energyCalibrationFunctions [inline]
erfFuncFluo(Double_t *x, Double_t *par)energyCalibrationFunctions
erfFunction(Double_t *x, Double_t *par)energyCalibrationFunctions
erfFunctionChargeSharing(Double_t *x, Double_t *par)energyCalibrationFunctions
gaussChargeSharing(Double_t *x, Double_t *par)energyCalibrationFunctions
kth_smallest(int *a, int n, int k)energyCalibrationFunctions [static]
median(float *x, int n)energyCalibrationFunctions [static]
quick_select(int arr[], int n)energyCalibrationFunctions [static]
scurve(Double_t *x, Double_t *par)energyCalibrationFunctions
scurveFluo(Double_t *x, Double_t *par)energyCalibrationFunctions
setScanSign(int s=0)energyCalibrationFunctions [inline]
signenergyCalibrationFunctions [private]
spectrum(Double_t *x, Double_t *par)energyCalibrationFunctions


Generated on Tue Mar 27 16:32:29 2012 by  - -doxygen 1.4.7
- - diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/classenergyCalibrationFunctions.html b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/classenergyCalibrationFunctions.html deleted file mode 100644 index 2a0dfd405..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/classenergyCalibrationFunctions.html +++ /dev/null @@ -1,428 +0,0 @@ - - -energyCalibrationFunctions Class Reference - - - - - - -

energyCalibrationFunctions Class Reference

Energy calibration functions. -More... -

-#include <energyCalibration.h> -

-List of all members. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Public Member Functions

 energyCalibrationFunctions (int s=-1)
int setScanSign (int s=0)
Double_t gaussChargeSharing (Double_t *x, Double_t *par)
Double_t erfFunction (Double_t *x, Double_t *par)
Double_t erfFunctionChargeSharing (Double_t *x, Double_t *par)
Double_t erfFuncFluo (Double_t *x, Double_t *par)
Double_t spectrum (Double_t *x, Double_t *par)
Double_t scurve (Double_t *x, Double_t *par)
Double_t scurveFluo (Double_t *x, Double_t *par)

Static Public Member Functions

static float median (float *x, int n)
static int quick_select (int arr[], int n)
static int kth_smallest (int *a, int n, int k)

Private Attributes

int sign
-


Detailed Description

-Energy calibration functions. -

-class containing all the possible energy calibration functions (scurves with and without charge sharing, gaussian spectrum with and without charge sharing, possibility of chosing the sign of the X-axis) -

-


Constructor & Destructor Documentation

- -
-
- - - - - - - - - -
energyCalibrationFunctions::energyCalibrationFunctions (int  s = -1  )  [inline]
-
-
- -

- -

-

-


Member Function Documentation

- -
-
- - - - - - - - - - - - - - - - - - -
Double_t energyCalibrationFunctions::erfFuncFluo (Double_t *  x,
Double_t *  par 
)
-
-
- -

-Double Erf function with charge sharing slope par[0] is the pedestal par[1] is the slope of the pedestal par[2] is the inflection point of the first energy par[3] is the RMS of the first energy par[4] is the amplitude of the first energy par[5] is the angual coefficient of the charge sharing slope of the first energy (scales with par[3]) par[6] is the inflection point of the second energy par[7] is the RMS of the second energy par[8] is the amplitude of the second energy par[9] is the angual coefficient of the charge sharing slope of the second energy (scales with par[8]) -

-

- -

-
- - - - - - - - - - - - - - - - - - -
Double_t energyCalibrationFunctions::erfFunction (Double_t *  x,
Double_t *  par 
)
-
-
- -

-Basic erf function par[0] is the inflection point par[1] is the RMS par[2] is the amplitude -

-

- -

-
- - - - - - - - - - - - - - - - - - -
Double_t energyCalibrationFunctions::erfFunctionChargeSharing (Double_t *  x,
Double_t *  par 
)
-
-
- -

-Erf function with charge sharing slope par[0] is the pedestal par[1] is the slope of the pedestal par[2] is the inflection point par[3] is the RMS par[4] is the amplitude par[5] is the angual coefficient of the charge sharing slope (scales with par[3]) -

-

- -

-
- - - - - - - - - - - - - - - - - - -
Double_t energyCalibrationFunctions::gaussChargeSharing (Double_t *  x,
Double_t *  par 
)
-
-
- -

-Gaussian Function with charge sharing pedestal par[0] is the absolute height of the background pedestal par[1] is the slope of the background pedestal par[2] is the gaussian peak position par[3] is the RMS of the gaussian (and of the pedestal) par[4] is the height of the function par[5] is the fractional height of the charge sharing pedestal (scales with par[3]) -

-

- -

-
- - - - - - - - - - - - - - - - - - - - - - - - -
static int energyCalibrationFunctions::kth_smallest (int *  a,
int  n,
int  k 
) [static]
-
-
- -

-Calculates the median of an array of n elements (swaps the arrays!) -

-

- -

-
- - - - - - - - - - - - - - - - - - -
static float energyCalibrationFunctions::median (float *  x,
int  n 
) [static]
-
-
- -

-Calculates the median of an array of n elements -

-

- -

-
- - - - - - - - - - - - - - - - - - -
static int energyCalibrationFunctions::quick_select (int  arr[],
int  n 
) [static]
-
-
- -

-Calculates the median of an array of n elements (swaps the arrays!) -

-

- -

-
- - - - - - - - - - - - - - - - - - -
Double_t energyCalibrationFunctions::scurve (Double_t *  x,
Double_t *  par 
)
-
-
- -

-Erf function with charge sharing slope with the correct scan sign par[0] is the pedestal par[1] is the slope of the pedestal par[2] is the inflection point par[3] is the RMS par[4] is the amplitude par[5] is the angual coefficient of the charge sharing slope (scales with par[3]) -

-

- -

-
- - - - - - - - - - - - - - - - - - -
Double_t energyCalibrationFunctions::scurveFluo (Double_t *  x,
Double_t *  par 
)
-
-
- -

-Double Erf function with charge sharing slope par[0] is the pedestal par[1] is the slope of the pedestal par[2] is the inflection point of the first energy par[3] is the RMS of the first energy par[4] is the amplitude of the first energy par[5] is the angual coefficient of the charge sharing slope of the first energy (scales with par[3]) par[6] is the inflection point of the second energy par[7] is the RMS of the second energy par[8] is the amplitude of the second energy par[9] is the angual coefficient of the charge sharing slope of the second energy (scales with par[8]) -

-

- -

-
- - - - - - - - - -
int energyCalibrationFunctions::setScanSign (int  s = 0  )  [inline]
-
-
- -

-sets scan sign

Parameters:
- - -
s can be 1 (energy and x-axis have the same direction) or -1 (energy and x-axis have opposite directions) otherwise gets
-
-
Returns:
current scan sign can be 1 (energy and x-axis have the same direction) or -1 (energy and x-axis have opposite directions)
- -
-

- -

-
- - - - - - - - - - - - - - - - - - -
Double_t energyCalibrationFunctions::spectrum (Double_t *  x,
Double_t *  par 
)
-
-
- -

-static function Gaussian with charge sharing pedestal with the correct scan sign par[0] is the absolute height of the background pedestal par[1] is the fractional height of the charge sharing pedestal (scales with par[3] par[2] is the gaussian peak position par[3] is the RMS of the gaussian (and of the pedestal) par[4] is the height of the function -

-

-


Member Data Documentation

- -
-
- - - - -
int energyCalibrationFunctions::sign [private]
-
-
- -

- -

-

-


The documentation for this class was generated from the following file: -
Generated on Tue Mar 27 16:32:29 2012 by  - -doxygen 1.4.7
- - diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/classes.html b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/classes.html deleted file mode 100644 index 4cc7a4ddd..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/classes.html +++ /dev/null @@ -1,69 +0,0 @@ - - - - - -Alphabetical List - - - - - - - - - -
-

Class Index

- -
  E  
-
energyCalibration   energyCalibrationFunctions   
-
- - - - -
- -
- -
Generated on Tue Mar 20 17:21:14 2012 by  - -doxygen 1.6.0
- - diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/doxygen.css b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/doxygen.css deleted file mode 100644 index 5d583694e..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/doxygen.css +++ /dev/null @@ -1,358 +0,0 @@ -BODY,H1,H2,H3,H4,H5,H6,P,CENTER,TD,TH,UL,DL,DIV { - font-family: Geneva, Arial, Helvetica, sans-serif; -} -BODY,TD { - font-size: 90%; -} -H1 { - text-align: center; - font-size: 160%; -} -H2 { - font-size: 120%; -} -H3 { - font-size: 100%; -} -CAPTION { font-weight: bold } -DIV.qindex { - width: 100%; - background-color: #e8eef2; - border: 1px solid #84b0c7; - text-align: center; - margin: 2px; - padding: 2px; - line-height: 140%; -} -DIV.nav { - width: 100%; - background-color: #e8eef2; - border: 1px solid #84b0c7; - text-align: center; - margin: 2px; - padding: 2px; - line-height: 140%; -} -DIV.navtab { - background-color: #e8eef2; - border: 1px solid #84b0c7; - text-align: center; - margin: 2px; - margin-right: 15px; - padding: 2px; -} -TD.navtab { - font-size: 70%; -} -A.qindex { - text-decoration: none; - font-weight: bold; - color: #1A419D; -} -A.qindex:visited { - text-decoration: none; - font-weight: bold; - color: #1A419D -} -A.qindex:hover { - text-decoration: none; - background-color: #ddddff; -} -A.qindexHL { - text-decoration: none; - font-weight: bold; - background-color: #6666cc; - color: #ffffff; - border: 1px double #9295C2; -} -A.qindexHL:hover { - text-decoration: none; - background-color: #6666cc; - color: #ffffff; -} -A.qindexHL:visited { text-decoration: none; background-color: #6666cc; color: #ffffff } -A.el { text-decoration: none; font-weight: bold } -A.elRef { font-weight: bold } -A.code:link { text-decoration: none; font-weight: normal; color: #0000FF} -A.code:visited { text-decoration: none; font-weight: normal; color: #0000FF} -A.codeRef:link { font-weight: normal; color: #0000FF} -A.codeRef:visited { font-weight: normal; color: #0000FF} -A:hover { text-decoration: none; background-color: #f2f2ff } -DL.el { margin-left: -1cm } -.fragment { - font-family: monospace, fixed; - font-size: 95%; -} -PRE.fragment { - border: 1px solid #CCCCCC; - background-color: #f5f5f5; - margin-top: 4px; - margin-bottom: 4px; - margin-left: 2px; - margin-right: 8px; - padding-left: 6px; - padding-right: 6px; - padding-top: 4px; - padding-bottom: 4px; -} -DIV.ah { background-color: black; font-weight: bold; color: #ffffff; margin-bottom: 3px; margin-top: 3px } - -DIV.groupHeader { - margin-left: 16px; - margin-top: 12px; - margin-bottom: 6px; - font-weight: bold; -} -DIV.groupText { margin-left: 16px; font-style: italic; font-size: 90% } -BODY { - background: white; - color: black; - margin-right: 20px; - margin-left: 20px; -} -TD.indexkey { - background-color: #e8eef2; - font-weight: bold; - padding-right : 10px; - padding-top : 2px; - padding-left : 10px; - padding-bottom : 2px; - margin-left : 0px; - margin-right : 0px; - margin-top : 2px; - margin-bottom : 2px; - border: 1px solid #CCCCCC; -} -TD.indexvalue { - background-color: #e8eef2; - font-style: italic; - padding-right : 10px; - padding-top : 2px; - padding-left : 10px; - padding-bottom : 2px; - margin-left : 0px; - margin-right : 0px; - margin-top : 2px; - margin-bottom : 2px; - border: 1px solid #CCCCCC; -} -TR.memlist { - background-color: #f0f0f0; -} -P.formulaDsp { text-align: center; } -IMG.formulaDsp { } -IMG.formulaInl { vertical-align: middle; } -SPAN.keyword { color: #008000 } -SPAN.keywordtype { color: #604020 } -SPAN.keywordflow { color: #e08000 } -SPAN.comment { color: #800000 } -SPAN.preprocessor { color: #806020 } -SPAN.stringliteral { color: #002080 } -SPAN.charliteral { color: #008080 } -.mdescLeft { - padding: 0px 8px 4px 8px; - font-size: 80%; - font-style: italic; - background-color: #FAFAFA; - border-top: 1px none #E0E0E0; - border-right: 1px none #E0E0E0; - border-bottom: 1px none #E0E0E0; - border-left: 1px none #E0E0E0; - margin: 0px; -} -.mdescRight { - padding: 0px 8px 4px 8px; - font-size: 80%; - font-style: italic; - background-color: #FAFAFA; - border-top: 1px none #E0E0E0; - border-right: 1px none #E0E0E0; - border-bottom: 1px none #E0E0E0; - border-left: 1px none #E0E0E0; - margin: 0px; -} -.memItemLeft { - padding: 1px 0px 0px 8px; - margin: 4px; - border-top-width: 1px; - border-right-width: 1px; - border-bottom-width: 1px; - border-left-width: 1px; - border-top-color: #E0E0E0; - border-right-color: #E0E0E0; - border-bottom-color: #E0E0E0; - border-left-color: #E0E0E0; - border-top-style: solid; - border-right-style: none; - border-bottom-style: none; - border-left-style: none; - background-color: #FAFAFA; - font-size: 80%; -} -.memItemRight { - padding: 1px 8px 0px 8px; - margin: 4px; - border-top-width: 1px; - border-right-width: 1px; - border-bottom-width: 1px; - border-left-width: 1px; - border-top-color: #E0E0E0; - border-right-color: #E0E0E0; - border-bottom-color: #E0E0E0; - border-left-color: #E0E0E0; - border-top-style: solid; - border-right-style: none; - border-bottom-style: none; - border-left-style: none; - background-color: #FAFAFA; - font-size: 80%; -} -.memTemplItemLeft { - padding: 1px 0px 0px 8px; - margin: 4px; - border-top-width: 1px; - border-right-width: 1px; - border-bottom-width: 1px; - border-left-width: 1px; - border-top-color: #E0E0E0; - border-right-color: #E0E0E0; - border-bottom-color: #E0E0E0; - border-left-color: #E0E0E0; - border-top-style: none; - border-right-style: none; - border-bottom-style: none; - border-left-style: none; - background-color: #FAFAFA; - font-size: 80%; -} -.memTemplItemRight { - padding: 1px 8px 0px 8px; - margin: 4px; - border-top-width: 1px; - border-right-width: 1px; - border-bottom-width: 1px; - border-left-width: 1px; - border-top-color: #E0E0E0; - border-right-color: #E0E0E0; - border-bottom-color: #E0E0E0; - border-left-color: #E0E0E0; - border-top-style: none; - border-right-style: none; - border-bottom-style: none; - border-left-style: none; - background-color: #FAFAFA; - font-size: 80%; -} -.memTemplParams { - padding: 1px 0px 0px 8px; - margin: 4px; - border-top-width: 1px; - border-right-width: 1px; - border-bottom-width: 1px; - border-left-width: 1px; - border-top-color: #E0E0E0; - border-right-color: #E0E0E0; - border-bottom-color: #E0E0E0; - border-left-color: #E0E0E0; - border-top-style: solid; - border-right-style: none; - border-bottom-style: none; - border-left-style: none; - color: #606060; - background-color: #FAFAFA; - font-size: 80%; -} -.search { color: #003399; - font-weight: bold; -} -FORM.search { - margin-bottom: 0px; - margin-top: 0px; -} -INPUT.search { font-size: 75%; - color: #000080; - font-weight: normal; - background-color: #e8eef2; -} -TD.tiny { font-size: 75%; -} -a { - color: #1A41A8; -} -a:visited { - color: #2A3798; -} -.dirtab { padding: 4px; - border-collapse: collapse; - border: 1px solid #84b0c7; -} -TH.dirtab { background: #e8eef2; - font-weight: bold; -} -HR { height: 1px; - border: none; - border-top: 1px solid black; -} - -/* Style for detailed member documentation */ -.memtemplate { - font-size: 80%; - color: #606060; - font-weight: normal; -} -.memnav { - background-color: #e8eef2; - border: 1px solid #84b0c7; - text-align: center; - margin: 2px; - margin-right: 15px; - padding: 2px; -} -.memitem { - padding: 4px; - background-color: #eef3f5; - border-width: 1px; - border-style: solid; - border-color: #dedeee; - -moz-border-radius: 8px 8px 8px 8px; -} -.memname { - white-space: nowrap; - font-weight: bold; -} -.memdoc{ - padding-left: 10px; -} -.memproto { - background-color: #d5e1e8; - width: 100%; - border-width: 1px; - border-style: solid; - border-color: #84b0c7; - font-weight: bold; - -moz-border-radius: 8px 8px 8px 8px; -} -.paramkey { - text-align: right; -} -.paramtype { - white-space: nowrap; -} -.paramname { - color: #602020; - font-style: italic; -} -/* End Styling for detailed member documentation */ - -/* for the tree view */ -.ftvtree { - font-family: sans-serif; - margin:0.5em; -} -.directory { font-size: 9pt; font-weight: bold; } -.directory h3 { margin: 0px; margin-top: 1em; font-size: 11pt; } -.directory > h3 { margin-top: 0; } -.directory p { margin: 0px; white-space: nowrap; } -.directory div { display: none; margin: 0px; } -.directory img { vertical-align: -30%; } - diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/doxygen.png b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/doxygen.png deleted file mode 100644 index f0a274bba..000000000 Binary files a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/doxygen.png and /dev/null differ diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/energyCalibration_8h-source.html b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/energyCalibration_8h-source.html deleted file mode 100644 index 64e8c0558..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/energyCalibration_8h-source.html +++ /dev/null @@ -1,164 +0,0 @@ - - -energyCalibration.h Source File - - - - - - -

energyCalibration.h

Go to the documentation of this file.
00001 
-00002 #ifndef ENERGYCALIBRATION_H
-00003 #define ENERGYCALIBRATION_H
-00004 
-00005 #include <TROOT.h>
-00006 #include <TF1.h>
-00007 
-00008 using namespace std;
-00009 
-00010 class TH1F;
-00011 class TGraphErrors;
-00012 
-00013 
-00014 
-00015 
-00016 
-00017 const float conven=1000./3.6; 
-00018 const float el=1.67E-4; 
-00050 class energyCalibrationFunctions {
-00051 
-00052  public:
-00053   
-00054   energyCalibrationFunctions(int s=-1) {setScanSign(s);};
-00055   
-00060   int setScanSign(int s=0) {if (s==1 || s==-1) sign=s; return sign;};;
-00061   
-00062 
-00072   Double_t gaussChargeSharing(Double_t *x, Double_t *par);
-00073 
-00080 Double_t erfFunction(Double_t *x, Double_t *par) ;
-00081 
-00090 Double_t erfFunctionChargeSharing(Double_t *x, Double_t *par);
-00091   
-00105 Double_t erfFuncFluo(Double_t *x, Double_t *par);
-00106 
-00107 
-00109   static float median(float *x, int n);
-00111   static int quick_select(int arr[], int n);
-00113   static int kth_smallest(int *a, int n, int k);
-00114 
-00115   
-00124   Double_t spectrum(Double_t *x, Double_t *par);
-00125 
-00126 
-00135   Double_t scurve(Double_t *x, Double_t *par);
-00136 
-00137 
-00138 
-00151   Double_t scurveFluo(Double_t *x, Double_t *par);
-00152 
-00153 
-00154  private:
-00155   int sign;
-00156     
-00157 
-00158 };
-00159 
-00165 class energyCalibration  {
-00166 
-00167 
-00168  public:
-00172   energyCalibration();
-00173     
-00177   ~energyCalibration();
-00178     
-00183   int setPlotFlag(int p=-1) {if (p>=0) plot_flag=p; return plot_flag;};
-00184 
-00189   int setScanSign(int s=0) {return funcs->setScanSign(s);};
-00190   
-00195   int setChargeSharing(int p=-1);
-00196   
-00201   void setFitRange(Double_t mi, Double_t ma){fit_min=mi; fit_max=ma;};
-00202 
-00207   void getFitRange(Double_t &mi, Double_t &ma){mi=fit_min; ma=fit_max;};
-00208 
-00209 
-00219   void setStartParameters(Double_t *par);
-00220   
-00230   void getStartParameters(Double_t *par);
-00231 
-00239   TF1 *fitSCurve(TH1 *h1, Double_t *mypar, Double_t *emypar);
-00240 
-00241 
-00249   TF1 *fitSpectrum(TH1 *h1, Double_t *mypar, Double_t *emypar);
-00250 
-00251 
-00265   TGraphErrors* linearCalibration(int nscan, Double_t *en, Double_t *een, Double_t *fl, Double_t *efl, Double_t &gain, Double_t &off, Double_t &egain, Double_t &eoff);  
-00266 
-00279   TGraphErrors* calibrateScurves(int nscan, Double_t *en, Double_t *een, TH1F **h1, Double_t &gain, Double_t &off, Double_t &egain, Double_t &eoff){return calibrate(nscan, en, een, h1, gain, off, egain, eoff, 1);};    
-00280 
-00293   TGraphErrors* calibrateSpectra(int nscan, Double_t *en, Double_t *een, TH1F **h1, Double_t &gain, Double_t &off, Double_t &egain, Double_t &eoff){return calibrate(nscan, en, een, h1, gain, off, egain, eoff, 0);};  
-00294 
-00295 
-00296 
-00297  private:
-00309   TGraphErrors* calibrate(int nscan, Double_t *en, Double_t *een, TH1F **h1, Double_t &gain, Double_t &off, Double_t &egain, Double_t &eoff, int integral=1);  
-00310 
-00311 
-00319   void initFitFunction(TF1 *fun, TH1 *h1);
-00320 
-00321 
-00330   TF1 *fitFunction(TF1 *fun, TH1 *h1, Double_t *mypar, Double_t *emypar);  
-00331 
-00332 
-00333   int plot_flag; 
-00335   int cs_flag; 
-00337   Double_t fit_min; 
-00338   Double_t fit_max; 
-00340   Double_t bg_offset; 
-00341   Double_t bg_slope; 
-00342   Double_t flex; 
-00343   Double_t noise; 
-00344   Double_t ampl; 
-00345   Double_t cs_slope; 
-00347   energyCalibrationFunctions *funcs;
-00348 
-00349   TF1 *fscurve; 
-00351   TF1 *fspectrum; 
-00354 };
-00355 
-00356 #endif
-00357 
-00358 
-00359 
-00360 
-00361 
-00362 
-00363 
-00364 
-00365 
-00366 
-00367 
-00368 
-00369 
-00370 
-00371 
-00372 
-00373 
-00374 
-00375 
-

Generated on Tue Mar 27 16:32:29 2012 by  - -doxygen 1.4.7
- - diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/energyCalibration_8h.html b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/energyCalibration_8h.html deleted file mode 100644 index a25ed2496..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/energyCalibration_8h.html +++ /dev/null @@ -1,76 +0,0 @@ - - -energyCalibration.h File Reference - - - - - - -

energyCalibration.h File Reference

#include <TROOT.h>
-#include <TF1.h>
- -

-Go to the source code of this file. - - - - - - - - - - - - - - - -

Namespaces

namespace  std

Classes

class  energyCalibrationFunctions
 Energy calibration functions. More...
class  energyCalibration

Variables

const float conven = 1000./3.6
const float el = 1.67E-4
-


Variable Documentation

- -
-
- - - - -
const float conven = 1000./3.6
-
-
- -

-electrons/keV -

-

- -

-
- - - - -
const float el = 1.67E-4
-
-
- -

-electron charge in fC -

-

-


Generated on Tue Mar 27 16:32:29 2012 by  - -doxygen 1.4.7
- - diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/energyCalibration_8h_source.html b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/energyCalibration_8h_source.html deleted file mode 100644 index fc14ca380..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/energyCalibration_8h_source.html +++ /dev/null @@ -1,190 +0,0 @@ - - - - - -energyCalibration.h Source File - - - - - - - - - - - - - -
- -
- -
Generated on Tue Mar 20 17:21:14 2012 by  - -doxygen 1.6.0
- - diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/files.html b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/files.html deleted file mode 100644 index a0ea14100..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/files.html +++ /dev/null @@ -1,27 +0,0 @@ - - -File Index - - - - - - -

File List

Here is a list of all files with brief descriptions: - -
energyCalibration.h [code]
-
Generated on Tue Mar 27 16:32:29 2012 by  - -doxygen 1.4.7
- - diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/functions.html b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/functions.html deleted file mode 100644 index 2dc86e2c0..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/functions.html +++ /dev/null @@ -1,126 +0,0 @@ - - -Class Members - - - - - - -
- -
-
- -
- -

-Here is a list of all class members with links to the classes they belong to: -

-

- a -

-

- b -

-

- c -

-

- e -

-

- f -

-

- g -

-

- i -

-

- k -

-

- l -

-

- m -

-

- n -

-

- p -

-

- q -

-

- s -

-

- ~ -

-
Generated on Tue Mar 27 16:32:29 2012 by  - -doxygen 1.4.7
- - diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/functions_func.html b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/functions_func.html deleted file mode 100644 index a82a14a3a..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/functions_func.html +++ /dev/null @@ -1,63 +0,0 @@ - - -Class Members - Functions - - - - - - -
- -
-  -

-

-
Generated on Tue Mar 27 16:32:29 2012 by  - -doxygen 1.4.7
- - diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/functions_vars.html b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/functions_vars.html deleted file mode 100644 index 3eb5ab2c3..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/functions_vars.html +++ /dev/null @@ -1,49 +0,0 @@ - - -Class Members - Variables - - - - - - -
- -
-  -

-

-
Generated on Tue Mar 27 16:32:29 2012 by  - -doxygen 1.4.7
- - diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/globals.html b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/globals.html deleted file mode 100644 index 6867e7583..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/globals.html +++ /dev/null @@ -1,36 +0,0 @@ - - -Class Members - - - - - - -
- -
-Here is a list of all file members with links to the files they belong to: -

-

-
Generated on Tue Mar 27 16:32:29 2012 by  - -doxygen 1.4.7
- - diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/globals_vars.html b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/globals_vars.html deleted file mode 100644 index efb3d3424..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/globals_vars.html +++ /dev/null @@ -1,36 +0,0 @@ - - -Class Members - - - - - - -
- -
-  -

-

-
Generated on Tue Mar 27 16:32:29 2012 by  - -doxygen 1.4.7
- - diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/index.html b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/index.html deleted file mode 100644 index 8e6122ad2..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/index.html +++ /dev/null @@ -1,25 +0,0 @@ - - -Common Root library for SLS detectors data analysis - - - - - -

Common Root library for SLS detectors data analysis

-

-

-Introduction

-We know very well s-curves etc. but at the end everybody uses different functions ;-).

-Motivation

-It would be greate to use everybody the same functions...
Generated on Tue Mar 27 16:32:29 2012 by  - -doxygen 1.4.7
- - diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/installdox b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/installdox deleted file mode 100755 index 9b89fe025..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/installdox +++ /dev/null @@ -1,117 +0,0 @@ -#!/usr/bin/perl - -%subst = ( ); -$quiet = 0; - -if (open(F,"search.cfg")) -{ - $_= ; s/[ \t\n]*$//g ; $subst{"_doc"} = $_; - $_= ; s/[ \t\n]*$//g ; $subst{"_cgi"} = $_; -} - -while ( @ARGV ) { - $_ = shift @ARGV; - if ( s/^-// ) { - if ( /^l(.*)/ ) { - $v = ($1 eq "") ? shift @ARGV : $1; - ($v =~ /\/$/) || ($v .= "/"); - $_ = $v; - if ( /(.+)\@(.+)/ ) { - if ( exists $subst{$1} ) { - $subst{$1} = $2; - } else { - print STDERR "Unknown tag file $1 given with option -l\n"; - &usage(); - } - } else { - print STDERR "Argument $_ is invalid for option -l\n"; - &usage(); - } - } - elsif ( /^q/ ) { - $quiet = 1; - } - elsif ( /^\?|^h/ ) { - &usage(); - } - else { - print STDERR "Illegal option -$_\n"; - &usage(); - } - } - else { - push (@files, $_ ); - } -} - -foreach $sub (keys %subst) -{ - if ( $subst{$sub} eq "" ) - { - print STDERR "No substitute given for tag file `$sub'\n"; - &usage(); - } - elsif ( ! $quiet && $sub ne "_doc" && $sub ne "_cgi" ) - { - print "Substituting $subst{$sub} for each occurence of tag file $sub\n"; - } -} - -if ( ! @files ) { - if (opendir(D,".")) { - foreach $file ( readdir(D) ) { - $match = ".html"; - next if ( $file =~ /^\.\.?$/ ); - ($file =~ /$match/) && (push @files, $file); - ($file =~ "tree.js") && (push @files, $file); - } - closedir(D); - } -} - -if ( ! @files ) { - print STDERR "Warning: No input files given and none found!\n"; -} - -foreach $f (@files) -{ - if ( ! $quiet ) { - print "Editing: $f...\n"; - } - $oldf = $f; - $f .= ".bak"; - unless (rename $oldf,$f) { - print STDERR "Error: cannot rename file $oldf\n"; - exit 1; - } - if (open(F,"<$f")) { - unless (open(G,">$oldf")) { - print STDERR "Error: opening file $oldf for writing\n"; - exit 1; - } - if ($oldf ne "tree.js") { - while () { - s/doxygen\=\"([^ \"\:\t\>\<]*)\:([^ \"\t\>\<]*)\" (href|src)=\"\2/doxygen\=\"$1:$subst{$1}\" \3=\"$subst{$1}/g; - print G "$_"; - } - } - else { - while () { - s/\"([^ \"\:\t\>\<]*)\:([^ \"\t\>\<]*)\", \"\2/\"$1:$subst{$1}\" ,\"$subst{$1}/g; - print G "$_"; - } - } - } - else { - print STDERR "Warning file $f does not exist\n"; - } - unlink $f; -} - -sub usage { - print STDERR "Usage: installdox [options] [html-file [html-file ...]]\n"; - print STDERR "Options:\n"; - print STDERR " -l tagfile\@linkName tag file + URL or directory \n"; - print STDERR " -q Quiet mode\n\n"; - exit 1; -} diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/namespaces.html b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/namespaces.html deleted file mode 100644 index f3343cb4d..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/namespaces.html +++ /dev/null @@ -1,22 +0,0 @@ - - -Namespace Index - - - - - -

Namespace List

Here is a list of all namespaces with brief descriptions: - -
std
-
Generated on Tue Mar 27 16:32:29 2012 by  - -doxygen 1.4.7
- - diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/namespacestd.html b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/namespacestd.html deleted file mode 100644 index 7f96b5d3c..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/namespacestd.html +++ /dev/null @@ -1,24 +0,0 @@ - - -std Namespace Reference - - - - - -

std Namespace Reference

-

- - -
-


Generated on Tue Mar 27 16:32:29 2012 by  - -doxygen 1.4.7
- - diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/all_61.html b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/all_61.html deleted file mode 100644 index dbc525140..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/all_61.html +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - -
-
Loading...
-
-
- ampl - energyCalibration -
-
-
Searching...
-
No Matches
- -
- - diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/all_62.html b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/all_62.html deleted file mode 100644 index 1587baf85..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/all_62.html +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - -
-
Loading...
-
-
- bg_offset - energyCalibration -
-
-
-
- bg_slope - energyCalibration -
-
-
Searching...
-
No Matches
- -
- - diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/all_63.html b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/all_63.html deleted file mode 100644 index 9f05baa3d..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/all_63.html +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - -
-
Loading...
-
-
- calibrate - energyCalibration -
-
-
-
- conven - energyCalibration.h -
-
-
-
- cs_slope - energyCalibration -
-
-
Searching...
-
No Matches
- -
- - diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/all_65.html b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/all_65.html deleted file mode 100644 index d8cc513ff..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/all_65.html +++ /dev/null @@ -1,66 +0,0 @@ - - - - - - -
-
Loading...
-
-
- el - energyCalibration.h -
-
- - - -
-
- erfFuncFluo - energyCalibrationFunctions -
-
-
-
- erfFunction - energyCalibrationFunctions -
-
-
-
- erfFunctionChargeSharing - energyCalibrationFunctions -
-
-
Searching...
-
No Matches
- -
- - diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/all_66.html b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/all_66.html deleted file mode 100644 index bd1572f3b..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/all_66.html +++ /dev/null @@ -1,55 +0,0 @@ - - - - - - -
-
Loading...
-
-
- fit_max - energyCalibration -
-
-
-
- fit_min - energyCalibration -
-
-
-
- fitSCurve - energyCalibration -
-
-
-
- flex - energyCalibration -
-
-
-
- fscurve - energyCalibration -
-
-
-
- funcs - energyCalibration -
-
-
Searching...
-
No Matches
- -
- - diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/all_67.html b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/all_67.html deleted file mode 100644 index a5fbc8718..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/all_67.html +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - -
-
Loading...
-
-
- gaussChargeSharing - energyCalibrationFunctions -
-
-
-
- getFitRange - energyCalibration -
-
-
-
- getStartParameters - energyCalibration -
-
-
Searching...
-
No Matches
- -
- - diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/all_6b.html b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/all_6b.html deleted file mode 100644 index 40cf25174..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/all_6b.html +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - -
-
Loading...
-
-
- kth_smallest - energyCalibrationFunctions -
-
-
Searching...
-
No Matches
- -
- - diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/all_6c.html b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/all_6c.html deleted file mode 100644 index 6ddf1903c..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/all_6c.html +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - -
-
Loading...
-
-
- linearCalibration - energyCalibration -
-
-
Searching...
-
No Matches
- -
- - diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/all_6d.html b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/all_6d.html deleted file mode 100644 index d7612fe26..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/all_6d.html +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - -
-
Loading...
-
-
- median - energyCalibrationFunctions -
-
-
Searching...
-
No Matches
- -
- - diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/all_6e.html b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/all_6e.html deleted file mode 100644 index 7ee4200c2..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/all_6e.html +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - -
-
Loading...
-
-
- noise - energyCalibration -
-
-
Searching...
-
No Matches
- -
- - diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/all_70.html b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/all_70.html deleted file mode 100644 index 402fa63cb..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/all_70.html +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - -
-
Loading...
-
-
- plot_flag - energyCalibration -
-
-
Searching...
-
No Matches
- -
- - diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/all_71.html b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/all_71.html deleted file mode 100644 index 0c68aa1c7..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/all_71.html +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - -
-
Loading...
-
-
- quick_select - energyCalibrationFunctions -
-
-
Searching...
-
No Matches
- -
- - diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/all_73.html b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/all_73.html deleted file mode 100644 index 52cede178..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/all_73.html +++ /dev/null @@ -1,70 +0,0 @@ - - - - - - -
-
Loading...
-
-
- scurve - energyCalibrationFunctions -
-
-
-
- scurveFluo - energyCalibrationFunctions -
-
-
-
- setFitRange - energyCalibration -
-
-
-
- setPlotFlag - energyCalibration -
-
- -
-
- setStartParameters - energyCalibration -
-
-
-
- sign - energyCalibrationFunctions -
-
-
-
- spectrum - energyCalibrationFunctions -
-
-
Searching...
-
No Matches
- -
- - diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/all_7e.html b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/all_7e.html deleted file mode 100644 index 22b73eeab..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/all_7e.html +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - -
-
Loading...
-
-
- ~energyCalibration - energyCalibration -
-
-
Searching...
-
No Matches
- -
- - diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/classes_65.html b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/classes_65.html deleted file mode 100644 index 0cd426302..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/classes_65.html +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - -
-
Loading...
- - -
Searching...
-
No Matches
- -
- - diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/close.png b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/close.png deleted file mode 100644 index 9342d3dfe..000000000 Binary files a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/close.png and /dev/null differ diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/files_65.html b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/files_65.html deleted file mode 100644 index 72afed66a..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/files_65.html +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - -
-
Loading...
- -
Searching...
-
No Matches
- -
- - diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/functions_63.html b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/functions_63.html deleted file mode 100644 index dbde61421..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/functions_63.html +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - -
-
Loading...
-
-
- calibrate - energyCalibration -
-
-
Searching...
-
No Matches
- -
- - diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/functions_65.html b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/functions_65.html deleted file mode 100644 index 4aac8500d..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/functions_65.html +++ /dev/null @@ -1,49 +0,0 @@ - - - - - - -
-
Loading...
-
-
- energyCalibration - energyCalibration -
-
-
-
- energyCalibrationFunctions - energyCalibrationFunctions -
-
-
-
- erfFuncFluo - energyCalibrationFunctions -
-
-
-
- erfFunction - energyCalibrationFunctions -
-
-
-
- erfFunctionChargeSharing - energyCalibrationFunctions -
-
-
Searching...
-
No Matches
- -
- - diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/functions_66.html b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/functions_66.html deleted file mode 100644 index e1b9f157c..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/functions_66.html +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - -
-
Loading...
-
-
- fitSCurve - energyCalibration -
-
-
Searching...
-
No Matches
- -
- - diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/functions_67.html b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/functions_67.html deleted file mode 100644 index a5fbc8718..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/functions_67.html +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - -
-
Loading...
-
-
- gaussChargeSharing - energyCalibrationFunctions -
-
-
-
- getFitRange - energyCalibration -
-
-
-
- getStartParameters - energyCalibration -
-
-
Searching...
-
No Matches
- -
- - diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/functions_6b.html b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/functions_6b.html deleted file mode 100644 index 40cf25174..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/functions_6b.html +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - -
-
Loading...
-
-
- kth_smallest - energyCalibrationFunctions -
-
-
Searching...
-
No Matches
- -
- - diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/functions_6c.html b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/functions_6c.html deleted file mode 100644 index 6ddf1903c..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/functions_6c.html +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - -
-
Loading...
-
-
- linearCalibration - energyCalibration -
-
-
Searching...
-
No Matches
- -
- - diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/functions_6d.html b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/functions_6d.html deleted file mode 100644 index d7612fe26..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/functions_6d.html +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - -
-
Loading...
-
-
- median - energyCalibrationFunctions -
-
-
Searching...
-
No Matches
- -
- - diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/functions_71.html b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/functions_71.html deleted file mode 100644 index 0c68aa1c7..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/functions_71.html +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - -
-
Loading...
-
-
- quick_select - energyCalibrationFunctions -
-
-
Searching...
-
No Matches
- -
- - diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/functions_73.html b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/functions_73.html deleted file mode 100644 index 4daf9bb0f..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/functions_73.html +++ /dev/null @@ -1,64 +0,0 @@ - - - - - - -
-
Loading...
-
-
- scurve - energyCalibrationFunctions -
-
-
-
- scurveFluo - energyCalibrationFunctions -
-
-
-
- setFitRange - energyCalibration -
-
-
-
- setPlotFlag - energyCalibration -
-
- -
-
- setStartParameters - energyCalibration -
-
-
-
- spectrum - energyCalibrationFunctions -
-
-
Searching...
-
No Matches
- -
- - diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/functions_7e.html b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/functions_7e.html deleted file mode 100644 index 22b73eeab..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/functions_7e.html +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - -
-
Loading...
-
-
- ~energyCalibration - energyCalibration -
-
-
Searching...
-
No Matches
- -
- - diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/nomatches.html b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/nomatches.html deleted file mode 100644 index fd9248fe3..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/nomatches.html +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - -
-
No Matches
-
- - diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/search.css b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/search.css deleted file mode 100644 index d263b9724..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/search.css +++ /dev/null @@ -1,198 +0,0 @@ -/*---------------- Search Box */ - -#MSearchBox { - padding: 0px; - margin: 0px; - border: none; - border: 1px solid #84B0C7; - white-space: nowrap; - -moz-border-radius: 8px; - -webkit-border-top-left-radius: 8px; - -webkit-border-top-right-radius: 8px; - -webkit-border-bottom-left-radius: 8px; - -webkit-border-bottom-right-radius: 8px; -} -#MSearchField { - font: 9pt Arial, Verdana, sans-serif; - color: #999999; - background-color: #FFFFFF; - font-style: normal; - cursor: text; - padding: 1px 1px; - margin: 0px 6px 0px 0px; - border: none; - outline: none; - vertical-align: middle; -} -.MSearchBoxActive #MSearchField { - color: #000000; -} -#MSearchSelect { - float : none; - display : inline; - background : none; - font: 9pt Verdana, sans-serif; - border: none; - margin: 0px 0px 0px 6px; - vertical-align: middle; - padding: 0px 0px; -} - -#MSearchClose { - float : none; - display : none; - background : none; - border: none; - margin: 0px 4px 0px 0px; - padding: 0px 0px; - outline: none; -} - -#MSearchCloseImg { - vertical-align: middle; -} - -.MSearchBoxLeft { - display: block; - text-align: left; - float: left; - margin-left: 6px; -} -.MSearchBoxRight { - display: block; - float: right; - text-align: right; - margin-right: 6px; -} -.MSearchBoxSpacer { - font-size: 0px; - clear: both; -} -.MSearchBoxRow { - font-size: 0px; - clear: both; -} - -/*---------------- Search filter selection */ - -#MSearchSelectWindow { - display: none; - position: absolute; - left: 0; top: 0; - border: 1px solid #A0A0A0; - background-color: #FAFAFA; - z-index: 1; - padding-top: 4px; - padding-bottom: 4px; - -moz-border-radius: 4px; - -webkit-border-top-left-radius: 4px; - -webkit-border-top-right-radius: 4px; - -webkit-border-bottom-left-radius: 4px; - -webkit-border-bottom-right-radius: 4px; - -webkit-box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.15); - } -.SelectItem { - font: 8pt Arial, Verdana, sans-serif; - padding-left: 2px; - padding-right: 12px; - border: 0px; -} -span.SelectionMark { - margin-right: 4px; - font-family: monospace; - outline-style: none; - text-decoration: none; -} -a.SelectItem { - display: block; - outline-style: none; - color: #000000; - text-decoration: none; - padding-left: 6px; - padding-right: 12px; -} -a.SelectItem:focus, -a.SelectItem:active { - color: #000000; - outline-style: none; - text-decoration: none; -} -a.SelectItem:hover { - color: #FFFFFF; - background-color: #2A50E4; - outline-style: none; - text-decoration: none; - cursor: pointer; - display: block; -} - -/*---------------- Search results window */ - -iframe#MSearchResults { - width: 60ex; - height: 15em; - } -#MSearchResultsWindow { - display: none; - position: absolute; - left: 0; top: 0; - border: 1px solid #000000; - background-color: #EEF3F5; - } - -/* ----------------------------------- */ - - -#SRIndex { - clear:both; - padding-bottom: 15px; -} - -.SREntry { - font-size: 10pt; - padding-left: 1ex; -} -.SRPage .SREntry { - font-size: 8pt; - padding: 1px 5px; -} -body.SRPage { - margin: 5px 2px; -} - -.SRChildren { - padding-left: 3ex; padding-bottom: .5em -} -.SRPage .SRChildren { - display: none; -} -.SRSymbol { - font-weight: bold; color: #153788; - font-family: Arial, Verdana, sans-serif; - text-decoration: none; - outline: none; -} - -a.SRScope { - display: block; - color: #153788; - font-family: Arial, Verdana, sans-serif; - text-decoration: none; - outline: none; -} - -a.SRSymbol:focus, a.SRSymbol:active, -a.SRScope:focus, a.SRScope:active { - text-decoration: underline; -} - -.SRPage .SRStatus { - padding: 2px 5px; - font-size: 8pt; - font-style: italic; -} - -.SRResult { - display: none; -} - diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/search.js b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/search.js deleted file mode 100644 index 4fadd5247..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/search.js +++ /dev/null @@ -1,734 +0,0 @@ -// Search script generated by doxygen -// Copyright (C) 2009 by Dimitri van Heesch. - -// The code in this file is loosly based on main.js, part of Natural Docs, -// which is Copyright (C) 2003-2008 Greg Valure -// Natural Docs is licensed under the GPL. - -var indexSectionsWithContent = -{ - 0: "000000000000000000000000000000000000000000000000000000000000000001110111000111101101000000000010", - 1: "000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000", - 2: "000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000", - 3: "000000000000000000000000000000000000000000000000000000000000000000010111000111000101000000000010", - 4: "000000000000000000000000000000000000000000000000000000000000000001110110000000101001000000000000" -}; - -var indexSectionNames = -{ - 0: "all", - 1: "classes", - 2: "files", - 3: "functions", - 4: "variables" -}; - -function convertToId(search) -{ - var result = ''; - for (i=0;i do a search - { - this.Search(); - } - } - - this.OnSearchSelectKey = function(evt) - { - var e = (evt) ? evt : window.event; // for IE - if (e.keyCode==40 && this.searchIndex0) // Up - { - this.searchIndex--; - this.OnSelectItem(this.searchIndex); - } - else if (e.keyCode==13 || e.keyCode==27) - { - this.OnSelectItem(this.searchIndex); - this.CloseSelectionWindow(); - this.DOMSearchField().focus(); - } - return false; - } - - // --------- Actions - - // Closes the results window. - this.CloseResultsWindow = function() - { - this.DOMPopupSearchResultsWindow().style.display = 'none'; - this.DOMSearchClose().style.display = 'none'; - this.Activate(false); - } - - this.CloseSelectionWindow = function() - { - this.DOMSearchSelectWindow().style.display = 'none'; - } - - // Performs a search. - this.Search = function() - { - this.keyTimeout = 0; - - // strip leading whitespace - var searchValue = this.DOMSearchField().value.replace(/^ +/, ""); - - var code = searchValue.toLowerCase().charCodeAt(0); - var hexCode; - if (code<16) - { - hexCode="0"+code.toString(16); - } - else - { - hexCode=code.toString(16); - } - - var resultsPage; - var resultsPageWithSearch; - var hasResultsPage; - - if (indexSectionsWithContent[this.searchIndex].charAt(code-32) == '1') - { - resultsPage = this.resultsPath + '/' + indexSectionNames[this.searchIndex] + '_' + hexCode + '.html'; - resultsPageWithSearch = resultsPage+'?'+escape(searchValue); - hasResultsPage = true; - } - else // nothing available for this search term - { - resultsPage = this.resultsPath + '/nomatches.html'; - resultsPageWithSearch = resultsPage; - hasResultsPage = false; - } - - window.frames.MSearchResults.location.href = resultsPageWithSearch; - var domPopupSearchResultsWindow = this.DOMPopupSearchResultsWindow(); - - if (domPopupSearchResultsWindow.style.display!='block') - { - var domSearchBox = this.DOMSearchBox(); - this.DOMSearchClose().style.display = 'inline'; - if (this.insideFrame) - { - var domPopupSearchResults = this.DOMPopupSearchResults(); - domPopupSearchResultsWindow.style.position = 'relative'; - domPopupSearchResultsWindow.style.display = 'block'; - var width = document.body.clientWidth - 8; // the -8 is for IE :-( - domPopupSearchResultsWindow.style.width = width + 'px'; - domPopupSearchResults.style.width = width + 'px'; - } - else - { - var domPopupSearchResults = this.DOMPopupSearchResults(); - var left = getXPos(domSearchBox) + domSearchBox.offsetWidth; - var top = getYPos(domSearchBox) + domSearchBox.offsetHeight + 1; - domPopupSearchResultsWindow.style.display = 'block'; - left -= domPopupSearchResults.offsetWidth; - domPopupSearchResultsWindow.style.top = top + 'px'; - domPopupSearchResultsWindow.style.left = left + 'px'; - } - } - - this.lastSearchValue = searchValue; - this.lastResultsPage = resultsPage; - } - - // -------- Activation Functions - - // Activates or deactivates the search panel, resetting things to - // their default values if necessary. - this.Activate = function(isActive) - { - if (isActive || // open it - this.DOMPopupSearchResultsWindow().style.display == 'block' - ) - { - this.DOMSearchBox().className = 'MSearchBoxActive'; - - var searchField = this.DOMSearchField(); - - if (searchField.value == this.searchLabel) // clear "Search" term upon entry - { - searchField.value = ''; - this.searchActive = true; - } - } - else if (!isActive) // directly remove the panel - { - this.DOMSearchBox().className = 'MSearchBoxInactive'; - this.DOMSearchField().value = this.searchLabel; - this.searchActive = false; - this.lastSearchValue = '' - this.lastResultsPage = ''; - } - } -} - -// ----------------------------------------------------------------------- - -// The class that handles everything on the search results page. -function SearchResults(name) -{ - // The number of matches from the last run of . - this.lastMatchCount = 0; - this.lastKey = 0; - this.repeatOn = false; - - // Toggles the visibility of the passed element ID. - this.FindChildElement = function(id) - { - var parentElement = document.getElementById(id); - var element = parentElement.firstChild; - - while (element && element!=parentElement) - { - if (element.nodeName == 'DIV' && element.className == 'SRChildren') - { - return element; - } - - if (element.nodeName == 'DIV' && element.hasChildNodes()) - { - element = element.firstChild; - } - else if (element.nextSibling) - { - element = element.nextSibling; - } - else - { - do - { - element = element.parentNode; - } - while (element && element!=parentElement && !element.nextSibling); - - if (element && element!=parentElement) - { - element = element.nextSibling; - } - } - } - } - - this.Toggle = function(id) - { - var element = this.FindChildElement(id); - if (element) - { - if (element.style.display == 'block') - { - element.style.display = 'none'; - } - else - { - element.style.display = 'block'; - } - } - } - - // Searches for the passed string. If there is no parameter, - // it takes it from the URL query. - // - // Always returns true, since other documents may try to call it - // and that may or may not be possible. - this.Search = function(search) - { - if (!search) // get search word from URL - { - search = window.location.search; - search = search.substring(1); // Remove the leading '?' - search = unescape(search); - } - - search = search.replace(/^ +/, ""); // strip leading spaces - search = search.replace(/ +$/, ""); // strip trailing spaces - search = search.toLowerCase(); - search = convertToId(search); - - var resultRows = document.getElementsByTagName("div"); - var matches = 0; - - var i = 0; - while (i < resultRows.length) - { - var row = resultRows.item(i); - if (row.className == "SRResult") - { - var rowMatchName = row.id.toLowerCase(); - rowMatchName = rowMatchName.replace(/^sr\d*_/, ''); // strip 'sr123_' - - if (search.length<=rowMatchName.length && - rowMatchName.substr(0, search.length)==search) - { - row.style.display = 'block'; - matches++; - } - else - { - row.style.display = 'none'; - } - } - i++; - } - document.getElementById("Searching").style.display='none'; - if (matches == 0) // no results - { - document.getElementById("NoMatches").style.display='block'; - } - else // at least one result - { - document.getElementById("NoMatches").style.display='none'; - } - this.lastMatchCount = matches; - return true; - } - - // return the first item with index index or higher that is visible - this.NavNext = function(index) - { - var focusItem; - while (1) - { - var focusName = 'Item'+index; - focusItem = document.getElementById(focusName); - if (focusItem && focusItem.parentNode.parentNode.style.display=='block') - { - break; - } - else if (!focusItem) // last element - { - break; - } - focusItem=null; - index++; - } - return focusItem; - } - - this.NavPrev = function(index) - { - var focusItem; - while (1) - { - var focusName = 'Item'+index; - focusItem = document.getElementById(focusName); - if (focusItem && focusItem.parentNode.parentNode.style.display=='block') - { - break; - } - else if (!focusItem) // last element - { - break; - } - focusItem=null; - index--; - } - return focusItem; - } - - this.ProcessKeys = function(e) - { - if (e.type == "keydown") - { - this.repeatOn = false; - this.lastKey = e.keyCode; - } - else if (e.type == "keypress") - { - if (!this.repeatOn) - { - if (this.lastKey) this.repeatOn = true; - return false; // ignore first keypress after keydown - } - } - else if (e.type == "keyup") - { - this.lastKey = 0; - this.repeatOn = false; - } - return this.lastKey!=0; - } - - this.Nav = function(evt,itemIndex) - { - var e = (evt) ? evt : window.event; // for IE - if (e.keyCode==13) return true; - if (!this.ProcessKeys(e)) return false; - - if (this.lastKey==38) // Up - { - var newIndex = itemIndex-1; - var focusItem = this.NavPrev(newIndex); - if (focusItem) - { - var child = this.FindChildElement(focusItem.parentNode.parentNode.id); - if (child && child.style.display == 'block') // children visible - { - var n=0; - var tmpElem; - while (1) // search for last child - { - tmpElem = document.getElementById('Item'+newIndex+'_c'+n); - if (tmpElem) - { - focusItem = tmpElem; - } - else // found it! - { - break; - } - n++; - } - } - } - if (focusItem) - { - focusItem.focus(); - } - else // return focus to search field - { - parent.document.getElementById("MSearchField").focus(); - } - } - else if (this.lastKey==40) // Down - { - var newIndex = itemIndex+1; - var focusItem; - var item = document.getElementById('Item'+itemIndex); - var elem = this.FindChildElement(item.parentNode.parentNode.id); - if (elem && elem.style.display == 'block') // children visible - { - focusItem = document.getElementById('Item'+itemIndex+'_c0'); - } - if (!focusItem) focusItem = this.NavNext(newIndex); - if (focusItem) focusItem.focus(); - } - else if (this.lastKey==39) // Right - { - var item = document.getElementById('Item'+itemIndex); - var elem = this.FindChildElement(item.parentNode.parentNode.id); - if (elem) elem.style.display = 'block'; - } - else if (this.lastKey==37) // Left - { - var item = document.getElementById('Item'+itemIndex); - var elem = this.FindChildElement(item.parentNode.parentNode.id); - if (elem) elem.style.display = 'none'; - } - else if (this.lastKey==27) // Escape - { - parent.searchBox.CloseResultsWindow(); - parent.document.getElementById("MSearchField").focus(); - } - else if (this.lastKey==13) // Enter - { - return true; - } - return false; - } - - this.NavChild = function(evt,itemIndex,childIndex) - { - var e = (evt) ? evt : window.event; // for IE - if (e.keyCode==13) return true; - if (!this.ProcessKeys(e)) return false; - - if (this.lastKey==38) // Up - { - if (childIndex>0) - { - var newIndex = childIndex-1; - document.getElementById('Item'+itemIndex+'_c'+newIndex).focus(); - } - else // already at first child, jump to parent - { - document.getElementById('Item'+itemIndex).focus(); - } - } - else if (this.lastKey==40) // Down - { - var newIndex = childIndex+1; - var elem = document.getElementById('Item'+itemIndex+'_c'+newIndex); - if (!elem) // last child, jump to parent next parent - { - elem = this.NavNext(itemIndex+1); - } - if (elem) - { - elem.focus(); - } - } - else if (this.lastKey==27) // Escape - { - parent.searchBox.CloseResultsWindow(); - parent.document.getElementById("MSearchField").focus(); - } - else if (this.lastKey==13) // Enter - { - return true; - } - return false; - } -} diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/search.png b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/search.png deleted file mode 100644 index 9dd2396db..000000000 Binary files a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/search.png and /dev/null differ diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/variables_61.html b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/variables_61.html deleted file mode 100644 index dbc525140..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/variables_61.html +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - -
-
Loading...
-
-
- ampl - energyCalibration -
-
-
Searching...
-
No Matches
- -
- - diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/variables_62.html b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/variables_62.html deleted file mode 100644 index 1587baf85..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/variables_62.html +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - -
-
Loading...
-
-
- bg_offset - energyCalibration -
-
-
-
- bg_slope - energyCalibration -
-
-
Searching...
-
No Matches
- -
- - diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/variables_63.html b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/variables_63.html deleted file mode 100644 index 6a2de4531..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/variables_63.html +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - -
-
Loading...
-
-
- conven - energyCalibration.h -
-
-
-
- cs_slope - energyCalibration -
-
-
Searching...
-
No Matches
- -
- - diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/variables_65.html b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/variables_65.html deleted file mode 100644 index b199804b0..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/variables_65.html +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - -
-
Loading...
-
-
- el - energyCalibration.h -
-
-
Searching...
-
No Matches
- -
- - diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/variables_66.html b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/variables_66.html deleted file mode 100644 index d0ae5492f..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/variables_66.html +++ /dev/null @@ -1,49 +0,0 @@ - - - - - - -
-
Loading...
-
-
- fit_max - energyCalibration -
-
-
-
- fit_min - energyCalibration -
-
-
-
- flex - energyCalibration -
-
-
-
- fscurve - energyCalibration -
-
-
-
- funcs - energyCalibration -
-
-
Searching...
-
No Matches
- -
- - diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/variables_6e.html b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/variables_6e.html deleted file mode 100644 index 7ee4200c2..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/variables_6e.html +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - -
-
Loading...
-
-
- noise - energyCalibration -
-
-
Searching...
-
No Matches
- -
- - diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/variables_70.html b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/variables_70.html deleted file mode 100644 index 402fa63cb..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/variables_70.html +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - -
-
Loading...
-
-
- plot_flag - energyCalibration -
-
-
Searching...
-
No Matches
- -
- - diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/variables_73.html b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/variables_73.html deleted file mode 100644 index 786cf3968..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/variables_73.html +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - -
-
Loading...
-
-
- sign - energyCalibrationFunctions -
-
-
Searching...
-
No Matches
- -
- - diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/tab_b.gif b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/tab_b.gif deleted file mode 100644 index 0d623483f..000000000 Binary files a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/tab_b.gif and /dev/null differ diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/tab_l.gif b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/tab_l.gif deleted file mode 100644 index 9b1e6337c..000000000 Binary files a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/tab_l.gif and /dev/null differ diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/tab_r.gif b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/tab_r.gif deleted file mode 100644 index ce9dd9f53..000000000 Binary files a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/tab_r.gif and /dev/null differ diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/tabs.css b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/tabs.css deleted file mode 100644 index a61552a67..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/tabs.css +++ /dev/null @@ -1,102 +0,0 @@ -/* tabs styles, based on http://www.alistapart.com/articles/slidingdoors */ - -DIV.tabs -{ - float : left; - width : 100%; - background : url("tab_b.gif") repeat-x bottom; - margin-bottom : 4px; -} - -DIV.tabs UL -{ - margin : 0px; - padding-left : 10px; - list-style : none; -} - -DIV.tabs LI, DIV.tabs FORM -{ - display : inline; - margin : 0px; - padding : 0px; -} - -DIV.tabs FORM -{ - float : right; -} - -DIV.tabs A -{ - float : left; - background : url("tab_r.gif") no-repeat right top; - border-bottom : 1px solid #84B0C7; - font-size : x-small; - font-weight : bold; - text-decoration : none; -} - -DIV.tabs A:hover -{ - background-position: 100% -150px; -} - -DIV.tabs A:link, DIV.tabs A:visited, -DIV.tabs A:active, DIV.tabs A:hover -{ - color: #1A419D; -} - -DIV.tabs SPAN -{ - float : left; - display : block; - background : url("tab_l.gif") no-repeat left top; - padding : 5px 9px; - white-space : nowrap; -} - -DIV.tabs INPUT -{ - float : right; - display : inline; - font-size : 1em; -} - -DIV.tabs TD -{ - font-size : x-small; - font-weight : bold; - text-decoration : none; -} - - - -/* Commented Backslash Hack hides rule from IE5-Mac \*/ -DIV.tabs SPAN {float : none;} -/* End IE5-Mac hack */ - -DIV.tabs A:hover SPAN -{ - background-position: 0% -150px; -} - -DIV.tabs LI#current A -{ - background-position: 100% -150px; - border-width : 0px; -} - -DIV.tabs LI#current SPAN -{ - background-position: 0% -150px; - padding-bottom : 6px; -} - -DIV.nav -{ - background : none; - border : none; - border-bottom : 1px solid #84B0C7; -} diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/latex/FreeSans.ttf b/slsDetectorSoftware/slsDetectorAnalysis/docs/latex/FreeSans.ttf deleted file mode 100644 index b550b90ba..000000000 Binary files a/slsDetectorSoftware/slsDetectorAnalysis/docs/latex/FreeSans.ttf and /dev/null differ diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/latex/Makefile b/slsDetectorSoftware/slsDetectorAnalysis/docs/latex/Makefile deleted file mode 100644 index 776fcf968..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/docs/latex/Makefile +++ /dev/null @@ -1,39 +0,0 @@ -all: clean refman.dvi - -ps: refman.ps - -pdf: refman.pdf - -ps_2on1: refman_2on1.ps - -pdf_2on1: refman_2on1.pdf - -refman.ps: refman.dvi - dvips -o refman.ps refman.dvi - -refman.pdf: refman.ps - ps2pdf refman.ps refman.pdf - -refman.dvi: refman.tex doxygen.sty - echo "Running latex..." - latex refman.tex - echo "Running makeindex..." - makeindex refman.idx - echo "Rerunning latex...." - latex refman.tex - latex_count=5 ; \ - while egrep -s 'Rerun (LaTeX|to get cross-references right)' refman.log && [ $$latex_count -gt 0 ] ;\ - do \ - echo "Rerunning latex...." ;\ - latex refman.tex ;\ - latex_count=`expr $$latex_count - 1` ;\ - done - -refman_2on1.ps: refman.ps - psnup -2 refman.ps >refman_2on1.ps - -refman_2on1.pdf: refman_2on1.ps - ps2pdf refman_2on1.ps refman_2on1.pdf - -clean: - rm -f *.ps *.dvi *.aux *.toc *.idx *.ind *.ilg *.log *.out refman.pdf diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/latex/annotated.tex b/slsDetectorSoftware/slsDetectorAnalysis/docs/latex/annotated.tex deleted file mode 100644 index dc3097571..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/docs/latex/annotated.tex +++ /dev/null @@ -1,5 +0,0 @@ -\section{Class List} -Here are the classes, structs, unions and interfaces with brief descriptions:\begin{CompactList} -\item\contentsline{section}{\bf{energy\-Calibration} }{\pageref{classenergyCalibration}}{} -\item\contentsline{section}{\bf{energy\-Calibration\-Functions} (Energy calibration functions )}{\pageref{classenergyCalibrationFunctions}}{} -\end{CompactList} diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/latex/classenergyCalibration.tex b/slsDetectorSoftware/slsDetectorAnalysis/docs/latex/classenergyCalibration.tex deleted file mode 100644 index ca62e39dd..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/docs/latex/classenergyCalibration.tex +++ /dev/null @@ -1,337 +0,0 @@ -\section{energy\-Calibration Class Reference} -\label{classenergyCalibration}\index{energyCalibration@{energyCalibration}} -{\tt \#include $<$energy\-Calibration.h$>$} - -\subsection*{Public Member Functions} -\begin{CompactItemize} -\item -\bf{energy\-Calibration} () -\item -\bf{$\sim$energy\-Calibration} () -\item -int \bf{set\-Plot\-Flag} (int p=-1) -\item -int \bf{set\-Scan\-Sign} (int s=0) -\item -int \bf{set\-Charge\-Sharing} (int p=-1) -\item -void \bf{set\-Fit\-Range} (Double\_\-t mi, Double\_\-t ma) -\item -void \bf{get\-Fit\-Range} (Double\_\-t \&mi, Double\_\-t \&ma) -\item -void \bf{set\-Start\-Parameters} (Double\_\-t $\ast$par) -\item -void \bf{get\-Start\-Parameters} (Double\_\-t $\ast$par) -\item -TF1 $\ast$ \bf{fit\-SCurve} (TH1 $\ast$h1, Double\_\-t $\ast$mypar, Double\_\-t $\ast$emypar) -\item -TF1 $\ast$ \bf{fit\-Spectrum} (TH1 $\ast$h1, Double\_\-t $\ast$mypar, Double\_\-t $\ast$emypar) -\item -TGraph\-Errors $\ast$ \bf{linear\-Calibration} (int nscan, Double\_\-t $\ast$en, Double\_\-t $\ast$een, Double\_\-t $\ast$fl, Double\_\-t $\ast$efl, Double\_\-t \&gain, Double\_\-t \&off, Double\_\-t \&egain, Double\_\-t \&eoff) -\item -TGraph\-Errors $\ast$ \bf{calibrate\-Scurves} (int nscan, Double\_\-t $\ast$en, Double\_\-t $\ast$een, TH1F $\ast$$\ast$h1, Double\_\-t \&gain, Double\_\-t \&off, Double\_\-t \&egain, Double\_\-t \&eoff) -\item -TGraph\-Errors $\ast$ \bf{calibrate\-Spectra} (int nscan, Double\_\-t $\ast$en, Double\_\-t $\ast$een, TH1F $\ast$$\ast$h1, Double\_\-t \&gain, Double\_\-t \&off, Double\_\-t \&egain, Double\_\-t \&eoff) -\end{CompactItemize} -\subsection*{Private Member Functions} -\begin{CompactItemize} -\item -TGraph\-Errors $\ast$ \bf{calibrate} (int nscan, Double\_\-t $\ast$en, Double\_\-t $\ast$een, TH1F $\ast$$\ast$h1, Double\_\-t \&gain, Double\_\-t \&off, Double\_\-t \&egain, Double\_\-t \&eoff, int integral=1) -\item -void \bf{init\-Fit\-Function} (TF1 $\ast$fun, TH1 $\ast$h1) -\item -TF1 $\ast$ \bf{fit\-Function} (TF1 $\ast$fun, TH1 $\ast$h1, Double\_\-t $\ast$mypar, Double\_\-t $\ast$emypar) -\end{CompactItemize} -\subsection*{Private Attributes} -\begin{CompactItemize} -\item -int \bf{plot\_\-flag} -\item -int \bf{cs\_\-flag} -\item -Double\_\-t \bf{fit\_\-min} -\item -Double\_\-t \bf{fit\_\-max} -\item -Double\_\-t \bf{bg\_\-offset} -\item -Double\_\-t \bf{bg\_\-slope} -\item -Double\_\-t \bf{flex} -\item -Double\_\-t \bf{noise} -\item -Double\_\-t \bf{ampl} -\item -Double\_\-t \bf{cs\_\-slope} -\item -\bf{energy\-Calibration\-Functions} $\ast$ \bf{funcs} -\item -TF1 $\ast$ \bf{fscurve} -\item -TF1 $\ast$ \bf{fspectrum} -\end{CompactItemize} - - -\subsection{Detailed Description} -class alowing the energy calibration of photon counting and anlogue detectors - - - -\subsection{Constructor \& Destructor Documentation} -\index{energyCalibration@{energy\-Calibration}!energyCalibration@{energyCalibration}} -\index{energyCalibration@{energyCalibration}!energyCalibration@{energy\-Calibration}} -\subsubsection{\setlength{\rightskip}{0pt plus 5cm}energy\-Calibration::energy\-Calibration ()}\label{classenergyCalibration_16f0658d2b526f52784057b2166efd22} - - -default constructor - creates the function with which the s-curves will be fitted \index{energyCalibration@{energy\-Calibration}!~energyCalibration@{$\sim$energyCalibration}} -\index{~energyCalibration@{$\sim$energyCalibration}!energyCalibration@{energy\-Calibration}} -\subsubsection{\setlength{\rightskip}{0pt plus 5cm}energy\-Calibration::$\sim$energy\-Calibration ()}\label{classenergyCalibration_3bae2b9c26893daa8f583758509c844f} - - -default destructor - deletes the function with which the s-curves will be fitted - -\subsection{Member Function Documentation} -\index{energyCalibration@{energy\-Calibration}!calibrate@{calibrate}} -\index{calibrate@{calibrate}!energyCalibration@{energy\-Calibration}} -\subsubsection{\setlength{\rightskip}{0pt plus 5cm}TGraph\-Errors$\ast$ energy\-Calibration::calibrate (int {\em nscan}, Double\_\-t $\ast$ {\em en}, Double\_\-t $\ast$ {\em een}, TH1F $\ast$$\ast$ {\em h1}, Double\_\-t \& {\em gain}, Double\_\-t \& {\em off}, Double\_\-t \& {\em egain}, Double\_\-t \& {\em eoff}, int {\em integral} = {\tt 1})\hspace{0.3cm}{\tt [private]}}\label{classenergyCalibration_378daeddde40b6127ee6ed595506928c} - - -calculates gain and offset for the set of energies \begin{Desc} -\item[Parameters:] -\begin{description} -\item[{\em nscan}]number of energy scans \item[{\em en}]array of energies (nscan long) \item[{\em een}]array of errors on energies (nscan long) - can be NULL! \item[{\em h1}]array of TH1 \item[{\em gain}]reference to gain resulting from the fit \item[{\em offset}]reference to offset resulting from the fit \item[{\em integral}]1 is an s-curve set (default), 0 spectra \end{description} -\end{Desc} -\begin{Desc} -\item[Returns:]graph energy vs peak/inflection point \end{Desc} -\index{energyCalibration@{energy\-Calibration}!calibrateScurves@{calibrateScurves}} -\index{calibrateScurves@{calibrateScurves}!energyCalibration@{energy\-Calibration}} -\subsubsection{\setlength{\rightskip}{0pt plus 5cm}TGraph\-Errors$\ast$ energy\-Calibration::calibrate\-Scurves (int {\em nscan}, Double\_\-t $\ast$ {\em en}, Double\_\-t $\ast$ {\em een}, TH1F $\ast$$\ast$ {\em h1}, Double\_\-t \& {\em gain}, Double\_\-t \& {\em off}, Double\_\-t \& {\em egain}, Double\_\-t \& {\em eoff})\hspace{0.3cm}{\tt [inline]}}\label{classenergyCalibration_6f5ee6771522a31e4fe1eca143e2aa9b} - - -calculates gain and offset for the set of energy scans \begin{Desc} -\item[Parameters:] -\begin{description} -\item[{\em nscan}]number of energy scans \item[{\em en}]array of energies (nscan long) \item[{\em een}]array of errors on energies (nscan long) - can be NULL! \item[{\em h1}]array of TH1 \item[{\em gain}]reference to gain resulting from the fit \item[{\em off}]reference to offset resulting from the fit \item[{\em egain}]reference to error on the gain resulting from the fit \item[{\em eoff}]reference to the error on the offset resulting from the fit \end{description} -\end{Desc} -\begin{Desc} -\item[Returns:]graph energy vs inflection point \end{Desc} -\index{energyCalibration@{energy\-Calibration}!calibrateSpectra@{calibrateSpectra}} -\index{calibrateSpectra@{calibrateSpectra}!energyCalibration@{energy\-Calibration}} -\subsubsection{\setlength{\rightskip}{0pt plus 5cm}TGraph\-Errors$\ast$ energy\-Calibration::calibrate\-Spectra (int {\em nscan}, Double\_\-t $\ast$ {\em en}, Double\_\-t $\ast$ {\em een}, TH1F $\ast$$\ast$ {\em h1}, Double\_\-t \& {\em gain}, Double\_\-t \& {\em off}, Double\_\-t \& {\em egain}, Double\_\-t \& {\em eoff})\hspace{0.3cm}{\tt [inline]}}\label{classenergyCalibration_092637f656c0b88d57797e3ebd0f3e58} - - -calculates gain and offset for the set of energy spectra \begin{Desc} -\item[Parameters:] -\begin{description} -\item[{\em nscan}]number of energy scans \item[{\em en}]array of energies (nscan long) \item[{\em een}]array of errors on energies (nscan long) - can be NULL! \item[{\em h1}]array of TH1 \item[{\em gain}]reference to gain resulting from the fit \item[{\em off}]reference to offset resulting from the fit \item[{\em egain}]reference to error on the gain resulting from the fit \item[{\em eoff}]reference to the error on the offset resulting from the fit \end{description} -\end{Desc} -\begin{Desc} -\item[Returns:]graph energy vs peak \end{Desc} -\index{energyCalibration@{energy\-Calibration}!fitFunction@{fitFunction}} -\index{fitFunction@{fitFunction}!energyCalibration@{energy\-Calibration}} -\subsubsection{\setlength{\rightskip}{0pt plus 5cm}TF1$\ast$ energy\-Calibration::fit\-Function (TF1 $\ast$ {\em fun}, TH1 $\ast$ {\em h1}, Double\_\-t $\ast$ {\em mypar}, Double\_\-t $\ast$ {\em emypar})\hspace{0.3cm}{\tt [private]}}\label{classenergyCalibration_fe1c6dc5f56d12fe06569f401da19729} - - -Perfors the fit according to the flags specified and returns the fitted function \begin{Desc} -\item[Parameters:] -\begin{description} -\item[{\em fun}]function to fit \item[{\em h1}]histogram to fit \item[{\em mypar}]pointer to fit parameters array \item[{\em emypar}]pointer to fit parameter errors \end{description} -\end{Desc} -\begin{Desc} -\item[Returns:]the fitted function - can be used e.g. to get the Chi2 or similar \end{Desc} -\index{energyCalibration@{energy\-Calibration}!fitSCurve@{fitSCurve}} -\index{fitSCurve@{fitSCurve}!energyCalibration@{energy\-Calibration}} -\subsubsection{\setlength{\rightskip}{0pt plus 5cm}TF1$\ast$ energy\-Calibration::fit\-SCurve (TH1 $\ast$ {\em h1}, Double\_\-t $\ast$ {\em mypar}, Double\_\-t $\ast$ {\em emypar})}\label{classenergyCalibration_0dcd8e06e31f7b70488a012db12b2bf8} - - -fits histogram with the s-curve function \begin{Desc} -\item[Parameters:] -\begin{description} -\item[{\em h1}]1d-histogram to be fitted \item[{\em mypar}]pointer to fit parameters array \item[{\em emypar}]pointer to fit parameter errors \end{description} -\end{Desc} -\begin{Desc} -\item[Returns:]the fitted function - can be used e.g. to get the Chi2 or similar \end{Desc} -\index{energyCalibration@{energy\-Calibration}!fitSpectrum@{fitSpectrum}} -\index{fitSpectrum@{fitSpectrum}!energyCalibration@{energy\-Calibration}} -\subsubsection{\setlength{\rightskip}{0pt plus 5cm}TF1$\ast$ energy\-Calibration::fit\-Spectrum (TH1 $\ast$ {\em h1}, Double\_\-t $\ast$ {\em mypar}, Double\_\-t $\ast$ {\em emypar})}\label{classenergyCalibration_7d22b28cd2fad3d334f15f3d6dc7975a} - - -fits histogram with the spectrum \begin{Desc} -\item[Parameters:] -\begin{description} -\item[{\em h1}]1d-histogram to be fitted \item[{\em mypar}]pointer to fit parameters array \item[{\em emypar}]pointer to fit parameter errors \end{description} -\end{Desc} -\begin{Desc} -\item[Returns:]the fitted function - can be used e.g. to get the Chi2 or similar \end{Desc} -\index{energyCalibration@{energy\-Calibration}!getFitRange@{getFitRange}} -\index{getFitRange@{getFitRange}!energyCalibration@{energy\-Calibration}} -\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void energy\-Calibration::get\-Fit\-Range (Double\_\-t \& {\em mi}, Double\_\-t \& {\em ma})\hspace{0.3cm}{\tt [inline]}}\label{classenergyCalibration_bfb02327a6897bd97525c01697a1ba4f} - - -gets the s-curve fit range \begin{Desc} -\item[Parameters:] -\begin{description} -\item[{\em mi}]reference for minimum of the fit range (-1 is histogram x-min) \item[{\em ma}]reference for maximum of the fit range (-1 is histogram x-max) \end{description} -\end{Desc} -\index{energyCalibration@{energy\-Calibration}!getStartParameters@{getStartParameters}} -\index{getStartParameters@{getStartParameters}!energyCalibration@{energy\-Calibration}} -\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void energy\-Calibration::get\-Start\-Parameters (Double\_\-t $\ast$ {\em par})}\label{classenergyCalibration_fc7411b7a3191748dfcc90f86b823bf4} - - -get start parameters for the s-curve function \begin{Desc} -\item[Parameters:] -\begin{description} -\item[{\em par}]parameters, -1 means auto-calculated par[0] is the pedestal par[1] is the slope of the pedestal par[2] is the inflection point par[3] is the RMS par[4] is the amplitude par[5] is the angual coefficient of the charge sharing slope (scales with par[3]) -- always positive \end{description} -\end{Desc} -\index{energyCalibration@{energy\-Calibration}!initFitFunction@{initFitFunction}} -\index{initFitFunction@{initFitFunction}!energyCalibration@{energy\-Calibration}} -\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void energy\-Calibration::init\-Fit\-Function (TF1 $\ast$ {\em fun}, TH1 $\ast$ {\em h1})\hspace{0.3cm}{\tt [private]}}\label{classenergyCalibration_3e84328c11772b6263224340ec924e37} - - -Initializes the start parameters and the range of the fit depending on the histogram characteristics and/or on the start parameters specified by the user \begin{Desc} -\item[Parameters:] -\begin{description} -\item[{\em fun}]pointer to function to be initialized \item[{\em h1}]histogram from which to extract the range and start parameters, if not already specified by the user \end{description} -\end{Desc} -\index{energyCalibration@{energy\-Calibration}!linearCalibration@{linearCalibration}} -\index{linearCalibration@{linearCalibration}!energyCalibration@{energy\-Calibration}} -\subsubsection{\setlength{\rightskip}{0pt plus 5cm}TGraph\-Errors$\ast$ energy\-Calibration::linear\-Calibration (int {\em nscan}, Double\_\-t $\ast$ {\em en}, Double\_\-t $\ast$ {\em een}, Double\_\-t $\ast$ {\em fl}, Double\_\-t $\ast$ {\em efl}, Double\_\-t \& {\em gain}, Double\_\-t \& {\em off}, Double\_\-t \& {\em egain}, Double\_\-t \& {\em eoff})}\label{classenergyCalibration_c7f46f2d051f28211681e851f99d3fc4} - - -calculates gain and offset for the set of inflection points \begin{Desc} -\item[Parameters:] -\begin{description} -\item[{\em nscan}]number of energy scans \item[{\em en}]array of energies (nscan long) \item[{\em een}]array of errors on energies (nscan long) - can be NULL! \item[{\em fl}]array of inflection points (nscan long) \item[{\em efl}]array of errors on the inflection points (nscan long) \item[{\em gain}]reference to gain resulting from the fit \item[{\em off}]reference to offset resulting from the fit \item[{\em egain}]reference to error on the gain resulting from the fit \item[{\em eoff}]reference to the error on the offset resulting from the fit \end{description} -\end{Desc} -\begin{Desc} -\item[Returns:]graph energy vs inflection point \end{Desc} -\index{energyCalibration@{energy\-Calibration}!setChargeSharing@{setChargeSharing}} -\index{setChargeSharing@{setChargeSharing}!energyCalibration@{energy\-Calibration}} -\subsubsection{\setlength{\rightskip}{0pt plus 5cm}int energy\-Calibration::set\-Charge\-Sharing (int {\em p} = {\tt -1})}\label{classenergyCalibration_e2809b419799e8b199944f185d4ebab8} - - -sets plot flag \begin{Desc} -\item[Parameters:] -\begin{description} -\item[{\em p}]plot flag (-1 gets, 0 unsets, $>$0 plot) \end{description} -\end{Desc} -\begin{Desc} -\item[Returns:]current plot flag \end{Desc} -\index{energyCalibration@{energy\-Calibration}!setFitRange@{setFitRange}} -\index{setFitRange@{setFitRange}!energyCalibration@{energy\-Calibration}} -\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void energy\-Calibration::set\-Fit\-Range (Double\_\-t {\em mi}, Double\_\-t {\em ma})\hspace{0.3cm}{\tt [inline]}}\label{classenergyCalibration_695cef5428a833d515172d987774f67b} - - -sets the s-curve fit range \begin{Desc} -\item[Parameters:] -\begin{description} -\item[{\em mi}]minimum of the fit range (-1 is histogram x-min) \item[{\em ma}]maximum of the fit range (-1 is histogram x-max) \end{description} -\end{Desc} -\index{energyCalibration@{energy\-Calibration}!setPlotFlag@{setPlotFlag}} -\index{setPlotFlag@{setPlotFlag}!energyCalibration@{energy\-Calibration}} -\subsubsection{\setlength{\rightskip}{0pt plus 5cm}int energy\-Calibration::set\-Plot\-Flag (int {\em p} = {\tt -1})\hspace{0.3cm}{\tt [inline]}}\label{classenergyCalibration_3d9af0857f7a68b7e4519917ea97e6be} - - -sets plot flag \begin{Desc} -\item[Parameters:] -\begin{description} -\item[{\em p}]plot flag (-1 gets, 0 unsets, $>$0 plot) \end{description} -\end{Desc} -\begin{Desc} -\item[Returns:]current plot flag \end{Desc} -\index{energyCalibration@{energy\-Calibration}!setScanSign@{setScanSign}} -\index{setScanSign@{setScanSign}!energyCalibration@{energy\-Calibration}} -\subsubsection{\setlength{\rightskip}{0pt plus 5cm}int energy\-Calibration::set\-Scan\-Sign (int {\em s} = {\tt 0})\hspace{0.3cm}{\tt [inline]}}\label{classenergyCalibration_7dbf1676b30ffe90c5aa917f1b2b77ee} - - -sets scan sign \begin{Desc} -\item[Parameters:] -\begin{description} -\item[{\em s}]can be 1 (energy and x-axis have the same direction) or -1 (energy and x-axis have opposite directions) otherwise gets \end{description} -\end{Desc} -\begin{Desc} -\item[Returns:]current scan sign can be 1 (energy and x-axis have the same direction) or -1 (energy and x-axis have opposite directions) \end{Desc} -\index{energyCalibration@{energy\-Calibration}!setStartParameters@{setStartParameters}} -\index{setStartParameters@{setStartParameters}!energyCalibration@{energy\-Calibration}} -\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void energy\-Calibration::set\-Start\-Parameters (Double\_\-t $\ast$ {\em par})}\label{classenergyCalibration_ba156f5290f7b404d7b8ea735fd7e7bf} - - -set start parameters for the s-curve function \begin{Desc} -\item[Parameters:] -\begin{description} -\item[{\em par}]parameters, -1 sets to auto-calculation par[0] is the pedestal par[1] is the slope of the pedestal par[2] is the inflection point par[3] is the RMS par[4] is the amplitude par[5] is the angual coefficient of the charge sharing slope (scales with par[3]) -- always positive \end{description} -\end{Desc} - - -\subsection{Member Data Documentation} -\index{energyCalibration@{energy\-Calibration}!ampl@{ampl}} -\index{ampl@{ampl}!energyCalibration@{energy\-Calibration}} -\subsubsection{\setlength{\rightskip}{0pt plus 5cm}Double\_\-t \bf{energy\-Calibration::ampl}\hspace{0.3cm}{\tt [private]}}\label{classenergyCalibration_77b954cd513271d2cfafee6033435584} - - -start value for the number of photons \index{energyCalibration@{energy\-Calibration}!bg_offset@{bg\_\-offset}} -\index{bg_offset@{bg\_\-offset}!energyCalibration@{energy\-Calibration}} -\subsubsection{\setlength{\rightskip}{0pt plus 5cm}Double\_\-t \bf{energy\-Calibration::bg\_\-offset}\hspace{0.3cm}{\tt [private]}}\label{classenergyCalibration_aa11f256a8b0a94c28a98d068013b327} - - -start value for the background pedestal \index{energyCalibration@{energy\-Calibration}!bg_slope@{bg\_\-slope}} -\index{bg_slope@{bg\_\-slope}!energyCalibration@{energy\-Calibration}} -\subsubsection{\setlength{\rightskip}{0pt plus 5cm}Double\_\-t \bf{energy\-Calibration::bg\_\-slope}\hspace{0.3cm}{\tt [private]}}\label{classenergyCalibration_9676e5cc2757c723c2262d641fb4b8b4} - - -start value for the background slope \index{energyCalibration@{energy\-Calibration}!cs_flag@{cs\_\-flag}} -\index{cs_flag@{cs\_\-flag}!energyCalibration@{energy\-Calibration}} -\subsubsection{\setlength{\rightskip}{0pt plus 5cm}int \bf{energy\-Calibration::cs\_\-flag}\hspace{0.3cm}{\tt [private]}}\label{classenergyCalibration_ce0be11dcc8418db3c7c2b139a015c96} - - -0 functions without charge sharing contribution, $>$0 with charge sharing contribution \index{energyCalibration@{energy\-Calibration}!cs_slope@{cs\_\-slope}} -\index{cs_slope@{cs\_\-slope}!energyCalibration@{energy\-Calibration}} -\subsubsection{\setlength{\rightskip}{0pt plus 5cm}Double\_\-t \bf{energy\-Calibration::cs\_\-slope}\hspace{0.3cm}{\tt [private]}}\label{classenergyCalibration_ca1efedbfea0ad5c9ea2d794e3fb368d} - - -start value for the charge sharing slope \index{energyCalibration@{energy\-Calibration}!fit_max@{fit\_\-max}} -\index{fit_max@{fit\_\-max}!energyCalibration@{energy\-Calibration}} -\subsubsection{\setlength{\rightskip}{0pt plus 5cm}Double\_\-t \bf{energy\-Calibration::fit\_\-max}\hspace{0.3cm}{\tt [private]}}\label{classenergyCalibration_e979386a3f787ef706f4a9ec5bf41d7d} - - -maximum of the s-curve fitting range, -1 is histogram x-max \index{energyCalibration@{energy\-Calibration}!fit_min@{fit\_\-min}} -\index{fit_min@{fit\_\-min}!energyCalibration@{energy\-Calibration}} -\subsubsection{\setlength{\rightskip}{0pt plus 5cm}Double\_\-t \bf{energy\-Calibration::fit\_\-min}\hspace{0.3cm}{\tt [private]}}\label{classenergyCalibration_262f574732186cdd8d3a11344d03d0bb} - - -minimum of the s-curve fitting range, -1 is histogram x-min \index{energyCalibration@{energy\-Calibration}!flex@{flex}} -\index{flex@{flex}!energyCalibration@{energy\-Calibration}} -\subsubsection{\setlength{\rightskip}{0pt plus 5cm}Double\_\-t \bf{energy\-Calibration::flex}\hspace{0.3cm}{\tt [private]}}\label{classenergyCalibration_b99d770f1c9af68d591ed20847813ad1} - - -start value for the inflection point \index{energyCalibration@{energy\-Calibration}!fscurve@{fscurve}} -\index{fscurve@{fscurve}!energyCalibration@{energy\-Calibration}} -\subsubsection{\setlength{\rightskip}{0pt plus 5cm}TF1$\ast$ \bf{energy\-Calibration::fscurve}\hspace{0.3cm}{\tt [private]}}\label{classenergyCalibration_57706a328324c25dd9f8ba6d1486e4ce} - - -function with which the s-curve will be fitted \index{energyCalibration@{energy\-Calibration}!fspectrum@{fspectrum}} -\index{fspectrum@{fspectrum}!energyCalibration@{energy\-Calibration}} -\subsubsection{\setlength{\rightskip}{0pt plus 5cm}TF1$\ast$ \bf{energy\-Calibration::fspectrum}\hspace{0.3cm}{\tt [private]}}\label{classenergyCalibration_2ee734ab28b78dc5786a7ba430f8baa5} - - -function with which the spectrum will be fitted \index{energyCalibration@{energy\-Calibration}!funcs@{funcs}} -\index{funcs@{funcs}!energyCalibration@{energy\-Calibration}} -\subsubsection{\setlength{\rightskip}{0pt plus 5cm}\bf{energy\-Calibration\-Functions}$\ast$ \bf{energy\-Calibration::funcs}\hspace{0.3cm}{\tt [private]}}\label{classenergyCalibration_e9b3307bf858331241871bde42fdd24e} - - -\index{energyCalibration@{energy\-Calibration}!noise@{noise}} -\index{noise@{noise}!energyCalibration@{energy\-Calibration}} -\subsubsection{\setlength{\rightskip}{0pt plus 5cm}Double\_\-t \bf{energy\-Calibration::noise}\hspace{0.3cm}{\tt [private]}}\label{classenergyCalibration_4461206397e2442c92be9151ee231ec5} - - -start value for the noise \index{energyCalibration@{energy\-Calibration}!plot_flag@{plot\_\-flag}} -\index{plot_flag@{plot\_\-flag}!energyCalibration@{energy\-Calibration}} -\subsubsection{\setlength{\rightskip}{0pt plus 5cm}int \bf{energy\-Calibration::plot\_\-flag}\hspace{0.3cm}{\tt [private]}}\label{classenergyCalibration_4edfb157df3624be677177dec0f9555b} - - -0 does not plot, $>$0 plots (flags?) - -The documentation for this class was generated from the following file:\begin{CompactItemize} -\item -\bf{energy\-Calibration.h}\end{CompactItemize} diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/latex/classenergyCalibrationFunctions.tex b/slsDetectorSoftware/slsDetectorAnalysis/docs/latex/classenergyCalibrationFunctions.tex deleted file mode 100644 index 1e8920959..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/docs/latex/classenergyCalibrationFunctions.tex +++ /dev/null @@ -1,135 +0,0 @@ -\section{energy\-Calibration\-Functions Class Reference} -\label{classenergyCalibrationFunctions}\index{energyCalibrationFunctions@{energyCalibrationFunctions}} -Energy calibration functions. - - -{\tt \#include $<$energy\-Calibration.h$>$} - -\subsection*{Public Member Functions} -\begin{CompactItemize} -\item -\bf{energy\-Calibration\-Functions} (int s=-1) -\item -int \bf{set\-Scan\-Sign} (int s=0) -\item -Double\_\-t \bf{gauss\-Charge\-Sharing} (Double\_\-t $\ast$x, Double\_\-t $\ast$par) -\item -Double\_\-t \bf{erf\-Function} (Double\_\-t $\ast$x, Double\_\-t $\ast$par) -\item -Double\_\-t \bf{erf\-Function\-Charge\-Sharing} (Double\_\-t $\ast$x, Double\_\-t $\ast$par) -\item -Double\_\-t \bf{erf\-Func\-Fluo} (Double\_\-t $\ast$x, Double\_\-t $\ast$par) -\item -Double\_\-t \bf{spectrum} (Double\_\-t $\ast$x, Double\_\-t $\ast$par) -\item -Double\_\-t \bf{scurve} (Double\_\-t $\ast$x, Double\_\-t $\ast$par) -\item -Double\_\-t \bf{scurve\-Fluo} (Double\_\-t $\ast$x, Double\_\-t $\ast$par) -\end{CompactItemize} -\subsection*{Static Public Member Functions} -\begin{CompactItemize} -\item -static float \bf{median} (float $\ast$x, int n) -\item -static int \bf{quick\_\-select} (int arr[$\,$], int n) -\item -static int \bf{kth\_\-smallest} (int $\ast$a, int n, int k) -\end{CompactItemize} -\subsection*{Private Attributes} -\begin{CompactItemize} -\item -int \bf{sign} -\end{CompactItemize} - - -\subsection{Detailed Description} -Energy calibration functions. - -class containing all the possible energy calibration functions (scurves with and without charge sharing, gaussian spectrum with and without charge sharing, possibility of chosing the sign of the X-axis) - - - -\subsection{Constructor \& Destructor Documentation} -\index{energyCalibrationFunctions@{energy\-Calibration\-Functions}!energyCalibrationFunctions@{energyCalibrationFunctions}} -\index{energyCalibrationFunctions@{energyCalibrationFunctions}!energyCalibrationFunctions@{energy\-Calibration\-Functions}} -\subsubsection{\setlength{\rightskip}{0pt plus 5cm}energy\-Calibration\-Functions::energy\-Calibration\-Functions (int {\em s} = {\tt -1})\hspace{0.3cm}{\tt [inline]}}\label{classenergyCalibrationFunctions_8c17162b89f3b2e642004e7c88a22ac2} - - - - -\subsection{Member Function Documentation} -\index{energyCalibrationFunctions@{energy\-Calibration\-Functions}!erfFuncFluo@{erfFuncFluo}} -\index{erfFuncFluo@{erfFuncFluo}!energyCalibrationFunctions@{energy\-Calibration\-Functions}} -\subsubsection{\setlength{\rightskip}{0pt plus 5cm}Double\_\-t energy\-Calibration\-Functions::erf\-Func\-Fluo (Double\_\-t $\ast$ {\em x}, Double\_\-t $\ast$ {\em par})}\label{classenergyCalibrationFunctions_a5fbe9da48bc2ef90b699e06ea8c5111} - - -Double Erf function with charge sharing slope par[0] is the pedestal par[1] is the slope of the pedestal par[2] is the inflection point of the first energy par[3] is the RMS of the first energy par[4] is the amplitude of the first energy par[5] is the angual coefficient of the charge sharing slope of the first energy (scales with par[3]) par[6] is the inflection point of the second energy par[7] is the RMS of the second energy par[8] is the amplitude of the second energy par[9] is the angual coefficient of the charge sharing slope of the second energy (scales with par[8]) \index{energyCalibrationFunctions@{energy\-Calibration\-Functions}!erfFunction@{erfFunction}} -\index{erfFunction@{erfFunction}!energyCalibrationFunctions@{energy\-Calibration\-Functions}} -\subsubsection{\setlength{\rightskip}{0pt plus 5cm}Double\_\-t energy\-Calibration\-Functions::erf\-Function (Double\_\-t $\ast$ {\em x}, Double\_\-t $\ast$ {\em par})}\label{classenergyCalibrationFunctions_2da1e3b9a10d23233256f8c2234f2457} - - -Basic erf function par[0] is the inflection point par[1] is the RMS par[2] is the amplitude \index{energyCalibrationFunctions@{energy\-Calibration\-Functions}!erfFunctionChargeSharing@{erfFunctionChargeSharing}} -\index{erfFunctionChargeSharing@{erfFunctionChargeSharing}!energyCalibrationFunctions@{energy\-Calibration\-Functions}} -\subsubsection{\setlength{\rightskip}{0pt plus 5cm}Double\_\-t energy\-Calibration\-Functions::erf\-Function\-Charge\-Sharing (Double\_\-t $\ast$ {\em x}, Double\_\-t $\ast$ {\em par})}\label{classenergyCalibrationFunctions_8d1b3d0f8b30423dad56d8ce5323a4a8} - - -Erf function with charge sharing slope par[0] is the pedestal par[1] is the slope of the pedestal par[2] is the inflection point par[3] is the RMS par[4] is the amplitude par[5] is the angual coefficient of the charge sharing slope (scales with par[3]) \index{energyCalibrationFunctions@{energy\-Calibration\-Functions}!gaussChargeSharing@{gaussChargeSharing}} -\index{gaussChargeSharing@{gaussChargeSharing}!energyCalibrationFunctions@{energy\-Calibration\-Functions}} -\subsubsection{\setlength{\rightskip}{0pt plus 5cm}Double\_\-t energy\-Calibration\-Functions::gauss\-Charge\-Sharing (Double\_\-t $\ast$ {\em x}, Double\_\-t $\ast$ {\em par})}\label{classenergyCalibrationFunctions_e9582e5c46d27ad25d6139d0386698f7} - - -Gaussian Function with charge sharing pedestal par[0] is the absolute height of the background pedestal par[1] is the slope of the background pedestal par[2] is the gaussian peak position par[3] is the RMS of the gaussian (and of the pedestal) par[4] is the height of the function par[5] is the fractional height of the charge sharing pedestal (scales with par[3]) \index{energyCalibrationFunctions@{energy\-Calibration\-Functions}!kth_smallest@{kth\_\-smallest}} -\index{kth_smallest@{kth\_\-smallest}!energyCalibrationFunctions@{energy\-Calibration\-Functions}} -\subsubsection{\setlength{\rightskip}{0pt plus 5cm}static int energy\-Calibration\-Functions::kth\_\-smallest (int $\ast$ {\em a}, int {\em n}, int {\em k})\hspace{0.3cm}{\tt [static]}}\label{classenergyCalibrationFunctions_7d9a7b8d0c8ff69638a5fbb9f4c04b90} - - -Calculates the median of an array of n elements (swaps the arrays!) \index{energyCalibrationFunctions@{energy\-Calibration\-Functions}!median@{median}} -\index{median@{median}!energyCalibrationFunctions@{energy\-Calibration\-Functions}} -\subsubsection{\setlength{\rightskip}{0pt plus 5cm}static float energy\-Calibration\-Functions::median (float $\ast$ {\em x}, int {\em n})\hspace{0.3cm}{\tt [static]}}\label{classenergyCalibrationFunctions_37f557bacb75213073c8d421cc1240f4} - - -Calculates the median of an array of n elements \index{energyCalibrationFunctions@{energy\-Calibration\-Functions}!quick_select@{quick\_\-select}} -\index{quick_select@{quick\_\-select}!energyCalibrationFunctions@{energy\-Calibration\-Functions}} -\subsubsection{\setlength{\rightskip}{0pt plus 5cm}static int energy\-Calibration\-Functions::quick\_\-select (int {\em arr}[$\,$], int {\em n})\hspace{0.3cm}{\tt [static]}}\label{classenergyCalibrationFunctions_a3ab0e7c3c862fb51dfda78f1b09a55c} - - -Calculates the median of an array of n elements (swaps the arrays!) \index{energyCalibrationFunctions@{energy\-Calibration\-Functions}!scurve@{scurve}} -\index{scurve@{scurve}!energyCalibrationFunctions@{energy\-Calibration\-Functions}} -\subsubsection{\setlength{\rightskip}{0pt plus 5cm}Double\_\-t energy\-Calibration\-Functions::scurve (Double\_\-t $\ast$ {\em x}, Double\_\-t $\ast$ {\em par})}\label{classenergyCalibrationFunctions_e220482622e88a46b12498b0e4d8113a} - - -Erf function with charge sharing slope with the correct scan sign par[0] is the pedestal par[1] is the slope of the pedestal par[2] is the inflection point par[3] is the RMS par[4] is the amplitude par[5] is the angual coefficient of the charge sharing slope (scales with par[3]) \index{energyCalibrationFunctions@{energy\-Calibration\-Functions}!scurveFluo@{scurveFluo}} -\index{scurveFluo@{scurveFluo}!energyCalibrationFunctions@{energy\-Calibration\-Functions}} -\subsubsection{\setlength{\rightskip}{0pt plus 5cm}Double\_\-t energy\-Calibration\-Functions::scurve\-Fluo (Double\_\-t $\ast$ {\em x}, Double\_\-t $\ast$ {\em par})}\label{classenergyCalibrationFunctions_4eba39623b518d67a63192970a78f530} - - -Double Erf function with charge sharing slope par[0] is the pedestal par[1] is the slope of the pedestal par[2] is the inflection point of the first energy par[3] is the RMS of the first energy par[4] is the amplitude of the first energy par[5] is the angual coefficient of the charge sharing slope of the first energy (scales with par[3]) par[6] is the inflection point of the second energy par[7] is the RMS of the second energy par[8] is the amplitude of the second energy par[9] is the angual coefficient of the charge sharing slope of the second energy (scales with par[8]) \index{energyCalibrationFunctions@{energy\-Calibration\-Functions}!setScanSign@{setScanSign}} -\index{setScanSign@{setScanSign}!energyCalibrationFunctions@{energy\-Calibration\-Functions}} -\subsubsection{\setlength{\rightskip}{0pt plus 5cm}int energy\-Calibration\-Functions::set\-Scan\-Sign (int {\em s} = {\tt 0})\hspace{0.3cm}{\tt [inline]}}\label{classenergyCalibrationFunctions_716759a1ae09ea3c841f824af3ece415} - - -sets scan sign \begin{Desc} -\item[Parameters:] -\begin{description} -\item[{\em s}]can be 1 (energy and x-axis have the same direction) or -1 (energy and x-axis have opposite directions) otherwise gets \end{description} -\end{Desc} -\begin{Desc} -\item[Returns:]current scan sign can be 1 (energy and x-axis have the same direction) or -1 (energy and x-axis have opposite directions) \end{Desc} -\index{energyCalibrationFunctions@{energy\-Calibration\-Functions}!spectrum@{spectrum}} -\index{spectrum@{spectrum}!energyCalibrationFunctions@{energy\-Calibration\-Functions}} -\subsubsection{\setlength{\rightskip}{0pt plus 5cm}Double\_\-t energy\-Calibration\-Functions::spectrum (Double\_\-t $\ast$ {\em x}, Double\_\-t $\ast$ {\em par})}\label{classenergyCalibrationFunctions_015eb05dc34b77642ab2a2a9f126f170} - - -static function Gaussian with charge sharing pedestal with the correct scan sign par[0] is the absolute height of the background pedestal par[1] is the fractional height of the charge sharing pedestal (scales with par[3] par[2] is the gaussian peak position par[3] is the RMS of the gaussian (and of the pedestal) par[4] is the height of the function - -\subsection{Member Data Documentation} -\index{energyCalibrationFunctions@{energy\-Calibration\-Functions}!sign@{sign}} -\index{sign@{sign}!energyCalibrationFunctions@{energy\-Calibration\-Functions}} -\subsubsection{\setlength{\rightskip}{0pt plus 5cm}int \bf{energy\-Calibration\-Functions::sign}\hspace{0.3cm}{\tt [private]}}\label{classenergyCalibrationFunctions_4fc7c435169b5bf4672cf654270097d0} - - - - -The documentation for this class was generated from the following file:\begin{CompactItemize} -\item -\bf{energy\-Calibration.h}\end{CompactItemize} diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/latex/doxygen.sty b/slsDetectorSoftware/slsDetectorAnalysis/docs/latex/doxygen.sty deleted file mode 100644 index ff2b57e23..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/docs/latex/doxygen.sty +++ /dev/null @@ -1,78 +0,0 @@ -\NeedsTeXFormat{LaTeX2e} -\ProvidesPackage{doxygen} -\RequirePackage{calc} -\RequirePackage{array} -\pagestyle{fancyplain} -\newcommand{\clearemptydoublepage}{\newpage{\pagestyle{empty}\cleardoublepage}} -\renewcommand{\chaptermark}[1]{\markboth{#1}{}} -\renewcommand{\sectionmark}[1]{\markright{\thesection\ #1}} -\lhead[\fancyplain{}{\bfseries\thepage}] - {\fancyplain{}{\bfseries\rightmark}} -\rhead[\fancyplain{}{\bfseries\leftmark}] - {\fancyplain{}{\bfseries\thepage}} -\rfoot[\fancyplain{}{\bfseries\scriptsize Generated on Tue Mar 27 16:32:29 2012 by Doxygen }]{} -\lfoot[]{\fancyplain{}{\bfseries\scriptsize Generated on Tue Mar 27 16:32:29 2012 by Doxygen }} -\cfoot{} -\newenvironment{Code} -{\footnotesize} -{\normalsize} -\newcommand{\doxyref}[3]{\textbf{#1} (\textnormal{#2}\,\pageref{#3})} -\newenvironment{DocInclude} -{\footnotesize} -{\normalsize} -\newenvironment{VerbInclude} -{\footnotesize} -{\normalsize} -\newenvironment{Image} -{\begin{figure}[H]} -{\end{figure}} -\newenvironment{ImageNoCaption}{}{} -\newenvironment{CompactList} -{\begin{list}{}{ - \setlength{\leftmargin}{0.5cm} - \setlength{\itemsep}{0pt} - \setlength{\parsep}{0pt} - \setlength{\topsep}{0pt} - \renewcommand{\makelabel}{\hfill}}} -{\end{list}} -\newenvironment{CompactItemize} -{ - \begin{itemize} - \setlength{\itemsep}{-3pt} - \setlength{\parsep}{0pt} - \setlength{\topsep}{0pt} - \setlength{\partopsep}{0pt} -} -{\end{itemize}} -\newcommand{\PBS}[1]{\let\temp=\\#1\let\\=\temp} -\newlength{\tmplength} -\newenvironment{TabularC}[1] -{ -\setlength{\tmplength} - {\linewidth/(#1)-\tabcolsep*2-\arrayrulewidth*(#1+1)/(#1)} - \par\begin{tabular*}{\linewidth} - {*{#1}{|>{\PBS\raggedright\hspace{0pt}}p{\the\tmplength}}|} -} -{\end{tabular*}\par} -\newcommand{\entrylabel}[1]{ - {\parbox[b]{\labelwidth-4pt}{\makebox[0pt][l]{\textbf{#1}}\vspace{1.5\baselineskip}}}} -\newenvironment{Desc} -{\begin{list}{} - { - \settowidth{\labelwidth}{40pt} - \setlength{\leftmargin}{\labelwidth} - \setlength{\parsep}{0pt} - \setlength{\itemsep}{-4pt} - \renewcommand{\makelabel}{\entrylabel} - } -} -{\end{list}} -\newenvironment{Indent} - {\begin{list}{}{\setlength{\leftmargin}{0.5cm}} - \item[]\ignorespaces} - {\unskip\end{list}} -\setlength{\parindent}{0cm} -\setlength{\parskip}{0.2cm} -\addtocounter{secnumdepth}{1} -\sloppy -\usepackage[T1]{fontenc} diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/latex/energyCalibration_8h.tex b/slsDetectorSoftware/slsDetectorAnalysis/docs/latex/energyCalibration_8h.tex deleted file mode 100644 index 3c9d9f6c8..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/docs/latex/energyCalibration_8h.tex +++ /dev/null @@ -1,37 +0,0 @@ -\section{energy\-Calibration.h File Reference} -\label{energyCalibration_8h}\index{energyCalibration.h@{energyCalibration.h}} -{\tt \#include $<$TROOT.h$>$}\par -{\tt \#include $<$TF1.h$>$}\par -\subsection*{Namespaces} -\begin{CompactItemize} -\item -namespace \bf{std} -\end{CompactItemize} -\subsection*{Classes} -\begin{CompactItemize} -\item -class \bf{energy\-Calibration\-Functions} -\begin{CompactList}\small\item\em Energy calibration functions. \item\end{CompactList}\item -class \bf{energy\-Calibration} -\end{CompactItemize} -\subsection*{Variables} -\begin{CompactItemize} -\item -const float \bf{conven} = 1000./3.6 -\item -const float \bf{el} = 1.67E-4 -\end{CompactItemize} - - -\subsection{Variable Documentation} -\index{energyCalibration.h@{energy\-Calibration.h}!conven@{conven}} -\index{conven@{conven}!energyCalibration.h@{energy\-Calibration.h}} -\subsubsection{\setlength{\rightskip}{0pt plus 5cm}const float \bf{conven} = 1000./3.6}\label{energyCalibration_8h_a48a6c1eb7d418c5d0618fbb161ae321} - - -electrons/ke\-V \index{energyCalibration.h@{energy\-Calibration.h}!el@{el}} -\index{el@{el}!energyCalibration.h@{energy\-Calibration.h}} -\subsubsection{\setlength{\rightskip}{0pt plus 5cm}const float \bf{el} = 1.67E-4}\label{energyCalibration_8h_d1db7b454cab6ae1749310d7f444849b} - - -electron charge in f\-C \ No newline at end of file diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/latex/files.tex b/slsDetectorSoftware/slsDetectorAnalysis/docs/latex/files.tex deleted file mode 100644 index d3d460d1e..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/docs/latex/files.tex +++ /dev/null @@ -1,4 +0,0 @@ -\section{File List} -Here is a list of all files with brief descriptions:\begin{CompactList} -\item\contentsline{section}{\bf{energy\-Calibration.h} }{\pageref{energyCalibration_8h}}{} -\end{CompactList} diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/latex/index.tex b/slsDetectorSoftware/slsDetectorAnalysis/docs/latex/index.tex deleted file mode 100644 index 4b31a1dff..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/docs/latex/index.tex +++ /dev/null @@ -1,3 +0,0 @@ -\section{Introduction}\label{index_intro_sec} -We know very well s-curves etc. but at the end everybody uses different functions ;-).\subsection{Motivation}\label{index_mot_sec} -It would be greate to use everybody the same functions... \ No newline at end of file diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/latex/namespaces.tex b/slsDetectorSoftware/slsDetectorAnalysis/docs/latex/namespaces.tex deleted file mode 100644 index c2ca33382..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/docs/latex/namespaces.tex +++ /dev/null @@ -1,4 +0,0 @@ -\section{Namespace List} -Here is a list of all namespaces with brief descriptions:\begin{CompactList} -\item\contentsline{section}{\bf{std} }{\pageref{namespacestd}}{} -\end{CompactList} diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/latex/namespacestd.tex b/slsDetectorSoftware/slsDetectorAnalysis/docs/latex/namespacestd.tex deleted file mode 100644 index a1732dd75..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/docs/latex/namespacestd.tex +++ /dev/null @@ -1,4 +0,0 @@ -\section{std Namespace Reference} -\label{namespacestd}\index{std@{std}} - - diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/latex/refman.tex b/slsDetectorSoftware/slsDetectorAnalysis/docs/latex/refman.tex deleted file mode 100644 index 110991b6b..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/docs/latex/refman.tex +++ /dev/null @@ -1,46 +0,0 @@ -\documentclass[a4paper]{book} -\usepackage{a4wide} -\usepackage{makeidx} -\usepackage{fancyhdr} -\usepackage{graphicx} -\usepackage{multicol} -\usepackage{float} -\usepackage{textcomp} -\usepackage{alltt} -\usepackage{doxygen} -\makeindex -\setcounter{tocdepth}{1} -\renewcommand{\footrulewidth}{0.4pt} -\begin{document} -\begin{titlepage} -\vspace*{7cm} -\begin{center} -{\Large Reference Manual}\\ -\vspace*{1cm} -{\large Generated by Doxygen 1.4.7}\\ -\vspace*{0.5cm} -{\small Tue Mar 27 16:32:29 2012}\\ -\end{center} -\end{titlepage} -\clearemptydoublepage -\pagenumbering{roman} -\tableofcontents -\clearemptydoublepage -\pagenumbering{arabic} -\chapter{Common Root library for SLS detectors data analysis } -\label{index}\input{index} -\chapter{Namespace Index} -\input{namespaces} -\chapter{Class Index} -\input{annotated} -\chapter{File Index} -\input{files} -\chapter{Namespace Documentation} -\input{namespacestd} -\chapter{Class Documentation} -\input{classenergyCalibration} -\include{classenergyCalibrationFunctions} -\chapter{File Documentation} -\input{energyCalibration_8h} -\printindex -\end{document} diff --git a/slsDetectorSoftware/slsDetectorAnalysis/doxy.config b/slsDetectorSoftware/slsDetectorAnalysis/doxy.config deleted file mode 100644 index c6f5f7f13..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/doxy.config +++ /dev/null @@ -1,65 +0,0 @@ -# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in -# documentation are documented, even if no documentation was available. -# Private class members and static file members will be hidden unless -# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES - -EXTRACT_ALL = YES - -# If the EXTRACT_PRIVATE tag is set to YES all private members of a class -# will be included in the documentation. - -EXTRACT_PRIVATE = YES - -# If the EXTRACT_STATIC tag is set to YES all static members of a file -# will be included in the documentation. - -EXTRACT_STATIC = YES - -# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) -# defined locally in source files will be included in the documentation. -# If set to NO only classes defined in header files are included. - -EXTRACT_LOCAL_CLASSES = YES - -# This flag is only useful for Objective-C code. When set to YES local -# methods, which are defined in the implementation section but not in -# the interface are included in the documentation. -# If set to NO (the default) only methods in the interface are included. - -EXTRACT_LOCAL_METHODS = YES - -# If this flag is set to YES, the members of anonymous namespaces will be -# extracted and appear in the documentation as a namespace called -# 'anonymous_namespace{file}', where file will be replaced with the base -# name of the file that contains the anonymous namespace. By default -# anonymous namespace are hidden. - -EXTRACT_ANON_NSPACES = NO - -# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all -# undocumented members of documented classes, files or namespaces. -# If set to NO (the default) these members will be included in the -# various overviews, but no documentation section is generated. -# This option has no effect if EXTRACT_ALL is enabled. - -HIDE_UNDOC_MEMBERS = NO - -# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all -# undocumented classes that are normally visible in the class hierarchy. -# If set to NO (the default) these classes will be included in the various -# overviews. This option has no effect if EXTRACT_ALL is enabled. - -HIDE_UNDOC_CLASSES = NO - -# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all -# friend (class|struct|union) declarations. -# If set to NO (the default) these declarations will be included in the -# documentation. - -HIDE_FRIEND_COMPOUNDS = NO - -INPUT = energyCalibration.h - - -OUTPUT_DIRECTORY = docs - diff --git a/slsDetectorSoftware/slsDetectorAnalysis/enCalLogClass.h b/slsDetectorSoftware/slsDetectorAnalysis/enCalLogClass.h deleted file mode 100644 index e3a010df4..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/enCalLogClass.h +++ /dev/null @@ -1,133 +0,0 @@ -#ifndef ENCALLOGCLASS_H -#define ENCALLOGCLASS_H - -#include -#include - - -#ifdef __CINT__ -#define MYROOT -#endif - -#ifndef MYROOT -#include "slsDetectorCommand.h" -#include "slsDetectorUtils.h" -#include "sls_detector_defs.h" -#endif - -; - -class enCalLogClass { - - - public: - -#ifndef MYROOT - enCalLogClass(slsDetectorUtils *det){ \ - char cmd[1000]; \ - char *argv[2]; \ - strcpy(vars[0],"settings"); \ - strcpy(vars[1],"type"); \ - strcpy(vars[2],"nmod"); \ - strcpy(vars[3],"modulenumber"); \ - argv[0]=cmd; \ - sprintf(cmd,"_%d.encal",det->getFileIndex()); \ - outfile.open(std::string(det->getFilePath()+std::string("/")+det->getFileName()+std::string(cmd)).c_str()); \ - myDet=new slsDetectorCommand(det); \ - strcpy(cmd,vars[0]); \ - outfile << cmd << " " << myDet->executeLine(1,argv,slsDetectorDefs::GET_ACTION) << endl; \ - strcpy(cmd,vars[1]); \ - outfile << cmd << " " << myDet->executeLine(1,argv,slsDetectorDefs::GET_ACTION) << endl; \ - strcpy(cmd,vars[2]); \ - outfile << cmd << " " << myDet->executeLine(1,argv,slsDetectorDefs::GET_ACTION) << endl; \ - for (int im=0; imsetNumberOfModules(); im++) { \ - sprintf(cmd,"%s:%d",vars[3],im); \ - outfile << cmd << " " << myDet->executeLine(1,argv,slsDetectorDefs::GET_ACTION) << endl; \ - } \ - }; - - ~enCalLogClass(){delete myDet; outfile.close();}; -#else - enCalLogClass() { \ - strcpy(vars[0],"settings"); \ - strcpy(vars[1],"type"); \ - strcpy(vars[2],"nmod"); \ - strcpy(vars[3],"modulenumber"); \ - }; - ~enCalLogClass(){}; -#endif - - - int addStep(double threshold, std::string fname) {outfile << threshold << " " << fname << endl; return 0;}; - - - // - - int readHeader(std::ifstream &infile, char *settings, int &nmod, int &chanspermod, int *mods ) { \ - nmod=0; strcpy(settings,"unknown"); chanspermod=0; \ - char line[1000],myarg[100]; \ - int dum; \ - for (int iv=0; iv<3; iv++) { \ - infile.getline(line,1000); \ - switch (iv) { \ - case 0: \ - sscanf(line,"settings %s", settings); \ - break; \ - case 1: \ - sscanf(line,"type %s", myarg); \ - if (std::string(myarg).find("Mythen")!=std::string::npos) \ - chanspermod=1280; \ - else if (std::string(myarg).find("Gotthard")!=std::string::npos) \ - chanspermod=1280; \ - else \ - chanspermod=65535; \ - break; \ - case 2: \ - sscanf(line,"nmod %d", &nmod); \ - break; \ - default: \ - ; \ - }; \ - if (infile.bad() || infile.eof()) { cout << "bad file "<< iv << endl; return -1;} \ - } \ - for (int im=0; im -#include -#include -#include -#endif - -#include - -#define max(a,b) ((a) > (b) ? (a) : (b)) -#define min(a,b) ((a) < (b) ? (a) : (b)) -#define ELEM_SWAP(a,b) { register int t=(a);(a)=(b);(b)=t; } - - -using namespace std; - -#ifdef MYROOT -Double_t energyCalibrationFunctions::gaussChargeSharing(Double_t *x, Double_t *par) { - Double_t f, arg=0; - if (par[3]!=0) arg=(x[0]-par[2])/par[3]; - f=par[4]*TMath::Exp(-1*arg*arg/2.); - f=f+par[5]*(par[4]/2*(TMath::Erfc(sign*arg/(TMath::Sqrt(2.)))))+par[0]-par[1]*sign*x[0]; - return f; -} - -// basic erf function -Double_t energyCalibrationFunctions::erfFunction(Double_t *x, Double_t *par) { - double arg=0; - if (par[1]!=0) arg=(par[0]-x[0])/par[1]; - return ((par[2]/2.*(1+TMath::Erf(sign*arg/(TMath::Sqrt(2)))))); -}; - - -Double_t energyCalibrationFunctions::erfFunctionChargeSharing(Double_t *x, Double_t *par) { - Double_t f; - - f=erfFunction(x, par+2)*(1+par[5]*(par[2]-x[0]))+par[0]-par[1]*x[0]*sign; - return f; -}; - - -Double_t energyCalibrationFunctions::erfFuncFluo(Double_t *x, Double_t *par) { - Double_t f; - f=erfFunctionChargeSharing(x, par)+erfFunction(x, par+6)*(1+par[9]*(par[6]-x[0])); - return f; -}; -#endif - -double energyCalibrationFunctions::median(double *x, int n){ - // sorts x into xmed array and returns median - // n is number of values already in the xmed array - double xmed[n]; - int k,i,j; - - for (i=0; i*(x+j)) - k++; - if (*(x+i)==*(x+j)) { - if (i>j) - k++; - } - } - xmed[k]=*(x+i); - } - k=n/2; - return xmed[k]; -} - - -int energyCalibrationFunctions::quick_select(int arr[], int n){ - int low, high ; - int median; - int middle, ll, hh; - - low = 0 ; high = n-1 ; median = (low + high) / 2; - for (;;) { - if (high <= low) /* One element only */ - return arr[median] ; - - if (high == low + 1) { /* Two elements only */ - if (arr[low] > arr[high]) - ELEM_SWAP(arr[low], arr[high]) ; - return arr[median] ; - } - - /* Find median of low, middle and high items; swap into position low */ - middle = (low + high) / 2; - if (arr[middle] > arr[high]) ELEM_SWAP(arr[middle], arr[high]) ; - if (arr[low] > arr[high]) ELEM_SWAP(arr[low], arr[high]) ; - if (arr[middle] > arr[low]) ELEM_SWAP(arr[middle], arr[low]) ; - - /* Swap low item (now in position middle) into position (low+1) */ - ELEM_SWAP(arr[middle], arr[low+1]) ; - - /* Nibble from each end towards middle, swapping items when stuck */ - ll = low + 1; - hh = high; - for (;;) { - do ll++; while (arr[low] > arr[ll]) ; - do hh--; while (arr[hh] > arr[low]) ; - - if (hh < ll) - break; - - ELEM_SWAP(arr[ll], arr[hh]) ; - } - - /* Swap middle item (in position low) back into correct position */ - ELEM_SWAP(arr[low], arr[hh]) ; - - /* Re-set active partition */ - if (hh <= median) - low = ll; - if (hh >= median) - high = hh - 1; - } -} - -int energyCalibrationFunctions::kth_smallest(int *a, int n, int k){ - register int i,j,l,m ; - register double x ; - - l=0 ; m=n-1 ; - while (lSetParNames("Background Offset","Background Slope","Inflection Point","Noise RMS", "Number of Photons","Charge Sharing Slope"); - - fspectrum=new TF1("fspectrum",funcs,&energyCalibrationFunctions::spectrum,0,1000,6,"energyCalibrationFunctions","spectrum"); - fspectrum->SetParNames("Background Pedestal","Background slope", "Peak position","Noise RMS", "Number of Photons","Charge Sharing Pedestal"); - -#endif - - -} - - - -void energyCalibration::fixParameter(int ip, Double_t val){ - - fscurve->FixParameter(ip, val); - fspectrum->FixParameter(ip, val); -} - - -void energyCalibration::releaseParameter(int ip){ - - fscurve->ReleaseParameter(ip); - fspectrum->ReleaseParameter(ip); -} - - - - - - - -energyCalibration::~energyCalibration(){ -#ifdef MYROOT - delete fscurve; - delete fspectrum; -#endif - -} - -#ifdef MYROOT - - - -TH1F* energyCalibration::createMedianHistogram(TH2F* h2, int ch0, int nch) { - - if (h2==NULL || nch==0) - return NULL; - - double *x=new double[nch]; - TH1F *h1=NULL; - - double val=-1; - double me=0; - - - h1=new TH1F("median","Median",h2->GetYaxis()->GetNbins(),h2->GetYaxis()->GetXmin(),h2->GetYaxis()->GetXmax()); - - - for (int ib=0; ibGetXaxis()->GetNbins(); ib++) { - me=0; - for (int ich=0; ichGetBinContent(ch0+ich+1,ib+1); - me+=x[ich]; - } - cout << ib << " calculating median ch0=" << ch0 << " nch=" << nch << endl; - val=energyCalibrationFunctions::median(x, nch); - cout << "median=" << val << " mean= " << me/nch << endl; - h1->SetBinContent(ib+1,val); - } - delete [] x; - return h1; - - - -} - - - - - - - - - - - - - - -void energyCalibration::setStartParameters(Double_t *par){ - bg_offset=par[0]; - bg_slope=par[1]; - flex=par[2]; - noise=par[3]; - ampl=par[4]; - cs_slope=par[5]; -} - - -void energyCalibration::getStartParameters(Double_t *par){ - par[0]=bg_offset; - par[1]=bg_slope; - par[2]=flex; - par[3]=noise; - par[4]=ampl; - par[5]=cs_slope; -} - -#endif -int energyCalibration::setChargeSharing(int p) { - if (p>=0) { - cs_flag=p; -#ifdef MYROOT - if (p) { - fscurve->ReleaseParameter(5); - fspectrum->ReleaseParameter(1); - } else { - fscurve->FixParameter(5,0); - fspectrum->FixParameter(1,0); - } -#endif - } - - return cs_flag; -} - - -#ifdef MYROOT -void energyCalibration::initFitFunction(TF1 *fun, TH1 *h1) { - - Double_t min=fit_min, max=fit_max; - - Double_t mypar[6]; - - if (max==-1) - max=h1->GetXaxis()->GetXmax(); - - if (min==-1) - min=h1->GetXaxis()->GetXmin(); - - - if (bg_offset==-1) - mypar[0]=0; - else - mypar[0]=bg_offset; - - - if (bg_slope==-1) - mypar[1]=0; - else - mypar[1]=bg_slope; - - - if (flex==-1) - mypar[2]=(min+max)/2.; - else - mypar[2]=flex; - - - if (noise==-1) - mypar[3]=0.1; - else - mypar[3]=noise; - - if (ampl==-1) - mypar[4]=h1->GetBinContent(h1->GetXaxis()->FindBin(0.5*(max+min))); - else - mypar[4]=ampl; - - if (cs_slope==-1) - mypar[5]=0; - else - mypar[5]=cs_slope; - - fun->SetParameters(mypar); - - fun->SetRange(min,max); - -} - - -TF1* energyCalibration::fitFunction(TF1 *fun, TH1 *h1, Double_t *mypar, Double_t *emypar) { - - - TF1* fitfun; - - char fname[100]; - - strcpy(fname, fun->GetName()); - - if (plot_flag) { - h1->Fit(fname,"R"); - } else - h1->Fit(fname,"R0Q"); - - - fitfun= h1->GetFunction(fname); - fitfun->GetParameters(mypar); - for (int ip=0; ip<6; ip++) { - emypar[ip]=fitfun->GetParError(ip); - } - return fitfun; -} - -TF1* energyCalibration::fitSCurve(TH1 *h1, Double_t *mypar, Double_t *emypar) { - initFitFunction(fscurve,h1); - return fitFunction(fscurve, h1, mypar, emypar); -} - - - - - -TF1* energyCalibration::fitSpectrum(TH1 *h1, Double_t *mypar, Double_t *emypar) { - initFitFunction(fspectrum,h1); - return fitFunction(fspectrum, h1, mypar, emypar); -} - - - -TGraphErrors* energyCalibration::linearCalibration(int nscan, Double_t *en, Double_t *een, Double_t *fl, Double_t *efl, Double_t &gain, Double_t &off, Double_t &egain, Double_t &eoff) { - - TGraphErrors *gr; - - Double_t mypar[2]; - - gr = new TGraphErrors(nscan,en,fl,een,efl); - - if (plot_flag) { - gr->Fit("pol1"); - gr->SetMarkerStyle(20); - } else - gr->Fit("pol1","0Q"); - - TF1 *fitfun= gr->GetFunction("pol1"); - fitfun->GetParameters(mypar); - - egain=fitfun->GetParError(1); - eoff=fitfun->GetParError(0); - - gain=funcs->setScanSign()*mypar[1]; - off=mypar[0]; - - return gr; -} - - -TGraphErrors* energyCalibration::calibrate(int nscan, Double_t *en, Double_t *een, TH1F **h1, Double_t &gain, Double_t &off, Double_t &egain, Double_t &eoff, int integral) { - - TH1F *h; - - Double_t mypar[6], emypar[6]; - Double_t fl[nscan], efl[nscan]; - - - for (int ien=0; ien -#include -class TH1F; -class TH2F; -class TGraphErrors; -#endif - - - - - - - -const double conven=1000./3.6; /**< electrons/keV */ -const double el=1.67E-4; /**< electron charge in fC */ - - - -/** - \mainpage Common Root library for SLS detectors data analysis - * - * \section intro_sec Introduction - We know very well s-curves etc. but at the end everybody uses different functions ;-). - - * \subsection mot_sec Motivation - It would be greate to use everybody the same functions... - -*/ - - -/** - * - * -@libdoc The energiCalibration class contains all the necessary functions for s-curve fitting and linear calibration of the threshold. - * - * @short Energy calibration functions - * @author Anna Bergamaschi - * @version 0.1alpha - - - */ - -/** - class containing all the possible energy calibration functions (scurves with and without charge sharing, gaussian spectrum with and without charge sharing, possibility of chosing the sign of the X-axis) - -*/ -class energyCalibrationFunctions { - - public: - - energyCalibrationFunctions(int s=-1) {setScanSign(s);}; - - /** sets scan sign - \param s can be 1 (energy and x-axis have the same direction) or -1 (energy and x-axis have opposite directions) otherwise gets - \returns current scan sign can be 1 (energy and x-axis have the same direction) or -1 (energy and x-axis have opposite directions) - */ - int setScanSign(int s=0) {if (s==1 || s==-1) sign=s; return sign;};; - - -#ifdef MYROOT - /** - Gaussian Function with charge sharing pedestal - par[0] is the absolute height of the background pedestal - par[1] is the slope of the background pedestal - par[2] is the gaussian peak position - par[3] is the RMS of the gaussian (and of the pedestal) - par[4] is the height of the function - par[5] is the fractional height of the charge sharing pedestal (scales with par[3]) - */ - Double_t gaussChargeSharing(Double_t *x, Double_t *par); - - /** - Basic erf function - par[0] is the inflection point - par[1] is the RMS - par[2] is the amplitude - */ -Double_t erfFunction(Double_t *x, Double_t *par) ; - - /** Erf function with charge sharing slope - par[0] is the pedestal - par[1] is the slope of the pedestal - par[2] is the inflection point - par[3] is the RMS - par[4] is the amplitude - par[5] is the angual coefficient of the charge sharing slope (scales with par[3]) - */ -Double_t erfFunctionChargeSharing(Double_t *x, Double_t *par); - - /** Double Erf function with charge sharing slope - par[0] is the pedestal - par[1] is the slope of the pedestal - par[2] is the inflection point of the first energy - par[3] is the RMS of the first energy - par[4] is the amplitude of the first energy - par[5] is the angual coefficient of the charge sharing slope of the first energy (scales with par[3]) - par[6] is the inflection point of the second energy - par[7] is the RMS of the second energy - par[8] is the amplitude of the second energy - par[9] is the angual coefficient of the charge sharing slope of the second energy (scales with par[8]) - */ - -Double_t erfFuncFluo(Double_t *x, Double_t *par); - - - /** - static function Gaussian with charge sharing pedestal with the correct scan sign - par[0] is the absolute height of the background pedestal - par[1] is the fractional height of the charge sharing pedestal (scales with par[3] - par[2] is the gaussian peak position - par[3] is the RMS of the gaussian (and of the pedestal) - par[4] is the height of the function - */ - Double_t spectrum(Double_t *x, Double_t *par); - - - /** Erf function with charge sharing slope with the correct scan sign - par[0] is the pedestal - par[1] is the slope of the pedestal - par[2] is the inflection point - par[3] is the RMS - par[4] is the amplitude - par[5] is the angual coefficient of the charge sharing slope (scales with par[3]) - */ - Double_t scurve(Double_t *x, Double_t *par); - - - - /** Double Erf function with charge sharing slope - par[0] is the pedestal - par[1] is the slope of the pedestal - par[2] is the inflection point of the first energy - par[3] is the RMS of the first energy - par[4] is the amplitude of the first energy - par[5] is the angual coefficient of the charge sharing slope of the first energy (scales with par[3]) - par[6] is the inflection point of the second energy - par[7] is the RMS of the second energy - par[8] is the amplitude of the second energy - par[9] is the angual coefficient of the charge sharing slope of the second energy (scales with par[8]) - */ - Double_t scurveFluo(Double_t *x, Double_t *par); - -#endif - -/** Calculates the median of an array of n elements */ - static double median(double *x, int n); -/** Calculates the median of an array of n elements (swaps the arrays!)*/ - static int quick_select(int arr[], int n); -/** Calculates the median of an array of n elements (swaps the arrays!)*/ - static int kth_smallest(int *a, int n, int k); - - private: - int sign; - - -}; - -/** - class alowing the energy calibration of photon counting and anlogue detectors - -*/ - -class energyCalibration { - - - public: - /** - default constructor - creates the function with which the s-curves will be fitted - */ - energyCalibration(); - - /** - default destructor - deletes the function with which the s-curves will be fitted - */ - ~energyCalibration(); - - /** sets plot flag - \param p plot flag (-1 gets, 0 unsets, >0 plot) - \returns current plot flag - */ - int setPlotFlag(int p=-1) {if (p>=0) plot_flag=p; return plot_flag;}; - - /** sets scan sign - \param s can be 1 (energy and x-axis have the same direction) or -1 (energy and x-axis have opposite directions) otherwise gets - \returns current scan sign can be 1 (energy and x-axis have the same direction) or -1 (energy and x-axis have opposite directions) - */ - int setScanSign(int s=0) {return funcs->setScanSign(s);}; - - /** sets plot flag - \param p plot flag (-1 gets, 0 unsets, >0 plot) - \returns current plot flag - */ - int setChargeSharing(int p=-1); - - - void fixParameter(int ip, Double_t val); - - void releaseParameter(int ip); - -#ifdef MYROOT - - static TH1F* createMedianHistogram(TH2F* h2, int ch0, int nch); - - - /** sets the s-curve fit range - \param mi minimum of the fit range (-1 is histogram x-min) - \param ma maximum of the fit range (-1 is histogram x-max) - */ - void setFitRange(Double_t mi, Double_t ma){fit_min=mi; fit_max=ma;}; - - /** gets the s-curve fit range - \param mi reference for minimum of the fit range (-1 is histogram x-min) - \param ma reference for maximum of the fit range (-1 is histogram x-max) - */ - void getFitRange(Double_t &mi, Double_t &ma){mi=fit_min; ma=fit_max;}; - - -/** set start parameters for the s-curve function - \param par parameters, -1 sets to auto-calculation - par[0] is the pedestal - par[1] is the slope of the pedestal - par[2] is the inflection point - par[3] is the RMS - par[4] is the amplitude - par[5] is the angual coefficient of the charge sharing slope (scales with par[3]) -- always positive - */ - void setStartParameters(Double_t *par); - -/** get start parameters for the s-curve function - \param par parameters, -1 means auto-calculated - par[0] is the pedestal - par[1] is the slope of the pedestal - par[2] is the inflection point - par[3] is the RMS - par[4] is the amplitude - par[5] is the angual coefficient of the charge sharing slope (scales with par[3]) -- always positive - */ - void getStartParameters(Double_t *par); - - /** - fits histogram with the s-curve function - \param h1 1d-histogram to be fitted - \param mypar pointer to fit parameters array - \param emypar pointer to fit parameter errors - \returns the fitted function - can be used e.g. to get the Chi2 or similar - */ - TF1 *fitSCurve(TH1 *h1, Double_t *mypar, Double_t *emypar); - - - /** - fits histogram with the spectrum - \param h1 1d-histogram to be fitted - \param mypar pointer to fit parameters array - \param emypar pointer to fit parameter errors - \returns the fitted function - can be used e.g. to get the Chi2 or similar - */ - TF1 *fitSpectrum(TH1 *h1, Double_t *mypar, Double_t *emypar); - - - /** - calculates gain and offset for the set of inflection points - \param nscan number of energy scans - \param en array of energies (nscan long) - \param een array of errors on energies (nscan long) - can be NULL! - \param fl array of inflection points (nscan long) - \param efl array of errors on the inflection points (nscan long) - \param gain reference to gain resulting from the fit - \param off reference to offset resulting from the fit - \param egain reference to error on the gain resulting from the fit - \param eoff reference to the error on the offset resulting from the fit - \returns graph energy vs inflection point - */ - TGraphErrors* linearCalibration(int nscan, Double_t *en, Double_t *een, Double_t *fl, Double_t *efl, Double_t &gain, Double_t &off, Double_t &egain, Double_t &eoff); - - /** - calculates gain and offset for the set of energy scans - \param nscan number of energy scans - \param en array of energies (nscan long) - \param een array of errors on energies (nscan long) - can be NULL! - \param h1 array of TH1 - \param gain reference to gain resulting from the fit - \param off reference to offset resulting from the fit - \param egain reference to error on the gain resulting from the fit - \param eoff reference to the error on the offset resulting from the fit - \returns graph energy vs inflection point - */ - TGraphErrors* calibrateScurves(int nscan, Double_t *en, Double_t *een, TH1F **h1, Double_t &gain, Double_t &off, Double_t &egain, Double_t &eoff){return calibrate(nscan, en, een, h1, gain, off, egain, eoff, 1);}; - - /** - calculates gain and offset for the set of energy spectra - \param nscan number of energy scans - \param en array of energies (nscan long) - \param een array of errors on energies (nscan long) - can be NULL! - \param h1 array of TH1 - \param gain reference to gain resulting from the fit - \param off reference to offset resulting from the fit - \param egain reference to error on the gain resulting from the fit - \param eoff reference to the error on the offset resulting from the fit - \returns graph energy vs peak - */ - TGraphErrors* calibrateSpectra(int nscan, Double_t *en, Double_t *een, TH1F **h1, Double_t &gain, Double_t &off, Double_t &egain, Double_t &eoff){return calibrate(nscan, en, een, h1, gain, off, egain, eoff, 0);}; - - -#endif - private: - -#ifdef MYROOT - /** - calculates gain and offset for the set of energies - \param nscan number of energy scans - \param en array of energies (nscan long) - \param een array of errors on energies (nscan long) - can be NULL! - \param h1 array of TH1 - \param gain reference to gain resulting from the fit - \param off reference to offset resulting from the fit - \param egain reference to error on the gain resulting from the fit - \param eoff reference to the error on the offset resulting from the fit - \param integral 1 is an s-curve set (default), 0 spectra - \returns graph energy vs peak/inflection point - */ - TGraphErrors* calibrate(int nscan, Double_t *en, Double_t *een, TH1F **h1, Double_t &gain, Double_t &off, Double_t &egain, Double_t &eoff, int integral=1); - - - /** - Initializes the start parameters and the range of the fit depending on the histogram characteristics and/or on the start parameters specified by the user - \param fun pointer to function to be initialized - \param h1 histogram from which to extract the range and start parameters, if not already specified by the user - -*/ - - void initFitFunction(TF1 *fun, TH1 *h1); - - - /** - Performs the fit according to the flags specified and returns the fitted function - \param fun function to fit - \param h1 histogram to fit - \param mypar pointer to fit parameters array - \param emypar pointer to fit parameter errors - \returns the fitted function - can be used e.g. to get the Chi2 or similar - */ - TF1 *fitFunction(TF1 *fun, TH1 *h1, Double_t *mypar, Double_t *emypar); - -#endif - -#ifdef MYROOT - Double_t fit_min; /**< minimum of the s-curve fitting range, -1 is histogram x-min */ - Double_t fit_max; /**< maximum of the s-curve fitting range, -1 is histogram x-max */ - - Double_t bg_offset; /**< start value for the background pedestal */ - Double_t bg_slope; /**< start value for the background slope */ - Double_t flex; /**< start value for the inflection point */ - Double_t noise; /**< start value for the noise */ - Double_t ampl; /**< start value for the number of photons */ - Double_t cs_slope; /**< start value for the charge sharing slope */ - - - TF1 *fscurve; /**< function with which the s-curve will be fitted */ - - TF1 *fspectrum; /**< function with which the spectrum will be fitted */ - -#endif - - energyCalibrationFunctions *funcs; - int plot_flag; /**< 0 does not plot, >0 plots (flags?) */ - - int cs_flag; /**< 0 functions without charge sharing contribution, >0 with charge sharing contribution */ - -}; - -#endif - - - - - - - - - - - - - - - - - - - diff --git a/slsDetectorSoftware/slsDetectorAnalysis/energyCalibrationMacro.C b/slsDetectorSoftware/slsDetectorAnalysis/energyCalibrationMacro.C deleted file mode 100644 index 5a4c4386f..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/energyCalibrationMacro.C +++ /dev/null @@ -1,24 +0,0 @@ -{ - - TH1F *h1[3]; - TH2F *h2=createScan("/scratch/stability_test/ag_source_S%d_10.raw",500,900,10,1280*2); - h1[0]=getCh(h2,500); - h1[1]=getCh(h2,300); - h1[2]=getCh(h2,700); - Double_t gain, offset, eg, eo; - Double_t en[3]={20,22,24}; - TH1F *h; - energyCalibration *e=new energyCalibration(); - e->setFitRange(500,700); - Double_t mypar[6]; - mypar[0]=0; //pedestal - mypar[1]=0; //pedestal slope - mypar[2]=-1; //inflection point - must be free for all energies and will be set at half of the scan range - mypar[3]=10; //noise rms - mypar[4]=1000; //number of photons - mypar[5]=0; //charge sharing slope - e->setFitParameters(mypar); - - TGraphErrors *gr=e->calibrate(3,en,NULL,h1,gain,offset,eg,eo); - -} diff --git a/slsDetectorSoftware/slsDetectorAnalysis/energyConversion.cpp b/slsDetectorSoftware/slsDetectorAnalysis/energyConversion.cpp deleted file mode 100644 index 91a555caa..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/energyConversion.cpp +++ /dev/null @@ -1,614 +0,0 @@ -#include "energyConversion.h" - -#include -#include -#include -#include - -#include "fileIOStatic.h" - -using namespace std; - - - - -int energyConversion::readCalibrationFile(string fname, double &gain, double &offset){ - - string str; - ifstream infile; -#ifdef VERBOSE - std::cout<< "Opening file "<< fname << std::endl; -#endif - infile.open(fname.c_str(), ios_base::in); - if (infile.is_open()) { - getline(infile,str); -#ifdef VERBOSE - std::cout<< str << std::endl; -#endif - istringstream ssstr(str); - ssstr >> offset >> gain; - infile.close(); - cout << "Calibration file loaded: " << fname << endl; - } else { - std::cout<< "Could not open calibration file "<< fname << std::endl; - gain=0.; - offset=0.; -#ifndef MYROOT - return FAIL; -#endif - return -1; - } -#ifndef MYROOT - return OK; -#endif - return 0; -}; - -int energyConversion::writeCalibrationFile(string fname, double gain, double offset){ - //std::cout<< "Function not yet implemented " << std::endl; - ofstream outfile; - outfile.open (fname.c_str()); - - // >> i/o operations here << - if (outfile.is_open()) { - outfile << offset << " " << gain << std::endl; - } else { - std::cout<< "Could not open calibration file "<< fname << " for writing" << std::endl; -#ifndef MYROOT - return FAIL; -#endif - return -1; - } - - outfile.close(); - -#ifndef MYROOT - return OK; -#endif - return 0; -}; - - -int energyConversion::readCalibrationFile(string fname, int *gain, int *offset){ - - string str; - ifstream infile; - double o,g; - int ig=0; -#ifdef VERBOSE - std::cout<< "Opening file "<< fname << std::endl; -#endif - infile.open(fname.c_str(), ios_base::in); - if (infile.is_open()) { - //get gain and offset - for (ig=0; ig<4; ig++) { - //while ( (getline(infile,str)) > -1) { - getline(infile,str); -#ifdef VERBOSE - std::cout<< str << std::endl; -#endif - istringstream ssstr(str); - ssstr >> o >> g; - offset[ig]=(int)(o*1000); - gain[ig]=(int)(g*1000); - // ig++; - if (ig>=4) - break; - } - infile.close(); - cout << "Calibration file loaded: " << fname << endl; - } else { - cout << "Could not open calibration file: "<< fname << std::endl; - gain[0]=0; - offset[0]=0; -#ifndef MYROOT - return FAIL; -#endif - return -1; - } -#ifndef MYROOT - return OK; -#endif - return 0; - -}; - -int energyConversion::writeCalibrationFile(string fname, int *gain, int *offset){ - //std::cout<< "Function not yet implemented " << std::endl; - ofstream outfile; - outfile.open (fname.c_str()); - // >> i/o operations here << - if (outfile.is_open()) { - for (int ig=0; ig<4; ig++) - outfile << ((double)offset[ig]/1000) << " " << ((double)gain[ig]/1000) << std::endl; - } else { - std::cout<< "Could not open calibration file "<< fname << " for writing" << std::endl; -#ifndef MYROOT - return FAIL; -#endif - return -1; - } - - outfile.close(); -#ifndef MYROOT - return OK; -#endif - return 0; -}; - - - -slsDetectorDefs::sls_detector_module* energyConversion::interpolateTrim(detectorType myDetectorType, sls_detector_module* a, sls_detector_module* b, const int energy, const int e1, const int e2, int tb){ - // only implemented for eiger currently (in terms of which dacs) - if(myDetectorType != EIGER) { - printf("Interpolation of Trim values not implemented for this detector!\n"); - return NULL; - } - - sls_detector_module* myMod = createModule(myDetectorType); - enum eiger_DacIndex{SVP,VTR,VRF,VRS,SVN,VTGSTV,VCMP_LL,VCMP_LR,CAL,VCMP_RL,RXB_RB,RXB_LB,VCMP_RR,VCP,VCN,VIS}; - - //Copy other dacs - int dacs_to_copy[] = {SVP,VTR,SVN,VTGSTV,RXB_RB,RXB_LB,VCN,VIS}; - int num_dacs_to_copy = sizeof(dacs_to_copy) / sizeof(dacs_to_copy[0]); - for (int i = 0; i < num_dacs_to_copy; ++i) { - if(a->dacs[dacs_to_copy[i]] != b->dacs[dacs_to_copy[i]]) { - deleteModule(myMod); - return NULL; - } - myMod->dacs[dacs_to_copy[i]] = a->dacs[dacs_to_copy[i]]; - } - - - //Copy irrelevant dacs (without failing): CAL - if (a->dacs[CAL] != b->dacs[CAL]) { - printf("Warning: DAC CAL differs in both energies (%d, %d)! ", - a->dacs[CAL], b->dacs[CAL]); - printf("Taking first: %d\n", a->dacs[CAL]); - } - myMod->dacs[CAL] = a->dacs[CAL]; - - - //Interpolate vrf, vcmp, vcp - int dacs_to_interpolate[] = {VRF,VCMP_LL,VCMP_LR,VCMP_RL,VCMP_RR,VCP, VRS}; - int num_dacs_to_interpolate = sizeof(dacs_to_interpolate) / sizeof(dacs_to_interpolate[0]); - for (int i = 0; i < num_dacs_to_interpolate; ++i) { - myMod->dacs[dacs_to_interpolate[i]] = linearInterpolation(energy, e1, e2, - a->dacs[dacs_to_interpolate[i]], b->dacs[dacs_to_interpolate[i]]); - } - - //Interpolate all trimbits - if(tb) { - for (int i = 0; inchan; i++) - myMod->chanregs[i] = linearInterpolation(energy, e1, e2, a->chanregs[i], b->chanregs[i]); - } - return myMod; -} - - - -#ifndef MYROOT - -/* I/O */ - - -slsDetectorDefs::sls_detector_module* energyConversion::readSettingsFile(string fname, detectorType myDetectorType, int& iodelay, int& tau, sls_detector_module* myMod, int tb){ - - - - - int nflag=0; - - - if (myMod==NULL) { - myMod=createModule(myDetectorType); - nflag=1; - } - - int id=0,i; - string names[100]; - string myfname; - string str; - ifstream infile; - ostringstream oss; - int iline=0; - string sargname; - int ival; - int ichan=0, ichip=0, idac=0; - int nch=((myMod->nchan)/(myMod->nchip)); - - //ascii settings/trim file - switch (myDetectorType) { - case MYTHEN: - break; - case MOENCH: - names[id++]="Vdac0"; - names[id++]="Vdac1"; - names[id++]="Vdac2"; - names[id++]="Vdac3"; - names[id++]="Vdac4"; - names[id++]="Vdac5"; - names[id++]="Vdac6"; - names[id++]="Vdac7"; - break; - case GOTTHARD: - case PROPIX: - names[id++]="Vref"; - names[id++]="VcascN"; - names[id++]="VcascP"; - names[id++]="Vout"; - names[id++]="Vcasc"; - names[id++]="Vin"; - names[id++]="Vref_comp"; - names[id++]="Vib_test"; - break; - case EIGER: - break; - case JUNGFRAU: - names[id++]="VDAC0"; - names[id++]="VDAC1"; - names[id++]="VDAC2"; - names[id++]="VDAC3"; - names[id++]="VDAC4"; - names[id++]="VDAC5"; - names[id++]="VDAC6"; - names[id++]="VDAC7"; - names[id++]="VDAC8"; - names[id++]="VDAC9"; - names[id++]="VDAC10"; - names[id++]="VDAC11"; - names[id++]="VDAC12"; - names[id++]="VDAC13"; - names[id++]="VDAC14"; - names[id++]="VDAC15"; - break; - default: - cout << "Unknown detector type - unknown format for settings file" << endl; - return NULL; - } - -#ifdef VERBOSE - std::cout<< "reading settings file for module number "<< myMod->module << std::endl; -#endif - myfname=fname; -#ifdef VERBOSE - std::cout<< "file name is "<< myfname << std::endl; -#endif - - switch (myDetectorType) { - - case MYTHEN: - infile.open(myfname.c_str(), ios_base::in); - if (infile.is_open()) { - for (int iarg=0; iargndac; iarg++) { - getline(infile,str); - iline++; - istringstream ssstr(str); - ssstr >> sargname >> ival; -#ifdef VERBOSE - std::cout<< sargname << " dac nr. " << idac << " is " << ival << std::endl; -#endif - myMod->dacs[idac]=ival; - idac++; - } - for (ichip=0; ichipnchip; ichip++) { - getline(infile,str); - iline++; -#ifdef VERYVERBOSE - std::cout<< str << std::endl; -#endif - istringstream ssstr(str); - ssstr >> sargname >> ival; -#ifdef VERYVERBOSE - std::cout<< "chip " << ichip << " " << sargname << " is " << ival << std::endl; -#endif - - myMod->chipregs[ichip]=ival; - for (ichan=0; ichannChans <<" iline " << iline<< std::endl; -#endif - iline++; - myMod->chanregs[ichip*nch+ichan]=0; - for (int iarg=0; iarg<6 ; iarg++) { - ssstr >> ival; - //if (ssstr.good()) { - switch (iarg) { - case 0: -#ifdef VERYVERBOSE - std::cout<< "trimbits " << ival ; -#endif - myMod->chanregs[ichip*nch+ichan]|=ival&TRIMBITMASK; - break; - case 1: -#ifdef VERYVERBOSE - std::cout<< " compen " << ival ; -#endif - myMod->chanregs[ichip*nch+ichan]|=ival<<9; - break; - case 2: -#ifdef VERYVERBOSE - std::cout<< " anen " << ival ; -#endif - myMod->chanregs[ichip*nch+ichan]|=ival<<8; - break; - case 3: -#ifdef VERYVERBOSE - std::cout<< " calen " << ival ; -#endif - myMod->chanregs[ichip*nch+ichan]|=ival<<7; - break; - case 4: -#ifdef VERBOSE - std::cout<< " outcomp " << ival ; -#endif - myMod->chanregs[ichip*nch+ichan]|=ival<<10; - break; - case 5: -#ifdef VERBOSE - std::cout<< " counts " << ival << std::endl; -#endif - myMod->chanregs[ichip*nch+ichan]|=ival<<11; - break; - default: - std::cout<< " too many columns" << std::endl; - break; - } - } - } - // } - } -#ifdef VERBOSE - std::cout<< "read " << ichan*ichip << " channels" <dacs,sizeof(dacs_t)*(myMod->ndac)); - infile.read((char*)&iodelay,sizeof(iodelay)); - infile.read((char*)&tau,sizeof(tau)); -#ifdef VERBOSE - for(int i=0;indac;i++) - std::cout << "dac " << i << ":" << myMod->dacs[i] << std::endl; - std::cout << "iodelay:" << iodelay << std::endl; - std::cout << "tau:" << tau << std::endl; -#endif - if(tb) { - infile.read((char*) myMod->chanregs,sizeof(int)*(myMod->nchan)); - if(infile.eof()){ - cout<> sargname >> ival; - for (i=0;idacs[i]=ival; - idac++; -#ifdef VERBOSE - std::cout<< sargname << " dac nr. " << idac << " is " << ival << std::endl; -#endif - break; - } - } - } - if (i < id) { -#ifdef VERBOSE - std::cout<< sargname << " dac nr. " << idac << " is " << ival << std::endl; -#endif - }else - std::cout<< "Unknown dac " << sargname << std::endl; - - infile.close(); - strcpy(settingsFile,fname.c_str()); - printf("Settings file loaded: %s\n",settingsFile); - return myMod; - - } - - //---------------------------------- - break; - - default: - std::cout<< "Unknown detector type - don't know how to read file" << myfname << std::endl; - infile.close(); - deleteModule(myMod); - return NULL; - - } - - printf("Error: Could not open settings file %s\n", myfname.c_str()); - if (nflag) - deleteModule(myMod); - - return NULL; - - - -}; - - -int energyConversion::writeSettingsFile(string fname, detectorType myDetectorType, sls_detector_module mod, int iodelay, int tau){ - - ofstream outfile; - - int nch=((mod.nchan)/(mod.nchip)); - - string names[100]; - int id=0; - switch (myDetectorType) { - case MYTHEN: - names[id++]="Vtrim"; - names[id++]="Vthresh"; - names[id++]="Rgsh1"; - names[id++]="Rgsh2"; - names[id++]="Rgpr"; - names[id++]="Vcal"; - names[id++]="outBuffEnable"; - break; - case MOENCH: - names[id++]="Vdac0"; - names[id++]="Vdac1"; - names[id++]="Vdac2"; - names[id++]="Vdac3"; - names[id++]="Vdac4"; - names[id++]="Vdac5"; - names[id++]="Vdac6"; - names[id++]="Vdac7"; - break; - case GOTTHARD: - case PROPIX: - names[id++]="Vref"; - names[id++]="VcascN"; - names[id++]="VcascP"; - names[id++]="Vout"; - names[id++]="Vcasc"; - names[id++]="Vin"; - names[id++]="Vref_comp"; - names[id++]="Vib_test"; - break; - case EIGER: - break; - case JUNGFRAU: - names[id++]="VDAC0"; - names[id++]="VDAC1"; - names[id++]="VDAC2"; - names[id++]="VDAC3"; - names[id++]="VDAC4"; - names[id++]="VDAC5"; - names[id++]="VDAC6"; - names[id++]="VDAC7"; - names[id++]="VDAC8"; - names[id++]="VDAC9"; - names[id++]="VDAC10"; - names[id++]="VDAC11"; - names[id++]="VDAC12"; - names[id++]="VDAC13"; - names[id++]="VDAC14"; - names[id++]="VDAC15"; - break; - default: - cout << "Unknown detector type - unknown format for settings file" << endl; - return FAIL; - } - - int iv, ichan, ichip; - int iv1, idac; - int nb; - - switch (myDetectorType) { - case EIGER: - outfile.open(fname.c_str(), ofstream::binary); - if (outfile.is_open()) { - iv = 1150; -#ifdef VERBOSE - for(int i=0;i(&iodelay), sizeof(iodelay)); - outfile.write(reinterpret_cast(&tau), sizeof(tau)); - outfile.write((char*)mod.chanregs, sizeof(int)*(mod.nchan)); - - outfile.close(); - return slsDetectorDefs::OK; - } - - printf("Could not open Settings file %s\n", fname.c_str()); - return slsDetectorDefs::FAIL; - default: - - - outfile.open(fname.c_str(), ios_base::out); - - if (outfile.is_open()) { - for (idac=0; idac>nb); - outfile << iv1 << " "; - nb=8; - iv1=((iv&(1<>nb); - outfile << iv1 << " "; - nb=7; - iv1=((iv&(1<>nb); - outfile <>nb); - outfile << iv1 << " "; - nb=11; - iv1= ((iv&0xfffff800)>>nb); - outfile << iv1 << std::endl; - } - } - } - outfile.close(); - return OK; - } - std::cout<< "could not open SETTINGS file " << fname << std::endl; - return FAIL; - - } - - -}; - - - -#endif diff --git a/slsDetectorSoftware/slsDetectorAnalysis/energyConversion.h b/slsDetectorSoftware/slsDetectorAnalysis/energyConversion.h deleted file mode 100644 index 518c75c34..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/energyConversion.h +++ /dev/null @@ -1,147 +0,0 @@ -#ifndef ENERGYCONVERSION_H -#define ENERGYCONVERSION_H - -#ifdef __CINT__ -#define MYROOT -#define __cplusplus -#endif - -//#ifndef MYROOT -//#include "sls_receiver_defs.h" -#include "sls_detector_defs.h" -//#endif -#include -#include - - -/** - @short class handling the energy calibration and trim files IO -*/ - - -class energyConversion -//#ifndef MYROOT -: private virtual slsDetectorDefs - //#endif -{ - public: - /** default constrauctor */ - energyConversion(){}; - /** default destructor */ - virtual ~energyConversion(){}; - - - /** - reads a calibration file - \param fname file to be read - \param gain reference to the gain variable - \param offset reference to the offset variable - \returns OK if successful, else FAIL or -1 - - */ - static int readCalibrationFile(std::string fname, double &gain, double &offset); - - /** - writes a calibration file - \param fname file to be written - \param gain - \param offset - \returns OK if successful, else FAIL or -1 - */ - static int writeCalibrationFile(std::string fname, double gain, double offset); - - /** - reads a calibration file - \param fname file to be read - \param gain reference to the gain variable - \param offset reference to the offset variable - \returns OK if successful, else FAIL or -1 - */ - static int readCalibrationFile(std::string fname, int *gain, int *offset); - - /** - writes a calibration file - \param fname file to be written - \param gain reference to the gain variable - \param offset reference to the offset variable - \returns OK if successful, else FAIL or -1 - */ - static int writeCalibrationFile(std::string fname, int *gain, int *offset); - - - - //Template function to do linear interpolation between two points - template - V linearInterpolation(const E x, const E x1, const E x2, const V y1, const V y2){ - double k = static_cast(y2-y1)/(x2-x1); - double m = y1-k*x1; - int y = round( k*x+m ); - return static_cast(y); - } - - - /** - * interpolates dacs and trimbits between 2 trim files - \param myDetectorType detector type (needed for which dacs that neeeds to be interpolated & which kept same) - \param a first module structure - \param b second module structure - \param energy energy to trim at - \param e1 reference trim value - \param e2 reference trim value - \param tb 1 to include trimbits, 0 to exclude (used for eiger) - \returns the pointer to the module structure with interpolated values or NULL if error - */ - sls_detector_module* interpolateTrim(detectorType myDetectorType, sls_detector_module* a, sls_detector_module* b, const int energy, const int e1, const int e2, int tb=1); - - - -#ifndef MYROOT - - /** - reads a trim/settings file - \param fname name of the file to be read - \param myDetectorType detector type (needed for number of channels, chips, dacs etc.) - \param iodelay io delay (detector specific) - \param tau tau (detector specific) - \param myMod pointer to the module structure which has to be set.
If it is NULL a new module structure will be created - \param tb 1 to include trimbits, 0 to exclude (used for eiger) - \returns the pointer to myMod or NULL if reading the file failed - */ - - sls_detector_module* readSettingsFile(std::string fname, detectorType myDetectorType, int& iodelay, int& tau, sls_detector_module* myMod=NULL, int tb=1); - - /** - writes a trim/settings file - \param fname name of the file to be written - \param myDetectorType detector type (needed for number of channels, chips, dacs etc.) - \param mod module structure which has to be written to file - \param iodelay io delay (detector specific) - \param tau tau (detector specific) - \returns OK or FAIL if the file could not be written - - \sa ::sls_detector_module mythenDetector::writeSettingsFile(string, sls_detector_module) - */ - int writeSettingsFile(std::string fname, detectorType myDetectorType, sls_detector_module mod, int iodelay, int tau); - - /** allocates the momery for a detector module structure - \param myDetectorType detector type (needed for number of channels, chips, dacs etc.) - \returns pointer to detector module - */ - virtual sls_detector_module* createModule(detectorType myDetectorType)=0; - - /** - frees the memory of a detector module structure - \param myMod pointer to memeory to be freed - */ - virtual void deleteModule(sls_detector_module *myMod)=0; - - - protected: - /** pointer to settings file name */ - char *settingsFile; - - -#endif - -}; -#endif diff --git a/slsDetectorSoftware/slsDetectorAnalysis/fileIO.cpp b/slsDetectorSoftware/slsDetectorAnalysis/fileIO.cpp deleted file mode 100644 index 051094145..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/fileIO.cpp +++ /dev/null @@ -1,204 +0,0 @@ -#include "fileIO.h" - -using namespace std; - - -/* I/O */ - -/* generates file name without extension*/ - -string fileIO::createFileName() { - - pthread_mutex_lock(&mf); - currentFileName=fileIOStatic::createFileName(filePath, \ - fileName, \ - getActionMask(), \ - getCurrentScanVariable(0), \ - getScanPrecision(0), \ - getCurrentScanVariable(1), \ - getScanPrecision(1), \ - getCurrentPositionIndex(), \ - getNumberOfPositions(), \ - *fileIndex, \ - frameIndex, \ - detIndex \ - ); - - //if (getDetectorsType()==JUNGFRAUCTB) { - // nBytes=2*getTotalNumberOfChannels(); - //} else - nBytes=getDataBytes(); - pthread_mutex_unlock(&mf); - return currentFileName; - -} - - - -/* generates file prefix for receivers */ - -string fileIO::createReceiverFilePrefix() { - pthread_mutex_lock(&mf); - currentReceiverFilePrefix=fileIOStatic::createReceiverFilePrefix(fileName, \ - getActionMask(), \ - getCurrentScanVariable(0), \ - getScanPrecision(0), \ - getCurrentScanVariable(1), \ - getScanPrecision(1), \ - getCurrentPositionIndex(), \ - getNumberOfPositions(), \ - detIndex \ - ); - pthread_mutex_unlock(&mf); - return currentReceiverFilePrefix; - -} - - - -/*writes raw data file */ - -int fileIO::writeDataFile(string fname, double *data, double *err, double *ang, char dataformat, int nch){ - if (nch==-1) - nch=getTotalNumberOfChannels(); - - // cout << "Write filexxx...." << endl; - - return fileIOStatic::writeDataFile(fname, nch, data, err, ang, dataformat); - -} -int fileIO::writeDataFile(ofstream &outfile, double *data, double *err, double *ang, char dataformat, int nch, int offset){ - if (nch==-1) - nch=getTotalNumberOfChannels(); - - //cout << "Write file...." << endl; - - return fileIOStatic::writeDataFile(outfile, nch, data, err, ang, dataformat, offset); - -} - - -int fileIO::writeDataFile(string fname, int *data){ - - return fileIOStatic::writeDataFile(fname, getTotalNumberOfChannels(), data); -} - - - - -int fileIO::writeDataFile(ofstream &outfile, int *data, int offset){ - - // cout << "Write raw file...." << endl; - return fileIOStatic::writeDataFile(outfile, getTotalNumberOfChannels(), data, offset); -} - - - -int fileIO::writeDataFile(void *data, int iframe) { - - if (iframe<0) - iframe=frameIndex; - - if ((*framesPerFile)<2) - iframe=-1; - - if ((iframe%(*framesPerFile))==0 || (iframe<0) || filefd==0) { - createFileName(); - filefd = fopen((currentFileName+string(".raw")).c_str(), "w"); - } - - if (filefd){ -// fileIOStatic::writeBinaryDataFile(filefd,getDataBytes(), data); - cout <<"Writing "<< nBytes<< " dataBytes"<< endl; - fileIOStatic::writeBinaryDataFile(filefd,nBytes, data); - iframe++; - } - - if ((iframe%(*framesPerFile)==0) || (iframe<0)) { - if (filefd) - fclose(filefd); - filefd=NULL; - } - return 0; -} - - - -int fileIO::closeDataFile() { - cout << "close file...." << endl; - if (filefd) - fclose(filefd); - filefd=NULL; - return 0; -} - - - - - -int fileIO::writeDataFile(string fname, short int *data){ - - cout << "Write raw file...." << endl; - return fileIOStatic::writeDataFile(fname, getTotalNumberOfChannels(), data); -} - - - - - - - - - -int fileIO::writeDataFile(ofstream &outfile, short int *data, int offset){ - - return fileIOStatic::writeDataFile(outfile, getTotalNumberOfChannels(), data, offset); -} - - - - - - - - - - -int fileIO::readDataFile(string fname, double *data, double *err, double *ang, char dataformat) { - return fileIOStatic::readDataFile(getTotalNumberOfChannels(), fname, data, err, ang, dataformat); - -} - -int fileIO::readDataFile(ifstream &infile, double *data, double *err, double *ang, char dataformat, int offset) { - return fileIOStatic::readDataFile(getTotalNumberOfChannels(), infile, data, err, ang, dataformat, offset); - -} - - - -int fileIO::readDataFile(string fname, int *data){ - - return fileIOStatic::readDataFile(fname, data, getTotalNumberOfChannels()); -}; - - -int fileIO::readDataFile(ifstream &infile, int *data, int offset){ - - return fileIOStatic::readDataFile(infile, data, getTotalNumberOfChannels(), offset); -}; - - - - - -int fileIO::readDataFile(string fname, short int *data){ - - return fileIOStatic::readDataFile(fname, data, getTotalNumberOfChannels()); -}; - - -int fileIO::readDataFile(ifstream &infile, short int *data, int offset){ - - return fileIOStatic::readDataFile(infile, data, getTotalNumberOfChannels(),offset); -}; - diff --git a/slsDetectorSoftware/slsDetectorAnalysis/fileIO.h b/slsDetectorSoftware/slsDetectorAnalysis/fileIO.h deleted file mode 100644 index 1cc70cf55..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/fileIO.h +++ /dev/null @@ -1,420 +0,0 @@ -#ifndef FILEIO_H -#define FILEIO_H - -#include "slsDetectorBase.h" -#include "fileIOStatic.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -// -/** - @short class handling the data file I/O flags -*/ - -class fileIO : public fileIOStatic, public virtual slsDetectorBase { - - - public: - - /* enum rawFileFormat { */ -/* ASCII, */ -/* BINARY */ -/* } */ - - - /** default constructor */ - fileIO(): fileIOStatic(){ - currentFrameIndex=-1; - frameIndex=-1; - detIndex=-1; - framesPerFile=&nframes; - nframes=1; - filefd = NULL; - pthread_mutex_t mp1 = PTHREAD_MUTEX_INITIALIZER; - mf=mp1; - pthread_mutex_init(&mf, NULL); - }; - - /** virtual destructor */ - virtual ~fileIO(){}; - - using fileIOStatic::readDataFile; - using fileIOStatic::writeDataFile; - using fileIOStatic::createFileName; - - int getFileIndexFromFileName(std::string fname){ - int ret; - pthread_mutex_lock(&mf); - ret=fileIOStatic::getFileIndexFromFileName(fname); - pthread_mutex_unlock(&mf); - return ret; - }; - int getIndicesFromFileName(std::string fname, int &index){ - int ret; - pthread_mutex_lock(&mf); - ret=fileIOStatic::getIndicesFromFileName(fname,index); - pthread_mutex_unlock(&mf); - return ret; - }; - - - - int getVariablesFromFileName(std::string fname, int &index, int &p_index, double &sv0, double &sv1){ - - int ret; - pthread_mutex_lock(&mf); - ret=fileIOStatic::getVariablesFromFileName(fname, index, p_index, sv0, sv1); - pthread_mutex_unlock(&mf); - return ret; - }; - - int getVariablesFromFileName(std::string fname, int &index, int &f_index, int &p_index, double &sv0, double &sv1, int &detindex){ - - - int ret; - pthread_mutex_lock(&mf); - ret=fileIOStatic::getVariablesFromFileName(fname, f_index, index, p_index, sv0, sv1, detindex); - pthread_mutex_unlock(&mf); - return ret; - }; - - /** - sets the default output files path - \param s file path - \return actual file path - */ - virtual std::string setFilePath(std::string s) { - pthread_mutex_lock(&mf); - sprintf(filePath, "%s", s.c_str()); - pthread_mutex_unlock(&mf); - return std::string(filePath); - }; - - /** - sets the default output files root name - \param s file name to be set - \returns actual file name - */ - virtual std::string setFileName(std::string s) { - pthread_mutex_lock(&mf); - sprintf(fileName, "%s", s.c_str()); - pthread_mutex_unlock(&mf); - return std::string(fileName);}; - - /** - sets the default output file index - \param i start file index to be set - \returns actual file index - */ - virtual int setFileIndex(int i) { - pthread_mutex_lock(&mf); - *fileIndex=i; - pthread_mutex_unlock(&mf); - return *fileIndex; - }; - - /** - sets the default output file frame index - \param i file frame index to be set - \returns actual file frame index - */ - virtual int setFrameIndex(int i) { - pthread_mutex_lock(&mf); - frameIndex=i; - pthread_mutex_unlock(&mf); - return frameIndex;}; - - /** - sets the default output current frame index - \param i current frame index to be set - \returns actual current frame index - */ - virtual int setCurrentFrameIndex(int i) { - pthread_mutex_lock(&mf); - currentFrameIndex=i; - pthread_mutex_unlock(&mf); - return currentFrameIndex; - }; - - /** - sets the default output file index - \param i frame index to be set - \returns actual frame index - */ - virtual int setFramesPerFile(int i) { - pthread_mutex_lock(&mf); - if (i>0) *framesPerFile=i; - pthread_mutex_unlock(&mf); - return *framesPerFile;}; - - /** - sets the default output file index - \param i detector index to be set - \returns actual detector index - */ - virtual int setDetectorIndex(int i) { - pthread_mutex_lock(&mf); - detIndex=i; - pthread_mutex_unlock(&mf); - return detIndex;}; - - /** - sets the default file format - \param i file format to be set - \returns actual file frame format - */ - virtual fileFormat setFileFormat(int i) { - pthread_mutex_lock(&mf); - *fileFormatType=(fileFormat)i; - pthread_mutex_unlock(&mf); - return *fileFormatType; }; - - - - /** - \returns the output files path - - */ - virtual std::string getFilePath() {return std::string(filePath);}; - /** - \returns the output files root name - */ - virtual std::string getFileName() {return std::string(fileName);}; - - /** - \returns the output file index - */ - virtual int getFileIndex() {return *fileIndex;}; - - /** - \returns the output file frame index - */ - virtual int getFrameIndex() {return frameIndex;}; - - /** - \returns the output current frame index - */ - virtual int getCurrentFrameIndex() {return currentFrameIndex;}; - - /** - \returns the detector index - */ - virtual int getDetectorIndex() {return detIndex;}; - - /** - \returns the max frames per file - */ - virtual int getFramesPerFile() {return *framesPerFile;}; - - /** - \returns the max frames per file - */ - virtual fileFormat getFileFormat() {return *fileFormatType;}; - - - std::string createFileName(); - - std::string createReceiverFilePrefix(); - - - /** - writes a data file - \param fname of the file to be written - \param data array of data values - \param err array of arrors on the data. If NULL no errors will be written - \param ang array of angular values. If NULL data will be in the form chan-val(-err) otherwise ang-val(-err) - \param dataformat format of the data: can be 'i' integer or 'f' double (default) - \param nch number of channels to be written to file. if -1 defaults to the number of installed channels of the detector - \returns OK or FAIL if it could not write the file or data=NULL - */ - virtual int writeDataFile(std::string fname, double *data, double *err=NULL, double *ang=NULL, char dataformat='f', int nch=-1); - - - /** - - writes a data file - \param outfile output file stream - \param data array of data values - \param err array of arrors on the data. If NULL no errors will be written - - \param ang array of angular values. If NULL data will be in the form chan-val(-err) otherwise ang-val(-err) - \param dataformat format of the data: can be 'i' integer or 'f' double (default) - \param nch number of channels to be written to file. if -1 defaults to the number of installed channels of the detector - \param offset start channel number - \returns OK or FAIL if it could not write the file or data=NULL - - */ - virtual int writeDataFile(std::ofstream &outfile, double *data, double *err=NULL, double *ang=NULL, char dataformat='f', int nch=-1, int offset=0); - - - /** - writes a data file - \param fname of the file to be written - \param data array of data values - \returns OK or FAIL if it could not write the file or data=NULL - */ - virtual int writeDataFile(std::string fname, int *data); - - - virtual int writeDataFile(void *data, int iframe=-1); - - int closeDataFile(); - /** - writes a data file - \param outfile output file stream - \param data array of data values - \param offset start channel number - \returns OK or FAIL if it could not write the file or data=NULL - */ - virtual int writeDataFile(std::ofstream &outfile, int *data, int offset=0); - - - - /** - writes a data file of short ints - \param fname of the file to be written - \param data array of data values - \returns OK or FAIL if it could not write the file or data=NULL - */ - virtual int writeDataFile(std::string fname, short int *data); - - - - - - - - /** - writes a data file of short ints - \param outfile output file stream - \param data array of data values - \param offset start channel number - \returns OK or FAIL if it could not write the file or data=NULL - */ - virtual int writeDataFile(std::ofstream &outfile, short int *data, int offset=0); - - - /** - reads a data file - \param fname of the file to be read - \param data array of data values to be filled - \param err array of arrors on the data. If NULL no errors are expected on the file - - \param ang array of angular values. If NULL data are expected in the form chan-val(-err) otherwise ang-val(-err) - \param dataformat format of the data: can be 'i' integer or 'f' double (default) - \returns OK or FAIL if it could not read the file or data=NULL - */ - virtual int readDataFile(std::string fname, double *data, double *err=NULL, double *ang=NULL, char dataformat='f'); - - /** - reads a data file - \param ifstream input file stream - \param data array of data values to be filled - \param err array of arrors on the data. If NULL no errors are expected on the file - - \param ang array of angular values. If NULL data are expected in the form chan-val(-err) otherwise ang-val(-err) - \param offset start channel number to be expected - \returns OK or FAIL if it could not read the file or data=NULL - */ - int readDataFile(std::ifstream& infile, double *data, double *err=NULL, double *ang=NULL, char dataformat='f', int offset=0); - - /** - reads a raw data file - \param fname of the file to be read - \param data array of data values - \returns OK or FAIL if it could not read the file or data=NULL -yes */ - virtual int readDataFile(std::string fname, int *data); - -/** - reads a raw data file - \param infile input file stream - \param data array of data values - \param offset first channel number to be expected - \returns OK or FAIL if it could not read the file or data=NULL - */ - int readDataFile(std::ifstream &infile, int *data, int offset=0); - - /** - - reads a short int raw data file - \param fname of the file to be read - \param data array of data values - \returns OK or FAIL if it could not read the file or data=NULL - */ - virtual int readDataFile(std::string fname, short int *data); - /** - reads a short int raw data file - \param infile input file stream - \param data array of data values - \param offset first channel number to be expected - \returns OK or FAIL if it could not read the file or data=NULL - */ - int readDataFile(std::ifstream &infile, short int *data, int offset=0); - - virtual int getDataBytes ( )=0; - friend class slsDetector; - - std::string getCurrentFileName(){return currentFileName;}; - protected: - - - void incrementFileIndex() { (*fileIndex)++; }; - - void incrementFrameIndex(int i) { frameIndex=frameIndex+i; }; - - void incrementCurrentFrameIndex() { (currentFrameIndex)++; }; - - void incrementDetectorIndex() { (detIndex)++; }; - - - std::string getCurrentReceiverFilePrefix(){return currentReceiverFilePrefix;}; - - - std::string currentFileName; - - std::string currentReceiverFilePrefix; - - - /** output directory */ - char *filePath; - /** file root name */ - char *fileName; - /** file index */ - int *fileIndex; - /** file frame index */ - int frameIndex; - /** current frame index */ - int currentFrameIndex; - /** detector id */ - int detIndex; - /** frames per file */ - int *framesPerFile; - /** file format */ - fileFormat *fileFormatType; - - private: - - - FILE *filefd; - std::ofstream fstream; - - int nframes; - // int fformat; - - - int nBytes; - - /** mutex to synchronize read/write fname */ - pthread_mutex_t mf; -}; - -#endif diff --git a/slsDetectorSoftware/slsDetectorAnalysis/fileIOStatic.h b/slsDetectorSoftware/slsDetectorAnalysis/fileIOStatic.h deleted file mode 100644 index c76800791..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/fileIOStatic.h +++ /dev/null @@ -1,730 +0,0 @@ -#ifndef FILEIO_STATIC_H -#define FILEIO_STATIC_H - -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef __CINT -#define MYROOT -#endif - -using std::endl; -using std::cout; - -#include "sls_detector_defs.h" -// -/** - @short class handling the data file I/O flags -*/ - -class fileIOStatic { - - - - - public: - /** default constructor */ - fileIOStatic(){}; - /** virtual de`structor */ - virtual ~fileIOStatic(){}; - - - - - /** generates file name without extension - - always appends to file path and file name the run index. - - in case also appends the position index and the two level of scan varaibles with the specified precision - - Filenames will be of the form: filepath/(dz_)filename(_Sy_sw_px_fv)_i - where z is the detector index, y is the scan0 variable, W is the scan 1 variable, x is the position index, v is the frame index and i is the run index - \param filepath outdir - \param filename file root name - \param aMask action mask (scans, positions) - \param sv0 scan variable 0 - \param prec0 scan precision 0 - \param sv1 scan variable 1 - \param prec1 scan precision 1 - \param pindex position index - \param npos number of positions - \param findex file index - \param frameindex frame index - \param detindex detector id - \returns file name without extension - */ - static std::string createFileName(char *filepath, char *filename, int aMask, double sv0, int prec0, double sv1, int prec1, int pindex, int npos, int findex, int frameindex=-1, int detindex=-1){ \ - std::ostringstream osfn; \ - osfn << filepath << "/" << filename; \ - if ( aMask& (1 << (slsDetectorDefs::MAX_ACTIONS))) osfn << "_S" << std::fixed << std::setprecision(prec0) << sv0; \ - if (aMask & (1 << (slsDetectorDefs::MAX_ACTIONS+1))) osfn << "_s" << std::fixed << std::setprecision(prec1) << sv1; \ - if (pindex>0 && pindex<=npos) osfn << "_p" << pindex; \ - if(detindex>=0) osfn << "_d"<< detindex; \ - if(frameindex>=0) osfn << "_f" << frameindex; \ - osfn << "_" << findex; \ - return osfn.str(); \ - }; - - - /** generates file prefix for receivers without file path, frame index, file index or extension - - in case also appends the position index and the two level of scan varaibles with the specified precision - - File prefix will be of the form: (dz_)filename(_Sy_sw_px_) - where z is the detector index, y is the scan0 variable, W is the scan 1 variable and x is the position index - \param filename file root name - \param aMask action mask (scans, positions) - \param sv0 scan variable 0 - \param prec0 scan precision 0 - \param sv1 scan variable 1 - \param prec1 scan precision 1 - \param pindex position index - \param npos number of positions - \param detindex detector id - \returns file name without extension - */ - static std::string createReceiverFilePrefix(char *filename, int aMask, double sv0, int prec0, double sv1, int prec1, int pindex, int npos,int detindex=-1){ \ - std::ostringstream osfn; \ - osfn << filename; \ - if ( aMask& (1 << (slsDetectorDefs::MAX_ACTIONS))) osfn << "_S" << std::fixed << std::setprecision(prec0) << sv0; \ - if (aMask & (1 << (slsDetectorDefs::MAX_ACTIONS+1))) osfn << "_s" << std::fixed << std::setprecision(prec1) << sv1; \ - if (pindex>0 && pindex<=npos) osfn << "_p" << pindex; \ - if(detindex!=-1) osfn << "_d"<< detindex; \ - return osfn.str(); \ - }; - - - /** static function that returns the file index from the file name - \param fname file name - \returns file index - */ - static int getFileIndexFromFileName(std::string fname){ \ - int i; \ - size_t dot=fname.rfind("."); \ - if (dot==std::string::npos) \ - return -1; \ - size_t uscore=fname.rfind("_"); \ - if (uscore==std::string::npos) return -1; \ - if (sscanf( fname.substr(uscore+1,dot-uscore-1).c_str(),"%d",&i)) return i; \ - cout << "******************************** cannot parse file index" << endl; \ - return 0; \ - }; - - /** static function that returns the frame index and file index from the file name - \param fname file name - \param index reference to index - \returns frame index - */ - static int getIndicesFromFileName(std::string fname,int &index){ \ - int i; \ - std::string s; \ - size_t uscore=fname.rfind("_"); \ - if (uscore==std::string::npos) return -1; \ - s=fname; \ - if (sscanf(s.substr(uscore+1,s.size()-uscore-1).c_str(),"%d",&i)){ \ - index=i; \ - s=fname.substr(0,uscore); \ - } \ - /*else cout << "******************************** cannot parse file index" << endl; \*/ - uscore=s.rfind("_"); \ - if (sscanf( s.substr(uscore+1,s.size()-uscore-1).c_str(),"f%d",&i)){ \ - if(i==-1)return 0; \ - else return i; } \ - /*cout << "******************************** cannot parse frame index" << endl; \*/ - return 0; \ - }; - - - /** static function that returns the variables from the file name - \param fname file name - \param index reference to index - \param p_index reference to position index - \param sv0 reference to scan variable 0 - \param sv1 reference to scan variable 1 - \returns file index - */ - static int getVariablesFromFileName(std::string fname, int &index, int &p_index, double &sv0, double &sv1) { \ - int i; \ - double f; \ - std::string s; \ - index=-1; \ - p_index=-1; \ - sv0=-1; \ - sv1=-1; \ - size_t uscore=fname.rfind("_"); \ - if (uscore==std::string::npos) return -1; \ - s=fname; \ - if (sscanf(s.substr(uscore+1,s.size()-uscore-1).c_str(),"%d",&i)) { \ - index=i; \ - s=fname.substr(0,uscore); \ - } \ - /* else cout << "Warning: ******************************** cannot parse file index from " << s << endl; \*/ - uscore=s.rfind("_"); \ - if (sscanf( s.substr(uscore+1,s.size()-uscore-1).c_str(),"f%d",&i)) \ - s=fname.substr(0,uscore); \ - /*else cout << "Warning: ******************************** cannot parse frame index from " << s << endl; \*/ - uscore=s.rfind("_"); \ - if (sscanf( s.substr(uscore+1,s.size()-uscore-1).c_str(),"d%d",&i)) \ - s=fname.substr(0,uscore); \ - /* else cout << "Warning: ******************************** cannot parse detector index from " << s << endl; \*/ - uscore=s.rfind("_"); \ - if (sscanf( s.substr(uscore+1,s.size()-uscore-1).c_str(),"p%d",&i)) { \ - p_index=i; \ - s=fname.substr(0,uscore); \ - } \ - /* else cout << "Warning: ******************************** cannot parse position index from " << s << endl; \*/ - uscore=s.rfind("_"); \ - if (sscanf( s.substr(uscore+1,s.size()-uscore-1).c_str(),"s%lf",&f)) { \ - sv1=f; \ - s=fname.substr(0,uscore); \ - } \ - /* else cout << "Warning: ******************************** cannot parse scan varable 1 from " << s << endl; \*/ - uscore=s.rfind("_"); \ - if (sscanf( s.substr(uscore+1,s.size()-uscore-1).c_str(),"S%lf",&f)) { \ - sv0=f; \ - } \ - /* else cout << "Warning: ******************************** cannot parse scan varable 0 from " << s << endl; \*/ - return index; \ - }; - - - /** static function that returns the variables from the file name - \param fname file name - \param index reference to index - \param f_index reference to frame index - \param p_index reference to position index - \param sv0 reference to scan variable 0 - \param sv1 reference to scan variable 1 - \param detindex reference to detector id - \returns file index - */ - static int getVariablesFromFileName(std::string fname, int &index, int &f_index, int &p_index, double &sv0, double &sv1, int &detindex) { \ - int i; \ - double f; \ - std::string s; \ - index=-1; \ - p_index=-1; \ - sv0=-1; \ - sv1=-1; \ - size_t uscore=fname.rfind("_"); \ - if (uscore==std::string::npos) return -1; \ - s=fname; \ - if (sscanf(s.substr(uscore+1,s.size()-uscore-1).c_str(),"%d",&i)) { \ - index=i; \ - s=fname.substr(0,uscore); \ - } \ - /*else cout << "Warning: ******************************** cannot parse file index" << endl; \*/ - uscore=s.rfind("_"); \ - if (sscanf( s.substr(uscore+1,s.size()-uscore-1).c_str(),"f%d",&i)) { \ - f_index=i; \ - s=fname.substr(0,uscore); \ - } \ - /*else cout << "Warning: ******************************** cannot parse frame index" << endl; \*/ - uscore=s.rfind("_"); \ - if (sscanf( s.substr(uscore+1,s.size()-uscore-1).c_str(),"d%d",&i)) { \ - detindex=i; \ - s=fname.substr(0,uscore); \ - } \ - /* else cout << "Warning: ******************************** cannot parse detector id" << endl; \*/ - uscore=s.rfind("_"); \ - if (sscanf( s.substr(uscore+1,s.size()-uscore-1).c_str(),"p%d",&i)) { \ - p_index=i; \ - s=fname.substr(0,uscore); \ - } \ - /*else cout << "Warning: ******************************** cannot parse position index" << endl; \*/ - uscore=s.rfind("_"); \ - if (sscanf( s.substr(uscore+1,s.size()-uscore-1).c_str(),"s%lf",&f)) { \ - sv1=f; \ - s=fname.substr(0,uscore); \ - } \ - /*else cout << "Warning: ******************************** cannot parse scan varable 1" << endl; \*/ - uscore=s.rfind("_"); \ - if (sscanf( s.substr(uscore+1,s.size()-uscore-1).c_str(),"S%lf",&f)) { \ - sv0=f; \ - s=fname.substr(0,uscore); \ - } \ - /*else cout << "Warning: ******************************** cannot parse scan varable 0" << endl; \*/ - - return index; \ - }; - - - /** static function that verifies if the new file name containing new parameters matches all the given parameters - \param fname new complete file name prefix - \param index reference to index - \param f_index reference to frame index - \param p_index reference to position index - \param sv0 reference to scan variable 0 - \param sv1 reference to scan variable 1 - \param detindex reference to detector id - \returns file name - */ - static int verifySameFrame(std::string fname, int index, int f_index, int p_index, double sv0, double sv1, int detindex) { \ - int new_index=-1; - int new_f_index=-1; - int new_p_index=-1; - int new_det_index=-1; - double new_sv0=-1; - double new_sv1=-1; - getVariablesFromFileName(fname,new_index, new_f_index, new_p_index, new_sv0, new_sv1, new_det_index); - if(index!=new_index) return 0; - if(f_index!=new_f_index) return 0; - if(p_index!=new_p_index) return 0; - if(sv0!=new_sv0) return 0; - if(sv1!=new_sv1) return 0; - return 1; - } - - - /** static function that returns the name variable from the receiver complete file name prefix - \param fname complete file name prefix - \returns file name - */ - static std::string getNameFromReceiverFilePrefix(std::string fname) { \ - int i; \ - double f; \ - std::string s; \ - s=fname; \ - size_t uscore=s.rfind("_"); \ - if (sscanf( s.substr(uscore+1,s.size()-uscore-1).c_str(),"d%d",&i)) \ - s=fname.substr(0,uscore); \ - uscore=s.rfind("_"); \ - if (sscanf( s.substr(uscore+1,s.size()-uscore-1).c_str(),"p%d",&i)) \ - s=fname.substr(0,uscore); \ - uscore=s.rfind("_"); \ - if (sscanf( s.substr(uscore+1,s.size()-uscore-1).c_str(),"s%lf",&f)) \ - s=fname.substr(0,uscore); \ - uscore=s.rfind("_"); \ - if (sscanf( s.substr(uscore+1,s.size()-uscore-1).c_str(),"S%lf",&f)) \ - s=fname.substr(0,uscore); \ - - - return s; \ - }; - - - - - /** static function that returns the entire filename ithout file name prefix, detector index or extension - This will be concatenated with all the other detector file names for the gui - \param fname complete file name - \returns file name without file name prefix, detector index or extension - */ - static std::string getReceiverFileNameToConcatenate(std::string fname) { \ - int i;double f; \ - std::string s=fname; \ - if(fname.empty()) return fname; \ - size_t dot=s.find("."); - size_t uscore=s.rfind("_"); \ - - if (uscore==std::string::npos) return "??"; \ - if (sscanf(s.substr(uscore+1,s.size()-uscore-1).c_str(),"%d",&i)) \ - s=fname.substr(0,uscore); \ - uscore=s.rfind("_"); \ - if (sscanf( s.substr(uscore+1,s.size()-uscore-1).c_str(),"f%d",&i)) \ - s=fname.substr(0,uscore); \ - uscore=s.rfind("_"); \ - if (sscanf( s.substr(uscore+1,s.size()-uscore-1).c_str(),"d%d",&i)) \ - s=fname.substr(0,uscore); \ - uscore=s.rfind("_"); \ - if (sscanf( s.substr(uscore+1,s.size()-uscore-1).c_str(),"p%d",&i)) \ - s=fname.substr(0,uscore); \ - uscore=s.rfind("_"); \ - if (sscanf( s.substr(uscore+1,s.size()-uscore-1).c_str(),"s%lf",&f)) \ - s=fname.substr(0,uscore); \ - uscore=s.rfind("_"); \ - if (sscanf( s.substr(uscore+1,s.size()-uscore-1).c_str(),"S%lf",&f)) \ - s=fname.substr(0,uscore); \ - return(fname.substr(s.size(),dot-s.size()));\ - \ - }; - - - - - /** - - writes a data file - \param fname of the file to be written - \param nch number of channels to be written - \param data array of data values - \param err array of arrors on the data. If NULL no errors will be written - \param ang array of angular values. If NULL data will be in the form chan-val(-err) otherwise ang-val(-err) - \param dataformat format of the data: can be 'i' integer or 'f' double - \returns OK or FAIL if it could not write the file or data=NULL - - */ - - static int writeDataFile(std::string fname, int nch, double *data, double *err=NULL, double *ang=NULL, char dataformat='f'){ \ - std::ofstream outfile; \ - if (data==NULL) { \ - cout << "No data to write!" << endl; \ - return slsDetectorDefs::FAIL; \ - } \ - outfile.open (fname.c_str(),std::ios_base::out); \ - if (outfile.is_open()) { \ - writeDataFile(outfile, nch, data, err, ang, dataformat, 0); \ - outfile.close(); \ - return slsDetectorDefs::OK; \ - } else { \ - std::cout<< "Could not open file " << fname << "for writing"<< std::endl; \ - return slsDetectorDefs::FAIL; \ - } \ - }; - - - - - /** - writes a data file - \param outfile output file stream - \param nch number of channels to be written - \param data array of data values - \param err array of arrors on the data. If NULL no errors will be written - \param ang array of angular values. If NULL data will be in the form chan-val(-err) otherwise ang-val(-err) - \param dataformat format of the data: can be 'i' integer or 'f' double (default) - \param offset start channel number - \returns OK or FAIL if it could not write the file or data=NULL - */ - static int writeDataFile(std::ofstream &outfile, int nch, double *data, double *err=NULL, double *ang=NULL, char dataformat='f', int offset=0){ - int idata; \ - if (data==NULL || nch==0) { \ - cout << "No data to write!" << endl; \ - return slsDetectorDefs::FAIL; \ - } \ - for (int ichan=0; ichan> ichan >> fdata; \ - if (ssstr.fail() || ssstr.bad()) { \ - interrupt=1; \ - break; \ - } \ - ich=iline; \ - if (ichan> fang >> fdata; \ - ich=iline; \ - } \ - if (ssstr.fail() || ssstr.bad()) { \ - interrupt=1; \ - break; \ - } \ - if (err) \ - ssstr >> ferr; \ - if (ssstr.fail() || ssstr.bad()) { \ - interrupt=1; \ - break; \ - } \ - if (ich=nch) { \ - interrupt=1; \ - break; \ - } \ - } \ - return iline; \ - }; - - - /** - reads a raw data file - \param fname of the file to be read - \param data array of data values - \param nch number of channels - \returns OK or FAIL if it could not read the file or data=NULL - */ - static int readDataFile(std::string fname, int *data, int nch) { \ - std::ifstream infile; \ - int iline=0; \ - std::string str; \ - infile.open(fname.c_str(), std::ios_base::in); \ - if (infile.is_open()) { \ - iline=readDataFile(infile, data, nch, 0); \ - infile.close(); \ - } else { \ - std::cout<< "Could not read file " << fname << std::endl; \ - return -1; \ - } \ - return iline; \ - }; - - - /** - reads a raw data file - \param infile input file stream - \param data array of data values - \param nch number of channels - \param offset start channel value - \returns OK or FAIL if it could not read the file or data=NULL - */ - static int readDataFile(std::ifstream &infile, int *data, int nch, int offset) { \ - int ichan, idata, iline=0; \ - int interrupt=0; \ - std::string str; \ - while (infile.good() and interrupt==0) { \ - getline(infile,str); \ - std::istringstream ssstr(str); \ - ssstr >> ichan >> idata; \ - if (ssstr.fail() || ssstr.bad()) { \ - interrupt=1; \ - break; \ - } \ - if (iline=offset) { \ - data[iline]=idata; \ - iline++; \ - } \ - } else { \ - interrupt=1; \ - break; \ - } \ - } \ - return iline; \ - }; - - /** - reads a short int rawdata file - \param name of the file to be read - \param data array of data values - \param nch number of channels - \returns OK or FAIL if it could not read the file or data=NULL - */ - static int readDataFile(std::string fname, short int *data, int nch){ \ - std::ifstream infile; \ - int iline=0; \ - std::string str; \ - infile.open(fname.c_str(), std::ios_base::in); \ - if (infile.is_open()) { \ - iline=readDataFile(infile, data, nch, 0); \ - infile.close(); \ - } else { \ - std::cout<< "Could not read file " << fname << std::endl; \ - return -1; \ - } \ - return iline; \ - }; - - /** - reads a short int raw data file - \param infile input file stream - \param data array of data values - \param nch number of channels - \param offset start channel value - \returns OK or FAIL if it could not read the file or data=NULL - */ - static int readDataFile(std::ifstream &infile, short int *data, int nch, int offset) { \ - int ichan, iline=0; \ - short int idata; \ - int interrupt=0; \ - std::string str; \ - while (infile.good() and interrupt==0) { \ - getline(infile,str); \ - std::istringstream ssstr(str); \ - ssstr >> ichan >> idata; \ - if (ssstr.fail() || ssstr.bad()) { \ - interrupt=1; \ - break; \ - } \ - if (iline=offset) { \ - data[iline]=idata; \ - iline++; \ - } \ - } else { \ - interrupt=1; \ - break; \ - } \ - return iline; \ - }; \ - return iline; \ - }; -}; - -#endif diff --git a/slsDetectorSoftware/slsDetectorAnalysis/movingStat.h b/slsDetectorSoftware/slsDetectorAnalysis/movingStat.h deleted file mode 100644 index f81fab696..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/movingStat.h +++ /dev/null @@ -1,147 +0,0 @@ - /********************************************//** - * @file movingStat.h - * @short handles pedestal data and moves accordingly - ***********************************************/ -#ifndef MOVINGSTAT_H -#define MOVINGSTAT_H - -//#include "sls_detector_defs.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include - -; - - -typedef double double32_t; -typedef float float32_t; -typedef int int32_t; - - -/** - @short class handling pedestal data and moves according to data - */ - -class movingStat{ - -public: - /** - * Constructor - */ - movingStat() : n(0), m_n(0), m_oldM(0), m_newM(0), m_oldM2(0), m_newM2(0){} - - /** - * Clear number of data values - */ - inline void Clear(){ - m_n = 0; - } - - /** - * Set Pedestal - */ - inline void SetN(int i) {n=i;}; - - /** - * Get Pedestal - */ - inline int GetN() {return n;}; - - /** - * Calculate Pedestal - */ - inline void Calc(double x) { - if (m_n 0) ? m_newM/m_n : 0.0; - } - - /** - * Get mean 2 - */ - inline double M2() const{ - return ( (m_n > 1) ? m_newM2/m_n : 0.0 ); - } - - /** - * Get variance - */ - inline double Variance() const{ - return ( (m_n > 1) ? (M2()-Mean()*Mean()) : 0.0 ); - } - - /** - * Get standard deviation - */ - inline double StandardDeviation() const{ - return ( (Variance() > 0) ? sqrt( Variance() ) : -1 ); - } - -private: - /** pedestal */ - int n; - /** number of data values */ - int m_n; - - /** old and new mean */ - double m_oldM, m_newM, m_oldM2, m_newM2; -}; - - -#endif diff --git a/slsDetectorSoftware/slsDetectorAnalysis/postProcessing.cpp b/slsDetectorSoftware/slsDetectorAnalysis/postProcessing.cpp deleted file mode 100644 index 86f9faaf8..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/postProcessing.cpp +++ /dev/null @@ -1,901 +0,0 @@ -#include "postProcessing.h" -#include "postProcessingFuncs.h" -#include "angleConversionConstant.h" -#ifdef VERBOSE -#include "usersFunctions.h" -#elif EXTPP -#include "usersFunctions.h" -#endif -#include - -using namespace std; -//#define VERBOSE - -static void* startProcessData(void *n){ - postProcessing *myDet=(postProcessing*)n; - myDet->processData(1); - pthread_exit(NULL); - -}; - -static void* startProcessDataNoDelete(void *n){ - postProcessing *myDet=(postProcessing*)n; - myDet->processData(0); - pthread_exit(NULL); - -}; - - -int postProcessing::kbhit(){ - struct timeval tv; - fd_set fds; - tv.tv_sec = 0; - tv.tv_usec = 0; - FD_ZERO(&fds); - FD_SET(STDIN_FILENO, &fds); //STDIN_FILENO is 0 - select(STDIN_FILENO+1, &fds, NULL, NULL, &tv); - return FD_ISSET(STDIN_FILENO, &fds); -} - - -postProcessing::postProcessing(): expTime(NULL), badChannelMask(NULL), ang(NULL), val(NULL), err(NULL), numberOfChannels(0) { - pthread_mutex_t mp1 = PTHREAD_MUTEX_INITIALIZER; - mp=mp1; - pthread_mutex_init(&mp, NULL); - mg=mp1; - pthread_mutex_init(&mg, NULL); - ms=mp1; - pthread_mutex_init(&ms, NULL); - - //cout << "reg callback "<< endl; - dataReady = 0; - pCallbackArg = 0; - //cout << "done "<< endl; - rawDataReady = 0; - pRawDataArg = 0; - - - //#ifdef VERBOSE - // registerDataCallback(&defaultDataReadyFunc, NULL); - //#endif -#ifdef EXTPP - registerRawDataCallback(&defaultRawDataReadyFunc, NULL); -#endif - - ppFun=new postProcessingFuncs(); - -} - - - - - -postProcessing::~postProcessing(){ - delete ppFun; -}; - - - - - - - - -void postProcessing::processFrame(int *myData, int delflag, int jctb) { - - string fname; - int nn; - //double *fdata=NULL; - -#ifdef VERBOSE - cout << "start processing"<< endl; -#endif - - incrementProgress(); - -#ifdef VERBOSE - cout << "prog incremented"<< endl; -#endif - - /** decode data */ - - // cout << "decode 0"<< endl; - // if (getDetectorsType()==MYTHEN) { - - - // for (int ib=0; ib<1000; ib++) - // cout << ((*(((u_int64_t*)myData)+ib))>>17&1) ; - // cout << endl; - - - fdata=decodeData(myData,nn, fdata); - - //#ifdef VERBOSE - // cout << "decode 1"<< endl; - //#endif - // } else - // fdata=NULL; - if (rawDataReady) { -#ifdef VERBOSE - cout << "decoded data size is "<=0){ - if (getDetectorsType()==MYTHEN) - incrementFrameIndex(1); - else if((currentFrameIndex%getFramesPerFile())==0) - incrementFrameIndex(getFramesPerFile()); - } - - - - - if (fdata) - delete [] fdata; - fdata=NULL; - - - // if (jctb==0) { - delete [] myData; - myData=NULL; - -#ifdef VERBOSE - cout << "Pop data queue " << *fileIndex << endl; -#endif - - popDataQueue(); //remove the data from the queue - -#ifdef VERBOSE - cout << "Data queue popped" << endl; -#endif - - -#ifdef VERBOSE - cout << "process frame returning " << endl; -#endif - // } - -} - - - - -void postProcessing::doProcessing(double *lfdata, int delflag, string fname) { - - #ifdef VERBOSE - cout << "??????????????????????????????????????????? do processing - data size is " << arraySize << endl; - #endif - - - int np; - -#ifdef VERBOSE - cout << "arrays allocated " << endl; -#endif - int npos=getNumberOfPositions(); - - string ext=".dat"; - -#ifdef VERBOSE - cout << "npos is "<< npos << endl; -#endif - - double t=0; - - if (expTime) - t=(*expTime)*1E-9; - else - cout << "no pointer to exptime" << endl; -#ifdef VERBOSE - cout << "exptime is "<< t << endl; -#endif - - if (GetCurrentPositionIndex()<=1 || npos<2) { -#ifdef VERBOSE - cout << "init dataset" << endl; -#endif - - - if (*correctionMask&(1<< ANGULAR_CONVERSION)) - ang=new double[arraySize]; - else - ang=NULL; - - val=new double[arraySize]; - err=new double[arraySize]; - - initDataset(0); - } - -#ifdef VERBOSE - cout << "add frame" << endl; -#endif - - /**ot them -start processing -prog incremented -decode -fname is //run_f0_0 -??????????????????????????????????????????? do processing - data size is 30720 -arrays allocated -npos is 0 -exptime is 10.00 -init dataset -add frame -data queue size lock -data queue size unlock - **/ - - addFrame(lfdata,currentPosition, currentI0, t, fname, 0); - // cout << "++++++++++++++++++++" << GetCurrentPositionIndex() << " " << npos << " " << positionFinished() << " " << dataQueueSize() << endl; - if ((GetCurrentPositionIndex()>=npos && dataQueueSize()) || npos<2) { - //&& - - while(positionFinished()==0 && npos>1) { - ; - } -#ifdef VERBOSE - cout << "finalize dataset" << endl; -#endif - - finalizeDataset(ang, val, err, np); - //if (npos<2) { - IncrementPositionIndex(); - - pthread_mutex_lock(&mp); - fname=createFileName(); - pthread_mutex_unlock(&mp); - //} - - if((*correctionMask)&(1<0) { - - int *badChansList=new int[nbad]; - #ifdef VERBOSE - cout << "get badch array " << nbad << endl; - #endif - getBadChannelCorrection(badChansList); - #ifdef VERBOSE - cout << "done " << nbad << endl; - #endif - - if (badChannelMask) - delete [] badChannelMask; - - -#ifdef VERBOSE - cout << " nchans " << getTotalNumberOfChannels() << endl; -#endif - - badChannelMask=new int[getTotalNumberOfChannels()]; - -#ifdef VERBOSE - cout << " pointer to bad channel mask is " << badChannelMask << endl; -#endif - for (int ichan=0; ichan=0 ) { - if (badChannelMask[badChansList[ichan]]==0) { - badChannelMask[badChansList[ichan]]=1; - // cout << "bad: " << ichan << " " << badChansList[ichan] << endl; - } else - nbad--; - } - } - delete [] badChansList; - - } else { - if (badChannelMask) { -#ifdef VERBOSE - cout << "deleting bad channel mask beacuse number of bad channels is 0" << endl; -#endif - - delete [] badChannelMask; - badChannelMask=NULL; - } - } - - } else { -#ifdef VERBOSE - cout << "bad channel correction is disabled " << nbad << endl; -#endif - if (badChannelMask) { -#ifdef VERBOSE - cout << "deleting bad channel mask beacuse no bad channel correction is selected" << endl; -#endif - delete [] badChannelMask; - badChannelMask=NULL; - } - } - -#ifdef VERBOSE - cout << "number of bad channels is " << nbad << endl; -#endif - return nbad; - -} - - - - - - -void* postProcessing::processData(int delflag) { - if(setReceiverOnline()==OFFLINE_FLAG){ - -#ifdef VERBOSE - std::cout<< " ??????????????????????????????????????????? processing data - threaded mode " << *threadedProcessing << endl; -#endif - - - - - queuesize=dataQueueSize(); - - - int *myData; - int dum=1; -// int nf=1, ii, nch; -// int jctb=0; - - -// if (getDetectorsType()==JUNGFRAUCTB) { -// nch=getTotalNumberOfChannels(); -// nf= getDataBytes()/(nch*2); -// cout << "WILL PROCESS " << nf << "SAMPLES AND " << nch <<"CHANNELS PER FRAME!" << endl; -// jctb=1; -// }// else -// // cout << "NOOT A JCTB" << endl; - - fdata=NULL; - - while(dum | *threadedProcessing) { // ???????????????????????? - /* IF THERE ARE DATA PROCESS THEM*/ - // cout << "loop" << endl; - while((queuesize=dataQueueSize())>0) { - /** Pop data queue */ - #ifdef VERBOSE - cout << "data found"<< endl<r_conversion; - angOff[im]=p->offset; - angCenter[im]=p->center; - -#ifdef VERBOSE - cout << im << " " << angCenter[im] << " " << angRad[im] << " " << angOff[im] << endl; -#endif - - - } - sx=getAngularConversionParameter(SAMPLE_X); - sy=getAngularConversionParameter(SAMPLE_Y); - - } - - -#ifdef VERBOSE - cout << "init dataset" << endl; -#endif - // cout << "pp bad channel mask " << badChannelMask << endl; - fillBadChannelMask(); - // cout << "pp bad channel mask " << badChannelMask << endl; - - //cout << "EEEEEEEEEEEEEEEEEEEE init dataset " << endl; - ppFun->initDataset(&nmod,chPM,mM,badChannelMask, ffcoeff, fferr, &tdead, &angdir, angRad, angOff, angCenter, &to, &bs, &sx, &sy); - -#ifdef VERBOSE - cout << "done" << endl; -#endif - - delete [] chPM; - delete [] mM; - if (ffcoeff != NULL) delete [] ffcoeff; - if (fferr != NULL) delete [] fferr; - if (angRad != NULL) delete [] angRad; - if (angOff != NULL) delete [] angOff; - if (angCenter != NULL) delete [] angCenter; - - - if (*correctionMask&(1<< ANGULAR_CONVERSION)) { - arraySize=getNumberOfAngularBins(); - if (arraySize<=0) - arraySize=totch; - } else { - arraySize=totch; - } - - numberOfChannels=totch; - - queuesize=dataQueueSize(); - - // resetFinalDataQueue(); - resetDataQueue(); - - - } else { - - // cout << "EEEEEEEEEEEEEEEEEEEE init dataset XXXX " << endl; - - ppFun->initDataset(); - - - } - -} - - - - - - -void postProcessing::addFrame(double *data, double pos, double i0, double t, string fname, double var) { - // cout << "EEEEEEEEEEEEEEEEEEEE add frame " << pos << " " << i0 << endl; - - if (*correctionMask&(1<< I0_NORMALIZATION)) - ppFun->addFrame(data, &pos, &i0, &t, fname.c_str(), &var); - else - ppFun->addFrame(data, &pos,NULL, &t, fname.c_str(), &var); - - - -} - -void postProcessing::finalizeDataset(double *a, double *v, double *e, int &np) { - - // cout << "EEEEEEEEEEEEEEEEEEEE finalize dataset " << endl; - ppFun->finalizeDataset(a, v, e, &np); - -} - - - - - - - - - - - - - - - - - -void postProcessing::startThread(int delflag) { - - /////////////////////////////////// Initialize dataset - - //resetDataQueue(); - - setTotalProgress(); - - initDataset(1); - - /////////////////////////////////// Start thread //////////////////////////////////////////////////////// -#ifdef VERBOSE - cout << "start thread stuff" << endl; -#endif - - pthread_attr_t tattr; - int ret; - sched_param param, mparam; - int policy= SCHED_OTHER; - - // set the priority; others are unchanged - //newprio = 30; - mparam.sched_priority =1; - param.sched_priority =1; - - - /* Initialize and set thread detached attribute */ - pthread_attr_init(&tattr); - pthread_attr_setdetachstate(&tattr, PTHREAD_CREATE_JOINABLE); - - - - // param.sched_priority = 5; - // scheduling parameters of main thread - ret = pthread_setschedparam(pthread_self(), policy, &mparam); - - //#ifdef VERBOSE - // printf("current priority is %d\n",param.sched_priority); - //#endif - if (delflag) - ret = pthread_create(&dataProcessingThread, &tattr,startProcessData, (void*)this); - else - ret = pthread_create(&dataProcessingThread, &tattr,startProcessDataNoDelete, (void*)this); - - if (ret) - printf("ret %d\n", ret); - - pthread_attr_destroy(&tattr); - - // scheduling parameters of target thread - ret = pthread_setschedparam(dataProcessingThread, policy, ¶m); - -} - - - diff --git a/slsDetectorSoftware/slsDetectorAnalysis/postProcessing.h b/slsDetectorSoftware/slsDetectorAnalysis/postProcessing.h deleted file mode 100644 index 7903688dd..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/postProcessing.h +++ /dev/null @@ -1,385 +0,0 @@ -#ifndef POSTPROCESSING_H -#define POSTPROCESSING_H - - -#include "detectorData.h" -#include "slsDetectorBase.h" -#include "angularConversion.h" -#include "badChannelCorrections.h" -#include "fileIO.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -class postProcessingFuncs; - - -// - -#define MAX_BADCHANS 20000 - - -#define defaultTDead {170,90,750} /**< should be changed in order to have it separate for the different detector types */ - - -/** - @short methods for data postprocessing - - (including thread for writing data files and plotting in parallel with the acquisition) -*/ - -class postProcessing : public angularConversion, public fileIO, public badChannelCorrections { - -//public virtual angularConversion, public virtual fileIO { - - public: - postProcessing(); - virtual ~postProcessing(); - - - - - /** - get bad channels correction - \param bad pointer to array that if bad!=NULL will be filled with the bad channel list - \returns 0 if bad channel disabled or no bad channels, >0 otherwise - */ - virtual int getBadChannelCorrection(int *bad=NULL)=0; - - - /** - get flat field corrections - \param corr if !=NULL will be filled with the correction coefficients - \param ecorr if !=NULL will be filled with the correction coefficients errors - \returns 0 if ff correction disabled, >0 otherwise - */ - virtual int getFlatFieldCorrection(double *corr=NULL, double *ecorr=NULL)=0; - - /** - set flat field corrections - \param corr if !=NULL the flat field corrections will be filled with corr (NULL usets ff corrections) - \param ecorr if !=NULL the flat field correction errors will be filled with ecorr (1 otherwise) - \returns 0 if ff correction disabled, >0 otherwise - */ - virtual int setFlatFieldCorrection(double *corr, double *ecorr=NULL)=0; - - /** - set bad channels correction - \param fname file with bad channel list ("" disable) - \returns 0 if bad channel disabled, >0 otherwise - */ - virtual int setBadChannelCorrection(std::string fname="")=0; - - - /** - set bad channels correction - \param fname file with bad channel list ("" disable) - \param nbad reference to number of bad channels - \param badlist array of badchannels - \returns 0 if bad channel disabled, >0 otherwise - */ - virtual int setBadChannelCorrection(std::string fname, int &nbad, int *badlist, int off=0)=0; - using badChannelCorrections::setBadChannelCorrection; - - /** - set bad channels correction - \param nch number of bad channels - \param chs array of channels - \param ff 0 if normal bad channels, 1 if ff bad channels - \returns 0 if bad channel disabled, >0 otherwise - */ - virtual int setBadChannelCorrection(int nch, int *chs, int ff=0)=0; - - - - int enableWriteToFileMask(int i=-1) {if (i>0) ((*correctionMask)|=(1<>WRITE_FILE) ;}; - - int enableOverwriteMask(int i=-1) {if (i>0) ((*correctionMask)|=(1<>OVERWRITE_FILE) ;}; - - int setAngularCorrectionMask(int i=-1){if (i==0) (*correctionMask)&=~(1<< ANGULAR_CONVERSION); if (i>0) (*correctionMask)|=(1<< ANGULAR_CONVERSION); return (((*correctionMask)&(1<< ANGULAR_CONVERSION))>>ANGULAR_CONVERSION);}; - - - - int enableAngularConversion(int i=-1) {if (i>0) return setAngularConversionFile("default"); if (i==0) return setAngularConversionFile(""); return setAngularCorrectionMask();}; - - - int enableBadChannelCorrection(int i=-1) {if (i>0) return setBadChannelCorrection("default"); if (i==0) return setBadChannelCorrection(""); return (((*correctionMask)&(1<< DISCARD_BAD_CHANNELS))>>DISCARD_BAD_CHANNELS);}; - - - - - /** returns the bad channel list file */ - std::string getBadChannelCorrectionFile() {if ((*correctionMask)&(1<< DISCARD_BAD_CHANNELS)) return std::string(badChanFile); else return std::string("none");}; - - - /** - get flat field corrections file directory - \returns flat field correction file directory - */ - std::string getFlatFieldCorrectionDir(){return std::string(flatFieldDir);}; - /** - set flat field corrections file directory - \param flat field correction file directory - \returns flat field correction file directory - */ - std::string setFlatFieldCorrectionDir(std::string dir){strcpy(flatFieldDir,dir.c_str()); return std::string(flatFieldDir);}; - - /** - get flat field corrections file name - \returns flat field correction file name - */ - std::string getFlatFieldCorrectionFile(){ if ((*correctionMask)&(1<=0) *threadedProcessing=b; return *threadedProcessing;}; - - - - - /** processes the data - \param delflag 0 leaves the data in the final data queue - \returns nothing - - */ - void *processData(int delflag); - - /** processes the data - \param delflag 0 leaves the data in the final data queue - \returns nothing - - */ - void processFrame(int* myData, int delflag, int jctb=0); - - /** processes the data - \param delflag 0 leaves the data in the final data queue - \returns nothing - - */ - void doProcessing(double* myData, int delflag, std::string fname); - - - /** - pops the data from the data queue - \returns pointer to the popped data or NULL if the queue is empty. - \sa dataQueue - */ - int* popDataQueue(); - - int* dataQueueFront(); - - int dataQueueSize(); - -/* /\** */ -/* pops the data from thepostprocessed data queue */ -/* \returns pointer to the popped data or NULL if the queue is empty. */ -/* \sa finalDataQueue */ -/* *\/ */ -/* detectorData* popFinalDataQueue(); */ - - - int checkJoinThread(); - void setJoinThread(int v); - - - /** - resets the raw data queue - \sa dataQueue - */ - void resetDataQueue(); - -/* /\** */ -/* resets the postprocessed data queue */ -/* \sa finalDataQueue */ -/* *\/ */ -/* void resetFinalDataQueue(); */ - - - - - - int fillBadChannelMask(); - - - - - virtual int rateCorrect(double*, double*, double*, double*)=0; - virtual int flatFieldCorrect(double*, double*, double*, double*)=0; - - - virtual int fillModuleMask(int *mM)=0; - - virtual int getNMods()=0; - - - - int GetCurrentPositionIndex(){ pthread_mutex_lock(&mp); int retval=getCurrentPositionIndex(); pthread_mutex_unlock(&mp); return retval;}; - void IncrementPositionIndex(){ pthread_mutex_lock(&mp); incrementPositionIndex(); pthread_mutex_unlock(&mp);}; - - void IncrementFileIndex(){ pthread_mutex_lock(&mp); incrementFileIndex(); pthread_mutex_unlock(&mp); }; - int GetFileIndex(){ pthread_mutex_lock(&mp); int i=*fileIndex; pthread_mutex_unlock(&mp); return i;}; - - void ResetPositionIndex(){pthread_mutex_lock(&mp); resetPositionIndex(); pthread_mutex_unlock(&mp);}; - - - void registerDataCallback(int( *userCallback)(detectorData*, int, int, void*), void *pArg) { \ - dataReady = userCallback; \ - pCallbackArg = pArg; \ - if (setReceiverOnline() == slsDetectorDefs::ONLINE_FLAG) { \ - enableDataStreamingToClient(1); \ - enableDataStreamingFromReceiver(1);}}; \ - - - void registerRawDataCallback(int( *userCallback)(double*, int, void*), void *pArg) {rawDataReady = userCallback; pRawDataArg = pArg;}; - - virtual double getRateCorrectionTau()=0; - - - int positionFinished(int v=-1){pthread_mutex_lock(&mp); if (v>=0) posfinished=v; int retval=posfinished; pthread_mutex_unlock(&mp); return retval;}; - - double getCurrentPosition() {double p; pthread_mutex_lock(&mp); p=currentPosition; pthread_mutex_unlock(&mp); return p;}; - double setCurrentPosition(double v) { pthread_mutex_lock(&mp); currentPosition=v; pthread_mutex_unlock(&mp); return currentPosition;}; - - - - - void initDataset(int refresh); - void addFrame(double *data, double pos, double i0, double t, std::string fname, double var); - void finalizeDataset(double *a, double *v, double *e, int &np); - - virtual detectorType getDetectorsType(int pos=-1)=0; - - protected: - - int *threadedProcessing; - - int *correctionMask; - - char *flatFieldDir; - char *flatFieldFile; - - int64_t *expTime; - - /** mutex to synchronize main and data processing threads */ - pthread_mutex_t mp; - - - /** mutex to synchronizedata processing and plotting threads */ - pthread_mutex_t mg; - - /** mutex to synchronize slsdetector threads */ - pthread_mutex_t ms; - - /** sets when the acquisition is finished */ - int jointhread; - - /** sets when the position is finished */ - int posfinished; - - /** - data queue - */ - std::queue dataQueue; - /** - queue containing the postprocessed data - */ - std::queue finalDataQueue; - - /** data queue size */ - int queuesize; - - /** queue mutex */ - sem_t sem_queue; - /** set when detector finishes acquiring */ - int acquiringDone; - - - /** - start data processing thread - */ - void startThread(int delflag=1); // - /** the data processing thread */ - - pthread_t dataProcessingThread; - - - - /** pointer to bad channel mask 0 is channel is good 1 if it is bad \sa fillBadChannelMask() */ - int *badChannelMask; - - - - - /** - I0 measured - */ - double currentI0; - - - int arraySize; - - - - double *fdata; - int (*dataReady)(detectorData*,int, int, void*); - void *pCallbackArg; - detectorData *thisData; - - private: - int kbhit(void); - - // double *fdata; - // int (*dataReady)(detectorData*,int, int,void*); - // void *pCallbackArg; - - int (*rawDataReady)(double*,int,void*); - void *pRawDataArg; - - - postProcessingFuncs *ppFun; - //detectorData *thisData; - - - double *ang; - double *val; - double *err; - - int numberOfChannels; - - - -}; - - -/* static void* startProcessData(void *n){\ */ -/* postProcessing *myDet=(postProcessing*)n;\ */ -/* myDet->processData(1);\ */ -/* pthread_exit(NULL);\ */ - -/* }; */ - -/* static void* startProcessDataNoDelete(void *n){\ */ -/* postProcessing *myDet=(postProcessing*)n;\ */ -/* myDet->processData(0);\ */ -/* pthread_exit(NULL);\ */ - -/* }; */ - - - - -#endif diff --git a/slsDetectorSoftware/slsDetectorAnalysis/postProcessingFileIO_Standalone.cpp b/slsDetectorSoftware/slsDetectorAnalysis/postProcessingFileIO_Standalone.cpp deleted file mode 100644 index 275003a6c..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/postProcessingFileIO_Standalone.cpp +++ /dev/null @@ -1,602 +0,0 @@ -#include "postProcessingFileIO_Standalone.h" -#include "usersFunctions.h" -//#include "externPostProcessing.h" - -postProcessing::postProcessing(){ - - pthread_mutex_t mp1 = PTHREAD_MUTEX_INITIALIZER; - mp=mp1; - pthread_mutex_init(&mp, NULL); - mg=mp1; - pthread_mutex_init(&mg, NULL); - //cout << "reg callback "<< endl; - dataReady = 0; - pCallbackArg = 0; - registerDataCallback(&defaultDataReadyFunc, NULL); - //cout << "done "<< endl; - angConv=new angularConversion(numberOfPositions,detPositions,binSize, fineOffset, globalOffset); - IOfile= new fileIO(); - - //registerCallBackGetChansPerMod(&getChannelPerMod,this); - registerCallBackGetNumberofChannel(&defaultGetTotalNumberofChannels,this); - //registerAngularConversionCallback(&defaultAngularConversion,this); -} - - - - - - -int postProcessing::flatFieldCorrect(double datain, double errin, double &dataout, double &errout, double ffcoefficient, double fferr){ - double e; - - dataout=datain*ffcoefficient; - - if (errin==0 && datain>=0) - e=sqrt(datain); - else - e=errin; - - if (dataout>0) - errout=sqrt(e*ffcoefficient*e*ffcoefficient+datain*fferr*datain*fferr); - else - errout=1.0; - - return 0; -}; - - - int postProcessing::rateCorrect(double datain, double errin, double &dataout, double &errout, double tau, double t){ - - // double data; - double e; - - dataout=(datain*exp(tau*datain/t)); - - if (errin==0 && datain>=0) - e=sqrt(datain); - else - e=errin; - - if (dataout>0) - errout=e*dataout*sqrt((1/(datain*datain)+tau*tau/(t*t))); - else - errout=1.; - return 0; - -}; - - - - - -int postProcessing::setBadChannelCorrection(ifstream &infile, int &nbad, int *badlist, int moff){ - - int interrupt=0; - int ich; - int chmin,chmax; - string str; - - - - nbad=0; - while (infile.good() and interrupt==0) { - getline(infile,str); -#ifdef VERBOSE - std::cout << str << std::endl; -#endif - istringstream ssstr; - ssstr.str(str); - if (ssstr.bad() || ssstr.fail() || infile.eof()) { - interrupt=1; - break; - } - if (str.find('-')!=string::npos) { - ssstr >> chmin ; - ssstr.str(str.substr(str.find('-')+1,str.size())); - ssstr >> chmax; -#ifdef VERBOSE - std::cout << "channels between"<< chmin << " and " << chmax << std::endl; -#endif - for (ich=chmin; ich<=chmax; ich++) { - if (nbad> ich; -#ifdef VERBOSE - std::cout << "channel "<< ich << std::endl; -#endif - if (nbadcreateFileName(getActionMask(),getCurrentScanVariable(0),getScanPrecision(0),getCurrentScanVariable(1),getScanPrecision(1),getCurrentPositionIndex(),getNumberOfPositions()); - -//Checking for write flag - if(*correctionMask&(1<writeDataFile (fname+string(".raw"),fdata, NULL, NULL, 'i'); - - } - - doProcessing(fdata,delflag, fname); - - delete [] myData; - myData=NULL; - fdata=NULL; - -#ifdef VERBOSE - cout << "Pop data queue " << *fileIndex << endl; -#endif - - pthread_mutex_lock(&mp); - dataQueue.pop(); //remove the data from the queue - queuesize=dataQueue.size(); - pthread_mutex_unlock(&mp); - - -} - - - - -void postProcessing::doProcessing(double *lfdata, int delflag, string fname) { - - -// /** write raw data file */ -// if (*correctionMask==0 && delflag==1) { -// // delete [] fdata; -// ; -// } else { - - - - double *rcdata=NULL, *rcerr=NULL; - double *ffcdata=NULL, *ffcerr=NULL; - double *ang=NULL; - // int imod; - int np; - //string fname; - detectorData *thisData; - - - string ext=".dat"; - // fname=createFileName(); - - /** rate correction */ - if (*correctionMask&(1<writeDataFile (fname+ext, ffcdata, ffcerr,ang);} - } - - if (*correctionMask&(1<< ANGULAR_CONVERSION) && getNumberOfPositions()>0) { -#ifdef VERBOSE - cout << "**************Current position index is " << getCurrentPositionIndex() << endl; -#endif - // if (*numberOfPositions>0) {setTotalNumberOfChannels - if (getCurrentPositionIndex()<=1) { - -#ifdef VERBOSE - cout << "reset merging " << endl; -#endif - angConv->resetMerging(); - } - -#ifdef VERBOSE - cout << "add to merging "<< getCurrentPositionIndex() << endl; -#endif - - angConv->addToMerging(ang, ffcdata, ffcerr, badChannelMask ); - -#ifdef VERBOSE - cout << getCurrentPositionIndex() << " " << getNumberOfPositions() << endl; - -#endif - - - // cout << "lock 1" << endl; - pthread_mutex_lock(&mp); - if ((getCurrentPositionIndex()>=getNumberOfPositions() && posfinished==1 && queuesize==1)) { - -#ifdef VERBOSE - cout << "finalize merging " << getCurrentPositionIndex()<< endl; -#endif - np=angConv->finalizeMerging(); - /** file writing */ - angConv->incrementPositionIndex(); - // cout << "unlock 1" << endl; - pthread_mutex_unlock(&mp); - - - fname=IOfile->createFileName(getActionMask(),getCurrentScanVariable(0),getScanPrecision(0),getCurrentScanVariable(1),getScanPrecision(1),getCurrentPositionIndex(),getNumberOfPositions()); - -#ifdef VERBOSE - cout << "writing merged data file" << endl; -#endif - if(*correctionMask&(1<writeDataFile (fname+ext,np,angConv->getMergedCounts(), angConv->getMergedErrors(), angConv->getMergedPositions(),'f');} -#ifdef VERBOSE - cout << " done" << endl; -#endif - - - -// if (delflag) { -// deleteMerging(); -// } else { - thisData=new detectorData(angConv->getMergedCounts(),angConv->getMergedErrors(),angConv->getMergedPositions(),getCurrentProgress(),(fname+ext).c_str(),np); - - // // cout << "lock 2" << endl; -// pthread_mutex_lock(&mg); -// finalDataQueue.push(thisData); -// // cout << "unlock 2" << endl; - -// pthread_mutex_unlock(&mg); - - if (dataReady) { - - dataReady(thisData, pCallbackArg); - delete thisData; - } - -// } - // cout << "lock 3" << endl; - pthread_mutex_lock(&mp); - } - // cout << "unlock 3" << endl; - pthread_mutex_unlock(&mp); - - if (ffcdata) - delete [] ffcdata; - - ffcdata=NULL; - - if (ffcerr) - delete [] ffcerr; - ffcerr=NULL; - - if (ang) - delete [] ang; - ang=NULL; - - } else { -// if (delflag) { -// if (ffcdata) -// delete [] ffcdata; -// if (ffcerr) -// delete [] ffcerr; -// if ( ang) -// delete [] ang; -// } else { - thisData=new detectorData(ffcdata,ffcerr,NULL,getCurrentProgress(),(fname+ext).c_str(),getTotalNumberOfChannels()); - - - if (dataReady) { - dataReady(thisData, pCallbackArg); - delete thisData; - } -// pthread_mutex_lock(&mg); -// finalDataQueue.push(thisData); - - -// pthread_mutex_unlock(&mg); -// } - } - //} - - if(*correctionMask&(1<incrementFileIndex();} -#ifdef VERBOSE - cout << "fdata is " << fdata << endl; -#endif - -} - - - - - -int postProcessing::fillBadChannelMask() { - - int nbad=0; - - if (*correctionMask&(1<< DISCARD_BAD_CHANNELS)) { - nbad=getBadChannelCorrection(); -#ifdef VERBOSE - cout << "number of bad channels is " << nbad << endl; -#endif - if (nbad>0) { - - int *badChansList=new int[nbad]; - getBadChannelCorrection(badChansList); - - if (badChannelMask) - delete [] badChannelMask; - badChannelMask=new int[getTotalNumberOfChannels()]; - -#ifdef VERBOSE - cout << " pointer to bad channel mask is " << badChannelMask << endl; -#endif - for (int ichan=0; ichan=0 ) { - if (badChannelMask[badChansList[ichan]]==0) - nbad++; - badChannelMask[badChansList[ichan]]=1; - - } - } - delete [] badChansList; - - } else { - if (badChannelMask) { -#ifdef VERBOSE - cout << "deleting bad channel mask beacuse number of bad channels is 0" << endl; -#endif - - delete [] badChannelMask; - badChannelMask=NULL; - } - } - - } else { -#ifdef VERBOSE - cout << "bad channel correction is disabled " << nbad << endl; -#endif - if (badChannelMask) { -#ifdef VERBOSE - cout << "deleting bad channel mask beacuse no bad channel correction is selected" << endl; -#endif - delete [] badChannelMask; - badChannelMask=NULL; - } - } - -#ifdef VERBOSE - cout << "number of bad channels is " << nbad << endl; -#endif - return nbad; - -} - - - - - - -void* postProcessing::processData(int delflag) { - - -#ifdef VERBOSE - std::cout<< " processing data - threaded mode " << *threadedProcessing << endl; -#endif - - - angConv->setTotalNumberOfChannels(getTotalNumberOfChannels()); - IOfile->setTotalNumberofChannels(getTotalNumberOfChannels()); - setTotalProgress(); - pthread_mutex_lock(&mp); - queuesize=dataQueue.size(); - pthread_mutex_unlock(&mp); - - int *myData; - int dum=1; - - fdata=NULL; - - - while(dum | *threadedProcessing) { // ???????????????????????? - - - /* IF THERE ARE DATA PROCESS THEM*/ - pthread_mutex_lock(&mp); - while((queuesize=dataQueue.size())>0) { - /** Pop data queue */ - myData=dataQueue.front(); // get the data from the queue - pthread_mutex_unlock(&mp); - - if (myData) { - processFrame(myData,delflag); - //usleep(1000); - } - pthread_mutex_lock(&mp); - - } - pthread_mutex_unlock(&mp); - - /* IF THERE ARE NO DATA look if acquisition is finished */ - pthread_mutex_lock(&mp); - if (jointhread) { - if (dataQueue.size()==0) { - pthread_mutex_unlock(&mp); - break; - } - pthread_mutex_unlock(&mp); - } else { - pthread_mutex_unlock(&mp); - } - dum=0; - } - - if (fdata) { -#ifdef VERBOSE - cout << "delete fdata" << endl; -#endif - delete [] fdata; -#ifdef VERBOSE - cout << "done " << endl; -#endif - } - return 0; -} - - -int* postProcessing::popDataQueue() { - int *retval=NULL; - if( !dataQueue.empty() ) { - retval=dataQueue.front(); - dataQueue.pop(); - } - return retval; -} - -detectorData* postProcessing::popFinalDataQueue() { - detectorData *retval=NULL; - pthread_mutex_unlock(&mg); - if( !finalDataQueue.empty() ) { - retval=finalDataQueue.front(); - finalDataQueue.pop(); - } - pthread_mutex_unlock(&mg); - return retval; -} - -void postProcessing::resetDataQueue() { - int *retval=NULL; - while( !dataQueue.empty() ) { - retval=dataQueue.front(); - dataQueue.pop(); - delete [] retval; - } - -} - -void postProcessing::resetFinalDataQueue() { - detectorData *retval=NULL; - pthread_mutex_lock(&mg); - while( !finalDataQueue.empty() ) { - retval=finalDataQueue.front(); - finalDataQueue.pop(); - delete retval; - } - pthread_mutex_unlock(&mg); -} - - -void postProcessing::startThread(int delflag) { - pthread_attr_t tattr; - int ret; - sched_param param, mparam; - int policy= SCHED_OTHER; - - - // set the priority; others are unchanged - //newprio = 30; - mparam.sched_priority =1; - param.sched_priority =1; - - - /* Initialize and set thread detached attribute */ - pthread_attr_init(&tattr); - pthread_attr_setdetachstate(&tattr, PTHREAD_CREATE_JOINABLE); - - - - // param.sched_priority = 5; - // scheduling parameters of main thread - ret = pthread_setschedparam(pthread_self(), policy, &mparam); - //#ifdef VERBOSE - // printf("current priority is %d\n",param.sched_priority); - //#endif - if (delflag) - ret = pthread_create(&dataProcessingThread, &tattr,startProcessData, (void*)this); - else - ret = pthread_create(&dataProcessingThread, &tattr,startProcessDataNoDelete, (void*)this); - - pthread_attr_destroy(&tattr); - // scheduling parameters of target thread - ret = pthread_setschedparam(dataProcessingThread, policy, ¶m); - -} - - - diff --git a/slsDetectorSoftware/slsDetectorAnalysis/postProcessingFileIO_Standalone.h b/slsDetectorSoftware/slsDetectorAnalysis/postProcessingFileIO_Standalone.h deleted file mode 100644 index 7edfddc0b..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/postProcessingFileIO_Standalone.h +++ /dev/null @@ -1,391 +0,0 @@ -#ifndef POSTPROCESSING_H -#define POSTPROCESSING_H - - -#include "detectorData.h" -#include "sls_detector_defs.h" -#include "slsDetectorBase_Standalone.h" -#include "slsDetectorUsers.h" -#include "FileIO_Standalone.h" -#include "AngularConversion_Standalone.h" -//#include "externPostProcessing.h" - -#include - -#include -#include -#include -#include -#include -#include -#include -#include - - -class angularConversion; -class fileIO; - -; - -#define MAX_BADCHANS 2000 - - -#define defaultTDead {170,90,750} /**< should be changed in order to have it separate for the different detector types */ - - -/** - @short methods for data postprocessing - - (including thread for writing data files and plotting in parallel with the acquisition) -*/ - -class postProcessing : public virtual slsDetectorBase1 { - - -//: public angularConversion, public fileIO - - public: - postProcessing(); - virtual ~postProcessing(){}; - - - - /** - get bad channels correction - \param bad pointer to array that if bad!=NULL will be filled with the bad channel list - \returns 0 if bad channel disabled or no bad channels, >0 otherwise - */ - virtual int getBadChannelCorrection(int *bad=NULL)=0; - - - /** - get flat field corrections - \param corr if !=NULL will be filled with the correction coefficients - \param ecorr if !=NULL will be filled with the correction coefficients errors - \returns 0 if ff correction disabled, >0 otherwise - */ - virtual int getFlatFieldCorrection(double *corr=NULL, double *ecorr=NULL)=0; - - /** - set flat field corrections - \param corr if !=NULL the flat field corrections will be filled with corr (NULL usets ff corrections) - \param ecorr if !=NULL the flat field correction errors will be filled with ecorr (1 otherwise) - \returns 0 if ff correction disabled, >0 otherwise - */ - virtual int setFlatFieldCorrection(double *corr, double *ecorr=NULL)=0; - - /** - set bad channels correction - \param fname file with bad channel list ("" disable) - \returns 0 if bad channel disabled, >0 otherwise - */ - virtual int setBadChannelCorrection(string fname="")=0; - - static int setBadChannelCorrection(ifstream &infile, int &nbad, int *badlist, int moff=0); - /** - set bad channels correction - \param fname file with bad channel list ("" disable) - \param nbad reference to number of bad channels - \param badlist array of badchannels - \returns 0 if bad channel disabled, >0 otherwise - */ - virtual int setBadChannelCorrection(string fname, int &nbad, int *badlist, int off=0)=0; - - - /** - set bad channels correction - \param nch number of bad channels - \param chs array of channels - \param ff 0 if normal bad channels, 1 if ff bad channels - \returns 0 if bad channel disabled, >0 otherwise - */ - virtual int setBadChannelCorrection(int nch, int *chs, int ff=0)=0; - - /** - flat field correct data - \param datain data - \param errin error on data (if<=0 will default to sqrt(datain) - \param dataout corrected data - \param errout error on corrected data - \param ffcoefficient flat field correction coefficient - \param fferr erro on ffcoefficient - \returns 0 - */ - static int flatFieldCorrect(double datain, double errin, double &dataout, double &errout, double ffcoefficient, double fferr); - - /** - rate correct data - \param datain data - \param errin error on data (if<=0 will default to sqrt(datain) - \param dataout corrected data - \param errout error on corrected data - \param tau dead time 9in ns) - \param t acquisition time (in ns) - \returns 0 - */ - static int rateCorrect(double datain, double errin, double &dataout, double &errout, double tau, double t); - - - int enableWriteToFile(int i=-1) {if (i>0) ((*correctionMask)|=(1<0) (*correctionMask)|=(1<< ANGULAR_CONVERSION); return ((*correctionMask)&(1<< ANGULAR_CONVERSION));}; - - - - int enableAngularConversion(int i=-1) {if (i>0) return setAngularConversionFile("default"); if (i==0) return setAngularConversionFile(""); return setAngularCorrectionMask();}; - - - int enableBadChannelCorrection(int i=-1) {if (i>0) return setBadChannelCorrection("default"); if (i==0) return setBadChannelCorrection(""); return ((*correctionMask)&(1<< DISCARD_BAD_CHANNELS));}; - - - - - /** returns the bad channel list file */ - string getBadChannelCorrectionFile() {if ((*correctionMask)&(1<< DISCARD_BAD_CHANNELS)) return string(badChanFile); else return string("none");}; - - - /** - get flat field corrections file directory - \returns flat field correction file directory - */ - string getFlatFieldCorrectionDir(){return string(flatFieldDir);}; - /** - set flat field corrections file directory - \param flat field correction file directory - \returns flat field correction file directory - */ - string setFlatFieldCorrectionDir(string dir){strcpy(flatFieldDir,dir.c_str()); return string(flatFieldDir);}; - - /** - get flat field corrections file name - \returns flat field correction file name - */ - string getFlatFieldCorrectionFile(){ if ((*correctionMask)&(1<=0) *threadedProcessing=b; return *threadedProcessing;}; - - - - - /** processes the data - \param delflag 0 leaves the data in the final data queue - \returns nothing - - */ - void *processData(int delflag); - - /** processes the data - \param delflag 0 leaves the data in the final data queue - \returns nothing - - */ - void processFrame(int* myData, int delflag); - - /** processes the data - \param delflag 0 leaves the data in the final data queue - \returns nothing - - */ - void doProcessing(double* myData, int delflag, string fname); - - - /** - pops the data from the data queue - \returns pointer to the popped data or NULL if the queue is empty. - \sa dataQueue - */ - int* popDataQueue(); - - /** - pops the data from thepostprocessed data queue - \returns pointer to the popped data or NULL if the queue is empty. - \sa finalDataQueue - */ - detectorData* popFinalDataQueue(); - - - /** - resets the raw data queue - \sa dataQueue - */ - void resetDataQueue(); - - /** - resets the postprocessed data queue - \sa finalDataQueue - */ - void resetFinalDataQueue(); - - - - - - int fillBadChannelMask(); - - - - - virtual int rateCorrect(double*, double*, double*, double*)=0; - virtual int flatFieldCorrect(double*, double*, double*, double*)=0; - - - - - - //void registerAngularConversionCallback(int (*sAngularConversion)(int & ,angleConversionConstant* ,void *), void *arg){seAngularConversion=sAngularConversion; pAngular= arg; }; - - void registerDataCallback(int( *userCallback)(detectorData*, void*), void *pArg) {dataReady = userCallback; pCallbackArg = pArg;}; - - void registerCallBackGetNumberofChannel(int (*func)(int, void *),void *arg){ getNoChannel=func;pNumberofChannel=arg;}; - - - - /** - sets the angular conversion file - \param fname file to read - \returns angular conversion flag - */ - - int setAngularConversionFile(string fname); - - //static int defaultAngularConversion(int &direc, angleConversionConstant *angoff,void *p=NULL){ return ((postProcessing *)p)->getAngularConversion( direc,angleConversionConstant *angoff=NULL);}; - /** - returns the angular conversion file - */ - string getAngularConversionFile(){if (setAngularCorrectionMask()) return string(angConvFile); else return string("none");}; - - //static int setAngularConversion(); - - static int defaultGetTotalNumberofChannels (int nChannel, void *p=NULL){ if(nChannel>=0){ return ((postProcessing*)p)->getTotalNumberOfChannels();} else return -1;}; - - protected: - - int *threadedProcessing; - - int *correctionMask; - - char *flatFieldDir; - char *flatFieldFile; - - char *badChanFile; - int *nBadChans; - int *badChansList; - int *nBadFF; - int *badFFList; - int *direction; - - /** pointer to angular conversion file name*/ - char *angConvFile; - - - /** mutex to synchronize main and data processing threads */ - pthread_mutex_t mp; - - - /** mutex to synchronizedata processing and plotting threads */ - pthread_mutex_t mg; - - /** sets when the acquisition is finished */ - int jointhread; - - /** sets when the position is finished */ - int posfinished; - - /** - data queue - */ - queue dataQueue; - /** - queue containing the postprocessed data - */ - queue finalDataQueue; - - - /** data queue size */ - int queuesize; - - - - - /** - start data processing thread - */ - void startThread(int delflag=1); // - /** the data processing thread */ - - pthread_t dataProcessingThread; - - - - /** pointer to bad channel mask 0 is channel is good 1 if it is bad \sa fillBadChannelMask() */ - int *badChannelMask; - - - - - /** - I0 measured - */ - double currentI0; - - double *fdata; - - int (*seAngularConversion)(int & ,angleConversionConstant* ,void*); - int (*getNoChannel)(int ,void*); - int (*dataReady)(detectorData*,void*); - void *pCallbackArg, *pChpermod,*pNumberofChannel,*pAngular; - - - - private: - - angularConversion *angConv; - fileIO *IOfile; - - /** pointer to beamlien fine offset*/ - double *fineOffset; - /** pointer to beamlien global offset*/ - double *globalOffset; - /** pointer to number of positions for the acquisition*/ - int *numberOfPositions; - - /** pointer to the detector positions for the acquisition*/ - double *detPositions; - - angleConversionConstant angcc[MAXMODS*MAXDET]; - - - /** pointer to angular bin size*/ - double *binSize; - - -}; - - -static void* startProcessData(void *n){\ - postProcessing *myDet=(postProcessing*)n;\ - myDet->processData(1);\ - pthread_exit(NULL);\ - -}; - -static void* startProcessDataNoDelete(void *n){\ - postProcessing *myDet=(postProcessing*)n;\ - myDet->processData(0);\ - pthread_exit(NULL);\ - -}; - - - -#endif diff --git a/slsDetectorSoftware/slsDetectorAnalysis/postProcessingFuncs.cpp b/slsDetectorSoftware/slsDetectorAnalysis/postProcessingFuncs.cpp deleted file mode 100644 index a6845c8d6..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/postProcessingFuncs.cpp +++ /dev/null @@ -1,566 +0,0 @@ -#include "postProcessingFuncs.h" -#include "angleConversionConstant.h" -using namespace std; -//#define VERBOSE - -postProcessingFuncs::postProcessingFuncs(int *nModules,int *chPerMod,int modMask[],int badCh[], double ffcoeff[], double fferr[], double* t, int *dir, double angRadius[], double angOffset[], double angCentre[], double* to, double* bs, double *sX, double *sY): - nMods(0), chansPerMod(NULL), moduleMask(NULL), badChannelMask(NULL), ffCoeff(NULL), ffErr(NULL), tDead(0), angDir(1), angConv(NULL), totalOffset(0), binSize(0), sampleX(0), sampleY(0), totalChans(0), nBins(0), mp(NULL), mv(NULL), me(NULL), mm(NULL) -{ - initDataset(nModules, chPerMod,modMask,badCh, ffcoeff, fferr, t, dir, angRadius, angOffset, angCentre, to, bs, sX, sY); - -} - -int postProcessingFuncs::initDataset() { - - // cout << "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA init dataset " << endl; - - if (nBins) { - mp=new double[nBins]; - mv=new double[nBins]; - me=new double[nBins]; - mm=new int[nBins]; - resetMerging(mp,mv,me,mm, nBins); - // cout << "nbins " << nBins << endl; - } else { - mv=new double[totalChans]; - me=new double[totalChans]; - // cout << "nchans " << totalChans << endl; - } - totalI0=0; - - return 0; - -} - -int postProcessingFuncs::finalizeDataset(double *ang, double *val, double *err, int *np) { - - // cout << "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA finalize dataset " << endl; - - if (nBins) - *np=finalizeMerging(mp,mv,me,mm,nBins); - else - *np=totalChans; - - - - if (totalI0<=0) - totalI0=1.; - - - for (int ip=0; ip<(*np); ip++) { - - if (ang) - if (mp) - ang[ip]=mp[ip]; - - if (mv) - val[ip]=mv[ip]*totalI0; - - if (me) - err[ip]=me[ip]*totalI0; - - } - - - // cout << "delete mp " <chlast) { - // cout << *pos << " " << moduleMask[imod] << endl; - imod++; - ch0=chlast+1; - nchmod=chansPerMod[imod]; - chlast=ch0+nchmod-1; - } - - vin=data[ich]; - ein=0; - vout=data[ich]; - if (vout>=0) - eout=sqrt(vout); - else - eout=0; - - - if (tDead) { - //#ifdef VERBOSE - // cout << "ppFuncs ratecorrect" << endl; - //#endif - rateCorrect(vin, ein, vout, eout, tDead, *expTime); - vin=vout; - ein=eout; - } - //ffcorrect - - if (ffCoeff) { - //#ifdef VERBOSE - // cout << "ppFuncs ffcorrect" << endl; - //#endif - if (ffErr) - e=ffErr[ich]; - else - e=0; - flatFieldCorrect(vin, ein, vout, eout, ffCoeff[ich], e); - } - - - //i0correct - if (i0>0) { - //#ifdef VERBOSE - // cout << "ppFuncs i0 norm" << endl; - //#endif - vout/=i0; - eout/=i0; - } - - if (badChannelMask) { - //#ifdef VERBOSE - // cout << "ppFuncs badchans" << endl; - //#endif - if (badChannelMask[ich]) { - // cout << "------------------ Discarding channel " << ich << endl; - continue; - } - } - if (nBins) { - //angconv - -// #ifdef VERBOSE -// cout << "ppFuncs angconv" << endl; -// #endif -// //check module mask?!?!?!? - - - p1=convertAngle(*pos,ich-ch0,angConv[imod],moduleMask[imod],totalOffset,0,angDir); - -// #ifdef VERBOSE -// cout << "************************** ppFuncs merge" << endl; -// #endif - addPointToMerging(p1,vout,eout,mp,mv,me,mm, binSize, nBins); - - - } else { -#ifdef VERBOSE - cout << "ppFuncs merge" << endl; -#endif - //mp[ich]=ich; - mv[ich]+=vout; - me[ich]+=eout*eout; - } - } - return 0; -} - - - - - -int postProcessingFuncs::initDataset(int *nModules,int *chPerMod,int modMask[],int badCh[], double ffcoeff[], double fferr[], double* t, int *dir, double angRadius[], double angOffset[], double angCenter[], double* to, double* bs, double *sX, double *sY) { - - // cout << "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA init dataset XXXXXX " << endl; - //#ifdef VERBOSE - // cout << "delete pointers " << endl; - //#endif - - deletePointers(); - - - //#ifdef VERBOSE - // cout << "nmod " << endl; - //#endif - - if (nModules) - nMods=*nModules; - else - nMods=0; - - - //#ifdef VERBOSE - //cout << nMods << endl; - //#endif -#ifdef VERBOSE - cout << "tdead " << endl; -#endif - - if (t) - tDead=*t; - else - tDead=0; - -#ifdef VERBOSE - cout << tDead << endl; -#endif -#ifdef VERBOSE - cout << "toffset " << endl; -#endif - - if (to) - totalOffset=*to; - else - totalOffset=0; -#ifdef VERBOSE - cout << totalOffset << endl; -#endif - - - //#ifdef VERBOSE - // cout << "binsize " << endl; - //#endif - if (bs) - binSize=*bs; - else - binSize=0; - - - //#ifdef VERBOSE - // cout << binSize << endl; - //#endif -#ifdef VERBOSE - cout << "samplex " << endl; -#endif - if (sX) - sampleX=*sX; - else - sampleX=0; - -#ifdef VERBOSE - cout << sampleX << endl; -#endif -#ifdef VERBOSE - cout << "sampley " << endl; -#endif - if (sY) - sampleY=*sY; - else - sampleY=0; - -#ifdef VERBOSE - cout << sampleY << endl; -#endif - //#ifdef VERBOSE - // cout << "angdir " << endl; - //#endif - if (dir) - angDir=*dir; - else - angDir=1; - - //#ifdef VERBOSE - // cout << angDir << endl; - //#endif - totalChans=0; - - - if (nMods) - chansPerMod=new int [nMods]; - - if (nMods) - moduleMask=new int [nMods]; - - nBins=0; - if (angRadius && angOffset && angCenter && (binSize>0)) { - // cout << "??????? creating angConv"<< endl; - if (nMods) - angConv=new angleConversionConstant*[nMods]; - nBins=(int)(360./binSize)+1; - } - //#ifdef VERBOSE - //cout << "nBins " << nBins << endl; - //#endif - for (int im=0; im=0) - e=sqrt(datain); - else - e=errin; - - if (dataout>0) - errout=sqrt(e*ffcoefficient*e*ffcoefficient+datain*fferr*datain*fferr); - else - errout=1.0; - - return 0; -}; - - - int postProcessingFuncs::rateCorrect(double datain, double errin, double &dataout, double &errout, double tau, double t){ - - // double data; - double e; - - dataout=(datain*exp(tau*datain/t)); - - if (errin==0 && datain>=0) - e=sqrt(datain); - else - e=errin; - - if (dataout>0) - errout=e*dataout*sqrt((1/(datain*datain)+tau*tau/(t*t))); - else - errout=1.; - return 0; - -}; - - -int postProcessingFuncs::calculateFlatField(int* nModules, int *chPerMod, int *moduleMask, int *badChannelMask, double *ffData, double *ffCoeff, double *ffErr) { - int nmed=0, im=0; - double *xmed; - - // cout << "Claculate flat field " << endl; - - if (chPerMod==NULL) - return -1; - // if (moduleMask==NULL) - // return -1; - if (ffData==NULL) - return -1; - - if (ffErr==NULL) - return -1; - - - // cout << *nModules << " pp chpm0 " << chPerMod[0] << endl; - int totch=0; - int nm= *nModules; - for (int im=0; im0) { - im=0; - while ((imim; i--) - xmed[i]=xmed[i-1]; - - xmed[im]=ffData[ich]; - nmed++; - - } - - - - } - - - if (nmed>1 && xmed[nmed/2]>0) { - //#ifdef VERBOSE - // std::cout<< "Flat field median is " << xmed[nmed/2] << " calculated using "<< nmed << " points" << std::endl; - //#endif - - - // cout << "checking bad channel mask " << endl; - for (int ich=0; ich0) { - ffCoeff[ich]=xmed[nmed/2]/ffData[ich]; - ffErr[ich]=ffCoeff[ich]*sqrt(ffData[ich])/ffData[ich]; - } else { - ffCoeff[ich]=0.; - ffErr[ich]=1.; - } - cout << ich << " " << ffData[ich] << " " << ffCoeff[ich] << endl; - } - - } - cout << "done " << endl; - - delete [] xmed; - xmed=NULL; - - return 0; - -} - - - - - - diff --git a/slsDetectorSoftware/slsDetectorAnalysis/postProcessingFuncs.h b/slsDetectorSoftware/slsDetectorAnalysis/postProcessingFuncs.h deleted file mode 100644 index 5851c001f..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/postProcessingFuncs.h +++ /dev/null @@ -1,80 +0,0 @@ -#ifndef POSTPROCESSINGFUNCS_H -#define POSTPROCESSINGFUNCS_H - - - -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "angularConversionStatic.h" -class angleConversionConstant; - - - - -class postProcessingFuncs : public virtual angularConversionStatic - -{ - - public: - postProcessingFuncs(int *nModules=NULL,int *chPerMod=NULL,int *modMask=NULL,int *badChMask=NULL, double *ffcoeff=NULL, double *fferr=NULL, double* t=NULL, int *dir=NULL, double *angRadius=NULL, double *angOffset=NULL, double *angCentre=NULL, double* to=NULL, double* bs=NULL, double *sX=NULL, double *sY=NULL); - - - ~postProcessingFuncs(); - - - int initDataset(int *nModules,int *chPerMod,int modMask[],int badCh[], double ffcoeff[], double fferr[], double* tDead, int *dir, double angRadius[], double angOffset[], double angCentre[], double* to, double* bs, double *sX, double *sY); - - int initDataset(); - - - int finalizeDataset(double ang[], double val[], double err[], int *np); - - int addFrame(double data[], double *pos, double *IO, double *expTime, const char *filename, double *var=0); - - static int calculateFlatField(int* nModules, int *chPerMod, int moduleMask[], int badChannelMask[], double ffData[], double ffCoeff[], double ffErr[]); - - static int flatFieldCorrect(double datain, double errin, double &dataout, double &errout, double ffcoefficient, double fferr); - - - static int rateCorrect(double datain, double errin, double &dataout, double &errout, double tau, double t); - - private: - void deletePointers(); - - - int nMods; - int *chansPerMod; - int *moduleMask; - int *badChannelMask; - double *ffCoeff; - double *ffErr; - double tDead; - int angDir; - angleConversionConstant **angConv; - double totalOffset; - double binSize; - double sampleX; - double sampleY; - int totalChans; - - int nBins; - - double totalI0; - - - double *mp, *mv,*me; - int *mm; - -}; - - -#endif //POSTPROCESSINGFUNCS_H diff --git a/slsDetectorSoftware/slsDetectorAnalysis/postProcessing_Standalone.cpp b/slsDetectorSoftware/slsDetectorAnalysis/postProcessing_Standalone.cpp deleted file mode 100644 index 185d811ad..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/postProcessing_Standalone.cpp +++ /dev/null @@ -1,593 +0,0 @@ -#include "postProcessing.h" -#include "usersFunctions.h" -//#include "angularConversion.h" - -//#include "AngularConversion_Standalone.h" - -postProcessing::postProcessing(){ - pthread_mutex_t mp1 = PTHREAD_MUTEX_INITIALIZER; - mp=mp1; - pthread_mutex_init(&mp, NULL); - mg=mp1; - pthread_mutex_init(&mg, NULL); - //cout << "reg callback "<< endl; - dataReady = 0; - pCallbackArg = 0; - registerDataCallback(&defaultDataReadyFunc, NULL); - //tregisterCallBackGetChansPerMod(&defaultGetChansPerMod,NULL); - //cout << "done "<< endl; - angConv=new angularConversion(numberOfPositions,detPositions,binSize, fineOffset, globalOffset); -} - - - - - - -int postProcessing::flatFieldCorrect(double datain, double errin, double &dataout, double &errout, double ffcoefficient, double fferr){ - double e; - - dataout=datain*ffcoefficient; - - if (errin==0 && datain>=0) - e=sqrt(datain); - else - e=errin; - - if (dataout>0) - errout=sqrt(e*ffcoefficient*e*ffcoefficient+datain*fferr*datain*fferr); - else - errout=1.0; - - return 0; -}; - - - int postProcessing::rateCorrect(double datain, double errin, double &dataout, double &errout, double tau, double t){ - - // double data; - double e; - - dataout=(datain*exp(tau*datain/t)); - - if (errin==0 && datain>=0) - e=sqrt(datain); - else - e=errin; - - if (dataout>0) - errout=e*dataout*sqrt((1/(datain*datain)+tau*tau/(t*t))); - else - errout=1.; - return 0; - -}; - - - - - -int postProcessing::setBadChannelCorrection(ifstream &infile, int &nbad, int *badlist, int moff){ - - int interrupt=0; - int ich; - int chmin,chmax; - string str; - - - - nbad=0; - while (infile.good() and interrupt==0) { - getline(infile,str); -#ifdef VERBOSE - std::cout << str << std::endl; -#endif - istringstream ssstr; - ssstr.str(str); - if (ssstr.bad() || ssstr.fail() || infile.eof()) { - interrupt=1; - break; - } - if (str.find('-')!=string::npos) { - ssstr >> chmin ; - ssstr.str(str.substr(str.find('-')+1,str.size())); - ssstr >> chmax; -#ifdef VERBOSE - std::cout << "channels between"<< chmin << " and " << chmax << std::endl; -#endif - for (ich=chmin; ich<=chmax; ich++) { - if (nbad> ich; -#ifdef VERBOSE - std::cout << "channel "<< ich << std::endl; -#endif - if (nbad0) { -#ifdef VERBOSE - cout << "**************Current position index is " << getCurrentPositionIndex() << endl; -#endif - // if (*numberOfPositions>0) { - if (getCurrentPositionIndex()<=1) { - -#ifdef VERBOSE - cout << "reset merging " << endl; -#endif - angConv->resetMerging(); - } - -#ifdef VERBOSE - cout << "add to merging "<< getCurrentPositionIndex() << endl; -#endif - - angConv->addToMerging(ang, ffcdata, ffcerr, badChannelMask ); - -#ifdef VERBOSE - cout << getCurrentPositionIndex() << " " << getNumberOfPositions() << endl; - -#endif - - - // cout << "lock 1" << endl; - pthread_mutex_lock(&mp); - if ((getCurrentPositionIndex()>=getNumberOfPositions() && posfinished==1 && queuesize==1)) { - -#ifdef VERBOSE - cout << "finalize merging " << getCurrentPositionIndex()<< endl; -#endif - np=angConv->finalizeMerging(); - /** file writing */ - angConv->incrementPositionIndex(); - // cout << "unlock 1" << endl; - pthread_mutex_unlock(&mp); - - - fname=createFileName(); - -#ifdef VERBOSE - cout << "writing merged data file" << endl; -#endif - writeDataFile (fname+ext,np,angConv->getMergedCounts(), angConv->getMergedErrors(), angConv->getMergedPositions(),'f'); -#ifdef VERBOSE - cout << " done" << endl; -#endif - - - -// if (delflag) { -// deleteMerging(); -// } else { - thisData=new detectorData(angConv->getMergedCounts(),angConv->getMergedErrors(),angConv->getMergedPositions(),getCurrentProgress(),(fname+ext).c_str(),np); - - // // cout << "lock 2" << endl; -// pthread_mutex_lock(&mg); -// finalDataQueue.push(thisData); -// // cout << "unlock 2" << endl; - -// pthread_mutex_unlock(&mg); - - if (dataReady) { - - dataReady(thisData, pCallbackArg); - delete thisData; - } - -// } - // cout << "lock 3" << endl; - pthread_mutex_lock(&mp); - } - // cout << "unlock 3" << endl; - pthread_mutex_unlock(&mp); - - if (ffcdata) - delete [] ffcdata; - - ffcdata=NULL; - - if (ffcerr) - delete [] ffcerr; - ffcerr=NULL; - - if (ang) - delete [] ang; - ang=NULL; - - } else { -// if (delflag) { -// if (ffcdata) -// delete [] ffcdata; -// if (ffcerr) -// delete [] ffcerr; -// if ( ang) -// delete [] ang; -// } else { - thisData=new detectorData(ffcdata,ffcerr,NULL,getCurrentProgress(),(fname+ext).c_str(),getTotalNumberOfChannels()); - - - if (dataReady) { - dataReady(thisData, pCallbackArg); - delete thisData; - } -// pthread_mutex_lock(&mg); -// finalDataQueue.push(thisData); - - -// pthread_mutex_unlock(&mg); -// } - } - //} - - incrementFileIndex(); -#ifdef VERBOSE - cout << "fdata is " << fdata << endl; -#endif - -} - - - - - -int postProcessing::fillBadChannelMask() { - - int nbad=0; - - if (*correctionMask&(1<< DISCARD_BAD_CHANNELS)) { - nbad=getBadChannelCorrection(); -#ifdef VERBOSE - cout << "number of bad channels is " << nbad << endl; -#endif - if (nbad>0) { - - int *badChansList=new int[nbad]; - getBadChannelCorrection(badChansList); - - if (badChannelMask) - delete [] badChannelMask; - badChannelMask=new int[getTotalNumberOfChannels()]; - -#ifdef VERBOSE - cout << " pointer to bad channel mask is " << badChannelMask << endl; -#endif - for (int ichan=0; ichan=0 ) { - if (badChannelMask[badChansList[ichan]]==0) - nbad++; - badChannelMask[badChansList[ichan]]=1; - - } - } - delete [] badChansList; - - } else { - if (badChannelMask) { -#ifdef VERBOSE - cout << "deleting bad channel mask beacuse number of bad channels is 0" << endl; -#endif - - delete [] badChannelMask; - badChannelMask=NULL; - } - } - - } else { -#ifdef VERBOSE - cout << "bad channel correction is disabled " << nbad << endl; -#endif - if (badChannelMask) { -#ifdef VERBOSE - cout << "deleting bad channel mask beacuse no bad channel correction is selected" << endl; -#endif - delete [] badChannelMask; - badChannelMask=NULL; - } - } - -#ifdef VERBOSE - cout << "number of bad channels is " << nbad << endl; -#endif - return nbad; - -} - - - - - - -void* postProcessing::processData(int delflag) { - - -#ifdef VERBOSE - std::cout<< " processing data - threaded mode " << *threadedProcessing << endl; -#endif - - - angConv->setTotalNumberOfChannels(getTotalNumberOfChannels()); - setTotalProgress(); - pthread_mutex_lock(&mp); - queuesize=dataQueue.size(); - pthread_mutex_unlock(&mp); - - int *myData; - int dum=1; - - fdata=NULL; - - - while(dum | *threadedProcessing) { // ???????????????????????? - - - /* IF THERE ARE DATA PROCESS THEM*/ - pthread_mutex_lock(&mp); - while((queuesize=dataQueue.size())>0) { - /** Pop data queue */ - myData=dataQueue.front(); // get the data from the queue - pthread_mutex_unlock(&mp); - - if (myData) { - processFrame(myData,delflag); - //usleep(1000); - } - pthread_mutex_lock(&mp); - - } - pthread_mutex_unlock(&mp); - - /* IF THERE ARE NO DATA look if acquisition is finished */ - pthread_mutex_lock(&mp); - if (jointhread) { - if (dataQueue.size()==0) { - pthread_mutex_unlock(&mp); - break; - } - pthread_mutex_unlock(&mp); - } else { - pthread_mutex_unlock(&mp); - } - dum=0; - } - - if (fdata) { -#ifdef VERBOSE - cout << "delete fdata" << endl; -#endif - delete [] fdata; -#ifdef VERBOSE - cout << "done " << endl; -#endif - } - return 0; -} - - -int* postProcessing::popDataQueue() { - int *retval=NULL; - if( !dataQueue.empty() ) { - retval=dataQueue.front(); - dataQueue.pop(); - } - return retval; -} - -detectorData* postProcessing::popFinalDataQueue() { - detectorData *retval=NULL; - pthread_mutex_unlock(&mg); - if( !finalDataQueue.empty() ) { - retval=finalDataQueue.front(); - finalDataQueue.pop(); - } - pthread_mutex_unlock(&mg); - return retval; -} - -void postProcessing::resetDataQueue() { - int *retval=NULL; - while( !dataQueue.empty() ) { - retval=dataQueue.front(); - dataQueue.pop(); - delete [] retval; - } - -} - -void postProcessing::resetFinalDataQueue() { - detectorData *retval=NULL; - pthread_mutex_lock(&mg); - while( !finalDataQueue.empty() ) { - retval=finalDataQueue.front(); - finalDataQueue.pop(); - delete retval; - } - pthread_mutex_unlock(&mg); -} - - -void postProcessing::startThread(int delflag) { - pthread_attr_t tattr; - int ret; - sched_param param, mparam; - int policy= SCHED_OTHER; - - - // set the priority; others are unchanged - //newprio = 30; - mparam.sched_priority =1; - param.sched_priority =1; - - - /* Initialize and set thread detached attribute */ - pthread_attr_init(&tattr); - pthread_attr_setdetachstate(&tattr, PTHREAD_CREATE_JOINABLE); - - - - // param.sched_priority = 5; - // scheduling parameters of main thread - ret = pthread_setschedparam(pthread_self(), policy, &mparam); - //#ifdef VERBOSE - // printf("current priority is %d\n",param.sched_priority); - //#endif - if (delflag) - ret = pthread_create(&dataProcessingThread, &tattr,startProcessData, (void*)this); - else - ret = pthread_create(&dataProcessingThread, &tattr,startProcessDataNoDelete, (void*)this); - - pthread_attr_destroy(&tattr); - // scheduling parameters of target thread - ret = pthread_setschedparam(dataProcessingThread, policy, ¶m); - -} - - - diff --git a/slsDetectorSoftware/slsDetectorAnalysis/postProcessing_Standalone.h b/slsDetectorSoftware/slsDetectorAnalysis/postProcessing_Standalone.h deleted file mode 100644 index 213ed6de4..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/postProcessing_Standalone.h +++ /dev/null @@ -1,367 +0,0 @@ -#ifndef POSTPROCESSING_H -#define POSTPROCESSING_H - - -#include "detectorData.h" -#include "fileIO.h" -#include - -#include -#include -#include -#include -#include -#include -#include -#include - - -class angularConversion; - -; - -#define MAX_BADCHANS 2000 - - -#define defaultTDead {170,90,750} /**< should be changed in order to have it separate for the different detector types */ - - -/** - @short methods for data postprocessing - - (including thread for writing data files and plotting in parallel with the acquisition) -*/ - -class postProcessing : public virtual fileIO { - - -//: public angularConversion, public fileIO - - public: - postProcessing(); - virtual ~postProcessing(){}; - - - - - /** - get bad channels correction - \param bad pointer to array that if bad!=NULL will be filled with the bad channel list - \returns 0 if bad channel disabled or no bad channels, >0 otherwise - */ - virtual int getBadChannelCorrection(int *bad=NULL)=0; - - - /** - get flat field corrections - \param corr if !=NULL will be filled with the correction coefficients - \param ecorr if !=NULL will be filled with the correction coefficients errors - \returns 0 if ff correction disabled, >0 otherwise - */ - virtual int getFlatFieldCorrection(float *corr=NULL, float *ecorr=NULL)=0; - - /** - set flat field corrections - \param corr if !=NULL the flat field corrections will be filled with corr (NULL usets ff corrections) - \param ecorr if !=NULL the flat field correction errors will be filled with ecorr (1 otherwise) - \returns 0 if ff correction disabled, >0 otherwise - */ - virtual int setFlatFieldCorrection(float *corr, float *ecorr=NULL)=0; - - /** - set bad channels correction - \param fname file with bad channel list ("" disable) - \returns 0 if bad channel disabled, >0 otherwise - */ - virtual int setBadChannelCorrection(string fname="")=0; - - static int setBadChannelCorrection(ifstream &infile, int &nbad, int *badlist, int moff=0); - /** - set bad channels correction - \param fname file with bad channel list ("" disable) - -ff - \param nbad reference to number of bad channels - \param badlist array of badchannels - \returns 0 if bad channel disabled, >0 otherwise - */ - virtual int setBadChannelCorrection(string fname, int &nbad, int *badlist, int off=0)=0; - - - /** - set bad channels correction - \param nch number of bad channels - \param chs array of channels - \param ff 0 if normal bad channels, 1 if ff bad channels - \returns 0 if bad channel disabled, >0 otherwise - */ - virtual int setBadChannelCorrection(int nch, int *chs, int ff=0)=0; - - /** - flat field correct data - \param datain data - \param errin error on data (if<=0 will default to sqrt(datain) - \param dataout corrected data - \param errout error on corrected data - \param ffcoefficient flat field correction coefficient - \param fferr erro on ffcoefficient - \returns 0 - */ - static int flatFieldCorrect(float datain, float errin, float &dataout, float &errout, float ffcoefficient, float fferr); - - /** - rate correct data - \param datain data - \param errin error on data (if<=0 will default to sqrt(datain) - \param dataout corrected data - \param errout error on corrected data - \param tau dead time 9in ns) - \param t acquisition time (in ns) - \returns 0 - */ - static int rateCorrect(float datain, float errin, float &dataout, float &errout, float tau, float t); - - - int enableWriteToFile(int i=-1) {if (i>0) ((*correctionMask)|=(1<0) (*correctionMask)|=(1<< ANGULAR_CONVERSION); return ((*correctionMask)&(1<< ANGULAR_CONVERSION));}; - - - - int enableAngularConversion(int i=-1) {if (i>0) return setAngularConversionFile("default"); if (i==0) return setAngularConversionFile(""); return setAngularCorrectionMask();}; - - - int enableBadChannelCorrection(int i=-1) {if (i>0) return setBadChannelCorrection("default"); if (i==0) return setBadChannelCorrection(""); return ((*correctionMask)&(1<< DISCARD_BAD_CHANNELS));}; - - - - - /** returns the bad channel list file */ - string getBadChannelCorrectionFile() {if ((*correctionMask)&(1<< DISCARD_BAD_CHANNELS)) return string(badChanFile); else return string("none");}; - - - /** - get flat field corrections file directory - \returns flat field correction file directory - */ - string getFlatFieldCorrectionDir(){return string(flatFieldDir);}; - /** - set flat field corrections file directory - \param flat field correction file directory - \returns flat field correction file directory - */ - string setFlatFieldCorrectionDir(string dir){strcpy(flatFieldDir,dir.c_str()); return string(flatFieldDir);}; - - /** - get flat field corrections file name - \returns flat field correction file name - */ - string getFlatFieldCorrectionFile(){ if ((*correctionMask)&(1<=0) *threadedProcessing=b; return *threadedProcessing;}; - - - - - /** processes the data - \param delflag 0 leaves the data in the final data queue - \returns nothing - - */ - void *processData(int delflag); - - /** processes the data - \param delflag 0 leaves the data in the final data queue - \returns nothing - - */ - void processFrame(int* myData, int delflag); - - /** processes the data - \param delflag 0 leaves the data in the final data queue - \returns nothing - - */ - void doProcessing(float* myData, int delflag, string fname); - - - /** - pops the data from the data queue - \returns pointer to the popped data or NULL if the queue is empty. - \sa dataQueue - */ - int* popDataQueue(); - - /** - pops the data from thepostprocessed data queue - \returns pointer to the popped data or NULL if the queue is empty. - \sa finalDataQueue - */ - detectorData* popFinalDataQueue(); - - - /** - resets the raw data queue - \sa dataQueue - */ - void resetDataQueue(); - - /** - resets the postprocessed data queue - \sa finalDataQueue - */ - void resetFinalDataQueue(); - - - - - - int fillBadChannelMask(); - - - - - virtual int rateCorrect(float*, float*, float*, float*)=0; - virtual int flatFieldCorrect(float*, float*, float*, float*)=0; - - - - - - - - void registerDataCallback(int( *userCallback)(detectorData*, void*), void *pArg) {dataReady = userCallback; pCallbackArg = pArg;}; - //void registerCallBackGetChansPerMod(int (*func)(int, void *),void *arg){ getChansPerMod=func;pChpermod=arg;} - - - - /** - sets the angular conversion file - \param fname file to read - \returns angular conversion flag - */ - - int setAngularConversionFile(string fname); - - - /** - returns the angular conversion file - */ - string getAngularConversionFile(){if (setAngularCorrectionMask()) return string(angConvFile); else return string("none");}; - - - - protected: - - int *threadedProcessing; - - int *correctionMask; - - char *flatFieldDir; - char *flatFieldFile; - - char *badChanFile; - int *nBadChans; - int *badChansList; - int *nBadFF; - int *badFFList; - - /** pointer to angular conversion file name*/ - char *angConvFile; - - - /** mutex to synchronize main and data processing threads */ - pthread_mutex_t mp; - - - /** mutex to synchronizedata processing and plotting threads */ - pthread_mutex_t mg; - - /** sets when the acquisition is finished */ - int jointhread; - - /** sets when the position is finished */ - int posfinished; - - /** - data queue - */ - queue dataQueue; - /** - queue containing the postprocessed data - */ - queue finalDataQueue; - - - /** data queue size */ - int queuesize; - - - - - /** - start data processing thread - */ - void startThread(int delflag=1); // - /** the data processing thread */ - - pthread_t dataProcessingThread; - - - - /** pointer to bad channel mask 0 is channel is good 1 if it is bad \sa fillBadChannelMask() */ - int *badChannelMask; - - - - - /** - I0 measured - */ - float currentI0; - - float *fdata; - - - //int (*getChansPerMod)(int, void*); - - - int (*dataReady)(detectorData*,void*); - void *pCallbackArg, *pChpermod; - - - - private: - angularConversion *angConv; - - -}; - - -static void* startProcessData(void *n){\ - postProcessing *myDet=(postProcessing*)n;\ - myDet->processData(1);\ - pthread_exit(NULL);\ - -}; - -static void* startProcessDataNoDelete(void *n){\ - postProcessing *myDet=(postProcessing*)n;\ - myDet->processData(0);\ - pthread_exit(NULL);\ - -}; - - - -#endif diff --git a/slsDetectorSoftware/slsDetectorAnalysis/runningStat.h b/slsDetectorSoftware/slsDetectorAnalysis/runningStat.h deleted file mode 100644 index 98ab7986f..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/runningStat.h +++ /dev/null @@ -1,92 +0,0 @@ - /********************************************//** - * @file runningStat.h - * @short handles pedestal data and doesnt move - ***********************************************/ -#ifndef RUNNINGSTAT_H -#define RUNNINGSTAT_H - -#include - -//#include "sls_detector_defs.h" -#include -typedef double double32_t; -typedef float float32_t; -typedef int int32_t; - -/** - @short class handling pedestal data that is static - */ - -class runningStat{ - -public: - /** - * Constructor - */ - runningStat() : m_n(0),m_oldM(0),m_newM(0),m_oldS(0),m_newS(0) {} - - /** - * Clear number of data values - */ - void Clear(){ - m_n = 0; - } - - /** - * Push Pedestal - */ - void Push(double x){ - m_n++; - - // See Knuth TAOCP vol 2, 3rd edition, page 232 - if (m_n == 1){ - m_oldM = m_newM = x; - m_oldS = 0.0; - }else{ - m_newM = m_oldM + (x - m_oldM)/m_n; - m_newS = m_oldS + (x - m_oldM)*(x - m_newM); - - // set up for next iteration - m_oldM = m_newM; - m_oldS = m_newS; - } - } - - /** - * Get number of data values - */ - int NumDataValues() const{ - return m_n; - } - - /** - * Get mean - */ - double Mean() const{ - return (m_n > 0) ? m_newM : 0.0; - } - - /** - * Get variance - */ - double Variance() const{ - return ( (m_n > 1) ? m_newS/(m_n - 1) : 0.0 ); - } - - /** - * Get standard deviation - */ - double StandardDeviation() const{ - return sqrt( Variance() ); - } - -private: - /** number of data values */ - int m_n; - - /** old and new mean */ - double m_oldM, m_newM, m_oldS, m_newS; - -}; - -#endif diff --git a/slsDetectorSoftware/slsDetectorAnalysis/singlePhotonFilter.cpp b/slsDetectorSoftware/slsDetectorAnalysis/singlePhotonFilter.cpp deleted file mode 100644 index ee9dc95e7..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/singlePhotonFilter.cpp +++ /dev/null @@ -1,678 +0,0 @@ - /********************************************//** - * @file singlePhotonFilter.cpp - * @short single photon filter using trees - ***********************************************/ -#include "singlePhotonFilter.h" -#include - - -#define FILE_BUF_SIZE (16*1024*1024) //16mb -#define HEADER_SIZE_NUM_FRAMES 2 -#define HEADER_SIZE_NUM_PACKETS 1 - - -singlePhotonFilter::singlePhotonFilter(int nx, int ny, - int fmask, int pmask, int foffset, int poffset, int pperf, int iValue, - int16_t *m, int16_t *s, CircularFifo* f, int d, int* tfcaught, int* fcaught,uint32_t* cframenum): -#ifdef MYROOT1 - myTree(NULL), -#else - - nHitsPerFile(0), - nTotalHits(0), -#endif - myFile(NULL), - nHitsPerFrame(0), - nChannelsX(nx), - nChannelsY(ny), - nClusterX(CLUSTER_SIZE), - nClusterY(CLUSTER_SIZE), - map(m), - dataSize(d), - mask(s), - nped(DEFAULT_NUM_PEDESTAL), - nsigma(DEFAULT_SIGMA), - nbackground(DEFAULT_BACKGROUND), - outcorr(DEFAULT_CORRECTION), - fnum(0), - pnum(0), - ptot(0), - f0(0), - frame_index_mask(fmask), - packet_index_mask(pmask), - frame_index_offset(foffset), - packet_index_offset(poffset), - packets_per_frame(pperf), - incrementValue(iValue), - firstTime(true), - ret(0), - pIndex(0), - fIndex(0), - thread_started(0), - threads_mask(0x0), - currentThread(-1), - thisThreadIndex(-1), - fileIndex(0), - fifo(f), - totalFramesCaught(tfcaught), - framesCaught(fcaught), - currentframenum(cframenum), - freeFifoCallBack(NULL), - pFreeFifo(NULL){ - //cluster - if (nChannelsX) - nClusterX = 1; - -#ifndef MYROOT1 - //photonHitList=(single_photon_hit**) (new int*[nChannelsX*nChannelsY/(nClusterX*nClusterY)*1000]); - photonHitList=new single_photon_hit*[nChannelsX*nChannelsY/(nClusterX*nClusterY)*1000]; - for (int ii=0; iidata = new double[nClusterX*nClusterY]; - myPhotonHit->x = 0; - myPhotonHit->y = 0; - myPhotonHit->rms = 0; - myPhotonHit->ped = 0; - myPhotonHit->iframe = -1; - - for(int i=0;i < NUM_THREADS; i++){ - /*smp[i] = NULL;*/ - mem0[i]=NULL; - } - numFramesAlloted = new int[NUM_THREADS]; - - strcpy(savefilename,""); - strcpy(filePath,""); - strcpy(fileName,"run"); - - pthread_mutex_init(&write_mutex,NULL); - pthread_mutex_init(&running_mutex,NULL); - pthread_mutex_init(&frnum_mutex,NULL); - - - -} - - -singlePhotonFilter::~singlePhotonFilter(){ - enableCompression(false); - if(numFramesAlloted) delete [] numFramesAlloted; - writeToFile(); - closeFile(); - if(myFile) delete myFile; - if(mask) delete mask; - if(stat) delete stat; - if(nHitStat) delete nHitStat; - /*if(smp) delete []smp;*/ - if(mem0) delete [] mem0; - if(fifo) delete fifo; -} - - - - - - -int singlePhotonFilter::enableCompression(bool enable){ -//#ifdef VERBOSE - cout << "Compression set to " << enable; -#ifdef MYROOT1 - cout << " with root" << endl; -#else - cout << " without root" << endl; -#endif -//#endif - if(enable){ - threads_mask = 0x0; - currentThread = -1; - - for(int i=0; ifindHits(); - return this_pointer; -} - - - -int singlePhotonFilter::initTree(){ -#ifdef MYROOT1 - writeToFile(); - closeFile(); - sprintf(savefilename, "%s/%s_%d_.root", filePath,fileName,fileIndex); - - //file - myFile = new TFile(savefilename, "RECREATE"); /** later return error if it exists */ - cout<<"File created: "<Branch("iframe",&myPhotonHit->iframe,"iframe/I"); - myTree->Branch("x",&myPhotonHit->x,"x/I"); - myTree->Branch("y",&myPhotonHit->y,"y/I"); - myTree->Branch("data",myPhotonHit->data,cdata); - myTree->Branch("pedestal",&myPhotonHit->ped,"pedestal/D"); - myTree->Branch("rms",&myPhotonHit->rms,"rms/D"); -#else - - writeToFile(); - closeFile(); - sprintf(savefilename, "%s/%s_f%012d_%d.raw", filePath,fileName,nTotalHits,fileIndex); - myFile = fopen(savefilename, "w"); - setvbuf(myFile,NULL,_IOFBF,FILE_BUF_SIZE); - cout<<"File created: "<Write(); - nHitsPerFrame = 0; - return OK; - }else - cout << "ERROR: Could not write to " << nHitsPerFrame << " hits to file as file or tree doesnt exist" << endl; -#else - if(myFile){ - int ii; - /*cout<<"writing "<< nHitsPerFrame << " hits to file" << endl;*/ - for (ii=0; iiwrite(myFile); - // delete photonHitList[ii]; - } - // delete photonHitList[ii]; - // photonHitList[0]=new single_photon_hit(nClusterX,nClusterY); - - // fwrite((void*)(photonHitList), 1, sizeof(single_photon_hit)*nHitsPerFrame, myFile); - /*framesInFile += nHitsPerFrame;*/ - nHitsPerFrame = 0; - //cout<<"Exiting writeToFile"<GetCurrentFile(); - myFile->Close(); - myFile = NULL;//delete myFile; - } - myTree = NULL;//delete myTree; - } -#else - if(myFile) - fclose(myFile); - myFile = NULL; -#endif - return OK; -} - - - - - -void singlePhotonFilter::setupAcquisitionParameters(char *outfpath, char* outfname, int outfIndex){ - fileIndex = outfIndex; - strcpy(filePath,outfpath); - strcpy(fileName,outfname); - - fnum = 0; pnum = 0; ptot = 0; f0 = 0; firstTime = true; currentThread = -1; - *framesCaught = 0; - *currentframenum = 0; - - //initialize - for (int ir=0; irClear(); - nHitStat->SetN(nbackground); -#ifndef MYROOT1 - nTotalHits = 0; -#endif -} - - -/* - rets -case 0: waiting for next packet of new frame -case 1: finished with full frame, - start new frame -case -1: last packet of current frame, - invalidate remaining packets, - start new frame -case -2: first packet of new frame, - invalidate remaining packets, - check buffer needs to be pushed, - start new frame with the current packet, - then ret = 0 -case -3: last packet of new frame, - invalidate remaining packets, - check buffer needs to be pushed, - start new frame with current packet, - then ret = -1 (invalidate remaining packets and start a new frame) - */ -int singlePhotonFilter::verifyFrame(char *inData){ - ret = 0; - pIndex = 0; - fIndex = 0; - fIndex = (((uint32_t)(*((uint32_t*)inData)))& frame_index_mask) >> frame_index_offset; - pIndex = (((uint32_t)(*((uint32_t*)inData)))& packet_index_mask) >> packet_index_offset; - - //check validity of packet index - if ((pIndex < 0) && (pIndex >= packets_per_frame)){ - cout << "cannot decode packet index:" << pIndex << endl; - //its already dealt with cuz this frame will be discarded in the end - } - pIndex += incrementValue; - - //for moench, put first packet last - if (pIndex == 0) - pIndex = packets_per_frame; -//#ifdef VERYVERBOSE - cout<<"fi:"<>frame_index_offset); - //progress - if((clusteriframe + PROGRESS_INCREMENT) > *currentframenum){ - pthread_mutex_lock(&frnum_mutex); - *currentframenum = clusteriframe; - pthread_mutex_unlock(&frnum_mutex); - /*cout<<"currentframenum:"<data; - - //for each pixel - for (ir=0; ir= (dataSize))){ - cout << "Bad Channel Mapping index: " << map[currentIndex] << endl; - continue; - } - - //if frame within pedestal number - if (clusteriframe < nped){ - stat[currentIndex].Calc((double)(mask[currentIndex] ^ myData[map[currentIndex]])); - // frame outside pedestal number - }else{ - - dum = 1; - tot = 0; - clusterrms = stat[currentIndex].StandardDeviation();//-1 - clusterped = stat[currentIndex].Mean();//0 - sigmarms = clusterrms * nsigma; - - - clusterData[clusterCenterPixel] = ((double)(mask[currentIndex] ^ myData[map[currentIndex]])) - clusterped; - for (r=-deltaX; r <= deltaX; ++r ){ - if (((ir+r) < 0) || ((ir+r) >= nChannelsX)) - continue; - for(c=-1; c <= 1; ++c){ - if (((ic+c) < 0) || ((ic+c) >= nChannelsY)) - continue; - - - pixelIndex = currentIndex + (r*nChannelsY+c); - - if ((map[pixelIndex] < 0) || (map[pixelIndex] >= dataSize)){ - cout << "Bad Channel Mapping index: " << map[pixelIndex] << endl; - continue; - } - - clusterIndex = pixelIndex-(currentIndex - deltaX * nChannelsY - 1); - clusterData[clusterIndex] = ((double)(mask[pixelIndex] ^ myData[map[pixelIndex]])) - stat[pixelIndex].Mean(); - tot += clusterData[clusterIndex]; - //discard negative events - if (clusterData[clusterIndex] > clusterData[clusterCenterPixel]) - dum = 2; - - } - - } - - - if (tot < sqrtCluster * sigmarms) - dum = 0; - //discard events (for pedestal) where sum of the neighbours is too large. - if (clusterData[clusterCenterPixel] < sigmarms && dum != 0) - dum = 3; - //Appriximated running average - if (clusterData[clusterCenterPixel] > -sigmarms && - clusterData[clusterCenterPixel] < sigmarms && - dum == 0){ - stat[currentIndex].Calc((double)(mask[currentIndex]^myData[map[currentIndex]])); - } - // this is an event and we are in the center - else if (dum == 1){ - pthread_mutex_lock(&write_mutex); -#ifdef MYROOT1 - myTree->Fill(); -#else - for (int ix=0; ixdata[ix] = clusterData[ix]; - - photonHitList[nHitsPerFrame]->x = ic; - photonHitList[nHitsPerFrame]->y = ir; - photonHitList[nHitsPerFrame]->rms = clusterrms; - photonHitList[nHitsPerFrame]->ped = clusterped; - photonHitList[nHitsPerFrame]->iframe = clusteriframe; - //hit.write(myFile); - - nHitsPerFrame++; - - // cout << nHitsPerFrame << " " << nChannelsX*nChannelsY/(nClusterX*nClusterY)*1000 << endl; - - // photonHitList[nHitsPerFrame]=new single_photon_hit(nClusterX,nClusterY); - // cout << "done" << endl; - nHitsPerFile++; - nTotalHits++; - if(nHitsPerFile >= MAX_HITS_PER_FILE-1) - initTree(); -#endif - pthread_mutex_unlock(&write_mutex); - } - - } - } - } - }else{ - //cout<< "did no receiver fulll frame"<Calc((double)nHitsPerFrame); - //write for each frame, not packet - - pthread_mutex_lock(&write_mutex); - cout << "write to file " << nHitsPerFrame << endl; - writeToFile(); - pthread_mutex_unlock(&write_mutex); - - //increment offset - isData += dataSize; - - /* - if ((clusteriframe%1000 == 0) && (clusteriframe != 0) ){ - cout << dec << "Frame: " << clusteriframe << " Hit Avg over last frames: " << - nHitStat->Mean() << " .. "<StandardDeviation() << endl; - cout<<"writing "<< nHitsPerFrame << " hits to file" << endl; - } - */ - } - - pthread_mutex_lock(&write_mutex); - if(freeFifoCallBack) - freeFifoCallBack(freeData,pFreeFifo); - //fifo->push(freeData);//fifo->push(isData); - pthread_mutex_unlock(&write_mutex); - - //thread not running - pthread_mutex_lock(&running_mutex); - threads_mask^=(1<=25000) { - cout<<"*****************problem: "<<((theData-listmem0)/4096)<<" :"< -#include -#include -#include -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "circularFifo.h" -#include "runningStat.h" -#include "movingStat.h" -#include "single_photon_hit.h" - - - -typedef double double32_t; -typedef float float32_t; -typedef int int32_t; -#define MAX_STR_LENGTH 1000 - -/** - return values -*/ -enum { - OK, /**< function succeeded */ - FAIL /**< function failed */ -}; - - -/** - @short class handling trees and its data file - */ - -class singlePhotonFilter{ -public: - /** - * Constructor - * @param nx Number of Channels in X direction - * @param ny Number of Channels in Y direction - * @param fmask frame index mask - * @param pmask packet index mask - * @param foffset frame index offset - * @param poffset packet index offset - * @param pperf packets per frame - * @param iValue increment value (only for gotthard to increment index to have matching frame number) - * @param m Map to data without headers - * @param s mask as to which adcs are inverted - * @param f circular fifo buffer, which needs to be freed - * @param d Size of data with the headers - * @param tfcaught pointer to total frames caught- needs updation for client - * @param fcaught pointer to frames caught - needs updation for client - * @param cframenum pointer to currentframe num- needs updation for progress for gui - */ - singlePhotonFilter( - int nx, - int ny, - int fmask, - int pmask, - int foffset, - int poffset, - int pperf, - int iValue, - int16_t *m, - int16_t *s, - CircularFifo* f, - int d, - int* tfcaught, - int* fcaught, - uint32_t* cframenum); - - /** virtual destructor */ - virtual ~singlePhotonFilter(); - -#ifdef MYROOT1 - /** - * returns tree - */ - TTree *getTree(){ return myTree; }; -#endif - - /** - * Returns packets per frame - */ - int getPacketsPerFrame(){ return packets_per_frame;}; - - /** - * returns struct - */ - single_photon_hit* getStructure(){ return myPhotonHit; }; - - /** Set number of frames to calculate pedestal at beginning */ - void setNPed(int n){ nped = n; }; - - /** Get number of frames to calculate pedestal at beginning */ - int getNPed(){return nped;}; - - /** Set Distance from pedestal to detect a hit */ - void setNSigma(int n){ nsigma = n; }; - - /** Get Distance from pedestal to detect a hit */ - int getNSigma(){return nsigma;}; - - /** Set background */ - void setNBackground(int n){ nbackground = n; }; - - /** Get background */ - int getNBackground(){return nbackground;}; - - /** Set correction */ - void setOutCorr(double d){ outcorr = d; }; - - /** Get correction */ - double getOutCorr(){return outcorr;}; - - /** - * Construct a tree, populate struct for the single photon hit and provide all the masks and offsets - * @param outdir Output file directory/Output file name - * returns OK if successful, else FAIL - - */ - int initTree(); - - /** - * Writes tree/struct to file - * returns OK if successful, else FAIL - */ - int writeToFile(); - - /** - * Closes file - * returns OK if successful, else FAIL - */ - int closeFile(); - - /** - * Reset Indices before starting acquisition - */ - void setupAcquisitionParameters(char *outfpath, char* outfname, int outfIndex); - - /** reconstruct the frame with all the right packets - * @param inData the data from socket to be verified - * returns - * 0: waiting for next packet of new frame - * 1: finished with full frame, - * start new frame - * -1: last packet of current frame, - * invalidate remaining packets, - * start new frame - * -2: first packet of new frame, - * invalidate remaining packets, - * check buffer needs to be pushed, - * start new frame with the current packet, - * then ret = 0 - * -3: last packet of new frame, - * invalidate remaining packets, - * check buffer needs to be pushed, - * start new frame with current packet, - * then ret = -1 (invalidate remaining packets and start a new frame) - */ - int verifyFrame(char *inData); - - /** - * Find Hits frame by frame and save it in file/tree - */ - void findHits(); - - /** Enable or disable compression - * @param enable true to enable compression and false to disable - * returns OK for success or FAIL for failure, incase threads fail to start - * */ - int enableCompression(bool enable); - - /** create threads for compression - * @param this_pointer obejct of this class - * */ - static void* createThreads(void *this_pointer); - - /** assignjobs to each thread - * @param thisData a bunch of frames - * @param numThisData number of frames - * */ - void assignJobsForThread(char *thisData, int numThisData); - - /** Checks if all the threads are done processing - * @param returns 1 for jobs done and 0 for jobs not done - * */ - int checkIfJobsDone(); - - /** - * call back to free fifo - * call back arguments are - * fbuffer buffer address to be freed - */ - void registerCallBackFreeFifo(void (*func)(char*, void*),void *arg){freeFifoCallBack=func; pFreeFifo=arg;}; - - - -private: - -#ifdef MYROOT1 - /** Tree where the hits are stored */ - TTree *myTree; - - /** File where the tree is saved */ - TFile *myFile; -#else - FILE *myFile; - - /** pointer to array of structs when only using files */ - //single_photon_hit* photonHitList; - single_photon_hit ** photonHitList; - - /** Number of Hits per file */ - int nHitsPerFile; - - /** Total Number of Hits Per Acquisition */ - int nTotalHits; -#endif - - /** Number of Hits per frame*/ - int nHitsPerFrame; - - /** Maximum Number of hits written to file */ - const static int MAX_HITS_PER_FILE = 2000000; - - /** Number of Channels in X direction */ - int nChannelsX; - - /** Number of Channels in Y direction */ - int nChannelsY; - - /** Cluster size in X direction */ - int nClusterX; - - /** Cluster size in Y direction */ - int nClusterY; - - /** map to the data without headers */ - int16_t *map; - - /** Size of data with headers */ - int dataSize; - - /** mask as to which adcs are inverted */ - int16_t *mask; - - /** movingStat object */ - movingStat *stat; - - movingStat *nHitStat; - - /** single Photon Hit structure */ - single_photon_hit* myPhotonHit; - - /** Cluster size */ - const static int CLUSTER_SIZE = 3; - - /** Default Number of frames at the beginning to calculate pedestal */ - const static int DEFAULT_NUM_PEDESTAL = 500; - - /** Default Distance from pedestal to detect a hit */ - const static int DEFAULT_SIGMA = 5; - - /** Default Background */ - const static int DEFAULT_BACKGROUND = 1000; - - /** Default Correction Percentage */ - const static double DEFAULT_CORRECTION = 1.0; - - /** Number of frames at the beginning to calculate pedestal */ - int nped; - - /** Distance from pedestal to detect a hit */ - int nsigma; - - /** background */ - int nbackground; - - /** correction */ - double outcorr; - - /** previous frame index */ - unsigned int fnum; - - /** previous packet index */ - unsigned int pnum; - - /** total packets received */ - unsigned int ptot; - - /** first frame number */ - unsigned int f0; - - /** frame index mask */ - int frame_index_mask; - - /** packet index mask */ - int packet_index_mask; - - /** frame index offset */ - int frame_index_offset; - - /** packet index offset */ - int packet_index_offset; - - /** number of packets per frame */ - int packets_per_frame; - - /** increment value for index for gotthard */ - int incrementValue; - - /** first packet */ - bool firstTime; - - /** return status */ - int ret; - - /** current packet index */ - int pIndex; - - /** current frame index */ - int fIndex; - - /** thread related variables */ - static const int NUM_THREADS = 15; - pthread_t find_hits_thread[NUM_THREADS]; - volatile int thread_started; - volatile int threads_mask; - pthread_mutex_t write_mutex; - pthread_mutex_t running_mutex; - pthread_mutex_t frnum_mutex; - - static const int PROGRESS_INCREMENT = 100; - /** current thread the job being allotted to */ - int currentThread; - - /** current index alloted for each thread */ - int thisThreadIndex; - - /** semaphore to synchronize between different jobs on same thread */ - sem_t smp[NUM_THREADS]; - - /** starting memory of data for different threads */ - char* mem0[NUM_THREADS]; - - /** number of frames alloted for each thread to process */ - int* numFramesAlloted; - - - - /** final file name */ - char savefilename[MAX_STR_LENGTH]; - - /** file path */ - char filePath[MAX_STR_LENGTH]; - - /** file prefix */ - char fileName[MAX_STR_LENGTH]; - - /** file acquisition index */ - int fileIndex; - - - /** 0 for 1d and 1 for 2d */ - int deltaX; - - /** index of center of cluster for 1d and for 2d*/ - int clusterCenterPixel; - - /** squareroot of cluster */ - double sqrtCluster; - - /** circular fifo buffer to be freed */ - CircularFifo* fifo; - - /**total frames caught */ - int* totalFramesCaught; - - /** frames caught */ - int* framesCaught; - - /** current frame number */ - uint32_t* currentframenum; - - /** call back function */ - void (*freeFifoCallBack)(char*, void*); - - /** call back arguments */ - void *pFreeFifo; -}; - - - - -#endif diff --git a/slsDetectorSoftware/slsDetectorAnalysis/single_photon_hit.h b/slsDetectorSoftware/slsDetectorAnalysis/single_photon_hit.h deleted file mode 100644 index 278c9f691..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/single_photon_hit.h +++ /dev/null @@ -1,44 +0,0 @@ -#ifndef SINGLE_PHOTON_HIT_H -#define SINGLE_PHOTON_HIT_h - -typedef double double32_t; -typedef float float32_t; -typedef int int32_t; - -/* /\** */ -/* @short structure for a single photon hit */ -/* *\/ */ -/* typedef struct{ */ -/* double* data; /\**< data size *\/ */ -/* int x; /\**< x-coordinate of the center of hit *\/ */ -/* int y; /\**< x-coordinate of the center of hit *\/ */ -/* double rms; /\**< noise of central pixel *\/ */ -/* double ped; /\**< pedestal of the central pixel *\/ */ -/* int iframe; /\**< frame number *\/ */ -/* }single_photon_hit; */ - - -class single_photon_hit { - - public: - single_photon_hit(int nx, int ny=1): dx(nx), dy(ny) {data=new double[dx*dy];}; - ~single_photon_hit(){delete [] data;}; - void write(FILE *myFile) {fwrite((void*)this, 1, 3*sizeof(int)+2*sizeof(double), myFile); fwrite((void*)data, 1, dx*dy*sizeof(double), myFile);}; - void read(FILE *myFile) {fread((void*)this, 1, 3*sizeof(int)+2*sizeof(double), myFile); fread((void*)data, 1, dx*dy*sizeof(double), myFile);}; - void set_data(double v, int ix, int iy=0){data[(iy+dy/2)*dx+ix+dx/2]=v;}; - double get_data(int ix, int iy=0){return data[(iy+dy/2)*dx+ix+dx/2];}; - - - int x; /**< x-coordinate of the center of hit */ - int y; /**< x-coordinate of the center of hit */ - double rms; /**< noise of central pixel */ - double ped; /**< pedestal of the central pixel */ - int iframe; /**< frame number */ - double *data; /**< data size */ - const int dx; - const int dy; -}; - - - -#endif diff --git a/slsDetectorSoftware/slsDetectorClient/CMakeLists.txt b/slsDetectorSoftware/slsDetectorClient/CMakeLists.txt deleted file mode 100644 index aa65dcf79..000000000 --- a/slsDetectorSoftware/slsDetectorClient/CMakeLists.txt +++ /dev/null @@ -1,71 +0,0 @@ -set(SOURCES - sls_detector_client.cpp -) - -include_directories( - ../commonFiles - ../multiSlsDetector - ../slsDetector - ../slsDetectorAnalysis - ../slsReceiverInterface - ../usersFunctions - ../MySocketTCP -) - -add_executable(sls_detector_get - ${SOURCES} -) -target_link_libraries(sls_detector_get - slsDetectorShared - pthread - zmq - rt -) -set_target_properties(sls_detector_get PROPERTIES - RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin - COMPILE_DEFINITIONS GET=1 -) - -add_executable(sls_detector_put - ${SOURCES} -) -target_link_libraries(sls_detector_put - slsDetectorShared - pthread - zmq - rt -) -set_target_properties(sls_detector_put PROPERTIES - RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin - COMPILE_DEFINITIONS PUT=1 -) - -add_executable(sls_detector_acquire - ${SOURCES} -) -target_link_libraries(sls_detector_acquire - slsDetectorShared - pthread - zmq - rt -) -set_target_properties(sls_detector_acquire PROPERTIES - RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin - COMPILE_DEFINITIONS READOUT=1 -) - -add_executable(sls_detector_help - ${SOURCES} -) -target_link_libraries(sls_detector_help - slsDetectorShared - pthread - zmq - rt -) -set_target_properties(sls_detector_help PROPERTIES - RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin - COMPILE_DEFINITIONS HELP=1 -) - -install(TARGETS sls_detector_put sls_detector_get sls_detector_acquire sls_detector_help DESTINATION bin) diff --git a/slsDetectorSoftware/slsDetectorClient/Makefile b/slsDetectorSoftware/slsDetectorClient/Makefile deleted file mode 100644 index 9c26be641..000000000 --- a/slsDetectorSoftware/slsDetectorClient/Makefile +++ /dev/null @@ -1,111 +0,0 @@ -include ../../Makefile.include - -CFLAGS= -DC_ONLY -#FLAGS=-DVERBOSE -#ASM=$(shell echo "/lib/modules/`uname -r`/build/include") - -INCLUDES?= -I../commonFiles -I../slsDetector -I ../MySocketTCP -I../usersFunctions -I../multiSlsDetector -I../slsDetectorAnalysis -I../slsReceiverInterface -I ../../slsReceiverSoftware/include -I$(shell echo "/lib/modules/`uname -r`/build/include") -DESTDIR ?= ../../bin -BIN=$(DESTDIR) -LIBS?= -L$(DESTDIR) -lSlsDetector -LIBRARYDIR?=../ -LDFLAG= -L/usr/lib64/ -pthread -DOCDIR ?= $(PWD)/docs -SRC_CLNT=sls_detector_client.cpp - - -$(info ) -$(info #######################################) -$(info # In slsDetectorclient Makefile #) -$(info #######################################) -$(info ) - -all: clients - -nonstatic: clients - -clients: builddir lib $(DESTDIR)/sls_detector_put $(DESTDIR)/sls_detector_get $(DESTDIR)/sls_detector_acquire $(DESTDIR)/sls_detector_help - -static_clients: builddir lib $(DESTDIR)/ssls_detector_put $(DESTDIR)/ssls_detector_get $(DESTDIR)/ssls_detector_acquire $(DESTDIR)/ssls_detector_help - -builddir: -# echo $(LIBS) -# echo $(LDFLAG) - mkdir -p $(BIN) - -lib: -# echo $(LIBDIR) - cd $(LIBRARYDIR) && $(MAKE) DESTDIR=$(DESTDIR) TABSPACE='$(TABSPACE)' - @echo "" - @echo "#######################################" - @echo "# Back in slsDetectorClient Makefile #" - @echo "#######################################" - @echo "" - -$(DESTDIR)/ssls_detector_put: $(SRC_CLNT) $(DESTDIR)/libSlsDetector.so $(DESTDIR)/libSlsDetector.a - $(call colorecho,"#######################################") - $(call colorecho,"# Compiling ssls_detector_put #") - $(call colorecho,"#######################################") - $(CXX) -static -o $(BIN)/ssls_detector_put $(SRC_CLNT) $(FLAGS) $(INCLUDES) -DPUT $(LIBS) $(LDFLAG) - -$(DESTDIR)/ssls_detector_get: $(SRC_CLNT) $(DESTDIR)/libSlsDetector.so $(DESTDIR)/libSlsDetector.a - $(call colorecho,"#######################################") - $(call colorecho,"# Compiling ssls_detector_get #") - $(call colorecho,"#######################################") - $(CXX) -static -o $(BIN)/ssls_detector_get $(SRC_CLNT) $(FLAGS) $(INCLUDES) -DGET $(LIBS) $(LDFLAG) - -$(DESTDIR)/ssls_detector_acquire: $(SRC_CLNT) $(DESTDIR)/libSlsDetector.so $(DESTDIR)/libSlsDetector.a - $(call colorecho,"#######################################") - $(call colorecho,"# Compiling ssls_detector_acquire #") - $(call colorecho,"#######################################") - $(CXX) -static -o $(BIN)/ssls_detector_acquire $(SRC_CLNT) $(FLAGS) $(INCLUDES) -DREADOUT $(LIBS) $(LDFLAG) - -$(DESTDIR)/ssls_detector_help: $(SRC_CLNT) $(DESTDIR)/libSlsDetector.so $(DESTDIR)/libSlsDetector.a - $(call colorecho,"#######################################") - $(call colorecho,"# Compiling ssls_detector_help #") - $(call colorecho,"#######################################") - $(CXX) -static -o $(BIN)/ssls_detector_help $(SRC_CLNT) $(FLAGS) $(INCLUDES) -DHELP $(LIBS) $(LDFLAG) - - - -$(DESTDIR)/sls_detector_put: $(SRC_CLNT) $(DESTDIR)/libSlsDetector.so $(DESTDIR)/libSlsDetector.a - $(call colorecho,"#######################################") - $(call colorecho,"# Compiling sls_detector_put #") - $(call colorecho,"#######################################") - $(CXX) -o $(BIN)/sls_detector_put $(SRC_CLNT) $(FLAGS) $(INCLUDES) -DPUT $(LIBS) $(LDFLAG) - $(shell test -d $(DESTDIR) || mkdir -p $(DESTDIR)) - -$(DESTDIR)/sls_detector_get: $(SRC_CLNT) $(DESTDIR)/libSlsDetector.so $(DESTDIR)/libSlsDetector.a - $(call colorecho,"#######################################") - $(call colorecho,"# Compiling sls_detector_get #") - $(call colorecho,"#######################################") - $(CXX) -o $(BIN)/sls_detector_get $(SRC_CLNT) $(FLAGS) $(INCLUDES) -DGET $(LIBS) $(LDFLAG) - $(shell test -d $(DESTDIR) || mkdir -p $(DESTDIR)) - -$(DESTDIR)/sls_detector_acquire: $(SRC_CLNT) $(DESTDIR)/libSlsDetector.so $(DESTDIR)/libSlsDetector.a - $(call colorecho,"#######################################") - $(call colorecho,"# Compiling sls_detector_acquire #") - $(call colorecho,"#######################################") - $(CXX) -o $(BIN)/sls_detector_acquire $(SRC_CLNT) $(FLAGS) $(INCLUDES) -DREADOUT $(LIBS) $(LDFLAG) - $(shell test -d $(DESTDIR) || mkdir -p $(DESTDIR)) - -$(DESTDIR)/sls_detector_help: $(SRC_CLNT) $(DESTDIR)/libSlsDetector.so $(DESTDIR)/libSlsDetector.a - $(call colorecho,"#######################################") - $(call colorecho,"# Compiling sls_detector_help #") - $(call colorecho,"#######################################") - $(CXX) -o $(BIN)/sls_detector_help $(SRC_CLNT) $(FLAGS) $(INCLUDES) -DHELP $(LIBS) $(LDFLAG) - $(shell test -d $(DESTDIR) || mkdir -p $(DESTDIR)) - - -doc: - cd manual && make DESTDIR=$(DOCDIR) - -htmldoc: - cd manual && make html DESTDIR=$(DOCDIR) - -clean: -# cd manual && make clean - rm -rf $(BIN)/sls_detector_put $(BIN)/sls_detector_get $(BIN)/sls_detector_acquire $(BIN)/sls_detector_help $(BIN)/gui_client - -install: clients - diff --git a/slsDetectorSoftware/slsDetectorClient/Makefile.x04sa b/slsDetectorSoftware/slsDetectorClient/Makefile.x04sa deleted file mode 100644 index af02ea176..000000000 --- a/slsDetectorSoftware/slsDetectorClient/Makefile.x04sa +++ /dev/null @@ -1,54 +0,0 @@ -CFLAGS= -DC_ONLY -FLAGS=-DVERBOSE -INCLUDES= -I../slsDetectorSoftware/commonFiles -I../slsDetectorSoftware/slsDetector -I ../slsDetectorSoftware/MySocketTCP -I../slsDetectorSoftware/usersFunctions -I../slsDetectorSoftware/multiSlsDetector -I../slsDetectorSoftware/slsDetectorAnalysis -LIBS= -L../slsDetectorSoftware/ -LDFLAG= -lSlsDetector -pthread - -EPICSFLAGS=-DEPICS -I/usr/local/epics/base/include/ -I /usr/local/epics/base/include/os/Linux/ -L /usr/local/epics/base/lib/SL5-x86/ -Wl,-R/usr/local/epics/base/lib/SL5-x86 -lca -lCom - -BIN=bin - -SRC_CLNT=sls_detector_client.cpp - -clients: sls_detector_put sls_detector_get sls_detector_acquire sls_detector_help - -all: lib clients - -lib: - cd ../slsDetectorSoftware && $(MAKE) lib - - - -sls_detector_put: $(SRC_CLNT) - mkdir -p $(BIN) - $(CXX) -o $(BIN)/sls_detector_put $(SRC_CLNT) $(FLAGS) $(INCLUDES) -DPUT $(LIBS) $(LDFLAG) $(EPICSFLAGS) - -sls_detector_get: $(SRC_CLNT) - mkdir -p $(BIN) - $(CXX) -o $(BIN)/sls_detector_get $(SRC_CLNT) $(FLAGS) $(INCLUDES) -DGET $(LIBS) $(LDFLAG) $(EPICSFLAGS) - -sls_detector_acquire: $(SRC_CLNT) - mkdir -p $(BIN) - $(CXX) -o $(BIN)/sls_detector_acquire $(SRC_CLNT) $(FLAGS) $(INCLUDES) -DREADOUT $(LIBS) $(LDFLAG) $(EPICSFLAGS) - -sls_detector_help: $(SRC_CLNT) - mkdir -p $(BIN) - $(CXX) -o $(BIN)/sls_detector_help $(SRC_CLNT) $(FLAGS) $(INCLUDES) -DHELP $(LIBS) $(LDFLAG) $(EPICSFLAGS) - - -clean: - rm -rf $(BIN)/sls_detector_* - - - - - -install_sls_detector: all - $(shell test -d $(DESTDIR) || mkdir -p $(DESTDIR)) - cp -P $(BIN)/sls_detector_put $(DESTDIR) - cp -P $(BIN)/sls_detector_get $(DESTDIR) - cp -P $(BIN)/sls_detector_acquire $(DESTDIR) - cp -P $(BIN)/sls_detector_help $(DESTDIR) - - - diff --git a/slsDetectorSoftware/slsDetectorClient/sls_detector_client.cpp b/slsDetectorSoftware/slsDetectorClient/sls_detector_client.cpp deleted file mode 100644 index d0525f9a6..000000000 --- a/slsDetectorSoftware/slsDetectorClient/sls_detector_client.cpp +++ /dev/null @@ -1,46 +0,0 @@ -#include "multiSlsDetectorClient.h" -#include "gitInfoLib.h" - - -#include -using namespace std; - -int main(int argc, char *argv[]) - -{ - for (int i = 1; i < argc; ++i ) { - if (!(strcmp (argv[i],"--version")) || !(strcmp (argv[i],"-v"))) { - int64_t tempval = GITDATE; - cout << argv[0] << " " << GITBRANCH << " (0x" << hex << tempval << ")" << endl; - return 0; - } - } - -#ifdef PUT - int action=slsDetectorDefs::PUT_ACTION; -#endif - -#ifdef GET - int action=slsDetectorDefs::GET_ACTION; -#endif - - -#ifdef READOUT - int action=slsDetectorDefs::READOUT_ACTION; -#endif - - -#ifdef HELP - int action=slsDetectorDefs::HELP_ACTION; -#endif - - multiSlsDetectorClient *cl; - if (argc>1) - cl=new multiSlsDetectorClient(argc-1, argv+1, action); - else - cl=new multiSlsDetectorClient(argc-1, argv, action); - - delete cl; -} - - diff --git a/slsDetectorSoftware/slsDetectorServer/AD9257.h b/slsDetectorSoftware/slsDetectorServer/AD9257.h deleted file mode 100755 index a716af64c..000000000 --- a/slsDetectorSoftware/slsDetectorServer/AD9257.h +++ /dev/null @@ -1,141 +0,0 @@ -#ifndef AD9257_H -#define AD9257_H - -#include "ansi.h" - -#include "commonServerFunctions.h" -#include - -/* AD9257 ADC DEFINES */ -#define AD9257_ADC_NUMBITS (24) - -#define AD9257_DEV_IND_2_REG (0x04) -#define AD9257_CHAN_H_OFST (0) -#define AD9257_CHAN_H_MSK (0x00000001 << AD9257_CHAN_H_OFST) -#define AD9257_CHAN_G_OFST (1) -#define AD9257_CHAN_G_MSK (0x00000001 << AD9257_CHAN_G_OFST) -#define AD9257_CHAN_F_OFST (2) -#define AD9257_CHAN_F_MSK (0x00000001 << AD9257_CHAN_F_OFST) -#define AD9257_CHAN_E_OFST (3) -#define AD9257_CHAN_E_MSK (0x00000001 << AD9257_CHAN_E_OFST) - -#define AD9257_DEV_IND_1_REG (0x05) -#define AD9257_CHAN_D_OFST (0) -#define AD9257_CHAN_D_MSK (0x00000001 << AD9257_CHAN_D_OFST) -#define AD9257_CHAN_C_OFST (1) -#define AD9257_CHAN_C_MSK (0x00000001 << AD9257_CHAN_C_OFST) -#define AD9257_CHAN_B_OFST (2) -#define AD9257_CHAN_B_MSK (0x00000001 << AD9257_CHAN_B_OFST) -#define AD9257_CHAN_A_OFST (3) -#define AD9257_CHAN_A_MSK (0x00000001 << AD9257_CHAN_A_OFST) -#define AD9257_CLK_CH_DCO_OFST (4) -#define AD9257_CLK_CH_DCO_MSK (0x00000001 << AD9257_CLK_CH_DCO_OFST) -#define AD9257_CLK_CH_IFCO_OFST (5) -#define AD9257_CLK_CH_IFCO_MSK (0x00000001 << AD9257_CLK_CH_IFCO_OFST) - -#define AD9257_POWER_MODE_REG (0x08) -#define AD9257_POWER_INTERNAL_OFST (0) -#define AD9257_POWER_INTERNAL_MSK (0x00000003 << AD9257_POWER_INTERNAL_OFST) -#define AD9257_INT_RESET_VAL (0x3) -#define AD9257_INT_CHIP_RUN_VAL (0x0) -#define AD9257_POWER_EXTERNAL_OFST (5) -#define AD9257_POWER_EXTERNAL_MSK (0x00000001 << AD9257_POWER_EXTERNAL_OFST) -#define AD9257_EXT_FULL_POWER_VAL (0x0) -#define AD9257_EXT_STANDBY_VAL (0x1) - -#define AD9257_OUT_MODE_REG (0x14) -#define AD9257_OUT_FORMAT_OFST (0) -#define AD9257_OUT_FORMAT_MSK (0x00000001 << AD9257_OUT_FORMAT_OFST) -#define AD9257_OUT_BINARY_OFST_VAL (0) -#define AD9257_OUT_TWOS_COMPL_VAL (1) -#define AD9257_OUT_LVDS_OPT_OFST (6) -#define AD9257_OUT_LVDS_OPT_MSK (0x00000001 << AD9257_OUT_LVDS_OPT_OFST) -#define AD9257_OUT_LVDS_ANSI_VAL (0) -#define AD9257_OUT_LVDS_IEEE_VAL (1) - -#define AD9257_OUT_PHASE_REG (0x16) -#define AD9257_OUT_CLK_OFST (0) -#define AD9257_OUT_CLK_MSK (0x0000000F << AD9257_OUT_CLK_OFST) -#define AD9257_OUT_CLK_60_VAL (0x1) -#define AD9257_IN_CLK_OFST (4) -#define AD9257_IN_CLK_MSK (0x00000007 << AD9257_IN_CLK_OFST) -#define AD9257_IN_CLK_0_VAL (0x0) - -#define AD9257_VREF_REG (0x18) -#define AD9257_VREF_OFST (0) -#define AD9257_VREF_MSK (0x00000003 << AD9257_VREF_OFST) -#define AD9257_VREF_1_33_VAL (0x2) - -#define AD9257_TEST_MODE_REG (0x0D) -#define AD9257_OUT_TEST_OFST (0) -#define AD9257_OUT_TEST_MSK (0x0000000F << AD9257_OUT_TEST_OFST) -#define AD9257_NONE_VAL (0x0) -#define AD9257_MIXED_BIT_FREQ_VAL (0xC) -#define AD9257_TEST_RESET_SHORT_GEN (4) -#define AD9257_TEST_RESET_LONG_GEN (5) -#define AD9257_USER_IN_MODE_OFST (6) -#define AD9257_USER_IN_MODE_MSK (0x00000003 << AD9257_USER_IN_MODE_OFST) - - -void setAdc(int addr, int val) { - - u_int32_t codata; - codata = val + (addr << 8); - printf(" Setting ADC SPI Register. Wrote 0x%04x at 0x%04x\n", val, addr); - serializeToSPI(ADC_SPI_REG, codata, ADC_SERIAL_CS_OUT_MSK, AD9257_ADC_NUMBITS, - ADC_SERIAL_CLK_OUT_MSK, ADC_SERIAL_DATA_OUT_MSK, ADC_SERIAL_DATA_OUT_OFST); -} - -void prepareADC(){ - printf("\n\nPreparing ADC ... \n"); - - //power mode reset - printf("power mode reset:\n"); - setAdc(AD9257_POWER_MODE_REG, - (AD9257_INT_RESET_VAL << AD9257_POWER_INTERNAL_OFST) & AD9257_POWER_INTERNAL_MSK); - - //power mode chip run - printf("power mode chip run:\n"); - setAdc(AD9257_POWER_MODE_REG, - (AD9257_INT_CHIP_RUN_VAL << AD9257_POWER_INTERNAL_OFST) & AD9257_POWER_INTERNAL_MSK); - - //output clock phase - printf("output clock phase:\n"); - setAdc(AD9257_OUT_PHASE_REG, - (AD9257_OUT_CLK_60_VAL << AD9257_OUT_CLK_OFST) & AD9257_OUT_CLK_MSK); - - // lvds-iee reduced , binary offset - printf("lvds-iee reduced, binary offset:\n"); - setAdc(AD9257_OUT_MODE_REG, - (AD9257_OUT_LVDS_IEEE_VAL << AD9257_OUT_LVDS_OPT_OFST) & AD9257_OUT_LVDS_OPT_MSK); - - // all devices on chip to receive next command - printf("all devices on chip to receive next command:\n"); - setAdc(AD9257_DEV_IND_2_REG, - AD9257_CHAN_H_MSK | AD9257_CHAN_G_MSK | AD9257_CHAN_F_MSK | AD9257_CHAN_E_MSK); - setAdc(AD9257_DEV_IND_1_REG, - AD9257_CHAN_D_MSK | AD9257_CHAN_C_MSK | AD9257_CHAN_B_MSK | AD9257_CHAN_A_MSK | - AD9257_CLK_CH_DCO_MSK | AD9257_CLK_CH_IFCO_MSK); - - // vref 1.33 - printf("vref 1.33:\n"); - setAdc(AD9257_VREF_REG, - (AD9257_VREF_1_33_VAL << AD9257_VREF_OFST) & AD9257_VREF_MSK); - - // no test mode - printf("no test mode:\n"); - setAdc(AD9257_TEST_MODE_REG, - (AD9257_NONE_VAL << AD9257_OUT_TEST_OFST) & AD9257_OUT_TEST_MSK); - -#ifdef TESTADC - printf("***************************************** *******\n"); - printf("******* PUTTING ADC IN TEST MODE!!!!!!!!! *******\n"); - printf("***************************************** *******\n"); - // mixed bit frequency test mode - printf("mixed bit frequency test mode:\n"); - setAdc(AD9257_TEST_MODE_REG, - (AD9257_MIXED_BIT_FREQ_VAL << AD9257_OUT_TEST_OFST) & AD9257_OUT_TEST_MSK); -#endif -} - -#endif //AD9257_H diff --git a/slsDetectorSoftware/slsDetectorServer/Makefile b/slsDetectorSoftware/slsDetectorServer/Makefile deleted file mode 100644 index 8c3ee8d97..000000000 --- a/slsDetectorSoftware/slsDetectorServer/Makefile +++ /dev/null @@ -1,26 +0,0 @@ -CC = gcc -CLAGS += -Wall -DVIRTUAL -DDACS_INT -DGENERICD # -DSLS_DETECTOR_FUNCTION_LIST -LDLIBS += -lm - -PROGS = genericDetectorServer -DESTDIR ?= bin -INSTMODE = 0777 - -SRC_CLNT = slsDetectorServer.c slsDetectorServer_funcs.c communication_funcs.c slsDetectorFunctionList.c -OBJS = $(SRC_CLNT:.cpp=.o) - - - -all: clean $(PROGS) - -boot: $(OBJS) - -$(PROGS): - echo $(OBJS) - mkdir -p $(DESTDIR) - $(CC) $(SRC_CLNT) $(CLAGS) $(LDLIBS) -o $@ - mv $(PROGS) $(DESTDIR) - - -clean: - rm -rf $(DESTDIR)/$(PROGS) *.o diff --git a/slsDetectorSoftware/slsDetectorServer/blackfin.h b/slsDetectorSoftware/slsDetectorServer/blackfin.h deleted file mode 100755 index f95cd4ffe..000000000 --- a/slsDetectorSoftware/slsDetectorServer/blackfin.h +++ /dev/null @@ -1,162 +0,0 @@ -#ifndef BLACKFIN_H -#define BLACKFIN_H - -#include "ansi.h" - -#include -#include // open -#include // mmap - - -/* global variables */ -u_int64_t CSP0BASE = 0; -#define CSP0 0x20200000 -#define MEM_SIZE 0x100000 -#define MEM_MAP_SHIFT 1 - - - -/** - * Write into a 16 bit register - * @param offset address offset - * @param data 16 bit data - */ -void bus_w16(u_int32_t offset, u_int16_t data) { - volatile u_int16_t *ptr1; - ptr1=(u_int16_t*)(CSP0BASE+offset*2); - *ptr1=data; -} - -/** - * Read from a 16 bit register - * @param offset address offset - * @retuns 16 bit data read - */ -u_int16_t bus_r16(u_int32_t offset){ - volatile u_int16_t *ptr1; - ptr1=(u_int16_t*)(CSP0BASE+offset*2); - return *ptr1; -} - -/** - * Write into a 32 bit register - * @param offset address offset - * @param data 32 bit data - */ -void bus_w(u_int32_t offset, u_int32_t data) { - volatile u_int32_t *ptr1; - ptr1=(u_int32_t*)(CSP0BASE+offset*2); - *ptr1=data; -} - -/** - * Read from a 32 bit register - * @param offset address offset - * @retuns 32 bit data read - */ -u_int32_t bus_r(u_int32_t offset) { - volatile u_int32_t *ptr1; - ptr1=(u_int32_t*)(CSP0BASE+offset*2); - return *ptr1; -} - -/** - * Read from a 64 bit register - * @param aLSB LSB offset address - * @param aMSB MSB offset address - * @returns 64 bit data read - */ -int64_t get64BitReg(int aLSB, int aMSB){ - int64_t v64; - u_int32_t vLSB,vMSB; - vLSB=bus_r(aLSB); - vMSB=bus_r(aMSB); - v64=vMSB; - v64=(v64<<32) | vLSB; - printf(" reg64(%x,%x) %x %x %llx\n", aLSB, aMSB, vLSB, vMSB, (long long unsigned int)v64); - return v64; -} - -/** - * Write into a 64 bit register - * @param value 64 bit data - * @param aLSB LSB offset address - * @param aMSB MSB offset address - * @returns 64 bit data read - */ -int64_t set64BitReg(int64_t value, int aLSB, int aMSB){ - int64_t v64; - u_int32_t vLSB,vMSB; - if (value!=-1) { - vLSB=value&(0xffffffff); - bus_w(aLSB,vLSB); - v64=value>> 32; - vMSB=v64&(0xffffffff); - bus_w(aMSB,vMSB); - } - return get64BitReg(aLSB, aMSB); - -} - -/** - * Read from a 32 bit register (literal register value provided by client) - * @param offset address offset - * @retuns 32 bit data read - */ -u_int32_t readRegister(u_int32_t offset) { - return bus_r(offset << MEM_MAP_SHIFT); -} - -/** - * Write into a 32 bit register (literal register value provided by client) - * @param offset address offset - * @param data 32 bit data - */ -u_int32_t writeRegister(u_int32_t offset, u_int32_t data) { - bus_w(offset << MEM_MAP_SHIFT, data); - return readRegister(offset); -} - - -/** - * Map FPGA - */ -int mapCSP0(void) { - // if not mapped - if (CSP0BASE == 0) { - printf("Mapping memory\n"); -#ifdef VIRTUAL - CSP0BASE = malloc(MEM_SIZE); - if (CSP0BASE == NULL) { - cprintf(BG_RED, "Error: Could not allocate virtual memory.\n"); - return FAIL; - } - printf("memory allocated\n"); -#else - int fd; - fd = open("/dev/mem", O_RDWR | O_SYNC, 0); - if (fd == -1) { - cprintf(BG_RED, "Error: Can't find /dev/mem\n"); - return FAIL; - } -#ifdef VERBOSE - printf("/dev/mem opened\n"); -#endif - CSP0BASE = mmap(0, MEM_SIZE, PROT_READ|PROT_WRITE, MAP_FILE|MAP_SHARED, fd, CSP0); - if (CSP0BASE == MAP_FAILED) { - cprintf(BG_RED, "Error: Can't map memmory area\n"); - return FAIL; - } -#endif - printf("CSPOBASE mapped from 0x%llx to 0x%llx\n", - (long long unsigned int)CSP0BASE, - (long long unsigned int)(CSP0BASE+MEM_SIZE)); - printf("Status Register: %08x\n",bus_r(STATUS_REG)); - - }else - printf("Memory already mapped before\n"); - return OK; -} - - -#endif //BLACKFIN_H diff --git a/slsDetectorSoftware/slsDetectorServer/commonServerFunctions.h b/slsDetectorSoftware/slsDetectorServer/commonServerFunctions.h deleted file mode 100755 index 55d30b8c4..000000000 --- a/slsDetectorSoftware/slsDetectorServer/commonServerFunctions.h +++ /dev/null @@ -1,73 +0,0 @@ -#ifndef COMMON_SERVER_FUNCTIONS_H -#define COMMON_SERVER_FUNCTIONS_H - -#ifndef GOTTHARDD //gotthard already had bus_w etc defined in its firmware_funcs.c (not yet made with common files) -#include "blackfin.h" -#endif - -/* global variables */ - -void SPIChipSelect (u_int32_t* valw, u_int32_t addr, u_int32_t csmask) { - - // start point - (*valw) = 0xffffffff; // old board compatibility (not using specific bits) - bus_w (addr, (*valw)); - - // chip sel bar down - (*valw) &= ~csmask; /* todo with test: done a bit different, not with previous value */ - bus_w (addr, (*valw)); -} - - -void SPIChipDeselect (u_int32_t* valw, u_int32_t addr, u_int32_t csmask, u_int32_t clkmask) { - // chip sel bar up - (*valw) |= csmask; /* todo with test: not done for spi */ - bus_w (addr, (*valw)); - - //clk down - (*valw) &= ~clkmask; - bus_w (addr, (*valw)); - - // stop point = start point of course - (*valw) = 0xffffffff; // old board compatibility (not using specific bits) - bus_w (addr, (*valw)); -} - -void sendDataToSPI (u_int32_t* valw, u_int32_t addr, u_int32_t val, int numbitstosend, u_int32_t clkmask, u_int32_t digoutmask, int digofset) { - int i = 0; - for (i = 0; i < numbitstosend; ++i) { - - // clk down - (*valw) &= ~clkmask; - bus_w (addr, (*valw)); - - // write data (i) - (*valw) = (((*valw) & ~digoutmask) + // unset bit - (((val >> (numbitstosend - 1 - i)) & 0x1) << digofset)); // each bit from val starting from msb - bus_w (addr, (*valw)); - - // clk up - (*valw) |= clkmask ; - bus_w (addr, (*valw)); - } -} - - -void serializeToSPI(u_int32_t addr, u_int32_t val, u_int32_t csmask, int numbitstosend, u_int32_t clkmask, u_int32_t digoutmask, int digofset) { -#ifdef VERBOSE - if (numbitstosend == 16) - printf("Writing to SPI Register: 0x%04x\n",val); - else - printf("Writing to SPI Register: 0x%08x\n", val); -#endif - - u_int32_t valw; - - SPIChipSelect (&valw, addr, csmask); - - sendDataToSPI(&valw, addr, val, numbitstosend, clkmask, digoutmask, digofset); - - SPIChipDeselect(&valw, addr, csmask, clkmask); -} - -#endif //COMMON_SERVER_FUNCTIONS_H diff --git a/slsDetectorSoftware/slsDetectorServer/communication_funcs.c b/slsDetectorSoftware/slsDetectorServer/communication_funcs.c deleted file mode 120000 index 87a4f95d1..000000000 --- a/slsDetectorSoftware/slsDetectorServer/communication_funcs.c +++ /dev/null @@ -1 +0,0 @@ -../commonFiles/communication_funcs.c \ No newline at end of file diff --git a/slsDetectorSoftware/slsDetectorServer/communication_funcs.h b/slsDetectorSoftware/slsDetectorServer/communication_funcs.h deleted file mode 120000 index f220903b2..000000000 --- a/slsDetectorSoftware/slsDetectorServer/communication_funcs.h +++ /dev/null @@ -1 +0,0 @@ -../commonFiles/communication_funcs.h \ No newline at end of file diff --git a/slsDetectorSoftware/slsDetectorServer/programfpga.h b/slsDetectorSoftware/slsDetectorServer/programfpga.h deleted file mode 100755 index b37f521de..000000000 --- a/slsDetectorSoftware/slsDetectorServer/programfpga.h +++ /dev/null @@ -1,190 +0,0 @@ -#ifndef PROGRAM_FPGA_H -#define PROGRAM_FPGA_H - -#include "ansi.h" - -#include -#include // usleep -#include - - -/* global variables */ -#define CTRL_SRVR_INIT_TIME_US (300 * 1000) -int gpioDefined=0; -#define MTDSIZE 10 -char mtdvalue[MTDSIZE]; - - - -/** - * Define GPIO pins if not defined - */ -void defineGPIOpins(){ - if (!gpioDefined) { - //define the gpio pins - system("echo 7 > /sys/class/gpio/export"); - system("echo 9 > /sys/class/gpio/export"); - //define their direction - system("echo in > /sys/class/gpio/gpio7/direction"); - system("echo out > /sys/class/gpio/gpio9/direction"); - printf("gpio pins defined\n"); - gpioDefined = 1; - }else printf("gpio pins already defined earlier\n"); -} - -/** - * Notify FPGA to not touch flash - */ -void FPGAdontTouchFlash(){ - //tell FPGA to not touch flash - system("echo 0 > /sys/class/gpio/gpio9/value"); - //usleep(100*1000); -} - - -/** - * Notify FPGA to program from flash - */ -void FPGATouchFlash(){ - //tell FPGA to touch flash to program itself - system("echo 1 > /sys/class/gpio/gpio9/value"); -} - -/** - * Reset FPGA - */ -void resetFPGA(){ - cprintf(BLUE,"\n*** Reseting FPGA ***\n"); - FPGAdontTouchFlash(); - FPGATouchFlash(); - usleep(CTRL_SRVR_INIT_TIME_US); -} - -/** - * Erasing flash - */ -void eraseFlash(){ -#ifdef VERY_VERBOSE - printf("\nErasing Flash\n"); -#endif - char command[255]; - memset(command, 0, 255); - sprintf(command,"flash_eraseall %s",mtdvalue); - system(command); - printf("Flash erased\n"); -} - -/** - * Open the drive to copy program and - * notify FPGA not to touch the program - * @param filefp pointer to flash - * @return 0 for success, 1 for fail (cannot open file for writing program) - */ -int startWritingFPGAprogram(FILE** filefp){ -#ifdef VERY_VERBOSE - printf("\nStart Writing of FPGA program\n"); -#endif - - //getting the drive - char output[255]; - memset(output, 0, 255); - FILE* fp = popen("awk \'$4== \"\\\"bitfile(spi)\\\"\" {print $1}\' /proc/mtd", "r"); - if (fp == NULL) { - cprintf(RED,"popen returned NULL. Need that to get mtd drive.\n"); - return 1; - } - if (fgets(output, sizeof(output), fp) == NULL) { - cprintf(RED,"fgets returned NULL. Need that to get mtd drive.\n"); - return 1; - } - pclose(fp); - //cprintf(RED,"output: %s\n", output); - memset(mtdvalue, 0, MTDSIZE); - strcpy(mtdvalue,"/dev/"); - char* pch = strtok(output,":"); - if(pch == NULL){ - cprintf(RED,"Could not get mtd value\n"); - return 1; - } - strcat(mtdvalue,pch); - printf ("\nFlash drive found: %s\n",mtdvalue); - - FPGAdontTouchFlash(); - - //writing the program to flash - *filefp = fopen(mtdvalue, "w"); - if(*filefp == NULL){ - cprintf(RED,"Unable to open %s in write mode\n",mtdvalue); - return 1; - } - printf("Flash ready for writing\n"); - - return 0; -} - -/** - * When done writing the program, close file pointer and - * notify FPGA to pick up the program from flash - * @param filefp pointer to flash - */ -void stopWritingFPGAprogram(FILE* filefp){ -#ifdef VERY_VERBOSE - printf("\nStopping of writing FPGA program\n"); -#endif - - int wait = 0; - if(filefp!= NULL){ - fclose(filefp); - wait = 1; - } - - //touch and program - FPGATouchFlash(); - - if(wait){ -#ifdef VERY_VERBOSE - printf("Waiting for FPGA to program from flash\n"); -#endif - //waiting for success or done - char output[255]; - int res=0; - while(res == 0){ - FILE* sysFile = popen("cat /sys/class/gpio/gpio7/value", "r"); - fgets(output, sizeof(output), sysFile); - pclose(sysFile); - sscanf(output,"%d",&res); -#ifdef VERY_VERBOSE - printf("gpi07 returned %d\n",res); -#endif - } - } - printf("FPGA has picked up the program from flash\n\n"); -} - - -/** - * Write FPGA Program to flash - * @param fpgasrc source program - * @param fsize size of program - * @param filefp pointer to flash - * @return 0 for success, 1 for fail (cannot write) - */ -int writeFPGAProgram(char* fpgasrc, size_t fsize, FILE* filefp){ -#ifdef VERY_VERBOSE - printf("\nWriting of FPGA Program\n"); - cprintf(BLUE,"address of fpgasrc:%p\n",(void *)fpgasrc); - cprintf(BLUE,"fsize:%lu\n",fsize); - cprintf(BLUE,"pointer:%p\n",(void*)filefp); -#endif - - if(fwrite((void*)fpgasrc , sizeof(char) , fsize , filefp )!= fsize){ - cprintf(RED,"Could not write FPGA source to flash (size:%lu)\n", fsize); - return 1; - } -#ifdef VERY_VERBOSE - cprintf(BLUE, "program written to flash\n"); -#endif - return 0; -} - -#endif //PROGRAM_FPGA_H diff --git a/slsDetectorSoftware/slsDetectorServer/slsDetectorFunctionList.c b/slsDetectorSoftware/slsDetectorServer/slsDetectorFunctionList.c deleted file mode 100644 index c28ab462d..000000000 --- a/slsDetectorSoftware/slsDetectorServer/slsDetectorFunctionList.c +++ /dev/null @@ -1,838 +0,0 @@ -#ifdef SLS_DETECTOR_FUNCTION_LIST - -#include "slsDetectorFunctionList.h" -#include "slsDetectorServer_defs.h" - -#include -#include - - -const int nChans=NCHAN; -const int nChips=NCHIP; -const int nDacs=NDAC; -const int nAdcs=NADC; -const int allSelected=-2; -const int noneSelected=-1; - -sls_detector_module *detectorModules=NULL; -int *detectorChips=NULL; -int *detectorChans=NULL; -dacs_t *detectorDacs=NULL; -dacs_t *detectorAdcs=NULL; - -int nModY = NMAXMOD; -int nModX = NMAXMOD; -int dynamicRange= DYNAMIC_RANGE; -int dataBytes = NMAXMOD*NCHIP*NCHAN*2; -int masterMode = NO_MASTER; -int syncMode = NO_SYNCHRONIZATION; -int timingMode = AUTO_TIMING; - - - -enum detectorSettings thisSettings; -int sChan, sChip, sMod, sDac, sAdc; -int nModBoard; -extern int dataBytes; - - -int initializeDetectorStructure(){ - - int imod; - int n=getNModBoard(X)*getNModBoard(Y); -#ifdef VERBOSE - printf("Board is for %d modules\n",n); -#endif - detectorModules=malloc(n*sizeof(sls_detector_module)); - detectorChips=malloc(n*NCHIP*sizeof(int)); - detectorChans=malloc(n*NCHIP*NCHAN*sizeof(int)); - detectorDacs=malloc(n*NDAC*sizeof(int)); - detectorAdcs=malloc(n*NADC*sizeof(int)); -#ifdef VERBOSE - printf("modules from 0x%x to 0x%x\n",(unsigned int)(detectorModules), (unsigned int)(detectorModules+n)); - printf("chips from 0x%x to 0x%x\n",(unsigned int)(detectorChips), (unsigned int)(detectorChips+n*NCHIP)); - printf("chans from 0x%x to 0x%x\n",(unsigned int)(detectorChans), (unsigned int)(detectorChans+n*NCHIP*NCHAN)); - printf("dacs from 0x%x to 0x%x\n",(unsigned int)(detectorDacs), (unsigned int)(detectorDacs+n*NDAC)); - printf("adcs from 0x%x to 0x%x\n",(unsigned int)(detectorAdcs), (unsigned int)(detectorAdcs+n*NADC)); -#endif - for (imod=0; imoddacs=detectorDacs+imod*NDAC; - (detectorModules+imod)->adcs=detectorAdcs+imod*NADC; - (detectorModules+imod)->chipregs=detectorChips+imod*NCHIP; - (detectorModules+imod)->chanregs=detectorChans+imod*NCHIP*NCHAN; - (detectorModules+imod)->ndac=NDAC; - (detectorModules+imod)->nadc=NADC; - (detectorModules+imod)->nchip=NCHIP; - (detectorModules+imod)->nchan=NCHIP*NCHAN; - (detectorModules+imod)->module=imod; - (detectorModules+imod)->gain=0; - (detectorModules+imod)->offset=0; - (detectorModules+imod)->reg=0; - /* initialize registers, dacs, retrieve sn, adc values etc */ - } - thisSettings=UNINITIALIZED; - sChan=noneSelected; - sChip=noneSelected; - sMod=noneSelected; - sDac=noneSelected; - sAdc=noneSelected; - - return OK; -} - - - - - - -int setupDetector(){ - //testFpga(); - //testRAM(); - - //setSettings(GET_SETTINGS,-1); - //setFrames(1); - //setTrains(1); - //setExposureTime(1e6); - //setPeriod(1e9); - //setDelay(0); - //setGates(0); - - //setTiming(GET_EXTERNAL_COMMUNICATION_MODE); - //setMaster(GET_MASTER); - //setSynchronization(GET_SYNCHRONIZATION_MODE); - return OK; -} - - - - -int setNMod(int nm, enum dimension dim){ - return 1; -} - - - -int getNModBoard(enum dimension arg){ - return 1; -} - - - - - - - - -int64_t getModuleId(enum idMode arg, int imod){ - //DETECTOR_SERIAL_NUMBER - //DETECTOR_FIRMWARE_VERSION - return 0; -} - - - - -int64_t getDetectorId(enum idMode arg){ - //DETECTOR_SOFTWARE_VERSION defined in slsDetector_defs.h? - return 0; -} - - - - - -int moduleTest( enum digitalTestMode arg, int imod){ - //template testShiftIn from mcb_funcs.c - - //CHIP_TEST - //testShiftIn - //testShiftOut - //testShiftStSel - //testDataInOutMux - //testExtPulseMux - //testOutMux - //testFpgaMux - - return OK; -} - - - - - -int detectorTest( enum digitalTestMode arg){ - //templates from firmware_funcs.c - - //DETECTOR_FIRMWARE_TEST:testFpga() - //DETECTOR_MEMORY_TEST:testRAM() - //DETECTOR_BUS_TEST:testBus() - //DETECTOR_SOFTWARE_TEST:testFpga() - return OK; -} - - - - - - -double setDAC(enum dacIndex ind, double val, int imod){ - //template initDACbyIndexDACU from mcb_funcs.c - - //check that slsDetectorServer_funcs.c set_dac() has all the specific dac enums - //set dac and write to a register in fpga to remember dac value when server restarts - return 0; -} - - - -double getADC(enum dacIndex ind, int imod){ - //get adc value - return 0; -} - - - - -int setChannel(sls_detector_channel myChan){ - //template initChannelByNumber() from mcb_funcs.c - - return myChan.reg; -} - - -int getChannel(sls_detector_channel *myChan){ - //template getChannelbyNumber() from mcb_funcs.c - return FAIL; -} - - - -int setChip(sls_detector_chip myChip){ - //template initChipbyNumber() from mcb_funcs.c - return myChip.reg; -} - - -int getChip(sls_detector_chip *myChip){ - //template getChipbyNumber() from mcb_funcs.c - return FAIL; -} - -int setModule(sls_detector_module myChan){ - //template initModulebyNumber() from mcb_funcs.c - return OK; -} - -int getModule(sls_detector_module *myChan){ - //template getModulebyNumber() from mcb_funcs.c - return FAIL; -} - -int getThresholdEnergy(int imod){ - //template getThresholdEnergy() from mcb_funcs.c - //depending on settings - return FAIL; -} - - -int setThresholdEnergy(int thr, int imod){ - //template getThresholdEnergy() from mcb_funcs.c - //depending on settings - return FAIL; -} - - - -enum detectorSettings setSettings(enum detectorSettings sett, int imod){ - //template setSettings() from mcb_funcs.c - //reads the dac registers from fpga to confirm which settings, if weird, undefined - - return OK; -} - -int startStateMachine(){ - //template startStateMachine() from firmware_funcs.c - /* - fifoReset(); - now_ptr=(char*)ram_values; - //send start acquisition to fpga - */ - return FAIL; -} - - -int stopStateMachine(){ - //template stopStateMachine() from firmware_funcs.c - // send stop to fpga - //if status = busy after 500us, return FAIL - return FAIL; -} - - -int startReadOut(){ - //template startReadOut() from firmware_funcs.c - //send fpga start readout - return FAIL; -} - - -enum runStatus getRunStatus(){ - //template runState() from firmware_funcs.c - //get status from fpga - return ERROR; -} - - -char *readFrame(int *ret, char *mess){ - //template fifo_read_event() from firmware_funcs.c - //checks if state machine running and if fifo has data(look_at_me_reg) and accordingly reads frame - // memcpy(now_ptr, values, dataBytes); - //returns ptr to values - return NULL; -} - - -int64_t setTimer(enum timerIndex ind, int64_t val){ - //template setDelay() from firmware_funcs.c - //writes to reg - //FRAME_NUMBER - //ACQUISITION_TIME - //FRAME_PERIOD - //DELAY_AFTER_TRIGGER - //GATES_NUMBER - //PROBES_NUMBER - //CYCLES_NUMBER - return 0; -} - - -int64_t getTimeLeft(enum timerIndex ind){ - //template getDelay() from firmware_funcs.c - //reads from reg - //FRAME_NUMBER - //ACQUISITION_TIME - //FRAME_PERIOD - //DELAY_AFTER_TRIGGER - //GATES_NUMBER - //PROBES_NUMBER - //CYCLES_NUMBER - return -1; -} - - -int setDynamicRange(int dr){ - //template setDynamicRange() from firmware_funcs.c - return 0; -} - - -enum readOutFlags setReadOutFlags(enum readOutFlags val){ - //template setStoreInRAM from firmware_funcs.c - return -1; -} - - - - -int setROI(int n, ROI arg[], int *retvalsize, int *ret){ - return FAIL; -} - - - -int setSpeed(enum speedVariable arg, int val){ - //template setClockDivider() from firmware_funcs.c - //CLOCK_DIVIDER - //WAIT_STATES - //SET_SIGNAL_LENGTH - //TOT_CLOCK_DIVIDER - //TOT_DUTY_CYCLE - - //returns eg getClockDivider from firmware_funcs.c - return 0; -} - - - -int executeTrimming(enum trimMode mode, int par1, int par2, int imod){ - // template trim_with_noise from trimming_funcs.c - return FAIL; -} - - - - -int configureMAC(int ipad, long long int imacadd, long long int iservermacadd, int dtb){ - //detector specific. - return FAIL; -} - - -int loadImage(enum imageType index, char *imageVals){ - //detector specific. - return FAIL; -} - - -int readCounterBlock(int startACQ, char *counterVals){ - //detector specific. - return FAIL; -} - -int resetCounterBlock(int startACQ){ - //detector specific. - return FAIL; -} - -int startReceiver(int d){ - - return 0; -} - -int calibratePedestal(int frames){ - - return 0; -} - -int calculateDataBytes(){ - return 0; -} - -int getTotalNumberOfChannels(){return 0;} -int getTotalNumberOfChips(){return 0;} -int getTotalNumberOfModules(){return 0;} -int getNumberOfChannelsPerChip(){return 0;} -int getNumberOfChannelsPerModule(){return 0;} -int getNumberOfChipsPerModule(){return 0;} -int getNumberOfDACsPerModule(){return 0;} -int getNumberOfADCsPerModule(){return 0;} - - - - - - - -enum externalSignalFlag getExtSignal(int signalindex){ - //template getExtSignal from firmware_funcs.c - //return signals[signalindex]; - return -1; -} - - - - - -enum externalSignalFlag setExtSignal(int signalindex, enum externalSignalFlag flag){ - //template setExtSignal from firmware_funcs.c - - //in short..sets signals array, checks if agrees with timing mode, writes to fpga reg, calls synchronization and then settiming - /* - if (signalindex>=0 && signalindex<4) { - signals[signalindex]=flag; -#ifdef VERBOSE - printf("settings signal variable number %d to value %04x\n", signalindex, signals[signalindex]); -#endif - // if output signal, set it! - switch (flag) { - case GATE_IN_ACTIVE_HIGH: - case GATE_IN_ACTIVE_LOW: - if (timingMode==GATE_FIX_NUMBER || timingMode==GATE_WITH_START_TRIGGER)//timingMode = AUTO_TIMING by default and is set in setTiming() - setFPGASignal(signalindex,flag); //not implemented here, checks if flag within limits and writes to fpga reg - else - setFPGASignal(signalindex,SIGNAL_OFF); - break; - case TRIGGER_IN_RISING_EDGE: - case TRIGGER_IN_FALLING_EDGE: - if (timingMode==TRIGGER_EXPOSURE || timingMode==GATE_WITH_START_TRIGGER) - setFPGASignal(signalindex,flag); - else - setFPGASignal(signalindex,SIGNAL_OFF); - break; - case RO_TRIGGER_IN_RISING_EDGE: - case RO_TRIGGER_IN_FALLING_EDGE: - if (timingMode==BURST_TRIGGER) - setFPGASignal(signalindex,flag); - else - setFPGASignal(signalindex,SIGNAL_OFF); - break; - case MASTER_SLAVE_SYNCHRONIZATION: - setSynchronization(syncMode);//syncmode = NO_SYNCHRONIZATION by default and set with this function - break; - default: - setFPGASignal(signalindex,mode); - } - - setTiming(GET_EXTERNAL_COMMUNICATION_MODE); - } - */ - return getExtSignal(signalindex); -} - - - - - - -enum externalCommunicationMode setTiming( enum externalCommunicationMode arg){ - //template setTiming from firmware_funcs.c - //template getFPGASignal from firmware_funcs.c - - - //getFPGASignal(signalindex) used later on in this fucntion - //gets flag from fpga reg, checks if flag within limits, - //if( flag=SIGNAL_OFF and signals[signalindex]==MASTER_SLAVE_SYNCHRONIZATION), return -1, (ensures masterslaveflag !=off now) - //else return flag - - int ret=GET_EXTERNAL_COMMUNICATION_MODE; - //sets timingmode variable - //ensures that the signals are in acceptance with timing mode and according sets the timing mode - /* - int g=-1, t=-1, rot=-1; - - int i; - - switch (ti) { - case AUTO_TIMING: - timingMode=ti; - // disable all gates/triggers in except if used for master/slave synchronization - for (i=0; i<4; i++) { - if (getFPGASignal(i)>0 && getFPGASignal(i)=0 && t>=0 && rot<0) { - ret=GATE_WITH_START_TRIGGER; - } else if (g<0 && t>=0 && rot<0) { - ret=TRIGGER_EXPOSURE; - } else if (g>=0 && t<0 && rot<0) { - ret=GATE_FIX_NUMBER; - } else if (g<0 && t<0 && rot>0) { - ret=TRIGGER_READOUT; - } else if (g<0 && t<0 && rot<0) { - ret=AUTO_TIMING; - } - - */ - return ret; -} - - - -enum masterFlags setMaster(enum masterFlags arg){ - //template setMaster from firmware_funcs.c - /* - int i; - switch(f) { - case NO_MASTER: - // switch of gates or triggers - masterMode=NO_MASTER; - for (i=0; i<4; i++) { - if (signals[i]==MASTER_SLAVE_SYNCHRONIZATION) { - setFPGASignal(i,SIGNAL_OFF); - } - } - break; - case IS_MASTER: - // configure gate or trigger out - masterMode=IS_MASTER; - for (i=0; i<4; i++) { - if (signals[i]==MASTER_SLAVE_SYNCHRONIZATION) { - switch (syncMode) { - case NO_SYNCHRONIZATION: - setFPGASignal(i,SIGNAL_OFF); - break; - case MASTER_GATES: - setFPGASignal(i,GATE_OUT_ACTIVE_HIGH); - break; - case MASTER_TRIGGERS: - setFPGASignal(i,TRIGGER_OUT_RISING_EDGE); - break; - case SLAVE_STARTS_WHEN_MASTER_STOPS: - setFPGASignal(i,RO_TRIGGER_OUT_RISING_EDGE); - break; - default: - ; - } - } - } - break; - case IS_SLAVE: - // configure gate or trigger in - masterMode=IS_SLAVE; - for (i=0; i<4; i++) { - if (signals[i]==MASTER_SLAVE_SYNCHRONIZATION) { - switch (syncMode) { - case NO_SYNCHRONIZATION: - setFPGASignal(i,SIGNAL_OFF); - break; - case MASTER_GATES: - setFPGASignal(i,GATE_IN_ACTIVE_HIGH); - break; - case MASTER_TRIGGERS: - setFPGASignal(i,TRIGGER_IN_RISING_EDGE); - break; - case SLAVE_STARTS_WHEN_MASTER_STOPS: - setFPGASignal(i,TRIGGER_IN_RISING_EDGE); - break; - default: - ; - } - } - } - break; - default: - //do nothing - ; - } - - switch(masterMode) { - case NO_MASTER: - return NO_MASTER; - - - case IS_MASTER: - for (i=0; i<4; i++) { - if (signals[i]==MASTER_SLAVE_SYNCHRONIZATION) { - switch (syncMode) { - case NO_SYNCHRONIZATION: - return IS_MASTER; - case MASTER_GATES: - if (getFPGASignal(i)==GATE_OUT_ACTIVE_HIGH) - return IS_MASTER; - else - return NO_MASTER; - case MASTER_TRIGGERS: - if (getFPGASignal(i)==TRIGGER_OUT_RISING_EDGE) - return IS_MASTER; - else - return NO_MASTER; - case SLAVE_STARTS_WHEN_MASTER_STOPS: - if (getFPGASignal(i)==RO_TRIGGER_OUT_RISING_EDGE) - return IS_MASTER; - else - return NO_MASTER; - default: - return NO_MASTER; - } - - } - } - - case IS_SLAVE: - for (i=0; i<4; i++) { - if (signals[i]==MASTER_SLAVE_SYNCHRONIZATION) { - switch (syncMode) { - case NO_SYNCHRONIZATION: - return IS_SLAVE; - case MASTER_GATES: - if (getFPGASignal(i)==GATE_IN_ACTIVE_HIGH) - return IS_SLAVE; - else - return NO_MASTER; - case MASTER_TRIGGERS: - case SLAVE_STARTS_WHEN_MASTER_STOPS: - if (getFPGASignal(i)==TRIGGER_IN_RISING_EDGE) - return IS_SLAVE; - else - return NO_MASTER; - default: - return NO_MASTER; - } - - } - } - - } - */ - - return NO_MASTER; -} - - - -enum synchronizationMode setSynchronization(enum synchronizationMode arg){ - /* - int i; - - switch(s) { - case NO_SYNCHRONIZATION: - syncMode=NO_SYNCHRONIZATION; - for (i=0; i<4; i++) { - if (signals[i]==MASTER_SLAVE_SYNCHRONIZATION) { - setFPGASignal(i,SIGNAL_OFF); - } - } - break; - // disable external signals? - case MASTER_GATES: - // configure gate in or out - syncMode=MASTER_GATES; - for (i=0; i<4; i++) { - if (signals[i]==MASTER_SLAVE_SYNCHRONIZATION) { - if (masterMode==IS_MASTER) - setFPGASignal(i,GATE_OUT_ACTIVE_HIGH); - else if (masterMode==IS_SLAVE) - setFPGASignal(i,GATE_IN_ACTIVE_HIGH); - } - } - - break; - case MASTER_TRIGGERS: - // configure trigger in or out - syncMode=MASTER_TRIGGERS; - for (i=0; i<4; i++) { - if (signals[i]==MASTER_SLAVE_SYNCHRONIZATION) { - if (masterMode==IS_MASTER) - setFPGASignal(i,TRIGGER_OUT_RISING_EDGE); - else if (masterMode==IS_SLAVE) - setFPGASignal(i,TRIGGER_IN_RISING_EDGE); - } - } - break; - - - case SLAVE_STARTS_WHEN_MASTER_STOPS: - // configure trigger in or out - syncMode=SLAVE_STARTS_WHEN_MASTER_STOPS; - for (i=0; i<4; i++) { - if (signals[i]==MASTER_SLAVE_SYNCHRONIZATION) { - if (masterMode==IS_MASTER) - setFPGASignal(i,RO_TRIGGER_OUT_RISING_EDGE); - else if (masterMode==IS_SLAVE) - setFPGASignal(i,TRIGGER_IN_RISING_EDGE); - } - } - break; - - - default: - //do nothing - ; - } - - switch (syncMode) { - - case NO_SYNCHRONIZATION: - return NO_SYNCHRONIZATION; - - case MASTER_GATES: - - for (i=0; i<4; i++) { - if (signals[i]==MASTER_SLAVE_SYNCHRONIZATION) { - if (masterMode==IS_MASTER && getFPGASignal(i)==GATE_OUT_ACTIVE_HIGH) - return MASTER_GATES; - else if (masterMode==IS_SLAVE && getFPGASignal(i)==GATE_IN_ACTIVE_HIGH) - return MASTER_GATES; - } - } - return NO_SYNCHRONIZATION; - - case MASTER_TRIGGERS: - for (i=0; i<4; i++) { - if (signals[i]==MASTER_SLAVE_SYNCHRONIZATION) { - if (masterMode==IS_MASTER && getFPGASignal(i)==TRIGGER_OUT_RISING_EDGE) - return MASTER_TRIGGERS; - else if (masterMode==IS_SLAVE && getFPGASignal(i)==TRIGGER_IN_RISING_EDGE) - return MASTER_TRIGGERS; - } - } - return NO_SYNCHRONIZATION; - - case SLAVE_STARTS_WHEN_MASTER_STOPS: - for (i=0; i<4; i++) { - if (signals[i]==MASTER_SLAVE_SYNCHRONIZATION) { - if (masterMode==IS_MASTER && getFPGASignal(i)==RO_TRIGGER_OUT_RISING_EDGE) - return SLAVE_STARTS_WHEN_MASTER_STOPS; - else if (masterMode==IS_SLAVE && getFPGASignal(i)==TRIGGER_IN_RISING_EDGE) - return SLAVE_STARTS_WHEN_MASTER_STOPS; - } - } - return NO_SYNCHRONIZATION; - - default: - return NO_SYNCHRONIZATION; - - } - - - */ - return NO_SYNCHRONIZATION; -} - - - -#endif diff --git a/slsDetectorSoftware/slsDetectorServer/slsDetectorFunctionList.h b/slsDetectorSoftware/slsDetectorServer/slsDetectorFunctionList.h deleted file mode 100644 index b10be6845..000000000 --- a/slsDetectorSoftware/slsDetectorServer/slsDetectorFunctionList.h +++ /dev/null @@ -1,292 +0,0 @@ -#ifdef SLS_DETECTOR_FUNCTION_LIST -#ifndef SLS_DETECTOR_FUNCTION_LIST_H -#define SLS_DETECTOR_FUNCTION_LIST_H - -#include "sls_receiver_defs.h" -#include "slsDetectorServer_defs.h" // DAC_INDEX, ADC_INDEX, also include RegisterDefs.h - -#include -#include // FILE - - -/**************************************************** -This functions are used by the slsDetectroServer_funcs interface. -Here are the definitions, but the actual implementation should be done for each single detector. - -****************************************************/ - - -// basic tests -#if defined(EIGERD) || defined(JUNGFRAUD) || defined(GOTTHARD) -int isFirmwareCheckDone(); -int getFirmwareCheckResult(char** mess); -#endif - -void checkFirmwareCompatibility(int flag); -#if defined(MYTHEN3D) || defined(JUNGFRAUD) -int checkType(); -u_int32_t testFpga(void); -int testBus(void); -#endif - -#if defined(MYTHEND) || defined(JUNGFRAUD) || defined(MYTHEN3D) -int moduleTest( enum digitalTestMode arg, int imod); -#endif -#if defined(MYTHEND) || defined(JUNGFRAUD) -int detectorTest( enum digitalTestMode arg); -#endif - -// Ids -int64_t getDetectorId(enum idMode arg); -u_int64_t getFirmwareVersion(); -#ifdef MYTHEND -int64_t getModuleId(enum idMode arg, int imod); -#elif JUNGFRAUD -u_int64_t getFirmwareAPIVersion(); -u_int16_t getHardwareVersionNumber(); -u_int16_t getHardwareSerialNumber(); -#endif -#ifndef MYTHEN3D -u_int32_t getDetectorNumber(); -#endif -u_int64_t getDetectorMAC(); -u_int32_t getDetectorIP(); - - -// initialization -void initControlServer(); -void initStopServer(); -#ifdef EIGERD -void getModuleConfiguration(); -#endif - -// set up detector -void allocateDetectorStructureMemory(); -void setupDetector(); -#ifdef JUNGFRAUD -int setDefaultDacs(); -#endif - - -// advanced read/write reg -#ifndef EIGERD -extern u_int32_t writeRegister(u_int32_t offset, u_int32_t data); // blackfin.h -extern u_int32_t readRegister(u_int32_t offset); // blackfin.h -#else -uint32_t writeRegister(uint32_t offset, uint32_t data); -uint32_t readRegister(uint32_t offset); -#endif - - -// firmware functions (resets) -#if defined(MYTHEN3D) || defined(JUNGFRAUD) -int powerChip (int on); -void cleanFifos(); -void resetCore(); -void resetPeripheral(); -#endif -#ifdef MYTHEN3D -int getPhase(int i); -int configurePhase(int val, enum CLKINDEX i); -int configureFrequency(int val, int i); -#elif JUNGFRAUD -int autoCompDisable(int on); -int adcPhase(int st); -int getPhase(); -void configureASICTimer(); -#endif - -// parameters - nmod, dr, roi -int setNMod(int nm, enum dimension dim); // mythen specific, but for detector compatibility as a get -int getNModBoard(enum dimension arg); // mythen specific, but for detector compatibility as a get -int setDynamicRange(int dr); -#ifdef GOTTHARD -int setROI(int n, ROI arg[], int *retvalsize, int *ret); -#endif - -// parameters - readout -int setSpeed(enum speedVariable arg, int val); -#if defined(EIGERD) || defined(MYTHEND) -enum readOutFlags setReadOutFlags(enum readOutFlags val); -#endif -#ifdef MYTHEND -int executeTrimming(enum trimMode mode, int par1, int par2, int imod); -#endif - -// parameters - timer -#ifdef JUNGFRAUD -int selectStoragecellStart(int pos); -#endif -int64_t setTimer(enum timerIndex ind, int64_t val); -int64_t getTimeLeft(enum timerIndex ind); - - -// parameters - channel, chip, module, settings -#ifdef MYTHEND -int setChannel(sls_detector_channel myChan); -int getChannel(sls_detector_channel *myChan); -int setChip(sls_detector_chip myChip); -int getChip(sls_detector_chip *myChip); -#endif -#ifdef EIGERD -int setModule(sls_detector_module myMod, int delay); -#else -int setModule(sls_detector_module myMod); -#endif -int getModule(sls_detector_module *myMod); -enum detectorSettings setSettings(enum detectorSettings sett, int imod); -enum detectorSettings getSettings(); - - -// parameters - threshold -#if defined(MYTHEND) || defined(EIGERD) -int getThresholdEnergy(int imod); -int setThresholdEnergy(int ev, int imod); -#endif - -// parameters - dac, adc, hv -#if defined(MYTHEN3D) || defined(JUNGFRAUD) -void serializeToSPI(u_int32_t addr, u_int32_t val, u_int32_t csmask, int numbitstosend, u_int32_t clkmask, u_int32_t digoutmask, int digofset); -void initDac(int dacnum); -int voltageToDac(int value); -int dacToVoltage(unsigned int digital); -#endif -#ifdef MYTHEN3D -int setPower(enum DACINDEX ind, int val); -int powerToDac(int value, int chip); -int dacToPower(int value, int chip); -#endif - -#ifdef JUNGFRAUD -extern void setAdc(int addr, int val); // AD9257.h -#endif - -void setDAC(enum DACINDEX ind, int val, int imod, int mV, int retval[]); -#ifdef MYTHEN3D -int getVLimit(); -void setDacRegister(int dacnum,int dacvalue); -int getDacRegister(int dacnum); -#endif -#ifndef MYTHEN3D -int getADC(enum ADCINDEX ind, int imod); -#endif - -#if !defined(MYTHEN3D) && !defined(MYTHEND) -int setHighVoltage(int val); -#endif - - - -// parameters - timing, extsig -#ifdef MYTHEND -enum externalSignalFlag getExtSignal(int signalindex); -enum externalSignalFlag setExtSignal(int signalindex, enum externalSignalFlag flag); -#endif -enum externalCommunicationMode setTiming( enum externalCommunicationMode arg); - -// configure mac -#ifdef JUNGFRAUD -long int calcChecksum(int sourceip, int destip); -#endif -#if !defined(MYTHEN3D) && !defined(MYTHEND) -int configureMAC(uint32_t destip, uint64_t destmac, uint64_t sourcemac, uint32_t sourceip, uint32_t udpport, uint32_t udpport2, int ival); -#endif -#if defined(JUNGFRAUD) || defined(EIGERD) -int setDetectorPosition(int pos[]); -#endif - - -// very detector specific - -// gotthard specific - image, pedestal -#ifdef GOTTHARDD -int loadImage(enum imageType index, char *imageVals); -int readCounterBlock(int startACQ, char *counterVals); -int resetCounterBlock(int startACQ); -int calibratePedestal(int frames); - -// jungfrau specific - pll, flashing firmware -#elif defined(JUNGFRAUD) || defined(MYTHEN3D) -void resetPLL(); -u_int32_t setPllReconfigReg(u_int32_t reg, u_int32_t val); -void configurePll(); -int setThresholdTemperature(int val); -int setTemperatureControl(int val); -int setTemperatureEvent(int val); -extern void eraseFlash(); // programfpga.h -extern int startWritingFPGAprogram(FILE** filefp); // programfpga.h -extern void stopWritingFPGAprogram(FILE* filefp); // programfpga.h -extern int writeFPGAProgram(char* fpgasrc, size_t fsize, FILE* filefp); // programfpga.h - -// eiger specific - iodelay, 10g, pulse, rate, temp, activate, delay nw parameter -#elif EIGERD -int setIODelay(int val, int imod); -int enableTenGigabitEthernet(int val); -int setCounterBit(int val); -int pulsePixel(int n, int x, int y); -int pulsePixelNMove(int n, int x, int y); -int pulseChip(int n); -int64_t setRateCorrection(int64_t custom_tau_in_nsec); -int getRateCorrectionEnable(); -int getDefaultSettingsTau_in_nsec(); -void setDefaultSettingsTau_in_nsec(int t); -int64_t getCurrentTau(); -void setExternalGating(int enable[]); -int setAllTrimbits(int val); -int getAllTrimbits(); -int getBebFPGATemp(); -int activate(int enable); -#endif -#if defined(JUNGFRAUD) || defined(EIGERD) -int setNetworkParameter(enum NETWORKINDEX mode, int value); -#endif - - - - -// aquisition -#if defined(EIGERD) || defined(GOTTHARD) -int prepareAcquisition(); -#endif -int startStateMachine(); -#ifdef VIRTUAL -void* start_timer(void* arg); -#endif -int stopStateMachine(); -#ifdef EIGERD -int softwareTrigger(); -#endif -#ifndef JUNGFRAUD -int startReadOut(); -#endif -enum runStatus getRunStatus(); -void readFrame(int *ret, char *mess); -#ifdef JUNGFRAUD -u_int32_t runBusy(void); -#endif - - -//common -int copyModule(sls_detector_module *destMod, sls_detector_module *srcMod); -int calculateDataBytes(); -int getTotalNumberOfChannels(); -int getTotalNumberOfChips(); -int getTotalNumberOfModules(); -int getNumberOfChannelsPerModule(); -int getNumberOfChipsPerModule(); -int getNumberOfDACsPerModule(); -int getNumberOfADCsPerModule(); -#ifdef EIGERD -int getNumberOfGainsPerModule(); -int getNumberOfOffsetsPerModule(); -#endif -int getNumberOfChannelsPerChip(); - -// sync -enum masterFlags setMaster(enum masterFlags arg); -enum synchronizationMode setSynchronization(enum synchronizationMode arg); - - - -#endif -#endif diff --git a/slsDetectorSoftware/slsDetectorServer/slsDetectorServer.c b/slsDetectorSoftware/slsDetectorServer/slsDetectorServer.c deleted file mode 100755 index fd4b0e443..000000000 --- a/slsDetectorSoftware/slsDetectorServer/slsDetectorServer.c +++ /dev/null @@ -1,138 +0,0 @@ -/* A simple server in the internet domain using TCP - The port number is passed as an argument */ - -#include "sls_detector_defs.h" -#include "slsDetectorServer_defs.h" - -#include "communication_funcs.h" -#include "slsDetectorServer_funcs.h" - -#include -#include -#include -#include - -extern int sockfd; - - -void error(char *msg){ - perror(msg); -} - -int main(int argc, char *argv[]){ - int portno = DEFAULT_PORTNO; - int retval = OK; - int sd, fd; - int debugflag = 0; - int controlserver = 1; - - // if socket crash, ignores SISPIPE, prevents global signal handler - // subsequent read/write to socket gives error - must handle locally - signal(SIGPIPE, SIG_IGN); - - // circumvent the basic tests - { - int i; - for (i = 1; i < argc; ++i) { - if(!strcasecmp(argv[i],"-stopserver")) { - cprintf(BLUE,"Detected stop server\n"); - controlserver = 0; - } - else if(!strcasecmp(argv[i],"-devel")){ - cprintf(BLUE,"Detected developer mode\n"); - debugflag = 1; - } -#ifdef JUNGFRAUD - else if(!strcasecmp(argv[i],"-update")){ - cprintf(BLUE,"Detected update mode\n"); - debugflag = PROGRAMMING_MODE; - } -#endif - else if(strchr(argv[i],'-') != NULL) { - cprintf(RED,"cannot scan program argument %s\n", argv[1]); - return -1; - } - } - } - -#ifdef STOP_SERVER - char cmd[100]; - memset(cmd, 0, 100); -#endif - if (controlserver) { - portno = DEFAULT_PORTNO; - cprintf(BLUE, - "********************************************************\n" - "********* opening control server on port %d **********\n" - "********************************************************\n\n" - , portno); -#ifdef STOP_SERVER - { - int i; - for (i = 0; i < argc; ++i) - sprintf(cmd, "%s %s", cmd, argv[i]); - sprintf(cmd,"%s -stopserver&", cmd); - cprintf(BLUE,"cmd:%s\n", cmd); - system(cmd); - } -#endif - } else { - portno = DEFAULT_PORTNO+1; - cprintf(BLUE, - "********************************************************\n" - "*********** opening stop server on port %d ***********\n" - "********************************************************\n\n" - , portno); - } - - setModeFlag(debugflag); //defined in slsDetectorServer_funcs - init_detector(controlserver); //defined in slsDetectorServer_funcs - - sd=bindSocket(portno); //defined in communication_funcs - sockfd=sd; - if (getServerError(sd)) { //defined in communication_funcs - printf("server error!\n"); - return -1; - } - - /* assign function table */ - function_table(); //defined in slsDetectorServer_funcs -#ifdef VERBOSE - printf("function table assigned \n"); -#endif - - if (controlserver) - printf("\nControl Server Ready...\n\n"); - else - printf("\nStop Server Ready...\n\n"); - - /* waits for connection */ - while(retval!=GOODBYE) { -#ifdef VERBOSE - printf("\n"); -#endif -#ifdef VERY_VERBOSE - printf("Waiting for client call\n"); -#endif - fd=acceptConnection(sockfd); //defined in communication_funcs -#ifdef VERY_VERBOSE - printf("Conenction accepted\n"); -#endif - if (fd>0) { - retval=decode_function(fd); //defined in slsDetectorServer_funcs -#ifdef VERY_VERBOSE - printf("function executed\n"); -#endif - closeConnection(fd); //defined in communication_funcs -#ifdef VERY_VERBOSE - printf("connection closed\n"); -#endif - } - } - - exitServer(sockfd); //defined in communication_funcs - printf("Goodbye!\n"); - - return 0; -} - diff --git a/slsDetectorSoftware/slsDetectorServer/slsDetectorServer_defs.h b/slsDetectorSoftware/slsDetectorServer/slsDetectorServer_defs.h deleted file mode 100644 index 02e45004a..000000000 --- a/slsDetectorSoftware/slsDetectorServer/slsDetectorServer_defs.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - * slsDetectorServer_defs.h - * - * Created on: Jan 24, 2013 - * Author: l_maliakal_d - */ - -#ifndef SLSDETECTORSERVER_DEFS_H_ -#define SLSDETECTORSERVER_DEFS_H_ - -#include "sls_detector_defs.h" -#include - -/** This is only an example file!!! */ - -/* -#define GOODBYE (-200) -enum DAC_INDEX {examplesdac} - - Hardware Definitions -#define NMAXMOD (1) -#define NMOD (1) -#define NCHAN (256 * 256) -#define NCHIP (4) -#define NADC (0) -#define NDAC (16) -#define NGAIN (0) -#define NOFFSET (0) -*/ - -#endif /* SLSDETECTORSERVER_DEFS_H_ */ diff --git a/slsDetectorSoftware/slsDetectorServer/slsDetectorServer_funcs.c b/slsDetectorSoftware/slsDetectorServer/slsDetectorServer_funcs.c deleted file mode 100755 index 8cd09f2b1..000000000 --- a/slsDetectorSoftware/slsDetectorServer/slsDetectorServer_funcs.c +++ /dev/null @@ -1,5928 +0,0 @@ - -#include "sls_detector_defs.h" -#include "slsDetectorServer_funcs.h" -#include "slsDetectorFunctionList.h" -#include "communication_funcs.h" -#include "slsDetectorServer_defs.h" - -#include -#include -#include - - -// Global variables -extern int lockStatus; -extern char lastClientIP[INET_ADDRSTRLEN]; -extern char thisClientIP[INET_ADDRSTRLEN]; -extern int differentClients; - -//defined in the detector specific Makefile -#ifdef MYTHEND -const enum detectorType myDetectorType=MYTHEN; -#elif GOTTHARDD -const enum detectorType myDetectorType=GOTTHARD; -#elif EIGERD -const enum detectorType myDetectorType=EIGER; -#elif PICASSOD -const enum detectorType myDetectorType=PICASSO; -#elif MOENCHD -const enum detectorType myDetectorType=MOENCH; -#elif JUNGFRAUD -const enum detectorType myDetectorType=JUNGFRAU; -#elif MYTHEN3D -const enum detectorType myDetectorType=MYTHEN3; -#else -const enum detectorType myDetectorType=GENERIC; -#endif - -int sockfd; // (updated in slsDetectorServer) as extern -int (*flist[NUM_DET_FUNCTIONS])(int); -char mess[MAX_STR_LENGTH]; -int dataBytes = 10; -int isControlServer = 0; -int debugflag = 0; -#ifdef EIGERD -uint32_t dhcpipad = 0; -#endif - -/* initialization functions */ - -int printSocketReadError() { - cprintf(BG_RED, "Error reading from socket. Possible socket crash\n"); - return FAIL; -} - -void setModeFlag(int flag) { - debugflag = flag; -} - -void basictests() { -#ifdef SLS_DETECTOR_FUNCTION_LIST - checkFirmwareCompatibility(debugflag); -#endif -} - - -void init_detector(int controlserver) { -#ifdef VIRTUAL - printf("This is a VIRTUAL detector\n"); -#endif - -#ifdef SLS_DETECTOR_FUNCTION_LIST - if (controlserver) { - isControlServer = 1; - basictests(); -#ifdef JUNGFRAUD - if (debugflag != PROGRAMMING_MODE) -#endif - initControlServer(); -#ifdef EIGERD - dhcpipad = getDetectorIP(); -#endif - } - else initStopServer(); -#endif - strcpy(mess,"dummy message"); - strcpy(lastClientIP,"none"); - strcpy(thisClientIP,"none1"); - lockStatus=0; -} - - -int decode_function(int file_des) { - int fnum,n; - int ret=FAIL; -#ifdef VERBOSE - printf( "\nreceive data\n"); -#endif - n = receiveData(file_des,&fnum,sizeof(fnum),INT32); - if (n <= 0) { -#ifdef VERBOSE - printf("ERROR reading from socket %d, %d %d (%s)\n", n, fnum, file_des, getFunctionName((enum detFuncs)fnum)); -#endif - return FAIL; - } -#ifdef VERBOSE - else - printf("size of data received %d\n",n); -#endif - -#ifdef VERBOSE - printf(" calling function fnum=%d, (%s) located at 0x%x\n", fnum, getFunctionName((enum detFuncs)fnum), (unsigned int)flist[fnum]); -#endif -#ifdef JUNGFRAUD - if ((debugflag == PROGRAMMING_MODE) && - ((fnum != F_PROGRAM_FPGA) && (fnum != F_GET_DETECTOR_TYPE) && - (fnum != F_RESET_FPGA) && (fnum != F_UPDATE_CLIENT) && (fnum != F_CHECK_VERSION))) { - sprintf(mess,"This Function %s cannot be executed. ", getFunctionName((enum detFuncs)fnum)); - ret=(M_nofuncMode)(file_des); - } else -#endif - if (fnum<0 || fnum>=NUM_DET_FUNCTIONS) { - cprintf(BG_RED,"Unknown function enum %d\n", fnum); - ret=(M_nofunc)(file_des); - }else - ret=(*flist[fnum])(file_des); - if (ret == FAIL) - cprintf(RED, "Error executing the function = %d (%s)\n", fnum, getFunctionName((enum detFuncs)fnum)); - return ret; -} - - -const char* getFunctionName(enum detFuncs func) { - switch (func) { - case F_EXEC_COMMAND: return "F_EXEC_COMMAND"; - case F_GET_ERROR: return "F_GET_ERROR"; - case F_GET_DETECTOR_TYPE: return "F_GET_DETECTOR_TYPE"; - case F_SET_NUMBER_OF_MODULES: return "F_SET_NUMBER_OF_MODULES"; - case F_GET_MAX_NUMBER_OF_MODULES: return "F_GET_MAX_NUMBER_OF_MODULES"; - case F_SET_EXTERNAL_SIGNAL_FLAG: return "F_SET_EXTERNAL_SIGNAL_FLAG"; - case F_SET_EXTERNAL_COMMUNICATION_MODE: return "F_SET_EXTERNAL_COMMUNICATION_MODE"; - case F_GET_ID: return "F_GET_ID"; - case F_DIGITAL_TEST: return "F_DIGITAL_TEST"; - case F_ANALOG_TEST: return "F_ANALOG_TEST"; - case F_ENABLE_ANALOG_OUT: return "F_ENABLE_ANALOG_OUT"; - case F_CALIBRATION_PULSE: return "F_CALIBRATION_PULSE"; - case F_SET_DAC: return "F_SET_DAC"; - case F_GET_ADC: return "F_GET_ADC"; - case F_WRITE_REGISTER: return "F_WRITE_REGISTER"; - case F_READ_REGISTER: return "F_READ_REGISTER"; - case F_WRITE_MEMORY: return "F_WRITE_MEMORY"; - case F_READ_MEMORY: return "F_READ_MEMORY"; - case F_SET_CHANNEL: return "F_SET_CHANNEL"; - case F_GET_CHANNEL: return "F_GET_CHANNEL"; - case F_SET_ALL_CHANNELS: return "F_SET_ALL_CHANNELS"; - case F_SET_CHIP: return "F_SET_CHIP"; - case F_GET_CHIP: return "F_GET_CHIP"; - case F_SET_ALL_CHIPS: return "F_SET_ALL_CHIPS"; - case F_SET_MODULE: return "F_SET_MODULE"; - case F_GET_MODULE: return "F_GET_MODULE"; - case F_SET_ALL_MODULES: return "F_SET_ALL_MODULES"; - case F_SET_SETTINGS: return "F_SET_SETTINGS"; - case F_GET_THRESHOLD_ENERGY: return "F_GET_THRESHOLD_ENERGY"; - case F_SET_THRESHOLD_ENERGY: return "F_SET_THRESHOLD_ENERGY"; - case F_START_ACQUISITION: return "F_START_ACQUISITION"; - case F_STOP_ACQUISITION: return "F_STOP_ACQUISITION"; - case F_START_READOUT: return "F_START_READOUT"; - case F_GET_RUN_STATUS: return "F_GET_RUN_STATUS"; - case F_START_AND_READ_ALL: return "F_START_AND_READ_ALL"; - case F_READ_FRAME: return "F_READ_FRAME"; - case F_READ_ALL: return "F_READ_ALL"; - case F_SET_TIMER: return "F_SET_TIMER"; - case F_GET_TIME_LEFT: return "F_GET_TIME_LEFT"; - case F_SET_DYNAMIC_RANGE: return "F_SET_DYNAMIC_RANGE"; - case F_SET_READOUT_FLAGS: return "F_SET_READOUT_FLAGS"; - case F_SET_ROI: return "F_SET_ROI"; - case F_SET_SPEED: return "F_SET_SPEED"; - case F_EXECUTE_TRIMMING: return "F_EXECUTE_TRIMMING"; - case F_EXIT_SERVER: return "F_EXIT_SERVER"; - case F_LOCK_SERVER: return "F_LOCK_SERVER"; - case F_GET_LAST_CLIENT_IP: return "F_GET_LAST_CLIENT_IP"; - case F_SET_PORT: return "F_SET_PORT"; - case F_UPDATE_CLIENT: return "F_UPDATE_CLIENT"; - case F_CONFIGURE_MAC: return "F_CONFIGURE_MAC"; - case F_LOAD_IMAGE: return "F_LOAD_IMAGE"; - case F_SET_MASTER: return "F_SET_MASTER"; - case F_SET_SYNCHRONIZATION_MODE: return "F_SET_SYNCHRONIZATION_MODE"; - case F_READ_COUNTER_BLOCK: return "F_READ_COUNTER_BLOCK"; - case F_RESET_COUNTER_BLOCK: return "F_RESET_COUNTER_BLOCK"; - case F_CALIBRATE_PEDESTAL: return "F_CALIBRATE_PEDESTAL"; - case F_ENABLE_TEN_GIGA: return "F_ENABLE_TEN_GIGA"; - case F_SET_ALL_TRIMBITS: return "F_SET_ALL_TRIMBITS"; - case F_SET_CTB_PATTERN: return "F_SET_CTB_PATTERN"; - case F_WRITE_ADC_REG: return "F_WRITE_ADC_REG"; - case F_SET_COUNTER_BIT: return "F_SET_COUNTER_BIT"; - case F_PULSE_PIXEL: return "F_PULSE_PIXEL"; - case F_PULSE_PIXEL_AND_MOVE: return "F_PULSE_PIXEL_AND_MOVE"; - case F_PULSE_CHIP: return "F_PULSE_CHIP"; - case F_SET_RATE_CORRECT: return "F_SET_RATE_CORRECT"; - case F_GET_RATE_CORRECT: return "F_GET_RATE_CORRECT"; - case F_SET_NETWORK_PARAMETER: return "F_SET_NETWORK_PARAMETER"; - case F_PROGRAM_FPGA: return "F_PROGRAM_FPGA"; - case F_RESET_FPGA: return "F_RESET_FPGA"; - case F_POWER_CHIP: return "F_POWER_CHIP"; - case F_ACTIVATE: return "F_ACTIVATE"; - case F_PREPARE_ACQUISITION: return "F_PREPARE_ACQUISITION"; - case F_CLEANUP_ACQUISITION: return "F_CLEANUP_ACQUISITION"; - case F_THRESHOLD_TEMP: return "F_THRESHOLD_TEMP"; - case F_TEMP_CONTROL: return "F_TEMP_CONTROL"; - case F_TEMP_EVENT: return "F_TEMP_EVENT"; - case F_AUTO_COMP_DISABLE: return "F_AUTO_COMP_DISABLE"; - case F_STORAGE_CELL_START: return "F_STORAGE_CELL_START"; - case F_CHECK_VERSION: return "F_CHECK_VERSION"; - case F_SOFTWARE_TRIGGER: return "F_SOFTWARE_TRIGGER"; - - default: return "Unknown Function"; - } -} - -void function_table() { - flist[F_EXEC_COMMAND] = &exec_command; - flist[F_GET_ERROR] = &get_error; - flist[F_GET_DETECTOR_TYPE] = &get_detector_type; - flist[F_SET_NUMBER_OF_MODULES] = &set_number_of_modules; - flist[F_GET_MAX_NUMBER_OF_MODULES] = &get_max_number_of_modules; - flist[F_SET_EXTERNAL_SIGNAL_FLAG] = &set_external_signal_flag; - flist[F_SET_EXTERNAL_COMMUNICATION_MODE] = &set_external_communication_mode; - flist[F_GET_ID] = &get_id; - flist[F_DIGITAL_TEST] = &digital_test; - flist[F_ANALOG_TEST] = &analog_test; - flist[F_ENABLE_ANALOG_OUT] = &enable_analog_out; - flist[F_CALIBRATION_PULSE] = &calibration_pulse; - flist[F_SET_DAC] = &set_dac; - flist[F_GET_ADC] = &get_adc; - flist[F_WRITE_REGISTER] = &write_register; - flist[F_READ_REGISTER] = &read_register; - flist[F_WRITE_MEMORY] = &write_memory; - flist[F_READ_MEMORY] = &read_memory; - flist[F_SET_CHANNEL] = &set_channel; - flist[F_GET_CHANNEL] = &get_channel; - flist[F_SET_ALL_CHANNELS] = &set_all_channels; - flist[F_SET_CHIP] = &set_chip; - flist[F_GET_CHIP] = &get_chip; - flist[F_SET_ALL_CHIPS] = &set_all_chips; - flist[F_SET_MODULE] = &set_module; - flist[F_GET_MODULE] = &get_module; - flist[F_SET_ALL_MODULES] = &set_all_modules; - flist[F_SET_SETTINGS] = &set_settings; - flist[F_GET_THRESHOLD_ENERGY] = &get_threshold_energy; - flist[F_SET_THRESHOLD_ENERGY] = &set_threshold_energy; - flist[F_START_ACQUISITION] = &start_acquisition; - flist[F_STOP_ACQUISITION] = &stop_acquisition; - flist[F_START_READOUT] = &start_readout; - flist[F_GET_RUN_STATUS] = &get_run_status; - flist[F_START_AND_READ_ALL] = &start_and_read_all; - flist[F_READ_FRAME] = &read_frame; - flist[F_READ_ALL] = &read_all; - flist[F_SET_TIMER] = &set_timer; - flist[F_GET_TIME_LEFT] = &get_time_left; - flist[F_SET_DYNAMIC_RANGE] = &set_dynamic_range; - flist[F_SET_READOUT_FLAGS] = &set_readout_flags; - flist[F_SET_ROI] = &set_roi; - flist[F_SET_SPEED] = &set_speed; - flist[F_EXECUTE_TRIMMING] = &execute_trimming; - flist[F_EXIT_SERVER] = &exit_server; - flist[F_LOCK_SERVER] = &lock_server; - flist[F_GET_LAST_CLIENT_IP] = &get_last_client_ip; - flist[F_SET_PORT] = &set_port; - flist[F_UPDATE_CLIENT] = &update_client; - flist[F_CONFIGURE_MAC] = &configure_mac; - flist[F_LOAD_IMAGE] = &load_image; - flist[F_SET_MASTER] = &set_master; - flist[F_SET_SYNCHRONIZATION_MODE] = &set_synchronization; - flist[F_READ_COUNTER_BLOCK] = &read_counter_block; - flist[F_RESET_COUNTER_BLOCK] = &reset_counter_block; - flist[F_CALIBRATE_PEDESTAL] = &calibrate_pedestal; - flist[F_ENABLE_TEN_GIGA] = &enable_ten_giga; - flist[F_SET_ALL_TRIMBITS] = &set_all_trimbits; - flist[F_SET_CTB_PATTERN] = &set_ctb_pattern; - flist[F_WRITE_ADC_REG] = &write_adc_register; - flist[F_SET_COUNTER_BIT] = &set_counter_bit; - flist[F_PULSE_PIXEL] = &pulse_pixel; - flist[F_PULSE_PIXEL_AND_MOVE] = &pulse_pixel_and_move; - flist[F_PULSE_CHIP] = &pulse_chip; - flist[F_SET_RATE_CORRECT] = &set_rate_correct; - flist[F_GET_RATE_CORRECT] = &get_rate_correct; - flist[F_SET_NETWORK_PARAMETER] = &set_network_parameter; - flist[F_PROGRAM_FPGA] = &program_fpga; - flist[F_RESET_FPGA] = &reset_fpga; - flist[F_POWER_CHIP] = &power_chip; - flist[F_ACTIVATE] = &set_activate; - flist[F_PREPARE_ACQUISITION] = &prepare_acquisition; - flist[F_CLEANUP_ACQUISITION] = &cleanup_acquisition; - flist[F_THRESHOLD_TEMP] = &threshold_temp; - flist[F_TEMP_CONTROL] = &temp_control; - flist[F_TEMP_EVENT] = &temp_event; - flist[F_AUTO_COMP_DISABLE] = &auto_comp_disable; - flist[F_STORAGE_CELL_START] = &storage_cell_start; - flist[F_CHECK_VERSION] = &check_version; - flist[F_SOFTWARE_TRIGGER] = &software_trigger; - - // check - if (NUM_DET_FUNCTIONS >= TOO_MANY_FUNCTIONS_DEFINED) { - cprintf(BG_RED,"The last detector function enum has reached its limit\nGoodbye!\n"); - exit(EXIT_FAILURE); - } - -#ifdef VERYVERBOSE - { - int i=0; - for (i = 0; i < NUM_DET_FUNCTIONS ; i++) { - printf("function fnum=%d, (%s) located at 0x%x\n", i, getFunctionName((enum detFuncs)i), (unsigned int)flist[i]); - } - } -#endif -} - - -int M_nofunc(int file_des){ - int ret=FAIL,ret1=FAIL; - int n=0; - - //to receive any arguments - while (n > 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - - sprintf(mess,"Unrecognized Function. Please do not proceed.\n"); - cprintf(BG_RED,"Error: %s",mess); - n = sendData(file_des,&ret1,sizeof(ret1),INT32); - n = sendData(file_des,mess,sizeof(mess),OTHER); - - // return ok / fail - return ret; -} - - - -int M_nofuncMode(int file_des){ - int ret=FAIL,ret1=FAIL; - int n=0; - //to receive any arguments - while (n > 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - - strcat(mess, "On-board detector server in update mode. Restart detector server in normal mode (without any arguments) to continue.\n"); - cprintf(BG_RED,"Error: %s",mess); - n = sendData(file_des,&ret1,sizeof(ret1),INT32); - n = sendData(file_des,mess,sizeof(mess),OTHER); // mess is defined at function call - - // return ok / fail - return ret; -} - - - -/* functions called by client */ - - - -int exec_command(int file_des) { - int ret=OK,ret1=OK; - int n=0; - char cmd[MAX_STR_LENGTH]=""; - int sysret=0; - - // receive arguments - n = receiveData(file_des,cmd,MAX_STR_LENGTH,OTHER); - if (n < 0) return printSocketReadError(); - - // execute action if the arguments correctly arrived -#ifdef VERBOSE - printf("executing command %s\n", cmd); -#endif - if (differentClients && lockStatus) { - ret = FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - cprintf(RED, "Warning: %s", mess); - } else { - sysret=system(cmd); - //should be replaced by popen - if (sysret==0) { - sprintf(mess,"Succeeded\n"); - } else { - ret = FAIL; - sprintf(mess,"Executing Command failed\n"); - cprintf(RED, "Warning: %s", mess); - } - } - - ret1=ret; - n = sendData(file_des,&ret1,sizeof(ret),INT32); - n = sendData(file_des,mess,MAX_STR_LENGTH,OTHER); - - // return ok / fail - return ret; -} - - - -int get_error(int file_des) { - int ret=FAIL,ret1=FAIL; - int n=0; - sprintf(mess,"Function (Get Error) is not implemented for this detector\n"); - cprintf(RED, "Error: %s", mess); - - //to receive any arguments - while (n > 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - - n = sendData(file_des,&ret1,sizeof(ret),INT32); - n = sendData(file_des,mess,MAX_STR_LENGTH,OTHER); - - // return ok / fail - return ret; -} - - - -int get_detector_type(int file_des) { - int ret=OK,ret1=OK; - int n=0; - enum detectorType retval=-1; - - // execute action - retval=myDetectorType; -#ifdef VERBOSE - printf("Returning detector type %d\n",retval); -#endif - - if (differentClients) - ret=FORCE_UPDATE; - - // send ok / fail - n += sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - n += sendData(file_des,&retval,sizeof(retval),INT32); - - // return ok / fail - return ret; - - -} - - - - -int set_number_of_modules(int file_des) { - int ret=OK,ret1=OK; - int n=0; - int retval=0; - int arg[2]={-1,-1}; - sprintf(mess,"set number of modules failed\n"); - - // receive arguments - n = receiveData(file_des,&arg,sizeof(arg),INT32); - if (n < 0) return printSocketReadError(); - enum dimension dim=arg[0]; - int nm=arg[1]; - - // execute action -#ifdef VERBOSE - printf("Setting the number of modules in dimension %d to %d\n",dim,nm ); -#endif - if (lockStatus && differentClients && nm!=GET_FLAG) { - ret = FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - cprintf(RED, "Warning: %s", mess); - } -#ifdef SLS_DETECTOR_FUNCTION_LIST - else { - retval=setNMod(nm, dim); - dataBytes=calculateDataBytes(); - } -#endif - - if (retval==nm || nm==GET_FLAG) { - ret=OK; - if (differentClients) - ret=FORCE_UPDATE; - } else - ret=FAIL; - - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - if (ret!=FAIL) { - n += sendData(file_des,&retval,sizeof(retval),INT32); - } else { - n += sendData(file_des,mess,sizeof(mess),OTHER); - } - - // return ok / fail - return ret; -} - - - - -int get_max_number_of_modules(int file_des) { - int ret=OK,ret1=OK; - int n=0; - int retval=-1; - enum dimension arg=0; - sprintf(mess,"get max number of modules failed\n"); - - // receive arguments - n = receiveData(file_des,&arg,sizeof(arg),INT32); - if (n < 0) return printSocketReadError(); - - // execute action -#ifdef VERBOSE - printf("Getting the max number of modules in dimension %d \n",arg); -#endif -#ifdef SLS_DETECTOR_FUNCTION_LIST - retval=getNModBoard(arg); -#endif -#ifdef VERBOSE - printf("Max number of module in dimension %d is %d\n",arg,retval ); -#endif - if (differentClients && ret==OK) { - ret=FORCE_UPDATE; - } - - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - if (ret!=FAIL) { - n += sendData(file_des,&retval,sizeof(retval),INT32); - } else { - n += sendData(file_des,mess,sizeof(mess),OTHER); - } - - // return ok / fail - return ret; -} - - - - -int set_external_signal_flag(int file_des) { - int ret=OK,ret1=OK; - int n=0; - enum externalSignalFlag retval=GET_EXTERNAL_SIGNAL_FLAG; - sprintf(mess,"set external signal flag failed\n"); - -#ifndef MYTHEND - //to receive any arguments - while (n > 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - ret = FAIL; - sprintf(mess,"Function (Set External Signal Flag) is not implemented for this detector\n"); - cprintf(RED, "%s", mess); -#else - - // receive arguments - int arg[2]={-1,-1}; - n = receiveData(file_des,&arg,sizeof(arg),INT32); - if (n < 0) return printSocketReadError(); - - int signalindex=arg[0]; - enum externalSignalFlag flag=arg[1]; - - // execute action - if (lockStatus && differentClients && flag!=GET_EXTERNAL_SIGNAL_FLAG) { - ret = FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - cprintf(RED, "Warning: %s", mess); - } - -#ifdef SLS_DETECTOR_FUNCTION_LIST - else{ -#ifdef VERBOSE - printf("Setting external signal %d to flag %d\n",signalindex,flag); -#endif - switch (flag) { - case GET_EXTERNAL_SIGNAL_FLAG: - retval=getExtSignal(signalindex); - break; - default: - retval=setExtSignal(signalindex,flag); - if (retval!=flag) { - ret=FAIL; - sprintf(mess,"External signal %d flag should be 0x%04x but is 0x%04x\n", signalindex, flag, retval); - cprintf(RED, "%s", mess); - } - break; - } -#ifdef VERBOSE - printf("Set to flag %d\n",retval); -#endif - } -#endif - if (ret==OK && differentClients) - ret=FORCE_UPDATE; -#endif - - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - if (ret!=FAIL) { - n += sendData(file_des,&retval,sizeof(retval),INT32); - } else { - n += sendData(file_des,mess,sizeof(mess),OTHER); - } - - // return ok / fail - return ret; - -} - - -int set_external_communication_mode(int file_des) { - int ret=OK,ret1=OK; - int n=0; - enum externalCommunicationMode arg=GET_EXTERNAL_COMMUNICATION_MODE; - enum externalCommunicationMode retval=GET_EXTERNAL_COMMUNICATION_MODE; - sprintf(mess,"set external communication mode failed\n"); - - // receive arguments - n = receiveData(file_des,&arg,sizeof(arg),INT32); - if (n < 0) return printSocketReadError(); - - // execute action -#ifdef VERBOSE - printf("Setting external communication mode to %d\n", arg); -#endif -#ifdef SLS_DETECTOR_FUNCTION_LIST - switch(arg){ -#ifdef EIGERD - case GET_EXTERNAL_COMMUNICATION_MODE: - case AUTO_TIMING: - case TRIGGER_EXPOSURE: - case GATE_FIX_NUMBER: - case BURST_TRIGGER: -#elif JUNGFRAUD - case GET_EXTERNAL_COMMUNICATION_MODE: - case AUTO_TIMING: - case TRIGGER_EXPOSURE: -#endif - retval=setTiming(arg); - break; - default: - ret = FAIL; - sprintf(mess,"Timing mode (%d) is not implemented for this detector\n",(int)arg); - cprintf(RED, "Warning: %s", mess); - break; - } -#ifdef VERBOSE - if(ret==OK) - printf("retval:%d\n",retval); -#endif - if (ret==OK && differentClients==1) - ret=FORCE_UPDATE; - -#endif - - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - if (ret!=FAIL) { - n += sendData(file_des,&retval,sizeof(retval),INT32); - } else { - n += sendData(file_des,mess,sizeof(mess),OTHER); - } - - // return ok / fail - return ret; -} - - - - -int get_id(int file_des) { - int ret=OK,ret1=OK; - int n=0; - enum idMode arg=0; - int imod=-1; - int64_t retval=-1; - sprintf(mess,"get id failed\n"); - - // receive arguments - n = receiveData(file_des,&arg,sizeof(arg),INT32); - if (n < 0) return printSocketReadError(); - - if (arg == MODULE_SERIAL_NUMBER) { - n = receiveData(file_des,&imod,sizeof(imod),INT32); - if (n < 0) return printSocketReadError(); - } - - // execute action -#ifdef VERBOSE - printf("Getting id %d\n", arg); -#endif - -#ifdef SLS_DETECTOR_FUNCTION_LIST - switch (arg) { -#ifdef MYTHEND - case MODULE_SERIAL_NUMBER: - case MODULE_FIRMWARE_VERSION: -#ifdef VERBOSE - printf("of module %d\n", imod); -#endif - - if (imod>=0 && imod 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - ret = FAIL; - sprintf(mess,"Function (Digital Test) is not implemented for this detector\n"); - cprintf(RED, "%s", mess); -#else - - enum digitalTestMode arg=0; - int imod=-1; - int ival=-1; - - // receive arguments - n = receiveData(file_des,&arg,sizeof(arg),INT32); - if (n < 0) return printSocketReadError(); - - if (arg == CHIP_TEST) { - n = receiveData(file_des,&imod,sizeof(imod),INT32); - if (n < 0) return printSocketReadError(); - } - - if (arg == DIGITAL_BIT_TEST) { - n = receiveData(file_des,&ival,sizeof(ival),INT32); - if (n < 0) return printSocketReadError(); - } - - // execute action - if (differentClients && lockStatus) { - ret = FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - cprintf(RED, "Warning: %s", mess); - } else { -#ifdef VERBOSE - printf("Digital test mode %d\n",arg ); -#endif -#ifdef SLS_DETECTOR_FUNCTION_LIST - switch (arg) { - -#ifdef GOTTHARD - case DIGITAL_BIT_TEST: - retval=0; - break; - -#elif MYTHEND - case CHIP_TEST: -#ifdef VERBOSE - printf("of module %d\n", imod); -#endif - if (imod>=0 && imod 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - - n = sendData(file_des,&ret1,sizeof(ret),INT32); - n = sendData(file_des,mess,MAX_STR_LENGTH,OTHER); - - // return ok / fail - return ret; -} - - - -int enable_analog_out(int file_des) { - int ret=FAIL,ret1=FAIL; - int n=0; - sprintf(mess,"Function (Enable Analog Out) is not implemented for this detector\n"); - cprintf(RED, "Error: %s", mess); - - //to receive any arguments - while (n > 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - - n = sendData(file_des,&ret1,sizeof(ret),INT32); - n = sendData(file_des,mess,MAX_STR_LENGTH,OTHER); - - // return ok / fail - return ret; -} - - - -int calibration_pulse(int file_des) { - int ret=FAIL,ret1=FAIL; - int n=0; - sprintf(mess,"Function (Calibration Pulse) is not implemented for this detector\n"); - cprintf(RED, "Error: %s", mess); - - //to receive any arguments - while (n > 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - - n = sendData(file_des,&ret1,sizeof(ret),INT32); - n = sendData(file_des,mess,MAX_STR_LENGTH,OTHER); - - // return ok / fail - return ret; -} - - - - -int set_dac(int file_des) { - int ret=OK,ret1=OK; - int n=0; - int arg[3]={-1,-1,-1}; - int val=-1; - enum dacIndex ind=0; - int imod=-1; - int retval[2]={-1,-1}; - int mV=0; - sprintf(mess,"set DAC failed\n"); - - // receive arguments - n = receiveData(file_des,arg,sizeof(arg),INT32); - if (n < 0) return printSocketReadError(); - ind=arg[0]; - imod=arg[1]; - mV=arg[2]; - - n = receiveData(file_des,&val,sizeof(val),INT32); - if (n < 0) return printSocketReadError(); - - // checks -#ifdef MYTHEND -#ifdef SLS_DETECTOR_FUNCTION_LIST - if (imod>=getTotalNumberOfModules()) { - ret = FAIL; - sprintf(mess,"Module number %d out of range\n",imod); - cprintf(RED, "Warning: %s", mess); - } -#endif -#endif - // check if dac exists for this detector - enum DACINDEX idac=0; -#ifdef JUNGFRAUD - if ((ind != HV_NEW) && (ind >= NDAC_OLDBOARD)) { //for compatibility with old board - ret = FAIL; - sprintf(mess,"Dac Index (%d) is not implemented for this detector\n",(int)ind); - cprintf(RED, "Warning: %s", mess); - }else - idac = ind; -#else - switch (ind) { -#ifdef MYTHEND - case TRIMBIT_SIZE: //ind = VTRIM; - case THRESHOLD: - case SHAPER1: - case SHAPER2: - case CALIBRATION_PULSE: - case PREAMP: - break; -#elif GOTTHARDD - case G_VREF_DS : - break; - case G_VCASCN_PB: - break; - case G_VCASCP_PB: - break; - case G_VOUT_CM: - break; - case G_VCASC_OUT: - break; - case G_VIN_CM: - break; - case G_VREF_COMP: - break; - case G_IB_TESTC: - break; - case HV_POT: - break; -#elif EIGERD - case TRIMBIT_SIZE: - idac = VTR; - break; - case THRESHOLD: - idac = VTHRESHOLD; - break; - case E_SvP: - idac = SVP; - break; - case E_SvN: - idac = SVN; - break; - case E_Vtr: - idac = VTR; - break; - case E_Vrf: - idac = VRF; - break; - case E_Vrs: - idac = VRS; - break; - case E_Vtgstv: - idac = VTGSTV; - break; - case E_Vcmp_ll: - idac = VCMP_LL; - break; - case E_Vcmp_lr: - idac = VCMP_LR; - break; - case E_cal: - idac = CAL; - break; - case E_Vcmp_rl: - idac = VCMP_RL; - break; - case E_Vcmp_rr: - idac = VCMP_RR; - break; - case E_rxb_rb: - idac = RXB_RB; - break; - case E_rxb_lb: - idac = RXB_LB; - break; - case E_Vcp: - idac = VCP; - break; - case E_Vcn: - idac = VCN; - break; - case E_Vis: - idac = VIS; - break; - case HV_NEW: - break; - case IO_DELAY: - break; - /* -#elif JUNGFRAUD - case V_DAC0: - idac = VB_COMP; - break; - case V_DAC1: - idac = VDD_PROT; - break; - case V_DAC2: - idac = VIN_COM; - break; - case V_DAC3: - idac = VREF_PRECH; - break; - case V_DAC4: - idac = VB_PIXBUF; - break; - case V_DAC5: - idac = VB_DS; - break; - case V_DAC6: - idac = VREF_DS; - break; - case V_DAC7: - idac = VREF_COMP; - break; - case HV_POT: - break; - */ -#elif MYTHEN3D - case M_vIpre: - idac = vIpre; - break; - case M_vIbias: - idac = vIbias; - break; - case PREAMP: - idac = Vrf; - break; - case SHAPER1: - idac = VrfSh; - break; - case M_vIinSh: - idac = vIinSh; - break; - case M_VdcSh: - idac = VdcSh; - break; - case M_Vth2: - idac = Vth2; - break; - case M_VPL: - idac = VPL; - break; - case THRESHOLD: - idac = Vth1; - break; - case M_Vth3: - idac = Vth3; - break; - case TRIMBIT_SIZE: - idac = Vtrim; - break; - case M_casSh: - idac = casSh; - break; - case M_cas: - idac = cas; - break; - case M_vIbiasSh: - idac = vIbiasSh; - break; - case M_vIcin: - idac = vIcin; - break; - case CALIBRATION_PULSE: // !!! pulse height + 1400 DACu - idac = VPH; - break; - case M_vIpreOut: - idac = vIpreOut; - break; - case V_POWER_A: - idac = V_A; - break; - case V_POWER_B: - ipwr = V_B; - break; - case V_POWER_IO: - idac = V_IO; - break; - case V_POWER_CHIP: - idac = V_CHIP; - break; - case V_LIMIT: - idac = V_LIM; - break; -#endif - default: - ret = FAIL; - sprintf(mess,"Dac Index (%d) is not implemented for this detector\n",(int)ind); - cprintf(RED, "Warning: %s", mess); - break; - } -#endif - - // execute action -#ifdef VERBOSE - printf("Setting DAC %d of module %d to %d \n", idac, imod, val); -#endif -#ifdef SLS_DETECTOR_FUNCTION_LIST - int temp; - if (ret==OK) { - if (differentClients && lockStatus && val!=-1) { - ret = FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - cprintf(RED, "Warning: %s", mess); - } else { -#ifdef EIGERD - //iodelay - if(ind == IO_DELAY) - retval[0] = setIODelay(val,imod); - //high voltage - else -#endif - if((ind == HV_POT) || (ind == HV_NEW)) { - retval[0] = setHighVoltage(val); -#ifdef EIGERD - if ((retval[0] != SLAVE_HIGH_VOLTAGE_READ_VAL) && (retval[0] < 0)) { - ret = FAIL; - if(retval[0] == -1) - sprintf(mess, "Setting high voltage failed.Bad value %d. The range is from 0 to 200 V.\n",val); - else if(retval[0] == -2) - strcpy(mess, "Setting high voltage failed. Serial/i2c communication failed.\n"); - else if(retval[0] == -3) - strcpy(mess, "Getting high voltage failed. Serial/i2c communication failed.\n"); - cprintf(RED, "Warning: %s", mess); - } -#endif - } -#ifdef MYTHEN3D - else if ((ind >= V_POWER_A && ind <= V_POWER_CHIP) || ind == V_LIMIT) { - printf("Setting a power %d to %d\n",ind, val); - - if (!mV) { - ret = FAIL; - strcpy(mess, "Power of index %d should be set in mV instead of DACu", idac); - cprintf(RED, "Warning: %s", mess); - val = -1; - } - - int lim = getVLimit(); - if (ind != V_LIMIT && lim != -1 && val > lim) { - ret = FAIL; - strcpy(mess, "Power of index %d is %d, should be less than %dmV\n", idac, val, lim); - cprintf(RED, "Warning: %s", mess); - val = -1; - } - - retval[1] = retval[0] = setPower(idac,val); - if (val >= 0 && retval[1] != val) { - ret = FAIL; - sprintf(mess,"Setting power %d failed: wrote %d but read %d\n", idac, val, retval[1]); - cprintf(RED, "Warning: %s", mess); - } - } -#endif - //dac - else{ -#ifdef MYTHEN3D - if( mV && val > MAX_DACVOLTVAL) { - ret = FAIL; - strcpy(mess, "Dac of index %d should be less than %dmV\n", idac, val, MAX_DACVOLTVAL); - cprintf(RED, "Warning: %s", mess); - val = -1; - } - else if( !mV && val >= MAX_DACVAL) { - ret = FAIL; - strcpy(mess, "Dac of index %d should be less than %d (dac value)\n", idac, val, MAX_DACVAL); - cprintf(RED, "Warning: %s", mess); - val = -1; - } - - if (val >= 0) { - // conver to mV - int v = val; - if (!mV) - v = dacToVoltage(val); - - //checkvlimit compliant - int lim = getVLimit(); - if (lim!= -1 && v > lim) { - ret = FAIL; - strcpy(mess, "Dac of index %d should be less than %dmV (%d dac value)\n", idac, lim, voltageToDac(lim)); - cprintf(RED, "Warning: %s", mess); - val = -1; - } - } -#endif - setDAC(idac,val,imod,mV,retval); -#ifdef EIGERD - if(val != -1) { - //changing dac changes settings to undefined - switch(idac){ - case VCMP_LL: - case VCMP_LR: - case VCMP_RL: - case VCMP_RR: - case VRF: - case VCP: - setSettings(UNDEFINED,-1); - cprintf(RED,"Settings has been changed to undefined (changed specific dacs)\n"); - break; - default: - break; - } - } -#endif - //check - if (ret == OK) { - if(mV) - temp = retval[1]; - else - temp = retval[0]; - if ((abs(temp-val)<=5) || val==-1) { - ret = OK; - } else { - ret = FAIL; - sprintf(mess,"Setting dac %d of module %d: wrote %d but read %d\n", idac, imod, val, temp); - cprintf(RED, "Warning: %s", mess); - } - } - } - } - } -#endif -#ifdef VERBOSE - printf("DAC set to %d in dac units and %d mV\n", retval[0],retval[1]); -#endif - - if(ret == OK && differentClients) - ret=FORCE_UPDATE; - - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - if (ret!=FAIL) { - n += sendData(file_des,&retval,sizeof(retval),INT32); - } else { - n += sendData(file_des,mess,sizeof(mess),OTHER); - } - - // return ok / fail - return ret; -} - - - - - - -int get_adc(int file_des) { - int ret=OK,ret1=OK; - int n=0; - int arg[2]={-1,-1}; - int retval=-1; - enum dacIndex ind=0; - int imod=-1; - sprintf(mess,"get ADC failed\n"); - -#ifdef MYTHEN3D - //to receive any arguments - while (n > 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - ret = FAIL; - sprintf(mess,"Function (Get ADC) is not implemented for this detector\n"); - cprintf(RED, "Warning: %s", mess); -#else - - // receive arguments - n = receiveData(file_des,arg,sizeof(arg),INT32); - if (n < 0) return printSocketReadError(); - ind=arg[0]; - imod=arg[1]; - -#ifdef MYTHEND -#ifdef SLS_DETECTOR_FUNCTION_LIST - if (imod>=getTotalNumberOfModules() || imod<0) { - ret = FAIL; - sprintf(mess,"Module number %d out of range\n",imod); - cprintf(RED, "Warning: %s", mess); - } -#endif -#endif - - enum ADCINDEX iadc=0; - switch (ind) { -#ifdef EIGERD - case TEMPERATURE_FPGAEXT: - iadc = TEMP_FPGAEXT; - break; - case TEMPERATURE_10GE: - iadc = TEMP_10GE; - break; - case TEMPERATURE_DCDC: - iadc = TEMP_DCDC; - break; - case TEMPERATURE_SODL: - iadc = TEMP_SODL; - break; - case TEMPERATURE_SODR: - iadc = TEMP_SODR; - break; - case TEMPERATURE_FPGA: - iadc = TEMP_FPGA; - break; - case TEMPERATURE_FPGA2: - iadc = TEMP_FPGAFEBL; - break; - case TEMPERATURE_FPGA3: - iadc = TEMP_FPGAFEBR; - break; -#endif -#if defined(GOTTHARD) || defined(JUNGFRAUD) - case TEMPERATURE_FPGA: - iadc = TEMP_FPGA; - break; - case TEMPERATURE_ADC: - iadc = TEMP_ADC; - break; -#endif - default: - ret = FAIL; - sprintf(mess,"Dac Index (%d) is not implemented for this detector\n",(int)ind); - cprintf(RED, "Warning: %s", mess); - break; - } - -#ifdef VERBOSE - printf("Getting ADC %d of module %d\n", iadc, imod); -#endif -#ifdef SLS_DETECTOR_FUNCTION_LIST - if (ret==OK) - retval=getADC(iadc,imod); -#endif -#ifdef VERBOSE - printf("ADC is %f\n", retval); -#endif -#endif - - if (ret==OK && differentClients) - ret=FORCE_UPDATE; - - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - if (ret!=FAIL) { - n += sendData(file_des,&retval,sizeof(retval),INT32); - } else { - n += sendData(file_des,mess,sizeof(mess),OTHER); - } - - // return ok / fail - return ret; -} - - - - - -int write_register(int file_des) { - int ret=OK,ret1=OK; - int n=0; - uint32_t retval=-1; - sprintf(mess,"write to register failed\n"); - - // receive arguments - int arg[2]={-1,-1}; - n = receiveData(file_des,arg,sizeof(arg),INT32); - if (n < 0) return printSocketReadError(); - int addr=arg[0]; - uint32_t val=arg[1]; - - // execute action - if (differentClients && lockStatus) { - ret = FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - cprintf(RED, "Warning: %s", mess); - } -#ifdef SLS_DETECTOR_FUNCTION_LIST - else { -#ifdef VERBOSE - printf("writing to register 0x%x data 0x%x\n", addr, val); -#endif - retval=writeRegister(addr,val); - if (retval!=val) { - ret = FAIL; - sprintf(mess,"Writing to register 0x%x failed: wrote 0x%x but read 0x%x\n", addr, val, retval); - cprintf(RED, "Warning: %s", mess); - } - } -#endif -#ifdef VERBOSE - printf("Data set to 0x%x\n", retval); -#endif - if (ret==OK && differentClients) - ret=FORCE_UPDATE; - - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - if (ret!=FAIL) { - n += sendData(file_des,&retval,sizeof(retval),INT32); - } else { - n += sendData(file_des,mess,sizeof(mess),OTHER); - } - - // return ok / fail - return ret; - -} - - - - - -int read_register(int file_des) { - int ret=OK,ret1=OK; - int n=0; - uint32_t retval=-1; - sprintf(mess,"read register failed\n"); - - // receive arguments - int arg=0; - n = receiveData(file_des,&arg,sizeof(arg),INT32); - if (n < 0) return printSocketReadError(); - int addr=arg; - - // execute action -#ifdef VERBOSE - printf("reading register 0x%x\n", addr); -#endif -#ifdef SLS_DETECTOR_FUNCTION_LIST - retval=readRegister(addr); -#endif -#ifdef VERBOSE - printf("Returned value 0x%x\n", retval); -#endif - if (ret==OK && differentClients) - ret=FORCE_UPDATE; - - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - if (ret!=FAIL) { - n += sendData(file_des,&retval,sizeof(retval),INT32); - } else { - n += sendData(file_des,mess,sizeof(mess),OTHER); - } - - // return ok / fail - return ret; -} - - - - -int write_memory(int file_des) { - int ret=FAIL,ret1=FAIL; - int n=0; - sprintf(mess,"Function (Write Memory) is not implemented for this detector\n"); - cprintf(RED, "Error: %s", mess); - - //to receive any arguments - while (n > 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - - n = sendData(file_des,&ret1,sizeof(ret),INT32); - n = sendData(file_des,mess,MAX_STR_LENGTH,OTHER); - - // return ok / fail - return ret; -} - - -int read_memory(int file_des) { - int ret=FAIL,ret1=FAIL; - int n=0; - sprintf(mess,"Function (Read Memory) is not implemented for this detector\n"); - cprintf(RED, "Error: %s", mess); - - //to receive any arguments - while (n > 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - - n = sendData(file_des,&ret1,sizeof(ret),INT32); - n = sendData(file_des,mess,MAX_STR_LENGTH,OTHER); - - // return ok / fail - return ret; -} - - - -int set_channel(int file_des) { - int ret=OK,ret1=OK; - int n=0; - int retval=-1; - sprintf(mess,"set channel failed\n"); - -#ifndef MYTHEND - //to receive any arguments - while (n > 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - ret = FAIL; - sprintf(mess,"Function (Set Channel) is not implemented for this detector\n"); - cprintf(RED, "Warning: %s", mess); -#else - - // receive arguments - sls_detector_channel myChan; - n=receiveChannel(file_des, &myChan); - if (n < 0) return printSocketReadError(); - - // execute action -#ifdef VERBOSE - printf("Setting channel\n"); - printf("channel number is %d, chip number is %d, module number is %d, register is %lld\n", myChan.chan,myChan.chip, myChan.module, myChan.reg); -#endif - if (differentClients && lockStatus) { - ret = FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - cprintf(RED, "Warning: %s", mess); - } -#ifdef SLS_DETECTOR_FUNCTION_LIST - else if (myChan.chan>=getNumberOfChannelsPerChip()) { - ret = FAIL; - sprintf(mess,"channel number %d too large!\n",myChan.chan); - cprintf(RED, "Warning: %s", mess); - } - else if (myChan.chip>=getNumberOfChipsPerModule()) { - ret = FAIL; - sprintf(mess,"chip number %d too large!\n",myChan.chip); - cprintf(RED, "Warning: %s", mess); - } - else if (myChan.module>=getTotalNumberOfModules()) { - ret = FAIL; - sprintf(mess,"module number %d too large!\n",myChan.module); - cprintf(RED, "Warning: %s", mess); - } - else - retval=setChannel(myChan); -#endif - if (ret==OK && differentClients) - ret=FORCE_UPDATE; -#endif - - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - if (ret!=FAIL) { - n += sendData(file_des,&retval,sizeof(retval),INT32); - } else { - n += sendData(file_des,mess,sizeof(mess),OTHER); - } - - // return ok / fail - return ret; -} - - - - -int get_channel(int file_des) { - int ret=OK,ret1=OK; - int n=0; - sls_detector_channel retval; - sprintf(mess,"get channel failed\n"); - -#ifndef MYTHEND - //to receive any arguments - while (n > 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - ret = FAIL; - sprintf(mess,"Function (Get Channel) is not implemented for this detector\n"); - cprintf(RED, "Warning: %s", mess); -#else - - // receive arguments - int arg[3]={-1,-1,-1}; - n = receiveData(file_des,arg,sizeof(arg),INT32); - if (n < 0) return printSocketReadError(); - - // execute action - int ichan=arg[0]; - int ichip=arg[1]; - int imod=arg[2]; -#ifdef SLS_DETECTOR_FUNCTION_LIST - if (ichan>=getNumberOfChannelsPerChip()) { - ret=FAIL; - sprintf(mess, "channel number %d too large!\n",myChan.chan); - cprintf(RED, "Warning: %s", mess); - } else - retval.chan=ichan; - if (ichip>=getNumberOfChipsPerModule()) { - ret=FAIL; - sprintf(mess, "chip number %d too large!\n",myChan.chip); - cprintf(RED, "Warning: %s", mess); - } else - retval.chip=ichip; - - if (imod>=getTotalNumberOfModules()) { - ret=FAIL; - sprintf(mess, "module number %d too large!\n",myChan.module); - cprintf(RED, "Warning: %s", mess); - } else { - retval.module=imod; - ret=getChannel(&retval); -#ifdef VERBOSE - printf("Returning channel %d %d %d, 0x%llx\n", retval.chan, retval.chip, retval.mod, (retval.reg)); -#endif - } -#endif - if (ret==OK && differentClients) - ret=FORCE_UPDATE; -#endif - - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - if (ret!=FAIL) { - ret=sendChannel(file_des, &retval); - } else { - n += sendData(file_des,mess,sizeof(mess),OTHER); - } - - // return ok / fail - return ret; -} - - - -int set_all_channels(int file_des) { - int ret=FAIL,ret1=FAIL; - int n=0; - sprintf(mess,"Function (Set All Channels) is not implemented for this detector\n"); - cprintf(RED, "Error: %s", mess); - - //to receive any arguments - while (n > 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - - n = sendData(file_des,&ret1,sizeof(ret),INT32); - n = sendData(file_des,mess,MAX_STR_LENGTH,OTHER); - - // return ok / fail - return ret; -} - - - - - -int set_chip(int file_des) { - int ret=OK,ret1=OK; - int n=0; - int retval=-1; - sprintf(mess,"set chip failed\n"); - -#ifndef MYTHEND - //to receive any arguments - while (n > 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - ret = FAIL; - sprintf(mess,"Function (Set Chip) is not implemented for this detector\n"); - cprintf(RED, "Warning: %s", mess); -#else - sls_detector_chip myChip; - -#ifdef SLS_DETECTOR_FUNCTION_LIST - myChip.nchan=getNumberOfChannelsPerChip(); - int *ch(int*)malloc((myChip.nchan)*sizeof(int)); - myChip.chanregs=ch; - - // receive arguments - n=receiveChip(file_des, &myChip); -#ifdef VERBOSE - printf("Chip received\n"); -#endif - if(n < 0) return FAIL; - - // execute action - if (differentClients==1 && lockStatus==1) { - ret = FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - cprintf(RED, "Warning: %s", mess); - } - else{ -#ifdef VERBOSE - printf("Setting chip\n"); - printf("chip number is %d, module number is %d, register is %d, nchan %d\n",myChip.chip, myChip.module, myChip.reg, myChip.nchan); -#endif - if (myChip.chip>=getNumberOfChipsPerModule()) { - ret = FAIL; - sprintf(mess,"chip number %d too large!\n",myChan.chip); - cprintf(RED, "Warning: %s", mess); - } - else if (myChip.module>=getTotalNumberOfModules()) { - ret = FAIL; - sprintf(mess,"module number %d too large!\n",myChan.module); - cprintf(RED, "Warning: %s", mess); - } - else - retval=setChip(myChip); - } - free(ch); -#endif - if (ret==OK && differentClients) - ret=FORCE_UPDATE; -#endif - - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - if (ret!=FAIL) { - n += sendData(file_des,&retval,sizeof(retval),INT32); - } else { - n += sendData(file_des,mess,sizeof(mess),OTHER); - } - - // return ok / fail - return ret; -} - - - - -int get_chip(int file_des) { - int ret=OK,ret1=OK; - int n=0; - sls_detector_chip retval; - sprintf(mess,"get chip failed\n"); - -#ifndef MYTHEND - //to receive any arguments - while (n > 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - ret = FAIL; - sprintf(mess,"Function (Get Chip) is not implemented for this detector\n"); - cprintf(RED, "Warning: %s", mess); -#else - - // receive arguments - int arg[2]={-1,-1}; - n = receiveData(file_des,arg,sizeof(arg),INT32); - if (n < 0) return printSocketReadError(); - -#ifdef SLS_DETECTOR_FUNCTION_LIST - int ichip=arg[0]; - int imod=arg[1]; - - // execute action - if (ichip>=getNumberOfChipsPerModule()) { - ret = FAIL; - sprintf(mess,"channel number %d too large!\n",myChan.chan); - cprintf(RED, "Warning: %s", mess); - } else - retval.chip=ichip; - - if (imod>=getTotalNumberOfModules()) { - ret = FAIL; - sprintf(mess,"module number %d too large!\n",imod); - cprintf(RED, "Warning: %s", mess); - } else - retval.module=imod; - - if (ret==OK) - ret=getChip(&retval); -#endif -#ifdef VERBOSE - printf("Returning chip %d %d\n", ichip, imod); -#endif - if (ret==OK && differentClients) - ret=FORCE_UPDATE; -#endif - - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - if (ret!=FAIL) { - ret=sendChip(file_des, &retval); - } else { - n += sendData(file_des,mess,sizeof(mess),OTHER); - } - - // return ok / fail - return ret; -} - - - - -int set_all_chips(int file_des) { - int ret=FAIL,ret1=FAIL; - int n=0; - sprintf(mess,"Function (Set All Chips) is not implemented for this detector\n"); - cprintf(RED, "Error: %s", mess); - - //to receive any arguments - while (n > 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - - n = sendData(file_des,&ret1,sizeof(ret),INT32); - n = sendData(file_des,mess,MAX_STR_LENGTH,OTHER); - - // return ok / fail - return ret; -} - - - - - -int set_module(int file_des) { - int ret=OK,ret1=OK; - int n=0; - sls_detector_module myModule; - int retval=-1; -#ifdef EIGERD - int myIODelay=-1; - int myTau=-1; - int myEV=-1; -#endif - sprintf(mess,"set module failed\n"); - - -#ifdef MYTHEN3D - //to receive any arguments - while (n > 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - ret = FAIL; - sprintf(mess,"Function (Set Module) is not implemented for this detector\n"); - cprintf(RED, "Warning: %s", mess); -#else - - -#ifdef SLS_DETECTOR_FUNCTION_LIST - int *myDac=NULL; - int *myAdc=NULL; - int *myChip = NULL; - int *myChan = NULL; - - myDac=(int*)malloc(getNumberOfDACsPerModule()*sizeof(int)); - if (getNumberOfDACsPerModule() > 0 && myDac == NULL) { - ret = FAIL; - sprintf(mess,"could not allocate dacs\n"); - cprintf(RED, "Warning: %s", mess); - } - else { - myModule.dacs=myDac; - myAdc=(int*)malloc(getNumberOfADCsPerModule()*sizeof(int)); - if (getNumberOfADCsPerModule() > 0 && myAdc == NULL) { - ret = FAIL; - sprintf(mess,"could not allocate adcs\n"); - cprintf(RED, "Warning: %s", mess); - } - else { - myModule.adcs=myAdc; - //no chips and chans allocated for jungfrau, too much memory -#ifdef JUNGFRAUD - myModule.chipregs=NULL; - myModule.chanregs=NULL; -#else - myChip=(int*)malloc(getNumberOfChipsPerModule()*sizeof(int)); - if (getNumberOfChipsPerModule() > 0 && myChip == NULL) { - ret = FAIL; - sprintf(mess,"could not allocate chips\n"); - cprintf(RED, "Warning: %s", mess); - } - else { - myModule.chipregs=myChip; - myChan=(int*)malloc(getNumberOfChannelsPerModule()*sizeof(int)); - if (getNumberOfChannelsPerModule() > 0 && myChan == NULL) { - ret = FAIL; - sprintf(mess,"could not allocate chans\n"); - cprintf(RED, "Warning: %s", mess); - } - else { - myModule.chanregs=myChan; -#endif - myModule.nchip=getNumberOfChipsPerModule(); - myModule.nchan=getNumberOfChannelsPerModule(); - myModule.ndac=getNumberOfDACsPerModule(); - myModule.nadc=getNumberOfADCsPerModule(); - - - // receive arguments -#ifdef VERBOSE - printf("Setting module\n"); -#endif - n=receiveModuleGeneral(file_des, &myModule, -#ifdef JUNGFRAUD - 0 //0 is to receive partially (without trimbits etc.) -#else - 1 -#endif - ); - if (n<0) return FAIL; -#ifdef VERBOSE - printf("module number is %d,register is %d, nchan %d, nchip %d, ndac %d, nadc %d, gain %f, offset %f\n", - myModule.module, myModule.reg, myModule.nchan, myModule.nchip, myModule.ndac, myModule.nadc, myModule.gain,myModule.offset); -#endif -#ifdef EIGERD - n = receiveData(file_des,&myIODelay,sizeof(myIODelay),INT32); - if (n<0) return FAIL; - n = receiveData(file_des,&myTau,sizeof(myTau),INT32); - if (n<0) return FAIL; - n = receiveData(file_des,&myEV,sizeof(myEV),INT32); - if (n<0) return FAIL; -#ifdef VERBOSE - printf("IO Delay:%d\n",myIODelay); - printf("Tau:%d\n",myTau); - printf("eV:%d\n",myEV); -#endif -#endif -#ifndef JUNGFRAUD - } - } -#endif - } - } - - //check settings index - if (ret==OK) { -#ifdef MYTHEND - if (myModule.module>=getNModBoard()) { - ret = FAIL; - sprintf(mess,"Module Number to Set Module (%d) is too large\n", myModule.module); - cprintf(RED, "Warning: %s", mess); - } - if (myModule.module<0) - myModule.module=ALLMOD; -#endif -#if defined(JUNGFRAUD) || defined(EIGERD) - switch(myModule.reg){ - case GET_SETTINGS: - case UNINITIALIZED: -#ifdef EIGERD - case STANDARD: - case HIGHGAIN: - case LOWGAIN: - case VERYHIGHGAIN: - case VERYLOWGAIN: -#elif JUNGFRAUD - case DYNAMICGAIN: - case DYNAMICHG0: - case FIXGAIN1: - case FIXGAIN2: - case FORCESWITCHG1: - case FORCESWITCHG2: -#endif - break; - default: - ret = FAIL; - sprintf(mess,"Setting (%d) is not implemented for this detector\n", myModule.reg); - cprintf(RED, "Warning: %s", mess); - break; - } - } -#endif - - - // execute action - if (ret==OK) { - if (differentClients && lockStatus) { - ret = FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - cprintf(RED, "Warning: %s", mess); - } -#ifdef EIGERD - //set dacs, trimbits and iodelay - ret=setModule(myModule, myIODelay); - //set threshhold - if (myEV >= 0) - setThresholdEnergy(myEV,-1); - else { - //changes settings to undefined (loading a random trim file) - setSettings(UNDEFINED,-1); - cprintf(RED,"Settings has been changed to undefined (random trim file)\n"); - } - //rate correction - //switch off rate correction: no value read from load calib/load settings) - if(myTau == -1){ - if(getRateCorrectionEnable()){ - setRateCorrection(0); - ret = FAIL; - strcat(mess,"Cannot set Rate correction. No default tau provided. Deactivating Rate Correction\n"); - cprintf(RED, "Warning: %s", mess); - } - } - //normal tau value (only if enabled) - else{ - setDefaultSettingsTau_in_nsec(myTau); - if (getRateCorrectionEnable()){ - int64_t retvalTau = setRateCorrection(myTau); - if(myTau != retvalTau){ - cprintf(RED,"%s",mess); - ret=FAIL; - } - } - } - retval = getSettings(); -#else - retval=setModule(myModule); - if (retval != myModule.reg) - ret = FAIL; -#endif - if(myChip != NULL) free(myChip); - if(myChan != NULL) free(myChan); - if(myDac != NULL) free(myDac); - if(myAdc != NULL) free(myAdc); - } - if (ret==OK && differentClients) - ret=FORCE_UPDATE; -#endif -#endif - - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - if (ret!=FAIL) { - n += sendData(file_des,&retval,sizeof(retval),INT32); - } else { - n += sendData(file_des,mess,sizeof(mess),OTHER); - } - - // return ok / fail - return ret; -} - - - - - - - - -int get_module(int file_des) { - int ret=OK,ret1=OK; - int n=0; - int arg=-1; - int imod=-1; - sls_detector_module myModule; - sprintf(mess,"get module failed\n"); - -#ifdef MYTHEN3D - //to receive any arguments - while (n > 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - ret = FAIL; - sprintf(mess,"Function (Get Module) is not implemented for this detector\n"); - cprintf(RED, "Warning: %s", mess); -#else - - // receive arguments - n = receiveData(file_des,&arg,sizeof(arg),INT32); - if (n < 0) return printSocketReadError(); - imod=arg; - - // execute action -#ifdef SLS_DETECTOR_FUNCTION_LIST - int *myDac=NULL; - int *myAdc=NULL; - int *myChip = NULL; - int *myChan = NULL; - - if (imod<0 || imod>getTotalNumberOfModules()) { - ret = FAIL; - sprintf(mess,"Module Index (%d) is out of range\n", imod); - cprintf(RED, "Warning: %s", mess); - } - else { - myDac=(int*)malloc(getNumberOfDACsPerModule()*sizeof(int)); - if (getNumberOfDACsPerModule() > 0 && myDac == NULL) { - ret = FAIL; - sprintf(mess,"could not allocate dacs\n"); - cprintf(RED, "Warning: %s", mess); - } - else { - myModule.dacs=myDac; - myAdc=(int*)malloc(getNumberOfADCsPerModule()*sizeof(int)); - if (getNumberOfADCsPerModule() > 0 && myAdc == NULL) { - ret = FAIL; - sprintf(mess,"could not allocate adcs\n"); - cprintf(RED, "Warning: %s", mess); - } - else { - myModule.adcs=myAdc; - //no chips and chans allocated for jungfrau, too much memory -#ifdef JUNGFRAUD - myModule.chipregs=NULL; - myModule.chanregs=NULL; -#else - myChip=(int*)malloc(getNumberOfChipsPerModule()*sizeof(int)); - if (getNumberOfChipsPerModule() > 0 && myChip == NULL) { - ret = FAIL; - sprintf(mess,"could not allocate chips\n"); - cprintf(RED, "Warning: %s", mess); - } - else { - myModule.chipregs=myChip; - myChan=(int*)malloc(getNumberOfChannelsPerModule()*sizeof(int)); - if (getNumberOfChannelsPerModule() > 0 && myChan == NULL) { - ret = FAIL; - sprintf(mess,"could not allocate chans\n"); - cprintf(RED, "Warning: %s", mess); - } - else { - myModule.chanregs=myChan; -#endif - myModule.nchip=getNumberOfChipsPerModule(); - myModule.nchan=getNumberOfChannelsPerModule(); - myModule.ndac=getNumberOfDACsPerModule(); - myModule.nadc=getNumberOfADCsPerModule(); - myModule.module=imod; - getModule(&myModule); -#ifdef VERBOSE - printf("Returning module %d of register %x\n", imod, myModule.reg); -#endif -#ifndef JUNGFRAUD - } - } -#endif - } - } - } -#endif -#endif - if (ret==OK && differentClients) - ret=FORCE_UPDATE; - - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - if (ret!=FAIL) { - ret=sendModuleGeneral(file_des, &myModule, -#ifdef JUNGFRAUD - 0 //0 is to receive partially (without trimbits etc.) -#else - 1 -#endif - ); - } else { - n += sendData(file_des,mess,sizeof(mess),OTHER); - } - -#ifdef SLS_DETECTOR_FUNCTION_LIST - if(myChip != NULL) free(myChip); - if(myChan != NULL) free(myChan); - if(myDac != NULL) free(myDac); - if(myAdc != NULL) free(myAdc); -#endif - - // return ok / fail - return ret; - -} - - - -int set_all_modules(int file_des) { - int ret=FAIL,ret1=FAIL; - int n=0; - sprintf(mess,"Function (Set All Modules) is not implemented for this detector\n"); - cprintf(RED, "Error: %s", mess); - - //to receive any arguments - while (n > 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - - n = sendData(file_des,&ret1,sizeof(ret),INT32); - n = sendData(file_des,mess,MAX_STR_LENGTH,OTHER); - - // return ok / fail - return ret; -} - - - - -int set_settings(int file_des) { - int ret=OK,ret1=OK; - int n=0; - int arg[2]={-1,-1}; - int retval=-1; - int imod=-1; - enum detectorSettings isett=-1; - sprintf(mess,"set settings failed\n"); - -#ifdef MYTHEN3D - //to receive any arguments - while (n > 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - ret = FAIL; - sprintf(mess,"Function (Set Settings) is not implemented for this detector\n"); - cprintf(RED, "Warning: %s", mess); -#else - - // receive arguments - n = receiveData(file_des,&arg,sizeof(arg),INT32); - if (n < 0) return printSocketReadError(); - isett=arg[0]; - imod=arg[1]; - - // execute action - if (differentClients && lockStatus && isett!=GET_SETTINGS) { - ret = FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - cprintf(RED, "Warning: %s", mess); - } -#ifdef SLS_DETECTOR_FUNCTION_LIST - -#ifdef MYTHEND - if ( (ret != FAIL) && (imod>=getTotalNumberOfModules())) { - ret = FAIL; - sprintf(mess,"Module number %d out of range\n",imod); - cprintf(RED, "Warning: %s", mess); - } -#endif - switch(isett) { - case GET_SETTINGS: - case UNINITIALIZED: -#ifdef JUNGFRAUD - case DYNAMICGAIN: - case DYNAMICHG0: - case FIXGAIN1: - case FIXGAIN2: - case FORCESWITCHG1: - case FORCESWITCHG2: - break; - default: - ret = FAIL; - sprintf(mess,"Setting (%d) is not implemented for this detector.\n" - "Options are dynamicgain, dynamichg0, fixgain1, fixgain2, " - "forceswitchg1 and forceswitchg2.\n", isett); - cprintf(RED, "Warning: %s", mess); - break; -// other detectors -// #elif GOTTHARDD, MOENCHD, PROPIXD -#else - break; - default: - ret = FAIL; -#ifdef EIGERD - sprintf(mess,"Cannot set settings via SET_SETTINGS, use SET_MODULE\n"); -#else - sprintf(mess,"Setting (%d) is not implemented for this detector\n", isett); -#endif - cprintf(RED, "Warning: %s", mess); - break; -#endif - } - - if (ret != FAIL) { -#ifdef VERBOSE - printf("Changing settings of module %d to %d\n", imod, isett); -#endif - retval=setSettings(isett, imod); -#ifdef VERBOSE - printf("Settings changed to %d\n", isett); -#endif - if (retval == isett || isett < 0) { - ret=OK; - } else { - ret = FAIL; - sprintf(mess,"Changing settings of module %d: wrote %d but read %d\n", imod, isett, retval); - cprintf(RED, "Warning: %s", mess); - } - } - // set to default dacs, -//# also for #elif GOTTHARDD, MOENCHD, PROPIXD -#ifdef JUNGFRAUD - if (ret == OK && isett >= 0) { - ret = setDefaultDacs(); - if (ret == FAIL) { - strcpy(mess,"Could change settings, but could not set to default dacs\n"); - cprintf(RED, "Warning: %s", mess); - } - } -#endif -#endif -#endif - - if (ret==OK && differentClients) - ret=FORCE_UPDATE; - - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - if (ret==FAIL) { - n += sendData(file_des,mess,sizeof(mess),OTHER); - } else - n += sendData(file_des,&retval,sizeof(retval),INT32); - - // return ok / fail - return ret; -} - - - - - -int get_threshold_energy(int file_des) { - int ret=OK,ret1=OK; - int n=0; - int retval=-1; - sprintf(mess,"get threshold energy failed\n"); - -#if !defined(MYTHEND) && !defined(EIGERD) - //to receive any arguments - while (n > 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - ret = FAIL; - sprintf(mess,"Function (Get Threshold Energy) is not implemented for this detector\n"); - cprintf(RED, "Warning: %s", mess); -#else - - // receive arguments - int imod=-1; - n = receiveData(file_des,&imod,sizeof(imod),INT32); - if (n < 0) return printSocketReadError(); - - // execute action -#ifdef VERBOSE - printf("Getting threshold energy of module %d\n", imod); -#endif -#ifdef SLS_DETECTOR_FUNCTION_LIST - if (imod>=getTotalNumberOfModules()) { - ret=FAIL; - sprintf(mess,"Module number %d out of range\n",imod); - } - else { - retval=getThresholdEnergy(imod); -#ifdef VERBOSE - printf("Threshold is %d eV\n", retval); -#endif - } -#endif - if (ret==OK && differentClients) - ret=FORCE_UPDATE; -#endif - - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - if (ret==FAIL) { - n += sendData(file_des,mess,sizeof(mess),OTHER); - } else - n += sendData(file_des,&retval,sizeof(retval),INT32); - - // return ok / fail - return ret; -} - - - - -int set_threshold_energy(int file_des) { - int ret=OK,ret1=OK; - int n=0; - int retval=-1; - sprintf(mess,"set thhreshold energy failed\n"); - -#ifndef MYTHEND - //to receive any arguments - while (n > 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - ret = FAIL; -#ifdef EIGERD - sprintf(mess,"Function (Set Threshold Energy) is only implemented via Set Settings for this detector\n"); -#else - sprintf(mess,"Function (Set Threshold Energy) is not implemented for this detector\n"); -#endif - cprintf(RED, "Warning: %s", mess); -#else - - // receive arguments - int arg[3]={-1,-1,-1}; - n = receiveData(file_des,&arg,sizeof(arg),INT32); - if (n < 0) return printSocketReadError(); - - // execute action - int ethr=arg[0]; - int imod=arg[1]; - enum detectorSettings isett=arg[2]; - if (differentClients && lockStatus) { - ret=FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - } -#ifdef SLS_DETECTOR_FUNCTION_LIST - else if (imod>=getTotalNumberOfModules()) { - ret=FAIL; - sprintf(mess,"Module number %d out of range\n",imod); - } - else { - printf("Setting threshold energy of module %d to %d eV with settings %d\n", imod, ethr, isett); - retval=setThresholdEnergy(ethr, imod); -#ifdef VERBOSE - printf("Threshold set to %d eV\n", retval); -#endif - if (retval!=ethr) { - ret=FAIL; - sprintf(mess,"Setting threshold of module %d: wrote %d but read %d\n", imod, ethr, retval); - cprintf(RED, "Warning: %s", mess); - } -#endif - if (ret==OK && differentClients) - ret=FORCE_UPDATE; -#endif - - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - if (ret==FAIL) { - n += sendData(file_des,mess,sizeof(mess),OTHER); - } else - n += sendData(file_des,&retval,sizeof(retval),INT32); - - // return ok / fail - return ret; -} - - - - - -int start_acquisition(int file_des) { - int ret=OK,ret1=OK; - int n=0; - sprintf(mess,"start acquisition failed\n"); - - // execute action - if (differentClients && lockStatus) { - ret = FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - cprintf(RED, "Warning: %s", mess); - } -#ifdef SLS_DETECTOR_FUNCTION_LIST - else { - printf("Starting acquisition\n"); - ret=startStateMachine(); - if (ret==FAIL) - cprintf(RED, "Warning: %s", mess); - } -#endif - if (ret==OK && differentClients) - ret=FORCE_UPDATE; - - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - if (ret==FAIL) { - n += sendData(file_des,mess,sizeof(mess),OTHER); - } - - // return ok / fail - return ret; -} - - - -int stop_acquisition(int file_des) { - int ret=OK,ret1=OK; - int n=0; - sprintf(mess,"stop acquisition failed\n"); - - // execute action - if (differentClients && lockStatus) { - ret = FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - cprintf(RED, "Warning: %s", mess); - } -#ifdef SLS_DETECTOR_FUNCTION_LIST - else { - printf("Stopping acquisition\n"); - ret=stopStateMachine(); - if (ret==FAIL) - cprintf(RED, "Warning: %s", mess); - } -#endif - if (ret==OK && differentClients) - ret=FORCE_UPDATE; - - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - if (ret==FAIL) { - n += sendData(file_des,mess,sizeof(mess),OTHER); - } - - // return ok / fail - return ret; -} - - - - - -int start_readout(int file_des) { - int ret=OK,ret1=OK; - int n=0; - sprintf(mess,"start readout failed\n"); - -#ifdef JUNGFRAUD - //to receive any arguments - while (n > 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - ret = FAIL; - sprintf(mess,"Function (Start Readout) is not implemented for this detector\n"); - cprintf(RED, "%s", mess); -#else - - // execute action - if (differentClients && lockStatus) { - ret = FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - cprintf(RED, "Warning: %s", mess); - } -#ifdef SLS_DETECTOR_FUNCTION_LIST - else { - printf("Starting readout\n"); - ret=startReadOut(); - if (ret==FAIL) - cprintf(RED, "Warning: %s", mess); - } -#endif - if (ret==OK && differentClients) - ret=FORCE_UPDATE; -#endif - - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - if (ret==FAIL) { - n += sendData(file_des,mess,sizeof(mess),OTHER); - } - - // return ok / fail - return ret; -} - - - - - - -int get_run_status(int file_des) { - int ret=OK,ret1=OK; - enum runStatus s=ERROR; - - // execute action -#ifdef VERBOSE - printf("Getting status\n"); -#endif -#ifdef SLS_DETECTOR_FUNCTION_LIST - s= getRunStatus(); -#endif - if (differentClients) - ret=FORCE_UPDATE; - - // send ok / fail - sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - sendData(file_des,&s,sizeof(s),INT32); - - // return ok / fail - return ret; -} - - - - - -int start_and_read_all(int file_des) { - int dataret1=FAIL, dataret=FAIL; -#ifdef VERBOSE - printf("Starting and reading all frames\n"); -#endif - - // execute action - if (differentClients && lockStatus) { - dataret = FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - cprintf(RED, "Warning: %s", mess); - // ret could be swapped during sendData - dataret1 = dataret; - // send fail - sendData(file_des,&dataret1,sizeof(dataret),INT32); - // send return argument - sendData(file_des,mess,sizeof(mess),OTHER); - // return fail - return dataret; - } -#ifdef SLS_DETECTOR_FUNCTION_LIST - startStateMachine(); - read_all(file_des); -#endif - return OK; -} - - - - -int read_frame(int file_des) { - int dataret1=FAIL, dataret=FAIL; - int n=0; - sprintf(mess, "read frame failed\n"); - - // execute action - if (differentClients && lockStatus) { - dataret = FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - cprintf(RED, "Warning: %s", mess); - // ret could be swapped during sendData - dataret1 = dataret; - // send fail - sendData(file_des,&dataret1,sizeof(dataret),INT32); - // send return argument - sendData(file_des,mess,sizeof(mess),OTHER); - // return fail - return dataret; - } -#ifdef SLS_DETECTOR_FUNCTION_LIST - readFrame(&dataret, mess); -#endif - if(dataret == FAIL) - cprintf(RED,"%s\n",mess); - else - cprintf(GREEN,"%s",mess); - - if (differentClients) - dataret=FORCE_UPDATE; - - //dataret could be swapped during sendData - dataret1 = dataret; - // send finished / fail - n=sendData(file_des,&dataret1,sizeof(dataret1),INT32); - if (n<0) return FAIL; // if called from read_all, should fail to stop talking to a closed client socket - // send return argument - n=sendData(file_des,mess,sizeof(mess),OTHER); - if (n<0) return FAIL; // if called from read_all, should fail to stop talking to a closed client socket - // return finished / fail - return dataret; -} - - - - -int read_all(int file_des) { -#ifdef SLS_DETECTOR_FUNCTION_LIST - while(read_frame(file_des)==OK) { -#ifdef VERBOSE - printf("frame read\n"); -#endif - ; - } -#endif -#ifdef VERBOSE - printf("Frames finished or failed\n"); -#endif - return OK; -} - - - - -int set_timer(int file_des) { - int ret=OK,ret1=OK; - int n=0; - enum timerIndex ind=0; - int64_t tns=-1; - int64_t retval=-1; - sprintf(mess,"set timer failed\n"); - - // receive arguments - n = receiveData(file_des,&ind,sizeof(ind),INT32); - if (n < 0) return printSocketReadError(); - - n = receiveData(file_des,&tns,sizeof(tns),INT64); - if (n < 0) return printSocketReadError(); - - // execute action - if (differentClients && lockStatus && tns!=-1) { - ret = FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - cprintf(RED, "Warning: %s", mess); - } -#ifdef SLS_DETECTOR_FUNCTION_LIST - else { -#ifdef VERBOSE - printf("setting timer %d to %lld ns\n",ind,tns); -#endif -#ifdef EIGERD - int64_t subexptime = 0; -#endif - switch(ind) { -#ifdef JUNGFRAUD - case STORAGE_CELL_NUMBER: - if (tns > MAX_STORAGE_CELL_VAL) { - ret=FAIL; - strcpy(mess,"Max Storage cell number should not exceed 15\n"); - cprintf(RED, "Warning: %s", mess); - break; - } -#endif -#ifdef EIGERD - case SUBFRAME_ACQUISITION_TIME: - if (tns > ((int64_t)MAX_SUBFRAME_EXPOSURE_VAL_IN_10NS*10) ){ - ret=FAIL; - strcpy(mess,"Sub Frame exposure time should not exceed 5.368 seconds\n"); - cprintf(RED, "Warning: %s", mess); - break; - } - retval = setTimer(ind,tns); - break; - case SUBFRAME_DEADTIME: - subexptime = setTimer(SUBFRAME_ACQUISITION_TIME, -1); - if ((tns + subexptime) > ((int64_t)MAX_SUBFRAME_EXPOSURE_VAL_IN_10NS*10) ){ - ret=FAIL; - sprintf(mess,"Sub Frame Period should not exceed 5.368 seconds. " - "So sub frame dead time should not exceed %lfu seconds (subexptime = %lf seconds)\n", - ((((int64_t)MAX_SUBFRAME_EXPOSURE_VAL_IN_10NS*10) - subexptime)/1E9), (subexptime/1E9)); - cprintf(RED, "Warning: %s", mess); - break; - } - retval = setTimer(ind,tns); - break; -#endif -#ifdef MYTHEN - case PROBES_NUMBER: - case GATES_NUMBER: - case DELAY_AFTER_TRIGGER: -#elif JUNGFRAUD - case DELAY_AFTER_TRIGGER: -#elif MYTHEN3D - case DELAY_AFTER_TRIGGER: - case GATES_NUMBER: - case PROBES_NUMBER: - case SAMPLES_JCTB: -#endif - case FRAME_NUMBER: - case ACQUISITION_TIME: - case FRAME_PERIOD: - case CYCLES_NUMBER: - retval = setTimer(ind,tns); - break; - default: - ret = FAIL; - sprintf(mess,"Timer Index (%d) is not implemented for this detector\n", (int) ind); - cprintf(RED, "%s", mess); - break; - } - - -#if defined(MYTHEND) || defined(GOTTHARD) - if (ret == OK && ind==FRAME_NUMBER) { - ret=allocateRAM(); - if (ret!=OK) { - ret = FAIL; - sprintf(mess,"Could not allocate RAM for %lld frames\n", tns); - cprintf(RED, "%s", mess); - } - } -#endif - } -#endif - if (ret==OK && differentClients) - ret=FORCE_UPDATE; - - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - if (ret==FAIL) { - n += sendData(file_des,mess,sizeof(mess),OTHER); - } else - n += sendData(file_des,&retval,sizeof(retval),INT64); - - // return ok / fail - return ret; -} - - - - - - - - - -int get_time_left(int file_des) { - int ret=OK,ret1=OK; - int n=0; - int64_t retval=-1; - sprintf(mess,"get timer left failed\n"); - - - // receive arguments - enum timerIndex ind=0; - n = receiveData(file_des,&ind,sizeof(ind),INT32); - if (n < 0) return printSocketReadError(); - -#ifdef VERBOSE - printf("getting time left on timer %d \n",ind); -#endif -#ifdef SLS_DETECTOR_FUNCTION_LIST - -#ifdef JUNGFRAUD - if (ind == DELAY_AFTER_TRIGGER) { - ret = FAIL; - sprintf(mess,"Timer Left Index (%d) is not implemented for this release.\n", (int)ind); - cprintf(RED, "%s", mess); - } else { -#endif - - switch(ind) { -#ifdef EIGERD - case MEASURED_PERIOD: - case MEASURED_SUBPERIOD: -#elif MYTHEND - case PROBES_NUMBER: -#elif JUNGFRAUD - case FRAMES_FROM_START: - case FRAMES_FROM_START_PG: -#elif MYTHEN3D - case GATES_NUMBER: - case PROBES_NUMBER: - case SAMPLES_JCTB: -#endif -#ifndef EIGERD -#ifndef JUNGFRAUD - case GATES_NUMBER: -#endif - case FRAME_NUMBER: - case ACQUISITION_TIME: - case FRAME_PERIOD: - case DELAY_AFTER_TRIGGER: - case CYCLES_NUMBER: - case PROGRESS: - case ACTUAL_TIME: - case MEASUREMENT_TIME: -#endif - retval=getTimeLeft(ind); - break; - default: - ret = FAIL; - sprintf(mess,"Timer Left Index (%d) is not implemented for this detector\n", (int)ind); - cprintf(RED, "%s", mess); - break; - } -#ifdef VERBOSE - printf("Time left on timer %d is %lld\n",ind, retval); -#endif - -#ifdef JUNGFRAUD - } // end of if (ind == DELAY_AFTER_TRIGGER) -#endif - -#endif - if (ret==OK && differentClients) - ret=FORCE_UPDATE; - - - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - if (ret==FAIL) { - n += sendData(file_des,mess,sizeof(mess),OTHER); - } else - n += sendData(file_des,&retval,sizeof(retval),INT64); - - // return ok / fail - return ret; -} - - - - - - -int set_dynamic_range(int file_des) { - int ret=OK,ret1=OK; - int rateret=OK,rateret1=OK; - int n=0; - int dr=-1; - int retval=-1; - sprintf(mess,"set dynamic range failed\n"); - - // receive arguments - n = receiveData(file_des,&dr,sizeof(dr),INT32); - if (n < 0) return printSocketReadError(); - - // execute action - if (differentClients && lockStatus && dr>=0) { - ret = FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - cprintf(RED, "Warning: %s", mess); - } -#ifdef SLS_DETECTOR_FUNCTION_LIST - else { - switch(dr){ - case -1: - case 16: -#ifdef EIGERD - case 4: case 8: case 32: -#endif - break; - default: - ret = FAIL; - sprintf(mess,"Dynamic Range (%d) is not implemented for this detector\n", dr); - cprintf(RED, "Warning: %s", mess); - } - } - if(ret == OK){ -#ifdef EIGERD - int old_dr = setDynamicRange(-1); - retval=setDynamicRange(dr); - if (dr>=0 && retval!=dr) - ret=FAIL; - //look at rate correction only if dr change worked - if((ret==OK) && (dr!=32) && (dr!=16) && (dr!=-1) && (getRateCorrectionEnable())){ - setRateCorrection(0); - rateret = FAIL; - strcpy(mess,"Switching off Rate Correction. Must be in 32 or 16 bit mode\n"); - cprintf(RED,"%s",mess); - }else{ - //setting it if dr changed from 16 to 32 or vice versa with tau value as in rate table - if((dr!=-1) && (old_dr != dr) && getRateCorrectionEnable() && (dr == 16 || dr == 32)){ - setRateCorrection(-1); //tau_ns will not be -1 here - if(!getRateCorrectionEnable()){ - ret = FAIL; - strcpy(mess,"Deactivating Rate Correction. Could not set it.\n"); - cprintf(RED,"%s",mess); - } - } - } - -#else - retval = setDynamicRange(dr); -#endif - if (dr>=0) dataBytes=calculateDataBytes(); - } -#endif - if ((ret == OK) && dr>=0 && retval!=dr) { - ret = FAIL; - cprintf(RED,"%s",mess); - } - if (ret==OK && differentClients) - ret=FORCE_UPDATE; - - //rate correction ret - // ret could be swapped during sendData - rateret1 = rateret; - // send ok / fail - n = sendData(file_des,&rateret1,sizeof(rateret1),INT32); - // send return argument - if (ret==FAIL) { - n += sendData(file_des,mess,sizeof(mess),OTHER); - } - - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - if (ret==FAIL) { - n += sendData(file_des,mess,sizeof(mess),OTHER); - } else - n += sendData(file_des,&retval,sizeof(retval),INT32); - - // return ok / fail - return ret; -} - - - - - - -int set_readout_flags(int file_des) { - int ret=OK,ret1=OK; - int n=0; - enum readOutFlags retval=-1; - sprintf(mess,"set readout flags failed\n"); - -#if !defined(MYTHEND) && !defined(EIGERD) - //to receive any arguments - while (n > 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - ret=FAIL; - sprintf(mess,"Function (Set Read Out Flags) is not implemented for this detector\n"); - cprintf(RED, "%s",mess); -#else - - // receive arguments - enum readOutFlags arg=-1; - n = receiveData(file_des,&arg,sizeof(arg),INT32); - if (n < 0) return printSocketReadError(); - - // execute action - if (differentClients && lockStatus && arg!=GET_READOUT_FLAGS) { - ret = FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - cprintf(RED, "Warning: %s", mess); - } -#ifdef SLS_DETECTOR_FUNCTION_LIST - else { -#ifdef VERBOSE - printf("setting readout flags to %d\n",arg); -#endif - switch(arg) { - case GET_READOUT_FLAGS: -#ifdef MYTHEND - case TOT_MODE: - case NORMAL_READOUT: - case STORE_IN_RAM: - case CONTINOUS_RO: -#elif EIGERD - case STORE_IN_RAM: - case CONTINOUS_RO: - case PARALLEL: - case NONPARALLEL: - case SAFE: - case SHOW_OVERFLOW: - case NOOVERFLOW: -#endif - retval=setReadOutFlags(arg); - break; - default: - ret = FAIL; - sprintf(mess,"Readout Flag Index (%d) is not implemented for this detector\n", (int)arg); - cprintf(RED, "Warning: %s", mess); - break; - } -#endif - if (ret==OK && ((retval == -1) || ((arg!=-1) && ((retval&arg)!=arg)))){ - ret = FAIL; - sprintf(mess,"Could not change readout flag: should be 0x%x but is 0x%x\n", arg, retval); - cprintf(RED, "Warning: %s", mess); - } - - if (ret==OK && differentClients) - ret=FORCE_UPDATE; - } -#endif - - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - if (ret==FAIL) { - n += sendData(file_des,mess,sizeof(mess),OTHER); - } else - n += sendData(file_des,&retval,sizeof(retval),INT32); - - // return ok / fail - return ret; -} - - - - - - -int set_roi(int file_des) { - int ret=OK,ret1=OK; - int n=0; - strcpy(mess,"set nroi failed\n"); - -#ifndef GOTTHARDD - //to receive any arguments - while (n > 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - ret=FAIL; - sprintf(mess,"Function (Set ROI) is not implemented for this detector\n"); - cprintf(RED, "%s",mess); -#else - - ROI* retval=0; - int retvalsize=0,retvalsize1=0; - - // receive arguments - int nroi=-1; - ROI arg[MAX_ROIS]; - n = receiveData(file_des,&nroi,sizeof(nroi),INT32); - if (n < 0) return printSocketReadError(); - - { - int i; - if(nroi!=-1){ - for(i=0;i=0) { - ret = FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - cprintf(RED, "Warning: %s", mess); - } -#ifdef SLS_DETECTOR_FUNCTION_LIST - else { -#ifdef VERBOSE - printf("setting speed variable %d to %d\n",arg,val); -#endif - switch (arg) { -#ifdef JUNGFRAUD - case ADC_PHASE: - retval = adcPhase(val); - if ((val != 100000) && (retval!=val) && (val>=0)) { - ret=FAIL; - sprintf(mess,"could not change set adc phase: should be %d but is %d \n", val, retval); - cprintf(RED, "Warning: %s", mess); - } - break; -#endif -#ifdef MYTHEND - case CLOCK_DIVIDER: - case WAIT_STATES: - case SET_SIGNAL_LENGTH: - case TOT_CLOCK_DIVIDER: - case TOT_DUTY_CYCLE: -#elif EIGERD - case CLOCK_DIVIDER: -#elif JUNGFRAUD - case CLOCK_DIVIDER: -#elif MYTHEN3D - case DBIT_CLOCK: - case DBIT_PHASE: -#endif - retval=setSpeed(arg, val); - if ((retval!=val) && (val>=0)) { - ret=FAIL; - sprintf(mess,"could not change speed variable %d: should be %d but is %d \n",arg, val, retval); - cprintf(RED, "Warning: %s", mess); - } - break; - default: - ret = FAIL; - sprintf(mess,"Speed Index (%d) is not implemented for this detector\n",(int) arg); - cprintf(RED, "Warning: %s", mess); - break; - } - } -#endif - if (ret==OK && differentClients) - ret=FORCE_UPDATE; - - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - if (ret==FAIL) { - n += sendData(file_des,mess,sizeof(mess),OTHER); - } else - n += sendData(file_des,&retval,sizeof(retval),INT32); - - // return ok / fail - return ret; -} - - - - - -int execute_trimming(int file_des) { - int ret=OK,ret1=OK; - int n=0; - sprintf(mess,"execute trimming failed\n"); - -#ifndef MYTHEND - //to receive any arguments - while (n > 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - ret = FAIL; - sprintf(mess,"Function (Execute Trimming) is not implemented for this detector\n"); - cprintf(RED, "Warning: %s", mess); -#else - - int retval=-1; - - // receive arguments - enum trimMode mode=0; - int arg[3]={-1,-1,-1}; - n = receiveData(file_des,&mode,sizeof(mode),INT32); - if (n < 0) return printSocketReadError(); - - n = receiveData(file_des,arg,sizeof(arg),INT32); - if (n < 0) return printSocketReadError(); - - // execute action - int imod, par1,par2; - imod=arg[0]; - par1=arg[1]; - par2=arg[2]; - if (differentClients && lockStatus) { - ret = FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - cprintf(RED, "Warning: %s", mess); - } -#ifdef SLS_DETECTOR_FUNCTION_LIST - else if (imod>=getTotalNumberOfModules()) { - ret = FAIL; - sprintf(mess,"Module Number (%d) is out of range\n"); - cprintf(RED, "Warning: %s", mess); - } - else { -#ifdef VERBOSE - printf("trimming module %d mode %d, parameters %d %d \n",imod,mode, par1, par2); -#endif - switch(mode) { - case NOISE_TRIMMING: - case BEAM_TRIMMING: - case IMPROVE_TRIMMING: - case FIXEDSETTINGS_TRIMMING: - retval=executeTrimming(mode, par1, par2, imod); - if ((ret!=OK) && (retval>0)) { - ret=FAIL; - sprintf(mess,"Could not trim %d channels\n", retval); - cprintf(RED, "Warning: %s", mess); - } - break; - default: - ret = FAIL; - sprintf(mess,"Trimming Mode (%d) is not implemented for this detector\n", (int) mode); - cprintf(RED, "Warning: %s", mess); - break; - } - - } -#endif - if (ret==OK && differentClients) - ret=FORCE_UPDATE; -#endif - - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - if (ret==FAIL) { - n += sendData(file_des,mess,sizeof(mess),OTHER); - } - - // return ok / fail - return ret; -} - - - - - -int exit_server(int file_des) { - int ret=FAIL; - sprintf(mess,"Closing Server\n"); - cprintf(BG_RED,"Error: %s",mess); - // send ok / fail - sendData(file_des,&ret,sizeof(ret),INT32); - // send return argument - sendData(file_des,mess,sizeof(mess),OTHER); - return GOODBYE; -} - - - - -int lock_server(int file_des) { - int ret=OK,ret1=OK; - int n=0; - int lock=0; - sprintf(mess,"lock server failed\n"); - - // receive arguments - n = receiveData(file_des,&lock,sizeof(lock),INT32); - if (n < 0) return printSocketReadError(); - - // execute action - if (lock>=0) { - if (lockStatus==0 || strcmp(lastClientIP,thisClientIP)==0 || strcmp(lastClientIP,"none")==0) { - lockStatus=lock; - strcpy(lastClientIP,thisClientIP); - } else { - ret = FAIL; - sprintf(mess,"Server already locked by %s\n", lastClientIP); - cprintf(RED, "Warning: %s", mess); - } - } - if (ret==OK && differentClients) - ret=FORCE_UPDATE; - - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - if (ret==FAIL) { - n += sendData(file_des,mess,sizeof(mess),OTHER); - } else - n += sendData(file_des,&lockStatus,sizeof(lockStatus),INT32); - - // return ok / fail - return ret; -} - - - - - -int get_last_client_ip(int file_des) { - int ret=OK,ret1=OK; - if (differentClients) - ret=FORCE_UPDATE; - // send ok / fail - sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - sendData(file_des,lastClientIP,sizeof(lastClientIP),OTHER); - // return ok / fail - return ret; -} - - - - -int set_port(int file_des) { - int ret=OK,ret1=OK; - int n=0; - enum portType p_type=0; - int p_number=-1; - sprintf(mess,"set port failed\n"); - - // receive arguments - n = receiveData(file_des,&p_type,sizeof(p_type),INT32); - if (n < 0) return printSocketReadError(); - - n = receiveData(file_des,&p_number,sizeof(p_number),INT32); - if (n < 0) return printSocketReadError(); - - // execute action - int sd=-1; - if (differentClients && lockStatus) { - ret = FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - cprintf(RED, "Warning: %s", mess); - } - else { - if (p_number<1024) { - ret = FAIL; - sprintf(mess,"Port Number (%d) too low\n", p_number); - cprintf(RED, "Warning: %s", mess); - } - printf("set port %d to %d\n",p_type, p_number); - sd=bindSocket(p_number); - if (sd<0) { - ret = FAIL; - sprintf(mess,"Could not bind port %d\n", p_number); - cprintf(RED, "Warning: %s", mess); - if (sd==-10) { - ret = FAIL; - sprintf(mess,"Port %d already set\n", p_number); - cprintf(RED, "Warning: %s", mess); - } - } - if (ret==OK && differentClients) - ret=FORCE_UPDATE; - } - - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - if (ret==FAIL) { - n = sendData(file_des,mess,sizeof(mess),OTHER); - } else { - n = sendData(file_des,&p_number,sizeof(p_number),INT32); - closeConnection(file_des); - exitServer(sockfd); - sockfd=sd; - } - - // return ok / fail - return ret; -} - - - - -int update_client(int file_des) { - int ret=OK; - sendData(file_des,&ret,sizeof(ret),INT32); - return send_update(file_des); -} - - - - -int send_update(int file_des) { - int n=0; // if (n<0) should fail to stop talking to a closed client socket - int nm=0; - int64_t retval = 0; - enum detectorSettings t; - - n = sendData(file_des,lastClientIP,sizeof(lastClientIP),OTHER); - if (n < 0) return printSocketReadError(); - - -#ifdef SLS_DETECTOR_FUNCTION_LIST - nm=setNMod(GET_FLAG,X); -#endif - n = sendData(file_des,&nm,sizeof(nm),INT32); - if (n < 0) return printSocketReadError(); - - -#ifdef SLS_DETECTOR_FUNCTION_LIST - nm=setNMod(GET_FLAG,Y); -#endif - n = sendData(file_des,&nm,sizeof(nm),INT32); - if (n < 0) return printSocketReadError(); - - -#ifdef SLS_DETECTOR_FUNCTION_LIST - nm=setDynamicRange(GET_FLAG); -#endif - n = sendData(file_des,&nm,sizeof(nm),INT32); - if (n < 0) return printSocketReadError(); - - -#ifdef SLS_DETECTOR_FUNCTION_LIST - dataBytes=calculateDataBytes(); -#endif - n = sendData(file_des,&dataBytes,sizeof(dataBytes),INT32); - if (n < 0) return printSocketReadError(); - - -#ifdef SLS_DETECTOR_FUNCTION_LIST - t=setSettings(GET_SETTINGS, GET_FLAG); -#endif - n = sendData(file_des,&t,sizeof(t),INT32); - if (n < 0) return printSocketReadError(); - - -#if defined(MYTHEND) || defined(EIGERD) -#ifdef SLS_DETECTOR_FUNCTION_LIST - nm=getThresholdEnergy(GET_FLAG); -#endif - n = sendData(file_des,&nm,sizeof(nm),INT32); - if (n < 0) return printSocketReadError(); -#endif - - -#ifdef SLS_DETECTOR_FUNCTION_LIST - retval=setTimer(FRAME_NUMBER,GET_FLAG); -#endif - n = sendData(file_des,&retval,sizeof(int64_t),INT64); - if (n < 0) return printSocketReadError(); - - -#ifdef SLS_DETECTOR_FUNCTION_LIST - retval=setTimer(ACQUISITION_TIME,GET_FLAG); -#endif - n = sendData(file_des,&retval,sizeof(int64_t),INT64); - if (n < 0) return printSocketReadError(); - - -#ifdef EIGERD -#ifdef SLS_DETECTOR_FUNCTION_LIST - retval=setTimer(SUBFRAME_ACQUISITION_TIME,GET_FLAG); -#endif - n = sendData(file_des,&retval,sizeof(int64_t),INT64); - if (n < 0) return printSocketReadError(); - -#ifdef SLS_DETECTOR_FUNCTION_LIST - retval=setTimer(SUBFRAME_DEADTIME,GET_FLAG); -#endif - n = sendData(file_des,&retval,sizeof(int64_t),INT64); - if (n < 0) return printSocketReadError(); -#endif - - -#ifdef SLS_DETECTOR_FUNCTION_LIST - retval=setTimer(FRAME_PERIOD,GET_FLAG); -#endif - n = sendData(file_des,&retval,sizeof(int64_t),INT64); - if (n < 0) return printSocketReadError(); - - -#ifndef EIGERD -#ifdef SLS_DETECTOR_FUNCTION_LIST - retval=setTimer(DELAY_AFTER_TRIGGER,GET_FLAG); -#endif - n = sendData(file_des,&retval,sizeof(int64_t),INT64); - if (n < 0) return printSocketReadError(); -#endif - - -#if !defined(EIGERD) && !defined(JUNGFRAUD) -#ifdef SLS_DETECTOR_FUNCTION_LIST - retval=setTimer(GATES_NUMBER,GET_FLAG); -#endif - n = sendData(file_des,&retval,sizeof(int64_t),INT64); - if (n < 0) return printSocketReadError(); -#endif - - -#ifdef MYTHEND -#ifdef SLS_DETECTOR_FUNCTION_LIST - retval=setTimer(PROBES_NUMBER,GET_FLAG); -#endif - n = sendData(file_des,&retval,sizeof(int64_t),INT64); - if (n < 0) return printSocketReadError(); -#endif - - -#ifdef SLS_DETECTOR_FUNCTION_LIST - retval=setTimer(CYCLES_NUMBER,GET_FLAG); -#endif - n = sendData(file_des,&retval,sizeof(int64_t),INT64); - if (n < 0) return printSocketReadError(); - - - if (lockStatus==0) { - strcpy(lastClientIP,thisClientIP); - } - - return OK; -} - - - - - - -int configure_mac(int file_des) { - int ret=OK,ret1=OK; - int n=0; - int retval=-100; - sprintf(mess,"configure mac failed\n"); - -#ifdef MYTHEND - //to receive any arguments - while (n > 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - ret = FAIL; - strcpy(mess,"Function (Configure MAC) is not implemented for this detector\n"); - cprintf(RED, "Warning: %s", mess); -#else - - // receive arguments - char arg[6][50]; - memset(arg,0,sizeof(arg)); - n = receiveData(file_des,arg,sizeof(arg),OTHER); -#if defined(JUNGFRAUD) || defined(EIGERD) - int pos[3]={0,0,0}; - n = receiveData(file_des,pos,sizeof(pos),INT32); -#endif - if (n < 0) return printSocketReadError(); - - uint32_t ipad; - uint64_t imacadd; - uint64_t idetectormacadd; - uint32_t udpport; - uint32_t udpport2; - uint32_t detipad; - sscanf(arg[0], "%x", &ipad); -#ifdef VIRTUAL - sscanf(arg[1], "%lx", &imacadd); -#else - sscanf(arg[1], "%llx", &imacadd); -#endif - sscanf(arg[2], "%x", &udpport); -#ifdef VIRTUAL - sscanf(arg[3], "%lx", &idetectormacadd); -#else - sscanf(arg[3], "%llx", &idetectormacadd); -#endif - sscanf(arg[4], "%x", &detipad); - sscanf(arg[5], "%x", &udpport2); - - if (differentClients && lockStatus) { - ret = FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - cprintf(RED, "Warning: %s", mess); - } -#ifdef SLS_DETECTOR_FUNCTION_LIST - else { -#ifdef VERBOSE - int i; - //#ifdef GOTTHARD - //printf("\ndigital_test_bit in server %d\t",digitalTestBit); - //#endif - printf("\nipadd %x\t",ipad); - printf("destination ip is %d.%d.%d.%d = 0x%x \n",(ipad>>24)&0xff,(ipad>>16)&0xff,(ipad>>8)&0xff,(ipad)&0xff,ipad); - printf("macad:%llx\n",imacadd); - for (i=0;i<6;i++) - printf("mac adress %d is 0x%x \n",6-i,(unsigned int)(((imacadd>>(8*i))&0xFF))); - printf("udp port:0x%x\n",udpport); - printf("detector macad:%llx\n",idetectormacadd); - for (i=0;i<6;i++) - printf("detector mac adress %d is 0x%x \n",6-i,(unsigned int)(((idetectormacadd>>(8*i))&0xFF))); - printf("detipad %x\n",detipad); - printf("udp port2:0x%x\n",udpport2); - printf("\n"); - printf("Configuring MAC of module %d at port %x\n", imod, udpport); - -#if defined(JUNGFRAUD) || defined(EIGERD) - printf("Position: [%d,%d,%d]\n", pos[0],pos[1],pos[2]); -#endif -#endif - if(getRunStatus() == RUNNING){ - ret = stopStateMachine(); - } - if(ret==FAIL) { - sprintf(mess,"Could not stop detector acquisition to configure mac\n"); - cprintf(RED, "Warning: %s", mess); - } - else { -#ifdef EIGERD - // change mac to hardware mac, (for 1 gbe) change ip to hardware ip - if (idetectormacadd != getDetectorMAC()){ - printf("*************************************************\n"); - printf("WARNING: actual detector mac address %llx does not match " - "the one from client %llx\n", - (long long unsigned int)getDetectorMAC(), - (long long unsigned int)idetectormacadd); - idetectormacadd = getDetectorMAC(); - printf("WARNING: Matched detectormac to the hardware mac now\n"); - printf("*************************************************\n"); - } - - // always remember the ip sent from the client (could be for 10g(if not dhcp)) - if (detipad != getDetectorIP()) - dhcpipad = detipad; - - //only for 1Gbe - if(!enableTenGigabitEthernet(-1)){ - printf("*************************************************\n"); - printf("WARNING: Using DHCP IP for Configuring MAC\n"); - printf("*************************************************\n"); - detipad = getDetectorIP(); - } else - detipad = dhcpipad; -#endif - retval=configureMAC(ipad,imacadd,idetectormacadd,detipad,udpport,udpport2,0); //digitalTestBit); - if(retval==-1) { - ret = FAIL; - sprintf(mess,"Configure Mac failed\n"); - cprintf(RED, "Warning: %s", mess); - } - else { - printf("Configure MAC successful\n"); -#if defined(JUNGFRAUD) || defined(EIGERD) - ret = setDetectorPosition(pos); - if (ret == FAIL) { - sprintf(mess,"could not set detector position\n"); - cprintf(RED, "Warning: %s", mess); - } -#endif - } -#ifdef VERBOSE - printf("Configured MAC with retval %d\n", retval); -#endif - } - - } -#endif - if (differentClients) - ret=FORCE_UPDATE; -#endif - - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - if (ret==FAIL) { - n += sendData(file_des,mess,sizeof(mess),OTHER); - } else { - n += sendData(file_des,&retval,sizeof(retval),INT32); -#ifdef EIGERD - char arg[2][50]; - memset(arg,0,sizeof(arg)); - sprintf(arg[0],"%llx",(long long unsigned int)idetectormacadd); - sprintf(arg[1],"%x",detipad); - n += sendData(file_des,arg,sizeof(arg),OTHER); -#endif - } - // return ok / fail - return ret; -} - - - - - -int load_image(int file_des) { - int ret=OK,ret1=OK; - int n=0; - int retval=-1; - sprintf(mess,"Loading image failed\n"); - -#ifndef GOTTHARDD - //to receive any arguments - while (n > 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - ret = FAIL; - sprintf(mess,"Function (Load Image) is not implemented for this detector\n"); - cprintf(RED, "Warning: %s", mess); -#else - - // receive arguments - enum imageType index=0; - char ImageVals[dataBytes]; - memset(ImageVals,0,dataBytes); - n = receiveData(file_des,&index,sizeof(index),INT32); - if (n < 0) return printSocketReadError(); - - n = receiveData(file_des,ImageVals,dataBytes,OTHER); - if (n < 0) return printSocketReadError(); - - // execute action - if (differentClients && lockStatus) { - ret = FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - cprintf(RED, "Warning: %s", mess); - } -#ifdef SLS_DETECTOR_FUNCTION_LIST - else { - switch (index) { - case DARK_IMAGE : -#ifdef VERBOSE - printf("Loading Dark image\n"); -#endif - case GAIN_IMAGE : -#ifdef VERBOSE - printf("Loading Gain image\n"); -#endif - retval=loadImage(index,ImageVals); - if (retval==-1) { - ret = FAIL; - cprintf(RED, "Warning: %s", mess); - } - break; - default: - ret = FAIL; - sprintf(mess,"Load Image Index (%d) is not implemented for this detector\n", (int)index); - cprintf(RED, "Warning: %s", mess); - break; - } - } -#endif - if (ret==OK && differentClients) - ret=FORCE_UPDATE; -#endif - - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - if (ret==FAIL) { - n += sendData(file_des,mess,sizeof(mess),OTHER); - } else - n += sendData(file_des,&retval,sizeof(retval),INT32); - - // return ok / fail - return ret; -} - - - - - -int set_master(int file_des) { - int ret=OK,ret1=OK; - int n=0; - enum masterFlags arg=GET_MASTER; - enum masterFlags retval=GET_MASTER; - sprintf(mess,"set master failed\n"); - - // receive arguments - n = receiveData(file_des,&arg,sizeof(arg),INT32); - if (n < 0) return printSocketReadError(); - - // execute action - if (differentClients && lockStatus && ((int)arg!=(int)GET_MASTER)) { - ret = FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - cprintf(RED, "Warning: %s", mess); - } -#ifdef SLS_DETECTOR_FUNCTION_LIST - else { -#ifdef VERBOSE - printf("setting master flags to %d\n",arg); -#endif - retval=setMaster(arg); - if (retval==GET_MASTER) - ret=FAIL; - - if (ret==OK && differentClients) - ret=FORCE_UPDATE; - } -#endif - - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - if (ret==FAIL) { - n += sendData(file_des,mess,sizeof(mess),OTHER); - } else - n += sendData(file_des,&retval,sizeof(retval),INT32); - - // return ok / fail - return ret; -} - - - - - - - -int set_synchronization(int file_des) { - int ret=OK,ret1=OK; - int n=0; - enum synchronizationMode arg=GET_SYNCHRONIZATION_MODE; - enum synchronizationMode retval=GET_SYNCHRONIZATION_MODE; - sprintf(mess,"synchronization mode failed\n"); - - // receive arguments - n = receiveData(file_des,&arg,sizeof(arg),INT32); - if (n < 0) return printSocketReadError(); - - // execute action - if (differentClients && lockStatus && ((int)arg!=(int)GET_SYNCHRONIZATION_MODE)) { - ret = FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - cprintf(RED, "Warning: %s", mess); - } -#ifdef SLS_DETECTOR_FUNCTION_LIST - else { -#ifdef VERBOSE - printf("setting master flags to %d\n",arg); -#endif - retval=setSynchronization(arg); - if (retval==GET_SYNCHRONIZATION_MODE) - ret=FAIL; - - if (ret==OK && differentClients) - ret=FORCE_UPDATE; - } -#endif - - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - if (ret==FAIL) { - n += sendData(file_des,mess,sizeof(mess),OTHER); - } else - n += sendData(file_des,&retval,sizeof(retval),INT32); - - // return ok / fail - return ret; -} - - - - - -int read_counter_block(int file_des) { - int ret=OK,ret1=OK; - int n=0; - char CounterVals[dataBytes]; - memset(CounterVals,0,dataBytes); - sprintf(mess,"Read counter block failed\n"); - -#ifndef GOTTHARDD - //to receive any arguments - while (n > 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - ret = FAIL; - sprintf(mess,"Function (Read Counter Block) is not implemented for this detector\n"); - cprintf(RED, "Warning: %s", mess); -#else - - // receive arguments - int startACQ=-1; - n = receiveData(file_des,&startACQ,sizeof(startACQ),INT32); - if (n < 0) return printSocketReadError(); - - // execute action - if (differentClients && lockStatus) { - ret = FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - cprintf(RED, "Warning: %s", mess); - } -#ifdef SLS_DETECTOR_FUNCTION_LIST - else { - ret=readCounterBlock(startACQ,CounterVals); - if (ret == FAIL) - cprintf(RED, "Warning: %s", mess); -#ifdef VERBOSE - int i; - for(i=0;i<6;i++) - printf("%d:%d\t",i,CounterVals[i]); -#endif - } -#endif - if (ret==OK && differentClients) - ret=FORCE_UPDATE; -#endif - - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - if (ret==FAIL) { - n += sendData(file_des,mess,sizeof(mess),OTHER); - } else - n += sendData(file_des,CounterVals,dataBytes,OTHER); - - // return ok / fail - return ret; -} - - - - - -int reset_counter_block(int file_des) { - int ret=OK,ret1=OK; - int n=0; - sprintf(mess,"Reset counter block failed\n"); - -#ifndef GOTTHARDD - //to receive any arguments - while (n > 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - ret = FAIL; - sprintf(mess,"Function (Reset Counter Block) is not implemented for this detector\n"); - cprintf(RED, "Warning: %s", mess); -#else - - // receive arguments - int startACQ=-1; - n = receiveData(file_des,&startACQ,sizeof(startACQ),INT32); - if (n < 0) return printSocketReadError(); - - // execute action - if (differentClients && lockStatus) { - ret = FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - cprintf(RED, "Warning: %s", mess); - } -#ifdef SLS_DETECTOR_FUNCTION_LIST - else { - ret=resetCounterBlock(startACQ); - if (ret == FAIL) - cprintf(RED, "Warning: %s", mess); - } -#endif - if (ret==OK && differentClients) - ret=FORCE_UPDATE; -#endif - - - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - if (ret==FAIL) { - n += sendData(file_des,mess,sizeof(mess),OTHER); - } - - // return ok / fail - return ret; -} - - - - - -int calibrate_pedestal(int file_des){ - int ret=OK,ret1=OK; - int n=0; - int retval=-1; - sprintf(mess,"calibrate pedestal failed\n"); - - -#ifndef GOTTHARDD - //to receive any arguments - while (n > 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - ret = FAIL; - sprintf(mess,"Function (Calibrate Pedestal) is not implemented for this detector\n"); - cprintf(RED, "Warning: %s", mess); -#else - - // receive arguments - int frames=-1; - n = receiveData(file_des,&frames,sizeof(frames),INT32); - if (n < 0) return printSocketReadError(); - - - // execute action - if (differentClients && lockStatus) { - ret = FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - cprintf(RED, "Warning: %s", mess); - } -#ifdef SLS_DETECTOR_FUNCTION_LIST - else { - ret=calibratePedestal(frames); - if (ret == FAIL) - cprintf(RED, "Warning: %s", mess); - } -#endif - if(ret==OK && differentClients) - ret=FORCE_UPDATE; -#endif - - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - if (ret==FAIL) { - n += sendData(file_des,mess,sizeof(mess),OTHER); - } else - n += sendData(file_des,&retval,sizeof(retval),INT32); - - // return ok / fail - return ret; -} - - - - - - - - -int enable_ten_giga(int file_des) { - int ret=OK,ret1=OK; - int n=0; - int retval=-1; - sprintf(mess,"Enabling/disabling 10GbE failed\n"); - - // execute action -#ifndef EIGERD - //to receive any arguments - while (n > 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - ret = FAIL; - sprintf(mess,"Function (Enable 10 GbE) is not implemented for this detector\n"); - cprintf(RED, "Warning: %s", mess); -#else - - // receive arguments - int arg=-1; - n = receiveData(file_des,&arg,sizeof(arg),INT32); - if (n < 0) return printSocketReadError(); - - // execute action - if (differentClients && lockStatus && arg!=-1) { - ret = FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - cprintf(RED, "Warning: %s", mess); - } -#ifdef SLS_DETECTOR_FUNCTION_LIST - else { -#ifdef VERBOSE - printf("Enabling/Disabling 10Gbe :%d \n",arg); -#endif - retval=enableTenGigabitEthernet(arg); - if((arg != -1) && (retval != arg)) { - ret=FAIL; - cprintf(RED, "Warning: %s", mess); - } - else if (differentClients) - ret=FORCE_UPDATE; - } -#endif -#endif - - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - if (ret==FAIL) { - n += sendData(file_des,mess,sizeof(mess),OTHER); - } - n += sendData(file_des,&retval,sizeof(retval),INT32); - - // return ok / fail - return ret; -} - - - - -int set_all_trimbits(int file_des){ - int ret=OK,ret1=OK; - int n=0; - int retval=-1; - sprintf(mess,"setting all trimbits failed\n"); - -#ifndef EIGERD - //to receive any arguments - while (n > 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - ret = FAIL; - sprintf(mess,"Function (Set All Trimbits) is not implemented for this detector\n"); - cprintf(RED, "Warning: %s", mess); -#else - - // receive arguments - int arg=-1; - n = receiveData(file_des,&arg,sizeof(arg),INT32); - if (n < 0) return printSocketReadError(); - - - // execute action - if (differentClients && lockStatus && arg!=-1) { - ret = FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - cprintf(RED, "Warning: %s", mess); - } -#ifdef SLS_DETECTOR_FUNCTION_LIST - else { -#ifdef VERBOSE - printf("setting all trimbits to %d\n",arg); -#endif - if(arg < -1){ - ret = FAIL; - strcpy(mess,"Cant set trimbits to this value\n"); - cprintf(RED, "Warning: %s", mess); - }else { - if(arg >= 0){ - ret = setAllTrimbits(arg); - //changes settings to undefined - setSettings(UNDEFINED,-1); - cprintf(RED,"Settings has been changed to undefined (change all trimbits)\n"); - } - retval = getAllTrimbits(); - if (arg!=-1 && arg!=retval) { - ret=FAIL; - sprintf(mess,"Could not set all trimbits: should be %d but is %d\n", arg, retval); - cprintf(RED, "Warning: %s", mess); - } - } - } -#endif - if (ret==OK && differentClients) - ret=FORCE_UPDATE; -#endif - - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - if (ret==FAIL) { - n += sendData(file_des,mess,sizeof(mess),OTHER); - } else - n += sendData(file_des,&retval,sizeof(retval),INT32); - - // return ok / fail - return ret; -} - - -int set_ctb_pattern(int file_des) { - int ret=OK,ret1=OK; - int n=0; - sprintf(mess,"Could not set pattern\n"); - -#ifndef MYTHEN3D - //to receive any arguments - while (n > 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - - ret = FAIL; - sprintf(mess,"Function (Set CTB Pattern) is not implemented for this detector\n"); - cprintf(RED, "Error: %s", mess); - - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - n += sendData(file_des,mess,sizeof(mess),OTHER); - - return ret; - -#else - - int retval=-1; - int mode = -1; - int addr = -1, level = -1, nl = -1, start = -1, stop = -1; - uint64_t word = -1,retval64 = -1, t = -1; - - n = receiveDataOnly(file_des, &mode, sizeof(mode)); - printf("pattern mode is %d\n",mode); - - switch (mode) { - - case 0: //sets word - n = receiveDataOnly(file_des,&addr,sizeof(addr)); - n = receiveDataOnly(file_des,&word,sizeof(word)); - ret=OK; - - printf("pattern addr is %d %llx\n",addr, word); - switch (addr) { - case -1: - retval64=writePatternIOControl(word); - break; - case -2: - retval64=writePatternClkControl(word); - break; - default: - retval64=writePatternWord(addr,word); - }; - - - //write word; - //@param addr address of the word, -1 is I/O control register, -2 is clk control register - //@param word 64bit word to be written, -1 gets - - n = sendDataOnly(file_des,&ret,sizeof(ret)); - if (ret==FAIL) - n += sendDataOnly(file_des,mess,sizeof(mess)); - else - n += sendDataOnly(file_des,&retval64,sizeof(retval64)); - break; - - case 1: //pattern loop - // printf("loop\n"); - n = receiveDataOnly(file_des,&level,sizeof(level)); - n = receiveDataOnly(file_des,&start,sizeof(start)); - n = receiveDataOnly(file_des,&stop,sizeof(stop)); - n = receiveDataOnly(file_des,&nl,sizeof(nl)); - - - - // printf("level %d start %x stop %x nl %d\n",level, start, stop, nl); - /** Sets the pattern or loop limits in the CTB - @param level -1 complete pattern, 0,1,2, loop level - @param start start address if >=0 - @param stop stop address if >=0 - @param n number of loops (if level >=0) - @returns OK/FAIL - */ - ret=setPatternLoop(level, &start, &stop, &nl); - - n = sendDataOnly(file_des,&ret,sizeof(ret)); - if (ret==FAIL) - n += sendDataOnly(file_des,mess,sizeof(mess)); - else { - n += sendDataOnly(file_des,&start,sizeof(start)); - n += sendDataOnly(file_des,&stop,sizeof(stop)); - n += sendDataOnly(file_des,&nl,sizeof(nl)); - } - break; - - - - case 2: //wait address - printf("wait\n"); - n = receiveDataOnly(file_des,&level,sizeof(level)); - n = receiveDataOnly(file_des,&addr,sizeof(addr)); - - - - /** Sets the wait address in the CTB - @param level 0,1,2, wait level - @param addr wait address, -1 gets - @returns actual value - */ - printf("wait addr %d %x\n",level, addr); - retval=setPatternWaitAddress(level,addr); - printf("ret: wait addr %d %x\n",level, retval); - ret=OK; - n = sendDataOnly(file_des,&ret,sizeof(ret)); - if (ret==FAIL) - n += sendDataOnly(file_des,mess,sizeof(mess)); - else { - n += sendDataOnly(file_des,&retval,sizeof(retval)); - - } - - - break; - - - case 3: //wait time - printf("wait time\n"); - n = receiveDataOnly(file_des,&level,sizeof(level)); - n = receiveDataOnly(file_des,&t,sizeof(t)); - - - /** Sets the wait time in the CTB - @param level 0,1,2, wait level - @param t wait time, -1 gets - @returns actual value - */ - - ret=OK; - - retval64=setPatternWaitTime(level,t); - - n = sendDataOnly(file_des,&ret,sizeof(ret)); - if (ret==FAIL) - n += sendDataOnly(file_des,mess,sizeof(mess)); - else - n += sendDataOnly(file_des,&retval64,sizeof(retval64)); - - break; - - - - case 4: - n = receiveDataOnly(file_des,pat,sizeof(pat)); - for (addr=0; addr<1024; addr++) - writePatternWord(addr,word); - ret=OK; - retval=0; - n = sendDataOnly(file_des,&ret,sizeof(ret)); - if (ret==FAIL) - n += sendDataOnly(file_des,mess,sizeof(mess)); - else - n += sendDataOnly(file_des,&retval64,sizeof(retval64)); - - break; - - - - default: - ret=FAIL; - printf(mess); - sprintf(mess,"%s - wrong mode %d\n",mess, mode); - n = sendDataOnly(file_des,&ret,sizeof(ret)); - n += sendDataOnly(file_des,mess,sizeof(mess)); - } - - - // return ok / fail - return ret; -#endif -} - - - -int write_adc_register(int file_des) { - int ret=OK, ret1=OK; - int n=0; - int retval=-1; - sprintf(mess,"write to adc register failed\n"); - -#ifndef JUNGFRAUD - //to receive any arguments - while (n > 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - ret = FAIL; - sprintf(mess,"Function (Write ADC Register) is not implemented for this detector\n"); - cprintf(RED, "Warning: %s", mess); -#else - - // receive arguments - int arg[2]={-1,-1}; - n = receiveData(file_des,arg,sizeof(arg),INT32); - if (n < 0) return printSocketReadError(); - int addr=arg[0]; - int val=arg[1]; - - // execute action - if (differentClients && lockStatus) { - ret = FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - cprintf(RED, "Warning: %s", mess); - } - else { -#ifdef VERBOSE - printf("writing to register 0x%x data 0x%x\n", addr, val); -#endif - setAdc(addr,val); -#ifdef VERBOSE - printf("Data set to 0x%x\n", retval); -#endif - if (ret==OK && differentClients) - ret=FORCE_UPDATE; - } -#endif - - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - if (ret==FAIL) { - n += sendData(file_des,mess,sizeof(mess),OTHER); - } else - n += sendData(file_des,&retval,sizeof(retval),INT32); - - // return ok / fail - return ret; -} - - - - -int set_counter_bit(int file_des) { - int ret=OK,ret1=OK; - int n=0; - int retval=-1; - sprintf(mess,"set counter bit failed \n"); - -#ifndef EIGERD - //to receive any arguments - while (n > 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - ret = FAIL; - strcpy(mess,"Function (Set Counter Bit) is not implemented for this detector\n"); - cprintf(RED, "Warning: %s", mess); -#else - - // receive arguments - int arg=-1; - n = receiveData(file_des,&arg,sizeof(arg),INT32); - if (n < 0) return printSocketReadError(); - - // execute action - if (differentClients && lockStatus && arg!=-1) { - ret = FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - cprintf(RED, "Warning: %s", mess); - } -#ifdef SLS_DETECTOR_FUNCTION_LIST - else { -#ifdef VERBOSE - printf("Getting/Setting/Resetting counter bit :%d \n",arg); -#endif - retval=setCounterBit(arg); - if((arg != -1) && (retval != arg)) { - ret=FAIL; - cprintf(RED, "Warning: %s", mess); - } - if (ret==OK && differentClients) - ret=FORCE_UPDATE; - } -#endif -#endif - - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - if (ret==FAIL) { - n += sendData(file_des,mess,sizeof(mess),OTHER); - } - n += sendData(file_des,&retval,sizeof(retval),INT32); - - // return ok / fail - return ret; -} - - - - -int pulse_pixel(int file_des) { - int ret=OK,ret1=OK; - int n=0; - sprintf(mess,"pulse pixel failed\n"); - -#ifndef EIGERD - //to receive any arguments - while (n > 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - ret = FAIL; - strcpy(mess,"Function (Pulse Pixel) is not implemented for this detector\n"); - cprintf(RED, "Warning: %s", mess); -#else - - // receive arguments - int arg[3]={-1,-1,-1}; - n = receiveData(file_des,arg,sizeof(arg),INT32); - if (n < 0) return printSocketReadError(); - - // execute action - if (differentClients && lockStatus) { - ret = FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - cprintf(RED, "Warning: %s", mess); - } -#ifdef SLS_DETECTOR_FUNCTION_LIST - else { - ret=pulsePixel(arg[0],arg[1],arg[2]); - if (ret == FAIL) - cprintf(RED, "Warning: %s", mess); - } -#endif - if (ret==OK && differentClients) - ret=FORCE_UPDATE; -#endif - - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - if (ret==FAIL) { - n += sendData(file_des,mess,sizeof(mess),OTHER); - } - - // return ok / fail - return ret; -} - - - - -int pulse_pixel_and_move(int file_des) { - int ret=OK,ret1=OK; - int n=0; - sprintf(mess,"pulse pixel and move failed\n"); - -#ifndef EIGERD - //to receive any arguments - while (n > 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - ret = FAIL; - strcpy(mess,"Function (Pulse Pixel and Move) is not implemented for this detector\n"); - cprintf(RED, "Warning: %s", mess); -#else - - // receive arguments - int arg[3]={-1,-1,-1}; - n = receiveData(file_des,arg,sizeof(arg),INT32); - if (n < 0) return printSocketReadError(); - - // execute action - if (differentClients && lockStatus) { - ret = FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - cprintf(RED, "Warning: %s", mess); - } -#ifdef SLS_DETECTOR_FUNCTION_LIST - else { - ret=pulsePixelNMove(arg[0],arg[1],arg[2]); - if (ret == FAIL) - cprintf(RED, "Warning: %s", mess); - } -#endif - if(ret==OK && differentClients) - ret=FORCE_UPDATE; -#endif - - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - if (ret==FAIL) { - n += sendData(file_des,mess,sizeof(mess),OTHER); - } - - // return ok / fail - return ret; -} - - - - - - -int pulse_chip(int file_des) { - int ret=OK,ret1=OK; - int n=0; - sprintf(mess,"pulse chip failed\n"); - -#ifndef EIGERD - //to receive any arguments - while (n > 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - ret = FAIL; - strcpy(mess,"Function (Pulse Chip) is not implemented for this detector\n"); - cprintf(RED, "Warning: %s", mess); -#else - - // receive arguments - int arg = -1; - n = receiveData(file_des,&arg,sizeof(arg),INT32); - if (n < 0) return printSocketReadError(); - - // execute action - if (differentClients && lockStatus) { - ret = FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - cprintf(RED, "Warning: %s", mess); - } -#ifdef SLS_DETECTOR_FUNCTION_LIST - else { - ret=pulseChip(arg); - if (ret == FAIL) - cprintf(RED, "Warning: %s", mess); - } -#endif - if(ret==OK && differentClients) - ret=FORCE_UPDATE; -#endif - - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - if (ret==FAIL) { - n += sendData(file_des,mess,sizeof(mess),OTHER); - } - - // return ok / fail - return ret; -} - - - - - -int set_rate_correct(int file_des) { - int ret=OK,ret1=OK; - int n=0; - sprintf(mess,"Set rate correct failed\n"); - -#ifndef EIGERD - //to receive any arguments - while (n > 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - ret=FAIL; - sprintf(mess,"Function (Rate Correction) is not implemented for this detector\n"); - cprintf(RED, "Warning: %s", mess); -#else - - // receive arguments - int64_t tau_ns=-1; - n = receiveData(file_des,&tau_ns,sizeof(tau_ns),INT64); - if (n < 0) return printSocketReadError(); - - // execute action - if (differentClients && lockStatus) { - ret = FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - cprintf(RED, "Warning: %s", mess); - } -#ifdef SLS_DETECTOR_FUNCTION_LIST - else { - printf("Setting rate correction to %lld ns\n",(long long int)tau_ns); - //set rate - //wrong bit mode - if((setDynamicRange(-1)!=32) && (setDynamicRange(-1)!=16) && (tau_ns!=0)){ - ret=FAIL; - strcpy(mess,"Rate correction Deactivated, must be in 32 or 16 bit mode\n"); - cprintf(RED, "Warning: %s", mess); - } - //16 or 32 bit mode - else{ - if(tau_ns < 0) - tau_ns = getDefaultSettingsTau_in_nsec(); - else if(tau_ns > 0){ - //changing tau to a user defined value changes settings to undefined - setSettings(UNDEFINED,-1); - cprintf(RED,"Settings has been changed to undefined (tau changed)\n"); - } - - int64_t retval = setRateCorrection(tau_ns); - if(tau_ns != retval){ - ret=FAIL; - cprintf(RED, "Warning: %s", mess); - } - } - } -#endif - if (ret==OK && differentClients) - ret=FORCE_UPDATE; -#endif - - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - if (ret==FAIL) { - n = sendData(file_des,mess,sizeof(mess),OTHER); - } - - // return ok / fail - return ret; -} - - - - - -int get_rate_correct(int file_des) { - int ret=OK,ret1=OK; - int n=0; - int64_t retval=-1; - sprintf(mess,"Get Rate correct failed\n"); - -#ifndef EIGERD - //to receive any arguments - while (n > 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - ret=FAIL; - sprintf(mess,"Function (Get Rate Correction) is not implemented for this detector\n"); - cprintf(RED, "Warning: %s", mess); -#else - -#ifdef SLS_DETECTOR_FUNCTION_LIST - - // execute action - retval = getCurrentTau(); - printf("Getting rate correction %lld\n",(long long int)retval); - -#endif - if (ret==OK && differentClients) - ret=FORCE_UPDATE; -#endif - - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - if (ret==FAIL) { - n += sendData(file_des,mess,sizeof(mess),OTHER); - } else - n += sendData(file_des,&retval,sizeof(retval),INT64); - - // return ok / fail - return ret; -} - - - - - -int set_network_parameter(int file_des) { - int ret=OK,ret1=OK; - int n=0; - int retval=-1; - sprintf(mess,"set network parameter failed\n"); - -#if !defined(EIGERD) && !defined(JUNGFRAUD) - //to receive any arguments - while (n > 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - ret=FAIL; - sprintf(mess,"Function(Set Network Parmaeter) is not implemented for this detector\n"); - cprintf(RED, "Warning: %s", mess); -#else - - enum NETWORKINDEX index; - - // receive arguments - enum networkParameter mode=0; - int value=-1; - n = receiveData(file_des,&mode,sizeof(mode),INT32); - if (n < 0) return printSocketReadError(); - - n = receiveData(file_des,&value,sizeof(value),INT32); - if (n < 0) return printSocketReadError(); - - // execute action - if (differentClients && lockStatus && value >= 0) { - ret = FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - cprintf(RED, "Warning: %s", mess); - } -#ifdef SLS_DETECTOR_FUNCTION_LIST - else { -#ifdef VERBOSE - printf("setting network parameter mode %d to %d\n",(int)mode,value); -#endif - switch (mode) { - -#ifdef EIGERD - case FLOW_CONTROL_10G: - index = FLOWCTRL_10G; - break; - case DETECTOR_TXN_DELAY_LEFT: - index = TXN_LEFT; - break; - case DETECTOR_TXN_DELAY_RIGHT: - index = TXN_RIGHT; - break; -#endif - case DETECTOR_TXN_DELAY_FRAME: - index = TXN_FRAME; -#ifdef JUNGFRAUD - if (value > MAX_TIMESLOT_VAL) { - ret=FAIL; - sprintf(mess,"Transmission delay %d should be in range: 0 - %d\n", value, MAX_TIMESLOT_VAL); - cprintf(RED, "Warning: %s", mess); - } -#endif - break; - default: - ret=FAIL; - sprintf(mess,"Network Parameter Index (%d) is not implemented for this detector\n",(int) mode); - cprintf(RED, "Warning: %s", mess); - break; - } - if (ret==OK) { - retval=setNetworkParameter(index, value); - if ((retval!=value) && (value>=0)) { - ret=FAIL; - sprintf(mess,"could not change network parameter mode %d: should be %d but is %d \n",index, value, retval); - cprintf(RED, "Warning: %s", mess); - } - } - } -#endif - if (ret==OK && differentClients) - ret=FORCE_UPDATE; -#endif - - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - if (ret==FAIL) { - n += sendData(file_des,mess,sizeof(mess),OTHER); - } else - n += sendData(file_des,&retval,sizeof(retval),INT32); - - // return ok / fail - return ret; -} - - - - - - -int program_fpga(int file_des) { - int ret=OK,ret1=OK; - int n=0; - sprintf(mess,"program FPGA failed\n"); - -#ifndef JUNGFRAUD - //to receive any arguments - while (n > 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - ret=FAIL; - sprintf(mess,"Function (Program FPGA) is not implemented for this detector\n"); - cprintf(RED, "Warning: %s", mess); -#else - if (!debugflag) { - //to receive any arguments - while (n > 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - ret=FAIL; - sprintf(mess,"FPGA cannot be programmed in this mode. " - "Restart on-board detector server with -update for update mode to continue.\n"); - cprintf(RED, "Warning: %s", mess); - } - - else { - printf("Programming FPGA..."); - size_t filesize = 0; - size_t totalsize = 0; - size_t unitprogramsize = 0; - char* fpgasrc = NULL; - FILE* fp = NULL; - - // receive arguments - filesize - n = receiveData(file_des,&filesize,sizeof(filesize),INT32); - if (n < 0) return printSocketReadError(); - totalsize = filesize; -#ifdef VERY_VERBOSE - printf("\n\n Total size is:%d\n",totalsize); -#endif - - // execute action - if (differentClients && lockStatus) { - ret = FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - cprintf(RED, "Warning: %s", mess); - } -#ifdef SLS_DETECTOR_FUNCTION_LIST - else { - //opening file pointer to flash and telling FPGA to not touch flash - if(startWritingFPGAprogram(&fp) != OK) { - ret=FAIL; - sprintf(mess,"Could not write to flash. Error at startup.\n"); - cprintf(RED,"%s",mess); - } - - //---------------- first ret ---------------- - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - if (ret==FAIL) { - n += sendData(file_des,mess,sizeof(mess),OTHER); - } - //---------------- first ret ---------------- - - if(ret!=FAIL) { - //erasing flash - eraseFlash(); - fpgasrc = (char*)malloc(MAX_FPGAPROGRAMSIZE); - } - - //writing to flash part by part - while(ret != FAIL && filesize){ - - unitprogramsize = MAX_FPGAPROGRAMSIZE; //2mb - if(unitprogramsize > filesize) //less than 2mb - unitprogramsize = filesize; -#ifdef VERY_VERBOSE - printf("unit size to receive is:%d\n",unitprogramsize); - printf("filesize:%d currentpointer:%d\n",filesize,currentPointer); -#endif - - //receive - n = receiveData(file_des,fpgasrc,unitprogramsize,OTHER); - if (n < 0) return printSocketReadError(); - - if(!(unitprogramsize - filesize)){ - fpgasrc[unitprogramsize]='\0'; - filesize-=unitprogramsize; - unitprogramsize++; - }else - filesize-=unitprogramsize; - - ret = writeFPGAProgram(fpgasrc,unitprogramsize,fp); - - //---------------- middle rets ---------------- - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - if (ret==FAIL) { - n += sendData(file_des,mess,sizeof(mess),OTHER); - cprintf(RED,"Failure: Breaking out of program receiving\n"); - } - //---------------- middle rets ---------------- - - if(ret != FAIL){ - //print progress - printf("Writing to Flash:%d%%\r",(int) (((double)(totalsize-filesize)/totalsize)*100) ); - fflush(stdout); - } - } - - printf("\n"); - - //closing file pointer to flash and informing FPGA - stopWritingFPGAprogram(fp); - - //free resources - if(fpgasrc != NULL) - free(fpgasrc); - if(fp!=NULL) - fclose(fp); -#ifdef VERY_VERBOSE - printf("Done with program receiving command\n"); -#endif - - if (isControlServer) { - basictests(debugflag); - initControlServer(); - } - } -#endif - if (ret==OK) - ret=FORCE_UPDATE; - } -#endif - - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - if (ret==FAIL) { - n += sendData(file_des,mess,sizeof(mess),OTHER); - } - - // return ok / fail - return ret; -} - - - - - -int reset_fpga(int file_des) { - int ret=OK,ret1=OK; - int n=0; - sprintf(mess,"Reset FPGA unsuccessful\n"); - -#ifndef JUNGFRAUD - //to receive any arguments - while (n > 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - ret = FAIL; - sprintf(mess,"Function (Reset FPGA) is not implemented for this detector\n"); cprintf(RED, "%s", mess); -#else - - // execute action - if (differentClients && lockStatus) { - ret = FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - cprintf(RED, "Warning: %s", mess); - } -#ifdef SLS_DETECTOR_FUNCTION_LIST - else { - if (isControlServer) { - basictests(debugflag); // mapping of control server at lease -#ifdef JUNGFRAUD - if (debugflag != PROGRAMMING_MODE) -#endif - initControlServer(); - } - else initStopServer(); //remapping of stop server - ret = FORCE_UPDATE; - } -#endif -#endif - - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - if (ret==FAIL) { - n += sendData(file_des,mess,sizeof(mess),OTHER); - } - - // return ok / fail - return ret; -} - - - -int power_chip(int file_des) { - int ret=OK,ret1=OK; - int n=0; - int retval=-1; - sprintf(mess,"power chip failed\n"); - -#ifndef JUNGFRAUD - //to receive any arguments - while (n > 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - ret = FAIL; - sprintf(mess,"Function (Power Chip) is not implemented for this detector\n"); - cprintf(RED, "%s", mess); -#else - - // receive arguments - int arg=-1; - n = receiveData(file_des,&arg,sizeof(arg),INT32); - if (n < 0) return printSocketReadError(); - - // execute action - if (differentClients && lockStatus && arg!=-1) { - ret = FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - cprintf(RED, "Warning: %s", mess); - } -#ifdef SLS_DETECTOR_FUNCTION_LIST - else { -#ifdef VERBOSE - printf("Power chip to %d\n", arg); -#endif - retval=powerChip(arg); - -#ifdef VERBOSE - printf("Chip powered: %d\n",retval); -#endif - if (retval==arg || arg<0) { - ret=OK; - } else { - ret=FAIL; - if(setTemperatureEvent(-1) == 1) - sprintf(mess,"Powering chip failed due to over-temperature event. Clear event & power chip again. Wrote %d, read %d \n", arg, retval); - else - sprintf(mess,"Powering chip failed, wrote %d but read %d\n", arg, retval); - cprintf(RED, "Warning: %s", mess); - } - } -#endif - if (ret==OK && differentClients) - ret=FORCE_UPDATE; -#endif - - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - if (ret==FAIL) { - n += sendData(file_des,mess,sizeof(mess),OTHER); - } else - n += sendData(file_des,&retval,sizeof(retval),INT32); - - // return ok / fail - return ret; -} - - - - -int set_activate(int file_des) { - int ret=OK,ret1=OK; - int n=0; - int retval=-1; - sprintf(mess,"Activate/Deactivate failed\n"); - -#ifndef EIGERD - //to receive any arguments - while (n > 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - ret=FAIL; - sprintf(mess,"Function (Set Activate) is not implemented for this detector\n"); - cprintf(RED, "Warning: %s", mess); -#else - - // receive arguments - int arg=-1; - n = receiveData(file_des,&arg,sizeof(arg),INT32); - if (n < 0) return printSocketReadError(); - - // execute action - if (differentClients && lockStatus && arg!=-1) { - ret = FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - cprintf(RED, "Warning: %s", mess); - } -#ifdef SLS_DETECTOR_FUNCTION_LIST - else { -#ifdef VERBOSE - printf("Setting activate mode of detector to %d\n",arg); -#endif - retval=activate(arg); - if ((retval!=arg) && (arg!=-1)) { - ret=FAIL; - sprintf(mess,"Could not set activate mode to %d, is set to %d\n",arg, retval); - cprintf(RED, "Warning: %s", mess); - } - } -#endif - if (ret==OK && differentClients) - ret=FORCE_UPDATE; -#endif - - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - if (ret==FAIL) { - n += sendData(file_des,mess,sizeof(mess),OTHER); - } else - n += sendData(file_des,&retval,sizeof(retval),INT32); - - // return ok / fail - return ret; -} - - - - -int prepare_acquisition(int file_des) { - int ret=OK,ret1=OK; - int n=0; - strcpy(mess,"prepare acquisition failed\n"); - -#if !defined(GOTTHARDD) && !defined(EIGERD) - //to receive any arguments - while (n > 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - ret = FAIL; - sprintf(mess,"Function (Prepare Acquisition) is not implemented for this detector\n"); - cprintf(RED, "Warning: %s", mess); -#else - - // execute action - if (differentClients && lockStatus) { - ret = FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - cprintf(RED, "Warning: %s", mess); - } -#ifdef SLS_DETECTOR_FUNCTION_LIST - else { - ret = prepareAcquisition(); - if (ret == FAIL) - cprintf(RED, "Warning: %s", mess); - } -#endif - if(ret==OK && differentClients) - ret=FORCE_UPDATE; -#endif - - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - if (ret==FAIL) { - n += sendData(file_des,mess,sizeof(mess),OTHER); - } - - // return ok / fail - return ret; -} - - -int cleanup_acquisition(int file_des) { - int ret=OK,ret1=OK; - int n=0; - strcpy(mess,"prepare acquisition failed\n"); - -#ifndef GOTTHARDD - //to receive any arguments - while (n > 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - ret = FAIL; - sprintf(mess,"Function (Cleanup Acquisition) is not implemented for this detector\n"); - cprintf(RED, "Warning: %s", mess); -#else - - // execute action - if (differentClients && lockStatus) { - ret = FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - cprintf(RED, "Warning: %s", mess); - } -#ifdef SLS_DETECTOR_FUNCTION_LIST - else {//to be implemented when used here - ret = FAIL; - sprintf(mess,"Function (Cleanup Acquisition) is not implemented for this detector\n"); - cprintf(RED, "Warning: %s", mess); - } -#endif - if(ret==OK && differentClients) - ret=FORCE_UPDATE; -#endif - - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - if (ret==FAIL) { - n += sendData(file_des,mess,sizeof(mess),OTHER); - } - - // return ok / fail - return ret; -} - - - - -int threshold_temp(int file_des) { - int ret=OK,ret1=OK; - int n=0; - int retval=-1; - sprintf(mess,"could not set/get threshold temperature\n"); - -#ifndef JUNGFRAUD - //to receive any arguments - while (n > 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - ret = FAIL; - sprintf(mess,"Function (Threshold Temp) is not implemented for this detector\n"); - cprintf(RED, "%s", mess); -#else - int arg[2]={-1,-1}; - int val=-1; - - // receive arguments - n = receiveData(file_des,arg,sizeof(arg),INT32); - if (n < 0) return printSocketReadError(); - val=arg[0]; - //ignoring imod - if (val > MAX_THRESHOLD_TEMP_VAL) { - ret=FAIL; - sprintf(mess,"Threshold Temp %d should be in range: 0 - %d\n", val, MAX_THRESHOLD_TEMP_VAL); - cprintf(RED, "Warning: %s", mess); - } - - -#ifdef SLS_DETECTOR_FUNCTION_LIST - if (ret==OK) { -#ifdef VERBOSE - printf("Setting Threshold Temperature to %d\n", val); -#endif - retval=setThresholdTemperature(val); - } -#endif -#ifdef VERBOSE - printf("Threshold temperature is %d\n", retval); -#endif - - if (ret==OK && differentClients && val >= 0) - ret=FORCE_UPDATE; -#endif - - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - if (ret!=FAIL) { - n += sendData(file_des,&retval,sizeof(retval),INT32); - } else { - n += sendData(file_des,mess,sizeof(mess),OTHER); - } - - // return ok / fail - return ret; -} - - - -int temp_control(int file_des) { - int ret=OK,ret1=OK; - int n=0; - int retval=-1; - sprintf(mess,"could not set/get temperature control\n"); - -#ifndef JUNGFRAUD - //to receive any arguments - while (n > 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - ret = FAIL; - sprintf(mess,"Function (Temperature control) is not implemented for this detector\n"); - cprintf(RED, "%s", mess); -#else - int arg[2]={-1,-1}; - int val=-1; - - // receive arguments - n = receiveData(file_des,arg,sizeof(arg),INT32); - if (n < 0) return printSocketReadError(); - val=arg[0]; - //ignoring imod - - -#ifdef SLS_DETECTOR_FUNCTION_LIST - if (ret==OK) { -#ifdef VERBOSE - printf("Setting Temperature control to %d\n", val); -#endif - retval=setTemperatureControl(val); - } -#endif -#ifdef VERBOSE - printf("Temperature control is %d\n", retval); -#endif - if (ret==OK && differentClients && val >= 0) - ret=FORCE_UPDATE; -#endif - - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - if (ret!=FAIL) { - n += sendData(file_des,&retval,sizeof(retval),INT32); - } else { - n += sendData(file_des,mess,sizeof(mess),OTHER); - } - - // return ok / fail - return ret; -} - - - - -int temp_event(int file_des) { - int ret=OK,ret1=OK; - int n=0; - int retval=-1; - sprintf(mess,"could not set/get temperature event\n"); - -#ifndef JUNGFRAUD - //to receive any arguments - while (n > 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - ret = FAIL; - sprintf(mess,"Function (Temperature Event) is not implemented for this detector\n"); - cprintf(RED, "%s", mess); -#else - int arg[2]={-1,-1}; - int val=-1; - - // receive arguments - n = receiveData(file_des,arg,sizeof(arg),INT32); - if (n < 0) return printSocketReadError(); - val=arg[0]; - //ignoring imod - -#ifdef SLS_DETECTOR_FUNCTION_LIST - if (ret==OK) { -#ifdef VERBOSE - printf("Setting Temperature Event to %d\n", val); -#endif - retval=setTemperatureEvent(val); - } -#endif -#ifdef VERBOSE - printf("Temperature Event is %d\n", retval); -#endif - - if (ret==OK && differentClients && val >= 0) - ret=FORCE_UPDATE; -#endif - - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - if (ret!=FAIL) { - n += sendData(file_des,&retval,sizeof(retval),INT32); - } else { - n += sendData(file_des,mess,sizeof(mess),OTHER); - } - - // return ok / fail - return ret; -} - - - - - -int auto_comp_disable(int file_des) { - int ret=OK,ret1=OK; - int n=0; - int retval=-1; - sprintf(mess,"auto comp disable failed\n"); - -#ifndef JUNGFRAUD - //to receive any arguments - while (n > 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - ret = FAIL; - sprintf(mess,"Function (Auto Comp Disable) is not implemented for this detector\n"); - cprintf(RED, "%s", mess); -#else - - //to receive any arguments - while (n > 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - ret = FAIL; - sprintf(mess,"Function (Auto Comp Disable) is not yet implemented for this detector\n"); - cprintf(RED, "%s", mess); - - // receive arguments - int arg=-1; - n = receiveData(file_des,&arg,sizeof(arg),INT32); - if (n < 0) return printSocketReadError(); - - // execute action - if (differentClients && lockStatus && arg!=-1) { - ret = FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - cprintf(RED, "Warning: %s", mess); - } -#ifdef SLS_DETECTOR_FUNCTION_LIST - else { -#ifdef VERBOSE - printf("Auto Comp Disable to %d\n", arg); -#endif - retval=autoCompDisable(arg); - -#ifdef VERBOSE - printf("Auto comp disable set to: %d\n",retval); -#endif - if (retval==arg || arg<0) { - ret=OK; - } else { - ret=FAIL; - sprintf(mess,"Atuo Comp Disable failed, wrote %d but read %d\n", arg, retval); - cprintf(RED, "Warning: %s", mess); - } - } -#endif - if (ret==OK && differentClients) - ret=FORCE_UPDATE; -#endif - - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - if (ret==FAIL) { - n += sendData(file_des,mess,sizeof(mess),OTHER); - } else - n += sendData(file_des,&retval,sizeof(retval),INT32); - - // return ok / fail - return ret; -} - - - - - -int storage_cell_start(int file_des) { - int ret=OK,ret1=OK; - int n=0; - int retval=-1; - sprintf(mess,"storage cell start failed\n"); - -#ifndef JUNGFRAUD - //to receive any arguments - while (n > 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - ret = FAIL; - sprintf(mess,"Function (Storage cell start) is not implemented for this detector\n"); - cprintf(RED, "%s", mess); -#else - - // receive arguments - int arg=-1; - n = receiveData(file_des,&arg,sizeof(arg),INT32); - if (n < 0) return printSocketReadError(); - - // execute action - if (differentClients && lockStatus && arg!=-1) { - ret = FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - cprintf(RED, "Warning: %s", mess); - } -#ifdef SLS_DETECTOR_FUNCTION_LIST - else if (arg > MAX_STORAGE_CELL_VAL) { - ret=FAIL; - strcpy(mess,"Max Storage cell number should not exceed 15\n"); - cprintf(RED, "Warning: %s", mess); - } else { -#ifdef VERBOSE - printf("Storage cell start to %d\n", arg); -#endif - retval=selectStoragecellStart(arg); - -#ifdef VERBOSE - printf("Storage cell start: %d\n",retval); -#endif - if (retval==arg || arg<0) { - ret=OK; - } else { - sprintf(mess,"Storage cell start select failed, wrote %d but read %d\n", arg, retval); - cprintf(RED, "Warning: %s", mess); - } - } -#endif - if (ret==OK && differentClients) - ret=FORCE_UPDATE; -#endif - - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - if (ret==FAIL) { - n += sendData(file_des,mess,sizeof(mess),OTHER); - } else - n += sendData(file_des,&retval,sizeof(retval),INT32); - - // return ok / fail - return ret; -} - - - - -int check_version(int file_des) { - int ret=OK,ret1=OK; - int n=0; - sprintf(mess,"check version failed\n"); - -#if !defined(EIGERD) && !defined(JUNGFRAUD) && !defined(GOTTHARD) - //to receive any arguments - while (n > 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - ret=FAIL; - sprintf(mess,"Function (Check Version Compatibility) is not implemented for this detector\n"); - cprintf(RED, "Warning: %s", mess); -#else - - // receive arguments - int64_t arg=-1; - n = receiveData(file_des,&arg,sizeof(arg),INT64); - if (n < 0) return printSocketReadError(); - - // execute action -#ifdef SLS_DETECTOR_FUNCTION_LIST - - // check software- firmware compatibility and basic tests - if (isControlServer) { -#ifdef VERBOSE - printf("Checking software-firmware compatibility and basic test result\n"); -#endif - // check if firmware check is done - if (!isFirmwareCheckDone()) { - usleep(3 * 1000 * 1000); - if (!isFirmwareCheckDone()) { - ret = FAIL; - strcpy(mess,"Firmware Software Compatibility Check (Server Initialization) " - "still not done done in server. Unexpected.\n"); - cprintf(RED, "Warning: %s", mess); - } - } - // check firmware check result - if (ret == OK) { - char* firmware_message = NULL; - if (getFirmwareCheckResult(&firmware_message) == FAIL) { - ret = FAIL; - strcpy(mess, firmware_message); - cprintf(RED, "Warning: %s", mess); - } - } - } - - if (ret == OK) { -#ifdef VERBOSE - printf("Checking versioning compatibility with value %d\n",arg); -#endif - int64_t client_requiredVersion = arg; - int64_t det_apiVersion = getDetectorId(CLIENT_SOFTWARE_API_VERSION); - int64_t det_version = getDetectorId(DETECTOR_SOFTWARE_VERSION); - - // old client - if (det_apiVersion > client_requiredVersion) { - ret = FAIL; - sprintf(mess,"Client's detector SW API version: (0x%llx). " - "Detector's SW API Version: (0x%llx). " - "Incompatible, update client!\n", - (long long int)client_requiredVersion, (long long int)det_apiVersion); - cprintf(RED, "Warning: %s", mess); - } - - // old software - else if (client_requiredVersion > det_version) { - ret = FAIL; - sprintf(mess,"Detector SW Version: (0x%llx). " - "Client's detector SW API Version: (0x%llx). " - "Incompatible, update detector software!\n", - (long long int)det_version, (long long int)client_requiredVersion); - cprintf(RED, "Warning: %s", mess); - } - } -#endif -#endif - - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - if (ret==FAIL) { - n += sendData(file_des,mess,sizeof(mess),OTHER); - } - - // return ok / fail - return ret; -} - - - - -int software_trigger(int file_des) { - int ret=OK,ret1=OK; - int n=0; - sprintf(mess,"software trigger failed\n"); - -#ifndef EIGERD - //to receive any arguments - while (n > 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - ret = FAIL; - sprintf(mess,"Function (Software Trigger) is not implemented for this detector\n"); - cprintf(RED, "%s", mess); -#else - - // execute action - if (differentClients && lockStatus) { - ret = FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - cprintf(RED, "Warning: %s", mess); - } -#ifdef SLS_DETECTOR_FUNCTION_LIST - else { - printf("Software Trigger\n"); - ret=softwareTrigger(); - if (ret==FAIL) - cprintf(RED, "Warning: %s", mess); - } -#endif - if (ret==OK && differentClients) - ret=FORCE_UPDATE; -#endif - - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - if (ret==FAIL) { - n += sendData(file_des,mess,sizeof(mess),OTHER); - } - - // return ok / fail - return ret; -} - diff --git a/slsDetectorSoftware/slsDetectorServer/slsDetectorServer_funcs.h b/slsDetectorSoftware/slsDetectorServer/slsDetectorServer_funcs.h deleted file mode 100755 index a4bbaeb64..000000000 --- a/slsDetectorSoftware/slsDetectorServer/slsDetectorServer_funcs.h +++ /dev/null @@ -1,101 +0,0 @@ -#ifndef SERVER_FUNCS_H -#define SERVER_FUNCS_H - -#include "sls_receiver_defs.h" -#include - -// initialization functions -int printSocketReadError(); -void setModeFlag(int); -void basictests(); -void init_detector(int); -int decode_function(int); -const char* getFunctionName(enum detFuncs func); -void function_table(); -int M_nofunc(int); -int M_nofuncMode(int); - -// functions called by client -int exec_command(int); -int get_error(int); -int get_detector_type(int); -int set_number_of_modules(int); -int get_max_number_of_modules(int); -int set_external_signal_flag(int); -int set_external_communication_mode(int); -int get_id(int); -int digital_test(int); -int analog_test(int); -int enable_analog_out(int); -int calibration_pulse(int); -int set_dac(int); -int get_adc(int); -int write_register(int); -int read_register(int); -int write_memory(int); -int read_memory(int); -int set_channel(int); -int get_channel(int); -int set_all_channels(int); -int set_chip(int); -int get_chip(int); -int set_all_chips(int); -int set_module(int); -int get_module(int); -int set_all_modules(int); -int set_settings(int); -int get_threshold_energy(int); -int set_threshold_energy(int); -int start_acquisition(int); -int stop_acquisition(int); -int start_readout(int); -int get_run_status(int); -int start_and_read_all(int); -int read_frame(int); -int read_all(int); -int set_timer(int); -int get_time_left(int); -int set_dynamic_range(int); -int set_readout_flags(int); -int set_roi(int); -int set_speed(int); -int execute_trimming(int); -int exit_server(int); -int lock_server(int); -int get_last_client_ip(int); -int set_port(int); -int update_client(int); -int send_update(int); -int configure_mac(int); -int load_image(int); -int set_master(int); -int set_synchronization(int); -int read_counter_block(int); -int reset_counter_block(int); -int calibrate_pedestal(int); -int enable_ten_giga(int); -int set_all_trimbits(int); -int set_ctb_pattern(int); -int write_adc_register(int); -int set_counter_bit(int); -int pulse_pixel(int); -int pulse_pixel_and_move(int); -int pulse_chip(int); -int set_rate_correct(int); -int get_rate_correct(int); -int set_network_parameter(int); -int program_fpga(int); -int reset_fpga(int); -int power_chip(int); -int set_activate(int); -int prepare_acquisition(int); -int cleanup_acquisition(int); -int threshold_temp(int); -int temp_control(int); -int temp_event(int); -int auto_comp_disable(int); -int storage_cell_start(int); -int check_version(int); -int software_trigger(int); - -#endif diff --git a/slsDetectorSoftware/slsDetectorServer/slsDetector_stopServer.c b/slsDetectorSoftware/slsDetectorServer/slsDetector_stopServer.c deleted file mode 100755 index 1772ce2b6..000000000 --- a/slsDetectorSoftware/slsDetectorServer/slsDetector_stopServer.c +++ /dev/null @@ -1,46 +0,0 @@ -/* A simple server in the internet domain using TCP - The port number is passed as an argument */ -#include "communication_funcs.h" - -#include "slsDetectorFunctionList.h"/*#include "slsDetector_firmware.h" for the time being*/ -#include "slsDetectorServer_defs.h" - -#include -#include - -int sockfd; - -int main(int argc, char *argv[]) -{ - int portno; - int retval=0; - int sd,fd; - - portno = DEFAULT_PORTNO; - - - sd=bindSocket(portno); //defined in communication_funcs - if (getServerError(sd)) //defined in communication_funcs - return -1; - - - - /* waits for connection */ - while(retval!=GOODBYE) { -#ifdef VERBOSE - printf("\n"); -#endif -#ifdef VERY_VERBOSE - printf("Stop server: waiting for client call\n"); -#endif - fd=acceptConnection(sd); //defined in communication_funcs - retval=stopStateMachine();//defined in slsDetectorFirmare_funcs - closeConnection(fd); //defined in communication_funcs - } - - exitServer(sd); //defined in communication_funcs - printf("Goodbye!\n"); - - return 0; -} - diff --git a/slsDetectorSoftware/slsDetectorServer/sls_detector_defs.h b/slsDetectorSoftware/slsDetectorServer/sls_detector_defs.h deleted file mode 120000 index c5062e03f..000000000 --- a/slsDetectorSoftware/slsDetectorServer/sls_detector_defs.h +++ /dev/null @@ -1 +0,0 @@ -../commonFiles/sls_detector_defs.h \ No newline at end of file diff --git a/slsDetectorSoftware/slsDetectorServer/sls_detector_funcs.h b/slsDetectorSoftware/slsDetectorServer/sls_detector_funcs.h deleted file mode 120000 index 844b67129..000000000 --- a/slsDetectorSoftware/slsDetectorServer/sls_detector_funcs.h +++ /dev/null @@ -1 +0,0 @@ -../commonFiles/sls_detector_funcs.h \ No newline at end of file diff --git a/slsDetectorSoftware/slsReceiverInterface/receiverInterface.cpp b/slsDetectorSoftware/slsReceiverInterface/receiverInterface.cpp deleted file mode 100644 index 6173d4185..000000000 --- a/slsDetectorSoftware/slsReceiverInterface/receiverInterface.cpp +++ /dev/null @@ -1,217 +0,0 @@ -#include "receiverInterface.h" - - -#include -#include -#include -#include -#include -#include -#include - - - -receiverInterface::receiverInterface(MySocketTCP *socket):dataSocket(socket){} - - - -receiverInterface::~receiverInterface(){} - - - -int receiverInterface::sendString(int fnum, char retval[], char arg[]){ - int ret = slsDetectorDefs::FAIL; - char mess[MAX_STR_LENGTH]; - memset(mess, 0, MAX_STR_LENGTH); - - dataSocket->SendDataOnly(&fnum,sizeof(fnum)); - dataSocket->SendDataOnly(arg,MAX_STR_LENGTH); - dataSocket->ReceiveDataOnly(&ret,sizeof(ret)); - if (ret==slsDetectorDefs::FAIL){ - dataSocket->ReceiveDataOnly(mess,sizeof(mess)); - cprintf(RED, "Receiver returned error: %s", mess); - } - if(strstr(mess,"Unrecognized Function")==NULL) - dataSocket->ReceiveDataOnly(retval,MAX_STR_LENGTH); - - return ret; -} - - - -int receiverInterface::sendUDPDetails(int fnum, char retval[], char arg[3][MAX_STR_LENGTH]){ - char args[3][MAX_STR_LENGTH]; - int ret = slsDetectorDefs::FAIL; - char mess[MAX_STR_LENGTH]; - memset(mess, 0, MAX_STR_LENGTH); - - dataSocket->SendDataOnly(&fnum,sizeof(fnum)); - dataSocket->SendDataOnly(arg,sizeof(args)); - dataSocket->ReceiveDataOnly(&ret,sizeof(ret)); - if (ret==slsDetectorDefs::FAIL){ - dataSocket->ReceiveDataOnly(mess,sizeof(mess)); - cprintf(RED, "Receiver returned error: %s", mess); - } - else - dataSocket->ReceiveDataOnly(retval,MAX_STR_LENGTH); - - return ret; -} - - -int receiverInterface::sendInt(int fnum, int &retval, int arg){ - int ret = slsDetectorDefs::FAIL; - char mess[MAX_STR_LENGTH]; - memset(mess, 0, MAX_STR_LENGTH); - - dataSocket->SendDataOnly(&fnum,sizeof(fnum)); - dataSocket->SendDataOnly(&arg,sizeof(arg)); - dataSocket->ReceiveDataOnly(&ret,sizeof(ret)); - if (ret==slsDetectorDefs::FAIL){ - dataSocket->ReceiveDataOnly(mess,sizeof(mess)); - cprintf(RED, "Receiver returned error: %s", mess); - } - if(strstr(mess,"Unrecognized Function")==NULL) - dataSocket->ReceiveDataOnly(&retval,sizeof(retval)); - - return ret; -} - - - -int receiverInterface::getInt(int fnum, int &retval){ - int ret = slsDetectorDefs::FAIL; - char mess[MAX_STR_LENGTH]; - memset(mess, 0, MAX_STR_LENGTH); - - dataSocket->SendDataOnly(&fnum,sizeof(fnum)); - dataSocket->ReceiveDataOnly(&ret,sizeof(ret)); - if (ret==slsDetectorDefs::FAIL){ - dataSocket->ReceiveDataOnly(mess,sizeof(mess)); - cprintf(RED, "Receiver returned error: %s", mess); - } - if(strstr(mess,"Unrecognized Function")==NULL) - dataSocket->ReceiveDataOnly(&retval,sizeof(retval)); - - return ret; -} - - - -int receiverInterface::sendInt(int fnum, int64_t &retval, int64_t arg){ - int ret = slsDetectorDefs::FAIL; - char mess[MAX_STR_LENGTH]; - memset(mess, 0, MAX_STR_LENGTH); - - dataSocket->SendDataOnly(&fnum,sizeof(fnum)); - dataSocket->SendDataOnly(&arg,sizeof(arg)); - dataSocket->ReceiveDataOnly(&ret,sizeof(ret)); - if (ret==slsDetectorDefs::FAIL){ - dataSocket->ReceiveDataOnly(mess,sizeof(mess)); - cprintf(RED, "Receiver returned error: %s", mess); - } - if(strstr(mess,"Unrecognized Function")==NULL) - dataSocket->ReceiveDataOnly(&retval,sizeof(retval)); - - return ret; -} - - - -int receiverInterface::sendIntArray(int fnum, int64_t &retval, int64_t arg[2], char mess[]){ - int64_t args[2]; - int ret = slsDetectorDefs::FAIL; - memset(mess, 0, MAX_STR_LENGTH); - - dataSocket->SendDataOnly(&fnum,sizeof(fnum)); - dataSocket->SendDataOnly(arg,sizeof(args)); - dataSocket->ReceiveDataOnly(&ret,sizeof(ret)); - if (ret==slsDetectorDefs::FAIL){ - dataSocket->ReceiveDataOnly(mess,MAX_STR_LENGTH); - cprintf(RED, "Receiver returned error: %s", mess); - } - if(strstr(mess,"Unrecognized Function")==NULL) - dataSocket->ReceiveDataOnly(&retval,sizeof(retval)); - - return ret; -} - - - -int receiverInterface::sendIntArray(int fnum, int &retval, int arg[2]){ - int args[2]; - int ret = slsDetectorDefs::FAIL; - char mess[MAX_STR_LENGTH]; - memset(mess, 0, MAX_STR_LENGTH); - - dataSocket->SendDataOnly(&fnum,sizeof(fnum)); - dataSocket->SendDataOnly(arg,sizeof(args)); - dataSocket->ReceiveDataOnly(&ret,sizeof(ret)); - if (ret==slsDetectorDefs::FAIL){ - dataSocket->ReceiveDataOnly(mess,sizeof(mess)); - cprintf(RED, "Receiver returned error: %s", mess); - } - if(strstr(mess,"Unrecognized Function")==NULL) - dataSocket->ReceiveDataOnly(&retval,sizeof(retval)); - - return ret; -} - - - -int receiverInterface::getInt(int fnum, int64_t &retval){ - int ret = slsDetectorDefs::FAIL; - - dataSocket->SendDataOnly(&fnum,sizeof(fnum)); - dataSocket->ReceiveDataOnly(&ret,sizeof(ret)); - dataSocket->ReceiveDataOnly(&retval,sizeof(retval)); - - return ret; -} - - -int receiverInterface::getLastClientIP(int fnum, char retval[]){ - int ret = slsDetectorDefs::FAIL; - - dataSocket->SendDataOnly(&fnum,sizeof(fnum)); - dataSocket->ReceiveDataOnly(&ret,sizeof(ret)); - dataSocket->ReceiveDataOnly(retval,INET_ADDRSTRLEN); - - return ret; -} - - - -int receiverInterface::executeFunction(int fnum,char mess[]){ - int ret = slsDetectorDefs::FAIL; - memset(mess, 0, MAX_STR_LENGTH); - - dataSocket->SendDataOnly(&fnum,sizeof(fnum)); - dataSocket->ReceiveDataOnly(&ret,sizeof(ret)); - if (ret==slsDetectorDefs::FAIL){ - dataSocket->ReceiveDataOnly(mess,MAX_STR_LENGTH); - cprintf(RED, "Receiver returned error: %s", mess); - } - - return ret; -} - - - -int receiverInterface::sendROI(int fnum, int n, slsReceiverDefs::ROI roiLimits[]) { - int ret = slsDetectorDefs::FAIL; - char mess[MAX_STR_LENGTH]; - memset(mess, 0, MAX_STR_LENGTH); - - dataSocket->SendDataOnly(&fnum,sizeof(fnum)); - dataSocket->SendDataOnly(&n,sizeof(n)); - dataSocket->SendDataOnly(roiLimits,n * sizeof(slsReceiverDefs::ROI)); - dataSocket->ReceiveDataOnly(&ret,sizeof(ret)); - if (ret==slsDetectorDefs::FAIL){ - dataSocket->ReceiveDataOnly(mess,sizeof(mess)); - cprintf(RED, "Receiver returned error: %s", mess); - } - return ret; -} - - diff --git a/slsDetectorSoftware/slsReceiverInterface/receiverInterface.h b/slsDetectorSoftware/slsReceiverInterface/receiverInterface.h deleted file mode 100644 index f188c8da8..000000000 --- a/slsDetectorSoftware/slsReceiverInterface/receiverInterface.h +++ /dev/null @@ -1,154 +0,0 @@ - - - -#ifndef SLS_RECEIVER_INTERFACE_H -#define SLS_RECEIVER_INTERFACE_H - -#include "sls_detector_defs.h" -#include "MySocketTCP.h" - - - -/** - * - * @short the slsReceiverInterface class is the interface between the sls detector and the sls receiver - * @author Dhanya Maliakal - * @version 0.1alpha - */ - - -class receiverInterface{ - -public: - - /** - * (default) constructor - * @param socket tcp socket between client and receiver - */ - receiverInterface(MySocketTCP *socket); - - - /** - * destructor - */ - virtual ~receiverInterface(); - - /** - * Set the datasocket - * @param socket the data socket - */ - void setSocket(MySocketTCP *socket){dataSocket=socket;}; - - - /** - * Send a string to receiver - * @param fnum function enum to determine what parameter - * @param retval return value - * @param arg value to send - * \returns success of operation - */ - int sendString(int fnum, char retval[], char arg[]); - - /** - * Send a string to receiver - * @param fnum function enum to send udp ip and udp port - * @param retval return value receiver mac - * @param arg value to send - * \returns success of operation - */ - int sendUDPDetails(int fnum, char retval[], char arg[3][MAX_STR_LENGTH]); - - - /** - * Send an integer to receiver - * @param fnum function enum to determine what parameter - * @param retval return value - * @param arg value to send - * \returns success of operation - */ - int sendInt(int fnum, int &retval, int arg); - - /** - * Get an integer value from receiver - * @param fnum function enum to determine what parameter - * @param retval return value - * \returns success of operation - */ - int getInt(int fnum, int &retval); - - /** - * Send an integer to receiver - * @param fnum function enum to determine what parameter - * @param retval return value - * @param arg value to send - * \returns success of operation - */ - int sendInt(int fnum, int64_t &retval, int64_t arg); - - - /** - * Send an integer to receiver - * @param fnum function enum to determine what parameter - * @param retval return value - * @param arg values to send - * @param mess message returned - * \returns success of operation - */ - int sendIntArray(int fnum, int64_t &retval, int64_t arg[2],char mess[]); - - - /** - * Send an integer to receiver - * @param fnum function enum to determine what parameter - * @param retval return value - * @param arg values to send - * \returns success of operation - */ - int sendIntArray(int fnum, int &retval, int arg[2]); - - /** - * Get an integer value from receiver - * @param fnum function enum to determine what parameter - * @param retval return value - * \returns success of operation - */ - int getInt(int fnum, int64_t &retval); - - /** - * Get last client ip connected to receiver - * @param fnum function enum to get last client up - * @param retval return value - * \returns success of operation - */ - int getLastClientIP(int fnum, char retval[]); - - - /** - * Send a function number to execute function - * @param fnum function enum to determine which function to execute - * @param mess return error message - * \returns success of operation - */ - int executeFunction(int fnum,char mess[]); - - /** - * Send an integer to receiver - * @param fnum function enum to determine what parameter - * @param n number of ROIs to send - * @param roiLimits ROI structure - * \returns success of operation - */ - int sendROI(int fnum, int n, slsReceiverDefs::ROI roiLimits[]); - - //here one should implement the funcs listed in - -private: - - /** - * socket for data acquisition - */ - MySocketTCP *dataSocket; - -}; - -#endif diff --git a/slsDetectorSoftware/threadFiles/CondVar.cpp b/slsDetectorSoftware/threadFiles/CondVar.cpp deleted file mode 100644 index 2feff962f..000000000 --- a/slsDetectorSoftware/threadFiles/CondVar.cpp +++ /dev/null @@ -1,17 +0,0 @@ -#include "CondVar.h" - -CondVar::CondVar() { - pthread_cond_init(&m_cond_var, NULL); -} -CondVar::~CondVar() { - pthread_cond_destroy(&m_cond_var); -} -void CondVar::wait(pthread_mutex_t* mutex) { - pthread_cond_wait(&m_cond_var, mutex); -} -void CondVar::signal() { - pthread_cond_signal(&m_cond_var); -} -void CondVar::broadcast() { - pthread_cond_broadcast(&m_cond_var); -} diff --git a/slsDetectorSoftware/threadFiles/CondVar.h b/slsDetectorSoftware/threadFiles/CondVar.h deleted file mode 100644 index 3bf69d146..000000000 --- a/slsDetectorSoftware/threadFiles/CondVar.h +++ /dev/null @@ -1,23 +0,0 @@ -#pragma once - -#include -#include -#include -#include -#include - -#include "Global.h" - - -class CondVar { -public: - - CondVar(); - ~CondVar(); - void wait(pthread_mutex_t* mutex); - void signal(); - void broadcast(); - -private: - pthread_cond_t m_cond_var; -}; diff --git a/slsDetectorSoftware/threadFiles/Global.h b/slsDetectorSoftware/threadFiles/Global.h deleted file mode 100644 index 2596df0c0..000000000 --- a/slsDetectorSoftware/threadFiles/Global.h +++ /dev/null @@ -1,6 +0,0 @@ -#pragma once - -const int DEFAULT_POOL_SIZE = 10; -const int MAX_SINGLES = 5; -const int STARTED = 0; -const int STOPPED = 1; diff --git a/slsDetectorSoftware/threadFiles/Makefile b/slsDetectorSoftware/threadFiles/Makefile deleted file mode 100644 index a1eb27d29..000000000 --- a/slsDetectorSoftware/threadFiles/Makefile +++ /dev/null @@ -1,21 +0,0 @@ -OBJPATH=bin/obj -EXAMPLEPATH=bin/example - -all: - g++ CondVar.cpp -pthread -c -g -o $(OBJPATH)/CondVar.o - g++ Mutex.cpp -pthread -c -g -o $(OBJPATH)/Mutex.o - #g++ Task.cpp -pthread -c -g -o $(OBJPATH)/Task.o - g++ ThreadPool.cpp -pthread -c -g -o $(OBJPATH)/ThreadPool.o - g++ Multi.cpp -pthread -c -g -o $(OBJPATH)/Multi.o - #g++ $(OBJPATH)/CondVar.o $(OBJPATH)/Mutex.o $(OBJPATH)/Task.o $(OBJPATH)/ThreadPool.o threadpool_test.cpp Single.cpp Multi.cpp -pthread -I . -g -o $(EXAMPLEPATH)threadpool_test - g++ $(OBJPATH)/CondVar.o $(OBJPATH)/Mutex.o $(OBJPATH)/ThreadPool.o threadpool_test.cpp Single.cpp Multi.cpp -pthread -I . -g -o $(EXAMPLEPATH)threadpool_test - -#all: -# g++ threadpool.cpp -pthread -fpic -c -o bin/obj/threadpool.o -# g++ -L./bin bin/obj/threadpool.o -pthread threadpool_test.cpp -o bin/example/threadpool_test - -#threadpool: -# g++ threadpool.cpp -pthread -fpic -c -o bin/obj/threadpool.o -# g++ -shared -fPIC bin/obj/threadpool.o -o bin/lib/libthreadpool.so -#example: -# g++ -L./bin/lib -lthreadpool threadpool_test.cpp -o threadpool_test diff --git a/slsDetectorSoftware/threadFiles/Multi.cpp b/slsDetectorSoftware/threadFiles/Multi.cpp deleted file mode 100644 index 02e34438e..000000000 --- a/slsDetectorSoftware/threadFiles/Multi.cpp +++ /dev/null @@ -1,197 +0,0 @@ -#include "Multi.h" -#include "Single.h" -#include "ThreadPool.h" - - - -#include -#include -#include -#include -using namespace std; - -char ans[1000]; -int threadflag = 1; - -Multi::Multi() { - numSingles = 1; - threadpool = 0; - for(int i=0;idestroy_threadpool(); - threadpool=0; - } - if(numSingles > 0) - threadpool = new ThreadPool(numSingles); - switch(threadpool->initialize_threadpool()){ - case -1: - cerr << "Failed to initialize thread pool!" << endl; - return 0; - case 0: - cout << "Not initializing threads, only one detector" << endl; - break; - default: - cout << "Initialized Threadpool" << endl; - break; - } - return 1; -} - -int Multi::destroyThreadPool(){ - if(threadpool){ - threadpool->destroy_threadpool(); - threadpool=0; - cout<<"Destroyed Threadpool"<* binder = - // new func_t(&Single::printNumber,singles[i],inum,iret[i]); - Task* task = new Task(new func1_t(&Single::printNumber,singles[i],inum,iret[i])); - threadpool->add_task(task); - } - threadpool->wait_for_tasks_to_complete(); - - - for(int i=0;i1){ - string* sret[numSingles]; - - - for(int i=0;i* binder = - new func1_t(&Single::printString,singles[i],s,sret[i]); - Task* task = new Task(binder); - threadpool->add_task(task); - } - threadpool->wait_for_tasks_to_complete(); - for(int i=0;iprintString(s); - if(ret=="error") - ret = ret1; - else if (ret != ret1) - ret = "sss"; - } - } - return ret; -} - -char* Multi::printCharArray(char a[]){ - string ret="error", ret1="sss"; - - if(numSingles>1){ - string* sret[numSingles]; - - for(int i=0;i* binder = - new func1_t (&Single::printCharArray,singles[i],a,sret[i]); - Task* task = new Task(binder); - threadpool->add_task(task); - } - threadpool->wait_for_tasks_to_complete(); - - for(int i=0;iprintCharArray(a); - if(ret=="error") - ret = ret1; - else if (ret != ret1) - ret = "sss"; - } - } - strcpy(ans,ret.c_str()); - return ans; -} diff --git a/slsDetectorSoftware/threadFiles/Multi.h b/slsDetectorSoftware/threadFiles/Multi.h deleted file mode 100644 index cf34396a8..000000000 --- a/slsDetectorSoftware/threadFiles/Multi.h +++ /dev/null @@ -1,35 +0,0 @@ -#pragma once - - -#include "Global.h" - -#include - -class Single; -class ThreadPool; - -class Multi { -public: - - Multi(); - ~Multi(); - - std::string executeCommand(int argc,char* argv[]); - - int printNumber(int inum); - std::string printString(std::string s); - char* printCharArray(char a[]); - - int createThreadPool(); - int destroyThreadPool(); - -protected: - Single* singles[MAX_SINGLES]; - int numSingles; - ThreadPool* threadpool; - - - -}; - - diff --git a/slsDetectorSoftware/threadFiles/Mutex.cpp b/slsDetectorSoftware/threadFiles/Mutex.cpp deleted file mode 100644 index 4aefec723..000000000 --- a/slsDetectorSoftware/threadFiles/Mutex.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#include "Mutex.h" - -Mutex::Mutex() { - pthread_mutex_init(&m_lock, NULL); - is_locked = false; -} - -Mutex::~Mutex() { - while(is_locked); - //unlock(); // Unlock Mutex after shared resource is safe - pthread_mutex_destroy(&m_lock); -} - -void Mutex::lock() { - pthread_mutex_lock(&m_lock); - is_locked = true; -} - -void Mutex::unlock() { - is_locked = false; // do it BEFORE unlocking to avoid race condition - pthread_mutex_unlock(&m_lock); -} - -pthread_mutex_t* Mutex::get_mutex_ptr(){ - return &m_lock; -} diff --git a/slsDetectorSoftware/threadFiles/Mutex.h b/slsDetectorSoftware/threadFiles/Mutex.h deleted file mode 100644 index 33e108777..000000000 --- a/slsDetectorSoftware/threadFiles/Mutex.h +++ /dev/null @@ -1,27 +0,0 @@ -#pragma once - -#include -#include -#include -#include -#include -#include -#include - -#include "Global.h" - -// - -class Mutex -{ -public: - Mutex(); - ~Mutex(); - void lock(); - void unlock(); - pthread_mutex_t* get_mutex_ptr(); - -private: - pthread_mutex_t m_lock; - volatile bool is_locked; -}; diff --git a/slsDetectorSoftware/threadFiles/Single.cpp b/slsDetectorSoftware/threadFiles/Single.cpp deleted file mode 100644 index 43b0ca14b..000000000 --- a/slsDetectorSoftware/threadFiles/Single.cpp +++ /dev/null @@ -1,37 +0,0 @@ -#include "Single.h" - -#include -#include -using namespace std; - -char local_ans[1000]; - -Single::Single(int id) { - detID = id; - // cout<<"detID:"< -// - -class Single { -public: - Single(int id); - ~Single(); - int getID(); - - int printNumber(int i); - string printString(string s); - char* printCharArray(char a[]); - -private: - int detID; - - int* someValue; - -}; - diff --git a/slsDetectorSoftware/threadFiles/Task.h b/slsDetectorSoftware/threadFiles/Task.h deleted file mode 100644 index 585f4a119..000000000 --- a/slsDetectorSoftware/threadFiles/Task.h +++ /dev/null @@ -1,221 +0,0 @@ -#pragma once - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "Global.h" -#include "sls_detector_defs.h" - -class slsDetector; - -template -class func00_t{ -public: - func00_t(_Ret (slsDetector::*fn)(),slsDetector* ptr): - m_fn(fn),m_ptr(ptr){} - ~func00_t() {} - void operator()() const {((m_ptr->*m_fn)());} -private: - _Ret (slsDetector::*m_fn)(); - slsDetector* m_ptr; -}; - -template -class func0_t{ -public: - func0_t(_Ret (slsDetector::*fn)(),slsDetector* ptr, _Ret* sto): - m_fn(fn),m_ptr(ptr),m_store(sto){} - ~func0_t() {} - void operator()() const {*m_store = ((m_ptr->*m_fn)());} -private: - _Ret (slsDetector::*m_fn)(); - slsDetector* m_ptr; - _Ret* m_store; -}; - -template -class func1_t{ -public: - func1_t(_Ret (slsDetector::*fn)(_Arg1),slsDetector* ptr,_Arg1 arg1, _Ret* sto): - m_fn(fn),m_ptr(ptr),m_arg1(arg1),m_store(sto){} - ~func1_t() {} - void operator()() const {*m_store = ((m_ptr->*m_fn)(m_arg1));} -private: - _Ret (slsDetector::*m_fn)(_Arg1); - slsDetector* m_ptr; - _Arg1 m_arg1; - _Ret* m_store; -}; - -template -class func2_t{ -public: - func2_t(_Ret (slsDetector::*fn)(_Arg1,_Arg2),slsDetector* ptr,_Arg1 arg1,_Arg2 arg2,_Ret* sto): - m_fn(fn),m_ptr(ptr),m_arg1(arg1),m_arg2(arg2),m_store(sto){} - ~func2_t() {} - void operator()() const {*m_store = ((m_ptr->*m_fn)(m_arg1,m_arg2));} -private: - _Ret (slsDetector::*m_fn)(_Arg1,_Arg2); - slsDetector* m_ptr; - _Arg1 m_arg1; - _Arg2 m_arg2; - _Ret* m_store; -}; - -template -class func3_t{ -public: - func3_t(_Ret (slsDetector::*fn)(_Arg1,_Arg2,_Arg3),slsDetector* ptr,_Arg1 arg1,_Arg2 arg2,_Arg3 arg3,_Ret* sto): - m_fn(fn),m_ptr(ptr),m_arg1(arg1),m_arg2(arg2),m_arg3(arg3),m_store(sto){} - ~func3_t() {} - void operator()() const {*m_store = ((m_ptr->*m_fn)(m_arg1,m_arg2,m_arg3));} -private: - _Ret (slsDetector::*m_fn)(_Arg1,_Arg2,_Arg3); - slsDetector* m_ptr; - _Arg1 m_arg1; - _Arg2 m_arg2; - _Arg3 m_arg3; - _Ret* m_store; -}; - -template -class func4_t{ -public: - func4_t(_Ret (slsDetector::*fn)(_Arg1,_Arg2,_Arg3,_Arg4),slsDetector* ptr,_Arg1 arg1,_Arg2 arg2,_Arg3 arg3,_Arg4 arg4,_Ret* sto): - m_fn(fn),m_ptr(ptr),m_arg1(arg1),m_arg2(arg2),m_arg3(arg3),m_arg4(arg4),m_store(sto){} - ~func4_t() {} - void operator()() const {*m_store = ((m_ptr->*m_fn)(m_arg1,m_arg2,m_arg3,m_arg4));} -private: - _Ret (slsDetector::*m_fn)(_Arg1,_Arg2,_Arg3,_Arg4); - slsDetector* m_ptr; - _Arg1 m_arg1; - _Arg2 m_arg2; - _Arg3 m_arg3; - _Arg4 m_arg4; - _Ret* m_store; -}; - - -class SuperTask: public virtual slsDetectorDefs { -public: - SuperTask(): - m1(0),m2(0),m3(0),m4(0),m5(0),m6(0),m7(0),m8(0),m9(0),m10(0),m11(0),m12(0),m13(0),m14(0),m15(0),m16(0),m17(0),m18(0),m19(0){}; - virtual ~SuperTask(){}; -protected: - /** Function signature defined - * First argument is Return type, the remaining are arguments - */ - func00_t * m1; - func0_t * m2; - func0_t * m3; - func0_t * m4; - func1_t * m5; - func1_t * m6; - func1_t * m7; - func1_t * m8; - func2_t * m9; - func2_t * m10; - func2_t * m11; - func2_t * m12; - func3_t * m13; - func2_t * m14; - func3_t * m15; - func4_t * m16; - func4_t * m17; - func4_t * m18; - func1_t * m19; -}; - -class Task: public virtual SuperTask { -public: - /** Task Constructors using appropriate function signature - * First argument is Return type, the remaining are arguments - */ - Task(func00_t * t): SuperTask(),fnum(1){m1 = t;}; - Task(func0_t * t): SuperTask(),fnum(2){m2 = t;}; - Task(func0_t * t): SuperTask(),fnum(3){m3 = t;}; - Task(func0_t * t): SuperTask(),fnum(4){m4 = t;}; - Task(func1_t * t): SuperTask(),fnum(5){m5 = t;}; - Task(func1_t * t): SuperTask(),fnum(6){m6 = t;}; - Task(func1_t * t): SuperTask(),fnum(7){m7 = t;}; - Task(func1_t * t): SuperTask(),fnum(8){m8 = t;}; - Task(func2_t * t): SuperTask(),fnum(9){m9 = t;}; - Task(func2_t * t): SuperTask(),fnum(10){m10 = t;}; - Task(func2_t * t): SuperTask(),fnum(11){m11 = t;}; - Task(func2_t * t): SuperTask(),fnum(12){m12 = t;}; - Task(func3_t * t): SuperTask(),fnum(13){m13 = t;}; - Task(func2_t * t): SuperTask(),fnum(14){m14 = t;}; - Task(func3_t * t): SuperTask(),fnum(15){m15 = t;}; - Task(func4_t * t): SuperTask(),fnum(16){m16 = t;}; - Task(func4_t * t): SuperTask(),fnum(17){m17 = t;}; - Task(func4_t * t): SuperTask(),fnum(18){m18 = t;}; - Task(func1_t * t): SuperTask(),fnum(19){m19 = t;}; - - virtual ~Task(){ - switch(fnum) { - case 1: delete m1; break; - case 2: delete m2; break; - case 3: delete m3; break; - case 4: delete m4; break; - case 5: delete m5; break; - case 6: delete m6; break; - case 7: delete m7; break; - case 8: delete m8; break; - case 9: delete m9; break; - case 10: delete m10; break; - case 11: delete m11; break; - case 12: delete m12; break; - case 13: delete m13; break; - case 14: delete m14; break; - case 15: delete m15; break; - case 16: delete m16; break; - case 17: delete m17; break; - case 18: delete m18; break; - case 19: delete m19; break; - default: - cprintf(RED, "Error: Task not defined. Abort!\n"); - break; - } - - }; - - void operator()(){ - switch(fnum) { - case 1: (*m1)(); break; - case 2: (*m2)(); break; - case 3: (*m3)(); break; - case 4: (*m4)(); break; - case 5: (*m5)(); break; - case 6: (*m6)(); break; - case 7: (*m7)(); break; - case 8: (*m8)(); break; - case 9: (*m9)(); break; - case 10: (*m10)(); break; - case 11: (*m11)(); break; - case 12: (*m12)(); break; - case 13: (*m13)(); break; - case 14: (*m14)(); break; - case 15: (*m15)(); break; - case 16: (*m16)(); break; - case 17: (*m17)(); break; - case 18: (*m18)(); break; - case 19: (*m19)(); break; - default: - cprintf(RED, "Error: Task not defined. Abort!\n"); - break; - } - } - -private: - /** function number */ - int fnum; - -}; - - diff --git a/slsDetectorSoftware/threadFiles/ThreadPool.cpp b/slsDetectorSoftware/threadFiles/ThreadPool.cpp deleted file mode 100644 index 224038f5c..000000000 --- a/slsDetectorSoftware/threadFiles/ThreadPool.cpp +++ /dev/null @@ -1,191 +0,0 @@ -#include "ThreadPool.h" -#include -using namespace std; -ThreadPool::ThreadPool(int pool_size) : m_pool_size(pool_size){ -#ifdef VERBOSE - cout << "Constructed ThreadPool of size " << m_pool_size << endl; -#endif - m_tasks_loaded = false; - thread_started = false; - current_thread_number = -1; - number_of_ongoing_tasks = 0; - number_of_total_tasks = 0; -} - -ThreadPool::~ThreadPool(){ - // Release resources - if (m_pool_state != STOPPED) { - destroy_threadpool(); - } -} - - -extern "C" -void* start_thread(void* arg) -{ - ThreadPool* tp = (ThreadPool*) arg; - tp->execute_thread(); - return NULL; -} - -int ThreadPool::initialize_threadpool(){ - if(m_pool_size == 1) - return m_pool_size; - - m_pool_state = STARTED; - int ret = -1; - sem_init(&semStart,1,0); - sem_init(&semDone,1,0); - for (int i = 0; i < m_pool_size; i++) { - pthread_t tid; - thread_started = false; - current_thread_number = i; - ret = pthread_create(&tid, NULL, start_thread, (void*) this); - if (ret != 0) { - cerr << "pthread_create() failed: " << ret << endl; - return 0; - } - m_threads.push_back(tid); - while(!thread_started); - } -#ifdef VERBOSE - cout << m_pool_size << " threads created by the thread pool" << endl; -#endif - return m_pool_size; -} - -int ThreadPool::destroy_threadpool(){ - if(m_pool_size == 1) - return 0; - /*cout << "in destroying threadpool" << endl;*/ - // thread communication- modified m_pool_state may not show up - //to other threads until its modified in a lock! - m_task_mutex.lock(); - m_pool_state = STOPPED; - /*cout << "Broadcasting STOP signal to all threads..." << endl;*/ - m_task_cond_var.broadcast(); // notify all threads we are shttung down - m_task_mutex.unlock(); - -// int ret = -1; - for (int i = 0; i < m_pool_size; i++) { - sem_post(&semStart); - sem_post(&semDone); - - void* result; - pthread_join(m_threads[i], &result); - /*cout << "pthread_join() returned " << ret << ": " << strerror(errno) << endl;*/ - m_task_mutex.lock(); - m_task_cond_var.broadcast(); // try waking up a bunch of threads that are still waiting - m_task_mutex.unlock(); - } - - - sem_destroy(&semStart); - sem_destroy(&semDone); - number_of_ongoing_tasks = 0; - number_of_total_tasks = 0; - - /* cout << m_pool_size << " threads exited from the thread pool" << endl;*/ - return 0; -} - -void* ThreadPool::execute_thread(){ -//for debugging seting ithread value -// int ithread = current_thread_number; - thread_started = true; - Task* task = NULL; - m_tasks_loaded = false; - /*cout << "Starting thread " << pthread_self() << endl;*/ - while(true) { - // Try to pick a task - /*cout << "Locking: " << pthread_self() << endl;*/ - m_task_mutex.lock(); - - while ((m_pool_state != STOPPED) && (m_tasks.empty())) { - // Wait until there is a task in the queue - // Unlock mutex while wait, then lock it back when signaled - /* cout << "Unlocking and waiting: " << pthread_self() << endl;*/ - m_task_cond_var.wait(m_task_mutex.get_mutex_ptr()); - /* cout << "Signaled and locking: " << pthread_self() << endl;*/ - } - - // If the thread was woken up to notify process shutdown, return from here - if (m_pool_state == STOPPED) { - /* cout << "Unlocking and exiting: " << pthread_self() << endl;*/ - m_task_mutex.unlock(); - pthread_exit(NULL); - } - - task = m_tasks.front(); - m_tasks.pop_front(); - /*cout << "Unlocking: " << pthread_self() << endl;*/ - m_task_mutex.unlock(); - - sem_wait(&semStart); - - //cout<<"***"<run(arg); - /*cout << ithread <<" Done executing thread " << pthread_self() << endl;*/ - - delete task; - /*cout << ithread << " task deleted" << endl;*/ - - m_task_mutex.lock(); - number_of_ongoing_tasks--; - m_task_mutex.unlock(); - - //last task and check m_tasks_loaded to ensure done only once - if((!number_of_ongoing_tasks) && m_tasks_loaded){ - m_tasks_loaded = false; - } - - sem_post(&semDone); - //removed deleteing task to earlier - } - return NULL; -} - -int ThreadPool::add_task(Task* task){ - if(m_pool_size == 1){ - (*task)(); - return 0; - } - m_task_mutex.lock(); - - // TODO: put a limit on how many tasks can be added at most - m_tasks.push_back(task); - number_of_ongoing_tasks++; - number_of_total_tasks++; - m_task_cond_var.signal(); // wake up one thread that is waiting for a task to be available - m_task_mutex.unlock(); - return 0; -} - -void ThreadPool::startExecuting(){ - if(m_pool_size == 1) - return; - - /*cout << "waiting for tasks: locked. gonna wait" << endl;*/ - m_tasks_loaded = true; - - //giving all threads permission to start as all tasks have been added - for(int i=0;i -#include -#include -#include -#include -#include -#include -#include - -#include "Mutex.h" -#include "Task.h" -#include "CondVar.h" -#include "Global.h" -#include -// - - -class ThreadPool -{ -public: - ThreadPool(int pool_size); - ~ThreadPool(); - int initialize_threadpool(); - int destroy_threadpool(); - void* execute_thread(); - int add_task(Task* task); - void startExecuting(); - void wait_for_tasks_to_complete(); - -private: - int m_pool_size; - Mutex m_task_mutex; - CondVar m_task_cond_var; - std::vector m_threads; // storage for threads - std::deque m_tasks; - volatile int m_pool_state; - - volatile bool m_tasks_loaded; - volatile bool thread_started; - int current_thread_number; - - //volatile uint64_t tasks_done_mask; - volatile int number_of_ongoing_tasks; - volatile int number_of_total_tasks; - - sem_t semStart; - sem_t semDone; -}; - diff --git a/slsDetectorSoftware/threadFiles/bin/examplethreadpool_test b/slsDetectorSoftware/threadFiles/bin/examplethreadpool_test deleted file mode 100755 index 621d57a47..000000000 Binary files a/slsDetectorSoftware/threadFiles/bin/examplethreadpool_test and /dev/null differ diff --git a/slsDetectorSoftware/threadFiles/threadpool_test.cpp b/slsDetectorSoftware/threadFiles/threadpool_test.cpp deleted file mode 100644 index 2dbd2c416..000000000 --- a/slsDetectorSoftware/threadFiles/threadpool_test.cpp +++ /dev/null @@ -1,61 +0,0 @@ -//#include "ThreadPool.h" - -//#include "threadpool.h" - -#include -#include - -#include "Multi.h" -using namespace std; - -//const int MAX_TASKS = 4; - -/* -void hello(void* arg) -{ - string* x = (string*) arg; - cout << "Hello: " << *x << endl; -// cout << "\n"; -} -*/ -int main(int argc, char* argv[]) -{ - - Multi* m = new Multi(); - cout<<"Answer:"<< m->executeCommand(argc,argv) << endl; - delete m; - /* - ThreadPool tp(2); - int ret = tp.initialize_threadpool(); - if (ret == -1) { - cerr << "Failed to initialize thread pool!" << endl; - return 0; - } -*/ - - -/* - for (int i = 0; i < MAX_TASKS; i++) { - cout<<"adding task:" < gitInfo.txt - cd .. - ./genVersionHeader.sh $SPECDIR/gitInfo.txt $SPECDIR/$TMPFILE $SPECDIR/$INCLFILE - cd $WD -#fi \ No newline at end of file diff --git a/slsDetectorSoftware/usersFunctions/angleFunction.h b/slsDetectorSoftware/usersFunctions/angleFunction.h deleted file mode 100644 index d06adaf3b..000000000 --- a/slsDetectorSoftware/usersFunctions/angleFunction.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef DEFAULT_ANGLE_FUNCTION_H -#define DEFAULT_ANGLE_FUNCTION_H -#include - -/* - contains the conversion channel-angle for a module channel - conv_r=pitch/radius -*/ -#define PI 3.14159265358979323846 -#include - -double defaultAngleFunction(double ichan, double encoder, double totalOffset, double conv_r, double center, double offset, double tilt, int direction) {\ - (void) tilt; - double ang; - - ang=180./PI*(center*conv_r+direction*atan((double)(ichan-center)*conv_r))+encoder+totalOffset+offset; - - - //#ifdef VERBOSE - // printf("%d %f %f %f %f %f %f %d\n", ichan, ang, center, encoder, totalOffset, conv_r, offset, direction); - //#endif - - return ang; \ - return 180./PI*(center*conv_r+direction*atan((double)(ichan-center)*conv_r))+encoder+totalOffset+offset; }; - -#endif diff --git a/slsDetectorSoftware/usersFunctions/usersFunctions.cpp b/slsDetectorSoftware/usersFunctions/usersFunctions.cpp deleted file mode 100644 index 0d7b5318a..000000000 --- a/slsDetectorSoftware/usersFunctions/usersFunctions.cpp +++ /dev/null @@ -1,347 +0,0 @@ -#include "usersFunctions.h" -#include -#include - - -float pos; -float i0=0; -#ifdef EPICS - -#include -#include - -static double timeout = 3.0; - -chid ch_pos,ch_i0, ch_getpos; - - - - -/* connect to a PV */ -int connect_channel(const char *name, chid *ch_id) { - int status = ECA_NORMAL; - status = ca_create_channel(name, NULL, NULL, CA_PRIORITY_DEFAULT, ch_id); - if (status != ECA_NORMAL) - return status; - - status = ca_pend_io(timeout); - return status; -} - -/* disconnect to a PV */ -int disconnect_channel(chid ch_id) -{ - ca_clear_channel(ch_id); - ca_flush_io(); -} - -int caget(chid ch_id, double *value) { - - int status = ECA_NORMAL; - - status = ca_get(DBR_DOUBLE, ch_id, value); - if (status != ECA_NORMAL) { - return status; - } - - status = ca_pend_io(timeout); - if (status != ECA_NORMAL) { - return status; - } - - return status; -} - -int caputq(chid ch_id, double value) { - // does not wait! - int status = ECA_NORMAL; - - status = ca_put(DBR_DOUBLE, ch_id, &value); - if (status != ECA_NORMAL) - return status; - - status = ca_pend_io(timeout); - if (status != ECA_NORMAL) { - return status; - } - - return status; -} - -void put_callback(struct event_handler_args args) -{ - epicsEventId eid = (epicsEventId)args.usr; - epicsEventSignal(eid); -} - -int caput(chid ch_id, double value) { - - // waits! - int status = ECA_NORMAL; - epicsEventId eid = epicsEventCreate(epicsEventEmpty); - - status = ca_put_callback(DBR_DOUBLE, - ch_id, - &value, - put_callback, - eid); - status = ca_pend_io(timeout); - if (status != ECA_NORMAL) - return status; - - if (epicsEventWait(eid) != epicsEventWaitOK) - status = ECA_TIMEOUT; - - return status; -} - -//int main(int argc, char *argv[]) { - - - - - - - - -#endif - - - - - - - -// /* -// contains the conversion channel-angle for a module channel -// conv_r=pitch/radius -// */ - - -// double defaultAngleFunction(double ichan, double encoder, double totalOffset, double conv_r, double center, double offset, double tilt, int direction) { - - -// (void) tilt; /* to avoid warning: unused parameter */ -// double ang; - -// ang=180./PI*(center*conv_r+direction*atan((double)(ichan-center)*conv_r))+encoder+totalOffset+offset; - - -// //#ifdef VERBOSE -// printf("%d %f \n", ichan, ang); -// //#endif - -// return ang; - -// } - -/* reads the encoder and returns the position */ - -double defaultGetPosition(void*) { -#ifdef VERBOSE - printf("Getting motor position \n"); -#endif - // caget X04SA-ES2-TH2:RO.RBV - -#ifdef EPICS - int status; - - double value = 256; - if (ch_getpos<0) return -1; - -/* /\* caget *\/ */ - if (caget(ch_getpos, &value) == ECA_NORMAL) { -#ifdef VERBOSE - printf("caget: %f\n", value); -#endif - pos=value; - } else - printf(ca_message(status)); -#endif - - - - return pos; -} - -/* moves the encoder to position p */ - - -int defaultGoToPosition(double p, void*) { -#ifdef VERBOSE - printf("Setting motor position \n"); -#endif - -#ifdef EPICS - int status; - if (ch_pos<0) return -1; - /* /\* caput and wait until done *\/ */ - if ((status = caput(ch_pos, p)) == ECA_NORMAL) { - ; -#ifdef VERBOSE - printf("caput %f: success\n", p); -#endif - } else - printf(ca_message(status)); -#else - pos=p; -#endif - //"caputq X04SA-ES2-TH2:RO p" - //cawait -nounit -timeout 3600 X04SA-ES2-TH2:RO.DMOV '==1' - - return (int)p; -} - -/* moves the encoder to position p without waiting */ - -int defaultGoToPositionNoWait(double p, void*) { -#ifdef VERBOSE - printf("Setting motor position no wait \n"); -#endif - - -#ifdef EPICS - int status; - if (ch_pos<0) return -1; - /* /\* caput and wait until done *\/ */ - if ((status = caputq(ch_pos, p)) == ECA_NORMAL) { - ; -#ifdef VERBOSE - printf("caputq: success\n"); -#endif - } else - printf(ca_message(status)); -#else - pos=p; -#endif - //"caputq X04SA-ES2-TH2:RO p" - - return (int)p; - - pos=p; - return (int)pos; -} - - -/* reads I0 and returns the intensity */ - -double defaultGetI0(int t, void*) { -#ifdef VERBOSE - printf("Getting I0 readout \n"); -#endif - -#ifdef EPICS - int status; - - double value = 256; -/* /\* caget *\/ */ - if (ch_i0<0) return -1; - if (caget(ch_i0, &value) == ECA_NORMAL) { -#ifdef VERBOSE - printf("caget: %f\n", value); -#endif - - - if (t==0) - i0=value; - else - i0=value-i0; - - - - } else - printf(ca_message(status)); -#else - i0++; -#endif - - //"ca_get X04SA-ES2-SC:CH6" - return i0; - -} - - -int defaultConnectChannels(void *) { -#ifdef EPICS - //double value = 256; - /* channel name */ - //const char *name = "ARIDI-PCT:CURRENT"; - /* channel id */ - /* status code */ - int status; - -#ifdef VERBOSE - printf("starting...\n"); -#endif - - /* init channel access context before any caget/put */ - ca_context_create(ca_enable_preemptive_callback); -#ifdef VERBOSE - printf("context created\n"); -#endif - //"caputq X04SA-ES2-TH2:RO p" - - //"ca_get X04SA-ES2-SC:CH6" - - /* open the channel by name and return ch_id */ - status = connect_channel("X04SA-ES2-SC:CH6", &ch_i0); - if (status == ECA_NORMAL) { -#ifdef VERBOSE - printf("I0 channel connected \n"); -#endif - ; - } else { - printf(ca_message(status)); - //ch_i0=-1;; - } - status = connect_channel("X04SA-ES2-TH2:RO", &ch_pos); - if (status == ECA_NORMAL) { -#ifdef VERBOSE - printf("Detector position channel connected \n"); -#endif - ; - } else { - printf(ca_message(status)); - //ch_i0=-1;; - } - status = connect_channel("X04SA-ES2-TH2:RO.RBV", &ch_getpos); - if (status == ECA_NORMAL) { -#ifdef VERBOSE - printf("Detector get position channel connected \n"); -#endif - ; - } else { - printf(ca_message(status)); - //ch_getpos=-1;; - } - - // caget X04SA-ES2-TH2:RO.RBV - - //cawait -nounit -timeout 3600 X04SA-ES2-TH2:RO.DMOV '==1' -#endif - return 0; -} - -int defaultDisconnectChannels(void*) { -#ifdef EPICS - /* close channel connect */ - disconnect_channel(ch_i0); - disconnect_channel(ch_pos); - disconnect_channel(ch_getpos); - - /* delete channel access context before program exits */ - ca_context_destroy(); -#endif - return 0; -} - - - -int defaultDataReadyFunc(detectorData* d) { -#ifdef VERBOSE - printf("UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU Data received \n"); -#endif - return 0; -} - - diff --git a/slsDetectorSoftware/usersFunctions/usersFunctions.h b/slsDetectorSoftware/usersFunctions/usersFunctions.h deleted file mode 100644 index d2cc60f71..000000000 --- a/slsDetectorSoftware/usersFunctions/usersFunctions.h +++ /dev/null @@ -1,49 +0,0 @@ -#ifndef USERS_FUNCTIONS_H -#define USERS_FUNCTIONS_H -/****************************************************************** - -Functions depending on the experimental setup should be defined here - -******************************************************************/ - -#define PI 3.14159265358979323846 - - -#ifdef EPICS -#include -#include -#endif -#include "detectorData.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#ifdef EPICS - int connect_channel(const char *name, chid *ch_id); - int disconnect_channel(chid ch_id); - int caget(chid ch_id, double *value); - int caputq(chid ch_id, double value); - void put_callback(struct event_handler_args args); - int caput(chid ch_id, double value); -#endif - - - // double defaultAngleFunction(double ichan, double encoder, double totalOffset, double conv_r, double center, double offset, double tilt, int direction); - double defaultGetPosition(void*); - int defaultGoToPosition(double p, void*); - int defaultGoToPositionNoWait(double p, void*); - int defaultConnectChannels(void*); - int defaultDisconnectChannels(void*); - double defaultGetI0(int t, void*); - - int defaultDataReadyFunc(detectorData* d, void*); - - - -#ifdef __cplusplus -}; -#endif - - -#endif diff --git a/slsReceiverSoftware/.gitignore b/slsReceiverSoftware/.gitignore deleted file mode 100644 index a515bd3e6..000000000 --- a/slsReceiverSoftware/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -*~ -*.o -build/* -GPATH -GRTAGS -GSYMS -GTAGS -.project diff --git a/slsReceiverSoftware/CMakeLists.txt b/slsReceiverSoftware/CMakeLists.txt deleted file mode 100644 index 63311c5ef..000000000 --- a/slsReceiverSoftware/CMakeLists.txt +++ /dev/null @@ -1,100 +0,0 @@ -set(SOURCES - src/MySocketTCP.cpp - src/UDPInterface.cpp - src/UDPBaseImplementation.cpp - src/UDPStandardImplementation.cpp - src/slsReceiverTCPIPInterface.cpp - src/slsReceiver.cpp - src/slsReceiverUsers.cpp - src/utilities.cpp - src/File.cpp - src/BinaryFile.cpp - src/ThreadObject.cpp - src/Listener.cpp - src/DataProcessor.cpp - src/DataStreamer.cpp - src/Fifo.cpp -) - - -# HDF5 -if (SLS_USE_HDF5) - if (HDF5_FOUND) - include_directories( - ${HDF5_INCLUDE_DIRS} - ) - add_definitions( - -DHDF5C ${HDF5_DEFINITIONS} - ) - list (APPEND SOURCES - src/HDF5File.cpp - ) - endif () -endif (SLS_USE_HDF5) - - -add_definitions( - -DDACS_INT -DSLS_RECEIVER_UDP_FUNCTIONS -) - -include_directories( - include -) - -add_library(zmq STATIC IMPORTED GLOBAL) - -set(ZMQ_STATIC_ARCHIVE ${CMAKE_CURRENT_SOURCE_DIR}/include/libzmq.a) -set_target_properties(zmq PROPERTIES - IMPORTED_LOCATION ${ZMQ_STATIC_ARCHIVE} -) - -add_library(slsReceiverShared SHARED - ${SOURCES} - ${HEADERS} -) - -set(PUBLICHEADERS - include/sls_receiver_defs.h - include/ansi.h - include/sls_receiver_funcs.h - include/MySocketTCP.h - include/genericSocket.h - include/logger.h - include/sls_receiver_exceptions.h -) - - -set_target_properties(slsReceiverShared PROPERTIES - LIBRARY_OUTPUT_NAME SlsReceiver - LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin - PUBLIC_HEADER "${PUBLICHEADERS}" -) - -add_executable(slsReceiver - src/main.cpp -) -set_target_properties(slsReceiver PROPERTIES - RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin -) -target_link_libraries(slsReceiver - slsReceiverShared - pthread - zmq - rt -) - -if (HDF5_FOUND) - target_link_libraries(slsReceiver ${HDF5_LIBRARIES}) -endif () - - - -install(TARGETS slsReceiverShared slsReceiver - EXPORT "${TARGETS_EXPORT_NAME}" - RUNTIME DESTINATION bin - LIBRARY DESTINATION lib - ARCHIVE DESTINATION lib - PUBLIC_HEADER DESTINATION include) - -install(FILES ${ZMQ_STATIC_ARCHIVE} -DESTINATION lib) diff --git a/slsReceiverSoftware/Makefile b/slsReceiverSoftware/Makefile deleted file mode 100644 index 655d0c1dc..000000000 --- a/slsReceiverSoftware/Makefile +++ /dev/null @@ -1,126 +0,0 @@ -include ../Makefile.include - -DESTDIR ?= ../bin -LIBDIR ?= ../bin -DOCDIR ?= docs -SRCDIR = src -INCDIR = include -TESTDIR = test -BUILDDIR = build -PROGS = $(DESTDIR)/slsReceiver - - -CFLAGS= -g -DC_ONLY -fPIC -#FLAGS+= #-DVERBOSE -DVERYVERBOSE - -DFLAGS= -g -DDACS_INT -DSLS_RECEIVER_UDP_FUNCTIONS #-DVERBOSE - -INCLUDES?= $(INCLUDESRXR) -I include/ - -############################################################## -# ZMQ specific: in this case, you need ZMQ libraries already included in this package -########################################################### -LIBZMQDIR = include -LIBZMQ = -L$(LIBZMQDIR) -Wl,-rpath=$(LIBZMQDIR) -lzmq - - - -SRC_CLNT = MySocketTCP.cpp ThreadObject.cpp Listener.cpp DataProcessor.cpp DataStreamer.cpp Fifo.cpp File.cpp BinaryFile.cpp UDPInterface.cpp UDPBaseImplementation.cpp UDPStandardImplementation.cpp slsReceiverTCPIPInterface.cpp slsReceiver.cpp slsReceiverUsers.cpp utilities.cpp -DEPSINCLUDES = $(INCDIR)/ansi.h $(INCDIR)/sls_receiver_defs.h $(INCDIR)/sls_receiver_funcs.h $(INCDIR)/GeneralData.h $(INCDIR)/circularFifo.h $(INCDIR)/genericSocket.h $(INCDIR)/logger.h $(INCDIR)/receiver_defs.h $(INCDIR)/UDPInterface.h $(INCDIR)/utilities.h $(INCDIR)/ZmqSocket.h $(INCDIR)/BinaryFileStatic.h $(INCDIR)/HDF5FileStatic.h $(INCDIR)/sls_receiver_exceptions.h - - -ifeq ($(HDF5),yes) - SRC_CLNT += HDF5File.cpp -endif - -MAIN_SRC = main.cpp - - -OBJS=$(SRC_CLNT:%.cpp=$(BUILDDIR)/%.o) - -$(info ) -$(info #######################################) -$(info # In slsReceiverSoftware Makefile #) -$(info #######################################) -$(info ) - - -.PHONY: all intdoc package eigerReceiver clean - -all: builddir lib receiver - -dummy: $(DESTDIR)/dummyReceiver - -intdoc: $(SRC_H) $(SRC_CLNT) - doxygen doxy.config - -$(BUILDDIR)/%.o : $(SRCDIR)/%.cpp $(INCDIR)/%.h $(DEPSINCLUDES) Makefile -ifeq ($(ROOTSLS),yes) - $(CXX) -DROOTSLS -o $@ -c $< $(INCLUDES) $(DFLAGS) $(ROOTFLAGS) -fPIC $(EPICSFLAGS) $(LDFLAGRXR) -L/usr/lib64/ $(FLAGS) -else -# $(call colorecho,`./updateGitVersion.sh`) - $(CXX) -o $@ -c $< $(INCLUDES) $(DFLAGS) -fPIC $(EPICSFLAGS) $(LDFLAGRXR) -pthread $(FLAGS) $(LIBZMQ) -lrt -endif - -versioning: - $(call colorecho,`./updateGitVersion.sh`) - -lib: versioning $(OBJS) $(DESTDIR)/libSlsReceiver.so $(DESTDIR)/libSlsReceiver.a - -receiver: $(DESTDIR)/slsReceiver - -$(DESTDIR)/libSlsReceiver.so: $(OBJS) - $(call colorecho,"#######################################") - $(call colorecho,"# Compiling slsReceiver Library #") - $(call colorecho,"#######################################") - $(CXX) -shared -Wl,-soname,libSlsReceiver.so -o libSlsReceiver.so $(OBJS) -lc $(INCLUDES) $(DFLAGS) $(FLAGS) $(EPICSFLAGS) -L/usr/lib64 -pthread $(LIBZMQ) -lrt - $(shell test -d $(DESTDIR) || mkdir -p $(DESTDIR)) - mv libSlsReceiver.so $(DESTDIR) - -$(DESTDIR)/libSlsReceiver.a: $(OBJS) - ar rcs libSlsReceiver.a $(OBJS) - mv libSlsReceiver.a $(DESTDIR) - - -$(DESTDIR)/slsReceiver: $(SRCDIR)/$(MAIN_SRC) $(DESTDIR)/libSlsReceiver.so $(DESTDIR)/libSlsReceiver.a - $(call colorecho,"#######################################") - $(call colorecho,"# Compiling slsReceiver #") - $(call colorecho,"#######################################") - $(CXX) -o $@ $(SRCDIR)/$(MAIN_SRC) $(FLAGS) $(INCLUDES) $(CFLAGS) $(LIBS) $(LDFLAGRXR) -fPIC $(LIBZMQ) -lrt -#$(EIGERFLAGS) - - -$(DESTDIR)/dummyReceiver: $(SRCDIR)/$(DUMMY_MAIN_SRC) $(DESTDIR)/libSlsReceiver.so $(DESTDIR)/libSlsReceiver.a - $(call colorecho,"#######################################") - $(call colorecho,"# Compiling Dummy slsReceiver #") - $(call colorecho,"#######################################") - $(CXX) -o $@ $(SRCDIR)/$(DUMMY_MAIN_SRC) $(FLAGS) $(INCLUDES) $(CFLAGS) $(LIBS) $(LDFLAGRXR) -fPIC $(LIBZMQ) -lrt -#$(EIGERFLAGS) - - -clean: buildclean - make testclean - if test -e $(DESTDIR)/libSlsReceiver.a; then rm $(DESTDIR)/libSlsReceiver.a;fi - if test -e $(DESTDIR)/libSlsReceiver.so; then rm $(DESTDIR)/libSlsReceiver.so;fi - if test -e $(PROGS); then rm $(PROGS);fi - -builddir: - mkdir -p $(BUILDDIR) -# if [ ! -d $(BUILDDIR) ]; then mkdir $(BUILDDIR); fi - -buildclean: - rm -rf $(OBJS) - -testclean: - if [ -f $(TESTDIR)/rec ]; then \ - cd $(TESTDIR) && rm *.o rec send; \ - fi - - -#------------------------------------------------------------------------------- - -install: package - -install_inc: - $(shell test -d $(DESTDIR) || mkdir -p $(DESTDIR)) - cp -P slsReceiver/slsReceiverUsers.h $(DESTDIR) diff --git a/slsReceiverSoftware/gitInfo.txt b/slsReceiverSoftware/gitInfo.txt deleted file mode 100644 index 1cb9fbcb8..000000000 --- a/slsReceiverSoftware/gitInfo.txt +++ /dev/null @@ -1,9 +0,0 @@ -Path: slsDetectorsPackage/slsReceiverSoftware -URL: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git -Repository Root: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git -Repsitory UUID: e998226bce91a0d82ca0bb38c202d404357cf1ff -Revision: 859 -Branch: gh-pages -Last Changed Author: Dhanya_Thattil -Last Changed Rev: 4092 -Last Changed Date: 2019-04-08 11:25:40.000000002 +0200 ./updateAPIVersion.sh diff --git a/slsReceiverSoftware/include/BinaryFile.h b/slsReceiverSoftware/include/BinaryFile.h deleted file mode 100644 index 9cb585396..000000000 --- a/slsReceiverSoftware/include/BinaryFile.h +++ /dev/null @@ -1,120 +0,0 @@ -#pragma once -/************************************************ - * @file BinaryFile.h - * @short sets/gets properties for the binary file, - * creates/closes the file and writes data to it - ***********************************************/ -/** - *@short sets/gets properties for the binary file, creates/closes the file and writes data to it - */ - -#include "File.h" -#include "BinaryFileStatic.h" - -#include - - -class BinaryFile : private virtual slsReceiverDefs, public File, public BinaryFileStatic { - - public: - /** - * Constructor - * creates the File Writer - * @param ind self index - * @param maxf pointer to max frames per file - * @param nd pointer to number of detectors in each dimension - * @param fname pointer to file name prefix - * @param fpath pointer to file path - * @param findex pointer to file index - * @param owenable pointer to over write enable - * @param dindex pointer to detector index - * @param nunits pointer to number of theads/ units per detector - * @param nf pointer to number of images in acquisition - * @param dr pointer to dynamic range - * @param portno pointer to udp port number for logging - * @param smode pointer to silent mode - */ - BinaryFile(int ind, uint32_t* maxf, - int* nd, char* fname, char* fpath, uint64_t* findex, bool* owenable, - int* dindex, int* nunits, uint64_t* nf, uint32_t* dr, uint32_t* portno, - bool* smode); - - /** - * Destructor - */ - ~BinaryFile(); - - /** - * Print all member values - */ - void PrintMembers(); - - /** - * Create file - * @param fnum current frame index to include in file name - * @returns OK or FAIL - */ - int CreateFile(uint64_t fnum); - - /** - * Create master file - * @param en ten giga enable - * @param size image size - * @param nx number of pixels in x direction - * @param ny number of pixels in y direction - * @param at acquisition time - * @param st sub exposure time - * @param sp sub period - * @param ap acquisition period - * @returns OK or FAIL - */ - int CreateMasterFile(bool en, uint32_t size, - uint32_t nx, uint32_t ny, uint64_t at, uint64_t st, uint64_t sp, - uint64_t ap); - - /** - * Close Current File - */ - void CloseCurrentFile(); - - /** - * Close all Files - */ - void CloseAllFiles(); - - /** - * Write data to file - * @param buffer buffer to write from - * @param buffersize size of buffer - * @param fnum current image number - * @param nump number of packets caught - * @returns OK or FAIL - */ - int WriteToFile(char* buffer, int buffersize, uint64_t fnum, uint32_t nump); - - - - private: - - /** - * Get Type - * @return type - */ - fileFormat GetFileType(); - - - - /** File Descriptor */ - FILE* filefd; - - /** Master File Descriptor */ - static FILE* masterfd; - - /** Number of frames in file */ - uint32_t numFramesInFile; - - /** Number of actual packets caught in file */ - uint64_t numActualPacketsInFile; - -}; - diff --git a/slsReceiverSoftware/include/BinaryFileStatic.h b/slsReceiverSoftware/include/BinaryFileStatic.h deleted file mode 100644 index 348453b82..000000000 --- a/slsReceiverSoftware/include/BinaryFileStatic.h +++ /dev/null @@ -1,222 +0,0 @@ -#pragma once -/************************************************ - * @file BinaryFileStatic.h - * @short creating, closing, writing and reading - * from binary files - ***********************************************/ -/** - *@short creating, closing, writing and reading from binary files - */ - - -#include "ansi.h" - -#include -#include -#include - -#define MAX_MASTER_FILE_LENGTH 2000 - - -class BinaryFileStatic { - - public: - - /** Constructor */ - BinaryFileStatic(){}; - /** Destructor */ - virtual ~BinaryFileStatic(){}; - - /** - * Create File Name in format fpath/fnameprefix_fx_dy_z.raw, - * where x is fnum, y is (dindex * numunits + unitindex) and z is findex - * @param fpath file path - * @param fnameprefix file name prefix (includes scan and position variables) - * @param findex file index - * @param frindexenable frame index enable - * @param fnum frame number index - * @param dindex readout index - * @param numunits number of units per readout. eg. eiger has 2 udp units per readout - * @param unitindex unit index - * @returns complete file name created - */ - static std::string CreateFileName(char* fpath, char* fnameprefix, uint64_t findex, bool frindexenable, - uint64_t fnum = 0, int dindex = -1, int numunits = 1, int unitindex = 0) - { - std::ostringstream osfn; - osfn << fpath << "/" << fnameprefix; - if (dindex >= 0) osfn << "_d" << (dindex * numunits + unitindex); - if (frindexenable) osfn << "_f" << std::setfill('0') << std::setw(12) << fnum; - osfn << "_" << findex; - osfn << ".raw"; - return osfn.str(); - } - - /** - * Create file names for master file - * @param fpath file path - * @param fnameprefix file name prefix (includes scan and position variables) - * @param findex file index - * @returns master file name - */ - std::string CreateMasterFileName(char* fpath, char* fnameprefix, uint64_t findex) - { - std::ostringstream osfn; - osfn << fpath << "/" << fnameprefix; - osfn << "_master"; - osfn << "_" << findex; - osfn << ".raw"; - return osfn.str(); - } - - /** - * Close File - * @param fd file pointer - */ - static void CloseDataFile(FILE*& fd) - { - if (fd) - fclose(fd); - fd = 0; - } - - /** - * Write data to file - * @param fd file pointer - * @param buf buffer to write from - * @param bsize size of buffer - * @returns number of elements written - */ - static int WriteDataFile(FILE* fd, char* buf, int bsize) - { - if (!fd) - return 0; - return fwrite(buf, 1, bsize, fd); - } - - - /** - * Create master files - * @param fd pointer to file handle - * @param fname master file name - * @param owenable overwrite enable - * @param dr dynamic range - * @param tenE ten giga enable - * @param size image size - * @param nPixelsX number of pixels in x direction - * @param nPixelsY number of pixels in y direction - * @param nf number of images - * @param maxf maximum frames per file - * @param acquisitionTime acquisition time - * @param acquisitionPeriod acquisition period - * @param subexposuretime sub exposure time - * @param subperiod sub period - * @param version version of software for binary writing - * @returns 0 for success and 1 for fail - */ - static int CreateMasterDataFile(FILE*& fd, std::string fname, bool owenable, - uint32_t dr, bool tenE, uint32_t size, - uint32_t nPixelsX, uint32_t nPixelsY, uint64_t nf, - uint32_t maxf, - uint64_t acquisitionTime, uint64_t subexposuretime, - uint64_t subperiod, uint64_t acquisitionPeriod, double version) - { - if(!owenable){ - if (NULL == (fd = fopen((const char *) fname.c_str(), "wx"))){ - cprintf(RED,"Error in creating binary master file %s\n",fname.c_str()); - fd = 0; - return 1; - } - }else if (NULL == (fd = fopen((const char *) fname.c_str(), "w"))){ - cprintf(RED,"Error in creating binary master file %s\n",fname.c_str()); - fd = 0; - return 1; - } - time_t t = time(0); - char message[MAX_MASTER_FILE_LENGTH]; - sprintf(message, - "Version : %.1f\n" - "Dynamic Range : %d\n" - "Ten Giga : %d\n" - "Image Size : %d bytes\n" - "row : %d pixels\n" - "col : %d pixels\n" - "Max. Frames Per File : %u\n" - "Total Frames : %lld\n" - "Exptime (ns) : %lld\n" - "SubExptime (ns) : %lld\n" - "SubPeriod(ns) : %lld\n" - "Period (ns) : %lld\n" - "Timestamp : %s\n\n" - - "#Frame Header\n" - "Frame Number : 8 bytes\n" - "SubFrame Number/ExpLength : 4 bytes\n" - "Packet Number : 4 bytes\n" - "Bunch ID : 8 bytes\n" - "Timestamp : 8 bytes\n" - "Module Id : 2 bytes\n" - "Row : 2 bytes\n" - "Column : 2 bytes\n" - "Reserved : 2 bytes\n" - "Debug : 4 bytes\n" - "Round Robin Number : 2 bytes\n" - "Detector Type : 1 byte\n" - "Header Version : 1 byte\n" - "Packets Caught Mask : 64 bytes\n" - , - version, - dr, - tenE, - size, - nPixelsX, - nPixelsY, - maxf, - (long long int)nf, - (long long int)acquisitionTime, - (long long int)subexposuretime, - (long long int)subperiod, - (long long int)acquisitionPeriod, - ctime(&t)); - if (strlen(message) > MAX_MASTER_FILE_LENGTH) { - cprintf(RED,"Master File Size %d is greater than max str size %d\n", - (int)strlen(message), MAX_MASTER_FILE_LENGTH); - return 1; - } - - if (fwrite((void*)message, 1, strlen(message), fd) != strlen(message)) - return 1; - - BinaryFileStatic::CloseDataFile(fd); - return 0; - } - - - /** - * Create File - * @param fd file pointer - * @param owenable overwrite enable - * @param fname complete file name - * @param filebuffersize file buffer size - * @returns 0 for success and 1 for fail - */ - static int CreateDataFile(FILE*& fd, bool owenable, std::string fname, size_t filebuffersize) - { - if(!owenable){ - if (NULL == (fd = fopen((const char *) fname.c_str(), "wx"))){ - FILE_LOG(logERROR) << "Could not create/overwrite file" << fname; - fd = 0; - return 1; - } - }else if (NULL == (fd = fopen((const char *) fname.c_str(), "w"))){ - FILE_LOG(logERROR) << "Could not create file" << fname; - fd = 0; - return 1; - } - //setting file buffer size to 16mb - setvbuf(fd,NULL,_IOFBF,filebuffersize); - return 0; - } - -}; - diff --git a/slsReceiverSoftware/include/DataProcessor.h b/slsReceiverSoftware/include/DataProcessor.h deleted file mode 100644 index 6b7692430..000000000 --- a/slsReceiverSoftware/include/DataProcessor.h +++ /dev/null @@ -1,400 +0,0 @@ -#pragma once -/************************************************ - * @file DataProcessor.h - * @short creates data processor thread that - * pulls pointers to memory addresses from fifos - * and processes data stored in them & writes them to file - ***********************************************/ -/** - *@short creates & manages a data processor thread each - */ - -#include "ThreadObject.h" - -class GeneralData; -class Fifo; -class File; -class DataStreamer; - -#include - -class DataProcessor : private virtual slsReceiverDefs, public ThreadObject { - - public: - /** - * Constructor - * Calls Base Class CreateThread(), sets ErrorMask if error and increments NumberofDataProcessors - * @param ind self index - * @param dtype detector type - * @param f address of Fifo pointer - * @param ftype pointer to file format type - * @param fwenable file writer enable - * @param dsEnable pointer to data stream enable - * @param gpEnable pointer to gap pixels enable - * @param dr pointer to dynamic range - * @param freq pointer to streaming frequency - * @param timer pointer to timer if streaming frequency is random - * @param fp pointer to frame padding enable - * @param act pointer to activated - * @param depaden pointer to deactivated padding enable - * @param sm pointer to silent mode - * @param dataReadycb pointer to data ready call back function - * @param dataModifyReadycb pointer to data ready call back function with modified - * @param pDataReadycb pointer to arguments of data ready call back function. To write/stream a smaller size of processed data, change this value (only smaller value is allowed). - */ - DataProcessor(int ind, detectorType dtype, Fifo*& f, fileFormat* ftype, - bool fwenable, bool* dsEnable, bool* gpEnable, uint32_t* dr, - uint32_t* freq, uint32_t* timer, - bool* fp, bool* act, bool* depaden, bool* sm, - void (*dataReadycb)(char*, char*, uint32_t, void*), - void (*dataModifyReadycb)(char*, char*, uint32_t &, void*), - void *pDataReadycb); - - /** - * Destructor - * Calls Base Class DestroyThread() and decrements NumberofDataProcessors - */ - ~DataProcessor(); - - - //*** getters *** - /** - * Returns if the thread is currently running - * @returns true if thread is running, else false - */ - bool IsRunning(); - - /** - * Get acquisition started flag - * @return acquisition started flag - */ - bool GetAcquisitionStartedFlag(); - - /** - * Get measurement started flag - * @return measurement started flag - */ - bool GetMeasurementStartedFlag(); - - /** - * Get Total Complete Frames Caught for an entire acquisition (including all scans) - * @return total number of frames caught for entire acquisition - */ - uint64_t GetNumTotalFramesCaught(); - - /** - * Get Frames Complete Caught for each real time acquisition (eg. for each scan) - * @return number of frames caught for each scan - */ - uint64_t GetNumFramesCaught(); - - /** - * Gets Actual Current Frame Index (that has not been subtracted from firstAcquisitionIndex) thats been processed for an entire acquisition (including all scans) - * @return -1 if no frames have been caught, else current frame index (represents all scans too) - */ - uint64_t GetActualProcessedAcquisitionIndex(); - - /** - * Get Current Frame Index thats been processed for an entire acquisition (including all scans) - * @return -1 if no frames have been caught, else current frame index (represents all scans too) - */ - uint64_t GetProcessedAcquisitionIndex(); - - /** - * Get Current Frame Index thats been processed for each real time acquisition (eg. for each scan) - * @return -1 if no frames have been caught, else current frame index - */ - uint64_t GetProcessedMeasurementIndex(); - - //*** setters *** - /** - * Set bit in RunningMask to allow thread to run - */ - void StartRunning(); - - /** - * Reset bit in RunningMask to prevent thread from running - */ - void StopRunning(); - - /** - * Set Fifo pointer to the one given - * @param f address of Fifo pointer - */ - void SetFifo(Fifo*& f); - - /** - * Reset parameters for new acquisition (including all scans) - */ - void ResetParametersforNewAcquisition(); - - /** - * Reset parameters for new measurement (eg. for each scan) - */ - void ResetParametersforNewMeasurement(); - - /** - * Set GeneralData pointer to the one given - * @param g address of GeneralData (Detector Data) pointer - */ - void SetGeneralData(GeneralData* g); - - /** - * Set thread priority - * @priority priority - * @returns OK or FAIL - */ - int SetThreadPriority(int priority); - - /** - * Set File Format - * @param f file format - */ - void SetFileFormat(const fileFormat fs); - - /** - * Set up file writer object and call backs - * @param fwe file write enable - * @param nd pointer to number of detectors in each dimension - * @param maxf pointer to max frames per file - * @param fname pointer to file name prefix - * @param fpath pointer to file path - * @param findex pointer to file index - * @param owenable pointer to over write enable - * @param dindex pointer to detector index - * @param nunits pointer to number of threads/ units per detector - * @param nf pointer to number of images in acquisition - * @param dr pointer to dynamic range - * @param portno pointer to udp port number - * @param g address of GeneralData (Detector Data) pointer - */ - void SetupFileWriter(bool fwe, int* nd, uint32_t* maxf, char* fname, - char* fpath, uint64_t* findex, - bool* owenable, int* dindex, int* nunits, uint64_t* nf, uint32_t* dr, - uint32_t* portno, GeneralData* g = 0); - - /** - * Create New File - * @param en ten giga enable - * @param nf number of frames - * @param at acquisition time - * @param st sub exposure time - * @param sp sub period - * @param ap acquisition period - * @returns OK or FAIL - */ - int CreateNewFile(bool en, uint64_t nf, uint64_t at, uint64_t st, - uint64_t sp, uint64_t ap); - - /** - * Closes files - */ - void CloseFiles(); - - /** - * End of Acquisition - * @param anyPacketsCaught true if any packets are caught, else false - * @param numf number of images caught - */ - void EndofAcquisition(bool anyPacketsCaught, uint64_t numf); - - /** - * Update pixel dimensions in file writer - */ - void SetPixelDimension(); - - - - - private: - - /** - * Get Type - * @return type - */ - std::string GetType(); - - /** - * Record First Indices (firstAcquisitionIndex, firstMeasurementIndex) - * @param fnum frame index to record - */ - void RecordFirstIndices(uint64_t fnum); - - /** - * Destroy file writer object - * @return OK or FAIL - */ - void DestroyFileWriter(); - - /** - * Thread Exeution for DataProcessor Class - * Pop bound addresses, process them, - * write to file if needed & free the address - */ - void ThreadExecution(); - - /** - * Frees dummy buffer, - * reset running mask by calling StopRunning() - * @param buf address of pointer - */ - void StopProcessing(char* buf); - - /** - * Process an image popped from fifo, - * write to file if fw enabled & update parameters - * @param buffer - */ - void ProcessAnImage(char* buf); - - /** - * Calls CheckTimer and CheckCount for streaming frequency and timer - * and determines if the current image should be sent to streamer - * @returns true if it should to streamer, else false - */ - bool SendToStreamer(); - - /** - * This function should be called only in random frequency mode - * Checks if timer is done and ready to send to stream - * @returns true if ready to send to stream, else false - */ - bool CheckTimer(); - - /** - * This function should be called only in non random frequency mode - * Checks if count is done and ready to send to stream - * @returns true if ready to send to stream, else false - */ - bool CheckCount(); - - /** - * Pad Missing Packets from the bit mask - * @param buf buffer - */ - void PadMissingPackets(char* buf); - - /** - * Processing Function (inserting gap pixels) eiger specific - * @param buf pointer to image - * @param dr dynamic range - */ - void InsertGapPixels(char* buf, uint32_t dr); - - /** type of thread */ - static const std::string TypeName; - - /** Object running status */ - bool runningFlag; - - /** GeneralData (Detector Data) object */ - const GeneralData* generalData; - - /** Fifo structure */ - Fifo* fifo; - - - //individual members - /** Detector Type */ - detectorType myDetectorType; - - /** File writer implemented as binary or hdf5 File */ - File* file; - - /** Data Stream Enable */ - bool* dataStreamEnable; - - /** File Format Type */ - fileFormat* fileFormatType; - - /** File Write Enable */ - bool fileWriteEnable; - - /** Gap Pixels Enable */ - bool* gapPixelsEnable; - - - /** Dynamic Range */ - uint32_t* dynamicRange; - - /** Pointer to Streaming frequency, if 0, sending random images with a timer */ - uint32_t* streamingFrequency; - - /** Pointer to the timer if Streaming frequency is random */ - uint32_t* streamingTimerInMs; - - /** Current frequency count */ - uint32_t currentFreqCount; - - /** timer beginning stamp for random streaming */ - struct timespec timerBegin; - - /** temporary buffer for processing */ - char* tempBuffer; - - /** Activated/Deactivated */ - bool* activated; - - /** Deactivated padding enable */ - bool* deactivatedPaddingEnable; - - /** Silent Mode */ - bool* silentMode; - - /** frame padding */ - bool* framePadding; - - //acquisition start - /** Aquisition Started flag */ - bool acquisitionStartedFlag; - - /** Measurement Started flag */ - bool measurementStartedFlag; - - /** Frame Number of First Frame of an entire Acquisition (including all scans) */ - uint64_t firstAcquisitionIndex; - - /** Frame Number of First Frame for each real time acquisition (eg. for each scan) */ - uint64_t firstMeasurementIndex; - - - //for statistics - /**Number of complete frames caught for an entire acquisition (including all scans) */ - uint64_t numTotalFramesCaught; - - /** Number of complete frames caught for each real time acquisition (eg. for each scan) */ - uint64_t numFramesCaught; - - /** Frame Number of latest processed frame number of an entire Acquisition (including all scans) */ - uint64_t currentFrameIndex; - - - //call back - /** - * Call back for raw data - * args to raw data ready callback are - * sls_receiver_header frame metadata - * dataPointer is the pointer to the data - * dataSize in bytes is the size of the data in bytes. - */ - void (*rawDataReadyCallBack)(char*, - char*, uint32_t, void*); - - /** - * Call back for raw data (modified) - * args to raw data ready callback are - * sls_receiver_header frame metadata - * dataPointer is the pointer to the data - * revDatasize is the reference of data size in bytes. Can be modified to the new size to be written/streamed. (only smaller value). - */ - void (*rawDataModifyReadyCallBack)(char*, - char*, uint32_t &, void*); - - void *pRawDataReady; - - - - - -}; - diff --git a/slsReceiverSoftware/include/DataStreamer.h b/slsReceiverSoftware/include/DataStreamer.h deleted file mode 100644 index 8857102c7..000000000 --- a/slsReceiverSoftware/include/DataStreamer.h +++ /dev/null @@ -1,211 +0,0 @@ -#pragma once -/************************************************ - * @file DataStreamer.h - * @short streams data from receiver via ZMQ - ***********************************************/ -/** - *@short creates & manages a data streamer thread each - */ - -#include "ThreadObject.h" - -class GeneralData; -class Fifo; -class DataStreamer; -class ZmqSocket; - -#include - -class DataStreamer : private virtual slsReceiverDefs, public ThreadObject { - - public: - /** - * Constructor - * Calls Base Class CreateThread(), sets ErrorMask if error and increments NumberofDataStreamers - * @param ind self index - * @param f address of Fifo pointer - * @param dr pointer to dynamic range - * @param r roi - * @param fi pointer to file index - * @param fd flipped data enable for x and y dimensions - * @param ajh additional json header - * @param sm pointer to silent mode - */ - DataStreamer(int ind, Fifo*& f, uint32_t* dr, std::vector* r, - uint64_t* fi, int* fd, char* ajh, bool* sm); - - /** - * Destructor - * Calls Base Class DestroyThread() and decrements NumberofDataStreamers - */ - ~DataStreamer(); - - //*** getters *** - /** - * Returns if the thread is currently running - * @returns true if thread is running, else false - */ - bool IsRunning(); - - - //*** setters *** - /** - * Set bit in RunningMask to allow thread to run - */ - void StartRunning(); - - /** - * Reset bit in RunningMask to prevent thread from running - */ - void StopRunning(); - - /** - * Set Fifo pointer to the one given - * @param f address of Fifo pointer - */ - void SetFifo(Fifo*& f); - - /** - * Reset parameters for new acquisition (including all scans) - */ - void ResetParametersforNewAcquisition(); - - /** - * Reset parameters for new measurement (eg. for each scan) - */ - void ResetParametersforNewMeasurement(char* fname); - - /** - * Set GeneralData pointer to the one given - * @param g address of GeneralData (Detector Data) pointer - */ - void SetGeneralData(GeneralData* g); - - /** - * Set thread priority - * @priority priority - * @returns OK or FAIL - */ - int SetThreadPriority(int priority); - - /** - * Creates Zmq Sockets - * (throws an exception if it couldnt create zmq sockets) - * @param nunits pointer to number of theads/ units per detector - * @param port streaming port start index - * @param srcip streaming source ip - */ - void CreateZmqSockets(int* nunits, uint32_t port, const char* srcip); - - /** - * Shuts down and deletes Zmq Sockets - */ - void CloseZmqSocket(); - - /** - * Restream stop dummy packet - * @return OK or FAIL - */ - int RestreamStop(); - - - private: - - /** - * Get Type - * @return type - */ - std::string GetType(); - - /** - * Record First Indices (firstAcquisitionIndex, firstMeasurementIndex) - * @param fnum frame index to record - */ - void RecordFirstIndices(uint64_t fnum); - - /** - * Thread Exeution for DataStreamer Class - * Stream an image via zmq - */ - void ThreadExecution(); - - /** - * Frees dummy buffer, - * reset running mask by calling StopRunning() - * @param buf address of pointer - */ - void StopProcessing(char* buf); - - /** - * Process an image popped from fifo, - * write to file if fw enabled & update parameters - * @param buffer - */ - void ProcessAnImage(char* buf); - - /** - * Create and send Json Header - * @param rheader header of image - * @param size data size (could have been modified in call back) - * @param nx number of pixels in x dim - * @param ny number of pixels in y dim - * @param dummy true if its a dummy header - * @returns 0 if error, else 1 - */ - int SendHeader(sls_receiver_header* rheader, uint32_t size = 0, uint32_t nx = 0, uint32_t ny = 0, bool dummy = true); - - /** type of thread */ - static const std::string TypeName; - - /** Object running status */ - bool runningFlag; - - /** GeneralData (Detector Data) object */ - const GeneralData* generalData; - - /** Fifo structure */ - Fifo* fifo; - - - - /** ZMQ Socket - Receiver to Client */ - ZmqSocket* zmqSocket; - - /** Pointer to dynamic range */ - uint32_t* dynamicRange; - - /** ROI */ - std::vector* roi; - - /** adc Configured */ - int adcConfigured; - - /** Pointer to file index */ - uint64_t* fileIndex; - - /** flipped data across both dimensions enable */ - int* flippedData; - - /** additional json header */ - char* additionJsonHeader; - - /** Aquisition Started flag */ - bool acquisitionStartedFlag; - - /** Measurement Started flag */ - bool measurementStartedFlag; - - /** Frame Number of First Frame of an entire Acquisition (including all scans) */ - uint64_t firstAcquisitionIndex; - - /** Frame Number of First Frame for each real time acquisition (eg. for each scan) */ - uint64_t firstMeasurementIndex; - - /* File name to stream */ - char fileNametoStream[MAX_STR_LENGTH]; - - /** Complete buffer used for roi, eg. shortGotthard */ - char* completeBuffer; - -}; - diff --git a/slsReceiverSoftware/include/Fifo.h b/slsReceiverSoftware/include/Fifo.h deleted file mode 100644 index 5fad6a3cc..000000000 --- a/slsReceiverSoftware/include/Fifo.h +++ /dev/null @@ -1,111 +0,0 @@ -#pragma once -/************************************************ - * @file Fifo.h - * @short constructs the fifo structure - * which is a circular buffer with pointers to - * parts of allocated memory - ***********************************************/ -/** - *@short constructs the fifo structure - */ - -#include "sls_receiver_defs.h" -#include "logger.h" - -#include "circularFifo.h" - -class Fifo : private virtual slsReceiverDefs { - - public: - /** - * Constructor - * Calls CreateFifos that creates fifos and allocates memory - * @param ind self index - * @param fifoItemSize size of each fifo item - * @param depth fifo depth - */ - Fifo(int ind, uint32_t fifoItemSize, uint32_t depth); - - /** - * Destructor - */ - ~Fifo(); - - /** - * Frees the bound address by pushing into fifoFree - */ - void FreeAddress(char*& address); - - /** - * Pops free address from fifoFree - */ - void GetNewAddress(char*& address); - - /** - * Pushes bound address into fifoBound - */ - void PushAddress(char*& address); - - /** - * Pops bound address from fifoBound to process data - */ - void PopAddress(char*& address); - - /** - * Pushes bound address into fifoStream - */ - void PushAddressToStream(char*& address); - - /** - * Pops bound address from fifoStream to stream data - */ - void PopAddressToStream(char*& address); - - /** - * Get Maximum Level filled in Fifo Bound - * and reset this value for next intake - */ - int GetMaxLevelForFifoBound(); - - /** - * Get Minimum Level filled in Fifo Free - * and reset this value to max for next intake - */ - int GetMinLevelForFifoFree(); - - private: - - /** - * Create Fifos, allocate memory & push addresses into fifo - * @param fifoItemSize size of each fifo item - * @return OK if successful, else FAIL - */ - int CreateFifos(uint32_t fifoItemSize); - - /** - * Destroy Fifos and deallocate memory - */ - void DestroyFifos(); - - - /** Self Index */ - int index; - - /** Memory allocated, whose addresses are pushed into the fifos */ - char* memory; - - /** Circular Fifo pointing to addresses of bound data in memory */ - CircularFifo* fifoBound; - - /** Circular Fifo pointing to addresses of freed data in memory */ - CircularFifo* fifoFree; - - /** Circular Fifo pointing to addresses of to be streamed data in memory */ - CircularFifo* fifoStream; - - /** Fifo depth set */ - int fifoDepth; - - volatile int status_fifoBound; - volatile int status_fifoFree; -}; diff --git a/slsReceiverSoftware/include/File.h b/slsReceiverSoftware/include/File.h deleted file mode 100644 index cb403c2b1..000000000 --- a/slsReceiverSoftware/include/File.h +++ /dev/null @@ -1,217 +0,0 @@ -#pragma once -/************************************************ - * @file File.h - * @short sets/gets properties for the file, - * creates/closes the file and writes data to it - ***********************************************/ -/** - *@short sets/gets properties for the file, creates/closes the file and writes data to it - */ - -#include "sls_receiver_defs.h" -#include "logger.h" - -#include - - -class File : private virtual slsReceiverDefs { - - public: - /** - * Constructor - * creates the File Writer - * @param ind self index - * @param maxf pointer to max frames per file - * @param nd pointer to number of detectors in each dimension - * @param fname pointer to file name prefix - * @param fpath pointer to file path - * @param findex pointer to file index - * @param owenable pointer to over write enable - * @param dindex pointer to detector index - * @param nunits pointer to number of theads/ units per detector - * @param nf pointer to number of images in acquisition - * @param dr pointer to dynamic range - * @param portno pointer to udp port number for logging - * @param smode pointer to silent mode - */ - File(int ind, uint32_t* maxf, - int* nd, char* fname, char* fpath, uint64_t* findex, bool* owenable, - int* dindex, int* nunits, uint64_t* nf, uint32_t* dr, uint32_t* portno, - bool* smode); - - /** - * Destructor - */ - virtual ~File(); - - /** - * Get Current File Name - * @returns current file name - */ - std::string GetCurrentFileName(); - - /** - * Print all member values - */ - virtual void PrintMembers(); - - /** - * Get Type - * @return type - */ - virtual fileFormat GetFileType() = 0; - - /** - * Get Member Pointer Values before the object is destroyed - * @param nd pointer to number of detectors in each dimension - * @param maxf pointer to max frames per file - * @param fname pointer to file name prefix - * @param fpath pointer to file path - * @param findex pointer to file index - * @param owenable pointer to over write enable - * @param dindex pointer to detector index - * @param nunits pointer to number of theads/ units per detector - * @param nf pointer to number of images in acquisition - * @param dr pointer to dynamic range - * @param portno pointer to dynamic range - */ - void GetMemberPointerValues(int* nd, uint32_t*& maxf, char*& fname, char*& fpath, - uint64_t*& findex, bool*& owenable, - int*& dindex, int*& nunits, uint64_t*& nf, uint32_t*& dr, uint32_t*& portno); - - /** - * Create file - * @param fnum current frame index to include in file name - * @returns OK or FAIL - */ - virtual int CreateFile(uint64_t fnum){ - cprintf(RED,"This is a generic function CreateFile that should be " - "overloaded by a derived class\n"); - return OK; - } - - /** - * Close Current File - */ - virtual void CloseCurrentFile() { - cprintf(RED,"This is a generic function CloseCurrentFile that should be " - "overloaded by a derived class\n"); - } - - /** - * Close Files - */ - virtual void CloseAllFiles() { - cprintf(RED,"This is a generic function that should be overloaded " - "by a derived class\n"); - } - - /** - * Write data to file - * @param buffer buffer to write from - * @param fnum current image number - * @param nump number of packets caught - * @param OK or FAIL - */ - virtual int WriteToFile(char* buffer, int buffersize, uint64_t fnum, uint32_t nump) { - cprintf(RED,"This is a generic function WriteToFile that " - "should be overloaded by a derived class\n"); - return FAIL; - } - - /** - * Create master file - * @param en ten giga enable - * @param size image size - * @param nx number of pixels in x direction - * @param ny number of pixels in y direction - * @param at acquisition time - * @param st sub exposure time - * @param sp sub period - * @param ap acquisition period - * @returns OK or FAIL - */ - virtual int CreateMasterFile(bool en, uint32_t size, - uint32_t nx, uint32_t ny, uint64_t at, uint64_t st, - uint64_t sp, uint64_t ap) { - cprintf(RED,"This is a generic function CreateMasterFile that " - "should be overloaded by a derived class\n"); - return OK; - } - - // HDf5 specific - /** - * Set Number of pixels - * @param nx number of pixels in x direction - * @param ny number of pixels in y direction - */ - virtual void SetNumberofPixels(uint32_t nx, uint32_t ny) { - cprintf(RED,"This is a generic function SetNumberofPixels that " - "should be overloaded by a derived class\n"); - } - - /** - * End of Acquisition - * @param anyPacketsCaught true if any packets are caught, else false - * @param numf number of images caught - */ - virtual void EndofAcquisition(bool anyPacketsCaught, uint64_t numf) { - cprintf(RED,"This is a generic function EndofAcquisition that " - "should be overloaded by a derived class\n"); - } - - protected: - - /** master file writer/reader */ - bool master; - - /** Self Index */ - int index; - - /** Maximum frames per file */ - uint32_t* maxFramesPerFile; - - /** Master File Name */ - std::string masterFileName; - - /** Current File Name */ - std::string currentFileName; - - /** Number of Detectors in X dimension */ - int numDetX; - - /** Number of Detectors in Y dimension */ - int numDetY; - - /** File Name Prefix */ - char* fileNamePrefix; - - /** File Path */ - char* filePath; - - /** File Index */ - uint64_t* fileIndex; - - /** Over write enable */ - bool* overWriteEnable; - - /** Detector Index */ - int* detIndex; - - /** Number of units per detector. Eg. Eiger has 2, others 1 */ - int* numUnitsPerDetector; - - /** Number of images in acquisition */ - uint64_t* numImages; - - /** Dynamic Range */ - uint32_t* dynamicRange; - - /** UDP Port Number for logging */ - uint32_t* udpPortNumber; - - /** Silent Mode */ - bool* silentMode; - -}; - diff --git a/slsReceiverSoftware/include/GeneralData.h b/slsReceiverSoftware/include/GeneralData.h deleted file mode 100644 index c9276a778..000000000 --- a/slsReceiverSoftware/include/GeneralData.h +++ /dev/null @@ -1,675 +0,0 @@ -#pragma once -/************************************************ - * @file GeneralData.h - * @short abstract for setting/getting properties of detector data - ***********************************************/ -/** - *@short abstract for setting/getting properties of detector data - */ - -#include "sls_receiver_defs.h" -#include "receiver_defs.h" - -#include //ceil -#include - - -class GeneralData { - -public: - - /** DetectorType */ - slsReceiverDefs::detectorType myDetectorType; - - /** Number of Pixels in x axis */ - uint32_t nPixelsX; - - /** Number of Pixels in y axis */ - uint32_t nPixelsY; - - /** emptybuffer (mainly for jungfrau) */ - uint32_t emptyHeader; - - /** Size of header in Packet */ - uint32_t headerSizeinPacket; - - /** Size of just data in 1 packet (in bytes) */ - uint32_t dataSize; - - /** Size of 1 packet (in bytes) */ - uint32_t packetSize; - - /** Number of packets in an image (for each listening UDP port) */ - uint32_t packetsPerFrame; - - /** Image size (in bytes, for each listening UDP port) */ - uint32_t imageSize; - - /** Frame Number Mask */ - uint64_t frameIndexMask; - - /** Frame Index Offset */ - uint32_t frameIndexOffset; - - /** Packet Index Mask */ - uint32_t packetIndexMask; - - /** Packet Index Offset */ - uint32_t packetIndexOffset; - - /** Max Frames per binary file */ - uint32_t maxFramesPerFile; - - /** Header size of data saved into fifo buffer at a time*/ - uint32_t fifoBufferHeaderSize; - - /** Default Fifo depth */ - uint32_t defaultFifoDepth; - - /** Threads per receiver */ - uint32_t threadsPerReceiver; - - /** Size of a header packet */ - uint32_t headerPacketSize; - - /** Streaming (for ROI - mainly short Gotthard) - Number of Pixels in x axis */ - uint32_t nPixelsXComplete; - - /** Streaming (for ROI - mainly short Gotthard) - Number of Pixels in y axis */ - uint32_t nPixelsYComplete; - - /** Streaming (for ROI - mainly short Gotthard) - Image size (in bytes) */ - uint32_t imageSizeComplete; - - /** if standard header implemented in firmware */ - bool standardheader; - - /** default udp socket buffer size */ - uint32_t defaultUdpSocketBufferSize; - - - - /** Cosntructor */ - GeneralData(): - myDetectorType(slsReceiverDefs::GENERIC), - nPixelsX(0), - nPixelsY(0), - emptyHeader(0), - headerSizeinPacket(0), - dataSize(0), - packetSize(0), - packetsPerFrame(0), - imageSize(0), - frameIndexMask(0), - frameIndexOffset(0), - packetIndexMask(0), - packetIndexOffset(0), - maxFramesPerFile(0), - fifoBufferHeaderSize(0), - defaultFifoDepth(0), - threadsPerReceiver(1), - headerPacketSize(0), - nPixelsXComplete(0), - nPixelsYComplete(0), - imageSizeComplete(0), - standardheader(false), - defaultUdpSocketBufferSize(RECEIVE_SOCKET_BUFFER_SIZE) - {}; - - /** Destructor */ - virtual ~GeneralData(){}; - - /** - * Get Header Infomation (frame number, packet number) - * @param index thread index for debugging purposes - * @param packetData pointer to data - * @param dynamicRange dynamic range to assign subframenumber if 32 bit mode - * @param oddStartingPacket odd starting packet (gotthard) - * @param frameNumber frame number - * @param packetNumber packet number - * @param subFrameNumber sub frame number if applicable - * @param bunchId bunch id - */ - virtual void GetHeaderInfo(int index, char* packetData, uint32_t dynamicRange, bool oddStartingPacket, - uint64_t& frameNumber, uint32_t& packetNumber, uint32_t& subFrameNumber, uint64_t& bunchId) const - { - subFrameNumber = -1; - bunchId = -1; - frameNumber = ((uint32_t)(*((uint32_t*)(packetData)))); - frameNumber++; - packetNumber = frameNumber&packetIndexMask; - frameNumber = (frameNumber & frameIndexMask) >> frameIndexOffset; - } - - /** - * Set ROI - * @param i ROI - */ - virtual void SetROI(std::vector i) { - cprintf(RED,"This is a generic function that should be overloaded by a derived class\n"); - }; - - /** - * Get Adc configured - * @param index thread index for debugging purposes - * @param i pointer to a vector of ROI pointers - * @returns adc configured - */ - virtual int GetAdcConfigured(int index, std::vector* i) const{ - cprintf(RED,"This is a generic function that should be overloaded by a derived class\n"); - return 0; - }; - - /** - * Setting dynamic range changes member variables - * @param dr dynamic range - * @param tgEnable true if 10GbE is enabled, else false - */ - virtual void SetDynamicRange(int dr, bool tgEnable) { - cprintf(RED,"This is a generic function that should be overloaded by a derived class\n"); - }; - - /** - * Setting ten giga enable changes member variables - * @param tgEnable true if 10GbE is enabled, else false - * @param dr dynamic range - */ - virtual void SetTenGigaEnable(bool tgEnable, int dr) { - cprintf(RED,"This is a generic function that should be overloaded by a derived class\n"); - }; - - /** - * Setting packets per frame changes member variables - * @param ns number of samples - * @param nroich number of channels in roi - */ - virtual void setNumberofSamples(const uint64_t ns, uint32_t nroich) { - cprintf(RED,"This is a generic function that should be overloaded by a derived class\n"); - }; - - /** - * Enable Gap Pixels changes member variables - * @param enable true if gap pixels enable, else false - */ - virtual void SetGapPixelsEnable(bool b, int dr) { - cprintf(RED,"This is a generic function that should be overloaded by a derived class\n"); - }; - - /** - * Set odd starting packet (gotthard) - * @param index thread index for debugging purposes - * @param packetData pointer to data - * @returns true or false for odd starting packet number - */ - virtual bool SetOddStartingPacket(int index, char* packetData) { - cprintf(RED,"This is a generic function that should be overloaded by a derived class\n"); - return false; - }; - - - /** - * Print all variables - */ - virtual void Print() const { - FILE_LOG(logDEBUG) << "\n\nDetector Data Variables:"; - FILE_LOG(logDEBUG) << "myDetectorType: " << slsReceiverDefs::getDetectorType(myDetectorType); - FILE_LOG(logDEBUG) << "Pixels X: " << nPixelsX; - FILE_LOG(logDEBUG) << "Pixels Y: " << nPixelsY; - FILE_LOG(logDEBUG) << "Empty Header: " << emptyHeader; - FILE_LOG(logDEBUG) << "Header Size in Packet: " << headerSizeinPacket; - FILE_LOG(logDEBUG) << "Data Size: " << dataSize; - FILE_LOG(logDEBUG) << "Packet Size: " << packetSize; - FILE_LOG(logDEBUG) << "Packets per Frame: " << packetsPerFrame; - FILE_LOG(logDEBUG) << "Image Size: " << imageSize; - FILE_LOG(logDEBUG) << "Frame Index Mask: " << frameIndexMask; - FILE_LOG(logDEBUG) << "Frame Index Offset: " << frameIndexOffset; - FILE_LOG(logDEBUG) << "Packet Index Mask: " << packetIndexMask; - FILE_LOG(logDEBUG) << "Packet Index Offset: " << packetIndexOffset; - FILE_LOG(logDEBUG) << "Max Frames Per File: " << maxFramesPerFile; - FILE_LOG(logDEBUG) << "Fifo Buffer Header Size: " << fifoBufferHeaderSize; - FILE_LOG(logDEBUG) << "Default Fifo Depth: " << defaultFifoDepth; - FILE_LOG(logDEBUG) << "Threads Per Receiver: " << threadsPerReceiver; - FILE_LOG(logDEBUG) << "Header Packet Size: " << headerPacketSize; - FILE_LOG(logDEBUG) << "Complete Pixels X: " << nPixelsXComplete; - FILE_LOG(logDEBUG) << "Complete Pixels Y: " << nPixelsYComplete; - FILE_LOG(logDEBUG) << "Complete Image Size: " << imageSizeComplete; - FILE_LOG(logDEBUG) << "Standard Header: " << standardheader; - FILE_LOG(logDEBUG) << "UDP Socket Buffer Size: " << defaultUdpSocketBufferSize; - }; -}; - - -class GotthardData : public GeneralData { - -private: - const static int nChip = 10; - const static int nChan = 128; - const static int nChipsPerAdc = 2; - public: - - /** Constructor */ - GotthardData(){ - myDetectorType = slsReceiverDefs::GOTTHARD; - nPixelsX = 1280; - nPixelsY = 1; - headerSizeinPacket = 4; - dataSize = 1280; - packetSize = GOTTHARD_PACKET_SIZE; - packetsPerFrame = 2; - imageSize = dataSize*packetsPerFrame; - frameIndexMask = 0xFFFFFFFE; - frameIndexOffset = 1; - packetIndexMask = 1; - maxFramesPerFile = MAX_FRAMES_PER_FILE; - fifoBufferHeaderSize= FIFO_HEADER_NUMBYTES + sizeof(slsReceiverDefs::sls_receiver_header); - defaultFifoDepth = 50000; - }; - - - /** - * Get Header Infomation (frame number, packet number) - * @param index thread index for debugging purposes - * @param packetData pointer to data - * @param dynamicRange dynamic range to assign subframenumber if 32 bit mode - * @param oddStartingPacket odd starting packet (gotthard) - * @param frameNumber frame number - * @param packetNumber packet number - * @param subFrameNumber sub frame number if applicable - * @param bunchId bunch id - */ - void GetHeaderInfo(int index, char* packetData, uint32_t dynamicRange, bool oddStartingPacket, - uint64_t& frameNumber, uint32_t& packetNumber, uint32_t& subFrameNumber, uint64_t& bunchId) const - { - if (nPixelsX == 1280) { - subFrameNumber = -1; - bunchId = -1; - frameNumber = ((uint32_t)(*((uint32_t*)(packetData)))); - if (oddStartingPacket) - frameNumber++; - packetNumber = frameNumber&packetIndexMask; - frameNumber = (frameNumber & frameIndexMask) >> frameIndexOffset; - } else { - subFrameNumber = -1; - bunchId = -1; - frameNumber = ((uint32_t)(*((uint32_t*)(packetData)))); - packetNumber = 0; - } - } - - - /** - * Set ROI - * @param i ROI - */ - void SetROI(std::vector i) { - // all adcs - if(!i.size()) { - nPixelsX = 1280; - dataSize = 1280; - packetSize = GOTTHARD_PACKET_SIZE; - packetsPerFrame = 2; - imageSize = dataSize*packetsPerFrame; - frameIndexMask = 0xFFFFFFFE; - frameIndexOffset = 1; - packetIndexMask = 1; - maxFramesPerFile = MAX_FRAMES_PER_FILE; - fifoBufferHeaderSize= FIFO_HEADER_NUMBYTES + sizeof(slsReceiverDefs::sls_receiver_header); - defaultFifoDepth = 50000; - nPixelsXComplete = 0; - nPixelsYComplete = 0; - imageSizeComplete = 0; - } - - // single adc - else { - nPixelsX = 256; - dataSize = 512; - packetSize = 518; - packetsPerFrame = 1; - imageSize = dataSize*packetsPerFrame; - frameIndexMask = 0xFFFFFFFF; - frameIndexOffset = 0; - packetIndexMask = 0; - maxFramesPerFile = SHORT_MAX_FRAMES_PER_FILE; - fifoBufferHeaderSize= FIFO_HEADER_NUMBYTES + sizeof(slsReceiverDefs::sls_receiver_header); - defaultFifoDepth = 25000; - nPixelsXComplete = 1280; - nPixelsYComplete = 1; - imageSizeComplete = 1280 * 2; - } - }; - - /** - * Get Adc configured - * @param index thread index for debugging purposes - * @param i pointer to a vector of ROI - * @returns adc configured - */ - int GetAdcConfigured(int index, std::vector* i) const{ - int adc = -1; - // single adc - if(i->size()) { - // gotthard can have only one adc per detector enabled (or all) - // so just looking at the first roi is enough (more not possible at the moment) - - //if its for 1 adc or general - if ((i->at(0).xmin == 0) && (i->at(0).xmax == nChip * nChan)) - adc = -1; - else { - //adc = mid value/numchans also for only 1 roi - adc = ((((i->at(0).xmax) + (i->at(0).xmin))/2)/ - (nChan * nChipsPerAdc)); - if((adc < 0) || (adc > 4)) { - FILE_LOG(logWARNING) << index << ": Deleting ROI. " - "Adc value should be between 0 and 4"; - adc = -1; - } - } - } - FILE_LOG(logINFO) << "Adc Configured: " << adc; - return adc; - }; - - /** - * Set odd starting packet (gotthard) - * @param index thread index for debugging purposes - * @param packetData pointer to data - * @returns true or false for odd starting packet number - */ - bool SetOddStartingPacket(int index, char* packetData) { - bool oddStartingPacket = true; - // care only if no roi - if (nPixelsX == 1280) { - uint32_t fnum = ((uint32_t)(*((uint32_t*)(packetData)))); - uint32_t firstData = ((uint32_t)(*((uint32_t*)(packetData + 4)))); - // first packet - if (firstData == 0xCACACACA) { - // packet number should be 0, but is 1 => so odd starting packet - if (fnum & packetIndexMask) { - oddStartingPacket = true; - } else { - oddStartingPacket = false; - } - } - // second packet - else { - // packet number should be 1, but is 0 => so odd starting packet - if (!(fnum & packetIndexMask)) { - oddStartingPacket = true; - } else { - oddStartingPacket = false; - } - } - } - return oddStartingPacket; - }; - - -}; - - -class PropixData : public GeneralData { - - private: - - /**bytes per pixel for calculating image size */ - const static uint32_t bytesPerPixel = 2; - - public: - - /** Constructor */ - PropixData(){ - myDetectorType = slsReceiverDefs::PROPIX; - nPixelsX = 22; - nPixelsY = 22; - headerSizeinPacket = 4; - dataSize = 1280; - packetSize = 1286; - packetsPerFrame = 2; //not really - imageSize = nPixelsX*nPixelsY*bytesPerPixel; - frameIndexMask = 0xFFFFFFFE; - frameIndexOffset = 1; - packetIndexMask = 1; - maxFramesPerFile = MAX_FRAMES_PER_FILE; - fifoBufferHeaderSize= FIFO_HEADER_NUMBYTES + sizeof(slsReceiverDefs::sls_receiver_header); - defaultFifoDepth = 50000; - }; -}; - - -class Moench02Data : public GeneralData { - - public: - - /** Bytes Per Adc */ - const static uint32_t bytesPerAdc = (40*2); - - /** Constructor */ - Moench02Data(){ - myDetectorType = slsReceiverDefs::MOENCH; - nPixelsX = 160; - nPixelsY = 160; - headerSizeinPacket = 4; - dataSize = 1280; - packetSize = 1286; - packetsPerFrame = 40; - imageSize = dataSize*packetsPerFrame; - frameIndexMask = 0xFFFFFF00; - frameIndexOffset = 8; - packetIndexMask = 0xFF; - maxFramesPerFile = MOENCH_MAX_FRAMES_PER_FILE; - fifoBufferHeaderSize= FIFO_HEADER_NUMBYTES + sizeof(slsReceiverDefs::sls_receiver_header); - defaultFifoDepth = 2500; - }; - - /** - * Print all variables - */ - void Print() const { - GeneralData::Print(); - FILE_LOG(logINFO) << "Bytes Per Adc: " << bytesPerAdc; - } -}; - - -class Moench03Data : public GeneralData { - - public: - - /** Constructor */ - Moench03Data(){ - myDetectorType = slsReceiverDefs::MOENCH; - nPixelsX = 400; - nPixelsY = 400; - headerSizeinPacket = 22; - dataSize = 8192; - packetSize = headerSizeinPacket + dataSize; - packetsPerFrame = 40; - imageSize = dataSize*packetsPerFrame; - frameIndexMask = 0xFFFFFFFF; - frameIndexOffset = (6+8); - packetIndexMask = 0xFFFFFFFF; - maxFramesPerFile = JFRAU_MAX_FRAMES_PER_FILE; - fifoBufferHeaderSize= FIFO_HEADER_NUMBYTES + sizeof(slsReceiverDefs::sls_receiver_header); - defaultFifoDepth = 2500; - }; -}; - - -class JCTBData : public GeneralData { - - -private: - /** Structure of an jungfrau ctb packet header */ - typedef struct { - unsigned char emptyHeader[6]; - unsigned char reserved[4]; - unsigned char packetNumber[1]; - unsigned char frameNumber[3]; - unsigned char bunchid[8]; - } jfrauctb_packet_header_t; - - public: - - - - /** Bytes Per Adc */ - const static uint32_t bytesPerAdc = 2; - - /** Constructor */ - JCTBData(){ - myDetectorType = slsReceiverDefs::JUNGFRAUCTB; - nPixelsX = 400; - nPixelsY = 400; - headerSizeinPacket = 22; - dataSize = 8192; - packetSize = headerSizeinPacket + dataSize; - packetsPerFrame = 1; - imageSize = nPixelsX * nPixelsY * 2; - frameIndexMask = 0xFFFFFF; - maxFramesPerFile = JFCTB_MAX_FRAMES_PER_FILE; - fifoBufferHeaderSize= FIFO_HEADER_NUMBYTES + sizeof(slsReceiverDefs::sls_receiver_header); - defaultFifoDepth = 2500; - }; - - - /** - * Get Header Infomation (frame number, packet number) - * @param index thread index for debugging purposes - * @param packetData pointer to data - * @param dynamicRange dynamic range to assign subframenumber if 32 bit mode - * @param oddStartingPacket odd starting packet (gotthard) - * @param frameNumber frame number * @param packetNumber packet number - * @param subFrameNumber sub frame number if applicable - * @param bunchId bunch id - */ - void GetHeaderInfo(int index, char* packetData, uint32_t dynamicRange, bool oddStartingPacket, - uint64_t& frameNumber, uint32_t& packetNumber, uint32_t& subFrameNumber, uint64_t& bunchId) const { - subFrameNumber = -1; - jfrauctb_packet_header_t* header = (jfrauctb_packet_header_t*)(packetData); - frameNumber = (uint64_t)((*( (uint32_t*) header->frameNumber)) & frameIndexMask); - packetNumber = (uint32_t)(*( (uint8_t*) header->packetNumber)); - bunchId = (*((uint64_t*) header->bunchid)); - } - - /** - * Setting packets per frame changes member variables - * @param ns number of samples - * @param nroich number of channels in roi - */ - void setNumberofSamples(const uint64_t ns, uint32_t nroich) { - packetsPerFrame = ceil(double(2 * (nroich ? nroich : 32) * ns) / dataSize); - nPixelsY = (ns * 2) / 25;/* depends on nroich also?? */ - imageSize = nPixelsX * nPixelsY * 2; - }; - - /** - * Print all variables - */ - void Print() const { - GeneralData::Print(); - FILE_LOG(logINFO) << "Bytes Per Adc: " << bytesPerAdc; - } -}; - - -class JungfrauData : public GeneralData { - - public: - - /** Constructor */ - JungfrauData(){ - myDetectorType = slsReceiverDefs::JUNGFRAU; - nPixelsX = (256*4); - nPixelsY = 512; - emptyHeader = 6; - headerSizeinPacket = emptyHeader + sizeof(slsReceiverDefs::sls_detector_header); - dataSize = 8192; - packetSize = headerSizeinPacket + dataSize; - packetsPerFrame = 128; - imageSize = dataSize*packetsPerFrame; - maxFramesPerFile = JFRAU_MAX_FRAMES_PER_FILE; - fifoBufferHeaderSize= FIFO_HEADER_NUMBYTES + sizeof(slsReceiverDefs::sls_receiver_header); - defaultFifoDepth = 2500; - standardheader = true; - defaultUdpSocketBufferSize = (2000 * 1024 * 1024); - }; - -}; - - -class EigerData : public GeneralData { - - public: - - /** Constructor */ - EigerData(){ - myDetectorType = slsReceiverDefs::EIGER; - nPixelsX = (256*2); - nPixelsY = 256; - headerSizeinPacket = sizeof(slsReceiverDefs::sls_detector_header); - dataSize = 1024; - packetSize = headerSizeinPacket + dataSize; - packetsPerFrame = 256; - imageSize = dataSize*packetsPerFrame; - maxFramesPerFile = EIGER_MAX_FRAMES_PER_FILE; - fifoBufferHeaderSize= FIFO_HEADER_NUMBYTES + sizeof(slsReceiverDefs::sls_receiver_header); - defaultFifoDepth = 100; - threadsPerReceiver = 2; - headerPacketSize = 40; - standardheader = true; - }; - - /** - * Setting dynamic range changes member variables - * @param dr dynamic range - * @param tgEnable true if 10GbE is enabled, else false - */ - void SetDynamicRange(int dr, bool tgEnable) { - packetsPerFrame = (tgEnable ? 4 : 16) * dr; - imageSize = dataSize*packetsPerFrame; - } - - /** - * Setting ten giga enable changes member variables - * @param tgEnable true if 10GbE is enabled, else false - * @param dr dynamic range - */ - void SetTenGigaEnable(bool tgEnable, int dr) { - dataSize = (tgEnable ? 4096 : 1024); - packetSize = headerSizeinPacket + dataSize; - packetsPerFrame = (tgEnable ? 4 : 16) * dr; - imageSize = dataSize*packetsPerFrame; - }; - - /** - * Enable Gap Pixels changes member variables - * @param enable true if gap pixels enable, else false - * @param dr dynamic range - */ - void SetGapPixelsEnable(bool b, int dr) { - if (dr == 4) - b = 0; - switch((int)b) { - case 1: - nPixelsX = (256 * 2) + 3; - nPixelsY = 256 + 1; - imageSize = nPixelsX * nPixelsY * ((dr > 16) ? 4 : // 32 bit - ((dr > 8) ? 2 : // 16 bit - ((dr > 4) ? 1 : // 8 bit - 0.5))); // 4 bit - break; - default: - nPixelsX = (256*2); - nPixelsY = 256; - imageSize = nPixelsX * nPixelsY * ((dr > 16) ? 4 : // 32 bit - ((dr > 8) ? 2 : // 16 bit - ((dr > 4) ? 1 : // 8 bit - 0.5))); // 4 bit - break; - } - }; - - -}; - diff --git a/slsReceiverSoftware/include/HDF5File.h b/slsReceiverSoftware/include/HDF5File.h deleted file mode 100644 index ff5146e50..000000000 --- a/slsReceiverSoftware/include/HDF5File.h +++ /dev/null @@ -1,199 +0,0 @@ -#ifdef HDF5C -#pragma once -/************************************************ - * @file HDF5File.h - * @short sets/gets properties for the HDF5 file, - * creates/closes the file and writes data to it - ***********************************************/ -/** - *@short sets/gets properties for the HDF5 file, creates/closes the file and writes data to it - */ - - -#include "File.h" -#include "HDF5FileStatic.h" - -#include "H5Cpp.h" -#ifndef H5_NO_NAMESPACE - using namespace H5; -#endif - - -class HDF5File : private virtual slsReceiverDefs, public File, public HDF5FileStatic { - - public: - /** - * Constructor - * creates the File Writer - * @param ind self index - * @param maxf pointer to max frames per file - * @param nd pointer to number of detectors in each dimension - * @param fname pointer to file name prefix - * @param fpath pointer to file path - * @param findex pointer to file index - * @param owenable pointer to over write enable - * @param dindex pointer to detector index - * @param nunits pointer to number of theads/ units per detector - * @param nf pointer to number of images in acquisition - * @param dr pointer to dynamic range - * @param portno pointer to udp port number for logging - * @param nx number of pixels in x direction - * @param ny number of pixels in y direction - * @param smode pointer to silent mode - */ - HDF5File(int ind, uint32_t* maxf, - int* nd, char* fname, char* fpath, uint64_t* findex, bool* owenable, - int* dindex, int* nunits, uint64_t* nf, uint32_t* dr, uint32_t* portno, - uint32_t nx, uint32_t ny, - bool* smode); - - /** - * Destructor - */ - ~HDF5File(); - - /** - * Print all member values - */ - void PrintMembers(); - - /** - * Set Number of pixels - * @param nx number of pixels in x direction - * @param ny number of pixels in y direction - */ - void SetNumberofPixels(uint32_t nx, uint32_t ny); - - /** - * Create file - * @param fnum current frame index to include in file name - * @returns OK or FAIL - */ - int CreateFile(uint64_t fnum); - - /** - * Close Current File - */ - void CloseCurrentFile(); - - /** - * Close all Files - */ - void CloseAllFiles(); - - /** - * Write data to file - * @param buffer buffer to write from - * @param bsize size of buffer (not used) - * @param fnum current image number - * @param nump number of packets caught - * @returns OK or FAIL - */ - int WriteToFile(char* buffer, int bsize, uint64_t fnum, uint32_t nump); - - /** - * Create master file - * @param en ten giga enable - * @param size image size - * @param nx number of pixels in x direction - * @param ny number of pixels in y direction - * @param at acquisition time - * @param st sub exposure time - * @param sp sub period - * @param ap acquisition period - * @returns OK or FAIL - */ - int CreateMasterFile(bool en, uint32_t size, - uint32_t nx, uint32_t ny, uint64_t at, uint64_t st, uint64_t sp, - uint64_t ap); - - /** - * End of Acquisition - * @param anyPacketsCaught true if any packets are caught, else false - * @param numf number of images caught - */ - void EndofAcquisition(bool anyPacketsCaught, uint64_t numf); - - - private: - - /** - * Create Virtual File - * @param numf number of images caught - * @returns OK or FAIL - */ - int CreateVirtualFile(uint64_t numf); - - /** - * Link virtual file in master file - * Only for Jungfrau at the moment for 1 module and 1 data file - * @returns OK or FAIL - */ - int LinkVirtualFileinMasterFile(); - - /** - * Get Type - * @return type - */ - fileFormat GetFileType(); - - /** - * Updates data type depending on current dynamic range - */ - void UpdateDataType(); - - - - /** mutex to update static items among objects (threads)*/ - static pthread_mutex_t Mutex; - - /** Master File handle */ - static H5File* masterfd; - - /** Virtual File handle ( only file name because code in C as H5Pset_virtual doesnt exist yet in C++) */ - static hid_t virtualfd; - - /** File handle */ - H5File* filefd; - - /** Dataspace handle */ - DataSpace* dataspace; - - /** DataSet handle */ - DataSet* dataset; - - /** Datatype of dataset */ - DataType datatype; - - /** Number of pixels in x direction */ - uint32_t nPixelsX; - - /** Number of pixels in y direction */ - uint32_t nPixelsY; - - /** Number of frames in file */ - uint32_t numFramesInFile; - - /** Number of actual packets caught in file */ - uint64_t numActualPacketsInFile; - - /** Number of files in an acquisition - to verify need of virtual file */ - int numFilesinAcquisition; - - /** parameter names */ - std::vector parameterNames; - - /** parameter data types */ - std::vector parameterDataTypes; - - /** Dataspace of parameters */ - DataSpace* dataspace_para; - - /** Dataset array for parameters */ - std::vector dataset_para; - - /** Number of Images (including extended during acquisition) */ - uint64_t extNumImages; - -}; -#endif diff --git a/slsReceiverSoftware/include/HDF5FileStatic.h b/slsReceiverSoftware/include/HDF5FileStatic.h deleted file mode 100644 index 1fff667da..000000000 --- a/slsReceiverSoftware/include/HDF5FileStatic.h +++ /dev/null @@ -1,992 +0,0 @@ -#ifdef HDF5C -#pragma once -/************************************************ - * @file HDF5FileStatic.h - * @short creating, closing, writing and reading - * from HDF5 files - ***********************************************/ -/** - *@short creating, closing, writing and reading from HDF5 files - */ - -#include "H5Cpp.h" -#ifndef H5_NO_NAMESPACE -using namespace H5; -#endif -#include "sls_receiver_defs.h" -#include "logger.h" - -#include -#include -#include -#include -#include //malloc -#include -#include //memset - -class HDF5FileStatic: public virtual slsReceiverDefs { - -public: - - /** Constructor */ - HDF5FileStatic(){}; - /** Destructor */ - virtual ~HDF5FileStatic(){}; - - - /** - * Create File Name in format fpath/fnameprefix_fx_dy_z.raw, - * where x is fnum, y is (dindex * numunits + unitindex) and z is findex - * @param fpath file path - * @param fnameprefix file name prefix (includes scan and position variables) - * @param findex file index - * @param frindexenable frame index enable - * @param fnum frame number index - * @param dindex readout index - * @param numunits number of units per readout. eg. eiger has 2 udp units per readout - * @param unitindex unit index - * @returns complete file name created - */ - static std::string CreateFileName(char* fpath, char* fnameprefix, uint64_t findex, bool frindexenable, - uint64_t fnum = 0, int dindex = -1, int numunits = 1, int unitindex = 0) - { - std::ostringstream osfn; - osfn << fpath << "/" << fnameprefix; - if (dindex >= 0) osfn << "_d" << (dindex * numunits + unitindex); - if (frindexenable) osfn << "_f" << std::setfill('0') << std::setw(12) << fnum; - osfn << "_" << findex; - osfn << ".h5"; - return osfn.str(); - } - - /** - * Create master file name - * @param fpath file path - * @param fnameprefix file name prefix (includes scan and position variables) - * @param findex file index - * @returns master file name - */ - static std::string CreateMasterFileName(char* fpath, char* fnameprefix, uint64_t findex) - { - std::ostringstream osfn; - osfn << fpath << "/" << fnameprefix; - osfn << "_master"; - osfn << "_" << findex; - osfn << ".h5"; - return osfn.str(); - } - - /** - * Create virtual file name - * @param fpath file path - * @param fnameprefix file name prefix (includes scan and position variables) - * @param fnum current frame number - * @param findex file index - * @returns virtual file name - */ - static std::string CreateVirtualFileName(char* fpath, char* fnameprefix, uint64_t findex) - { - std::ostringstream osfn; - osfn << fpath << "/" << fnameprefix; - osfn << "_virtual"; - osfn << "_" << findex; - osfn << ".h5"; - return osfn.str(); - } - - /** - * Close File - * @param ind index for debugging - * @param fd file pointer - * @param dp dataspace pointer - * @param ds dataset pointer - * @param ds_para pointer to array of parameter datasets - */ - - static void CloseDataFile(int ind, H5File*& fd) - { - try { - Exception::dontPrint(); //to handle errors - if (fd) { - delete fd; - fd = 0; - } - } catch(Exception error) { - cprintf(RED,"Error in closing HDF5 handles of index %d\n", ind); - error.printErrorStack(); - } - } - - /* - * Close master file - * @param fd master hdf5 file object - */ - static void CloseMasterDataFile(H5File*& fd) - { - try { - Exception::dontPrint(); //to handle errors - if (fd) { - delete fd; - fd = 0; - } - } catch(Exception error) { - cprintf(RED,"Error in closing master HDF5 handles\n"); - error.printErrorStack(); - } - } - - /* - * Close virtual file - * (in C because H5Pset_virtual doesnt exist yet in C++) - * @param fd virtual hdf5 file handle - */ - static void CloseVirtualDataFile(hid_t& fd) - { - if(fd) { - if (H5Fclose(fd) < 0 ) - cprintf(RED,"Error in closing virtual HDF5 handles\n"); - fd = 0; - } - } - - /** - * Write data to file - * @param ind object index for debugging - * @param buf buffer to write from - * @param nDimx image number in file (imagenumber%maxframesinfile) - * @param nDimy number of pixels in y direction - * @param nDimz number of pixels in x direction - * @param dspace dataspace pointer - * @param dset dataset pointer - * @param dtype datatype - * @returns 0 for success and 1 for fail - */ - static int WriteDataFile(int ind, char* buf, - uint64_t nDimx, uint32_t nDimy, uint32_t nDimz, - DataSpace* dspace, DataSet* dset, DataType dtype) - { - hsize_t count[3] = {1, nDimy, nDimz}; - hsize_t start[3] = {nDimx, 0, 0}; - hsize_t dims2[2] = {nDimy, nDimz}; - try{ - Exception::dontPrint(); //to handle errors - - dspace->selectHyperslab( H5S_SELECT_SET, count, start); - DataSpace memspace(2,dims2); - dset->write(buf, dtype, memspace, *dspace); - memspace.close(); - } - catch(Exception error){ - cprintf(RED,"Error in writing to file in object %d\n",ind); - error.printErrorStack(); - return 1; - } - return 0; - } - - - - /** - * Write Parameter Arrays as datasets (to virtual file) - * @param ind self index - * @param dspace_para parameter dataspace - * @param fnum current frame number - * @param dset_para vector or dataset pointers of parameters - * @param rheader sls_receiver_header pointer - * @param parameterDataTypes parameter datatypes - */ - static int WriteParameterDatasets(int ind, DataSpace* dspace_para, uint64_t fnum, - std::vector dset_para,sls_receiver_header* rheader, - std::vector parameterDataTypes) - { - sls_detector_header header = rheader->detHeader; - hsize_t count[1] = {1}; - hsize_t start[1] = {fnum}; - int i = 0; - try{ - Exception::dontPrint(); //to handle errors - dspace_para->selectHyperslab( H5S_SELECT_SET, count, start); - DataSpace memspace(H5S_SCALAR); - dset_para[0]->write(&header.frameNumber, parameterDataTypes[0], memspace, *dspace_para);i=1; - dset_para[1]->write(&header.expLength, parameterDataTypes[1], memspace, *dspace_para);i=2; - dset_para[2]->write(&header.packetNumber, parameterDataTypes[2], memspace, *dspace_para);i=3; - dset_para[3]->write(&header.bunchId, parameterDataTypes[3], memspace, *dspace_para);i=4; - dset_para[4]->write(&header.timestamp, parameterDataTypes[4], memspace, *dspace_para);i=5; - dset_para[5]->write(&header.modId, parameterDataTypes[5], memspace, *dspace_para);i=6; - dset_para[6]->write(&header.row, parameterDataTypes[6], memspace, *dspace_para);i=7; - dset_para[7]->write(&header.column, parameterDataTypes[7], memspace, *dspace_para);i=8; - dset_para[8]->write(&header.reserved, parameterDataTypes[8], memspace, *dspace_para);i=9; - dset_para[9]->write(&header.debug, parameterDataTypes[9], memspace, *dspace_para);i=10; - dset_para[10]->write(&header.roundRNumber, parameterDataTypes[10], memspace, *dspace_para);i=11; - dset_para[11]->write(&header.detType, parameterDataTypes[11], memspace, *dspace_para);i=12; - dset_para[12]->write(&header.version, parameterDataTypes[12], memspace, *dspace_para);i=13; - - // contiguous bitset - if (sizeof(sls_bitset) == sizeof(bitset_storage)) { - dset_para[13]->write((char*)&(rheader->packetsMask), parameterDataTypes[13], memspace, *dspace_para); - } - - // not contiguous bitset - else { - // get contiguous representation of bit mask - bitset_storage storage; - memset(storage, 0 , sizeof(bitset_storage)); - sls_bitset bits = rheader->packetsMask; - for (int i = 0; i < MAX_NUM_PACKETS; ++i) - storage[i >> 3] |= (bits[i] << (i & 7)); - // write bitmask - dset_para[13]->write((char*)storage, parameterDataTypes[13], memspace, *dspace_para); - }i=14; - } - catch(Exception error){ - cprintf(RED,"Error in writing parameters (index:%d) to file in object %d\n", i, ind); - error.printErrorStack(); - return 1; - } - return 0; - } - - - - /** - * Extend datasets in #images dimension (x dimension) - * @param ind self index - * @param dpace data space pointer address - * @param dset data set pointer - * @param dspace_para parameter dataspace address pointer - * @param dset dataset parameter pointer - * @param initialNumImages initial number of images - * @returns 0 for success and 1 for fail - */ - static int ExtendDataset(int ind, DataSpace*& dspace, DataSet* dset, - DataSpace*& dspace_para, std::vector dset_para, - uint64_t initialNumImages) { - try{ - Exception::dontPrint(); //to handle errors - - hsize_t dims[3]; - dspace->getSimpleExtentDims(dims); - dims[0] += initialNumImages; - - dset->extend(dims); - delete dspace; - dspace = 0; - dspace = new DataSpace(dset->getSpace()); - - hsize_t dims_para[1] = {dims[0]}; - for (unsigned int i = 0; i < dset_para.size(); ++i) - dset_para[i]->extend(dims_para); - delete dspace_para; - dspace_para = 0; - dspace_para = new DataSpace(dset_para[0]->getSpace()); - - } - catch(Exception error){ - cprintf(RED,"Error in extending dataset in object %d\n",ind); - error.printError(); - return 1; - } - return 0; - } - - - /** - * Create master file - * @param fname master file name - * @param owenable overwrite enable - * @param dr dynamic range - * @param tenE ten giga enable - * @param size image size - * @param nx number of pixels in x direction - * @param ny number of pixels in y direction - * @param nf number of images - * @param maxf maximum frames per file - * @param acquisitionTime acquisition time - * @param subexposuretime sub exposure time - * @param subperiod sub period - * @param acquisitionPeriod acquisition period - * @param version version of software for hdf5 writing - * @returns 0 for success and 1 for fail - */ - static int CreateMasterDataFile(H5File*& fd, std::string fname, bool owenable, - uint32_t dr, bool tenE, uint32_t size, - uint32_t nPixelsx, uint32_t nPixelsy, uint64_t nf, - uint32_t maxf, - uint64_t acquisitionTime, uint64_t subexposuretime, - uint64_t subperiod, uint64_t acquisitionPeriod, double version) - { - try { - Exception::dontPrint(); //to handle errors - - FileAccPropList flist; - flist.setFcloseDegree(H5F_CLOSE_STRONG); - fd = 0; - if(!owenable) - fd = new H5File( fname.c_str(), H5F_ACC_EXCL, - FileCreatPropList::DEFAULT, - flist ); - else - fd = new H5File( fname.c_str(), H5F_ACC_TRUNC, - FileCreatPropList::DEFAULT, - flist ); - - //variables - DataSpace dataspace = DataSpace (H5S_SCALAR); - Attribute attribute; - DataSet dataset; - int iValue=0; - double dValue=0; - StrType strdatatype(PredType::C_S1,256); - - //create attributes - //version - dValue=version; - attribute = fd->createAttribute("version",PredType::NATIVE_DOUBLE, dataspace); - attribute.write(PredType::NATIVE_DOUBLE, &dValue); - - //Create a group in the file - Group group1( fd->createGroup( "entry" ) ); - Group group2( group1.createGroup("data") ); - Group group3( group1.createGroup("instrument") ); - Group group4( group3.createGroup("beam") ); - Group group5( group3.createGroup("detector") ); - Group group6( group1.createGroup("sample") ); - - //Dynamic Range - dataset = group5.createDataSet ( "dynamic range", PredType::NATIVE_INT, dataspace ); - dataset.write ( &dr, PredType::NATIVE_INT); - attribute = dataset.createAttribute("unit",strdatatype, dataspace); - attribute.write(strdatatype, std::string("bits")); - - //Ten Giga - iValue = tenE; - dataset = group5.createDataSet ( "ten giga enable", PredType::NATIVE_INT, dataspace ); - dataset.write ( &iValue, PredType::NATIVE_INT); - - //Image Size - dataset = group5.createDataSet ( "image size", PredType::NATIVE_INT, dataspace ); - dataset.write ( &size, PredType::NATIVE_INT); - attribute = dataset.createAttribute("unit",strdatatype, dataspace); - attribute.write(strdatatype, std::string("bytes")); - - //x - dataset = group5.createDataSet ( "number of pixels in x axis", PredType::NATIVE_INT, dataspace ); - dataset.write ( &nPixelsx, PredType::NATIVE_INT); - - //y - dataset = group5.createDataSet ( "number of pixels in y axis", PredType::NATIVE_INT, dataspace ); - dataset.write ( &nPixelsy, PredType::NATIVE_INT); - - //Maximum frames per file - dataset = group5.createDataSet ( "maximum frames per file", PredType::NATIVE_INT, dataspace ); - dataset.write ( &maxf, PredType::NATIVE_INT); - - //Total Frames - dataset = group5.createDataSet ( "total frames", PredType::STD_U64LE, dataspace ); - dataset.write ( &nf, PredType::STD_U64LE); - - //Exptime - dataset = group5.createDataSet ( "exposure time", PredType::STD_U64LE, dataspace ); - dataset.write ( &acquisitionTime, PredType::STD_U64LE); - attribute = dataset.createAttribute("unit",strdatatype, dataspace); - attribute.write(strdatatype, std::string("ns")); - - //SubExptime - dataset = group5.createDataSet ( "sub exposure time", PredType::STD_U64LE, dataspace ); - dataset.write ( &subexposuretime, PredType::STD_U64LE); - attribute = dataset.createAttribute("unit",strdatatype, dataspace); - attribute.write(strdatatype, std::string("ns")); - - //SubPeriod - dataset = group5.createDataSet ( "sub period", PredType::STD_U64LE, dataspace ); - dataset.write ( &subperiod, PredType::STD_U64LE); - attribute = dataset.createAttribute("unit",strdatatype, dataspace); - attribute.write(strdatatype, std::string("ns")); - - //Period - dataset = group5.createDataSet ( "acquisition period", PredType::STD_U64LE, dataspace ); - dataset.write ( &acquisitionPeriod, PredType::STD_U64LE); - attribute = dataset.createAttribute("unit",strdatatype, dataspace); - attribute.write(strdatatype, std::string("ns")); - - //Timestamp - time_t t = time(0); - dataset = group5.createDataSet ( "timestamp", strdatatype, dataspace ); - dataset.write ( std::string(ctime(&t)), strdatatype ); - - fd->close(); - - } catch(Exception error) { - cprintf(RED,"Error in creating master HDF5 handles\n"); - error.printErrorStack(); - if (fd) fd->close(); - return 1; - } - return 0; - } - - - - /** - * Create File - * @param ind object index for debugging - * @param owenable overwrite enable - * @param fname complete file name - * @param frindexenable frame index enable - * @param fnum current image number - * @param nDimx number of pixels in x dim (#frames) - * @param nDimy number of pixels in y dim (height y dir) - * @param nDimz number of pixels in z dim (width x dir) - * @param dtype data type - * @param fd file pointer - * @param dspace dataspace pointer - * @param dset dataset pointer - * @param version version of software for hdf5 writing - * @param maxchunkedimages maximum chunked images - * @param dspace_para dataspace of parameters - * @param dset_para vector of datasets of parameters - * @param parameterNames parameter names - * @param parameterDataTypes parameter datatypes - * @returns 0 for success and 1 for fail - */ - static int CreateDataFile(int ind, bool owenable, std::string fname, bool frindexenable, - uint64_t fnum, uint64_t nDimx, uint32_t nDimy, uint32_t nDimz, - DataType dtype, H5File*& fd, DataSpace*& dspace, DataSet*& dset, - double version, uint64_t maxchunkedimages, - DataSpace*& dspace_para, std::vector& dset_para, - std::vector parameterNames, - std::vector parameterDataTypes) - { - try { - Exception::dontPrint(); //to handle errors - - //file - FileAccPropList fapl; - fapl.setFcloseDegree(H5F_CLOSE_STRONG); - fd = 0; - if(!owenable) - fd = new H5File( fname.c_str(), H5F_ACC_EXCL, - FileCreatPropList::DEFAULT, - fapl ); - else - fd = new H5File( fname.c_str(), H5F_ACC_TRUNC, - FileCreatPropList::DEFAULT, - fapl ); - - //attributes - version - double dValue=version; - DataSpace dataspace_attr = DataSpace (H5S_SCALAR); - Attribute attribute = fd->createAttribute("version",PredType::NATIVE_DOUBLE, dataspace_attr); - attribute.write(PredType::NATIVE_DOUBLE, &dValue); - - //dataspace - hsize_t srcdims[3] = {nDimx, nDimy, nDimz}; - hsize_t srcdimsmax[3] = {H5S_UNLIMITED, nDimy, nDimz}; - dspace = 0; - dspace = new DataSpace (3,srcdims,srcdimsmax); - - - //dataset name - std::ostringstream osfn; - osfn << "/data"; - if (frindexenable) osfn << "_f" << std::setfill('0') << std::setw(12) << fnum; - std::string dsetname = osfn.str(); - - //dataset - //fill value - DSetCreatPropList plist; - int fill_value = -1; - plist.setFillValue(dtype, &fill_value); - // always create chunked dataset as unlimited is only supported with chunked layout - hsize_t chunk_dims[3] ={maxchunkedimages, nDimy, nDimz}; - plist.setChunk(3, chunk_dims); - dset = 0; - dset = new DataSet (fd->createDataSet(dsetname.c_str(), dtype, *dspace, plist)); - - //create parameter datasets - hsize_t dims[1] = {nDimx}; - hsize_t dimsmax[1] = {H5S_UNLIMITED}; - dspace_para = 0; - dspace_para = new DataSpace (1,dims,dimsmax); - - // always create chunked dataset as unlimited is only supported with chunked layout - DSetCreatPropList paralist; - hsize_t chunkpara_dims[3] = {maxchunkedimages}; - paralist.setChunk(1, chunkpara_dims); - - for (unsigned int i = 0; i < parameterNames.size(); ++i){ - DataSet* ds = new DataSet(fd->createDataSet(parameterNames[i], - parameterDataTypes[i], *dspace_para, paralist)); - dset_para.push_back(ds); - } - } - catch(Exception error){ - cprintf(RED,"Error in creating HDF5 handles in object %d\n",ind); - error.printErrorStack(); - if (fd) fd->close(); - return 1; - } - return 0; - } - - - /** - * Create virtual file - * (in C because H5Pset_virtual doesnt exist yet in C++) - * @param virtualFileName virtual file name - * @param fd virtual file handle - * @param masterFileName master file name - * @param fpath file path - * @param fnameprefix file name prefix (includes scan and position variables) - * @param findex file index - * @param frindexenable frame index enable - * @param dindex readout index - * @param numunits number of units per readout. eg. eiger has 2 udp units per readout - * @param maxFramesPerFile maximum frames per file - * @param numf number of frames caught - * @param srcDataseName source dataset name - * @param dataType datatype of data dataset - * @param numDety number of readouts in Y dir - * @param numDetz number of readouts in Z dir - * @param nDimy number of objects in y dimension in source file (Number of pixels in y dir) - * @param nDimz number of objects in z dimension in source file (Number of pixels in x dir) - * @param version version of software for hdf5 writing - * @param parameterNames parameter names - * @param parameterDataTypes parameter datatypes - * @returns 0 for success and 1 for fail - */ - static int CreateVirtualDataFile( - std::string virtualFileName, - hid_t& fd, std::string masterFileName, - char* fpath, char* fnameprefix, uint64_t findex, bool frindexenable, - int dindex, int numunits, - uint32_t maxFramesPerFile, uint64_t numf, - std::string srcDataseName, DataType dataType, - int numDety, int numDetz, uint32_t nDimy, uint32_t nDimz, - double version, - std::vector parameterNames, - std::vector parameterDataTypes) - { - //file - hid_t dfal = H5Pcreate (H5P_FILE_ACCESS); - if (dfal < 0) - return CloseFileOnError(fd, - std::string("Error in creating file access property for virtual file ") - + virtualFileName + std::string("\n")); - if (H5Pset_fclose_degree (dfal, H5F_CLOSE_STRONG) < 0) - return CloseFileOnError(fd, - std::string("Error in setting strong file close degree for virtual file ") - + virtualFileName + std::string("\n")); - fd = H5Fcreate( virtualFileName.c_str(), H5F_ACC_TRUNC, H5P_DEFAULT, dfal); - if (fd < 0) - return CloseFileOnError(fd, - std::string("Error in creating virtual file ") + virtualFileName + std::string("\n")); - - //attributes - version - hid_t dataspace_attr = H5Screate (H5S_SCALAR); - if (dataspace_attr < 0) - return CloseFileOnError(fd, - std::string("Error in creating dataspace for attribute in virtual file ") - + virtualFileName + std::string("\n")); - hid_t attrid = H5Acreate2 (fd, "version", H5T_NATIVE_DOUBLE, dataspace_attr, H5P_DEFAULT, H5P_DEFAULT); - if (attrid < 0) - return CloseFileOnError(fd, - std::string("Error in creating attribute in virtual file ") - + virtualFileName + std::string("\n")); - double attr_data = version; - if (H5Awrite (attrid, H5T_NATIVE_DOUBLE, &attr_data) < 0) - return CloseFileOnError(fd, - std::string("Error in writing attribute in virtual file ") - + virtualFileName + std::string("\n")); - if (H5Aclose (attrid) < 0) - return CloseFileOnError(fd, - std::string("Error in closing attribute in virtual file ") - + virtualFileName + std::string("\n")); - - - //virtual dataspace - hsize_t vdsdims[3] = {numf, numDety * nDimy, numDetz * nDimz}; - hid_t vdsDataspace = H5Screate_simple(3, vdsdims ,NULL); - if (vdsDataspace < 0) - return CloseFileOnError(fd, - std::string("Error in creating virtual dataspace in virtual file ") - + virtualFileName + std::string("\n")); - hsize_t vdsdims_para[2] = {numf, (unsigned int) numDety * numDetz}; - hid_t vdsDataspace_para = H5Screate_simple(2, vdsdims_para, NULL); - if (vdsDataspace_para < 0) - return CloseFileOnError(fd, - std::string("Error in creating virtual dataspace (parameters) in virtual file ") - + virtualFileName + std::string("\n")); - - - //fill values - hid_t dcpl = H5Pcreate (H5P_DATASET_CREATE); - if (dcpl < 0) - return CloseFileOnError(fd, - std::string("Error in creating file creation properties in virtual file ") - + virtualFileName + std::string("\n")); - int fill_value = -1; - if (H5Pset_fill_value (dcpl, GetDataTypeinC(dataType), &fill_value) < 0) - return CloseFileOnError(fd, - std::string("Error in creating fill value in virtual file ") - + virtualFileName + std::string("\n")); - hid_t dcpl_para[parameterNames.size()]; - for (unsigned int i = 0; i < parameterNames.size(); ++i) { - dcpl_para[i] = H5Pcreate (H5P_DATASET_CREATE); - if (dcpl_para[i] < 0) - return CloseFileOnError(fd, - std::string("Error in creating file creation properties (parameters) in virtual file ") - + virtualFileName + std::string("\n")); - if (H5Pset_fill_value (dcpl_para[i], GetDataTypeinC(parameterDataTypes[i]), &fill_value) < 0) - return CloseFileOnError(fd, - std::string("Error in creating fill value (parameters) in virtual file ") - + virtualFileName + std::string("\n")); - } - - //hyperslab - int numMajorHyperslab = numf/maxFramesPerFile; - if (numf%maxFramesPerFile) numMajorHyperslab++; - bool error = false; - uint64_t framesSaved = 0; - for (int j = 0; j < numMajorHyperslab; j++) { - - uint64_t nDimx = ((numf - framesSaved) > maxFramesPerFile) - ? maxFramesPerFile : (numf-framesSaved); - hsize_t offset[3] = {framesSaved, 0, 0}; - hsize_t count[3] = {nDimx, nDimy, nDimz}; - hsize_t offset_para[2] = {framesSaved, 0}; - hsize_t count_para[2] = {nDimx, 1}; - - for (int i = 0; i < numDety * numDetz; ++i) { - - //setect hyperslabs - if (H5Sselect_hyperslab (vdsDataspace, H5S_SELECT_SET, offset, NULL, count, NULL) < 0) { - cprintf(RED,"could not select hyperslab\n"); - error = true; - break; - } - if (H5Sselect_hyperslab (vdsDataspace_para, H5S_SELECT_SET, - offset_para, NULL, count_para, NULL) < 0) { - cprintf(RED,"could not select hyperslab for parameters\n"); - error = true; - break; - } - - //source file name - std::string srcFileName = HDF5FileStatic::CreateFileName(fpath, fnameprefix, findex, - frindexenable, framesSaved, dindex, numunits, i); - - // find relative path - std::string relative_srcFileName = srcFileName; - { - size_t i = srcFileName.rfind('/', srcFileName.length()); - if (i != std::string::npos) - relative_srcFileName = (srcFileName.substr(i+1, srcFileName.length() - i)); - } - - //source dataset name - std::ostringstream osfn; - osfn << "/data"; - if (frindexenable) osfn << "_f" << std::setfill('0') << std::setw(12) << framesSaved; - std::string srcDatasetName = osfn.str(); - - //source dataspace - hsize_t srcdims[3] = {nDimx, nDimy, nDimz}; - hsize_t srcdimsmax[3] = {H5S_UNLIMITED, nDimy, nDimz}; - hid_t srcDataspace = H5Screate_simple(3, srcdims, srcdimsmax); - if (srcDataspace < 0) - return CloseFileOnError(fd, - std::string("Error in creating source dataspace in virtual file ") - + virtualFileName + std::string("\n")); - hsize_t srcdims_para[1] = {nDimx}; - hsize_t srcdimsmax_para[1] = {H5S_UNLIMITED}; - hid_t srcDataspace_para = H5Screate_simple(1, srcdims_para, srcdimsmax_para); - if (srcDataspace_para < 0) - return CloseFileOnError(fd, - std::string("Error in creating source dataspace (parameters) in virtual file ") - + virtualFileName + std::string("\n")); - - //mapping - if (H5Pset_virtual(dcpl, vdsDataspace, relative_srcFileName.c_str(), - srcDatasetName.c_str(), srcDataspace) < 0) { - cprintf(RED,"could not set mapping for paramter 1\n"); - error = true; - break; - } - - for (unsigned int k = 0; k < parameterNames.size(); ++k) { - if (H5Pset_virtual(dcpl_para[k], vdsDataspace_para, relative_srcFileName.c_str(), - parameterNames[k], srcDataspace_para) < 0) { - cprintf(RED,"could not set mapping for paramter %d\n", k); - error = true; - break; - } - } - - //H5Sclose(srcDataspace); - //H5Sclose(srcDataspace_para); - offset[2] += nDimz; - if (offset[2] >= (numDetz * nDimz)) { - offset[2] = 0; - offset[1] += nDimy; - } - offset_para[1]++; - } - framesSaved += nDimx; - } - if (error) - return CloseFileOnError(fd, - std::string("Error in mapping files in virtual file ") - + virtualFileName + std::string("\n")); - - //dataset - std::string virtualDatasetName = srcDataseName; - hid_t vdsdataset = H5Dcreate2 (fd, virtualDatasetName.c_str(), - GetDataTypeinC(dataType), vdsDataspace, H5P_DEFAULT, dcpl, H5P_DEFAULT); - if (vdsdataset < 0) - return CloseFileOnError(fd, - std::string("Error in creating virutal dataset in virtual file ") - + virtualFileName + std::string("\n")); - - - //virtual parameter dataset - for (unsigned int i = 0; i < parameterNames.size(); ++i) { - hid_t vdsdataset_para = H5Dcreate2 (fd, - parameterNames[i], - GetDataTypeinC(parameterDataTypes[i]), vdsDataspace_para, - H5P_DEFAULT, dcpl_para[i], H5P_DEFAULT); - if (vdsdataset_para < 0) - return CloseFileOnError(fd, - std::string("Error in creating virutal dataset (parameters) in virtual file ") - + virtualFileName + std::string("\n")); - } - - //close - H5Fclose(fd); fd = 0; - - //link - return LinkVirtualInMaster(masterFileName, virtualFileName, virtualDatasetName, parameterNames); - } - - - - /** - * Copy file to another file (mainly to view virutal files in hdfviewer) - * @param dataType data type - * @param owenable overwrite enable - * @param oldFileName file name including path of file to copy - * @param oldDatasetName dataset name to copy - * @param newFileName file name including path of file to copy to - * @param newDatasetName dataset name to copy to - * @param rank rank - * @param nDimx Number of objects in x dimension - * @param nDimy Number of objects in y dimension - * @param nDimz Number of objects in z dimension - * @returns 0 for success and 1 for fail - */ - template - static int CopyVirtualFile(T datatype, bool owenable, std::string oldFileName, std::string oldDatasetName, - std::string newFileName, std::string newDatasetName, int rank, - uint64_t nDimx, uint32_t nDimy, uint32_t nDimz=0) - { - T *data_out; - switch (rank) { - case 2: - data_out = (T*)malloc(sizeof(T)*(nDimx*nDimy)); - break; - case 3: - data_out = (T*)malloc(sizeof(T)*(nDimx*nDimy*nDimz)); - break; - default: - cprintf(RED,"invalid rank. Options: 2 or 3\n"); - return 0; - } - if (datatype == PredType::STD_U16LE) { - FILE_LOG(logINFO) << "datatype:16"; - } else if (datatype == PredType::STD_U32LE) { - FILE_LOG(logINFO) << "datatype:32"; - } else if (datatype == PredType::STD_U64LE) { - FILE_LOG(logINFO) << "datatype:64"; - } else if (datatype == PredType::STD_U8LE) { - FILE_LOG(logINFO) << "datatype:8"; - } else { - FILE_LOG(logERROR) << "unknown datatype"; - return 1; - } - FILE_LOG(logINFO) << "owenable:" << (owenable?1:0) << std::endl - << "oldFileName:" << oldFileName << std::endl - << "oldDatasetName:" << oldDatasetName << std::endl - << "newFileName:" << newFileName << std::endl - << "newDatasetName:" << newDatasetName << std::endl - << "rank:" << rank << std::endl - << "nDimx:" << nDimx << std::endl - << "nDimy:" << nDimy << std::endl - << "nDimz:" << nDimz; - - H5File* oldfd; - H5File* newfd; - try { - Exception::dontPrint(); //to handle errors - - //open old file - oldfd = new H5File( oldFileName.c_str(), H5F_ACC_RDONLY); - DataSet oldDataset = oldfd->openDataSet( oldDatasetName.c_str()); - //read dataset - oldDataset.read( data_out, datatype); - //new file - FileAccPropList fapl; - fapl.setFcloseDegree(H5F_CLOSE_STRONG); - newfd = 0; - if(!owenable) - newfd = new H5File( newFileName.c_str(), H5F_ACC_EXCL, - FileCreatPropList::DEFAULT, - fapl ); - else - newfd = new H5File( newFileName.c_str(), H5F_ACC_TRUNC, - FileCreatPropList::DEFAULT, - fapl ); - //dataspace and dataset - DataSpace* newDataspace = 0; - if (rank == 3) { - hsize_t dims[3] = {nDimx, nDimy, nDimz}; - newDataspace = new DataSpace (3,dims); - } else if (rank == 2) { - hsize_t dims[2] = {nDimx, nDimy}; - newDataspace = new DataSpace (2,dims); - } - DataSet* newDataset = 0; - newDataset = new DataSet( newfd->createDataSet(newDatasetName.c_str(), datatype, *newDataspace)); - //write and close - newDataset->write(data_out,datatype); - newfd->close(); - oldfd->close(); - } catch(Exception error){ - cprintf(RED,"Error in copying virtual files\n"); - error.printErrorStack(); - free(data_out); - oldfd->close(); - newfd->close(); - return 1; - } - free(data_out); - return 0; - } - - - - /** - * Link the Virtual File in the Master File - * In C because H5Lcreate_external exists only in C - * @param masterFileName master file name - * @param virtualfname virtual file name - * @param virtualDatasetname virtual dataset name - * @param parameterNames parameter names - * @returns 0 for success and 1 for fail - */ - static int LinkVirtualInMaster(std::string masterFileName, std::string virtualfname, - std::string virtualDatasetname, std::vector parameterNames) { - char linkname[100]; - hid_t vfd = 0; - - hid_t dfal = H5Pcreate (H5P_FILE_ACCESS); - if (dfal < 0) - return CloseFileOnError( vfd, std::string("Error in creating file access property for link\n")); - if (H5Pset_fclose_degree (dfal, H5F_CLOSE_STRONG) < 0) - return CloseFileOnError( vfd, std::string("Error in setting strong file close degree for link\n")); - - //open master file - hid_t mfd = H5Fopen( masterFileName.c_str(), H5F_ACC_RDWR, dfal); - if (mfd < 0) - return CloseFileOnError( vfd, std::string("Error in opening master file\n")); - - //open virtual file - vfd = H5Fopen( virtualfname.c_str(), H5F_ACC_RDWR, dfal); - if (vfd < 0) { - H5Fclose(mfd); mfd = 0; - return CloseFileOnError( vfd, std::string("Error in opening virtual file\n")); - } - - // find relative path - std::string relative_virtualfname = virtualfname; - { - size_t i = virtualfname.rfind('/', virtualfname.length()); - if (i != std::string::npos) - relative_virtualfname = (virtualfname.substr(i+1, virtualfname.length() - i)); - } - - //**data dataset** - hid_t vdset = H5Dopen2( vfd, virtualDatasetname.c_str(), H5P_DEFAULT); - if (vdset < 0) { - H5Fclose(mfd); - return CloseFileOnError( vfd, std::string("Error in opening virtual data dataset\n")); - } - sprintf(linkname, "/entry/data/%s",virtualDatasetname.c_str()); - if(H5Lcreate_external( relative_virtualfname.c_str(), virtualDatasetname.c_str(), - mfd, linkname, H5P_DEFAULT, H5P_DEFAULT) < 0) { - H5Fclose(mfd); mfd = 0; - return CloseFileOnError( vfd, std::string("Error in creating link to data dataset\n")); - } - H5Dclose(vdset); - - //**paramter datasets** - for (unsigned int i = 0; i < parameterNames.size(); ++i){ - hid_t vdset_para = H5Dopen2( vfd, (std::string (parameterNames[i])).c_str(), H5P_DEFAULT); - if (vdset_para < 0) { - H5Fclose(mfd); mfd = 0; - return CloseFileOnError( vfd, std::string("Error in opening virtual parameter dataset to create link\n")); - } - sprintf(linkname, "/entry/data/%s",(std::string (parameterNames[i])).c_str()); - - if(H5Lcreate_external( relative_virtualfname.c_str(), (std::string (parameterNames[i])).c_str(), - mfd, linkname, H5P_DEFAULT, H5P_DEFAULT) < 0) { - H5Fclose(mfd); mfd = 0; - return CloseFileOnError( vfd, std::string("Error in creating link to virtual parameter dataset\n")); - } - } - - H5Fclose(mfd); mfd = 0; - H5Fclose(vfd); vfd = 0; - return 0; - } - - - - /** - * Print Error msg and Close File and called on error - * @returns 1 for fail - */ - static int CloseFileOnError(hid_t& fd, const std::string msg) { - cprintf(RED, "%s", msg.c_str()); - if(fd > 0) - H5Fclose(fd); - fd = 0; - return 1; - } - - - /** - * Get Data type in C - * @param dtype datatype in C++ - * @returns datatype in C - */ - static hid_t GetDataTypeinC(DataType dtype) { - if (dtype == PredType::STD_U8LE) - return H5T_STD_U8LE; - else if (dtype == PredType::STD_U16LE) - return H5T_STD_U16LE; - else if (dtype == PredType::STD_U32LE) - return H5T_STD_U32LE; - else if (dtype == PredType::STD_U64LE) - return H5T_STD_U64LE; - else { - hid_t s = H5Tcopy(H5T_C_S1); - H5Tset_size(s, MAX_NUM_PACKETS); - return s; - } - } - -}; - - - -#endif diff --git a/slsReceiverSoftware/include/Listener.h b/slsReceiverSoftware/include/Listener.h deleted file mode 100644 index 366b4cdc1..000000000 --- a/slsReceiverSoftware/include/Listener.h +++ /dev/null @@ -1,321 +0,0 @@ -#pragma once -/************************************************ - * @file Listener.h - * @short creates the listener thread that - * listens to udp sockets, writes data to memory - * & puts pointers to their memory addresses into fifos - ***********************************************/ -/** - *@short creates & manages a listener thread each - */ - -#include "ThreadObject.h" - -class GeneralData; -class Fifo; -class genericSocket; - -class Listener : private virtual slsReceiverDefs, public ThreadObject { - - public: - /** - * Constructor - * Calls Base Class CreateThread(), sets ErrorMask if error and increments NumberofListerners - * @param ind self index - * @param dtype detector type - * @param f address of Fifo pointer - * @param s pointer to receiver status - * @param portno pointer to udp port number - * @param e ethernet interface - * @param nf pointer to number of images to catch - * @param dr pointer to dynamic range - * @param us pointer to udp socket buffer size - * @param as pointer to actual udp socket buffer size - * @param fpf pointer to frames per file - * @param fdp frame discard policy - * @param act pointer to activated - * @param depaden pointer to deactivated padding enable - * @param sm pointer to silent mode - */ - Listener(int ind, detectorType dtype, Fifo*& f, runStatus* s, - uint32_t* portno, char* e, uint64_t* nf, uint32_t* dr, - uint32_t* us, uint32_t* as, uint32_t* fpf, - frameDiscardPolicy* fdp, bool* act, bool* depaden, bool* sm); - - /** - * Destructor - * Calls Base Class DestroyThread() and decrements NumberofListerners - */ - ~Listener(); - - - //*** getters *** - /** - * Returns if the thread is currently running - * @returns true if thread is running, else false - */ - bool IsRunning(); - - /** - * Get acquisition started flag - * @return acquisition started flag - */ - bool GetAcquisitionStartedFlag(); - - /** - * Get measurement started flag - * @return measurement started flag - */ - bool GetMeasurementStartedFlag(); - - /** - * Get Packets caught in a real time acquisition (start and stop of receiver) - * @return Packets caught in a real time acquisition - */ - uint64_t GetPacketsCaught(); - - /** - * Get Last Frame index caught - * @return last frame index caught - */ - uint64_t GetLastFrameIndexCaught(); - - - //*** setters *** - /** - * Set bit in RunningMask to allow thread to run - */ - void StartRunning(); - - /** - * Reset bit in RunningMask to prevent thread from running - */ - void StopRunning(); - - /** - * Set Fifo pointer to the one given - * @param f address of Fifo pointer - */ - void SetFifo(Fifo*& f); - - /** - * Reset parameters for new acquisition (including all scans) - */ - void ResetParametersforNewAcquisition(); - - /** - * Reset parameters for new measurement (eg. for each scan) - */ - void ResetParametersforNewMeasurement(); - - /** - * Set GeneralData pointer to the one given - * @param g address of GeneralData (Detector Data) pointer - */ - void SetGeneralData(GeneralData*& g); - - /** - * Set thread priority - * @priority priority - * @returns OK or FAIL - */ - int SetThreadPriority(int priority); - - /** - * Creates UDP Sockets - * @return OK or FAIL - */ - int CreateUDPSockets(); - - /** - * Shuts down and deletes UDP Sockets - */ - void ShutDownUDPSocket(); - - /** - * Create & closes a dummy UDP socket - * to set & get actual buffer size - * @param s UDP socket buffer size to be set - * @return OK or FAIL of dummy socket creation - */ - int CreateDummySocketForUDPSocketBufferSize(uint32_t s); - - /** - * Set hard coded (calculated but not from detector) row and column - * r is in row index if detector has not send them yet in firmware, - * c is in col index for jungfrau and eiger (for missing packets/deactivated eiger) - * c when used is in 2d - */ - void SetHardCodedPosition(uint16_t r, uint16_t c); - - - - private: - - /** - * Get Type - * @return type - */ - std::string GetType(); - - /** - * Record First Indices (firstAcquisitionIndex, firstMeasurementIndex) - * @param fnum frame index to record - */ - void RecordFirstIndices(uint64_t fnum); - - /** - * Thread Exeution for Listener Class - * Pop free addresses, listen to udp socket, - * write to memory & push the address into fifo - */ - void ThreadExecution(); - - /** - * Pushes non empty buffers into fifo/ frees empty buffer, - * pushes dummy buffer into fifo - * and reset running mask by calling StopRunning() - * @param buf address of buffer - */ - void StopListening(char* buf); - - /** - * Listen to the UDP Socket for an image, - * place them in the right order - * @param buffer - * @returns number of bytes of relevant data, can be image size or 0 (stop acquisition) - * or -1 to discard image - */ - uint32_t ListenToAnImage(char* buf); - - /** - * Print Fifo Statistics - */ - void PrintFifoStatistics(); - - - - /** type of thread */ - static const std::string TypeName; - - /** Object running status */ - bool runningFlag; - - /** GeneralData (Detector Data) object */ - GeneralData* generalData; - - /** Fifo structure */ - Fifo* fifo; - - - // individual members - /** Detector Type */ - detectorType myDetectorType; - - /** Receiver Status */ - runStatus* status; - - /** UDP Socket - Detector to Receiver */ - genericSocket* udpSocket; - - /** UDP Port Number */ - uint32_t* udpPortNumber; - - /** ethernet interface */ - char* eth; - - /** Number of Images to catch */ - uint64_t* numImages; - - /** Dynamic Range */ - uint32_t* dynamicRange; - - /** UDP Socket Buffer Size */ - uint32_t* udpSocketBufferSize; - - /** actual UDP Socket Buffer Size (double due to kernel bookkeeping) */ - uint32_t* actualUDPSocketBufferSize; - - /** frames per file */ - uint32_t* framesPerFile; - - /** frame discard policy */ - frameDiscardPolicy* frameDiscardMode; - - /** Activated/Deactivated */ - bool* activated; - - /** Deactivated padding enable */ - bool* deactivatedPaddingEnable; - - /** Silent Mode */ - bool* silentMode; - - /** row hardcoded as 1D or 2d, - * if detector does not send them yet or - * missing packets/deactivated (eiger/jungfrau sends 2d pos) **/ - uint16_t row; - - /** column hardcoded as 2D, - * deactivated eiger/missing packets (eiger/jungfrau sends 2d pos) **/ - uint16_t column; - - - // acquisition start - /** Aquisition Started flag */ - bool acquisitionStartedFlag; - - /** Measurement Started flag */ - bool measurementStartedFlag; - - /** Frame Number of First Frame of an entire Acquisition (including all scans) */ - uint64_t firstAcquisitionIndex; - - /** Frame Number of First Frame for each real time acquisition (eg. for each scan) */ - uint64_t firstMeasurementIndex; - - - // for acquisition summary - /** Number of complete Packets caught for each real time acquisition (eg. for each scan (start& stop of receiver)) */ - volatile uint64_t numPacketsCaught; - - /** Last Frame Index caught from udp network */ - uint64_t lastCaughtFrameIndex; - - - // parameters to acquire image - /** Current Frame Index, default value is 0 - * ( always check acquisitionStartedFlag for validity first) - */ - uint64_t currentFrameIndex; - - /** True if there is a packet carry over from previous Image */ - bool carryOverFlag; - - /** Carry over packet buffer */ - char* carryOverPacket; - - /** Listening buffer for one packet - might be removed when we can peek and eiger fnum is in header */ - char* listeningPacket; - - /** if the udp socket is connected */ - bool udpSocketAlive; - - /** Semaphore to synchonize deleting udp socket */ - sem_t semaphore_socket; - - - // for print progress during acqusition - /** number of packets for statistic */ - uint32_t numPacketsStatistic; - - /** number of images for statistic */ - uint32_t numFramesStatistic; - - /** - * starting packet number is odd or evern, accordingly increment frame number - * to get first packet number as 0 - * (pecific to gotthard, can vary between modules, hence defined here) */ - bool oddStartingPacket; -}; - diff --git a/slsReceiverSoftware/include/MySocketTCP.h b/slsReceiverSoftware/include/MySocketTCP.h deleted file mode 100644 index a3f6ea285..000000000 --- a/slsReceiverSoftware/include/MySocketTCP.h +++ /dev/null @@ -1,67 +0,0 @@ -#pragma once -/** - * - * @libdoc The MySocketTCP class provides a simple interface for creating and sending/receiving data over a TCP socket. - * - * @short This class provides a simple interface for creating and sending/receiving data over a TCP socket. - * @author Ian Johnson - * @version 1.0 - */ -//version 1.0, base development, Ian 19/01/09 -/* Modified by anna on 19.01.2009 */ -/* - canceled SetupParameters() and varaibles intialized in the constructors' headers; - defined SEND_REC_MAX_SIZE (for compatibilty with mythen (and possibly other) pure C servers (i would move it to the common header file) - - added #ifndef C_ONLY... to cutout class definition when including in pure C servers (can be removed if SEND_REC_MAX_SIZE is moved to the common header file) - - defined private variables char hostname[1000] and int portno to store connection informations; - - defined public functions int getHostname(char *name) and int getPortNumber() to retrieve connection informations - - added public function int getErrorStatus() returning 1 if socketDescriptor<0 - - remove exits in the constructors and replace them with socketDescriptor=-1 - - replaced the argument of send/receive data with void (to avoid too much casting or compiler errors/warnings) - - added a function which really does not close the socket between send/receive (senddataonly, receivedataonly) - -*/ -/* Modified by Anna on 31.10.2012 - -developed and - -*/ - - -#include "genericSocket.h" -#define TCP_PACKET_SIZE 4096 - -class MySocketTCP: public genericSocket { - - public: - MySocketTCP(const char* const host_ip_or_name, unsigned short int const port_number): genericSocket(host_ip_or_name, port_number,TCP), last_keep_connection_open_action_was_a_send(0){setPacketSize(TCP_PACKET_SIZE);}; // sender (client): where to? ip - MySocketTCP(unsigned short int const port_number):genericSocket(port_number,TCP), last_keep_connection_open_action_was_a_send(0) {setPacketSize(TCP_PACKET_SIZE);}; // receiver (server) local no need for ip - virtual ~MySocketTCP(){}; - - //The following two functions will connectioned->send/receive->disconnect - int SendData(void* buf,int length);//length in characters - int ReceiveData(void* buf,int length); - - - //The following two functions stay connected, blocking other connections, and must be manually disconnected, - // when the last call is a SendData() or ReceiveData() the disconnection will be done automatically - //These function will also automatically disconnect->reconnect if - // two reads (or two writes) are called in a row to preserve the data send/receive structure - int SendDataAndKeepConnection(void* buf,int length); - int ReceiveDataAndKeepConnection(void* buf,int length); - - private: - - - bool last_keep_connection_open_action_was_a_send; - - -}; - diff --git a/slsReceiverSoftware/include/ThreadObject.h b/slsReceiverSoftware/include/ThreadObject.h deleted file mode 100644 index 5b5639cea..000000000 --- a/slsReceiverSoftware/include/ThreadObject.h +++ /dev/null @@ -1,109 +0,0 @@ -#pragma once -/************************************************ - * @file ThreadObject.h - * @short creates/destroys a thread - ***********************************************/ -/** - *@short creates/destroys a thread - */ - -#include "sls_receiver_defs.h" -#include "logger.h" - -#include -#include -#include - -class ThreadObject : private virtual slsReceiverDefs { - - public: - /** - * Constructor - * @param ind self index - */ - ThreadObject(int ind); - - /** - * Destructor - * if alive, destroys thread - */ - virtual ~ThreadObject(); - - /** - * Print all member values - */ - void PrintMembers(); - - - /** - * Get Type - * @return type - */ - virtual std::string GetType() = 0; - - /** - * Returns if the thread is currently running - * @returns true if thread is running, else false - */ - virtual bool IsRunning() = 0; - - /** - * What is really being executed in the thread - */ - virtual void ThreadExecution() = 0; - - /** - * Post semaphore so thread can continue & start an acquisition - */ - void Continue(); - - protected: - - /** - * Destroy thread, semaphore and resets alive and killThread - */ - void DestroyThread(); - - /** - * Create Thread, sets semaphore, alive and killThread - * @return OK if successful, else FAIL - */ - int CreateThread(); - - - private: - - /** - * Static function using pointer from argument to call RunningThread() - * @param thisPointer pointer to an object of ThreadObject - */ - static void* StartThread(void *thisPointer); - - /** - * Actual Thread called: An infinite while loop in which, - * semaphore starts executing its contents as long RunningMask is satisfied - * Then it exits the thread on its own if killThread is true - */ - void RunningThread(); - - - protected: - /** Self Index */ - int index; - - /** Thread is alive/dead */ - volatile bool alive; - - /** Variable monitored by thread to kills itself */ - volatile bool killThread; - - /** Thread variable */ - pthread_t thread; - - /** Semaphore to synchonize starting of each run */ - sem_t semaphore; - - - -}; - diff --git a/slsReceiverSoftware/include/UDPBaseImplementation.h b/slsReceiverSoftware/include/UDPBaseImplementation.h deleted file mode 100644 index cafcd33bb..000000000 --- a/slsReceiverSoftware/include/UDPBaseImplementation.h +++ /dev/null @@ -1,859 +0,0 @@ -#pragma once -/********************************************//** - * @file UDPBaseImplementation.h - * @short does all the functions for a receiver, set/get parameters, start/stop etc. - ***********************************************/ - -//#include "sls_receiver_defs.h" -#include "UDPInterface.h" -//#include - -/** - * @short does all the base functions for a receiver, set/get parameters, start/stop etc. - */ - -class UDPBaseImplementation : protected virtual slsReceiverDefs, public UDPInterface { - - public: - - /************************************************************************* - * Constructor & Destructor ********************************************** - * They access local cache of configuration or detector parameters ******* - *************************************************************************/ - /** - * Constructor - */ - UDPBaseImplementation(); - - /** - * Destructor - */ - virtual ~UDPBaseImplementation(); - - /* - * Initialize class members - */ - void initializeMembers(); - - /************************************************************************* - * Getters *************************************************************** - * They access local cache of configuration or detector parameters ******* - *************************************************************************/ - - //**initial parameters*** - /* - * Get multi detector size - * @return pointer to array of multi detector size in every dimension - */ - int* getMultiDetectorSize() const; - - - /* - * Get detector position id - * @return detector position id - */ - int getDetectorPositionId() const; - - /* - * Get detector hostname - * @return NULL or hostname or NULL if uninitialized (max of 1000 characters) - */ - char *getDetectorHostname() const; - - /* - * Get flipped data across 'axis' - * @return if data is flipped across 'axis' - */ - int getFlippedData(int axis=0) const; - - /** - * Get Gap Pixels Enable (eiger specific) - * @return true if gap pixels enabled, else false - */ - bool getGapPixelsEnable() const; - - - //***file parameters*** - /** - * Get File Format - * @return file format - */ - fileFormat getFileFormat() const; - /** - * Get File Name Prefix (without frame index, file index and extension (_d0_f000000000000_8.raw)) - * @return NULL or file name prefix (max of 1000 characters) - */ - char *getFileName() const; - - /** - * Get File Path - * @return NULL or file path (max of 1000 characters) - */ - char *getFilePath() const; - - /** - * Get File Index - * @return file index of acquisition - */ - uint64_t getFileIndex() const; - - /** - * Get Frames per File (0 means infinite) - * @return Frames per File - */ - uint32_t getFramesPerFile() const; - - /** - * Get Frame Discard Policy - * @return Frame Discard Policy - */ - frameDiscardPolicy getFrameDiscardPolicy() const; - - /** - * Get Partial Frame Padding Enable - * @return Partial Frame Padding Enable - */ - bool getFramePaddingEnable() const; - - /** - * Get Scan Tag - * @return scan tag //FIXME: needed? (unsigned integer?) - */ - int getScanTag() const; - - /** - * Get File Write Enable - * @return true if file write enabled, else false - */ - bool getFileWriteEnable() const; - - /** - * Get File Over Write Enable - * @return true if file over write enabled, else false - */ - bool getOverwriteEnable() const; - - /** - * Get data compression, by saving only hits (so far implemented only for Moench and Gotthard) - * @return true if data compression enabled, else false - */ - bool getDataCompressionEnable() const; - - - //***acquisition count parameters*** - /** - * Get Total Frames Caught for an entire acquisition (including all scans) - * @return total number of frames caught for entire acquisition - */ - uint64_t getTotalFramesCaught() const; - - /** - * Get Frames Caught for each real time acquisition (eg. for each scan) - * @return number of frames caught for each scan - */ - uint64_t getFramesCaught() const; - - /** - * Get Current Frame Index for an entire acquisition (including all scans) - * @return -1 if no frames have been caught, else current frame index (represents all scans too) - */ - int64_t getAcquisitionIndex() const; - - - //***connection parameters*** - /** - * Get UDP Port Number - * @return udp port number - */ - uint32_t getUDPPortNumber() const; - - /** - * Get Second UDP Port Number (eiger specific) - * @return second udp port number - */ - uint32_t getUDPPortNumber2() const; - - /** - * Get Ehernet Interface - * @ethernet interface. eg. eth0 or "" if listening to all (max of 1000 characters) - */ - char *getEthernetInterface() const; - - - //***acquisition parameters*** - /** - * Get ROI - * @return index of adc enabled, else -1 if all enabled - */ - std::vector getROI() const; - - /** - * Get the Frequency of Frames Sent to GUI - * @return 0 for random frame requests, n for nth frame frequency - */ - uint32_t getFrameToGuiFrequency() const; - - /** - * Gets the timer between frames streamed when frequency is set to 0 - * @return timer between frames streamed - */ - uint32_t getFrameToGuiTimer() const; - - /** - * Get the data stream enable - * @return data stream enable - */ - bool getDataStreamEnable() const; - - - /** - * Get Acquisition Period - * @return acquisition period - */ - uint64_t getAcquisitionPeriod() const; - - /** - * Get Acquisition Time - * @return acquisition time - */ - uint64_t getAcquisitionTime() const; - - /** - * Get Sub Exposure Time - * @return Sub Exposure Time - */ - uint64_t getSubExpTime() const; - - /** - * Get Sub Period - * @return Sub Period - */ - uint64_t getSubPeriod() const; - - /* - * Get Number of Frames expected by receiver from detector - * The data receiver status will change from running to idle when it gets this number of frames FIXME: (Not implemented) - * @return number of frames expected - */ - uint64_t getNumberOfFrames() const; - - /* - * Get Number of Samples expected by receiver from detector (for chip test board only) - * @return number of samples expected - */ - uint64_t getNumberofSamples() const; - - /** - * Get Dynamic Range or Number of Bits Per Pixel - * @return dynamic range that is 4, 8, 16 or 32 - */ - uint32_t getDynamicRange() const; - - /** - * Get Ten Giga Enable - * @return true if 10Giga enabled, else false (1G enabled) - */ - bool getTenGigaEnable() const; - - /** - * Get Fifo Depth - * @return fifo depth - */ - uint32_t getFifoDepth() const; - - - //***receiver status*** - /** - * Get Listening Status of Receiver - * @return can be idle, listening or error depending on if the receiver is listening or not - */ - runStatus getStatus() const; - - /** - * Get Silent Mode - * @return silent mode - */ - bool getSilentMode() const; - - /** - * Get activate - * If deactivated, receiver will create dummy data if deactivated padding is enabled - * (as it will receive nothing from detector) - * @return false for deactivated, true for activated - */ - bool getActivate() const; - - /** - * Get deactivated padding enable - * If enabled, receiver will create dummy packets (0xFF), else it will create nothing - * (as it will receive nothing from detector) - * @return 0 for disabled, 1 for enabled - */ - bool getDeactivatedPadding() const; - - /** - * Get Streaming Port - * @return streaming port - */ - uint32_t getStreamingPort() const; - - /** - * Get streaming source ip - * @return streaming source ip - */ - char *getStreamingSourceIP() const; - - /** - * Get additional json header - * @return additional json header - */ - char *getAdditionalJsonHeader() const; - - /** (not saved in client shared memory) - * Get UDP Socket Buffer Size - * @return UDP Socket Buffer Size - */ - uint32_t getUDPSocketBufferSize() const; - - - /** (not saved in client shared memory) - * Get actual UDP Socket Buffer Size - * @return actual UDP Socket Buffer Size - */ - uint32_t getActualUDPSocketBufferSize() const; - - /************************************************************************* - * Setters *************************************************************** - * They modify the local cache of configuration or detector parameters *** - *************************************************************************/ - - //**initial parameters*** - /** - * Configure command line parameters - * @param config_map mapping of config parameters passed from command line arguments - */ - void configure(std::map config_map); - - /* - * Set multi detector size - * @param pointer to array of multi detector size in every dimension - */ - void setMultiDetectorSize(const int* size); - - /* - * Get flipped data across 'axis' - * @return if data is flipped across 'axis' - */ - void setFlippedData(int axis=0, int enable=-1); - - /** - * Set Gap Pixels Enable (eiger specific) - * @param b true for gap pixels enable, else false - * @return OK or FAIL - */ - int setGapPixelsEnable(const bool b); - - - //***file parameters*** - /** - * Set File Format - * @param f fileformat binary or hdf5 - */ - void setFileFormat(slsReceiverDefs::fileFormat f); - - /** - * Set File Name Prefix (without frame index, file index and extension (_d0_f000000000000_8.raw)) - * Does not check for file existence since it is created only at startReceiver - * @param c file name (max of 1000 characters) - */ - void setFileName(const char c[]); - - /** - * Set File Path - * Checks for file directory existence before setting file path, - * If it exists, it sets it - * @param c file path (max of 1000 characters) - */ - void setFilePath(const char c[]); - - /** - * Set File Index of acquisition - * @param i file index of acquisition - */ - void setFileIndex(const uint64_t i); - - /** - * Set Frames per File (0 means infinite) - * @param i Frames per File - */ - void setFramesPerFile(const uint32_t i); - - /** - * Set Frame Discard Policy - * @param i Frame Discard Policy - */ - void setFrameDiscardPolicy(const frameDiscardPolicy i); - - /** - * Set Partial Frame Padding Enable - * @param i Partial Frame Padding Enable - */ - void setFramePaddingEnable(const bool i); - - /** - * Set Scan Tag - * @param i scan tag //FIXME: needed? (unsigned integer?) - */ - void setScanTag(const int i); - - /** - * Set File Write Enable - * @param b true for file write enable, else false - */ - void setFileWriteEnable(const bool b); - - /** - * Set File Overwrite Enable - * @param b true for file overwrite enable, else false - */ - void setOverwriteEnable(const bool b); - - /** - * Set data compression, by saving only hits (so far implemented only for Moench and Gotthard) - * @param b true for data compression enable, else false - * @return OK or FAIL - */ - int setDataCompressionEnable(const bool b); - - - //***connection parameters*** - /** - * Set UDP Port Number - * @param i udp port number - */ - void setUDPPortNumber(const uint32_t i); - - /** - * Set Second UDP Port Number (eiger specific) - * @return second udp port number - */ - void setUDPPortNumber2(const uint32_t i); - - /** - * Set Ethernet Interface to listen to - * @param c ethernet inerface eg. eth0 (max of 1000 characters) - */ - void setEthernetInterface(const char* c); - - - //***acquisition parameters*** - /** - * Set ROI - * @param i ROI - * @return OK or FAIL - */ - int setROI(const std::vector i); - - /** - * Set the Frequency of Frames Sent to GUI - * @param freq 0 for random frame requests, n for nth frame frequency - * @return OK or FAIL - */ - int setFrameToGuiFrequency(const uint32_t freq); - - /** - * Sets the timer between frames streamed when frequency is set to 0 - * @param time_in_ms timer between frames streamed - */ - void setFrameToGuiTimer(const uint32_t time_in_ms); - - /** - * Set the data stream enable - * @param enable data stream enable - * @return OK or FAIL - */ - int setDataStreamEnable(const bool enable); - - /** - * Set Acquisition Period - * @param i acquisition period - * @return OK or FAIL - */ - int setAcquisitionPeriod(const uint64_t i); - - /** - * Set Acquisition Time - * @param i acquisition time - * @return OK or FAIL - */ - int setAcquisitionTime(const uint64_t i); - - /** - * Set Sub Exposure Time - * @param i Sub Exposure Time - * @return OK or FAIL - */ - void setSubExpTime(const uint64_t i); - - /** - * Set Sub Period - * @param i Period - * @return OK or FAIL - */ - void setSubPeriod(const uint64_t i); - - /** - * Set Number of Frames expected by receiver from detector - * The data receiver status will change from running to idle when it gets this number of frames - * @param i number of frames expected - */ - int setNumberOfFrames(const uint64_t i); - - /** - * Set Number of Samples expected by receiver from detector - * @param i number of Samples expected - * @return OK or FAIL - */ - int setNumberofSamples(const uint64_t i); - - /** - * Set Dynamic Range or Number of Bits Per Pixel - * @param i dynamic range that is 4, 8, 16 or 32 - * @return OK or FAIL - */ - int setDynamicRange(const uint32_t i); - - /** - * Set Ten Giga Enable - * @param b true if 10Giga enabled, else false (1G enabled) - * @return OK or FAIL - */ - int setTenGigaEnable(const bool b); - - /** - * Set Fifo Depth - * @param i fifo depth value - * @return OK or FAIL - */ - int setFifoDepth(const uint32_t i); - - //***receiver parameters*** - /** - * Set Silent Mode - * @param i silent mode. true sets, false unsets - */ - void setSilentMode(const bool i); - - /************************************************************************* - * Behavioral functions*************************************************** - * They may modify the status of the receiver **************************** - *************************************************************************/ - - - //***initial functions*** - /** - * Set receiver type (and corresponding detector variables in derived STANDARD class) - * It is the first function called by the client when connecting to receiver - * @param d detector type - * @return OK or FAIL - */ - int setDetectorType(const detectorType d); - - /** - * Set detector position id - * @param i position id - */ - void setDetectorPositionId(const int i); - - /** - * Sets detector hostname - * It is second function called by the client when connecting to receiver. - * you can call this function only once. - * @param c detector hostname - */ - void initialize(const char *c); - - - //***acquisition functions*** - /** - * Reset acquisition parameters such as total frames caught for an entire acquisition (including all scans) - */ - void resetAcquisitionCount(); - - /** - * Start Listening for Packets by activating all configuration settings to receiver - * @param c error message if FAIL - * @return OK or FAIL - */ - int startReceiver(char *c=NULL); - - /** - * Stop Listening for Packets - * Calls startReadout(), which stops listening and sets status to Transmitting - * When it has read every frame in buffer,it returns with the status Run_Finished - */ - void stopReceiver(); - - /** - * Stop Listening to Packets - * and sets status to Transmitting - */ - void startReadout(); - - /** - * Shuts down and deletes UDP Sockets - */ - void shutDownUDPSockets(); - - /** - * abort acquisition with minimum damage: close open files, cleanup. - * does nothing if state already is 'idle' - */ - void abort(); //FIXME: needed, isn't stopReceiver enough? - - /** - * Activate / Deactivate Receiver - * If deactivated, receiver will create dummy data if deactivated padding is enabled - * (as it will receive nothing from detector) - * @param enable enable - * @return false for disabled, true for enabled - */ - bool setActivate(const bool enable); - - /** - * Set deactivated padding enable - * If enabled, receiver will create dummy packets (0xFF), else it will create nothing - * (as it will receive nothing from detector) - * @param enable enable - * @return false for disabled, true for enabled - */ - bool setDeactivatedPadding(const bool enable); - - /** - * Set streaming port - * @param i streaming port - */ - void setStreamingPort(const uint32_t i); - - /** - * Set streaming source ip - * @param c streaming source ip - */ - void setStreamingSourceIP(const char* c); - - /** - * Set additional json header - */ - void setAdditionalJsonHeader(const char* c); - - /** (not saved in client shared memory) - * Set UDP Socket Buffer Size - * @param s UDP Socket Buffer Size - * @return OK or FAIL if dummy socket could be created - */ - int setUDPSocketBufferSize(const uint32_t s); - - /* - * Restream stop dummy packet from receiver - * @return OK or FAIL - */ - int restreamStop(); - - //***callback functions*** - /** - * Call back for start acquisition - * callback arguments are - * filepath - * filename - * fileindex - * datasize - * - * return value is insignificant at the moment - * we write depending on file write enable - * users get data to write depending on call backs registered - */ - void registerCallBackStartAcquisition(int (*func)(char*, char*, uint64_t, uint32_t, void*),void *arg); - - /** - * Call back for acquisition finished - * callback argument is - * total frames caught - */ - void registerCallBackAcquisitionFinished(void (*func)(uint64_t, void*),void *arg); - - /** - * Call back for raw data - * args to raw data ready callback are - * sls_receiver_header frame metadata - * dataPointer is the pointer to the data - * dataSize in bytes is the size of the data in bytes. - */ - void registerCallBackRawDataReady(void (*func)(char* , - char*, uint32_t, void*),void *arg); - - /** - * Call back for raw data (modified) - * args to raw data ready callback are - * sls_receiver_header frame metadata - * dataPointer is the pointer to the data - * revDatasize is the reference of data size in bytes. - * Can be modified to the new size to be written/streamed. (only smaller value). - */ - void registerCallBackRawDataModifyReady(void (*func)(char* , - char*, uint32_t &,void*),void *arg); - - - protected: - - /************************************************************************* - * Class Members ********************************************************* - *************************************************************************/ - //**detector parameters*** - /** detector type */ - detectorType myDetectorType; - /** Number of Detectors in each dimension direction */ - int numDet[MAX_DIMENSIONS]; - /*Detector Readout ID*/ - int detID; - /** detector hostname */ - char detHostname[MAX_STR_LENGTH]; - /** Acquisition Period */ - uint64_t acquisitionPeriod; - /** Acquisition Time */ - uint64_t acquisitionTime; - /** Sub Exposure Time */ - uint64_t subExpTime; - /** Sub Period */ - uint64_t subPeriod; - /** Frame Number */ - uint64_t numberOfFrames; - /** Samples Number */ - uint64_t numberOfSamples; - /** Dynamic Range */ - uint32_t dynamicRange; - /** Ten Giga Enable*/ - bool tengigaEnable; - /** Fifo Depth */ - uint32_t fifoDepth; - /** enable for flipping data across both axes */ - int flippedData[2]; - /** gap pixels enable */ - bool gapPixelsEnable; - - //***receiver parameters*** - /** Maximum Number of Listening Threads/ UDP Ports */ - const static int MAX_NUMBER_OF_LISTENING_THREADS = 2; - /** Receiver Status */ - runStatus status; - /** Activated/Deactivated */ - bool activated; - /** Deactivated padding enable */ - bool deactivatedPaddingEnable; - /** frame discard policy */ - frameDiscardPolicy frameDiscardMode; - /** frame padding */ - bool framePadding; - - //***connection parameters*** - /** Ethernet Interface */ - char eth[MAX_STR_LENGTH]; - /** Server UDP Port Number*/ - uint32_t udpPortNum[MAX_NUMBER_OF_LISTENING_THREADS]; - /** udp socket buffer size */ - uint32_t udpSocketBufferSize; - /** actual UDP Socket Buffer Size (halved due to kernel bookkeeping) */ - uint32_t actualUDPSocketBufferSize; - - //***file parameters*** - /** File format */ - fileFormat fileFormatType; - /** File Name without frame index, file index and extension (_d0_f000000000000_8.raw)*/ - char fileName[MAX_STR_LENGTH]; - /** File Path */ - char filePath[MAX_STR_LENGTH]; - /** File Index */ - uint64_t fileIndex; - /** Frames per file (0 means infinite) */ - uint32_t framesPerFile; - /** Scan Tag */ - int scanTag; - /** File Write enable */ - bool fileWriteEnable; - /** Overwrite enable */ - bool overwriteEnable; - /** Data Compression Enable - save only hits */ - bool dataCompressionEnable; - - //***acquisition parameters*** - /* ROI */ - std::vector roi; - /** Frequency of Frames sent to GUI */ - uint32_t frameToGuiFrequency; - /** Timer of Frames sent to GUI when frequency is 0 */ - uint32_t frameToGuiTimerinMS; - /** Data Stream Enable from Receiver */ - bool dataStreamEnable; - /** streaming port */ - uint32_t streamingPort; - /** streaming port */ - char streamingSrcIP[MAX_STR_LENGTH]; - /** additional json header */ - char additionalJsonHeader[MAX_STR_LENGTH]; - - //***receiver parameters*** - bool silentMode; - - - - //***callback parameters*** - /** - * Call back for start acquisition - * callback arguments are - * filepath - * filename - * fileindex - * datasize - * - * return value is insignificant at the moment - * we write depending on file write enable - * users get data to write depending on call backs registered - */ - int (*startAcquisitionCallBack)(char*, char*, uint64_t, uint32_t, void*); - void *pStartAcquisition; - - /** - * Call back for acquisition finished - * callback argument is - * total frames caught - */ - void (*acquisitionFinishedCallBack)(uint64_t, void*); - void *pAcquisitionFinished; - - - /** - * Call back for raw data - * args to raw data ready callback are - * sls_receiver_header frame metadata - * dataPointer is the pointer to the data - * dataSize in bytes is the size of the data in bytes. - */ - void (*rawDataReadyCallBack)(char* , - char*, uint32_t, void*); - - /** - * Call back for raw data (modified) - * args to raw data ready callback are - * sls_receiver_header frame metadata - * dataPointer is the pointer to the data - * revDatasize is the reference of data size in bytes. Can be modified to the new size to be written/streamed. (only smaller value). - */ - void (*rawDataModifyReadyCallBack)(char* , - char*, uint32_t &, void*); - - void *pRawDataReady; - - - -private: - -}; diff --git a/slsReceiverSoftware/include/UDPInterface.h b/slsReceiverSoftware/include/UDPInterface.h deleted file mode 100644 index 3879abd7e..000000000 --- a/slsReceiverSoftware/include/UDPInterface.h +++ /dev/null @@ -1,801 +0,0 @@ -#pragma once -/*********************************************** - * @file UDPInterface.h - * @short Base class with all the functions for the UDP inteface of the receiver - ***********************************************/ -/** - * \mainpage Base class with all the functions for the UDP inteface of the receiver - */ - -/** - * @short Base class with all the functions for the UDP inteface of the receiver - */ - -#include "sls_receiver_defs.h" -#include "receiver_defs.h" -#include "utilities.h" -#include "logger.h" - -#include -#include - -class UDPInterface { - - /* abstract class that defines the UDP interface of an sls detector data receiver. - * - * Use the factory method UDPInterface::create() to get an instance: - * - * UDPInterface *udp_interface = UDPInterface::create() - * - * Sequence of Calls from client (upon setting receiver) - * -setDetectorType - * -setMultiDetectorSize - * -setDetectorPositionId - * -initialize - * -setUDPPortNumber,setUDPPortNumber2,setEthernetInterface - * -setFilePath - * -setFileName - * -setFileIndex - * -setFileFormat - * -setFileWriteEnable - * -setOverwriteEnable - * -setAcquisitionPeriod - * -setNumberOfFrames - * -setAcquisitionTime - * -setSubExpTime (if eiger) - * -setNumberofSamples (if chip test board) - * -setDynamicRange - * -setFlippedData (if eiger) - * -setActivate (if eiger) - * -setDeactivatedPadding (if eiger) - * -setTenGigaEnable (if eiger) - * -setGapPixelsEnable - * -setStreamingPort - * -setStreamingSourceIP - * -setAdditionalJsonHeader - * -setDataStreamEnable - * -setROI - * - * - * - * supported sequence of method-calls: - * - * initialize() : once and only once after create() - * - * get*() : anytime after initialize(), multiples times - * - * set*() : anytime after initialize(), multiple times - * - * startReceiver(): anytime after initialize(). Will fail in TCPIP itself if state already is 'running': - * - * Only startReceiver() does change the data receiver configuration, it does pass the whole configuration cache to the data receiver. - * - * abort(), //FIXME: needed? - * - * stopReceiver() : anytime after initialize(). Will do nothing if state already is idle. - * Otherwise, sets status to transmitting when shutting down sockets - * then to run_finished when all data obtained - * then to idle when returning from this function - * - * - * getStatus() returns the actual state of the data receiver - idle, running or error, enum defined in include/sls_receiver_defs.h - * - * - * - * get*() and set*() methods access the local cache of configuration values only and *do not* modify the data receiver settings. - * - * set methods return nothing, use get methods to validate a set method success - * - * get-methods that return a char array (char *) allocate a new array at each call. The caller is responsible to free the allocated space: - * - * char *c = receiver->getFileName(); - * Or - * FIXME: so that the pointers are not shared external to the class, do the following way in the calling method? - * char *c = new char[MAX_STR_LENGTH]; - * strcpy(c,receiver->getFileName()); - * .... - * - * delete[] c; - * - * All pointers passed in externally will be allocated and freed by the calling function - * - * OK and FAIL are defined in include/sls_receiver_defs.h for functions implementing behavior - * - */ - - public: - - /************************************************************************* - * Constructor & Destructor ********************************************** - * They access local cache of configuration or detector parameters ******* - *************************************************************************/ - /** - * Constructor - * Only non virtual function implemented in this class - * Factory create method to create a standard or custom object - * @param [in] receiver_type type can be standard or custom (must be derived from base class) - * @return a UDPInterface reference to object depending on receiver type - */ - static UDPInterface *create(std::string receiver_type = "standard"); - - /** - * Destructor - */ - virtual ~UDPInterface() {}; - - - - /************************************************************************* - * Getters *************************************************************** - * They access local cache of configuration or detector parameters ******* - *************************************************************************/ - - //**initial/detector parameters*** - - /* - * Get multi detector size - * @return pointer to array of multi detector size in every dimension - */ - virtual int* getMultiDetectorSize() const = 0; - - /* - * Get detector position id - * @return detector position id - */ - virtual int getDetectorPositionId() const = 0; - - /* - * Get detector hostname - * @return hostname or NULL if uninitialized, must be released by calling function (max of 1000 characters) - */ - virtual char *getDetectorHostname() const = 0; - - /* - * Get flipped data across 'axis' - * @return if data is flipped across 'axis' - */ - virtual int getFlippedData(int axis=0) const = 0; - - /** - * Get Gap Pixels Enable (eiger specific) - * @return true if gap pixels enabled, else false - */ - virtual bool getGapPixelsEnable() const = 0; - - - //***file parameters*** - /** - * Get File Format - * @return file format - */ - virtual slsReceiverDefs::fileFormat getFileFormat() const = 0; - - /** - * Get File Name Prefix (without frame index, file index and extension (_d0_f000000000000_8.raw)) - * @return NULL or pointer to file name prefix, must be released by calling function (max of 1000 characters) - */ - virtual char *getFileName() const = 0; - - /** - * Get File Path - * @return NULL or pointer to file path, must be released by calling function (max of 1000 characters) - */ - virtual char *getFilePath() const = 0; - - /** - * Get File Index - * @return file index of acquisition - */ - virtual uint64_t getFileIndex() const = 0; - - /** - * Get Frames per File (0 means infinite) - * @return Frames per File - */ - virtual uint32_t getFramesPerFile() const = 0; - - /** - * Get Frame Discard Policy - * @return Frame Discard Policy - */ - virtual slsReceiverDefs::frameDiscardPolicy getFrameDiscardPolicy() const = 0; - - /** - * Get Partial Frame Padding Enable - * @return Partial Frame Padding Enable - */ - virtual bool getFramePaddingEnable() const = 0; - - /** - * Get Scan Tag - * @return scan tag //FIXME: needed? (unsigned integer?) - */ - virtual int getScanTag() const = 0; - - /** - * Get File Write Enable - * @return true if file write enabled, else false - */ - virtual bool getFileWriteEnable() const = 0; - - /** - * Get File Over Write Enable - * @return true if file over write enabled, else false - */ - virtual bool getOverwriteEnable() const = 0; - - /** - * Get data compression, by saving only hits (so far implemented only for Moench and Gotthard) - * @return true if data compression enabled, else false - */ - virtual bool getDataCompressionEnable() const = 0; - - - //***acquisition count parameters*** - /** - * Get Total Frames Caught for an entire acquisition (including all scans) - * @return total number of frames caught for entire acquisition - */ - virtual uint64_t getTotalFramesCaught() const = 0; - - /** - * Get Frames Caught for each real time acquisition (eg. for each scan) - * @return number of frames caught for each scan - */ - virtual uint64_t getFramesCaught() const = 0; - - /** - * Get Current Frame Index for an entire acquisition (including all scans) - * @return -1 if no frames have been caught, else current frame index (represents all scans too) or -1 if no packets caught - */ - virtual int64_t getAcquisitionIndex() const = 0; - - - //***connection parameters*** - /** - * Get UDP Port Number - * @return udp port number - */ - virtual uint32_t getUDPPortNumber() const = 0; - - /** - * Get Second UDP Port Number (eiger specific) - * @return second udp port number - */ - virtual uint32_t getUDPPortNumber2() const = 0; - - /** - * Get Ehernet Interface - * @return ethernet interface. eg. eth0 (max of 1000 characters) - */ - virtual char *getEthernetInterface() const = 0; - - - //***acquisition parameters*** - /** - * Get ROI - * @return index of adc enabled, else -1 if all enabled - */ - virtual std::vector getROI() const = 0; - - /** - * Get the Frequency of Frames Sent to GUI - * @return 0 for random frame requests, n for nth frame frequency - */ - virtual uint32_t getFrameToGuiFrequency() const = 0; - - /** - * Gets the timer between frames streamed when frequency is set to 0 - * @return timer between frames streamed - */ - virtual uint32_t getFrameToGuiTimer() const = 0; - - - /** - * Get the data stream enable - * @return data stream enable - */ - virtual bool getDataStreamEnable() const = 0; - - /** - * Get Acquisition Period - * @return acquisition period - */ - virtual uint64_t getAcquisitionPeriod() const = 0; - - /** - * Get Acquisition Time - * @return acquisition time - */ - virtual uint64_t getAcquisitionTime() const = 0; - - /** - * Get Sub Exposure Time - * @return Sub Exposure Time - */ - virtual uint64_t getSubExpTime() const = 0; - - /** - * Get Sub Period - * @return Sub Period - */ - virtual uint64_t getSubPeriod() const = 0; - - /* - * Get Number of Frames expected by receiver from detector - * The data receiver status will change from running to idle when it gets this number of frames FIXME: (for Leo? Not implemented) - * @return number of samples expected - */ - virtual uint64_t getNumberOfFrames() const = 0; - - /* - * Get Number of Samples expected by receiver from detector (for chip test board only) - * @return number of samples expected - */ - virtual uint64_t getNumberofSamples() const = 0; - - /** - * Get Dynamic Range or Number of Bits Per Pixel - * @return dynamic range that is 4, 8, 16 or 32 - */ - virtual uint32_t getDynamicRange() const = 0; - - /** - * Get Ten Giga Enable - * @return true if 10Giga enabled, else false (1G enabled) - */ - virtual bool getTenGigaEnable() const = 0; - - /** - * Get Fifo Depth - * @return fifo depth - */ - virtual uint32_t getFifoDepth() const = 0; - - //***receiver status*** - /** - * Get Listening Status of Receiver - * @return can be idle, listening or error depending on if the receiver is listening or not - */ - virtual slsReceiverDefs::runStatus getStatus() const = 0; - - /** (not saved in client shared memory) - * Get Silent Mode - * @return silent mode - */ - virtual bool getSilentMode() const = 0; - - /** - * Get activate - * If deactivated, receiver will create dummy data if deactivated padding is enabled - * (as it will receive nothing from detector) - * @return false for deactivated, true for activated - */ - virtual bool getActivate() const = 0; - - /** - * Get deactivated padding enable - * If enabled, receiver will create dummy packets (0xFF), else it will create nothing - * (as it will receive nothing from detector) - * @return false for disabled, true for enabled - */ - virtual bool getDeactivatedPadding() const = 0; - - /** - * Get Streaming Port - * @return streaming port - */ - virtual uint32_t getStreamingPort() const = 0; - - /** - * Get streaming source ip - * @return streaming source ip - */ - virtual char *getStreamingSourceIP() const = 0; - - /** - * Get additional json header - * @return additional json header - */ - virtual char *getAdditionalJsonHeader() const = 0; - - - /** (not saved in client shared memory) - * Get UDP Socket Buffer Size - * @return UDP Socket Buffer Size - */ - virtual uint32_t getUDPSocketBufferSize() const = 0; - - /** (not saved in client shared memory) - * Get actual UDP Socket Buffer Size - * @return actual UDP Socket Buffer Size - */ - virtual uint32_t getActualUDPSocketBufferSize() const = 0; - - /************************************************************************* - * Setters *************************************************************** - * They modify the local cache of configuration or detector parameters *** - *************************************************************************/ - - //**initial parameters*** - /** - * Configure command line parameters - * @param config_map mapping of config parameters passed from command line arguments - */ - virtual void configure(std::map config_map) = 0; - - /* - * Set multi detector size - * @param pointer to array of multi detector size in every dimension - */ - virtual void setMultiDetectorSize(const int* size) = 0; - - /* - * Get flipped data across 'axis' - * @return if data is flipped across 'axis' - */ - virtual void setFlippedData(int axis=0, int enable=-1) = 0; - - - /** - * Set Gap Pixels Enable (eiger specific) - * @param b true for gap pixels enable, else false - * @return OK or FAIL - */ - virtual int setGapPixelsEnable(const bool b) = 0; - - - //***file parameters*** - /** - * Set File Format - * @param f fileformat binary or hdf5 - */ - virtual void setFileFormat(slsReceiverDefs::fileFormat f) = 0; - - /** - * Set File Name Prefix (without frame index, file index and extension (_d0_f000000000000_8.raw)) - * Does not check for file existence since it is created only at startReceiver - * @param c file name (max of 1000 characters) - */ - virtual void setFileName(const char c[]) = 0; - - /** - * Set File Path - * Checks for file directory existence before setting file path - * @param c file path (max of 1000 characters) - */ - virtual void setFilePath(const char c[]) = 0; - - /** - * Set File Index of acquisition - * @param i file index of acquisition - */ - virtual void setFileIndex(const uint64_t i) = 0; - - /** - * Set Frames per File (0 means infinite) - * @param i Frames per File - */ - virtual void setFramesPerFile(const uint32_t i) = 0; - - /** - * Set Frame Discard Policy - * @param i Frame Discard Policy - */ - virtual void setFrameDiscardPolicy(const slsReceiverDefs::frameDiscardPolicy i) = 0; - - /** - * Set Partial Frame Padding Enable - * @param i Partial Frame Padding Enable - */ - virtual void setFramePaddingEnable(const bool i) = 0; - - /** - * Set Scan Tag - * @param i scan tag //FIXME: needed? (unsigned integer?) - */ - virtual void setScanTag(const int i) = 0; - - /** - * Set File Write Enable - * @param b true for file write enable, else false - */ - virtual void setFileWriteEnable(const bool b) = 0; - - /** - * Set File Overwrite Enable - * @param b true for file overwrite enable, else false - */ - virtual void setOverwriteEnable(const bool b) = 0; - - /** - * Set data compression, by saving only hits (so far implemented only for Moench and Gotthard) - * @param b true for data compression enable, else false - * @return OK or FAIL - */ - virtual int setDataCompressionEnable(const bool b) = 0; - - //***connection parameters*** - /** - * Set UDP Port Number - * @param i udp port number - */ - virtual void setUDPPortNumber(const uint32_t i) = 0; - - /** - * Set Second UDP Port Number (eiger specific) - * @return second udp port number - */ - virtual void setUDPPortNumber2(const uint32_t i) = 0; - - /** - * Set Ethernet Interface to listen to - * @param c ethernet inerface eg. eth0 (max of 1000 characters) - */ - virtual void setEthernetInterface(const char* c) = 0; - - - //***acquisition parameters*** - /** - * Set ROI - * @param i ROI - * @return OK or FAIL - */ - virtual int setROI(const std::vector i) = 0; - - /** - * Set the Frequency of Frames Sent to GUI - * @param freq 0 for random frame requests, n for nth frame frequency - * @return OK or FAIL - */ - virtual int setFrameToGuiFrequency(const uint32_t freq) = 0; - - /** - * Sets the timer between frames streamed when frequency is set to 0 - * @param time_in_ms timer between frames streamed - */ - virtual void setFrameToGuiTimer(const uint32_t time_in_ms) = 0; - - /** - * Set the data stream enable - * @param enable data stream enable - * @return OK or FAIL - */ - virtual int setDataStreamEnable(const bool enable) = 0; - - /** - * Set Acquisition Period - * @param i acquisition period - * @return OK or FAIL - */ - virtual int setAcquisitionPeriod(const uint64_t i) = 0; - - /** - * Set Acquisition Time - * @param i acquisition time - * @return OK or FAIL - */ - virtual int setAcquisitionTime(const uint64_t i) = 0; - - /** - * Set Sub Exposure Time - * @param i Sub Exposure Time - * @return OK or FAIL - */ - virtual void setSubExpTime(const uint64_t i) = 0; - - /** - * Set Sub Period - * @param i Period - * @return OK or FAIL - */ - virtual void setSubPeriod(const uint64_t i) = 0; - - /** - * Set Number of Frames expected by receiver from detector - * The data receiver status will change from running to idle when it gets this number of frames FIXME: (for Leo? Not implemented) - * @param i number of frames expected - * @return OK or FAIL - */ - virtual int setNumberOfFrames(const uint64_t i) = 0; - - /** - * Set Number of Samples expected by receiver from detector - * @param i number of Samples expected - * @return OK or FAIL - */ - virtual int setNumberofSamples(const uint64_t i) = 0; - - /** - * Set Dynamic Range or Number of Bits Per Pixel - * @param i dynamic range that is 4, 8, 16 or 32 - * @return OK or FAIL - */ - virtual int setDynamicRange(const uint32_t i) = 0; - - /** - * Set Ten Giga Enable - * @param b true if 10Giga enabled, else false (1G enabled) - * @return OK or FAIL - */ - virtual int setTenGigaEnable(const bool b) = 0; - - /** - * Set Fifo Depth - * @param i fifo depth value - * @return OK or FAIL - */ - virtual int setFifoDepth(const uint32_t i) = 0; - - - //***receiver parameters*** - /** - * Set Silent Mode - * @param i silent mode. true sets, false unsets - */ - virtual void setSilentMode(const bool i) = 0; - - - /************************************************************************* - * Behavioral functions*************************************************** - * They may modify the status of the receiver **************************** - *************************************************************************/ - - - //***initial functions*** - /** - * Set receiver type (and corresponding detector variables in derived STANDARD class) - * It is the first function called by the client when connecting to receiver - * @param d detector type - * @return OK or FAIL - */ - virtual int setDetectorType(const slsReceiverDefs::detectorType d) = 0; - - /** - * Set detector position id - * @param i position id - */ - virtual void setDetectorPositionId(const int i) = 0; - - /** - * Sets detector hostname - * It is second function called by the client when connecting to receiver. - * you can call this function only once. - * @param c detector hostname - */ - virtual void initialize(const char *c) = 0; - - - //***acquisition functions*** - /** - * Reset acquisition parameters such as total frames caught for an entire acquisition (including all scans) - */ - virtual void resetAcquisitionCount() = 0; - - /** - * Start Listening for Packets by activating all configuration settings to receiver - * @param c error message if FAIL - * @return OK or FAIL - */ - virtual int startReceiver(char *c=NULL) = 0; - - /** - * Stop Listening for Packets - * Calls startReadout(), which stops listening and sets status to Transmitting - * When it has read every frame in buffer,it returns with the status Run_Finished - */ - virtual void stopReceiver() = 0; - - /** - * Stop Listening to Packets - * and sets status to Transmitting - */ - virtual void startReadout() = 0; - - /** - * Shuts down and deletes UDP Sockets - */ - virtual void shutDownUDPSockets() = 0; - - /** - * abort acquisition with minimum damage: close open files, cleanup. - * does nothing if state already is 'idle' - */ - virtual void abort() = 0; //FIXME: needed, isnt stopReceiver enough? - - /** - * Activate / Deactivate Receiver - * If deactivated, receiver will create dummy data if deactivated padding is enabled - * (as it will receive nothing from detector) - * @param enable enable - * @return false for disabled, true for enabled - */ - virtual bool setActivate(const bool enable) = 0; - - /** - * Set deactivated padding enable - * If enabled, receiver will create dummy packets (0xFF), else it will create nothing - * (as it will receive nothing from detector) - * @param enable enable - * @return false for disabled, true for enabled - */ - virtual bool setDeactivatedPadding(const bool enable) = 0; - - /** - * Set streaming port - * @param i streaming port - */ - virtual void setStreamingPort(const uint32_t i) = 0; - - /** - * Set streaming source ip - * @param c streaming source ip - */ - virtual void setStreamingSourceIP(const char* c) = 0; - - /** - * Set additional json header - */ - virtual void setAdditionalJsonHeader(const char* c) = 0; - - /** (not saved in client shared memory) - * Set UDP Socket Buffer Size - * @param s UDP Socket Buffer Size - * @return OK or FAIL if dummy socket could be created - */ - virtual int setUDPSocketBufferSize(const uint32_t s) = 0; - - /* - * Restream stop dummy packet from receiver - * @return OK or FAIL - */ - virtual int restreamStop() = 0; - - - //***callback functions*** - /** - * Call back for start acquisition - * callback arguments are - * filepath - * filename - * fileindex - * datasize - * - * return value is insignificant at the moment - * we write depending on file write enable - * users get data to write depending on call backs registered - */ - virtual void registerCallBackStartAcquisition(int (*func)(char*, char*, uint64_t, uint32_t, void*),void *arg) = 0; - - /** - * Call back for acquisition finished - * callback argument is - * total frames caught - */ - virtual void registerCallBackAcquisitionFinished(void (*func)(uint64_t, void*),void *arg) = 0; - - /** - * Call back for raw data - * args to raw data ready callback are - * sls_receiver_header frame metadata - * dataPointer is the pointer to the data - * dataSize in bytes is the size of the data in bytes. - */ - virtual void registerCallBackRawDataReady(void (*func)(char* , - char*, uint32_t, void*),void *arg) = 0; - - /** - * Call back for raw data (modified) - * args to raw data ready callback are - * sls_receiver_header frame metadata - * dataPointer is the pointer to the data - * revDatasize is the reference of data size in bytes. Can be modified to the new size to be written/streamed. (only smaller value). - */ - virtual void registerCallBackRawDataModifyReady(void (*func)(char* , - char*, uint32_t &,void*),void *arg) = 0; - - - protected: - private: - -}; diff --git a/slsReceiverSoftware/include/UDPStandardImplementation.h b/slsReceiverSoftware/include/UDPStandardImplementation.h deleted file mode 100644 index 30f19a596..000000000 --- a/slsReceiverSoftware/include/UDPStandardImplementation.h +++ /dev/null @@ -1,282 +0,0 @@ -#pragma once -/********************************************//** - * @file UDPBaseImplementation.h - * @short does all the functions for a receiver, set/get parameters, start/stop etc. - ***********************************************/ -/** - * @short does all the functions for a receiver, set/get parameters, start/stop etc. - */ -#include "UDPBaseImplementation.h" - -class GeneralData; -class Listener; -class DataProcessor; -class DataStreamer; -class Fifo; - - - -class UDPStandardImplementation: private virtual slsReceiverDefs, public UDPBaseImplementation { - public: - - - //*** cosntructor & destructor *** - /** - * Constructor - */ - UDPStandardImplementation(); - - /** - * Destructor - */ - virtual ~UDPStandardImplementation(); - - - - //*** Overloaded Functions called by TCP Interface *** - - /** - * Get Total Frames Caught for an entire acquisition (including all scans) - * @return total number of frames caught for entire acquisition - */ - uint64_t getTotalFramesCaught() const; - - /** - * Get Frames Caught for each real time acquisition (eg. for each scan) - * @return number of frames caught for each scan - */ - uint64_t getFramesCaught() const; - - /** - * Get Current Frame Index for an entire acquisition (including all scans) - * @return -1 if no frames have been caught, else current frame index (represents all scans too) - */ - int64_t getAcquisitionIndex() const; - - /** - * Set Gap Pixels Enable (eiger specific) - * @param b true for gap pixels enable, else false - * @return OK or FAIL - */ - int setGapPixelsEnable(const bool b); - - /** - * Set File Format - * @param f fileformat binary or hdf5 - */ - void setFileFormat(slsReceiverDefs::fileFormat f); - - /** - * Set File Write Enable - * @param b true for file write enable, else false - */ - void setFileWriteEnable(const bool b); - - /** - * Set ROI - * @param i ROI - * @return OK or FAIL - */ - int setROI(const std::vector i); - - /** - * Set the Frequency of Frames Sent to GUI - * @param freq 0 for random frame requests, n for nth frame frequency - * @return OK or FAIL - */ - int setFrameToGuiFrequency(const uint32_t freq); - - /** - * Set the data stream enable - * @param enable data stream enable - * @return OK or FAIL - */ - int setDataStreamEnable(const bool enable); - - /** - * Set Number of Samples expected by receiver from detector - * @param i number of Samples expected - * @return OK or FAIL - */ - int setNumberofSamples(const uint64_t i); - - /** - * Set Dynamic Range or Number of Bits Per Pixel - * @param i dynamic range that is 4, 8, 16 or 32 - * @return OK or FAIL - */ - int setDynamicRange(const uint32_t i); - - /** - * Set Ten Giga Enable - * @param b true if 10GbE enabled, else false (1G enabled) - * @return OK or FAIL - */ - int setTenGigaEnable(const bool b); - - /** - * Set Fifo Depth - * @param i fifo depth value - * @return OK or FAIL - */ - int setFifoDepth(const uint32_t i); - - - /** - * Set receiver type (and corresponding detector variables in derived STANDARD class) - * It is the first function called by the client when connecting to receiver - * @param d detector type - * @return OK or FAIL - */ - int setDetectorType(const detectorType d); - - /** - * Set detector position id and construct filewriter - * @param i position id - */ - void setDetectorPositionId(const int i); - - /** - * Reset acquisition parameters such as total frames caught for an entire acquisition (including all scans) - */ - void resetAcquisitionCount(); - - /** - * Start Listening for Packets by activating all configuration settings to receiver - * When this function returns, it has status RUNNING(upon SUCCESS) or IDLE (upon failure) - * @param c error message if FAIL - * @return OK or FAIL - */ - int startReceiver(char *c=NULL); - - /** - * Stop Listening for Packets - * Calls startReadout(), which stops listening and sets status to Transmitting - * When it has read every frame in buffer, the status changes to Run_Finished - * When this function returns, receiver has status IDLE - * Pre: status is running, semaphores have been instantiated, - * Post: udp sockets shut down, status is idle, semaphores destroyed - */ - void stopReceiver(); - - /** - * Stop Listening to Packets - * and sets status to Transmitting - * Next step would be to get all data and stop receiver completely and return with idle state - * Pre: status is running, udp sockets have been initialized, stop receiver initiated - * Post:udp sockets closed, status is transmitting - */ - void startReadout(); - - /** - * Shuts down and deletes UDP Sockets - * also called in case of illegal shutdown of receiver - */ - void shutDownUDPSockets(); - - /** - * Closes file / all files(data compression involves multiple files) - */ - void closeFiles(); - - /** (not saved in client shared memory) - * Set UDP Socket Buffer Size - * @param s UDP Socket Buffer Size - * @return OK or FAIL if dummy socket could be created - */ - int setUDPSocketBufferSize(const uint32_t s); - - /** - * Restream stop dummy packet from receiver - * @return OK or FAIL - */ - int restreamStop(); - - -private: - - /** - * Delete and free member parameters - */ - void DeleteMembers(); - - /** - * Initialize member parameters - */ - void InitializeMembers(); - - /** - * Sets local network parameters, but requires permissions - */ - void SetLocalNetworkParameters(); - - /** - * Set Thread Priorities - */ - void SetThreadPriorities(); - - /** - * Set up the Fifo Structure for processing buffers - * between listening and dataprocessor threads - * @return OK or FAIL - */ - int SetupFifoStructure(); - - /** - * Reset parameters for new measurement (eg. for each scan) - */ - void ResetParametersforNewMeasurement(); - - /** - * Creates UDP Sockets - * @return OK or FAIL - */ - int CreateUDPSockets(); - - /** - * Creates the first file - * also does the startAcquisitionCallBack - * @return OK or FAIL - */ - int SetupWriter(); - - /** - * Start Running - * Set running mask and post semaphore of the threads - * to start the inner loop in execution thread - */ - void StartRunning(); - - - - //*** Class Members *** - - - //*** receiver parameters *** - /** Number of Threads */ - int numThreads; - - /** Number of Jobs */ - int numberofJobs; - - /** Number of channels in roi for jungfrauctb */ - uint32_t nroichannels; - - //** class objects *** - /** General Data Properties */ - GeneralData* generalData; - - /** Listener Objects that listen to UDP and push into fifo */ - std::vector listener; - - /** DataProcessor Objects that pull from fifo and process data */ - std::vector dataProcessor; - - /** DataStreamer Objects that stream data via ZMQ */ - std::vector dataStreamer; - - /** Fifo Structure to store addresses of memory writes */ - std::vector fifo; - -}; - diff --git a/slsReceiverSoftware/include/ZmqSocket.h b/slsReceiverSoftware/include/ZmqSocket.h deleted file mode 100644 index e58419a1e..000000000 --- a/slsReceiverSoftware/include/ZmqSocket.h +++ /dev/null @@ -1,592 +0,0 @@ -#pragma once -/************************************************ - * @file zmqSocket.h - * @short functions to open/close zmq sockets - ***********************************************/ -/** - *@short functions to open/close zmq sockets - */ - -#include "ansi.h" - - -#include -#include -#include -#include //gethostbyname() -#include //inet_ntoa -#include //json header in zmq stream -#include -#include //usleep in some machines -#include -using namespace rapidjson; - - -#define MAX_STR_LENGTH 1000 - -// #define ZMQ_DETAIL -#define ROIVERBOSITY - -class ZmqSocket { - -public: - - //Socket Options for optimization - //ZMQ_LINGER default is already -1 means no messages discarded. use this options if optimizing required - //ZMQ_SNDHWM default is 0 means no limit. use this to optimize if optimizing required - // eg. int value = -1; - // if (zmq_setsockopt(socketDescriptor, ZMQ_LINGER, &value,sizeof(value))) { - // Close(); - /** - * Constructor for a client - * Creates socket, context and connects to server - * @param hostname hostname or ip of server - * @param portnumber port number - */ - ZmqSocket (const char* const hostname_or_ip, const uint32_t portnumber): - portno (portnumber) - // headerMessage(0) - { - char ip[MAX_STR_LENGTH] = ""; - memset(ip, 0, MAX_STR_LENGTH); - - // convert hostname to ip (not required, but a test that returns if failed) - struct addrinfo *result; - if ((ConvertHostnameToInternetAddress(hostname_or_ip, &result)) || - (ConvertInternetAddresstoIpString(result, ip, MAX_STR_LENGTH))) - throw std::exception(); - - // construct address - sprintf (sockfd.serverAddress, "tcp://%s:%d", ip, portno); -#ifdef VERBOSE - cprintf(BLUE,"address:%s\n",sockfd.serverAddress); -#endif - - // create context - sockfd.contextDescriptor = zmq_ctx_new(); - if (sockfd.contextDescriptor == 0) - throw std::exception(); - - // create publisher - sockfd.socketDescriptor = zmq_socket (sockfd.contextDescriptor, ZMQ_SUB); - if (sockfd.socketDescriptor == 0) { - PrintError (); - Close (); - throw std::exception(); - } - - //Socket Options provided above - // an empty string implies receiving any messages - if ( zmq_setsockopt(sockfd.socketDescriptor, ZMQ_SUBSCRIBE, "", 0)) { - PrintError (); - Close(); - throw std::exception(); - } - //ZMQ_LINGER default is already -1 means no messages discarded. use this options if optimizing required - //ZMQ_SNDHWM default is 0 means no limit. use this to optimize if optimizing required - // eg. int value = -1; - int value = 0; - if (zmq_setsockopt(sockfd.socketDescriptor, ZMQ_LINGER, &value,sizeof(value))) { - PrintError (); - Close(); - throw std::exception(); - } - }; - - /** - * Constructor for a server - * Creates socket, context and connects to server - * @param hostname hostname or ip of server - * @param portnumber port number - * @param ethip is the ip of the ethernet interface to stream zmq from - */ - ZmqSocket (const uint32_t portnumber, const char *ethip): - - portno (portnumber) - // headerMessage(0) - { - sockfd.server = true; - - // create context - sockfd.contextDescriptor = zmq_ctx_new(); - if (sockfd.contextDescriptor == 0) - throw std::exception(); - // create publisher - sockfd.socketDescriptor = zmq_socket (sockfd.contextDescriptor, ZMQ_PUB); - if (sockfd.socketDescriptor == 0) { - PrintError (); - Close (); - throw std::exception(); - } - - //Socket Options provided above - - // construct addresss - sprintf (sockfd.serverAddress,"tcp://%s:%d", ethip, portno); -#ifdef VERBOSE - cprintf(BLUE,"address:%s\n",sockfd.serverAddress); -#endif - // bind address - if (zmq_bind (sockfd.socketDescriptor, sockfd.serverAddress) < 0) { - PrintError (); - Close (); - throw std::exception(); - } - - //sleep for a few milliseconds to allow a slow-joiner - usleep(200* 1000); - }; - - /** - * Destructor - */ - ~ZmqSocket () { - //mySocketDescriptor destructor also gets called - }; - - /** - * Returns Port Number - * @returns Port Number - */ - uint32_t GetPortNumber () { return portno; }; - - /** - * Returns Server Address - * @returns Server Address - */ - char* GetZmqServerAddress () { return sockfd.serverAddress; }; - - /** - * Returns Socket Descriptor - * @reutns Socket descriptor - */ - - void* GetsocketDescriptor () { return sockfd.socketDescriptor; }; - - /** - * Connect client socket to server socket - * @returns 1 for fail, 0 for success - */ - int Connect() { - if (zmq_connect(sockfd.socketDescriptor, sockfd.serverAddress) < 0) { - PrintError (); - return 1; - } - return 0; - } - - /** - * Unbinds the Socket - */ - void Disconnect () {sockfd.Disconnect();}; - - /** - * Close Socket and destroy Context - */ - void Close () { sockfd.Close(); }; - - /** - * Convert Hostname to Internet address info structure - * One must use freeaddrinfo(res) after using it - * @param hostname hostname - * @param res address of pointer to address info structure - * @return 1 for fail, 0 for success - */ - // Do not make this static (for multi threading environment) - int ConvertHostnameToInternetAddress (const char* const hostname, struct addrinfo **res) { - // criteria in selecting socket address structures returned by res - struct addrinfo hints; - memset (&hints, 0, sizeof (hints)); - hints.ai_family = AF_INET; - hints.ai_socktype = SOCK_STREAM; - // get host info into res - int errcode = getaddrinfo (hostname, NULL, &hints, res); - if (errcode != 0) { - cprintf (RED,"Error: Could not convert %s hostname to internet address (zmq):" - "%s\n", hostname, gai_strerror(errcode)); - } else { - if (*res == NULL) { - cprintf (RED,"Error: Could not convert %s hostname to internet address (zmq): " - "gettaddrinfo returned null\n", hostname); - } else{ - return 0; - } - } - cprintf(RED, "Error: Could not convert hostname to internet address\n"); - return 1; - }; - - /** - * Convert Internet Address structure pointer to ip string (char*) - * Clears the internet address structure as well - * @param res pointer to internet address structure - * @param ip pointer to char array to store result in - * @param ipsize size available in ip buffer - * @return 1 for fail, 0 for success - */ - // Do not make this static (for multi threading environment) - int ConvertInternetAddresstoIpString (struct addrinfo *res, char* ip, const int ipsize) { - if (inet_ntop (res->ai_family, &((struct sockaddr_in *) res->ai_addr)->sin_addr, ip, ipsize) != NULL) { - freeaddrinfo(res); - return 0; - } - cprintf(RED, "Error: Could not convert internet address to ip string\n"); - return 1; - } - - - - /** - * Send Message Header - * @param buf message - * @param length length of message - * @param dummy true if end of acquistion else false - * @returns 0 if error, else 1 - */ - int SendHeaderData ( int index, bool dummy, uint32_t jsonversion, uint32_t dynamicrange = 0, uint64_t fileIndex = 0, - uint32_t npixelsx = 0, uint32_t npixelsy = 0, uint32_t imageSize = 0, - uint64_t acqIndex = 0, uint64_t fIndex = 0, char* fname = NULL, - uint64_t frameNumber = 0, uint32_t expLength = 0, uint32_t packetNumber = 0, - uint64_t bunchId = 0, uint64_t timestamp = 0, - uint16_t modId = 0, uint16_t row = 0, uint16_t column = 0, uint16_t reserved = 0, - uint32_t debug = 0, uint16_t roundRNumber = 0, - uint8_t detType = 0, uint8_t version = 0, int* flippedData = 0, - char* additionalJsonHeader = 0) { - - - char buf[MAX_STR_LENGTH] = ""; - /** Json Header Format */ - const char* jsonHeaderFormat = - "{" - "\"jsonversion\":%u, " - "\"bitmode\":%u, " - "\"fileIndex\":%llu, " - "\"shape\":[%u, %u], " - "\"size\":%u, " - "\"acqIndex\":%llu, " - "\"fIndex\":%llu, " - "\"fname\":\"%s\", " - "\"data\": %d, " - - "\"frameNumber\":%llu, " - "\"expLength\":%u, " - "\"packetNumber\":%u, " - "\"bunchId\":%llu, " - "\"timestamp\":%llu, " - "\"modId\":%u, " - "\"row\":%u, " - "\"column\":%u, " - "\"reserved\":%u, " - "\"debug\":%u, " - "\"roundRNumber\":%u, " - "\"detType\":%u, " - "\"version\":%u, " - - //additional stuff - "\"flippedDataX\":%u" - - ;//"}\n"; - int length = sprintf(buf, jsonHeaderFormat, - jsonversion, dynamicrange, fileIndex, npixelsx, npixelsy, imageSize, - acqIndex, fIndex, (fname == NULL)? "":fname, dummy?0:1, - - frameNumber, expLength, packetNumber, bunchId, timestamp, - modId, row, column, reserved, debug, roundRNumber, - detType, version, - - //additional stuff - ((flippedData == 0 ) ? 0 :flippedData[0]) - ); - if (additionalJsonHeader && strlen(additionalJsonHeader)) { - length = sprintf(buf, "%s, %s}\n", buf, additionalJsonHeader); - } else { - length = sprintf(buf, "%s}\n", buf); - } - -#ifdef VERBOSE - //if(!index) - cprintf(BLUE,"%d : Streamer: buf: %s\n", index, buf); -#endif - - if(zmq_send (sockfd.socketDescriptor, buf, length, dummy?0:ZMQ_SNDMORE) < 0) { - PrintError (); - return 0; - } -#ifdef VERBOSE - cprintf(GREEN,"[%u] send header data\n",portno); -#endif - return 1; - }; - - /** - * Send Message Body - * @param buf message - * @param length length of message - * @returns 0 if error, else 1 - */ - int SendData (char* buf, int length) { - if(zmq_send (sockfd.socketDescriptor, buf, length, 0) < 0) { - PrintError (); - return 0; - } -#ifdef VERBOSE - cprintf(GREEN,"[%u] send data\n",portno); -#endif - return 1; - }; - - - /** - * Receive Message - * @param index self index for debugging - * @param message message - * @returns length of message, -1 if error - */ - int ReceiveMessage(const int index, zmq_msg_t& message) { - int length = zmq_msg_recv (&message, sockfd.socketDescriptor, 0); - if (length == -1) { - PrintError (); - cprintf (BG_RED,"Error: Could not read header for socket %d\n",index); - } -#ifdef VERBOSE - else - cprintf( RED,"Message %d Length: %d Header:%s \n", index, length, (char*) zmq_msg_data (&message) ); -#endif - return length; - }; - - - /** - * Receive Header (Important to close message after parsing header) - * @param index self index for debugging - * @param document parsed document reference - * @param version version that has to match, -1 to not care - * @returns 0 if error or end of acquisition, else 1 (call CloseHeaderMessage after parsing header) - */ - int ReceiveHeader(const int index, Document& document, uint32_t version) - { - std::vectorbuffer(MAX_STR_LENGTH); - int len = zmq_recv(sockfd.socketDescriptor, buffer.data(), buffer.size(),0); - if ( len > 0 ) { - bool dummy = false; -#ifdef ZMQ_DETAIL - cprintf( BLUE,"Header %d [%d] Length: %d Header:%s \n", index, portno, len, buffer.data()); -#endif - if ( ParseHeader (index, len, buffer.data(), document, dummy, version)) { -#ifdef ZMQ_DETAIL - cprintf( RED,"Parsed Header %d [%d] Length: %d Header:%s \n", index, portno, len, buffer.data() ); -#endif - if (dummy) { -#ifdef ZMQ_DETAIL - cprintf(RED,"%d [%d] Received end of acquisition\n", index, portno ); -#endif - return 0; - } -#ifdef ZMQ_DETAIL - cprintf(GREEN,"%d [%d] data\n",index, portno ); -#endif - return 1; - } - } - return 0; - }; - - - /** - * Close Header Message. Call this function if ReceiveHeader returned 1 - */ - // void CloseHeaderMessage() { - // if (headerMessage) - // zmq_msg_close(headerMessage); - // headerMessage = 0; - // }; - /** - * Parse Header - * @param index self index for debugging - * @param length length of message - * @param message message - * @param document parsed document reference - * @param dummy true if end of acqusition, else false, loaded upon parsing - * @param version version that has to match, -1 to not care - * @returns true if successful else false - */ - int ParseHeader(const int index, int length, char* buff, - Document& document, bool& dummy, uint32_t version) - { - if ( document.Parse( buff, length).HasParseError() ) { - cprintf( RED,"%d Could not parse. len:%d: Message:%s \n", index, length, buff ); - fflush ( stdout ); - // char* buf = (char*) zmq_msg_data (&message); - for ( int i= 0; i < length; ++i ) { - cprintf(RED,"%02x ",buff[i]); - } - printf("\n"); - fflush( stdout ); - return 0; - } - - if (document["jsonversion"].GetUint() != version) { - cprintf( RED, "version mismatch. required %u, got %u\n", version, document["jsonversion"].GetUint()); - return 0; - } - - dummy = false; - int temp = document["data"].GetUint(); - dummy = temp ? false : true; - - return 1; - }; - - - /** - * Receive Data - * @param index self index for debugging - * @param buf buffer to copy image data to - * @param size size of image - * @returns length of data received - */ - int ReceiveData(const int index, char* buf, const int size) - { - zmq_msg_t message; - zmq_msg_init (&message); - int length = ReceiveMessage(index, message); - - //actual data - if (length == size) { -#ifdef VERBOSE - cprintf(BLUE,"%d actual data\n", index); -#endif - memcpy(buf, (char*)zmq_msg_data(&message), size); - } - - //incorrect size (smaller) - else if (length < size){ -#ifdef ROIVERBOSITY - cprintf(RED,"Error: Received smaller packet size %d for socket %d\n", length, index); -#endif - memcpy(buf, (char*)zmq_msg_data(&message), length); - memset(buf+length,0xFF,size-length); - } - //incorrect size (larger) - else { - cprintf(RED,"Error: Received weird packet size %d for socket %d\n", length, index); - memset(buf,0xFF,size); - } - - zmq_msg_close(&message); - return length; - }; - - - - /** - * Print error - */ - void PrintError () { - switch (errno) { - case EINVAL: - cprintf(RED, "Error: The socket type/option or value/endpoint supplied is invalid (zmq)\n"); - break; - case EAGAIN: - cprintf(RED, "Error: Non-blocking mode was requested and the message cannot be sent/available at the moment (zmq)\n"); - break; - case ENOTSUP: - cprintf(RED, "Error: The zmq_send()/zmq_msg_recv() operation is not supported by this socket type (zmq)\n"); - break; - case EFSM: - cprintf(RED, "Error: The zmq_send()/zmq_msg_recv() unavailable now as socket in inappropriate state (eg. ZMQ_REP). Look up messaging patterns (zmq)\n"); - break; - case EFAULT: - cprintf(RED, "Error: The provided context/message is invalid (zmq)\n"); - break; - case EMFILE: - cprintf(RED, "Error: The limit on the total number of open ØMQ sockets has been reached (zmq)\n"); - break; - case EPROTONOSUPPORT: - cprintf(RED, "Error: The requested transport protocol is not supported (zmq)\n"); - break; - case ENOCOMPATPROTO: - cprintf(RED, "Error: The requested transport protocol is not compatible with the socket type (zmq)\n"); - break; - case EADDRINUSE: - cprintf(RED, "Error: The requested address is already in use (zmq)\n"); - break; - case EADDRNOTAVAIL: - cprintf(RED, "Error: The requested address was not local (zmq)\n"); - break; - case ENODEV: - cprintf(RED, "Error: The requested address specifies a nonexistent interface (zmq)\n"); - break; - case ETERM: - cprintf(RED, "Error: The ØMQ context associated with the specified socket was terminated (zmq)\n"); - break; - case ENOTSOCK: - cprintf(RED, "Error: The provided socket was invalid (zmq)\n"); - break; - case EINTR: - cprintf(RED, "Error: The operation was interrupted by delivery of a signal (zmq)\n"); - break; - case EMTHREAD: - cprintf(RED, "Error: No I/O thread is available to accomplish the task (zmq)\n"); - break; - default: - cprintf(RED, "Error: Unknown socket error (zmq)\n"); - break; - } - }; - - -private: - - /** - * Class to close socket descriptors automatically - * upon encountering exceptions in the ZmqSocket constructor - */ - class mySocketDescriptors { - public: - /** Constructor */ - mySocketDescriptors(): - server(false), - contextDescriptor(0), - socketDescriptor(0) {}; - /** Destructor */ - ~mySocketDescriptors() { - Disconnect(); - Close(); - } - /** Unbinds the Socket */ - void Disconnect () { - if (server) - zmq_unbind (socketDescriptor, serverAddress); - else - zmq_disconnect (socketDescriptor, serverAddress); - }; - /** Close Socket and destroy Context */ - void Close () { - if (socketDescriptor != NULL) { - zmq_close (socketDescriptor); - socketDescriptor = NULL; - } - - if (contextDescriptor != NULL) { - zmq_ctx_destroy (contextDescriptor); - contextDescriptor = NULL; - } - }; - /** true if server, else false */ - bool server; - /** Server Address */ - char serverAddress[1000]; - /** Context Descriptor */ - void* contextDescriptor; - /** Socket Descriptor */ - void* socketDescriptor; - }; - -private: - /** Port Number */ - uint32_t portno; - - /** Socket descriptor */ - mySocketDescriptors sockfd; -}; diff --git a/slsReceiverSoftware/include/ansi.h b/slsReceiverSoftware/include/ansi.h deleted file mode 100644 index 3bd8f6eb3..000000000 --- a/slsReceiverSoftware/include/ansi.h +++ /dev/null @@ -1,66 +0,0 @@ -#define RED "\x1b[31m" -#define GREEN "\x1b[32m" -#define YELLOW "\x1b[33m" -#define BLUE "\x1b[34m" -#define MAGENTA "\x1b[35m" -#define CYAN "\x1b[36m" -#define GRAY "\x1b[37m" -#define DARKGRAY "\x1b[30m" - -#define BG_BLACK "\x1b[48;5;232m" -#define BG_RED "\x1b[41m" -#define BG_GREEN "\x1b[42m" -#define BG_YELLOW "\x1b[43m" -#define BG_BLUE "\x1b[44m" -#define BG_MAGENTA "\x1b[45m" -#define BG_CYAN "\x1b[46m" -#define RESET "\x1b[0m" -#define BOLD "\x1b[1m" - -//on background black -#define bprintf(code, format, ...) printf(code BG_BLACK format RESET, ##__VA_ARGS__) - -//normal printout -#define cprintf(code, format, ...) printf(code format RESET, ##__VA_ARGS__) -/* - -Code examples - -example 1 (a snippet): - - -#ifdef MARTIN - cprintf(BLUE, "LL Write - Len: %2d - If: %X - Data: ",buffer_len, ll->ll_fifo_base); - for (i=0; i < buffer_len/4; i++) - cprintf(BLUE, "%.8X ",*(((unsigned *) buffer)+i)); - printf("\n"); -#endif - -#ifdef MARTIN - cprintf(CYAN, "LL Read - If: %X - Data: ",ll->ll_fifo_base); -#endif - - - -example 2: - -int main() -{ - int i=1; - printf("Normal %i\n", i); - cprintf(RED, "Red\n"); - cprintf(GREEN, "Green\n"); - cprintf(YELLOW, "Yellow\n"); - cprintf(BLUE, "Blue\n"); - cprintf(MAGENTA, "Mangenta %i\n", i); - cprintf(CYAN, "Cyan %i\n", i); - cprintf(BOLD, "White %i\n", i); - cprintf(RED BOLD, "Red %i\n", i); - cprintf(GREEN BOLD, "Green\n"); - cprintf(YELLOW BOLD, "Yellow\n"); - cprintf(BLUE BOLD, "Blue\n"); - cprintf(MAGENTA BOLD, "Mangenta %i\n", i); - cprintf(CYAN BOLD, "Cyan %i\n", i); -} - -*/ diff --git a/slsReceiverSoftware/include/circularFifo.h b/slsReceiverSoftware/include/circularFifo.h deleted file mode 100644 index f0b4eeb34..000000000 --- a/slsReceiverSoftware/include/circularFifo.h +++ /dev/null @@ -1,156 +0,0 @@ -#pragma once -/* CircularFifo.h -* Code & platform dependent issues with it was originally -* published at http://www.kjellkod.cc/threadsafecircularqueue -* 2009-11-02 -* @author Kjell Hedstr�m, hedstrom@kjellkod.cc -* modified by the sls detetor group -* */ - -//#include "sls_receiver_defs.h" -#include -#include -#include - -typedef double double32_t; -typedef float float32_t; -typedef int int32_t; - - - -/** Circular Fifo (a.k.a. Circular Buffer) -* Thread safe for one reader, and one writer */ -template -class CircularFifo { -public: - - CircularFifo(unsigned int Size) : tail(0), head(0){ - Capacity = Size + 1; - array.resize(Capacity); - sem_init(&data_mutex,0,0); - sem_init(&free_mutex,0,Size); - } - virtual ~CircularFifo() { - sem_destroy(&data_mutex); - sem_destroy(&free_mutex); - } - - bool push(Element*& item_, bool no_block=false); - bool pop(Element*& item_, bool no_block=false); - - bool isEmpty() const; - bool isFull() const; - - int getDataValue() const; - int getFreeValue() const; - -private: - std::vector array; - unsigned int tail; // input index - unsigned int head; // output index - unsigned int Capacity; - mutable sem_t data_mutex; - mutable sem_t free_mutex; - unsigned int increment(unsigned int idx_) const; -}; - -template -int CircularFifo::getDataValue() const -{ - int value; - sem_getvalue(&data_mutex, &value); - return value; -} - -template -int CircularFifo::getFreeValue() const -{ - int value; - sem_getvalue(&free_mutex, &value); - return value; -} - - -/** Producer only: Adds item to the circular queue. -* If queue is full at 'push' operation no update/overwrite -* will happen, it is up to the caller to handle this case -* -* \param item_ copy by reference the input item -* \param no_block if true, return immediately if fifo is full -* \return whether operation was successful or not */ -template -bool CircularFifo::push(Element*& item_, bool no_block) -{ - // check for fifo full - if (no_block && isFull()) - return false; - - sem_wait(&free_mutex); - array[tail] = item_; - tail = increment(tail); - sem_post(&data_mutex); - return true; -} - -/** Consumer only: Removes and returns item from the queue -* If queue is empty at 'pop' operation no retrieve will happen -* It is up to the caller to handle this case -* -* \param item_ return by reference the wanted item -* \param no_block if true, return immediately if fifo is full -* \return whether operation was successful or not */ -template -bool CircularFifo::pop(Element*& item_, bool no_block) -{ - // check for fifo empty - if (no_block && isEmpty()) - return false; - - sem_wait(&data_mutex); - item_ = array[head]; - head = increment(head); - sem_post(&free_mutex); - return true; -} - -/** Useful for testinng and Consumer check of status - * Remember that the 'empty' status can change quickly - * as the Procuder adds more items. - * - * \return true if circular buffer is empty */ -template -bool CircularFifo::isEmpty() const -{ - return (getDataValue() == 0); -} - -/** Useful for testing and Producer check of status - * Remember that the 'full' status can change quickly - * as the Consumer catches up. - * - * \return true if circular buffer is full. */ -template -bool CircularFifo::isFull() const -{ - return (getFreeValue() == 0); -} - -/** Increment helper function for index of the circular queue -* index is inremented or wrapped -* -* \param idx_ the index to the incremented/wrapped -* \return new value for the index */ -template -unsigned int CircularFifo::increment(unsigned int idx_) const -{ - // increment or wrap - // ================= - // index++; - // if(index == array.lenght) -> index = 0; - // - //or as written below: - // index = (index+1) % array.length - idx_ = (idx_+1) % Capacity; - return idx_; -} - diff --git a/slsReceiverSoftware/include/genericSocket.h b/slsReceiverSoftware/include/genericSocket.h deleted file mode 100644 index 1a49e9bad..000000000 --- a/slsReceiverSoftware/include/genericSocket.h +++ /dev/null @@ -1,835 +0,0 @@ -#pragma once -/** - * - * @libdoc genericSocket provides some functions to open/close sockets both TCP and UDP - * - * @short some functions to open/close sockets both TCP and UDP - * @author Anna Bergamaschi - * @version 0.0 - */ - -#include "ansi.h" -#include "sls_receiver_exceptions.h" - -#ifdef __CINT__ -//class sockaddr_in; -class socklen_t; -class uint32_t; -class uint32_t_ss; -// CINT view of types: -class sockaddr_in; -// { -// unsigned short int sa_family; -// unsigned char sa_data[14]; -// }; -#else - -#include -#include -#include -#include -#include -#include -#include // capabilities -#include - -#endif - -#include /******exit */ -#include -#include -#include -#include -#include -#include -#include "logger.h" - - -#define DEFAULT_PACKET_SIZE 1286 -#define SOCKET_BUFFER_SIZE (100*1024*1024) //100 MB -#define DEFAULT_BACKLOG 5 - - -class genericSocket{ - -public: - - /** Communication protocol */ - enum communicationProtocol{ - TCP, /**< TCP/IP */ - UDP /**< UDP */ - }; - - /** - * The constructor for a client - * throws an exception if the hostname/ip could not be converted to an internet address - * @param host_ip_or_name hostname or ip of the client - * @param port_number port number to connect to - * @param p TCP or UDP - * @param ps a single packet size - */ - genericSocket(const char* const host_ip_or_name, - unsigned short int const port_number, - communicationProtocol p, int ps = DEFAULT_PACKET_SIZE) : - portno(port_number), - protocol(p), - is_a_server(0), - packet_size(ps), - nsending(0), - nsent(0), - total_sent(0),// sender (client): where to? ip - header_packet_size(0), - actual_udp_socket_buffer_size(0) { - memset(&serverAddress, 0, sizeof(serverAddress)); - memset(&clientAddress, 0, sizeof(clientAddress)); - memset(lastClientIP,0,INET_ADDRSTRLEN); - memset(thisClientIP,0,INET_ADDRSTRLEN); - memset(dummyClientIP,0,INET_ADDRSTRLEN); - differentClients = 0; - - struct addrinfo *result; - if (ConvertHostnameToInternetAddress(host_ip_or_name, &result)) { - sockfd.fd = -1; - throw SocketException(); - } - - sockfd.fd = 0; - serverAddress.sin_family = result->ai_family; - memcpy((char *) &serverAddress.sin_addr.s_addr, - &((struct sockaddr_in *) result->ai_addr)->sin_addr, sizeof(in_addr_t)); - freeaddrinfo(result); - serverAddress.sin_port = htons(port_number); - clientAddress_length=sizeof(clientAddress); - }; - - /** - * The constructor for a server - * throws an exception if socket could not be created, closes descriptor before throwing - * @param port_number port number to connect to - * @param p TCP or UDP - * @param ps a single packet size - * @param eth interface name or IP address to listen to (if NULL, listen to all interfaces) - */ - genericSocket(unsigned short int const port_number, communicationProtocol p, - int ps = DEFAULT_PACKET_SIZE, const char *eth=NULL, int hsize=0, - uint32_t buf_size=SOCKET_BUFFER_SIZE): - portno(port_number), - protocol(p), - is_a_server(1), - packet_size(ps), - nsending(0), - nsent(0), - total_sent(0), - header_packet_size(hsize), - actual_udp_socket_buffer_size(0) { - - - memset(&serverAddress, 0, sizeof(serverAddress)); - memset(&clientAddress, 0, sizeof(clientAddress)); - memset(lastClientIP,0,INET_ADDRSTRLEN); - memset(thisClientIP,0,INET_ADDRSTRLEN); - memset(dummyClientIP,0,INET_ADDRSTRLEN); - differentClients = 0; - - // same port - if(serverAddress.sin_port == htons(port_number)){ - sockfd.fd = -10; - throw SamePortSocketException(); - } - - char ip[20]; - - strcpy(ip,"0.0.0.0"); - clientAddress_length=sizeof(clientAddress); - if (eth) { - strcpy(ip,nameToIp(std::string(eth)).c_str()); - if (std::string(ip)==std::string("0.0.0.0")) - strcpy(ip,eth); - } - - sockfd.fd = socket(AF_INET, getProtocol(),0); //tcp - - if (sockfd.fd < 0) { - cprintf(RED, "Can not create socket\n"); - sockfd.fd =-1; - throw SocketException(); - } - - // Set some fields in the serverAddress structure. - serverAddress.sin_family = AF_INET; - serverAddress.sin_port = htons(port_number); - serverAddress.sin_addr.s_addr = htonl(INADDR_ANY); - - - if (std::string(ip)!=std::string("0.0.0.0")) { - if (inet_pton(AF_INET, ip, &(serverAddress.sin_addr))); - else - serverAddress.sin_addr.s_addr = htonl(INADDR_ANY); - } - - - // reuse port - { - int val=1; - if (setsockopt(sockfd.fd,SOL_SOCKET,SO_REUSEADDR, - &val,sizeof(int)) == -1) { - cprintf(RED, "setsockopt REUSEADDR failed\n"); - sockfd.fd =-1; - throw SocketException(); - } - } - - //increase socket buffer size if its udp - if (p == UDP) { - uint32_t desired_size = buf_size; - uint32_t real_size = desired_size * 2; // kernel doubles this value for bookkeeping overhead - uint32_t ret_size = -1; - socklen_t optlen = sizeof(int); - - // confirm if sufficient - if (getsockopt(sockfd.fd, SOL_SOCKET, SO_RCVBUF, &ret_size, &optlen) == -1) { - FILE_LOG(logWARNING) << "[Port " << port_number << "] " - "Could not get rx socket receive buffer size"; - } else if (ret_size >= real_size) { - actual_udp_socket_buffer_size = ret_size; -#ifdef VEBOSE - FILE_LOG(logINFO) << "[Port " << port_number << "] " - "UDP rx socket buffer size is sufficient (" << ret_size << ")"; -#endif - } - - // not sufficient, enhance size - else { - // set buffer size (could not set) - if (setsockopt(sockfd.fd, SOL_SOCKET, SO_RCVBUF, - &desired_size, optlen) == -1) { - FILE_LOG(logWARNING) << "[Port " << port_number << "] " - "Could not set rx socket buffer size to " - << desired_size << ". (No Root Privileges?)"; - } - // confirm size - else if (getsockopt(sockfd.fd, SOL_SOCKET, SO_RCVBUF, - &ret_size, &optlen) == -1) { - FILE_LOG(logWARNING) << "[Port " << port_number << "] " - "Could not get rx socket buffer size"; - } - else if (ret_size >= real_size) { - actual_udp_socket_buffer_size = ret_size; - FILE_LOG(logINFO) << "[Port " << port_number << "] " - "UDP rx socket buffer size modified to " << ret_size; - } - // buffer size too large - else { - actual_udp_socket_buffer_size = ret_size; - // force a value larger than system limit - // (if run in a privileged context (capability CAP_NET_ADMIN set)) - int ret = setsockopt(sockfd.fd, SOL_SOCKET, SO_RCVBUFFORCE, - &desired_size, optlen); - getsockopt(sockfd.fd, SOL_SOCKET, SO_RCVBUF, - &ret_size, &optlen); - if (ret == -1) { - FILE_LOG(logWARNING) << "[Port " << port_number << "] " - "Could not force rx socket buffer size to " - << desired_size << ".\n Real size: " << ret_size << - ". (No Root Privileges?)\n" - " To remove this warning: set rx_udpsocksize from client to <= " << - (ret_size/2) << " (Real size:" << ret_size << ")."; - } else { - FILE_LOG(logINFO) << "[Port " << port_number << "] " - "UDP rx socket buffer size modified to " << ret_size; - } - } - } - } - - - if(bind(sockfd.fd,(struct sockaddr *) &serverAddress,sizeof(serverAddress))<0){ - cprintf(RED, "Can not bind socket\n"); - sockfd.fd =-1; - throw SocketException(); - } - - - if (getProtocol()==SOCK_STREAM) - listen(sockfd.fd, DEFAULT_BACKLOG); - - } - - /** - * The destructor: disconnects and close the socket - */ - ~genericSocket() { - //mySocketDescriptor destructor also gets called - serverAddress.sin_port=-1; - }; - - /** - * Returns actual udp socket buffer size/2. - * Halving is because of kernel book keeping - * @returns actual udp socket buffer size/2 - */ - int getActualUDPSocketBufferSize(){return actual_udp_socket_buffer_size;}; - - /** - * Get protocol TCP or UDP -- * @returns TCP or UDP - */ - int getCommunicationProtocol(){return protocol;}; - - /** - * Get port number - * @retrns port number - */ - uint16_t getPortNumber(){return ntohs(serverAddress.sin_port);} - - /** - * Get TCP Server File Descriptor - * @returns TCP Server file descriptor - */ - int getFileDes(){return sockfd.newfd;}; - - /** - * Get socket descriptor - * @returns socket descriptor - */ - int getsocketDescriptor(){return sockfd.fd;}; - - /** - * Get total bytes sent/received - * Makes sense only for udp socket as there is only receive data - */ - int getCurrentTotalReceived(){return total_sent;}; - - /** - * Get type of protocol based on protocol - * @param p TCP or UDP - * @returns SOCK_STREAM/SOCK_DGRAM or -1 - */ - int getProtocol(communicationProtocol p) { - switch (p) { - case TCP: - return SOCK_STREAM; - break; - case UDP: - return SOCK_DGRAM; - default: - cprintf(RED, "unknown protocol %d\n", p); - return -1; - } - }; - - /** - * Get current protocol type - * @returns SOCK_STREAM/SOCK_DGRAM or -1 - */ - int getProtocol() {return getProtocol(protocol);}; - - /** - * Close TCP Server socket descriptor - */ - void CloseServerTCPSocketDescriptor() { - if (protocol == TCP && is_a_server) { - if (sockfd.fd >= 0) { - close(sockfd.fd); - sockfd.fd = -1; - } - } - }; - - /** - * Disconnect - */ - void Disconnect(){ - if (protocol == TCP && is_a_server) { - if (sockfd.newfd >= 0) { - close(sockfd.newfd); - sockfd.newfd = -1; - } - return; - } - if (sockfd.fd >= 0) { - close(sockfd.fd); - sockfd.fd = -1; - } - }; - - /** - * Establishes connection - * @returns 1 if error - */ - int Connect(){ - - if(sockfd.newfd>0) return sockfd.newfd; - if (protocol==UDP) return -1; - - if(is_a_server && protocol==TCP){ //server tcp; the server will wait for the clients connection - if (sockfd.fd>0) { - if ((sockfd.newfd = accept(sockfd.fd,(struct sockaddr *) &clientAddress, &clientAddress_length)) < 0) { - cprintf(RED, "Error: with server accept, connection refused\n"); - switch(errno) { - case EWOULDBLOCK: - printf("ewouldblock eagain\n"); - break; - case EBADF: - printf("ebadf\n"); - break; - case ECONNABORTED: - printf("econnaborted\n"); - break; - case EFAULT: - printf("efault\n"); - break; - case EINTR: - printf("eintr\n"); - break; - case EINVAL: - printf("einval\n"); - break; - case EMFILE: - printf("emfile\n"); - break; - case ENFILE: - printf("enfile\n"); - break; - case ENOTSOCK: - printf("enotsock\n"); - break; - case EOPNOTSUPP: - printf("eOPNOTSUPP\n"); - break; - case ENOBUFS: - printf("ENOBUFS\n"); - break; - case ENOMEM: - printf("ENOMEM\n"); - break; - case ENOSR: - printf("ENOSR\n"); - break; - case EPROTO: - printf("EPROTO\n"); - break; - default: - printf("unknown error\n"); - } - } - else{ - inet_ntop(AF_INET, &(clientAddress.sin_addr), dummyClientIP, INET_ADDRSTRLEN); -#ifdef VERY_VERBOSE - cout << "client connected "<< sockfd.newfd << endl; -#endif - } - } -#ifdef VERY_VERBOSE - cout << "fd " << sockfd.newfd << endl; -#endif - return sockfd.newfd; - } else { - if (sockfd.fd<=0) - sockfd.fd = socket(AF_INET, getProtocol(),0); - // SetTimeOut(10); - if (sockfd.fd < 0){ - cprintf(RED, "Can not create socket\n"); - } else { - if(connect(sockfd.fd,(struct sockaddr *) &serverAddress,sizeof(serverAddress))<0){ - cprintf(RED, "Can not connect to socket\n"); - return -1; - } - } - return sockfd.fd; - } - }; - - /** - * Exit server - */ - void exitServer(){ - Disconnect(); - CloseServerTCPSocketDescriptor(); - }; - - /** - * Shut down socket - */ - void ShutDownSocket(){ - shutdown(sockfd.fd, SHUT_RDWR); - Disconnect(); - }; - - /** - * Set the socket timeout ts is in seconds - * @param ts time in seconds - * @returns 0 for success, else -1 - */ - int SetTimeOut(int ts){ - if (ts<=0) - return -1; - - struct timeval tout; - tout.tv_sec = 0; - tout.tv_usec = 0; - if(::setsockopt(sockfd.fd, SOL_SOCKET, SO_RCVTIMEO, - &tout, sizeof(struct timeval)) <0) { - cprintf(RED, "Error in setsockopt SO_RCVTIMEO %d\n", 0); - } - tout.tv_sec = ts; - tout.tv_usec = 0; - if(::setsockopt(sockfd.fd, SOL_SOCKET, SO_SNDTIMEO, - &tout, sizeof(struct timeval)) < 0) { - cprintf(RED, "Error in setsockopt SO_SNDTIMEO %d\n", ts); - } - return 0; - }; - - /** - * Set packet size - * @param i packet size - * @returns current packet size - */ - int setPacketSize(int i=-1) { if (i>=0) packet_size=i;return packet_size;}; - - /** - * Convert IP to hostname - * @param ip IP - * @returns hostname - */ - static std::string ipToName(std::string ip) { - struct ifaddrs *addrs, *iap; - struct sockaddr_in *sa; - - char buf[32]; - const int buf_len = sizeof(buf); - memset(buf,0,buf_len); - strcpy(buf,"none"); - - getifaddrs(&addrs); - for (iap = addrs; iap != NULL; iap = iap->ifa_next) { - if (iap->ifa_addr && (iap->ifa_flags & IFF_UP) && iap->ifa_addr->sa_family == AF_INET) { - sa = (struct sockaddr_in *)(iap->ifa_addr); - inet_ntop(iap->ifa_addr->sa_family, (void *)&(sa->sin_addr), buf, buf_len); - if (ip==std::string(buf)) { - //printf("%s\n", iap->ifa_name); - strcpy(buf,iap->ifa_name); - break; - } - } - } - freeifaddrs(addrs); - return std::string(buf); - }; - - /** - * Convert interface to mac address - * @param inf interface - * @returns mac address - */ - static std::string nameToMac(std::string inf) { - struct ifreq ifr; - int sock, j, k; - char mac[32]; - const int mac_len = sizeof(mac); - memset(mac,0,mac_len); - - sock=getSock(inf,&ifr); - - if (-1==ioctl(sock, SIOCGIFHWADDR, &ifr)) { - perror("ioctl(SIOCGIFHWADDR) "); - return std::string("00:00:00:00:00:00"); - } - for (j=0, k=0; j<6; j++) { - k+=snprintf(mac+k, mac_len-k-1, j ? ":%02X" : "%02X", - (int)(unsigned int)(unsigned char)ifr.ifr_hwaddr.sa_data[j]); - } - mac[mac_len-1]='\0'; - - if(sock!=1){ - close(sock); - } - return std::string(mac); - - }; - - /** - * Convert hostname to ip - * @param inf hostname - * @returns IP - */ - static std::string nameToIp(std::string inf){ - struct ifreq ifr; - int sock; - char *p, addr[32]; - const int addr_len = sizeof(addr); - memset(addr,0,addr_len); - - sock=getSock(inf,&ifr); - - if (-1==ioctl(sock, SIOCGIFADDR, &ifr)) { - perror("ioctl(SIOCGIFADDR) "); - return std::string("0.0.0.0"); - } - p=inet_ntoa(((struct sockaddr_in *)(&ifr.ifr_addr))->sin_addr); - strncpy(addr,p,addr_len-1); - addr[addr_len-1]='\0'; - - if(sock!=1){ - close(sock); - } - return std::string(addr); - - }; - - /** - * Get socket - * @param inf hostname - * @param ifr interface request structure - * @returns sock - */ - static int getSock(std::string inf, struct ifreq *ifr) { - - int sock; - sock=socket(PF_INET, SOCK_STREAM, 0); - if (-1==sock) { - perror("socket() "); - return 1; - } - strncpy(ifr->ifr_name,inf.c_str(),sizeof(ifr->ifr_name)-1); - ifr->ifr_name[sizeof(ifr->ifr_name)-1]='\0'; - - return sock; - }; - - /** - * Convert Hostname to Internet address info structure - * One must use freeaddrinfo(res) after using it - * @param hostname hostname - * @param res address of pointer to address info structure - * @return 1 for fail, 0 for success - */ - // Do not make this static (for multi threading environment) - int ConvertHostnameToInternetAddress (const char* const hostname, struct addrinfo **res) { - // criteria in selecting socket address structures returned by res - struct addrinfo hints; - memset (&hints, 0, sizeof (hints)); - hints.ai_family = AF_INET; - hints.ai_socktype = SOCK_STREAM; - // get host info into res - int errcode = getaddrinfo (hostname, NULL, &hints, res); - if (errcode != 0) { - cprintf (RED,"Error: Could not convert %s hostname to internet address (zmq):" - "%s\n", hostname, gai_strerror(errcode)); - } else { - if (*res == NULL) { - cprintf (RED,"Error: Could not convert %s hostname to internet address (zmq): " - "gettaddrinfo returned null\n", hostname); - } else{ - return 0; - } - } - cprintf(RED, "Error: Could not convert hostname to internet address\n"); - return 1; - }; - - /** - * Convert Internet Address structure pointer to ip string (char*) - * Clears the internet address structure as well - * @param res pointer to internet address structure - * @param ip pointer to char array to store result in - * @param ipsize size available in ip buffer - * @return 1 for fail, 0 for success - */ - // Do not make this static (for multi threading environment) - int ConvertInternetAddresstoIpString (struct addrinfo *res, char* ip, const int ipsize) { - if (inet_ntop (res->ai_family, &((struct sockaddr_in *) res->ai_addr)->sin_addr, ip, ipsize) != NULL) { - freeaddrinfo(res); - return 0; - } - cprintf(RED, "Error: Could not convert internet address to ip string\n"); - return 1; - } - - /** - * Receive data only - * @param buf data - * @param length size of data expecting, 0 for a single packet - * @returns size of data received - */ - int ReceiveDataOnly(void* buf,int length=0){ - - if (buf==NULL) return -1; - - total_sent=0; - int tcpfd = sockfd.fd; - - switch(protocol) { - case TCP: - tcpfd = (is_a_server ? sockfd.newfd : sockfd.fd); - if (tcpfd<0) return -1; - while(length>0){ - nsending = (length>packet_size) ? packet_size:length; - nsent = read(tcpfd,(char*)buf+total_sent,nsending); - if(!nsent) { - if(!total_sent) { - return -1; //to handle it - } - break; - } - length-=nsent; - total_sent+=nsent; - } - - if (total_sent>0) - strcpy(thisClientIP,dummyClientIP); - - if (strcmp(lastClientIP,thisClientIP)) - differentClients=1; - else - differentClients=0; - - break; - case UDP: - if (sockfd.fd<0) return -1; - //if length given, listens to length, else listens for packetsize till length is reached - if(length){ - while(length>0){ - nsending = (length>packet_size) ? packet_size:length; - nsent = recvfrom(sockfd.fd,(char*)buf+total_sent,nsending, 0, (struct sockaddr *) &clientAddress, &clientAddress_length); - if(nsent == header_packet_size) - continue; - if(nsent != nsending){ - if(nsent && (nsent != -1)) - cprintf(RED,"Incomplete Packet size %d\n",nsent); - break; - } - length-=nsent; - total_sent+=nsent; - } - } - //listens to only 1 packet - else{ - //normal - nsending=packet_size; - while(1){ -#ifdef VERYVERBOSE - cprintf(BLUE,"%d gonna listen\n", portno); fflush(stdout); -#endif - nsent = recvfrom(sockfd.fd,(char*)buf+total_sent,nsending, 0, (struct sockaddr *) &clientAddress, &clientAddress_length); - //break out of loop only if read one packets size or read didnt work (cuz of shutdown) - if(nsent<=0 || nsent == packet_size) - break; - //incomplete packets or header packets ignored and read buffer again - if(nsent != packet_size && nsent != header_packet_size) - cprintf(RED,"%d Incomplete Packet size %d\n", portno, nsent); - } - //nsent = 1040; - if(nsent > 0)total_sent+=nsent; - } - break; - default: - ; - } -#ifdef VERY_VERBOSE - cout << "sent "<< total_sent << " Bytes" << endl; -#endif - return total_sent; - } - - /** - * Send data only - * @param buf data - * @param length size of data expecting - * @returns size of data sent - */ - int SendDataOnly(void *buf, int length) { -#ifdef VERY_VERBOSE - cout << "want to send "<< length << " Bytes" << endl; -#endif - if (buf==NULL) return -1; - - total_sent=0; - - int tcpfd = sockfd.fd; - - switch(protocol) { - case TCP: - tcpfd = (is_a_server ? sockfd.newfd : sockfd.fd); - if (tcpfd<0) return -1; - while(length>0){ - nsending = (length>packet_size) ? packet_size:length; - nsent = write(tcpfd,(char*)buf+total_sent,nsending); - if(is_a_server && nsent < 0) { - cprintf(BG_RED, "Error writing to socket. Possible client socket crash\n"); - break; - } - if(!nsent) break; - length-=nsent; - total_sent+=nsent; - } - break; - case UDP: - if (sockfd.fd<0) return -1; - while(length>0){ - nsending = (length>packet_size) ? packet_size:length; - nsent = sendto(sockfd.fd,(char*)buf+total_sent,nsending, 0, (struct sockaddr *) &clientAddress, clientAddress_length); - if(!nsent) break; - length-=nsent; - total_sent+=nsent; - } - - break; - default: - ; - } -#ifdef VERY_VERBOSE - cout << "sent "<< total_sent << " Bytes" << endl; -#endif - return total_sent; - } - - char lastClientIP[INET_ADDRSTRLEN]; - char thisClientIP[INET_ADDRSTRLEN]; - int differentClients; - -private: - /** - * Class to close socket descriptors automatically - * upon encountering exceptions in the genericSocket constructor - */ - class mySocketDescriptors { - public: - - /** Constructor */ - mySocketDescriptors():fd(-1), newfd(-1){}; - /** Destructor */ - ~mySocketDescriptors() { - // close TCP server new socket descriptor from accept - if (newfd >= 0) { - close(newfd); - } - // close socket descriptor - if (fd >= 0) { - close(fd); - } - } - /** socket descriptor */ - int fd; - /** new socket descriptor in TCP server from accept */ - int newfd; - }; - -protected: - int portno; - communicationProtocol protocol; - int is_a_server; - mySocketDescriptors sockfd; - int packet_size; - struct sockaddr_in clientAddress, serverAddress; - socklen_t clientAddress_length; - char dummyClientIP[INET_ADDRSTRLEN]; - -private: - int nsending; - int nsent; - int total_sent; - int header_packet_size; - int actual_udp_socket_buffer_size; -}; diff --git a/slsReceiverSoftware/include/gitInfoReceiver.h b/slsReceiverSoftware/include/gitInfoReceiver.h deleted file mode 100644 index cb066ae47..000000000 --- a/slsReceiverSoftware/include/gitInfoReceiver.h +++ /dev/null @@ -1,6 +0,0 @@ -#define GITURL "git@github.com:slsdetectorgroup/slsDetectorPackage.git" -#define GITREPUUID "e998226bce91a0d82ca0bb38c202d404357cf1ff" -#define GITAUTH "Dhanya_Thattil" -#define GITREV 0x4092 -#define GITDATE 0x20190408 -#define GITBRANCH "gh-pages" diff --git a/slsReceiverSoftware/include/gitInfoReceiverTmp.h b/slsReceiverSoftware/include/gitInfoReceiverTmp.h deleted file mode 100644 index dfd9bb246..000000000 --- a/slsReceiverSoftware/include/gitInfoReceiverTmp.h +++ /dev/null @@ -1,6 +0,0 @@ -#define GITURL "" -#define GITREPUUID "" -#define GITAUTH "" -#define GITREV "" -#define GITDATE "" -#define GITBRANCH "" diff --git a/slsReceiverSoftware/include/libzmq.a b/slsReceiverSoftware/include/libzmq.a deleted file mode 100644 index 0bc273d00..000000000 Binary files a/slsReceiverSoftware/include/libzmq.a and /dev/null differ diff --git a/slsReceiverSoftware/include/logger.h b/slsReceiverSoftware/include/logger.h deleted file mode 100644 index 32370605c..000000000 --- a/slsReceiverSoftware/include/logger.h +++ /dev/null @@ -1,231 +0,0 @@ -#pragma once - -#include -#include -#include -#include -#include - - - -#ifdef FIFODEBUG -#define FILELOG_MAX_LEVEL logDEBUG5 -#elif VERYVERBOSE -#define FILELOG_MAX_LEVEL logDEBUG4 -#elif VERBOSE -#define FILELOG_MAX_LEVEL logDEBUG -#endif - -#ifndef FILELOG_MAX_LEVEL -#define FILELOG_MAX_LEVEL logINFO -#endif - - -#define STRINGIFY(x) #x -#define TOSTRING(x) STRINGIFY(x) -#define MYCONCAT(x,y) -#define __AT__ std::string(__FILE__) + std::string("::") + std::string(__func__) + std::string("(): ") -#define __SHORT_FORM_OF_FILE__ \ -(strrchr(__FILE__,'/') \ -? strrchr(__FILE__,'/')+1 \ -: __FILE__ \ -) -#define __SHORT_AT__ std::string(__SHORT_FORM_OF_FILE__) + std::string("::") + std::string(__func__) + std::string("(): ") - - - - -inline std::string NowTime(); - -enum TLogLevel {logERROR, logWARNING, logINFO, logDEBUG, logDEBUG1, logDEBUG2, logDEBUG3, logDEBUG4, logDEBUG5}; - -template class Log{ - public: - Log(); - virtual ~Log(); - std::ostringstream& Get(TLogLevel level = logINFO); - static TLogLevel& ReportingLevel(); - static std::string ToString(TLogLevel level); - static TLogLevel FromString(const std::string& level); - protected: - std::ostringstream os; - TLogLevel lev; - private: - Log(const Log&); - Log& operator =(const Log&); -}; - - -class Output2FILE { -public: - static FILE*& Stream(); - static void Output(const std::string& msg); - static void Output(const std::string& msg, TLogLevel level); -}; - -#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) -# if defined (BUILDING_FILELOG_DLL) -# define FILELOG_DECLSPEC __declspec (dllexport) -# elif defined (USING_FILELOG_DLL) -# define FILELOG_DECLSPEC __declspec (dllimport) -# else -# define FILELOG_DECLSPEC -# endif // BUILDING_DBSIMPLE_DLL -#else -# define FILELOG_DECLSPEC -#endif // _WIN32 - -class FILELOG_DECLSPEC FILELog : public Log {}; -//typedef Log FILELog; - -#define FILE_LOG(level) \ - if (level > FILELOG_MAX_LEVEL) ; \ - else if (level > FILELog::ReportingLevel() || !Output2FILE::Stream()) ; \ - else FILELog().Get(level) - - -#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) - -#include - - - -inline std::string NowTime() - -{ - const int MAX_LEN = 200; - char buffer[MAX_LEN]; - if (GetTimeFormatA(LOCALE_USER_DEFAULT, 0, 0, - "HH':'mm':'ss", buffer, MAX_LEN) == 0) - return "Error in NowTime()"; - - char result[100] = {0}; - static DWORD first = GetTickCount(); - sprintf(result, "%s.%03ld", buffer, (long)(GetTickCount() - first) % 1000); - return result; -} - -#else - -#include - -inline std::string NowTime() -{ - char buffer[11]; - const int buffer_len = sizeof(buffer); - time_t t; - time(&t); - tm r; - strftime(buffer, buffer_len, "%X", localtime_r(&t, &r)); - buffer[buffer_len - 1] = 0; - struct timeval tv; - gettimeofday(&tv, 0); - char result[100]; - const int result_len = sizeof(result); - snprintf(result, result_len, "%s.%03ld", buffer, (long)tv.tv_usec / 1000); - result[result_len - 1] = 0; - return result; -} - -#endif //WIN32 - - -template Log::Log():lev(logDEBUG){} - -template std::ostringstream& Log::Get(TLogLevel level) -{ - lev = level; - os << "- " << NowTime(); - os << " " << ToString(level) << ": "; - if (level > logDEBUG) - os << std::string(level - logDEBUG, '\t'); - return os; -} - -template Log::~Log() -{ - os << std::endl; - T::Output( os.str(),lev); // T::Output( os.str()); -} - -template TLogLevel& Log::ReportingLevel() -{ - static TLogLevel reportingLevel = logDEBUG5; - return reportingLevel; -} - -template std::string Log::ToString(TLogLevel level) -{ - static const char* const buffer[] = {"ERROR", "WARNING", "INFO", "DEBUG", "DEBUG1", "DEBUG2", "DEBUG3", "DEBUG4","DEBUG5"}; - return buffer[level]; -} - -template -TLogLevel Log::FromString(const std::string& level) -{ - if (level == "DEBUG5") - return logDEBUG5; - if (level == "DEBUG4") - return logDEBUG4; - if (level == "DEBUG3") - return logDEBUG3; - if (level == "DEBUG2") - return logDEBUG2; - if (level == "DEBUG1") - return logDEBUG1; - if (level == "DEBUG") - return logDEBUG; - if (level == "INFO") - return logINFO; - if (level == "WARNING") - return logWARNING; - if (level == "ERROR") - return logERROR; - Log().Get(logWARNING) << "Unknown logging level '" << level << "'. Using INFO level as default."; - return logINFO; -} - - -inline FILE*& Output2FILE::Stream() -{ - static FILE* pStream = stderr; - return pStream; -} - -inline void Output2FILE::Output(const std::string& msg) -{ - FILE* pStream = Stream(); - if (!pStream) - return; - fprintf(pStream, "%s", msg.c_str()); - fflush(pStream); -} - -inline void Output2FILE::Output(const std::string& msg, TLogLevel level) -{ - FILE* pStream = Stream(); - if (!pStream) - return; - bool out = true; - switch(level){ - case logERROR: cprintf(RED BOLD,"%s",msg.c_str()); break; - case logWARNING: cprintf(YELLOW BOLD,"%s",msg.c_str()); break; - case logINFO: cprintf(RESET,"%s",msg.c_str()); break; - default: fprintf(pStream,"%s",msg.c_str()); out = false; break; - } - fflush(out ? stdout : pStream); -} - -#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) -# if defined (BUILDING_FILELOG_DLL) -# define FILELOG_DECLSPEC __declspec (dllexport) -# elif defined (USING_FILELOG_DLL) -# define FILELOG_DECLSPEC __declspec (dllimport) -# else -# define FILELOG_DECLSPEC -# endif // BUILDING_DBSIMPLE_DLL -#else -# define FILELOG_DECLSPEC -#endif // _WIN32 - - diff --git a/slsReceiverSoftware/include/rapidjson/allocators.h b/slsReceiverSoftware/include/rapidjson/allocators.h deleted file mode 100644 index 98affe03f..000000000 --- a/slsReceiverSoftware/include/rapidjson/allocators.h +++ /dev/null @@ -1,271 +0,0 @@ -// Tencent is pleased to support the open source community by making RapidJSON available. -// -// Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved. -// -// Licensed under the MIT License (the "License"); you may not use this file except -// in compliance with the License. You may obtain a copy of the License at -// -// http://opensource.org/licenses/MIT -// -// Unless required by applicable law or agreed to in writing, software distributed -// under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR -// CONDITIONS OF ANY KIND, either express or implied. See the License for the -// specific language governing permissions and limitations under the License. - -#ifndef RAPIDJSON_ALLOCATORS_H_ -#define RAPIDJSON_ALLOCATORS_H_ - -#include "rapidjson.h" - -RAPIDJSON_NAMESPACE_BEGIN - -/////////////////////////////////////////////////////////////////////////////// -// Allocator - -/*! \class rapidjson::Allocator - \brief Concept for allocating, resizing and freeing memory block. - - Note that Malloc() and Realloc() are non-static but Free() is static. - - So if an allocator need to support Free(), it needs to put its pointer in - the header of memory block. - -\code -concept Allocator { - static const bool kNeedFree; //!< Whether this allocator needs to call Free(). - - // Allocate a memory block. - // \param size of the memory block in bytes. - // \returns pointer to the memory block. - void* Malloc(size_t size); - - // Resize a memory block. - // \param originalPtr The pointer to current memory block. Null pointer is permitted. - // \param originalSize The current size in bytes. (Design issue: since some allocator may not book-keep this, explicitly pass to it can save memory.) - // \param newSize the new size in bytes. - void* Realloc(void* originalPtr, size_t originalSize, size_t newSize); - - // Free a memory block. - // \param pointer to the memory block. Null pointer is permitted. - static void Free(void *ptr); -}; -\endcode -*/ - -/////////////////////////////////////////////////////////////////////////////// -// CrtAllocator - -//! C-runtime library allocator. -/*! This class is just wrapper for standard C library memory routines. - \note implements Allocator concept -*/ -class CrtAllocator { -public: - static const bool kNeedFree = true; - void* Malloc(size_t size) { - if (size) // behavior of malloc(0) is implementation defined. - return std::malloc(size); - else - return NULL; // standardize to returning NULL. - } - void* Realloc(void* originalPtr, size_t originalSize, size_t newSize) { - (void)originalSize; - if (newSize == 0) { - std::free(originalPtr); - return NULL; - } - return std::realloc(originalPtr, newSize); - } - static void Free(void *ptr) { std::free(ptr); } -}; - -/////////////////////////////////////////////////////////////////////////////// -// MemoryPoolAllocator - -//! Default memory allocator used by the parser and DOM. -/*! This allocator allocate memory blocks from pre-allocated memory chunks. - - It does not free memory blocks. And Realloc() only allocate new memory. - - The memory chunks are allocated by BaseAllocator, which is CrtAllocator by default. - - User may also supply a buffer as the first chunk. - - If the user-buffer is full then additional chunks are allocated by BaseAllocator. - - The user-buffer is not deallocated by this allocator. - - \tparam BaseAllocator the allocator type for allocating memory chunks. Default is CrtAllocator. - \note implements Allocator concept -*/ -template -class MemoryPoolAllocator { -public: - static const bool kNeedFree = false; //!< Tell users that no need to call Free() with this allocator. (concept Allocator) - - //! Constructor with chunkSize. - /*! \param chunkSize The size of memory chunk. The default is kDefaultChunkSize. - \param baseAllocator The allocator for allocating memory chunks. - */ - MemoryPoolAllocator(size_t chunkSize = kDefaultChunkCapacity, BaseAllocator* baseAllocator = 0) : - chunkHead_(0), chunk_capacity_(chunkSize), userBuffer_(0), baseAllocator_(baseAllocator), ownBaseAllocator_(0) - { - } - - //! Constructor with user-supplied buffer. - /*! The user buffer will be used firstly. When it is full, memory pool allocates new chunk with chunk size. - - The user buffer will not be deallocated when this allocator is destructed. - - \param buffer User supplied buffer. - \param size Size of the buffer in bytes. It must at least larger than sizeof(ChunkHeader). - \param chunkSize The size of memory chunk. The default is kDefaultChunkSize. - \param baseAllocator The allocator for allocating memory chunks. - */ - MemoryPoolAllocator(void *buffer, size_t size, size_t chunkSize = kDefaultChunkCapacity, BaseAllocator* baseAllocator = 0) : - chunkHead_(0), chunk_capacity_(chunkSize), userBuffer_(buffer), baseAllocator_(baseAllocator), ownBaseAllocator_(0) - { - RAPIDJSON_ASSERT(buffer != 0); - RAPIDJSON_ASSERT(size > sizeof(ChunkHeader)); - chunkHead_ = reinterpret_cast(buffer); - chunkHead_->capacity = size - sizeof(ChunkHeader); - chunkHead_->size = 0; - chunkHead_->next = 0; - } - - //! Destructor. - /*! This deallocates all memory chunks, excluding the user-supplied buffer. - */ - ~MemoryPoolAllocator() { - Clear(); - RAPIDJSON_DELETE(ownBaseAllocator_); - } - - //! Deallocates all memory chunks, excluding the user-supplied buffer. - void Clear() { - while (chunkHead_ && chunkHead_ != userBuffer_) { - ChunkHeader* next = chunkHead_->next; - baseAllocator_->Free(chunkHead_); - chunkHead_ = next; - } - if (chunkHead_ && chunkHead_ == userBuffer_) - chunkHead_->size = 0; // Clear user buffer - } - - //! Computes the total capacity of allocated memory chunks. - /*! \return total capacity in bytes. - */ - size_t Capacity() const { - size_t capacity = 0; - for (ChunkHeader* c = chunkHead_; c != 0; c = c->next) - capacity += c->capacity; - return capacity; - } - - //! Computes the memory blocks allocated. - /*! \return total used bytes. - */ - size_t Size() const { - size_t size = 0; - for (ChunkHeader* c = chunkHead_; c != 0; c = c->next) - size += c->size; - return size; - } - - //! Allocates a memory block. (concept Allocator) - void* Malloc(size_t size) { - if (!size) - return NULL; - - size = RAPIDJSON_ALIGN(size); - if (chunkHead_ == 0 || chunkHead_->size + size > chunkHead_->capacity) - if (!AddChunk(chunk_capacity_ > size ? chunk_capacity_ : size)) - return NULL; - - void *buffer = reinterpret_cast(chunkHead_) + RAPIDJSON_ALIGN(sizeof(ChunkHeader)) + chunkHead_->size; - chunkHead_->size += size; - return buffer; - } - - //! Resizes a memory block (concept Allocator) - void* Realloc(void* originalPtr, size_t originalSize, size_t newSize) { - if (originalPtr == 0) - return Malloc(newSize); - - if (newSize == 0) - return NULL; - - originalSize = RAPIDJSON_ALIGN(originalSize); - newSize = RAPIDJSON_ALIGN(newSize); - - // Do not shrink if new size is smaller than original - if (originalSize >= newSize) - return originalPtr; - - // Simply expand it if it is the last allocation and there is sufficient space - if (originalPtr == reinterpret_cast(chunkHead_) + RAPIDJSON_ALIGN(sizeof(ChunkHeader)) + chunkHead_->size - originalSize) { - size_t increment = static_cast(newSize - originalSize); - if (chunkHead_->size + increment <= chunkHead_->capacity) { - chunkHead_->size += increment; - return originalPtr; - } - } - - // Realloc process: allocate and copy memory, do not free original buffer. - if (void* newBuffer = Malloc(newSize)) { - if (originalSize) - std::memcpy(newBuffer, originalPtr, originalSize); - return newBuffer; - } - else - return NULL; - } - - //! Frees a memory block (concept Allocator) - static void Free(void *ptr) { (void)ptr; } // Do nothing - -private: - //! Copy constructor is not permitted. - MemoryPoolAllocator(const MemoryPoolAllocator& rhs) /* = delete */; - //! Copy assignment operator is not permitted. - MemoryPoolAllocator& operator=(const MemoryPoolAllocator& rhs) /* = delete */; - - //! Creates a new chunk. - /*! \param capacity Capacity of the chunk in bytes. - \return true if success. - */ - bool AddChunk(size_t capacity) { - if (!baseAllocator_) - ownBaseAllocator_ = baseAllocator_ = RAPIDJSON_NEW(BaseAllocator()); - if (ChunkHeader* chunk = reinterpret_cast(baseAllocator_->Malloc(RAPIDJSON_ALIGN(sizeof(ChunkHeader)) + capacity))) { - chunk->capacity = capacity; - chunk->size = 0; - chunk->next = chunkHead_; - chunkHead_ = chunk; - return true; - } - else - return false; - } - - static const int kDefaultChunkCapacity = 64 * 1024; //!< Default chunk capacity. - - //! Chunk header for perpending to each chunk. - /*! Chunks are stored as a singly linked list. - */ - struct ChunkHeader { - size_t capacity; //!< Capacity of the chunk in bytes (excluding the header itself). - size_t size; //!< Current size of allocated memory in bytes. - ChunkHeader *next; //!< Next chunk in the linked list. - }; - - ChunkHeader *chunkHead_; //!< Head of the chunk linked-list. Only the head chunk serves allocation. - size_t chunk_capacity_; //!< The minimum capacity of chunk when they are allocated. - void *userBuffer_; //!< User supplied buffer. - BaseAllocator* baseAllocator_; //!< base allocator for allocating memory chunks. - BaseAllocator* ownBaseAllocator_; //!< base allocator created by this object. -}; - -RAPIDJSON_NAMESPACE_END - -#endif // RAPIDJSON_ENCODINGS_H_ diff --git a/slsReceiverSoftware/include/rapidjson/document.h b/slsReceiverSoftware/include/rapidjson/document.h deleted file mode 100644 index e3e20dfbd..000000000 --- a/slsReceiverSoftware/include/rapidjson/document.h +++ /dev/null @@ -1,2575 +0,0 @@ -// Tencent is pleased to support the open source community by making RapidJSON available. -// -// Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved. -// -// Licensed under the MIT License (the "License"); you may not use this file except -// in compliance with the License. You may obtain a copy of the License at -// -// http://opensource.org/licenses/MIT -// -// Unless required by applicable law or agreed to in writing, software distributed -// under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR -// CONDITIONS OF ANY KIND, either express or implied. See the License for the -// specific language governing permissions and limitations under the License. - -#ifndef RAPIDJSON_DOCUMENT_H_ -#define RAPIDJSON_DOCUMENT_H_ - -/*! \file document.h */ - -#include "reader.h" -#include "internal/meta.h" -#include "internal/strfunc.h" -#include "memorystream.h" -#include "encodedstream.h" -#include // placement new -#include - -RAPIDJSON_DIAG_PUSH -#ifdef _MSC_VER -RAPIDJSON_DIAG_OFF(4127) // conditional expression is constant -RAPIDJSON_DIAG_OFF(4244) // conversion from kXxxFlags to 'uint16_t', possible loss of data -#endif - -#ifdef __clang__ -RAPIDJSON_DIAG_OFF(padded) -RAPIDJSON_DIAG_OFF(switch-enum) -RAPIDJSON_DIAG_OFF(c++98-compat) -#endif - -#ifdef __GNUC__ -RAPIDJSON_DIAG_OFF(effc++) -#if __GNUC__ >= 6 -RAPIDJSON_DIAG_OFF(terminate) // ignore throwing RAPIDJSON_ASSERT in RAPIDJSON_NOEXCEPT functions -#endif -#endif // __GNUC__ - -#ifndef RAPIDJSON_NOMEMBERITERATORCLASS -#include // std::iterator, std::random_access_iterator_tag -#endif - -#if RAPIDJSON_HAS_CXX11_RVALUE_REFS -#include // std::move -#endif - -RAPIDJSON_NAMESPACE_BEGIN - -// Forward declaration. -template -class GenericValue; - -template -class GenericDocument; - -//! Name-value pair in a JSON object value. -/*! - This class was internal to GenericValue. It used to be a inner struct. - But a compiler (IBM XL C/C++ for AIX) have reported to have problem with that so it moved as a namespace scope struct. - https://code.google.com/p/rapidjson/issues/detail?id=64 -*/ -template -struct GenericMember { - GenericValue name; //!< name of member (must be a string) - GenericValue value; //!< value of member. -}; - -/////////////////////////////////////////////////////////////////////////////// -// GenericMemberIterator - -#ifndef RAPIDJSON_NOMEMBERITERATORCLASS - -//! (Constant) member iterator for a JSON object value -/*! - \tparam Const Is this a constant iterator? - \tparam Encoding Encoding of the value. (Even non-string values need to have the same encoding in a document) - \tparam Allocator Allocator type for allocating memory of object, array and string. - - This class implements a Random Access Iterator for GenericMember elements - of a GenericValue, see ISO/IEC 14882:2003(E) C++ standard, 24.1 [lib.iterator.requirements]. - - \note This iterator implementation is mainly intended to avoid implicit - conversions from iterator values to \c NULL, - e.g. from GenericValue::FindMember. - - \note Define \c RAPIDJSON_NOMEMBERITERATORCLASS to fall back to a - pointer-based implementation, if your platform doesn't provide - the C++ header. - - \see GenericMember, GenericValue::MemberIterator, GenericValue::ConstMemberIterator - */ -template -class GenericMemberIterator - : public std::iterator >::Type> { - - friend class GenericValue; - template friend class GenericMemberIterator; - - typedef GenericMember PlainType; - typedef typename internal::MaybeAddConst::Type ValueType; - typedef std::iterator BaseType; - -public: - //! Iterator type itself - typedef GenericMemberIterator Iterator; - //! Constant iterator type - typedef GenericMemberIterator ConstIterator; - //! Non-constant iterator type - typedef GenericMemberIterator NonConstIterator; - - //! Pointer to (const) GenericMember - typedef typename BaseType::pointer Pointer; - //! Reference to (const) GenericMember - typedef typename BaseType::reference Reference; - //! Signed integer type (e.g. \c ptrdiff_t) - typedef typename BaseType::difference_type DifferenceType; - - //! Default constructor (singular value) - /*! Creates an iterator pointing to no element. - \note All operations, except for comparisons, are undefined on such values. - */ - GenericMemberIterator() : ptr_() {} - - //! Iterator conversions to more const - /*! - \param it (Non-const) iterator to copy from - - Allows the creation of an iterator from another GenericMemberIterator - that is "less const". Especially, creating a non-constant iterator - from a constant iterator are disabled: - \li const -> non-const (not ok) - \li const -> const (ok) - \li non-const -> const (ok) - \li non-const -> non-const (ok) - - \note If the \c Const template parameter is already \c false, this - constructor effectively defines a regular copy-constructor. - Otherwise, the copy constructor is implicitly defined. - */ - GenericMemberIterator(const NonConstIterator & it) : ptr_(it.ptr_) {} - Iterator& operator=(const NonConstIterator & it) { ptr_ = it.ptr_; return *this; } - - //! @name stepping - //@{ - Iterator& operator++(){ ++ptr_; return *this; } - Iterator& operator--(){ --ptr_; return *this; } - Iterator operator++(int){ Iterator old(*this); ++ptr_; return old; } - Iterator operator--(int){ Iterator old(*this); --ptr_; return old; } - //@} - - //! @name increment/decrement - //@{ - Iterator operator+(DifferenceType n) const { return Iterator(ptr_+n); } - Iterator operator-(DifferenceType n) const { return Iterator(ptr_-n); } - - Iterator& operator+=(DifferenceType n) { ptr_+=n; return *this; } - Iterator& operator-=(DifferenceType n) { ptr_-=n; return *this; } - //@} - - //! @name relations - //@{ - bool operator==(ConstIterator that) const { return ptr_ == that.ptr_; } - bool operator!=(ConstIterator that) const { return ptr_ != that.ptr_; } - bool operator<=(ConstIterator that) const { return ptr_ <= that.ptr_; } - bool operator>=(ConstIterator that) const { return ptr_ >= that.ptr_; } - bool operator< (ConstIterator that) const { return ptr_ < that.ptr_; } - bool operator> (ConstIterator that) const { return ptr_ > that.ptr_; } - //@} - - //! @name dereference - //@{ - Reference operator*() const { return *ptr_; } - Pointer operator->() const { return ptr_; } - Reference operator[](DifferenceType n) const { return ptr_[n]; } - //@} - - //! Distance - DifferenceType operator-(ConstIterator that) const { return ptr_-that.ptr_; } - -private: - //! Internal constructor from plain pointer - explicit GenericMemberIterator(Pointer p) : ptr_(p) {} - - Pointer ptr_; //!< raw pointer -}; - -#else // RAPIDJSON_NOMEMBERITERATORCLASS - -// class-based member iterator implementation disabled, use plain pointers - -template -struct GenericMemberIterator; - -//! non-const GenericMemberIterator -template -struct GenericMemberIterator { - //! use plain pointer as iterator type - typedef GenericMember* Iterator; -}; -//! const GenericMemberIterator -template -struct GenericMemberIterator { - //! use plain const pointer as iterator type - typedef const GenericMember* Iterator; -}; - -#endif // RAPIDJSON_NOMEMBERITERATORCLASS - -/////////////////////////////////////////////////////////////////////////////// -// GenericStringRef - -//! Reference to a constant string (not taking a copy) -/*! - \tparam CharType character type of the string - - This helper class is used to automatically infer constant string - references for string literals, especially from \c const \b (!) - character arrays. - - The main use is for creating JSON string values without copying the - source string via an \ref Allocator. This requires that the referenced - string pointers have a sufficient lifetime, which exceeds the lifetime - of the associated GenericValue. - - \b Example - \code - Value v("foo"); // ok, no need to copy & calculate length - const char foo[] = "foo"; - v.SetString(foo); // ok - - const char* bar = foo; - // Value x(bar); // not ok, can't rely on bar's lifetime - Value x(StringRef(bar)); // lifetime explicitly guaranteed by user - Value y(StringRef(bar, 3)); // ok, explicitly pass length - \endcode - - \see StringRef, GenericValue::SetString -*/ -template -struct GenericStringRef { - typedef CharType Ch; //!< character type of the string - - //! Create string reference from \c const character array -#ifndef __clang__ // -Wdocumentation - /*! - This constructor implicitly creates a constant string reference from - a \c const character array. It has better performance than - \ref StringRef(const CharType*) by inferring the string \ref length - from the array length, and also supports strings containing null - characters. - - \tparam N length of the string, automatically inferred - - \param str Constant character array, lifetime assumed to be longer - than the use of the string in e.g. a GenericValue - - \post \ref s == str - - \note Constant complexity. - \note There is a hidden, private overload to disallow references to - non-const character arrays to be created via this constructor. - By this, e.g. function-scope arrays used to be filled via - \c snprintf are excluded from consideration. - In such cases, the referenced string should be \b copied to the - GenericValue instead. - */ -#endif - template - GenericStringRef(const CharType (&str)[N]) RAPIDJSON_NOEXCEPT - : s(str), length(N-1) {} - - //! Explicitly create string reference from \c const character pointer -#ifndef __clang__ // -Wdocumentation - /*! - This constructor can be used to \b explicitly create a reference to - a constant string pointer. - - \see StringRef(const CharType*) - - \param str Constant character pointer, lifetime assumed to be longer - than the use of the string in e.g. a GenericValue - - \post \ref s == str - - \note There is a hidden, private overload to disallow references to - non-const character arrays to be created via this constructor. - By this, e.g. function-scope arrays used to be filled via - \c snprintf are excluded from consideration. - In such cases, the referenced string should be \b copied to the - GenericValue instead. - */ -#endif - explicit GenericStringRef(const CharType* str) - : s(str), length(internal::StrLen(str)){ RAPIDJSON_ASSERT(s != 0); } - - //! Create constant string reference from pointer and length -#ifndef __clang__ // -Wdocumentation - /*! \param str constant string, lifetime assumed to be longer than the use of the string in e.g. a GenericValue - \param len length of the string, excluding the trailing NULL terminator - - \post \ref s == str && \ref length == len - \note Constant complexity. - */ -#endif - GenericStringRef(const CharType* str, SizeType len) - : s(str), length(len) { RAPIDJSON_ASSERT(s != 0); } - - GenericStringRef(const GenericStringRef& rhs) : s(rhs.s), length(rhs.length) {} - - GenericStringRef& operator=(const GenericStringRef& rhs) { s = rhs.s; length = rhs.length; } - - //! implicit conversion to plain CharType pointer - operator const Ch *() const { return s; } - - const Ch* const s; //!< plain CharType pointer - const SizeType length; //!< length of the string (excluding the trailing NULL terminator) - -private: - //! Disallow construction from non-const array - template - GenericStringRef(CharType (&str)[N]) /* = delete */; -}; - -//! Mark a character pointer as constant string -/*! Mark a plain character pointer as a "string literal". This function - can be used to avoid copying a character string to be referenced as a - value in a JSON GenericValue object, if the string's lifetime is known - to be valid long enough. - \tparam CharType Character type of the string - \param str Constant string, lifetime assumed to be longer than the use of the string in e.g. a GenericValue - \return GenericStringRef string reference object - \relatesalso GenericStringRef - - \see GenericValue::GenericValue(StringRefType), GenericValue::operator=(StringRefType), GenericValue::SetString(StringRefType), GenericValue::PushBack(StringRefType, Allocator&), GenericValue::AddMember -*/ -template -inline GenericStringRef StringRef(const CharType* str) { - return GenericStringRef(str, internal::StrLen(str)); -} - -//! Mark a character pointer as constant string -/*! Mark a plain character pointer as a "string literal". This function - can be used to avoid copying a character string to be referenced as a - value in a JSON GenericValue object, if the string's lifetime is known - to be valid long enough. - - This version has better performance with supplied length, and also - supports string containing null characters. - - \tparam CharType character type of the string - \param str Constant string, lifetime assumed to be longer than the use of the string in e.g. a GenericValue - \param length The length of source string. - \return GenericStringRef string reference object - \relatesalso GenericStringRef -*/ -template -inline GenericStringRef StringRef(const CharType* str, size_t length) { - return GenericStringRef(str, SizeType(length)); -} - -#if RAPIDJSON_HAS_STDSTRING -//! Mark a string object as constant string -/*! Mark a string object (e.g. \c std::string) as a "string literal". - This function can be used to avoid copying a string to be referenced as a - value in a JSON GenericValue object, if the string's lifetime is known - to be valid long enough. - - \tparam CharType character type of the string - \param str Constant string, lifetime assumed to be longer than the use of the string in e.g. a GenericValue - \return GenericStringRef string reference object - \relatesalso GenericStringRef - \note Requires the definition of the preprocessor symbol \ref RAPIDJSON_HAS_STDSTRING. -*/ -template -inline GenericStringRef StringRef(const std::basic_string& str) { - return GenericStringRef(str.data(), SizeType(str.size())); -} -#endif - -/////////////////////////////////////////////////////////////////////////////// -// GenericValue type traits -namespace internal { - -template -struct IsGenericValueImpl : FalseType {}; - -// select candidates according to nested encoding and allocator types -template struct IsGenericValueImpl::Type, typename Void::Type> - : IsBaseOf, T>::Type {}; - -// helper to match arbitrary GenericValue instantiations, including derived classes -template struct IsGenericValue : IsGenericValueImpl::Type {}; - -} // namespace internal - -/////////////////////////////////////////////////////////////////////////////// -// TypeHelper - -namespace internal { - -template -struct TypeHelper {}; - -template -struct TypeHelper { - static bool Is(const ValueType& v) { return v.IsBool(); } - static bool Get(const ValueType& v) { return v.GetBool(); } - static ValueType& Set(ValueType& v, bool data) { return v.SetBool(data); } - static ValueType& Set(ValueType& v, bool data, typename ValueType::AllocatorType&) { return v.SetBool(data); } -}; - -template -struct TypeHelper { - static bool Is(const ValueType& v) { return v.IsInt(); } - static int Get(const ValueType& v) { return v.GetInt(); } - static ValueType& Set(ValueType& v, int data) { return v.SetInt(data); } - static ValueType& Set(ValueType& v, int data, typename ValueType::AllocatorType&) { return v.SetInt(data); } -}; - -template -struct TypeHelper { - static bool Is(const ValueType& v) { return v.IsUint(); } - static unsigned Get(const ValueType& v) { return v.GetUint(); } - static ValueType& Set(ValueType& v, unsigned data) { return v.SetUint(data); } - static ValueType& Set(ValueType& v, unsigned data, typename ValueType::AllocatorType&) { return v.SetUint(data); } -}; - -template -struct TypeHelper { - static bool Is(const ValueType& v) { return v.IsInt64(); } - static int64_t Get(const ValueType& v) { return v.GetInt64(); } - static ValueType& Set(ValueType& v, int64_t data) { return v.SetInt64(data); } - static ValueType& Set(ValueType& v, int64_t data, typename ValueType::AllocatorType&) { return v.SetInt64(data); } -}; - -template -struct TypeHelper { - static bool Is(const ValueType& v) { return v.IsUint64(); } - static uint64_t Get(const ValueType& v) { return v.GetUint64(); } - static ValueType& Set(ValueType& v, uint64_t data) { return v.SetUint64(data); } - static ValueType& Set(ValueType& v, uint64_t data, typename ValueType::AllocatorType&) { return v.SetUint64(data); } -}; - -template -struct TypeHelper { - static bool Is(const ValueType& v) { return v.IsDouble(); } - static double Get(const ValueType& v) { return v.GetDouble(); } - static ValueType& Set(ValueType& v, double data) { return v.SetDouble(data); } - static ValueType& Set(ValueType& v, double data, typename ValueType::AllocatorType&) { return v.SetDouble(data); } -}; - -template -struct TypeHelper { - static bool Is(const ValueType& v) { return v.IsFloat(); } - static float Get(const ValueType& v) { return v.GetFloat(); } - static ValueType& Set(ValueType& v, float data) { return v.SetFloat(data); } - static ValueType& Set(ValueType& v, float data, typename ValueType::AllocatorType&) { return v.SetFloat(data); } -}; - -template -struct TypeHelper { - typedef const typename ValueType::Ch* StringType; - static bool Is(const ValueType& v) { return v.IsString(); } - static StringType Get(const ValueType& v) { return v.GetString(); } - static ValueType& Set(ValueType& v, const StringType data) { return v.SetString(typename ValueType::StringRefType(data)); } - static ValueType& Set(ValueType& v, const StringType data, typename ValueType::AllocatorType& a) { return v.SetString(data, a); } -}; - -#if RAPIDJSON_HAS_STDSTRING -template -struct TypeHelper > { - typedef std::basic_string StringType; - static bool Is(const ValueType& v) { return v.IsString(); } - static StringType Get(const ValueType& v) { return StringType(v.GetString(), v.GetStringLength()); } - static ValueType& Set(ValueType& v, const StringType& data, typename ValueType::AllocatorType& a) { return v.SetString(data, a); } -}; -#endif - -template -struct TypeHelper { - typedef typename ValueType::Array ArrayType; - static bool Is(const ValueType& v) { return v.IsArray(); } - static ArrayType Get(ValueType& v) { return v.GetArray(); } - static ValueType& Set(ValueType& v, ArrayType data) { return v = data; } - static ValueType& Set(ValueType& v, ArrayType data, typename ValueType::AllocatorType&) { return v = data; } -}; - -template -struct TypeHelper { - typedef typename ValueType::ConstArray ArrayType; - static bool Is(const ValueType& v) { return v.IsArray(); } - static ArrayType Get(const ValueType& v) { return v.GetArray(); } -}; - -template -struct TypeHelper { - typedef typename ValueType::Object ObjectType; - static bool Is(const ValueType& v) { return v.IsObject(); } - static ObjectType Get(ValueType& v) { return v.GetObject(); } - static ValueType& Set(ValueType& v, ObjectType data) { return v = data; } - static ValueType& Set(ValueType& v, ObjectType data, typename ValueType::AllocatorType&) { v = data; } -}; - -template -struct TypeHelper { - typedef typename ValueType::ConstObject ObjectType; - static bool Is(const ValueType& v) { return v.IsObject(); } - static ObjectType Get(const ValueType& v) { return v.GetObject(); } -}; - -} // namespace internal - -// Forward declarations -template class GenericArray; -template class GenericObject; - -/////////////////////////////////////////////////////////////////////////////// -// GenericValue - -//! Represents a JSON value. Use Value for UTF8 encoding and default allocator. -/*! - A JSON value can be one of 7 types. This class is a variant type supporting - these types. - - Use the Value if UTF8 and default allocator - - \tparam Encoding Encoding of the value. (Even non-string values need to have the same encoding in a document) - \tparam Allocator Allocator type for allocating memory of object, array and string. -*/ -template > -class GenericValue { -public: - //! Name-value pair in an object. - typedef GenericMember Member; - typedef Encoding EncodingType; //!< Encoding type from template parameter. - typedef Allocator AllocatorType; //!< Allocator type from template parameter. - typedef typename Encoding::Ch Ch; //!< Character type derived from Encoding. - typedef GenericStringRef StringRefType; //!< Reference to a constant string - typedef typename GenericMemberIterator::Iterator MemberIterator; //!< Member iterator for iterating in object. - typedef typename GenericMemberIterator::Iterator ConstMemberIterator; //!< Constant member iterator for iterating in object. - typedef GenericValue* ValueIterator; //!< Value iterator for iterating in array. - typedef const GenericValue* ConstValueIterator; //!< Constant value iterator for iterating in array. - typedef GenericValue ValueType; //!< Value type of itself. - typedef GenericArray Array; - typedef GenericArray ConstArray; - typedef GenericObject Object; - typedef GenericObject ConstObject; - - //!@name Constructors and destructor. - //@{ - - //! Default constructor creates a null value. - GenericValue() RAPIDJSON_NOEXCEPT : data_() { data_.f.flags = kNullFlag; } - -#if RAPIDJSON_HAS_CXX11_RVALUE_REFS - //! Move constructor in C++11 - GenericValue(GenericValue&& rhs) RAPIDJSON_NOEXCEPT : data_(rhs.data_) { - rhs.data_.f.flags = kNullFlag; // give up contents - } -#endif - -private: - //! Copy constructor is not permitted. - GenericValue(const GenericValue& rhs); - -#if RAPIDJSON_HAS_CXX11_RVALUE_REFS - //! Moving from a GenericDocument is not permitted. - template - GenericValue(GenericDocument&& rhs); - - //! Move assignment from a GenericDocument is not permitted. - template - GenericValue& operator=(GenericDocument&& rhs); -#endif - -public: - - //! Constructor with JSON value type. - /*! This creates a Value of specified type with default content. - \param type Type of the value. - \note Default content for number is zero. - */ - explicit GenericValue(Type type) RAPIDJSON_NOEXCEPT : data_() { - static const uint16_t defaultFlags[7] = { - kNullFlag, kFalseFlag, kTrueFlag, kObjectFlag, kArrayFlag, kShortStringFlag, - kNumberAnyFlag - }; - RAPIDJSON_ASSERT(type <= kNumberType); - data_.f.flags = defaultFlags[type]; - - // Use ShortString to store empty string. - if (type == kStringType) - data_.ss.SetLength(0); - } - - //! Explicit copy constructor (with allocator) - /*! Creates a copy of a Value by using the given Allocator - \tparam SourceAllocator allocator of \c rhs - \param rhs Value to copy from (read-only) - \param allocator Allocator for allocating copied elements and buffers. Commonly use GenericDocument::GetAllocator(). - \see CopyFrom() - */ - template< typename SourceAllocator > - GenericValue(const GenericValue& rhs, Allocator & allocator); - - //! Constructor for boolean value. - /*! \param b Boolean value - \note This constructor is limited to \em real boolean values and rejects - implicitly converted types like arbitrary pointers. Use an explicit cast - to \c bool, if you want to construct a boolean JSON value in such cases. - */ -#ifndef RAPIDJSON_DOXYGEN_RUNNING // hide SFINAE from Doxygen - template - explicit GenericValue(T b, RAPIDJSON_ENABLEIF((internal::IsSame))) RAPIDJSON_NOEXCEPT // See #472 -#else - explicit GenericValue(bool b) RAPIDJSON_NOEXCEPT -#endif - : data_() { - // safe-guard against failing SFINAE - RAPIDJSON_STATIC_ASSERT((internal::IsSame::Value)); - data_.f.flags = b ? kTrueFlag : kFalseFlag; - } - - //! Constructor for int value. - explicit GenericValue(int i) RAPIDJSON_NOEXCEPT : data_() { - data_.n.i64 = i; - data_.f.flags = (i >= 0) ? (kNumberIntFlag | kUintFlag | kUint64Flag) : kNumberIntFlag; - } - - //! Constructor for unsigned value. - explicit GenericValue(unsigned u) RAPIDJSON_NOEXCEPT : data_() { - data_.n.u64 = u; - data_.f.flags = (u & 0x80000000) ? kNumberUintFlag : (kNumberUintFlag | kIntFlag | kInt64Flag); - } - - //! Constructor for int64_t value. - explicit GenericValue(int64_t i64) RAPIDJSON_NOEXCEPT : data_() { - data_.n.i64 = i64; - data_.f.flags = kNumberInt64Flag; - if (i64 >= 0) { - data_.f.flags |= kNumberUint64Flag; - if (!(static_cast(i64) & RAPIDJSON_UINT64_C2(0xFFFFFFFF, 0x00000000))) - data_.f.flags |= kUintFlag; - if (!(static_cast(i64) & RAPIDJSON_UINT64_C2(0xFFFFFFFF, 0x80000000))) - data_.f.flags |= kIntFlag; - } - else if (i64 >= static_cast(RAPIDJSON_UINT64_C2(0xFFFFFFFF, 0x80000000))) - data_.f.flags |= kIntFlag; - } - - //! Constructor for uint64_t value. - explicit GenericValue(uint64_t u64) RAPIDJSON_NOEXCEPT : data_() { - data_.n.u64 = u64; - data_.f.flags = kNumberUint64Flag; - if (!(u64 & RAPIDJSON_UINT64_C2(0x80000000, 0x00000000))) - data_.f.flags |= kInt64Flag; - if (!(u64 & RAPIDJSON_UINT64_C2(0xFFFFFFFF, 0x00000000))) - data_.f.flags |= kUintFlag; - if (!(u64 & RAPIDJSON_UINT64_C2(0xFFFFFFFF, 0x80000000))) - data_.f.flags |= kIntFlag; - } - - //! Constructor for double value. - explicit GenericValue(double d) RAPIDJSON_NOEXCEPT : data_() { data_.n.d = d; data_.f.flags = kNumberDoubleFlag; } - - //! Constructor for constant string (i.e. do not make a copy of string) - GenericValue(const Ch* s, SizeType length) RAPIDJSON_NOEXCEPT : data_() { SetStringRaw(StringRef(s, length)); } - - //! Constructor for constant string (i.e. do not make a copy of string) - explicit GenericValue(StringRefType s) RAPIDJSON_NOEXCEPT : data_() { SetStringRaw(s); } - - //! Constructor for copy-string (i.e. do make a copy of string) - GenericValue(const Ch* s, SizeType length, Allocator& allocator) : data_() { SetStringRaw(StringRef(s, length), allocator); } - - //! Constructor for copy-string (i.e. do make a copy of string) - GenericValue(const Ch*s, Allocator& allocator) : data_() { SetStringRaw(StringRef(s), allocator); } - -#if RAPIDJSON_HAS_STDSTRING - //! Constructor for copy-string from a string object (i.e. do make a copy of string) - /*! \note Requires the definition of the preprocessor symbol \ref RAPIDJSON_HAS_STDSTRING. - */ - GenericValue(const std::basic_string& s, Allocator& allocator) : data_() { SetStringRaw(StringRef(s), allocator); } -#endif - - //! Constructor for Array. - /*! - \param a An array obtained by \c GetArray(). - \note \c Array is always pass-by-value. - \note the source array is moved into this value and the sourec array becomes empty. - */ - GenericValue(Array a) RAPIDJSON_NOEXCEPT : data_(a.value_.data_) { - a.value_.data_ = Data(); - a.value_.data_.f.flags = kArrayFlag; - } - - //! Constructor for Object. - /*! - \param o An object obtained by \c GetObject(). - \note \c Object is always pass-by-value. - \note the source object is moved into this value and the sourec object becomes empty. - */ - GenericValue(Object o) RAPIDJSON_NOEXCEPT : data_(o.value_.data_) { - o.value_.data_ = Data(); - o.value_.data_.f.flags = kObjectFlag; - } - - //! Destructor. - /*! Need to destruct elements of array, members of object, or copy-string. - */ - ~GenericValue() { - if (Allocator::kNeedFree) { // Shortcut by Allocator's trait - switch(data_.f.flags) { - case kArrayFlag: - { - GenericValue* e = GetElementsPointer(); - for (GenericValue* v = e; v != e + data_.a.size; ++v) - v->~GenericValue(); - Allocator::Free(e); - } - break; - - case kObjectFlag: - for (MemberIterator m = MemberBegin(); m != MemberEnd(); ++m) - m->~Member(); - Allocator::Free(GetMembersPointer()); - break; - - case kCopyStringFlag: - Allocator::Free(const_cast(GetStringPointer())); - break; - - default: - break; // Do nothing for other types. - } - } - } - - //@} - - //!@name Assignment operators - //@{ - - //! Assignment with move semantics. - /*! \param rhs Source of the assignment. It will become a null value after assignment. - */ - GenericValue& operator=(GenericValue& rhs) RAPIDJSON_NOEXCEPT { - RAPIDJSON_ASSERT(this != &rhs); - this->~GenericValue(); - RawAssign(rhs); - return *this; - } - -#if RAPIDJSON_HAS_CXX11_RVALUE_REFS - //! Move assignment in C++11 - GenericValue& operator=(GenericValue&& rhs) RAPIDJSON_NOEXCEPT { - return *this = rhs.Move(); - } -#endif - - //! Assignment of constant string reference (no copy) - /*! \param str Constant string reference to be assigned - \note This overload is needed to avoid clashes with the generic primitive type assignment overload below. - \see GenericStringRef, operator=(T) - */ - GenericValue& operator=(StringRefType str) RAPIDJSON_NOEXCEPT { - GenericValue s(str); - return *this = s; - } - - //! Assignment with primitive types. - /*! \tparam T Either \ref Type, \c int, \c unsigned, \c int64_t, \c uint64_t - \param value The value to be assigned. - - \note The source type \c T explicitly disallows all pointer types, - especially (\c const) \ref Ch*. This helps avoiding implicitly - referencing character strings with insufficient lifetime, use - \ref SetString(const Ch*, Allocator&) (for copying) or - \ref StringRef() (to explicitly mark the pointer as constant) instead. - All other pointer types would implicitly convert to \c bool, - use \ref SetBool() instead. - */ - template - RAPIDJSON_DISABLEIF_RETURN((internal::IsPointer), (GenericValue&)) - operator=(T value) { - GenericValue v(value); - return *this = v; - } - - //! Deep-copy assignment from Value - /*! Assigns a \b copy of the Value to the current Value object - \tparam SourceAllocator Allocator type of \c rhs - \param rhs Value to copy from (read-only) - \param allocator Allocator to use for copying - */ - template - GenericValue& CopyFrom(const GenericValue& rhs, Allocator& allocator) { - RAPIDJSON_ASSERT(static_cast(this) != static_cast(&rhs)); - this->~GenericValue(); - new (this) GenericValue(rhs, allocator); - return *this; - } - - //! Exchange the contents of this value with those of other. - /*! - \param other Another value. - \note Constant complexity. - */ - GenericValue& Swap(GenericValue& other) RAPIDJSON_NOEXCEPT { - GenericValue temp; - temp.RawAssign(*this); - RawAssign(other); - other.RawAssign(temp); - return *this; - } - - //! free-standing swap function helper - /*! - Helper function to enable support for common swap implementation pattern based on \c std::swap: - \code - void swap(MyClass& a, MyClass& b) { - using std::swap; - swap(a.value, b.value); - // ... - } - \endcode - \see Swap() - */ - friend inline void swap(GenericValue& a, GenericValue& b) RAPIDJSON_NOEXCEPT { a.Swap(b); } - - //! Prepare Value for move semantics - /*! \return *this */ - GenericValue& Move() RAPIDJSON_NOEXCEPT { return *this; } - //@} - - //!@name Equal-to and not-equal-to operators - //@{ - //! Equal-to operator - /*! - \note If an object contains duplicated named member, comparing equality with any object is always \c false. - \note Linear time complexity (number of all values in the subtree and total lengths of all strings). - */ - template - bool operator==(const GenericValue& rhs) const { - typedef GenericValue RhsType; - if (GetType() != rhs.GetType()) - return false; - - switch (GetType()) { - case kObjectType: // Warning: O(n^2) inner-loop - if (data_.o.size != rhs.data_.o.size) - return false; - for (ConstMemberIterator lhsMemberItr = MemberBegin(); lhsMemberItr != MemberEnd(); ++lhsMemberItr) { - typename RhsType::ConstMemberIterator rhsMemberItr = rhs.FindMember(lhsMemberItr->name); - if (rhsMemberItr == rhs.MemberEnd() || lhsMemberItr->value != rhsMemberItr->value) - return false; - } - return true; - - case kArrayType: - if (data_.a.size != rhs.data_.a.size) - return false; - for (SizeType i = 0; i < data_.a.size; i++) - if ((*this)[i] != rhs[i]) - return false; - return true; - - case kStringType: - return StringEqual(rhs); - - case kNumberType: - if (IsDouble() || rhs.IsDouble()) { - double a = GetDouble(); // May convert from integer to double. - double b = rhs.GetDouble(); // Ditto - return a >= b && a <= b; // Prevent -Wfloat-equal - } - else - return data_.n.u64 == rhs.data_.n.u64; - - default: - return true; - } - } - - //! Equal-to operator with const C-string pointer - bool operator==(const Ch* rhs) const { return *this == GenericValue(StringRef(rhs)); } - -#if RAPIDJSON_HAS_STDSTRING - //! Equal-to operator with string object - /*! \note Requires the definition of the preprocessor symbol \ref RAPIDJSON_HAS_STDSTRING. - */ - bool operator==(const std::basic_string& rhs) const { return *this == GenericValue(StringRef(rhs)); } -#endif - - //! Equal-to operator with primitive types - /*! \tparam T Either \ref Type, \c int, \c unsigned, \c int64_t, \c uint64_t, \c double, \c true, \c false - */ - template RAPIDJSON_DISABLEIF_RETURN((internal::OrExpr,internal::IsGenericValue >), (bool)) operator==(const T& rhs) const { return *this == GenericValue(rhs); } - - //! Not-equal-to operator - /*! \return !(*this == rhs) - */ - template - bool operator!=(const GenericValue& rhs) const { return !(*this == rhs); } - - //! Not-equal-to operator with const C-string pointer - bool operator!=(const Ch* rhs) const { return !(*this == rhs); } - - //! Not-equal-to operator with arbitrary types - /*! \return !(*this == rhs) - */ - template RAPIDJSON_DISABLEIF_RETURN((internal::IsGenericValue), (bool)) operator!=(const T& rhs) const { return !(*this == rhs); } - - //! Equal-to operator with arbitrary types (symmetric version) - /*! \return (rhs == lhs) - */ - template friend RAPIDJSON_DISABLEIF_RETURN((internal::IsGenericValue), (bool)) operator==(const T& lhs, const GenericValue& rhs) { return rhs == lhs; } - - //! Not-Equal-to operator with arbitrary types (symmetric version) - /*! \return !(rhs == lhs) - */ - template friend RAPIDJSON_DISABLEIF_RETURN((internal::IsGenericValue), (bool)) operator!=(const T& lhs, const GenericValue& rhs) { return !(rhs == lhs); } - //@} - - //!@name Type - //@{ - - Type GetType() const { return static_cast(data_.f.flags & kTypeMask); } - bool IsNull() const { return data_.f.flags == kNullFlag; } - bool IsFalse() const { return data_.f.flags == kFalseFlag; } - bool IsTrue() const { return data_.f.flags == kTrueFlag; } - bool IsBool() const { return (data_.f.flags & kBoolFlag) != 0; } - bool IsObject() const { return data_.f.flags == kObjectFlag; } - bool IsArray() const { return data_.f.flags == kArrayFlag; } - bool IsNumber() const { return (data_.f.flags & kNumberFlag) != 0; } - bool IsInt() const { return (data_.f.flags & kIntFlag) != 0; } - bool IsUint() const { return (data_.f.flags & kUintFlag) != 0; } - bool IsInt64() const { return (data_.f.flags & kInt64Flag) != 0; } - bool IsUint64() const { return (data_.f.flags & kUint64Flag) != 0; } - bool IsDouble() const { return (data_.f.flags & kDoubleFlag) != 0; } - bool IsString() const { return (data_.f.flags & kStringFlag) != 0; } - - // Checks whether a number can be losslessly converted to a double. - bool IsLosslessDouble() const { - if (!IsNumber()) return false; - if (IsUint64()) { - uint64_t u = GetUint64(); - volatile double d = static_cast(u); - return (d >= 0.0) - && (d < static_cast(std::numeric_limits::max())) - && (u == static_cast(d)); - } - if (IsInt64()) { - int64_t i = GetInt64(); - volatile double d = static_cast(i); - return (d >= static_cast(std::numeric_limits::min())) - && (d < static_cast(std::numeric_limits::max())) - && (i == static_cast(d)); - } - return true; // double, int, uint are always lossless - } - - // Checks whether a number is a float (possible lossy). - bool IsFloat() const { - if ((data_.f.flags & kDoubleFlag) == 0) - return false; - double d = GetDouble(); - return d >= -3.4028234e38 && d <= 3.4028234e38; - } - // Checks whether a number can be losslessly converted to a float. - bool IsLosslessFloat() const { - if (!IsNumber()) return false; - double a = GetDouble(); - if (a < static_cast(-std::numeric_limits::max()) - || a > static_cast(std::numeric_limits::max())) - return false; - double b = static_cast(static_cast(a)); - return a >= b && a <= b; // Prevent -Wfloat-equal - } - - //@} - - //!@name Null - //@{ - - GenericValue& SetNull() { this->~GenericValue(); new (this) GenericValue(); return *this; } - - //@} - - //!@name Bool - //@{ - - bool GetBool() const { RAPIDJSON_ASSERT(IsBool()); return data_.f.flags == kTrueFlag; } - //!< Set boolean value - /*! \post IsBool() == true */ - GenericValue& SetBool(bool b) { this->~GenericValue(); new (this) GenericValue(b); return *this; } - - //@} - - //!@name Object - //@{ - - //! Set this value as an empty object. - /*! \post IsObject() == true */ - GenericValue& SetObject() { this->~GenericValue(); new (this) GenericValue(kObjectType); return *this; } - - //! Get the number of members in the object. - SizeType MemberCount() const { RAPIDJSON_ASSERT(IsObject()); return data_.o.size; } - - //! Check whether the object is empty. - bool ObjectEmpty() const { RAPIDJSON_ASSERT(IsObject()); return data_.o.size == 0; } - - //! Get a value from an object associated with the name. - /*! \pre IsObject() == true - \tparam T Either \c Ch or \c const \c Ch (template used for disambiguation with \ref operator[](SizeType)) - \note In version 0.1x, if the member is not found, this function returns a null value. This makes issue 7. - Since 0.2, if the name is not correct, it will assert. - If user is unsure whether a member exists, user should use HasMember() first. - A better approach is to use FindMember(). - \note Linear time complexity. - */ - template - RAPIDJSON_DISABLEIF_RETURN((internal::NotExpr::Type, Ch> >),(GenericValue&)) operator[](T* name) { - GenericValue n(StringRef(name)); - return (*this)[n]; - } - template - RAPIDJSON_DISABLEIF_RETURN((internal::NotExpr::Type, Ch> >),(const GenericValue&)) operator[](T* name) const { return const_cast(*this)[name]; } - - //! Get a value from an object associated with the name. - /*! \pre IsObject() == true - \tparam SourceAllocator Allocator of the \c name value - - \note Compared to \ref operator[](T*), this version is faster because it does not need a StrLen(). - And it can also handle strings with embedded null characters. - - \note Linear time complexity. - */ - template - GenericValue& operator[](const GenericValue& name) { - MemberIterator member = FindMember(name); - if (member != MemberEnd()) - return member->value; - else { - RAPIDJSON_ASSERT(false); // see above note - - // This will generate -Wexit-time-destructors in clang - // static GenericValue NullValue; - // return NullValue; - - // Use static buffer and placement-new to prevent destruction - static char buffer[sizeof(GenericValue)]; - return *new (buffer) GenericValue(); - } - } - template - const GenericValue& operator[](const GenericValue& name) const { return const_cast(*this)[name]; } - -#if RAPIDJSON_HAS_STDSTRING - //! Get a value from an object associated with name (string object). - GenericValue& operator[](const std::basic_string& name) { return (*this)[GenericValue(StringRef(name))]; } - const GenericValue& operator[](const std::basic_string& name) const { return (*this)[GenericValue(StringRef(name))]; } -#endif - - //! Const member iterator - /*! \pre IsObject() == true */ - ConstMemberIterator MemberBegin() const { RAPIDJSON_ASSERT(IsObject()); return ConstMemberIterator(GetMembersPointer()); } - //! Const \em past-the-end member iterator - /*! \pre IsObject() == true */ - ConstMemberIterator MemberEnd() const { RAPIDJSON_ASSERT(IsObject()); return ConstMemberIterator(GetMembersPointer() + data_.o.size); } - //! Member iterator - /*! \pre IsObject() == true */ - MemberIterator MemberBegin() { RAPIDJSON_ASSERT(IsObject()); return MemberIterator(GetMembersPointer()); } - //! \em Past-the-end member iterator - /*! \pre IsObject() == true */ - MemberIterator MemberEnd() { RAPIDJSON_ASSERT(IsObject()); return MemberIterator(GetMembersPointer() + data_.o.size); } - - //! Check whether a member exists in the object. - /*! - \param name Member name to be searched. - \pre IsObject() == true - \return Whether a member with that name exists. - \note It is better to use FindMember() directly if you need the obtain the value as well. - \note Linear time complexity. - */ - bool HasMember(const Ch* name) const { return FindMember(name) != MemberEnd(); } - -#if RAPIDJSON_HAS_STDSTRING - //! Check whether a member exists in the object with string object. - /*! - \param name Member name to be searched. - \pre IsObject() == true - \return Whether a member with that name exists. - \note It is better to use FindMember() directly if you need the obtain the value as well. - \note Linear time complexity. - */ - bool HasMember(const std::basic_string& name) const { return FindMember(name) != MemberEnd(); } -#endif - - //! Check whether a member exists in the object with GenericValue name. - /*! - This version is faster because it does not need a StrLen(). It can also handle string with null character. - \param name Member name to be searched. - \pre IsObject() == true - \return Whether a member with that name exists. - \note It is better to use FindMember() directly if you need the obtain the value as well. - \note Linear time complexity. - */ - template - bool HasMember(const GenericValue& name) const { return FindMember(name) != MemberEnd(); } - - //! Find member by name. - /*! - \param name Member name to be searched. - \pre IsObject() == true - \return Iterator to member, if it exists. - Otherwise returns \ref MemberEnd(). - - \note Earlier versions of Rapidjson returned a \c NULL pointer, in case - the requested member doesn't exist. For consistency with e.g. - \c std::map, this has been changed to MemberEnd() now. - \note Linear time complexity. - */ - MemberIterator FindMember(const Ch* name) { - GenericValue n(StringRef(name)); - return FindMember(n); - } - - ConstMemberIterator FindMember(const Ch* name) const { return const_cast(*this).FindMember(name); } - - //! Find member by name. - /*! - This version is faster because it does not need a StrLen(). It can also handle string with null character. - \param name Member name to be searched. - \pre IsObject() == true - \return Iterator to member, if it exists. - Otherwise returns \ref MemberEnd(). - - \note Earlier versions of Rapidjson returned a \c NULL pointer, in case - the requested member doesn't exist. For consistency with e.g. - \c std::map, this has been changed to MemberEnd() now. - \note Linear time complexity. - */ - template - MemberIterator FindMember(const GenericValue& name) { - RAPIDJSON_ASSERT(IsObject()); - RAPIDJSON_ASSERT(name.IsString()); - MemberIterator member = MemberBegin(); - for ( ; member != MemberEnd(); ++member) - if (name.StringEqual(member->name)) - break; - return member; - } - template ConstMemberIterator FindMember(const GenericValue& name) const { return const_cast(*this).FindMember(name); } - -#if RAPIDJSON_HAS_STDSTRING - //! Find member by string object name. - /*! - \param name Member name to be searched. - \pre IsObject() == true - \return Iterator to member, if it exists. - Otherwise returns \ref MemberEnd(). - */ - MemberIterator FindMember(const std::basic_string& name) { return FindMember(GenericValue(StringRef(name))); } - ConstMemberIterator FindMember(const std::basic_string& name) const { return FindMember(GenericValue(StringRef(name))); } -#endif - - //! Add a member (name-value pair) to the object. - /*! \param name A string value as name of member. - \param value Value of any type. - \param allocator Allocator for reallocating memory. It must be the same one as used before. Commonly use GenericDocument::GetAllocator(). - \return The value itself for fluent API. - \note The ownership of \c name and \c value will be transferred to this object on success. - \pre IsObject() && name.IsString() - \post name.IsNull() && value.IsNull() - \note Amortized Constant time complexity. - */ - GenericValue& AddMember(GenericValue& name, GenericValue& value, Allocator& allocator) { - RAPIDJSON_ASSERT(IsObject()); - RAPIDJSON_ASSERT(name.IsString()); - - ObjectData& o = data_.o; - if (o.size >= o.capacity) { - if (o.capacity == 0) { - o.capacity = kDefaultObjectCapacity; - SetMembersPointer(reinterpret_cast(allocator.Malloc(o.capacity * sizeof(Member)))); - } - else { - SizeType oldCapacity = o.capacity; - o.capacity += (oldCapacity + 1) / 2; // grow by factor 1.5 - SetMembersPointer(reinterpret_cast(allocator.Realloc(GetMembersPointer(), oldCapacity * sizeof(Member), o.capacity * sizeof(Member)))); - } - } - Member* members = GetMembersPointer(); - members[o.size].name.RawAssign(name); - members[o.size].value.RawAssign(value); - o.size++; - return *this; - } - - //! Add a constant string value as member (name-value pair) to the object. - /*! \param name A string value as name of member. - \param value constant string reference as value of member. - \param allocator Allocator for reallocating memory. It must be the same one as used before. Commonly use GenericDocument::GetAllocator(). - \return The value itself for fluent API. - \pre IsObject() - \note This overload is needed to avoid clashes with the generic primitive type AddMember(GenericValue&,T,Allocator&) overload below. - \note Amortized Constant time complexity. - */ - GenericValue& AddMember(GenericValue& name, StringRefType value, Allocator& allocator) { - GenericValue v(value); - return AddMember(name, v, allocator); - } - -#if RAPIDJSON_HAS_STDSTRING - //! Add a string object as member (name-value pair) to the object. - /*! \param name A string value as name of member. - \param value constant string reference as value of member. - \param allocator Allocator for reallocating memory. It must be the same one as used before. Commonly use GenericDocument::GetAllocator(). - \return The value itself for fluent API. - \pre IsObject() - \note This overload is needed to avoid clashes with the generic primitive type AddMember(GenericValue&,T,Allocator&) overload below. - \note Amortized Constant time complexity. - */ - GenericValue& AddMember(GenericValue& name, std::basic_string& value, Allocator& allocator) { - GenericValue v(value, allocator); - return AddMember(name, v, allocator); - } -#endif - - //! Add any primitive value as member (name-value pair) to the object. - /*! \tparam T Either \ref Type, \c int, \c unsigned, \c int64_t, \c uint64_t - \param name A string value as name of member. - \param value Value of primitive type \c T as value of member - \param allocator Allocator for reallocating memory. Commonly use GenericDocument::GetAllocator(). - \return The value itself for fluent API. - \pre IsObject() - - \note The source type \c T explicitly disallows all pointer types, - especially (\c const) \ref Ch*. This helps avoiding implicitly - referencing character strings with insufficient lifetime, use - \ref AddMember(StringRefType, GenericValue&, Allocator&) or \ref - AddMember(StringRefType, StringRefType, Allocator&). - All other pointer types would implicitly convert to \c bool, - use an explicit cast instead, if needed. - \note Amortized Constant time complexity. - */ - template - RAPIDJSON_DISABLEIF_RETURN((internal::OrExpr, internal::IsGenericValue >), (GenericValue&)) - AddMember(GenericValue& name, T value, Allocator& allocator) { - GenericValue v(value); - return AddMember(name, v, allocator); - } - -#if RAPIDJSON_HAS_CXX11_RVALUE_REFS - GenericValue& AddMember(GenericValue&& name, GenericValue&& value, Allocator& allocator) { - return AddMember(name, value, allocator); - } - GenericValue& AddMember(GenericValue&& name, GenericValue& value, Allocator& allocator) { - return AddMember(name, value, allocator); - } - GenericValue& AddMember(GenericValue& name, GenericValue&& value, Allocator& allocator) { - return AddMember(name, value, allocator); - } - GenericValue& AddMember(StringRefType name, GenericValue&& value, Allocator& allocator) { - GenericValue n(name); - return AddMember(n, value, allocator); - } -#endif // RAPIDJSON_HAS_CXX11_RVALUE_REFS - - - //! Add a member (name-value pair) to the object. - /*! \param name A constant string reference as name of member. - \param value Value of any type. - \param allocator Allocator for reallocating memory. It must be the same one as used before. Commonly use GenericDocument::GetAllocator(). - \return The value itself for fluent API. - \note The ownership of \c value will be transferred to this object on success. - \pre IsObject() - \post value.IsNull() - \note Amortized Constant time complexity. - */ - GenericValue& AddMember(StringRefType name, GenericValue& value, Allocator& allocator) { - GenericValue n(name); - return AddMember(n, value, allocator); - } - - //! Add a constant string value as member (name-value pair) to the object. - /*! \param name A constant string reference as name of member. - \param value constant string reference as value of member. - \param allocator Allocator for reallocating memory. It must be the same one as used before. Commonly use GenericDocument::GetAllocator(). - \return The value itself for fluent API. - \pre IsObject() - \note This overload is needed to avoid clashes with the generic primitive type AddMember(StringRefType,T,Allocator&) overload below. - \note Amortized Constant time complexity. - */ - GenericValue& AddMember(StringRefType name, StringRefType value, Allocator& allocator) { - GenericValue v(value); - return AddMember(name, v, allocator); - } - - //! Add any primitive value as member (name-value pair) to the object. - /*! \tparam T Either \ref Type, \c int, \c unsigned, \c int64_t, \c uint64_t - \param name A constant string reference as name of member. - \param value Value of primitive type \c T as value of member - \param allocator Allocator for reallocating memory. Commonly use GenericDocument::GetAllocator(). - \return The value itself for fluent API. - \pre IsObject() - - \note The source type \c T explicitly disallows all pointer types, - especially (\c const) \ref Ch*. This helps avoiding implicitly - referencing character strings with insufficient lifetime, use - \ref AddMember(StringRefType, GenericValue&, Allocator&) or \ref - AddMember(StringRefType, StringRefType, Allocator&). - All other pointer types would implicitly convert to \c bool, - use an explicit cast instead, if needed. - \note Amortized Constant time complexity. - */ - template - RAPIDJSON_DISABLEIF_RETURN((internal::OrExpr, internal::IsGenericValue >), (GenericValue&)) - AddMember(StringRefType name, T value, Allocator& allocator) { - GenericValue n(name); - return AddMember(n, value, allocator); - } - - //! Remove all members in the object. - /*! This function do not deallocate memory in the object, i.e. the capacity is unchanged. - \note Linear time complexity. - */ - void RemoveAllMembers() { - RAPIDJSON_ASSERT(IsObject()); - for (MemberIterator m = MemberBegin(); m != MemberEnd(); ++m) - m->~Member(); - data_.o.size = 0; - } - - //! Remove a member in object by its name. - /*! \param name Name of member to be removed. - \return Whether the member existed. - \note This function may reorder the object members. Use \ref - EraseMember(ConstMemberIterator) if you need to preserve the - relative order of the remaining members. - \note Linear time complexity. - */ - bool RemoveMember(const Ch* name) { - GenericValue n(StringRef(name)); - return RemoveMember(n); - } - -#if RAPIDJSON_HAS_STDSTRING - bool RemoveMember(const std::basic_string& name) { return RemoveMember(GenericValue(StringRef(name))); } -#endif - - template - bool RemoveMember(const GenericValue& name) { - MemberIterator m = FindMember(name); - if (m != MemberEnd()) { - RemoveMember(m); - return true; - } - else - return false; - } - - //! Remove a member in object by iterator. - /*! \param m member iterator (obtained by FindMember() or MemberBegin()). - \return the new iterator after removal. - \note This function may reorder the object members. Use \ref - EraseMember(ConstMemberIterator) if you need to preserve the - relative order of the remaining members. - \note Constant time complexity. - */ - MemberIterator RemoveMember(MemberIterator m) { - RAPIDJSON_ASSERT(IsObject()); - RAPIDJSON_ASSERT(data_.o.size > 0); - RAPIDJSON_ASSERT(GetMembersPointer() != 0); - RAPIDJSON_ASSERT(m >= MemberBegin() && m < MemberEnd()); - - MemberIterator last(GetMembersPointer() + (data_.o.size - 1)); - if (data_.o.size > 1 && m != last) - *m = *last; // Move the last one to this place - else - m->~Member(); // Only one left, just destroy - --data_.o.size; - return m; - } - - //! Remove a member from an object by iterator. - /*! \param pos iterator to the member to remove - \pre IsObject() == true && \ref MemberBegin() <= \c pos < \ref MemberEnd() - \return Iterator following the removed element. - If the iterator \c pos refers to the last element, the \ref MemberEnd() iterator is returned. - \note This function preserves the relative order of the remaining object - members. If you do not need this, use the more efficient \ref RemoveMember(MemberIterator). - \note Linear time complexity. - */ - MemberIterator EraseMember(ConstMemberIterator pos) { - return EraseMember(pos, pos +1); - } - - //! Remove members in the range [first, last) from an object. - /*! \param first iterator to the first member to remove - \param last iterator following the last member to remove - \pre IsObject() == true && \ref MemberBegin() <= \c first <= \c last <= \ref MemberEnd() - \return Iterator following the last removed element. - \note This function preserves the relative order of the remaining object - members. - \note Linear time complexity. - */ - MemberIterator EraseMember(ConstMemberIterator first, ConstMemberIterator last) { - RAPIDJSON_ASSERT(IsObject()); - RAPIDJSON_ASSERT(data_.o.size > 0); - RAPIDJSON_ASSERT(GetMembersPointer() != 0); - RAPIDJSON_ASSERT(first >= MemberBegin()); - RAPIDJSON_ASSERT(first <= last); - RAPIDJSON_ASSERT(last <= MemberEnd()); - - MemberIterator pos = MemberBegin() + (first - MemberBegin()); - for (MemberIterator itr = pos; itr != last; ++itr) - itr->~Member(); - std::memmove(&*pos, &*last, static_cast(MemberEnd() - last) * sizeof(Member)); - data_.o.size -= static_cast(last - first); - return pos; - } - - //! Erase a member in object by its name. - /*! \param name Name of member to be removed. - \return Whether the member existed. - \note Linear time complexity. - */ - bool EraseMember(const Ch* name) { - GenericValue n(StringRef(name)); - return EraseMember(n); - } - -#if RAPIDJSON_HAS_STDSTRING - bool EraseMember(const std::basic_string& name) { return EraseMember(GenericValue(StringRef(name))); } -#endif - - template - bool EraseMember(const GenericValue& name) { - MemberIterator m = FindMember(name); - if (m != MemberEnd()) { - EraseMember(m); - return true; - } - else - return false; - } - - Object GetObject() { RAPIDJSON_ASSERT(IsObject()); return Object(*this); } - ConstObject GetObject() const { RAPIDJSON_ASSERT(IsObject()); return ConstObject(*this); } - - //@} - - //!@name Array - //@{ - - //! Set this value as an empty array. - /*! \post IsArray == true */ - GenericValue& SetArray() { this->~GenericValue(); new (this) GenericValue(kArrayType); return *this; } - - //! Get the number of elements in array. - SizeType Size() const { RAPIDJSON_ASSERT(IsArray()); return data_.a.size; } - - //! Get the capacity of array. - SizeType Capacity() const { RAPIDJSON_ASSERT(IsArray()); return data_.a.capacity; } - - //! Check whether the array is empty. - bool Empty() const { RAPIDJSON_ASSERT(IsArray()); return data_.a.size == 0; } - - //! Remove all elements in the array. - /*! This function do not deallocate memory in the array, i.e. the capacity is unchanged. - \note Linear time complexity. - */ - void Clear() { - RAPIDJSON_ASSERT(IsArray()); - GenericValue* e = GetElementsPointer(); - for (GenericValue* v = e; v != e + data_.a.size; ++v) - v->~GenericValue(); - data_.a.size = 0; - } - - //! Get an element from array by index. - /*! \pre IsArray() == true - \param index Zero-based index of element. - \see operator[](T*) - */ - GenericValue& operator[](SizeType index) { - RAPIDJSON_ASSERT(IsArray()); - RAPIDJSON_ASSERT(index < data_.a.size); - return GetElementsPointer()[index]; - } - const GenericValue& operator[](SizeType index) const { return const_cast(*this)[index]; } - - //! Element iterator - /*! \pre IsArray() == true */ - ValueIterator Begin() { RAPIDJSON_ASSERT(IsArray()); return GetElementsPointer(); } - //! \em Past-the-end element iterator - /*! \pre IsArray() == true */ - ValueIterator End() { RAPIDJSON_ASSERT(IsArray()); return GetElementsPointer() + data_.a.size; } - //! Constant element iterator - /*! \pre IsArray() == true */ - ConstValueIterator Begin() const { return const_cast(*this).Begin(); } - //! Constant \em past-the-end element iterator - /*! \pre IsArray() == true */ - ConstValueIterator End() const { return const_cast(*this).End(); } - - //! Request the array to have enough capacity to store elements. - /*! \param newCapacity The capacity that the array at least need to have. - \param allocator Allocator for reallocating memory. It must be the same one as used before. Commonly use GenericDocument::GetAllocator(). - \return The value itself for fluent API. - \note Linear time complexity. - */ - GenericValue& Reserve(SizeType newCapacity, Allocator &allocator) { - RAPIDJSON_ASSERT(IsArray()); - if (newCapacity > data_.a.capacity) { - SetElementsPointer(reinterpret_cast(allocator.Realloc(GetElementsPointer(), data_.a.capacity * sizeof(GenericValue), newCapacity * sizeof(GenericValue)))); - data_.a.capacity = newCapacity; - } - return *this; - } - - //! Append a GenericValue at the end of the array. - /*! \param value Value to be appended. - \param allocator Allocator for reallocating memory. It must be the same one as used before. Commonly use GenericDocument::GetAllocator(). - \pre IsArray() == true - \post value.IsNull() == true - \return The value itself for fluent API. - \note The ownership of \c value will be transferred to this array on success. - \note If the number of elements to be appended is known, calls Reserve() once first may be more efficient. - \note Amortized constant time complexity. - */ - GenericValue& PushBack(GenericValue& value, Allocator& allocator) { - RAPIDJSON_ASSERT(IsArray()); - if (data_.a.size >= data_.a.capacity) - Reserve(data_.a.capacity == 0 ? kDefaultArrayCapacity : (data_.a.capacity + (data_.a.capacity + 1) / 2), allocator); - GetElementsPointer()[data_.a.size++].RawAssign(value); - return *this; - } - -#if RAPIDJSON_HAS_CXX11_RVALUE_REFS - GenericValue& PushBack(GenericValue&& value, Allocator& allocator) { - return PushBack(value, allocator); - } -#endif // RAPIDJSON_HAS_CXX11_RVALUE_REFS - - //! Append a constant string reference at the end of the array. - /*! \param value Constant string reference to be appended. - \param allocator Allocator for reallocating memory. It must be the same one used previously. Commonly use GenericDocument::GetAllocator(). - \pre IsArray() == true - \return The value itself for fluent API. - \note If the number of elements to be appended is known, calls Reserve() once first may be more efficient. - \note Amortized constant time complexity. - \see GenericStringRef - */ - GenericValue& PushBack(StringRefType value, Allocator& allocator) { - return (*this).template PushBack(value, allocator); - } - - //! Append a primitive value at the end of the array. - /*! \tparam T Either \ref Type, \c int, \c unsigned, \c int64_t, \c uint64_t - \param value Value of primitive type T to be appended. - \param allocator Allocator for reallocating memory. It must be the same one as used before. Commonly use GenericDocument::GetAllocator(). - \pre IsArray() == true - \return The value itself for fluent API. - \note If the number of elements to be appended is known, calls Reserve() once first may be more efficient. - - \note The source type \c T explicitly disallows all pointer types, - especially (\c const) \ref Ch*. This helps avoiding implicitly - referencing character strings with insufficient lifetime, use - \ref PushBack(GenericValue&, Allocator&) or \ref - PushBack(StringRefType, Allocator&). - All other pointer types would implicitly convert to \c bool, - use an explicit cast instead, if needed. - \note Amortized constant time complexity. - */ - template - RAPIDJSON_DISABLEIF_RETURN((internal::OrExpr, internal::IsGenericValue >), (GenericValue&)) - PushBack(T value, Allocator& allocator) { - GenericValue v(value); - return PushBack(v, allocator); - } - - //! Remove the last element in the array. - /*! - \note Constant time complexity. - */ - GenericValue& PopBack() { - RAPIDJSON_ASSERT(IsArray()); - RAPIDJSON_ASSERT(!Empty()); - GetElementsPointer()[--data_.a.size].~GenericValue(); - return *this; - } - - //! Remove an element of array by iterator. - /*! - \param pos iterator to the element to remove - \pre IsArray() == true && \ref Begin() <= \c pos < \ref End() - \return Iterator following the removed element. If the iterator pos refers to the last element, the End() iterator is returned. - \note Linear time complexity. - */ - ValueIterator Erase(ConstValueIterator pos) { - return Erase(pos, pos + 1); - } - - //! Remove elements in the range [first, last) of the array. - /*! - \param first iterator to the first element to remove - \param last iterator following the last element to remove - \pre IsArray() == true && \ref Begin() <= \c first <= \c last <= \ref End() - \return Iterator following the last removed element. - \note Linear time complexity. - */ - ValueIterator Erase(ConstValueIterator first, ConstValueIterator last) { - RAPIDJSON_ASSERT(IsArray()); - RAPIDJSON_ASSERT(data_.a.size > 0); - RAPIDJSON_ASSERT(GetElementsPointer() != 0); - RAPIDJSON_ASSERT(first >= Begin()); - RAPIDJSON_ASSERT(first <= last); - RAPIDJSON_ASSERT(last <= End()); - ValueIterator pos = Begin() + (first - Begin()); - for (ValueIterator itr = pos; itr != last; ++itr) - itr->~GenericValue(); - std::memmove(pos, last, static_cast(End() - last) * sizeof(GenericValue)); - data_.a.size -= static_cast(last - first); - return pos; - } - - Array GetArray() { RAPIDJSON_ASSERT(IsArray()); return Array(*this); } - ConstArray GetArray() const { RAPIDJSON_ASSERT(IsArray()); return ConstArray(*this); } - - //@} - - //!@name Number - //@{ - - int GetInt() const { RAPIDJSON_ASSERT(data_.f.flags & kIntFlag); return data_.n.i.i; } - unsigned GetUint() const { RAPIDJSON_ASSERT(data_.f.flags & kUintFlag); return data_.n.u.u; } - int64_t GetInt64() const { RAPIDJSON_ASSERT(data_.f.flags & kInt64Flag); return data_.n.i64; } - uint64_t GetUint64() const { RAPIDJSON_ASSERT(data_.f.flags & kUint64Flag); return data_.n.u64; } - - //! Get the value as double type. - /*! \note If the value is 64-bit integer type, it may lose precision. Use \c IsLosslessDouble() to check whether the converison is lossless. - */ - double GetDouble() const { - RAPIDJSON_ASSERT(IsNumber()); - if ((data_.f.flags & kDoubleFlag) != 0) return data_.n.d; // exact type, no conversion. - if ((data_.f.flags & kIntFlag) != 0) return data_.n.i.i; // int -> double - if ((data_.f.flags & kUintFlag) != 0) return data_.n.u.u; // unsigned -> double - if ((data_.f.flags & kInt64Flag) != 0) return static_cast(data_.n.i64); // int64_t -> double (may lose precision) - RAPIDJSON_ASSERT((data_.f.flags & kUint64Flag) != 0); return static_cast(data_.n.u64); // uint64_t -> double (may lose precision) - } - - //! Get the value as float type. - /*! \note If the value is 64-bit integer type, it may lose precision. Use \c IsLosslessFloat() to check whether the converison is lossless. - */ - float GetFloat() const { - return static_cast(GetDouble()); - } - - GenericValue& SetInt(int i) { this->~GenericValue(); new (this) GenericValue(i); return *this; } - GenericValue& SetUint(unsigned u) { this->~GenericValue(); new (this) GenericValue(u); return *this; } - GenericValue& SetInt64(int64_t i64) { this->~GenericValue(); new (this) GenericValue(i64); return *this; } - GenericValue& SetUint64(uint64_t u64) { this->~GenericValue(); new (this) GenericValue(u64); return *this; } - GenericValue& SetDouble(double d) { this->~GenericValue(); new (this) GenericValue(d); return *this; } - GenericValue& SetFloat(float f) { this->~GenericValue(); new (this) GenericValue(f); return *this; } - - //@} - - //!@name String - //@{ - - const Ch* GetString() const { RAPIDJSON_ASSERT(IsString()); return (data_.f.flags & kInlineStrFlag) ? data_.ss.str : GetStringPointer(); } - - //! Get the length of string. - /*! Since rapidjson permits "\\u0000" in the json string, strlen(v.GetString()) may not equal to v.GetStringLength(). - */ - SizeType GetStringLength() const { RAPIDJSON_ASSERT(IsString()); return ((data_.f.flags & kInlineStrFlag) ? (data_.ss.GetLength()) : data_.s.length); } - - //! Set this value as a string without copying source string. - /*! This version has better performance with supplied length, and also support string containing null character. - \param s source string pointer. - \param length The length of source string, excluding the trailing null terminator. - \return The value itself for fluent API. - \post IsString() == true && GetString() == s && GetStringLength() == length - \see SetString(StringRefType) - */ - GenericValue& SetString(const Ch* s, SizeType length) { return SetString(StringRef(s, length)); } - - //! Set this value as a string without copying source string. - /*! \param s source string reference - \return The value itself for fluent API. - \post IsString() == true && GetString() == s && GetStringLength() == s.length - */ - GenericValue& SetString(StringRefType s) { this->~GenericValue(); SetStringRaw(s); return *this; } - - //! Set this value as a string by copying from source string. - /*! This version has better performance with supplied length, and also support string containing null character. - \param s source string. - \param length The length of source string, excluding the trailing null terminator. - \param allocator Allocator for allocating copied buffer. Commonly use GenericDocument::GetAllocator(). - \return The value itself for fluent API. - \post IsString() == true && GetString() != s && strcmp(GetString(),s) == 0 && GetStringLength() == length - */ - GenericValue& SetString(const Ch* s, SizeType length, Allocator& allocator) { this->~GenericValue(); SetStringRaw(StringRef(s, length), allocator); return *this; } - - //! Set this value as a string by copying from source string. - /*! \param s source string. - \param allocator Allocator for allocating copied buffer. Commonly use GenericDocument::GetAllocator(). - \return The value itself for fluent API. - \post IsString() == true && GetString() != s && strcmp(GetString(),s) == 0 && GetStringLength() == length - */ - GenericValue& SetString(const Ch* s, Allocator& allocator) { return SetString(s, internal::StrLen(s), allocator); } - -#if RAPIDJSON_HAS_STDSTRING - //! Set this value as a string by copying from source string. - /*! \param s source string. - \param allocator Allocator for allocating copied buffer. Commonly use GenericDocument::GetAllocator(). - \return The value itself for fluent API. - \post IsString() == true && GetString() != s.data() && strcmp(GetString(),s.data() == 0 && GetStringLength() == s.size() - \note Requires the definition of the preprocessor symbol \ref RAPIDJSON_HAS_STDSTRING. - */ - GenericValue& SetString(const std::basic_string& s, Allocator& allocator) { return SetString(s.data(), SizeType(s.size()), allocator); } -#endif - - //@} - - //!@name Array - //@{ - - //! Templated version for checking whether this value is type T. - /*! - \tparam T Either \c bool, \c int, \c unsigned, \c int64_t, \c uint64_t, \c double, \c float, \c const \c char*, \c std::basic_string - */ - template - bool Is() const { return internal::TypeHelper::Is(*this); } - - template - T Get() const { return internal::TypeHelper::Get(*this); } - - template - T Get() { return internal::TypeHelper::Get(*this); } - - template - ValueType& Set(const T& data) { return internal::TypeHelper::Set(*this, data); } - - template - ValueType& Set(const T& data, AllocatorType& allocator) { return internal::TypeHelper::Set(*this, data, allocator); } - - //@} - - //! Generate events of this value to a Handler. - /*! This function adopts the GoF visitor pattern. - Typical usage is to output this JSON value as JSON text via Writer, which is a Handler. - It can also be used to deep clone this value via GenericDocument, which is also a Handler. - \tparam Handler type of handler. - \param handler An object implementing concept Handler. - */ - template - bool Accept(Handler& handler) const { - switch(GetType()) { - case kNullType: return handler.Null(); - case kFalseType: return handler.Bool(false); - case kTrueType: return handler.Bool(true); - - case kObjectType: - if (RAPIDJSON_UNLIKELY(!handler.StartObject())) - return false; - for (ConstMemberIterator m = MemberBegin(); m != MemberEnd(); ++m) { - RAPIDJSON_ASSERT(m->name.IsString()); // User may change the type of name by MemberIterator. - if (RAPIDJSON_UNLIKELY(!handler.Key(m->name.GetString(), m->name.GetStringLength(), (m->name.data_.f.flags & kCopyFlag) != 0))) - return false; - if (RAPIDJSON_UNLIKELY(!m->value.Accept(handler))) - return false; - } - return handler.EndObject(data_.o.size); - - case kArrayType: - if (RAPIDJSON_UNLIKELY(!handler.StartArray())) - return false; - for (const GenericValue* v = Begin(); v != End(); ++v) - if (RAPIDJSON_UNLIKELY(!v->Accept(handler))) - return false; - return handler.EndArray(data_.a.size); - - case kStringType: - return handler.String(GetString(), GetStringLength(), (data_.f.flags & kCopyFlag) != 0); - - default: - RAPIDJSON_ASSERT(GetType() == kNumberType); - if (IsDouble()) return handler.Double(data_.n.d); - else if (IsInt()) return handler.Int(data_.n.i.i); - else if (IsUint()) return handler.Uint(data_.n.u.u); - else if (IsInt64()) return handler.Int64(data_.n.i64); - else return handler.Uint64(data_.n.u64); - } - } - -private: - template friend class GenericValue; - template friend class GenericDocument; - - enum { - kBoolFlag = 0x0008, - kNumberFlag = 0x0010, - kIntFlag = 0x0020, - kUintFlag = 0x0040, - kInt64Flag = 0x0080, - kUint64Flag = 0x0100, - kDoubleFlag = 0x0200, - kStringFlag = 0x0400, - kCopyFlag = 0x0800, - kInlineStrFlag = 0x1000, - - // Initial flags of different types. - kNullFlag = kNullType, - kTrueFlag = kTrueType | kBoolFlag, - kFalseFlag = kFalseType | kBoolFlag, - kNumberIntFlag = kNumberType | kNumberFlag | kIntFlag | kInt64Flag, - kNumberUintFlag = kNumberType | kNumberFlag | kUintFlag | kUint64Flag | kInt64Flag, - kNumberInt64Flag = kNumberType | kNumberFlag | kInt64Flag, - kNumberUint64Flag = kNumberType | kNumberFlag | kUint64Flag, - kNumberDoubleFlag = kNumberType | kNumberFlag | kDoubleFlag, - kNumberAnyFlag = kNumberType | kNumberFlag | kIntFlag | kInt64Flag | kUintFlag | kUint64Flag | kDoubleFlag, - kConstStringFlag = kStringType | kStringFlag, - kCopyStringFlag = kStringType | kStringFlag | kCopyFlag, - kShortStringFlag = kStringType | kStringFlag | kCopyFlag | kInlineStrFlag, - kObjectFlag = kObjectType, - kArrayFlag = kArrayType, - - kTypeMask = 0x07 - }; - - static const SizeType kDefaultArrayCapacity = 16; - static const SizeType kDefaultObjectCapacity = 16; - - struct Flag { -#if RAPIDJSON_48BITPOINTER_OPTIMIZATION - char payload[sizeof(SizeType) * 2 + 6]; // 2 x SizeType + lower 48-bit pointer -#elif RAPIDJSON_64BIT - char payload[sizeof(SizeType) * 2 + sizeof(void*) + 6]; // 6 padding bytes -#else - char payload[sizeof(SizeType) * 2 + sizeof(void*) + 2]; // 2 padding bytes -#endif - uint16_t flags; - }; - - struct String { - SizeType length; - SizeType hashcode; //!< reserved - const Ch* str; - }; // 12 bytes in 32-bit mode, 16 bytes in 64-bit mode - - // implementation detail: ShortString can represent zero-terminated strings up to MaxSize chars - // (excluding the terminating zero) and store a value to determine the length of the contained - // string in the last character str[LenPos] by storing "MaxSize - length" there. If the string - // to store has the maximal length of MaxSize then str[LenPos] will be 0 and therefore act as - // the string terminator as well. For getting the string length back from that value just use - // "MaxSize - str[LenPos]". - // This allows to store 13-chars strings in 32-bit mode, 21-chars strings in 64-bit mode, - // 13-chars strings for RAPIDJSON_48BITPOINTER_OPTIMIZATION=1 inline (for `UTF8`-encoded strings). - struct ShortString { - enum { MaxChars = sizeof(static_cast(0)->payload) / sizeof(Ch), MaxSize = MaxChars - 1, LenPos = MaxSize }; - Ch str[MaxChars]; - - inline static bool Usable(SizeType len) { return (MaxSize >= len); } - inline void SetLength(SizeType len) { str[LenPos] = static_cast(MaxSize - len); } - inline SizeType GetLength() const { return static_cast(MaxSize - str[LenPos]); } - }; // at most as many bytes as "String" above => 12 bytes in 32-bit mode, 16 bytes in 64-bit mode - - // By using proper binary layout, retrieval of different integer types do not need conversions. - union Number { -#if RAPIDJSON_ENDIAN == RAPIDJSON_LITTLEENDIAN - struct I { - int i; - char padding[4]; - }i; - struct U { - unsigned u; - char padding2[4]; - }u; -#else - struct I { - char padding[4]; - int i; - }i; - struct U { - char padding2[4]; - unsigned u; - }u; -#endif - int64_t i64; - uint64_t u64; - double d; - }; // 8 bytes - - struct ObjectData { - SizeType size; - SizeType capacity; - Member* members; - }; // 12 bytes in 32-bit mode, 16 bytes in 64-bit mode - - struct ArrayData { - SizeType size; - SizeType capacity; - GenericValue* elements; - }; // 12 bytes in 32-bit mode, 16 bytes in 64-bit mode - - union Data { - String s; - ShortString ss; - Number n; - ObjectData o; - ArrayData a; - Flag f; - }; // 16 bytes in 32-bit mode, 24 bytes in 64-bit mode, 16 bytes in 64-bit with RAPIDJSON_48BITPOINTER_OPTIMIZATION - - RAPIDJSON_FORCEINLINE const Ch* GetStringPointer() const { return RAPIDJSON_GETPOINTER(Ch, data_.s.str); } - RAPIDJSON_FORCEINLINE const Ch* SetStringPointer(const Ch* str) { return RAPIDJSON_SETPOINTER(Ch, data_.s.str, str); } - RAPIDJSON_FORCEINLINE GenericValue* GetElementsPointer() const { return RAPIDJSON_GETPOINTER(GenericValue, data_.a.elements); } - RAPIDJSON_FORCEINLINE GenericValue* SetElementsPointer(GenericValue* elements) { return RAPIDJSON_SETPOINTER(GenericValue, data_.a.elements, elements); } - RAPIDJSON_FORCEINLINE Member* GetMembersPointer() const { return RAPIDJSON_GETPOINTER(Member, data_.o.members); } - RAPIDJSON_FORCEINLINE Member* SetMembersPointer(Member* members) { return RAPIDJSON_SETPOINTER(Member, data_.o.members, members); } - - // Initialize this value as array with initial data, without calling destructor. - void SetArrayRaw(GenericValue* values, SizeType count, Allocator& allocator) { - data_.f.flags = kArrayFlag; - if (count) { - GenericValue* e = static_cast(allocator.Malloc(count * sizeof(GenericValue))); - SetElementsPointer(e); - std::memcpy(e, values, count * sizeof(GenericValue)); - } - else - SetElementsPointer(0); - data_.a.size = data_.a.capacity = count; - } - - //! Initialize this value as object with initial data, without calling destructor. - void SetObjectRaw(Member* members, SizeType count, Allocator& allocator) { - data_.f.flags = kObjectFlag; - if (count) { - Member* m = static_cast(allocator.Malloc(count * sizeof(Member))); - SetMembersPointer(m); - std::memcpy(m, members, count * sizeof(Member)); - } - else - SetMembersPointer(0); - data_.o.size = data_.o.capacity = count; - } - - //! Initialize this value as constant string, without calling destructor. - void SetStringRaw(StringRefType s) RAPIDJSON_NOEXCEPT { - data_.f.flags = kConstStringFlag; - SetStringPointer(s); - data_.s.length = s.length; - } - - //! Initialize this value as copy string with initial data, without calling destructor. - void SetStringRaw(StringRefType s, Allocator& allocator) { - Ch* str = 0; - if (ShortString::Usable(s.length)) { - data_.f.flags = kShortStringFlag; - data_.ss.SetLength(s.length); - str = data_.ss.str; - } else { - data_.f.flags = kCopyStringFlag; - data_.s.length = s.length; - str = static_cast(allocator.Malloc((s.length + 1) * sizeof(Ch))); - SetStringPointer(str); - } - std::memcpy(str, s, s.length * sizeof(Ch)); - str[s.length] = '\0'; - } - - //! Assignment without calling destructor - void RawAssign(GenericValue& rhs) RAPIDJSON_NOEXCEPT { - data_ = rhs.data_; - // data_.f.flags = rhs.data_.f.flags; - rhs.data_.f.flags = kNullFlag; - } - - template - bool StringEqual(const GenericValue& rhs) const { - RAPIDJSON_ASSERT(IsString()); - RAPIDJSON_ASSERT(rhs.IsString()); - - const SizeType len1 = GetStringLength(); - const SizeType len2 = rhs.GetStringLength(); - if(len1 != len2) { return false; } - - const Ch* const str1 = GetString(); - const Ch* const str2 = rhs.GetString(); - if(str1 == str2) { return true; } // fast path for constant string - - return (std::memcmp(str1, str2, sizeof(Ch) * len1) == 0); - } - - Data data_; -}; - -//! GenericValue with UTF8 encoding -typedef GenericValue > Value; - -/////////////////////////////////////////////////////////////////////////////// -// GenericDocument - -//! A document for parsing JSON text as DOM. -/*! - \note implements Handler concept - \tparam Encoding Encoding for both parsing and string storage. - \tparam Allocator Allocator for allocating memory for the DOM - \tparam StackAllocator Allocator for allocating memory for stack during parsing. - \warning Although GenericDocument inherits from GenericValue, the API does \b not provide any virtual functions, especially no virtual destructor. To avoid memory leaks, do not \c delete a GenericDocument object via a pointer to a GenericValue. -*/ -template , typename StackAllocator = CrtAllocator> -class GenericDocument : public GenericValue { -public: - typedef typename Encoding::Ch Ch; //!< Character type derived from Encoding. - typedef GenericValue ValueType; //!< Value type of the document. - typedef Allocator AllocatorType; //!< Allocator type from template parameter. - - //! Constructor - /*! Creates an empty document of specified type. - \param type Mandatory type of object to create. - \param allocator Optional allocator for allocating memory. - \param stackCapacity Optional initial capacity of stack in bytes. - \param stackAllocator Optional allocator for allocating memory for stack. - */ - explicit GenericDocument(Type type, Allocator* allocator = 0, size_t stackCapacity = kDefaultStackCapacity, StackAllocator* stackAllocator = 0) : - GenericValue(type), allocator_(allocator), ownAllocator_(0), stack_(stackAllocator, stackCapacity), parseResult_() - { - if (!allocator_) - ownAllocator_ = allocator_ = RAPIDJSON_NEW(Allocator()); - } - - //! Constructor - /*! Creates an empty document which type is Null. - \param allocator Optional allocator for allocating memory. - \param stackCapacity Optional initial capacity of stack in bytes. - \param stackAllocator Optional allocator for allocating memory for stack. - */ - GenericDocument(Allocator* allocator = 0, size_t stackCapacity = kDefaultStackCapacity, StackAllocator* stackAllocator = 0) : - allocator_(allocator), ownAllocator_(0), stack_(stackAllocator, stackCapacity), parseResult_() - { - if (!allocator_) - ownAllocator_ = allocator_ = RAPIDJSON_NEW(Allocator()); - } - -#if RAPIDJSON_HAS_CXX11_RVALUE_REFS - //! Move constructor in C++11 - GenericDocument(GenericDocument&& rhs) RAPIDJSON_NOEXCEPT - : ValueType(std::forward(rhs)), // explicit cast to avoid prohibited move from Document - allocator_(rhs.allocator_), - ownAllocator_(rhs.ownAllocator_), - stack_(std::move(rhs.stack_)), - parseResult_(rhs.parseResult_) - { - rhs.allocator_ = 0; - rhs.ownAllocator_ = 0; - rhs.parseResult_ = ParseResult(); - } -#endif - - ~GenericDocument() { - Destroy(); - } - -#if RAPIDJSON_HAS_CXX11_RVALUE_REFS - //! Move assignment in C++11 - GenericDocument& operator=(GenericDocument&& rhs) RAPIDJSON_NOEXCEPT - { - // The cast to ValueType is necessary here, because otherwise it would - // attempt to call GenericValue's templated assignment operator. - ValueType::operator=(std::forward(rhs)); - - // Calling the destructor here would prematurely call stack_'s destructor - Destroy(); - - allocator_ = rhs.allocator_; - ownAllocator_ = rhs.ownAllocator_; - stack_ = std::move(rhs.stack_); - parseResult_ = rhs.parseResult_; - - rhs.allocator_ = 0; - rhs.ownAllocator_ = 0; - rhs.parseResult_ = ParseResult(); - - return *this; - } -#endif - - //! Exchange the contents of this document with those of another. - /*! - \param rhs Another document. - \note Constant complexity. - \see GenericValue::Swap - */ - GenericDocument& Swap(GenericDocument& rhs) RAPIDJSON_NOEXCEPT { - ValueType::Swap(rhs); - stack_.Swap(rhs.stack_); - internal::Swap(allocator_, rhs.allocator_); - internal::Swap(ownAllocator_, rhs.ownAllocator_); - internal::Swap(parseResult_, rhs.parseResult_); - return *this; - } - - //! free-standing swap function helper - /*! - Helper function to enable support for common swap implementation pattern based on \c std::swap: - \code - void swap(MyClass& a, MyClass& b) { - using std::swap; - swap(a.doc, b.doc); - // ... - } - \endcode - \see Swap() - */ - friend inline void swap(GenericDocument& a, GenericDocument& b) RAPIDJSON_NOEXCEPT { a.Swap(b); } - - //! Populate this document by a generator which produces SAX events. - /*! \tparam Generator A functor with bool f(Handler) prototype. - \param g Generator functor which sends SAX events to the parameter. - \return The document itself for fluent API. - */ - template - GenericDocument& Populate(Generator& g) { - ClearStackOnExit scope(*this); - if (g(*this)) { - RAPIDJSON_ASSERT(stack_.GetSize() == sizeof(ValueType)); // Got one and only one root object - ValueType::operator=(*stack_.template Pop(1));// Move value from stack to document - } - return *this; - } - - //!@name Parse from stream - //!@{ - - //! Parse JSON text from an input stream (with Encoding conversion) - /*! \tparam parseFlags Combination of \ref ParseFlag. - \tparam SourceEncoding Encoding of input stream - \tparam InputStream Type of input stream, implementing Stream concept - \param is Input stream to be parsed. - \return The document itself for fluent API. - */ - template - GenericDocument& ParseStream(InputStream& is) { - GenericReader reader( - stack_.HasAllocator() ? &stack_.GetAllocator() : 0); - ClearStackOnExit scope(*this); - parseResult_ = reader.template Parse(is, *this); - if (parseResult_) { - RAPIDJSON_ASSERT(stack_.GetSize() == sizeof(ValueType)); // Got one and only one root object - ValueType::operator=(*stack_.template Pop(1));// Move value from stack to document - } - return *this; - } - - //! Parse JSON text from an input stream - /*! \tparam parseFlags Combination of \ref ParseFlag. - \tparam InputStream Type of input stream, implementing Stream concept - \param is Input stream to be parsed. - \return The document itself for fluent API. - */ - template - GenericDocument& ParseStream(InputStream& is) { - return ParseStream(is); - } - - //! Parse JSON text from an input stream (with \ref kParseDefaultFlags) - /*! \tparam InputStream Type of input stream, implementing Stream concept - \param is Input stream to be parsed. - \return The document itself for fluent API. - */ - template - GenericDocument& ParseStream(InputStream& is) { - return ParseStream(is); - } - //!@} - - //!@name Parse in-place from mutable string - //!@{ - - //! Parse JSON text from a mutable string - /*! \tparam parseFlags Combination of \ref ParseFlag. - \param str Mutable zero-terminated string to be parsed. - \return The document itself for fluent API. - */ - template - GenericDocument& ParseInsitu(Ch* str) { - GenericInsituStringStream s(str); - return ParseStream(s); - } - - //! Parse JSON text from a mutable string (with \ref kParseDefaultFlags) - /*! \param str Mutable zero-terminated string to be parsed. - \return The document itself for fluent API. - */ - GenericDocument& ParseInsitu(Ch* str) { - return ParseInsitu(str); - } - //!@} - - //!@name Parse from read-only string - //!@{ - - //! Parse JSON text from a read-only string (with Encoding conversion) - /*! \tparam parseFlags Combination of \ref ParseFlag (must not contain \ref kParseInsituFlag). - \tparam SourceEncoding Transcoding from input Encoding - \param str Read-only zero-terminated string to be parsed. - */ - template - GenericDocument& Parse(const typename SourceEncoding::Ch* str) { - RAPIDJSON_ASSERT(!(parseFlags & kParseInsituFlag)); - GenericStringStream s(str); - return ParseStream(s); - } - - //! Parse JSON text from a read-only string - /*! \tparam parseFlags Combination of \ref ParseFlag (must not contain \ref kParseInsituFlag). - \param str Read-only zero-terminated string to be parsed. - */ - template - GenericDocument& Parse(const Ch* str) { - return Parse(str); - } - - //! Parse JSON text from a read-only string (with \ref kParseDefaultFlags) - /*! \param str Read-only zero-terminated string to be parsed. - */ - GenericDocument& Parse(const Ch* str) { - return Parse(str); - } - - template - GenericDocument& Parse(const typename SourceEncoding::Ch* str, size_t length) { - RAPIDJSON_ASSERT(!(parseFlags & kParseInsituFlag)); - MemoryStream ms(static_cast(str), length * sizeof(typename SourceEncoding::Ch)); - EncodedInputStream is(ms); - ParseStream(is); - return *this; - } - - template - GenericDocument& Parse(const Ch* str, size_t length) { - return Parse(str, length); - } - - GenericDocument& Parse(const Ch* str, size_t length) { - return Parse(str, length); - } - -#if RAPIDJSON_HAS_STDSTRING - template - GenericDocument& Parse(const std::basic_string& str) { - // c_str() is constant complexity according to standard. Should be faster than Parse(const char*, size_t) - return Parse(str.c_str()); - } - - template - GenericDocument& Parse(const std::basic_string& str) { - return Parse(str.c_str()); - } - - GenericDocument& Parse(const std::basic_string& str) { - return Parse(str); - } -#endif // RAPIDJSON_HAS_STDSTRING - - //!@} - - //!@name Handling parse errors - //!@{ - - //! Whether a parse error has occured in the last parsing. - bool HasParseError() const { return parseResult_.IsError(); } - - //! Get the \ref ParseErrorCode of last parsing. - ParseErrorCode GetParseError() const { return parseResult_.Code(); } - - //! Get the position of last parsing error in input, 0 otherwise. - size_t GetErrorOffset() const { return parseResult_.Offset(); } - - //! Implicit conversion to get the last parse result -#ifndef __clang // -Wdocumentation - /*! \return \ref ParseResult of the last parse operation - - \code - Document doc; - ParseResult ok = doc.Parse(json); - if (!ok) - printf( "JSON parse error: %s (%u)\n", GetParseError_En(ok.Code()), ok.Offset()); - \endcode - */ -#endif - operator ParseResult() const { return parseResult_; } - //!@} - - //! Get the allocator of this document. - Allocator& GetAllocator() { - RAPIDJSON_ASSERT(allocator_); - return *allocator_; - } - - //! Get the capacity of stack in bytes. - size_t GetStackCapacity() const { return stack_.GetCapacity(); } - -private: - // clear stack on any exit from ParseStream, e.g. due to exception - struct ClearStackOnExit { - explicit ClearStackOnExit(GenericDocument& d) : d_(d) {} - ~ClearStackOnExit() { d_.ClearStack(); } - private: - ClearStackOnExit(const ClearStackOnExit&); - ClearStackOnExit& operator=(const ClearStackOnExit&); - GenericDocument& d_; - }; - - // callers of the following private Handler functions - // template friend class GenericReader; // for parsing - template friend class GenericValue; // for deep copying - -public: - // Implementation of Handler - bool Null() { new (stack_.template Push()) ValueType(); return true; } - bool Bool(bool b) { new (stack_.template Push()) ValueType(b); return true; } - bool Int(int i) { new (stack_.template Push()) ValueType(i); return true; } - bool Uint(unsigned i) { new (stack_.template Push()) ValueType(i); return true; } - bool Int64(int64_t i) { new (stack_.template Push()) ValueType(i); return true; } - bool Uint64(uint64_t i) { new (stack_.template Push()) ValueType(i); return true; } - bool Double(double d) { new (stack_.template Push()) ValueType(d); return true; } - - bool RawNumber(const Ch* str, SizeType length, bool copy) { - if (copy) - new (stack_.template Push()) ValueType(str, length, GetAllocator()); - else - new (stack_.template Push()) ValueType(str, length); - return true; - } - - bool String(const Ch* str, SizeType length, bool copy) { - if (copy) - new (stack_.template Push()) ValueType(str, length, GetAllocator()); - else - new (stack_.template Push()) ValueType(str, length); - return true; - } - - bool StartObject() { new (stack_.template Push()) ValueType(kObjectType); return true; } - - bool Key(const Ch* str, SizeType length, bool copy) { return String(str, length, copy); } - - bool EndObject(SizeType memberCount) { - typename ValueType::Member* members = stack_.template Pop(memberCount); - stack_.template Top()->SetObjectRaw(members, memberCount, GetAllocator()); - return true; - } - - bool StartArray() { new (stack_.template Push()) ValueType(kArrayType); return true; } - - bool EndArray(SizeType elementCount) { - ValueType* elements = stack_.template Pop(elementCount); - stack_.template Top()->SetArrayRaw(elements, elementCount, GetAllocator()); - return true; - } - -private: - //! Prohibit copying - GenericDocument(const GenericDocument&); - //! Prohibit assignment - GenericDocument& operator=(const GenericDocument&); - - void ClearStack() { - if (Allocator::kNeedFree) - while (stack_.GetSize() > 0) // Here assumes all elements in stack array are GenericValue (Member is actually 2 GenericValue objects) - (stack_.template Pop(1))->~ValueType(); - else - stack_.Clear(); - stack_.ShrinkToFit(); - } - - void Destroy() { - RAPIDJSON_DELETE(ownAllocator_); - } - - static const size_t kDefaultStackCapacity = 1024; - Allocator* allocator_; - Allocator* ownAllocator_; - internal::Stack stack_; - ParseResult parseResult_; -}; - -//! GenericDocument with UTF8 encoding -typedef GenericDocument > Document; - -// defined here due to the dependency on GenericDocument -template -template -inline -GenericValue::GenericValue(const GenericValue& rhs, Allocator& allocator) -{ - switch (rhs.GetType()) { - case kObjectType: - case kArrayType: { // perform deep copy via SAX Handler - GenericDocument d(&allocator); - rhs.Accept(d); - RawAssign(*d.stack_.template Pop(1)); - } - break; - case kStringType: - if (rhs.data_.f.flags == kConstStringFlag) { - data_.f.flags = rhs.data_.f.flags; - data_ = *reinterpret_cast(&rhs.data_); - } else { - SetStringRaw(StringRef(rhs.GetString(), rhs.GetStringLength()), allocator); - } - break; - default: - data_.f.flags = rhs.data_.f.flags; - data_ = *reinterpret_cast(&rhs.data_); - break; - } -} - -//! Helper class for accessing Value of array type. -/*! - Instance of this helper class is obtained by \c GenericValue::GetArray(). - In addition to all APIs for array type, it provides range-based for loop if \c RAPIDJSON_HAS_CXX11_RANGE_FOR=1. -*/ -template -class GenericArray { -public: - typedef GenericArray ConstArray; - typedef GenericArray Array; - typedef ValueT PlainType; - typedef typename internal::MaybeAddConst::Type ValueType; - typedef ValueType* ValueIterator; // This may be const or non-const iterator - typedef const ValueT* ConstValueIterator; - typedef typename ValueType::AllocatorType AllocatorType; - typedef typename ValueType::StringRefType StringRefType; - - template - friend class GenericValue; - - GenericArray(const GenericArray& rhs) : value_(rhs.value_) {} - GenericArray& operator=(const GenericArray& rhs) { value_ = rhs.value_; return *this; } - ~GenericArray() {} - - SizeType Size() const { return value_.Size(); } - SizeType Capacity() const { return value_.Capacity(); } - bool Empty() const { return value_.Empty(); } - void Clear() const { value_.Clear(); } - ValueType& operator[](SizeType index) const { return value_[index]; } - ValueIterator Begin() const { return value_.Begin(); } - ValueIterator End() const { return value_.End(); } - GenericArray Reserve(SizeType newCapacity, AllocatorType &allocator) const { value_.Reserve(newCapacity, allocator); return *this; } - GenericArray PushBack(ValueType& value, AllocatorType& allocator) const { value_.PushBack(value, allocator); return *this; } -#if RAPIDJSON_HAS_CXX11_RVALUE_REFS - GenericArray PushBack(ValueType&& value, AllocatorType& allocator) const { value_.PushBack(value, allocator); return *this; } -#endif // RAPIDJSON_HAS_CXX11_RVALUE_REFS - GenericArray PushBack(StringRefType value, AllocatorType& allocator) const { value_.PushBack(value, allocator); return *this; } - template RAPIDJSON_DISABLEIF_RETURN((internal::OrExpr, internal::IsGenericValue >), (const GenericArray&)) PushBack(T value, AllocatorType& allocator) const { value_.PushBack(value, allocator); return *this; } - GenericArray PopBack() const { value_.PopBack(); return *this; } - ValueIterator Erase(ConstValueIterator pos) const { return value_.Erase(pos); } - ValueIterator Erase(ConstValueIterator first, ConstValueIterator last) const { return value_.Erase(first, last); } - -#if RAPIDJSON_HAS_CXX11_RANGE_FOR - ValueIterator begin() const { return value_.Begin(); } - ValueIterator end() const { return value_.End(); } -#endif - -private: - GenericArray(); - GenericArray(ValueType& value) : value_(value) {} - ValueType& value_; -}; - -//! Helper class for accessing Value of object type. -/*! - Instance of this helper class is obtained by \c GenericValue::GetObject(). - In addition to all APIs for array type, it provides range-based for loop if \c RAPIDJSON_HAS_CXX11_RANGE_FOR=1. -*/ -template -class GenericObject { -public: - typedef GenericObject ConstObject; - typedef GenericObject Object; - typedef ValueT PlainType; - typedef typename internal::MaybeAddConst::Type ValueType; - typedef GenericMemberIterator MemberIterator; // This may be const or non-const iterator - typedef GenericMemberIterator ConstMemberIterator; - typedef typename ValueType::AllocatorType AllocatorType; - typedef typename ValueType::StringRefType StringRefType; - typedef typename ValueType::EncodingType EncodingType; - typedef typename ValueType::Ch Ch; - - template - friend class GenericValue; - - GenericObject(const GenericObject& rhs) : value_(rhs.value_) {} - GenericObject& operator=(const GenericObject& rhs) { value_ = rhs.value_; return *this; } - ~GenericObject() {} - - SizeType MemberCount() const { return value_.MemberCount(); } - bool ObjectEmpty() const { return value_.ObjectEmpty(); } - template ValueType& operator[](T* name) const { return value_[name]; } - template ValueType& operator[](const GenericValue& name) const { return value_[name]; } -#if RAPIDJSON_HAS_STDSTRING - ValueType& operator[](const std::basic_string& name) const { return value_[name]; } -#endif - MemberIterator MemberBegin() const { return value_.MemberBegin(); } - MemberIterator MemberEnd() const { return value_.MemberEnd(); } - bool HasMember(const Ch* name) const { return value_.HasMember(name); } -#if RAPIDJSON_HAS_STDSTRING - bool HasMember(const std::basic_string& name) const { return value_.HasMember(name); } -#endif - template bool HasMember(const GenericValue& name) const { return value_.HasMember(name); } - MemberIterator FindMember(const Ch* name) const { return value_.FindMember(name); } - template MemberIterator FindMember(const GenericValue& name) const { return value_.FindMember(name); } -#if RAPIDJSON_HAS_STDSTRING - MemberIterator FindMember(const std::basic_string& name) const { return value_.FindMember(name); } -#endif - GenericObject AddMember(ValueType& name, ValueType& value, AllocatorType& allocator) const { value_.AddMember(name, value, allocator); return *this; } - GenericObject AddMember(ValueType& name, StringRefType value, AllocatorType& allocator) const { value_.AddMember(name, value, allocator); return *this; } -#if RAPIDJSON_HAS_STDSTRING - GenericObject AddMember(ValueType& name, std::basic_string& value, AllocatorType& allocator) const { value_.AddMember(name, value, allocator); return *this; } -#endif - template RAPIDJSON_DISABLEIF_RETURN((internal::OrExpr, internal::IsGenericValue >), (ValueType&)) AddMember(ValueType& name, T value, AllocatorType& allocator) const { value_.AddMember(name, value, allocator); return *this; } -#if RAPIDJSON_HAS_CXX11_RVALUE_REFS - GenericObject AddMember(ValueType&& name, ValueType&& value, AllocatorType& allocator) const { value_.AddMember(name, value, allocator); return *this; } - GenericObject AddMember(ValueType&& name, ValueType& value, AllocatorType& allocator) const { value_.AddMember(name, value, allocator); return *this; } - GenericObject AddMember(ValueType& name, ValueType&& value, AllocatorType& allocator) const { value_.AddMember(name, value, allocator); return *this; } - GenericObject AddMember(StringRefType name, ValueType&& value, AllocatorType& allocator) const { value_.AddMember(name, value, allocator); return *this; } -#endif // RAPIDJSON_HAS_CXX11_RVALUE_REFS - GenericObject AddMember(StringRefType name, ValueType& value, AllocatorType& allocator) const { value_.AddMember(name, value, allocator); return *this; } - GenericObject AddMember(StringRefType name, StringRefType value, AllocatorType& allocator) const { value_.AddMember(name, value, allocator); return *this; } - template RAPIDJSON_DISABLEIF_RETURN((internal::OrExpr, internal::IsGenericValue >), (GenericObject)) AddMember(StringRefType name, T value, AllocatorType& allocator) const { value_.AddMember(name, value, allocator); return *this; } - void RemoveAllMembers() { return value_.RemoveAllMembers(); } - bool RemoveMember(const Ch* name) const { return value_.RemoveMember(name); } -#if RAPIDJSON_HAS_STDSTRING - bool RemoveMember(const std::basic_string& name) const { return value_.RemoveMember(name); } -#endif - template bool RemoveMember(const GenericValue& name) const { return value_.RemoveMember(name); } - MemberIterator RemoveMember(MemberIterator m) const { return value_.RemoveMember(m); } - MemberIterator EraseMember(ConstMemberIterator pos) const { return value_.EraseMember(pos); } - MemberIterator EraseMember(ConstMemberIterator first, ConstMemberIterator last) const { return value_.EraseMember(first, last); } - bool EraseMember(const Ch* name) const { return value_.EraseMember(name); } -#if RAPIDJSON_HAS_STDSTRING - bool EraseMember(const std::basic_string& name) const { return EraseMember(ValueType(StringRef(name))); } -#endif - template bool EraseMember(const GenericValue& name) const { return value_.EraseMember(name); } - -#if RAPIDJSON_HAS_CXX11_RANGE_FOR - MemberIterator begin() const { return value_.MemberBegin(); } - MemberIterator end() const { return value_.MemberEnd(); } -#endif - -private: - GenericObject(); - GenericObject(ValueType& value) : value_(value) {} - ValueType& value_; -}; - -RAPIDJSON_NAMESPACE_END -RAPIDJSON_DIAG_POP - -#endif // RAPIDJSON_DOCUMENT_H_ diff --git a/slsReceiverSoftware/include/rapidjson/encodedstream.h b/slsReceiverSoftware/include/rapidjson/encodedstream.h deleted file mode 100644 index 145068386..000000000 --- a/slsReceiverSoftware/include/rapidjson/encodedstream.h +++ /dev/null @@ -1,299 +0,0 @@ -// Tencent is pleased to support the open source community by making RapidJSON available. -// -// Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved. -// -// Licensed under the MIT License (the "License"); you may not use this file except -// in compliance with the License. You may obtain a copy of the License at -// -// http://opensource.org/licenses/MIT -// -// Unless required by applicable law or agreed to in writing, software distributed -// under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR -// CONDITIONS OF ANY KIND, either express or implied. See the License for the -// specific language governing permissions and limitations under the License. - -#ifndef RAPIDJSON_ENCODEDSTREAM_H_ -#define RAPIDJSON_ENCODEDSTREAM_H_ - -#include "stream.h" -#include "memorystream.h" - -#ifdef __GNUC__ -RAPIDJSON_DIAG_PUSH -RAPIDJSON_DIAG_OFF(effc++) -#endif - -#ifdef __clang__ -RAPIDJSON_DIAG_PUSH -RAPIDJSON_DIAG_OFF(padded) -#endif - -RAPIDJSON_NAMESPACE_BEGIN - -//! Input byte stream wrapper with a statically bound encoding. -/*! - \tparam Encoding The interpretation of encoding of the stream. Either UTF8, UTF16LE, UTF16BE, UTF32LE, UTF32BE. - \tparam InputByteStream Type of input byte stream. For example, FileReadStream. -*/ -template -class EncodedInputStream { - RAPIDJSON_STATIC_ASSERT(sizeof(typename InputByteStream::Ch) == 1); -public: - typedef typename Encoding::Ch Ch; - - EncodedInputStream(InputByteStream& is) : is_(is) { - current_ = Encoding::TakeBOM(is_); - } - - Ch Peek() const { return current_; } - Ch Take() { Ch c = current_; current_ = Encoding::Take(is_); return c; } - size_t Tell() const { return is_.Tell(); } - - // Not implemented - void Put(Ch) { RAPIDJSON_ASSERT(false); } - void Flush() { RAPIDJSON_ASSERT(false); } - Ch* PutBegin() { RAPIDJSON_ASSERT(false); return 0; } - size_t PutEnd(Ch*) { RAPIDJSON_ASSERT(false); return 0; } - -private: - EncodedInputStream(const EncodedInputStream&); - EncodedInputStream& operator=(const EncodedInputStream&); - - InputByteStream& is_; - Ch current_; -}; - -//! Specialized for UTF8 MemoryStream. -template <> -class EncodedInputStream, MemoryStream> { -public: - typedef UTF8<>::Ch Ch; - - EncodedInputStream(MemoryStream& is) : is_(is) { - if (static_cast(is_.Peek()) == 0xEFu) is_.Take(); - if (static_cast(is_.Peek()) == 0xBBu) is_.Take(); - if (static_cast(is_.Peek()) == 0xBFu) is_.Take(); - } - Ch Peek() const { return is_.Peek(); } - Ch Take() { return is_.Take(); } - size_t Tell() const { return is_.Tell(); } - - // Not implemented - void Put(Ch) {} - void Flush() {} - Ch* PutBegin() { return 0; } - size_t PutEnd(Ch*) { return 0; } - - MemoryStream& is_; - -private: - EncodedInputStream(const EncodedInputStream&); - EncodedInputStream& operator=(const EncodedInputStream&); -}; - -//! Output byte stream wrapper with statically bound encoding. -/*! - \tparam Encoding The interpretation of encoding of the stream. Either UTF8, UTF16LE, UTF16BE, UTF32LE, UTF32BE. - \tparam OutputByteStream Type of input byte stream. For example, FileWriteStream. -*/ -template -class EncodedOutputStream { - RAPIDJSON_STATIC_ASSERT(sizeof(typename OutputByteStream::Ch) == 1); -public: - typedef typename Encoding::Ch Ch; - - EncodedOutputStream(OutputByteStream& os, bool putBOM = true) : os_(os) { - if (putBOM) - Encoding::PutBOM(os_); - } - - void Put(Ch c) { Encoding::Put(os_, c); } - void Flush() { os_.Flush(); } - - // Not implemented - Ch Peek() const { RAPIDJSON_ASSERT(false); return 0;} - Ch Take() { RAPIDJSON_ASSERT(false); return 0;} - size_t Tell() const { RAPIDJSON_ASSERT(false); return 0; } - Ch* PutBegin() { RAPIDJSON_ASSERT(false); return 0; } - size_t PutEnd(Ch*) { RAPIDJSON_ASSERT(false); return 0; } - -private: - EncodedOutputStream(const EncodedOutputStream&); - EncodedOutputStream& operator=(const EncodedOutputStream&); - - OutputByteStream& os_; -}; - -#define RAPIDJSON_ENCODINGS_FUNC(x) UTF8::x, UTF16LE::x, UTF16BE::x, UTF32LE::x, UTF32BE::x - -//! Input stream wrapper with dynamically bound encoding and automatic encoding detection. -/*! - \tparam CharType Type of character for reading. - \tparam InputByteStream type of input byte stream to be wrapped. -*/ -template -class AutoUTFInputStream { - RAPIDJSON_STATIC_ASSERT(sizeof(typename InputByteStream::Ch) == 1); -public: - typedef CharType Ch; - - //! Constructor. - /*! - \param is input stream to be wrapped. - \param type UTF encoding type if it is not detected from the stream. - */ - AutoUTFInputStream(InputByteStream& is, UTFType type = kUTF8) : is_(&is), type_(type), hasBOM_(false) { - RAPIDJSON_ASSERT(type >= kUTF8 && type <= kUTF32BE); - DetectType(); - static const TakeFunc f[] = { RAPIDJSON_ENCODINGS_FUNC(Take) }; - takeFunc_ = f[type_]; - current_ = takeFunc_(*is_); - } - - UTFType GetType() const { return type_; } - bool HasBOM() const { return hasBOM_; } - - Ch Peek() const { return current_; } - Ch Take() { Ch c = current_; current_ = takeFunc_(*is_); return c; } - size_t Tell() const { return is_->Tell(); } - - // Not implemented - void Put(Ch) { RAPIDJSON_ASSERT(false); } - void Flush() { RAPIDJSON_ASSERT(false); } - Ch* PutBegin() { RAPIDJSON_ASSERT(false); return 0; } - size_t PutEnd(Ch*) { RAPIDJSON_ASSERT(false); return 0; } - -private: - AutoUTFInputStream(const AutoUTFInputStream&); - AutoUTFInputStream& operator=(const AutoUTFInputStream&); - - // Detect encoding type with BOM or RFC 4627 - void DetectType() { - // BOM (Byte Order Mark): - // 00 00 FE FF UTF-32BE - // FF FE 00 00 UTF-32LE - // FE FF UTF-16BE - // FF FE UTF-16LE - // EF BB BF UTF-8 - - const unsigned char* c = reinterpret_cast(is_->Peek4()); - if (!c) - return; - - unsigned bom = static_cast(c[0] | (c[1] << 8) | (c[2] << 16) | (c[3] << 24)); - hasBOM_ = false; - if (bom == 0xFFFE0000) { type_ = kUTF32BE; hasBOM_ = true; is_->Take(); is_->Take(); is_->Take(); is_->Take(); } - else if (bom == 0x0000FEFF) { type_ = kUTF32LE; hasBOM_ = true; is_->Take(); is_->Take(); is_->Take(); is_->Take(); } - else if ((bom & 0xFFFF) == 0xFFFE) { type_ = kUTF16BE; hasBOM_ = true; is_->Take(); is_->Take(); } - else if ((bom & 0xFFFF) == 0xFEFF) { type_ = kUTF16LE; hasBOM_ = true; is_->Take(); is_->Take(); } - else if ((bom & 0xFFFFFF) == 0xBFBBEF) { type_ = kUTF8; hasBOM_ = true; is_->Take(); is_->Take(); is_->Take(); } - - // RFC 4627: Section 3 - // "Since the first two characters of a JSON text will always be ASCII - // characters [RFC0020], it is possible to determine whether an octet - // stream is UTF-8, UTF-16 (BE or LE), or UTF-32 (BE or LE) by looking - // at the pattern of nulls in the first four octets." - // 00 00 00 xx UTF-32BE - // 00 xx 00 xx UTF-16BE - // xx 00 00 00 UTF-32LE - // xx 00 xx 00 UTF-16LE - // xx xx xx xx UTF-8 - - if (!hasBOM_) { - unsigned pattern = (c[0] ? 1 : 0) | (c[1] ? 2 : 0) | (c[2] ? 4 : 0) | (c[3] ? 8 : 0); - switch (pattern) { - case 0x08: type_ = kUTF32BE; break; - case 0x0A: type_ = kUTF16BE; break; - case 0x01: type_ = kUTF32LE; break; - case 0x05: type_ = kUTF16LE; break; - case 0x0F: type_ = kUTF8; break; - default: break; // Use type defined by user. - } - } - - // Runtime check whether the size of character type is sufficient. It only perform checks with assertion. - if (type_ == kUTF16LE || type_ == kUTF16BE) RAPIDJSON_ASSERT(sizeof(Ch) >= 2); - if (type_ == kUTF32LE || type_ == kUTF32BE) RAPIDJSON_ASSERT(sizeof(Ch) >= 4); - } - - typedef Ch (*TakeFunc)(InputByteStream& is); - InputByteStream* is_; - UTFType type_; - Ch current_; - TakeFunc takeFunc_; - bool hasBOM_; -}; - -//! Output stream wrapper with dynamically bound encoding and automatic encoding detection. -/*! - \tparam CharType Type of character for writing. - \tparam OutputByteStream type of output byte stream to be wrapped. -*/ -template -class AutoUTFOutputStream { - RAPIDJSON_STATIC_ASSERT(sizeof(typename OutputByteStream::Ch) == 1); -public: - typedef CharType Ch; - - //! Constructor. - /*! - \param os output stream to be wrapped. - \param type UTF encoding type. - \param putBOM Whether to write BOM at the beginning of the stream. - */ - AutoUTFOutputStream(OutputByteStream& os, UTFType type, bool putBOM) : os_(&os), type_(type) { - RAPIDJSON_ASSERT(type >= kUTF8 && type <= kUTF32BE); - - // Runtime check whether the size of character type is sufficient. It only perform checks with assertion. - if (type_ == kUTF16LE || type_ == kUTF16BE) RAPIDJSON_ASSERT(sizeof(Ch) >= 2); - if (type_ == kUTF32LE || type_ == kUTF32BE) RAPIDJSON_ASSERT(sizeof(Ch) >= 4); - - static const PutFunc f[] = { RAPIDJSON_ENCODINGS_FUNC(Put) }; - putFunc_ = f[type_]; - - if (putBOM) - PutBOM(); - } - - UTFType GetType() const { return type_; } - - void Put(Ch c) { putFunc_(*os_, c); } - void Flush() { os_->Flush(); } - - // Not implemented - Ch Peek() const { RAPIDJSON_ASSERT(false); return 0;} - Ch Take() { RAPIDJSON_ASSERT(false); return 0;} - size_t Tell() const { RAPIDJSON_ASSERT(false); return 0; } - Ch* PutBegin() { RAPIDJSON_ASSERT(false); return 0; } - size_t PutEnd(Ch*) { RAPIDJSON_ASSERT(false); return 0; } - -private: - AutoUTFOutputStream(const AutoUTFOutputStream&); - AutoUTFOutputStream& operator=(const AutoUTFOutputStream&); - - void PutBOM() { - typedef void (*PutBOMFunc)(OutputByteStream&); - static const PutBOMFunc f[] = { RAPIDJSON_ENCODINGS_FUNC(PutBOM) }; - f[type_](*os_); - } - - typedef void (*PutFunc)(OutputByteStream&, Ch); - - OutputByteStream* os_; - UTFType type_; - PutFunc putFunc_; -}; - -#undef RAPIDJSON_ENCODINGS_FUNC - -RAPIDJSON_NAMESPACE_END - -#ifdef __clang__ -RAPIDJSON_DIAG_POP -#endif - -#ifdef __GNUC__ -RAPIDJSON_DIAG_POP -#endif - -#endif // RAPIDJSON_FILESTREAM_H_ diff --git a/slsReceiverSoftware/include/rapidjson/encodings.h b/slsReceiverSoftware/include/rapidjson/encodings.h deleted file mode 100644 index baa7c2b17..000000000 --- a/slsReceiverSoftware/include/rapidjson/encodings.h +++ /dev/null @@ -1,716 +0,0 @@ -// Tencent is pleased to support the open source community by making RapidJSON available. -// -// Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved. -// -// Licensed under the MIT License (the "License"); you may not use this file except -// in compliance with the License. You may obtain a copy of the License at -// -// http://opensource.org/licenses/MIT -// -// Unless required by applicable law or agreed to in writing, software distributed -// under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR -// CONDITIONS OF ANY KIND, either express or implied. See the License for the -// specific language governing permissions and limitations under the License. - -#ifndef RAPIDJSON_ENCODINGS_H_ -#define RAPIDJSON_ENCODINGS_H_ - -#include "rapidjson.h" - -#ifdef _MSC_VER -RAPIDJSON_DIAG_PUSH -RAPIDJSON_DIAG_OFF(4244) // conversion from 'type1' to 'type2', possible loss of data -RAPIDJSON_DIAG_OFF(4702) // unreachable code -#elif defined(__GNUC__) -RAPIDJSON_DIAG_PUSH -RAPIDJSON_DIAG_OFF(effc++) -RAPIDJSON_DIAG_OFF(overflow) -#endif - -RAPIDJSON_NAMESPACE_BEGIN - -/////////////////////////////////////////////////////////////////////////////// -// Encoding - -/*! \class rapidjson::Encoding - \brief Concept for encoding of Unicode characters. - -\code -concept Encoding { - typename Ch; //! Type of character. A "character" is actually a code unit in unicode's definition. - - enum { supportUnicode = 1 }; // or 0 if not supporting unicode - - //! \brief Encode a Unicode codepoint to an output stream. - //! \param os Output stream. - //! \param codepoint An unicode codepoint, ranging from 0x0 to 0x10FFFF inclusively. - template - static void Encode(OutputStream& os, unsigned codepoint); - - //! \brief Decode a Unicode codepoint from an input stream. - //! \param is Input stream. - //! \param codepoint Output of the unicode codepoint. - //! \return true if a valid codepoint can be decoded from the stream. - template - static bool Decode(InputStream& is, unsigned* codepoint); - - //! \brief Validate one Unicode codepoint from an encoded stream. - //! \param is Input stream to obtain codepoint. - //! \param os Output for copying one codepoint. - //! \return true if it is valid. - //! \note This function just validating and copying the codepoint without actually decode it. - template - static bool Validate(InputStream& is, OutputStream& os); - - // The following functions are deal with byte streams. - - //! Take a character from input byte stream, skip BOM if exist. - template - static CharType TakeBOM(InputByteStream& is); - - //! Take a character from input byte stream. - template - static Ch Take(InputByteStream& is); - - //! Put BOM to output byte stream. - template - static void PutBOM(OutputByteStream& os); - - //! Put a character to output byte stream. - template - static void Put(OutputByteStream& os, Ch c); -}; -\endcode -*/ - -/////////////////////////////////////////////////////////////////////////////// -// UTF8 - -//! UTF-8 encoding. -/*! http://en.wikipedia.org/wiki/UTF-8 - http://tools.ietf.org/html/rfc3629 - \tparam CharType Code unit for storing 8-bit UTF-8 data. Default is char. - \note implements Encoding concept -*/ -template -struct UTF8 { - typedef CharType Ch; - - enum { supportUnicode = 1 }; - - template - static void Encode(OutputStream& os, unsigned codepoint) { - if (codepoint <= 0x7F) - os.Put(static_cast(codepoint & 0xFF)); - else if (codepoint <= 0x7FF) { - os.Put(static_cast(0xC0 | ((codepoint >> 6) & 0xFF))); - os.Put(static_cast(0x80 | ((codepoint & 0x3F)))); - } - else if (codepoint <= 0xFFFF) { - os.Put(static_cast(0xE0 | ((codepoint >> 12) & 0xFF))); - os.Put(static_cast(0x80 | ((codepoint >> 6) & 0x3F))); - os.Put(static_cast(0x80 | (codepoint & 0x3F))); - } - else { - RAPIDJSON_ASSERT(codepoint <= 0x10FFFF); - os.Put(static_cast(0xF0 | ((codepoint >> 18) & 0xFF))); - os.Put(static_cast(0x80 | ((codepoint >> 12) & 0x3F))); - os.Put(static_cast(0x80 | ((codepoint >> 6) & 0x3F))); - os.Put(static_cast(0x80 | (codepoint & 0x3F))); - } - } - - template - static void EncodeUnsafe(OutputStream& os, unsigned codepoint) { - if (codepoint <= 0x7F) - PutUnsafe(os, static_cast(codepoint & 0xFF)); - else if (codepoint <= 0x7FF) { - PutUnsafe(os, static_cast(0xC0 | ((codepoint >> 6) & 0xFF))); - PutUnsafe(os, static_cast(0x80 | ((codepoint & 0x3F)))); - } - else if (codepoint <= 0xFFFF) { - PutUnsafe(os, static_cast(0xE0 | ((codepoint >> 12) & 0xFF))); - PutUnsafe(os, static_cast(0x80 | ((codepoint >> 6) & 0x3F))); - PutUnsafe(os, static_cast(0x80 | (codepoint & 0x3F))); - } - else { - RAPIDJSON_ASSERT(codepoint <= 0x10FFFF); - PutUnsafe(os, static_cast(0xF0 | ((codepoint >> 18) & 0xFF))); - PutUnsafe(os, static_cast(0x80 | ((codepoint >> 12) & 0x3F))); - PutUnsafe(os, static_cast(0x80 | ((codepoint >> 6) & 0x3F))); - PutUnsafe(os, static_cast(0x80 | (codepoint & 0x3F))); - } - } - - template - static bool Decode(InputStream& is, unsigned* codepoint) { -#define COPY() c = is.Take(); *codepoint = (*codepoint << 6) | (static_cast(c) & 0x3Fu) -#define TRANS(mask) result &= ((GetRange(static_cast(c)) & mask) != 0) -#define TAIL() COPY(); TRANS(0x70) - typename InputStream::Ch c = is.Take(); - if (!(c & 0x80)) { - *codepoint = static_cast(c); - return true; - } - - unsigned char type = GetRange(static_cast(c)); - if (type >= 32) { - *codepoint = 0; - } else { - *codepoint = (0xFF >> type) & static_cast(c); - } - bool result = true; - switch (type) { - case 2: TAIL(); return result; - case 3: TAIL(); TAIL(); return result; - case 4: COPY(); TRANS(0x50); TAIL(); return result; - case 5: COPY(); TRANS(0x10); TAIL(); TAIL(); return result; - case 6: TAIL(); TAIL(); TAIL(); return result; - case 10: COPY(); TRANS(0x20); TAIL(); return result; - case 11: COPY(); TRANS(0x60); TAIL(); TAIL(); return result; - default: return false; - } -#undef COPY -#undef TRANS -#undef TAIL - } - - template - static bool Validate(InputStream& is, OutputStream& os) { -#define COPY() os.Put(c = is.Take()) -#define TRANS(mask) result &= ((GetRange(static_cast(c)) & mask) != 0) -#define TAIL() COPY(); TRANS(0x70) - Ch c; - COPY(); - if (!(c & 0x80)) - return true; - - bool result = true; - switch (GetRange(static_cast(c))) { - case 2: TAIL(); return result; - case 3: TAIL(); TAIL(); return result; - case 4: COPY(); TRANS(0x50); TAIL(); return result; - case 5: COPY(); TRANS(0x10); TAIL(); TAIL(); return result; - case 6: TAIL(); TAIL(); TAIL(); return result; - case 10: COPY(); TRANS(0x20); TAIL(); return result; - case 11: COPY(); TRANS(0x60); TAIL(); TAIL(); return result; - default: return false; - } -#undef COPY -#undef TRANS -#undef TAIL - } - - static unsigned char GetRange(unsigned char c) { - // Referring to DFA of http://bjoern.hoehrmann.de/utf-8/decoder/dfa/ - // With new mapping 1 -> 0x10, 7 -> 0x20, 9 -> 0x40, such that AND operation can test multiple types. - static const unsigned char type[] = { - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10, - 0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40, - 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, - 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, - 8,8,2,2,2,2,2,2,2,2,2,2,2,2,2,2, 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, - 10,3,3,3,3,3,3,3,3,3,3,3,3,4,3,3, 11,6,6,6,5,8,8,8,8,8,8,8,8,8,8,8, - }; - return type[c]; - } - - template - static CharType TakeBOM(InputByteStream& is) { - RAPIDJSON_STATIC_ASSERT(sizeof(typename InputByteStream::Ch) == 1); - typename InputByteStream::Ch c = Take(is); - if (static_cast(c) != 0xEFu) return c; - c = is.Take(); - if (static_cast(c) != 0xBBu) return c; - c = is.Take(); - if (static_cast(c) != 0xBFu) return c; - c = is.Take(); - return c; - } - - template - static Ch Take(InputByteStream& is) { - RAPIDJSON_STATIC_ASSERT(sizeof(typename InputByteStream::Ch) == 1); - return static_cast(is.Take()); - } - - template - static void PutBOM(OutputByteStream& os) { - RAPIDJSON_STATIC_ASSERT(sizeof(typename OutputByteStream::Ch) == 1); - os.Put(static_cast(0xEFu)); - os.Put(static_cast(0xBBu)); - os.Put(static_cast(0xBFu)); - } - - template - static void Put(OutputByteStream& os, Ch c) { - RAPIDJSON_STATIC_ASSERT(sizeof(typename OutputByteStream::Ch) == 1); - os.Put(static_cast(c)); - } -}; - -/////////////////////////////////////////////////////////////////////////////// -// UTF16 - -//! UTF-16 encoding. -/*! http://en.wikipedia.org/wiki/UTF-16 - http://tools.ietf.org/html/rfc2781 - \tparam CharType Type for storing 16-bit UTF-16 data. Default is wchar_t. C++11 may use char16_t instead. - \note implements Encoding concept - - \note For in-memory access, no need to concern endianness. The code units and code points are represented by CPU's endianness. - For streaming, use UTF16LE and UTF16BE, which handle endianness. -*/ -template -struct UTF16 { - typedef CharType Ch; - RAPIDJSON_STATIC_ASSERT(sizeof(Ch) >= 2); - - enum { supportUnicode = 1 }; - - template - static void Encode(OutputStream& os, unsigned codepoint) { - RAPIDJSON_STATIC_ASSERT(sizeof(typename OutputStream::Ch) >= 2); - if (codepoint <= 0xFFFF) { - RAPIDJSON_ASSERT(codepoint < 0xD800 || codepoint > 0xDFFF); // Code point itself cannot be surrogate pair - os.Put(static_cast(codepoint)); - } - else { - RAPIDJSON_ASSERT(codepoint <= 0x10FFFF); - unsigned v = codepoint - 0x10000; - os.Put(static_cast((v >> 10) | 0xD800)); - os.Put((v & 0x3FF) | 0xDC00); - } - } - - - template - static void EncodeUnsafe(OutputStream& os, unsigned codepoint) { - RAPIDJSON_STATIC_ASSERT(sizeof(typename OutputStream::Ch) >= 2); - if (codepoint <= 0xFFFF) { - RAPIDJSON_ASSERT(codepoint < 0xD800 || codepoint > 0xDFFF); // Code point itself cannot be surrogate pair - PutUnsafe(os, static_cast(codepoint)); - } - else { - RAPIDJSON_ASSERT(codepoint <= 0x10FFFF); - unsigned v = codepoint - 0x10000; - PutUnsafe(os, static_cast((v >> 10) | 0xD800)); - PutUnsafe(os, (v & 0x3FF) | 0xDC00); - } - } - - template - static bool Decode(InputStream& is, unsigned* codepoint) { - RAPIDJSON_STATIC_ASSERT(sizeof(typename InputStream::Ch) >= 2); - typename InputStream::Ch c = is.Take(); - if (c < 0xD800 || c > 0xDFFF) { - *codepoint = static_cast(c); - return true; - } - else if (c <= 0xDBFF) { - *codepoint = (static_cast(c) & 0x3FF) << 10; - c = is.Take(); - *codepoint |= (static_cast(c) & 0x3FF); - *codepoint += 0x10000; - return c >= 0xDC00 && c <= 0xDFFF; - } - return false; - } - - template - static bool Validate(InputStream& is, OutputStream& os) { - RAPIDJSON_STATIC_ASSERT(sizeof(typename InputStream::Ch) >= 2); - RAPIDJSON_STATIC_ASSERT(sizeof(typename OutputStream::Ch) >= 2); - typename InputStream::Ch c; - os.Put(static_cast(c = is.Take())); - if (c < 0xD800 || c > 0xDFFF) - return true; - else if (c <= 0xDBFF) { - os.Put(c = is.Take()); - return c >= 0xDC00 && c <= 0xDFFF; - } - return false; - } -}; - -//! UTF-16 little endian encoding. -template -struct UTF16LE : UTF16 { - template - static CharType TakeBOM(InputByteStream& is) { - RAPIDJSON_STATIC_ASSERT(sizeof(typename InputByteStream::Ch) == 1); - CharType c = Take(is); - return static_cast(c) == 0xFEFFu ? Take(is) : c; - } - - template - static CharType Take(InputByteStream& is) { - RAPIDJSON_STATIC_ASSERT(sizeof(typename InputByteStream::Ch) == 1); - unsigned c = static_cast(is.Take()); - c |= static_cast(static_cast(is.Take())) << 8; - return static_cast(c); - } - - template - static void PutBOM(OutputByteStream& os) { - RAPIDJSON_STATIC_ASSERT(sizeof(typename OutputByteStream::Ch) == 1); - os.Put(static_cast(0xFFu)); - os.Put(static_cast(0xFEu)); - } - - template - static void Put(OutputByteStream& os, CharType c) { - RAPIDJSON_STATIC_ASSERT(sizeof(typename OutputByteStream::Ch) == 1); - os.Put(static_cast(static_cast(c) & 0xFFu)); - os.Put(static_cast((static_cast(c) >> 8) & 0xFFu)); - } -}; - -//! UTF-16 big endian encoding. -template -struct UTF16BE : UTF16 { - template - static CharType TakeBOM(InputByteStream& is) { - RAPIDJSON_STATIC_ASSERT(sizeof(typename InputByteStream::Ch) == 1); - CharType c = Take(is); - return static_cast(c) == 0xFEFFu ? Take(is) : c; - } - - template - static CharType Take(InputByteStream& is) { - RAPIDJSON_STATIC_ASSERT(sizeof(typename InputByteStream::Ch) == 1); - unsigned c = static_cast(static_cast(is.Take())) << 8; - c |= static_cast(is.Take()); - return static_cast(c); - } - - template - static void PutBOM(OutputByteStream& os) { - RAPIDJSON_STATIC_ASSERT(sizeof(typename OutputByteStream::Ch) == 1); - os.Put(static_cast(0xFEu)); - os.Put(static_cast(0xFFu)); - } - - template - static void Put(OutputByteStream& os, CharType c) { - RAPIDJSON_STATIC_ASSERT(sizeof(typename OutputByteStream::Ch) == 1); - os.Put(static_cast((static_cast(c) >> 8) & 0xFFu)); - os.Put(static_cast(static_cast(c) & 0xFFu)); - } -}; - -/////////////////////////////////////////////////////////////////////////////// -// UTF32 - -//! UTF-32 encoding. -/*! http://en.wikipedia.org/wiki/UTF-32 - \tparam CharType Type for storing 32-bit UTF-32 data. Default is unsigned. C++11 may use char32_t instead. - \note implements Encoding concept - - \note For in-memory access, no need to concern endianness. The code units and code points are represented by CPU's endianness. - For streaming, use UTF32LE and UTF32BE, which handle endianness. -*/ -template -struct UTF32 { - typedef CharType Ch; - RAPIDJSON_STATIC_ASSERT(sizeof(Ch) >= 4); - - enum { supportUnicode = 1 }; - - template - static void Encode(OutputStream& os, unsigned codepoint) { - RAPIDJSON_STATIC_ASSERT(sizeof(typename OutputStream::Ch) >= 4); - RAPIDJSON_ASSERT(codepoint <= 0x10FFFF); - os.Put(codepoint); - } - - template - static void EncodeUnsafe(OutputStream& os, unsigned codepoint) { - RAPIDJSON_STATIC_ASSERT(sizeof(typename OutputStream::Ch) >= 4); - RAPIDJSON_ASSERT(codepoint <= 0x10FFFF); - PutUnsafe(os, codepoint); - } - - template - static bool Decode(InputStream& is, unsigned* codepoint) { - RAPIDJSON_STATIC_ASSERT(sizeof(typename InputStream::Ch) >= 4); - Ch c = is.Take(); - *codepoint = c; - return c <= 0x10FFFF; - } - - template - static bool Validate(InputStream& is, OutputStream& os) { - RAPIDJSON_STATIC_ASSERT(sizeof(typename InputStream::Ch) >= 4); - Ch c; - os.Put(c = is.Take()); - return c <= 0x10FFFF; - } -}; - -//! UTF-32 little endian enocoding. -template -struct UTF32LE : UTF32 { - template - static CharType TakeBOM(InputByteStream& is) { - RAPIDJSON_STATIC_ASSERT(sizeof(typename InputByteStream::Ch) == 1); - CharType c = Take(is); - return static_cast(c) == 0x0000FEFFu ? Take(is) : c; - } - - template - static CharType Take(InputByteStream& is) { - RAPIDJSON_STATIC_ASSERT(sizeof(typename InputByteStream::Ch) == 1); - unsigned c = static_cast(is.Take()); - c |= static_cast(static_cast(is.Take())) << 8; - c |= static_cast(static_cast(is.Take())) << 16; - c |= static_cast(static_cast(is.Take())) << 24; - return static_cast(c); - } - - template - static void PutBOM(OutputByteStream& os) { - RAPIDJSON_STATIC_ASSERT(sizeof(typename OutputByteStream::Ch) == 1); - os.Put(static_cast(0xFFu)); - os.Put(static_cast(0xFEu)); - os.Put(static_cast(0x00u)); - os.Put(static_cast(0x00u)); - } - - template - static void Put(OutputByteStream& os, CharType c) { - RAPIDJSON_STATIC_ASSERT(sizeof(typename OutputByteStream::Ch) == 1); - os.Put(static_cast(c & 0xFFu)); - os.Put(static_cast((c >> 8) & 0xFFu)); - os.Put(static_cast((c >> 16) & 0xFFu)); - os.Put(static_cast((c >> 24) & 0xFFu)); - } -}; - -//! UTF-32 big endian encoding. -template -struct UTF32BE : UTF32 { - template - static CharType TakeBOM(InputByteStream& is) { - RAPIDJSON_STATIC_ASSERT(sizeof(typename InputByteStream::Ch) == 1); - CharType c = Take(is); - return static_cast(c) == 0x0000FEFFu ? Take(is) : c; - } - - template - static CharType Take(InputByteStream& is) { - RAPIDJSON_STATIC_ASSERT(sizeof(typename InputByteStream::Ch) == 1); - unsigned c = static_cast(static_cast(is.Take())) << 24; - c |= static_cast(static_cast(is.Take())) << 16; - c |= static_cast(static_cast(is.Take())) << 8; - c |= static_cast(static_cast(is.Take())); - return static_cast(c); - } - - template - static void PutBOM(OutputByteStream& os) { - RAPIDJSON_STATIC_ASSERT(sizeof(typename OutputByteStream::Ch) == 1); - os.Put(static_cast(0x00u)); - os.Put(static_cast(0x00u)); - os.Put(static_cast(0xFEu)); - os.Put(static_cast(0xFFu)); - } - - template - static void Put(OutputByteStream& os, CharType c) { - RAPIDJSON_STATIC_ASSERT(sizeof(typename OutputByteStream::Ch) == 1); - os.Put(static_cast((c >> 24) & 0xFFu)); - os.Put(static_cast((c >> 16) & 0xFFu)); - os.Put(static_cast((c >> 8) & 0xFFu)); - os.Put(static_cast(c & 0xFFu)); - } -}; - -/////////////////////////////////////////////////////////////////////////////// -// ASCII - -//! ASCII encoding. -/*! http://en.wikipedia.org/wiki/ASCII - \tparam CharType Code unit for storing 7-bit ASCII data. Default is char. - \note implements Encoding concept -*/ -template -struct ASCII { - typedef CharType Ch; - - enum { supportUnicode = 0 }; - - template - static void Encode(OutputStream& os, unsigned codepoint) { - RAPIDJSON_ASSERT(codepoint <= 0x7F); - os.Put(static_cast(codepoint & 0xFF)); - } - - template - static void EncodeUnsafe(OutputStream& os, unsigned codepoint) { - RAPIDJSON_ASSERT(codepoint <= 0x7F); - PutUnsafe(os, static_cast(codepoint & 0xFF)); - } - - template - static bool Decode(InputStream& is, unsigned* codepoint) { - uint8_t c = static_cast(is.Take()); - *codepoint = c; - return c <= 0X7F; - } - - template - static bool Validate(InputStream& is, OutputStream& os) { - uint8_t c = static_cast(is.Take()); - os.Put(static_cast(c)); - return c <= 0x7F; - } - - template - static CharType TakeBOM(InputByteStream& is) { - RAPIDJSON_STATIC_ASSERT(sizeof(typename InputByteStream::Ch) == 1); - uint8_t c = static_cast(Take(is)); - return static_cast(c); - } - - template - static Ch Take(InputByteStream& is) { - RAPIDJSON_STATIC_ASSERT(sizeof(typename InputByteStream::Ch) == 1); - return static_cast(is.Take()); - } - - template - static void PutBOM(OutputByteStream& os) { - RAPIDJSON_STATIC_ASSERT(sizeof(typename OutputByteStream::Ch) == 1); - (void)os; - } - - template - static void Put(OutputByteStream& os, Ch c) { - RAPIDJSON_STATIC_ASSERT(sizeof(typename OutputByteStream::Ch) == 1); - os.Put(static_cast(c)); - } -}; - -/////////////////////////////////////////////////////////////////////////////// -// AutoUTF - -//! Runtime-specified UTF encoding type of a stream. -enum UTFType { - kUTF8 = 0, //!< UTF-8. - kUTF16LE = 1, //!< UTF-16 little endian. - kUTF16BE = 2, //!< UTF-16 big endian. - kUTF32LE = 3, //!< UTF-32 little endian. - kUTF32BE = 4 //!< UTF-32 big endian. -}; - -//! Dynamically select encoding according to stream's runtime-specified UTF encoding type. -/*! \note This class can be used with AutoUTFInputtStream and AutoUTFOutputStream, which provides GetType(). -*/ -template -struct AutoUTF { - typedef CharType Ch; - - enum { supportUnicode = 1 }; - -#define RAPIDJSON_ENCODINGS_FUNC(x) UTF8::x, UTF16LE::x, UTF16BE::x, UTF32LE::x, UTF32BE::x - - template - RAPIDJSON_FORCEINLINE static void Encode(OutputStream& os, unsigned codepoint) { - typedef void (*EncodeFunc)(OutputStream&, unsigned); - static const EncodeFunc f[] = { RAPIDJSON_ENCODINGS_FUNC(Encode) }; - (*f[os.GetType()])(os, codepoint); - } - - template - RAPIDJSON_FORCEINLINE static void EncodeUnsafe(OutputStream& os, unsigned codepoint) { - typedef void (*EncodeFunc)(OutputStream&, unsigned); - static const EncodeFunc f[] = { RAPIDJSON_ENCODINGS_FUNC(EncodeUnsafe) }; - (*f[os.GetType()])(os, codepoint); - } - - template - RAPIDJSON_FORCEINLINE static bool Decode(InputStream& is, unsigned* codepoint) { - typedef bool (*DecodeFunc)(InputStream&, unsigned*); - static const DecodeFunc f[] = { RAPIDJSON_ENCODINGS_FUNC(Decode) }; - return (*f[is.GetType()])(is, codepoint); - } - - template - RAPIDJSON_FORCEINLINE static bool Validate(InputStream& is, OutputStream& os) { - typedef bool (*ValidateFunc)(InputStream&, OutputStream&); - static const ValidateFunc f[] = { RAPIDJSON_ENCODINGS_FUNC(Validate) }; - return (*f[is.GetType()])(is, os); - } - -#undef RAPIDJSON_ENCODINGS_FUNC -}; - -/////////////////////////////////////////////////////////////////////////////// -// Transcoder - -//! Encoding conversion. -template -struct Transcoder { - //! Take one Unicode codepoint from source encoding, convert it to target encoding and put it to the output stream. - template - RAPIDJSON_FORCEINLINE static bool Transcode(InputStream& is, OutputStream& os) { - unsigned codepoint; - if (!SourceEncoding::Decode(is, &codepoint)) - return false; - TargetEncoding::Encode(os, codepoint); - return true; - } - - template - RAPIDJSON_FORCEINLINE static bool TranscodeUnsafe(InputStream& is, OutputStream& os) { - unsigned codepoint; - if (!SourceEncoding::Decode(is, &codepoint)) - return false; - TargetEncoding::EncodeUnsafe(os, codepoint); - return true; - } - - //! Validate one Unicode codepoint from an encoded stream. - template - RAPIDJSON_FORCEINLINE static bool Validate(InputStream& is, OutputStream& os) { - return Transcode(is, os); // Since source/target encoding is different, must transcode. - } -}; - -// Forward declaration. -template -inline void PutUnsafe(Stream& stream, typename Stream::Ch c); - -//! Specialization of Transcoder with same source and target encoding. -template -struct Transcoder { - template - RAPIDJSON_FORCEINLINE static bool Transcode(InputStream& is, OutputStream& os) { - os.Put(is.Take()); // Just copy one code unit. This semantic is different from primary template class. - return true; - } - - template - RAPIDJSON_FORCEINLINE static bool TranscodeUnsafe(InputStream& is, OutputStream& os) { - PutUnsafe(os, is.Take()); // Just copy one code unit. This semantic is different from primary template class. - return true; - } - - template - RAPIDJSON_FORCEINLINE static bool Validate(InputStream& is, OutputStream& os) { - return Encoding::Validate(is, os); // source/target encoding are the same - } -}; - -RAPIDJSON_NAMESPACE_END - -#if defined(__GNUC__) || defined(_MSC_VER) -RAPIDJSON_DIAG_POP -#endif - -#endif // RAPIDJSON_ENCODINGS_H_ diff --git a/slsReceiverSoftware/include/rapidjson/error/en.h b/slsReceiverSoftware/include/rapidjson/error/en.h deleted file mode 100644 index 2db838bff..000000000 --- a/slsReceiverSoftware/include/rapidjson/error/en.h +++ /dev/null @@ -1,74 +0,0 @@ -// Tencent is pleased to support the open source community by making RapidJSON available. -// -// Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved. -// -// Licensed under the MIT License (the "License"); you may not use this file except -// in compliance with the License. You may obtain a copy of the License at -// -// http://opensource.org/licenses/MIT -// -// Unless required by applicable law or agreed to in writing, software distributed -// under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR -// CONDITIONS OF ANY KIND, either express or implied. See the License for the -// specific language governing permissions and limitations under the License. - -#ifndef RAPIDJSON_ERROR_EN_H_ -#define RAPIDJSON_ERROR_EN_H_ - -#include "error.h" - -#ifdef __clang__ -RAPIDJSON_DIAG_PUSH -RAPIDJSON_DIAG_OFF(switch-enum) -RAPIDJSON_DIAG_OFF(covered-switch-default) -#endif - -RAPIDJSON_NAMESPACE_BEGIN - -//! Maps error code of parsing into error message. -/*! - \ingroup RAPIDJSON_ERRORS - \param parseErrorCode Error code obtained in parsing. - \return the error message. - \note User can make a copy of this function for localization. - Using switch-case is safer for future modification of error codes. -*/ -inline const RAPIDJSON_ERROR_CHARTYPE* GetParseError_En(ParseErrorCode parseErrorCode) { - switch (parseErrorCode) { - case kParseErrorNone: return RAPIDJSON_ERROR_STRING("No error."); - - case kParseErrorDocumentEmpty: return RAPIDJSON_ERROR_STRING("The document is empty."); - case kParseErrorDocumentRootNotSingular: return RAPIDJSON_ERROR_STRING("The document root must not be followed by other values."); - - case kParseErrorValueInvalid: return RAPIDJSON_ERROR_STRING("Invalid value."); - - case kParseErrorObjectMissName: return RAPIDJSON_ERROR_STRING("Missing a name for object member."); - case kParseErrorObjectMissColon: return RAPIDJSON_ERROR_STRING("Missing a colon after a name of object member."); - case kParseErrorObjectMissCommaOrCurlyBracket: return RAPIDJSON_ERROR_STRING("Missing a comma or '}' after an object member."); - - case kParseErrorArrayMissCommaOrSquareBracket: return RAPIDJSON_ERROR_STRING("Missing a comma or ']' after an array element."); - - case kParseErrorStringUnicodeEscapeInvalidHex: return RAPIDJSON_ERROR_STRING("Incorrect hex digit after \\u escape in string."); - case kParseErrorStringUnicodeSurrogateInvalid: return RAPIDJSON_ERROR_STRING("The surrogate pair in string is invalid."); - case kParseErrorStringEscapeInvalid: return RAPIDJSON_ERROR_STRING("Invalid escape character in string."); - case kParseErrorStringMissQuotationMark: return RAPIDJSON_ERROR_STRING("Missing a closing quotation mark in string."); - case kParseErrorStringInvalidEncoding: return RAPIDJSON_ERROR_STRING("Invalid encoding in string."); - - case kParseErrorNumberTooBig: return RAPIDJSON_ERROR_STRING("Number too big to be stored in double."); - case kParseErrorNumberMissFraction: return RAPIDJSON_ERROR_STRING("Miss fraction part in number."); - case kParseErrorNumberMissExponent: return RAPIDJSON_ERROR_STRING("Miss exponent in number."); - - case kParseErrorTermination: return RAPIDJSON_ERROR_STRING("Terminate parsing due to Handler error."); - case kParseErrorUnspecificSyntaxError: return RAPIDJSON_ERROR_STRING("Unspecific syntax error."); - - default: return RAPIDJSON_ERROR_STRING("Unknown error."); - } -} - -RAPIDJSON_NAMESPACE_END - -#ifdef __clang__ -RAPIDJSON_DIAG_POP -#endif - -#endif // RAPIDJSON_ERROR_EN_H_ diff --git a/slsReceiverSoftware/include/rapidjson/error/error.h b/slsReceiverSoftware/include/rapidjson/error/error.h deleted file mode 100644 index 95cb31a72..000000000 --- a/slsReceiverSoftware/include/rapidjson/error/error.h +++ /dev/null @@ -1,155 +0,0 @@ -// Tencent is pleased to support the open source community by making RapidJSON available. -// -// Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved. -// -// Licensed under the MIT License (the "License"); you may not use this file except -// in compliance with the License. You may obtain a copy of the License at -// -// http://opensource.org/licenses/MIT -// -// Unless required by applicable law or agreed to in writing, software distributed -// under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR -// CONDITIONS OF ANY KIND, either express or implied. See the License for the -// specific language governing permissions and limitations under the License. - -#ifndef RAPIDJSON_ERROR_ERROR_H_ -#define RAPIDJSON_ERROR_ERROR_H_ - -#include "../rapidjson.h" - -#ifdef __clang__ -RAPIDJSON_DIAG_PUSH -RAPIDJSON_DIAG_OFF(padded) -#endif - -/*! \file error.h */ - -/*! \defgroup RAPIDJSON_ERRORS RapidJSON error handling */ - -/////////////////////////////////////////////////////////////////////////////// -// RAPIDJSON_ERROR_CHARTYPE - -//! Character type of error messages. -/*! \ingroup RAPIDJSON_ERRORS - The default character type is \c char. - On Windows, user can define this macro as \c TCHAR for supporting both - unicode/non-unicode settings. -*/ -#ifndef RAPIDJSON_ERROR_CHARTYPE -#define RAPIDJSON_ERROR_CHARTYPE char -#endif - -/////////////////////////////////////////////////////////////////////////////// -// RAPIDJSON_ERROR_STRING - -//! Macro for converting string literial to \ref RAPIDJSON_ERROR_CHARTYPE[]. -/*! \ingroup RAPIDJSON_ERRORS - By default this conversion macro does nothing. - On Windows, user can define this macro as \c _T(x) for supporting both - unicode/non-unicode settings. -*/ -#ifndef RAPIDJSON_ERROR_STRING -#define RAPIDJSON_ERROR_STRING(x) x -#endif - -RAPIDJSON_NAMESPACE_BEGIN - -/////////////////////////////////////////////////////////////////////////////// -// ParseErrorCode - -//! Error code of parsing. -/*! \ingroup RAPIDJSON_ERRORS - \see GenericReader::Parse, GenericReader::GetParseErrorCode -*/ -enum ParseErrorCode { - kParseErrorNone = 0, //!< No error. - - kParseErrorDocumentEmpty, //!< The document is empty. - kParseErrorDocumentRootNotSingular, //!< The document root must not follow by other values. - - kParseErrorValueInvalid, //!< Invalid value. - - kParseErrorObjectMissName, //!< Missing a name for object member. - kParseErrorObjectMissColon, //!< Missing a colon after a name of object member. - kParseErrorObjectMissCommaOrCurlyBracket, //!< Missing a comma or '}' after an object member. - - kParseErrorArrayMissCommaOrSquareBracket, //!< Missing a comma or ']' after an array element. - - kParseErrorStringUnicodeEscapeInvalidHex, //!< Incorrect hex digit after \\u escape in string. - kParseErrorStringUnicodeSurrogateInvalid, //!< The surrogate pair in string is invalid. - kParseErrorStringEscapeInvalid, //!< Invalid escape character in string. - kParseErrorStringMissQuotationMark, //!< Missing a closing quotation mark in string. - kParseErrorStringInvalidEncoding, //!< Invalid encoding in string. - - kParseErrorNumberTooBig, //!< Number too big to be stored in double. - kParseErrorNumberMissFraction, //!< Miss fraction part in number. - kParseErrorNumberMissExponent, //!< Miss exponent in number. - - kParseErrorTermination, //!< Parsing was terminated. - kParseErrorUnspecificSyntaxError //!< Unspecific syntax error. -}; - -//! Result of parsing (wraps ParseErrorCode) -/*! - \ingroup RAPIDJSON_ERRORS - \code - Document doc; - ParseResult ok = doc.Parse("[42]"); - if (!ok) { - fprintf(stderr, "JSON parse error: %s (%u)", - GetParseError_En(ok.Code()), ok.Offset()); - exit(EXIT_FAILURE); - } - \endcode - \see GenericReader::Parse, GenericDocument::Parse -*/ -struct ParseResult { -public: - //! Default constructor, no error. - ParseResult() : code_(kParseErrorNone), offset_(0) {} - //! Constructor to set an error. - ParseResult(ParseErrorCode code, size_t offset) : code_(code), offset_(offset) {} - - //! Get the error code. - ParseErrorCode Code() const { return code_; } - //! Get the error offset, if \ref IsError(), 0 otherwise. - size_t Offset() const { return offset_; } - - //! Conversion to \c bool, returns \c true, iff !\ref IsError(). - operator bool() const { return !IsError(); } - //! Whether the result is an error. - bool IsError() const { return code_ != kParseErrorNone; } - - bool operator==(const ParseResult& that) const { return code_ == that.code_; } - bool operator==(ParseErrorCode code) const { return code_ == code; } - friend bool operator==(ParseErrorCode code, const ParseResult & err) { return code == err.code_; } - - //! Reset error code. - void Clear() { Set(kParseErrorNone); } - //! Update error code and offset. - void Set(ParseErrorCode code, size_t offset = 0) { code_ = code; offset_ = offset; } - -private: - ParseErrorCode code_; - size_t offset_; -}; - -//! Function pointer type of GetParseError(). -/*! \ingroup RAPIDJSON_ERRORS - - This is the prototype for \c GetParseError_X(), where \c X is a locale. - User can dynamically change locale in runtime, e.g.: -\code - GetParseErrorFunc GetParseError = GetParseError_En; // or whatever - const RAPIDJSON_ERROR_CHARTYPE* s = GetParseError(document.GetParseErrorCode()); -\endcode -*/ -typedef const RAPIDJSON_ERROR_CHARTYPE* (*GetParseErrorFunc)(ParseErrorCode); - -RAPIDJSON_NAMESPACE_END - -#ifdef __clang__ -RAPIDJSON_DIAG_POP -#endif - -#endif // RAPIDJSON_ERROR_ERROR_H_ diff --git a/slsReceiverSoftware/include/rapidjson/filereadstream.h b/slsReceiverSoftware/include/rapidjson/filereadstream.h deleted file mode 100644 index b56ea13b3..000000000 --- a/slsReceiverSoftware/include/rapidjson/filereadstream.h +++ /dev/null @@ -1,99 +0,0 @@ -// Tencent is pleased to support the open source community by making RapidJSON available. -// -// Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved. -// -// Licensed under the MIT License (the "License"); you may not use this file except -// in compliance with the License. You may obtain a copy of the License at -// -// http://opensource.org/licenses/MIT -// -// Unless required by applicable law or agreed to in writing, software distributed -// under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR -// CONDITIONS OF ANY KIND, either express or implied. See the License for the -// specific language governing permissions and limitations under the License. - -#ifndef RAPIDJSON_FILEREADSTREAM_H_ -#define RAPIDJSON_FILEREADSTREAM_H_ - -#include "stream.h" -#include - -#ifdef __clang__ -RAPIDJSON_DIAG_PUSH -RAPIDJSON_DIAG_OFF(padded) -RAPIDJSON_DIAG_OFF(unreachable-code) -RAPIDJSON_DIAG_OFF(missing-noreturn) -#endif - -RAPIDJSON_NAMESPACE_BEGIN - -//! File byte stream for input using fread(). -/*! - \note implements Stream concept -*/ -class FileReadStream { -public: - typedef char Ch; //!< Character type (byte). - - //! Constructor. - /*! - \param fp File pointer opened for read. - \param buffer user-supplied buffer. - \param bufferSize size of buffer in bytes. Must >=4 bytes. - */ - FileReadStream(std::FILE* fp, char* buffer, size_t bufferSize) : fp_(fp), buffer_(buffer), bufferSize_(bufferSize), bufferLast_(0), current_(buffer_), readCount_(0), count_(0), eof_(false) { - RAPIDJSON_ASSERT(fp_ != 0); - RAPIDJSON_ASSERT(bufferSize >= 4); - Read(); - } - - Ch Peek() const { return *current_; } - Ch Take() { Ch c = *current_; Read(); return c; } - size_t Tell() const { return count_ + static_cast(current_ - buffer_); } - - // Not implemented - void Put(Ch) { RAPIDJSON_ASSERT(false); } - void Flush() { RAPIDJSON_ASSERT(false); } - Ch* PutBegin() { RAPIDJSON_ASSERT(false); return 0; } - size_t PutEnd(Ch*) { RAPIDJSON_ASSERT(false); return 0; } - - // For encoding detection only. - const Ch* Peek4() const { - return (current_ + 4 <= bufferLast_) ? current_ : 0; - } - -private: - void Read() { - if (current_ < bufferLast_) - ++current_; - else if (!eof_) { - count_ += readCount_; - readCount_ = fread(buffer_, 1, bufferSize_, fp_); - bufferLast_ = buffer_ + readCount_ - 1; - current_ = buffer_; - - if (readCount_ < bufferSize_) { - buffer_[readCount_] = '\0'; - ++bufferLast_; - eof_ = true; - } - } - } - - std::FILE* fp_; - Ch *buffer_; - size_t bufferSize_; - Ch *bufferLast_; - Ch *current_; - size_t readCount_; - size_t count_; //!< Number of characters read - bool eof_; -}; - -RAPIDJSON_NAMESPACE_END - -#ifdef __clang__ -RAPIDJSON_DIAG_POP -#endif - -#endif // RAPIDJSON_FILESTREAM_H_ diff --git a/slsReceiverSoftware/include/rapidjson/filewritestream.h b/slsReceiverSoftware/include/rapidjson/filewritestream.h deleted file mode 100644 index 6378dd60e..000000000 --- a/slsReceiverSoftware/include/rapidjson/filewritestream.h +++ /dev/null @@ -1,104 +0,0 @@ -// Tencent is pleased to support the open source community by making RapidJSON available. -// -// Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved. -// -// Licensed under the MIT License (the "License"); you may not use this file except -// in compliance with the License. You may obtain a copy of the License at -// -// http://opensource.org/licenses/MIT -// -// Unless required by applicable law or agreed to in writing, software distributed -// under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR -// CONDITIONS OF ANY KIND, either express or implied. See the License for the -// specific language governing permissions and limitations under the License. - -#ifndef RAPIDJSON_FILEWRITESTREAM_H_ -#define RAPIDJSON_FILEWRITESTREAM_H_ - -#include "stream.h" -#include - -#ifdef __clang__ -RAPIDJSON_DIAG_PUSH -RAPIDJSON_DIAG_OFF(unreachable-code) -#endif - -RAPIDJSON_NAMESPACE_BEGIN - -//! Wrapper of C file stream for input using fread(). -/*! - \note implements Stream concept -*/ -class FileWriteStream { -public: - typedef char Ch; //!< Character type. Only support char. - - FileWriteStream(std::FILE* fp, char* buffer, size_t bufferSize) : fp_(fp), buffer_(buffer), bufferEnd_(buffer + bufferSize), current_(buffer_) { - RAPIDJSON_ASSERT(fp_ != 0); - } - - void Put(char c) { - if (current_ >= bufferEnd_) - Flush(); - - *current_++ = c; - } - - void PutN(char c, size_t n) { - size_t avail = static_cast(bufferEnd_ - current_); - while (n > avail) { - std::memset(current_, c, avail); - current_ += avail; - Flush(); - n -= avail; - avail = static_cast(bufferEnd_ - current_); - } - - if (n > 0) { - std::memset(current_, c, n); - current_ += n; - } - } - - void Flush() { - if (current_ != buffer_) { - size_t result = fwrite(buffer_, 1, static_cast(current_ - buffer_), fp_); - if (result < static_cast(current_ - buffer_)) { - // failure deliberately ignored at this time - // added to avoid warn_unused_result build errors - } - current_ = buffer_; - } - } - - // Not implemented - char Peek() const { RAPIDJSON_ASSERT(false); return 0; } - char Take() { RAPIDJSON_ASSERT(false); return 0; } - size_t Tell() const { RAPIDJSON_ASSERT(false); return 0; } - char* PutBegin() { RAPIDJSON_ASSERT(false); return 0; } - size_t PutEnd(char*) { RAPIDJSON_ASSERT(false); return 0; } - -private: - // Prohibit copy constructor & assignment operator. - FileWriteStream(const FileWriteStream&); - FileWriteStream& operator=(const FileWriteStream&); - - std::FILE* fp_; - char *buffer_; - char *bufferEnd_; - char *current_; -}; - -//! Implement specialized version of PutN() with memset() for better performance. -template<> -inline void PutN(FileWriteStream& stream, char c, size_t n) { - stream.PutN(c, n); -} - -RAPIDJSON_NAMESPACE_END - -#ifdef __clang__ -RAPIDJSON_DIAG_POP -#endif - -#endif // RAPIDJSON_FILESTREAM_H_ diff --git a/slsReceiverSoftware/include/rapidjson/fwd.h b/slsReceiverSoftware/include/rapidjson/fwd.h deleted file mode 100644 index e8104e841..000000000 --- a/slsReceiverSoftware/include/rapidjson/fwd.h +++ /dev/null @@ -1,151 +0,0 @@ -// Tencent is pleased to support the open source community by making RapidJSON available. -// -// Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved. -// -// Licensed under the MIT License (the "License"); you may not use this file except -// in compliance with the License. You may obtain a copy of the License at -// -// http://opensource.org/licenses/MIT -// -// Unless required by applicable law or agreed to in writing, software distributed -// under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR -// CONDITIONS OF ANY KIND, either express or implied. See the License for the -// specific language governing permissions and limitations under the License. - -#ifndef RAPIDJSON_FWD_H_ -#define RAPIDJSON_FWD_H_ - -#include "rapidjson.h" - -RAPIDJSON_NAMESPACE_BEGIN - -// encodings.h - -template struct UTF8; -template struct UTF16; -template struct UTF16BE; -template struct UTF16LE; -template struct UTF32; -template struct UTF32BE; -template struct UTF32LE; -template struct ASCII; -template struct AutoUTF; - -template -struct Transcoder; - -// allocators.h - -class CrtAllocator; - -template -class MemoryPoolAllocator; - -// stream.h - -template -struct GenericStringStream; - -typedef GenericStringStream > StringStream; - -template -struct GenericInsituStringStream; - -typedef GenericInsituStringStream > InsituStringStream; - -// stringbuffer.h - -template -class GenericStringBuffer; - -typedef GenericStringBuffer, CrtAllocator> StringBuffer; - -// filereadstream.h - -class FileReadStream; - -// filewritestream.h - -class FileWriteStream; - -// memorybuffer.h - -template -struct GenericMemoryBuffer; - -typedef GenericMemoryBuffer MemoryBuffer; - -// memorystream.h - -struct MemoryStream; - -// reader.h - -template -struct BaseReaderHandler; - -template -class GenericReader; - -typedef GenericReader, UTF8, CrtAllocator> Reader; - -// writer.h - -template -class Writer; - -// prettywriter.h - -template -class PrettyWriter; - -// document.h - -template -struct GenericMember; - -template -class GenericMemberIterator; - -template -struct GenericStringRef; - -template -class GenericValue; - -typedef GenericValue, MemoryPoolAllocator > Value; - -template -class GenericDocument; - -typedef GenericDocument, MemoryPoolAllocator, CrtAllocator> Document; - -// pointer.h - -template -class GenericPointer; - -typedef GenericPointer Pointer; - -// schema.h - -template -class IGenericRemoteSchemaDocumentProvider; - -template -class GenericSchemaDocument; - -typedef GenericSchemaDocument SchemaDocument; -typedef IGenericRemoteSchemaDocumentProvider IRemoteSchemaDocumentProvider; - -template < - typename SchemaDocumentType, - typename OutputHandler, - typename StateAllocator> -class GenericSchemaValidator; - -typedef GenericSchemaValidator, void>, CrtAllocator> SchemaValidator; - -RAPIDJSON_NAMESPACE_END - -#endif // RAPIDJSON_RAPIDJSONFWD_H_ diff --git a/slsReceiverSoftware/include/rapidjson/internal/biginteger.h b/slsReceiverSoftware/include/rapidjson/internal/biginteger.h deleted file mode 100644 index 9d3e88c99..000000000 --- a/slsReceiverSoftware/include/rapidjson/internal/biginteger.h +++ /dev/null @@ -1,290 +0,0 @@ -// Tencent is pleased to support the open source community by making RapidJSON available. -// -// Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved. -// -// Licensed under the MIT License (the "License"); you may not use this file except -// in compliance with the License. You may obtain a copy of the License at -// -// http://opensource.org/licenses/MIT -// -// Unless required by applicable law or agreed to in writing, software distributed -// under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR -// CONDITIONS OF ANY KIND, either express or implied. See the License for the -// specific language governing permissions and limitations under the License. - -#ifndef RAPIDJSON_BIGINTEGER_H_ -#define RAPIDJSON_BIGINTEGER_H_ - -#include "../rapidjson.h" - -#if defined(_MSC_VER) && defined(_M_AMD64) -#include // for _umul128 -#pragma intrinsic(_umul128) -#endif - -RAPIDJSON_NAMESPACE_BEGIN -namespace internal { - -class BigInteger { -public: - typedef uint64_t Type; - - BigInteger(const BigInteger& rhs) : count_(rhs.count_) { - std::memcpy(digits_, rhs.digits_, count_ * sizeof(Type)); - } - - explicit BigInteger(uint64_t u) : count_(1) { - digits_[0] = u; - } - - BigInteger(const char* decimals, size_t length) : count_(1) { - RAPIDJSON_ASSERT(length > 0); - digits_[0] = 0; - size_t i = 0; - const size_t kMaxDigitPerIteration = 19; // 2^64 = 18446744073709551616 > 10^19 - while (length >= kMaxDigitPerIteration) { - AppendDecimal64(decimals + i, decimals + i + kMaxDigitPerIteration); - length -= kMaxDigitPerIteration; - i += kMaxDigitPerIteration; - } - - if (length > 0) - AppendDecimal64(decimals + i, decimals + i + length); - } - - BigInteger& operator=(const BigInteger &rhs) - { - if (this != &rhs) { - count_ = rhs.count_; - std::memcpy(digits_, rhs.digits_, count_ * sizeof(Type)); - } - return *this; - } - - BigInteger& operator=(uint64_t u) { - digits_[0] = u; - count_ = 1; - return *this; - } - - BigInteger& operator+=(uint64_t u) { - Type backup = digits_[0]; - digits_[0] += u; - for (size_t i = 0; i < count_ - 1; i++) { - if (digits_[i] >= backup) - return *this; // no carry - backup = digits_[i + 1]; - digits_[i + 1] += 1; - } - - // Last carry - if (digits_[count_ - 1] < backup) - PushBack(1); - - return *this; - } - - BigInteger& operator*=(uint64_t u) { - if (u == 0) return *this = 0; - if (u == 1) return *this; - if (*this == 1) return *this = u; - - uint64_t k = 0; - for (size_t i = 0; i < count_; i++) { - uint64_t hi; - digits_[i] = MulAdd64(digits_[i], u, k, &hi); - k = hi; - } - - if (k > 0) - PushBack(k); - - return *this; - } - - BigInteger& operator*=(uint32_t u) { - if (u == 0) return *this = 0; - if (u == 1) return *this; - if (*this == 1) return *this = u; - - uint64_t k = 0; - for (size_t i = 0; i < count_; i++) { - const uint64_t c = digits_[i] >> 32; - const uint64_t d = digits_[i] & 0xFFFFFFFF; - const uint64_t uc = u * c; - const uint64_t ud = u * d; - const uint64_t p0 = ud + k; - const uint64_t p1 = uc + (p0 >> 32); - digits_[i] = (p0 & 0xFFFFFFFF) | (p1 << 32); - k = p1 >> 32; - } - - if (k > 0) - PushBack(k); - - return *this; - } - - BigInteger& operator<<=(size_t shift) { - if (IsZero() || shift == 0) return *this; - - size_t offset = shift / kTypeBit; - size_t interShift = shift % kTypeBit; - RAPIDJSON_ASSERT(count_ + offset <= kCapacity); - - if (interShift == 0) { - std::memmove(&digits_[count_ - 1 + offset], &digits_[count_ - 1], count_ * sizeof(Type)); - count_ += offset; - } - else { - digits_[count_] = 0; - for (size_t i = count_; i > 0; i--) - digits_[i + offset] = (digits_[i] << interShift) | (digits_[i - 1] >> (kTypeBit - interShift)); - digits_[offset] = digits_[0] << interShift; - count_ += offset; - if (digits_[count_]) - count_++; - } - - std::memset(digits_, 0, offset * sizeof(Type)); - - return *this; - } - - bool operator==(const BigInteger& rhs) const { - return count_ == rhs.count_ && std::memcmp(digits_, rhs.digits_, count_ * sizeof(Type)) == 0; - } - - bool operator==(const Type rhs) const { - return count_ == 1 && digits_[0] == rhs; - } - - BigInteger& MultiplyPow5(unsigned exp) { - static const uint32_t kPow5[12] = { - 5, - 5 * 5, - 5 * 5 * 5, - 5 * 5 * 5 * 5, - 5 * 5 * 5 * 5 * 5, - 5 * 5 * 5 * 5 * 5 * 5, - 5 * 5 * 5 * 5 * 5 * 5 * 5, - 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5, - 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5, - 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5, - 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5, - 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 - }; - if (exp == 0) return *this; - for (; exp >= 27; exp -= 27) *this *= RAPIDJSON_UINT64_C2(0X6765C793, 0XFA10079D); // 5^27 - for (; exp >= 13; exp -= 13) *this *= static_cast(1220703125u); // 5^13 - if (exp > 0) *this *= kPow5[exp - 1]; - return *this; - } - - // Compute absolute difference of this and rhs. - // Assume this != rhs - bool Difference(const BigInteger& rhs, BigInteger* out) const { - int cmp = Compare(rhs); - RAPIDJSON_ASSERT(cmp != 0); - const BigInteger *a, *b; // Makes a > b - bool ret; - if (cmp < 0) { a = &rhs; b = this; ret = true; } - else { a = this; b = &rhs; ret = false; } - - Type borrow = 0; - for (size_t i = 0; i < a->count_; i++) { - Type d = a->digits_[i] - borrow; - if (i < b->count_) - d -= b->digits_[i]; - borrow = (d > a->digits_[i]) ? 1 : 0; - out->digits_[i] = d; - if (d != 0) - out->count_ = i + 1; - } - - return ret; - } - - int Compare(const BigInteger& rhs) const { - if (count_ != rhs.count_) - return count_ < rhs.count_ ? -1 : 1; - - for (size_t i = count_; i-- > 0;) - if (digits_[i] != rhs.digits_[i]) - return digits_[i] < rhs.digits_[i] ? -1 : 1; - - return 0; - } - - size_t GetCount() const { return count_; } - Type GetDigit(size_t index) const { RAPIDJSON_ASSERT(index < count_); return digits_[index]; } - bool IsZero() const { return count_ == 1 && digits_[0] == 0; } - -private: - void AppendDecimal64(const char* begin, const char* end) { - uint64_t u = ParseUint64(begin, end); - if (IsZero()) - *this = u; - else { - unsigned exp = static_cast(end - begin); - (MultiplyPow5(exp) <<= exp) += u; // *this = *this * 10^exp + u - } - } - - void PushBack(Type digit) { - RAPIDJSON_ASSERT(count_ < kCapacity); - digits_[count_++] = digit; - } - - static uint64_t ParseUint64(const char* begin, const char* end) { - uint64_t r = 0; - for (const char* p = begin; p != end; ++p) { - RAPIDJSON_ASSERT(*p >= '0' && *p <= '9'); - r = r * 10u + static_cast(*p - '0'); - } - return r; - } - - // Assume a * b + k < 2^128 - static uint64_t MulAdd64(uint64_t a, uint64_t b, uint64_t k, uint64_t* outHigh) { -#if defined(_MSC_VER) && defined(_M_AMD64) - uint64_t low = _umul128(a, b, outHigh) + k; - if (low < k) - (*outHigh)++; - return low; -#elif (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) && defined(__x86_64__) - __extension__ typedef unsigned __int128 uint128; - uint128 p = static_cast(a) * static_cast(b); - p += k; - *outHigh = static_cast(p >> 64); - return static_cast(p); -#else - const uint64_t a0 = a & 0xFFFFFFFF, a1 = a >> 32, b0 = b & 0xFFFFFFFF, b1 = b >> 32; - uint64_t x0 = a0 * b0, x1 = a0 * b1, x2 = a1 * b0, x3 = a1 * b1; - x1 += (x0 >> 32); // can't give carry - x1 += x2; - if (x1 < x2) - x3 += (static_cast(1) << 32); - uint64_t lo = (x1 << 32) + (x0 & 0xFFFFFFFF); - uint64_t hi = x3 + (x1 >> 32); - - lo += k; - if (lo < k) - hi++; - *outHigh = hi; - return lo; -#endif - } - - static const size_t kBitCount = 3328; // 64bit * 54 > 10^1000 - static const size_t kCapacity = kBitCount / sizeof(Type); - static const size_t kTypeBit = sizeof(Type) * 8; - - Type digits_[kCapacity]; - size_t count_; -}; - -} // namespace internal -RAPIDJSON_NAMESPACE_END - -#endif // RAPIDJSON_BIGINTEGER_H_ diff --git a/slsReceiverSoftware/include/rapidjson/internal/diyfp.h b/slsReceiverSoftware/include/rapidjson/internal/diyfp.h deleted file mode 100644 index c9fefdc61..000000000 --- a/slsReceiverSoftware/include/rapidjson/internal/diyfp.h +++ /dev/null @@ -1,258 +0,0 @@ -// Tencent is pleased to support the open source community by making RapidJSON available. -// -// Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved. -// -// Licensed under the MIT License (the "License"); you may not use this file except -// in compliance with the License. You may obtain a copy of the License at -// -// http://opensource.org/licenses/MIT -// -// Unless required by applicable law or agreed to in writing, software distributed -// under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR -// CONDITIONS OF ANY KIND, either express or implied. See the License for the -// specific language governing permissions and limitations under the License. - -// This is a C++ header-only implementation of Grisu2 algorithm from the publication: -// Loitsch, Florian. "Printing floating-point numbers quickly and accurately with -// integers." ACM Sigplan Notices 45.6 (2010): 233-243. - -#ifndef RAPIDJSON_DIYFP_H_ -#define RAPIDJSON_DIYFP_H_ - -#include "../rapidjson.h" - -#if defined(_MSC_VER) && defined(_M_AMD64) -#include -#pragma intrinsic(_BitScanReverse64) -#pragma intrinsic(_umul128) -#endif - -RAPIDJSON_NAMESPACE_BEGIN -namespace internal { - -#ifdef __GNUC__ -RAPIDJSON_DIAG_PUSH -RAPIDJSON_DIAG_OFF(effc++) -#endif - -#ifdef __clang__ -RAPIDJSON_DIAG_PUSH -RAPIDJSON_DIAG_OFF(padded) -#endif - -struct DiyFp { - DiyFp() : f(), e() {} - - DiyFp(uint64_t fp, int exp) : f(fp), e(exp) {} - - explicit DiyFp(double d) { - union { - double d; - uint64_t u64; - } u = { d }; - - int biased_e = static_cast((u.u64 & kDpExponentMask) >> kDpSignificandSize); - uint64_t significand = (u.u64 & kDpSignificandMask); - if (biased_e != 0) { - f = significand + kDpHiddenBit; - e = biased_e - kDpExponentBias; - } - else { - f = significand; - e = kDpMinExponent + 1; - } - } - - DiyFp operator-(const DiyFp& rhs) const { - return DiyFp(f - rhs.f, e); - } - - DiyFp operator*(const DiyFp& rhs) const { -#if defined(_MSC_VER) && defined(_M_AMD64) - uint64_t h; - uint64_t l = _umul128(f, rhs.f, &h); - if (l & (uint64_t(1) << 63)) // rounding - h++; - return DiyFp(h, e + rhs.e + 64); -#elif (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) && defined(__x86_64__) - __extension__ typedef unsigned __int128 uint128; - uint128 p = static_cast(f) * static_cast(rhs.f); - uint64_t h = static_cast(p >> 64); - uint64_t l = static_cast(p); - if (l & (uint64_t(1) << 63)) // rounding - h++; - return DiyFp(h, e + rhs.e + 64); -#else - const uint64_t M32 = 0xFFFFFFFF; - const uint64_t a = f >> 32; - const uint64_t b = f & M32; - const uint64_t c = rhs.f >> 32; - const uint64_t d = rhs.f & M32; - const uint64_t ac = a * c; - const uint64_t bc = b * c; - const uint64_t ad = a * d; - const uint64_t bd = b * d; - uint64_t tmp = (bd >> 32) + (ad & M32) + (bc & M32); - tmp += 1U << 31; /// mult_round - return DiyFp(ac + (ad >> 32) + (bc >> 32) + (tmp >> 32), e + rhs.e + 64); -#endif - } - - DiyFp Normalize() const { -#if defined(_MSC_VER) && defined(_M_AMD64) - unsigned long index; - _BitScanReverse64(&index, f); - return DiyFp(f << (63 - index), e - (63 - index)); -#elif defined(__GNUC__) && __GNUC__ >= 4 - int s = __builtin_clzll(f); - return DiyFp(f << s, e - s); -#else - DiyFp res = *this; - while (!(res.f & (static_cast(1) << 63))) { - res.f <<= 1; - res.e--; - } - return res; -#endif - } - - DiyFp NormalizeBoundary() const { - DiyFp res = *this; - while (!(res.f & (kDpHiddenBit << 1))) { - res.f <<= 1; - res.e--; - } - res.f <<= (kDiySignificandSize - kDpSignificandSize - 2); - res.e = res.e - (kDiySignificandSize - kDpSignificandSize - 2); - return res; - } - - void NormalizedBoundaries(DiyFp* minus, DiyFp* plus) const { - DiyFp pl = DiyFp((f << 1) + 1, e - 1).NormalizeBoundary(); - DiyFp mi = (f == kDpHiddenBit) ? DiyFp((f << 2) - 1, e - 2) : DiyFp((f << 1) - 1, e - 1); - mi.f <<= mi.e - pl.e; - mi.e = pl.e; - *plus = pl; - *minus = mi; - } - - double ToDouble() const { - union { - double d; - uint64_t u64; - }u; - const uint64_t be = (e == kDpDenormalExponent && (f & kDpHiddenBit) == 0) ? 0 : - static_cast(e + kDpExponentBias); - u.u64 = (f & kDpSignificandMask) | (be << kDpSignificandSize); - return u.d; - } - - static const int kDiySignificandSize = 64; - static const int kDpSignificandSize = 52; - static const int kDpExponentBias = 0x3FF + kDpSignificandSize; - static const int kDpMaxExponent = 0x7FF - kDpExponentBias; - static const int kDpMinExponent = -kDpExponentBias; - static const int kDpDenormalExponent = -kDpExponentBias + 1; - static const uint64_t kDpExponentMask = RAPIDJSON_UINT64_C2(0x7FF00000, 0x00000000); - static const uint64_t kDpSignificandMask = RAPIDJSON_UINT64_C2(0x000FFFFF, 0xFFFFFFFF); - static const uint64_t kDpHiddenBit = RAPIDJSON_UINT64_C2(0x00100000, 0x00000000); - - uint64_t f; - int e; -}; - -inline DiyFp GetCachedPowerByIndex(size_t index) { - // 10^-348, 10^-340, ..., 10^340 - static const uint64_t kCachedPowers_F[] = { - RAPIDJSON_UINT64_C2(0xfa8fd5a0, 0x081c0288), RAPIDJSON_UINT64_C2(0xbaaee17f, 0xa23ebf76), - RAPIDJSON_UINT64_C2(0x8b16fb20, 0x3055ac76), RAPIDJSON_UINT64_C2(0xcf42894a, 0x5dce35ea), - RAPIDJSON_UINT64_C2(0x9a6bb0aa, 0x55653b2d), RAPIDJSON_UINT64_C2(0xe61acf03, 0x3d1a45df), - RAPIDJSON_UINT64_C2(0xab70fe17, 0xc79ac6ca), RAPIDJSON_UINT64_C2(0xff77b1fc, 0xbebcdc4f), - RAPIDJSON_UINT64_C2(0xbe5691ef, 0x416bd60c), RAPIDJSON_UINT64_C2(0x8dd01fad, 0x907ffc3c), - RAPIDJSON_UINT64_C2(0xd3515c28, 0x31559a83), RAPIDJSON_UINT64_C2(0x9d71ac8f, 0xada6c9b5), - RAPIDJSON_UINT64_C2(0xea9c2277, 0x23ee8bcb), RAPIDJSON_UINT64_C2(0xaecc4991, 0x4078536d), - RAPIDJSON_UINT64_C2(0x823c1279, 0x5db6ce57), RAPIDJSON_UINT64_C2(0xc2109436, 0x4dfb5637), - RAPIDJSON_UINT64_C2(0x9096ea6f, 0x3848984f), RAPIDJSON_UINT64_C2(0xd77485cb, 0x25823ac7), - RAPIDJSON_UINT64_C2(0xa086cfcd, 0x97bf97f4), RAPIDJSON_UINT64_C2(0xef340a98, 0x172aace5), - RAPIDJSON_UINT64_C2(0xb23867fb, 0x2a35b28e), RAPIDJSON_UINT64_C2(0x84c8d4df, 0xd2c63f3b), - RAPIDJSON_UINT64_C2(0xc5dd4427, 0x1ad3cdba), RAPIDJSON_UINT64_C2(0x936b9fce, 0xbb25c996), - RAPIDJSON_UINT64_C2(0xdbac6c24, 0x7d62a584), RAPIDJSON_UINT64_C2(0xa3ab6658, 0x0d5fdaf6), - RAPIDJSON_UINT64_C2(0xf3e2f893, 0xdec3f126), RAPIDJSON_UINT64_C2(0xb5b5ada8, 0xaaff80b8), - RAPIDJSON_UINT64_C2(0x87625f05, 0x6c7c4a8b), RAPIDJSON_UINT64_C2(0xc9bcff60, 0x34c13053), - RAPIDJSON_UINT64_C2(0x964e858c, 0x91ba2655), RAPIDJSON_UINT64_C2(0xdff97724, 0x70297ebd), - RAPIDJSON_UINT64_C2(0xa6dfbd9f, 0xb8e5b88f), RAPIDJSON_UINT64_C2(0xf8a95fcf, 0x88747d94), - RAPIDJSON_UINT64_C2(0xb9447093, 0x8fa89bcf), RAPIDJSON_UINT64_C2(0x8a08f0f8, 0xbf0f156b), - RAPIDJSON_UINT64_C2(0xcdb02555, 0x653131b6), RAPIDJSON_UINT64_C2(0x993fe2c6, 0xd07b7fac), - RAPIDJSON_UINT64_C2(0xe45c10c4, 0x2a2b3b06), RAPIDJSON_UINT64_C2(0xaa242499, 0x697392d3), - RAPIDJSON_UINT64_C2(0xfd87b5f2, 0x8300ca0e), RAPIDJSON_UINT64_C2(0xbce50864, 0x92111aeb), - RAPIDJSON_UINT64_C2(0x8cbccc09, 0x6f5088cc), RAPIDJSON_UINT64_C2(0xd1b71758, 0xe219652c), - RAPIDJSON_UINT64_C2(0x9c400000, 0x00000000), RAPIDJSON_UINT64_C2(0xe8d4a510, 0x00000000), - RAPIDJSON_UINT64_C2(0xad78ebc5, 0xac620000), RAPIDJSON_UINT64_C2(0x813f3978, 0xf8940984), - RAPIDJSON_UINT64_C2(0xc097ce7b, 0xc90715b3), RAPIDJSON_UINT64_C2(0x8f7e32ce, 0x7bea5c70), - RAPIDJSON_UINT64_C2(0xd5d238a4, 0xabe98068), RAPIDJSON_UINT64_C2(0x9f4f2726, 0x179a2245), - RAPIDJSON_UINT64_C2(0xed63a231, 0xd4c4fb27), RAPIDJSON_UINT64_C2(0xb0de6538, 0x8cc8ada8), - RAPIDJSON_UINT64_C2(0x83c7088e, 0x1aab65db), RAPIDJSON_UINT64_C2(0xc45d1df9, 0x42711d9a), - RAPIDJSON_UINT64_C2(0x924d692c, 0xa61be758), RAPIDJSON_UINT64_C2(0xda01ee64, 0x1a708dea), - RAPIDJSON_UINT64_C2(0xa26da399, 0x9aef774a), RAPIDJSON_UINT64_C2(0xf209787b, 0xb47d6b85), - RAPIDJSON_UINT64_C2(0xb454e4a1, 0x79dd1877), RAPIDJSON_UINT64_C2(0x865b8692, 0x5b9bc5c2), - RAPIDJSON_UINT64_C2(0xc83553c5, 0xc8965d3d), RAPIDJSON_UINT64_C2(0x952ab45c, 0xfa97a0b3), - RAPIDJSON_UINT64_C2(0xde469fbd, 0x99a05fe3), RAPIDJSON_UINT64_C2(0xa59bc234, 0xdb398c25), - RAPIDJSON_UINT64_C2(0xf6c69a72, 0xa3989f5c), RAPIDJSON_UINT64_C2(0xb7dcbf53, 0x54e9bece), - RAPIDJSON_UINT64_C2(0x88fcf317, 0xf22241e2), RAPIDJSON_UINT64_C2(0xcc20ce9b, 0xd35c78a5), - RAPIDJSON_UINT64_C2(0x98165af3, 0x7b2153df), RAPIDJSON_UINT64_C2(0xe2a0b5dc, 0x971f303a), - RAPIDJSON_UINT64_C2(0xa8d9d153, 0x5ce3b396), RAPIDJSON_UINT64_C2(0xfb9b7cd9, 0xa4a7443c), - RAPIDJSON_UINT64_C2(0xbb764c4c, 0xa7a44410), RAPIDJSON_UINT64_C2(0x8bab8eef, 0xb6409c1a), - RAPIDJSON_UINT64_C2(0xd01fef10, 0xa657842c), RAPIDJSON_UINT64_C2(0x9b10a4e5, 0xe9913129), - RAPIDJSON_UINT64_C2(0xe7109bfb, 0xa19c0c9d), RAPIDJSON_UINT64_C2(0xac2820d9, 0x623bf429), - RAPIDJSON_UINT64_C2(0x80444b5e, 0x7aa7cf85), RAPIDJSON_UINT64_C2(0xbf21e440, 0x03acdd2d), - RAPIDJSON_UINT64_C2(0x8e679c2f, 0x5e44ff8f), RAPIDJSON_UINT64_C2(0xd433179d, 0x9c8cb841), - RAPIDJSON_UINT64_C2(0x9e19db92, 0xb4e31ba9), RAPIDJSON_UINT64_C2(0xeb96bf6e, 0xbadf77d9), - RAPIDJSON_UINT64_C2(0xaf87023b, 0x9bf0ee6b) - }; - static const int16_t kCachedPowers_E[] = { - -1220, -1193, -1166, -1140, -1113, -1087, -1060, -1034, -1007, -980, - -954, -927, -901, -874, -847, -821, -794, -768, -741, -715, - -688, -661, -635, -608, -582, -555, -529, -502, -475, -449, - -422, -396, -369, -343, -316, -289, -263, -236, -210, -183, - -157, -130, -103, -77, -50, -24, 3, 30, 56, 83, - 109, 136, 162, 189, 216, 242, 269, 295, 322, 348, - 375, 402, 428, 455, 481, 508, 534, 561, 588, 614, - 641, 667, 694, 720, 747, 774, 800, 827, 853, 880, - 907, 933, 960, 986, 1013, 1039, 1066 - }; - return DiyFp(kCachedPowers_F[index], kCachedPowers_E[index]); -} - -inline DiyFp GetCachedPower(int e, int* K) { - - //int k = static_cast(ceil((-61 - e) * 0.30102999566398114)) + 374; - double dk = (-61 - e) * 0.30102999566398114 + 347; // dk must be positive, so can do ceiling in positive - int k = static_cast(dk); - if (dk - k > 0.0) - k++; - - unsigned index = static_cast((k >> 3) + 1); - *K = -(-348 + static_cast(index << 3)); // decimal exponent no need lookup table - - return GetCachedPowerByIndex(index); -} - -inline DiyFp GetCachedPower10(int exp, int *outExp) { - unsigned index = (static_cast(exp) + 348u) / 8u; - *outExp = -348 + static_cast(index) * 8; - return GetCachedPowerByIndex(index); - } - -#ifdef __GNUC__ -RAPIDJSON_DIAG_POP -#endif - -#ifdef __clang__ -RAPIDJSON_DIAG_POP -RAPIDJSON_DIAG_OFF(padded) -#endif - -} // namespace internal -RAPIDJSON_NAMESPACE_END - -#endif // RAPIDJSON_DIYFP_H_ diff --git a/slsReceiverSoftware/include/rapidjson/internal/dtoa.h b/slsReceiverSoftware/include/rapidjson/internal/dtoa.h deleted file mode 100644 index 8d6350e62..000000000 --- a/slsReceiverSoftware/include/rapidjson/internal/dtoa.h +++ /dev/null @@ -1,245 +0,0 @@ -// Tencent is pleased to support the open source community by making RapidJSON available. -// -// Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved. -// -// Licensed under the MIT License (the "License"); you may not use this file except -// in compliance with the License. You may obtain a copy of the License at -// -// http://opensource.org/licenses/MIT -// -// Unless required by applicable law or agreed to in writing, software distributed -// under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR -// CONDITIONS OF ANY KIND, either express or implied. See the License for the -// specific language governing permissions and limitations under the License. - -// This is a C++ header-only implementation of Grisu2 algorithm from the publication: -// Loitsch, Florian. "Printing floating-point numbers quickly and accurately with -// integers." ACM Sigplan Notices 45.6 (2010): 233-243. - -#ifndef RAPIDJSON_DTOA_ -#define RAPIDJSON_DTOA_ - -#include "itoa.h" // GetDigitsLut() -#include "diyfp.h" -#include "ieee754.h" - -RAPIDJSON_NAMESPACE_BEGIN -namespace internal { - -#ifdef __GNUC__ -RAPIDJSON_DIAG_PUSH -RAPIDJSON_DIAG_OFF(effc++) -RAPIDJSON_DIAG_OFF(array-bounds) // some gcc versions generate wrong warnings https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59124 -#endif - -inline void GrisuRound(char* buffer, int len, uint64_t delta, uint64_t rest, uint64_t ten_kappa, uint64_t wp_w) { - while (rest < wp_w && delta - rest >= ten_kappa && - (rest + ten_kappa < wp_w || /// closer - wp_w - rest > rest + ten_kappa - wp_w)) { - buffer[len - 1]--; - rest += ten_kappa; - } -} - -inline unsigned CountDecimalDigit32(uint32_t n) { - // Simple pure C++ implementation was faster than __builtin_clz version in this situation. - if (n < 10) return 1; - if (n < 100) return 2; - if (n < 1000) return 3; - if (n < 10000) return 4; - if (n < 100000) return 5; - if (n < 1000000) return 6; - if (n < 10000000) return 7; - if (n < 100000000) return 8; - // Will not reach 10 digits in DigitGen() - //if (n < 1000000000) return 9; - //return 10; - return 9; -} - -inline void DigitGen(const DiyFp& W, const DiyFp& Mp, uint64_t delta, char* buffer, int* len, int* K) { - static const uint32_t kPow10[] = { 1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000 }; - const DiyFp one(uint64_t(1) << -Mp.e, Mp.e); - const DiyFp wp_w = Mp - W; - uint32_t p1 = static_cast(Mp.f >> -one.e); - uint64_t p2 = Mp.f & (one.f - 1); - unsigned kappa = CountDecimalDigit32(p1); // kappa in [0, 9] - *len = 0; - - while (kappa > 0) { - uint32_t d = 0; - switch (kappa) { - case 9: d = p1 / 100000000; p1 %= 100000000; break; - case 8: d = p1 / 10000000; p1 %= 10000000; break; - case 7: d = p1 / 1000000; p1 %= 1000000; break; - case 6: d = p1 / 100000; p1 %= 100000; break; - case 5: d = p1 / 10000; p1 %= 10000; break; - case 4: d = p1 / 1000; p1 %= 1000; break; - case 3: d = p1 / 100; p1 %= 100; break; - case 2: d = p1 / 10; p1 %= 10; break; - case 1: d = p1; p1 = 0; break; - default:; - } - if (d || *len) - buffer[(*len)++] = static_cast('0' + static_cast(d)); - kappa--; - uint64_t tmp = (static_cast(p1) << -one.e) + p2; - if (tmp <= delta) { - *K += kappa; - GrisuRound(buffer, *len, delta, tmp, static_cast(kPow10[kappa]) << -one.e, wp_w.f); - return; - } - } - - // kappa = 0 - for (;;) { - p2 *= 10; - delta *= 10; - char d = static_cast(p2 >> -one.e); - if (d || *len) - buffer[(*len)++] = static_cast('0' + d); - p2 &= one.f - 1; - kappa--; - if (p2 < delta) { - *K += kappa; - int index = -static_cast(kappa); - GrisuRound(buffer, *len, delta, p2, one.f, wp_w.f * (index < 9 ? kPow10[-static_cast(kappa)] : 0)); - return; - } - } -} - -inline void Grisu2(double value, char* buffer, int* length, int* K) { - const DiyFp v(value); - DiyFp w_m, w_p; - v.NormalizedBoundaries(&w_m, &w_p); - - const DiyFp c_mk = GetCachedPower(w_p.e, K); - const DiyFp W = v.Normalize() * c_mk; - DiyFp Wp = w_p * c_mk; - DiyFp Wm = w_m * c_mk; - Wm.f++; - Wp.f--; - DigitGen(W, Wp, Wp.f - Wm.f, buffer, length, K); -} - -inline char* WriteExponent(int K, char* buffer) { - if (K < 0) { - *buffer++ = '-'; - K = -K; - } - - if (K >= 100) { - *buffer++ = static_cast('0' + static_cast(K / 100)); - K %= 100; - const char* d = GetDigitsLut() + K * 2; - *buffer++ = d[0]; - *buffer++ = d[1]; - } - else if (K >= 10) { - const char* d = GetDigitsLut() + K * 2; - *buffer++ = d[0]; - *buffer++ = d[1]; - } - else - *buffer++ = static_cast('0' + static_cast(K)); - - return buffer; -} - -inline char* Prettify(char* buffer, int length, int k, int maxDecimalPlaces) { - const int kk = length + k; // 10^(kk-1) <= v < 10^kk - - if (0 <= k && kk <= 21) { - // 1234e7 -> 12340000000 - for (int i = length; i < kk; i++) - buffer[i] = '0'; - buffer[kk] = '.'; - buffer[kk + 1] = '0'; - return &buffer[kk + 2]; - } - else if (0 < kk && kk <= 21) { - // 1234e-2 -> 12.34 - std::memmove(&buffer[kk + 1], &buffer[kk], static_cast(length - kk)); - buffer[kk] = '.'; - if (0 > k + maxDecimalPlaces) { - // When maxDecimalPlaces = 2, 1.2345 -> 1.23, 1.102 -> 1.1 - // Remove extra trailing zeros (at least one) after truncation. - for (int i = kk + maxDecimalPlaces; i > kk + 1; i--) - if (buffer[i] != '0') - return &buffer[i + 1]; - return &buffer[kk + 2]; // Reserve one zero - } - else - return &buffer[length + 1]; - } - else if (-6 < kk && kk <= 0) { - // 1234e-6 -> 0.001234 - const int offset = 2 - kk; - std::memmove(&buffer[offset], &buffer[0], static_cast(length)); - buffer[0] = '0'; - buffer[1] = '.'; - for (int i = 2; i < offset; i++) - buffer[i] = '0'; - if (length - kk > maxDecimalPlaces) { - // When maxDecimalPlaces = 2, 0.123 -> 0.12, 0.102 -> 0.1 - // Remove extra trailing zeros (at least one) after truncation. - for (int i = maxDecimalPlaces + 1; i > 2; i--) - if (buffer[i] != '0') - return &buffer[i + 1]; - return &buffer[3]; // Reserve one zero - } - else - return &buffer[length + offset]; - } - else if (kk < -maxDecimalPlaces) { - // Truncate to zero - buffer[0] = '0'; - buffer[1] = '.'; - buffer[2] = '0'; - return &buffer[3]; - } - else if (length == 1) { - // 1e30 - buffer[1] = 'e'; - return WriteExponent(kk - 1, &buffer[2]); - } - else { - // 1234e30 -> 1.234e33 - std::memmove(&buffer[2], &buffer[1], static_cast(length - 1)); - buffer[1] = '.'; - buffer[length + 1] = 'e'; - return WriteExponent(kk - 1, &buffer[0 + length + 2]); - } -} - -inline char* dtoa(double value, char* buffer, int maxDecimalPlaces = 324) { - RAPIDJSON_ASSERT(maxDecimalPlaces >= 1); - Double d(value); - if (d.IsZero()) { - if (d.Sign()) - *buffer++ = '-'; // -0.0, Issue #289 - buffer[0] = '0'; - buffer[1] = '.'; - buffer[2] = '0'; - return &buffer[3]; - } - else { - if (value < 0) { - *buffer++ = '-'; - value = -value; - } - int length, K; - Grisu2(value, buffer, &length, &K); - return Prettify(buffer, length, K, maxDecimalPlaces); - } -} - -#ifdef __GNUC__ -RAPIDJSON_DIAG_POP -#endif - -} // namespace internal -RAPIDJSON_NAMESPACE_END - -#endif // RAPIDJSON_DTOA_ diff --git a/slsReceiverSoftware/include/rapidjson/internal/ieee754.h b/slsReceiverSoftware/include/rapidjson/internal/ieee754.h deleted file mode 100644 index 82bb0b99e..000000000 --- a/slsReceiverSoftware/include/rapidjson/internal/ieee754.h +++ /dev/null @@ -1,78 +0,0 @@ -// Tencent is pleased to support the open source community by making RapidJSON available. -// -// Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved. -// -// Licensed under the MIT License (the "License"); you may not use this file except -// in compliance with the License. You may obtain a copy of the License at -// -// http://opensource.org/licenses/MIT -// -// Unless required by applicable law or agreed to in writing, software distributed -// under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR -// CONDITIONS OF ANY KIND, either express or implied. See the License for the -// specific language governing permissions and limitations under the License. - -#ifndef RAPIDJSON_IEEE754_ -#define RAPIDJSON_IEEE754_ - -#include "../rapidjson.h" - -RAPIDJSON_NAMESPACE_BEGIN -namespace internal { - -class Double { -public: - Double() {} - Double(double d) : d_(d) {} - Double(uint64_t u) : u_(u) {} - - double Value() const { return d_; } - uint64_t Uint64Value() const { return u_; } - - double NextPositiveDouble() const { - RAPIDJSON_ASSERT(!Sign()); - return Double(u_ + 1).Value(); - } - - bool Sign() const { return (u_ & kSignMask) != 0; } - uint64_t Significand() const { return u_ & kSignificandMask; } - int Exponent() const { return static_cast(((u_ & kExponentMask) >> kSignificandSize) - kExponentBias); } - - bool IsNan() const { return (u_ & kExponentMask) == kExponentMask && Significand() != 0; } - bool IsInf() const { return (u_ & kExponentMask) == kExponentMask && Significand() == 0; } - bool IsNanOrInf() const { return (u_ & kExponentMask) == kExponentMask; } - bool IsNormal() const { return (u_ & kExponentMask) != 0 || Significand() == 0; } - bool IsZero() const { return (u_ & (kExponentMask | kSignificandMask)) == 0; } - - uint64_t IntegerSignificand() const { return IsNormal() ? Significand() | kHiddenBit : Significand(); } - int IntegerExponent() const { return (IsNormal() ? Exponent() : kDenormalExponent) - kSignificandSize; } - uint64_t ToBias() const { return (u_ & kSignMask) ? ~u_ + 1 : u_ | kSignMask; } - - static unsigned EffectiveSignificandSize(int order) { - if (order >= -1021) - return 53; - else if (order <= -1074) - return 0; - else - return static_cast(order) + 1074; - } - -private: - static const int kSignificandSize = 52; - static const int kExponentBias = 0x3FF; - static const int kDenormalExponent = 1 - kExponentBias; - static const uint64_t kSignMask = RAPIDJSON_UINT64_C2(0x80000000, 0x00000000); - static const uint64_t kExponentMask = RAPIDJSON_UINT64_C2(0x7FF00000, 0x00000000); - static const uint64_t kSignificandMask = RAPIDJSON_UINT64_C2(0x000FFFFF, 0xFFFFFFFF); - static const uint64_t kHiddenBit = RAPIDJSON_UINT64_C2(0x00100000, 0x00000000); - - union { - double d_; - uint64_t u_; - }; -}; - -} // namespace internal -RAPIDJSON_NAMESPACE_END - -#endif // RAPIDJSON_IEEE754_ diff --git a/slsReceiverSoftware/include/rapidjson/internal/itoa.h b/slsReceiverSoftware/include/rapidjson/internal/itoa.h deleted file mode 100644 index 01a4e7e72..000000000 --- a/slsReceiverSoftware/include/rapidjson/internal/itoa.h +++ /dev/null @@ -1,304 +0,0 @@ -// Tencent is pleased to support the open source community by making RapidJSON available. -// -// Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved. -// -// Licensed under the MIT License (the "License"); you may not use this file except -// in compliance with the License. You may obtain a copy of the License at -// -// http://opensource.org/licenses/MIT -// -// Unless required by applicable law or agreed to in writing, software distributed -// under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR -// CONDITIONS OF ANY KIND, either express or implied. See the License for the -// specific language governing permissions and limitations under the License. - -#ifndef RAPIDJSON_ITOA_ -#define RAPIDJSON_ITOA_ - -#include "../rapidjson.h" - -RAPIDJSON_NAMESPACE_BEGIN -namespace internal { - -inline const char* GetDigitsLut() { - static const char cDigitsLut[200] = { - '0','0','0','1','0','2','0','3','0','4','0','5','0','6','0','7','0','8','0','9', - '1','0','1','1','1','2','1','3','1','4','1','5','1','6','1','7','1','8','1','9', - '2','0','2','1','2','2','2','3','2','4','2','5','2','6','2','7','2','8','2','9', - '3','0','3','1','3','2','3','3','3','4','3','5','3','6','3','7','3','8','3','9', - '4','0','4','1','4','2','4','3','4','4','4','5','4','6','4','7','4','8','4','9', - '5','0','5','1','5','2','5','3','5','4','5','5','5','6','5','7','5','8','5','9', - '6','0','6','1','6','2','6','3','6','4','6','5','6','6','6','7','6','8','6','9', - '7','0','7','1','7','2','7','3','7','4','7','5','7','6','7','7','7','8','7','9', - '8','0','8','1','8','2','8','3','8','4','8','5','8','6','8','7','8','8','8','9', - '9','0','9','1','9','2','9','3','9','4','9','5','9','6','9','7','9','8','9','9' - }; - return cDigitsLut; -} - -inline char* u32toa(uint32_t value, char* buffer) { - const char* cDigitsLut = GetDigitsLut(); - - if (value < 10000) { - const uint32_t d1 = (value / 100) << 1; - const uint32_t d2 = (value % 100) << 1; - - if (value >= 1000) - *buffer++ = cDigitsLut[d1]; - if (value >= 100) - *buffer++ = cDigitsLut[d1 + 1]; - if (value >= 10) - *buffer++ = cDigitsLut[d2]; - *buffer++ = cDigitsLut[d2 + 1]; - } - else if (value < 100000000) { - // value = bbbbcccc - const uint32_t b = value / 10000; - const uint32_t c = value % 10000; - - const uint32_t d1 = (b / 100) << 1; - const uint32_t d2 = (b % 100) << 1; - - const uint32_t d3 = (c / 100) << 1; - const uint32_t d4 = (c % 100) << 1; - - if (value >= 10000000) - *buffer++ = cDigitsLut[d1]; - if (value >= 1000000) - *buffer++ = cDigitsLut[d1 + 1]; - if (value >= 100000) - *buffer++ = cDigitsLut[d2]; - *buffer++ = cDigitsLut[d2 + 1]; - - *buffer++ = cDigitsLut[d3]; - *buffer++ = cDigitsLut[d3 + 1]; - *buffer++ = cDigitsLut[d4]; - *buffer++ = cDigitsLut[d4 + 1]; - } - else { - // value = aabbbbcccc in decimal - - const uint32_t a = value / 100000000; // 1 to 42 - value %= 100000000; - - if (a >= 10) { - const unsigned i = a << 1; - *buffer++ = cDigitsLut[i]; - *buffer++ = cDigitsLut[i + 1]; - } - else - *buffer++ = static_cast('0' + static_cast(a)); - - const uint32_t b = value / 10000; // 0 to 9999 - const uint32_t c = value % 10000; // 0 to 9999 - - const uint32_t d1 = (b / 100) << 1; - const uint32_t d2 = (b % 100) << 1; - - const uint32_t d3 = (c / 100) << 1; - const uint32_t d4 = (c % 100) << 1; - - *buffer++ = cDigitsLut[d1]; - *buffer++ = cDigitsLut[d1 + 1]; - *buffer++ = cDigitsLut[d2]; - *buffer++ = cDigitsLut[d2 + 1]; - *buffer++ = cDigitsLut[d3]; - *buffer++ = cDigitsLut[d3 + 1]; - *buffer++ = cDigitsLut[d4]; - *buffer++ = cDigitsLut[d4 + 1]; - } - return buffer; -} - -inline char* i32toa(int32_t value, char* buffer) { - uint32_t u = static_cast(value); - if (value < 0) { - *buffer++ = '-'; - u = ~u + 1; - } - - return u32toa(u, buffer); -} - -inline char* u64toa(uint64_t value, char* buffer) { - const char* cDigitsLut = GetDigitsLut(); - const uint64_t kTen8 = 100000000; - const uint64_t kTen9 = kTen8 * 10; - const uint64_t kTen10 = kTen8 * 100; - const uint64_t kTen11 = kTen8 * 1000; - const uint64_t kTen12 = kTen8 * 10000; - const uint64_t kTen13 = kTen8 * 100000; - const uint64_t kTen14 = kTen8 * 1000000; - const uint64_t kTen15 = kTen8 * 10000000; - const uint64_t kTen16 = kTen8 * kTen8; - - if (value < kTen8) { - uint32_t v = static_cast(value); - if (v < 10000) { - const uint32_t d1 = (v / 100) << 1; - const uint32_t d2 = (v % 100) << 1; - - if (v >= 1000) - *buffer++ = cDigitsLut[d1]; - if (v >= 100) - *buffer++ = cDigitsLut[d1 + 1]; - if (v >= 10) - *buffer++ = cDigitsLut[d2]; - *buffer++ = cDigitsLut[d2 + 1]; - } - else { - // value = bbbbcccc - const uint32_t b = v / 10000; - const uint32_t c = v % 10000; - - const uint32_t d1 = (b / 100) << 1; - const uint32_t d2 = (b % 100) << 1; - - const uint32_t d3 = (c / 100) << 1; - const uint32_t d4 = (c % 100) << 1; - - if (value >= 10000000) - *buffer++ = cDigitsLut[d1]; - if (value >= 1000000) - *buffer++ = cDigitsLut[d1 + 1]; - if (value >= 100000) - *buffer++ = cDigitsLut[d2]; - *buffer++ = cDigitsLut[d2 + 1]; - - *buffer++ = cDigitsLut[d3]; - *buffer++ = cDigitsLut[d3 + 1]; - *buffer++ = cDigitsLut[d4]; - *buffer++ = cDigitsLut[d4 + 1]; - } - } - else if (value < kTen16) { - const uint32_t v0 = static_cast(value / kTen8); - const uint32_t v1 = static_cast(value % kTen8); - - const uint32_t b0 = v0 / 10000; - const uint32_t c0 = v0 % 10000; - - const uint32_t d1 = (b0 / 100) << 1; - const uint32_t d2 = (b0 % 100) << 1; - - const uint32_t d3 = (c0 / 100) << 1; - const uint32_t d4 = (c0 % 100) << 1; - - const uint32_t b1 = v1 / 10000; - const uint32_t c1 = v1 % 10000; - - const uint32_t d5 = (b1 / 100) << 1; - const uint32_t d6 = (b1 % 100) << 1; - - const uint32_t d7 = (c1 / 100) << 1; - const uint32_t d8 = (c1 % 100) << 1; - - if (value >= kTen15) - *buffer++ = cDigitsLut[d1]; - if (value >= kTen14) - *buffer++ = cDigitsLut[d1 + 1]; - if (value >= kTen13) - *buffer++ = cDigitsLut[d2]; - if (value >= kTen12) - *buffer++ = cDigitsLut[d2 + 1]; - if (value >= kTen11) - *buffer++ = cDigitsLut[d3]; - if (value >= kTen10) - *buffer++ = cDigitsLut[d3 + 1]; - if (value >= kTen9) - *buffer++ = cDigitsLut[d4]; - if (value >= kTen8) - *buffer++ = cDigitsLut[d4 + 1]; - - *buffer++ = cDigitsLut[d5]; - *buffer++ = cDigitsLut[d5 + 1]; - *buffer++ = cDigitsLut[d6]; - *buffer++ = cDigitsLut[d6 + 1]; - *buffer++ = cDigitsLut[d7]; - *buffer++ = cDigitsLut[d7 + 1]; - *buffer++ = cDigitsLut[d8]; - *buffer++ = cDigitsLut[d8 + 1]; - } - else { - const uint32_t a = static_cast(value / kTen16); // 1 to 1844 - value %= kTen16; - - if (a < 10) - *buffer++ = static_cast('0' + static_cast(a)); - else if (a < 100) { - const uint32_t i = a << 1; - *buffer++ = cDigitsLut[i]; - *buffer++ = cDigitsLut[i + 1]; - } - else if (a < 1000) { - *buffer++ = static_cast('0' + static_cast(a / 100)); - - const uint32_t i = (a % 100) << 1; - *buffer++ = cDigitsLut[i]; - *buffer++ = cDigitsLut[i + 1]; - } - else { - const uint32_t i = (a / 100) << 1; - const uint32_t j = (a % 100) << 1; - *buffer++ = cDigitsLut[i]; - *buffer++ = cDigitsLut[i + 1]; - *buffer++ = cDigitsLut[j]; - *buffer++ = cDigitsLut[j + 1]; - } - - const uint32_t v0 = static_cast(value / kTen8); - const uint32_t v1 = static_cast(value % kTen8); - - const uint32_t b0 = v0 / 10000; - const uint32_t c0 = v0 % 10000; - - const uint32_t d1 = (b0 / 100) << 1; - const uint32_t d2 = (b0 % 100) << 1; - - const uint32_t d3 = (c0 / 100) << 1; - const uint32_t d4 = (c0 % 100) << 1; - - const uint32_t b1 = v1 / 10000; - const uint32_t c1 = v1 % 10000; - - const uint32_t d5 = (b1 / 100) << 1; - const uint32_t d6 = (b1 % 100) << 1; - - const uint32_t d7 = (c1 / 100) << 1; - const uint32_t d8 = (c1 % 100) << 1; - - *buffer++ = cDigitsLut[d1]; - *buffer++ = cDigitsLut[d1 + 1]; - *buffer++ = cDigitsLut[d2]; - *buffer++ = cDigitsLut[d2 + 1]; - *buffer++ = cDigitsLut[d3]; - *buffer++ = cDigitsLut[d3 + 1]; - *buffer++ = cDigitsLut[d4]; - *buffer++ = cDigitsLut[d4 + 1]; - *buffer++ = cDigitsLut[d5]; - *buffer++ = cDigitsLut[d5 + 1]; - *buffer++ = cDigitsLut[d6]; - *buffer++ = cDigitsLut[d6 + 1]; - *buffer++ = cDigitsLut[d7]; - *buffer++ = cDigitsLut[d7 + 1]; - *buffer++ = cDigitsLut[d8]; - *buffer++ = cDigitsLut[d8 + 1]; - } - - return buffer; -} - -inline char* i64toa(int64_t value, char* buffer) { - uint64_t u = static_cast(value); - if (value < 0) { - *buffer++ = '-'; - u = ~u + 1; - } - - return u64toa(u, buffer); -} - -} // namespace internal -RAPIDJSON_NAMESPACE_END - -#endif // RAPIDJSON_ITOA_ diff --git a/slsReceiverSoftware/include/rapidjson/internal/meta.h b/slsReceiverSoftware/include/rapidjson/internal/meta.h deleted file mode 100644 index 5a9aaa428..000000000 --- a/slsReceiverSoftware/include/rapidjson/internal/meta.h +++ /dev/null @@ -1,181 +0,0 @@ -// Tencent is pleased to support the open source community by making RapidJSON available. -// -// Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved. -// -// Licensed under the MIT License (the "License"); you may not use this file except -// in compliance with the License. You may obtain a copy of the License at -// -// http://opensource.org/licenses/MIT -// -// Unless required by applicable law or agreed to in writing, software distributed -// under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR -// CONDITIONS OF ANY KIND, either express or implied. See the License for the -// specific language governing permissions and limitations under the License. - -#ifndef RAPIDJSON_INTERNAL_META_H_ -#define RAPIDJSON_INTERNAL_META_H_ - -#include "../rapidjson.h" - -#ifdef __GNUC__ -RAPIDJSON_DIAG_PUSH -RAPIDJSON_DIAG_OFF(effc++) -#endif -#if defined(_MSC_VER) -RAPIDJSON_DIAG_PUSH -RAPIDJSON_DIAG_OFF(6334) -#endif - -#if RAPIDJSON_HAS_CXX11_TYPETRAITS -#include -#endif - -//@cond RAPIDJSON_INTERNAL -RAPIDJSON_NAMESPACE_BEGIN -namespace internal { - -// Helper to wrap/convert arbitrary types to void, useful for arbitrary type matching -template struct Void { typedef void Type; }; - -/////////////////////////////////////////////////////////////////////////////// -// BoolType, TrueType, FalseType -// -template struct BoolType { - static const bool Value = Cond; - typedef BoolType Type; -}; -typedef BoolType TrueType; -typedef BoolType FalseType; - - -/////////////////////////////////////////////////////////////////////////////// -// SelectIf, BoolExpr, NotExpr, AndExpr, OrExpr -// - -template struct SelectIfImpl { template struct Apply { typedef T1 Type; }; }; -template <> struct SelectIfImpl { template struct Apply { typedef T2 Type; }; }; -template struct SelectIfCond : SelectIfImpl::template Apply {}; -template struct SelectIf : SelectIfCond {}; - -template struct AndExprCond : FalseType {}; -template <> struct AndExprCond : TrueType {}; -template struct OrExprCond : TrueType {}; -template <> struct OrExprCond : FalseType {}; - -template struct BoolExpr : SelectIf::Type {}; -template struct NotExpr : SelectIf::Type {}; -template struct AndExpr : AndExprCond::Type {}; -template struct OrExpr : OrExprCond::Type {}; - - -/////////////////////////////////////////////////////////////////////////////// -// AddConst, MaybeAddConst, RemoveConst -template struct AddConst { typedef const T Type; }; -template struct MaybeAddConst : SelectIfCond {}; -template struct RemoveConst { typedef T Type; }; -template struct RemoveConst { typedef T Type; }; - - -/////////////////////////////////////////////////////////////////////////////// -// IsSame, IsConst, IsMoreConst, IsPointer -// -template struct IsSame : FalseType {}; -template struct IsSame : TrueType {}; - -template struct IsConst : FalseType {}; -template struct IsConst : TrueType {}; - -template -struct IsMoreConst - : AndExpr::Type, typename RemoveConst::Type>, - BoolType::Value >= IsConst::Value> >::Type {}; - -template struct IsPointer : FalseType {}; -template struct IsPointer : TrueType {}; - -/////////////////////////////////////////////////////////////////////////////// -// IsBaseOf -// -#if RAPIDJSON_HAS_CXX11_TYPETRAITS - -template struct IsBaseOf - : BoolType< ::std::is_base_of::value> {}; - -#else // simplified version adopted from Boost - -template struct IsBaseOfImpl { - RAPIDJSON_STATIC_ASSERT(sizeof(B) != 0); - RAPIDJSON_STATIC_ASSERT(sizeof(D) != 0); - - typedef char (&Yes)[1]; - typedef char (&No) [2]; - - template - static Yes Check(const D*, T); - static No Check(const B*, int); - - struct Host { - operator const B*() const; - operator const D*(); - }; - - enum { Value = (sizeof(Check(Host(), 0)) == sizeof(Yes)) }; -}; - -template struct IsBaseOf - : OrExpr, BoolExpr > >::Type {}; - -#endif // RAPIDJSON_HAS_CXX11_TYPETRAITS - - -////////////////////////////////////////////////////////////////////////// -// EnableIf / DisableIf -// -template struct EnableIfCond { typedef T Type; }; -template struct EnableIfCond { /* empty */ }; - -template struct DisableIfCond { typedef T Type; }; -template struct DisableIfCond { /* empty */ }; - -template -struct EnableIf : EnableIfCond {}; - -template -struct DisableIf : DisableIfCond {}; - -// SFINAE helpers -struct SfinaeTag {}; -template struct RemoveSfinaeTag; -template struct RemoveSfinaeTag { typedef T Type; }; - -#define RAPIDJSON_REMOVEFPTR_(type) \ - typename ::RAPIDJSON_NAMESPACE::internal::RemoveSfinaeTag \ - < ::RAPIDJSON_NAMESPACE::internal::SfinaeTag&(*) type>::Type - -#define RAPIDJSON_ENABLEIF(cond) \ - typename ::RAPIDJSON_NAMESPACE::internal::EnableIf \ - ::Type * = NULL - -#define RAPIDJSON_DISABLEIF(cond) \ - typename ::RAPIDJSON_NAMESPACE::internal::DisableIf \ - ::Type * = NULL - -#define RAPIDJSON_ENABLEIF_RETURN(cond,returntype) \ - typename ::RAPIDJSON_NAMESPACE::internal::EnableIf \ - ::Type - -#define RAPIDJSON_DISABLEIF_RETURN(cond,returntype) \ - typename ::RAPIDJSON_NAMESPACE::internal::DisableIf \ - ::Type - -} // namespace internal -RAPIDJSON_NAMESPACE_END -//@endcond - -#if defined(__GNUC__) || defined(_MSC_VER) -RAPIDJSON_DIAG_POP -#endif - -#endif // RAPIDJSON_INTERNAL_META_H_ diff --git a/slsReceiverSoftware/include/rapidjson/internal/pow10.h b/slsReceiverSoftware/include/rapidjson/internal/pow10.h deleted file mode 100644 index 02f475d70..000000000 --- a/slsReceiverSoftware/include/rapidjson/internal/pow10.h +++ /dev/null @@ -1,55 +0,0 @@ -// Tencent is pleased to support the open source community by making RapidJSON available. -// -// Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved. -// -// Licensed under the MIT License (the "License"); you may not use this file except -// in compliance with the License. You may obtain a copy of the License at -// -// http://opensource.org/licenses/MIT -// -// Unless required by applicable law or agreed to in writing, software distributed -// under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR -// CONDITIONS OF ANY KIND, either express or implied. See the License for the -// specific language governing permissions and limitations under the License. - -#ifndef RAPIDJSON_POW10_ -#define RAPIDJSON_POW10_ - -#include "../rapidjson.h" - -RAPIDJSON_NAMESPACE_BEGIN -namespace internal { - -//! Computes integer powers of 10 in double (10.0^n). -/*! This function uses lookup table for fast and accurate results. - \param n non-negative exponent. Must <= 308. - \return 10.0^n -*/ -inline double Pow10(int n) { - static const double e[] = { // 1e-0...1e308: 309 * 8 bytes = 2472 bytes - 1e+0, - 1e+1, 1e+2, 1e+3, 1e+4, 1e+5, 1e+6, 1e+7, 1e+8, 1e+9, 1e+10, 1e+11, 1e+12, 1e+13, 1e+14, 1e+15, 1e+16, 1e+17, 1e+18, 1e+19, 1e+20, - 1e+21, 1e+22, 1e+23, 1e+24, 1e+25, 1e+26, 1e+27, 1e+28, 1e+29, 1e+30, 1e+31, 1e+32, 1e+33, 1e+34, 1e+35, 1e+36, 1e+37, 1e+38, 1e+39, 1e+40, - 1e+41, 1e+42, 1e+43, 1e+44, 1e+45, 1e+46, 1e+47, 1e+48, 1e+49, 1e+50, 1e+51, 1e+52, 1e+53, 1e+54, 1e+55, 1e+56, 1e+57, 1e+58, 1e+59, 1e+60, - 1e+61, 1e+62, 1e+63, 1e+64, 1e+65, 1e+66, 1e+67, 1e+68, 1e+69, 1e+70, 1e+71, 1e+72, 1e+73, 1e+74, 1e+75, 1e+76, 1e+77, 1e+78, 1e+79, 1e+80, - 1e+81, 1e+82, 1e+83, 1e+84, 1e+85, 1e+86, 1e+87, 1e+88, 1e+89, 1e+90, 1e+91, 1e+92, 1e+93, 1e+94, 1e+95, 1e+96, 1e+97, 1e+98, 1e+99, 1e+100, - 1e+101,1e+102,1e+103,1e+104,1e+105,1e+106,1e+107,1e+108,1e+109,1e+110,1e+111,1e+112,1e+113,1e+114,1e+115,1e+116,1e+117,1e+118,1e+119,1e+120, - 1e+121,1e+122,1e+123,1e+124,1e+125,1e+126,1e+127,1e+128,1e+129,1e+130,1e+131,1e+132,1e+133,1e+134,1e+135,1e+136,1e+137,1e+138,1e+139,1e+140, - 1e+141,1e+142,1e+143,1e+144,1e+145,1e+146,1e+147,1e+148,1e+149,1e+150,1e+151,1e+152,1e+153,1e+154,1e+155,1e+156,1e+157,1e+158,1e+159,1e+160, - 1e+161,1e+162,1e+163,1e+164,1e+165,1e+166,1e+167,1e+168,1e+169,1e+170,1e+171,1e+172,1e+173,1e+174,1e+175,1e+176,1e+177,1e+178,1e+179,1e+180, - 1e+181,1e+182,1e+183,1e+184,1e+185,1e+186,1e+187,1e+188,1e+189,1e+190,1e+191,1e+192,1e+193,1e+194,1e+195,1e+196,1e+197,1e+198,1e+199,1e+200, - 1e+201,1e+202,1e+203,1e+204,1e+205,1e+206,1e+207,1e+208,1e+209,1e+210,1e+211,1e+212,1e+213,1e+214,1e+215,1e+216,1e+217,1e+218,1e+219,1e+220, - 1e+221,1e+222,1e+223,1e+224,1e+225,1e+226,1e+227,1e+228,1e+229,1e+230,1e+231,1e+232,1e+233,1e+234,1e+235,1e+236,1e+237,1e+238,1e+239,1e+240, - 1e+241,1e+242,1e+243,1e+244,1e+245,1e+246,1e+247,1e+248,1e+249,1e+250,1e+251,1e+252,1e+253,1e+254,1e+255,1e+256,1e+257,1e+258,1e+259,1e+260, - 1e+261,1e+262,1e+263,1e+264,1e+265,1e+266,1e+267,1e+268,1e+269,1e+270,1e+271,1e+272,1e+273,1e+274,1e+275,1e+276,1e+277,1e+278,1e+279,1e+280, - 1e+281,1e+282,1e+283,1e+284,1e+285,1e+286,1e+287,1e+288,1e+289,1e+290,1e+291,1e+292,1e+293,1e+294,1e+295,1e+296,1e+297,1e+298,1e+299,1e+300, - 1e+301,1e+302,1e+303,1e+304,1e+305,1e+306,1e+307,1e+308 - }; - RAPIDJSON_ASSERT(n >= 0 && n <= 308); - return e[n]; -} - -} // namespace internal -RAPIDJSON_NAMESPACE_END - -#endif // RAPIDJSON_POW10_ diff --git a/slsReceiverSoftware/include/rapidjson/internal/regex.h b/slsReceiverSoftware/include/rapidjson/internal/regex.h deleted file mode 100644 index 422a5240b..000000000 --- a/slsReceiverSoftware/include/rapidjson/internal/regex.h +++ /dev/null @@ -1,701 +0,0 @@ -// Tencent is pleased to support the open source community by making RapidJSON available. -// -// Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved. -// -// Licensed under the MIT License (the "License"); you may not use this file except -// in compliance with the License. You may obtain a copy of the License at -// -// http://opensource.org/licenses/MIT -// -// Unless required by applicable law or agreed to in writing, software distributed -// under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR -// CONDITIONS OF ANY KIND, either express or implied. See the License for the -// specific language governing permissions and limitations under the License. - -#ifndef RAPIDJSON_INTERNAL_REGEX_H_ -#define RAPIDJSON_INTERNAL_REGEX_H_ - -#include "../allocators.h" -#include "../stream.h" -#include "stack.h" - -#ifdef __clang__ -RAPIDJSON_DIAG_PUSH -RAPIDJSON_DIAG_OFF(padded) -RAPIDJSON_DIAG_OFF(switch-enum) -RAPIDJSON_DIAG_OFF(implicit-fallthrough) -#endif - -#ifdef __GNUC__ -RAPIDJSON_DIAG_PUSH -RAPIDJSON_DIAG_OFF(effc++) -#endif - -#ifdef _MSC_VER -RAPIDJSON_DIAG_PUSH -RAPIDJSON_DIAG_OFF(4512) // assignment operator could not be generated -#endif - -#ifndef RAPIDJSON_REGEX_VERBOSE -#define RAPIDJSON_REGEX_VERBOSE 0 -#endif - -RAPIDJSON_NAMESPACE_BEGIN -namespace internal { - -/////////////////////////////////////////////////////////////////////////////// -// GenericRegex - -static const SizeType kRegexInvalidState = ~SizeType(0); //!< Represents an invalid index in GenericRegex::State::out, out1 -static const SizeType kRegexInvalidRange = ~SizeType(0); - -//! Regular expression engine with subset of ECMAscript grammar. -/*! - Supported regular expression syntax: - - \c ab Concatenation - - \c a|b Alternation - - \c a? Zero or one - - \c a* Zero or more - - \c a+ One or more - - \c a{3} Exactly 3 times - - \c a{3,} At least 3 times - - \c a{3,5} 3 to 5 times - - \c (ab) Grouping - - \c ^a At the beginning - - \c a$ At the end - - \c . Any character - - \c [abc] Character classes - - \c [a-c] Character class range - - \c [a-z0-9_] Character class combination - - \c [^abc] Negated character classes - - \c [^a-c] Negated character class range - - \c [\b] Backspace (U+0008) - - \c \\| \\\\ ... Escape characters - - \c \\f Form feed (U+000C) - - \c \\n Line feed (U+000A) - - \c \\r Carriage return (U+000D) - - \c \\t Tab (U+0009) - - \c \\v Vertical tab (U+000B) - - \note This is a Thompson NFA engine, implemented with reference to - Cox, Russ. "Regular Expression Matching Can Be Simple And Fast (but is slow in Java, Perl, PHP, Python, Ruby,...).", - https://swtch.com/~rsc/regexp/regexp1.html -*/ -template -class GenericRegex { -public: - typedef typename Encoding::Ch Ch; - - GenericRegex(const Ch* source, Allocator* allocator = 0) : - states_(allocator, 256), ranges_(allocator, 256), root_(kRegexInvalidState), stateCount_(), rangeCount_(), - stateSet_(), state0_(allocator, 0), state1_(allocator, 0), anchorBegin_(), anchorEnd_() - { - GenericStringStream ss(source); - DecodedStream > ds(ss); - Parse(ds); - } - - ~GenericRegex() { - Allocator::Free(stateSet_); - } - - bool IsValid() const { - return root_ != kRegexInvalidState; - } - - template - bool Match(InputStream& is) const { - return SearchWithAnchoring(is, true, true); - } - - bool Match(const Ch* s) const { - GenericStringStream is(s); - return Match(is); - } - - template - bool Search(InputStream& is) const { - return SearchWithAnchoring(is, anchorBegin_, anchorEnd_); - } - - bool Search(const Ch* s) const { - GenericStringStream is(s); - return Search(is); - } - -private: - enum Operator { - kZeroOrOne, - kZeroOrMore, - kOneOrMore, - kConcatenation, - kAlternation, - kLeftParenthesis - }; - - static const unsigned kAnyCharacterClass = 0xFFFFFFFF; //!< For '.' - static const unsigned kRangeCharacterClass = 0xFFFFFFFE; - static const unsigned kRangeNegationFlag = 0x80000000; - - struct Range { - unsigned start; // - unsigned end; - SizeType next; - }; - - struct State { - SizeType out; //!< Equals to kInvalid for matching state - SizeType out1; //!< Equals to non-kInvalid for split - SizeType rangeStart; - unsigned codepoint; - }; - - struct Frag { - Frag(SizeType s, SizeType o, SizeType m) : start(s), out(o), minIndex(m) {} - SizeType start; - SizeType out; //!< link-list of all output states - SizeType minIndex; - }; - - template - class DecodedStream { - public: - DecodedStream(SourceStream& ss) : ss_(ss), codepoint_() { Decode(); } - unsigned Peek() { return codepoint_; } - unsigned Take() { - unsigned c = codepoint_; - if (c) // No further decoding when '\0' - Decode(); - return c; - } - - private: - void Decode() { - if (!Encoding::Decode(ss_, &codepoint_)) - codepoint_ = 0; - } - - SourceStream& ss_; - unsigned codepoint_; - }; - - State& GetState(SizeType index) { - RAPIDJSON_ASSERT(index < stateCount_); - return states_.template Bottom()[index]; - } - - const State& GetState(SizeType index) const { - RAPIDJSON_ASSERT(index < stateCount_); - return states_.template Bottom()[index]; - } - - Range& GetRange(SizeType index) { - RAPIDJSON_ASSERT(index < rangeCount_); - return ranges_.template Bottom()[index]; - } - - const Range& GetRange(SizeType index) const { - RAPIDJSON_ASSERT(index < rangeCount_); - return ranges_.template Bottom()[index]; - } - - template - void Parse(DecodedStream& ds) { - Allocator allocator; - Stack operandStack(&allocator, 256); // Frag - Stack operatorStack(&allocator, 256); // Operator - Stack atomCountStack(&allocator, 256); // unsigned (Atom per parenthesis) - - *atomCountStack.template Push() = 0; - - unsigned codepoint; - while (ds.Peek() != 0) { - switch (codepoint = ds.Take()) { - case '^': - anchorBegin_ = true; - break; - - case '$': - anchorEnd_ = true; - break; - - case '|': - while (!operatorStack.Empty() && *operatorStack.template Top() < kAlternation) - if (!Eval(operandStack, *operatorStack.template Pop(1))) - return; - *operatorStack.template Push() = kAlternation; - *atomCountStack.template Top() = 0; - break; - - case '(': - *operatorStack.template Push() = kLeftParenthesis; - *atomCountStack.template Push() = 0; - break; - - case ')': - while (!operatorStack.Empty() && *operatorStack.template Top() != kLeftParenthesis) - if (!Eval(operandStack, *operatorStack.template Pop(1))) - return; - if (operatorStack.Empty()) - return; - operatorStack.template Pop(1); - atomCountStack.template Pop(1); - ImplicitConcatenation(atomCountStack, operatorStack); - break; - - case '?': - if (!Eval(operandStack, kZeroOrOne)) - return; - break; - - case '*': - if (!Eval(operandStack, kZeroOrMore)) - return; - break; - - case '+': - if (!Eval(operandStack, kOneOrMore)) - return; - break; - - case '{': - { - unsigned n, m; - if (!ParseUnsigned(ds, &n)) - return; - - if (ds.Peek() == ',') { - ds.Take(); - if (ds.Peek() == '}') - m = kInfinityQuantifier; - else if (!ParseUnsigned(ds, &m) || m < n) - return; - } - else - m = n; - - if (!EvalQuantifier(operandStack, n, m) || ds.Peek() != '}') - return; - ds.Take(); - } - break; - - case '.': - PushOperand(operandStack, kAnyCharacterClass); - ImplicitConcatenation(atomCountStack, operatorStack); - break; - - case '[': - { - SizeType range; - if (!ParseRange(ds, &range)) - return; - SizeType s = NewState(kRegexInvalidState, kRegexInvalidState, kRangeCharacterClass); - GetState(s).rangeStart = range; - *operandStack.template Push() = Frag(s, s, s); - } - ImplicitConcatenation(atomCountStack, operatorStack); - break; - - case '\\': // Escape character - if (!CharacterEscape(ds, &codepoint)) - return; // Unsupported escape character - // fall through to default - - default: // Pattern character - PushOperand(operandStack, codepoint); - ImplicitConcatenation(atomCountStack, operatorStack); - } - } - - while (!operatorStack.Empty()) - if (!Eval(operandStack, *operatorStack.template Pop(1))) - return; - - // Link the operand to matching state. - if (operandStack.GetSize() == sizeof(Frag)) { - Frag* e = operandStack.template Pop(1); - Patch(e->out, NewState(kRegexInvalidState, kRegexInvalidState, 0)); - root_ = e->start; - -#if RAPIDJSON_REGEX_VERBOSE - printf("root: %d\n", root_); - for (SizeType i = 0; i < stateCount_ ; i++) { - State& s = GetState(i); - printf("[%2d] out: %2d out1: %2d c: '%c'\n", i, s.out, s.out1, (char)s.codepoint); - } - printf("\n"); -#endif - } - - // Preallocate buffer for SearchWithAnchoring() - RAPIDJSON_ASSERT(stateSet_ == 0); - if (stateCount_ > 0) { - stateSet_ = static_cast(states_.GetAllocator().Malloc(GetStateSetSize())); - state0_.template Reserve(stateCount_); - state1_.template Reserve(stateCount_); - } - } - - SizeType NewState(SizeType out, SizeType out1, unsigned codepoint) { - State* s = states_.template Push(); - s->out = out; - s->out1 = out1; - s->codepoint = codepoint; - s->rangeStart = kRegexInvalidRange; - return stateCount_++; - } - - void PushOperand(Stack& operandStack, unsigned codepoint) { - SizeType s = NewState(kRegexInvalidState, kRegexInvalidState, codepoint); - *operandStack.template Push() = Frag(s, s, s); - } - - void ImplicitConcatenation(Stack& atomCountStack, Stack& operatorStack) { - if (*atomCountStack.template Top()) - *operatorStack.template Push() = kConcatenation; - (*atomCountStack.template Top())++; - } - - SizeType Append(SizeType l1, SizeType l2) { - SizeType old = l1; - while (GetState(l1).out != kRegexInvalidState) - l1 = GetState(l1).out; - GetState(l1).out = l2; - return old; - } - - void Patch(SizeType l, SizeType s) { - for (SizeType next; l != kRegexInvalidState; l = next) { - next = GetState(l).out; - GetState(l).out = s; - } - } - - bool Eval(Stack& operandStack, Operator op) { - switch (op) { - case kConcatenation: - RAPIDJSON_ASSERT(operandStack.GetSize() >= sizeof(Frag) * 2); - { - Frag e2 = *operandStack.template Pop(1); - Frag e1 = *operandStack.template Pop(1); - Patch(e1.out, e2.start); - *operandStack.template Push() = Frag(e1.start, e2.out, Min(e1.minIndex, e2.minIndex)); - } - return true; - - case kAlternation: - if (operandStack.GetSize() >= sizeof(Frag) * 2) { - Frag e2 = *operandStack.template Pop(1); - Frag e1 = *operandStack.template Pop(1); - SizeType s = NewState(e1.start, e2.start, 0); - *operandStack.template Push() = Frag(s, Append(e1.out, e2.out), Min(e1.minIndex, e2.minIndex)); - return true; - } - return false; - - case kZeroOrOne: - if (operandStack.GetSize() >= sizeof(Frag)) { - Frag e = *operandStack.template Pop(1); - SizeType s = NewState(kRegexInvalidState, e.start, 0); - *operandStack.template Push() = Frag(s, Append(e.out, s), e.minIndex); - return true; - } - return false; - - case kZeroOrMore: - if (operandStack.GetSize() >= sizeof(Frag)) { - Frag e = *operandStack.template Pop(1); - SizeType s = NewState(kRegexInvalidState, e.start, 0); - Patch(e.out, s); - *operandStack.template Push() = Frag(s, s, e.minIndex); - return true; - } - return false; - - default: - RAPIDJSON_ASSERT(op == kOneOrMore); - if (operandStack.GetSize() >= sizeof(Frag)) { - Frag e = *operandStack.template Pop(1); - SizeType s = NewState(kRegexInvalidState, e.start, 0); - Patch(e.out, s); - *operandStack.template Push() = Frag(e.start, s, e.minIndex); - return true; - } - return false; - } - } - - bool EvalQuantifier(Stack& operandStack, unsigned n, unsigned m) { - RAPIDJSON_ASSERT(n <= m); - RAPIDJSON_ASSERT(operandStack.GetSize() >= sizeof(Frag)); - - if (n == 0) { - if (m == 0) // a{0} not support - return false; - else if (m == kInfinityQuantifier) - Eval(operandStack, kZeroOrMore); // a{0,} -> a* - else { - Eval(operandStack, kZeroOrOne); // a{0,5} -> a? - for (unsigned i = 0; i < m - 1; i++) - CloneTopOperand(operandStack); // a{0,5} -> a? a? a? a? a? - for (unsigned i = 0; i < m - 1; i++) - Eval(operandStack, kConcatenation); // a{0,5} -> a?a?a?a?a? - } - return true; - } - - for (unsigned i = 0; i < n - 1; i++) // a{3} -> a a a - CloneTopOperand(operandStack); - - if (m == kInfinityQuantifier) - Eval(operandStack, kOneOrMore); // a{3,} -> a a a+ - else if (m > n) { - CloneTopOperand(operandStack); // a{3,5} -> a a a a - Eval(operandStack, kZeroOrOne); // a{3,5} -> a a a a? - for (unsigned i = n; i < m - 1; i++) - CloneTopOperand(operandStack); // a{3,5} -> a a a a? a? - for (unsigned i = n; i < m; i++) - Eval(operandStack, kConcatenation); // a{3,5} -> a a aa?a? - } - - for (unsigned i = 0; i < n - 1; i++) - Eval(operandStack, kConcatenation); // a{3} -> aaa, a{3,} -> aaa+, a{3.5} -> aaaa?a? - - return true; - } - - static SizeType Min(SizeType a, SizeType b) { return a < b ? a : b; } - - void CloneTopOperand(Stack& operandStack) { - const Frag src = *operandStack.template Top(); // Copy constructor to prevent invalidation - SizeType count = stateCount_ - src.minIndex; // Assumes top operand contains states in [src->minIndex, stateCount_) - State* s = states_.template Push(count); - memcpy(s, &GetState(src.minIndex), count * sizeof(State)); - for (SizeType j = 0; j < count; j++) { - if (s[j].out != kRegexInvalidState) - s[j].out += count; - if (s[j].out1 != kRegexInvalidState) - s[j].out1 += count; - } - *operandStack.template Push() = Frag(src.start + count, src.out + count, src.minIndex + count); - stateCount_ += count; - } - - template - bool ParseUnsigned(DecodedStream& ds, unsigned* u) { - unsigned r = 0; - if (ds.Peek() < '0' || ds.Peek() > '9') - return false; - while (ds.Peek() >= '0' && ds.Peek() <= '9') { - if (r >= 429496729 && ds.Peek() > '5') // 2^32 - 1 = 4294967295 - return false; // overflow - r = r * 10 + (ds.Take() - '0'); - } - *u = r; - return true; - } - - template - bool ParseRange(DecodedStream& ds, SizeType* range) { - bool isBegin = true; - bool negate = false; - int step = 0; - SizeType start = kRegexInvalidRange; - SizeType current = kRegexInvalidRange; - unsigned codepoint; - while ((codepoint = ds.Take()) != 0) { - if (isBegin) { - isBegin = false; - if (codepoint == '^') { - negate = true; - continue; - } - } - - switch (codepoint) { - case ']': - if (start == kRegexInvalidRange) - return false; // Error: nothing inside [] - if (step == 2) { // Add trailing '-' - SizeType r = NewRange('-'); - RAPIDJSON_ASSERT(current != kRegexInvalidRange); - GetRange(current).next = r; - } - if (negate) - GetRange(start).start |= kRangeNegationFlag; - *range = start; - return true; - - case '\\': - if (ds.Peek() == 'b') { - ds.Take(); - codepoint = 0x0008; // Escape backspace character - } - else if (!CharacterEscape(ds, &codepoint)) - return false; - // fall through to default - - default: - switch (step) { - case 1: - if (codepoint == '-') { - step++; - break; - } - // fall through to step 0 for other characters - - case 0: - { - SizeType r = NewRange(codepoint); - if (current != kRegexInvalidRange) - GetRange(current).next = r; - if (start == kRegexInvalidRange) - start = r; - current = r; - } - step = 1; - break; - - default: - RAPIDJSON_ASSERT(step == 2); - GetRange(current).end = codepoint; - step = 0; - } - } - } - return false; - } - - SizeType NewRange(unsigned codepoint) { - Range* r = ranges_.template Push(); - r->start = r->end = codepoint; - r->next = kRegexInvalidRange; - return rangeCount_++; - } - - template - bool CharacterEscape(DecodedStream& ds, unsigned* escapedCodepoint) { - unsigned codepoint; - switch (codepoint = ds.Take()) { - case '^': - case '$': - case '|': - case '(': - case ')': - case '?': - case '*': - case '+': - case '.': - case '[': - case ']': - case '{': - case '}': - case '\\': - *escapedCodepoint = codepoint; return true; - case 'f': *escapedCodepoint = 0x000C; return true; - case 'n': *escapedCodepoint = 0x000A; return true; - case 'r': *escapedCodepoint = 0x000D; return true; - case 't': *escapedCodepoint = 0x0009; return true; - case 'v': *escapedCodepoint = 0x000B; return true; - default: - return false; // Unsupported escape character - } - } - - template - bool SearchWithAnchoring(InputStream& is, bool anchorBegin, bool anchorEnd) const { - RAPIDJSON_ASSERT(IsValid()); - DecodedStream ds(is); - - state0_.Clear(); - Stack *current = &state0_, *next = &state1_; - const size_t stateSetSize = GetStateSetSize(); - std::memset(stateSet_, 0, stateSetSize); - - bool matched = AddState(*current, root_); - unsigned codepoint; - while (!current->Empty() && (codepoint = ds.Take()) != 0) { - std::memset(stateSet_, 0, stateSetSize); - next->Clear(); - matched = false; - for (const SizeType* s = current->template Bottom(); s != current->template End(); ++s) { - const State& sr = GetState(*s); - if (sr.codepoint == codepoint || - sr.codepoint == kAnyCharacterClass || - (sr.codepoint == kRangeCharacterClass && MatchRange(sr.rangeStart, codepoint))) - { - matched = AddState(*next, sr.out) || matched; - if (!anchorEnd && matched) - return true; - } - if (!anchorBegin) - AddState(*next, root_); - } - internal::Swap(current, next); - } - - return matched; - } - - size_t GetStateSetSize() const { - return (stateCount_ + 31) / 32 * 4; - } - - // Return whether the added states is a match state - bool AddState(Stack& l, SizeType index) const { - RAPIDJSON_ASSERT(index != kRegexInvalidState); - - const State& s = GetState(index); - if (s.out1 != kRegexInvalidState) { // Split - bool matched = AddState(l, s.out); - return AddState(l, s.out1) || matched; - } - else if (!(stateSet_[index >> 5] & (1 << (index & 31)))) { - stateSet_[index >> 5] |= (1 << (index & 31)); - *l.template PushUnsafe() = index; - } - return s.out == kRegexInvalidState; // by using PushUnsafe() above, we can ensure s is not validated due to reallocation. - } - - bool MatchRange(SizeType rangeIndex, unsigned codepoint) const { - bool yes = (GetRange(rangeIndex).start & kRangeNegationFlag) == 0; - while (rangeIndex != kRegexInvalidRange) { - const Range& r = GetRange(rangeIndex); - if (codepoint >= (r.start & ~kRangeNegationFlag) && codepoint <= r.end) - return yes; - rangeIndex = r.next; - } - return !yes; - } - - Stack states_; - Stack ranges_; - SizeType root_; - SizeType stateCount_; - SizeType rangeCount_; - - static const unsigned kInfinityQuantifier = ~0u; - - // For SearchWithAnchoring() - uint32_t* stateSet_; // allocated by states_.GetAllocator() - mutable Stack state0_; - mutable Stack state1_; - bool anchorBegin_; - bool anchorEnd_; -}; - -typedef GenericRegex > Regex; - -} // namespace internal -RAPIDJSON_NAMESPACE_END - -#ifdef __clang__ -RAPIDJSON_DIAG_POP -#endif - -#ifdef _MSC_VER -RAPIDJSON_DIAG_POP -#endif - -#endif // RAPIDJSON_INTERNAL_REGEX_H_ diff --git a/slsReceiverSoftware/include/rapidjson/internal/stack.h b/slsReceiverSoftware/include/rapidjson/internal/stack.h deleted file mode 100644 index 022c9aab4..000000000 --- a/slsReceiverSoftware/include/rapidjson/internal/stack.h +++ /dev/null @@ -1,230 +0,0 @@ -// Tencent is pleased to support the open source community by making RapidJSON available. -// -// Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved. -// -// Licensed under the MIT License (the "License"); you may not use this file except -// in compliance with the License. You may obtain a copy of the License at -// -// http://opensource.org/licenses/MIT -// -// Unless required by applicable law or agreed to in writing, software distributed -// under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR -// CONDITIONS OF ANY KIND, either express or implied. See the License for the -// specific language governing permissions and limitations under the License. - -#ifndef RAPIDJSON_INTERNAL_STACK_H_ -#define RAPIDJSON_INTERNAL_STACK_H_ - -#include "../allocators.h" -#include "swap.h" - -#if defined(__clang__) -RAPIDJSON_DIAG_PUSH -RAPIDJSON_DIAG_OFF(c++98-compat) -#endif - -RAPIDJSON_NAMESPACE_BEGIN -namespace internal { - -/////////////////////////////////////////////////////////////////////////////// -// Stack - -//! A type-unsafe stack for storing different types of data. -/*! \tparam Allocator Allocator for allocating stack memory. -*/ -template -class Stack { -public: - // Optimization note: Do not allocate memory for stack_ in constructor. - // Do it lazily when first Push() -> Expand() -> Resize(). - Stack(Allocator* allocator, size_t stackCapacity) : allocator_(allocator), ownAllocator_(0), stack_(0), stackTop_(0), stackEnd_(0), initialCapacity_(stackCapacity) { - } - -#if RAPIDJSON_HAS_CXX11_RVALUE_REFS - Stack(Stack&& rhs) - : allocator_(rhs.allocator_), - ownAllocator_(rhs.ownAllocator_), - stack_(rhs.stack_), - stackTop_(rhs.stackTop_), - stackEnd_(rhs.stackEnd_), - initialCapacity_(rhs.initialCapacity_) - { - rhs.allocator_ = 0; - rhs.ownAllocator_ = 0; - rhs.stack_ = 0; - rhs.stackTop_ = 0; - rhs.stackEnd_ = 0; - rhs.initialCapacity_ = 0; - } -#endif - - ~Stack() { - Destroy(); - } - -#if RAPIDJSON_HAS_CXX11_RVALUE_REFS - Stack& operator=(Stack&& rhs) { - if (&rhs != this) - { - Destroy(); - - allocator_ = rhs.allocator_; - ownAllocator_ = rhs.ownAllocator_; - stack_ = rhs.stack_; - stackTop_ = rhs.stackTop_; - stackEnd_ = rhs.stackEnd_; - initialCapacity_ = rhs.initialCapacity_; - - rhs.allocator_ = 0; - rhs.ownAllocator_ = 0; - rhs.stack_ = 0; - rhs.stackTop_ = 0; - rhs.stackEnd_ = 0; - rhs.initialCapacity_ = 0; - } - return *this; - } -#endif - - void Swap(Stack& rhs) RAPIDJSON_NOEXCEPT { - internal::Swap(allocator_, rhs.allocator_); - internal::Swap(ownAllocator_, rhs.ownAllocator_); - internal::Swap(stack_, rhs.stack_); - internal::Swap(stackTop_, rhs.stackTop_); - internal::Swap(stackEnd_, rhs.stackEnd_); - internal::Swap(initialCapacity_, rhs.initialCapacity_); - } - - void Clear() { stackTop_ = stack_; } - - void ShrinkToFit() { - if (Empty()) { - // If the stack is empty, completely deallocate the memory. - Allocator::Free(stack_); - stack_ = 0; - stackTop_ = 0; - stackEnd_ = 0; - } - else - Resize(GetSize()); - } - - // Optimization note: try to minimize the size of this function for force inline. - // Expansion is run very infrequently, so it is moved to another (probably non-inline) function. - template - RAPIDJSON_FORCEINLINE void Reserve(size_t count = 1) { - // Expand the stack if needed - if (RAPIDJSON_UNLIKELY(stackTop_ + sizeof(T) * count > stackEnd_)) - Expand(count); - } - - template - RAPIDJSON_FORCEINLINE T* Push(size_t count = 1) { - Reserve(count); - return PushUnsafe(count); - } - - template - RAPIDJSON_FORCEINLINE T* PushUnsafe(size_t count = 1) { - RAPIDJSON_ASSERT(stackTop_ + sizeof(T) * count <= stackEnd_); - T* ret = reinterpret_cast(stackTop_); - stackTop_ += sizeof(T) * count; - return ret; - } - - template - T* Pop(size_t count) { - RAPIDJSON_ASSERT(GetSize() >= count * sizeof(T)); - stackTop_ -= count * sizeof(T); - return reinterpret_cast(stackTop_); - } - - template - T* Top() { - RAPIDJSON_ASSERT(GetSize() >= sizeof(T)); - return reinterpret_cast(stackTop_ - sizeof(T)); - } - - template - const T* Top() const { - RAPIDJSON_ASSERT(GetSize() >= sizeof(T)); - return reinterpret_cast(stackTop_ - sizeof(T)); - } - - template - T* End() { return reinterpret_cast(stackTop_); } - - template - const T* End() const { return reinterpret_cast(stackTop_); } - - template - T* Bottom() { return reinterpret_cast(stack_); } - - template - const T* Bottom() const { return reinterpret_cast(stack_); } - - bool HasAllocator() const { - return allocator_ != 0; - } - - Allocator& GetAllocator() { - RAPIDJSON_ASSERT(allocator_); - return *allocator_; - } - - bool Empty() const { return stackTop_ == stack_; } - size_t GetSize() const { return static_cast(stackTop_ - stack_); } - size_t GetCapacity() const { return static_cast(stackEnd_ - stack_); } - -private: - template - void Expand(size_t count) { - // Only expand the capacity if the current stack exists. Otherwise just create a stack with initial capacity. - size_t newCapacity; - if (stack_ == 0) { - if (!allocator_) - ownAllocator_ = allocator_ = RAPIDJSON_NEW(Allocator()); - newCapacity = initialCapacity_; - } else { - newCapacity = GetCapacity(); - newCapacity += (newCapacity + 1) / 2; - } - size_t newSize = GetSize() + sizeof(T) * count; - if (newCapacity < newSize) - newCapacity = newSize; - - Resize(newCapacity); - } - - void Resize(size_t newCapacity) { - const size_t size = GetSize(); // Backup the current size - stack_ = static_cast(allocator_->Realloc(stack_, GetCapacity(), newCapacity)); - stackTop_ = stack_ + size; - stackEnd_ = stack_ + newCapacity; - } - - void Destroy() { - Allocator::Free(stack_); - RAPIDJSON_DELETE(ownAllocator_); // Only delete if it is owned by the stack - } - - // Prohibit copy constructor & assignment operator. - Stack(const Stack&); - Stack& operator=(const Stack&); - - Allocator* allocator_; - Allocator* ownAllocator_; - char *stack_; - char *stackTop_; - char *stackEnd_; - size_t initialCapacity_; -}; - -} // namespace internal -RAPIDJSON_NAMESPACE_END - -#if defined(__clang__) -RAPIDJSON_DIAG_POP -#endif - -#endif // RAPIDJSON_STACK_H_ diff --git a/slsReceiverSoftware/include/rapidjson/internal/strfunc.h b/slsReceiverSoftware/include/rapidjson/internal/strfunc.h deleted file mode 100644 index 2edfae526..000000000 --- a/slsReceiverSoftware/include/rapidjson/internal/strfunc.h +++ /dev/null @@ -1,55 +0,0 @@ -// Tencent is pleased to support the open source community by making RapidJSON available. -// -// Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved. -// -// Licensed under the MIT License (the "License"); you may not use this file except -// in compliance with the License. You may obtain a copy of the License at -// -// http://opensource.org/licenses/MIT -// -// Unless required by applicable law or agreed to in writing, software distributed -// under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR -// CONDITIONS OF ANY KIND, either express or implied. See the License for the -// specific language governing permissions and limitations under the License. - -#ifndef RAPIDJSON_INTERNAL_STRFUNC_H_ -#define RAPIDJSON_INTERNAL_STRFUNC_H_ - -#include "../stream.h" - -RAPIDJSON_NAMESPACE_BEGIN -namespace internal { - -//! Custom strlen() which works on different character types. -/*! \tparam Ch Character type (e.g. char, wchar_t, short) - \param s Null-terminated input string. - \return Number of characters in the string. - \note This has the same semantics as strlen(), the return value is not number of Unicode codepoints. -*/ -template -inline SizeType StrLen(const Ch* s) { - const Ch* p = s; - while (*p) ++p; - return SizeType(p - s); -} - -//! Returns number of code points in a encoded string. -template -bool CountStringCodePoint(const typename Encoding::Ch* s, SizeType length, SizeType* outCount) { - GenericStringStream is(s); - const typename Encoding::Ch* end = s + length; - SizeType count = 0; - while (is.src_ < end) { - unsigned codepoint; - if (!Encoding::Decode(is, &codepoint)) - return false; - count++; - } - *outCount = count; - return true; -} - -} // namespace internal -RAPIDJSON_NAMESPACE_END - -#endif // RAPIDJSON_INTERNAL_STRFUNC_H_ diff --git a/slsReceiverSoftware/include/rapidjson/internal/strtod.h b/slsReceiverSoftware/include/rapidjson/internal/strtod.h deleted file mode 100644 index 289c413b0..000000000 --- a/slsReceiverSoftware/include/rapidjson/internal/strtod.h +++ /dev/null @@ -1,269 +0,0 @@ -// Tencent is pleased to support the open source community by making RapidJSON available. -// -// Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved. -// -// Licensed under the MIT License (the "License"); you may not use this file except -// in compliance with the License. You may obtain a copy of the License at -// -// http://opensource.org/licenses/MIT -// -// Unless required by applicable law or agreed to in writing, software distributed -// under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR -// CONDITIONS OF ANY KIND, either express or implied. See the License for the -// specific language governing permissions and limitations under the License. - -#ifndef RAPIDJSON_STRTOD_ -#define RAPIDJSON_STRTOD_ - -#include "ieee754.h" -#include "biginteger.h" -#include "diyfp.h" -#include "pow10.h" - -RAPIDJSON_NAMESPACE_BEGIN -namespace internal { - -inline double FastPath(double significand, int exp) { - if (exp < -308) - return 0.0; - else if (exp >= 0) - return significand * internal::Pow10(exp); - else - return significand / internal::Pow10(-exp); -} - -inline double StrtodNormalPrecision(double d, int p) { - if (p < -308) { - // Prevent expSum < -308, making Pow10(p) = 0 - d = FastPath(d, -308); - d = FastPath(d, p + 308); - } - else - d = FastPath(d, p); - return d; -} - -template -inline T Min3(T a, T b, T c) { - T m = a; - if (m > b) m = b; - if (m > c) m = c; - return m; -} - -inline int CheckWithinHalfULP(double b, const BigInteger& d, int dExp) { - const Double db(b); - const uint64_t bInt = db.IntegerSignificand(); - const int bExp = db.IntegerExponent(); - const int hExp = bExp - 1; - - int dS_Exp2 = 0, dS_Exp5 = 0, bS_Exp2 = 0, bS_Exp5 = 0, hS_Exp2 = 0, hS_Exp5 = 0; - - // Adjust for decimal exponent - if (dExp >= 0) { - dS_Exp2 += dExp; - dS_Exp5 += dExp; - } - else { - bS_Exp2 -= dExp; - bS_Exp5 -= dExp; - hS_Exp2 -= dExp; - hS_Exp5 -= dExp; - } - - // Adjust for binary exponent - if (bExp >= 0) - bS_Exp2 += bExp; - else { - dS_Exp2 -= bExp; - hS_Exp2 -= bExp; - } - - // Adjust for half ulp exponent - if (hExp >= 0) - hS_Exp2 += hExp; - else { - dS_Exp2 -= hExp; - bS_Exp2 -= hExp; - } - - // Remove common power of two factor from all three scaled values - int common_Exp2 = Min3(dS_Exp2, bS_Exp2, hS_Exp2); - dS_Exp2 -= common_Exp2; - bS_Exp2 -= common_Exp2; - hS_Exp2 -= common_Exp2; - - BigInteger dS = d; - dS.MultiplyPow5(static_cast(dS_Exp5)) <<= static_cast(dS_Exp2); - - BigInteger bS(bInt); - bS.MultiplyPow5(static_cast(bS_Exp5)) <<= static_cast(bS_Exp2); - - BigInteger hS(1); - hS.MultiplyPow5(static_cast(hS_Exp5)) <<= static_cast(hS_Exp2); - - BigInteger delta(0); - dS.Difference(bS, &delta); - - return delta.Compare(hS); -} - -inline bool StrtodFast(double d, int p, double* result) { - // Use fast path for string-to-double conversion if possible - // see http://www.exploringbinary.com/fast-path-decimal-to-floating-point-conversion/ - if (p > 22 && p < 22 + 16) { - // Fast Path Cases In Disguise - d *= internal::Pow10(p - 22); - p = 22; - } - - if (p >= -22 && p <= 22 && d <= 9007199254740991.0) { // 2^53 - 1 - *result = FastPath(d, p); - return true; - } - else - return false; -} - -// Compute an approximation and see if it is within 1/2 ULP -inline bool StrtodDiyFp(const char* decimals, size_t length, size_t decimalPosition, int exp, double* result) { - uint64_t significand = 0; - size_t i = 0; // 2^64 - 1 = 18446744073709551615, 1844674407370955161 = 0x1999999999999999 - for (; i < length; i++) { - if (significand > RAPIDJSON_UINT64_C2(0x19999999, 0x99999999) || - (significand == RAPIDJSON_UINT64_C2(0x19999999, 0x99999999) && decimals[i] > '5')) - break; - significand = significand * 10u + static_cast(decimals[i] - '0'); - } - - if (i < length && decimals[i] >= '5') // Rounding - significand++; - - size_t remaining = length - i; - const unsigned kUlpShift = 3; - const unsigned kUlp = 1 << kUlpShift; - int64_t error = (remaining == 0) ? 0 : kUlp / 2; - - DiyFp v(significand, 0); - v = v.Normalize(); - error <<= -v.e; - - const int dExp = static_cast(decimalPosition) - static_cast(i) + exp; - - int actualExp; - DiyFp cachedPower = GetCachedPower10(dExp, &actualExp); - if (actualExp != dExp) { - static const DiyFp kPow10[] = { - DiyFp(RAPIDJSON_UINT64_C2(0xa0000000, 00000000), -60), // 10^1 - DiyFp(RAPIDJSON_UINT64_C2(0xc8000000, 00000000), -57), // 10^2 - DiyFp(RAPIDJSON_UINT64_C2(0xfa000000, 00000000), -54), // 10^3 - DiyFp(RAPIDJSON_UINT64_C2(0x9c400000, 00000000), -50), // 10^4 - DiyFp(RAPIDJSON_UINT64_C2(0xc3500000, 00000000), -47), // 10^5 - DiyFp(RAPIDJSON_UINT64_C2(0xf4240000, 00000000), -44), // 10^6 - DiyFp(RAPIDJSON_UINT64_C2(0x98968000, 00000000), -40) // 10^7 - }; - int adjustment = dExp - actualExp - 1; - RAPIDJSON_ASSERT(adjustment >= 0 && adjustment < 7); - v = v * kPow10[adjustment]; - if (length + static_cast(adjustment)> 19u) // has more digits than decimal digits in 64-bit - error += kUlp / 2; - } - - v = v * cachedPower; - - error += kUlp + (error == 0 ? 0 : 1); - - const int oldExp = v.e; - v = v.Normalize(); - error <<= oldExp - v.e; - - const unsigned effectiveSignificandSize = Double::EffectiveSignificandSize(64 + v.e); - unsigned precisionSize = 64 - effectiveSignificandSize; - if (precisionSize + kUlpShift >= 64) { - unsigned scaleExp = (precisionSize + kUlpShift) - 63; - v.f >>= scaleExp; - v.e += scaleExp; - error = (error >> scaleExp) + 1 + static_cast(kUlp); - precisionSize -= scaleExp; - } - - DiyFp rounded(v.f >> precisionSize, v.e + static_cast(precisionSize)); - const uint64_t precisionBits = (v.f & ((uint64_t(1) << precisionSize) - 1)) * kUlp; - const uint64_t halfWay = (uint64_t(1) << (precisionSize - 1)) * kUlp; - if (precisionBits >= halfWay + static_cast(error)) { - rounded.f++; - if (rounded.f & (DiyFp::kDpHiddenBit << 1)) { // rounding overflows mantissa (issue #340) - rounded.f >>= 1; - rounded.e++; - } - } - - *result = rounded.ToDouble(); - - return halfWay - static_cast(error) >= precisionBits || precisionBits >= halfWay + static_cast(error); -} - -inline double StrtodBigInteger(double approx, const char* decimals, size_t length, size_t decimalPosition, int exp) { - const BigInteger dInt(decimals, length); - const int dExp = static_cast(decimalPosition) - static_cast(length) + exp; - Double a(approx); - int cmp = CheckWithinHalfULP(a.Value(), dInt, dExp); - if (cmp < 0) - return a.Value(); // within half ULP - else if (cmp == 0) { - // Round towards even - if (a.Significand() & 1) - return a.NextPositiveDouble(); - else - return a.Value(); - } - else // adjustment - return a.NextPositiveDouble(); -} - -inline double StrtodFullPrecision(double d, int p, const char* decimals, size_t length, size_t decimalPosition, int exp) { - RAPIDJSON_ASSERT(d >= 0.0); - RAPIDJSON_ASSERT(length >= 1); - - double result; - if (StrtodFast(d, p, &result)) - return result; - - // Trim leading zeros - while (*decimals == '0' && length > 1) { - length--; - decimals++; - decimalPosition--; - } - - // Trim trailing zeros - while (decimals[length - 1] == '0' && length > 1) { - length--; - decimalPosition--; - exp++; - } - - // Trim right-most digits - const int kMaxDecimalDigit = 780; - if (static_cast(length) > kMaxDecimalDigit) { - int delta = (static_cast(length) - kMaxDecimalDigit); - exp += delta; - decimalPosition -= static_cast(delta); - length = kMaxDecimalDigit; - } - - // If too small, underflow to zero - if (int(length) + exp < -324) - return 0.0; - - if (StrtodDiyFp(decimals, length, decimalPosition, exp, &result)) - return result; - - // Use approximation from StrtodDiyFp and make adjustment with BigInteger comparison - return StrtodBigInteger(result, decimals, length, decimalPosition, exp); -} - -} // namespace internal -RAPIDJSON_NAMESPACE_END - -#endif // RAPIDJSON_STRTOD_ diff --git a/slsReceiverSoftware/include/rapidjson/internal/swap.h b/slsReceiverSoftware/include/rapidjson/internal/swap.h deleted file mode 100644 index 666e49f97..000000000 --- a/slsReceiverSoftware/include/rapidjson/internal/swap.h +++ /dev/null @@ -1,46 +0,0 @@ -// Tencent is pleased to support the open source community by making RapidJSON available. -// -// Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved. -// -// Licensed under the MIT License (the "License"); you may not use this file except -// in compliance with the License. You may obtain a copy of the License at -// -// http://opensource.org/licenses/MIT -// -// Unless required by applicable law or agreed to in writing, software distributed -// under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR -// CONDITIONS OF ANY KIND, either express or implied. See the License for the -// specific language governing permissions and limitations under the License. - -#ifndef RAPIDJSON_INTERNAL_SWAP_H_ -#define RAPIDJSON_INTERNAL_SWAP_H_ - -#include "../rapidjson.h" - -#if defined(__clang__) -RAPIDJSON_DIAG_PUSH -RAPIDJSON_DIAG_OFF(c++98-compat) -#endif - -RAPIDJSON_NAMESPACE_BEGIN -namespace internal { - -//! Custom swap() to avoid dependency on C++ header -/*! \tparam T Type of the arguments to swap, should be instantiated with primitive C++ types only. - \note This has the same semantics as std::swap(). -*/ -template -inline void Swap(T& a, T& b) RAPIDJSON_NOEXCEPT { - T tmp = a; - a = b; - b = tmp; -} - -} // namespace internal -RAPIDJSON_NAMESPACE_END - -#if defined(__clang__) -RAPIDJSON_DIAG_POP -#endif - -#endif // RAPIDJSON_INTERNAL_SWAP_H_ diff --git a/slsReceiverSoftware/include/rapidjson/istreamwrapper.h b/slsReceiverSoftware/include/rapidjson/istreamwrapper.h deleted file mode 100644 index f5fe28977..000000000 --- a/slsReceiverSoftware/include/rapidjson/istreamwrapper.h +++ /dev/null @@ -1,115 +0,0 @@ -// Tencent is pleased to support the open source community by making RapidJSON available. -// -// Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved. -// -// Licensed under the MIT License (the "License"); you may not use this file except -// in compliance with the License. You may obtain a copy of the License at -// -// http://opensource.org/licenses/MIT -// -// Unless required by applicable law or agreed to in writing, software distributed -// under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR -// CONDITIONS OF ANY KIND, either express or implied. See the License for the -// specific language governing permissions and limitations under the License. - -#ifndef RAPIDJSON_ISTREAMWRAPPER_H_ -#define RAPIDJSON_ISTREAMWRAPPER_H_ - -#include "stream.h" -#include - -#ifdef __clang__ -RAPIDJSON_DIAG_PUSH -RAPIDJSON_DIAG_OFF(padded) -#endif - -#ifdef _MSC_VER -RAPIDJSON_DIAG_PUSH -RAPIDJSON_DIAG_OFF(4351) // new behavior: elements of array 'array' will be default initialized -#endif - -RAPIDJSON_NAMESPACE_BEGIN - -//! Wrapper of \c std::basic_istream into RapidJSON's Stream concept. -/*! - The classes can be wrapped including but not limited to: - - - \c std::istringstream - - \c std::stringstream - - \c std::wistringstream - - \c std::wstringstream - - \c std::ifstream - - \c std::fstream - - \c std::wifstream - - \c std::wfstream - - \tparam StreamType Class derived from \c std::basic_istream. -*/ - -template -class BasicIStreamWrapper { -public: - typedef typename StreamType::char_type Ch; - BasicIStreamWrapper(StreamType& stream) : stream_(stream), count_(), peekBuffer_() {} - - Ch Peek() const { - typename StreamType::int_type c = stream_.peek(); - return RAPIDJSON_LIKELY(c != StreamType::traits_type::eof()) ? static_cast(c) : '\0'; - } - - Ch Take() { - typename StreamType::int_type c = stream_.get(); - if (RAPIDJSON_LIKELY(c != StreamType::traits_type::eof())) { - count_++; - return static_cast(c); - } - else - return '\0'; - } - - // tellg() may return -1 when failed. So we count by ourself. - size_t Tell() const { return count_; } - - Ch* PutBegin() { RAPIDJSON_ASSERT(false); return 0; } - void Put(Ch) { RAPIDJSON_ASSERT(false); } - void Flush() { RAPIDJSON_ASSERT(false); } - size_t PutEnd(Ch*) { RAPIDJSON_ASSERT(false); return 0; } - - // For encoding detection only. - const Ch* Peek4() const { - RAPIDJSON_ASSERT(sizeof(Ch) == 1); // Only usable for byte stream. - int i; - bool hasError = false; - for (i = 0; i < 4; ++i) { - typename StreamType::int_type c = stream_.get(); - if (c == StreamType::traits_type::eof()) { - hasError = true; - stream_.clear(); - break; - } - peekBuffer_[i] = static_cast(c); - } - for (--i; i >= 0; --i) - stream_.putback(peekBuffer_[i]); - return !hasError ? peekBuffer_ : 0; - } - -private: - BasicIStreamWrapper(const BasicIStreamWrapper&); - BasicIStreamWrapper& operator=(const BasicIStreamWrapper&); - - StreamType& stream_; - size_t count_; //!< Number of characters read. Note: - mutable Ch peekBuffer_[4]; -}; - -typedef BasicIStreamWrapper IStreamWrapper; -typedef BasicIStreamWrapper WIStreamWrapper; - -#if defined(__clang__) || defined(_MSC_VER) -RAPIDJSON_DIAG_POP -#endif - -RAPIDJSON_NAMESPACE_END - -#endif // RAPIDJSON_ISTREAMWRAPPER_H_ diff --git a/slsReceiverSoftware/include/rapidjson/memorybuffer.h b/slsReceiverSoftware/include/rapidjson/memorybuffer.h deleted file mode 100644 index 39bee1dec..000000000 --- a/slsReceiverSoftware/include/rapidjson/memorybuffer.h +++ /dev/null @@ -1,70 +0,0 @@ -// Tencent is pleased to support the open source community by making RapidJSON available. -// -// Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved. -// -// Licensed under the MIT License (the "License"); you may not use this file except -// in compliance with the License. You may obtain a copy of the License at -// -// http://opensource.org/licenses/MIT -// -// Unless required by applicable law or agreed to in writing, software distributed -// under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR -// CONDITIONS OF ANY KIND, either express or implied. See the License for the -// specific language governing permissions and limitations under the License. - -#ifndef RAPIDJSON_MEMORYBUFFER_H_ -#define RAPIDJSON_MEMORYBUFFER_H_ - -#include "stream.h" -#include "internal/stack.h" - -RAPIDJSON_NAMESPACE_BEGIN - -//! Represents an in-memory output byte stream. -/*! - This class is mainly for being wrapped by EncodedOutputStream or AutoUTFOutputStream. - - It is similar to FileWriteBuffer but the destination is an in-memory buffer instead of a file. - - Differences between MemoryBuffer and StringBuffer: - 1. StringBuffer has Encoding but MemoryBuffer is only a byte buffer. - 2. StringBuffer::GetString() returns a null-terminated string. MemoryBuffer::GetBuffer() returns a buffer without terminator. - - \tparam Allocator type for allocating memory buffer. - \note implements Stream concept -*/ -template -struct GenericMemoryBuffer { - typedef char Ch; // byte - - GenericMemoryBuffer(Allocator* allocator = 0, size_t capacity = kDefaultCapacity) : stack_(allocator, capacity) {} - - void Put(Ch c) { *stack_.template Push() = c; } - void Flush() {} - - void Clear() { stack_.Clear(); } - void ShrinkToFit() { stack_.ShrinkToFit(); } - Ch* Push(size_t count) { return stack_.template Push(count); } - void Pop(size_t count) { stack_.template Pop(count); } - - const Ch* GetBuffer() const { - return stack_.template Bottom(); - } - - size_t GetSize() const { return stack_.GetSize(); } - - static const size_t kDefaultCapacity = 256; - mutable internal::Stack stack_; -}; - -typedef GenericMemoryBuffer<> MemoryBuffer; - -//! Implement specialized version of PutN() with memset() for better performance. -template<> -inline void PutN(MemoryBuffer& memoryBuffer, char c, size_t n) { - std::memset(memoryBuffer.stack_.Push(n), c, n * sizeof(c)); -} - -RAPIDJSON_NAMESPACE_END - -#endif // RAPIDJSON_MEMORYBUFFER_H_ diff --git a/slsReceiverSoftware/include/rapidjson/memorystream.h b/slsReceiverSoftware/include/rapidjson/memorystream.h deleted file mode 100644 index 1d71d8a4f..000000000 --- a/slsReceiverSoftware/include/rapidjson/memorystream.h +++ /dev/null @@ -1,71 +0,0 @@ -// Tencent is pleased to support the open source community by making RapidJSON available. -// -// Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved. -// -// Licensed under the MIT License (the "License"); you may not use this file except -// in compliance with the License. You may obtain a copy of the License at -// -// http://opensource.org/licenses/MIT -// -// Unless required by applicable law or agreed to in writing, software distributed -// under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR -// CONDITIONS OF ANY KIND, either express or implied. See the License for the -// specific language governing permissions and limitations under the License. - -#ifndef RAPIDJSON_MEMORYSTREAM_H_ -#define RAPIDJSON_MEMORYSTREAM_H_ - -#include "stream.h" - -#ifdef __clang__ -RAPIDJSON_DIAG_PUSH -RAPIDJSON_DIAG_OFF(unreachable-code) -RAPIDJSON_DIAG_OFF(missing-noreturn) -#endif - -RAPIDJSON_NAMESPACE_BEGIN - -//! Represents an in-memory input byte stream. -/*! - This class is mainly for being wrapped by EncodedInputStream or AutoUTFInputStream. - - It is similar to FileReadBuffer but the source is an in-memory buffer instead of a file. - - Differences between MemoryStream and StringStream: - 1. StringStream has encoding but MemoryStream is a byte stream. - 2. MemoryStream needs size of the source buffer and the buffer don't need to be null terminated. StringStream assume null-terminated string as source. - 3. MemoryStream supports Peek4() for encoding detection. StringStream is specified with an encoding so it should not have Peek4(). - \note implements Stream concept -*/ -struct MemoryStream { - typedef char Ch; // byte - - MemoryStream(const Ch *src, size_t size) : src_(src), begin_(src), end_(src + size), size_(size) {} - - Ch Peek() const { return RAPIDJSON_UNLIKELY(src_ == end_) ? '\0' : *src_; } - Ch Take() { return RAPIDJSON_UNLIKELY(src_ == end_) ? '\0' : *src_++; } - size_t Tell() const { return static_cast(src_ - begin_); } - - Ch* PutBegin() { RAPIDJSON_ASSERT(false); return 0; } - void Put(Ch) { RAPIDJSON_ASSERT(false); } - void Flush() { RAPIDJSON_ASSERT(false); } - size_t PutEnd(Ch*) { RAPIDJSON_ASSERT(false); return 0; } - - // For encoding detection only. - const Ch* Peek4() const { - return Tell() + 4 <= size_ ? src_ : 0; - } - - const Ch* src_; //!< Current read position. - const Ch* begin_; //!< Original head of the string. - const Ch* end_; //!< End of stream. - size_t size_; //!< Size of the stream. -}; - -RAPIDJSON_NAMESPACE_END - -#ifdef __clang__ -RAPIDJSON_DIAG_POP -#endif - -#endif // RAPIDJSON_MEMORYBUFFER_H_ diff --git a/slsReceiverSoftware/include/rapidjson/msinttypes/inttypes.h b/slsReceiverSoftware/include/rapidjson/msinttypes/inttypes.h deleted file mode 100644 index 18111286b..000000000 --- a/slsReceiverSoftware/include/rapidjson/msinttypes/inttypes.h +++ /dev/null @@ -1,316 +0,0 @@ -// ISO C9x compliant inttypes.h for Microsoft Visual Studio -// Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124 -// -// Copyright (c) 2006-2013 Alexander Chemeris -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// 1. Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// -// 2. Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// 3. Neither the name of the product nor the names of its contributors may -// be used to endorse or promote products derived from this software -// without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED -// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO -// EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; -// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR -// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF -// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -/////////////////////////////////////////////////////////////////////////////// - -// The above software in this distribution may have been modified by -// THL A29 Limited ("Tencent Modifications"). -// All Tencent Modifications are Copyright (C) 2015 THL A29 Limited. - -#ifndef _MSC_VER // [ -#error "Use this header only with Microsoft Visual C++ compilers!" -#endif // _MSC_VER ] - -#ifndef _MSC_INTTYPES_H_ // [ -#define _MSC_INTTYPES_H_ - -#if _MSC_VER > 1000 -#pragma once -#endif - -#include "stdint.h" - -// miloyip: VC supports inttypes.h since VC2013 -#if _MSC_VER >= 1800 -#include -#else - -// 7.8 Format conversion of integer types - -typedef struct { - intmax_t quot; - intmax_t rem; -} imaxdiv_t; - -// 7.8.1 Macros for format specifiers - -#if !defined(__cplusplus) || defined(__STDC_FORMAT_MACROS) // [ See footnote 185 at page 198 - -// The fprintf macros for signed integers are: -#define PRId8 "d" -#define PRIi8 "i" -#define PRIdLEAST8 "d" -#define PRIiLEAST8 "i" -#define PRIdFAST8 "d" -#define PRIiFAST8 "i" - -#define PRId16 "hd" -#define PRIi16 "hi" -#define PRIdLEAST16 "hd" -#define PRIiLEAST16 "hi" -#define PRIdFAST16 "hd" -#define PRIiFAST16 "hi" - -#define PRId32 "I32d" -#define PRIi32 "I32i" -#define PRIdLEAST32 "I32d" -#define PRIiLEAST32 "I32i" -#define PRIdFAST32 "I32d" -#define PRIiFAST32 "I32i" - -#define PRId64 "I64d" -#define PRIi64 "I64i" -#define PRIdLEAST64 "I64d" -#define PRIiLEAST64 "I64i" -#define PRIdFAST64 "I64d" -#define PRIiFAST64 "I64i" - -#define PRIdMAX "I64d" -#define PRIiMAX "I64i" - -#define PRIdPTR "Id" -#define PRIiPTR "Ii" - -// The fprintf macros for unsigned integers are: -#define PRIo8 "o" -#define PRIu8 "u" -#define PRIx8 "x" -#define PRIX8 "X" -#define PRIoLEAST8 "o" -#define PRIuLEAST8 "u" -#define PRIxLEAST8 "x" -#define PRIXLEAST8 "X" -#define PRIoFAST8 "o" -#define PRIuFAST8 "u" -#define PRIxFAST8 "x" -#define PRIXFAST8 "X" - -#define PRIo16 "ho" -#define PRIu16 "hu" -#define PRIx16 "hx" -#define PRIX16 "hX" -#define PRIoLEAST16 "ho" -#define PRIuLEAST16 "hu" -#define PRIxLEAST16 "hx" -#define PRIXLEAST16 "hX" -#define PRIoFAST16 "ho" -#define PRIuFAST16 "hu" -#define PRIxFAST16 "hx" -#define PRIXFAST16 "hX" - -#define PRIo32 "I32o" -#define PRIu32 "I32u" -#define PRIx32 "I32x" -#define PRIX32 "I32X" -#define PRIoLEAST32 "I32o" -#define PRIuLEAST32 "I32u" -#define PRIxLEAST32 "I32x" -#define PRIXLEAST32 "I32X" -#define PRIoFAST32 "I32o" -#define PRIuFAST32 "I32u" -#define PRIxFAST32 "I32x" -#define PRIXFAST32 "I32X" - -#define PRIo64 "I64o" -#define PRIu64 "I64u" -#define PRIx64 "I64x" -#define PRIX64 "I64X" -#define PRIoLEAST64 "I64o" -#define PRIuLEAST64 "I64u" -#define PRIxLEAST64 "I64x" -#define PRIXLEAST64 "I64X" -#define PRIoFAST64 "I64o" -#define PRIuFAST64 "I64u" -#define PRIxFAST64 "I64x" -#define PRIXFAST64 "I64X" - -#define PRIoMAX "I64o" -#define PRIuMAX "I64u" -#define PRIxMAX "I64x" -#define PRIXMAX "I64X" - -#define PRIoPTR "Io" -#define PRIuPTR "Iu" -#define PRIxPTR "Ix" -#define PRIXPTR "IX" - -// The fscanf macros for signed integers are: -#define SCNd8 "d" -#define SCNi8 "i" -#define SCNdLEAST8 "d" -#define SCNiLEAST8 "i" -#define SCNdFAST8 "d" -#define SCNiFAST8 "i" - -#define SCNd16 "hd" -#define SCNi16 "hi" -#define SCNdLEAST16 "hd" -#define SCNiLEAST16 "hi" -#define SCNdFAST16 "hd" -#define SCNiFAST16 "hi" - -#define SCNd32 "ld" -#define SCNi32 "li" -#define SCNdLEAST32 "ld" -#define SCNiLEAST32 "li" -#define SCNdFAST32 "ld" -#define SCNiFAST32 "li" - -#define SCNd64 "I64d" -#define SCNi64 "I64i" -#define SCNdLEAST64 "I64d" -#define SCNiLEAST64 "I64i" -#define SCNdFAST64 "I64d" -#define SCNiFAST64 "I64i" - -#define SCNdMAX "I64d" -#define SCNiMAX "I64i" - -#ifdef _WIN64 // [ -# define SCNdPTR "I64d" -# define SCNiPTR "I64i" -#else // _WIN64 ][ -# define SCNdPTR "ld" -# define SCNiPTR "li" -#endif // _WIN64 ] - -// The fscanf macros for unsigned integers are: -#define SCNo8 "o" -#define SCNu8 "u" -#define SCNx8 "x" -#define SCNX8 "X" -#define SCNoLEAST8 "o" -#define SCNuLEAST8 "u" -#define SCNxLEAST8 "x" -#define SCNXLEAST8 "X" -#define SCNoFAST8 "o" -#define SCNuFAST8 "u" -#define SCNxFAST8 "x" -#define SCNXFAST8 "X" - -#define SCNo16 "ho" -#define SCNu16 "hu" -#define SCNx16 "hx" -#define SCNX16 "hX" -#define SCNoLEAST16 "ho" -#define SCNuLEAST16 "hu" -#define SCNxLEAST16 "hx" -#define SCNXLEAST16 "hX" -#define SCNoFAST16 "ho" -#define SCNuFAST16 "hu" -#define SCNxFAST16 "hx" -#define SCNXFAST16 "hX" - -#define SCNo32 "lo" -#define SCNu32 "lu" -#define SCNx32 "lx" -#define SCNX32 "lX" -#define SCNoLEAST32 "lo" -#define SCNuLEAST32 "lu" -#define SCNxLEAST32 "lx" -#define SCNXLEAST32 "lX" -#define SCNoFAST32 "lo" -#define SCNuFAST32 "lu" -#define SCNxFAST32 "lx" -#define SCNXFAST32 "lX" - -#define SCNo64 "I64o" -#define SCNu64 "I64u" -#define SCNx64 "I64x" -#define SCNX64 "I64X" -#define SCNoLEAST64 "I64o" -#define SCNuLEAST64 "I64u" -#define SCNxLEAST64 "I64x" -#define SCNXLEAST64 "I64X" -#define SCNoFAST64 "I64o" -#define SCNuFAST64 "I64u" -#define SCNxFAST64 "I64x" -#define SCNXFAST64 "I64X" - -#define SCNoMAX "I64o" -#define SCNuMAX "I64u" -#define SCNxMAX "I64x" -#define SCNXMAX "I64X" - -#ifdef _WIN64 // [ -# define SCNoPTR "I64o" -# define SCNuPTR "I64u" -# define SCNxPTR "I64x" -# define SCNXPTR "I64X" -#else // _WIN64 ][ -# define SCNoPTR "lo" -# define SCNuPTR "lu" -# define SCNxPTR "lx" -# define SCNXPTR "lX" -#endif // _WIN64 ] - -#endif // __STDC_FORMAT_MACROS ] - -// 7.8.2 Functions for greatest-width integer types - -// 7.8.2.1 The imaxabs function -#define imaxabs _abs64 - -// 7.8.2.2 The imaxdiv function - -// This is modified version of div() function from Microsoft's div.c found -// in %MSVC.NET%\crt\src\div.c -#ifdef STATIC_IMAXDIV // [ -static -#else // STATIC_IMAXDIV ][ -_inline -#endif // STATIC_IMAXDIV ] -imaxdiv_t __cdecl imaxdiv(intmax_t numer, intmax_t denom) -{ - imaxdiv_t result; - - result.quot = numer / denom; - result.rem = numer % denom; - - if (numer < 0 && result.rem > 0) { - // did division wrong; must fix up - ++result.quot; - result.rem -= denom; - } - - return result; -} - -// 7.8.2.3 The strtoimax and strtoumax functions -#define strtoimax _strtoi64 -#define strtoumax _strtoui64 - -// 7.8.2.4 The wcstoimax and wcstoumax functions -#define wcstoimax _wcstoi64 -#define wcstoumax _wcstoui64 - -#endif // _MSC_VER >= 1800 - -#endif // _MSC_INTTYPES_H_ ] diff --git a/slsReceiverSoftware/include/rapidjson/msinttypes/stdint.h b/slsReceiverSoftware/include/rapidjson/msinttypes/stdint.h deleted file mode 100644 index 3d4477b9a..000000000 --- a/slsReceiverSoftware/include/rapidjson/msinttypes/stdint.h +++ /dev/null @@ -1,300 +0,0 @@ -// ISO C9x compliant stdint.h for Microsoft Visual Studio -// Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124 -// -// Copyright (c) 2006-2013 Alexander Chemeris -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// 1. Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// -// 2. Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// 3. Neither the name of the product nor the names of its contributors may -// be used to endorse or promote products derived from this software -// without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED -// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO -// EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; -// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR -// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF -// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -/////////////////////////////////////////////////////////////////////////////// - -// The above software in this distribution may have been modified by -// THL A29 Limited ("Tencent Modifications"). -// All Tencent Modifications are Copyright (C) 2015 THL A29 Limited. - -#ifndef _MSC_VER // [ -#error "Use this header only with Microsoft Visual C++ compilers!" -#endif // _MSC_VER ] - -#ifndef _MSC_STDINT_H_ // [ -#define _MSC_STDINT_H_ - -#if _MSC_VER > 1000 -#pragma once -#endif - -// miloyip: Originally Visual Studio 2010 uses its own stdint.h. However it generates warning with INT64_C(), so change to use this file for vs2010. -#if _MSC_VER >= 1600 // [ -#include - -#if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS) // [ See footnote 224 at page 260 - -#undef INT8_C -#undef INT16_C -#undef INT32_C -#undef INT64_C -#undef UINT8_C -#undef UINT16_C -#undef UINT32_C -#undef UINT64_C - -// 7.18.4.1 Macros for minimum-width integer constants - -#define INT8_C(val) val##i8 -#define INT16_C(val) val##i16 -#define INT32_C(val) val##i32 -#define INT64_C(val) val##i64 - -#define UINT8_C(val) val##ui8 -#define UINT16_C(val) val##ui16 -#define UINT32_C(val) val##ui32 -#define UINT64_C(val) val##ui64 - -// 7.18.4.2 Macros for greatest-width integer constants -// These #ifndef's are needed to prevent collisions with . -// Check out Issue 9 for the details. -#ifndef INTMAX_C // [ -# define INTMAX_C INT64_C -#endif // INTMAX_C ] -#ifndef UINTMAX_C // [ -# define UINTMAX_C UINT64_C -#endif // UINTMAX_C ] - -#endif // __STDC_CONSTANT_MACROS ] - -#else // ] _MSC_VER >= 1700 [ - -#include - -// For Visual Studio 6 in C++ mode and for many Visual Studio versions when -// compiling for ARM we have to wrap include with 'extern "C++" {}' -// or compiler would give many errors like this: -// error C2733: second C linkage of overloaded function 'wmemchr' not allowed -#if defined(__cplusplus) && !defined(_M_ARM) -extern "C" { -#endif -# include -#if defined(__cplusplus) && !defined(_M_ARM) -} -#endif - -// Define _W64 macros to mark types changing their size, like intptr_t. -#ifndef _W64 -# if !defined(__midl) && (defined(_X86_) || defined(_M_IX86)) && _MSC_VER >= 1300 -# define _W64 __w64 -# else -# define _W64 -# endif -#endif - - -// 7.18.1 Integer types - -// 7.18.1.1 Exact-width integer types - -// Visual Studio 6 and Embedded Visual C++ 4 doesn't -// realize that, e.g. char has the same size as __int8 -// so we give up on __intX for them. -#if (_MSC_VER < 1300) - typedef signed char int8_t; - typedef signed short int16_t; - typedef signed int int32_t; - typedef unsigned char uint8_t; - typedef unsigned short uint16_t; - typedef unsigned int uint32_t; -#else - typedef signed __int8 int8_t; - typedef signed __int16 int16_t; - typedef signed __int32 int32_t; - typedef unsigned __int8 uint8_t; - typedef unsigned __int16 uint16_t; - typedef unsigned __int32 uint32_t; -#endif -typedef signed __int64 int64_t; -typedef unsigned __int64 uint64_t; - - -// 7.18.1.2 Minimum-width integer types -typedef int8_t int_least8_t; -typedef int16_t int_least16_t; -typedef int32_t int_least32_t; -typedef int64_t int_least64_t; -typedef uint8_t uint_least8_t; -typedef uint16_t uint_least16_t; -typedef uint32_t uint_least32_t; -typedef uint64_t uint_least64_t; - -// 7.18.1.3 Fastest minimum-width integer types -typedef int8_t int_fast8_t; -typedef int16_t int_fast16_t; -typedef int32_t int_fast32_t; -typedef int64_t int_fast64_t; -typedef uint8_t uint_fast8_t; -typedef uint16_t uint_fast16_t; -typedef uint32_t uint_fast32_t; -typedef uint64_t uint_fast64_t; - -// 7.18.1.4 Integer types capable of holding object pointers -#ifdef _WIN64 // [ - typedef signed __int64 intptr_t; - typedef unsigned __int64 uintptr_t; -#else // _WIN64 ][ - typedef _W64 signed int intptr_t; - typedef _W64 unsigned int uintptr_t; -#endif // _WIN64 ] - -// 7.18.1.5 Greatest-width integer types -typedef int64_t intmax_t; -typedef uint64_t uintmax_t; - - -// 7.18.2 Limits of specified-width integer types - -#if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) // [ See footnote 220 at page 257 and footnote 221 at page 259 - -// 7.18.2.1 Limits of exact-width integer types -#define INT8_MIN ((int8_t)_I8_MIN) -#define INT8_MAX _I8_MAX -#define INT16_MIN ((int16_t)_I16_MIN) -#define INT16_MAX _I16_MAX -#define INT32_MIN ((int32_t)_I32_MIN) -#define INT32_MAX _I32_MAX -#define INT64_MIN ((int64_t)_I64_MIN) -#define INT64_MAX _I64_MAX -#define UINT8_MAX _UI8_MAX -#define UINT16_MAX _UI16_MAX -#define UINT32_MAX _UI32_MAX -#define UINT64_MAX _UI64_MAX - -// 7.18.2.2 Limits of minimum-width integer types -#define INT_LEAST8_MIN INT8_MIN -#define INT_LEAST8_MAX INT8_MAX -#define INT_LEAST16_MIN INT16_MIN -#define INT_LEAST16_MAX INT16_MAX -#define INT_LEAST32_MIN INT32_MIN -#define INT_LEAST32_MAX INT32_MAX -#define INT_LEAST64_MIN INT64_MIN -#define INT_LEAST64_MAX INT64_MAX -#define UINT_LEAST8_MAX UINT8_MAX -#define UINT_LEAST16_MAX UINT16_MAX -#define UINT_LEAST32_MAX UINT32_MAX -#define UINT_LEAST64_MAX UINT64_MAX - -// 7.18.2.3 Limits of fastest minimum-width integer types -#define INT_FAST8_MIN INT8_MIN -#define INT_FAST8_MAX INT8_MAX -#define INT_FAST16_MIN INT16_MIN -#define INT_FAST16_MAX INT16_MAX -#define INT_FAST32_MIN INT32_MIN -#define INT_FAST32_MAX INT32_MAX -#define INT_FAST64_MIN INT64_MIN -#define INT_FAST64_MAX INT64_MAX -#define UINT_FAST8_MAX UINT8_MAX -#define UINT_FAST16_MAX UINT16_MAX -#define UINT_FAST32_MAX UINT32_MAX -#define UINT_FAST64_MAX UINT64_MAX - -// 7.18.2.4 Limits of integer types capable of holding object pointers -#ifdef _WIN64 // [ -# define INTPTR_MIN INT64_MIN -# define INTPTR_MAX INT64_MAX -# define UINTPTR_MAX UINT64_MAX -#else // _WIN64 ][ -# define INTPTR_MIN INT32_MIN -# define INTPTR_MAX INT32_MAX -# define UINTPTR_MAX UINT32_MAX -#endif // _WIN64 ] - -// 7.18.2.5 Limits of greatest-width integer types -#define INTMAX_MIN INT64_MIN -#define INTMAX_MAX INT64_MAX -#define UINTMAX_MAX UINT64_MAX - -// 7.18.3 Limits of other integer types - -#ifdef _WIN64 // [ -# define PTRDIFF_MIN _I64_MIN -# define PTRDIFF_MAX _I64_MAX -#else // _WIN64 ][ -# define PTRDIFF_MIN _I32_MIN -# define PTRDIFF_MAX _I32_MAX -#endif // _WIN64 ] - -#define SIG_ATOMIC_MIN INT_MIN -#define SIG_ATOMIC_MAX INT_MAX - -#ifndef SIZE_MAX // [ -# ifdef _WIN64 // [ -# define SIZE_MAX _UI64_MAX -# else // _WIN64 ][ -# define SIZE_MAX _UI32_MAX -# endif // _WIN64 ] -#endif // SIZE_MAX ] - -// WCHAR_MIN and WCHAR_MAX are also defined in -#ifndef WCHAR_MIN // [ -# define WCHAR_MIN 0 -#endif // WCHAR_MIN ] -#ifndef WCHAR_MAX // [ -# define WCHAR_MAX _UI16_MAX -#endif // WCHAR_MAX ] - -#define WINT_MIN 0 -#define WINT_MAX _UI16_MAX - -#endif // __STDC_LIMIT_MACROS ] - - -// 7.18.4 Limits of other integer types - -#if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS) // [ See footnote 224 at page 260 - -// 7.18.4.1 Macros for minimum-width integer constants - -#define INT8_C(val) val##i8 -#define INT16_C(val) val##i16 -#define INT32_C(val) val##i32 -#define INT64_C(val) val##i64 - -#define UINT8_C(val) val##ui8 -#define UINT16_C(val) val##ui16 -#define UINT32_C(val) val##ui32 -#define UINT64_C(val) val##ui64 - -// 7.18.4.2 Macros for greatest-width integer constants -// These #ifndef's are needed to prevent collisions with . -// Check out Issue 9 for the details. -#ifndef INTMAX_C // [ -# define INTMAX_C INT64_C -#endif // INTMAX_C ] -#ifndef UINTMAX_C // [ -# define UINTMAX_C UINT64_C -#endif // UINTMAX_C ] - -#endif // __STDC_CONSTANT_MACROS ] - -#endif // _MSC_VER >= 1600 ] - -#endif // _MSC_STDINT_H_ ] diff --git a/slsReceiverSoftware/include/rapidjson/ostreamwrapper.h b/slsReceiverSoftware/include/rapidjson/ostreamwrapper.h deleted file mode 100644 index 6f4667c08..000000000 --- a/slsReceiverSoftware/include/rapidjson/ostreamwrapper.h +++ /dev/null @@ -1,81 +0,0 @@ -// Tencent is pleased to support the open source community by making RapidJSON available. -// -// Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved. -// -// Licensed under the MIT License (the "License"); you may not use this file except -// in compliance with the License. You may obtain a copy of the License at -// -// http://opensource.org/licenses/MIT -// -// Unless required by applicable law or agreed to in writing, software distributed -// under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR -// CONDITIONS OF ANY KIND, either express or implied. See the License for the -// specific language governing permissions and limitations under the License. - -#ifndef RAPIDJSON_OSTREAMWRAPPER_H_ -#define RAPIDJSON_OSTREAMWRAPPER_H_ - -#include "stream.h" -#include - -#ifdef __clang__ -RAPIDJSON_DIAG_PUSH -RAPIDJSON_DIAG_OFF(padded) -#endif - -RAPIDJSON_NAMESPACE_BEGIN - -//! Wrapper of \c std::basic_ostream into RapidJSON's Stream concept. -/*! - The classes can be wrapped including but not limited to: - - - \c std::ostringstream - - \c std::stringstream - - \c std::wpstringstream - - \c std::wstringstream - - \c std::ifstream - - \c std::fstream - - \c std::wofstream - - \c std::wfstream - - \tparam StreamType Class derived from \c std::basic_ostream. -*/ - -template -class BasicOStreamWrapper { -public: - typedef typename StreamType::char_type Ch; - BasicOStreamWrapper(StreamType& stream) : stream_(stream) {} - - void Put(Ch c) { - stream_.put(c); - } - - void Flush() { - stream_.flush(); - } - - // Not implemented - char Peek() const { RAPIDJSON_ASSERT(false); return 0; } - char Take() { RAPIDJSON_ASSERT(false); return 0; } - size_t Tell() const { RAPIDJSON_ASSERT(false); return 0; } - char* PutBegin() { RAPIDJSON_ASSERT(false); return 0; } - size_t PutEnd(char*) { RAPIDJSON_ASSERT(false); return 0; } - -private: - BasicOStreamWrapper(const BasicOStreamWrapper&); - BasicOStreamWrapper& operator=(const BasicOStreamWrapper&); - - StreamType& stream_; -}; - -typedef BasicOStreamWrapper OStreamWrapper; -typedef BasicOStreamWrapper WOStreamWrapper; - -#ifdef __clang__ -RAPIDJSON_DIAG_POP -#endif - -RAPIDJSON_NAMESPACE_END - -#endif // RAPIDJSON_OSTREAMWRAPPER_H_ diff --git a/slsReceiverSoftware/include/rapidjson/pointer.h b/slsReceiverSoftware/include/rapidjson/pointer.h deleted file mode 100644 index 0206ac1c8..000000000 --- a/slsReceiverSoftware/include/rapidjson/pointer.h +++ /dev/null @@ -1,1358 +0,0 @@ -// Tencent is pleased to support the open source community by making RapidJSON available. -// -// Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved. -// -// Licensed under the MIT License (the "License"); you may not use this file except -// in compliance with the License. You may obtain a copy of the License at -// -// http://opensource.org/licenses/MIT -// -// Unless required by applicable law or agreed to in writing, software distributed -// under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR -// CONDITIONS OF ANY KIND, either express or implied. See the License for the -// specific language governing permissions and limitations under the License. - -#ifndef RAPIDJSON_POINTER_H_ -#define RAPIDJSON_POINTER_H_ - -#include "document.h" -#include "internal/itoa.h" - -#ifdef __clang__ -RAPIDJSON_DIAG_PUSH -RAPIDJSON_DIAG_OFF(switch-enum) -#endif - -#ifdef _MSC_VER -RAPIDJSON_DIAG_PUSH -RAPIDJSON_DIAG_OFF(4512) // assignment operator could not be generated -#endif - -RAPIDJSON_NAMESPACE_BEGIN - -static const SizeType kPointerInvalidIndex = ~SizeType(0); //!< Represents an invalid index in GenericPointer::Token - -//! Error code of parsing. -/*! \ingroup RAPIDJSON_ERRORS - \see GenericPointer::GenericPointer, GenericPointer::GetParseErrorCode -*/ -enum PointerParseErrorCode { - kPointerParseErrorNone = 0, //!< The parse is successful - - kPointerParseErrorTokenMustBeginWithSolidus, //!< A token must begin with a '/' - kPointerParseErrorInvalidEscape, //!< Invalid escape - kPointerParseErrorInvalidPercentEncoding, //!< Invalid percent encoding in URI fragment - kPointerParseErrorCharacterMustPercentEncode //!< A character must percent encoded in URI fragment -}; - -/////////////////////////////////////////////////////////////////////////////// -// GenericPointer - -//! Represents a JSON Pointer. Use Pointer for UTF8 encoding and default allocator. -/*! - This class implements RFC 6901 "JavaScript Object Notation (JSON) Pointer" - (https://tools.ietf.org/html/rfc6901). - - A JSON pointer is for identifying a specific value in a JSON document - (GenericDocument). It can simplify coding of DOM tree manipulation, because it - can access multiple-level depth of DOM tree with single API call. - - After it parses a string representation (e.g. "/foo/0" or URI fragment - representation (e.g. "#/foo/0") into its internal representation (tokens), - it can be used to resolve a specific value in multiple documents, or sub-tree - of documents. - - Contrary to GenericValue, Pointer can be copy constructed and copy assigned. - Apart from assignment, a Pointer cannot be modified after construction. - - Although Pointer is very convenient, please aware that constructing Pointer - involves parsing and dynamic memory allocation. A special constructor with user- - supplied tokens eliminates these. - - GenericPointer depends on GenericDocument and GenericValue. - - \tparam ValueType The value type of the DOM tree. E.g. GenericValue > - \tparam Allocator The allocator type for allocating memory for internal representation. - - \note GenericPointer uses same encoding of ValueType. - However, Allocator of GenericPointer is independent of Allocator of Value. -*/ -template -class GenericPointer { -public: - typedef typename ValueType::EncodingType EncodingType; //!< Encoding type from Value - typedef typename ValueType::Ch Ch; //!< Character type from Value - - //! A token is the basic units of internal representation. - /*! - A JSON pointer string representation "/foo/123" is parsed to two tokens: - "foo" and 123. 123 will be represented in both numeric form and string form. - They are resolved according to the actual value type (object or array). - - For token that are not numbers, or the numeric value is out of bound - (greater than limits of SizeType), they are only treated as string form - (i.e. the token's index will be equal to kPointerInvalidIndex). - - This struct is public so that user can create a Pointer without parsing and - allocation, using a special constructor. - */ - struct Token { - const Ch* name; //!< Name of the token. It has null character at the end but it can contain null character. - SizeType length; //!< Length of the name. - SizeType index; //!< A valid array index, if it is not equal to kPointerInvalidIndex. - }; - - //!@name Constructors and destructor. - //@{ - - //! Default constructor. - GenericPointer(Allocator* allocator = 0) : allocator_(allocator), ownAllocator_(), nameBuffer_(), tokens_(), tokenCount_(), parseErrorOffset_(), parseErrorCode_(kPointerParseErrorNone) {} - - //! Constructor that parses a string or URI fragment representation. - /*! - \param source A null-terminated, string or URI fragment representation of JSON pointer. - \param allocator User supplied allocator for this pointer. If no allocator is provided, it creates a self-owned one. - */ - explicit GenericPointer(const Ch* source, Allocator* allocator = 0) : allocator_(allocator), ownAllocator_(), nameBuffer_(), tokens_(), tokenCount_(), parseErrorOffset_(), parseErrorCode_(kPointerParseErrorNone) { - Parse(source, internal::StrLen(source)); - } - -#if RAPIDJSON_HAS_STDSTRING - //! Constructor that parses a string or URI fragment representation. - /*! - \param source A string or URI fragment representation of JSON pointer. - \param allocator User supplied allocator for this pointer. If no allocator is provided, it creates a self-owned one. - \note Requires the definition of the preprocessor symbol \ref RAPIDJSON_HAS_STDSTRING. - */ - explicit GenericPointer(const std::basic_string& source, Allocator* allocator = 0) : allocator_(allocator), ownAllocator_(), nameBuffer_(), tokens_(), tokenCount_(), parseErrorOffset_(), parseErrorCode_(kPointerParseErrorNone) { - Parse(source.c_str(), source.size()); - } -#endif - - //! Constructor that parses a string or URI fragment representation, with length of the source string. - /*! - \param source A string or URI fragment representation of JSON pointer. - \param length Length of source. - \param allocator User supplied allocator for this pointer. If no allocator is provided, it creates a self-owned one. - \note Slightly faster than the overload without length. - */ - GenericPointer(const Ch* source, size_t length, Allocator* allocator = 0) : allocator_(allocator), ownAllocator_(), nameBuffer_(), tokens_(), tokenCount_(), parseErrorOffset_(), parseErrorCode_(kPointerParseErrorNone) { - Parse(source, length); - } - - //! Constructor with user-supplied tokens. - /*! - This constructor let user supplies const array of tokens. - This prevents the parsing process and eliminates allocation. - This is preferred for memory constrained environments. - - \param tokens An constant array of tokens representing the JSON pointer. - \param tokenCount Number of tokens. - - \b Example - \code - #define NAME(s) { s, sizeof(s) / sizeof(s[0]) - 1, kPointerInvalidIndex } - #define INDEX(i) { #i, sizeof(#i) - 1, i } - - static const Pointer::Token kTokens[] = { NAME("foo"), INDEX(123) }; - static const Pointer p(kTokens, sizeof(kTokens) / sizeof(kTokens[0])); - // Equivalent to static const Pointer p("/foo/123"); - - #undef NAME - #undef INDEX - \endcode - */ - GenericPointer(const Token* tokens, size_t tokenCount) : allocator_(), ownAllocator_(), nameBuffer_(), tokens_(const_cast(tokens)), tokenCount_(tokenCount), parseErrorOffset_(), parseErrorCode_(kPointerParseErrorNone) {} - - //! Copy constructor. - GenericPointer(const GenericPointer& rhs, Allocator* allocator = 0) : allocator_(allocator), ownAllocator_(), nameBuffer_(), tokens_(), tokenCount_(), parseErrorOffset_(), parseErrorCode_(kPointerParseErrorNone) { - *this = rhs; - } - - //! Destructor. - ~GenericPointer() { - if (nameBuffer_) // If user-supplied tokens constructor is used, nameBuffer_ is nullptr and tokens_ are not deallocated. - Allocator::Free(tokens_); - RAPIDJSON_DELETE(ownAllocator_); - } - - //! Assignment operator. - GenericPointer& operator=(const GenericPointer& rhs) { - if (this != &rhs) { - // Do not delete ownAllcator - if (nameBuffer_) - Allocator::Free(tokens_); - - tokenCount_ = rhs.tokenCount_; - parseErrorOffset_ = rhs.parseErrorOffset_; - parseErrorCode_ = rhs.parseErrorCode_; - - if (rhs.nameBuffer_) - CopyFromRaw(rhs); // Normally parsed tokens. - else { - tokens_ = rhs.tokens_; // User supplied const tokens. - nameBuffer_ = 0; - } - } - return *this; - } - - //@} - - //!@name Append token - //@{ - - //! Append a token and return a new Pointer - /*! - \param token Token to be appended. - \param allocator Allocator for the newly return Pointer. - \return A new Pointer with appended token. - */ - GenericPointer Append(const Token& token, Allocator* allocator = 0) const { - GenericPointer r; - r.allocator_ = allocator; - Ch *p = r.CopyFromRaw(*this, 1, token.length + 1); - std::memcpy(p, token.name, (token.length + 1) * sizeof(Ch)); - r.tokens_[tokenCount_].name = p; - r.tokens_[tokenCount_].length = token.length; - r.tokens_[tokenCount_].index = token.index; - return r; - } - - //! Append a name token with length, and return a new Pointer - /*! - \param name Name to be appended. - \param length Length of name. - \param allocator Allocator for the newly return Pointer. - \return A new Pointer with appended token. - */ - GenericPointer Append(const Ch* name, SizeType length, Allocator* allocator = 0) const { - Token token = { name, length, kPointerInvalidIndex }; - return Append(token, allocator); - } - - //! Append a name token without length, and return a new Pointer - /*! - \param name Name (const Ch*) to be appended. - \param allocator Allocator for the newly return Pointer. - \return A new Pointer with appended token. - */ - template - RAPIDJSON_DISABLEIF_RETURN((internal::NotExpr::Type, Ch> >), (GenericPointer)) - Append(T* name, Allocator* allocator = 0) const { - return Append(name, StrLen(name), allocator); - } - -#if RAPIDJSON_HAS_STDSTRING - //! Append a name token, and return a new Pointer - /*! - \param name Name to be appended. - \param allocator Allocator for the newly return Pointer. - \return A new Pointer with appended token. - */ - GenericPointer Append(const std::basic_string& name, Allocator* allocator = 0) const { - return Append(name.c_str(), static_cast(name.size()), allocator); - } -#endif - - //! Append a index token, and return a new Pointer - /*! - \param index Index to be appended. - \param allocator Allocator for the newly return Pointer. - \return A new Pointer with appended token. - */ - GenericPointer Append(SizeType index, Allocator* allocator = 0) const { - char buffer[21]; - char* end = sizeof(SizeType) == 4 ? internal::u32toa(index, buffer) : internal::u64toa(index, buffer); - SizeType length = static_cast(end - buffer); - buffer[length] = '\0'; - - if (sizeof(Ch) == 1) { - Token token = { reinterpret_cast(buffer), length, index }; - return Append(token, allocator); - } - else { - Ch name[21]; - for (size_t i = 0; i <= length; i++) - name[i] = buffer[i]; - Token token = { name, length, index }; - return Append(token, allocator); - } - } - - //! Append a token by value, and return a new Pointer - /*! - \param token token to be appended. - \param allocator Allocator for the newly return Pointer. - \return A new Pointer with appended token. - */ - GenericPointer Append(const ValueType& token, Allocator* allocator = 0) const { - if (token.IsString()) - return Append(token.GetString(), token.GetStringLength(), allocator); - else { - RAPIDJSON_ASSERT(token.IsUint64()); - RAPIDJSON_ASSERT(token.GetUint64() <= SizeType(~0)); - return Append(static_cast(token.GetUint64()), allocator); - } - } - - //!@name Handling Parse Error - //@{ - - //! Check whether this is a valid pointer. - bool IsValid() const { return parseErrorCode_ == kPointerParseErrorNone; } - - //! Get the parsing error offset in code unit. - size_t GetParseErrorOffset() const { return parseErrorOffset_; } - - //! Get the parsing error code. - PointerParseErrorCode GetParseErrorCode() const { return parseErrorCode_; } - - //@} - - //! Get the allocator of this pointer. - Allocator& GetAllocator() { return *allocator_; } - - //!@name Tokens - //@{ - - //! Get the token array (const version only). - const Token* GetTokens() const { return tokens_; } - - //! Get the number of tokens. - size_t GetTokenCount() const { return tokenCount_; } - - //@} - - //!@name Equality/inequality operators - //@{ - - //! Equality operator. - /*! - \note When any pointers are invalid, always returns false. - */ - bool operator==(const GenericPointer& rhs) const { - if (!IsValid() || !rhs.IsValid() || tokenCount_ != rhs.tokenCount_) - return false; - - for (size_t i = 0; i < tokenCount_; i++) { - if (tokens_[i].index != rhs.tokens_[i].index || - tokens_[i].length != rhs.tokens_[i].length || - (tokens_[i].length != 0 && std::memcmp(tokens_[i].name, rhs.tokens_[i].name, sizeof(Ch)* tokens_[i].length) != 0)) - { - return false; - } - } - - return true; - } - - //! Inequality operator. - /*! - \note When any pointers are invalid, always returns true. - */ - bool operator!=(const GenericPointer& rhs) const { return !(*this == rhs); } - - //@} - - //!@name Stringify - //@{ - - //! Stringify the pointer into string representation. - /*! - \tparam OutputStream Type of output stream. - \param os The output stream. - */ - template - bool Stringify(OutputStream& os) const { - return Stringify(os); - } - - //! Stringify the pointer into URI fragment representation. - /*! - \tparam OutputStream Type of output stream. - \param os The output stream. - */ - template - bool StringifyUriFragment(OutputStream& os) const { - return Stringify(os); - } - - //@} - - //!@name Create value - //@{ - - //! Create a value in a subtree. - /*! - If the value is not exist, it creates all parent values and a JSON Null value. - So it always succeed and return the newly created or existing value. - - Remind that it may change types of parents according to tokens, so it - potentially removes previously stored values. For example, if a document - was an array, and "/foo" is used to create a value, then the document - will be changed to an object, and all existing array elements are lost. - - \param root Root value of a DOM subtree to be resolved. It can be any value other than document root. - \param allocator Allocator for creating the values if the specified value or its parents are not exist. - \param alreadyExist If non-null, it stores whether the resolved value is already exist. - \return The resolved newly created (a JSON Null value), or already exists value. - */ - ValueType& Create(ValueType& root, typename ValueType::AllocatorType& allocator, bool* alreadyExist = 0) const { - RAPIDJSON_ASSERT(IsValid()); - ValueType* v = &root; - bool exist = true; - for (const Token *t = tokens_; t != tokens_ + tokenCount_; ++t) { - if (v->IsArray() && t->name[0] == '-' && t->length == 1) { - v->PushBack(ValueType().Move(), allocator); - v = &((*v)[v->Size() - 1]); - exist = false; - } - else { - if (t->index == kPointerInvalidIndex) { // must be object name - if (!v->IsObject()) - v->SetObject(); // Change to Object - } - else { // object name or array index - if (!v->IsArray() && !v->IsObject()) - v->SetArray(); // Change to Array - } - - if (v->IsArray()) { - if (t->index >= v->Size()) { - v->Reserve(t->index + 1, allocator); - while (t->index >= v->Size()) - v->PushBack(ValueType().Move(), allocator); - exist = false; - } - v = &((*v)[t->index]); - } - else { - typename ValueType::MemberIterator m = v->FindMember(GenericStringRef(t->name, t->length)); - if (m == v->MemberEnd()) { - v->AddMember(ValueType(t->name, t->length, allocator).Move(), ValueType().Move(), allocator); - v = &(--v->MemberEnd())->value; // Assumes AddMember() appends at the end - exist = false; - } - else - v = &m->value; - } - } - } - - if (alreadyExist) - *alreadyExist = exist; - - return *v; - } - - //! Creates a value in a document. - /*! - \param document A document to be resolved. - \param alreadyExist If non-null, it stores whether the resolved value is already exist. - \return The resolved newly created, or already exists value. - */ - template - ValueType& Create(GenericDocument& document, bool* alreadyExist = 0) const { - return Create(document, document.GetAllocator(), alreadyExist); - } - - //@} - - //!@name Query value - //@{ - - //! Query a value in a subtree. - /*! - \param root Root value of a DOM sub-tree to be resolved. It can be any value other than document root. - \param unresolvedTokenIndex If the pointer cannot resolve a token in the pointer, this parameter can obtain the index of unresolved token. - \return Pointer to the value if it can be resolved. Otherwise null. - - \note - There are only 3 situations when a value cannot be resolved: - 1. A value in the path is not an array nor object. - 2. An object value does not contain the token. - 3. A token is out of range of an array value. - - Use unresolvedTokenIndex to retrieve the token index. - */ - ValueType* Get(ValueType& root, size_t* unresolvedTokenIndex = 0) const { - RAPIDJSON_ASSERT(IsValid()); - ValueType* v = &root; - for (const Token *t = tokens_; t != tokens_ + tokenCount_; ++t) { - switch (v->GetType()) { - case kObjectType: - { - typename ValueType::MemberIterator m = v->FindMember(GenericStringRef(t->name, t->length)); - if (m == v->MemberEnd()) - break; - v = &m->value; - } - continue; - case kArrayType: - if (t->index == kPointerInvalidIndex || t->index >= v->Size()) - break; - v = &((*v)[t->index]); - continue; - default: - break; - } - - // Error: unresolved token - if (unresolvedTokenIndex) - *unresolvedTokenIndex = static_cast(t - tokens_); - return 0; - } - return v; - } - - //! Query a const value in a const subtree. - /*! - \param root Root value of a DOM sub-tree to be resolved. It can be any value other than document root. - \return Pointer to the value if it can be resolved. Otherwise null. - */ - const ValueType* Get(const ValueType& root, size_t* unresolvedTokenIndex = 0) const { - return Get(const_cast(root), unresolvedTokenIndex); - } - - //@} - - //!@name Query a value with default - //@{ - - //! Query a value in a subtree with default value. - /*! - Similar to Get(), but if the specified value do not exists, it creates all parents and clone the default value. - So that this function always succeed. - - \param root Root value of a DOM sub-tree to be resolved. It can be any value other than document root. - \param defaultValue Default value to be cloned if the value was not exists. - \param allocator Allocator for creating the values if the specified value or its parents are not exist. - \see Create() - */ - ValueType& GetWithDefault(ValueType& root, const ValueType& defaultValue, typename ValueType::AllocatorType& allocator) const { - bool alreadyExist; - Value& v = Create(root, allocator, &alreadyExist); - return alreadyExist ? v : v.CopyFrom(defaultValue, allocator); - } - - //! Query a value in a subtree with default null-terminated string. - ValueType& GetWithDefault(ValueType& root, const Ch* defaultValue, typename ValueType::AllocatorType& allocator) const { - bool alreadyExist; - Value& v = Create(root, allocator, &alreadyExist); - return alreadyExist ? v : v.SetString(defaultValue, allocator); - } - -#if RAPIDJSON_HAS_STDSTRING - //! Query a value in a subtree with default std::basic_string. - ValueType& GetWithDefault(ValueType& root, const std::basic_string& defaultValue, typename ValueType::AllocatorType& allocator) const { - bool alreadyExist; - Value& v = Create(root, allocator, &alreadyExist); - return alreadyExist ? v : v.SetString(defaultValue, allocator); - } -#endif - - //! Query a value in a subtree with default primitive value. - /*! - \tparam T Either \ref Type, \c int, \c unsigned, \c int64_t, \c uint64_t, \c bool - */ - template - RAPIDJSON_DISABLEIF_RETURN((internal::OrExpr, internal::IsGenericValue >), (ValueType&)) - GetWithDefault(ValueType& root, T defaultValue, typename ValueType::AllocatorType& allocator) const { - return GetWithDefault(root, ValueType(defaultValue).Move(), allocator); - } - - //! Query a value in a document with default value. - template - ValueType& GetWithDefault(GenericDocument& document, const ValueType& defaultValue) const { - return GetWithDefault(document, defaultValue, document.GetAllocator()); - } - - //! Query a value in a document with default null-terminated string. - template - ValueType& GetWithDefault(GenericDocument& document, const Ch* defaultValue) const { - return GetWithDefault(document, defaultValue, document.GetAllocator()); - } - -#if RAPIDJSON_HAS_STDSTRING - //! Query a value in a document with default std::basic_string. - template - ValueType& GetWithDefault(GenericDocument& document, const std::basic_string& defaultValue) const { - return GetWithDefault(document, defaultValue, document.GetAllocator()); - } -#endif - - //! Query a value in a document with default primitive value. - /*! - \tparam T Either \ref Type, \c int, \c unsigned, \c int64_t, \c uint64_t, \c bool - */ - template - RAPIDJSON_DISABLEIF_RETURN((internal::OrExpr, internal::IsGenericValue >), (ValueType&)) - GetWithDefault(GenericDocument& document, T defaultValue) const { - return GetWithDefault(document, defaultValue, document.GetAllocator()); - } - - //@} - - //!@name Set a value - //@{ - - //! Set a value in a subtree, with move semantics. - /*! - It creates all parents if they are not exist or types are different to the tokens. - So this function always succeeds but potentially remove existing values. - - \param root Root value of a DOM sub-tree to be resolved. It can be any value other than document root. - \param value Value to be set. - \param allocator Allocator for creating the values if the specified value or its parents are not exist. - \see Create() - */ - ValueType& Set(ValueType& root, ValueType& value, typename ValueType::AllocatorType& allocator) const { - return Create(root, allocator) = value; - } - - //! Set a value in a subtree, with copy semantics. - ValueType& Set(ValueType& root, const ValueType& value, typename ValueType::AllocatorType& allocator) const { - return Create(root, allocator).CopyFrom(value, allocator); - } - - //! Set a null-terminated string in a subtree. - ValueType& Set(ValueType& root, const Ch* value, typename ValueType::AllocatorType& allocator) const { - return Create(root, allocator) = ValueType(value, allocator).Move(); - } - -#if RAPIDJSON_HAS_STDSTRING - //! Set a std::basic_string in a subtree. - ValueType& Set(ValueType& root, const std::basic_string& value, typename ValueType::AllocatorType& allocator) const { - return Create(root, allocator) = ValueType(value, allocator).Move(); - } -#endif - - //! Set a primitive value in a subtree. - /*! - \tparam T Either \ref Type, \c int, \c unsigned, \c int64_t, \c uint64_t, \c bool - */ - template - RAPIDJSON_DISABLEIF_RETURN((internal::OrExpr, internal::IsGenericValue >), (ValueType&)) - Set(ValueType& root, T value, typename ValueType::AllocatorType& allocator) const { - return Create(root, allocator) = ValueType(value).Move(); - } - - //! Set a value in a document, with move semantics. - template - ValueType& Set(GenericDocument& document, ValueType& value) const { - return Create(document) = value; - } - - //! Set a value in a document, with copy semantics. - template - ValueType& Set(GenericDocument& document, const ValueType& value) const { - return Create(document).CopyFrom(value, document.GetAllocator()); - } - - //! Set a null-terminated string in a document. - template - ValueType& Set(GenericDocument& document, const Ch* value) const { - return Create(document) = ValueType(value, document.GetAllocator()).Move(); - } - -#if RAPIDJSON_HAS_STDSTRING - //! Sets a std::basic_string in a document. - template - ValueType& Set(GenericDocument& document, const std::basic_string& value) const { - return Create(document) = ValueType(value, document.GetAllocator()).Move(); - } -#endif - - //! Set a primitive value in a document. - /*! - \tparam T Either \ref Type, \c int, \c unsigned, \c int64_t, \c uint64_t, \c bool - */ - template - RAPIDJSON_DISABLEIF_RETURN((internal::OrExpr, internal::IsGenericValue >), (ValueType&)) - Set(GenericDocument& document, T value) const { - return Create(document) = value; - } - - //@} - - //!@name Swap a value - //@{ - - //! Swap a value with a value in a subtree. - /*! - It creates all parents if they are not exist or types are different to the tokens. - So this function always succeeds but potentially remove existing values. - - \param root Root value of a DOM sub-tree to be resolved. It can be any value other than document root. - \param value Value to be swapped. - \param allocator Allocator for creating the values if the specified value or its parents are not exist. - \see Create() - */ - ValueType& Swap(ValueType& root, ValueType& value, typename ValueType::AllocatorType& allocator) const { - return Create(root, allocator).Swap(value); - } - - //! Swap a value with a value in a document. - template - ValueType& Swap(GenericDocument& document, ValueType& value) const { - return Create(document).Swap(value); - } - - //@} - - //! Erase a value in a subtree. - /*! - \param root Root value of a DOM sub-tree to be resolved. It can be any value other than document root. - \return Whether the resolved value is found and erased. - - \note Erasing with an empty pointer \c Pointer(""), i.e. the root, always fail and return false. - */ - bool Erase(ValueType& root) const { - RAPIDJSON_ASSERT(IsValid()); - if (tokenCount_ == 0) // Cannot erase the root - return false; - - ValueType* v = &root; - const Token* last = tokens_ + (tokenCount_ - 1); - for (const Token *t = tokens_; t != last; ++t) { - switch (v->GetType()) { - case kObjectType: - { - typename ValueType::MemberIterator m = v->FindMember(GenericStringRef(t->name, t->length)); - if (m == v->MemberEnd()) - return false; - v = &m->value; - } - break; - case kArrayType: - if (t->index == kPointerInvalidIndex || t->index >= v->Size()) - return false; - v = &((*v)[t->index]); - break; - default: - return false; - } - } - - switch (v->GetType()) { - case kObjectType: - return v->EraseMember(GenericStringRef(last->name, last->length)); - case kArrayType: - if (last->index == kPointerInvalidIndex || last->index >= v->Size()) - return false; - v->Erase(v->Begin() + last->index); - return true; - default: - return false; - } - } - -private: - //! Clone the content from rhs to this. - /*! - \param rhs Source pointer. - \param extraToken Extra tokens to be allocated. - \param extraNameBufferSize Extra name buffer size (in number of Ch) to be allocated. - \return Start of non-occupied name buffer, for storing extra names. - */ - Ch* CopyFromRaw(const GenericPointer& rhs, size_t extraToken = 0, size_t extraNameBufferSize = 0) { - if (!allocator_) // allocator is independently owned. - ownAllocator_ = allocator_ = RAPIDJSON_NEW(Allocator()); - - size_t nameBufferSize = rhs.tokenCount_; // null terminators for tokens - for (Token *t = rhs.tokens_; t != rhs.tokens_ + rhs.tokenCount_; ++t) - nameBufferSize += t->length; - - tokenCount_ = rhs.tokenCount_ + extraToken; - tokens_ = static_cast(allocator_->Malloc(tokenCount_ * sizeof(Token) + (nameBufferSize + extraNameBufferSize) * sizeof(Ch))); - nameBuffer_ = reinterpret_cast(tokens_ + tokenCount_); - if (rhs.tokenCount_ > 0) { - std::memcpy(tokens_, rhs.tokens_, rhs.tokenCount_ * sizeof(Token)); - } - if (nameBufferSize > 0) { - std::memcpy(nameBuffer_, rhs.nameBuffer_, nameBufferSize * sizeof(Ch)); - } - - // Adjust pointers to name buffer - std::ptrdiff_t diff = nameBuffer_ - rhs.nameBuffer_; - for (Token *t = tokens_; t != tokens_ + rhs.tokenCount_; ++t) - t->name += diff; - - return nameBuffer_ + nameBufferSize; - } - - //! Check whether a character should be percent-encoded. - /*! - According to RFC 3986 2.3 Unreserved Characters. - \param c The character (code unit) to be tested. - */ - bool NeedPercentEncode(Ch c) const { - return !((c >= '0' && c <= '9') || (c >= 'A' && c <='Z') || (c >= 'a' && c <= 'z') || c == '-' || c == '.' || c == '_' || c =='~'); - } - - //! Parse a JSON String or its URI fragment representation into tokens. -#ifndef __clang__ // -Wdocumentation - /*! - \param source Either a JSON Pointer string, or its URI fragment representation. Not need to be null terminated. - \param length Length of the source string. - \note Source cannot be JSON String Representation of JSON Pointer, e.g. In "/\u0000", \u0000 will not be unescaped. - */ -#endif - void Parse(const Ch* source, size_t length) { - RAPIDJSON_ASSERT(source != NULL); - RAPIDJSON_ASSERT(nameBuffer_ == 0); - RAPIDJSON_ASSERT(tokens_ == 0); - - // Create own allocator if user did not supply. - if (!allocator_) - ownAllocator_ = allocator_ = RAPIDJSON_NEW(Allocator()); - - // Count number of '/' as tokenCount - tokenCount_ = 0; - for (const Ch* s = source; s != source + length; s++) - if (*s == '/') - tokenCount_++; - - Token* token = tokens_ = static_cast(allocator_->Malloc(tokenCount_ * sizeof(Token) + length * sizeof(Ch))); - Ch* name = nameBuffer_ = reinterpret_cast(tokens_ + tokenCount_); - size_t i = 0; - - // Detect if it is a URI fragment - bool uriFragment = false; - if (source[i] == '#') { - uriFragment = true; - i++; - } - - if (i != length && source[i] != '/') { - parseErrorCode_ = kPointerParseErrorTokenMustBeginWithSolidus; - goto error; - } - - while (i < length) { - RAPIDJSON_ASSERT(source[i] == '/'); - i++; // consumes '/' - - token->name = name; - bool isNumber = true; - - while (i < length && source[i] != '/') { - Ch c = source[i]; - if (uriFragment) { - // Decoding percent-encoding for URI fragment - if (c == '%') { - PercentDecodeStream is(&source[i], source + length); - GenericInsituStringStream os(name); - Ch* begin = os.PutBegin(); - if (!Transcoder, EncodingType>().Validate(is, os) || !is.IsValid()) { - parseErrorCode_ = kPointerParseErrorInvalidPercentEncoding; - goto error; - } - size_t len = os.PutEnd(begin); - i += is.Tell() - 1; - if (len == 1) - c = *name; - else { - name += len; - isNumber = false; - i++; - continue; - } - } - else if (NeedPercentEncode(c)) { - parseErrorCode_ = kPointerParseErrorCharacterMustPercentEncode; - goto error; - } - } - - i++; - - // Escaping "~0" -> '~', "~1" -> '/' - if (c == '~') { - if (i < length) { - c = source[i]; - if (c == '0') c = '~'; - else if (c == '1') c = '/'; - else { - parseErrorCode_ = kPointerParseErrorInvalidEscape; - goto error; - } - i++; - } - else { - parseErrorCode_ = kPointerParseErrorInvalidEscape; - goto error; - } - } - - // First check for index: all of characters are digit - if (c < '0' || c > '9') - isNumber = false; - - *name++ = c; - } - token->length = static_cast(name - token->name); - if (token->length == 0) - isNumber = false; - *name++ = '\0'; // Null terminator - - // Second check for index: more than one digit cannot have leading zero - if (isNumber && token->length > 1 && token->name[0] == '0') - isNumber = false; - - // String to SizeType conversion - SizeType n = 0; - if (isNumber) { - for (size_t j = 0; j < token->length; j++) { - SizeType m = n * 10 + static_cast(token->name[j] - '0'); - if (m < n) { // overflow detection - isNumber = false; - break; - } - n = m; - } - } - - token->index = isNumber ? n : kPointerInvalidIndex; - token++; - } - - RAPIDJSON_ASSERT(name <= nameBuffer_ + length); // Should not overflow buffer - parseErrorCode_ = kPointerParseErrorNone; - return; - - error: - Allocator::Free(tokens_); - nameBuffer_ = 0; - tokens_ = 0; - tokenCount_ = 0; - parseErrorOffset_ = i; - return; - } - - //! Stringify to string or URI fragment representation. - /*! - \tparam uriFragment True for stringifying to URI fragment representation. False for string representation. - \tparam OutputStream type of output stream. - \param os The output stream. - */ - template - bool Stringify(OutputStream& os) const { - RAPIDJSON_ASSERT(IsValid()); - - if (uriFragment) - os.Put('#'); - - for (Token *t = tokens_; t != tokens_ + tokenCount_; ++t) { - os.Put('/'); - for (size_t j = 0; j < t->length; j++) { - Ch c = t->name[j]; - if (c == '~') { - os.Put('~'); - os.Put('0'); - } - else if (c == '/') { - os.Put('~'); - os.Put('1'); - } - else if (uriFragment && NeedPercentEncode(c)) { - // Transcode to UTF8 sequence - GenericStringStream source(&t->name[j]); - PercentEncodeStream target(os); - if (!Transcoder >().Validate(source, target)) - return false; - j += source.Tell() - 1; - } - else - os.Put(c); - } - } - return true; - } - - //! A helper stream for decoding a percent-encoded sequence into code unit. - /*! - This stream decodes %XY triplet into code unit (0-255). - If it encounters invalid characters, it sets output code unit as 0 and - mark invalid, and to be checked by IsValid(). - */ - class PercentDecodeStream { - public: - typedef typename ValueType::Ch Ch; - - //! Constructor - /*! - \param source Start of the stream - \param end Past-the-end of the stream. - */ - PercentDecodeStream(const Ch* source, const Ch* end) : src_(source), head_(source), end_(end), valid_(true) {} - - Ch Take() { - if (*src_ != '%' || src_ + 3 > end_) { // %XY triplet - valid_ = false; - return 0; - } - src_++; - Ch c = 0; - for (int j = 0; j < 2; j++) { - c = static_cast(c << 4); - Ch h = *src_; - if (h >= '0' && h <= '9') c = static_cast(c + h - '0'); - else if (h >= 'A' && h <= 'F') c = static_cast(c + h - 'A' + 10); - else if (h >= 'a' && h <= 'f') c = static_cast(c + h - 'a' + 10); - else { - valid_ = false; - return 0; - } - src_++; - } - return c; - } - - size_t Tell() const { return static_cast(src_ - head_); } - bool IsValid() const { return valid_; } - - private: - const Ch* src_; //!< Current read position. - const Ch* head_; //!< Original head of the string. - const Ch* end_; //!< Past-the-end position. - bool valid_; //!< Whether the parsing is valid. - }; - - //! A helper stream to encode character (UTF-8 code unit) into percent-encoded sequence. - template - class PercentEncodeStream { - public: - PercentEncodeStream(OutputStream& os) : os_(os) {} - void Put(char c) { // UTF-8 must be byte - unsigned char u = static_cast(c); - static const char hexDigits[16] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' }; - os_.Put('%'); - os_.Put(hexDigits[u >> 4]); - os_.Put(hexDigits[u & 15]); - } - private: - OutputStream& os_; - }; - - Allocator* allocator_; //!< The current allocator. It is either user-supplied or equal to ownAllocator_. - Allocator* ownAllocator_; //!< Allocator owned by this Pointer. - Ch* nameBuffer_; //!< A buffer containing all names in tokens. - Token* tokens_; //!< A list of tokens. - size_t tokenCount_; //!< Number of tokens in tokens_. - size_t parseErrorOffset_; //!< Offset in code unit when parsing fail. - PointerParseErrorCode parseErrorCode_; //!< Parsing error code. -}; - -//! GenericPointer for Value (UTF-8, default allocator). -typedef GenericPointer Pointer; - -//!@name Helper functions for GenericPointer -//@{ - -////////////////////////////////////////////////////////////////////////////// - -template -typename T::ValueType& CreateValueByPointer(T& root, const GenericPointer& pointer, typename T::AllocatorType& a) { - return pointer.Create(root, a); -} - -template -typename T::ValueType& CreateValueByPointer(T& root, const CharType(&source)[N], typename T::AllocatorType& a) { - return GenericPointer(source, N - 1).Create(root, a); -} - -// No allocator parameter - -template -typename DocumentType::ValueType& CreateValueByPointer(DocumentType& document, const GenericPointer& pointer) { - return pointer.Create(document); -} - -template -typename DocumentType::ValueType& CreateValueByPointer(DocumentType& document, const CharType(&source)[N]) { - return GenericPointer(source, N - 1).Create(document); -} - -////////////////////////////////////////////////////////////////////////////// - -template -typename T::ValueType* GetValueByPointer(T& root, const GenericPointer& pointer, size_t* unresolvedTokenIndex = 0) { - return pointer.Get(root, unresolvedTokenIndex); -} - -template -const typename T::ValueType* GetValueByPointer(const T& root, const GenericPointer& pointer, size_t* unresolvedTokenIndex = 0) { - return pointer.Get(root, unresolvedTokenIndex); -} - -template -typename T::ValueType* GetValueByPointer(T& root, const CharType (&source)[N], size_t* unresolvedTokenIndex = 0) { - return GenericPointer(source, N - 1).Get(root, unresolvedTokenIndex); -} - -template -const typename T::ValueType* GetValueByPointer(const T& root, const CharType(&source)[N], size_t* unresolvedTokenIndex = 0) { - return GenericPointer(source, N - 1).Get(root, unresolvedTokenIndex); -} - -////////////////////////////////////////////////////////////////////////////// - -template -typename T::ValueType& GetValueByPointerWithDefault(T& root, const GenericPointer& pointer, const typename T::ValueType& defaultValue, typename T::AllocatorType& a) { - return pointer.GetWithDefault(root, defaultValue, a); -} - -template -typename T::ValueType& GetValueByPointerWithDefault(T& root, const GenericPointer& pointer, const typename T::Ch* defaultValue, typename T::AllocatorType& a) { - return pointer.GetWithDefault(root, defaultValue, a); -} - -#if RAPIDJSON_HAS_STDSTRING -template -typename T::ValueType& GetValueByPointerWithDefault(T& root, const GenericPointer& pointer, const std::basic_string& defaultValue, typename T::AllocatorType& a) { - return pointer.GetWithDefault(root, defaultValue, a); -} -#endif - -template -RAPIDJSON_DISABLEIF_RETURN((internal::OrExpr, internal::IsGenericValue >), (typename T::ValueType&)) -GetValueByPointerWithDefault(T& root, const GenericPointer& pointer, T2 defaultValue, typename T::AllocatorType& a) { - return pointer.GetWithDefault(root, defaultValue, a); -} - -template -typename T::ValueType& GetValueByPointerWithDefault(T& root, const CharType(&source)[N], const typename T::ValueType& defaultValue, typename T::AllocatorType& a) { - return GenericPointer(source, N - 1).GetWithDefault(root, defaultValue, a); -} - -template -typename T::ValueType& GetValueByPointerWithDefault(T& root, const CharType(&source)[N], const typename T::Ch* defaultValue, typename T::AllocatorType& a) { - return GenericPointer(source, N - 1).GetWithDefault(root, defaultValue, a); -} - -#if RAPIDJSON_HAS_STDSTRING -template -typename T::ValueType& GetValueByPointerWithDefault(T& root, const CharType(&source)[N], const std::basic_string& defaultValue, typename T::AllocatorType& a) { - return GenericPointer(source, N - 1).GetWithDefault(root, defaultValue, a); -} -#endif - -template -RAPIDJSON_DISABLEIF_RETURN((internal::OrExpr, internal::IsGenericValue >), (typename T::ValueType&)) -GetValueByPointerWithDefault(T& root, const CharType(&source)[N], T2 defaultValue, typename T::AllocatorType& a) { - return GenericPointer(source, N - 1).GetWithDefault(root, defaultValue, a); -} - -// No allocator parameter - -template -typename DocumentType::ValueType& GetValueByPointerWithDefault(DocumentType& document, const GenericPointer& pointer, const typename DocumentType::ValueType& defaultValue) { - return pointer.GetWithDefault(document, defaultValue); -} - -template -typename DocumentType::ValueType& GetValueByPointerWithDefault(DocumentType& document, const GenericPointer& pointer, const typename DocumentType::Ch* defaultValue) { - return pointer.GetWithDefault(document, defaultValue); -} - -#if RAPIDJSON_HAS_STDSTRING -template -typename DocumentType::ValueType& GetValueByPointerWithDefault(DocumentType& document, const GenericPointer& pointer, const std::basic_string& defaultValue) { - return pointer.GetWithDefault(document, defaultValue); -} -#endif - -template -RAPIDJSON_DISABLEIF_RETURN((internal::OrExpr, internal::IsGenericValue >), (typename DocumentType::ValueType&)) -GetValueByPointerWithDefault(DocumentType& document, const GenericPointer& pointer, T2 defaultValue) { - return pointer.GetWithDefault(document, defaultValue); -} - -template -typename DocumentType::ValueType& GetValueByPointerWithDefault(DocumentType& document, const CharType(&source)[N], const typename DocumentType::ValueType& defaultValue) { - return GenericPointer(source, N - 1).GetWithDefault(document, defaultValue); -} - -template -typename DocumentType::ValueType& GetValueByPointerWithDefault(DocumentType& document, const CharType(&source)[N], const typename DocumentType::Ch* defaultValue) { - return GenericPointer(source, N - 1).GetWithDefault(document, defaultValue); -} - -#if RAPIDJSON_HAS_STDSTRING -template -typename DocumentType::ValueType& GetValueByPointerWithDefault(DocumentType& document, const CharType(&source)[N], const std::basic_string& defaultValue) { - return GenericPointer(source, N - 1).GetWithDefault(document, defaultValue); -} -#endif - -template -RAPIDJSON_DISABLEIF_RETURN((internal::OrExpr, internal::IsGenericValue >), (typename DocumentType::ValueType&)) -GetValueByPointerWithDefault(DocumentType& document, const CharType(&source)[N], T2 defaultValue) { - return GenericPointer(source, N - 1).GetWithDefault(document, defaultValue); -} - -////////////////////////////////////////////////////////////////////////////// - -template -typename T::ValueType& SetValueByPointer(T& root, const GenericPointer& pointer, typename T::ValueType& value, typename T::AllocatorType& a) { - return pointer.Set(root, value, a); -} - -template -typename T::ValueType& SetValueByPointer(T& root, const GenericPointer& pointer, const typename T::ValueType& value, typename T::AllocatorType& a) { - return pointer.Set(root, value, a); -} - -template -typename T::ValueType& SetValueByPointer(T& root, const GenericPointer& pointer, const typename T::Ch* value, typename T::AllocatorType& a) { - return pointer.Set(root, value, a); -} - -#if RAPIDJSON_HAS_STDSTRING -template -typename T::ValueType& SetValueByPointer(T& root, const GenericPointer& pointer, const std::basic_string& value, typename T::AllocatorType& a) { - return pointer.Set(root, value, a); -} -#endif - -template -RAPIDJSON_DISABLEIF_RETURN((internal::OrExpr, internal::IsGenericValue >), (typename T::ValueType&)) -SetValueByPointer(T& root, const GenericPointer& pointer, T2 value, typename T::AllocatorType& a) { - return pointer.Set(root, value, a); -} - -template -typename T::ValueType& SetValueByPointer(T& root, const CharType(&source)[N], typename T::ValueType& value, typename T::AllocatorType& a) { - return GenericPointer(source, N - 1).Set(root, value, a); -} - -template -typename T::ValueType& SetValueByPointer(T& root, const CharType(&source)[N], const typename T::ValueType& value, typename T::AllocatorType& a) { - return GenericPointer(source, N - 1).Set(root, value, a); -} - -template -typename T::ValueType& SetValueByPointer(T& root, const CharType(&source)[N], const typename T::Ch* value, typename T::AllocatorType& a) { - return GenericPointer(source, N - 1).Set(root, value, a); -} - -#if RAPIDJSON_HAS_STDSTRING -template -typename T::ValueType& SetValueByPointer(T& root, const CharType(&source)[N], const std::basic_string& value, typename T::AllocatorType& a) { - return GenericPointer(source, N - 1).Set(root, value, a); -} -#endif - -template -RAPIDJSON_DISABLEIF_RETURN((internal::OrExpr, internal::IsGenericValue >), (typename T::ValueType&)) -SetValueByPointer(T& root, const CharType(&source)[N], T2 value, typename T::AllocatorType& a) { - return GenericPointer(source, N - 1).Set(root, value, a); -} - -// No allocator parameter - -template -typename DocumentType::ValueType& SetValueByPointer(DocumentType& document, const GenericPointer& pointer, typename DocumentType::ValueType& value) { - return pointer.Set(document, value); -} - -template -typename DocumentType::ValueType& SetValueByPointer(DocumentType& document, const GenericPointer& pointer, const typename DocumentType::ValueType& value) { - return pointer.Set(document, value); -} - -template -typename DocumentType::ValueType& SetValueByPointer(DocumentType& document, const GenericPointer& pointer, const typename DocumentType::Ch* value) { - return pointer.Set(document, value); -} - -#if RAPIDJSON_HAS_STDSTRING -template -typename DocumentType::ValueType& SetValueByPointer(DocumentType& document, const GenericPointer& pointer, const std::basic_string& value) { - return pointer.Set(document, value); -} -#endif - -template -RAPIDJSON_DISABLEIF_RETURN((internal::OrExpr, internal::IsGenericValue >), (typename DocumentType::ValueType&)) -SetValueByPointer(DocumentType& document, const GenericPointer& pointer, T2 value) { - return pointer.Set(document, value); -} - -template -typename DocumentType::ValueType& SetValueByPointer(DocumentType& document, const CharType(&source)[N], typename DocumentType::ValueType& value) { - return GenericPointer(source, N - 1).Set(document, value); -} - -template -typename DocumentType::ValueType& SetValueByPointer(DocumentType& document, const CharType(&source)[N], const typename DocumentType::ValueType& value) { - return GenericPointer(source, N - 1).Set(document, value); -} - -template -typename DocumentType::ValueType& SetValueByPointer(DocumentType& document, const CharType(&source)[N], const typename DocumentType::Ch* value) { - return GenericPointer(source, N - 1).Set(document, value); -} - -#if RAPIDJSON_HAS_STDSTRING -template -typename DocumentType::ValueType& SetValueByPointer(DocumentType& document, const CharType(&source)[N], const std::basic_string& value) { - return GenericPointer(source, N - 1).Set(document, value); -} -#endif - -template -RAPIDJSON_DISABLEIF_RETURN((internal::OrExpr, internal::IsGenericValue >), (typename DocumentType::ValueType&)) -SetValueByPointer(DocumentType& document, const CharType(&source)[N], T2 value) { - return GenericPointer(source, N - 1).Set(document, value); -} - -////////////////////////////////////////////////////////////////////////////// - -template -typename T::ValueType& SwapValueByPointer(T& root, const GenericPointer& pointer, typename T::ValueType& value, typename T::AllocatorType& a) { - return pointer.Swap(root, value, a); -} - -template -typename T::ValueType& SwapValueByPointer(T& root, const CharType(&source)[N], typename T::ValueType& value, typename T::AllocatorType& a) { - return GenericPointer(source, N - 1).Swap(root, value, a); -} - -template -typename DocumentType::ValueType& SwapValueByPointer(DocumentType& document, const GenericPointer& pointer, typename DocumentType::ValueType& value) { - return pointer.Swap(document, value); -} - -template -typename DocumentType::ValueType& SwapValueByPointer(DocumentType& document, const CharType(&source)[N], typename DocumentType::ValueType& value) { - return GenericPointer(source, N - 1).Swap(document, value); -} - -////////////////////////////////////////////////////////////////////////////// - -template -bool EraseValueByPointer(T& root, const GenericPointer& pointer) { - return pointer.Erase(root); -} - -template -bool EraseValueByPointer(T& root, const CharType(&source)[N]) { - return GenericPointer(source, N - 1).Erase(root); -} - -//@} - -RAPIDJSON_NAMESPACE_END - -#ifdef __clang__ -RAPIDJSON_DIAG_POP -#endif - -#ifdef _MSC_VER -RAPIDJSON_DIAG_POP -#endif - -#endif // RAPIDJSON_POINTER_H_ diff --git a/slsReceiverSoftware/include/rapidjson/prettywriter.h b/slsReceiverSoftware/include/rapidjson/prettywriter.h deleted file mode 100644 index 0dcb0fee9..000000000 --- a/slsReceiverSoftware/include/rapidjson/prettywriter.h +++ /dev/null @@ -1,255 +0,0 @@ -// Tencent is pleased to support the open source community by making RapidJSON available. -// -// Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved. -// -// Licensed under the MIT License (the "License"); you may not use this file except -// in compliance with the License. You may obtain a copy of the License at -// -// http://opensource.org/licenses/MIT -// -// Unless required by applicable law or agreed to in writing, software distributed -// under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR -// CONDITIONS OF ANY KIND, either express or implied. See the License for the -// specific language governing permissions and limitations under the License. - -#ifndef RAPIDJSON_PRETTYWRITER_H_ -#define RAPIDJSON_PRETTYWRITER_H_ - -#include "writer.h" - -#ifdef __GNUC__ -RAPIDJSON_DIAG_PUSH -RAPIDJSON_DIAG_OFF(effc++) -#endif - -RAPIDJSON_NAMESPACE_BEGIN - -//! Combination of PrettyWriter format flags. -/*! \see PrettyWriter::SetFormatOptions - */ -enum PrettyFormatOptions { - kFormatDefault = 0, //!< Default pretty formatting. - kFormatSingleLineArray = 1 //!< Format arrays on a single line. -}; - -//! Writer with indentation and spacing. -/*! - \tparam OutputStream Type of ouptut os. - \tparam SourceEncoding Encoding of source string. - \tparam TargetEncoding Encoding of output stream. - \tparam StackAllocator Type of allocator for allocating memory of stack. -*/ -template, typename TargetEncoding = UTF8<>, typename StackAllocator = CrtAllocator, unsigned writeFlags = kWriteDefaultFlags> -class PrettyWriter : public Writer { -public: - typedef Writer Base; - typedef typename Base::Ch Ch; - - //! Constructor - /*! \param os Output stream. - \param allocator User supplied allocator. If it is null, it will create a private one. - \param levelDepth Initial capacity of stack. - */ - explicit PrettyWriter(OutputStream& os, StackAllocator* allocator = 0, size_t levelDepth = Base::kDefaultLevelDepth) : - Base(os, allocator, levelDepth), indentChar_(' '), indentCharCount_(4), formatOptions_(kFormatDefault) {} - - - explicit PrettyWriter(StackAllocator* allocator = 0, size_t levelDepth = Base::kDefaultLevelDepth) : - Base(allocator, levelDepth), indentChar_(' '), indentCharCount_(4) {} - - //! Set custom indentation. - /*! \param indentChar Character for indentation. Must be whitespace character (' ', '\\t', '\\n', '\\r'). - \param indentCharCount Number of indent characters for each indentation level. - \note The default indentation is 4 spaces. - */ - PrettyWriter& SetIndent(Ch indentChar, unsigned indentCharCount) { - RAPIDJSON_ASSERT(indentChar == ' ' || indentChar == '\t' || indentChar == '\n' || indentChar == '\r'); - indentChar_ = indentChar; - indentCharCount_ = indentCharCount; - return *this; - } - - //! Set pretty writer formatting options. - /*! \param options Formatting options. - */ - PrettyWriter& SetFormatOptions(PrettyFormatOptions options) { - formatOptions_ = options; - return *this; - } - - /*! @name Implementation of Handler - \see Handler - */ - //@{ - - bool Null() { PrettyPrefix(kNullType); return Base::WriteNull(); } - bool Bool(bool b) { PrettyPrefix(b ? kTrueType : kFalseType); return Base::WriteBool(b); } - bool Int(int i) { PrettyPrefix(kNumberType); return Base::WriteInt(i); } - bool Uint(unsigned u) { PrettyPrefix(kNumberType); return Base::WriteUint(u); } - bool Int64(int64_t i64) { PrettyPrefix(kNumberType); return Base::WriteInt64(i64); } - bool Uint64(uint64_t u64) { PrettyPrefix(kNumberType); return Base::WriteUint64(u64); } - bool Double(double d) { PrettyPrefix(kNumberType); return Base::WriteDouble(d); } - - bool RawNumber(const Ch* str, SizeType length, bool copy = false) { - (void)copy; - PrettyPrefix(kNumberType); - return Base::WriteString(str, length); - } - - bool String(const Ch* str, SizeType length, bool copy = false) { - (void)copy; - PrettyPrefix(kStringType); - return Base::WriteString(str, length); - } - -#if RAPIDJSON_HAS_STDSTRING - bool String(const std::basic_string& str) { - return String(str.data(), SizeType(str.size())); - } -#endif - - bool StartObject() { - PrettyPrefix(kObjectType); - new (Base::level_stack_.template Push()) typename Base::Level(false); - return Base::WriteStartObject(); - } - - bool Key(const Ch* str, SizeType length, bool copy = false) { return String(str, length, copy); } - -#if RAPIDJSON_HAS_STDSTRING - bool Key(const std::basic_string& str) { - return Key(str.data(), SizeType(str.size())); - } -#endif - - bool EndObject(SizeType memberCount = 0) { - (void)memberCount; - RAPIDJSON_ASSERT(Base::level_stack_.GetSize() >= sizeof(typename Base::Level)); - RAPIDJSON_ASSERT(!Base::level_stack_.template Top()->inArray); - bool empty = Base::level_stack_.template Pop(1)->valueCount == 0; - - if (!empty) { - Base::os_->Put('\n'); - WriteIndent(); - } - bool ret = Base::WriteEndObject(); - (void)ret; - RAPIDJSON_ASSERT(ret == true); - if (Base::level_stack_.Empty()) // end of json text - Base::os_->Flush(); - return true; - } - - bool StartArray() { - PrettyPrefix(kArrayType); - new (Base::level_stack_.template Push()) typename Base::Level(true); - return Base::WriteStartArray(); - } - - bool EndArray(SizeType memberCount = 0) { - (void)memberCount; - RAPIDJSON_ASSERT(Base::level_stack_.GetSize() >= sizeof(typename Base::Level)); - RAPIDJSON_ASSERT(Base::level_stack_.template Top()->inArray); - bool empty = Base::level_stack_.template Pop(1)->valueCount == 0; - - if (!empty && !(formatOptions_ & kFormatSingleLineArray)) { - Base::os_->Put('\n'); - WriteIndent(); - } - bool ret = Base::WriteEndArray(); - (void)ret; - RAPIDJSON_ASSERT(ret == true); - if (Base::level_stack_.Empty()) // end of json text - Base::os_->Flush(); - return true; - } - - //@} - - /*! @name Convenience extensions */ - //@{ - - //! Simpler but slower overload. - bool String(const Ch* str) { return String(str, internal::StrLen(str)); } - bool Key(const Ch* str) { return Key(str, internal::StrLen(str)); } - - //@} - - //! Write a raw JSON value. - /*! - For user to write a stringified JSON as a value. - - \param json A well-formed JSON value. It should not contain null character within [0, length - 1] range. - \param length Length of the json. - \param type Type of the root of json. - \note When using PrettyWriter::RawValue(), the result json may not be indented correctly. - */ - bool RawValue(const Ch* json, size_t length, Type type) { PrettyPrefix(type); return Base::WriteRawValue(json, length); } - -protected: - void PrettyPrefix(Type type) { - (void)type; - if (Base::level_stack_.GetSize() != 0) { // this value is not at root - typename Base::Level* level = Base::level_stack_.template Top(); - - if (level->inArray) { - if (level->valueCount > 0) { - Base::os_->Put(','); // add comma if it is not the first element in array - if (formatOptions_ & kFormatSingleLineArray) - Base::os_->Put(' '); - } - - if (!(formatOptions_ & kFormatSingleLineArray)) { - Base::os_->Put('\n'); - WriteIndent(); - } - } - else { // in object - if (level->valueCount > 0) { - if (level->valueCount % 2 == 0) { - Base::os_->Put(','); - Base::os_->Put('\n'); - } - else { - Base::os_->Put(':'); - Base::os_->Put(' '); - } - } - else - Base::os_->Put('\n'); - - if (level->valueCount % 2 == 0) - WriteIndent(); - } - if (!level->inArray && level->valueCount % 2 == 0) - RAPIDJSON_ASSERT(type == kStringType); // if it's in object, then even number should be a name - level->valueCount++; - } - else { - RAPIDJSON_ASSERT(!Base::hasRoot_); // Should only has one and only one root. - Base::hasRoot_ = true; - } - } - - void WriteIndent() { - size_t count = (Base::level_stack_.GetSize() / sizeof(typename Base::Level)) * indentCharCount_; - PutN(*Base::os_, static_cast(indentChar_), count); - } - - Ch indentChar_; - unsigned indentCharCount_; - PrettyFormatOptions formatOptions_; - -private: - // Prohibit copy constructor & assignment operator. - PrettyWriter(const PrettyWriter&); - PrettyWriter& operator=(const PrettyWriter&); -}; - -RAPIDJSON_NAMESPACE_END - -#ifdef __GNUC__ -RAPIDJSON_DIAG_POP -#endif - -#endif // RAPIDJSON_RAPIDJSON_H_ diff --git a/slsReceiverSoftware/include/rapidjson/rapidjson.h b/slsReceiverSoftware/include/rapidjson/rapidjson.h deleted file mode 100644 index 053b2ce43..000000000 --- a/slsReceiverSoftware/include/rapidjson/rapidjson.h +++ /dev/null @@ -1,615 +0,0 @@ -// Tencent is pleased to support the open source community by making RapidJSON available. -// -// Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved. -// -// Licensed under the MIT License (the "License"); you may not use this file except -// in compliance with the License. You may obtain a copy of the License at -// -// http://opensource.org/licenses/MIT -// -// Unless required by applicable law or agreed to in writing, software distributed -// under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR -// CONDITIONS OF ANY KIND, either express or implied. See the License for the -// specific language governing permissions and limitations under the License. - -#ifndef RAPIDJSON_RAPIDJSON_H_ -#define RAPIDJSON_RAPIDJSON_H_ - -/*!\file rapidjson.h - \brief common definitions and configuration - - \see RAPIDJSON_CONFIG - */ - -/*! \defgroup RAPIDJSON_CONFIG RapidJSON configuration - \brief Configuration macros for library features - - Some RapidJSON features are configurable to adapt the library to a wide - variety of platforms, environments and usage scenarios. Most of the - features can be configured in terms of overriden or predefined - preprocessor macros at compile-time. - - Some additional customization is available in the \ref RAPIDJSON_ERRORS APIs. - - \note These macros should be given on the compiler command-line - (where applicable) to avoid inconsistent values when compiling - different translation units of a single application. - */ - -#include // malloc(), realloc(), free(), size_t -#include // memset(), memcpy(), memmove(), memcmp() - -/////////////////////////////////////////////////////////////////////////////// -// RAPIDJSON_VERSION_STRING -// -// ALWAYS synchronize the following 3 macros with corresponding variables in /CMakeLists.txt. -// - -//!@cond RAPIDJSON_HIDDEN_FROM_DOXYGEN -// token stringification -#define RAPIDJSON_STRINGIFY(x) RAPIDJSON_DO_STRINGIFY(x) -#define RAPIDJSON_DO_STRINGIFY(x) #x -//!@endcond - -/*! \def RAPIDJSON_MAJOR_VERSION - \ingroup RAPIDJSON_CONFIG - \brief Major version of RapidJSON in integer. -*/ -/*! \def RAPIDJSON_MINOR_VERSION - \ingroup RAPIDJSON_CONFIG - \brief Minor version of RapidJSON in integer. -*/ -/*! \def RAPIDJSON_PATCH_VERSION - \ingroup RAPIDJSON_CONFIG - \brief Patch version of RapidJSON in integer. -*/ -/*! \def RAPIDJSON_VERSION_STRING - \ingroup RAPIDJSON_CONFIG - \brief Version of RapidJSON in ".." string format. -*/ -#define RAPIDJSON_MAJOR_VERSION 1 -#define RAPIDJSON_MINOR_VERSION 1 -#define RAPIDJSON_PATCH_VERSION 0 -#define RAPIDJSON_VERSION_STRING \ - RAPIDJSON_STRINGIFY(RAPIDJSON_MAJOR_VERSION.RAPIDJSON_MINOR_VERSION.RAPIDJSON_PATCH_VERSION) - -/////////////////////////////////////////////////////////////////////////////// -// RAPIDJSON_NAMESPACE_(BEGIN|END) -/*! \def RAPIDJSON_NAMESPACE - \ingroup RAPIDJSON_CONFIG - \brief provide custom rapidjson namespace - - In order to avoid symbol clashes and/or "One Definition Rule" errors - between multiple inclusions of (different versions of) RapidJSON in - a single binary, users can customize the name of the main RapidJSON - namespace. - - In case of a single nesting level, defining \c RAPIDJSON_NAMESPACE - to a custom name (e.g. \c MyRapidJSON) is sufficient. If multiple - levels are needed, both \ref RAPIDJSON_NAMESPACE_BEGIN and \ref - RAPIDJSON_NAMESPACE_END need to be defined as well: - - \code - // in some .cpp file - #define RAPIDJSON_NAMESPACE my::rapidjson - #define RAPIDJSON_NAMESPACE_BEGIN namespace my { namespace rapidjson { - #define RAPIDJSON_NAMESPACE_END } } - #include "rapidjson/..." - \endcode - - \see rapidjson - */ -/*! \def RAPIDJSON_NAMESPACE_BEGIN - \ingroup RAPIDJSON_CONFIG - \brief provide custom rapidjson namespace (opening expression) - \see RAPIDJSON_NAMESPACE -*/ -/*! \def RAPIDJSON_NAMESPACE_END - \ingroup RAPIDJSON_CONFIG - \brief provide custom rapidjson namespace (closing expression) - \see RAPIDJSON_NAMESPACE -*/ -#ifndef RAPIDJSON_NAMESPACE -#define RAPIDJSON_NAMESPACE rapidjson -#endif -#ifndef RAPIDJSON_NAMESPACE_BEGIN -#define RAPIDJSON_NAMESPACE_BEGIN namespace RAPIDJSON_NAMESPACE { -#endif -#ifndef RAPIDJSON_NAMESPACE_END -#define RAPIDJSON_NAMESPACE_END } -#endif - -/////////////////////////////////////////////////////////////////////////////// -// RAPIDJSON_HAS_STDSTRING - -#ifndef RAPIDJSON_HAS_STDSTRING -#ifdef RAPIDJSON_DOXYGEN_RUNNING -#define RAPIDJSON_HAS_STDSTRING 1 // force generation of documentation -#else -#define RAPIDJSON_HAS_STDSTRING 0 // no std::string support by default -#endif -/*! \def RAPIDJSON_HAS_STDSTRING - \ingroup RAPIDJSON_CONFIG - \brief Enable RapidJSON support for \c std::string - - By defining this preprocessor symbol to \c 1, several convenience functions for using - \ref rapidjson::GenericValue with \c std::string are enabled, especially - for construction and comparison. - - \hideinitializer -*/ -#endif // !defined(RAPIDJSON_HAS_STDSTRING) - -#if RAPIDJSON_HAS_STDSTRING -#include -#endif // RAPIDJSON_HAS_STDSTRING - -/////////////////////////////////////////////////////////////////////////////// -// RAPIDJSON_NO_INT64DEFINE - -/*! \def RAPIDJSON_NO_INT64DEFINE - \ingroup RAPIDJSON_CONFIG - \brief Use external 64-bit integer types. - - RapidJSON requires the 64-bit integer types \c int64_t and \c uint64_t types - to be available at global scope. - - If users have their own definition, define RAPIDJSON_NO_INT64DEFINE to - prevent RapidJSON from defining its own types. -*/ -#ifndef RAPIDJSON_NO_INT64DEFINE -//!@cond RAPIDJSON_HIDDEN_FROM_DOXYGEN -#if defined(_MSC_VER) && (_MSC_VER < 1800) // Visual Studio 2013 -#include "msinttypes/stdint.h" -#include "msinttypes/inttypes.h" -#else -// Other compilers should have this. -#include -#include -#endif -//!@endcond -#ifdef RAPIDJSON_DOXYGEN_RUNNING -#define RAPIDJSON_NO_INT64DEFINE -#endif -#endif // RAPIDJSON_NO_INT64TYPEDEF - -/////////////////////////////////////////////////////////////////////////////// -// RAPIDJSON_FORCEINLINE - -#ifndef RAPIDJSON_FORCEINLINE -//!@cond RAPIDJSON_HIDDEN_FROM_DOXYGEN -#if defined(_MSC_VER) && defined(NDEBUG) -#define RAPIDJSON_FORCEINLINE __forceinline -#elif defined(__GNUC__) && __GNUC__ >= 4 && defined(NDEBUG) -#define RAPIDJSON_FORCEINLINE __attribute__((always_inline)) -#else -#define RAPIDJSON_FORCEINLINE -#endif -//!@endcond -#endif // RAPIDJSON_FORCEINLINE - -/////////////////////////////////////////////////////////////////////////////// -// RAPIDJSON_ENDIAN -#define RAPIDJSON_LITTLEENDIAN 0 //!< Little endian machine -#define RAPIDJSON_BIGENDIAN 1 //!< Big endian machine - -//! Endianness of the machine. -/*! - \def RAPIDJSON_ENDIAN - \ingroup RAPIDJSON_CONFIG - - GCC 4.6 provided macro for detecting endianness of the target machine. But other - compilers may not have this. User can define RAPIDJSON_ENDIAN to either - \ref RAPIDJSON_LITTLEENDIAN or \ref RAPIDJSON_BIGENDIAN. - - Default detection implemented with reference to - \li https://gcc.gnu.org/onlinedocs/gcc-4.6.0/cpp/Common-Predefined-Macros.html - \li http://www.boost.org/doc/libs/1_42_0/boost/detail/endian.hpp -*/ -#ifndef RAPIDJSON_ENDIAN -// Detect with GCC 4.6's macro -# ifdef __BYTE_ORDER__ -# if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ -# define RAPIDJSON_ENDIAN RAPIDJSON_LITTLEENDIAN -# elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ -# define RAPIDJSON_ENDIAN RAPIDJSON_BIGENDIAN -# else -# error Unknown machine endianess detected. User needs to define RAPIDJSON_ENDIAN. -# endif // __BYTE_ORDER__ -// Detect with GLIBC's endian.h -# elif defined(__GLIBC__) -# include -# if (__BYTE_ORDER == __LITTLE_ENDIAN) -# define RAPIDJSON_ENDIAN RAPIDJSON_LITTLEENDIAN -# elif (__BYTE_ORDER == __BIG_ENDIAN) -# define RAPIDJSON_ENDIAN RAPIDJSON_BIGENDIAN -# else -# error Unknown machine endianess detected. User needs to define RAPIDJSON_ENDIAN. -# endif // __GLIBC__ -// Detect with _LITTLE_ENDIAN and _BIG_ENDIAN macro -# elif defined(_LITTLE_ENDIAN) && !defined(_BIG_ENDIAN) -# define RAPIDJSON_ENDIAN RAPIDJSON_LITTLEENDIAN -# elif defined(_BIG_ENDIAN) && !defined(_LITTLE_ENDIAN) -# define RAPIDJSON_ENDIAN RAPIDJSON_BIGENDIAN -// Detect with architecture macros -# elif defined(__sparc) || defined(__sparc__) || defined(_POWER) || defined(__powerpc__) || defined(__ppc__) || defined(__hpux) || defined(__hppa) || defined(_MIPSEB) || defined(_POWER) || defined(__s390__) -# define RAPIDJSON_ENDIAN RAPIDJSON_BIGENDIAN -# elif defined(__i386__) || defined(__alpha__) || defined(__ia64) || defined(__ia64__) || defined(_M_IX86) || defined(_M_IA64) || defined(_M_ALPHA) || defined(__amd64) || defined(__amd64__) || defined(_M_AMD64) || defined(__x86_64) || defined(__x86_64__) || defined(_M_X64) || defined(__bfin__) -# define RAPIDJSON_ENDIAN RAPIDJSON_LITTLEENDIAN -# elif defined(_MSC_VER) && defined(_M_ARM) -# define RAPIDJSON_ENDIAN RAPIDJSON_LITTLEENDIAN -# elif defined(RAPIDJSON_DOXYGEN_RUNNING) -# define RAPIDJSON_ENDIAN -# else -# error Unknown machine endianess detected. User needs to define RAPIDJSON_ENDIAN. -# endif -#endif // RAPIDJSON_ENDIAN - -/////////////////////////////////////////////////////////////////////////////// -// RAPIDJSON_64BIT - -//! Whether using 64-bit architecture -#ifndef RAPIDJSON_64BIT -#if defined(__LP64__) || (defined(__x86_64__) && defined(__ILP32__)) || defined(_WIN64) || defined(__EMSCRIPTEN__) -#define RAPIDJSON_64BIT 1 -#else -#define RAPIDJSON_64BIT 0 -#endif -#endif // RAPIDJSON_64BIT - -/////////////////////////////////////////////////////////////////////////////// -// RAPIDJSON_ALIGN - -//! Data alignment of the machine. -/*! \ingroup RAPIDJSON_CONFIG - \param x pointer to align - - Some machines require strict data alignment. Currently the default uses 4 bytes - alignment on 32-bit platforms and 8 bytes alignment for 64-bit platforms. - User can customize by defining the RAPIDJSON_ALIGN function macro. -*/ -#ifndef RAPIDJSON_ALIGN -#if RAPIDJSON_64BIT == 1 -#define RAPIDJSON_ALIGN(x) (((x) + static_cast(7u)) & ~static_cast(7u)) -#else -#define RAPIDJSON_ALIGN(x) (((x) + 3u) & ~3u) -#endif -#endif - -/////////////////////////////////////////////////////////////////////////////// -// RAPIDJSON_UINT64_C2 - -//! Construct a 64-bit literal by a pair of 32-bit integer. -/*! - 64-bit literal with or without ULL suffix is prone to compiler warnings. - UINT64_C() is C macro which cause compilation problems. - Use this macro to define 64-bit constants by a pair of 32-bit integer. -*/ -#ifndef RAPIDJSON_UINT64_C2 -#define RAPIDJSON_UINT64_C2(high32, low32) ((static_cast(high32) << 32) | static_cast(low32)) -#endif - -/////////////////////////////////////////////////////////////////////////////// -// RAPIDJSON_48BITPOINTER_OPTIMIZATION - -//! Use only lower 48-bit address for some pointers. -/*! - \ingroup RAPIDJSON_CONFIG - - This optimization uses the fact that current X86-64 architecture only implement lower 48-bit virtual address. - The higher 16-bit can be used for storing other data. - \c GenericValue uses this optimization to reduce its size form 24 bytes to 16 bytes in 64-bit architecture. -*/ -#ifndef RAPIDJSON_48BITPOINTER_OPTIMIZATION -#if defined(__amd64__) || defined(__amd64) || defined(__x86_64__) || defined(__x86_64) || defined(_M_X64) || defined(_M_AMD64) -#define RAPIDJSON_48BITPOINTER_OPTIMIZATION 1 -#else -#define RAPIDJSON_48BITPOINTER_OPTIMIZATION 0 -#endif -#endif // RAPIDJSON_48BITPOINTER_OPTIMIZATION - -#if RAPIDJSON_48BITPOINTER_OPTIMIZATION == 1 -#if RAPIDJSON_64BIT != 1 -#error RAPIDJSON_48BITPOINTER_OPTIMIZATION can only be set to 1 when RAPIDJSON_64BIT=1 -#endif -#define RAPIDJSON_SETPOINTER(type, p, x) (p = reinterpret_cast((reinterpret_cast(p) & static_cast(RAPIDJSON_UINT64_C2(0xFFFF0000, 0x00000000))) | reinterpret_cast(reinterpret_cast(x)))) -#define RAPIDJSON_GETPOINTER(type, p) (reinterpret_cast(reinterpret_cast(p) & static_cast(RAPIDJSON_UINT64_C2(0x0000FFFF, 0xFFFFFFFF)))) -#else -#define RAPIDJSON_SETPOINTER(type, p, x) (p = (x)) -#define RAPIDJSON_GETPOINTER(type, p) (p) -#endif - -/////////////////////////////////////////////////////////////////////////////// -// RAPIDJSON_SSE2/RAPIDJSON_SSE42/RAPIDJSON_SIMD - -/*! \def RAPIDJSON_SIMD - \ingroup RAPIDJSON_CONFIG - \brief Enable SSE2/SSE4.2 optimization. - - RapidJSON supports optimized implementations for some parsing operations - based on the SSE2 or SSE4.2 SIMD extensions on modern Intel-compatible - processors. - - To enable these optimizations, two different symbols can be defined; - \code - // Enable SSE2 optimization. - #define RAPIDJSON_SSE2 - - // Enable SSE4.2 optimization. - #define RAPIDJSON_SSE42 - \endcode - - \c RAPIDJSON_SSE42 takes precedence, if both are defined. - - If any of these symbols is defined, RapidJSON defines the macro - \c RAPIDJSON_SIMD to indicate the availability of the optimized code. -*/ -#if defined(RAPIDJSON_SSE2) || defined(RAPIDJSON_SSE42) \ - || defined(RAPIDJSON_DOXYGEN_RUNNING) -#define RAPIDJSON_SIMD -#endif - -/////////////////////////////////////////////////////////////////////////////// -// RAPIDJSON_NO_SIZETYPEDEFINE - -#ifndef RAPIDJSON_NO_SIZETYPEDEFINE -/*! \def RAPIDJSON_NO_SIZETYPEDEFINE - \ingroup RAPIDJSON_CONFIG - \brief User-provided \c SizeType definition. - - In order to avoid using 32-bit size types for indexing strings and arrays, - define this preprocessor symbol and provide the type rapidjson::SizeType - before including RapidJSON: - \code - #define RAPIDJSON_NO_SIZETYPEDEFINE - namespace rapidjson { typedef ::std::size_t SizeType; } - #include "rapidjson/..." - \endcode - - \see rapidjson::SizeType -*/ -#ifdef RAPIDJSON_DOXYGEN_RUNNING -#define RAPIDJSON_NO_SIZETYPEDEFINE -#endif -RAPIDJSON_NAMESPACE_BEGIN -//! Size type (for string lengths, array sizes, etc.) -/*! RapidJSON uses 32-bit array/string indices even on 64-bit platforms, - instead of using \c size_t. Users may override the SizeType by defining - \ref RAPIDJSON_NO_SIZETYPEDEFINE. -*/ -typedef unsigned SizeType; -RAPIDJSON_NAMESPACE_END -#endif - -// always import std::size_t to rapidjson namespace -RAPIDJSON_NAMESPACE_BEGIN -using std::size_t; -RAPIDJSON_NAMESPACE_END - -/////////////////////////////////////////////////////////////////////////////// -// RAPIDJSON_ASSERT - -//! Assertion. -/*! \ingroup RAPIDJSON_CONFIG - By default, rapidjson uses C \c assert() for internal assertions. - User can override it by defining RAPIDJSON_ASSERT(x) macro. - - \note Parsing errors are handled and can be customized by the - \ref RAPIDJSON_ERRORS APIs. -*/ -#ifndef RAPIDJSON_ASSERT -#include -#define RAPIDJSON_ASSERT(x) assert(x) -#endif // RAPIDJSON_ASSERT - -/////////////////////////////////////////////////////////////////////////////// -// RAPIDJSON_STATIC_ASSERT - -// Adopt from boost -#ifndef RAPIDJSON_STATIC_ASSERT -#ifndef __clang__ -//!@cond RAPIDJSON_HIDDEN_FROM_DOXYGEN -#endif -RAPIDJSON_NAMESPACE_BEGIN -template struct STATIC_ASSERTION_FAILURE; -template <> struct STATIC_ASSERTION_FAILURE { enum { value = 1 }; }; -template struct StaticAssertTest {}; -RAPIDJSON_NAMESPACE_END - -#define RAPIDJSON_JOIN(X, Y) RAPIDJSON_DO_JOIN(X, Y) -#define RAPIDJSON_DO_JOIN(X, Y) RAPIDJSON_DO_JOIN2(X, Y) -#define RAPIDJSON_DO_JOIN2(X, Y) X##Y - -#if defined(__GNUC__) -#define RAPIDJSON_STATIC_ASSERT_UNUSED_ATTRIBUTE __attribute__((unused)) -#else -#define RAPIDJSON_STATIC_ASSERT_UNUSED_ATTRIBUTE -#endif -#ifndef __clang__ -//!@endcond -#endif - -/*! \def RAPIDJSON_STATIC_ASSERT - \brief (Internal) macro to check for conditions at compile-time - \param x compile-time condition - \hideinitializer - */ -#define RAPIDJSON_STATIC_ASSERT(x) \ - typedef ::RAPIDJSON_NAMESPACE::StaticAssertTest< \ - sizeof(::RAPIDJSON_NAMESPACE::STATIC_ASSERTION_FAILURE)> \ - RAPIDJSON_JOIN(StaticAssertTypedef, __LINE__) RAPIDJSON_STATIC_ASSERT_UNUSED_ATTRIBUTE -#endif - -/////////////////////////////////////////////////////////////////////////////// -// RAPIDJSON_LIKELY, RAPIDJSON_UNLIKELY - -//! Compiler branching hint for expression with high probability to be true. -/*! - \ingroup RAPIDJSON_CONFIG - \param x Boolean expression likely to be true. -*/ -#ifndef RAPIDJSON_LIKELY -#if defined(__GNUC__) || defined(__clang__) -#define RAPIDJSON_LIKELY(x) __builtin_expect(!!(x), 1) -#else -#define RAPIDJSON_LIKELY(x) (x) -#endif -#endif - -//! Compiler branching hint for expression with low probability to be true. -/*! - \ingroup RAPIDJSON_CONFIG - \param x Boolean expression unlikely to be true. -*/ -#ifndef RAPIDJSON_UNLIKELY -#if defined(__GNUC__) || defined(__clang__) -#define RAPIDJSON_UNLIKELY(x) __builtin_expect(!!(x), 0) -#else -#define RAPIDJSON_UNLIKELY(x) (x) -#endif -#endif - -/////////////////////////////////////////////////////////////////////////////// -// Helpers - -//!@cond RAPIDJSON_HIDDEN_FROM_DOXYGEN - -#define RAPIDJSON_MULTILINEMACRO_BEGIN do { -#define RAPIDJSON_MULTILINEMACRO_END \ -} while((void)0, 0) - -// adopted from Boost -#define RAPIDJSON_VERSION_CODE(x,y,z) \ - (((x)*100000) + ((y)*100) + (z)) - -/////////////////////////////////////////////////////////////////////////////// -// RAPIDJSON_DIAG_PUSH/POP, RAPIDJSON_DIAG_OFF - -#if defined(__GNUC__) -#define RAPIDJSON_GNUC \ - RAPIDJSON_VERSION_CODE(__GNUC__,__GNUC_MINOR__,__GNUC_PATCHLEVEL__) -#endif - -#if defined(__clang__) || (defined(RAPIDJSON_GNUC) && RAPIDJSON_GNUC >= RAPIDJSON_VERSION_CODE(4,2,0)) - -#define RAPIDJSON_PRAGMA(x) _Pragma(RAPIDJSON_STRINGIFY(x)) -#define RAPIDJSON_DIAG_PRAGMA(x) RAPIDJSON_PRAGMA(GCC diagnostic x) -#define RAPIDJSON_DIAG_OFF(x) \ - RAPIDJSON_DIAG_PRAGMA(ignored RAPIDJSON_STRINGIFY(RAPIDJSON_JOIN(-W,x))) - -// push/pop support in Clang and GCC>=4.6 -#if defined(__clang__) || (defined(RAPIDJSON_GNUC) && RAPIDJSON_GNUC >= RAPIDJSON_VERSION_CODE(4,6,0)) -#define RAPIDJSON_DIAG_PUSH RAPIDJSON_DIAG_PRAGMA(push) -#define RAPIDJSON_DIAG_POP RAPIDJSON_DIAG_PRAGMA(pop) -#else // GCC >= 4.2, < 4.6 -#define RAPIDJSON_DIAG_PUSH /* ignored */ -#define RAPIDJSON_DIAG_POP /* ignored */ -#endif - -#elif defined(_MSC_VER) - -// pragma (MSVC specific) -#define RAPIDJSON_PRAGMA(x) __pragma(x) -#define RAPIDJSON_DIAG_PRAGMA(x) RAPIDJSON_PRAGMA(warning(x)) - -#define RAPIDJSON_DIAG_OFF(x) RAPIDJSON_DIAG_PRAGMA(disable: x) -#define RAPIDJSON_DIAG_PUSH RAPIDJSON_DIAG_PRAGMA(push) -#define RAPIDJSON_DIAG_POP RAPIDJSON_DIAG_PRAGMA(pop) - -#else - -#define RAPIDJSON_DIAG_OFF(x) /* ignored */ -#define RAPIDJSON_DIAG_PUSH /* ignored */ -#define RAPIDJSON_DIAG_POP /* ignored */ - -#endif // RAPIDJSON_DIAG_* - -/////////////////////////////////////////////////////////////////////////////// -// C++11 features - -#ifndef RAPIDJSON_HAS_CXX11_RVALUE_REFS -#if defined(__clang__) -#if __has_feature(cxx_rvalue_references) && \ - (defined(_LIBCPP_VERSION) || defined(__GLIBCXX__) && __GLIBCXX__ >= 20080306) -#define RAPIDJSON_HAS_CXX11_RVALUE_REFS 1 -#else -#define RAPIDJSON_HAS_CXX11_RVALUE_REFS 0 -#endif -#elif (defined(RAPIDJSON_GNUC) && (RAPIDJSON_GNUC >= RAPIDJSON_VERSION_CODE(4,3,0)) && defined(__GXX_EXPERIMENTAL_CXX0X__)) || \ - (defined(_MSC_VER) && _MSC_VER >= 1600) - -#define RAPIDJSON_HAS_CXX11_RVALUE_REFS 1 -#else -#define RAPIDJSON_HAS_CXX11_RVALUE_REFS 0 -#endif -#endif // RAPIDJSON_HAS_CXX11_RVALUE_REFS - -#ifndef RAPIDJSON_HAS_CXX11_NOEXCEPT -#if defined(__clang__) -#define RAPIDJSON_HAS_CXX11_NOEXCEPT __has_feature(cxx_noexcept) -#elif (defined(RAPIDJSON_GNUC) && (RAPIDJSON_GNUC >= RAPIDJSON_VERSION_CODE(4,6,0)) && defined(__GXX_EXPERIMENTAL_CXX0X__)) -// (defined(_MSC_VER) && _MSC_VER >= ????) // not yet supported -#define RAPIDJSON_HAS_CXX11_NOEXCEPT 1 -#else -#define RAPIDJSON_HAS_CXX11_NOEXCEPT 0 -#endif -#endif -#if RAPIDJSON_HAS_CXX11_NOEXCEPT -#define RAPIDJSON_NOEXCEPT noexcept -#else -#define RAPIDJSON_NOEXCEPT /* noexcept */ -#endif // RAPIDJSON_HAS_CXX11_NOEXCEPT - -// no automatic detection, yet -#ifndef RAPIDJSON_HAS_CXX11_TYPETRAITS -#define RAPIDJSON_HAS_CXX11_TYPETRAITS 0 -#endif - -#ifndef RAPIDJSON_HAS_CXX11_RANGE_FOR -#if defined(__clang__) -#define RAPIDJSON_HAS_CXX11_RANGE_FOR __has_feature(cxx_range_for) -#elif (defined(RAPIDJSON_GNUC) && (RAPIDJSON_GNUC >= RAPIDJSON_VERSION_CODE(4,3,0)) && defined(__GXX_EXPERIMENTAL_CXX0X__)) || \ - (defined(_MSC_VER) && _MSC_VER >= 1700) -#define RAPIDJSON_HAS_CXX11_RANGE_FOR 1 -#else -#define RAPIDJSON_HAS_CXX11_RANGE_FOR 0 -#endif -#endif // RAPIDJSON_HAS_CXX11_RANGE_FOR - -//!@endcond - -/////////////////////////////////////////////////////////////////////////////// -// new/delete - -#ifndef RAPIDJSON_NEW -///! customization point for global \c new -#define RAPIDJSON_NEW(x) new x -#endif -#ifndef RAPIDJSON_DELETE -///! customization point for global \c delete -#define RAPIDJSON_DELETE(x) delete x -#endif - -/////////////////////////////////////////////////////////////////////////////// -// Type - -/*! \namespace rapidjson - \brief main RapidJSON namespace - \see RAPIDJSON_NAMESPACE -*/ -RAPIDJSON_NAMESPACE_BEGIN - -//! Type of JSON value -enum Type { - kNullType = 0, //!< null - kFalseType = 1, //!< false - kTrueType = 2, //!< true - kObjectType = 3, //!< object - kArrayType = 4, //!< array - kStringType = 5, //!< string - kNumberType = 6 //!< number -}; - -RAPIDJSON_NAMESPACE_END - -#endif // RAPIDJSON_RAPIDJSON_H_ diff --git a/slsReceiverSoftware/include/rapidjson/reader.h b/slsReceiverSoftware/include/rapidjson/reader.h deleted file mode 100644 index 19f8849b1..000000000 --- a/slsReceiverSoftware/include/rapidjson/reader.h +++ /dev/null @@ -1,1879 +0,0 @@ -// Tencent is pleased to support the open source community by making RapidJSON available. -// -// Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved. -// -// Licensed under the MIT License (the "License"); you may not use this file except -// in compliance with the License. You may obtain a copy of the License at -// -// http://opensource.org/licenses/MIT -// -// Unless required by applicable law or agreed to in writing, software distributed -// under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR -// CONDITIONS OF ANY KIND, either express or implied. See the License for the -// specific language governing permissions and limitations under the License. - -#ifndef RAPIDJSON_READER_H_ -#define RAPIDJSON_READER_H_ - -/*! \file reader.h */ - -#include "allocators.h" -#include "stream.h" -#include "encodedstream.h" -#include "internal/meta.h" -#include "internal/stack.h" -#include "internal/strtod.h" -#include - -#if defined(RAPIDJSON_SIMD) && defined(_MSC_VER) -#include -#pragma intrinsic(_BitScanForward) -#endif -#ifdef RAPIDJSON_SSE42 -#include -#elif defined(RAPIDJSON_SSE2) -#include -#endif - -#ifdef _MSC_VER -RAPIDJSON_DIAG_PUSH -RAPIDJSON_DIAG_OFF(4127) // conditional expression is constant -RAPIDJSON_DIAG_OFF(4702) // unreachable code -#endif - -#ifdef __clang__ -RAPIDJSON_DIAG_PUSH -RAPIDJSON_DIAG_OFF(old-style-cast) -RAPIDJSON_DIAG_OFF(padded) -RAPIDJSON_DIAG_OFF(switch-enum) -#endif - -#ifdef __GNUC__ -RAPIDJSON_DIAG_PUSH -RAPIDJSON_DIAG_OFF(effc++) -#endif - -//!@cond RAPIDJSON_HIDDEN_FROM_DOXYGEN -#define RAPIDJSON_NOTHING /* deliberately empty */ -#ifndef RAPIDJSON_PARSE_ERROR_EARLY_RETURN -#define RAPIDJSON_PARSE_ERROR_EARLY_RETURN(value) \ - RAPIDJSON_MULTILINEMACRO_BEGIN \ - if (RAPIDJSON_UNLIKELY(HasParseError())) { return value; } \ - RAPIDJSON_MULTILINEMACRO_END -#endif -#define RAPIDJSON_PARSE_ERROR_EARLY_RETURN_VOID \ - RAPIDJSON_PARSE_ERROR_EARLY_RETURN(RAPIDJSON_NOTHING) -//!@endcond - -/*! \def RAPIDJSON_PARSE_ERROR_NORETURN - \ingroup RAPIDJSON_ERRORS - \brief Macro to indicate a parse error. - \param parseErrorCode \ref rapidjson::ParseErrorCode of the error - \param offset position of the error in JSON input (\c size_t) - - This macros can be used as a customization point for the internal - error handling mechanism of RapidJSON. - - A common usage model is to throw an exception instead of requiring the - caller to explicitly check the \ref rapidjson::GenericReader::Parse's - return value: - - \code - #define RAPIDJSON_PARSE_ERROR_NORETURN(parseErrorCode,offset) \ - throw ParseException(parseErrorCode, #parseErrorCode, offset) - - #include // std::runtime_error - #include "rapidjson/error/error.h" // rapidjson::ParseResult - - struct ParseException : std::runtime_error, rapidjson::ParseResult { - ParseException(rapidjson::ParseErrorCode code, const char* msg, size_t offset) - : std::runtime_error(msg), ParseResult(code, offset) {} - }; - - #include "rapidjson/reader.h" - \endcode - - \see RAPIDJSON_PARSE_ERROR, rapidjson::GenericReader::Parse - */ -#ifndef RAPIDJSON_PARSE_ERROR_NORETURN -#define RAPIDJSON_PARSE_ERROR_NORETURN(parseErrorCode, offset) \ - RAPIDJSON_MULTILINEMACRO_BEGIN \ - RAPIDJSON_ASSERT(!HasParseError()); /* Error can only be assigned once */ \ - SetParseError(parseErrorCode, offset); \ - RAPIDJSON_MULTILINEMACRO_END -#endif - -/*! \def RAPIDJSON_PARSE_ERROR - \ingroup RAPIDJSON_ERRORS - \brief (Internal) macro to indicate and handle a parse error. - \param parseErrorCode \ref rapidjson::ParseErrorCode of the error - \param offset position of the error in JSON input (\c size_t) - - Invokes RAPIDJSON_PARSE_ERROR_NORETURN and stops the parsing. - - \see RAPIDJSON_PARSE_ERROR_NORETURN - \hideinitializer - */ -#ifndef RAPIDJSON_PARSE_ERROR -#define RAPIDJSON_PARSE_ERROR(parseErrorCode, offset) \ - RAPIDJSON_MULTILINEMACRO_BEGIN \ - RAPIDJSON_PARSE_ERROR_NORETURN(parseErrorCode, offset); \ - RAPIDJSON_PARSE_ERROR_EARLY_RETURN_VOID; \ - RAPIDJSON_MULTILINEMACRO_END -#endif - -#include "error/error.h" // ParseErrorCode, ParseResult - -RAPIDJSON_NAMESPACE_BEGIN - -/////////////////////////////////////////////////////////////////////////////// -// ParseFlag - -/*! \def RAPIDJSON_PARSE_DEFAULT_FLAGS - \ingroup RAPIDJSON_CONFIG - \brief User-defined kParseDefaultFlags definition. - - User can define this as any \c ParseFlag combinations. -*/ -#ifndef RAPIDJSON_PARSE_DEFAULT_FLAGS -#define RAPIDJSON_PARSE_DEFAULT_FLAGS kParseNoFlags -#endif - -//! Combination of parseFlags -/*! \see Reader::Parse, Document::Parse, Document::ParseInsitu, Document::ParseStream - */ -enum ParseFlag { - kParseNoFlags = 0, //!< No flags are set. - kParseInsituFlag = 1, //!< In-situ(destructive) parsing. - kParseValidateEncodingFlag = 2, //!< Validate encoding of JSON strings. - kParseIterativeFlag = 4, //!< Iterative(constant complexity in terms of function call stack size) parsing. - kParseStopWhenDoneFlag = 8, //!< After parsing a complete JSON root from stream, stop further processing the rest of stream. When this flag is used, parser will not generate kParseErrorDocumentRootNotSingular error. - kParseFullPrecisionFlag = 16, //!< Parse number in full precision (but slower). - kParseCommentsFlag = 32, //!< Allow one-line (//) and multi-line (/**/) comments. - kParseNumbersAsStringsFlag = 64, //!< Parse all numbers (ints/doubles) as strings. - kParseTrailingCommasFlag = 128, //!< Allow trailing commas at the end of objects and arrays. - kParseNanAndInfFlag = 256, //!< Allow parsing NaN, Inf, Infinity, -Inf and -Infinity as doubles. - kParseDefaultFlags = RAPIDJSON_PARSE_DEFAULT_FLAGS //!< Default parse flags. Can be customized by defining RAPIDJSON_PARSE_DEFAULT_FLAGS -}; - -/////////////////////////////////////////////////////////////////////////////// -// Handler - -/*! \class rapidjson::Handler - \brief Concept for receiving events from GenericReader upon parsing. - The functions return true if no error occurs. If they return false, - the event publisher should terminate the process. -\code -concept Handler { - typename Ch; - - bool Null(); - bool Bool(bool b); - bool Int(int i); - bool Uint(unsigned i); - bool Int64(int64_t i); - bool Uint64(uint64_t i); - bool Double(double d); - /// enabled via kParseNumbersAsStringsFlag, string is not null-terminated (use length) - bool RawNumber(const Ch* str, SizeType length, bool copy); - bool String(const Ch* str, SizeType length, bool copy); - bool StartObject(); - bool Key(const Ch* str, SizeType length, bool copy); - bool EndObject(SizeType memberCount); - bool StartArray(); - bool EndArray(SizeType elementCount); -}; -\endcode -*/ -/////////////////////////////////////////////////////////////////////////////// -// BaseReaderHandler - -//! Default implementation of Handler. -/*! This can be used as base class of any reader handler. - \note implements Handler concept -*/ -template, typename Derived = void> -struct BaseReaderHandler { - typedef typename Encoding::Ch Ch; - - typedef typename internal::SelectIf, BaseReaderHandler, Derived>::Type Override; - - bool Default() { return true; } - bool Null() { return static_cast(*this).Default(); } - bool Bool(bool) { return static_cast(*this).Default(); } - bool Int(int) { return static_cast(*this).Default(); } - bool Uint(unsigned) { return static_cast(*this).Default(); } - bool Int64(int64_t) { return static_cast(*this).Default(); } - bool Uint64(uint64_t) { return static_cast(*this).Default(); } - bool Double(double) { return static_cast(*this).Default(); } - /// enabled via kParseNumbersAsStringsFlag, string is not null-terminated (use length) - bool RawNumber(const Ch* str, SizeType len, bool copy) { return static_cast(*this).String(str, len, copy); } - bool String(const Ch*, SizeType, bool) { return static_cast(*this).Default(); } - bool StartObject() { return static_cast(*this).Default(); } - bool Key(const Ch* str, SizeType len, bool copy) { return static_cast(*this).String(str, len, copy); } - bool EndObject(SizeType) { return static_cast(*this).Default(); } - bool StartArray() { return static_cast(*this).Default(); } - bool EndArray(SizeType) { return static_cast(*this).Default(); } -}; - -/////////////////////////////////////////////////////////////////////////////// -// StreamLocalCopy - -namespace internal { - -template::copyOptimization> -class StreamLocalCopy; - -//! Do copy optimization. -template -class StreamLocalCopy { -public: - StreamLocalCopy(Stream& original) : s(original), original_(original) {} - ~StreamLocalCopy() { original_ = s; } - - Stream s; - -private: - StreamLocalCopy& operator=(const StreamLocalCopy&) /* = delete */; - - Stream& original_; -}; - -//! Keep reference. -template -class StreamLocalCopy { -public: - StreamLocalCopy(Stream& original) : s(original) {} - - Stream& s; - -private: - StreamLocalCopy& operator=(const StreamLocalCopy&) /* = delete */; -}; - -} // namespace internal - -/////////////////////////////////////////////////////////////////////////////// -// SkipWhitespace - -//! Skip the JSON white spaces in a stream. -/*! \param is A input stream for skipping white spaces. - \note This function has SSE2/SSE4.2 specialization. -*/ -template -void SkipWhitespace(InputStream& is) { - internal::StreamLocalCopy copy(is); - InputStream& s(copy.s); - - typename InputStream::Ch c; - while ((c = s.Peek()) == ' ' || c == '\n' || c == '\r' || c == '\t') - s.Take(); -} - -inline const char* SkipWhitespace(const char* p, const char* end) { - while (p != end && (*p == ' ' || *p == '\n' || *p == '\r' || *p == '\t')) - ++p; - return p; -} - -#ifdef RAPIDJSON_SSE42 -//! Skip whitespace with SSE 4.2 pcmpistrm instruction, testing 16 8-byte characters at once. -inline const char *SkipWhitespace_SIMD(const char* p) { - // Fast return for single non-whitespace - if (*p == ' ' || *p == '\n' || *p == '\r' || *p == '\t') - ++p; - else - return p; - - // 16-byte align to the next boundary - const char* nextAligned = reinterpret_cast((reinterpret_cast(p) + 15) & static_cast(~15)); - while (p != nextAligned) - if (*p == ' ' || *p == '\n' || *p == '\r' || *p == '\t') - ++p; - else - return p; - - // The rest of string using SIMD - static const char whitespace[16] = " \n\r\t"; - const __m128i w = _mm_loadu_si128(reinterpret_cast(&whitespace[0])); - - for (;; p += 16) { - const __m128i s = _mm_load_si128(reinterpret_cast(p)); - const int r = _mm_cvtsi128_si32(_mm_cmpistrm(w, s, _SIDD_UBYTE_OPS | _SIDD_CMP_EQUAL_ANY | _SIDD_BIT_MASK | _SIDD_NEGATIVE_POLARITY)); - if (r != 0) { // some of characters is non-whitespace -#ifdef _MSC_VER // Find the index of first non-whitespace - unsigned long offset; - _BitScanForward(&offset, r); - return p + offset; -#else - return p + __builtin_ffs(r) - 1; -#endif - } - } -} - -inline const char *SkipWhitespace_SIMD(const char* p, const char* end) { - // Fast return for single non-whitespace - if (p != end && (*p == ' ' || *p == '\n' || *p == '\r' || *p == '\t')) - ++p; - else - return p; - - // The middle of string using SIMD - static const char whitespace[16] = " \n\r\t"; - const __m128i w = _mm_loadu_si128(reinterpret_cast(&whitespace[0])); - - for (; p <= end - 16; p += 16) { - const __m128i s = _mm_loadu_si128(reinterpret_cast(p)); - const int r = _mm_cvtsi128_si32(_mm_cmpistrm(w, s, _SIDD_UBYTE_OPS | _SIDD_CMP_EQUAL_ANY | _SIDD_BIT_MASK | _SIDD_NEGATIVE_POLARITY)); - if (r != 0) { // some of characters is non-whitespace -#ifdef _MSC_VER // Find the index of first non-whitespace - unsigned long offset; - _BitScanForward(&offset, r); - return p + offset; -#else - return p + __builtin_ffs(r) - 1; -#endif - } - } - - return SkipWhitespace(p, end); -} - -#elif defined(RAPIDJSON_SSE2) - -//! Skip whitespace with SSE2 instructions, testing 16 8-byte characters at once. -inline const char *SkipWhitespace_SIMD(const char* p) { - // Fast return for single non-whitespace - if (*p == ' ' || *p == '\n' || *p == '\r' || *p == '\t') - ++p; - else - return p; - - // 16-byte align to the next boundary - const char* nextAligned = reinterpret_cast((reinterpret_cast(p) + 15) & static_cast(~15)); - while (p != nextAligned) - if (*p == ' ' || *p == '\n' || *p == '\r' || *p == '\t') - ++p; - else - return p; - - // The rest of string - #define C16(c) { c, c, c, c, c, c, c, c, c, c, c, c, c, c, c, c } - static const char whitespaces[4][16] = { C16(' '), C16('\n'), C16('\r'), C16('\t') }; - #undef C16 - - const __m128i w0 = _mm_loadu_si128(reinterpret_cast(&whitespaces[0][0])); - const __m128i w1 = _mm_loadu_si128(reinterpret_cast(&whitespaces[1][0])); - const __m128i w2 = _mm_loadu_si128(reinterpret_cast(&whitespaces[2][0])); - const __m128i w3 = _mm_loadu_si128(reinterpret_cast(&whitespaces[3][0])); - - for (;; p += 16) { - const __m128i s = _mm_load_si128(reinterpret_cast(p)); - __m128i x = _mm_cmpeq_epi8(s, w0); - x = _mm_or_si128(x, _mm_cmpeq_epi8(s, w1)); - x = _mm_or_si128(x, _mm_cmpeq_epi8(s, w2)); - x = _mm_or_si128(x, _mm_cmpeq_epi8(s, w3)); - unsigned short r = static_cast(~_mm_movemask_epi8(x)); - if (r != 0) { // some of characters may be non-whitespace -#ifdef _MSC_VER // Find the index of first non-whitespace - unsigned long offset; - _BitScanForward(&offset, r); - return p + offset; -#else - return p + __builtin_ffs(r) - 1; -#endif - } - } -} - -inline const char *SkipWhitespace_SIMD(const char* p, const char* end) { - // Fast return for single non-whitespace - if (p != end && (*p == ' ' || *p == '\n' || *p == '\r' || *p == '\t')) - ++p; - else - return p; - - // The rest of string - #define C16(c) { c, c, c, c, c, c, c, c, c, c, c, c, c, c, c, c } - static const char whitespaces[4][16] = { C16(' '), C16('\n'), C16('\r'), C16('\t') }; - #undef C16 - - const __m128i w0 = _mm_loadu_si128(reinterpret_cast(&whitespaces[0][0])); - const __m128i w1 = _mm_loadu_si128(reinterpret_cast(&whitespaces[1][0])); - const __m128i w2 = _mm_loadu_si128(reinterpret_cast(&whitespaces[2][0])); - const __m128i w3 = _mm_loadu_si128(reinterpret_cast(&whitespaces[3][0])); - - for (; p <= end - 16; p += 16) { - const __m128i s = _mm_loadu_si128(reinterpret_cast(p)); - __m128i x = _mm_cmpeq_epi8(s, w0); - x = _mm_or_si128(x, _mm_cmpeq_epi8(s, w1)); - x = _mm_or_si128(x, _mm_cmpeq_epi8(s, w2)); - x = _mm_or_si128(x, _mm_cmpeq_epi8(s, w3)); - unsigned short r = static_cast(~_mm_movemask_epi8(x)); - if (r != 0) { // some of characters may be non-whitespace -#ifdef _MSC_VER // Find the index of first non-whitespace - unsigned long offset; - _BitScanForward(&offset, r); - return p + offset; -#else - return p + __builtin_ffs(r) - 1; -#endif - } - } - - return SkipWhitespace(p, end); -} - -#endif // RAPIDJSON_SSE2 - -#ifdef RAPIDJSON_SIMD -//! Template function specialization for InsituStringStream -template<> inline void SkipWhitespace(InsituStringStream& is) { - is.src_ = const_cast(SkipWhitespace_SIMD(is.src_)); -} - -//! Template function specialization for StringStream -template<> inline void SkipWhitespace(StringStream& is) { - is.src_ = SkipWhitespace_SIMD(is.src_); -} - -template<> inline void SkipWhitespace(EncodedInputStream, MemoryStream>& is) { - is.is_.src_ = SkipWhitespace_SIMD(is.is_.src_, is.is_.end_); -} -#endif // RAPIDJSON_SIMD - -/////////////////////////////////////////////////////////////////////////////// -// GenericReader - -//! SAX-style JSON parser. Use \ref Reader for UTF8 encoding and default allocator. -/*! GenericReader parses JSON text from a stream, and send events synchronously to an - object implementing Handler concept. - - It needs to allocate a stack for storing a single decoded string during - non-destructive parsing. - - For in-situ parsing, the decoded string is directly written to the source - text string, no temporary buffer is required. - - A GenericReader object can be reused for parsing multiple JSON text. - - \tparam SourceEncoding Encoding of the input stream. - \tparam TargetEncoding Encoding of the parse output. - \tparam StackAllocator Allocator type for stack. -*/ -template -class GenericReader { -public: - typedef typename SourceEncoding::Ch Ch; //!< SourceEncoding character type - - //! Constructor. - /*! \param stackAllocator Optional allocator for allocating stack memory. (Only use for non-destructive parsing) - \param stackCapacity stack capacity in bytes for storing a single decoded string. (Only use for non-destructive parsing) - */ - GenericReader(StackAllocator* stackAllocator = 0, size_t stackCapacity = kDefaultStackCapacity) : stack_(stackAllocator, stackCapacity), parseResult_() {} - - //! Parse JSON text. - /*! \tparam parseFlags Combination of \ref ParseFlag. - \tparam InputStream Type of input stream, implementing Stream concept. - \tparam Handler Type of handler, implementing Handler concept. - \param is Input stream to be parsed. - \param handler The handler to receive events. - \return Whether the parsing is successful. - */ - template - ParseResult Parse(InputStream& is, Handler& handler) { - if (parseFlags & kParseIterativeFlag) - return IterativeParse(is, handler); - - parseResult_.Clear(); - - ClearStackOnExit scope(*this); - - SkipWhitespaceAndComments(is); - RAPIDJSON_PARSE_ERROR_EARLY_RETURN(parseResult_); - - if (RAPIDJSON_UNLIKELY(is.Peek() == '\0')) { - RAPIDJSON_PARSE_ERROR_NORETURN(kParseErrorDocumentEmpty, is.Tell()); - RAPIDJSON_PARSE_ERROR_EARLY_RETURN(parseResult_); - } - else { - ParseValue(is, handler); - RAPIDJSON_PARSE_ERROR_EARLY_RETURN(parseResult_); - - if (!(parseFlags & kParseStopWhenDoneFlag)) { - SkipWhitespaceAndComments(is); - RAPIDJSON_PARSE_ERROR_EARLY_RETURN(parseResult_); - - if (RAPIDJSON_UNLIKELY(is.Peek() != '\0')) { - RAPIDJSON_PARSE_ERROR_NORETURN(kParseErrorDocumentRootNotSingular, is.Tell()); - RAPIDJSON_PARSE_ERROR_EARLY_RETURN(parseResult_); - } - } - } - - return parseResult_; - } - - //! Parse JSON text (with \ref kParseDefaultFlags) - /*! \tparam InputStream Type of input stream, implementing Stream concept - \tparam Handler Type of handler, implementing Handler concept. - \param is Input stream to be parsed. - \param handler The handler to receive events. - \return Whether the parsing is successful. - */ - template - ParseResult Parse(InputStream& is, Handler& handler) { - return Parse(is, handler); - } - - //! Whether a parse error has occured in the last parsing. - bool HasParseError() const { return parseResult_.IsError(); } - - //! Get the \ref ParseErrorCode of last parsing. - ParseErrorCode GetParseErrorCode() const { return parseResult_.Code(); } - - //! Get the position of last parsing error in input, 0 otherwise. - size_t GetErrorOffset() const { return parseResult_.Offset(); } - -protected: - void SetParseError(ParseErrorCode code, size_t offset) { parseResult_.Set(code, offset); } - -private: - // Prohibit copy constructor & assignment operator. - GenericReader(const GenericReader&); - GenericReader& operator=(const GenericReader&); - - void ClearStack() { stack_.Clear(); } - - // clear stack on any exit from ParseStream, e.g. due to exception - struct ClearStackOnExit { - explicit ClearStackOnExit(GenericReader& r) : r_(r) {} - ~ClearStackOnExit() { r_.ClearStack(); } - private: - GenericReader& r_; - ClearStackOnExit(const ClearStackOnExit&); - ClearStackOnExit& operator=(const ClearStackOnExit&); - }; - - template - void SkipWhitespaceAndComments(InputStream& is) { - SkipWhitespace(is); - - if (parseFlags & kParseCommentsFlag) { - while (RAPIDJSON_UNLIKELY(Consume(is, '/'))) { - if (Consume(is, '*')) { - while (true) { - if (RAPIDJSON_UNLIKELY(is.Peek() == '\0')) - RAPIDJSON_PARSE_ERROR(kParseErrorUnspecificSyntaxError, is.Tell()); - else if (Consume(is, '*')) { - if (Consume(is, '/')) - break; - } - else - is.Take(); - } - } - else if (RAPIDJSON_LIKELY(Consume(is, '/'))) - while (is.Peek() != '\0' && is.Take() != '\n'); - else - RAPIDJSON_PARSE_ERROR(kParseErrorUnspecificSyntaxError, is.Tell()); - - SkipWhitespace(is); - } - } - } - - // Parse object: { string : value, ... } - template - void ParseObject(InputStream& is, Handler& handler) { - RAPIDJSON_ASSERT(is.Peek() == '{'); - is.Take(); // Skip '{' - - if (RAPIDJSON_UNLIKELY(!handler.StartObject())) - RAPIDJSON_PARSE_ERROR(kParseErrorTermination, is.Tell()); - - SkipWhitespaceAndComments(is); - RAPIDJSON_PARSE_ERROR_EARLY_RETURN_VOID; - - if (Consume(is, '}')) { - if (RAPIDJSON_UNLIKELY(!handler.EndObject(0))) // empty object - RAPIDJSON_PARSE_ERROR(kParseErrorTermination, is.Tell()); - return; - } - - for (SizeType memberCount = 0;;) { - if (RAPIDJSON_UNLIKELY(is.Peek() != '"')) - RAPIDJSON_PARSE_ERROR(kParseErrorObjectMissName, is.Tell()); - - ParseString(is, handler, true); - RAPIDJSON_PARSE_ERROR_EARLY_RETURN_VOID; - - SkipWhitespaceAndComments(is); - RAPIDJSON_PARSE_ERROR_EARLY_RETURN_VOID; - - if (RAPIDJSON_UNLIKELY(!Consume(is, ':'))) - RAPIDJSON_PARSE_ERROR(kParseErrorObjectMissColon, is.Tell()); - - SkipWhitespaceAndComments(is); - RAPIDJSON_PARSE_ERROR_EARLY_RETURN_VOID; - - ParseValue(is, handler); - RAPIDJSON_PARSE_ERROR_EARLY_RETURN_VOID; - - SkipWhitespaceAndComments(is); - RAPIDJSON_PARSE_ERROR_EARLY_RETURN_VOID; - - ++memberCount; - - switch (is.Peek()) { - case ',': - is.Take(); - SkipWhitespaceAndComments(is); - RAPIDJSON_PARSE_ERROR_EARLY_RETURN_VOID; - break; - case '}': - is.Take(); - if (RAPIDJSON_UNLIKELY(!handler.EndObject(memberCount))) - RAPIDJSON_PARSE_ERROR(kParseErrorTermination, is.Tell()); - return; - default: - RAPIDJSON_PARSE_ERROR(kParseErrorObjectMissCommaOrCurlyBracket, is.Tell()); break; // This useless break is only for making warning and coverage happy - } - - if (parseFlags & kParseTrailingCommasFlag) { - if (is.Peek() == '}') { - if (RAPIDJSON_UNLIKELY(!handler.EndObject(memberCount))) - RAPIDJSON_PARSE_ERROR(kParseErrorTermination, is.Tell()); - is.Take(); - return; - } - } - } - } - - // Parse array: [ value, ... ] - template - void ParseArray(InputStream& is, Handler& handler) { - RAPIDJSON_ASSERT(is.Peek() == '['); - is.Take(); // Skip '[' - - if (RAPIDJSON_UNLIKELY(!handler.StartArray())) - RAPIDJSON_PARSE_ERROR(kParseErrorTermination, is.Tell()); - - SkipWhitespaceAndComments(is); - RAPIDJSON_PARSE_ERROR_EARLY_RETURN_VOID; - - if (Consume(is, ']')) { - if (RAPIDJSON_UNLIKELY(!handler.EndArray(0))) // empty array - RAPIDJSON_PARSE_ERROR(kParseErrorTermination, is.Tell()); - return; - } - - for (SizeType elementCount = 0;;) { - ParseValue(is, handler); - RAPIDJSON_PARSE_ERROR_EARLY_RETURN_VOID; - - ++elementCount; - SkipWhitespaceAndComments(is); - RAPIDJSON_PARSE_ERROR_EARLY_RETURN_VOID; - - if (Consume(is, ',')) { - SkipWhitespaceAndComments(is); - RAPIDJSON_PARSE_ERROR_EARLY_RETURN_VOID; - } - else if (Consume(is, ']')) { - if (RAPIDJSON_UNLIKELY(!handler.EndArray(elementCount))) - RAPIDJSON_PARSE_ERROR(kParseErrorTermination, is.Tell()); - return; - } - else - RAPIDJSON_PARSE_ERROR(kParseErrorArrayMissCommaOrSquareBracket, is.Tell()); - - if (parseFlags & kParseTrailingCommasFlag) { - if (is.Peek() == ']') { - if (RAPIDJSON_UNLIKELY(!handler.EndArray(elementCount))) - RAPIDJSON_PARSE_ERROR(kParseErrorTermination, is.Tell()); - is.Take(); - return; - } - } - } - } - - template - void ParseNull(InputStream& is, Handler& handler) { - RAPIDJSON_ASSERT(is.Peek() == 'n'); - is.Take(); - - if (RAPIDJSON_LIKELY(Consume(is, 'u') && Consume(is, 'l') && Consume(is, 'l'))) { - if (RAPIDJSON_UNLIKELY(!handler.Null())) - RAPIDJSON_PARSE_ERROR(kParseErrorTermination, is.Tell()); - } - else - RAPIDJSON_PARSE_ERROR(kParseErrorValueInvalid, is.Tell()); - } - - template - void ParseTrue(InputStream& is, Handler& handler) { - RAPIDJSON_ASSERT(is.Peek() == 't'); - is.Take(); - - if (RAPIDJSON_LIKELY(Consume(is, 'r') && Consume(is, 'u') && Consume(is, 'e'))) { - if (RAPIDJSON_UNLIKELY(!handler.Bool(true))) - RAPIDJSON_PARSE_ERROR(kParseErrorTermination, is.Tell()); - } - else - RAPIDJSON_PARSE_ERROR(kParseErrorValueInvalid, is.Tell()); - } - - template - void ParseFalse(InputStream& is, Handler& handler) { - RAPIDJSON_ASSERT(is.Peek() == 'f'); - is.Take(); - - if (RAPIDJSON_LIKELY(Consume(is, 'a') && Consume(is, 'l') && Consume(is, 's') && Consume(is, 'e'))) { - if (RAPIDJSON_UNLIKELY(!handler.Bool(false))) - RAPIDJSON_PARSE_ERROR(kParseErrorTermination, is.Tell()); - } - else - RAPIDJSON_PARSE_ERROR(kParseErrorValueInvalid, is.Tell()); - } - - template - RAPIDJSON_FORCEINLINE static bool Consume(InputStream& is, typename InputStream::Ch expect) { - if (RAPIDJSON_LIKELY(is.Peek() == expect)) { - is.Take(); - return true; - } - else - return false; - } - - // Helper function to parse four hexidecimal digits in \uXXXX in ParseString(). - template - unsigned ParseHex4(InputStream& is, size_t escapeOffset) { - unsigned codepoint = 0; - for (int i = 0; i < 4; i++) { - Ch c = is.Peek(); - codepoint <<= 4; - codepoint += static_cast(c); - if (c >= '0' && c <= '9') - codepoint -= '0'; - else if (c >= 'A' && c <= 'F') - codepoint -= 'A' - 10; - else if (c >= 'a' && c <= 'f') - codepoint -= 'a' - 10; - else { - RAPIDJSON_PARSE_ERROR_NORETURN(kParseErrorStringUnicodeEscapeInvalidHex, escapeOffset); - RAPIDJSON_PARSE_ERROR_EARLY_RETURN(0); - } - is.Take(); - } - return codepoint; - } - - template - class StackStream { - public: - typedef CharType Ch; - - StackStream(internal::Stack& stack) : stack_(stack), length_(0) {} - RAPIDJSON_FORCEINLINE void Put(Ch c) { - *stack_.template Push() = c; - ++length_; - } - - RAPIDJSON_FORCEINLINE void* Push(SizeType count) { - length_ += count; - return stack_.template Push(count); - } - - size_t Length() const { return length_; } - - Ch* Pop() { - return stack_.template Pop(length_); - } - - private: - StackStream(const StackStream&); - StackStream& operator=(const StackStream&); - - internal::Stack& stack_; - SizeType length_; - }; - - // Parse string and generate String event. Different code paths for kParseInsituFlag. - template - void ParseString(InputStream& is, Handler& handler, bool isKey = false) { - internal::StreamLocalCopy copy(is); - InputStream& s(copy.s); - - RAPIDJSON_ASSERT(s.Peek() == '\"'); - s.Take(); // Skip '\"' - - bool success = false; - if (parseFlags & kParseInsituFlag) { - typename InputStream::Ch *head = s.PutBegin(); - ParseStringToStream(s, s); - RAPIDJSON_PARSE_ERROR_EARLY_RETURN_VOID; - size_t length = s.PutEnd(head) - 1; - RAPIDJSON_ASSERT(length <= 0xFFFFFFFF); - const typename TargetEncoding::Ch* const str = reinterpret_cast(head); - success = (isKey ? handler.Key(str, SizeType(length), false) : handler.String(str, SizeType(length), false)); - } - else { - StackStream stackStream(stack_); - ParseStringToStream(s, stackStream); - RAPIDJSON_PARSE_ERROR_EARLY_RETURN_VOID; - SizeType length = static_cast(stackStream.Length()) - 1; - const typename TargetEncoding::Ch* const str = stackStream.Pop(); - success = (isKey ? handler.Key(str, length, true) : handler.String(str, length, true)); - } - if (RAPIDJSON_UNLIKELY(!success)) - RAPIDJSON_PARSE_ERROR(kParseErrorTermination, s.Tell()); - } - - // Parse string to an output is - // This function handles the prefix/suffix double quotes, escaping, and optional encoding validation. - template - RAPIDJSON_FORCEINLINE void ParseStringToStream(InputStream& is, OutputStream& os) { -//!@cond RAPIDJSON_HIDDEN_FROM_DOXYGEN -#define Z16 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - static const char escape[256] = { - Z16, Z16, 0, 0,'\"', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,'/', - Z16, Z16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,'\\', 0, 0, 0, - 0, 0,'\b', 0, 0, 0,'\f', 0, 0, 0, 0, 0, 0, 0,'\n', 0, - 0, 0,'\r', 0,'\t', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - Z16, Z16, Z16, Z16, Z16, Z16, Z16, Z16 - }; -#undef Z16 -//!@endcond - - for (;;) { - // Scan and copy string before "\\\"" or < 0x20. This is an optional optimzation. - if (!(parseFlags & kParseValidateEncodingFlag)) - ScanCopyUnescapedString(is, os); - - Ch c = is.Peek(); - if (RAPIDJSON_UNLIKELY(c == '\\')) { // Escape - size_t escapeOffset = is.Tell(); // For invalid escaping, report the inital '\\' as error offset - is.Take(); - Ch e = is.Peek(); - if ((sizeof(Ch) == 1 || unsigned(e) < 256) && RAPIDJSON_LIKELY(escape[static_cast(e)])) { - is.Take(); - os.Put(static_cast(escape[static_cast(e)])); - } - else if (RAPIDJSON_LIKELY(e == 'u')) { // Unicode - is.Take(); - unsigned codepoint = ParseHex4(is, escapeOffset); - RAPIDJSON_PARSE_ERROR_EARLY_RETURN_VOID; - if (RAPIDJSON_UNLIKELY(codepoint >= 0xD800 && codepoint <= 0xDBFF)) { - // Handle UTF-16 surrogate pair - if (RAPIDJSON_UNLIKELY(!Consume(is, '\\') || !Consume(is, 'u'))) - RAPIDJSON_PARSE_ERROR(kParseErrorStringUnicodeSurrogateInvalid, escapeOffset); - unsigned codepoint2 = ParseHex4(is, escapeOffset); - RAPIDJSON_PARSE_ERROR_EARLY_RETURN_VOID; - if (RAPIDJSON_UNLIKELY(codepoint2 < 0xDC00 || codepoint2 > 0xDFFF)) - RAPIDJSON_PARSE_ERROR(kParseErrorStringUnicodeSurrogateInvalid, escapeOffset); - codepoint = (((codepoint - 0xD800) << 10) | (codepoint2 - 0xDC00)) + 0x10000; - } - TEncoding::Encode(os, codepoint); - } - else - RAPIDJSON_PARSE_ERROR(kParseErrorStringEscapeInvalid, escapeOffset); - } - else if (RAPIDJSON_UNLIKELY(c == '"')) { // Closing double quote - is.Take(); - os.Put('\0'); // null-terminate the string - return; - } - else if (RAPIDJSON_UNLIKELY(static_cast(c) < 0x20)) { // RFC 4627: unescaped = %x20-21 / %x23-5B / %x5D-10FFFF - if (c == '\0') - RAPIDJSON_PARSE_ERROR(kParseErrorStringMissQuotationMark, is.Tell()); - else - RAPIDJSON_PARSE_ERROR(kParseErrorStringEscapeInvalid, is.Tell()); - } - else { - size_t offset = is.Tell(); - if (RAPIDJSON_UNLIKELY((parseFlags & kParseValidateEncodingFlag ? - !Transcoder::Validate(is, os) : - !Transcoder::Transcode(is, os)))) - RAPIDJSON_PARSE_ERROR(kParseErrorStringInvalidEncoding, offset); - } - } - } - - template - static RAPIDJSON_FORCEINLINE void ScanCopyUnescapedString(InputStream&, OutputStream&) { - // Do nothing for generic version - } - -#if defined(RAPIDJSON_SSE2) || defined(RAPIDJSON_SSE42) - // StringStream -> StackStream - static RAPIDJSON_FORCEINLINE void ScanCopyUnescapedString(StringStream& is, StackStream& os) { - const char* p = is.src_; - - // Scan one by one until alignment (unaligned load may cross page boundary and cause crash) - const char* nextAligned = reinterpret_cast((reinterpret_cast(p) + 15) & static_cast(~15)); - while (p != nextAligned) - if (RAPIDJSON_UNLIKELY(*p == '\"') || RAPIDJSON_UNLIKELY(*p == '\\') || RAPIDJSON_UNLIKELY(static_cast(*p) < 0x20)) { - is.src_ = p; - return; - } - else - os.Put(*p++); - - // The rest of string using SIMD - static const char dquote[16] = { '\"', '\"', '\"', '\"', '\"', '\"', '\"', '\"', '\"', '\"', '\"', '\"', '\"', '\"', '\"', '\"' }; - static const char bslash[16] = { '\\', '\\', '\\', '\\', '\\', '\\', '\\', '\\', '\\', '\\', '\\', '\\', '\\', '\\', '\\', '\\' }; - static const char space[16] = { 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19 }; - const __m128i dq = _mm_loadu_si128(reinterpret_cast(&dquote[0])); - const __m128i bs = _mm_loadu_si128(reinterpret_cast(&bslash[0])); - const __m128i sp = _mm_loadu_si128(reinterpret_cast(&space[0])); - - for (;; p += 16) { - const __m128i s = _mm_load_si128(reinterpret_cast(p)); - const __m128i t1 = _mm_cmpeq_epi8(s, dq); - const __m128i t2 = _mm_cmpeq_epi8(s, bs); - const __m128i t3 = _mm_cmpeq_epi8(_mm_max_epu8(s, sp), sp); // s < 0x20 <=> max(s, 0x19) == 0x19 - const __m128i x = _mm_or_si128(_mm_or_si128(t1, t2), t3); - unsigned short r = static_cast(_mm_movemask_epi8(x)); - if (RAPIDJSON_UNLIKELY(r != 0)) { // some of characters is escaped - SizeType length; - #ifdef _MSC_VER // Find the index of first escaped - unsigned long offset; - _BitScanForward(&offset, r); - length = offset; - #else - length = static_cast(__builtin_ffs(r) - 1); - #endif - char* q = reinterpret_cast(os.Push(length)); - for (size_t i = 0; i < length; i++) - q[i] = p[i]; - - p += length; - break; - } - _mm_storeu_si128(reinterpret_cast<__m128i *>(os.Push(16)), s); - } - - is.src_ = p; - } - - // InsituStringStream -> InsituStringStream - static RAPIDJSON_FORCEINLINE void ScanCopyUnescapedString(InsituStringStream& is, InsituStringStream& os) { - RAPIDJSON_ASSERT(&is == &os); - (void)os; - - if (is.src_ == is.dst_) { - SkipUnescapedString(is); - return; - } - - char* p = is.src_; - char *q = is.dst_; - - // Scan one by one until alignment (unaligned load may cross page boundary and cause crash) - const char* nextAligned = reinterpret_cast((reinterpret_cast(p) + 15) & static_cast(~15)); - while (p != nextAligned) - if (RAPIDJSON_UNLIKELY(*p == '\"') || RAPIDJSON_UNLIKELY(*p == '\\') || RAPIDJSON_UNLIKELY(static_cast(*p) < 0x20)) { - is.src_ = p; - is.dst_ = q; - return; - } - else - *q++ = *p++; - - // The rest of string using SIMD - static const char dquote[16] = { '\"', '\"', '\"', '\"', '\"', '\"', '\"', '\"', '\"', '\"', '\"', '\"', '\"', '\"', '\"', '\"' }; - static const char bslash[16] = { '\\', '\\', '\\', '\\', '\\', '\\', '\\', '\\', '\\', '\\', '\\', '\\', '\\', '\\', '\\', '\\' }; - static const char space[16] = { 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19 }; - const __m128i dq = _mm_loadu_si128(reinterpret_cast(&dquote[0])); - const __m128i bs = _mm_loadu_si128(reinterpret_cast(&bslash[0])); - const __m128i sp = _mm_loadu_si128(reinterpret_cast(&space[0])); - - for (;; p += 16, q += 16) { - const __m128i s = _mm_load_si128(reinterpret_cast(p)); - const __m128i t1 = _mm_cmpeq_epi8(s, dq); - const __m128i t2 = _mm_cmpeq_epi8(s, bs); - const __m128i t3 = _mm_cmpeq_epi8(_mm_max_epu8(s, sp), sp); // s < 0x20 <=> max(s, 0x19) == 0x19 - const __m128i x = _mm_or_si128(_mm_or_si128(t1, t2), t3); - unsigned short r = static_cast(_mm_movemask_epi8(x)); - if (RAPIDJSON_UNLIKELY(r != 0)) { // some of characters is escaped - size_t length; -#ifdef _MSC_VER // Find the index of first escaped - unsigned long offset; - _BitScanForward(&offset, r); - length = offset; -#else - length = static_cast(__builtin_ffs(r) - 1); -#endif - for (const char* pend = p + length; p != pend; ) - *q++ = *p++; - break; - } - _mm_storeu_si128(reinterpret_cast<__m128i *>(q), s); - } - - is.src_ = p; - is.dst_ = q; - } - - // When read/write pointers are the same for insitu stream, just skip unescaped characters - static RAPIDJSON_FORCEINLINE void SkipUnescapedString(InsituStringStream& is) { - RAPIDJSON_ASSERT(is.src_ == is.dst_); - char* p = is.src_; - - // Scan one by one until alignment (unaligned load may cross page boundary and cause crash) - const char* nextAligned = reinterpret_cast((reinterpret_cast(p) + 15) & static_cast(~15)); - for (; p != nextAligned; p++) - if (RAPIDJSON_UNLIKELY(*p == '\"') || RAPIDJSON_UNLIKELY(*p == '\\') || RAPIDJSON_UNLIKELY(static_cast(*p) < 0x20)) { - is.src_ = is.dst_ = p; - return; - } - - // The rest of string using SIMD - static const char dquote[16] = { '\"', '\"', '\"', '\"', '\"', '\"', '\"', '\"', '\"', '\"', '\"', '\"', '\"', '\"', '\"', '\"' }; - static const char bslash[16] = { '\\', '\\', '\\', '\\', '\\', '\\', '\\', '\\', '\\', '\\', '\\', '\\', '\\', '\\', '\\', '\\' }; - static const char space[16] = { 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19 }; - const __m128i dq = _mm_loadu_si128(reinterpret_cast(&dquote[0])); - const __m128i bs = _mm_loadu_si128(reinterpret_cast(&bslash[0])); - const __m128i sp = _mm_loadu_si128(reinterpret_cast(&space[0])); - - for (;; p += 16) { - const __m128i s = _mm_load_si128(reinterpret_cast(p)); - const __m128i t1 = _mm_cmpeq_epi8(s, dq); - const __m128i t2 = _mm_cmpeq_epi8(s, bs); - const __m128i t3 = _mm_cmpeq_epi8(_mm_max_epu8(s, sp), sp); // s < 0x20 <=> max(s, 0x19) == 0x19 - const __m128i x = _mm_or_si128(_mm_or_si128(t1, t2), t3); - unsigned short r = static_cast(_mm_movemask_epi8(x)); - if (RAPIDJSON_UNLIKELY(r != 0)) { // some of characters is escaped - size_t length; -#ifdef _MSC_VER // Find the index of first escaped - unsigned long offset; - _BitScanForward(&offset, r); - length = offset; -#else - length = static_cast(__builtin_ffs(r) - 1); -#endif - p += length; - break; - } - } - - is.src_ = is.dst_ = p; - } -#endif - - template - class NumberStream; - - template - class NumberStream { - public: - typedef typename InputStream::Ch Ch; - - NumberStream(GenericReader& reader, InputStream& s) : is(s) { (void)reader; } - ~NumberStream() {} - - RAPIDJSON_FORCEINLINE Ch Peek() const { return is.Peek(); } - RAPIDJSON_FORCEINLINE Ch TakePush() { return is.Take(); } - RAPIDJSON_FORCEINLINE Ch Take() { return is.Take(); } - RAPIDJSON_FORCEINLINE void Push(char) {} - - size_t Tell() { return is.Tell(); } - size_t Length() { return 0; } - const char* Pop() { return 0; } - - protected: - NumberStream& operator=(const NumberStream&); - - InputStream& is; - }; - - template - class NumberStream : public NumberStream { - typedef NumberStream Base; - public: - NumberStream(GenericReader& reader, InputStream& is) : Base(reader, is), stackStream(reader.stack_) {} - ~NumberStream() {} - - RAPIDJSON_FORCEINLINE Ch TakePush() { - stackStream.Put(static_cast(Base::is.Peek())); - return Base::is.Take(); - } - - RAPIDJSON_FORCEINLINE void Push(char c) { - stackStream.Put(c); - } - - size_t Length() { return stackStream.Length(); } - - const char* Pop() { - stackStream.Put('\0'); - return stackStream.Pop(); - } - - private: - StackStream stackStream; - }; - - template - class NumberStream : public NumberStream { - typedef NumberStream Base; - public: - NumberStream(GenericReader& reader, InputStream& is) : Base(reader, is) {} - ~NumberStream() {} - - RAPIDJSON_FORCEINLINE Ch Take() { return Base::TakePush(); } - }; - - template - void ParseNumber(InputStream& is, Handler& handler) { - internal::StreamLocalCopy copy(is); - NumberStream s(*this, copy.s); - - size_t startOffset = s.Tell(); - double d = 0.0; - bool useNanOrInf = false; - - // Parse minus - bool minus = Consume(s, '-'); - - // Parse int: zero / ( digit1-9 *DIGIT ) - unsigned i = 0; - uint64_t i64 = 0; - bool use64bit = false; - int significandDigit = 0; - if (RAPIDJSON_UNLIKELY(s.Peek() == '0')) { - i = 0; - s.TakePush(); - } - else if (RAPIDJSON_LIKELY(s.Peek() >= '1' && s.Peek() <= '9')) { - i = static_cast(s.TakePush() - '0'); - - if (minus) - while (RAPIDJSON_LIKELY(s.Peek() >= '0' && s.Peek() <= '9')) { - if (RAPIDJSON_UNLIKELY(i >= 214748364)) { // 2^31 = 2147483648 - if (RAPIDJSON_LIKELY(i != 214748364 || s.Peek() > '8')) { - i64 = i; - use64bit = true; - break; - } - } - i = i * 10 + static_cast(s.TakePush() - '0'); - significandDigit++; - } - else - while (RAPIDJSON_LIKELY(s.Peek() >= '0' && s.Peek() <= '9')) { - if (RAPIDJSON_UNLIKELY(i >= 429496729)) { // 2^32 - 1 = 4294967295 - if (RAPIDJSON_LIKELY(i != 429496729 || s.Peek() > '5')) { - i64 = i; - use64bit = true; - break; - } - } - i = i * 10 + static_cast(s.TakePush() - '0'); - significandDigit++; - } - } - // Parse NaN or Infinity here - else if ((parseFlags & kParseNanAndInfFlag) && RAPIDJSON_LIKELY((s.Peek() == 'I' || s.Peek() == 'N'))) { - useNanOrInf = true; - if (RAPIDJSON_LIKELY(Consume(s, 'N') && Consume(s, 'a') && Consume(s, 'N'))) { - d = std::numeric_limits::quiet_NaN(); - } - else if (RAPIDJSON_LIKELY(Consume(s, 'I') && Consume(s, 'n') && Consume(s, 'f'))) { - d = (minus ? -std::numeric_limits::infinity() : std::numeric_limits::infinity()); - if (RAPIDJSON_UNLIKELY(s.Peek() == 'i' && !(Consume(s, 'i') && Consume(s, 'n') - && Consume(s, 'i') && Consume(s, 't') && Consume(s, 'y')))) - RAPIDJSON_PARSE_ERROR(kParseErrorValueInvalid, s.Tell()); - } - else - RAPIDJSON_PARSE_ERROR(kParseErrorValueInvalid, s.Tell()); - } - else - RAPIDJSON_PARSE_ERROR(kParseErrorValueInvalid, s.Tell()); - - // Parse 64bit int - bool useDouble = false; - if (use64bit) { - if (minus) - while (RAPIDJSON_LIKELY(s.Peek() >= '0' && s.Peek() <= '9')) { - if (RAPIDJSON_UNLIKELY(i64 >= RAPIDJSON_UINT64_C2(0x0CCCCCCC, 0xCCCCCCCC))) // 2^63 = 9223372036854775808 - if (RAPIDJSON_LIKELY(i64 != RAPIDJSON_UINT64_C2(0x0CCCCCCC, 0xCCCCCCCC) || s.Peek() > '8')) { - d = static_cast(i64); - useDouble = true; - break; - } - i64 = i64 * 10 + static_cast(s.TakePush() - '0'); - significandDigit++; - } - else - while (RAPIDJSON_LIKELY(s.Peek() >= '0' && s.Peek() <= '9')) { - if (RAPIDJSON_UNLIKELY(i64 >= RAPIDJSON_UINT64_C2(0x19999999, 0x99999999))) // 2^64 - 1 = 18446744073709551615 - if (RAPIDJSON_LIKELY(i64 != RAPIDJSON_UINT64_C2(0x19999999, 0x99999999) || s.Peek() > '5')) { - d = static_cast(i64); - useDouble = true; - break; - } - i64 = i64 * 10 + static_cast(s.TakePush() - '0'); - significandDigit++; - } - } - - // Force double for big integer - if (useDouble) { - while (RAPIDJSON_LIKELY(s.Peek() >= '0' && s.Peek() <= '9')) { - if (RAPIDJSON_UNLIKELY(d >= 1.7976931348623157e307)) // DBL_MAX / 10.0 - RAPIDJSON_PARSE_ERROR(kParseErrorNumberTooBig, startOffset); - d = d * 10 + (s.TakePush() - '0'); - } - } - - // Parse frac = decimal-point 1*DIGIT - int expFrac = 0; - size_t decimalPosition; - if (Consume(s, '.')) { - decimalPosition = s.Length(); - - if (RAPIDJSON_UNLIKELY(!(s.Peek() >= '0' && s.Peek() <= '9'))) - RAPIDJSON_PARSE_ERROR(kParseErrorNumberMissFraction, s.Tell()); - - if (!useDouble) { -#if RAPIDJSON_64BIT - // Use i64 to store significand in 64-bit architecture - if (!use64bit) - i64 = i; - - while (RAPIDJSON_LIKELY(s.Peek() >= '0' && s.Peek() <= '9')) { - if (i64 > RAPIDJSON_UINT64_C2(0x1FFFFF, 0xFFFFFFFF)) // 2^53 - 1 for fast path - break; - else { - i64 = i64 * 10 + static_cast(s.TakePush() - '0'); - --expFrac; - if (i64 != 0) - significandDigit++; - } - } - - d = static_cast(i64); -#else - // Use double to store significand in 32-bit architecture - d = static_cast(use64bit ? i64 : i); -#endif - useDouble = true; - } - - while (RAPIDJSON_LIKELY(s.Peek() >= '0' && s.Peek() <= '9')) { - if (significandDigit < 17) { - d = d * 10.0 + (s.TakePush() - '0'); - --expFrac; - if (RAPIDJSON_LIKELY(d > 0.0)) - significandDigit++; - } - else - s.TakePush(); - } - } - else - decimalPosition = s.Length(); // decimal position at the end of integer. - - // Parse exp = e [ minus / plus ] 1*DIGIT - int exp = 0; - if (Consume(s, 'e') || Consume(s, 'E')) { - if (!useDouble) { - d = static_cast(use64bit ? i64 : i); - useDouble = true; - } - - bool expMinus = false; - if (Consume(s, '+')) - ; - else if (Consume(s, '-')) - expMinus = true; - - if (RAPIDJSON_LIKELY(s.Peek() >= '0' && s.Peek() <= '9')) { - exp = static_cast(s.Take() - '0'); - if (expMinus) { - while (RAPIDJSON_LIKELY(s.Peek() >= '0' && s.Peek() <= '9')) { - exp = exp * 10 + static_cast(s.Take() - '0'); - if (exp >= 214748364) { // Issue #313: prevent overflow exponent - while (RAPIDJSON_UNLIKELY(s.Peek() >= '0' && s.Peek() <= '9')) // Consume the rest of exponent - s.Take(); - } - } - } - else { // positive exp - int maxExp = 308 - expFrac; - while (RAPIDJSON_LIKELY(s.Peek() >= '0' && s.Peek() <= '9')) { - exp = exp * 10 + static_cast(s.Take() - '0'); - if (RAPIDJSON_UNLIKELY(exp > maxExp)) - RAPIDJSON_PARSE_ERROR(kParseErrorNumberTooBig, startOffset); - } - } - } - else - RAPIDJSON_PARSE_ERROR(kParseErrorNumberMissExponent, s.Tell()); - - if (expMinus) - exp = -exp; - } - - // Finish parsing, call event according to the type of number. - bool cont = true; - - if (parseFlags & kParseNumbersAsStringsFlag) { - if (parseFlags & kParseInsituFlag) { - s.Pop(); // Pop stack no matter if it will be used or not. - typename InputStream::Ch* head = is.PutBegin(); - const size_t length = s.Tell() - startOffset; - RAPIDJSON_ASSERT(length <= 0xFFFFFFFF); - // unable to insert the \0 character here, it will erase the comma after this number - const typename TargetEncoding::Ch* const str = reinterpret_cast(head); - cont = handler.RawNumber(str, SizeType(length), false); - } - else { - SizeType numCharsToCopy = static_cast(s.Length()); - StringStream srcStream(s.Pop()); - StackStream dstStream(stack_); - while (numCharsToCopy--) { - Transcoder, TargetEncoding>::Transcode(srcStream, dstStream); - } - dstStream.Put('\0'); - const typename TargetEncoding::Ch* str = dstStream.Pop(); - const SizeType length = static_cast(dstStream.Length()) - 1; - cont = handler.RawNumber(str, SizeType(length), true); - } - } - else { - size_t length = s.Length(); - const char* decimal = s.Pop(); // Pop stack no matter if it will be used or not. - - if (useDouble) { - int p = exp + expFrac; - if (parseFlags & kParseFullPrecisionFlag) - d = internal::StrtodFullPrecision(d, p, decimal, length, decimalPosition, exp); - else - d = internal::StrtodNormalPrecision(d, p); - - cont = handler.Double(minus ? -d : d); - } - else if (useNanOrInf) { - cont = handler.Double(d); - } - else { - if (use64bit) { - if (minus) - cont = handler.Int64(static_cast(~i64 + 1)); - else - cont = handler.Uint64(i64); - } - else { - if (minus) - cont = handler.Int(static_cast(~i + 1)); - else - cont = handler.Uint(i); - } - } - } - if (RAPIDJSON_UNLIKELY(!cont)) - RAPIDJSON_PARSE_ERROR(kParseErrorTermination, startOffset); - } - - // Parse any JSON value - template - void ParseValue(InputStream& is, Handler& handler) { - switch (is.Peek()) { - case 'n': ParseNull (is, handler); break; - case 't': ParseTrue (is, handler); break; - case 'f': ParseFalse (is, handler); break; - case '"': ParseString(is, handler); break; - case '{': ParseObject(is, handler); break; - case '[': ParseArray (is, handler); break; - default : - ParseNumber(is, handler); - break; - - } - } - - // Iterative Parsing - - // States - enum IterativeParsingState { - IterativeParsingStartState = 0, - IterativeParsingFinishState, - IterativeParsingErrorState, - - // Object states - IterativeParsingObjectInitialState, - IterativeParsingMemberKeyState, - IterativeParsingKeyValueDelimiterState, - IterativeParsingMemberValueState, - IterativeParsingMemberDelimiterState, - IterativeParsingObjectFinishState, - - // Array states - IterativeParsingArrayInitialState, - IterativeParsingElementState, - IterativeParsingElementDelimiterState, - IterativeParsingArrayFinishState, - - // Single value state - IterativeParsingValueState - }; - - enum { cIterativeParsingStateCount = IterativeParsingValueState + 1 }; - - // Tokens - enum Token { - LeftBracketToken = 0, - RightBracketToken, - - LeftCurlyBracketToken, - RightCurlyBracketToken, - - CommaToken, - ColonToken, - - StringToken, - FalseToken, - TrueToken, - NullToken, - NumberToken, - - kTokenCount - }; - - RAPIDJSON_FORCEINLINE Token Tokenize(Ch c) { - -//!@cond RAPIDJSON_HIDDEN_FROM_DOXYGEN -#define N NumberToken -#define N16 N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N - // Maps from ASCII to Token - static const unsigned char tokenMap[256] = { - N16, // 00~0F - N16, // 10~1F - N, N, StringToken, N, N, N, N, N, N, N, N, N, CommaToken, N, N, N, // 20~2F - N, N, N, N, N, N, N, N, N, N, ColonToken, N, N, N, N, N, // 30~3F - N16, // 40~4F - N, N, N, N, N, N, N, N, N, N, N, LeftBracketToken, N, RightBracketToken, N, N, // 50~5F - N, N, N, N, N, N, FalseToken, N, N, N, N, N, N, N, NullToken, N, // 60~6F - N, N, N, N, TrueToken, N, N, N, N, N, N, LeftCurlyBracketToken, N, RightCurlyBracketToken, N, N, // 70~7F - N16, N16, N16, N16, N16, N16, N16, N16 // 80~FF - }; -#undef N -#undef N16 -//!@endcond - - if (sizeof(Ch) == 1 || static_cast(c) < 256) - return static_cast(tokenMap[static_cast(c)]); - else - return NumberToken; - } - - RAPIDJSON_FORCEINLINE IterativeParsingState Predict(IterativeParsingState state, Token token) { - // current state x one lookahead token -> new state - static const char G[cIterativeParsingStateCount][kTokenCount] = { - // Start - { - IterativeParsingArrayInitialState, // Left bracket - IterativeParsingErrorState, // Right bracket - IterativeParsingObjectInitialState, // Left curly bracket - IterativeParsingErrorState, // Right curly bracket - IterativeParsingErrorState, // Comma - IterativeParsingErrorState, // Colon - IterativeParsingValueState, // String - IterativeParsingValueState, // False - IterativeParsingValueState, // True - IterativeParsingValueState, // Null - IterativeParsingValueState // Number - }, - // Finish(sink state) - { - IterativeParsingErrorState, IterativeParsingErrorState, IterativeParsingErrorState, IterativeParsingErrorState, IterativeParsingErrorState, - IterativeParsingErrorState, IterativeParsingErrorState, IterativeParsingErrorState, IterativeParsingErrorState, IterativeParsingErrorState, - IterativeParsingErrorState - }, - // Error(sink state) - { - IterativeParsingErrorState, IterativeParsingErrorState, IterativeParsingErrorState, IterativeParsingErrorState, IterativeParsingErrorState, - IterativeParsingErrorState, IterativeParsingErrorState, IterativeParsingErrorState, IterativeParsingErrorState, IterativeParsingErrorState, - IterativeParsingErrorState - }, - // ObjectInitial - { - IterativeParsingErrorState, // Left bracket - IterativeParsingErrorState, // Right bracket - IterativeParsingErrorState, // Left curly bracket - IterativeParsingObjectFinishState, // Right curly bracket - IterativeParsingErrorState, // Comma - IterativeParsingErrorState, // Colon - IterativeParsingMemberKeyState, // String - IterativeParsingErrorState, // False - IterativeParsingErrorState, // True - IterativeParsingErrorState, // Null - IterativeParsingErrorState // Number - }, - // MemberKey - { - IterativeParsingErrorState, // Left bracket - IterativeParsingErrorState, // Right bracket - IterativeParsingErrorState, // Left curly bracket - IterativeParsingErrorState, // Right curly bracket - IterativeParsingErrorState, // Comma - IterativeParsingKeyValueDelimiterState, // Colon - IterativeParsingErrorState, // String - IterativeParsingErrorState, // False - IterativeParsingErrorState, // True - IterativeParsingErrorState, // Null - IterativeParsingErrorState // Number - }, - // KeyValueDelimiter - { - IterativeParsingArrayInitialState, // Left bracket(push MemberValue state) - IterativeParsingErrorState, // Right bracket - IterativeParsingObjectInitialState, // Left curly bracket(push MemberValue state) - IterativeParsingErrorState, // Right curly bracket - IterativeParsingErrorState, // Comma - IterativeParsingErrorState, // Colon - IterativeParsingMemberValueState, // String - IterativeParsingMemberValueState, // False - IterativeParsingMemberValueState, // True - IterativeParsingMemberValueState, // Null - IterativeParsingMemberValueState // Number - }, - // MemberValue - { - IterativeParsingErrorState, // Left bracket - IterativeParsingErrorState, // Right bracket - IterativeParsingErrorState, // Left curly bracket - IterativeParsingObjectFinishState, // Right curly bracket - IterativeParsingMemberDelimiterState, // Comma - IterativeParsingErrorState, // Colon - IterativeParsingErrorState, // String - IterativeParsingErrorState, // False - IterativeParsingErrorState, // True - IterativeParsingErrorState, // Null - IterativeParsingErrorState // Number - }, - // MemberDelimiter - { - IterativeParsingErrorState, // Left bracket - IterativeParsingErrorState, // Right bracket - IterativeParsingErrorState, // Left curly bracket - IterativeParsingObjectFinishState, // Right curly bracket - IterativeParsingErrorState, // Comma - IterativeParsingErrorState, // Colon - IterativeParsingMemberKeyState, // String - IterativeParsingErrorState, // False - IterativeParsingErrorState, // True - IterativeParsingErrorState, // Null - IterativeParsingErrorState // Number - }, - // ObjectFinish(sink state) - { - IterativeParsingErrorState, IterativeParsingErrorState, IterativeParsingErrorState, IterativeParsingErrorState, IterativeParsingErrorState, - IterativeParsingErrorState, IterativeParsingErrorState, IterativeParsingErrorState, IterativeParsingErrorState, IterativeParsingErrorState, - IterativeParsingErrorState - }, - // ArrayInitial - { - IterativeParsingArrayInitialState, // Left bracket(push Element state) - IterativeParsingArrayFinishState, // Right bracket - IterativeParsingObjectInitialState, // Left curly bracket(push Element state) - IterativeParsingErrorState, // Right curly bracket - IterativeParsingErrorState, // Comma - IterativeParsingErrorState, // Colon - IterativeParsingElementState, // String - IterativeParsingElementState, // False - IterativeParsingElementState, // True - IterativeParsingElementState, // Null - IterativeParsingElementState // Number - }, - // Element - { - IterativeParsingErrorState, // Left bracket - IterativeParsingArrayFinishState, // Right bracket - IterativeParsingErrorState, // Left curly bracket - IterativeParsingErrorState, // Right curly bracket - IterativeParsingElementDelimiterState, // Comma - IterativeParsingErrorState, // Colon - IterativeParsingErrorState, // String - IterativeParsingErrorState, // False - IterativeParsingErrorState, // True - IterativeParsingErrorState, // Null - IterativeParsingErrorState // Number - }, - // ElementDelimiter - { - IterativeParsingArrayInitialState, // Left bracket(push Element state) - IterativeParsingArrayFinishState, // Right bracket - IterativeParsingObjectInitialState, // Left curly bracket(push Element state) - IterativeParsingErrorState, // Right curly bracket - IterativeParsingErrorState, // Comma - IterativeParsingErrorState, // Colon - IterativeParsingElementState, // String - IterativeParsingElementState, // False - IterativeParsingElementState, // True - IterativeParsingElementState, // Null - IterativeParsingElementState // Number - }, - // ArrayFinish(sink state) - { - IterativeParsingErrorState, IterativeParsingErrorState, IterativeParsingErrorState, IterativeParsingErrorState, IterativeParsingErrorState, - IterativeParsingErrorState, IterativeParsingErrorState, IterativeParsingErrorState, IterativeParsingErrorState, IterativeParsingErrorState, - IterativeParsingErrorState - }, - // Single Value (sink state) - { - IterativeParsingErrorState, IterativeParsingErrorState, IterativeParsingErrorState, IterativeParsingErrorState, IterativeParsingErrorState, - IterativeParsingErrorState, IterativeParsingErrorState, IterativeParsingErrorState, IterativeParsingErrorState, IterativeParsingErrorState, - IterativeParsingErrorState - } - }; // End of G - - return static_cast(G[state][token]); - } - - // Make an advance in the token stream and state based on the candidate destination state which was returned by Transit(). - // May return a new state on state pop. - template - RAPIDJSON_FORCEINLINE IterativeParsingState Transit(IterativeParsingState src, Token token, IterativeParsingState dst, InputStream& is, Handler& handler) { - (void)token; - - switch (dst) { - case IterativeParsingErrorState: - return dst; - - case IterativeParsingObjectInitialState: - case IterativeParsingArrayInitialState: - { - // Push the state(Element or MemeberValue) if we are nested in another array or value of member. - // In this way we can get the correct state on ObjectFinish or ArrayFinish by frame pop. - IterativeParsingState n = src; - if (src == IterativeParsingArrayInitialState || src == IterativeParsingElementDelimiterState) - n = IterativeParsingElementState; - else if (src == IterativeParsingKeyValueDelimiterState) - n = IterativeParsingMemberValueState; - // Push current state. - *stack_.template Push(1) = n; - // Initialize and push the member/element count. - *stack_.template Push(1) = 0; - // Call handler - bool hr = (dst == IterativeParsingObjectInitialState) ? handler.StartObject() : handler.StartArray(); - // On handler short circuits the parsing. - if (!hr) { - RAPIDJSON_PARSE_ERROR_NORETURN(kParseErrorTermination, is.Tell()); - return IterativeParsingErrorState; - } - else { - is.Take(); - return dst; - } - } - - case IterativeParsingMemberKeyState: - ParseString(is, handler, true); - if (HasParseError()) - return IterativeParsingErrorState; - else - return dst; - - case IterativeParsingKeyValueDelimiterState: - RAPIDJSON_ASSERT(token == ColonToken); - is.Take(); - return dst; - - case IterativeParsingMemberValueState: - // Must be non-compound value. Or it would be ObjectInitial or ArrayInitial state. - ParseValue(is, handler); - if (HasParseError()) { - return IterativeParsingErrorState; - } - return dst; - - case IterativeParsingElementState: - // Must be non-compound value. Or it would be ObjectInitial or ArrayInitial state. - ParseValue(is, handler); - if (HasParseError()) { - return IterativeParsingErrorState; - } - return dst; - - case IterativeParsingMemberDelimiterState: - case IterativeParsingElementDelimiterState: - is.Take(); - // Update member/element count. - *stack_.template Top() = *stack_.template Top() + 1; - return dst; - - case IterativeParsingObjectFinishState: - { - // Transit from delimiter is only allowed when trailing commas are enabled - if (!(parseFlags & kParseTrailingCommasFlag) && src == IterativeParsingMemberDelimiterState) { - RAPIDJSON_PARSE_ERROR_NORETURN(kParseErrorObjectMissName, is.Tell()); - return IterativeParsingErrorState; - } - // Get member count. - SizeType c = *stack_.template Pop(1); - // If the object is not empty, count the last member. - if (src == IterativeParsingMemberValueState) - ++c; - // Restore the state. - IterativeParsingState n = static_cast(*stack_.template Pop(1)); - // Transit to Finish state if this is the topmost scope. - if (n == IterativeParsingStartState) - n = IterativeParsingFinishState; - // Call handler - bool hr = handler.EndObject(c); - // On handler short circuits the parsing. - if (!hr) { - RAPIDJSON_PARSE_ERROR_NORETURN(kParseErrorTermination, is.Tell()); - return IterativeParsingErrorState; - } - else { - is.Take(); - return n; - } - } - - case IterativeParsingArrayFinishState: - { - // Transit from delimiter is only allowed when trailing commas are enabled - if (!(parseFlags & kParseTrailingCommasFlag) && src == IterativeParsingElementDelimiterState) { - RAPIDJSON_PARSE_ERROR_NORETURN(kParseErrorValueInvalid, is.Tell()); - return IterativeParsingErrorState; - } - // Get element count. - SizeType c = *stack_.template Pop(1); - // If the array is not empty, count the last element. - if (src == IterativeParsingElementState) - ++c; - // Restore the state. - IterativeParsingState n = static_cast(*stack_.template Pop(1)); - // Transit to Finish state if this is the topmost scope. - if (n == IterativeParsingStartState) - n = IterativeParsingFinishState; - // Call handler - bool hr = handler.EndArray(c); - // On handler short circuits the parsing. - if (!hr) { - RAPIDJSON_PARSE_ERROR_NORETURN(kParseErrorTermination, is.Tell()); - return IterativeParsingErrorState; - } - else { - is.Take(); - return n; - } - } - - default: - // This branch is for IterativeParsingValueState actually. - // Use `default:` rather than - // `case IterativeParsingValueState:` is for code coverage. - - // The IterativeParsingStartState is not enumerated in this switch-case. - // It is impossible for that case. And it can be caught by following assertion. - - // The IterativeParsingFinishState is not enumerated in this switch-case either. - // It is a "derivative" state which cannot triggered from Predict() directly. - // Therefore it cannot happen here. And it can be caught by following assertion. - RAPIDJSON_ASSERT(dst == IterativeParsingValueState); - - // Must be non-compound value. Or it would be ObjectInitial or ArrayInitial state. - ParseValue(is, handler); - if (HasParseError()) { - return IterativeParsingErrorState; - } - return IterativeParsingFinishState; - } - } - - template - void HandleError(IterativeParsingState src, InputStream& is) { - if (HasParseError()) { - // Error flag has been set. - return; - } - - switch (src) { - case IterativeParsingStartState: RAPIDJSON_PARSE_ERROR(kParseErrorDocumentEmpty, is.Tell()); return; - case IterativeParsingFinishState: RAPIDJSON_PARSE_ERROR(kParseErrorDocumentRootNotSingular, is.Tell()); return; - case IterativeParsingObjectInitialState: - case IterativeParsingMemberDelimiterState: RAPIDJSON_PARSE_ERROR(kParseErrorObjectMissName, is.Tell()); return; - case IterativeParsingMemberKeyState: RAPIDJSON_PARSE_ERROR(kParseErrorObjectMissColon, is.Tell()); return; - case IterativeParsingMemberValueState: RAPIDJSON_PARSE_ERROR(kParseErrorObjectMissCommaOrCurlyBracket, is.Tell()); return; - case IterativeParsingKeyValueDelimiterState: - case IterativeParsingArrayInitialState: - case IterativeParsingElementDelimiterState: RAPIDJSON_PARSE_ERROR(kParseErrorValueInvalid, is.Tell()); return; - default: RAPIDJSON_ASSERT(src == IterativeParsingElementState); RAPIDJSON_PARSE_ERROR(kParseErrorArrayMissCommaOrSquareBracket, is.Tell()); return; - } - } - - template - ParseResult IterativeParse(InputStream& is, Handler& handler) { - parseResult_.Clear(); - ClearStackOnExit scope(*this); - IterativeParsingState state = IterativeParsingStartState; - - SkipWhitespaceAndComments(is); - RAPIDJSON_PARSE_ERROR_EARLY_RETURN(parseResult_); - while (is.Peek() != '\0') { - Token t = Tokenize(is.Peek()); - IterativeParsingState n = Predict(state, t); - IterativeParsingState d = Transit(state, t, n, is, handler); - - if (d == IterativeParsingErrorState) { - HandleError(state, is); - break; - } - - state = d; - - // Do not further consume streams if a root JSON has been parsed. - if ((parseFlags & kParseStopWhenDoneFlag) && state == IterativeParsingFinishState) - break; - - SkipWhitespaceAndComments(is); - RAPIDJSON_PARSE_ERROR_EARLY_RETURN(parseResult_); - } - - // Handle the end of file. - if (state != IterativeParsingFinishState) - HandleError(state, is); - - return parseResult_; - } - - static const size_t kDefaultStackCapacity = 256; //!< Default stack capacity in bytes for storing a single decoded string. - internal::Stack stack_; //!< A stack for storing decoded string temporarily during non-destructive parsing. - ParseResult parseResult_; -}; // class GenericReader - -//! Reader with UTF8 encoding and default allocator. -typedef GenericReader, UTF8<> > Reader; - -RAPIDJSON_NAMESPACE_END - -#ifdef __clang__ -RAPIDJSON_DIAG_POP -#endif - - -#ifdef __GNUC__ -RAPIDJSON_DIAG_POP -#endif - -#ifdef _MSC_VER -RAPIDJSON_DIAG_POP -#endif - -#endif // RAPIDJSON_READER_H_ diff --git a/slsReceiverSoftware/include/rapidjson/schema.h b/slsReceiverSoftware/include/rapidjson/schema.h deleted file mode 100644 index b182aa27f..000000000 --- a/slsReceiverSoftware/include/rapidjson/schema.h +++ /dev/null @@ -1,2006 +0,0 @@ -// Tencent is pleased to support the open source community by making RapidJSON available-> -// -// Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip-> All rights reserved-> -// -// Licensed under the MIT License (the "License"); you may not use this file except -// in compliance with the License-> You may obtain a copy of the License at -// -// http://opensource->org/licenses/MIT -// -// Unless required by applicable law or agreed to in writing, software distributed -// under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR -// CONDITIONS OF ANY KIND, either express or implied-> See the License for the -// specific language governing permissions and limitations under the License-> - -#ifndef RAPIDJSON_SCHEMA_H_ -#define RAPIDJSON_SCHEMA_H_ - -#include "document.h" -#include "pointer.h" -#include // abs, floor - -#if !defined(RAPIDJSON_SCHEMA_USE_INTERNALREGEX) -#define RAPIDJSON_SCHEMA_USE_INTERNALREGEX 1 -#else -#define RAPIDJSON_SCHEMA_USE_INTERNALREGEX 0 -#endif - -#if !RAPIDJSON_SCHEMA_USE_INTERNALREGEX && !defined(RAPIDJSON_SCHEMA_USE_STDREGEX) && (__cplusplus >=201103L || (defined(_MSC_VER) && _MSC_VER >= 1800)) -#define RAPIDJSON_SCHEMA_USE_STDREGEX 1 -#else -#define RAPIDJSON_SCHEMA_USE_STDREGEX 0 -#endif - -#if RAPIDJSON_SCHEMA_USE_INTERNALREGEX -#include "internal/regex.h" -#elif RAPIDJSON_SCHEMA_USE_STDREGEX -#include -#endif - -#if RAPIDJSON_SCHEMA_USE_INTERNALREGEX || RAPIDJSON_SCHEMA_USE_STDREGEX -#define RAPIDJSON_SCHEMA_HAS_REGEX 1 -#else -#define RAPIDJSON_SCHEMA_HAS_REGEX 0 -#endif - -#ifndef RAPIDJSON_SCHEMA_VERBOSE -#define RAPIDJSON_SCHEMA_VERBOSE 0 -#endif - -#if RAPIDJSON_SCHEMA_VERBOSE -#include "stringbuffer.h" -#endif - -RAPIDJSON_DIAG_PUSH - -#if defined(__GNUC__) -RAPIDJSON_DIAG_OFF(effc++) -#endif - -#ifdef __clang__ -RAPIDJSON_DIAG_OFF(weak-vtables) -RAPIDJSON_DIAG_OFF(exit-time-destructors) -RAPIDJSON_DIAG_OFF(c++98-compat-pedantic) -RAPIDJSON_DIAG_OFF(variadic-macros) -#endif - -#ifdef _MSC_VER -RAPIDJSON_DIAG_OFF(4512) // assignment operator could not be generated -#endif - -RAPIDJSON_NAMESPACE_BEGIN - -/////////////////////////////////////////////////////////////////////////////// -// Verbose Utilities - -#if RAPIDJSON_SCHEMA_VERBOSE - -namespace internal { - -inline void PrintInvalidKeyword(const char* keyword) { - printf("Fail keyword: %s\n", keyword); -} - -inline void PrintInvalidKeyword(const wchar_t* keyword) { - wprintf(L"Fail keyword: %ls\n", keyword); -} - -inline void PrintInvalidDocument(const char* document) { - printf("Fail document: %s\n\n", document); -} - -inline void PrintInvalidDocument(const wchar_t* document) { - wprintf(L"Fail document: %ls\n\n", document); -} - -inline void PrintValidatorPointers(unsigned depth, const char* s, const char* d) { - printf("S: %*s%s\nD: %*s%s\n\n", depth * 4, " ", s, depth * 4, " ", d); -} - -inline void PrintValidatorPointers(unsigned depth, const wchar_t* s, const wchar_t* d) { - wprintf(L"S: %*ls%ls\nD: %*ls%ls\n\n", depth * 4, L" ", s, depth * 4, L" ", d); -} - -} // namespace internal - -#endif // RAPIDJSON_SCHEMA_VERBOSE - -/////////////////////////////////////////////////////////////////////////////// -// RAPIDJSON_INVALID_KEYWORD_RETURN - -#if RAPIDJSON_SCHEMA_VERBOSE -#define RAPIDJSON_INVALID_KEYWORD_VERBOSE(keyword) internal::PrintInvalidKeyword(keyword) -#else -#define RAPIDJSON_INVALID_KEYWORD_VERBOSE(keyword) -#endif - -#define RAPIDJSON_INVALID_KEYWORD_RETURN(keyword)\ -RAPIDJSON_MULTILINEMACRO_BEGIN\ - context.invalidKeyword = keyword.GetString();\ - RAPIDJSON_INVALID_KEYWORD_VERBOSE(keyword.GetString());\ - return false;\ -RAPIDJSON_MULTILINEMACRO_END - -/////////////////////////////////////////////////////////////////////////////// -// Forward declarations - -template -class GenericSchemaDocument; - -namespace internal { - -template -class Schema; - -/////////////////////////////////////////////////////////////////////////////// -// ISchemaValidator - -class ISchemaValidator { -public: - virtual ~ISchemaValidator() {} - virtual bool IsValid() const = 0; -}; - -/////////////////////////////////////////////////////////////////////////////// -// ISchemaStateFactory - -template -class ISchemaStateFactory { -public: - virtual ~ISchemaStateFactory() {} - virtual ISchemaValidator* CreateSchemaValidator(const SchemaType&) = 0; - virtual void DestroySchemaValidator(ISchemaValidator* validator) = 0; - virtual void* CreateHasher() = 0; - virtual uint64_t GetHashCode(void* hasher) = 0; - virtual void DestroryHasher(void* hasher) = 0; - virtual void* MallocState(size_t size) = 0; - virtual void FreeState(void* p) = 0; -}; - -/////////////////////////////////////////////////////////////////////////////// -// Hasher - -// For comparison of compound value -template -class Hasher { -public: - typedef typename Encoding::Ch Ch; - - Hasher(Allocator* allocator = 0, size_t stackCapacity = kDefaultSize) : stack_(allocator, stackCapacity) {} - - bool Null() { return WriteType(kNullType); } - bool Bool(bool b) { return WriteType(b ? kTrueType : kFalseType); } - bool Int(int i) { Number n; n.u.i = i; n.d = static_cast(i); return WriteNumber(n); } - bool Uint(unsigned u) { Number n; n.u.u = u; n.d = static_cast(u); return WriteNumber(n); } - bool Int64(int64_t i) { Number n; n.u.i = i; n.d = static_cast(i); return WriteNumber(n); } - bool Uint64(uint64_t u) { Number n; n.u.u = u; n.d = static_cast(u); return WriteNumber(n); } - bool Double(double d) { - Number n; - if (d < 0) n.u.i = static_cast(d); - else n.u.u = static_cast(d); - n.d = d; - return WriteNumber(n); - } - - bool RawNumber(const Ch* str, SizeType len, bool) { - WriteBuffer(kNumberType, str, len * sizeof(Ch)); - return true; - } - - bool String(const Ch* str, SizeType len, bool) { - WriteBuffer(kStringType, str, len * sizeof(Ch)); - return true; - } - - bool StartObject() { return true; } - bool Key(const Ch* str, SizeType len, bool copy) { return String(str, len, copy); } - bool EndObject(SizeType memberCount) { - uint64_t h = Hash(0, kObjectType); - uint64_t* kv = stack_.template Pop(memberCount * 2); - for (SizeType i = 0; i < memberCount; i++) - h ^= Hash(kv[i * 2], kv[i * 2 + 1]); // Use xor to achieve member order insensitive - *stack_.template Push() = h; - return true; - } - - bool StartArray() { return true; } - bool EndArray(SizeType elementCount) { - uint64_t h = Hash(0, kArrayType); - uint64_t* e = stack_.template Pop(elementCount); - for (SizeType i = 0; i < elementCount; i++) - h = Hash(h, e[i]); // Use hash to achieve element order sensitive - *stack_.template Push() = h; - return true; - } - - bool IsValid() const { return stack_.GetSize() == sizeof(uint64_t); } - - uint64_t GetHashCode() const { - RAPIDJSON_ASSERT(IsValid()); - return *stack_.template Top(); - } - -private: - static const size_t kDefaultSize = 256; - struct Number { - union U { - uint64_t u; - int64_t i; - }u; - double d; - }; - - bool WriteType(Type type) { return WriteBuffer(type, 0, 0); } - - bool WriteNumber(const Number& n) { return WriteBuffer(kNumberType, &n, sizeof(n)); } - - bool WriteBuffer(Type type, const void* data, size_t len) { - // FNV-1a from http://isthe.com/chongo/tech/comp/fnv/ - uint64_t h = Hash(RAPIDJSON_UINT64_C2(0x84222325, 0xcbf29ce4), type); - const unsigned char* d = static_cast(data); - for (size_t i = 0; i < len; i++) - h = Hash(h, d[i]); - *stack_.template Push() = h; - return true; - } - - static uint64_t Hash(uint64_t h, uint64_t d) { - static const uint64_t kPrime = RAPIDJSON_UINT64_C2(0x00000100, 0x000001b3); - h ^= d; - h *= kPrime; - return h; - } - - Stack stack_; -}; - -/////////////////////////////////////////////////////////////////////////////// -// SchemaValidationContext - -template -struct SchemaValidationContext { - typedef Schema SchemaType; - typedef ISchemaStateFactory SchemaValidatorFactoryType; - typedef typename SchemaType::ValueType ValueType; - typedef typename ValueType::Ch Ch; - - enum PatternValidatorType { - kPatternValidatorOnly, - kPatternValidatorWithProperty, - kPatternValidatorWithAdditionalProperty - }; - - SchemaValidationContext(SchemaValidatorFactoryType& f, const SchemaType* s) : - factory(f), - schema(s), - valueSchema(), - invalidKeyword(), - hasher(), - arrayElementHashCodes(), - validators(), - validatorCount(), - patternPropertiesValidators(), - patternPropertiesValidatorCount(), - patternPropertiesSchemas(), - patternPropertiesSchemaCount(), - valuePatternValidatorType(kPatternValidatorOnly), - propertyExist(), - inArray(false), - valueUniqueness(false), - arrayUniqueness(false) - { - } - - ~SchemaValidationContext() { - if (hasher) - factory.DestroryHasher(hasher); - if (validators) { - for (SizeType i = 0; i < validatorCount; i++) - factory.DestroySchemaValidator(validators[i]); - factory.FreeState(validators); - } - if (patternPropertiesValidators) { - for (SizeType i = 0; i < patternPropertiesValidatorCount; i++) - factory.DestroySchemaValidator(patternPropertiesValidators[i]); - factory.FreeState(patternPropertiesValidators); - } - if (patternPropertiesSchemas) - factory.FreeState(patternPropertiesSchemas); - if (propertyExist) - factory.FreeState(propertyExist); - } - - SchemaValidatorFactoryType& factory; - const SchemaType* schema; - const SchemaType* valueSchema; - const Ch* invalidKeyword; - void* hasher; // Only validator access - void* arrayElementHashCodes; // Only validator access this - ISchemaValidator** validators; - SizeType validatorCount; - ISchemaValidator** patternPropertiesValidators; - SizeType patternPropertiesValidatorCount; - const SchemaType** patternPropertiesSchemas; - SizeType patternPropertiesSchemaCount; - PatternValidatorType valuePatternValidatorType; - PatternValidatorType objectPatternValidatorType; - SizeType arrayElementIndex; - bool* propertyExist; - bool inArray; - bool valueUniqueness; - bool arrayUniqueness; -}; - -/////////////////////////////////////////////////////////////////////////////// -// Schema - -template -class Schema { -public: - typedef typename SchemaDocumentType::ValueType ValueType; - typedef typename SchemaDocumentType::AllocatorType AllocatorType; - typedef typename SchemaDocumentType::PointerType PointerType; - typedef typename ValueType::EncodingType EncodingType; - typedef typename EncodingType::Ch Ch; - typedef SchemaValidationContext Context; - typedef Schema SchemaType; - typedef GenericValue SValue; - friend class GenericSchemaDocument; - - Schema(SchemaDocumentType* schemaDocument, const PointerType& p, const ValueType& value, const ValueType& document, AllocatorType* allocator) : - allocator_(allocator), - enum_(), - enumCount_(), - not_(), - type_((1 << kTotalSchemaType) - 1), // typeless - validatorCount_(), - properties_(), - additionalPropertiesSchema_(), - patternProperties_(), - patternPropertyCount_(), - propertyCount_(), - minProperties_(), - maxProperties_(SizeType(~0)), - additionalProperties_(true), - hasDependencies_(), - hasRequired_(), - hasSchemaDependencies_(), - additionalItemsSchema_(), - itemsList_(), - itemsTuple_(), - itemsTupleCount_(), - minItems_(), - maxItems_(SizeType(~0)), - additionalItems_(true), - uniqueItems_(false), - pattern_(), - minLength_(0), - maxLength_(~SizeType(0)), - exclusiveMinimum_(false), - exclusiveMaximum_(false) - { - typedef typename SchemaDocumentType::ValueType ValueType; - typedef typename ValueType::ConstValueIterator ConstValueIterator; - typedef typename ValueType::ConstMemberIterator ConstMemberIterator; - - if (!value.IsObject()) - return; - - if (const ValueType* v = GetMember(value, GetTypeString())) { - type_ = 0; - if (v->IsString()) - AddType(*v); - else if (v->IsArray()) - for (ConstValueIterator itr = v->Begin(); itr != v->End(); ++itr) - AddType(*itr); - } - - if (const ValueType* v = GetMember(value, GetEnumString())) - if (v->IsArray() && v->Size() > 0) { - enum_ = static_cast(allocator_->Malloc(sizeof(uint64_t) * v->Size())); - for (ConstValueIterator itr = v->Begin(); itr != v->End(); ++itr) { - typedef Hasher > EnumHasherType; - char buffer[256 + 24]; - MemoryPoolAllocator<> hasherAllocator(buffer, sizeof(buffer)); - EnumHasherType h(&hasherAllocator, 256); - itr->Accept(h); - enum_[enumCount_++] = h.GetHashCode(); - } - } - - if (schemaDocument) { - AssignIfExist(allOf_, *schemaDocument, p, value, GetAllOfString(), document); - AssignIfExist(anyOf_, *schemaDocument, p, value, GetAnyOfString(), document); - AssignIfExist(oneOf_, *schemaDocument, p, value, GetOneOfString(), document); - } - - if (const ValueType* v = GetMember(value, GetNotString())) { - schemaDocument->CreateSchema(¬_, p.Append(GetNotString(), allocator_), *v, document); - notValidatorIndex_ = validatorCount_; - validatorCount_++; - } - - // Object - - const ValueType* properties = GetMember(value, GetPropertiesString()); - const ValueType* required = GetMember(value, GetRequiredString()); - const ValueType* dependencies = GetMember(value, GetDependenciesString()); - { - // Gather properties from properties/required/dependencies - SValue allProperties(kArrayType); - - if (properties && properties->IsObject()) - for (ConstMemberIterator itr = properties->MemberBegin(); itr != properties->MemberEnd(); ++itr) - AddUniqueElement(allProperties, itr->name); - - if (required && required->IsArray()) - for (ConstValueIterator itr = required->Begin(); itr != required->End(); ++itr) - if (itr->IsString()) - AddUniqueElement(allProperties, *itr); - - if (dependencies && dependencies->IsObject()) - for (ConstMemberIterator itr = dependencies->MemberBegin(); itr != dependencies->MemberEnd(); ++itr) { - AddUniqueElement(allProperties, itr->name); - if (itr->value.IsArray()) - for (ConstValueIterator i = itr->value.Begin(); i != itr->value.End(); ++i) - if (i->IsString()) - AddUniqueElement(allProperties, *i); - } - - if (allProperties.Size() > 0) { - propertyCount_ = allProperties.Size(); - properties_ = static_cast(allocator_->Malloc(sizeof(Property) * propertyCount_)); - for (SizeType i = 0; i < propertyCount_; i++) { - new (&properties_[i]) Property(); - properties_[i].name = allProperties[i]; - properties_[i].schema = GetTypeless(); - } - } - } - - if (properties && properties->IsObject()) { - PointerType q = p.Append(GetPropertiesString(), allocator_); - for (ConstMemberIterator itr = properties->MemberBegin(); itr != properties->MemberEnd(); ++itr) { - SizeType index; - if (FindPropertyIndex(itr->name, &index)) - schemaDocument->CreateSchema(&properties_[index].schema, q.Append(itr->name, allocator_), itr->value, document); - } - } - - if (const ValueType* v = GetMember(value, GetPatternPropertiesString())) { - PointerType q = p.Append(GetPatternPropertiesString(), allocator_); - patternProperties_ = static_cast(allocator_->Malloc(sizeof(PatternProperty) * v->MemberCount())); - patternPropertyCount_ = 0; - - for (ConstMemberIterator itr = v->MemberBegin(); itr != v->MemberEnd(); ++itr) { - new (&patternProperties_[patternPropertyCount_]) PatternProperty(); - patternProperties_[patternPropertyCount_].pattern = CreatePattern(itr->name); - schemaDocument->CreateSchema(&patternProperties_[patternPropertyCount_].schema, q.Append(itr->name, allocator_), itr->value, document); - patternPropertyCount_++; - } - } - - if (required && required->IsArray()) - for (ConstValueIterator itr = required->Begin(); itr != required->End(); ++itr) - if (itr->IsString()) { - SizeType index; - if (FindPropertyIndex(*itr, &index)) { - properties_[index].required = true; - hasRequired_ = true; - } - } - - if (dependencies && dependencies->IsObject()) { - PointerType q = p.Append(GetDependenciesString(), allocator_); - hasDependencies_ = true; - for (ConstMemberIterator itr = dependencies->MemberBegin(); itr != dependencies->MemberEnd(); ++itr) { - SizeType sourceIndex; - if (FindPropertyIndex(itr->name, &sourceIndex)) { - if (itr->value.IsArray()) { - properties_[sourceIndex].dependencies = static_cast(allocator_->Malloc(sizeof(bool) * propertyCount_)); - std::memset(properties_[sourceIndex].dependencies, 0, sizeof(bool)* propertyCount_); - for (ConstValueIterator targetItr = itr->value.Begin(); targetItr != itr->value.End(); ++targetItr) { - SizeType targetIndex; - if (FindPropertyIndex(*targetItr, &targetIndex)) - properties_[sourceIndex].dependencies[targetIndex] = true; - } - } - else if (itr->value.IsObject()) { - hasSchemaDependencies_ = true; - schemaDocument->CreateSchema(&properties_[sourceIndex].dependenciesSchema, q.Append(itr->name, allocator_), itr->value, document); - properties_[sourceIndex].dependenciesValidatorIndex = validatorCount_; - validatorCount_++; - } - } - } - } - - if (const ValueType* v = GetMember(value, GetAdditionalPropertiesString())) { - if (v->IsBool()) - additionalProperties_ = v->GetBool(); - else if (v->IsObject()) - schemaDocument->CreateSchema(&additionalPropertiesSchema_, p.Append(GetAdditionalPropertiesString(), allocator_), *v, document); - } - - AssignIfExist(minProperties_, value, GetMinPropertiesString()); - AssignIfExist(maxProperties_, value, GetMaxPropertiesString()); - - // Array - if (const ValueType* v = GetMember(value, GetItemsString())) { - PointerType q = p.Append(GetItemsString(), allocator_); - if (v->IsObject()) // List validation - schemaDocument->CreateSchema(&itemsList_, q, *v, document); - else if (v->IsArray()) { // Tuple validation - itemsTuple_ = static_cast(allocator_->Malloc(sizeof(const Schema*) * v->Size())); - SizeType index = 0; - for (ConstValueIterator itr = v->Begin(); itr != v->End(); ++itr, index++) - schemaDocument->CreateSchema(&itemsTuple_[itemsTupleCount_++], q.Append(index, allocator_), *itr, document); - } - } - - AssignIfExist(minItems_, value, GetMinItemsString()); - AssignIfExist(maxItems_, value, GetMaxItemsString()); - - if (const ValueType* v = GetMember(value, GetAdditionalItemsString())) { - if (v->IsBool()) - additionalItems_ = v->GetBool(); - else if (v->IsObject()) - schemaDocument->CreateSchema(&additionalItemsSchema_, p.Append(GetAdditionalItemsString(), allocator_), *v, document); - } - - AssignIfExist(uniqueItems_, value, GetUniqueItemsString()); - - // String - AssignIfExist(minLength_, value, GetMinLengthString()); - AssignIfExist(maxLength_, value, GetMaxLengthString()); - - if (const ValueType* v = GetMember(value, GetPatternString())) - pattern_ = CreatePattern(*v); - - // Number - if (const ValueType* v = GetMember(value, GetMinimumString())) - if (v->IsNumber()) - minimum_.CopyFrom(*v, *allocator_); - - if (const ValueType* v = GetMember(value, GetMaximumString())) - if (v->IsNumber()) - maximum_.CopyFrom(*v, *allocator_); - - AssignIfExist(exclusiveMinimum_, value, GetExclusiveMinimumString()); - AssignIfExist(exclusiveMaximum_, value, GetExclusiveMaximumString()); - - if (const ValueType* v = GetMember(value, GetMultipleOfString())) - if (v->IsNumber() && v->GetDouble() > 0.0) - multipleOf_.CopyFrom(*v, *allocator_); - } - - ~Schema() { - if (allocator_) { - allocator_->Free(enum_); - } - if (properties_) { - for (SizeType i = 0; i < propertyCount_; i++) - properties_[i].~Property(); - AllocatorType::Free(properties_); - } - if (patternProperties_) { - for (SizeType i = 0; i < patternPropertyCount_; i++) - patternProperties_[i].~PatternProperty(); - AllocatorType::Free(patternProperties_); - } - AllocatorType::Free(itemsTuple_); -#if RAPIDJSON_SCHEMA_HAS_REGEX - if (pattern_) { - pattern_->~RegexType(); - allocator_->Free(pattern_); - } -#endif - } - - bool BeginValue(Context& context) const { - if (context.inArray) { - if (uniqueItems_) - context.valueUniqueness = true; - - if (itemsList_) - context.valueSchema = itemsList_; - else if (itemsTuple_) { - if (context.arrayElementIndex < itemsTupleCount_) - context.valueSchema = itemsTuple_[context.arrayElementIndex]; - else if (additionalItemsSchema_) - context.valueSchema = additionalItemsSchema_; - else if (additionalItems_) - context.valueSchema = GetTypeless(); - else - RAPIDJSON_INVALID_KEYWORD_RETURN(GetItemsString()); - } - else - context.valueSchema = GetTypeless(); - - context.arrayElementIndex++; - } - return true; - } - - RAPIDJSON_FORCEINLINE bool EndValue(Context& context) const { - if (context.patternPropertiesValidatorCount > 0) { - bool otherValid = false; - SizeType count = context.patternPropertiesValidatorCount; - if (context.objectPatternValidatorType != Context::kPatternValidatorOnly) - otherValid = context.patternPropertiesValidators[--count]->IsValid(); - - bool patternValid = true; - for (SizeType i = 0; i < count; i++) - if (!context.patternPropertiesValidators[i]->IsValid()) { - patternValid = false; - break; - } - - if (context.objectPatternValidatorType == Context::kPatternValidatorOnly) { - if (!patternValid) - RAPIDJSON_INVALID_KEYWORD_RETURN(GetPatternPropertiesString()); - } - else if (context.objectPatternValidatorType == Context::kPatternValidatorWithProperty) { - if (!patternValid || !otherValid) - RAPIDJSON_INVALID_KEYWORD_RETURN(GetPatternPropertiesString()); - } - else if (!patternValid && !otherValid) // kPatternValidatorWithAdditionalProperty) - RAPIDJSON_INVALID_KEYWORD_RETURN(GetPatternPropertiesString()); - } - - if (enum_) { - const uint64_t h = context.factory.GetHashCode(context.hasher); - for (SizeType i = 0; i < enumCount_; i++) - if (enum_[i] == h) - goto foundEnum; - RAPIDJSON_INVALID_KEYWORD_RETURN(GetEnumString()); - foundEnum:; - } - - if (allOf_.schemas) - for (SizeType i = allOf_.begin; i < allOf_.begin + allOf_.count; i++) - if (!context.validators[i]->IsValid()) - RAPIDJSON_INVALID_KEYWORD_RETURN(GetAllOfString()); - - if (anyOf_.schemas) { - for (SizeType i = anyOf_.begin; i < anyOf_.begin + anyOf_.count; i++) - if (context.validators[i]->IsValid()) - goto foundAny; - RAPIDJSON_INVALID_KEYWORD_RETURN(GetAnyOfString()); - foundAny:; - } - - if (oneOf_.schemas) { - bool oneValid = false; - for (SizeType i = oneOf_.begin; i < oneOf_.begin + oneOf_.count; i++) - if (context.validators[i]->IsValid()) { - if (oneValid) - RAPIDJSON_INVALID_KEYWORD_RETURN(GetOneOfString()); - else - oneValid = true; - } - if (!oneValid) - RAPIDJSON_INVALID_KEYWORD_RETURN(GetOneOfString()); - } - - if (not_ && context.validators[notValidatorIndex_]->IsValid()) - RAPIDJSON_INVALID_KEYWORD_RETURN(GetNotString()); - - return true; - } - - bool Null(Context& context) const { - if (!(type_ & (1 << kNullSchemaType))) - RAPIDJSON_INVALID_KEYWORD_RETURN(GetTypeString()); - return CreateParallelValidator(context); - } - - bool Bool(Context& context, bool) const { - if (!(type_ & (1 << kBooleanSchemaType))) - RAPIDJSON_INVALID_KEYWORD_RETURN(GetTypeString()); - return CreateParallelValidator(context); - } - - bool Int(Context& context, int i) const { - if (!CheckInt(context, i)) - return false; - return CreateParallelValidator(context); - } - - bool Uint(Context& context, unsigned u) const { - if (!CheckUint(context, u)) - return false; - return CreateParallelValidator(context); - } - - bool Int64(Context& context, int64_t i) const { - if (!CheckInt(context, i)) - return false; - return CreateParallelValidator(context); - } - - bool Uint64(Context& context, uint64_t u) const { - if (!CheckUint(context, u)) - return false; - return CreateParallelValidator(context); - } - - bool Double(Context& context, double d) const { - if (!(type_ & (1 << kNumberSchemaType))) - RAPIDJSON_INVALID_KEYWORD_RETURN(GetTypeString()); - - if (!minimum_.IsNull() && !CheckDoubleMinimum(context, d)) - return false; - - if (!maximum_.IsNull() && !CheckDoubleMaximum(context, d)) - return false; - - if (!multipleOf_.IsNull() && !CheckDoubleMultipleOf(context, d)) - return false; - - return CreateParallelValidator(context); - } - - bool String(Context& context, const Ch* str, SizeType length, bool) const { - if (!(type_ & (1 << kStringSchemaType))) - RAPIDJSON_INVALID_KEYWORD_RETURN(GetTypeString()); - - if (minLength_ != 0 || maxLength_ != SizeType(~0)) { - SizeType count; - if (internal::CountStringCodePoint(str, length, &count)) { - if (count < minLength_) - RAPIDJSON_INVALID_KEYWORD_RETURN(GetMinLengthString()); - if (count > maxLength_) - RAPIDJSON_INVALID_KEYWORD_RETURN(GetMaxLengthString()); - } - } - - if (pattern_ && !IsPatternMatch(pattern_, str, length)) - RAPIDJSON_INVALID_KEYWORD_RETURN(GetPatternString()); - - return CreateParallelValidator(context); - } - - bool StartObject(Context& context) const { - if (!(type_ & (1 << kObjectSchemaType))) - RAPIDJSON_INVALID_KEYWORD_RETURN(GetTypeString()); - - if (hasDependencies_ || hasRequired_) { - context.propertyExist = static_cast(context.factory.MallocState(sizeof(bool) * propertyCount_)); - std::memset(context.propertyExist, 0, sizeof(bool) * propertyCount_); - } - - if (patternProperties_) { // pre-allocate schema array - SizeType count = patternPropertyCount_ + 1; // extra for valuePatternValidatorType - context.patternPropertiesSchemas = static_cast(context.factory.MallocState(sizeof(const SchemaType*) * count)); - context.patternPropertiesSchemaCount = 0; - std::memset(context.patternPropertiesSchemas, 0, sizeof(SchemaType*) * count); - } - - return CreateParallelValidator(context); - } - - bool Key(Context& context, const Ch* str, SizeType len, bool) const { - if (patternProperties_) { - context.patternPropertiesSchemaCount = 0; - for (SizeType i = 0; i < patternPropertyCount_; i++) - if (patternProperties_[i].pattern && IsPatternMatch(patternProperties_[i].pattern, str, len)) - context.patternPropertiesSchemas[context.patternPropertiesSchemaCount++] = patternProperties_[i].schema; - } - - SizeType index; - if (FindPropertyIndex(ValueType(str, len).Move(), &index)) { - if (context.patternPropertiesSchemaCount > 0) { - context.patternPropertiesSchemas[context.patternPropertiesSchemaCount++] = properties_[index].schema; - context.valueSchema = GetTypeless(); - context.valuePatternValidatorType = Context::kPatternValidatorWithProperty; - } - else - context.valueSchema = properties_[index].schema; - - if (context.propertyExist) - context.propertyExist[index] = true; - - return true; - } - - if (additionalPropertiesSchema_) { - if (additionalPropertiesSchema_ && context.patternPropertiesSchemaCount > 0) { - context.patternPropertiesSchemas[context.patternPropertiesSchemaCount++] = additionalPropertiesSchema_; - context.valueSchema = GetTypeless(); - context.valuePatternValidatorType = Context::kPatternValidatorWithAdditionalProperty; - } - else - context.valueSchema = additionalPropertiesSchema_; - return true; - } - else if (additionalProperties_) { - context.valueSchema = GetTypeless(); - return true; - } - - if (context.patternPropertiesSchemaCount == 0) // patternProperties are not additional properties - RAPIDJSON_INVALID_KEYWORD_RETURN(GetAdditionalPropertiesString()); - - return true; - } - - bool EndObject(Context& context, SizeType memberCount) const { - if (hasRequired_) - for (SizeType index = 0; index < propertyCount_; index++) - if (properties_[index].required) - if (!context.propertyExist[index]) - RAPIDJSON_INVALID_KEYWORD_RETURN(GetRequiredString()); - - if (memberCount < minProperties_) - RAPIDJSON_INVALID_KEYWORD_RETURN(GetMinPropertiesString()); - - if (memberCount > maxProperties_) - RAPIDJSON_INVALID_KEYWORD_RETURN(GetMaxPropertiesString()); - - if (hasDependencies_) { - for (SizeType sourceIndex = 0; sourceIndex < propertyCount_; sourceIndex++) - if (context.propertyExist[sourceIndex]) { - if (properties_[sourceIndex].dependencies) { - for (SizeType targetIndex = 0; targetIndex < propertyCount_; targetIndex++) - if (properties_[sourceIndex].dependencies[targetIndex] && !context.propertyExist[targetIndex]) - RAPIDJSON_INVALID_KEYWORD_RETURN(GetDependenciesString()); - } - else if (properties_[sourceIndex].dependenciesSchema) - if (!context.validators[properties_[sourceIndex].dependenciesValidatorIndex]->IsValid()) - RAPIDJSON_INVALID_KEYWORD_RETURN(GetDependenciesString()); - } - } - - return true; - } - - bool StartArray(Context& context) const { - if (!(type_ & (1 << kArraySchemaType))) - RAPIDJSON_INVALID_KEYWORD_RETURN(GetTypeString()); - - context.arrayElementIndex = 0; - context.inArray = true; - - return CreateParallelValidator(context); - } - - bool EndArray(Context& context, SizeType elementCount) const { - context.inArray = false; - - if (elementCount < minItems_) - RAPIDJSON_INVALID_KEYWORD_RETURN(GetMinItemsString()); - - if (elementCount > maxItems_) - RAPIDJSON_INVALID_KEYWORD_RETURN(GetMaxItemsString()); - - return true; - } - - // Generate functions for string literal according to Ch -#define RAPIDJSON_STRING_(name, ...) \ - static const ValueType& Get##name##String() {\ - static const Ch s[] = { __VA_ARGS__, '\0' };\ - static const ValueType v(s, sizeof(s) / sizeof(Ch) - 1);\ - return v;\ - } - - RAPIDJSON_STRING_(Null, 'n', 'u', 'l', 'l') - RAPIDJSON_STRING_(Boolean, 'b', 'o', 'o', 'l', 'e', 'a', 'n') - RAPIDJSON_STRING_(Object, 'o', 'b', 'j', 'e', 'c', 't') - RAPIDJSON_STRING_(Array, 'a', 'r', 'r', 'a', 'y') - RAPIDJSON_STRING_(String, 's', 't', 'r', 'i', 'n', 'g') - RAPIDJSON_STRING_(Number, 'n', 'u', 'm', 'b', 'e', 'r') - RAPIDJSON_STRING_(Integer, 'i', 'n', 't', 'e', 'g', 'e', 'r') - RAPIDJSON_STRING_(Type, 't', 'y', 'p', 'e') - RAPIDJSON_STRING_(Enum, 'e', 'n', 'u', 'm') - RAPIDJSON_STRING_(AllOf, 'a', 'l', 'l', 'O', 'f') - RAPIDJSON_STRING_(AnyOf, 'a', 'n', 'y', 'O', 'f') - RAPIDJSON_STRING_(OneOf, 'o', 'n', 'e', 'O', 'f') - RAPIDJSON_STRING_(Not, 'n', 'o', 't') - RAPIDJSON_STRING_(Properties, 'p', 'r', 'o', 'p', 'e', 'r', 't', 'i', 'e', 's') - RAPIDJSON_STRING_(Required, 'r', 'e', 'q', 'u', 'i', 'r', 'e', 'd') - RAPIDJSON_STRING_(Dependencies, 'd', 'e', 'p', 'e', 'n', 'd', 'e', 'n', 'c', 'i', 'e', 's') - RAPIDJSON_STRING_(PatternProperties, 'p', 'a', 't', 't', 'e', 'r', 'n', 'P', 'r', 'o', 'p', 'e', 'r', 't', 'i', 'e', 's') - RAPIDJSON_STRING_(AdditionalProperties, 'a', 'd', 'd', 'i', 't', 'i', 'o', 'n', 'a', 'l', 'P', 'r', 'o', 'p', 'e', 'r', 't', 'i', 'e', 's') - RAPIDJSON_STRING_(MinProperties, 'm', 'i', 'n', 'P', 'r', 'o', 'p', 'e', 'r', 't', 'i', 'e', 's') - RAPIDJSON_STRING_(MaxProperties, 'm', 'a', 'x', 'P', 'r', 'o', 'p', 'e', 'r', 't', 'i', 'e', 's') - RAPIDJSON_STRING_(Items, 'i', 't', 'e', 'm', 's') - RAPIDJSON_STRING_(MinItems, 'm', 'i', 'n', 'I', 't', 'e', 'm', 's') - RAPIDJSON_STRING_(MaxItems, 'm', 'a', 'x', 'I', 't', 'e', 'm', 's') - RAPIDJSON_STRING_(AdditionalItems, 'a', 'd', 'd', 'i', 't', 'i', 'o', 'n', 'a', 'l', 'I', 't', 'e', 'm', 's') - RAPIDJSON_STRING_(UniqueItems, 'u', 'n', 'i', 'q', 'u', 'e', 'I', 't', 'e', 'm', 's') - RAPIDJSON_STRING_(MinLength, 'm', 'i', 'n', 'L', 'e', 'n', 'g', 't', 'h') - RAPIDJSON_STRING_(MaxLength, 'm', 'a', 'x', 'L', 'e', 'n', 'g', 't', 'h') - RAPIDJSON_STRING_(Pattern, 'p', 'a', 't', 't', 'e', 'r', 'n') - RAPIDJSON_STRING_(Minimum, 'm', 'i', 'n', 'i', 'm', 'u', 'm') - RAPIDJSON_STRING_(Maximum, 'm', 'a', 'x', 'i', 'm', 'u', 'm') - RAPIDJSON_STRING_(ExclusiveMinimum, 'e', 'x', 'c', 'l', 'u', 's', 'i', 'v', 'e', 'M', 'i', 'n', 'i', 'm', 'u', 'm') - RAPIDJSON_STRING_(ExclusiveMaximum, 'e', 'x', 'c', 'l', 'u', 's', 'i', 'v', 'e', 'M', 'a', 'x', 'i', 'm', 'u', 'm') - RAPIDJSON_STRING_(MultipleOf, 'm', 'u', 'l', 't', 'i', 'p', 'l', 'e', 'O', 'f') - -#undef RAPIDJSON_STRING_ - -private: - enum SchemaValueType { - kNullSchemaType, - kBooleanSchemaType, - kObjectSchemaType, - kArraySchemaType, - kStringSchemaType, - kNumberSchemaType, - kIntegerSchemaType, - kTotalSchemaType - }; - -#if RAPIDJSON_SCHEMA_USE_INTERNALREGEX - typedef internal::GenericRegex RegexType; -#elif RAPIDJSON_SCHEMA_USE_STDREGEX - typedef std::basic_regex RegexType; -#else - typedef char RegexType; -#endif - - struct SchemaArray { - SchemaArray() : schemas(), count() {} - ~SchemaArray() { AllocatorType::Free(schemas); } - const SchemaType** schemas; - SizeType begin; // begin index of context.validators - SizeType count; - }; - - static const SchemaType* GetTypeless() { - static SchemaType typeless(0, PointerType(), ValueType(kObjectType).Move(), ValueType(kObjectType).Move(), 0); - return &typeless; - } - - template - void AddUniqueElement(V1& a, const V2& v) { - for (typename V1::ConstValueIterator itr = a.Begin(); itr != a.End(); ++itr) - if (*itr == v) - return; - V1 c(v, *allocator_); - a.PushBack(c, *allocator_); - } - - static const ValueType* GetMember(const ValueType& value, const ValueType& name) { - typename ValueType::ConstMemberIterator itr = value.FindMember(name); - return itr != value.MemberEnd() ? &(itr->value) : 0; - } - - static void AssignIfExist(bool& out, const ValueType& value, const ValueType& name) { - if (const ValueType* v = GetMember(value, name)) - if (v->IsBool()) - out = v->GetBool(); - } - - static void AssignIfExist(SizeType& out, const ValueType& value, const ValueType& name) { - if (const ValueType* v = GetMember(value, name)) - if (v->IsUint64() && v->GetUint64() <= SizeType(~0)) - out = static_cast(v->GetUint64()); - } - - void AssignIfExist(SchemaArray& out, SchemaDocumentType& schemaDocument, const PointerType& p, const ValueType& value, const ValueType& name, const ValueType& document) { - if (const ValueType* v = GetMember(value, name)) { - if (v->IsArray() && v->Size() > 0) { - PointerType q = p.Append(name, allocator_); - out.count = v->Size(); - out.schemas = static_cast(allocator_->Malloc(out.count * sizeof(const Schema*))); - memset(out.schemas, 0, sizeof(Schema*)* out.count); - for (SizeType i = 0; i < out.count; i++) - schemaDocument.CreateSchema(&out.schemas[i], q.Append(i, allocator_), (*v)[i], document); - out.begin = validatorCount_; - validatorCount_ += out.count; - } - } - } - -#if RAPIDJSON_SCHEMA_USE_INTERNALREGEX - template - RegexType* CreatePattern(const ValueType& value) { - if (value.IsString()) { - RegexType* r = new (allocator_->Malloc(sizeof(RegexType))) RegexType(value.GetString()); - if (!r->IsValid()) { - r->~RegexType(); - AllocatorType::Free(r); - r = 0; - } - return r; - } - return 0; - } - - static bool IsPatternMatch(const RegexType* pattern, const Ch *str, SizeType) { - return pattern->Search(str); - } -#elif RAPIDJSON_SCHEMA_USE_STDREGEX - template - RegexType* CreatePattern(const ValueType& value) { - if (value.IsString()) - try { - return new (allocator_->Malloc(sizeof(RegexType))) RegexType(value.GetString(), std::size_t(value.GetStringLength()), std::regex_constants::ECMAScript); - } - catch (const std::regex_error&) { - } - return 0; - } - - static bool IsPatternMatch(const RegexType* pattern, const Ch *str, SizeType length) { - std::match_results r; - return std::regex_search(str, str + length, r, *pattern); - } -#else - template - RegexType* CreatePattern(const ValueType&) { return 0; } - - static bool IsPatternMatch(const RegexType*, const Ch *, SizeType) { return true; } -#endif // RAPIDJSON_SCHEMA_USE_STDREGEX - - void AddType(const ValueType& type) { - if (type == GetNullString() ) type_ |= 1 << kNullSchemaType; - else if (type == GetBooleanString()) type_ |= 1 << kBooleanSchemaType; - else if (type == GetObjectString() ) type_ |= 1 << kObjectSchemaType; - else if (type == GetArrayString() ) type_ |= 1 << kArraySchemaType; - else if (type == GetStringString() ) type_ |= 1 << kStringSchemaType; - else if (type == GetIntegerString()) type_ |= 1 << kIntegerSchemaType; - else if (type == GetNumberString() ) type_ |= (1 << kNumberSchemaType) | (1 << kIntegerSchemaType); - } - - bool CreateParallelValidator(Context& context) const { - if (enum_ || context.arrayUniqueness) - context.hasher = context.factory.CreateHasher(); - - if (validatorCount_) { - RAPIDJSON_ASSERT(context.validators == 0); - context.validators = static_cast(context.factory.MallocState(sizeof(ISchemaValidator*) * validatorCount_)); - context.validatorCount = validatorCount_; - - if (allOf_.schemas) - CreateSchemaValidators(context, allOf_); - - if (anyOf_.schemas) - CreateSchemaValidators(context, anyOf_); - - if (oneOf_.schemas) - CreateSchemaValidators(context, oneOf_); - - if (not_) - context.validators[notValidatorIndex_] = context.factory.CreateSchemaValidator(*not_); - - if (hasSchemaDependencies_) { - for (SizeType i = 0; i < propertyCount_; i++) - if (properties_[i].dependenciesSchema) - context.validators[properties_[i].dependenciesValidatorIndex] = context.factory.CreateSchemaValidator(*properties_[i].dependenciesSchema); - } - } - - return true; - } - - void CreateSchemaValidators(Context& context, const SchemaArray& schemas) const { - for (SizeType i = 0; i < schemas.count; i++) - context.validators[schemas.begin + i] = context.factory.CreateSchemaValidator(*schemas.schemas[i]); - } - - // O(n) - bool FindPropertyIndex(const ValueType& name, SizeType* outIndex) const { - SizeType len = name.GetStringLength(); - const Ch* str = name.GetString(); - for (SizeType index = 0; index < propertyCount_; index++) - if (properties_[index].name.GetStringLength() == len && - (std::memcmp(properties_[index].name.GetString(), str, sizeof(Ch) * len) == 0)) - { - *outIndex = index; - return true; - } - return false; - } - - bool CheckInt(Context& context, int64_t i) const { - if (!(type_ & ((1 << kIntegerSchemaType) | (1 << kNumberSchemaType)))) - RAPIDJSON_INVALID_KEYWORD_RETURN(GetTypeString()); - - if (!minimum_.IsNull()) { - if (minimum_.IsInt64()) { - if (exclusiveMinimum_ ? i <= minimum_.GetInt64() : i < minimum_.GetInt64()) - RAPIDJSON_INVALID_KEYWORD_RETURN(GetMinimumString()); - } - else if (minimum_.IsUint64()) { - RAPIDJSON_INVALID_KEYWORD_RETURN(GetMinimumString()); // i <= max(int64_t) < minimum.GetUint64() - } - else if (!CheckDoubleMinimum(context, static_cast(i))) - return false; - } - - if (!maximum_.IsNull()) { - if (maximum_.IsInt64()) { - if (exclusiveMaximum_ ? i >= maximum_.GetInt64() : i > maximum_.GetInt64()) - RAPIDJSON_INVALID_KEYWORD_RETURN(GetMaximumString()); - } - else if (maximum_.IsUint64()) - /* do nothing */; // i <= max(int64_t) < maximum_.GetUint64() - else if (!CheckDoubleMaximum(context, static_cast(i))) - return false; - } - - if (!multipleOf_.IsNull()) { - if (multipleOf_.IsUint64()) { - if (static_cast(i >= 0 ? i : -i) % multipleOf_.GetUint64() != 0) - RAPIDJSON_INVALID_KEYWORD_RETURN(GetMultipleOfString()); - } - else if (!CheckDoubleMultipleOf(context, static_cast(i))) - return false; - } - - return true; - } - - bool CheckUint(Context& context, uint64_t i) const { - if (!(type_ & ((1 << kIntegerSchemaType) | (1 << kNumberSchemaType)))) - RAPIDJSON_INVALID_KEYWORD_RETURN(GetTypeString()); - - if (!minimum_.IsNull()) { - if (minimum_.IsUint64()) { - if (exclusiveMinimum_ ? i <= minimum_.GetUint64() : i < minimum_.GetUint64()) - RAPIDJSON_INVALID_KEYWORD_RETURN(GetMinimumString()); - } - else if (minimum_.IsInt64()) - /* do nothing */; // i >= 0 > minimum.Getint64() - else if (!CheckDoubleMinimum(context, static_cast(i))) - return false; - } - - if (!maximum_.IsNull()) { - if (maximum_.IsUint64()) { - if (exclusiveMaximum_ ? i >= maximum_.GetUint64() : i > maximum_.GetUint64()) - RAPIDJSON_INVALID_KEYWORD_RETURN(GetMaximumString()); - } - else if (maximum_.IsInt64()) - RAPIDJSON_INVALID_KEYWORD_RETURN(GetMaximumString()); // i >= 0 > maximum_ - else if (!CheckDoubleMaximum(context, static_cast(i))) - return false; - } - - if (!multipleOf_.IsNull()) { - if (multipleOf_.IsUint64()) { - if (i % multipleOf_.GetUint64() != 0) - RAPIDJSON_INVALID_KEYWORD_RETURN(GetMultipleOfString()); - } - else if (!CheckDoubleMultipleOf(context, static_cast(i))) - return false; - } - - return true; - } - - bool CheckDoubleMinimum(Context& context, double d) const { - if (exclusiveMinimum_ ? d <= minimum_.GetDouble() : d < minimum_.GetDouble()) - RAPIDJSON_INVALID_KEYWORD_RETURN(GetMinimumString()); - return true; - } - - bool CheckDoubleMaximum(Context& context, double d) const { - if (exclusiveMaximum_ ? d >= maximum_.GetDouble() : d > maximum_.GetDouble()) - RAPIDJSON_INVALID_KEYWORD_RETURN(GetMaximumString()); - return true; - } - - bool CheckDoubleMultipleOf(Context& context, double d) const { - double a = std::abs(d), b = std::abs(multipleOf_.GetDouble()); - double q = std::floor(a / b); - double r = a - q * b; - if (r > 0.0) - RAPIDJSON_INVALID_KEYWORD_RETURN(GetMultipleOfString()); - return true; - } - - struct Property { - Property() : schema(), dependenciesSchema(), dependenciesValidatorIndex(), dependencies(), required(false) {} - ~Property() { AllocatorType::Free(dependencies); } - SValue name; - const SchemaType* schema; - const SchemaType* dependenciesSchema; - SizeType dependenciesValidatorIndex; - bool* dependencies; - bool required; - }; - - struct PatternProperty { - PatternProperty() : schema(), pattern() {} - ~PatternProperty() { - if (pattern) { - pattern->~RegexType(); - AllocatorType::Free(pattern); - } - } - const SchemaType* schema; - RegexType* pattern; - }; - - AllocatorType* allocator_; - uint64_t* enum_; - SizeType enumCount_; - SchemaArray allOf_; - SchemaArray anyOf_; - SchemaArray oneOf_; - const SchemaType* not_; - unsigned type_; // bitmask of kSchemaType - SizeType validatorCount_; - SizeType notValidatorIndex_; - - Property* properties_; - const SchemaType* additionalPropertiesSchema_; - PatternProperty* patternProperties_; - SizeType patternPropertyCount_; - SizeType propertyCount_; - SizeType minProperties_; - SizeType maxProperties_; - bool additionalProperties_; - bool hasDependencies_; - bool hasRequired_; - bool hasSchemaDependencies_; - - const SchemaType* additionalItemsSchema_; - const SchemaType* itemsList_; - const SchemaType** itemsTuple_; - SizeType itemsTupleCount_; - SizeType minItems_; - SizeType maxItems_; - bool additionalItems_; - bool uniqueItems_; - - RegexType* pattern_; - SizeType minLength_; - SizeType maxLength_; - - SValue minimum_; - SValue maximum_; - SValue multipleOf_; - bool exclusiveMinimum_; - bool exclusiveMaximum_; -}; - -template -struct TokenHelper { - RAPIDJSON_FORCEINLINE static void AppendIndexToken(Stack& documentStack, SizeType index) { - *documentStack.template Push() = '/'; - char buffer[21]; - size_t length = static_cast((sizeof(SizeType) == 4 ? u32toa(index, buffer) : u64toa(index, buffer)) - buffer); - for (size_t i = 0; i < length; i++) - *documentStack.template Push() = buffer[i]; - } -}; - -// Partial specialized version for char to prevent buffer copying. -template -struct TokenHelper { - RAPIDJSON_FORCEINLINE static void AppendIndexToken(Stack& documentStack, SizeType index) { - if (sizeof(SizeType) == 4) { - char *buffer = documentStack.template Push(1 + 10); // '/' + uint - *buffer++ = '/'; - const char* end = internal::u32toa(index, buffer); - documentStack.template Pop(static_cast(10 - (end - buffer))); - } - else { - char *buffer = documentStack.template Push(1 + 20); // '/' + uint64 - *buffer++ = '/'; - const char* end = internal::u64toa(index, buffer); - documentStack.template Pop(static_cast(20 - (end - buffer))); - } - } -}; - -} // namespace internal - -/////////////////////////////////////////////////////////////////////////////// -// IGenericRemoteSchemaDocumentProvider - -template -class IGenericRemoteSchemaDocumentProvider { -public: - typedef typename SchemaDocumentType::Ch Ch; - - virtual ~IGenericRemoteSchemaDocumentProvider() {} - virtual const SchemaDocumentType* GetRemoteDocument(const Ch* uri, SizeType length) = 0; -}; - -/////////////////////////////////////////////////////////////////////////////// -// GenericSchemaDocument - -//! JSON schema document. -/*! - A JSON schema document is a compiled version of a JSON schema. - It is basically a tree of internal::Schema. - - \note This is an immutable class (i.e. its instance cannot be modified after construction). - \tparam ValueT Type of JSON value (e.g. \c Value ), which also determine the encoding. - \tparam Allocator Allocator type for allocating memory of this document. -*/ -template -class GenericSchemaDocument { -public: - typedef ValueT ValueType; - typedef IGenericRemoteSchemaDocumentProvider IRemoteSchemaDocumentProviderType; - typedef Allocator AllocatorType; - typedef typename ValueType::EncodingType EncodingType; - typedef typename EncodingType::Ch Ch; - typedef internal::Schema SchemaType; - typedef GenericPointer PointerType; - friend class internal::Schema; - template - friend class GenericSchemaValidator; - - //! Constructor. - /*! - Compile a JSON document into schema document. - - \param document A JSON document as source. - \param remoteProvider An optional remote schema document provider for resolving remote reference. Can be null. - \param allocator An optional allocator instance for allocating memory. Can be null. - */ - explicit GenericSchemaDocument(const ValueType& document, IRemoteSchemaDocumentProviderType* remoteProvider = 0, Allocator* allocator = 0) : - remoteProvider_(remoteProvider), - allocator_(allocator), - ownAllocator_(), - root_(), - schemaMap_(allocator, kInitialSchemaMapSize), - schemaRef_(allocator, kInitialSchemaRefSize) - { - if (!allocator_) - ownAllocator_ = allocator_ = RAPIDJSON_NEW(Allocator()); - - // Generate root schema, it will call CreateSchema() to create sub-schemas, - // And call AddRefSchema() if there are $ref. - CreateSchemaRecursive(&root_, PointerType(), document, document); - - // Resolve $ref - while (!schemaRef_.Empty()) { - SchemaRefEntry* refEntry = schemaRef_.template Pop(1); - if (const SchemaType* s = GetSchema(refEntry->target)) { - if (refEntry->schema) - *refEntry->schema = s; - - // Create entry in map if not exist - if (!GetSchema(refEntry->source)) { - new (schemaMap_.template Push()) SchemaEntry(refEntry->source, const_cast(s), false, allocator_); - } - } - refEntry->~SchemaRefEntry(); - } - - RAPIDJSON_ASSERT(root_ != 0); - - schemaRef_.ShrinkToFit(); // Deallocate all memory for ref - } - -#if RAPIDJSON_HAS_CXX11_RVALUE_REFS - //! Move constructor in C++11 - GenericSchemaDocument(GenericSchemaDocument&& rhs) RAPIDJSON_NOEXCEPT : - remoteProvider_(rhs.remoteProvider_), - allocator_(rhs.allocator_), - ownAllocator_(rhs.ownAllocator_), - root_(rhs.root_), - schemaMap_(std::move(rhs.schemaMap_)), - schemaRef_(std::move(rhs.schemaRef_)) - { - rhs.remoteProvider_ = 0; - rhs.allocator_ = 0; - rhs.ownAllocator_ = 0; - } -#endif - - //! Destructor - ~GenericSchemaDocument() { - while (!schemaMap_.Empty()) - schemaMap_.template Pop(1)->~SchemaEntry(); - - RAPIDJSON_DELETE(ownAllocator_); - } - - //! Get the root schema. - const SchemaType& GetRoot() const { return *root_; } - -private: - //! Prohibit copying - GenericSchemaDocument(const GenericSchemaDocument&); - //! Prohibit assignment - GenericSchemaDocument& operator=(const GenericSchemaDocument&); - - struct SchemaRefEntry { - SchemaRefEntry(const PointerType& s, const PointerType& t, const SchemaType** outSchema, Allocator *allocator) : source(s, allocator), target(t, allocator), schema(outSchema) {} - PointerType source; - PointerType target; - const SchemaType** schema; - }; - - struct SchemaEntry { - SchemaEntry(const PointerType& p, SchemaType* s, bool o, Allocator* allocator) : pointer(p, allocator), schema(s), owned(o) {} - ~SchemaEntry() { - if (owned) { - schema->~SchemaType(); - Allocator::Free(schema); - } - } - PointerType pointer; - SchemaType* schema; - bool owned; - }; - - void CreateSchemaRecursive(const SchemaType** schema, const PointerType& pointer, const ValueType& v, const ValueType& document) { - if (schema) - *schema = SchemaType::GetTypeless(); - - if (v.GetType() == kObjectType) { - const SchemaType* s = GetSchema(pointer); - if (!s) - CreateSchema(schema, pointer, v, document); - - for (typename ValueType::ConstMemberIterator itr = v.MemberBegin(); itr != v.MemberEnd(); ++itr) - CreateSchemaRecursive(0, pointer.Append(itr->name, allocator_), itr->value, document); - } - else if (v.GetType() == kArrayType) - for (SizeType i = 0; i < v.Size(); i++) - CreateSchemaRecursive(0, pointer.Append(i, allocator_), v[i], document); - } - - void CreateSchema(const SchemaType** schema, const PointerType& pointer, const ValueType& v, const ValueType& document) { - RAPIDJSON_ASSERT(pointer.IsValid()); - if (v.IsObject()) { - if (!HandleRefSchema(pointer, schema, v, document)) { - SchemaType* s = new (allocator_->Malloc(sizeof(SchemaType))) SchemaType(this, pointer, v, document, allocator_); - new (schemaMap_.template Push()) SchemaEntry(pointer, s, true, allocator_); - if (schema) - *schema = s; - } - } - } - - bool HandleRefSchema(const PointerType& source, const SchemaType** schema, const ValueType& v, const ValueType& document) { - static const Ch kRefString[] = { '$', 'r', 'e', 'f', '\0' }; - static const ValueType kRefValue(kRefString, 4); - - typename ValueType::ConstMemberIterator itr = v.FindMember(kRefValue); - if (itr == v.MemberEnd()) - return false; - - if (itr->value.IsString()) { - SizeType len = itr->value.GetStringLength(); - if (len > 0) { - const Ch* s = itr->value.GetString(); - SizeType i = 0; - while (i < len && s[i] != '#') // Find the first # - i++; - - if (i > 0) { // Remote reference, resolve immediately - if (remoteProvider_) { - if (const GenericSchemaDocument* remoteDocument = remoteProvider_->GetRemoteDocument(s, i - 1)) { - PointerType pointer(&s[i], len - i, allocator_); - if (pointer.IsValid()) { - if (const SchemaType* sc = remoteDocument->GetSchema(pointer)) { - if (schema) - *schema = sc; - return true; - } - } - } - } - } - else if (s[i] == '#') { // Local reference, defer resolution - PointerType pointer(&s[i], len - i, allocator_); - if (pointer.IsValid()) { - if (const ValueType* nv = pointer.Get(document)) - if (HandleRefSchema(source, schema, *nv, document)) - return true; - - new (schemaRef_.template Push()) SchemaRefEntry(source, pointer, schema, allocator_); - return true; - } - } - } - } - return false; - } - - const SchemaType* GetSchema(const PointerType& pointer) const { - for (const SchemaEntry* target = schemaMap_.template Bottom(); target != schemaMap_.template End(); ++target) - if (pointer == target->pointer) - return target->schema; - return 0; - } - - PointerType GetPointer(const SchemaType* schema) const { - for (const SchemaEntry* target = schemaMap_.template Bottom(); target != schemaMap_.template End(); ++target) - if (schema == target->schema) - return target->pointer; - return PointerType(); - } - - static const size_t kInitialSchemaMapSize = 64; - static const size_t kInitialSchemaRefSize = 64; - - IRemoteSchemaDocumentProviderType* remoteProvider_; - Allocator *allocator_; - Allocator *ownAllocator_; - const SchemaType* root_; //!< Root schema. - internal::Stack schemaMap_; // Stores created Pointer -> Schemas - internal::Stack schemaRef_; // Stores Pointer from $ref and schema which holds the $ref -}; - -//! GenericSchemaDocument using Value type. -typedef GenericSchemaDocument SchemaDocument; -//! IGenericRemoteSchemaDocumentProvider using SchemaDocument. -typedef IGenericRemoteSchemaDocumentProvider IRemoteSchemaDocumentProvider; - -/////////////////////////////////////////////////////////////////////////////// -// GenericSchemaValidator - -//! JSON Schema Validator. -/*! - A SAX style JSON schema validator. - It uses a \c GenericSchemaDocument to validate SAX events. - It delegates the incoming SAX events to an output handler. - The default output handler does nothing. - It can be reused multiple times by calling \c Reset(). - - \tparam SchemaDocumentType Type of schema document. - \tparam OutputHandler Type of output handler. Default handler does nothing. - \tparam StateAllocator Allocator for storing the internal validation states. -*/ -template < - typename SchemaDocumentType, - typename OutputHandler = BaseReaderHandler, - typename StateAllocator = CrtAllocator> -class GenericSchemaValidator : - public internal::ISchemaStateFactory, - public internal::ISchemaValidator -{ -public: - typedef typename SchemaDocumentType::SchemaType SchemaType; - typedef typename SchemaDocumentType::PointerType PointerType; - typedef typename SchemaType::EncodingType EncodingType; - typedef typename EncodingType::Ch Ch; - - //! Constructor without output handler. - /*! - \param schemaDocument The schema document to conform to. - \param allocator Optional allocator for storing internal validation states. - \param schemaStackCapacity Optional initial capacity of schema path stack. - \param documentStackCapacity Optional initial capacity of document path stack. - */ - GenericSchemaValidator( - const SchemaDocumentType& schemaDocument, - StateAllocator* allocator = 0, - size_t schemaStackCapacity = kDefaultSchemaStackCapacity, - size_t documentStackCapacity = kDefaultDocumentStackCapacity) - : - schemaDocument_(&schemaDocument), - root_(schemaDocument.GetRoot()), - outputHandler_(GetNullHandler()), - stateAllocator_(allocator), - ownStateAllocator_(0), - schemaStack_(allocator, schemaStackCapacity), - documentStack_(allocator, documentStackCapacity), - valid_(true) -#if RAPIDJSON_SCHEMA_VERBOSE - , depth_(0) -#endif - { - } - - //! Constructor with output handler. - /*! - \param schemaDocument The schema document to conform to. - \param allocator Optional allocator for storing internal validation states. - \param schemaStackCapacity Optional initial capacity of schema path stack. - \param documentStackCapacity Optional initial capacity of document path stack. - */ - GenericSchemaValidator( - const SchemaDocumentType& schemaDocument, - OutputHandler& outputHandler, - StateAllocator* allocator = 0, - size_t schemaStackCapacity = kDefaultSchemaStackCapacity, - size_t documentStackCapacity = kDefaultDocumentStackCapacity) - : - schemaDocument_(&schemaDocument), - root_(schemaDocument.GetRoot()), - outputHandler_(outputHandler), - stateAllocator_(allocator), - ownStateAllocator_(0), - schemaStack_(allocator, schemaStackCapacity), - documentStack_(allocator, documentStackCapacity), - valid_(true) -#if RAPIDJSON_SCHEMA_VERBOSE - , depth_(0) -#endif - { - } - - //! Destructor. - ~GenericSchemaValidator() { - Reset(); - RAPIDJSON_DELETE(ownStateAllocator_); - } - - //! Reset the internal states. - void Reset() { - while (!schemaStack_.Empty()) - PopSchema(); - documentStack_.Clear(); - valid_ = true; - } - - //! Checks whether the current state is valid. - // Implementation of ISchemaValidator - virtual bool IsValid() const { return valid_; } - - //! Gets the JSON pointer pointed to the invalid schema. - PointerType GetInvalidSchemaPointer() const { - return schemaStack_.Empty() ? PointerType() : schemaDocument_->GetPointer(&CurrentSchema()); - } - - //! Gets the keyword of invalid schema. - const Ch* GetInvalidSchemaKeyword() const { - return schemaStack_.Empty() ? 0 : CurrentContext().invalidKeyword; - } - - //! Gets the JSON pointer pointed to the invalid value. - PointerType GetInvalidDocumentPointer() const { - return documentStack_.Empty() ? PointerType() : PointerType(documentStack_.template Bottom(), documentStack_.GetSize() / sizeof(Ch)); - } - -#if RAPIDJSON_SCHEMA_VERBOSE -#define RAPIDJSON_SCHEMA_HANDLE_BEGIN_VERBOSE_() \ -RAPIDJSON_MULTILINEMACRO_BEGIN\ - *documentStack_.template Push() = '\0';\ - documentStack_.template Pop(1);\ - internal::PrintInvalidDocument(documentStack_.template Bottom());\ -RAPIDJSON_MULTILINEMACRO_END -#else -#define RAPIDJSON_SCHEMA_HANDLE_BEGIN_VERBOSE_() -#endif - -#define RAPIDJSON_SCHEMA_HANDLE_BEGIN_(method, arg1)\ - if (!valid_) return false; \ - if (!BeginValue() || !CurrentSchema().method arg1) {\ - RAPIDJSON_SCHEMA_HANDLE_BEGIN_VERBOSE_();\ - return valid_ = false;\ - } - -#define RAPIDJSON_SCHEMA_HANDLE_PARALLEL_(method, arg2)\ - for (Context* context = schemaStack_.template Bottom(); context != schemaStack_.template End(); context++) {\ - if (context->hasher)\ - static_cast(context->hasher)->method arg2;\ - if (context->validators)\ - for (SizeType i_ = 0; i_ < context->validatorCount; i_++)\ - static_cast(context->validators[i_])->method arg2;\ - if (context->patternPropertiesValidators)\ - for (SizeType i_ = 0; i_ < context->patternPropertiesValidatorCount; i_++)\ - static_cast(context->patternPropertiesValidators[i_])->method arg2;\ - } - -#define RAPIDJSON_SCHEMA_HANDLE_END_(method, arg2)\ - return valid_ = EndValue() && outputHandler_.method arg2 - -#define RAPIDJSON_SCHEMA_HANDLE_VALUE_(method, arg1, arg2) \ - RAPIDJSON_SCHEMA_HANDLE_BEGIN_ (method, arg1);\ - RAPIDJSON_SCHEMA_HANDLE_PARALLEL_(method, arg2);\ - RAPIDJSON_SCHEMA_HANDLE_END_ (method, arg2) - - bool Null() { RAPIDJSON_SCHEMA_HANDLE_VALUE_(Null, (CurrentContext() ), ( )); } - bool Bool(bool b) { RAPIDJSON_SCHEMA_HANDLE_VALUE_(Bool, (CurrentContext(), b), (b)); } - bool Int(int i) { RAPIDJSON_SCHEMA_HANDLE_VALUE_(Int, (CurrentContext(), i), (i)); } - bool Uint(unsigned u) { RAPIDJSON_SCHEMA_HANDLE_VALUE_(Uint, (CurrentContext(), u), (u)); } - bool Int64(int64_t i) { RAPIDJSON_SCHEMA_HANDLE_VALUE_(Int64, (CurrentContext(), i), (i)); } - bool Uint64(uint64_t u) { RAPIDJSON_SCHEMA_HANDLE_VALUE_(Uint64, (CurrentContext(), u), (u)); } - bool Double(double d) { RAPIDJSON_SCHEMA_HANDLE_VALUE_(Double, (CurrentContext(), d), (d)); } - bool RawNumber(const Ch* str, SizeType length, bool copy) - { RAPIDJSON_SCHEMA_HANDLE_VALUE_(String, (CurrentContext(), str, length, copy), (str, length, copy)); } - bool String(const Ch* str, SizeType length, bool copy) - { RAPIDJSON_SCHEMA_HANDLE_VALUE_(String, (CurrentContext(), str, length, copy), (str, length, copy)); } - - bool StartObject() { - RAPIDJSON_SCHEMA_HANDLE_BEGIN_(StartObject, (CurrentContext())); - RAPIDJSON_SCHEMA_HANDLE_PARALLEL_(StartObject, ()); - return valid_ = outputHandler_.StartObject(); - } - - bool Key(const Ch* str, SizeType len, bool copy) { - if (!valid_) return false; - AppendToken(str, len); - if (!CurrentSchema().Key(CurrentContext(), str, len, copy)) return valid_ = false; - RAPIDJSON_SCHEMA_HANDLE_PARALLEL_(Key, (str, len, copy)); - return valid_ = outputHandler_.Key(str, len, copy); - } - - bool EndObject(SizeType memberCount) { - if (!valid_) return false; - RAPIDJSON_SCHEMA_HANDLE_PARALLEL_(EndObject, (memberCount)); - if (!CurrentSchema().EndObject(CurrentContext(), memberCount)) return valid_ = false; - RAPIDJSON_SCHEMA_HANDLE_END_(EndObject, (memberCount)); - } - - bool StartArray() { - RAPIDJSON_SCHEMA_HANDLE_BEGIN_(StartArray, (CurrentContext())); - RAPIDJSON_SCHEMA_HANDLE_PARALLEL_(StartArray, ()); - return valid_ = outputHandler_.StartArray(); - } - - bool EndArray(SizeType elementCount) { - if (!valid_) return false; - RAPIDJSON_SCHEMA_HANDLE_PARALLEL_(EndArray, (elementCount)); - if (!CurrentSchema().EndArray(CurrentContext(), elementCount)) return valid_ = false; - RAPIDJSON_SCHEMA_HANDLE_END_(EndArray, (elementCount)); - } - -#undef RAPIDJSON_SCHEMA_HANDLE_BEGIN_VERBOSE_ -#undef RAPIDJSON_SCHEMA_HANDLE_BEGIN_ -#undef RAPIDJSON_SCHEMA_HANDLE_PARALLEL_ -#undef RAPIDJSON_SCHEMA_HANDLE_VALUE_ - - // Implementation of ISchemaStateFactory - virtual ISchemaValidator* CreateSchemaValidator(const SchemaType& root) { - return new (GetStateAllocator().Malloc(sizeof(GenericSchemaValidator))) GenericSchemaValidator(*schemaDocument_, root, -#if RAPIDJSON_SCHEMA_VERBOSE - depth_ + 1, -#endif - &GetStateAllocator()); - } - - virtual void DestroySchemaValidator(ISchemaValidator* validator) { - GenericSchemaValidator* v = static_cast(validator); - v->~GenericSchemaValidator(); - StateAllocator::Free(v); - } - - virtual void* CreateHasher() { - return new (GetStateAllocator().Malloc(sizeof(HasherType))) HasherType(&GetStateAllocator()); - } - - virtual uint64_t GetHashCode(void* hasher) { - return static_cast(hasher)->GetHashCode(); - } - - virtual void DestroryHasher(void* hasher) { - HasherType* h = static_cast(hasher); - h->~HasherType(); - StateAllocator::Free(h); - } - - virtual void* MallocState(size_t size) { - return GetStateAllocator().Malloc(size); - } - - virtual void FreeState(void* p) { - return StateAllocator::Free(p); - } - -private: - typedef typename SchemaType::Context Context; - typedef GenericValue, StateAllocator> HashCodeArray; - typedef internal::Hasher HasherType; - - GenericSchemaValidator( - const SchemaDocumentType& schemaDocument, - const SchemaType& root, -#if RAPIDJSON_SCHEMA_VERBOSE - unsigned depth, -#endif - StateAllocator* allocator = 0, - size_t schemaStackCapacity = kDefaultSchemaStackCapacity, - size_t documentStackCapacity = kDefaultDocumentStackCapacity) - : - schemaDocument_(&schemaDocument), - root_(root), - outputHandler_(GetNullHandler()), - stateAllocator_(allocator), - ownStateAllocator_(0), - schemaStack_(allocator, schemaStackCapacity), - documentStack_(allocator, documentStackCapacity), - valid_(true) -#if RAPIDJSON_SCHEMA_VERBOSE - , depth_(depth) -#endif - { - } - - StateAllocator& GetStateAllocator() { - if (!stateAllocator_) - stateAllocator_ = ownStateAllocator_ = RAPIDJSON_NEW(StateAllocator()); - return *stateAllocator_; - } - - bool BeginValue() { - if (schemaStack_.Empty()) - PushSchema(root_); - else { - if (CurrentContext().inArray) - internal::TokenHelper, Ch>::AppendIndexToken(documentStack_, CurrentContext().arrayElementIndex); - - if (!CurrentSchema().BeginValue(CurrentContext())) - return false; - - SizeType count = CurrentContext().patternPropertiesSchemaCount; - const SchemaType** sa = CurrentContext().patternPropertiesSchemas; - typename Context::PatternValidatorType patternValidatorType = CurrentContext().valuePatternValidatorType; - bool valueUniqueness = CurrentContext().valueUniqueness; - if (CurrentContext().valueSchema) - PushSchema(*CurrentContext().valueSchema); - - if (count > 0) { - CurrentContext().objectPatternValidatorType = patternValidatorType; - ISchemaValidator**& va = CurrentContext().patternPropertiesValidators; - SizeType& validatorCount = CurrentContext().patternPropertiesValidatorCount; - va = static_cast(MallocState(sizeof(ISchemaValidator*) * count)); - for (SizeType i = 0; i < count; i++) - va[validatorCount++] = CreateSchemaValidator(*sa[i]); - } - - CurrentContext().arrayUniqueness = valueUniqueness; - } - return true; - } - - bool EndValue() { - if (!CurrentSchema().EndValue(CurrentContext())) - return false; - -#if RAPIDJSON_SCHEMA_VERBOSE - GenericStringBuffer sb; - schemaDocument_->GetPointer(&CurrentSchema()).Stringify(sb); - - *documentStack_.template Push() = '\0'; - documentStack_.template Pop(1); - internal::PrintValidatorPointers(depth_, sb.GetString(), documentStack_.template Bottom()); -#endif - - uint64_t h = CurrentContext().arrayUniqueness ? static_cast(CurrentContext().hasher)->GetHashCode() : 0; - - PopSchema(); - - if (!schemaStack_.Empty()) { - Context& context = CurrentContext(); - if (context.valueUniqueness) { - HashCodeArray* a = static_cast(context.arrayElementHashCodes); - if (!a) - CurrentContext().arrayElementHashCodes = a = new (GetStateAllocator().Malloc(sizeof(HashCodeArray))) HashCodeArray(kArrayType); - for (typename HashCodeArray::ConstValueIterator itr = a->Begin(); itr != a->End(); ++itr) - if (itr->GetUint64() == h) - RAPIDJSON_INVALID_KEYWORD_RETURN(SchemaType::GetUniqueItemsString()); - a->PushBack(h, GetStateAllocator()); - } - } - - // Remove the last token of document pointer - while (!documentStack_.Empty() && *documentStack_.template Pop(1) != '/') - ; - - return true; - } - - void AppendToken(const Ch* str, SizeType len) { - documentStack_.template Reserve(1 + len * 2); // worst case all characters are escaped as two characters - *documentStack_.template PushUnsafe() = '/'; - for (SizeType i = 0; i < len; i++) { - if (str[i] == '~') { - *documentStack_.template PushUnsafe() = '~'; - *documentStack_.template PushUnsafe() = '0'; - } - else if (str[i] == '/') { - *documentStack_.template PushUnsafe() = '~'; - *documentStack_.template PushUnsafe() = '1'; - } - else - *documentStack_.template PushUnsafe() = str[i]; - } - } - - RAPIDJSON_FORCEINLINE void PushSchema(const SchemaType& schema) { new (schemaStack_.template Push()) Context(*this, &schema); } - - RAPIDJSON_FORCEINLINE void PopSchema() { - Context* c = schemaStack_.template Pop(1); - if (HashCodeArray* a = static_cast(c->arrayElementHashCodes)) { - a->~HashCodeArray(); - StateAllocator::Free(a); - } - c->~Context(); - } - - const SchemaType& CurrentSchema() const { return *schemaStack_.template Top()->schema; } - Context& CurrentContext() { return *schemaStack_.template Top(); } - const Context& CurrentContext() const { return *schemaStack_.template Top(); } - - static OutputHandler& GetNullHandler() { - static OutputHandler nullHandler; - return nullHandler; - } - - static const size_t kDefaultSchemaStackCapacity = 1024; - static const size_t kDefaultDocumentStackCapacity = 256; - const SchemaDocumentType* schemaDocument_; - const SchemaType& root_; - OutputHandler& outputHandler_; - StateAllocator* stateAllocator_; - StateAllocator* ownStateAllocator_; - internal::Stack schemaStack_; //!< stack to store the current path of schema (BaseSchemaType *) - internal::Stack documentStack_; //!< stack to store the current path of validating document (Ch) - bool valid_; -#if RAPIDJSON_SCHEMA_VERBOSE - unsigned depth_; -#endif -}; - -typedef GenericSchemaValidator SchemaValidator; - -/////////////////////////////////////////////////////////////////////////////// -// SchemaValidatingReader - -//! A helper class for parsing with validation. -/*! - This helper class is a functor, designed as a parameter of \ref GenericDocument::Populate(). - - \tparam parseFlags Combination of \ref ParseFlag. - \tparam InputStream Type of input stream, implementing Stream concept. - \tparam SourceEncoding Encoding of the input stream. - \tparam SchemaDocumentType Type of schema document. - \tparam StackAllocator Allocator type for stack. -*/ -template < - unsigned parseFlags, - typename InputStream, - typename SourceEncoding, - typename SchemaDocumentType = SchemaDocument, - typename StackAllocator = CrtAllocator> -class SchemaValidatingReader { -public: - typedef typename SchemaDocumentType::PointerType PointerType; - typedef typename InputStream::Ch Ch; - - //! Constructor - /*! - \param is Input stream. - \param sd Schema document. - */ - SchemaValidatingReader(InputStream& is, const SchemaDocumentType& sd) : is_(is), sd_(sd), invalidSchemaKeyword_(), isValid_(true) {} - - template - bool operator()(Handler& handler) { - GenericReader reader; - GenericSchemaValidator validator(sd_, handler); - parseResult_ = reader.template Parse(is_, validator); - - isValid_ = validator.IsValid(); - if (isValid_) { - invalidSchemaPointer_ = PointerType(); - invalidSchemaKeyword_ = 0; - invalidDocumentPointer_ = PointerType(); - } - else { - invalidSchemaPointer_ = validator.GetInvalidSchemaPointer(); - invalidSchemaKeyword_ = validator.GetInvalidSchemaKeyword(); - invalidDocumentPointer_ = validator.GetInvalidDocumentPointer(); - } - - return parseResult_; - } - - const ParseResult& GetParseResult() const { return parseResult_; } - bool IsValid() const { return isValid_; } - const PointerType& GetInvalidSchemaPointer() const { return invalidSchemaPointer_; } - const Ch* GetInvalidSchemaKeyword() const { return invalidSchemaKeyword_; } - const PointerType& GetInvalidDocumentPointer() const { return invalidDocumentPointer_; } - -private: - InputStream& is_; - const SchemaDocumentType& sd_; - - ParseResult parseResult_; - PointerType invalidSchemaPointer_; - const Ch* invalidSchemaKeyword_; - PointerType invalidDocumentPointer_; - bool isValid_; -}; - -RAPIDJSON_NAMESPACE_END -RAPIDJSON_DIAG_POP - -#endif // RAPIDJSON_SCHEMA_H_ diff --git a/slsReceiverSoftware/include/rapidjson/stream.h b/slsReceiverSoftware/include/rapidjson/stream.h deleted file mode 100644 index fef82c252..000000000 --- a/slsReceiverSoftware/include/rapidjson/stream.h +++ /dev/null @@ -1,179 +0,0 @@ -// Tencent is pleased to support the open source community by making RapidJSON available. -// -// Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved. -// -// Licensed under the MIT License (the "License"); you may not use this file except -// in compliance with the License. You may obtain a copy of the License at -// -// http://opensource.org/licenses/MIT -// -// Unless required by applicable law or agreed to in writing, software distributed -// under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR -// CONDITIONS OF ANY KIND, either express or implied. See the License for the -// specific language governing permissions and limitations under the License. - -#include "rapidjson.h" - -#ifndef RAPIDJSON_STREAM_H_ -#define RAPIDJSON_STREAM_H_ - -#include "encodings.h" - -RAPIDJSON_NAMESPACE_BEGIN - -/////////////////////////////////////////////////////////////////////////////// -// Stream - -/*! \class rapidjson::Stream - \brief Concept for reading and writing characters. - - For read-only stream, no need to implement PutBegin(), Put(), Flush() and PutEnd(). - - For write-only stream, only need to implement Put() and Flush(). - -\code -concept Stream { - typename Ch; //!< Character type of the stream. - - //! Read the current character from stream without moving the read cursor. - Ch Peek() const; - - //! Read the current character from stream and moving the read cursor to next character. - Ch Take(); - - //! Get the current read cursor. - //! \return Number of characters read from start. - size_t Tell(); - - //! Begin writing operation at the current read pointer. - //! \return The begin writer pointer. - Ch* PutBegin(); - - //! Write a character. - void Put(Ch c); - - //! Flush the buffer. - void Flush(); - - //! End the writing operation. - //! \param begin The begin write pointer returned by PutBegin(). - //! \return Number of characters written. - size_t PutEnd(Ch* begin); -} -\endcode -*/ - -//! Provides additional information for stream. -/*! - By using traits pattern, this type provides a default configuration for stream. - For custom stream, this type can be specialized for other configuration. - See TEST(Reader, CustomStringStream) in readertest.cpp for example. -*/ -template -struct StreamTraits { - //! Whether to make local copy of stream for optimization during parsing. - /*! - By default, for safety, streams do not use local copy optimization. - Stream that can be copied fast should specialize this, like StreamTraits. - */ - enum { copyOptimization = 0 }; -}; - -//! Reserve n characters for writing to a stream. -template -inline void PutReserve(Stream& stream, size_t count) { - (void)stream; - (void)count; -} - -//! Write character to a stream, presuming buffer is reserved. -template -inline void PutUnsafe(Stream& stream, typename Stream::Ch c) { - stream.Put(c); -} - -//! Put N copies of a character to a stream. -template -inline void PutN(Stream& stream, Ch c, size_t n) { - PutReserve(stream, n); - for (size_t i = 0; i < n; i++) - PutUnsafe(stream, c); -} - -/////////////////////////////////////////////////////////////////////////////// -// StringStream - -//! Read-only string stream. -/*! \note implements Stream concept -*/ -template -struct GenericStringStream { - typedef typename Encoding::Ch Ch; - - GenericStringStream(const Ch *src) : src_(src), head_(src) {} - - Ch Peek() const { return *src_; } - Ch Take() { return *src_++; } - size_t Tell() const { return static_cast(src_ - head_); } - - Ch* PutBegin() { RAPIDJSON_ASSERT(false); return 0; } - void Put(Ch) { RAPIDJSON_ASSERT(false); } - void Flush() { RAPIDJSON_ASSERT(false); } - size_t PutEnd(Ch*) { RAPIDJSON_ASSERT(false); return 0; } - - const Ch* src_; //!< Current read position. - const Ch* head_; //!< Original head of the string. -}; - -template -struct StreamTraits > { - enum { copyOptimization = 1 }; -}; - -//! String stream with UTF8 encoding. -typedef GenericStringStream > StringStream; - -/////////////////////////////////////////////////////////////////////////////// -// InsituStringStream - -//! A read-write string stream. -/*! This string stream is particularly designed for in-situ parsing. - \note implements Stream concept -*/ -template -struct GenericInsituStringStream { - typedef typename Encoding::Ch Ch; - - GenericInsituStringStream(Ch *src) : src_(src), dst_(0), head_(src) {} - - // Read - Ch Peek() { return *src_; } - Ch Take() { return *src_++; } - size_t Tell() { return static_cast(src_ - head_); } - - // Write - void Put(Ch c) { RAPIDJSON_ASSERT(dst_ != 0); *dst_++ = c; } - - Ch* PutBegin() { return dst_ = src_; } - size_t PutEnd(Ch* begin) { return static_cast(dst_ - begin); } - void Flush() {} - - Ch* Push(size_t count) { Ch* begin = dst_; dst_ += count; return begin; } - void Pop(size_t count) { dst_ -= count; } - - Ch* src_; - Ch* dst_; - Ch* head_; -}; - -template -struct StreamTraits > { - enum { copyOptimization = 1 }; -}; - -//! Insitu string stream with UTF8 encoding. -typedef GenericInsituStringStream > InsituStringStream; - -RAPIDJSON_NAMESPACE_END - -#endif // RAPIDJSON_STREAM_H_ diff --git a/slsReceiverSoftware/include/rapidjson/stringbuffer.h b/slsReceiverSoftware/include/rapidjson/stringbuffer.h deleted file mode 100644 index 78f34d209..000000000 --- a/slsReceiverSoftware/include/rapidjson/stringbuffer.h +++ /dev/null @@ -1,117 +0,0 @@ -// Tencent is pleased to support the open source community by making RapidJSON available. -// -// Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved. -// -// Licensed under the MIT License (the "License"); you may not use this file except -// in compliance with the License. You may obtain a copy of the License at -// -// http://opensource.org/licenses/MIT -// -// Unless required by applicable law or agreed to in writing, software distributed -// under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR -// CONDITIONS OF ANY KIND, either express or implied. See the License for the -// specific language governing permissions and limitations under the License. - -#ifndef RAPIDJSON_STRINGBUFFER_H_ -#define RAPIDJSON_STRINGBUFFER_H_ - -#include "stream.h" -#include "internal/stack.h" - -#if RAPIDJSON_HAS_CXX11_RVALUE_REFS -#include // std::move -#endif - -#include "internal/stack.h" - -#if defined(__clang__) -RAPIDJSON_DIAG_PUSH -RAPIDJSON_DIAG_OFF(c++98-compat) -#endif - -RAPIDJSON_NAMESPACE_BEGIN - -//! Represents an in-memory output stream. -/*! - \tparam Encoding Encoding of the stream. - \tparam Allocator type for allocating memory buffer. - \note implements Stream concept -*/ -template -class GenericStringBuffer { -public: - typedef typename Encoding::Ch Ch; - - GenericStringBuffer(Allocator* allocator = 0, size_t capacity = kDefaultCapacity) : stack_(allocator, capacity) {} - -#if RAPIDJSON_HAS_CXX11_RVALUE_REFS - GenericStringBuffer(GenericStringBuffer&& rhs) : stack_(std::move(rhs.stack_)) {} - GenericStringBuffer& operator=(GenericStringBuffer&& rhs) { - if (&rhs != this) - stack_ = std::move(rhs.stack_); - return *this; - } -#endif - - void Put(Ch c) { *stack_.template Push() = c; } - void PutUnsafe(Ch c) { *stack_.template PushUnsafe() = c; } - void Flush() {} - - void Clear() { stack_.Clear(); } - void ShrinkToFit() { - // Push and pop a null terminator. This is safe. - *stack_.template Push() = '\0'; - stack_.ShrinkToFit(); - stack_.template Pop(1); - } - - void Reserve(size_t count) { stack_.template Reserve(count); } - Ch* Push(size_t count) { return stack_.template Push(count); } - Ch* PushUnsafe(size_t count) { return stack_.template PushUnsafe(count); } - void Pop(size_t count) { stack_.template Pop(count); } - - const Ch* GetString() const { - // Push and pop a null terminator. This is safe. - *stack_.template Push() = '\0'; - stack_.template Pop(1); - - return stack_.template Bottom(); - } - - size_t GetSize() const { return stack_.GetSize(); } - - static const size_t kDefaultCapacity = 256; - mutable internal::Stack stack_; - -private: - // Prohibit copy constructor & assignment operator. - GenericStringBuffer(const GenericStringBuffer&); - GenericStringBuffer& operator=(const GenericStringBuffer&); -}; - -//! String buffer with UTF8 encoding -typedef GenericStringBuffer > StringBuffer; - -template -inline void PutReserve(GenericStringBuffer& stream, size_t count) { - stream.Reserve(count); -} - -template -inline void PutUnsafe(GenericStringBuffer& stream, typename Encoding::Ch c) { - stream.PutUnsafe(c); -} - -//! Implement specialized version of PutN() with memset() for better performance. -template<> -inline void PutN(GenericStringBuffer >& stream, char c, size_t n) { - std::memset(stream.stack_.Push(n), c, n * sizeof(c)); -} - -RAPIDJSON_NAMESPACE_END - -#if defined(__clang__) -RAPIDJSON_DIAG_POP -#endif - -#endif // RAPIDJSON_STRINGBUFFER_H_ diff --git a/slsReceiverSoftware/include/rapidjson/writer.h b/slsReceiverSoftware/include/rapidjson/writer.h deleted file mode 100644 index 94f22dd5f..000000000 --- a/slsReceiverSoftware/include/rapidjson/writer.h +++ /dev/null @@ -1,610 +0,0 @@ -// Tencent is pleased to support the open source community by making RapidJSON available. -// -// Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved. -// -// Licensed under the MIT License (the "License"); you may not use this file except -// in compliance with the License. You may obtain a copy of the License at -// -// http://opensource.org/licenses/MIT -// -// Unless required by applicable law or agreed to in writing, software distributed -// under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR -// CONDITIONS OF ANY KIND, either express or implied. See the License for the -// specific language governing permissions and limitations under the License. - -#ifndef RAPIDJSON_WRITER_H_ -#define RAPIDJSON_WRITER_H_ - -#include "stream.h" -#include "internal/stack.h" -#include "internal/strfunc.h" -#include "internal/dtoa.h" -#include "internal/itoa.h" -#include "stringbuffer.h" -#include // placement new - -#if defined(RAPIDJSON_SIMD) && defined(_MSC_VER) -#include -#pragma intrinsic(_BitScanForward) -#endif -#ifdef RAPIDJSON_SSE42 -#include -#elif defined(RAPIDJSON_SSE2) -#include -#endif - -#ifdef _MSC_VER -RAPIDJSON_DIAG_PUSH -RAPIDJSON_DIAG_OFF(4127) // conditional expression is constant -#endif - -#ifdef __clang__ -RAPIDJSON_DIAG_PUSH -RAPIDJSON_DIAG_OFF(padded) -RAPIDJSON_DIAG_OFF(unreachable-code) -#endif - -RAPIDJSON_NAMESPACE_BEGIN - -/////////////////////////////////////////////////////////////////////////////// -// WriteFlag - -/*! \def RAPIDJSON_WRITE_DEFAULT_FLAGS - \ingroup RAPIDJSON_CONFIG - \brief User-defined kWriteDefaultFlags definition. - - User can define this as any \c WriteFlag combinations. -*/ -#ifndef RAPIDJSON_WRITE_DEFAULT_FLAGS -#define RAPIDJSON_WRITE_DEFAULT_FLAGS kWriteNoFlags -#endif - -//! Combination of writeFlags -enum WriteFlag { - kWriteNoFlags = 0, //!< No flags are set. - kWriteValidateEncodingFlag = 1, //!< Validate encoding of JSON strings. - kWriteNanAndInfFlag = 2, //!< Allow writing of Infinity, -Infinity and NaN. - kWriteDefaultFlags = RAPIDJSON_WRITE_DEFAULT_FLAGS //!< Default write flags. Can be customized by defining RAPIDJSON_WRITE_DEFAULT_FLAGS -}; - -//! JSON writer -/*! Writer implements the concept Handler. - It generates JSON text by events to an output os. - - User may programmatically calls the functions of a writer to generate JSON text. - - On the other side, a writer can also be passed to objects that generates events, - - for example Reader::Parse() and Document::Accept(). - - \tparam OutputStream Type of output stream. - \tparam SourceEncoding Encoding of source string. - \tparam TargetEncoding Encoding of output stream. - \tparam StackAllocator Type of allocator for allocating memory of stack. - \note implements Handler concept -*/ -template, typename TargetEncoding = UTF8<>, typename StackAllocator = CrtAllocator, unsigned writeFlags = kWriteDefaultFlags> -class Writer { -public: - typedef typename SourceEncoding::Ch Ch; - - static const int kDefaultMaxDecimalPlaces = 324; - - //! Constructor - /*! \param os Output stream. - \param stackAllocator User supplied allocator. If it is null, it will create a private one. - \param levelDepth Initial capacity of stack. - */ - explicit - Writer(OutputStream& os, StackAllocator* stackAllocator = 0, size_t levelDepth = kDefaultLevelDepth) : - os_(&os), level_stack_(stackAllocator, levelDepth * sizeof(Level)), maxDecimalPlaces_(kDefaultMaxDecimalPlaces), hasRoot_(false) {} - - explicit - Writer(StackAllocator* allocator = 0, size_t levelDepth = kDefaultLevelDepth) : - os_(0), level_stack_(allocator, levelDepth * sizeof(Level)), maxDecimalPlaces_(kDefaultMaxDecimalPlaces), hasRoot_(false) {} - - //! Reset the writer with a new stream. - /*! - This function reset the writer with a new stream and default settings, - in order to make a Writer object reusable for output multiple JSONs. - - \param os New output stream. - \code - Writer writer(os1); - writer.StartObject(); - // ... - writer.EndObject(); - - writer.Reset(os2); - writer.StartObject(); - // ... - writer.EndObject(); - \endcode - */ - void Reset(OutputStream& os) { - os_ = &os; - hasRoot_ = false; - level_stack_.Clear(); - } - - //! Checks whether the output is a complete JSON. - /*! - A complete JSON has a complete root object or array. - */ - bool IsComplete() const { - return hasRoot_ && level_stack_.Empty(); - } - - int GetMaxDecimalPlaces() const { - return maxDecimalPlaces_; - } - - //! Sets the maximum number of decimal places for double output. - /*! - This setting truncates the output with specified number of decimal places. - - For example, - - \code - writer.SetMaxDecimalPlaces(3); - writer.StartArray(); - writer.Double(0.12345); // "0.123" - writer.Double(0.0001); // "0.0" - writer.Double(1.234567890123456e30); // "1.234567890123456e30" (do not truncate significand for positive exponent) - writer.Double(1.23e-4); // "0.0" (do truncate significand for negative exponent) - writer.EndArray(); - \endcode - - The default setting does not truncate any decimal places. You can restore to this setting by calling - \code - writer.SetMaxDecimalPlaces(Writer::kDefaultMaxDecimalPlaces); - \endcode - */ - void SetMaxDecimalPlaces(int maxDecimalPlaces) { - maxDecimalPlaces_ = maxDecimalPlaces; - } - - /*!@name Implementation of Handler - \see Handler - */ - //@{ - - bool Null() { Prefix(kNullType); return EndValue(WriteNull()); } - bool Bool(bool b) { Prefix(b ? kTrueType : kFalseType); return EndValue(WriteBool(b)); } - bool Int(int i) { Prefix(kNumberType); return EndValue(WriteInt(i)); } - bool Uint(unsigned u) { Prefix(kNumberType); return EndValue(WriteUint(u)); } - bool Int64(int64_t i64) { Prefix(kNumberType); return EndValue(WriteInt64(i64)); } - bool Uint64(uint64_t u64) { Prefix(kNumberType); return EndValue(WriteUint64(u64)); } - - //! Writes the given \c double value to the stream - /*! - \param d The value to be written. - \return Whether it is succeed. - */ - bool Double(double d) { Prefix(kNumberType); return EndValue(WriteDouble(d)); } - - bool RawNumber(const Ch* str, SizeType length, bool copy = false) { - (void)copy; - Prefix(kNumberType); - return EndValue(WriteString(str, length)); - } - - bool String(const Ch* str, SizeType length, bool copy = false) { - (void)copy; - Prefix(kStringType); - return EndValue(WriteString(str, length)); - } - -#if RAPIDJSON_HAS_STDSTRING - bool String(const std::basic_string& str) { - return String(str.data(), SizeType(str.size())); - } -#endif - - bool StartObject() { - Prefix(kObjectType); - new (level_stack_.template Push()) Level(false); - return WriteStartObject(); - } - - bool Key(const Ch* str, SizeType length, bool copy = false) { return String(str, length, copy); } - - bool EndObject(SizeType memberCount = 0) { - (void)memberCount; - RAPIDJSON_ASSERT(level_stack_.GetSize() >= sizeof(Level)); - RAPIDJSON_ASSERT(!level_stack_.template Top()->inArray); - level_stack_.template Pop(1); - return EndValue(WriteEndObject()); - } - - bool StartArray() { - Prefix(kArrayType); - new (level_stack_.template Push()) Level(true); - return WriteStartArray(); - } - - bool EndArray(SizeType elementCount = 0) { - (void)elementCount; - RAPIDJSON_ASSERT(level_stack_.GetSize() >= sizeof(Level)); - RAPIDJSON_ASSERT(level_stack_.template Top()->inArray); - level_stack_.template Pop(1); - return EndValue(WriteEndArray()); - } - //@} - - /*! @name Convenience extensions */ - //@{ - - //! Simpler but slower overload. - bool String(const Ch* str) { return String(str, internal::StrLen(str)); } - bool Key(const Ch* str) { return Key(str, internal::StrLen(str)); } - - //@} - - //! Write a raw JSON value. - /*! - For user to write a stringified JSON as a value. - - \param json A well-formed JSON value. It should not contain null character within [0, length - 1] range. - \param length Length of the json. - \param type Type of the root of json. - */ - bool RawValue(const Ch* json, size_t length, Type type) { Prefix(type); return EndValue(WriteRawValue(json, length)); } - -protected: - //! Information for each nested level - struct Level { - Level(bool inArray_) : valueCount(0), inArray(inArray_) {} - size_t valueCount; //!< number of values in this level - bool inArray; //!< true if in array, otherwise in object - }; - - static const size_t kDefaultLevelDepth = 32; - - bool WriteNull() { - PutReserve(*os_, 4); - PutUnsafe(*os_, 'n'); PutUnsafe(*os_, 'u'); PutUnsafe(*os_, 'l'); PutUnsafe(*os_, 'l'); return true; - } - - bool WriteBool(bool b) { - if (b) { - PutReserve(*os_, 4); - PutUnsafe(*os_, 't'); PutUnsafe(*os_, 'r'); PutUnsafe(*os_, 'u'); PutUnsafe(*os_, 'e'); - } - else { - PutReserve(*os_, 5); - PutUnsafe(*os_, 'f'); PutUnsafe(*os_, 'a'); PutUnsafe(*os_, 'l'); PutUnsafe(*os_, 's'); PutUnsafe(*os_, 'e'); - } - return true; - } - - bool WriteInt(int i) { - char buffer[11]; - const char* end = internal::i32toa(i, buffer); - PutReserve(*os_, static_cast(end - buffer)); - for (const char* p = buffer; p != end; ++p) - PutUnsafe(*os_, static_cast(*p)); - return true; - } - - bool WriteUint(unsigned u) { - char buffer[10]; - const char* end = internal::u32toa(u, buffer); - PutReserve(*os_, static_cast(end - buffer)); - for (const char* p = buffer; p != end; ++p) - PutUnsafe(*os_, static_cast(*p)); - return true; - } - - bool WriteInt64(int64_t i64) { - char buffer[21]; - const char* end = internal::i64toa(i64, buffer); - PutReserve(*os_, static_cast(end - buffer)); - for (const char* p = buffer; p != end; ++p) - PutUnsafe(*os_, static_cast(*p)); - return true; - } - - bool WriteUint64(uint64_t u64) { - char buffer[20]; - char* end = internal::u64toa(u64, buffer); - PutReserve(*os_, static_cast(end - buffer)); - for (char* p = buffer; p != end; ++p) - PutUnsafe(*os_, static_cast(*p)); - return true; - } - - bool WriteDouble(double d) { - if (internal::Double(d).IsNanOrInf()) { - if (!(writeFlags & kWriteNanAndInfFlag)) - return false; - if (internal::Double(d).IsNan()) { - PutReserve(*os_, 3); - PutUnsafe(*os_, 'N'); PutUnsafe(*os_, 'a'); PutUnsafe(*os_, 'N'); - return true; - } - if (internal::Double(d).Sign()) { - PutReserve(*os_, 9); - PutUnsafe(*os_, '-'); - } - else - PutReserve(*os_, 8); - PutUnsafe(*os_, 'I'); PutUnsafe(*os_, 'n'); PutUnsafe(*os_, 'f'); - PutUnsafe(*os_, 'i'); PutUnsafe(*os_, 'n'); PutUnsafe(*os_, 'i'); PutUnsafe(*os_, 't'); PutUnsafe(*os_, 'y'); - return true; - } - - char buffer[25]; - char* end = internal::dtoa(d, buffer, maxDecimalPlaces_); - PutReserve(*os_, static_cast(end - buffer)); - for (char* p = buffer; p != end; ++p) - PutUnsafe(*os_, static_cast(*p)); - return true; - } - - bool WriteString(const Ch* str, SizeType length) { - static const typename TargetEncoding::Ch hexDigits[16] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' }; - static const char escape[256] = { -#define Z16 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - //0 1 2 3 4 5 6 7 8 9 A B C D E F - 'u', 'u', 'u', 'u', 'u', 'u', 'u', 'u', 'b', 't', 'n', 'u', 'f', 'r', 'u', 'u', // 00 - 'u', 'u', 'u', 'u', 'u', 'u', 'u', 'u', 'u', 'u', 'u', 'u', 'u', 'u', 'u', 'u', // 10 - 0, 0, '"', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 20 - Z16, Z16, // 30~4F - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,'\\', 0, 0, 0, // 50 - Z16, Z16, Z16, Z16, Z16, Z16, Z16, Z16, Z16, Z16 // 60~FF -#undef Z16 - }; - - if (TargetEncoding::supportUnicode) - PutReserve(*os_, 2 + length * 6); // "\uxxxx..." - else - PutReserve(*os_, 2 + length * 12); // "\uxxxx\uyyyy..." - - PutUnsafe(*os_, '\"'); - GenericStringStream is(str); - while (ScanWriteUnescapedString(is, length)) { - const Ch c = is.Peek(); - if (!TargetEncoding::supportUnicode && static_cast(c) >= 0x80) { - // Unicode escaping - unsigned codepoint; - if (RAPIDJSON_UNLIKELY(!SourceEncoding::Decode(is, &codepoint))) - return false; - PutUnsafe(*os_, '\\'); - PutUnsafe(*os_, 'u'); - if (codepoint <= 0xD7FF || (codepoint >= 0xE000 && codepoint <= 0xFFFF)) { - PutUnsafe(*os_, hexDigits[(codepoint >> 12) & 15]); - PutUnsafe(*os_, hexDigits[(codepoint >> 8) & 15]); - PutUnsafe(*os_, hexDigits[(codepoint >> 4) & 15]); - PutUnsafe(*os_, hexDigits[(codepoint ) & 15]); - } - else { - RAPIDJSON_ASSERT(codepoint >= 0x010000 && codepoint <= 0x10FFFF); - // Surrogate pair - unsigned s = codepoint - 0x010000; - unsigned lead = (s >> 10) + 0xD800; - unsigned trail = (s & 0x3FF) + 0xDC00; - PutUnsafe(*os_, hexDigits[(lead >> 12) & 15]); - PutUnsafe(*os_, hexDigits[(lead >> 8) & 15]); - PutUnsafe(*os_, hexDigits[(lead >> 4) & 15]); - PutUnsafe(*os_, hexDigits[(lead ) & 15]); - PutUnsafe(*os_, '\\'); - PutUnsafe(*os_, 'u'); - PutUnsafe(*os_, hexDigits[(trail >> 12) & 15]); - PutUnsafe(*os_, hexDigits[(trail >> 8) & 15]); - PutUnsafe(*os_, hexDigits[(trail >> 4) & 15]); - PutUnsafe(*os_, hexDigits[(trail ) & 15]); - } - } - else if ((sizeof(Ch) == 1 || static_cast(c) < 256) && RAPIDJSON_UNLIKELY(escape[static_cast(c)])) { - is.Take(); - PutUnsafe(*os_, '\\'); - PutUnsafe(*os_, static_cast(escape[static_cast(c)])); - if (escape[static_cast(c)] == 'u') { - PutUnsafe(*os_, '0'); - PutUnsafe(*os_, '0'); - PutUnsafe(*os_, hexDigits[static_cast(c) >> 4]); - PutUnsafe(*os_, hexDigits[static_cast(c) & 0xF]); - } - } - else if (RAPIDJSON_UNLIKELY(!(writeFlags & kWriteValidateEncodingFlag ? - Transcoder::Validate(is, *os_) : - Transcoder::TranscodeUnsafe(is, *os_)))) - return false; - } - PutUnsafe(*os_, '\"'); - return true; - } - - bool ScanWriteUnescapedString(GenericStringStream& is, size_t length) { - return RAPIDJSON_LIKELY(is.Tell() < length); - } - - bool WriteStartObject() { os_->Put('{'); return true; } - bool WriteEndObject() { os_->Put('}'); return true; } - bool WriteStartArray() { os_->Put('['); return true; } - bool WriteEndArray() { os_->Put(']'); return true; } - - bool WriteRawValue(const Ch* json, size_t length) { - PutReserve(*os_, length); - for (size_t i = 0; i < length; i++) { - RAPIDJSON_ASSERT(json[i] != '\0'); - PutUnsafe(*os_, json[i]); - } - return true; - } - - void Prefix(Type type) { - (void)type; - if (RAPIDJSON_LIKELY(level_stack_.GetSize() != 0)) { // this value is not at root - Level* level = level_stack_.template Top(); - if (level->valueCount > 0) { - if (level->inArray) - os_->Put(','); // add comma if it is not the first element in array - else // in object - os_->Put((level->valueCount % 2 == 0) ? ',' : ':'); - } - if (!level->inArray && level->valueCount % 2 == 0) - RAPIDJSON_ASSERT(type == kStringType); // if it's in object, then even number should be a name - level->valueCount++; - } - else { - RAPIDJSON_ASSERT(!hasRoot_); // Should only has one and only one root. - hasRoot_ = true; - } - } - - // Flush the value if it is the top level one. - bool EndValue(bool ret) { - if (RAPIDJSON_UNLIKELY(level_stack_.Empty())) // end of json text - os_->Flush(); - return ret; - } - - OutputStream* os_; - internal::Stack level_stack_; - int maxDecimalPlaces_; - bool hasRoot_; - -private: - // Prohibit copy constructor & assignment operator. - Writer(const Writer&); - Writer& operator=(const Writer&); -}; - -// Full specialization for StringStream to prevent memory copying - -template<> -inline bool Writer::WriteInt(int i) { - char *buffer = os_->Push(11); - const char* end = internal::i32toa(i, buffer); - os_->Pop(static_cast(11 - (end - buffer))); - return true; -} - -template<> -inline bool Writer::WriteUint(unsigned u) { - char *buffer = os_->Push(10); - const char* end = internal::u32toa(u, buffer); - os_->Pop(static_cast(10 - (end - buffer))); - return true; -} - -template<> -inline bool Writer::WriteInt64(int64_t i64) { - char *buffer = os_->Push(21); - const char* end = internal::i64toa(i64, buffer); - os_->Pop(static_cast(21 - (end - buffer))); - return true; -} - -template<> -inline bool Writer::WriteUint64(uint64_t u) { - char *buffer = os_->Push(20); - const char* end = internal::u64toa(u, buffer); - os_->Pop(static_cast(20 - (end - buffer))); - return true; -} - -template<> -inline bool Writer::WriteDouble(double d) { - if (internal::Double(d).IsNanOrInf()) { - // Note: This code path can only be reached if (RAPIDJSON_WRITE_DEFAULT_FLAGS & kWriteNanAndInfFlag). - if (!(kWriteDefaultFlags & kWriteNanAndInfFlag)) - return false; - if (internal::Double(d).IsNan()) { - PutReserve(*os_, 3); - PutUnsafe(*os_, 'N'); PutUnsafe(*os_, 'a'); PutUnsafe(*os_, 'N'); - return true; - } - if (internal::Double(d).Sign()) { - PutReserve(*os_, 9); - PutUnsafe(*os_, '-'); - } - else - PutReserve(*os_, 8); - PutUnsafe(*os_, 'I'); PutUnsafe(*os_, 'n'); PutUnsafe(*os_, 'f'); - PutUnsafe(*os_, 'i'); PutUnsafe(*os_, 'n'); PutUnsafe(*os_, 'i'); PutUnsafe(*os_, 't'); PutUnsafe(*os_, 'y'); - return true; - } - - char *buffer = os_->Push(25); - char* end = internal::dtoa(d, buffer, maxDecimalPlaces_); - os_->Pop(static_cast(25 - (end - buffer))); - return true; -} - -#if defined(RAPIDJSON_SSE2) || defined(RAPIDJSON_SSE42) -template<> -inline bool Writer::ScanWriteUnescapedString(StringStream& is, size_t length) { - if (length < 16) - return RAPIDJSON_LIKELY(is.Tell() < length); - - if (!RAPIDJSON_LIKELY(is.Tell() < length)) - return false; - - const char* p = is.src_; - const char* end = is.head_ + length; - const char* nextAligned = reinterpret_cast((reinterpret_cast(p) + 15) & static_cast(~15)); - const char* endAligned = reinterpret_cast(reinterpret_cast(end) & static_cast(~15)); - if (nextAligned > end) - return true; - - while (p != nextAligned) - if (*p < 0x20 || *p == '\"' || *p == '\\') { - is.src_ = p; - return RAPIDJSON_LIKELY(is.Tell() < length); - } - else - os_->PutUnsafe(*p++); - - // The rest of string using SIMD - static const char dquote[16] = { '\"', '\"', '\"', '\"', '\"', '\"', '\"', '\"', '\"', '\"', '\"', '\"', '\"', '\"', '\"', '\"' }; - static const char bslash[16] = { '\\', '\\', '\\', '\\', '\\', '\\', '\\', '\\', '\\', '\\', '\\', '\\', '\\', '\\', '\\', '\\' }; - static const char space[16] = { 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19 }; - const __m128i dq = _mm_loadu_si128(reinterpret_cast(&dquote[0])); - const __m128i bs = _mm_loadu_si128(reinterpret_cast(&bslash[0])); - const __m128i sp = _mm_loadu_si128(reinterpret_cast(&space[0])); - - for (; p != endAligned; p += 16) { - const __m128i s = _mm_load_si128(reinterpret_cast(p)); - const __m128i t1 = _mm_cmpeq_epi8(s, dq); - const __m128i t2 = _mm_cmpeq_epi8(s, bs); - const __m128i t3 = _mm_cmpeq_epi8(_mm_max_epu8(s, sp), sp); // s < 0x20 <=> max(s, 0x19) == 0x19 - const __m128i x = _mm_or_si128(_mm_or_si128(t1, t2), t3); - unsigned short r = static_cast(_mm_movemask_epi8(x)); - if (RAPIDJSON_UNLIKELY(r != 0)) { // some of characters is escaped - SizeType len; -#ifdef _MSC_VER // Find the index of first escaped - unsigned long offset; - _BitScanForward(&offset, r); - len = offset; -#else - len = static_cast(__builtin_ffs(r) - 1); -#endif - char* q = reinterpret_cast(os_->PushUnsafe(len)); - for (size_t i = 0; i < len; i++) - q[i] = p[i]; - - p += len; - break; - } - _mm_storeu_si128(reinterpret_cast<__m128i *>(os_->PushUnsafe(16)), s); - } - - is.src_ = p; - return RAPIDJSON_LIKELY(is.Tell() < length); -} -#endif // defined(RAPIDJSON_SSE2) || defined(RAPIDJSON_SSE42) - -RAPIDJSON_NAMESPACE_END - -#ifdef _MSC_VER -RAPIDJSON_DIAG_POP -#endif - -#ifdef __clang__ -RAPIDJSON_DIAG_POP -#endif - -#endif // RAPIDJSON_RAPIDJSON_H_ diff --git a/slsReceiverSoftware/include/receiver_defs.h b/slsReceiverSoftware/include/receiver_defs.h deleted file mode 100755 index 7d34bef05..000000000 --- a/slsReceiverSoftware/include/receiver_defs.h +++ /dev/null @@ -1,50 +0,0 @@ -#pragma once - -#include "sls_receiver_defs.h" -#include - -#define MAX_DIMENSIONS 2 -//socket -#define GOODBYE -200 -#define RECEIVE_SOCKET_BUFFER_SIZE (100*1024*1024) - -#define MAX_SOCKET_INPUT_PACKET_QUEUE 250000 - - -//files -#define DO_NOTHING 0 -#define DO_EVERYTHING 1 - -#define STATISTIC_FRAMENUMBER_INFINITE 20000 - -//binary -#define FILE_BUFFER_SIZE (16*1024*1024) //16mb - -//fifo -#define FIFO_HEADER_NUMBYTES 4 - - -//hdf5 -#define MAX_CHUNKED_IMAGES 1 - -//versions -#define HDF5_WRITER_VERSION 3.0 //1 decimal places -#define BINARY_WRITER_VERSION 3.0 //1 decimal places - - -//parameters to calculate fifo depth -#define SAMPLE_TIME_IN_NS 100000000//100ms -#define MAX_JOBS_PER_THREAD 1000 - - -//to differentiate between gotthard and short gotthard -#define GOTTHARD_PACKET_SIZE 1286 - - -#define DUMMY_PACKET_VALUE 0xFFFFFFFF - -#define LISTENER_PRIORITY 90 -#define PROCESSOR_PRIORITY 70 -#define STREAMER_PRIORITY 10 -#define TCP_PRIORITY 10 - diff --git a/slsReceiverSoftware/include/slsReceiver.h b/slsReceiverSoftware/include/slsReceiver.h deleted file mode 100644 index 896f63817..000000000 --- a/slsReceiverSoftware/include/slsReceiver.h +++ /dev/null @@ -1,103 +0,0 @@ -#pragma once -/********************************************//** - * @file slsReceiver.h - * @short creates the UDP and TCP class objects - ***********************************************/ - - - -#include "slsReceiverTCPIPInterface.h" -#include "UDPInterface.h" - -#include "receiver_defs.h" -#include "MySocketTCP.h" -//#include "utilities.h" - - -/** - *@short creates the UDP and TCP class objects - */ - -class slsReceiver : private virtual slsReceiverDefs { - - public: - /** - * Constructor - * Starts up a Receiver server. Reads configuration file, options, and - * assembles a Receiver using TCP and UDP detector interfaces - * throws an exception in case of failure - * @param argc from command line - * @param argv from command line - */ - slsReceiver(int argc, char *argv[]); - - /** - * Destructor - */ - ~slsReceiver(); - - /** - * starts listening on the TCP port for client comminication - \return 0 for success or 1 for FAIL in creating TCP server - */ - int start(); - - /** - * stops listening to the TCP & UDP port and exit receiver program - */ - void stop(); - - /** - * get get Receiver Version - \returns id - */ - int64_t getReceiverVersion(); - - /** - * Call back for start acquisition - * callback arguments are - * filepath - * filename - * fileindex - * datasize - * - * return value is undefined at the moment - * we write depending on file write enable - * users get data to write depending on call backs registered - */ - void registerCallBackStartAcquisition(int (*func)(char*, char*, uint64_t, uint32_t, void*),void *arg); - - /** - * Call back for acquisition finished - * callback argument is - * total frames caught - */ - void registerCallBackAcquisitionFinished(void (*func)(uint64_t, void*),void *arg); - - /** - * Call back for raw data - * args to raw data ready callback are - * sls_receiver_header frame metadata - * dataPointer is the pointer to the data - * dataSize in bytes is the size of the data in bytes. - */ - void registerCallBackRawDataReady(void (*func)(char* , - char*, uint32_t, void*),void *arg); - - /** - * Call back for raw data (modified) - * args to raw data ready callback are - * sls_receiver_header frame metadata - * dataPointer is the pointer to the data - * revDatasize is the reference of data size in bytes. - * Can be modified to the new size to be written/streamed. (only smaller value). - */ - void registerCallBackRawDataModifyReady(void (*func)(char* , - char*, uint32_t &,void*),void *arg); - - - - private: - slsReceiverTCPIPInterface* tcpipInterface; -}; - diff --git a/slsReceiverSoftware/include/slsReceiverTCPIPInterface.h b/slsReceiverSoftware/include/slsReceiverTCPIPInterface.h deleted file mode 100644 index 1b28c2ed4..000000000 --- a/slsReceiverSoftware/include/slsReceiverTCPIPInterface.h +++ /dev/null @@ -1,373 +0,0 @@ -#pragma once -/********************************************//** - * @file slsReceiverTCPIPInterface.h - * @short interface between receiver and client - ***********************************************/ - - -#include "sls_receiver_defs.h" -#include "receiver_defs.h" -#include "MySocketTCP.h" -#include "UDPInterface.h" - - - -/** - *@short interface between receiver and client - */ - -class slsReceiverTCPIPInterface : private virtual slsReceiverDefs { - - public: - - /** Destructor */ - virtual ~slsReceiverTCPIPInterface(); - - /** - * Constructor - * reads config file, creates socket, assigns function table - * throws an exception in case of failure to construct - * @param pn port number (defaults to default port number) - */ - - slsReceiverTCPIPInterface(int pn=-1); - - /** - * Starts listening on the TCP port for client comminication - \returns OK or FAIL - */ - int start(); - - /** stop listening on the TCP & UDP port for client comminication */ - void stop(); - - - /** gets version */ - int64_t getReceiverVersion(); - - //***callback functions*** - /** - * Call back for start acquisition - * callback arguments are - * filepath - * filename - * fileindex - * datasize - * - * return value is insignificant at the moment - * we write depending on file write enable - * users get data to write depending on call backs registered - */ - void registerCallBackStartAcquisition(int (*func)(char*, char*, uint64_t, uint32_t, void*),void *arg); - - /** - * Call back for acquisition finished - * callback argument is - * total frames caught - */ - void registerCallBackAcquisitionFinished(void (*func)(uint64_t, void*),void *arg); - - /** - * Call back for raw data - * args to raw data ready callback are - * sls_receiver_header frame metadata - * dataPointer is the pointer to the data - * dataSize in bytes is the size of the data in bytes. - */ - void registerCallBackRawDataReady(void (*func)(char* , - char*, uint32_t, void*),void *arg); - - /** - * Call back for raw data (modified) - * args to raw data ready callback are - * sls_receiver_header frame metadata - * dataPointer is the pointer to the data - * revDatasize is the reference of data size in bytes. - * Can be modified to the new size to be written/streamed. (only smaller value). - */ - void registerCallBackRawDataModifyReady(void (*func)(char* , - char*, uint32_t &,void*),void *arg); - - private: - - /** - * Static function - Thread started which is a TCP server - * Called by start() - * @param this_pointer pointer to this object - */ - static void* startTCPServerThread(void *this_pointer); - - - /** - * Thread started which is a TCP server - * Called by start() - */ - void startTCPServer(); - - /** retuns function name with function index */ - const char* getFunctionName(enum recFuncs func); - - /** assigns functions to the fnum enum */ - int function_table(); - - /** Decodes Function */ - int decode_function(); - - /** print socket read error */ - int printSocketReadError(); - - /** receiver object is null */ - void invalidReceiverObject(); - - /** receiver already locked */ - void receiverlocked(); - - /** receiver not idle */ - void receiverNotIdle(); - - /** function not implemented for specific detector */ - void functionNotImplemented(); - - /** Unrecognized Function */ - int M_nofunc(); - - - - /** Execute command */ - int exec_command(); - - /** Exit Receiver Server */ - int exit_server(); - - /** Locks Receiver */ - int lock_receiver(); - - /** Get Last Client IP*/ - int get_last_client_ip(); - - /** Set port */ - int set_port(); - - /** Updates Client if different clients connect */ - int update_client(); - - /** Sends the updated parameters to client */ - int send_update(); - - /** get version, calls get_version */ - int get_id(); - - /** Set detector type */ - int set_detector_type(); - - /** set detector hostname */ - int set_detector_hostname(); - - /** set roi */ - int set_roi(); - - /** Set up UDP Details */ - int setup_udp(); - - /** set acquisition period, frame number etc */ - int set_timer(); - - /** set dynamic range */ - int set_dynamic_range(); - - /** Sets the receiver to send every nth frame to gui, or only upon gui request */ - int set_read_frequency(); - - /** Gets receiver status */ - int get_status(); - - /** Start Receiver - starts listening to udp packets from detector */ - int start_receiver(); - - /** Stop Receiver - stops listening to udp packets from detector*/ - int stop_receiver(); - - /** set status to transmitting and - * when fifo is empty later, sets status to run_finished */ - int start_readout(); - - /** Set File path */ - int set_file_dir(); - - /** Set File name without frame index, file index and extension */ - int set_file_name(); - - /** Set File index */ - int set_file_index(); - - /** Gets frame index for each acquisition */ - int get_frame_index(); - - /** Gets Total Frames Caught */ - int get_frames_caught(); - - /** Resets Total Frames Caught */ - int reset_frames_caught(); - - /** Enable File Write*/ - int enable_file_write(); - - /** enable compression */ - int enable_compression(); - - /** enable overwrite */ - int enable_overwrite(); - - /** enable 10Gbe */ - int enable_tengiga(); - - /** set fifo depth */ - int set_fifo_depth(); - - /** activate/ deactivate */ - int set_activate(); - - /* Set the data stream enable */ - int set_data_stream_enable(); - - /** Sets the timer between frames streamed by receiver when frequency is set to 0 */ - int set_read_receiver_timer(); - - /** enable flipped data */ - int set_flipped_data(); - - /** set file format */ - int set_file_format(); - - /** set position id */ - int set_detector_posid(); - - /** set multi detector size */ - int set_multi_detector_size(); - - /** set streaming port */ - int set_streaming_port(); - - /** set streaming source ip */ - int set_streaming_source_ip(); - - /** set silent mode */ - int set_silent_mode(); - - /** enable gap pixels */ - int enable_gap_pixels(); - - /** restream stop packet */ - int restream_stop(); - - /** set additional json header */ - int set_additional_json_header(); - - /** set udp socket buffer size */ - int set_udp_socket_buffer_size(); - - /** get real udp socket buffer size */ - int get_real_udp_socket_buffer_size(); - - /** set frames per file */ - int set_frames_per_file(); - - /** check version compatibility */ - int check_version_compatibility(); - - /** set frame discard policy */ - int set_discard_policy(); - - /** set partial frame padding enable*/ - int set_padding_enable(); - - /** set deactivated receiver padding enable */ - int set_deactivated_receiver_padding_enable(); - - - /** detector type */ - detectorType myDetectorType; - - /** slsReceiverBase object */ - UDPInterface *receiverBase; - - /** Function List */ - int (slsReceiverTCPIPInterface::*flist[NUM_REC_FUNCTIONS])(); - - /** Message */ - char mess[MAX_STR_LENGTH]; - - /** success/failure */ - int ret; - - /** function index */ - int fnum; - - /** Lock Status if server locked to a client */ - int lockStatus; - - /** kill tcp server thread */ - int killTCPServerThread; - - /** thread for TCP server */ - pthread_t TCPServer_thread; - - /** tcp thread created flag*/ - bool tcpThreadCreated; - - /** port number */ - int portNumber; - - //***callback parameters*** - /** - * Call back for start acquisition - * callback arguments are - * filepath - * filename - * fileindex - * datasize - * - * return value is insignificant at the moment - * we write depending on file write enable - * users get data to write depending on call backs registered - */ - int (*startAcquisitionCallBack)(char*, char*, uint64_t, uint32_t, void*); - void *pStartAcquisition; - - /** - * Call back for acquisition finished - * callback argument is - * total frames caught - */ - void (*acquisitionFinishedCallBack)(uint64_t, void*); - void *pAcquisitionFinished; - - - /** - * Call back for raw data - * args to raw data ready callback are - * sls_receiver_header frame metadata - * dataPointer is the pointer to the data - * dataSize in bytes is the size of the data in bytes. - */ - void (*rawDataReadyCallBack)(char* , - char*, uint32_t, void*); - - /** - * Call back for raw data (modified) - * args to raw data ready callback are - * sls_receiver_header frame metadata - * dataPointer is the pointer to the data - * revDatasize is the reference of data size in bytes. Can be modified to the new size to be written/streamed. (only smaller value). - */ - void (*rawDataModifyReadyCallBack)(char* , - char*, uint32_t &, void*); - - void *pRawDataReady; - - - -protected: - /** Socket */ - MySocketTCP* mySock; -}; diff --git a/slsReceiverSoftware/include/slsReceiverUsers.h b/slsReceiverSoftware/include/slsReceiverUsers.h deleted file mode 100644 index 8b17796d2..000000000 --- a/slsReceiverSoftware/include/slsReceiverUsers.h +++ /dev/null @@ -1,88 +0,0 @@ -#pragma once - -#include -#include - - -class slsReceiver; - - /** -@short Class for implementing the SLS data receiver in the users application. Callbacks can be defined for processing and/or saving data - - slsReceiverUsers is a class that can be instantiated in the users software to receive the data from the detectors. Callbacks can be defined for processing and/or saving data - ***********************************************/ - -class slsReceiverUsers { - -public: - /** - * Constructor - * reads config file, creates socket, assigns function table - * @param argc from command line - * @param argv from command line - * @param success socket creation was successfull - */ - slsReceiverUsers(int argc, char *argv[], int &success); - - - /** Destructor */ - ~slsReceiverUsers(); - - /** - * starts listening on the TCP port for client comminication - \return 0 for success or 1 for FAIL in creating TCP server - */ - int start(); - - /** stops listening to the TCP & UDP port and exit receiver program*/ - void stop(); - - /** - get get Receiver Version - \returns id - */ - int64_t getReceiverVersion(); - - /** - - @short register calbback for starting the acquisition - \param func callback to be called when starting the acquisition. Its arguments are filepath, filename, fileindex, datasize - \param arg argument - \return value is insignificant at the moment, we write depending on file write enable, users get data to write depending on call backs registered - */ - void registerCallBackStartAcquisition(int (*func)(char* filepath, char* filename, uint64_t fileindex, uint32_t datasize, void*),void *arg); - - - /** - @short register callback for end of acquisition - \param func end of acquisition callback. Argument nf is total frames caught - \param arg argument - \returns nothing - */ - void registerCallBackAcquisitionFinished(void (*func)(uint64_t nf, void*),void *arg); - - - - /** - @short register callback to be called when data are available (to process and/or save the data). - \param func raw data ready callback. arguments are sls_receiver_header, dataPointer, dataSize - \param arg argument - \returns nothing - */ - void registerCallBackRawDataReady(void (*func)(char* header, - char* datapointer, uint32_t datasize, void*),void *arg); - - - /** - @short register callback to be called when data are available (to process and/or save the data). - \param func raw data ready callback. arguments are sls_receiver_header, dataPointer, revDatasize is the reference of data size in bytes. Can be modified to the new size to be written/streamed. (only smaller value). - \param arg argument - \returns nothing - */ - void registerCallBackRawDataModifyReady(void (*func)(char* header, - char* datapointer, uint32_t &revDatasize, void*),void *arg); - - //receiver object - slsReceiver* receiver; -}; - diff --git a/slsReceiverSoftware/include/sls_receiver_defs.h b/slsReceiverSoftware/include/sls_receiver_defs.h deleted file mode 100755 index c23558fa8..000000000 --- a/slsReceiverSoftware/include/sls_receiver_defs.h +++ /dev/null @@ -1,323 +0,0 @@ -#pragma once - - -#ifdef __CINT__ -#define MYROOT -#define __cplusplus -#endif - -#include -#ifdef __cplusplus -#include -#include -#endif -#include "ansi.h" - - -typedef double double32_t; -typedef float float32_t; -typedef int int32_t; - -/** default maximum string length */ -#define MAX_STR_LENGTH 1000 -#define MAX_FRAMES_PER_FILE 20000 -#define SHORT_MAX_FRAMES_PER_FILE 100000 -#define MOENCH_MAX_FRAMES_PER_FILE 1000 -#define EIGER_MAX_FRAMES_PER_FILE 10000 -#define JFRAU_MAX_FRAMES_PER_FILE 10000 -#define JFCTB_MAX_FRAMES_PER_FILE 100000 - - -#define DEFAULT_STREAMING_TIMER_IN_MS 200 - -/** default ports */ -#define DEFAULT_PORTNO 1952 -#define DEFAULT_UDP_PORTNO 50001 -#define DEFAULT_GUI_PORTNO 65001 -#define DEFAULT_ZMQ_CL_PORTNO 30001 -#define DEFAULT_ZMQ_RX_PORTNO 30001 - -#define SLS_DETECTOR_HEADER_VERSION 0x2 -#define SLS_DETECTOR_JSON_HEADER_VERSION 0x3 - -/** - \file sls_receiver_defs.h -This file contains all the basic definitions common to the slsReceiver class -and to the server programs running on the receiver - * @author Anna Bergamaschi - * @version 0.1alpha (any string) - * @see slsDetector -$Revision: 809 $ - */ - - -#ifdef __cplusplus - -/** @short class containing all the constants and enum definitions */ -class slsReceiverDefs { -public: - - slsReceiverDefs(){}; - -#endif - - /** - Type of the detector - */ - enum detectorType { - GET_DETECTOR_TYPE=-1, /**< the detector will return its type */ - GENERIC, /**< generic sls detector */ - MYTHEN, /**< mythen */ - PILATUS, /**< pilatus */ - EIGER, /**< eiger */ - GOTTHARD, /**< gotthard */ - PICASSO, /**< picasso */ - AGIPD, /**< agipd */ - MOENCH, /**< moench */ - JUNGFRAU, /**< jungfrau */ - JUNGFRAUCTB, /**< jungfrauCTBversion */ - PROPIX, /**< propix */ - MYTHEN3 /**< mythen 3 */ - }; - - - /** - return values - */ - enum { - OK, /**< function succeeded */ - FAIL, /**< function failed */ - FINISHED, /**< acquisition finished */ - FORCE_UPDATE - }; - - - /** - indexes for the acquisition timers - */ - enum timerIndex { - FRAME_NUMBER, /**< number of real time frames: total number of acquisitions is number or frames*number of cycles */ - ACQUISITION_TIME, /**< exposure time */ - FRAME_PERIOD, /**< period between exposures */ - DELAY_AFTER_TRIGGER, /**< delay between trigger and start of exposure or readout (in triggered mode) */ - GATES_NUMBER, /**< number of gates per frame (in gated mode) */ - PROBES_NUMBER, /**< number of probe types in pump-probe mode */ - CYCLES_NUMBER, /**< number of cycles: total number of acquisitions is number or frames*number of cycles */ - ACTUAL_TIME, /**< Actual time of the detector's internal timer */ - MEASUREMENT_TIME, /**< Time of the measurement from the detector (fifo) */ - - PROGRESS, /**< fraction of measurement elapsed - only get! */ - MEASUREMENTS_NUMBER, - FRAMES_FROM_START, - FRAMES_FROM_START_PG, - SAMPLES_JCTB, - SUBFRAME_ACQUISITION_TIME, /**< subframe exposure time */ - STORAGE_CELL_NUMBER, /** sls_bitset; - - typedef struct { - sls_detector_header detHeader; /**< is the detector header */ - sls_bitset packetsMask; /**< is the packets caught bit mask */ - } sls_receiver_header; - - typedef uint8_t bitset_storage[MAX_NUM_PACKETS/8]; - -#endif - /** - * frameDiscardPolicy - */ - enum frameDiscardPolicy { - GET_FRAME_DISCARD_POLICY = -1, /**< to get the missing packet mode */ - NO_DISCARD, /**< pad incomplete packets with -1, default mode */ - DISCARD_EMPTY_FRAMES, /**< discard incomplete frames, fastest mode, save space, not suitable for multiple modules */ - DISCARD_PARTIAL_FRAMES, /**< ignore missing packets, must check with packetsMask for data integrity, fast mode and suitable for multiple modules */ - NUM_DISCARD_POLICIES - }; - - - /** - format - */ - enum fileFormat { - GET_FILE_FORMAT=-1,/**< the receiver will return its file format */ - BINARY, /**< binary format */ - ASCII, /**< ascii format */ - HDF5, /**< hdf5 format */ - NUM_FILE_FORMATS - }; - - - /** - @short structure for a region of interest - xmin,xmax,ymin,ymax define the limits of the region - */ - typedef struct { - int xmin; /**< is the roi xmin (in channel number) */ - int xmax; /**< is the roi xmax (in channel number)*/ - int ymin; /**< is the roi ymin (in channel number)*/ - int ymax; /**< is the roi ymax (in channel number)*/ - } ROI ; - - - -#ifdef __cplusplus - /** returns string from enabled/disabled - \param b true or false - \returns string enabled, disabled - */ - static std::string stringEnable(bool b){\ - if(b) return std::string("enabled"); \ - else return std::string("disabled"); \ - }; - - /** returns detector type string from detector type index - \param t string can be Mythen, Pilatus, Eiger, Gotthard, Agipd, Unknown - \returns MYTHEN, PILATUS, EIGER, GOTTHARD, AGIPD, MÖNCH, GENERIC - */ - static std::string getDetectorType(detectorType t){ \ - switch (t) { \ - case MYTHEN: return std::string("Mythen"); \ - case PILATUS: return std::string("Pilatus"); \ - case EIGER: return std::string("Eiger"); \ - case GOTTHARD: return std::string("Gotthard"); \ - case AGIPD: return std::string("Agipd"); \ - case MOENCH: return std::string("Moench"); \ - case JUNGFRAU: return std::string("Jungfrau"); \ - case JUNGFRAUCTB: return std::string("JungfrauCTB"); \ - case PROPIX: return std::string("Propix"); \ - case MYTHEN3: return std::string("Mythen3"); \ - default: return std::string("Unknown"); \ - }}; - - /** returns detector type index from detector type string - \param type can be MYTHEN, PILATUS, EIGER, GOTTHARD, AGIPD, GENERIC - \returns Mythen, Pilatus, Eiger, Gotthard, Agipd, Mönch, Unknown - */ - static detectorType getDetectorType(std::string const type){\ - if (type=="Mythen") return MYTHEN; \ - if (type=="Pilatus") return PILATUS; \ - if (type=="Eiger") return EIGER; \ - if (type=="Gotthard") return GOTTHARD; \ - if (type=="Agipd") return AGIPD; \ - if (type=="Moench") return MOENCH; \ - if (type=="Jungfrau") return JUNGFRAU; \ - if (type=="JungfrauCTB") return JUNGFRAUCTB; \ - if (type=="Propix") return PROPIX; \ - if (type=="Mythen3") return MYTHEN3; \ - return GENERIC; \ - }; - - - /** returns string from run status index - \param s can be ERROR, WAITING, RUNNING, TRANSMITTING, RUN_FINISHED - \returns string error, waiting, running, data, finished - */ - static std::string runStatusType(runStatus s){\ - switch (s) { \ - case ERROR: return std::string("error"); \ - case WAITING: return std::string("waiting"); \ - case RUNNING: return std::string("running"); \ - case TRANSMITTING: return std::string("data"); \ - case RUN_FINISHED: return std::string("finished"); \ - case STOPPED: return std::string("stopped"); \ - default: return std::string("idle"); \ - }}; - - - /** returns string from file format index - \param s can be BINARY, ASCII, HDF5 - \returns string binary, ascii, hdf5 - */ - static std::string getFileFormatType(fileFormat f){\ - switch (f) { \ - case ASCII: return std::string("ascii"); \ - case HDF5: return std::string("hdf5"); \ - case BINARY: return std::string("binary"); \ - default: return std::string("unknown"); \ - }}; - - /** - * Returns string of frame discard policy index - * @param f can be NO_DISCARD, DISCARD_EMPTY_FRAMES, DISCARD_PARTIAL_FRAMES - * @returns No Discard, Discard Empty Frames, Discard Partial Frames, unknown - */ - static std::string getFrameDiscardPolicyType(frameDiscardPolicy f) { \ - switch (f) { \ - case NO_DISCARD: return std::string("No Discard"); \ - case DISCARD_EMPTY_FRAMES: return std::string("Discard Empty Frames"); \ - case DISCARD_PARTIAL_FRAMES: return std::string("Discard Partial Frames"); \ - default: return std::string("unknown"); \ - }}; \ - -#endif - -#ifdef __cplusplus -protected: -#endif - -#ifndef MYROOT -#include "sls_receiver_funcs.h" -#endif - -#ifdef __cplusplus -}; -#endif -; diff --git a/slsReceiverSoftware/include/sls_receiver_exceptions.h b/slsReceiverSoftware/include/sls_receiver_exceptions.h deleted file mode 100644 index 8ad322ff6..000000000 --- a/slsReceiverSoftware/include/sls_receiver_exceptions.h +++ /dev/null @@ -1,42 +0,0 @@ -#pragma once -/************************************************ - * @file sls_receiver_exceptions.h - * @short exceptions defined - ***********************************************/ -/** - *@short exceptions defined - */ - -#include -#include - -struct SlsDetectorPackageExceptions : public std::exception { -public: - SlsDetectorPackageExceptions() {} - std::string GetMessage() const { return "SLS Detector Package Failed";}; -}; - -struct SharedMemoryException : public SlsDetectorPackageExceptions { -public: - SharedMemoryException() {} - std::string GetMessage() const { return "Shared Memory Failed";}; -}; - -struct ThreadpoolException : public SlsDetectorPackageExceptions { -public: - ThreadpoolException() {} - std::string GetMessage() const { return "Threadpool Failed";}; -}; - -struct SocketException : public SlsDetectorPackageExceptions { -public: - SocketException() {} - std::string GetMessage() const { return "Socket Failed";}; -}; - -struct SamePortSocketException : public SocketException { -public: - SamePortSocketException() {} - std::string GetMessage() const { return "Socket Failed";}; -}; - diff --git a/slsReceiverSoftware/include/sls_receiver_funcs.h b/slsReceiverSoftware/include/sls_receiver_funcs.h deleted file mode 100644 index 281088f19..000000000 --- a/slsReceiverSoftware/include/sls_receiver_funcs.h +++ /dev/null @@ -1,80 +0,0 @@ -#pragma once -/** - @internal - function indexes to call on the server - All set functions with argument -1 work as get, when possible - */ - -#define REC_FUNC_START_INDEX 128 - -enum recFuncs{ - //General functions - F_EXEC_RECEIVER_COMMAND=REC_FUNC_START_INDEX, /**< command is executed */ - F_EXIT_RECEIVER, /**< turn off receiver server */ - F_LOCK_RECEIVER, /**< Locks/Unlocks server communication to the given client */ - F_GET_LAST_RECEIVER_CLIENT_IP, /**< returns the IP of the client last connected to the receiver */ - F_SET_RECEIVER_PORT, /**< Changes communication port of the receiver */ - F_UPDATE_RECEIVER_CLIENT, /**< Returns all the important parameters to update the shared memory of the client */ - - // Identification - F_GET_RECEIVER_ID, /**< get receiver id of version */ - F_GET_RECEIVER_TYPE, /**< return receiver type */ - F_SEND_RECEIVER_DETHOSTNAME, /**< set detector hostname to receiver */ - - //network functions - F_RECEIVER_SET_ROI, /**< Sets receiver ROI */ - F_SETUP_RECEIVER_UDP, /**< sets the receiver udp connection and returns receiver mac address */ - - //Acquisition setup functions - F_SET_RECEIVER_TIMER, /**< set/get timer value */ - F_SET_RECEIVER_DYNAMIC_RANGE, /**< set/get detector dynamic range */ - F_READ_RECEIVER_FREQUENCY, /**< sets the frequency of receiver sending frames to gui */ - - // Acquisition functions - F_GET_RECEIVER_STATUS, /**< gets the status of receiver listening mode */ - F_START_RECEIVER, /**< starts the receiver listening mode */ - F_STOP_RECEIVER, /**< stops the receiver listening mode */ - F_START_RECEIVER_READOUT, /**< acquisition has stopped. start remaining readout in receiver */ - - //file functions - F_SET_RECEIVER_FILE_PATH, /**< sets receiver file directory */ - F_SET_RECEIVER_FILE_NAME, /**< sets receiver file name */ - F_SET_RECEIVER_FILE_INDEX, /**< sets receiver file index */ - F_GET_RECEIVER_FRAME_INDEX, /**< gets the receiver frame index */ - F_GET_RECEIVER_FRAMES_CAUGHT, /**< gets the number of frames caught by receiver */ - F_RESET_RECEIVER_FRAMES_CAUGHT, /**< resets the frames caught by receiver */ - F_ENABLE_RECEIVER_FILE_WRITE, /**< sets the receiver file write */ - F_ENABLE_RECEIVER_COMPRESSION, /**< enable compression in receiver */ - F_ENABLE_RECEIVER_OVERWRITE, /**< set overwrite flag in receiver */ - - F_ENABLE_RECEIVER_TEN_GIGA, /**< enable 10Gbe in receiver */ - F_SET_RECEIVER_FIFO_DEPTH, /**< set receiver fifo depth */ - - F_RECEIVER_ACTIVATE, /** < activate/deactivate readout */ - F_STREAM_DATA_FROM_RECEIVER, /**< stream data from receiver to client */ - F_READ_RECEIVER_TIMER, /** < sets the timer between each data stream in receiver */ - F_SET_FLIPPED_DATA_RECEIVER, /** < sets the enable to flip data across x/y axis (bottom/top) */ - F_SET_RECEIVER_FILE_FORMAT, /** < sets the receiver file format */ - - F_SEND_RECEIVER_DETPOSID, /** < sets the detector position id in the reveiver */ - F_SEND_RECEIVER_MULTIDETSIZE, /** < sets the multi detector size to the receiver */ - F_SET_RECEIVER_STREAMING_PORT, /** < sets the receiver streaming port */ - F_RECEIVER_STREAMING_SRC_IP, /** < sets the receiver streaming source IP */ - F_SET_RECEIVER_SILENT_MODE, /** < sets the receiver silent mode */ - F_ENABLE_GAPPIXELS_IN_RECEIVER, /** < sets gap pixels in the receiver */ - F_RESTREAM_STOP_FROM_RECEIVER, /** < restream stop from receiver */ - F_ADDITIONAL_JSON_HEADER, /** < additional json header */ - F_RECEIVER_UDP_SOCK_BUF_SIZE, /** < UDP socket buffer size */ - F_RECEIVER_REAL_UDP_SOCK_BUF_SIZE, /** < real UDP socket buffer size */ - F_SET_RECEIVER_FRAMES_PER_FILE, /** < receiver frames per file */ - F_RECEIVER_CHECK_VERSION, /** < check receiver version compatibility */ - F_RECEIVER_DISCARD_POLICY, /** < frames discard policy */ - F_RECEIVER_PADDING_ENABLE, /** < partial frames padding enable */ - F_RECEIVER_DEACTIVATED_PADDING_ENABLE, /** < deactivated receiver padding enable */ - /* Always append functions hereafter!!! */ - - - /* Always append functions before!!! */ - NUM_REC_FUNCTIONS -}; - diff --git a/slsReceiverSoftware/include/utilities.h b/slsReceiverSoftware/include/utilities.h deleted file mode 100644 index 5db78e8e1..000000000 --- a/slsReceiverSoftware/include/utilities.h +++ /dev/null @@ -1,15 +0,0 @@ -#pragma once -#include -#include -#include -#include -#include - -#include "sls_receiver_defs.h" - -/* uncomment next line to enable debug output */ -//#define EIGER_DEBUG - - -int read_config_file(std::string fname, int *tcpip_port_no, std::map * configuration_map); - diff --git a/slsReceiverSoftware/include/versionAPI.h b/slsReceiverSoftware/include/versionAPI.h deleted file mode 120000 index a4d75aa2a..000000000 --- a/slsReceiverSoftware/include/versionAPI.h +++ /dev/null @@ -1 +0,0 @@ -../../slsDetectorSoftware/commonFiles/versionAPI.h \ No newline at end of file diff --git a/slsReceiverSoftware/include/zmq.h b/slsReceiverSoftware/include/zmq.h deleted file mode 100644 index 8970d5bd6..000000000 --- a/slsReceiverSoftware/include/zmq.h +++ /dev/null @@ -1,417 +0,0 @@ -/* - Copyright (c) 2007-2013 Contributors as noted in the AUTHORS file - - This file is part of 0MQ. - - 0MQ is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - 0MQ is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . - - ************************************************************************* - NOTE to contributors. This file comprises the principal public contract - for ZeroMQ API users (along with zmq_utils.h). Any change to this file - supplied in a stable release SHOULD not break existing applications. - In practice this means that the value of constants must not change, and - that old values may not be reused for new constants. - ************************************************************************* -*/ - -#ifndef __ZMQ_H_INCLUDED__ -#define __ZMQ_H_INCLUDED__ - -/* Version macros for compile-time API version detection */ -#define ZMQ_VERSION_MAJOR 4 -#define ZMQ_VERSION_MINOR 0 -#define ZMQ_VERSION_PATCH 8 - -#define ZMQ_MAKE_VERSION(major, minor, patch) \ - ((major) * 10000 + (minor) * 100 + (patch)) -#define ZMQ_VERSION \ - ZMQ_MAKE_VERSION(ZMQ_VERSION_MAJOR, ZMQ_VERSION_MINOR, ZMQ_VERSION_PATCH) - -#ifdef __cplusplus -extern "C" { -#endif - -#if !defined _WIN32_WCE -#include -#endif -#include -#include -#if defined _WIN32 -#include -#endif - -/* Handle DSO symbol visibility */ -#if defined _WIN32 -# if defined ZMQ_STATIC -# define ZMQ_EXPORT -# elif defined DLL_EXPORT -# define ZMQ_EXPORT __declspec(dllexport) -# else -# define ZMQ_EXPORT __declspec(dllimport) -# endif -#else -# if defined __SUNPRO_C || defined __SUNPRO_CC -# define ZMQ_EXPORT __global -# elif (defined __GNUC__ && __GNUC__ >= 4) || defined __INTEL_COMPILER -# define ZMQ_EXPORT __attribute__ ((visibility("default"))) -# else -# define ZMQ_EXPORT -# endif -#endif - -/* Define integer types needed for event interface */ -#if defined ZMQ_HAVE_SOLARIS || defined ZMQ_HAVE_OPENVMS -# include -#elif defined _MSC_VER && _MSC_VER < 1600 -# ifndef int32_t -typedef __int32 int32_t; -# endif -# ifndef uint16_t -typedef unsigned __int16 uint16_t; -# endif -# ifndef uint8_t -typedef unsigned __int8 uint8_t; -# endif -#else -# include -#endif - - -/******************************************************************************/ -/* 0MQ errors. */ -/******************************************************************************/ - -/* A number random enough not to collide with different errno ranges on */ -/* different OSes. The assumption is that error_t is at least 32-bit type. */ -#define ZMQ_HAUSNUMERO 156384712 - -/* On Windows platform some of the standard POSIX errnos are not defined. */ -#ifndef ENOTSUP -#define ENOTSUP (ZMQ_HAUSNUMERO + 1) -#endif -#ifndef EPROTONOSUPPORT -#define EPROTONOSUPPORT (ZMQ_HAUSNUMERO + 2) -#endif -#ifndef ENOBUFS -#define ENOBUFS (ZMQ_HAUSNUMERO + 3) -#endif -#ifndef ENETDOWN -#define ENETDOWN (ZMQ_HAUSNUMERO + 4) -#endif -#ifndef EADDRINUSE -#define EADDRINUSE (ZMQ_HAUSNUMERO + 5) -#endif -#ifndef EADDRNOTAVAIL -#define EADDRNOTAVAIL (ZMQ_HAUSNUMERO + 6) -#endif -#ifndef ECONNREFUSED -#define ECONNREFUSED (ZMQ_HAUSNUMERO + 7) -#endif -#ifndef EINPROGRESS -#define EINPROGRESS (ZMQ_HAUSNUMERO + 8) -#endif -#ifndef ENOTSOCK -#define ENOTSOCK (ZMQ_HAUSNUMERO + 9) -#endif -#ifndef EMSGSIZE -#define EMSGSIZE (ZMQ_HAUSNUMERO + 10) -#endif -#ifndef EAFNOSUPPORT -#define EAFNOSUPPORT (ZMQ_HAUSNUMERO + 11) -#endif -#ifndef ENETUNREACH -#define ENETUNREACH (ZMQ_HAUSNUMERO + 12) -#endif -#ifndef ECONNABORTED -#define ECONNABORTED (ZMQ_HAUSNUMERO + 13) -#endif -#ifndef ECONNRESET -#define ECONNRESET (ZMQ_HAUSNUMERO + 14) -#endif -#ifndef ENOTCONN -#define ENOTCONN (ZMQ_HAUSNUMERO + 15) -#endif -#ifndef ETIMEDOUT -#define ETIMEDOUT (ZMQ_HAUSNUMERO + 16) -#endif -#ifndef EHOSTUNREACH -#define EHOSTUNREACH (ZMQ_HAUSNUMERO + 17) -#endif -#ifndef ENETRESET -#define ENETRESET (ZMQ_HAUSNUMERO + 18) -#endif - -/* Native 0MQ error codes. */ -#define EFSM (ZMQ_HAUSNUMERO + 51) -#define ENOCOMPATPROTO (ZMQ_HAUSNUMERO + 52) -#define ETERM (ZMQ_HAUSNUMERO + 53) -#define EMTHREAD (ZMQ_HAUSNUMERO + 54) - -/* Run-time API version detection */ -ZMQ_EXPORT void zmq_version (int *major, int *minor, int *patch); - -/* This function retrieves the errno as it is known to 0MQ library. The goal */ -/* of this function is to make the code 100% portable, including where 0MQ */ -/* compiled with certain CRT library (on Windows) is linked to an */ -/* application that uses different CRT library. */ -ZMQ_EXPORT int zmq_errno (void); - -/* Resolves system errors and 0MQ errors to human-readable string. */ -ZMQ_EXPORT const char *zmq_strerror (int errnum); - -/******************************************************************************/ -/* 0MQ infrastructure (a.k.a. context) initialisation & termination. */ -/******************************************************************************/ - -/* New API */ -/* Context options */ -#define ZMQ_IO_THREADS 1 -#define ZMQ_MAX_SOCKETS 2 - -/* Default for new contexts */ -#define ZMQ_IO_THREADS_DFLT 1 -#define ZMQ_MAX_SOCKETS_DFLT 1023 - -ZMQ_EXPORT void *zmq_ctx_new (void); -ZMQ_EXPORT int zmq_ctx_term (void *context); -ZMQ_EXPORT int zmq_ctx_shutdown (void *ctx_); -ZMQ_EXPORT int zmq_ctx_set (void *context, int option, int optval); -ZMQ_EXPORT int zmq_ctx_get (void *context, int option); - -/* Old (legacy) API */ -ZMQ_EXPORT void *zmq_init (int io_threads); -ZMQ_EXPORT int zmq_term (void *context); -ZMQ_EXPORT int zmq_ctx_destroy (void *context); - - -/******************************************************************************/ -/* 0MQ message definition. */ -/******************************************************************************/ - -typedef struct zmq_msg_t {unsigned char _ [32];} zmq_msg_t; - -typedef void (zmq_free_fn) (void *data, void *hint); - -ZMQ_EXPORT int zmq_msg_init (zmq_msg_t *msg); -ZMQ_EXPORT int zmq_msg_init_size (zmq_msg_t *msg, size_t size); -ZMQ_EXPORT int zmq_msg_init_data (zmq_msg_t *msg, void *data, - size_t size, zmq_free_fn *ffn, void *hint); -ZMQ_EXPORT int zmq_msg_send (zmq_msg_t *msg, void *s, int flags); -ZMQ_EXPORT int zmq_msg_recv (zmq_msg_t *msg, void *s, int flags); -ZMQ_EXPORT int zmq_msg_close (zmq_msg_t *msg); -ZMQ_EXPORT int zmq_msg_move (zmq_msg_t *dest, zmq_msg_t *src); -ZMQ_EXPORT int zmq_msg_copy (zmq_msg_t *dest, zmq_msg_t *src); -ZMQ_EXPORT void *zmq_msg_data (zmq_msg_t *msg); -ZMQ_EXPORT size_t zmq_msg_size (zmq_msg_t *msg); -ZMQ_EXPORT int zmq_msg_more (zmq_msg_t *msg); -ZMQ_EXPORT int zmq_msg_get (zmq_msg_t *msg, int option); -ZMQ_EXPORT int zmq_msg_set (zmq_msg_t *msg, int option, int optval); - - -/******************************************************************************/ -/* 0MQ socket definition. */ -/******************************************************************************/ - -/* Socket types. */ -#define ZMQ_PAIR 0 -#define ZMQ_PUB 1 -#define ZMQ_SUB 2 -#define ZMQ_REQ 3 -#define ZMQ_REP 4 -#define ZMQ_DEALER 5 -#define ZMQ_ROUTER 6 -#define ZMQ_PULL 7 -#define ZMQ_PUSH 8 -#define ZMQ_XPUB 9 -#define ZMQ_XSUB 10 -#define ZMQ_STREAM 11 - -/* Deprecated aliases */ -#define ZMQ_XREQ ZMQ_DEALER -#define ZMQ_XREP ZMQ_ROUTER - -/* Socket options. */ -#define ZMQ_AFFINITY 4 -#define ZMQ_IDENTITY 5 -#define ZMQ_SUBSCRIBE 6 -#define ZMQ_UNSUBSCRIBE 7 -#define ZMQ_RATE 8 -#define ZMQ_RECOVERY_IVL 9 -#define ZMQ_SNDBUF 11 -#define ZMQ_RCVBUF 12 -#define ZMQ_RCVMORE 13 -#define ZMQ_FD 14 -#define ZMQ_EVENTS 15 -#define ZMQ_TYPE 16 -#define ZMQ_LINGER 17 -#define ZMQ_RECONNECT_IVL 18 -#define ZMQ_BACKLOG 19 -#define ZMQ_RECONNECT_IVL_MAX 21 -#define ZMQ_MAXMSGSIZE 22 -#define ZMQ_SNDHWM 23 -#define ZMQ_RCVHWM 24 -#define ZMQ_MULTICAST_HOPS 25 -#define ZMQ_RCVTIMEO 27 -#define ZMQ_SNDTIMEO 28 -#define ZMQ_LAST_ENDPOINT 32 -#define ZMQ_ROUTER_MANDATORY 33 -#define ZMQ_TCP_KEEPALIVE 34 -#define ZMQ_TCP_KEEPALIVE_CNT 35 -#define ZMQ_TCP_KEEPALIVE_IDLE 36 -#define ZMQ_TCP_KEEPALIVE_INTVL 37 -#define ZMQ_TCP_ACCEPT_FILTER 38 -#define ZMQ_IMMEDIATE 39 -#define ZMQ_XPUB_VERBOSE 40 -#define ZMQ_ROUTER_RAW 41 -#define ZMQ_IPV6 42 -#define ZMQ_MECHANISM 43 -#define ZMQ_PLAIN_SERVER 44 -#define ZMQ_PLAIN_USERNAME 45 -#define ZMQ_PLAIN_PASSWORD 46 -#define ZMQ_CURVE_SERVER 47 -#define ZMQ_CURVE_PUBLICKEY 48 -#define ZMQ_CURVE_SECRETKEY 49 -#define ZMQ_CURVE_SERVERKEY 50 -#define ZMQ_PROBE_ROUTER 51 -#define ZMQ_REQ_CORRELATE 52 -#define ZMQ_REQ_RELAXED 53 -#define ZMQ_CONFLATE 54 -#define ZMQ_ZAP_DOMAIN 55 - -/* Message options */ -#define ZMQ_MORE 1 - -/* Send/recv options. */ -#define ZMQ_DONTWAIT 1 -#define ZMQ_SNDMORE 2 - -/* Security mechanisms */ -#define ZMQ_NULL 0 -#define ZMQ_PLAIN 1 -#define ZMQ_CURVE 2 - -/* Deprecated options and aliases */ -#define ZMQ_IPV4ONLY 31 -#define ZMQ_DELAY_ATTACH_ON_CONNECT ZMQ_IMMEDIATE -#define ZMQ_NOBLOCK ZMQ_DONTWAIT -#define ZMQ_FAIL_UNROUTABLE ZMQ_ROUTER_MANDATORY -#define ZMQ_ROUTER_BEHAVIOR ZMQ_ROUTER_MANDATORY - -/******************************************************************************/ -/* 0MQ socket events and monitoring */ -/******************************************************************************/ - -/* Socket transport events (tcp and ipc only) */ -#define ZMQ_EVENT_CONNECTED 1 -#define ZMQ_EVENT_CONNECT_DELAYED 2 -#define ZMQ_EVENT_CONNECT_RETRIED 4 - -#define ZMQ_EVENT_LISTENING 8 -#define ZMQ_EVENT_BIND_FAILED 16 - -#define ZMQ_EVENT_ACCEPTED 32 -#define ZMQ_EVENT_ACCEPT_FAILED 64 - -#define ZMQ_EVENT_CLOSED 128 -#define ZMQ_EVENT_CLOSE_FAILED 256 -#define ZMQ_EVENT_DISCONNECTED 512 -#define ZMQ_EVENT_MONITOR_STOPPED 1024 - -#define ZMQ_EVENT_ALL ( ZMQ_EVENT_CONNECTED | ZMQ_EVENT_CONNECT_DELAYED | \ - ZMQ_EVENT_CONNECT_RETRIED | ZMQ_EVENT_LISTENING | \ - ZMQ_EVENT_BIND_FAILED | ZMQ_EVENT_ACCEPTED | \ - ZMQ_EVENT_ACCEPT_FAILED | ZMQ_EVENT_CLOSED | \ - ZMQ_EVENT_CLOSE_FAILED | ZMQ_EVENT_DISCONNECTED | \ - ZMQ_EVENT_MONITOR_STOPPED) - -/* Socket event data */ -typedef struct { - uint16_t event; // id of the event as bitfield - int32_t value ; // value is either error code, fd or reconnect interval -} zmq_event_t; - -ZMQ_EXPORT void *zmq_socket (void *, int type); -ZMQ_EXPORT int zmq_close (void *s); -ZMQ_EXPORT int zmq_setsockopt (void *s, int option, const void *optval, - size_t optvallen); -ZMQ_EXPORT int zmq_getsockopt (void *s, int option, void *optval, - size_t *optvallen); -ZMQ_EXPORT int zmq_bind (void *s, const char *addr); -ZMQ_EXPORT int zmq_connect (void *s, const char *addr); -ZMQ_EXPORT int zmq_unbind (void *s, const char *addr); -ZMQ_EXPORT int zmq_disconnect (void *s, const char *addr); -ZMQ_EXPORT int zmq_send (void *s, const void *buf, size_t len, int flags); -ZMQ_EXPORT int zmq_send_const (void *s, const void *buf, size_t len, int flags); -ZMQ_EXPORT int zmq_recv (void *s, void *buf, size_t len, int flags); -ZMQ_EXPORT int zmq_socket_monitor (void *s, const char *addr, int events); - -ZMQ_EXPORT int zmq_sendmsg (void *s, zmq_msg_t *msg, int flags); -ZMQ_EXPORT int zmq_recvmsg (void *s, zmq_msg_t *msg, int flags); - -/* Experimental */ -struct iovec; - -ZMQ_EXPORT int zmq_sendiov (void *s, struct iovec *iov, size_t count, int flags); -ZMQ_EXPORT int zmq_recviov (void *s, struct iovec *iov, size_t *count, int flags); - -/******************************************************************************/ -/* I/O multiplexing. */ -/******************************************************************************/ - -#define ZMQ_POLLIN 1 -#define ZMQ_POLLOUT 2 -#define ZMQ_POLLERR 4 - -typedef struct -{ - void *socket; -#if defined _WIN32 - SOCKET fd; -#else - int fd; -#endif - short events; - short revents; -} zmq_pollitem_t; - -#define ZMQ_POLLITEMS_DFLT 16 - -ZMQ_EXPORT int zmq_poll (zmq_pollitem_t *items, int nitems, long timeout); - -/* Built-in message proxy (3-way) */ - -ZMQ_EXPORT int zmq_proxy (void *frontend, void *backend, void *capture); -ZMQ_EXPORT int zmq_proxy_steerable (void *frontend, void *backend, void *capture, void *control); - -/* Encode a binary key as printable text using ZMQ RFC 32 */ -ZMQ_EXPORT char *zmq_z85_encode (char *dest, uint8_t *data, size_t size); - -/* Encode a binary key from printable text per ZMQ RFC 32 */ -ZMQ_EXPORT uint8_t *zmq_z85_decode (uint8_t *dest, char *string); - -/* Deprecated aliases */ -#define ZMQ_STREAMER 1 -#define ZMQ_FORWARDER 2 -#define ZMQ_QUEUE 3 -/* Deprecated method */ -ZMQ_EXPORT int zmq_device (int type, void *frontend, void *backend); - -#undef ZMQ_EXPORT - -#ifdef __cplusplus -} -#endif - -#endif - diff --git a/slsReceiverSoftware/slsReceiverUsers.doxy b/slsReceiverSoftware/slsReceiverUsers.doxy deleted file mode 100644 index b5d37ae18..000000000 --- a/slsReceiverSoftware/slsReceiverUsers.doxy +++ /dev/null @@ -1,86 +0,0 @@ -# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in -# documentation are documented, even if no documentation was available. -# Private class members and static file members will be hidden unless -# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES - -EXTRACT_ALL = YES - -# If the EXTRACT_PRIVATE tag is set to YES all private members of a class -# will be included in the documentation. - -EXTRACT_PRIVATE = NO - - - -# If the EXTRACT_STATIC tag is set to YES all static members of a file -# will be included in the documentation. - -EXTRACT_STATIC = YES - -# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) -# defined locally in source files will be included in the documentation. -# If set to NO only classes defined in header files are included. - -EXTRACT_LOCAL_CLASSES = YES - -# This flag is only useful for Objective-C code. When set to YES local -# methods, which are defined in the implementation section but not in -# the interface are included in the documentation. -# If set to NO (the default) only methods in the interface are included. - -EXTRACT_LOCAL_METHODS = YES - -# If this flag is set to YES, the members of anonymous namespaces will be -# extracted and appear in the documentation as a namespace called -# 'anonymous_namespace{file}', where file will be replaced with the base -# name of the file that contains the anonymous namespace. By default -# anonymous namespace are hidden. - -EXTRACT_ANON_NSPACES = NO - -# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all -# undocumented members of documented classes, files or namespaces. -# If set to NO (the default) these members will be included in the -# various overviews, but no documentation section is generated. -# This option has no effect if EXTRACT_ALL is enabled. - -HIDE_UNDOC_MEMBERS = NO - -# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all -# undocumented classes that are normally visible in the class hierarchy. -# If set to NO (the default) these classes will be included in the various -# overviews. This option has no effect if EXTRACT_ALL is enabled. - -HIDE_UNDOC_CLASSES = NO - -# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all -# friend (class|struct|union) declarations. -# If set to NO (the default) these declarations will be included in the -# documentation. - -HIDE_FRIEND_COMPOUNDS = NO - -INTERNAL_DOCS = NO - -SHOW_INCLUDE_FILES = NO - -SHOW_FILES = NO - -SHOW_NAMESPACES = NO - -COMPACT_LATEX = YES - -PAPER_TYPE = a4 - -PDF_HYPERLINKS = YES - -USE_PDFLATEX = YES - -LATEX_HIDE_INDICES = YES - - -PREDEFINED = __cplusplus - -INPUT = slsReceiver/slsReceiverBase.h - -OUTPUT_DIRECTORY = slsReceiverUsersDocs diff --git a/slsReceiverSoftware/src/.cproject b/slsReceiverSoftware/src/.cproject deleted file mode 100644 index d34dce296..000000000 --- a/slsReceiverSoftware/src/.cproject +++ /dev/null @@ -1,51 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/slsReceiverSoftware/src/.project b/slsReceiverSoftware/src/.project deleted file mode 100644 index 3c7b96561..000000000 --- a/slsReceiverSoftware/src/.project +++ /dev/null @@ -1,28 +0,0 @@ - - - Receiver - - - newMythenSoftware - - - - org.eclipse.cdt.managedbuilder.core.genmakebuilder - clean,full,incremental, - - - - - org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder - full,incremental, - - - - - - org.eclipse.cdt.core.cnature - org.eclipse.cdt.core.ccnature - org.eclipse.cdt.managedbuilder.core.managedBuildNature - org.eclipse.cdt.managedbuilder.core.ScannerConfigNature - - diff --git a/slsReceiverSoftware/src/BinaryFile.cpp b/slsReceiverSoftware/src/BinaryFile.cpp deleted file mode 100644 index 16072fd72..000000000 --- a/slsReceiverSoftware/src/BinaryFile.cpp +++ /dev/null @@ -1,138 +0,0 @@ -/************************************************ - * @file BinaryFile.cpp - * @short sets/gets properties for the binary file, - * creates/closes the file and writes data to it - ***********************************************/ - -#include "BinaryFile.h" -#include "receiver_defs.h" -#include "Fifo.h" - -#include - - -FILE* BinaryFile::masterfd = 0; - -BinaryFile::BinaryFile(int ind, uint32_t* maxf, - int* nd, char* fname, char* fpath, uint64_t* findex, bool* owenable, - int* dindex, int* nunits, uint64_t* nf, uint32_t* dr, uint32_t* portno, - bool* smode): - File(ind, maxf, nd, fname, fpath, findex, owenable, dindex, nunits, nf, dr, portno, smode), - filefd(0), - numFramesInFile(0), - numActualPacketsInFile(0) -{ -#ifdef VERBOSE - PrintMembers(); -#endif -} - -BinaryFile::~BinaryFile() { - CloseAllFiles(); -} - -void BinaryFile::PrintMembers() { - File::PrintMembers(); - FILE_LOG(logINFO) << "Max Frames Per File: " << *maxFramesPerFile; - FILE_LOG(logINFO) << "Number of Frames in File: " << numFramesInFile; -} - -slsReceiverDefs::fileFormat BinaryFile::GetFileType() { - return BINARY; -} - - -int BinaryFile::CreateFile(uint64_t fnum) { - numFramesInFile = 0; - numActualPacketsInFile = 0; - - currentFileName = BinaryFileStatic::CreateFileName(filePath, fileNamePrefix, *fileIndex, - (*numImages > 1), fnum, *detIndex, *numUnitsPerDetector, index); - - if (BinaryFileStatic::CreateDataFile(filefd, *overWriteEnable, currentFileName, FILE_BUFFER_SIZE) == FAIL) - return FAIL; - - if(!(*silentMode)) { - FILE_LOG(logINFO) << "[" << *udpPortNumber << "]: Binary File created: " << currentFileName; - } - return OK; -} - -void BinaryFile::CloseCurrentFile() { - BinaryFileStatic::CloseDataFile(filefd); -} - -void BinaryFile::CloseAllFiles() { - BinaryFileStatic::CloseDataFile(filefd); - if (master && (*detIndex==0)) - BinaryFileStatic::CloseDataFile(masterfd); -} - -int BinaryFile::WriteToFile(char* buffer, int buffersize, uint64_t fnum, uint32_t nump) { - // check if maxframesperfile = 0 for infinite - if ((*maxFramesPerFile) && (numFramesInFile >= (*maxFramesPerFile))) { - CloseCurrentFile(); - CreateFile(fnum); - } - numFramesInFile++; - numActualPacketsInFile += nump; - - // write to file - int ret = 0; - - // contiguous bitset - if (sizeof(sls_bitset) == sizeof(bitset_storage)) { - ret = BinaryFileStatic::WriteDataFile(filefd, buffer, buffersize); - } - - // not contiguous bitset - else { - // write detector header - ret = BinaryFileStatic::WriteDataFile(filefd, buffer, sizeof(sls_detector_header)); - - // get contiguous representation of bit mask - bitset_storage storage; - memset(storage, 0 , sizeof(bitset_storage)); - sls_bitset bits = *(sls_bitset*)(buffer + sizeof(sls_detector_header)); - for (int i = 0; i < MAX_NUM_PACKETS; ++i) - storage[i >> 3] |= (bits[i] << (i & 7)); - // write bitmask - ret += BinaryFileStatic::WriteDataFile(filefd, (char*)storage, sizeof(bitset_storage)); - - // write data - ret += BinaryFileStatic::WriteDataFile(filefd, - buffer + sizeof(sls_detector_header), buffersize - sizeof(sls_receiver_header)); - } - - // if write error - if (ret != buffersize) { - cprintf(RED,"%d Error: Write to file failed for image number %lld\n", - index, (long long int)fnum); - return FAIL; - } - return OK; -} - - -int BinaryFile::CreateMasterFile(bool en, uint32_t size, - uint32_t nx, uint32_t ny, uint64_t at, uint64_t st, uint64_t sp, - uint64_t ap) { - //beginning of every acquisition - numFramesInFile = 0; - numActualPacketsInFile = 0; - - if (master && (*detIndex==0)) { - masterFileName = BinaryFileStatic::CreateMasterFileName(filePath, - fileNamePrefix, *fileIndex); - if(!(*silentMode)) { - FILE_LOG(logINFO) << "Master File: " << masterFileName; - } - return BinaryFileStatic::CreateMasterDataFile(masterfd, masterFileName, - *overWriteEnable, - *dynamicRange, en, size, nx, ny, *numImages, *maxFramesPerFile, - at, st, sp, ap, BINARY_WRITER_VERSION); - } - return OK; -} - - diff --git a/slsReceiverSoftware/src/DataProcessor.cpp b/slsReceiverSoftware/src/DataProcessor.cpp deleted file mode 100644 index 3a71e52cd..000000000 --- a/slsReceiverSoftware/src/DataProcessor.cpp +++ /dev/null @@ -1,598 +0,0 @@ -/************************************************ - * @file DataProcessor.cpp - * @short creates data processor thread that - * pulls pointers to memory addresses from fifos - * and processes data stored in them & writes them to file - ***********************************************/ - - -#include "DataProcessor.h" -#include "GeneralData.h" -#include "Fifo.h" -#include "BinaryFile.h" -#ifdef HDF5C -#include "HDF5File.h" -#endif -#include "DataStreamer.h" - -#include -#include -#include - -const std::string DataProcessor::TypeName = "DataProcessor"; - - -DataProcessor::DataProcessor(int ind, detectorType dtype, Fifo*& f, - fileFormat* ftype, bool fwenable, - bool* dsEnable, bool* gpEnable, uint32_t* dr, - uint32_t* freq, uint32_t* timer, - bool* fp, bool* act, bool* depaden, bool* sm, - void (*dataReadycb)(char*, char*, uint32_t, void*), - void (*dataModifyReadycb)(char*, char*, uint32_t &, void*), - void *pDataReadycb) : - - ThreadObject(ind), - runningFlag(0), - generalData(0), - fifo(f), - myDetectorType(dtype), - file(0), - dataStreamEnable(dsEnable), - fileFormatType(ftype), - fileWriteEnable(fwenable), - gapPixelsEnable(gpEnable), - dynamicRange(dr), - streamingFrequency(freq), - streamingTimerInMs(timer), - currentFreqCount(0), - tempBuffer(0), - activated(act), - deactivatedPaddingEnable(depaden), - silentMode(sm), - framePadding(fp), - acquisitionStartedFlag(false), - measurementStartedFlag(false), - firstAcquisitionIndex(0), - firstMeasurementIndex(0), - numTotalFramesCaught(0), - numFramesCaught(0), - currentFrameIndex(0), - rawDataReadyCallBack(dataReadycb), - rawDataModifyReadyCallBack(dataModifyReadycb), - pRawDataReady(pDataReadycb) -{ - if(ThreadObject::CreateThread() == FAIL) - throw std::exception(); - - FILE_LOG(logDEBUG) << "DataProcessor " << ind << " created"; - - memset((void*)&timerBegin, 0, sizeof(timespec)); -} - - -DataProcessor::~DataProcessor() { - if (file) delete file; - if (tempBuffer) delete [] tempBuffer; - ThreadObject::DestroyThread(); -} - -/** getters */ -std::string DataProcessor::GetType(){ - return TypeName; -} - -bool DataProcessor::IsRunning() { - return runningFlag; -} - -bool DataProcessor::GetAcquisitionStartedFlag(){ - return acquisitionStartedFlag; -} - -bool DataProcessor::GetMeasurementStartedFlag(){ - return measurementStartedFlag; -} - -uint64_t DataProcessor::GetNumTotalFramesCaught() { - return numTotalFramesCaught; -} - -uint64_t DataProcessor::GetNumFramesCaught() { - return numFramesCaught; -} - -uint64_t DataProcessor::GetActualProcessedAcquisitionIndex() { - return currentFrameIndex; -} - -uint64_t DataProcessor::GetProcessedAcquisitionIndex() { - return currentFrameIndex - firstAcquisitionIndex; -} - -uint64_t DataProcessor::GetProcessedMeasurementIndex() { - return currentFrameIndex - firstMeasurementIndex; -} - - - -/** setters */ -void DataProcessor::StartRunning() { - runningFlag = true; -} - - -void DataProcessor::StopRunning() { - runningFlag = false; -} - -void DataProcessor::SetFifo(Fifo*& f) { - fifo = f; -} - -void DataProcessor::ResetParametersforNewAcquisition() { - numTotalFramesCaught = 0; - firstAcquisitionIndex = 0; - currentFrameIndex = 0; - acquisitionStartedFlag = false; -} - -void DataProcessor::ResetParametersforNewMeasurement(){ - runningFlag = false; - numFramesCaught = 0; - firstMeasurementIndex = 0; - measurementStartedFlag = false; - - if (tempBuffer) { - delete [] tempBuffer; - tempBuffer = 0; - } - if (*gapPixelsEnable) { - tempBuffer = new char[generalData->imageSize]; - memset(tempBuffer, 0, generalData->imageSize); - } -} - - -void DataProcessor::RecordFirstIndices(uint64_t fnum) { - //listen to this fnum, later +1 - currentFrameIndex = fnum; - - measurementStartedFlag = true; - firstMeasurementIndex = fnum; - - //start of entire acquisition - if (!acquisitionStartedFlag) { - acquisitionStartedFlag = true; - firstAcquisitionIndex = fnum; - } - -#ifdef VERBOSE - cprintf(BLUE,"%d First Acquisition Index:%lld\tFirst Measurement Index:%lld\n", - index, (long long int)firstAcquisitionIndex, (long long int)firstMeasurementIndex); -#endif -} - - -void DataProcessor::SetGeneralData(GeneralData* g) { - generalData = g; -#ifdef VERY_VERBOSE - generalData->Print(); -#endif - if (file) { - if (file->GetFileType() == HDF5) { - file->SetNumberofPixels(generalData->nPixelsX, generalData->nPixelsY); - } - } -} - - -int DataProcessor::SetThreadPriority(int priority) { - struct sched_param param; - param.sched_priority = priority; - if (pthread_setschedparam(thread, SCHED_FIFO, ¶m) == EPERM) - return FAIL; - FILE_LOG(logINFO) << "Processor Thread Priority set to " << priority; - return OK; -} - - -void DataProcessor::SetFileFormat(const fileFormat f) { - if (file && file->GetFileType() != f) { - //remember the pointer values before they are destroyed - int nd[MAX_DIMENSIONS];nd[0] = 0; nd[1] = 0; - uint32_t* maxf = 0; - char* fname=0; char* fpath=0; uint64_t* findex=0; - bool* owenable=0; int* dindex=0; int* nunits=0; uint64_t* nf = 0; - uint32_t* dr = 0; uint32_t* port = 0; - file->GetMemberPointerValues(nd, maxf, fname, fpath, findex, - owenable, dindex, nunits, nf, dr, port); - //create file writer with same pointers - SetupFileWriter(fileWriteEnable, nd, maxf, fname, fpath, findex, - owenable, dindex, nunits, nf, dr, port); - } -} - - -void DataProcessor::SetupFileWriter(bool fwe, int* nd, uint32_t* maxf, - char* fname, char* fpath, uint64_t* findex, - bool* owenable, int* dindex, int* nunits, uint64_t* nf, uint32_t* dr, - uint32_t* portno, - GeneralData* g) -{ - fileWriteEnable = fwe; - if (g) - generalData = g; - - - if (file) { - delete file; file = 0; - } - - if (fileWriteEnable) { - switch(*fileFormatType){ -#ifdef HDF5C - case HDF5: - file = new HDF5File(index, maxf, - nd, fname, fpath, findex, owenable, - dindex, nunits, nf, dr, portno, - generalData->nPixelsX, generalData->nPixelsY, silentMode); - break; -#endif - default: - file = new BinaryFile(index, maxf, - nd, fname, fpath, findex, owenable, - dindex, nunits, nf, dr, portno, silentMode); - break; - } - } -} - -// only the first file -int DataProcessor::CreateNewFile(bool en, uint64_t nf, uint64_t at, uint64_t st, - uint64_t sp, uint64_t ap) { - if (file == NULL) - return FAIL; - file->CloseAllFiles(); - if (file->CreateMasterFile(en, generalData->imageSize, - generalData->nPixelsX, generalData->nPixelsY, - at, st, sp, ap) == FAIL) - return FAIL; - if (file->CreateFile(currentFrameIndex) == FAIL) - return FAIL; - return OK; -} - - -void DataProcessor::CloseFiles() { - if (file) - file->CloseAllFiles(); -} - -void DataProcessor::EndofAcquisition(bool anyPacketsCaught, uint64_t numf) { - if (file && file->GetFileType() == HDF5) { - file->EndofAcquisition(anyPacketsCaught, numf); - } -} - - -void DataProcessor::ThreadExecution() { - char* buffer=0; - fifo->PopAddress(buffer); -#ifdef FIFODEBUG - if (!index) cprintf(BLUE,"DataProcessor %d, pop 0x%p buffer:%s\n", - index,(void*)(buffer),buffer); -#endif - - //check dummy - uint32_t numBytes = (uint32_t)(*((uint32_t*)buffer)); -#ifdef VERBOSE - if (!index) cprintf(BLUE,"DataProcessor %d, Numbytes:%u\n", index,numBytes); -#endif - if (numBytes == DUMMY_PACKET_VALUE) { - StopProcessing(buffer); - return; - } - - ProcessAnImage(buffer); - - //stream (if time/freq to stream) or free - if (*dataStreamEnable && SendToStreamer()) - fifo->PushAddressToStream(buffer); - else - fifo->FreeAddress(buffer); -} - - -void DataProcessor::StopProcessing(char* buf) { -#ifdef VERBOSE - if (!index) - cprintf(RED,"DataProcessing %d: Dummy\n", index); -#endif - //stream or free - if (*dataStreamEnable) - fifo->PushAddressToStream(buf); - else - fifo->FreeAddress(buf); - - if (file) - file->CloseCurrentFile(); - StopRunning(); -#ifdef VERBOSE - FILE_LOG(logINFO) << index << ": Processing Completed"; -#endif -} - - -void DataProcessor::ProcessAnImage(char* buf) { - - sls_receiver_header* rheader = (sls_receiver_header*) (buf + FIFO_HEADER_NUMBYTES); - sls_detector_header header = rheader->detHeader; - uint64_t fnum = header.frameNumber; - currentFrameIndex = fnum; - uint32_t nump = header.packetNumber; - if (nump == generalData->packetsPerFrame) { - numFramesCaught++; - numTotalFramesCaught++; - } - - -#ifdef VERBOSE - if (!index) - cprintf(BLUE,"DataProcessing %d: fnum:%lu\n", index, fnum); -#endif - - if (!measurementStartedFlag) { -#ifdef VERBOSE - if (!index) cprintf(BLUE,"DataProcessing %d: fnum:%lu\n", index, fnum); -#endif - RecordFirstIndices(fnum); - - if (*dataStreamEnable) { - //restart timer - clock_gettime(CLOCK_REALTIME, &timerBegin); - timerBegin.tv_sec -= (*streamingTimerInMs) / 1000; - timerBegin.tv_nsec -= ((*streamingTimerInMs) % 1000) * 1000000; - - //to send first image - currentFreqCount = *streamingFrequency; - } - } - - if (*gapPixelsEnable && (*dynamicRange!=4)) - InsertGapPixels(buf + FIFO_HEADER_NUMBYTES + sizeof(sls_receiver_header), - *dynamicRange); - - - // frame padding - if (*activated && *framePadding && nump < generalData->packetsPerFrame) - PadMissingPackets(buf); - - // deactivated and padding enabled - else if (!(*activated) && *deactivatedPaddingEnable) - PadMissingPackets(buf); - - // normal call back - if (rawDataReadyCallBack) { - rawDataReadyCallBack( - (char*)rheader, - buf + FIFO_HEADER_NUMBYTES + sizeof(sls_receiver_header), - (uint32_t)(*((uint32_t*)buf)), - pRawDataReady); - } - - // call back with modified size - else if (rawDataModifyReadyCallBack) { - uint32_t revsize = (uint32_t)(*((uint32_t*)buf)); - rawDataModifyReadyCallBack( - (char*)rheader, - buf + FIFO_HEADER_NUMBYTES + sizeof(sls_receiver_header), - revsize, - pRawDataReady); - (*((uint32_t*)buf)) = revsize; - } - - - // write to file - if (file) - file->WriteToFile(buf + FIFO_HEADER_NUMBYTES, - sizeof(sls_receiver_header) + (uint32_t)(*((uint32_t*)buf)), //+ size of data (resizable from previous call back - fnum-firstMeasurementIndex, nump); - - - -} - - - -bool DataProcessor::SendToStreamer() { - //skip - if (!(*streamingFrequency)) { - if (!CheckTimer()) - return false; - } else { - if (!CheckCount()) - return false; - } - return true; -} - - -bool DataProcessor::CheckTimer() { - struct timespec end; - clock_gettime(CLOCK_REALTIME, &end); -#ifdef VERBOSE - cprintf(BLUE,"%d Timer elapsed time:%f seconds\n", index, - ( end.tv_sec - timerBegin.tv_sec ) + ( end.tv_nsec - timerBegin.tv_nsec ) - / 1000000000.0); -#endif - //still less than streaming timer, keep waiting - if((( end.tv_sec - timerBegin.tv_sec ) + ( end.tv_nsec - timerBegin.tv_nsec ) - / 1000000000.0) < ((double)*streamingTimerInMs/1000.00)) - return false; - - //restart timer - clock_gettime(CLOCK_REALTIME, &timerBegin); - return true; -} - - -bool DataProcessor::CheckCount() { - if (currentFreqCount == *streamingFrequency ) { - currentFreqCount = 1; - return true; - } - currentFreqCount++; - return false; -} - - -void DataProcessor::SetPixelDimension() { - if (file) { - if (file->GetFileType() == HDF5) { - file->SetNumberofPixels(generalData->nPixelsX, generalData->nPixelsY); - } - } -} - - -void DataProcessor::PadMissingPackets(char* buf) { - FILE_LOG(logDEBUG) << index << ": Padding Missing Packets"; - - uint32_t pperFrame = generalData->packetsPerFrame; - sls_receiver_header* header = (sls_receiver_header*) (buf + FIFO_HEADER_NUMBYTES); - uint32_t nmissing = pperFrame - header->detHeader.packetNumber; - sls_bitset pmask = header->packetsMask; - - uint32_t dsize = generalData->dataSize; - uint32_t fifohsize = generalData->fifoBufferHeaderSize; - uint32_t corrected_dsize = dsize - ((pperFrame * dsize) - generalData->imageSize); -#ifdef VERBOSE - cprintf(RED,"bitmask:%s\n", pmask.to_string().c_str()); -#endif - for (unsigned int pnum = 0; pnum < pperFrame; ++pnum) { - - // not missing packet - if (pmask[pnum]) - continue; - - // done with padding, exit loop earlier - if (!nmissing) - break; - - FILE_LOG(logDEBUG) << "padding for " << index << " for pnum: " << pnum << std::endl; - - // missing packet - switch(myDetectorType) { - //for gotthard, 1st packet: 4 bytes fnum, CACA + CACA, 639*2 bytes data - // 2nd packet: 4 bytes fnum, previous 1*2 bytes data + 640*2 bytes data !! - case GOTTHARD: - if(!pnum) - memset(buf + fifohsize + (pnum * dsize), 0xFF, dsize-2); - else - memset(buf + fifohsize + (pnum * dsize), 0xFF, dsize+2); - break; - case JUNGFRAUCTB: - if (pnum == (pperFrame-1)) - memset(buf + fifohsize + (pnum * dsize), 0xFF, corrected_dsize); - else - memset(buf + fifohsize + (pnum * dsize), 0xFF, dsize); - break; - default: - memset(buf + fifohsize + (pnum * dsize), 0xFF, dsize); - break; - } - --nmissing; - } -} - - -/** eiger specific */ -void DataProcessor::InsertGapPixels(char* buf, uint32_t dr) { - - memset(tempBuffer, 0xFF, generalData->imageSize); - - const uint32_t nx = generalData->nPixelsX; - const uint32_t ny = generalData->nPixelsY; - const uint32_t npx = nx * ny; - - char* srcptr = 0; - char* dstptr = 0; - - const uint32_t b1px = generalData->imageSize / (npx); // not double as not dealing with 4 bit mode - const uint32_t b2px = 2 * b1px; - const uint32_t b1pxofst = (index ? b1px : 0); // left fpga (index 0) has no extra 1px offset, but right fpga has - const uint32_t b1chip = 256 * b1px; - const uint32_t b1line = (nx * b1px); - - // copying line by line - srcptr = buf; - dstptr = tempBuffer + b1line + b1pxofst; // left fpga (index 0) has no extra 1px offset, but right fpga has - for (uint32_t i = 0; i < (ny-1); ++i) { - memcpy(dstptr, srcptr, b1chip); - srcptr += b1chip; - dstptr += (b1chip + b2px); - memcpy(dstptr, srcptr, b1chip); - srcptr += b1chip; - dstptr += (b1chip + b1px); - } - - // vertical filling of values - { - char* srcgp1 = 0; char* srcgp2 = 0; char* srcgp3 = 0; - char* dstgp1 = 0; char* dstgp2 = 0; char* dstgp3 = 0; - const uint32_t b3px = 3 * b1px; - - srcptr = tempBuffer + b1line; - dstptr = tempBuffer + b1line; - - for (uint32_t i = 0; i < (ny-1); ++i) { - srcgp1 = srcptr + b1pxofst + b1chip - b1px; - dstgp1 = srcgp1 + b1px; - srcgp2 = srcgp1 + b3px; - dstgp2 = dstgp1 + b1px; - if (!index) { - srcgp3 = srcptr + b1line - b2px; - dstgp3 = srcgp3 + b1px; - } else { - srcgp3 = srcptr + b1px; - dstgp3 = srcptr; - } - switch (dr) { - case 8: - (*((uint8_t*)srcgp1)) = (*((uint8_t*)srcgp1))/2; (*((uint8_t*)dstgp1)) = (*((uint8_t*)srcgp1)); - (*((uint8_t*)srcgp2)) = (*((uint8_t*)srcgp2))/2; (*((uint8_t*)dstgp2)) = (*((uint8_t*)srcgp2)); - (*((uint8_t*)srcgp3)) = (*((uint8_t*)srcgp3))/2; (*((uint8_t*)dstgp3)) = (*((uint8_t*)srcgp3)); - break; - case 16: - (*((uint16_t*)srcgp1)) = (*((uint16_t*)srcgp1))/2; (*((uint16_t*)dstgp1)) = (*((uint16_t*)srcgp1)); - (*((uint16_t*)srcgp2)) = (*((uint16_t*)srcgp2))/2; (*((uint16_t*)dstgp2)) = (*((uint16_t*)srcgp2)); - (*((uint16_t*)srcgp3)) = (*((uint16_t*)srcgp3))/2; (*((uint16_t*)dstgp3)) = (*((uint16_t*)srcgp3)); - break; - default: - (*((uint32_t*)srcgp1)) = (*((uint32_t*)srcgp1))/2; (*((uint32_t*)dstgp1)) = (*((uint32_t*)srcgp1)); - (*((uint32_t*)srcgp2)) = (*((uint32_t*)srcgp2))/2; (*((uint32_t*)dstgp2)) = (*((uint32_t*)srcgp2)); - (*((uint32_t*)srcgp3)) = (*((uint32_t*)srcgp3))/2; (*((uint32_t*)dstgp3)) = (*((uint32_t*)srcgp3)); - break; - } - srcptr += b1line; - dstptr += b1line; - } - - } - - // horizontal filling of values - srcptr = tempBuffer + b1line; - dstptr = tempBuffer; - for (uint32_t i = 0; i < nx; ++i) { - switch (dr) { - case 8: (*((uint8_t*)srcptr)) = (*((uint8_t*)srcptr))/2; (*((uint8_t*)dstptr)) = (*((uint8_t*)srcptr)); break; - case 16:(*((uint16_t*)srcptr)) = (*((uint16_t*)srcptr))/2; (*((uint16_t*)dstptr)) = (*((uint16_t*)srcptr)); break; - default:(*((uint32_t*)srcptr)) = (*((uint32_t*)srcptr))/2; (*((uint32_t*)dstptr)) = (*((uint32_t*)srcptr)); break; - } - srcptr += b1px; - dstptr += b1px; - } - - memcpy(buf, tempBuffer, generalData->imageSize); - return; -} diff --git a/slsReceiverSoftware/src/DataStreamer.cpp b/slsReceiverSoftware/src/DataStreamer.cpp deleted file mode 100644 index 47689f48e..000000000 --- a/slsReceiverSoftware/src/DataStreamer.cpp +++ /dev/null @@ -1,287 +0,0 @@ -/************************************************ - * @file DataStreamer.cpp - * @short streams data from receiver via ZMQ - ***********************************************/ - - -#include "DataStreamer.h" -#include "GeneralData.h" -#include "Fifo.h" -#include "ZmqSocket.h" - -#include -#include - -const std::string DataStreamer::TypeName = "DataStreamer"; - - -DataStreamer::DataStreamer(int ind, Fifo*& f, uint32_t* dr, std::vector* r, - uint64_t* fi, int* fd, char* ajh, bool* sm) : - ThreadObject(ind), - runningFlag(0), - generalData(0), - fifo(f), - zmqSocket(0), - dynamicRange(dr), - roi(r), - adcConfigured(-1), - fileIndex(fi), - flippedData(fd), - additionJsonHeader(ajh), - acquisitionStartedFlag(false), - measurementStartedFlag(false), - firstAcquisitionIndex(0), - firstMeasurementIndex(0), - completeBuffer(0) -{ - if(ThreadObject::CreateThread() == FAIL) - throw std::exception(); - - FILE_LOG(logDEBUG) << "DataStreamer " << ind << " created"; - - memset(fileNametoStream, 0, MAX_STR_LENGTH); -} - - -DataStreamer::~DataStreamer() { - CloseZmqSocket(); - if (completeBuffer) delete [] completeBuffer; - ThreadObject::DestroyThread(); -} - -/** getters */ -std::string DataStreamer::GetType(){ - return TypeName; -} - -bool DataStreamer::IsRunning() { - return runningFlag; -} - - -/** setters */ -void DataStreamer::StartRunning() { - runningFlag = true; -} - - -void DataStreamer::StopRunning() { - runningFlag = false; -} - -void DataStreamer::SetFifo(Fifo*& f) { - fifo = f; -} - -void DataStreamer::ResetParametersforNewAcquisition() { - firstAcquisitionIndex = 0; - acquisitionStartedFlag = false; -} - -void DataStreamer::ResetParametersforNewMeasurement(char* fname){ - runningFlag = false; - firstMeasurementIndex = 0; - measurementStartedFlag = false; - strcpy(fileNametoStream, fname); - if (completeBuffer) { - delete [] completeBuffer; - completeBuffer = 0; - } - if (roi->size()) { - if (generalData->myDetectorType == GOTTHARD) { - adcConfigured = generalData->GetAdcConfigured(index, roi); - } - completeBuffer = new char[generalData->imageSizeComplete]; - memset(completeBuffer, 0, generalData->imageSizeComplete); - } -} - - -void DataStreamer::RecordFirstIndices(uint64_t fnum) { - measurementStartedFlag = true; - firstMeasurementIndex = fnum; - - //start of entire acquisition - if (!acquisitionStartedFlag) { - acquisitionStartedFlag = true; - firstAcquisitionIndex = fnum; - } - -#ifdef VERBOSE - cprintf(BLUE,"%d First Acquisition Index:%lld\tFirst Measurement Index:%lld\n", - index, (long long int)firstAcquisitionIndex, (long long int)firstMeasurementIndex); -#endif -} - - -void DataStreamer::SetGeneralData(GeneralData* g) { - generalData = g; -#ifdef VERY_VERBOSE - generalData->Print(); -#endif -} - -int DataStreamer::SetThreadPriority(int priority) { - struct sched_param param; - param.sched_priority = priority; - if (pthread_setschedparam(thread, SCHED_FIFO, ¶m) == EPERM) - return FAIL; - FILE_LOG(logINFO) << "Streamer Thread Priority set to " << priority; - return OK; -} - - -void DataStreamer::CreateZmqSockets(int* nunits, uint32_t port, const char* srcip) { - uint32_t portnum = port + index; - - try { - zmqSocket = new ZmqSocket(portnum, (strlen(srcip)?srcip:NULL)); - } catch (...) { - cprintf(RED, "Error: Could not create Zmq socket on port %d for Streamer %d\n", portnum, index); - throw; - } - FILE_LOG(logINFO) << index << " Streamer: Zmq Server started at " << zmqSocket->GetZmqServerAddress(); -} - - -void DataStreamer::CloseZmqSocket() { - if (zmqSocket) { - delete zmqSocket; - zmqSocket = 0; - } -} - - -void DataStreamer::ThreadExecution() { - char* buffer=0; - fifo->PopAddressToStream(buffer); -#ifdef FIFODEBUG - if (!index) cprintf(BLUE,"DataStreamer %d, pop 0x%p buffer:%s\n", index,(void*)(buffer),buffer); -#endif - - //check dummy - uint32_t numBytes = (uint32_t)(*((uint32_t*)buffer)); -#ifdef VERBOSE - cprintf(GREEN,"DataStreamer %d, Numbytes:%u\n", index,numBytes); -#endif - if (numBytes == DUMMY_PACKET_VALUE) { - StopProcessing(buffer); - return; - } - - ProcessAnImage(buffer); - - //free - fifo->FreeAddress(buffer); - -} - - - -void DataStreamer::StopProcessing(char* buf) { -#ifdef VERBOSE - if (!index) - cprintf(RED,"DataStreamer %d: Dummy\n", index); -#endif - sls_receiver_header* header = (sls_receiver_header*) (buf); - //send dummy header and data - if (!SendHeader(header, 0, 0, 0, true)) - cprintf(RED,"Error: Could not send zmq dummy header for streamer %d\n", index); - - fifo->FreeAddress(buf); - StopRunning(); -#ifdef VERBOSE - FILE_LOG(logINFO) << index << ": Streaming Completed"; -#endif -} - -/** buf includes only the standard header */ -void DataStreamer::ProcessAnImage(char* buf) { - - sls_receiver_header* header = (sls_receiver_header*) (buf + FIFO_HEADER_NUMBYTES); - uint64_t fnum = header->detHeader.frameNumber; -#ifdef VERBOSE - cprintf(MAGENTA,"DataStreamer %d: fnum:%lu\n", index,fnum); -#endif - - if (!measurementStartedFlag) { -#ifdef VERBOSE - if (!index) cprintf(MAGENTA,"DataStreamer %d: fnum:%lu\n", index, fnum); -#endif - RecordFirstIndices(fnum); - } - - //shortframe gotthard - if (completeBuffer) { - - //disregarding the size modified from callback (always using imageSizeComplete - // instead of buf (32 bit) because gui needs imagesizecomplete and listener - //write imagesize - - if (!SendHeader(header, generalData->imageSizeComplete, - generalData->nPixelsXComplete, generalData->nPixelsYComplete, false)) - cprintf(RED,"Error: Could not send zmq header for fnum %lld and streamer %d\n", - (long long int) fnum, index); - - memcpy(completeBuffer + ((generalData->imageSize) * adcConfigured), - buf + FIFO_HEADER_NUMBYTES + sizeof(sls_receiver_header), - (uint32_t)(*((uint32_t*)buf)) ); - - if (!zmqSocket->SendData(completeBuffer, generalData->imageSizeComplete)) - cprintf(RED,"Error: Could not send zmq data for fnum %lld and streamer %d\n", - (long long int) fnum, index); - } - - - //normal - else { - - if (!SendHeader(header, (uint32_t)(*((uint32_t*)buf)), - generalData->nPixelsX, generalData->nPixelsY, false)) // new size possibly from callback - cprintf(RED,"Error: Could not send zmq header for fnum %lld and streamer %d\n", - (long long int) fnum, index); - - if (!zmqSocket->SendData(buf + FIFO_HEADER_NUMBYTES + sizeof(sls_receiver_header), - (uint32_t)(*((uint32_t*)buf)) )) // new size possibly from callback - cprintf(RED,"Error: Could not send zmq data for fnum %lld and streamer %d\n", - (long long int) fnum, index); - } -} - - - -int DataStreamer::SendHeader(sls_receiver_header* rheader, uint32_t size, uint32_t nx, uint32_t ny, bool dummy) { - - if (dummy) - return zmqSocket->SendHeaderData(index, dummy,SLS_DETECTOR_JSON_HEADER_VERSION); - - sls_detector_header header = rheader->detHeader; - - uint64_t frameIndex = header.frameNumber - firstMeasurementIndex; - uint64_t acquisitionIndex = header.frameNumber - firstAcquisitionIndex; - - return zmqSocket->SendHeaderData(index, dummy, SLS_DETECTOR_JSON_HEADER_VERSION, *dynamicRange, *fileIndex, - nx, ny, size, - acquisitionIndex, frameIndex, fileNametoStream, - header.frameNumber, header.expLength, header.packetNumber, header.bunchId, header.timestamp, - header.modId, header.row, header.column, header.reserved, - header.debug, header.roundRNumber, - header.detType, header.version, - flippedData, - additionJsonHeader - ); -} - - - -int DataStreamer::RestreamStop() { - //send dummy header - int ret = zmqSocket->SendHeaderData(index, true, SLS_DETECTOR_JSON_HEADER_VERSION); - if (!ret) { - FILE_LOG(logERROR) << "Could not Restream Dummy Header via ZMQ for port " << zmqSocket->GetPortNumber(); - return FAIL; - } - return OK; -} - - diff --git a/slsReceiverSoftware/src/Fifo.cpp b/slsReceiverSoftware/src/Fifo.cpp deleted file mode 100644 index a39be358a..000000000 --- a/slsReceiverSoftware/src/Fifo.cpp +++ /dev/null @@ -1,137 +0,0 @@ -/************************************************ - * @file Fifo.cpp - * @short constructs the fifo structure - * which is a circular buffer with pointers to - * parts of allocated memory - ***********************************************/ - -#include "Fifo.h" - -#include -#include -#include - - -Fifo::Fifo(int ind, uint32_t fifoItemSize, uint32_t depth): - index(ind), - memory(0), - fifoBound(0), - fifoFree(0), - fifoStream(0), - fifoDepth(depth), - status_fifoBound(0), - status_fifoFree(depth){ - FILE_LOG(logDEBUG) << __AT__ << " called"; - if(CreateFifos(fifoItemSize) == FAIL) - throw std::exception(); -} - - -Fifo::~Fifo() { - FILE_LOG(logDEBUG) << __AT__ << " called"; - //cprintf(BLUE,"Fifo Object %d: Goodbye\n", index); - DestroyFifos(); -} - - - -int Fifo::CreateFifos(uint32_t fifoItemSize) { - FILE_LOG(logDEBUG) << __AT__ << " called"; - - //destroy if not already - DestroyFifos(); - - //create fifos - fifoBound = new CircularFifo(fifoDepth); - fifoFree = new CircularFifo(fifoDepth); - fifoStream = new CircularFifo(fifoDepth); - //allocate memory - size_t mem_len = fifoItemSize * fifoDepth * sizeof(char); - memory = (char*) malloc (mem_len); - if (memory == NULL){ - FILE_LOG(logERROR) << "Could not allocate memory for fifos"; - return FAIL; - } - memset(memory, 0, mem_len); - FILE_LOG(logDEBUG) << "Memory Allocated " << index << ": " << mem_len << " bytes"; - - { //push free addresses into fifoFree fifo - char* buffer = memory; - for (int i = 0; i < fifoDepth; ++i) { - //sprintf(buffer,"memory"); - FreeAddress(buffer); - buffer += fifoItemSize; - } - } - FILE_LOG(logINFO) << "Fifo " << index << " reconstructed Depth (rx_fifodepth): " << fifoFree->getDataValue(); - return OK; -} - - -void Fifo::DestroyFifos(){ - FILE_LOG(logDEBUG) << __AT__ << " called"; - - if(memory) { - free(memory); - memory = 0; - } - if (fifoBound) { - delete fifoBound; - fifoBound = 0; - } - if (fifoFree) { - delete fifoFree; - fifoFree = 0; - } - if (fifoStream) { - delete fifoStream; - fifoStream = 0; - } -} - - -void Fifo::FreeAddress(char*& address) { - fifoFree->push(address); -} - -void Fifo::GetNewAddress(char*& address) { - int temp = fifoFree->getDataValue(); - if (temp < status_fifoFree) - status_fifoFree = temp; - fifoFree->pop(address); -} - -void Fifo::PushAddress(char*& address) { - int temp = fifoBound->getDataValue(); - if (temp > status_fifoBound) - status_fifoBound = temp; - while(!fifoBound->push(address)); - /*temp = fifoBound->getDataValue(); - if (temp > status_fifoBound) - status_fifoBound = temp;*/ -} - -void Fifo::PopAddress(char*& address) { - fifoBound->pop(address); -} - -void Fifo::PushAddressToStream(char*& address) { - fifoStream->push(address); -} - -void Fifo::PopAddressToStream(char*& address) { - fifoStream->pop(address); -} - -int Fifo::GetMaxLevelForFifoBound() { - int temp = status_fifoBound; - status_fifoBound = 0; - return temp; -} - -int Fifo::GetMinLevelForFifoFree() { - int temp = status_fifoFree; - status_fifoFree = fifoDepth; - return temp; -} - diff --git a/slsReceiverSoftware/src/File.cpp b/slsReceiverSoftware/src/File.cpp deleted file mode 100644 index d7748cb26..000000000 --- a/slsReceiverSoftware/src/File.cpp +++ /dev/null @@ -1,80 +0,0 @@ -/************************************************ - * @file File.cpp - * @short sets/gets properties for the file, - * creates/closes the file and writes data to it - ***********************************************/ - -#include "File.h" - -#include - - -File::File(int ind, uint32_t* maxf, - int* nd, char* fname, char* fpath, uint64_t* findex, bool* owenable, - int* dindex, int* nunits, uint64_t* nf, uint32_t* dr, uint32_t* portno, - bool* smode): - index(ind), - maxFramesPerFile(maxf), - numDetX(nd[0]), - numDetY(nd[1]), - fileNamePrefix(fname), - filePath(fpath), - fileIndex(findex), - overWriteEnable(owenable), - detIndex(dindex), - numUnitsPerDetector(nunits), - numImages(nf), - dynamicRange(dr), - udpPortNumber(portno), - silentMode(smode) - -{ - master = index?false:true; -} - -File::~File() {} - -std::string File::GetCurrentFileName() { - return currentFileName; -} - -void File::PrintMembers() { - FILE_LOG(logINFO) << "\nGeneral Writer Variables:" << std::endl - << "Index: " << index << std::endl - << "Max Frames Per File: " << *maxFramesPerFile << std::endl - << "Number of Detectors in x dir: " << numDetX << std::endl - << "Number of Detectors in y dir: " << numDetY << std::endl - << "File Name Prefix: " << fileNamePrefix << std::endl - << "File Path: " << filePath << std::endl - << "File Index: " << *fileIndex << std::endl - << "Over Write Enable: " << *overWriteEnable << std::endl - - << "Detector Index: " << *detIndex << std::endl - << "Number of Units Per Detector: " << *numUnitsPerDetector << std::endl - << "Number of Images in Acquisition: " << *numImages << std::endl - << "Dynamic Range: " << *dynamicRange << std::endl - << "UDP Port number: " << *udpPortNumber << std::endl - << "Master File Name: " << masterFileName << std::endl - << "Current File Name: " << currentFileName << std::endl - << "Silent Mode: " << *silentMode; -} - - -void File::GetMemberPointerValues(int* nd, uint32_t*& maxf, char*& fname, char*& fpath, uint64_t*& findex, bool*& owenable, - int*& dindex, int*& nunits, uint64_t*& nf, uint32_t*& dr, uint32_t*& portno) -{ - nd[0] = numDetX; - nd[1] = numDetY; - maxf = maxFramesPerFile; - fname = fileNamePrefix; - fpath = filePath; - findex = fileIndex; - owenable = overWriteEnable; - dindex = detIndex; - nunits = numUnitsPerDetector; - nf = numImages; - dr = dynamicRange; - portno = udpPortNumber; -} - - diff --git a/slsReceiverSoftware/src/HDF5File.cpp b/slsReceiverSoftware/src/HDF5File.cpp deleted file mode 100644 index 597c1bd6e..000000000 --- a/slsReceiverSoftware/src/HDF5File.cpp +++ /dev/null @@ -1,332 +0,0 @@ -/************************************************ - * @file HDF5File.cpp - * @short sets/gets properties for the HDF5 file, - * creates/closes the file and writes data to it - ***********************************************/ -#include "HDF5File.h" -#include "receiver_defs.h" -#include "Fifo.h" - -#include -#include -#include //basename -#include - - -pthread_mutex_t HDF5File::Mutex = PTHREAD_MUTEX_INITIALIZER; -H5File* HDF5File::masterfd = 0; -hid_t HDF5File::virtualfd = 0; - - - -HDF5File::HDF5File(int ind, uint32_t* maxf, - int* nd, char* fname, char* fpath, uint64_t* findex, bool* owenable, - int* dindex, int* nunits, uint64_t* nf, uint32_t* dr, uint32_t* portno, - uint32_t nx, uint32_t ny, - bool* smode): - - File(ind, maxf, nd, fname, fpath, findex, owenable, dindex, nunits, nf, dr, portno, smode), - filefd(0), - dataspace(0), - dataset(0), - datatype(PredType::STD_U16LE), - nPixelsX(nx), - nPixelsY(ny), - numFramesInFile(0), - numActualPacketsInFile(0), - numFilesinAcquisition(0), - dataspace_para(0), - extNumImages(0) -{ -#ifdef VERBOSE - PrintMembers(); -#endif - dataset_para.clear(); - parameterNames.clear(); - parameterDataTypes.clear(); - - parameterNames.push_back("frame number"); - parameterDataTypes.push_back(PredType::STD_U64LE); - - parameterNames.push_back("exp length or sub exposure time"); - parameterDataTypes.push_back(PredType::STD_U32LE); - - parameterNames.push_back("packets caught"); - parameterDataTypes.push_back(PredType::STD_U32LE); - - parameterNames.push_back("bunch id"); - parameterDataTypes.push_back(PredType::STD_U64LE); - - parameterNames.push_back("timestamp"); - parameterDataTypes.push_back(PredType::STD_U64LE); - - parameterNames.push_back("mod id"); - parameterDataTypes.push_back(PredType::STD_U16LE); - - parameterNames.push_back("row"); - parameterDataTypes.push_back(PredType::STD_U16LE); - - parameterNames.push_back("column"); - parameterDataTypes.push_back(PredType::STD_U16LE); - - parameterNames.push_back("reserved"); - parameterDataTypes.push_back(PredType::STD_U16LE); - - parameterNames.push_back("debug"); - parameterDataTypes.push_back(PredType::STD_U32LE); - - parameterNames.push_back("round robin number"); - parameterDataTypes.push_back(PredType::STD_U16LE); - - parameterNames.push_back("detector type"); - parameterDataTypes.push_back(PredType::STD_U8LE); - - parameterNames.push_back("detector header version"); - parameterDataTypes.push_back(PredType::STD_U8LE); - - parameterNames.push_back("packets caught bit mask"); - StrType strdatatype(PredType::C_S1, sizeof(bitset_storage)); - parameterDataTypes.push_back(strdatatype); - -} - - -HDF5File::~HDF5File() { - CloseAllFiles(); -} - -void HDF5File::PrintMembers() { - File::PrintMembers(); - UpdateDataType(); - if (datatype == PredType::STD_U8LE) { - FILE_LOG(logINFO) << "Data Type: 4 or 8"; - } else if (datatype == PredType::STD_U16LE) { - FILE_LOG(logINFO) << "Data Type: 16"; - } else if (datatype == PredType::STD_U32LE) { - FILE_LOG(logINFO) << "Data Type: 32"; - } else { - FILE_LOG(logERROR) << "unknown data type"; - } -} - - -void HDF5File::SetNumberofPixels(uint32_t nx, uint32_t ny) { - nPixelsX = nx; - nPixelsY = ny; -} - - -slsReceiverDefs::fileFormat HDF5File::GetFileType() { - return HDF5; -} - - -void HDF5File::UpdateDataType() { - switch(*dynamicRange){ - case 16: datatype = PredType::STD_U16LE; break; - case 32: datatype = PredType::STD_U32LE; break; - default: datatype = PredType::STD_U8LE; break; - } -} - - -int HDF5File::CreateFile(uint64_t fnum) { - numFilesinAcquisition++; - numFramesInFile = 0; - numActualPacketsInFile = 0; - currentFileName = HDF5FileStatic::CreateFileName(filePath, fileNamePrefix, *fileIndex, - (*numImages > 1), fnum, *detIndex, *numUnitsPerDetector, index); - - //first time - if(!fnum) UpdateDataType(); - - uint64_t framestosave = ((*maxFramesPerFile == 0) ? *numImages : // infinite images - (((extNumImages - fnum) > (*maxFramesPerFile)) ? // save up to maximum at a time - (*maxFramesPerFile) : (extNumImages-fnum))); - pthread_mutex_lock(&Mutex); - if (HDF5FileStatic::CreateDataFile(index, *overWriteEnable, currentFileName, (*numImages > 1), - fnum, framestosave, nPixelsY, ((*dynamicRange==4) ? (nPixelsX/2) : nPixelsX), - datatype, filefd, dataspace, dataset, - HDF5_WRITER_VERSION, MAX_CHUNKED_IMAGES, - dataspace_para, dataset_para, - parameterNames, parameterDataTypes) == FAIL) { - pthread_mutex_unlock(&Mutex); - return FAIL; - } - pthread_mutex_unlock(&Mutex); - if (dataspace == NULL) - cprintf(RED,"Got nothing!\n"); - - if(!(*silentMode)) { - FILE_LOG(logINFO) << *udpPortNumber << ": HDF5 File created: " << currentFileName; - } - return OK; -} - - -void HDF5File::CloseCurrentFile() { - pthread_mutex_lock(&Mutex); - HDF5FileStatic::CloseDataFile(index, filefd); - pthread_mutex_unlock(&Mutex); - for (unsigned int i = 0; i < dataset_para.size(); ++i) - delete dataset_para[i]; - dataset_para.clear(); - if(dataspace_para) {delete dataspace_para;dataspace_para=0;} - if(dataset) {delete dataset;dataset=0;} - if(dataspace) {delete dataspace;dataspace=0;} - if(filefd) {delete filefd;filefd=0;} -} - - -void HDF5File::CloseAllFiles() { - numFilesinAcquisition = 0; - pthread_mutex_lock(&Mutex); - HDF5FileStatic::CloseDataFile(index, filefd); - if (master && (*detIndex==0)) { - HDF5FileStatic::CloseMasterDataFile(masterfd); - HDF5FileStatic::CloseVirtualDataFile(virtualfd); - } - pthread_mutex_unlock(&Mutex); - - for (unsigned int i = 0; i < dataset_para.size(); ++i) - delete dataset_para[i]; - dataset_para.clear(); - if(dataspace_para) delete dataspace_para; - if(dataset) delete dataset; - if(dataspace) delete dataspace; - if(filefd) delete filefd; -} - - -int HDF5File::WriteToFile(char* buffer, int buffersize, uint64_t fnum, uint32_t nump) { - - // check if maxframesperfile = 0 for infinite - if ((*maxFramesPerFile) && (numFramesInFile >= (*maxFramesPerFile))) { - CloseCurrentFile(); - CreateFile(fnum); - } - numFramesInFile++; - numActualPacketsInFile += nump; - pthread_mutex_lock(&Mutex); - - // extend dataset (when receiver start followed by many status starts (jungfrau))) - if (fnum >= extNumImages) { - if (HDF5FileStatic::ExtendDataset(index, dataspace, dataset, - dataspace_para, dataset_para, *numImages) == OK) { - if (!(*silentMode)) { - cprintf(BLUE,"%d Extending HDF5 dataset by %llu, Total x Dimension: %llu\n", - index, (long long unsigned int)extNumImages, - (long long unsigned int)(extNumImages + *numImages)); - } - extNumImages += *numImages; - } - } - - if (HDF5FileStatic::WriteDataFile(index, buffer + sizeof(sls_receiver_header), - // infinite then no need for %maxframesperfile - ((*maxFramesPerFile == 0) ? fnum : fnum%(*maxFramesPerFile)), - nPixelsY, ((*dynamicRange==4) ? (nPixelsX/2) : nPixelsX), - dataspace, dataset, datatype) == OK) { - - if (HDF5FileStatic::WriteParameterDatasets(index, dataspace_para, - // infinite then no need for %maxframesperfile - ((*maxFramesPerFile == 0) ? fnum : fnum%(*maxFramesPerFile)), - dataset_para, (sls_receiver_header*) (buffer), - parameterDataTypes) == OK) { - pthread_mutex_unlock(&Mutex); - return OK; - } - } - pthread_mutex_unlock(&Mutex); - cprintf(RED,"%d Error: Write to file failed\n", index); - return FAIL; -} - - -int HDF5File::CreateMasterFile(bool en, uint32_t size, - uint32_t nx, uint32_t ny, uint64_t at, uint64_t st, uint64_t sp, - uint64_t ap) { - - //beginning of every acquisition - numFramesInFile = 0; - numActualPacketsInFile = 0; - extNumImages = *numImages; - - if (master && (*detIndex==0)) { - virtualfd = 0; - masterFileName = HDF5FileStatic::CreateMasterFileName(filePath, - fileNamePrefix, *fileIndex); - if(!(*silentMode)) { - FILE_LOG(logINFO) << "Master File: " << masterFileName; - } - pthread_mutex_lock(&Mutex); - int ret = HDF5FileStatic::CreateMasterDataFile(masterfd, masterFileName, - *overWriteEnable, - *dynamicRange, en, size, nx, ny, *numImages, *maxFramesPerFile, - at, st, sp, ap, - HDF5_WRITER_VERSION); - pthread_mutex_unlock(&Mutex); - return ret; - } - return OK; -} - - -void HDF5File::EndofAcquisition(bool anyPacketsCaught, uint64_t numf) { - //not created before - if (!virtualfd && anyPacketsCaught) { - - // called only by the one maser receiver - if (master && (*detIndex==0)) { - - //only one file and one sub image (link current file in master) - if (((numFilesinAcquisition == 1) && (numDetY*numDetX) == 1)) { - LinkVirtualFileinMasterFile(); - } - //create virutal file - else{ - CreateVirtualFile(numf);} - } - } - numFilesinAcquisition = 0; -} - - -// called only by the one maser receiver -int HDF5File::CreateVirtualFile(uint64_t numf) { - pthread_mutex_lock(&Mutex); - - std::string vname = HDF5FileStatic::CreateVirtualFileName(filePath, fileNamePrefix, *fileIndex); - if(!(*silentMode)) { - FILE_LOG(logINFO) << "Virtual File: " << vname; - } - - int ret = HDF5FileStatic::CreateVirtualDataFile(vname, - virtualfd, masterFileName, - filePath, fileNamePrefix, *fileIndex, (*numImages > 1), - *detIndex, *numUnitsPerDetector, - // infinite images in 1 file, then maxfrperfile = numf - ((*maxFramesPerFile == 0) ? numf+1 : *maxFramesPerFile), - numf+1, - "data", datatype, - numDetY, numDetX, nPixelsY, ((*dynamicRange==4) ? (nPixelsX/2) : nPixelsX), - HDF5_WRITER_VERSION, - parameterNames, parameterDataTypes); - pthread_mutex_unlock(&Mutex); - return ret; -} - -// called only by the one maser receiver -int HDF5File::LinkVirtualFileinMasterFile() { - //dataset name - std::ostringstream osfn; - osfn << "/data"; - if ((*numImages > 1)) osfn << "_f" << std::setfill('0') << std::setw(12) << 0; - std::string dsetname = osfn.str(); - - pthread_mutex_lock(&Mutex); - int ret = HDF5FileStatic::LinkVirtualInMaster(masterFileName, currentFileName, - dsetname, parameterNames); - pthread_mutex_unlock(&Mutex); - return ret; -} diff --git a/slsReceiverSoftware/src/Listener.cpp b/slsReceiverSoftware/src/Listener.cpp deleted file mode 100644 index 3ca976b44..000000000 --- a/slsReceiverSoftware/src/Listener.cpp +++ /dev/null @@ -1,668 +0,0 @@ -/************************************************ - * @file Listener.cpp - * @short creates the listener thread that - * listens to udp sockets, writes data to memory - * & puts pointers to their memory addresses into fifos - ***********************************************/ - - -#include "Listener.h" -#include "GeneralData.h" -#include "Fifo.h" -#include "genericSocket.h" - -#include -#include -#include - -const std::string Listener::TypeName = "Listener"; - - -Listener::Listener(int ind, detectorType dtype, Fifo*& f, runStatus* s, - uint32_t* portno, char* e, uint64_t* nf, uint32_t* dr, - uint32_t* us, uint32_t* as, uint32_t* fpf, - frameDiscardPolicy* fdp, bool* act, bool* depaden, bool* sm) : - ThreadObject(ind), - runningFlag(0), - generalData(0), - fifo(f), - myDetectorType(dtype), - status(s), - udpSocket(0), - udpPortNumber(portno), - eth(e), - numImages(nf), - dynamicRange(dr), - udpSocketBufferSize(us), - actualUDPSocketBufferSize(as), - framesPerFile(fpf), - frameDiscardMode(fdp), - activated(act), - deactivatedPaddingEnable(depaden), - silentMode(sm), - row(0), - column(0), - acquisitionStartedFlag(false), - measurementStartedFlag(false), - firstAcquisitionIndex(0), - firstMeasurementIndex(0), - numPacketsCaught(0), - lastCaughtFrameIndex(0), - currentFrameIndex(0), - carryOverFlag(0), - carryOverPacket(0), - listeningPacket(0), - udpSocketAlive(0), - numPacketsStatistic(0), - numFramesStatistic(0), - oddStartingPacket(true) -{ - if(ThreadObject::CreateThread() == FAIL) - throw std::exception(); - - FILE_LOG(logDEBUG) << "Listener " << ind << " created"; -} - - -Listener::~Listener() { - if (udpSocket){ - delete udpSocket; - sem_post(&semaphore_socket); - sem_destroy(&semaphore_socket); - } - if (carryOverPacket) delete [] carryOverPacket; - if (listeningPacket) delete [] listeningPacket; - ThreadObject::DestroyThread(); -} - -/** getters */ -std::string Listener::GetType(){ - return TypeName; -} - -bool Listener::IsRunning() { - return runningFlag; -} - -bool Listener::GetAcquisitionStartedFlag(){ - return acquisitionStartedFlag; -} - -bool Listener::GetMeasurementStartedFlag(){ - return measurementStartedFlag; -} - -uint64_t Listener::GetPacketsCaught() { - return numPacketsCaught; -} - -uint64_t Listener::GetLastFrameIndexCaught() { - return lastCaughtFrameIndex; -} - -/** setters */ -void Listener::StartRunning() { - runningFlag = true; -} - - -void Listener::StopRunning() { - runningFlag = false; -} - - -void Listener::SetFifo(Fifo*& f) { - fifo = f; -} - - -void Listener::ResetParametersforNewAcquisition() { - acquisitionStartedFlag = false; - firstAcquisitionIndex = 0; - currentFrameIndex = 0; - lastCaughtFrameIndex = 0; -} - - -void Listener::ResetParametersforNewMeasurement() { - runningFlag = false; - measurementStartedFlag = false; - numPacketsCaught = 0; - firstMeasurementIndex = 0; - carryOverFlag = false; - if (carryOverPacket) - delete [] carryOverPacket; - carryOverPacket = new char[generalData->packetSize]; - memset(carryOverPacket,0,generalData->packetSize); - if (listeningPacket) - delete [] listeningPacket; - listeningPacket = new char[generalData->packetSize]; - memset(listeningPacket,0,generalData->packetSize); - - numPacketsStatistic = 0; - numFramesStatistic = 0; - //reset fifo statistic - fifo->GetMaxLevelForFifoBound(); - fifo->GetMinLevelForFifoFree(); -} - - - -void Listener::RecordFirstIndices(uint64_t fnum) { - //listen to this fnum, later +1 - currentFrameIndex = fnum; - - measurementStartedFlag = true; - firstMeasurementIndex = fnum; - - //start of entire acquisition - if (!acquisitionStartedFlag) { - acquisitionStartedFlag = true; - firstAcquisitionIndex = fnum; - } - - if(!(*silentMode)) { - if (!index) cprintf(BLUE,"%d First Acquisition Index:%lu\n" - "%d First Measurement Index:%lu\n", - index, firstAcquisitionIndex, - index, firstMeasurementIndex); - } -} - - -void Listener::SetGeneralData(GeneralData*& g) { - generalData = g; -#ifdef VERY_VERBOSE - generalData->Print(); -#endif -} - - -int Listener::SetThreadPriority(int priority) { - struct sched_param param; - param.sched_priority = priority; - if (pthread_setschedparam(thread, SCHED_FIFO, ¶m) == EPERM) - return FAIL; - FILE_LOG(logINFO) << "Listener Thread Priority set to " << priority; - return OK; -} - -int Listener::CreateUDPSockets() { - - if (!(*activated)) { - return OK; - } - - //if eth is mistaken with ip address - if (strchr(eth,'.') != NULL){ - memset(eth, 0, MAX_STR_LENGTH); - } - if(!strlen(eth)){ - FILE_LOG(logWARNING) << "eth is empty. Listening to all"; - } - - ShutDownUDPSocket(); - - try{ - genericSocket* g = new genericSocket(*udpPortNumber, genericSocket::UDP, - generalData->packetSize, (strlen(eth)?eth:NULL), generalData->headerPacketSize, - *udpSocketBufferSize); - udpSocket = g; - FILE_LOG(logINFO) << index << ": UDP port opened at port " << *udpPortNumber; - } catch (...) { - FILE_LOG(logERROR) << "Could not create UDP socket on port " << *udpPortNumber; - return FAIL; - } - - udpSocketAlive = true; - sem_init(&semaphore_socket,1,0); - - // doubled due to kernel bookkeeping (could also be less due to permissions) - *actualUDPSocketBufferSize = udpSocket->getActualUDPSocketBufferSize(); - - return OK; -} - - - -void Listener::ShutDownUDPSocket() { - if(udpSocket){ - udpSocketAlive = false; - udpSocket->ShutDownSocket(); - FILE_LOG(logINFO) << "Shut down of UDP port " << *udpPortNumber; - fflush(stdout); - // wait only if the threads have started as it is the threads that - //give a post to semaphore(at stopListening) - if (runningFlag) - sem_wait(&semaphore_socket); - delete udpSocket; - udpSocket = 0; - sem_destroy(&semaphore_socket); - } -} - - -int Listener::CreateDummySocketForUDPSocketBufferSize(uint32_t s) { - FILE_LOG(logINFO) << "Testing UDP Socket Buffer size with test port " << *udpPortNumber; - - if (!(*activated)) { - *actualUDPSocketBufferSize = (s*2); - return OK; - } - - uint32_t temp = *udpSocketBufferSize; - *udpSocketBufferSize = s; - - //if eth is mistaken with ip address - if (strchr(eth,'.') != NULL){ - memset(eth, 0, MAX_STR_LENGTH); - } - - // shutdown if any open - if(udpSocket){ - udpSocket->ShutDownSocket(); - delete udpSocket; - udpSocket = 0; - } - - //create dummy socket - try { - udpSocket = new genericSocket(*udpPortNumber, genericSocket::UDP, - generalData->packetSize, (strlen(eth)?eth:NULL), generalData->headerPacketSize, - *udpSocketBufferSize); - } catch (...) { - FILE_LOG(logERROR) << "Could not create a test UDP socket on port " << *udpPortNumber; - return FAIL; - } - - - // doubled due to kernel bookkeeping (could also be less due to permissions) - *actualUDPSocketBufferSize = udpSocket->getActualUDPSocketBufferSize(); - if (*actualUDPSocketBufferSize != (s*2)) { - *udpSocketBufferSize = temp; - } - - - // shutdown socket - if(udpSocket){ - udpSocketAlive = false; - udpSocket->ShutDownSocket(); - delete udpSocket; - udpSocket = 0; - } - - return OK; -} - -void Listener::SetHardCodedPosition(uint16_t r, uint16_t c) { - row = r; - column = c; -} - -void Listener::ThreadExecution() { - char* buffer; - int rc = 0; - - fifo->GetNewAddress(buffer); -#ifdef FIFODEBUG - cprintf(GREEN,"Listener %d, pop 0x%p buffer:%s\n", index,(void*)(buffer),buffer); -#endif - - //udpsocket doesnt exist - if (*activated && !udpSocketAlive && !carryOverFlag) { - //FILE_LOG(logERROR) << "Listening_Thread " << index << ": UDP Socket not created or shut down earlier"; - (*((uint32_t*)buffer)) = 0; - StopListening(buffer); - return; - } - - //get data - if ((*status != TRANSMITTING && (!(*activated) || udpSocketAlive)) || carryOverFlag) { - rc = ListenToAnImage(buffer); - } - - - //error check, (should not be here) if not transmitting yet (previous if) rc should be > 0 - if (rc == 0) { - //cprintf(RED,"%d Socket shut down while waiting for future packet. udpsocketalive:%d\n",index, udpSocketAlive ); - if (!udpSocketAlive) { - (*((uint32_t*)buffer)) = 0; - StopListening(buffer); - }else - fifo->FreeAddress(buffer); - return; - } - - // discarding image - else if (rc < 0) { - FILE_LOG(logDEBUG) << index << " discarding fnum:" << currentFrameIndex; - fifo->FreeAddress(buffer); - currentFrameIndex++; - return; - } - - (*((uint32_t*)buffer)) = rc; - (*((uint64_t*)(buffer + FIFO_HEADER_NUMBYTES ))) = currentFrameIndex; //for those returning earlier - currentFrameIndex++; - - //push into fifo - fifo->PushAddress(buffer); - - //Statistics - if(!(*silentMode)) { - numFramesStatistic++; - if (numFramesStatistic >= - //second condition also for infinite #number of frames - (((*framesPerFile) == 0) ? STATISTIC_FRAMENUMBER_INFINITE : (*framesPerFile)) ) - PrintFifoStatistics(); - } -} - - - -void Listener::StopListening(char* buf) { - (*((uint32_t*)buf)) = DUMMY_PACKET_VALUE; - fifo->PushAddress(buf); - StopRunning(); - - sem_post(&semaphore_socket); -#ifdef VERBOSE - cprintf(GREEN,"%d: Listening Packets (%u) : %llu\n", index, *udpPortNumber, numPacketsCaught); - cprintf(GREEN,"%d: Listening Completed\n", index); -#endif -} - - -/* buf includes the fifo header and packet header */ -uint32_t Listener::ListenToAnImage(char* buf) { - - int rc = 0; - uint64_t fnum = 0, bid = 0; - uint32_t pnum = 0, snum = 0; - uint32_t numpackets = 0; - uint32_t dsize = generalData->dataSize; - uint32_t hsize = generalData->headerSizeinPacket; //(includes empty header) - uint32_t esize = generalData->emptyHeader; - uint32_t fifohsize = generalData->fifoBufferHeaderSize; - uint32_t pperFrame = generalData->packetsPerFrame; - bool isHeaderEmpty = true; - sls_detector_header* old_header = 0; - sls_receiver_header* new_header = 0; - bool standardheader = generalData->standardheader; - uint32_t corrected_dsize = dsize - ((pperFrame * dsize) - generalData->imageSize); - - - //reset to -1 - memset(buf, 0, fifohsize); - /*memset(buf + fifohsize, 0xFF, generalData->imageSize);*/ - new_header = (sls_receiver_header*) (buf + FIFO_HEADER_NUMBYTES); - - // deactivated (eiger) - if (!(*activated)) { - // no padding - if (!(*deactivatedPaddingEnable)) - return 0; - // padding without setting bitmask (all missing packets padded in dataProcessor) - if (currentFrameIndex >= *numImages) - return 0; - - //(eiger) first fnum starts at 1 - if (!currentFrameIndex) { - ++currentFrameIndex; - } - new_header->detHeader.frameNumber = currentFrameIndex; - new_header->detHeader.row = row; - new_header->detHeader.column = column; - new_header->detHeader.detType = (uint8_t) generalData->myDetectorType; - new_header->detHeader.version = (uint8_t) SLS_DETECTOR_HEADER_VERSION; - return generalData->imageSize; - } - - - - //look for carry over - if (carryOverFlag) { - //cprintf(RED,"%d carry flag\n",index); - //check if its the current image packet - // -------------------------- new header ---------------------------------------------------------------------- - if (standardheader) { - old_header = (sls_detector_header*) (carryOverPacket + esize); - fnum = old_header->frameNumber; - pnum = old_header->packetNumber; - } - // -------------------old header ----------------------------------------------------------------------------- - else { - generalData->GetHeaderInfo(index, carryOverPacket + esize, - *dynamicRange, oddStartingPacket, fnum, pnum, snum, bid); - } - //------------------------------------------------------------------------------------------------------------ - if (fnum != currentFrameIndex) { - if (fnum < currentFrameIndex) { - cprintf(RED,"Error:(Weird), With carry flag: Frame number %lu less than current frame number %lu\n", fnum, currentFrameIndex); - return 0; - } - switch(*frameDiscardMode) { - case DISCARD_EMPTY_FRAMES: - if (!numpackets) - return -1; - break; - case DISCARD_PARTIAL_FRAMES: - return -1; - default: - break; - } - new_header->detHeader.packetNumber = numpackets; - if(isHeaderEmpty) { - new_header->detHeader.row = row; - new_header->detHeader.column = column; - } - return generalData->imageSize; - } - - //copy packet - switch(myDetectorType) { - //for gotthard, 1st packet: 4 bytes fnum, CACA + CACA, 639*2 bytes data - // 2nd packet: 4 bytes fnum, previous 1*2 bytes data + 640*2 bytes data !! - case GOTTHARD: - if(!pnum) - memcpy(buf + fifohsize , carryOverPacket + hsize+4, dsize-2); - else - memcpy(buf + fifohsize + dsize - 2, carryOverPacket + hsize, dsize+2); - break; - case JUNGFRAUCTB: - if (pnum == (pperFrame-1)) - memcpy(buf + fifohsize + (pnum * dsize), carryOverPacket + hsize, corrected_dsize); - else - memcpy(buf + fifohsize + (pnum * dsize), carryOverPacket + hsize, dsize); - break; - default: - memcpy(buf + fifohsize + (pnum * dsize), carryOverPacket + hsize, dsize); - break; - } - - carryOverFlag = false; - ++numpackets; //number of packets in this image (each time its copied to buf) - new_header->packetsMask[pnum] = 1; - - //writer header - if(isHeaderEmpty) { - // -------------------------- new header ---------------------------------------------------------------------- - if (standardheader) { - memcpy((char*)new_header, (char*)old_header, sizeof(sls_detector_header)); - } - // -------------------old header ------------------------------------------------------------------------------ - else { - new_header->detHeader.frameNumber = fnum; - new_header->detHeader.row = row; - new_header->detHeader.column = column; - new_header->detHeader.detType = (uint8_t) generalData->myDetectorType; - new_header->detHeader.version = (uint8_t) SLS_DETECTOR_HEADER_VERSION; - } - //------------------------------------------------------------------------------------------------------------ - isHeaderEmpty = false; - } - - } - - - - - //until last packet isHeaderEmpty to account for gotthard short frame, else never entering this loop) - while ( numpackets < pperFrame) { - //listen to new packet - rc = 0; - if (udpSocketAlive){ - rc = udpSocket->ReceiveDataOnly(listeningPacket); - } - // end of acquisition - if(rc <= 0) { - if (numpackets == 0) return 0; //empty image - - switch(*frameDiscardMode) { - case DISCARD_EMPTY_FRAMES: - if (!numpackets) - return -1; - break; - case DISCARD_PARTIAL_FRAMES: - return -1; - default: - break; - } - new_header->detHeader.packetNumber = numpackets; //number of packets caught - if(isHeaderEmpty) { - new_header->detHeader.row = row; - new_header->detHeader.column = column; - } - return generalData->imageSize; //empty packet now, but not empty image - } - - //update parameters - numPacketsCaught++; //record immediately to get more time before socket shutdown - numPacketsStatistic++; - - // -------------------------- new header ---------------------------------------------------------------------- - if (standardheader) { - old_header = (sls_detector_header*) (listeningPacket + esize); - fnum = old_header->frameNumber; - pnum = old_header->packetNumber; - } - // -------------------old header ----------------------------------------------------------------------------- - else { - // set first packet to be odd or even (check required when switching from roi to no roi) - if (myDetectorType == GOTTHARD && !measurementStartedFlag) { - oddStartingPacket = generalData->SetOddStartingPacket(index, listeningPacket + esize); - } - - generalData->GetHeaderInfo(index, listeningPacket + esize, - *dynamicRange, oddStartingPacket, fnum, pnum, snum, bid); - } - //------------------------------------------------------------------------------------------------------------ - - // Eiger Firmware in a weird state - if (myDetectorType == EIGER && fnum == 0) { - cprintf(RED,"[%u]: Got Frame Number Zero from Firmware. Discarding Packet\n", *udpPortNumber); - numPacketsCaught--; - return 0; - } - - lastCaughtFrameIndex = fnum; - - -#ifdef VERBOSE - //if (!index) - cprintf(GREEN,"Listening %d: currentfindex:%lu, fnum:%lu, pnum:%u numpackets:%u\n", - index,currentFrameIndex, fnum, pnum, numpackets); -#endif - if (!measurementStartedFlag) - RecordFirstIndices(fnum); - - //future packet by looking at image number (all other detectors) - if (fnum != currentFrameIndex) { - //cprintf(RED,"setting carry over flag to true num:%llu nump:%u\n",fnum, numpackets ); - carryOverFlag = true; - memcpy(carryOverPacket,listeningPacket, generalData->packetSize); - - switch(*frameDiscardMode) { - case DISCARD_EMPTY_FRAMES: - if (!numpackets) - return -1; - break; - case DISCARD_PARTIAL_FRAMES: - return -1; - default: - break; - } - new_header->detHeader.packetNumber = numpackets; //number of packets caught - if(isHeaderEmpty) { - new_header->detHeader.row = row; - new_header->detHeader.column = column; - } - return generalData->imageSize; - } - - //copy packet - switch(myDetectorType) { - //for gotthard, 1st packet: 4 bytes fnum, CACA + CACA, 639*2 bytes data - // 2nd packet: 4 bytes fnum, previous 1*2 bytes data + 640*2 bytes data !! - case GOTTHARD: - if(!pnum) - memcpy(buf + fifohsize + (pnum * dsize), listeningPacket + hsize+4, dsize-2); - else - memcpy(buf + fifohsize + (pnum * dsize) - 2, listeningPacket + hsize, dsize+2); - break; - case JUNGFRAUCTB: - if (pnum == (pperFrame-1)) - memcpy(buf + fifohsize + (pnum * dsize), listeningPacket + hsize, corrected_dsize); - else - memcpy(buf + fifohsize + (pnum * dsize), listeningPacket + hsize, dsize); - break; - default: - memcpy(buf + fifohsize + (pnum * dsize), listeningPacket + hsize, dsize); - break; - } - ++numpackets; //number of packets in this image (each time its copied to buf) - new_header->packetsMask[pnum] = 1; - - if(isHeaderEmpty) { - // -------------------------- new header ---------------------------------------------------------------------- - if (standardheader) { - memcpy((char*)new_header, (char*)old_header, sizeof(sls_detector_header)); - } - // -------------------old header ------------------------------------------------------------------------------ - else { - new_header->detHeader.frameNumber = fnum; - new_header->detHeader.row = row; - new_header->detHeader.column = column; - new_header->detHeader.detType = (uint8_t) generalData->myDetectorType; - new_header->detHeader.version = (uint8_t) SLS_DETECTOR_HEADER_VERSION; - } - //------------------------------------------------------------------------------------------------------------ - isHeaderEmpty = false; - } - } - - // complete image - new_header->detHeader.packetNumber = numpackets; //number of packets caught - return generalData->imageSize; -} - - - - -void Listener::PrintFifoStatistics() { -#ifdef VERBOSE - cout << "numFramesStatistic:" << numFramesStatistic << " numPacketsStatistic:" << numPacketsStatistic << endl; -#endif - //calculate packet loss - int64_t loss = -1; - loss = (numFramesStatistic*(generalData->packetsPerFrame)) - numPacketsStatistic; - numPacketsStatistic = 0; - numFramesStatistic = 0; - - if (loss) - cprintf(RED,"[%u]: Packet_Loss:%lu Used_Fifo_Max_Level:%d \tFree_Slots_Min_Level:%d \tCurrent_Frame#:%lu\n", - *udpPortNumber,loss, fifo->GetMaxLevelForFifoBound() , fifo->GetMinLevelForFifoFree(), currentFrameIndex); - else - cprintf(GREEN,"[%u]: Packet_Loss:%lu Used_Fifo_Max_Level:%d \tFree_Slots_Min_Level:%d \tCurrent_Frame#:%lu\n", - *udpPortNumber,loss, fifo->GetMaxLevelForFifoBound(), fifo->GetMinLevelForFifoFree(), currentFrameIndex); -} diff --git a/slsReceiverSoftware/src/MySocketTCP.cpp b/slsReceiverSoftware/src/MySocketTCP.cpp deleted file mode 100644 index b34231352..000000000 --- a/slsReceiverSoftware/src/MySocketTCP.cpp +++ /dev/null @@ -1,46 +0,0 @@ - -//version 1.0, base development, Ian 19/01/09 - - -#include "MySocketTCP.h" -#include -#include -#include - - - - -int MySocketTCP::SendData(void* buf,int length){//length in characters - int ndata = SendDataAndKeepConnection(buf,length); - Disconnect(); - return ndata; -} - -int MySocketTCP::SendDataAndKeepConnection(void* buf,int length){//length in characters - if(last_keep_connection_open_action_was_a_send) Disconnect(); //to keep a structured data flow; - - Connect(); - int total_sent=SendDataOnly(buf,length); - last_keep_connection_open_action_was_a_send=1; - return total_sent; -} - - - - -int MySocketTCP::ReceiveData(void* buf,int length){//length in characters - int ndata = ReceiveDataAndKeepConnection(buf,length); - Disconnect(); - return ndata; -} - -int MySocketTCP::ReceiveDataAndKeepConnection(void* buf,int length){//length in characters - if(!last_keep_connection_open_action_was_a_send) Disconnect(); //to a keep structured data flow; - - Connect(); - // should preform two reads one to receive incomming char count - int total_received=ReceiveDataOnly(buf,length); - last_keep_connection_open_action_was_a_send=0; - return total_received; -} - diff --git a/slsReceiverSoftware/src/ThreadObject.cpp b/slsReceiverSoftware/src/ThreadObject.cpp deleted file mode 100644 index cd381cc21..000000000 --- a/slsReceiverSoftware/src/ThreadObject.cpp +++ /dev/null @@ -1,106 +0,0 @@ -/************************************************ - * @file ThreadObject.cpp - * @short creates/destroys a thread - ***********************************************/ - - - -#include "ThreadObject.h" - -#include -#include - - - -ThreadObject::ThreadObject(int ind): - index(ind), - alive(false), - killThread(false), - thread(0) -{ - PrintMembers(); -} - - -ThreadObject::~ThreadObject() { - DestroyThread(); -} - - -void ThreadObject::PrintMembers() { - FILE_LOG(logDEBUG) << "Index : " << index - << "\nalive: " << alive - << "\nkillThread: " << killThread - << "\npthread: " << thread; -} - - -void ThreadObject::DestroyThread() { - if(alive){ - killThread = true; - sem_post(&semaphore); - pthread_join(thread,NULL); - sem_destroy(&semaphore); - killThread = false; - alive = false; - FILE_LOG(logDEBUG) << GetType() << " thread with index " << index << " destroyed successfully."; - } -} - - -int ThreadObject::CreateThread() { - if(alive){ - FILE_LOG(logERROR) << "Cannot create thread " << index << ". Already alive"; - return FAIL; - } - sem_init(&semaphore,1,0); - killThread = false; - - if(pthread_create(&thread, NULL,StartThread, (void*) this)){ - FILE_LOG(logERROR) << "Could not create " << GetType() << " thread with index " << index; - return FAIL; - } - alive = true; - FILE_LOG(logDEBUG) << GetType() << " thread " << index << " created successfully."; - - return OK; -} - - -void* ThreadObject::StartThread(void* thisPointer) { - ((ThreadObject*)thisPointer)->RunningThread(); - return thisPointer; -} - - -void ThreadObject::RunningThread() { - cprintf(BLUE,"Created [ %s Thread %d, Tid: %ld ]\n", GetType().c_str(),index, (long)syscall(SYS_gettid)); - while(true) { - - while(IsRunning()) { - - ThreadExecution(); - - }//end of inner loop - - - //wait till the next acquisition - sem_wait(&semaphore); - - if(killThread) { - cprintf(BLUE,"Exiting [ %s Thread %d, Tid: %ld ]\n", GetType().c_str(),index, (long)syscall(SYS_gettid)); - pthread_exit(NULL); - } - - }//end of outer loop -} - - - - -void ThreadObject::Continue() { - sem_post(&semaphore); -} - - - diff --git a/slsReceiverSoftware/src/UDPBaseImplementation.cpp b/slsReceiverSoftware/src/UDPBaseImplementation.cpp deleted file mode 100644 index f8e28cb71..000000000 --- a/slsReceiverSoftware/src/UDPBaseImplementation.cpp +++ /dev/null @@ -1,825 +0,0 @@ -//#ifdef SLS_RECEIVER_UDP_FUNCTIONS -/********************************************//** - * @file UDPBaseImplementation.cpp - * @short does all the functions for a receiver, set/get parameters, start/stop etc. - ***********************************************/ - -#include "UDPBaseImplementation.h" - -#include // stat -#include -#include - - - -/************************************************************************* - * Constructor & Destructor ********************************************** - * They access local cache of configuration or detector parameters ******* - *************************************************************************/ -UDPBaseImplementation::UDPBaseImplementation(){ - FILE_LOG(logDEBUG) << __AT__ << " starting"; - - initializeMembers(); - - //***callback parameters*** - startAcquisitionCallBack = NULL; - pStartAcquisition = NULL; - acquisitionFinishedCallBack = NULL; - pAcquisitionFinished = NULL; - rawDataReadyCallBack = NULL; - rawDataModifyReadyCallBack = NULL; - pRawDataReady = NULL; -} - -void UDPBaseImplementation::initializeMembers(){ - FILE_LOG(logDEBUG) << __AT__ << " starting"; - - FILE_LOG(logDEBUG) << "Info: Initializing base members"; - //**detector parameters*** - for (int i = 0; i < MAX_DIMENSIONS; ++i) - numDet[i] = 0; - detID = 0; - myDetectorType = GENERIC; - strcpy(detHostname,""); - acquisitionPeriod = 0; - acquisitionTime = 0; - subExpTime = 0; - subPeriod = 0; - numberOfFrames = 0; - numberOfSamples = 0; - dynamicRange = 16; - tengigaEnable = false; - fifoDepth = 0; - flippedData[0] = 0; - flippedData[1] = 0; - gapPixelsEnable = false; - - //***receiver parameters*** - status = IDLE; - activated = true; - deactivatedPaddingEnable = true; - frameDiscardMode = NO_DISCARD; - framePadding = false; - - //***connection parameters*** - strcpy(eth,""); - for(int i=0;i 1) return -1; - return flippedData[axis]; -} - -bool UDPBaseImplementation::getGapPixelsEnable() const { - FILE_LOG(logDEBUG) << __AT__ << " starting"; - return gapPixelsEnable; -} - -/***file parameters***/ -slsReceiverDefs::fileFormat UDPBaseImplementation::getFileFormat() const{ - FILE_LOG(logDEBUG) << __AT__ << " starting"; - return fileFormatType; -} - - -char *UDPBaseImplementation::getFileName() const{ - FILE_LOG(logDEBUG) << __AT__ << " starting"; - - //not initialized - if(!strlen(fileName)) - return NULL; - - char* output = new char[MAX_STR_LENGTH](); - strcpy(output,fileName); - //freed by calling function - return output; -} - -char *UDPBaseImplementation::getFilePath() const{ - FILE_LOG(logDEBUG) << __AT__ << " starting"; - - //not initialized - if(!strlen(filePath)) - return NULL; - - char* output = new char[MAX_STR_LENGTH](); - strcpy(output,filePath); - //freed by calling function - return output; -} - -uint64_t UDPBaseImplementation::getFileIndex() const{ - FILE_LOG(logDEBUG) << __AT__ << " starting"; - return fileIndex; -} - -uint32_t UDPBaseImplementation::getFramesPerFile() const{ - FILE_LOG(logDEBUG) << __AT__ << " starting"; - return framesPerFile; -} - -slsReceiverDefs::frameDiscardPolicy UDPBaseImplementation::getFrameDiscardPolicy() const{ - FILE_LOG(logDEBUG) << __AT__ << " starting"; - return frameDiscardMode; -} - -bool UDPBaseImplementation::getFramePaddingEnable() const{ - FILE_LOG(logDEBUG) << __AT__ << " starting"; - return framePadding; -} - -int UDPBaseImplementation::getScanTag() const{ - FILE_LOG(logDEBUG) << __AT__ << " starting"; - return scanTag; -} - -bool UDPBaseImplementation::getFileWriteEnable() const{ - FILE_LOG(logDEBUG) << __AT__ << " starting"; - return fileWriteEnable; -} - -bool UDPBaseImplementation::getOverwriteEnable() const{ - FILE_LOG(logDEBUG) << __AT__ << " starting"; - return overwriteEnable; -} - -bool UDPBaseImplementation::getDataCompressionEnable() const{ - FILE_LOG(logDEBUG) << __AT__ << " starting"; - return dataCompressionEnable; -} - -/***acquisition count parameters***/ -uint64_t UDPBaseImplementation::getTotalFramesCaught() const{ - FILE_LOG(logDEBUG) << __AT__ << " starting"; - return 0; -} - -uint64_t UDPBaseImplementation::getFramesCaught() const{ - FILE_LOG(logDEBUG) << __AT__ << " starting"; - return 0; -} - -int64_t UDPBaseImplementation::getAcquisitionIndex() const{ - FILE_LOG(logDEBUG) << __AT__ << " starting"; - return -1; -} - - -/***connection parameters***/ -uint32_t UDPBaseImplementation::getUDPPortNumber() const{ - FILE_LOG(logDEBUG) << __AT__ << " starting"; - return udpPortNum[0]; -} - -uint32_t UDPBaseImplementation::getUDPPortNumber2() const{ - FILE_LOG(logDEBUG) << __AT__ << " starting"; - return udpPortNum[1]; -} - -char *UDPBaseImplementation::getEthernetInterface() const{ - FILE_LOG(logDEBUG) << __AT__ << " starting"; - - char* output = new char[MAX_STR_LENGTH](); - strcpy(output,eth); - //freed by calling function - return output; -} - - -/***acquisition parameters***/ -std::vector UDPBaseImplementation::getROI() const{ - FILE_LOG(logDEBUG) << __AT__ << " starting"; - return roi; -} - -uint32_t UDPBaseImplementation::getFrameToGuiFrequency() const{ - FILE_LOG(logDEBUG) << __AT__ << " starting"; - return frameToGuiFrequency; -} - -uint32_t UDPBaseImplementation::getFrameToGuiTimer() const{ - FILE_LOG(logDEBUG) << __AT__ << " starting"; - return frameToGuiTimerinMS; -} - -bool UDPBaseImplementation::getDataStreamEnable() const{ - FILE_LOG(logDEBUG) << __AT__ << " starting"; - return dataStreamEnable; -} - -uint64_t UDPBaseImplementation::getAcquisitionPeriod() const{ - FILE_LOG(logDEBUG) << __AT__ << " starting"; - return acquisitionPeriod; -} - -uint64_t UDPBaseImplementation::getAcquisitionTime() const{ - FILE_LOG(logDEBUG) << __AT__ << " starting"; - return acquisitionTime; -} - -uint64_t UDPBaseImplementation::getSubExpTime() const{ - FILE_LOG(logDEBUG) << __AT__ << " starting"; - return subExpTime; -} - -uint64_t UDPBaseImplementation::getSubPeriod() const{ - FILE_LOG(logDEBUG) << __AT__ << " starting"; - return subPeriod; -} - -uint64_t UDPBaseImplementation::getNumberOfFrames() const{ - FILE_LOG(logDEBUG) << __AT__ << " starting"; - return numberOfFrames; -} - -uint64_t UDPBaseImplementation::getNumberofSamples() const{ - FILE_LOG(logDEBUG) << __AT__ << " starting"; - return numberOfSamples; -} - -uint32_t UDPBaseImplementation::getDynamicRange() const{ - FILE_LOG(logDEBUG) << __AT__ << " starting"; - return dynamicRange;} - -bool UDPBaseImplementation::getTenGigaEnable() const{ - FILE_LOG(logDEBUG) << __AT__ << " starting"; - return tengigaEnable; -} - -uint32_t UDPBaseImplementation::getFifoDepth() const{ - FILE_LOG(logDEBUG) << __AT__ << " starting"; - return fifoDepth; -} - -/***receiver status***/ -slsReceiverDefs::runStatus UDPBaseImplementation::getStatus() const{ - FILE_LOG(logDEBUG) << __AT__ << " starting"; - return status;} - -bool UDPBaseImplementation::getSilentMode() const{ - FILE_LOG(logDEBUG) << __AT__ << " starting"; - return silentMode;} - -bool UDPBaseImplementation::getActivate() const{ - FILE_LOG(logDEBUG) << __AT__ << " starting"; - return activated; -} - -bool UDPBaseImplementation::getDeactivatedPadding() const{ - FILE_LOG(logDEBUG) << __AT__ << " starting"; - return deactivatedPaddingEnable; -} - -uint32_t UDPBaseImplementation::getStreamingPort() const{ - FILE_LOG(logDEBUG) << __AT__ << " starting"; - return streamingPort; -} - -char *UDPBaseImplementation::getStreamingSourceIP() const{ - FILE_LOG(logDEBUG) << __AT__ << " starting"; - - char* output = new char[MAX_STR_LENGTH](); - strcpy(output,streamingSrcIP); - //freed by calling function - return output; -} - -char *UDPBaseImplementation::getAdditionalJsonHeader() const{ - FILE_LOG(logDEBUG) << __AT__ << " starting"; - - char* output = new char[MAX_STR_LENGTH](); - memset(output, 0, MAX_STR_LENGTH); - strcpy(output,additionalJsonHeader); - //freed by calling function - return output; -} - -uint32_t UDPBaseImplementation::getUDPSocketBufferSize() const { - FILE_LOG(logDEBUG) << __AT__ << " starting"; - return udpSocketBufferSize; -} - -uint32_t UDPBaseImplementation::getActualUDPSocketBufferSize() const { - FILE_LOG(logDEBUG) << __AT__ << " starting"; - return actualUDPSocketBufferSize; -} - -/************************************************************************* - * Setters *************************************************************** - * They modify the local cache of configuration or detector parameters *** - *************************************************************************/ - -/**initial parameters***/ -void UDPBaseImplementation::configure(std::map config_map){ - FILE_LOG(logERROR) << __AT__ << " doing nothing..."; - FILE_LOG(logERROR) << __AT__ << " must be overridden by child classes"; -} - -void UDPBaseImplementation::setMultiDetectorSize(const int* size) { - FILE_LOG(logDEBUG) << __AT__ << " starting"; - char message[100]; - strcpy(message, "Detector Size: ("); - for (int i = 0; i < MAX_DIMENSIONS; ++i) { - if (myDetectorType == EIGER && (!i)) - numDet[i] = size[i]*2; - else - numDet[i] = size[i]; - sprintf(message,"%s%d",message,numDet[i]); - if (i < MAX_DIMENSIONS-1 ) - strcat(message,","); - } - strcat(message,")"); - FILE_LOG(logINFO) << message; -} - -void UDPBaseImplementation::setFlippedData(int axis, int enable){ - FILE_LOG(logDEBUG) << __AT__ << " starting"; - if(axis<0 || axis>1) return; - flippedData[axis] = enable==0?0:1; - FILE_LOG(logINFO) << "Flipped Data: " << flippedData[0] << " , " << flippedData[1]; -} - -int UDPBaseImplementation::setGapPixelsEnable(const bool b) { - FILE_LOG(logDEBUG) << __AT__ << " starting"; - gapPixelsEnable = b; - FILE_LOG(logINFO) << "Gap Pixels Enable: " << gapPixelsEnable; - - // overridden - return OK; -} - -/***file parameters***/ -void UDPBaseImplementation::setFileFormat(const fileFormat f){ - FILE_LOG(logDEBUG) << __AT__ << " starting"; - - switch(f){ -#ifdef HDF5C - case HDF5: - fileFormatType = HDF5; - break; -#endif - default: - fileFormatType = BINARY; - break; - } - - FILE_LOG(logINFO) << "File Format: " << getFileFormatType(fileFormatType); -} - - -void UDPBaseImplementation::setFileName(const char c[]){ - FILE_LOG(logDEBUG) << __AT__ << " starting"; - - if(strlen(c)) - strcpy(fileName, c); - FILE_LOG(logINFO) << "File name: " << fileName; -} - -void UDPBaseImplementation::setFilePath(const char c[]){ - FILE_LOG(logDEBUG) << __AT__ << " starting"; - - - if(strlen(c)){ - //check if filepath exists - struct stat st; - if(stat(c,&st) == 0) - strcpy(filePath,c); - else - FILE_LOG(logERROR) << "FilePath does not exist: " << filePath; - } - FILE_LOG(logINFO) << "File path: " << filePath; -} - -void UDPBaseImplementation::setFileIndex(const uint64_t i){ - FILE_LOG(logDEBUG) << __AT__ << " starting"; - - fileIndex = i; - FILE_LOG(logINFO) << "File Index: " << fileIndex; -} - -void UDPBaseImplementation::setFramesPerFile(const uint32_t i){ - FILE_LOG(logDEBUG) << __AT__ << " starting"; - - framesPerFile = i; - FILE_LOG(logINFO) << "Frames per file: " << framesPerFile; -} - -void UDPBaseImplementation::setFrameDiscardPolicy(const frameDiscardPolicy i){ - FILE_LOG(logDEBUG) << __AT__ << " starting"; - - if (i >= 0 && i < NUM_DISCARD_POLICIES) - frameDiscardMode = i; - - FILE_LOG(logINFO) << "Frame Discard Policy: " << getFrameDiscardPolicyType(frameDiscardMode); -} - -void UDPBaseImplementation::setFramePaddingEnable(const bool i){ - FILE_LOG(logDEBUG) << __AT__ << " starting"; - - framePadding = i; - FILE_LOG(logINFO) << "Frame Padding: " << framePadding; -} - -//FIXME: needed? -void UDPBaseImplementation::setScanTag(const int i){ - FILE_LOG(logDEBUG) << __AT__ << " starting"; - - scanTag = i; - FILE_LOG(logINFO) << "Scan Tag: " << scanTag; - -} - -void UDPBaseImplementation::setFileWriteEnable(const bool b){ - FILE_LOG(logDEBUG) << __AT__ << " starting"; - - fileWriteEnable = b; - FILE_LOG(logINFO) << "File Write Enable: " << stringEnable(fileWriteEnable); -} - -void UDPBaseImplementation::setOverwriteEnable(const bool b){ - FILE_LOG(logDEBUG) << __AT__ << " starting"; - - overwriteEnable = b; - FILE_LOG(logINFO) << "Overwrite Enable: " << stringEnable(overwriteEnable); -} - -int UDPBaseImplementation::setDataCompressionEnable(const bool b){ - FILE_LOG(logDEBUG) << __AT__ << " starting"; - - dataCompressionEnable = b; - FILE_LOG(logINFO) << "Data Compression : " << stringEnable(dataCompressionEnable); - - //overridden methods might return FAIL - return OK; -} - - -/***connection parameters***/ -void UDPBaseImplementation::setUDPPortNumber(const uint32_t i){ - FILE_LOG(logDEBUG) << __AT__ << " starting"; - - udpPortNum[0] = i; - FILE_LOG(logINFO) << "UDP Port Number[0]: " << udpPortNum[0]; -} - -void UDPBaseImplementation::setUDPPortNumber2(const uint32_t i){ - FILE_LOG(logDEBUG) << __AT__ << " starting"; - - udpPortNum[1] = i; - FILE_LOG(logINFO) << "UDP Port Number[1]: " << udpPortNum[1]; -} - -void UDPBaseImplementation::setEthernetInterface(const char* c){ - FILE_LOG(logDEBUG) << __AT__ << " starting"; - - strcpy(eth, c); - FILE_LOG(logINFO) << "Ethernet Interface: " << eth; -} - - -/***acquisition parameters***/ -int UDPBaseImplementation::setROI(const std::vector i){ - FILE_LOG(logDEBUG) << __AT__ << " starting"; - - roi = i; - - std::stringstream sstm; - sstm << "ROI: "; - if (!roi.size()) - sstm << "0"; - else { - for (unsigned int i = 0; i < roi.size(); ++i) { - sstm << "( " << - roi[i].xmin << ", " << - roi[i].xmax << ", " << - roi[i].ymin << ", " << - roi[i].ymax << " )"; - } - } - std::string message = sstm.str(); - FILE_LOG(logINFO) << message; - - //overrridden child classes might return FAIL - return OK; -} - -int UDPBaseImplementation::setFrameToGuiFrequency(const uint32_t freq){ - FILE_LOG(logDEBUG) << __AT__ << " starting"; - - frameToGuiFrequency = freq; - FILE_LOG(logINFO) << "Frame To Gui Frequency: " << frameToGuiFrequency; - - //overrridden child classes might return FAIL - return OK; -} - -void UDPBaseImplementation::setFrameToGuiTimer(const uint32_t time_in_ms){ - FILE_LOG(logDEBUG) << __AT__ << " starting"; - - frameToGuiTimerinMS = time_in_ms; - FILE_LOG(logINFO) << "Frame To Gui Timer: " << frameToGuiTimerinMS; -} - - -int UDPBaseImplementation::setDataStreamEnable(const bool enable){ - FILE_LOG(logDEBUG) << __AT__ << " starting"; - - dataStreamEnable = enable; - FILE_LOG(logINFO) << "Streaming Data from Receiver: " << dataStreamEnable; - - //overrridden child classes might return FAIL - return OK; -} - - -int UDPBaseImplementation::setAcquisitionPeriod(const uint64_t i){ - FILE_LOG(logDEBUG) << __AT__ << " starting"; - - acquisitionPeriod = i; - FILE_LOG(logINFO) << "Acquisition Period: " << (double)acquisitionPeriod/(1E9) << "s"; - - //overrridden child classes might return FAIL - return OK; -} - -int UDPBaseImplementation::setAcquisitionTime(const uint64_t i){ - FILE_LOG(logDEBUG) << __AT__ << " starting"; - - acquisitionTime = i; - FILE_LOG(logINFO) << "Acquisition Time: " << (double)acquisitionTime/(1E9) << "s"; - - //overrridden child classes might return FAIL - return OK; -} - -void UDPBaseImplementation::setSubExpTime(const uint64_t i){ - FILE_LOG(logDEBUG) << __AT__ << " starting"; - - subExpTime = i; - FILE_LOG(logINFO) << "Sub Exposure Time: " << (double)subExpTime/(1E9) << "s"; -} - -void UDPBaseImplementation::setSubPeriod(const uint64_t i){ - FILE_LOG(logDEBUG) << __AT__ << " starting"; - - subPeriod = i; - FILE_LOG(logINFO) << "Sub Exposure Time: " << (double)subPeriod/(1E9) << "s"; -} - -int UDPBaseImplementation::setNumberOfFrames(const uint64_t i){ - FILE_LOG(logDEBUG) << __AT__ << " starting"; - - numberOfFrames = i; - FILE_LOG(logINFO) << "Number of Frames: " << numberOfFrames; - - //overrridden child classes might return FAIL - return OK; -} - -int UDPBaseImplementation::setNumberofSamples(const uint64_t i){ - FILE_LOG(logDEBUG) << __AT__ << " starting"; - - numberOfSamples = i; - FILE_LOG(logINFO) << "Number of Samples: " << numberOfSamples; - - //overrridden child classes might return FAIL - return OK; -} - -int UDPBaseImplementation::setDynamicRange(const uint32_t i){ - FILE_LOG(logDEBUG) << __AT__ << " starting"; - - dynamicRange = i; - FILE_LOG(logINFO) << "Dynamic Range: " << dynamicRange; - - //overrridden child classes might return FAIL - return OK; -} - -int UDPBaseImplementation::setTenGigaEnable(const bool b){ - FILE_LOG(logDEBUG) << __AT__ << " starting"; - - tengigaEnable = b; - FILE_LOG(logINFO) << "Ten Giga Enable: " << stringEnable(tengigaEnable); - - //overridden functions might return FAIL - return OK; -} - -int UDPBaseImplementation::setFifoDepth(const uint32_t i){ - FILE_LOG(logDEBUG) << __AT__ << " starting"; - - fifoDepth = i; - FILE_LOG(logINFO) << "Fifo Depth: " << i; - - //overridden functions might return FAIL - return OK; -} - -/***receiver parameters***/ -void UDPBaseImplementation::setSilentMode(const bool i){ - FILE_LOG(logDEBUG) << __AT__ << " starting"; - - silentMode = i; - FILE_LOG(logINFO) << "Silent Mode: " << i; -} - -/************************************************************************* - * Behavioral functions*************************************************** - * They may modify the status of the receiver **************************** - *************************************************************************/ - - -/***initial functions***/ -int UDPBaseImplementation::setDetectorType(const detectorType d){ - FILE_LOG(logDEBUG) << __AT__ << " starting"; - - myDetectorType = d; - //if eiger, set numberofListeningThreads = 2; - FILE_LOG(logINFO) << "Detector Type: " << getDetectorType(d); - return OK; -} - -void UDPBaseImplementation::setDetectorPositionId(const int i){ - FILE_LOG(logDEBUG) << __AT__ << " starting"; - - detID = i; - FILE_LOG(logINFO) << "Detector Position Id: " << detID; -} - -void UDPBaseImplementation::initialize(const char *c){ - FILE_LOG(logDEBUG) << __AT__ << " starting"; - - if(strlen(c)) - strcpy(detHostname, c); - FILE_LOG(logINFO) << "Detector Hostname: " << detHostname; -} - - -/***acquisition functions***/ -void UDPBaseImplementation::resetAcquisitionCount(){ - FILE_LOG(logDEBUG) << __AT__ << " starting"; - - //overriden by resetting of new acquisition parameters -} - -int UDPBaseImplementation::startReceiver(char *c){ - FILE_LOG(logERROR) << __AT__ << " doing nothing..."; - FILE_LOG(logERROR) << __AT__ << " must be overridden by child classes"; - return OK; -} - -void UDPBaseImplementation::stopReceiver(){ - FILE_LOG(logERROR) << __AT__ << " doing nothing..."; - FILE_LOG(logERROR) << __AT__ << " must be overridden by child classes"; -} - -void UDPBaseImplementation::startReadout(){ - FILE_LOG(logERROR) << __AT__ << " doing nothing..."; - FILE_LOG(logERROR) << __AT__ << " must be overridden by child classes"; -} - -void UDPBaseImplementation::shutDownUDPSockets(){ - FILE_LOG(logERROR) << __AT__ << " doing nothing..."; - FILE_LOG(logERROR) << __AT__ << " must be overridden by child classes"; -} - - -//FIXME: needed, isnt stopReceiver enough? -void UDPBaseImplementation::abort(){ - FILE_LOG(logERROR) << __AT__ << " doing nothing..."; - FILE_LOG(logERROR) << __AT__ << " must be overridden by child classes"; -} - - -bool UDPBaseImplementation::setActivate(bool enable){ - FILE_LOG(logDEBUG) << __AT__ << " starting"; - activated = enable; - FILE_LOG(logINFO) << "Activation: " << stringEnable(activated); - return activated; -} - -bool UDPBaseImplementation::setDeactivatedPadding(bool enable){ - FILE_LOG(logDEBUG) << __AT__ << " starting"; - deactivatedPaddingEnable = enable; - FILE_LOG(logINFO) << "Deactivated Padding Enable: " << stringEnable(deactivatedPaddingEnable); - return deactivatedPaddingEnable; -} - -void UDPBaseImplementation::setStreamingPort(const uint32_t i) { - streamingPort = i; - - FILE_LOG(logINFO) << "Streaming Port: " << streamingPort; -} - -void UDPBaseImplementation::setStreamingSourceIP(const char c[]){ - FILE_LOG(logDEBUG) << __AT__ << " starting"; - strcpy(streamingSrcIP, c); - FILE_LOG(logINFO) << "Streaming Source IP: " << streamingSrcIP; -} - -void UDPBaseImplementation::setAdditionalJsonHeader(const char c[]){ - FILE_LOG(logDEBUG) << __AT__ << " starting"; - strcpy(additionalJsonHeader, c); - FILE_LOG(logINFO) << "Additional JSON Header: " << additionalJsonHeader; -} - -int UDPBaseImplementation::setUDPSocketBufferSize(const uint32_t s) { - FILE_LOG(logDEBUG) << __AT__ << " starting"; - - udpSocketBufferSize = s; - return OK; -} - - -int UDPBaseImplementation::restreamStop() { - FILE_LOG(logERROR) << __AT__ << " doing nothing..."; - FILE_LOG(logERROR) << __AT__ << " must be overridden by child classes"; - return OK; -} - -/***callback functions***/ -void UDPBaseImplementation::registerCallBackStartAcquisition(int (*func)(char*, char*, uint64_t, uint32_t, void*),void *arg){ - startAcquisitionCallBack=func; - pStartAcquisition=arg; -} - -void UDPBaseImplementation::registerCallBackAcquisitionFinished(void (*func)(uint64_t, void*),void *arg){ - acquisitionFinishedCallBack=func; - pAcquisitionFinished=arg; -} - -void UDPBaseImplementation::registerCallBackRawDataReady(void (*func)(char* , - char*, uint32_t, void*),void *arg){ - rawDataReadyCallBack=func; - pRawDataReady=arg; -} - -void UDPBaseImplementation::registerCallBackRawDataModifyReady(void (*func)(char* , - char*, uint32_t&, void*),void *arg){ - rawDataModifyReadyCallBack=func; - pRawDataReady=arg; -} -//#endif diff --git a/slsReceiverSoftware/src/UDPInterface.cpp b/slsReceiverSoftware/src/UDPInterface.cpp deleted file mode 100644 index 73d5835af..000000000 --- a/slsReceiverSoftware/src/UDPInterface.cpp +++ /dev/null @@ -1,30 +0,0 @@ -//#ifdef SLS_RECEIVER_UDP_FUNCTIONS -/********************************************//** - * @file slsReceiverUDPFunctions.cpp - * @short does all the functions for a receiver, set/get parameters, start/stop etc. - ***********************************************/ - - -#include -#include - - -#include "UDPInterface.h" -#include "UDPBaseImplementation.h" -#include "UDPStandardImplementation.h" - - -UDPInterface * UDPInterface::create(std::string receiver_type){ - - if (receiver_type == "standard"){ - FILE_LOG(logINFO) << "Starting " << receiver_type; - return new UDPStandardImplementation(); - } - else{ - FILE_LOG(logERROR) << "UDP interface not supported, using base implementation"; - return new UDPBaseImplementation(); - } -} - - -//#endif diff --git a/slsReceiverSoftware/src/UDPStandardImplementation.cpp b/slsReceiverSoftware/src/UDPStandardImplementation.cpp deleted file mode 100644 index 75d611006..000000000 --- a/slsReceiverSoftware/src/UDPStandardImplementation.cpp +++ /dev/null @@ -1,822 +0,0 @@ -/********************************************//** - * @file UDPStandardImplementation.cpp - * @short does all the functions for a receiver, set/get parameters, start/stop etc. - ***********************************************/ - - -#include "UDPStandardImplementation.h" -#include "GeneralData.h" -#include "Listener.h" -#include "DataProcessor.h" -#include "DataStreamer.h" -#include "Fifo.h" -#include "ZmqSocket.h" //just for the zmq port define - -#include //system -#include //strcpy -#include //eperm -#include - - -/** cosntructor & destructor */ - -UDPStandardImplementation::UDPStandardImplementation() { - InitializeMembers(); -} - - -UDPStandardImplementation::~UDPStandardImplementation() { - DeleteMembers(); -} - - -void UDPStandardImplementation::DeleteMembers() { - if (generalData) { delete generalData; generalData=0;} - for (std::vector::const_iterator it = listener.begin(); it != listener.end(); ++it) - delete(*it); - listener.clear(); - for (std::vector::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it) - delete(*it); - dataProcessor.clear(); - for (std::vector::const_iterator it = dataStreamer.begin(); it != dataStreamer.end(); ++it) - delete(*it); - dataStreamer.clear(); - for (std::vector::const_iterator it = fifo.begin(); it != fifo.end(); ++it) - delete(*it); - fifo.clear(); -} - - -void UDPStandardImplementation::InitializeMembers() { - UDPBaseImplementation::initializeMembers(); - acquisitionPeriod = SAMPLE_TIME_IN_NS; - - //*** receiver parameters *** - numThreads = 1; - numberofJobs = 1; - nroichannels = 0; - - //** class objects *** - generalData = 0; -} - - - -/*** Overloaded Functions called by TCP Interface ***/ - -uint64_t UDPStandardImplementation::getTotalFramesCaught() const { - uint64_t sum = 0; - uint32_t flagsum = 0; - - std::vector::const_iterator it; - for (std::vector::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it) { - flagsum += ((*it)->GetMeasurementStartedFlag() ? 1 : 0); - sum += (*it)->GetNumTotalFramesCaught(); - } - - //no data processed - if (flagsum != dataProcessor.size()) return 0; - - return (sum/dataProcessor.size()); -} - -uint64_t UDPStandardImplementation::getFramesCaught() const { - uint64_t sum = 0; - uint32_t flagsum = 0; - - for (std::vector::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it) { - flagsum += ((*it)->GetAcquisitionStartedFlag() ? 1 : 0); - sum += (*it)->GetNumFramesCaught(); - } - - //no data processed - if (flagsum != dataProcessor.size()) return 0; - - return (sum/dataProcessor.size()); -} - -int64_t UDPStandardImplementation::getAcquisitionIndex() const { - uint64_t sum = 0; - uint32_t flagsum = 0; - - for (std::vector::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it){ - flagsum += ((*it)->GetAcquisitionStartedFlag() ? 1 : 0); - sum += (*it)->GetActualProcessedAcquisitionIndex(); - } - - //no data processed - if (flagsum != dataProcessor.size()) return -1; - - return (sum/dataProcessor.size()); -} - - - -int UDPStandardImplementation::setGapPixelsEnable(const bool b) { - if (gapPixelsEnable != b) { - gapPixelsEnable = b; - - // side effects - generalData->SetGapPixelsEnable(b, dynamicRange); - // to update npixelsx, npixelsy in file writer - for (std::vector::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it) - (*it)->SetPixelDimension(); - - numberofJobs = -1; //changes to imagesize has to be noted to recreate fifo structure - if (SetupFifoStructure() == FAIL) - return FAIL; - } - FILE_LOG(logINFO) << "Gap Pixels Enable: " << gapPixelsEnable; - return OK; -} - - -void UDPStandardImplementation::setFileFormat(const fileFormat f){ - switch(f){ -#ifdef HDF5C - case HDF5: - fileFormatType = HDF5; - break; -#endif - default: - fileFormatType = BINARY; - break; - } - //destroy file writer, set file format and create file writer - for (std::vector::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it) - (*it)->SetFileFormat(f); - - FILE_LOG(logINFO) << "File Format:" << getFileFormatType(fileFormatType); -} - - -void UDPStandardImplementation::setFileWriteEnable(const bool b){ - if (fileWriteEnable != b){ - fileWriteEnable = b; - for (unsigned int i = 0; i < dataProcessor.size(); ++i) { - dataProcessor[i]->SetupFileWriter(fileWriteEnable, (int*)numDet, - &framesPerFile, fileName, filePath, &fileIndex, &overwriteEnable, - &detID, &numThreads, &numberOfFrames, &dynamicRange, &udpPortNum[i], - generalData); - } - } - - FILE_LOG(logINFO) << "File Write Enable: " << stringEnable(fileWriteEnable); -} - - - - -int UDPStandardImplementation::setROI(const std::vector i) { - if (myDetectorType != GOTTHARD) { - cprintf(RED, "Error: Can not set ROI for this detector\n"); - return FAIL; - } - - - bool change = false; - if (roi.size() != i.size()) - change = true; - else { - for (unsigned int iloop = 0; iloop < i.size(); ++iloop) { - if ( - (roi[iloop].xmin != i[iloop].xmin) || - (roi[iloop].xmax != i[iloop].xmax) || - (roi[iloop].ymin != i[iloop].ymin) || - (roi[iloop].xmax != i[iloop].xmax)) { - change = true; - break; - } - } - } - - if (change) { - - roi = i; - - generalData->SetROI(i); - framesPerFile = generalData->maxFramesPerFile; - - numberofJobs = -1; //changes to imagesize has to be noted to recreate fifo structure - if (SetupFifoStructure() == FAIL) - return FAIL; - - for (std::vector::const_iterator it = listener.begin(); it != listener.end(); ++it) - (*it)->SetGeneralData(generalData); - for (std::vector::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it) - (*it)->SetGeneralData(generalData); - for (std::vector::const_iterator it = dataStreamer.begin(); it != dataStreamer.end(); ++it) - (*it)->SetGeneralData(generalData); - } - - - std::stringstream sstm; - sstm << "ROI: "; - if (!roi.size()) - sstm << "0"; - else { - for (unsigned int i = 0; i < roi.size(); ++i) { - sstm << "( " << - roi[i].xmin << ", " << - roi[i].xmax << ", " << - roi[i].ymin << ", " << - roi[i].ymax << " )"; - } - } - std::string message = sstm.str(); - FILE_LOG(logINFO) << message; - return OK; -} - - -int UDPStandardImplementation::setFrameToGuiFrequency(const uint32_t freq) { - if (frameToGuiFrequency != freq) { - frameToGuiFrequency = freq; - } - FILE_LOG(logINFO) << "Frame to Gui Frequency: " << frameToGuiFrequency; - return OK; -} - - -int UDPStandardImplementation::setDataStreamEnable(const bool enable) { - - if (dataStreamEnable != enable) { - dataStreamEnable = enable; - - //data sockets have to be created again as the client ones are - for (std::vector::const_iterator it = dataStreamer.begin(); it != dataStreamer.end(); ++it) - delete(*it); - dataStreamer.clear(); - - if (enable) { - for ( int i = 0; i < numThreads; ++i ) { - try { - DataStreamer* s = new DataStreamer(i, fifo[i], &dynamicRange, - &roi, &fileIndex, flippedData, additionalJsonHeader, &silentMode); - dataStreamer.push_back(s); - dataStreamer[i]->SetGeneralData(generalData); - dataStreamer[i]->CreateZmqSockets(&numThreads, streamingPort, streamingSrcIP); - } - catch(...) { - for (std::vector::const_iterator it = dataStreamer.begin(); it != dataStreamer.end(); ++it) - delete(*it); - dataStreamer.clear(); - dataStreamEnable = false; - return FAIL; - } - } - SetThreadPriorities(); - } - } - FILE_LOG(logINFO) << "Data Send to Gui: " << dataStreamEnable; - return OK; -} - - - -int UDPStandardImplementation::setNumberofSamples(const uint64_t i) { - if (numberOfSamples != i) { - numberOfSamples = i; - - generalData->setNumberofSamples(i, nroichannels); - numberofJobs = -1; //changes to imagesize has to be noted to recreate fifo structure - if (SetupFifoStructure() == FAIL) - return FAIL; - } - FILE_LOG (logINFO) << "Number of Samples: " << numberOfSamples; - FILE_LOG (logINFO) << "Packets per Frame: " << (generalData->packetsPerFrame); - return OK; -} - - -int UDPStandardImplementation::setDynamicRange(const uint32_t i) { - if (dynamicRange != i) { - dynamicRange = i; - - //side effects - generalData->SetDynamicRange(i,tengigaEnable); - generalData->SetGapPixelsEnable(gapPixelsEnable, dynamicRange); - // to update npixelsx, npixelsy in file writer - for (std::vector::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it) - (*it)->SetPixelDimension(); - - numberofJobs = -1; //changes to imagesize has to be noted to recreate fifo structure - if (SetupFifoStructure() == FAIL) - return FAIL; - } - FILE_LOG(logINFO) << "Dynamic Range: " << dynamicRange; - return OK; -} - - -int UDPStandardImplementation::setTenGigaEnable(const bool b) { - if (tengigaEnable != b) { - tengigaEnable = b; - //side effects - generalData->SetTenGigaEnable(b,dynamicRange); - - numberofJobs = -1; //changes to imagesize has to be noted to recreate fifo structure - if (SetupFifoStructure() == FAIL) - return FAIL; - } - FILE_LOG(logINFO) << "Ten Giga: " << stringEnable(tengigaEnable); - return OK; -} - - -int UDPStandardImplementation::setFifoDepth(const uint32_t i) { - if (fifoDepth != i) { - fifoDepth = i; - - numberofJobs = -1; //changes to imagesize has to be noted to recreate fifo structure - if (SetupFifoStructure() == FAIL) - return FAIL; - } - FILE_LOG(logINFO) << "Fifo Depth: " << i; - return OK; -} - - - -int UDPStandardImplementation::setDetectorType(const detectorType d) { - FILE_LOG(logDEBUG) << "Setting receiver type"; - DeleteMembers(); - InitializeMembers(); - myDetectorType = d; - switch(myDetectorType) { - case GOTTHARD: - case PROPIX: - case MOENCH: - case EIGER: - case JUNGFRAUCTB: - case JUNGFRAU: - FILE_LOG(logINFO) << " ***** " << getDetectorType(d) << " Receiver *****"; - break; - default: - FILE_LOG(logERROR) << "This is an unknown receiver type " << (int)d; - return FAIL; - } - - - //set detector specific variables - switch(myDetectorType) { - case GOTTHARD: generalData = new GotthardData(); break; - case PROPIX: generalData = new PropixData(); break; - case MOENCH: generalData = new Moench02Data(); break; - case EIGER: generalData = new EigerData(); break; - case JUNGFRAUCTB: generalData = new JCTBData(); break; - case JUNGFRAU: generalData = new JungfrauData(); break; - default: break; - } - numThreads = generalData->threadsPerReceiver; - fifoDepth = generalData->defaultFifoDepth; - udpSocketBufferSize = generalData->defaultUdpSocketBufferSize; - framesPerFile = generalData->maxFramesPerFile; - - //local network parameters - SetLocalNetworkParameters(); - - //create fifo structure - numberofJobs = -1; - if (SetupFifoStructure() == FAIL) { - FILE_LOG(logERROR) << "Could not allocate memory for fifo structure"; - return FAIL; - } - - //create threads - for ( int i = 0; i < numThreads; ++i ) { - - try { - Listener* l = new Listener(i, myDetectorType, fifo[i], &status, - &udpPortNum[i], eth, &numberOfFrames, &dynamicRange, - &udpSocketBufferSize, &actualUDPSocketBufferSize, &framesPerFile, - &frameDiscardMode, &activated, &deactivatedPaddingEnable, &silentMode); - listener.push_back(l); - - DataProcessor* p = new DataProcessor(i, myDetectorType, fifo[i], &fileFormatType, - fileWriteEnable, &dataStreamEnable, &gapPixelsEnable, - &dynamicRange, &frameToGuiFrequency, &frameToGuiTimerinMS, - &framePadding, &activated, &deactivatedPaddingEnable, &silentMode, - rawDataReadyCallBack, rawDataModifyReadyCallBack, pRawDataReady); - dataProcessor.push_back(p); - } - catch (...) { - FILE_LOG(logERROR) << "Could not create listener/dataprocessor threads (index:" << i << ")"; - for (std::vector::const_iterator it = listener.begin(); it != listener.end(); ++it) - delete(*it); - listener.clear(); - for (std::vector::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it) - delete(*it); - dataProcessor.clear(); - return FAIL; - } - } - - //set up writer and callbacks - for (std::vector::const_iterator it = listener.begin(); it != listener.end(); ++it) - (*it)->SetGeneralData(generalData); - for (std::vector::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it) - (*it)->SetGeneralData(generalData); - - SetThreadPriorities(); - - // check udp socket buffer size - setUDPSocketBufferSize(udpSocketBufferSize); - - FILE_LOG(logDEBUG) << " Detector type set to " << getDetectorType(d); - return OK; -} - - - - -void UDPStandardImplementation::setDetectorPositionId(const int i){ - detID = i; - FILE_LOG(logINFO) << "Detector Position Id:" << detID; - for (unsigned int i = 0; i < dataProcessor.size(); ++i) { - dataProcessor[i]->SetupFileWriter(fileWriteEnable, (int*)numDet, - &framesPerFile, fileName, filePath, &fileIndex, &overwriteEnable, - &detID, &numThreads, &numberOfFrames, &dynamicRange, &udpPortNum[i], - generalData); - } - - for (unsigned int i = 0; i < listener.size(); ++i) { - uint16_t row = 0, col = 0; - row = detID % numDet[1]; // row - col = (detID / numDet[1]) * ((myDetectorType == EIGER) ? 2 : 1) + i; // col for horiz. udp ports - listener[i]->SetHardCodedPosition(row, col); - } -} - - -void UDPStandardImplementation::resetAcquisitionCount() { - for (std::vector::const_iterator it = listener.begin(); it != listener.end(); ++it) - (*it)->ResetParametersforNewAcquisition(); - - for (std::vector::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it) - (*it)->ResetParametersforNewAcquisition(); - - for (std::vector::const_iterator it = dataStreamer.begin(); it != dataStreamer.end(); ++it) - (*it)->ResetParametersforNewAcquisition(); - - FILE_LOG(logINFO) << "Acquisition Count has been reset"; -} - - - -int UDPStandardImplementation::startReceiver(char *c) { - cprintf(RESET,"\n"); - FILE_LOG(logINFO) << "Starting Receiver"; - ResetParametersforNewMeasurement(); - - //listener - if (CreateUDPSockets() == FAIL) { - strcpy(c,"Could not create UDP Socket(s)."); - FILE_LOG(logERROR) << c; - return FAIL; - } - - //callbacks - if (startAcquisitionCallBack) { - startAcquisitionCallBack(filePath, fileName, fileIndex, - (generalData->imageSize) * numberofJobs + (generalData->fifoBufferHeaderSize), pStartAcquisition); - if (rawDataReadyCallBack != NULL) { - FILE_LOG(logINFO) << "Data Write has been defined externally"; - } - } - - //processor->writer - if (fileWriteEnable) { - if (SetupWriter() == FAIL) { - strcpy(c,"Could not create file."); - FILE_LOG(logERROR) << c; - return FAIL; - } - } else - FILE_LOG(logINFO) << "File Write Disabled"; - - FILE_LOG(logINFO) << "Ready ..."; - - //status - status = RUNNING; - - //Let Threads continue to be ready for acquisition - StartRunning(); - - FILE_LOG(logINFO) << "Receiver Started"; - FILE_LOG(logINFO) << "Status: " << runStatusType(status); - return OK; -} - - - -void UDPStandardImplementation::stopReceiver(){ - FILE_LOG(logINFO) << "Stopping Receiver"; - - //set status to transmitting - startReadout(); - - //wait for the processes (Listener and DataProcessor) to be done - bool running = true; - while(running) { - running = false; - for (std::vector::const_iterator it = listener.begin(); it != listener.end(); ++it) - if ((*it)->IsRunning()) - running = true; - for (std::vector::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it) - if ((*it)->IsRunning()) - running = true; - usleep(5000); - } - - - //create virtual file - if (fileWriteEnable && fileFormatType == HDF5) { - uint64_t maxIndexCaught = 0; - bool anycaught = false; - for (std::vector::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it) { - maxIndexCaught = std::max(maxIndexCaught, (*it)->GetProcessedMeasurementIndex()); - if((*it)->GetMeasurementStartedFlag()) - anycaught = true; - } - //to create virtual file & set files/acquisition to 0 (only hdf5 at the moment) - dataProcessor[0]->EndofAcquisition(anycaught, maxIndexCaught); - } - - //wait for the processes (DataStreamer) to be done - running = true; - while(running) { - running = false; - for (std::vector::const_iterator it = dataStreamer.begin(); it != dataStreamer.end(); ++it) - if ((*it)->IsRunning()) - running = true; - usleep(5000); - } - - status = RUN_FINISHED; - FILE_LOG(logINFO) << "Status: " << runStatusType(status); - - - { //statistics - uint64_t tot = 0; - for (int i = 0; i < numThreads; i++) { - tot += dataProcessor[i]->GetNumFramesCaught(); - - uint64_t missingpackets = numberOfFrames*generalData->packetsPerFrame-listener[i]->GetPacketsCaught(); - if ((int)missingpackets > 0) { - cprintf(RED, "\n[Port %d]\n",udpPortNum[i]); - cprintf(RED, "Missing Packets\t\t: %lld\n",(long long int)missingpackets); - cprintf(RED, "Complete Frames\t\t: %lld\n",(long long int)dataProcessor[i]->GetNumFramesCaught()); - cprintf(RED, "Last Frame Caught\t: %lld\n",(long long int)listener[i]->GetLastFrameIndexCaught()); - }else{ - cprintf(GREEN, "\n[Port %d]\n",udpPortNum[i]); - cprintf(GREEN, "Missing Packets\t\t: %lld\n",(long long int)missingpackets); - cprintf(GREEN, "Complete Frames\t\t: %lld\n",(long long int)dataProcessor[i]->GetNumFramesCaught()); - cprintf(GREEN, "Last Frame Caught\t: %lld\n",(long long int)listener[i]->GetLastFrameIndexCaught()); - } - } - if(!activated) - cprintf(RED,"Note: Deactivated Receiver\n"); - //callback - if (acquisitionFinishedCallBack) - acquisitionFinishedCallBack((tot/numThreads), pAcquisitionFinished); - } - - //change status - status = IDLE; - - FILE_LOG(logINFO) << "Receiver Stopped"; - FILE_LOG(logINFO) << "Status: " << runStatusType(status); -} - - - -void UDPStandardImplementation::startReadout(){ - if(status == RUNNING){ - - // wait for incoming delayed packets - //current packets caught - volatile int totalP = 0,prev=-1; - for (std::vector::const_iterator it = listener.begin(); it != listener.end(); ++it) - totalP += (*it)->GetPacketsCaught(); - - //wait for all packets - if((unsigned long long int)totalP!=numberOfFrames*generalData->packetsPerFrame*listener.size()){ - - //wait as long as there is change from prev totalP, - while(prev != totalP){ -#ifdef VERY_VERBOSE - cprintf(MAGENTA,"waiting for all packets prevP:%d totalP:%d\n", - prev,totalP); - -#endif - //usleep(1*1000*1000);usleep(1*1000*1000);usleep(1*1000*1000);usleep(1*1000*1000); - usleep(5*1000);/* Need to find optimal time **/ - - prev = totalP; - totalP = 0; - - for (std::vector::const_iterator it = listener.begin(); it != listener.end(); ++it) - totalP += (*it)->GetPacketsCaught(); -#ifdef VERY_VERBOSE - cprintf(MAGENTA,"\tupdated: totalP:%d\n",totalP); -#endif - } - } - - - //set status - status = TRANSMITTING; - FILE_LOG(logINFO) << "Status: Transmitting"; - } - //shut down udp sockets so as to make listeners push dummy (end) packets for processors - shutDownUDPSockets(); -} - - -void UDPStandardImplementation::shutDownUDPSockets() { - for (std::vector::const_iterator it = listener.begin(); it != listener.end(); ++it) - (*it)->ShutDownUDPSocket(); -} - - - -void UDPStandardImplementation::closeFiles() { - uint64_t maxIndexCaught = 0; - bool anycaught = false; - for (std::vector::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it) { - (*it)->CloseFiles(); - maxIndexCaught = std::max(maxIndexCaught, (*it)->GetProcessedMeasurementIndex()); - if((*it)->GetMeasurementStartedFlag()) - anycaught = true; - } - //to create virtual file & set files/acquisition to 0 (only hdf5 at the moment) - dataProcessor[0]->EndofAcquisition(anycaught, maxIndexCaught); -} - -int UDPStandardImplementation::setUDPSocketBufferSize(const uint32_t s) { - if (listener.size()) - return listener[0]->CreateDummySocketForUDPSocketBufferSize(s); - return FAIL; -} - -int UDPStandardImplementation::restreamStop() { - bool ret = OK; - for (std::vector::const_iterator it = dataStreamer.begin(); it != dataStreamer.end(); ++it) { - if ((*it)->RestreamStop() == FAIL) - ret = FAIL; - } - - // if fail, prints in datastreamer - if (ret == OK) { - FILE_LOG(logINFO) << "Restreaming Dummy Header via ZMQ successful"; - } - - return ret; -} - - -void UDPStandardImplementation::SetLocalNetworkParameters() { - - // to increase Max length of input packet queue - int max_back_log; - const char *proc_file_name = "/proc/sys/net/core/netdev_max_backlog"; - { - std::ifstream proc_file(proc_file_name); - proc_file >> max_back_log; - } - - if (max_back_log < MAX_SOCKET_INPUT_PACKET_QUEUE) { - std::ofstream proc_file(proc_file_name); - if (proc_file.good()) { - proc_file << MAX_SOCKET_INPUT_PACKET_QUEUE << std::endl; - cprintf(GREEN, "Max length of input packet queue " - "[/proc/sys/net/core/netdev_max_backlog] modified to %d\n", - MAX_SOCKET_INPUT_PACKET_QUEUE); - } else { - const char *msg = "Could not change max length of " - "input packet queue [net.core.netdev_max_backlog]. (No Root Privileges?)"; - FILE_LOG(logWARNING) << msg; - } - } -} - - - -void UDPStandardImplementation::SetThreadPriorities() { - - for (std::vector::const_iterator it = listener.begin(); it != listener.end(); ++it){ - if ((*it)->SetThreadPriority(LISTENER_PRIORITY) == FAIL) { - FILE_LOG(logWARNING) << "Could not prioritize listener threads. (No Root Privileges?)"; - return; - } - } - std::ostringstream osfn; - osfn << "Priorities set - " - "Listener:" << LISTENER_PRIORITY; - - FILE_LOG(logINFO) << osfn.str(); -} - - -int UDPStandardImplementation::SetupFifoStructure() { - numberofJobs = 1; - - - for (std::vector::const_iterator it = fifo.begin(); it != fifo.end(); ++it) - delete(*it); - fifo.clear(); - for ( int i = 0; i < numThreads; ++i ) { - - //create fifo structure - try { - Fifo* f = new Fifo (i, - (generalData->imageSize) * numberofJobs + (generalData->fifoBufferHeaderSize), - fifoDepth); - fifo.push_back(f); - } catch (...) { - cprintf(RED,"Error: Could not allocate memory for fifo structure of index %d\n", i); - for (std::vector::const_iterator it = fifo.begin(); it != fifo.end(); ++it) - delete(*it); - fifo.clear(); - return FAIL; - } - //set the listener & dataprocessor threads to point to the right fifo - if(listener.size())listener[i]->SetFifo(fifo[i]); - if(dataProcessor.size())dataProcessor[i]->SetFifo(fifo[i]); - if(dataStreamer.size())dataStreamer[i]->SetFifo(fifo[i]); - } - - FILE_LOG(logINFO) << "Memory Allocated Per Fifo: " << ( ((generalData->imageSize) * numberofJobs + (generalData->fifoBufferHeaderSize)) * fifoDepth) << " bytes" ; - FILE_LOG(logINFO) << numThreads << " Fifo structure(s) reconstructed"; - return OK; -} - - - -void UDPStandardImplementation::ResetParametersforNewMeasurement() { - for (std::vector::const_iterator it = listener.begin(); it != listener.end(); ++it) - (*it)->ResetParametersforNewMeasurement(); - for (std::vector::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it) - (*it)->ResetParametersforNewMeasurement(); - - if (dataStreamEnable) { - char fnametostream[MAX_STR_LENGTH]; - snprintf(fnametostream, MAX_STR_LENGTH, "%s/%s", filePath, fileName); - for (std::vector::const_iterator it = dataStreamer.begin(); it != dataStreamer.end(); ++it) - (*it)->ResetParametersforNewMeasurement(fnametostream); - } -} - - - -int UDPStandardImplementation::CreateUDPSockets() { - bool error = false; - for (unsigned int i = 0; i < listener.size(); ++i) - if (listener[i]->CreateUDPSockets() == FAIL) { - error = true; - break; - } - if (error) { - shutDownUDPSockets(); - return FAIL; - } - - FILE_LOG(logDEBUG) << "UDP socket(s) created successfully."; - return OK; -} - - -int UDPStandardImplementation::SetupWriter() { - bool error = false; - for (unsigned int i = 0; i < dataProcessor.size(); ++i) - if (dataProcessor[i]->CreateNewFile(tengigaEnable, - numberOfFrames, acquisitionTime, subExpTime, subPeriod, acquisitionPeriod) == FAIL) { - error = true; - break; - } - if (error) { - shutDownUDPSockets(); - closeFiles(); - return FAIL; - } - - return OK; -} - - -void UDPStandardImplementation::StartRunning() { - //set running mask and post semaphore to start the inner loop in execution thread - for (std::vector::const_iterator it = listener.begin(); it != listener.end(); ++it) { - (*it)->StartRunning(); - (*it)->Continue(); - } - for (std::vector::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it){ - (*it)->StartRunning(); - (*it)->Continue(); - } - for (std::vector::const_iterator it = dataStreamer.begin(); it != dataStreamer.end(); ++it){ - (*it)->StartRunning(); - (*it)->Continue(); - } -} diff --git a/slsReceiverSoftware/src/main.cpp b/slsReceiverSoftware/src/main.cpp deleted file mode 100644 index 2b2166d83..000000000 --- a/slsReceiverSoftware/src/main.cpp +++ /dev/null @@ -1,159 +0,0 @@ -/* A simple server in the internet domain using TCP - The port number is passed as an argument */ - -#include "sls_receiver_defs.h" -#include "slsReceiverUsers.h" - -#include -#include -#include //SIGINT -#include //system - -#include "utilities.h" -#include "logger.h" - -#include //wait -#include //wait -#include //usleep -#include - - -bool keeprunning; - -void sigInterruptHandler(int p){ - keeprunning = false; -} - -/* -int StartAcq(char* filepath, char* filename, uint64_t fileindex, uint32_t datasize, void*p){ - printf("#### StartAcq: filepath:%s filename:%s fileindex:%llu datasize:%u ####\n", - filepath, filename, fileindex, datasize); - - cprintf(BLUE, "--StartAcq: returning 0\n"); - return 0; -} - - -void AcquisitionFinished(uint64_t frames, void*p){ - cprintf(BLUE, "#### AcquisitionFinished: frames:%llu ####\n",frames); -} - - -void GetData(char* metadata, char* datapointer, uint32_t datasize, void* p){ - slsReceiverDefs::sls_receiver_header* header = (slsReceiverDefs::sls_receiver_header*)metadata; - slsReceiverDefs::sls_detector_header detectorHeader = header->detHeader; - - PRINT_IN_COLOR (detectorHeader.modId?detectorHeader.modId:detectorHeader.row, - "#### %d GetData: ####\n" - "frameNumber: %llu\t\texpLength: %u\t\tpacketNumber: %u\t\tbunchId: %llu" - "\t\ttimestamp: %llu\t\tmodId: %u\t\t" - "xCrow%u\t\tcolumn: %u\t\tcolumn: %u\t\tdebug: %u" - "\t\troundRNumber: %u\t\tdetType: %u\t\tversion: %u" - //"\t\tpacketsMask:%s" - "\t\tfirstbytedata: 0x%x\t\tdatsize: %u\n\n", - detectorHeader.row, detectorHeader.frameNumber, - detectorHeader.expLength, detectorHeader.packetNumber, detectorHeader.bunchId, - detectorHeader.timestamp, detectorHeader.modId, - detectorHeader.row, detectorHeader.column, detectorHeader.column, - detectorHeader.debug, detectorHeader.roundRNumber, - detectorHeader.detType, detectorHeader.version, - //header->packetsMask.to_string().c_str(), - ((uint8_t)(*((uint8_t*)(datapointer)))), datasize); -} -*/ - - -int main(int argc, char *argv[]) { - - keeprunning = true; - cprintf(BLUE,"Created [ Tid: %ld ]\n", (long)syscall(SYS_gettid)); - - // Catch signal SIGINT to close files and call destructors properly - struct sigaction sa; - sa.sa_flags=0; // no flags - sa.sa_handler=sigInterruptHandler; // handler function - sigemptyset(&sa.sa_mask); // dont block additional signals during invocation of handler - if (sigaction(SIGINT, &sa, NULL) == -1) { - cprintf(RED, "Could not set handler function for SIGINT\n"); - } - - - // if socket crash, ignores SISPIPE, prevents global signal handler - // subsequent read/write to socket gives error - must handle locally - struct sigaction asa; - asa.sa_flags=0; // no flags - asa.sa_handler=SIG_IGN; // handler function - sigemptyset(&asa.sa_mask); // dont block additional signals during invocation of handler - if (sigaction(SIGPIPE, &asa, NULL) == -1) { - cprintf(RED, "Could not set handler function for SIGPIPE\n"); - } - - - int ret = slsReceiverDefs::OK; - slsReceiverUsers *receiver = new slsReceiverUsers(argc, argv, ret); - if(ret==slsReceiverDefs::FAIL){ - delete receiver; - cprintf(BLUE,"Exiting [ Tid: %ld ]\n", (long)syscall(SYS_gettid)); - exit(EXIT_FAILURE); - } - - - //register callbacks - - /** - callback arguments are - filepath - filename - fileindex - datasize - - return value is - 0 raw data ready callback takes care of open,close,write file - 1 callback writes file, we have to open, close it - 2 we open, close, write file, callback does not do anything - - registerCallBackStartAcquisition(int (*func)(char*, char*,int, int, void*),void *arg); - */ - //receiver->registerCallBackStartAcquisition(startAcquisitionCallBack,NULL); - - - /** - callback argument is - total farmes caught - registerCallBackAcquisitionFinished(void (*func)(int, void*),void *arg); - */ - //receiver->registerCallBackAcquisitionFinished(acquisitionFinishedCallBack,NULL); - - - /** - args to raw data ready callback are - sls_receiver_header frame metadata - datapointer - file descriptor - guidatapointer (NULL, no data required) - NEVER DELETE THE DATA POINTER - REMEMBER THAT THE CALLBACK IS BLOCKING - registerCallBackRawDataReady(void (*func)(char*, char*, uint32_t, void*),void *arg); - */ - //receiver->registerCallBackRawDataReady(rawDataReadyCallBack,NULL); - - - - //start tcp server thread - if (receiver->start() == slsReceiverDefs::FAIL){ - delete receiver; - cprintf(BLUE,"Exiting [ Tid: %ld ]\n", (long)syscall(SYS_gettid)); - exit(EXIT_FAILURE); - } - - FILE_LOG(logINFO) << "Ready ... "; - cprintf(RESET, "\n[ Press \'Ctrl+c\' to exit ]\n"); - while(keeprunning) - pause(); - - delete receiver; - cprintf(BLUE,"Exiting [ Tid: %ld ]\n", (long)syscall(SYS_gettid)); - FILE_LOG(logINFO) << "Goodbye!"; - return 0; -} - diff --git a/slsReceiverSoftware/src/slsReceiver.cpp b/slsReceiverSoftware/src/slsReceiver.cpp deleted file mode 100644 index 06c81d01f..000000000 --- a/slsReceiverSoftware/src/slsReceiver.cpp +++ /dev/null @@ -1,143 +0,0 @@ -/********************************************//** - * @file slsReceiver.cpp - * @short creates the UDP and TCP class objects - ***********************************************/ - -#include -#include -#include -#include -#include -#include -#include - -#include "slsReceiver.h" -#include "gitInfoReceiver.h" - - - - -slsReceiver::slsReceiver(int argc, char *argv[]): - tcpipInterface (0) { - - // options - std::map configuration_map; - int tcpip_port_no = 1954; - std::string fname = ""; - int64_t tempval = 0; - - //parse command line for config - static struct option long_options[] = { - // These options set a flag. - //{"verbose", no_argument, &verbose_flag, 1}, - // These options don’t set a flag. We distinguish them by their indices. - {"config", required_argument, 0, 'f'}, - {"rx_tcpport", required_argument, 0, 't'}, - {"version", no_argument, 0, 'v'}, - {"help", no_argument, 0, 'h'}, - {0, 0, 0, 0} - }; - - //initialize global optind variable (required when instantiating multiple receivers in the same process) - optind = 1; - // getopt_long stores the option index here. - int option_index = 0; - int c = 0; - - while ( c != -1 ){ - c = getopt_long (argc, argv, "hvf:t:", long_options, &option_index); - - // Detect the end of the options. - if (c == -1) - break; - - switch(c){ - - case 'f': - fname = optarg; -#ifdef VERYVERBOSE - FILE_LOG(logDEBUG) << long_options[option_index].name << " " << optarg << endl; -#endif - break; - - case 't': - sscanf(optarg, "%d", &tcpip_port_no); - break; - - case 'v': - tempval = GITREV; - tempval = (tempval <<32) | GITDATE; - std::cout << "SLS Receiver " << GITBRANCH << " (0x" << std::hex << tempval << ")" << std::endl; - throw std::exception(); - - case 'h': - default: - std::string help_message = "\n" - + std::string(argv[0]) + "\n" - + "Usage: " + std::string(argv[0]) + " [arguments]\n" - + "Possible arguments are:\n" - + "\t-f, --config : Loads config from file\n" - + "\t-t, --rx_tcpport : TCP Communication Port with client. \n" - + "\t Default: 1954. Required for multiple \n" - + "\t receivers\n\n"; - - FILE_LOG(logINFO) << help_message << std::endl; - throw std::exception(); - - } - } - - if( !fname.empty() && read_config_file(fname, &tcpip_port_no, &configuration_map) == FAIL) { - throw std::exception(); - } - - // might throw an exception - tcpipInterface = new slsReceiverTCPIPInterface(tcpip_port_no); - -} - - -slsReceiver::~slsReceiver() { - if(tcpipInterface) - delete tcpipInterface; -} - - -int slsReceiver::start() { - return tcpipInterface->start(); -} - - -void slsReceiver::stop() { - tcpipInterface->stop(); -} - - -int64_t slsReceiver::getReceiverVersion(){ - return tcpipInterface->getReceiverVersion(); -} - - -void slsReceiver::registerCallBackStartAcquisition(int (*func)( - char*, char*, uint64_t, uint32_t, void*),void *arg){ - tcpipInterface->registerCallBackStartAcquisition(func,arg); -} - - - -void slsReceiver::registerCallBackAcquisitionFinished( - void (*func)(uint64_t, void*),void *arg){ - tcpipInterface->registerCallBackAcquisitionFinished(func,arg); -} - - -void slsReceiver::registerCallBackRawDataReady(void (*func)(char*, - char*, uint32_t, void*),void *arg){ - tcpipInterface->registerCallBackRawDataReady(func,arg); -} - - -void slsReceiver::registerCallBackRawDataModifyReady(void (*func)(char*, - char*, uint32_t &, void*),void *arg){ - tcpipInterface->registerCallBackRawDataModifyReady(func,arg); -} diff --git a/slsReceiverSoftware/src/slsReceiverTCPIPInterface.cpp b/slsReceiverSoftware/src/slsReceiverTCPIPInterface.cpp deleted file mode 100644 index ffa489851..000000000 --- a/slsReceiverSoftware/src/slsReceiverTCPIPInterface.cpp +++ /dev/null @@ -1,2983 +0,0 @@ -/********************************************//** - * @file slsReceiverTCPIPInterface.cpp - * @short interface between receiver and client - ***********************************************/ - -#include "slsReceiverTCPIPInterface.h" -#include "UDPInterface.h" -#include "gitInfoReceiver.h" -#include "slsReceiverUsers.h" -#include "slsReceiver.h" -#include "versionAPI.h" - -#include //EXIT -#include -#include -#include -#include -#include -#include -#include - - - -slsReceiverTCPIPInterface::~slsReceiverTCPIPInterface() { - stop(); - if(mySock) { - delete mySock; - mySock=NULL; - } - if(receiverBase) - delete receiverBase; -} - -slsReceiverTCPIPInterface::slsReceiverTCPIPInterface(int pn): - myDetectorType(GOTTHARD), - receiverBase(0), - ret(OK), - fnum(-1), - lockStatus(0), - killTCPServerThread(0), - tcpThreadCreated(false), - portNumber(DEFAULT_PORTNO+2), - mySock(0) -{ - //***callback parameters*** - startAcquisitionCallBack = NULL; - pStartAcquisition = NULL; - acquisitionFinishedCallBack = NULL; - pAcquisitionFinished = NULL; - rawDataReadyCallBack = NULL; - rawDataModifyReadyCallBack = NULL; - pRawDataReady = NULL; - - // create socket - portNumber = (pn > 0 ? pn : DEFAULT_PORTNO + 2); - MySocketTCP* m = new MySocketTCP(portNumber); - mySock = m; - - //initialize variables - strcpy(mySock->lastClientIP,"none"); - strcpy(mySock->thisClientIP,"none1"); - memset(mess,0,sizeof(mess)); - strcpy(mess,"dummy message"); - - function_table(); -#ifdef VERYVERBOSE - FILE_LOG(logINFO) << "Function table assigned."; -#endif - -} - - -int slsReceiverTCPIPInterface::start(){ - FILE_LOG(logDEBUG) << "Creating TCP Server Thread"; - killTCPServerThread = 0; - if(pthread_create(&TCPServer_thread, NULL,startTCPServerThread, (void*) this)){ - FILE_LOG(logERROR) << "Could not create TCP Server thread"; - return FAIL; - } - tcpThreadCreated = true; - //#ifdef VERYVERBOSE - FILE_LOG(logDEBUG) << "TCP Server thread created successfully."; - //#endif - return OK; -} - - -void slsReceiverTCPIPInterface::stop(){ - if (tcpThreadCreated) { - FILE_LOG(logINFO) << "Shutting down TCP Socket on port " << portNumber; - killTCPServerThread = 1; - if(mySock) mySock->ShutDownSocket(); - FILE_LOG(logDEBUG) << "TCP Socket closed on port " << portNumber; - pthread_join(TCPServer_thread, NULL); - tcpThreadCreated = false; - killTCPServerThread = 0; - FILE_LOG(logDEBUG) << "Exiting TCP Server Thread on port " << portNumber; - } -} - - - -int64_t slsReceiverTCPIPInterface::getReceiverVersion(){ - int64_t retval = GITDATE & 0xFFFFFF; - return retval; -} - - - -/***callback functions***/ -void slsReceiverTCPIPInterface::registerCallBackStartAcquisition(int (*func)(char*, char*, uint64_t, uint32_t, void*),void *arg){ - startAcquisitionCallBack=func; - pStartAcquisition=arg; -} - -void slsReceiverTCPIPInterface::registerCallBackAcquisitionFinished(void (*func)(uint64_t, void*),void *arg){ - acquisitionFinishedCallBack=func; - pAcquisitionFinished=arg; -} - -void slsReceiverTCPIPInterface::registerCallBackRawDataReady(void (*func)(char* , - char*, uint32_t, void*),void *arg){ - rawDataReadyCallBack=func; - pRawDataReady=arg; -} - -void slsReceiverTCPIPInterface::registerCallBackRawDataModifyReady(void (*func)(char* , - char*, uint32_t &,void*),void *arg){ - rawDataModifyReadyCallBack=func; - pRawDataReady=arg; -} - - - -void* slsReceiverTCPIPInterface::startTCPServerThread(void *this_pointer){ - ((slsReceiverTCPIPInterface*)this_pointer)->startTCPServer(); - return this_pointer; -} - - -void slsReceiverTCPIPInterface::startTCPServer(){ - cprintf(BLUE,"Created [ TCP server Tid: %ld ]\n", (long)syscall(SYS_gettid)); - FILE_LOG(logINFO) << "SLS Receiver starting TCP Server on port " << portNumber << std::endl; - -#ifdef VERYVERBOSE - FILE_LOG(logDEBUG5) << "Starting Receiver TCP Server"; -#endif - int v=OK; - - while(1) { -#ifdef VERYVERBOSE - FILE_LOG(logDEBUG5); -#endif -#ifdef VERY_VERBOSE - FILE_LOG(logDEBUG5) << "Waiting for client call"; -#endif - if(mySock->Connect() >= 0){ -#ifdef VERY_VERBOSE - FILE_LOG(logDEBUG5) << "Conenction accepted"; -#endif - v = decode_function(); -#ifdef VERY_VERBOSE - FILE_LOG(logDEBUG5) << "function executed"; -#endif - mySock->Disconnect(); -#ifdef VERY_VERBOSE - FILE_LOG(logDEBUG5) << "connection closed"; -#endif - } - - //if tcp command was to exit server - if(v==GOODBYE){ - FILE_LOG(logINFO) << "Shutting down UDP Socket"; - if(receiverBase){ - receiverBase->shutDownUDPSockets(); - } - - mySock->exitServer(); - cprintf(BLUE,"Exiting [ TCP server Tid: %ld ]\n", (long)syscall(SYS_gettid)); - pthread_exit(NULL); - } - - //if user entered exit - if(killTCPServerThread) { - if (v != GOODBYE) { - if(receiverBase){ - receiverBase->shutDownUDPSockets(); - } - } - cprintf(BLUE,"Exiting [ TCP server Tid: %ld ]\n", (long)syscall(SYS_gettid)); - pthread_exit(NULL); - } - - } -} - - -const char* slsReceiverTCPIPInterface::getFunctionName(enum recFuncs func) { - switch (func) { - case F_EXEC_RECEIVER_COMMAND: return "F_EXEC_RECEIVER_COMMAND"; - case F_EXIT_RECEIVER: return "F_EXIT_RECEIVER"; - case F_LOCK_RECEIVER: return "F_LOCK_RECEIVER"; - case F_GET_LAST_RECEIVER_CLIENT_IP: return "F_GET_LAST_RECEIVER_CLIENT_IP"; - case F_SET_RECEIVER_PORT: return "F_SET_RECEIVER_PORT"; - case F_UPDATE_RECEIVER_CLIENT: return "F_UPDATE_RECEIVER_CLIENT"; - case F_GET_RECEIVER_ID: return "F_GET_RECEIVER_ID"; - case F_GET_RECEIVER_TYPE: return "F_GET_RECEIVER_TYPE"; - case F_SEND_RECEIVER_DETHOSTNAME: return "F_SEND_RECEIVER_DETHOSTNAME"; - case F_RECEIVER_SET_ROI: return "F_RECEIVER_SET_ROI"; - case F_SETUP_RECEIVER_UDP: return "F_SETUP_RECEIVER_UDP"; - case F_SET_RECEIVER_TIMER: return "F_SET_RECEIVER_TIMER"; - case F_SET_RECEIVER_DYNAMIC_RANGE: return "F_SET_RECEIVER_DYNAMIC_RANGE"; - case F_READ_RECEIVER_FREQUENCY: return "F_READ_RECEIVER_FREQUENCY"; - case F_GET_RECEIVER_STATUS: return "F_GET_RECEIVER_STATUS"; - case F_START_RECEIVER: return "F_START_RECEIVER"; - case F_STOP_RECEIVER: return "F_STOP_RECEIVER"; - case F_START_RECEIVER_READOUT: return "F_START_RECEIVER_READOUT"; - case F_SET_RECEIVER_FILE_PATH: return "F_SET_RECEIVER_FILE_PATH"; - case F_SET_RECEIVER_FILE_NAME: return "F_SET_RECEIVER_FILE_NAME"; - case F_SET_RECEIVER_FILE_INDEX: return "F_SET_RECEIVER_FILE_INDEX"; - case F_GET_RECEIVER_FRAME_INDEX: return "F_GET_RECEIVER_FRAME_INDEX"; - case F_GET_RECEIVER_FRAMES_CAUGHT: return "F_GET_RECEIVER_FRAMES_CAUGHT"; - case F_RESET_RECEIVER_FRAMES_CAUGHT:return "F_RESET_RECEIVER_FRAMES_CAUGHT"; - case F_ENABLE_RECEIVER_FILE_WRITE: return "F_ENABLE_RECEIVER_FILE_WRITE"; - case F_ENABLE_RECEIVER_COMPRESSION: return "F_ENABLE_RECEIVER_COMPRESSION"; - case F_ENABLE_RECEIVER_OVERWRITE: return "F_ENABLE_RECEIVER_OVERWRITE"; - case F_ENABLE_RECEIVER_TEN_GIGA: return "F_ENABLE_RECEIVER_TEN_GIGA"; - case F_SET_RECEIVER_FIFO_DEPTH: return "F_SET_RECEIVER_FIFO_DEPTH"; - case F_RECEIVER_ACTIVATE: return "F_RECEIVER_ACTIVATE"; - case F_STREAM_DATA_FROM_RECEIVER: return "F_STREAM_DATA_FROM_RECEIVER"; - case F_READ_RECEIVER_TIMER: return "F_READ_RECEIVER_TIMER"; - case F_SET_FLIPPED_DATA_RECEIVER: return "F_SET_FLIPPED_DATA_RECEIVER"; - case F_SET_RECEIVER_FILE_FORMAT: return "F_SET_RECEIVER_FILE_FORMAT"; - case F_SEND_RECEIVER_DETPOSID: return "F_SEND_RECEIVER_DETPOSID"; - case F_SEND_RECEIVER_MULTIDETSIZE: return "F_SEND_RECEIVER_MULTIDETSIZE"; - case F_SET_RECEIVER_STREAMING_PORT: return "F_SET_RECEIVER_STREAMING_PORT"; - case F_SET_RECEIVER_SILENT_MODE: return "F_SET_RECEIVER_SILENT_MODE"; - case F_RECEIVER_STREAMING_SRC_IP: return "F_RECEIVER_STREAMING_SRC_IP"; - case F_ENABLE_GAPPIXELS_IN_RECEIVER:return "F_ENABLE_GAPPIXELS_IN_RECEIVER"; - case F_RESTREAM_STOP_FROM_RECEIVER: return "F_RESTREAM_STOP_FROM_RECEIVER"; - case F_ADDITIONAL_JSON_HEADER: return "F_ADDITIONAL_JSON_HEADER"; - case F_RECEIVER_UDP_SOCK_BUF_SIZE: return "F_RECEIVER_UDP_SOCK_BUF_SIZE"; - case F_RECEIVER_REAL_UDP_SOCK_BUF_SIZE: return "F_RECEIVER_REAL_UDP_SOCK_BUF_SIZE"; - case F_SET_RECEIVER_FRAMES_PER_FILE:return "F_SET_RECEIVER_FRAMES_PER_FILE"; - case F_RECEIVER_CHECK_VERSION: return "F_RECEIVER_CHECK_VERSION"; - case F_RECEIVER_DISCARD_POLICY: return "F_RECEIVER_DISCARD_POLICY"; - case F_RECEIVER_PADDING_ENABLE: return "F_RECEIVER_PADDING_ENABLE"; - case F_RECEIVER_DEACTIVATED_PADDING_ENABLE: return "F_RECEIVER_DEACTIVATED_PADDING_ENABLE"; - - default: return "Unknown Function"; - } -} - - - -int slsReceiverTCPIPInterface::function_table(){ - flist[F_EXEC_RECEIVER_COMMAND] = &slsReceiverTCPIPInterface::exec_command; - flist[F_EXIT_RECEIVER] = &slsReceiverTCPIPInterface::exit_server; - flist[F_LOCK_RECEIVER] = &slsReceiverTCPIPInterface::lock_receiver; - flist[F_GET_LAST_RECEIVER_CLIENT_IP] = &slsReceiverTCPIPInterface::get_last_client_ip; - flist[F_SET_RECEIVER_PORT] = &slsReceiverTCPIPInterface::set_port; - flist[F_UPDATE_RECEIVER_CLIENT] = &slsReceiverTCPIPInterface::update_client; - flist[F_GET_RECEIVER_ID] = &slsReceiverTCPIPInterface::get_id; - flist[F_GET_RECEIVER_TYPE] = &slsReceiverTCPIPInterface::set_detector_type; - flist[F_SEND_RECEIVER_DETHOSTNAME] = &slsReceiverTCPIPInterface::set_detector_hostname; - flist[F_RECEIVER_SET_ROI] = &slsReceiverTCPIPInterface::set_roi; - flist[F_SETUP_RECEIVER_UDP] = &slsReceiverTCPIPInterface::setup_udp; - flist[F_SET_RECEIVER_TIMER] = &slsReceiverTCPIPInterface::set_timer; - flist[F_SET_RECEIVER_DYNAMIC_RANGE] = &slsReceiverTCPIPInterface::set_dynamic_range; - flist[F_READ_RECEIVER_FREQUENCY] = &slsReceiverTCPIPInterface::set_read_frequency; - flist[F_GET_RECEIVER_STATUS] = &slsReceiverTCPIPInterface::get_status; - flist[F_START_RECEIVER] = &slsReceiverTCPIPInterface::start_receiver; - flist[F_STOP_RECEIVER] = &slsReceiverTCPIPInterface::stop_receiver; - flist[F_START_RECEIVER_READOUT] = &slsReceiverTCPIPInterface::start_readout; - flist[F_SET_RECEIVER_FILE_PATH] = &slsReceiverTCPIPInterface::set_file_dir; - flist[F_SET_RECEIVER_FILE_NAME] = &slsReceiverTCPIPInterface::set_file_name; - flist[F_SET_RECEIVER_FILE_INDEX] = &slsReceiverTCPIPInterface::set_file_index; - flist[F_GET_RECEIVER_FRAME_INDEX] = &slsReceiverTCPIPInterface::get_frame_index; - flist[F_GET_RECEIVER_FRAMES_CAUGHT] = &slsReceiverTCPIPInterface::get_frames_caught; - flist[F_RESET_RECEIVER_FRAMES_CAUGHT] = &slsReceiverTCPIPInterface::reset_frames_caught; - flist[F_ENABLE_RECEIVER_FILE_WRITE] = &slsReceiverTCPIPInterface::enable_file_write; - flist[F_ENABLE_RECEIVER_COMPRESSION] = &slsReceiverTCPIPInterface::enable_compression; - flist[F_ENABLE_RECEIVER_OVERWRITE] = &slsReceiverTCPIPInterface::enable_overwrite; - flist[F_ENABLE_RECEIVER_TEN_GIGA] = &slsReceiverTCPIPInterface::enable_tengiga; - flist[F_SET_RECEIVER_FIFO_DEPTH] = &slsReceiverTCPIPInterface::set_fifo_depth; - flist[F_RECEIVER_ACTIVATE] = &slsReceiverTCPIPInterface::set_activate; - flist[F_STREAM_DATA_FROM_RECEIVER] = &slsReceiverTCPIPInterface::set_data_stream_enable; - flist[F_READ_RECEIVER_TIMER] = &slsReceiverTCPIPInterface::set_read_receiver_timer; - flist[F_SET_FLIPPED_DATA_RECEIVER] = &slsReceiverTCPIPInterface::set_flipped_data; - flist[F_SET_RECEIVER_FILE_FORMAT] = &slsReceiverTCPIPInterface::set_file_format; - flist[F_SEND_RECEIVER_DETPOSID] = &slsReceiverTCPIPInterface::set_detector_posid; - flist[F_SEND_RECEIVER_MULTIDETSIZE] = &slsReceiverTCPIPInterface::set_multi_detector_size; - flist[F_SET_RECEIVER_STREAMING_PORT] = &slsReceiverTCPIPInterface::set_streaming_port; - flist[F_SET_RECEIVER_SILENT_MODE] = &slsReceiverTCPIPInterface::set_silent_mode; - flist[F_RECEIVER_STREAMING_SRC_IP] = &slsReceiverTCPIPInterface::set_streaming_source_ip; - flist[F_ENABLE_GAPPIXELS_IN_RECEIVER] = &slsReceiverTCPIPInterface::enable_gap_pixels; - flist[F_RESTREAM_STOP_FROM_RECEIVER] = &slsReceiverTCPIPInterface::restream_stop; - flist[F_ADDITIONAL_JSON_HEADER] = &slsReceiverTCPIPInterface::set_additional_json_header; - flist[F_RECEIVER_UDP_SOCK_BUF_SIZE] = &slsReceiverTCPIPInterface::set_udp_socket_buffer_size; - flist[F_RECEIVER_REAL_UDP_SOCK_BUF_SIZE]= &slsReceiverTCPIPInterface::get_real_udp_socket_buffer_size; - flist[F_SET_RECEIVER_FRAMES_PER_FILE] = &slsReceiverTCPIPInterface::set_frames_per_file; - flist[F_RECEIVER_CHECK_VERSION] = &slsReceiverTCPIPInterface::check_version_compatibility; - flist[F_RECEIVER_DISCARD_POLICY] = &slsReceiverTCPIPInterface::set_discard_policy; - flist[F_RECEIVER_PADDING_ENABLE] = &slsReceiverTCPIPInterface::set_padding_enable; - flist[F_RECEIVER_DEACTIVATED_PADDING_ENABLE] = &slsReceiverTCPIPInterface::set_deactivated_receiver_padding_enable; - - -#ifdef VERYVERBOSE - for (int i = 0; i < NUM_REC_FUNCTIONS ; i++) { - FILE_LOG(logINFO) << "function fnum: " << i << " (" << getFunctionName((enum recFuncs)i) << ") located at " << (unsigned int)flist[i]; - } -#endif - return OK; - -} - - - - -int slsReceiverTCPIPInterface::decode_function(){ - ret = FAIL; -#ifdef VERYVERBOSE - cprintf(RESET,"\n"); -#endif - FILE_LOG(logDEBUG1) << "waiting to receive data"; - int n = mySock->ReceiveDataOnly(&fnum,sizeof(fnum)); - if (n <= 0) { - FILE_LOG(logDEBUG1) << "ERROR reading from socket. " - "Received " << n << " bytes," << - "fnum:" << fnum << " " - "(" << getFunctionName((enum recFuncs)fnum) << ")"; - return FAIL; - } - else - FILE_LOG(logDEBUG1) << "Received " << n << " bytes"; - - FILE_LOG(logDEBUG1) << "calling function fnum: "<< fnum << " " - "(" << getFunctionName((enum recFuncs)fnum) << ") " - "located at " << flist[fnum]; - - if (fnum < REC_FUNC_START_INDEX || fnum >= NUM_REC_FUNCTIONS) { - FILE_LOG(logERROR) << "Unknown function enum " << fnum; - ret=(this->M_nofunc)(); - } else{ - ret=(this->*flist[fnum])(); - } - if (ret == FAIL) { - FILE_LOG(logERROR) << "Failed to execute function = " << fnum << " (" << getFunctionName((enum recFuncs)fnum) << ")"; - } - return ret; -} - - - -int slsReceiverTCPIPInterface::printSocketReadError() { - FILE_LOG(logERROR) << "Reading from socket failed. Possible socket crash"; - return FAIL; -} - - -void slsReceiverTCPIPInterface::invalidReceiverObject() { - ret=FAIL; - strcpy(mess,"Receiver not set up. Please use rx_hostname first.\n"); - FILE_LOG(logERROR) << mess; -} - - -void slsReceiverTCPIPInterface::receiverlocked() { - ret = FAIL; - sprintf(mess,"Receiver locked by %s\n",mySock->lastClientIP); - FILE_LOG(logERROR) << mess; -} - - -void slsReceiverTCPIPInterface::receiverNotIdle() { - ret = FAIL; - sprintf(mess,"Can not execute %s when receiver is not idle\n", getFunctionName((enum recFuncs)fnum)); - FILE_LOG(logERROR) << mess; -} - -void slsReceiverTCPIPInterface::functionNotImplemented() { - ret = FAIL; - sprintf(mess, "Function (%s) is not implemented for this detector\n",getFunctionName((enum recFuncs)fnum)); - FILE_LOG(logERROR) << mess; -} - - -int slsReceiverTCPIPInterface::M_nofunc(){printf("111 \n"); - ret = FAIL; - memset(mess, 0, sizeof(mess)); - int n = 0; - - // to receive any arguments - while (n > 0) - n = mySock->ReceiveDataOnly(mess,MAX_STR_LENGTH); - - strcpy(mess,"Unrecognized Function. Please do not proceed.\n"); - FILE_LOG(logERROR) << mess; - - // send ok / fail - mySock->SendDataOnly(&ret,sizeof(ret)); - // send return argument - mySock->SendDataOnly(mess,sizeof(mess)); - // return ok / fail - return ret; -} - - - - -int slsReceiverTCPIPInterface::exec_command() { - ret = OK; - memset(mess, 0, sizeof(mess)); - char cmd[MAX_STR_LENGTH]; - memset(cmd,0,sizeof(cmd)); - int sysret = 0; - - // receive arguments - if (mySock->ReceiveDataOnly(cmd,MAX_STR_LENGTH) < 0) - return printSocketReadError(); - - // execute action -#ifdef VERYVERBOSE - FILE_LOG(logDEBUG5) << "executing command " << cmd; -#endif - if (mySock->differentClients && lockStatus) - receiverlocked(); - else { - sysret=system(cmd); - //should be replaced by popen - if (sysret == 0) { - sprintf(mess,"Succeeded\n"); - } else { - ret = FAIL; - sprintf(mess,"Executing Command failed\n"); - FILE_LOG(logERROR) << mess; - } - } - - // send answer - mySock->SendDataOnly(&ret,sizeof(ret)); - mySock->SendDataOnly(mess,MAX_STR_LENGTH); - - // return ok/fail - return ret; -} - - - -int slsReceiverTCPIPInterface::exit_server() { - ret = GOODBYE; - strcpy(mess,"closing server"); - mySock->SendDataOnly(&ret,sizeof(ret)); - mySock->SendDataOnly(mess,sizeof(mess)); - cprintf(RED,"%s\n",mess); - return ret; -} - - - -int slsReceiverTCPIPInterface::lock_receiver() { - ret = OK; - memset(mess, 0, sizeof(mess)); - int lock = 0; - - // receive arguments - if (mySock->ReceiveDataOnly(&lock,sizeof(lock)) < 0 ) - return printSocketReadError(); - - // execute action - if (lock >= 0) { - if (!lockStatus || (!strcmp(mySock->lastClientIP,mySock->thisClientIP)) || (!strcmp(mySock->lastClientIP,"none"))) { - lockStatus = lock; - strcpy(mySock->lastClientIP,mySock->thisClientIP); - } else - receiverlocked(); - } - - if (ret == OK && mySock->differentClients) - ret = FORCE_UPDATE; - - // send answer - mySock->SendDataOnly(&ret,sizeof(ret)); - if (ret == FAIL) - mySock->SendDataOnly(mess,sizeof(mess)); - else - mySock->SendDataOnly(&lockStatus,sizeof(lockStatus)); - - // return ok/fail - return ret; -} - - - -int slsReceiverTCPIPInterface::get_last_client_ip() { - ret = OK; - - if (mySock->differentClients) - ret = FORCE_UPDATE; - - // send answer - mySock->SendDataOnly(&ret,sizeof(ret)); - mySock->SendDataOnly(mySock->lastClientIP,sizeof(mySock->lastClientIP)); - - // return ok/fail - return ret; -} - - - -int slsReceiverTCPIPInterface::set_port() { - ret = OK; - memset(mess, 0, sizeof(mess)); - int p_type = 0; - int p_number = -1; - MySocketTCP* mySocket = 0; - char oldLastClientIP[INET_ADDRSTRLEN]; - memset(oldLastClientIP, 0, sizeof(oldLastClientIP)); - - // receive arguments - if (mySock->ReceiveDataOnly(&p_type,sizeof(p_type)) < 0 ) - return printSocketReadError(); - if (mySock->ReceiveDataOnly(&p_number,sizeof(p_number)) < 0 ) - return printSocketReadError(); - - // execute action - if (mySock->differentClients && lockStatus) { - ret=FAIL; - sprintf(mess,"Detector locked by %s\n",mySock->lastClientIP); - FILE_LOG(logERROR) << mess; - } - else { - if (p_number < 1024) { - ret = FAIL; - sprintf(mess,"Port Number (%d) too low\n", p_number); - FILE_LOG(logERROR) << mess; - } else { - FILE_LOG(logINFO) << "set port to " << p_number <lastClientIP); - - try { - mySocket = new MySocketTCP(p_number); - strcpy(mySock->lastClientIP,oldLastClientIP); - } catch(SamePortSocketException e) { - ret = FAIL; - sprintf(mess, "Could not bind port %d. It is already set\n", p_number); - FILE_LOG(logERROR) << mess; - } catch (...) { - ret = FAIL; - sprintf(mess, "Could not bind port %d.\n", p_number); - FILE_LOG(logERROR) << mess; - } - } - } - - if (ret == OK && mySock->differentClients) - ret = FORCE_UPDATE; - - // send answer - mySock->SendDataOnly(&ret,sizeof(ret)); - if (ret == FAIL) - mySock->SendDataOnly(mess,sizeof(mess)); - else { - mySock->SendDataOnly(&p_number,sizeof(p_number)); - if(ret != FAIL){ - mySock->Disconnect(); - delete mySock; - mySock = mySocket; - } - } - - // return ok/fail - return ret; -} - - - -int slsReceiverTCPIPInterface::update_client() { - ret = OK; - memset(mess, 0, sizeof(mess)); - if (receiverBase == NULL) - invalidReceiverObject(); - - // send answer - mySock->SendDataOnly(&ret,sizeof(ret)); - //fail and force_update - if (ret != OK){ - mySock->SendDataOnly(mess,sizeof(mess)); - // return ok/fail - return ret; - } - - // update - return send_update(); -} - - - -int slsReceiverTCPIPInterface::send_update() { - int ind = -1; - char defaultVal[MAX_STR_LENGTH]; - memset(defaultVal, 0, sizeof(defaultVal)); - char* path = NULL; - int n = 0; - - n += mySock->SendDataOnly(mySock->lastClientIP,sizeof(mySock->lastClientIP)); - - // filepath -#ifdef SLS_RECEIVER_UDP_FUNCTIONS - path = receiverBase->getFilePath(); -#endif - if (path == NULL) - n += mySock->SendDataOnly(defaultVal,MAX_STR_LENGTH); - else { - n += mySock->SendDataOnly(path,MAX_STR_LENGTH); - delete[] path; - } - - // filename -#ifdef SLS_RECEIVER_UDP_FUNCTIONS - path = receiverBase->getFileName(); -#endif - if(path == NULL) - n += mySock->SendDataOnly(defaultVal,MAX_STR_LENGTH); - else { - n += mySock->SendDataOnly(path,MAX_STR_LENGTH); - delete[] path; - } - - // index -#ifdef SLS_RECEIVER_UDP_FUNCTIONS - ind=receiverBase->getFileIndex(); -#endif - n += mySock->SendDataOnly(&ind,sizeof(ind)); - - //file format -#ifdef SLS_RECEIVER_UDP_FUNCTIONS - ind=(int)receiverBase->getFileFormat(); -#endif - n += mySock->SendDataOnly(&ind,sizeof(ind)); - - //frames per file -#ifdef SLS_RECEIVER_UDP_FUNCTIONS - ind=(int)receiverBase->getFramesPerFile(); -#endif - n += mySock->SendDataOnly(&ind,sizeof(ind)); - - //frame discard policy -#ifdef SLS_RECEIVER_UDP_FUNCTIONS - ind=(int)receiverBase->getFrameDiscardPolicy(); -#endif - n += mySock->SendDataOnly(&ind,sizeof(ind)); - - //frame padding -#ifdef SLS_RECEIVER_UDP_FUNCTIONS - ind=(int)receiverBase->getFramePaddingEnable(); -#endif - n += mySock->SendDataOnly(&ind,sizeof(ind)); - - // file write enable -#ifdef SLS_RECEIVER_UDP_FUNCTIONS - ind=(int)receiverBase->getFileWriteEnable(); -#endif - n += mySock->SendDataOnly(&ind,sizeof(ind)); - - // file overwrite enable -#ifdef SLS_RECEIVER_UDP_FUNCTIONS - ind=(int)receiverBase->getOverwriteEnable(); -#endif - n += mySock->SendDataOnly(&ind,sizeof(ind)); - - // gap pixels -#ifdef SLS_RECEIVER_UDP_FUNCTIONS - ind=(int)receiverBase->getGapPixelsEnable(); -#endif - n += mySock->SendDataOnly(&ind,sizeof(ind)); - - // receiver read frequency -#ifdef SLS_RECEIVER_UDP_FUNCTIONS - ind=(int)receiverBase->getFrameToGuiFrequency(); -#endif - n += mySock->SendDataOnly(&ind,sizeof(ind)); - - // streaming port -#ifdef SLS_RECEIVER_UDP_FUNCTIONS - ind=(int)receiverBase->getStreamingPort(); -#endif - n += mySock->SendDataOnly(&ind,sizeof(ind)); - - // streaming source ip -#ifdef SLS_RECEIVER_UDP_FUNCTIONS - path = receiverBase->getStreamingSourceIP(); -#endif - mySock->SendDataOnly(path,MAX_STR_LENGTH); - if (path != NULL) - delete[] path; - - // additional json header -#ifdef SLS_RECEIVER_UDP_FUNCTIONS - path = receiverBase->getAdditionalJsonHeader(); -#endif - mySock->SendDataOnly(path,MAX_STR_LENGTH); - if (path != NULL) - delete[] path; - - // data streaming enable -#ifdef SLS_RECEIVER_UDP_FUNCTIONS - ind=(int)receiverBase->getDataStreamEnable(); -#endif - n += mySock->SendDataOnly(&ind,sizeof(ind)); - - // activate -#ifdef SLS_RECEIVER_UDP_FUNCTIONS - ind=(int)receiverBase->getActivate(); -#endif - n += mySock->SendDataOnly(&ind,sizeof(ind)); - - // deactivated padding enable -#ifdef SLS_RECEIVER_UDP_FUNCTIONS - ind=(int)receiverBase->getDeactivatedPadding(); -#endif - n += mySock->SendDataOnly(&ind,sizeof(ind)); - - // silent mode -#ifdef SLS_RECEIVER_UDP_FUNCTIONS - ind=(int)receiverBase->getSilentMode(); -#endif - n += mySock->SendDataOnly(&ind,sizeof(ind)); - - if (!lockStatus) - strcpy(mySock->lastClientIP,mySock->thisClientIP); - - return OK; -} - - - -int slsReceiverTCPIPInterface::get_id(){ - ret = OK; - int64_t retval=-1; - - // execute action -#ifdef SLS_RECEIVER_UDP_FUNCTIONS - retval = getReceiverVersion(); -#endif - - if(mySock->differentClients) - ret = FORCE_UPDATE; - - // send answer - mySock->SendDataOnly(&ret,sizeof(ret)); - mySock->SendDataOnly(&retval,sizeof(retval)); - - // return ok/fail - return ret; -} - - - -int slsReceiverTCPIPInterface::set_detector_type(){ - ret = OK; - memset(mess, 0, sizeof(mess)); - detectorType dr = GENERIC; - detectorType retval = GENERIC; - - // receive arguments - if (mySock->ReceiveDataOnly(&dr,sizeof(dr)) < 0 ) - return printSocketReadError(); - - // execute action - if (dr == GET_DETECTOR_TYPE) - retval = myDetectorType; -#ifdef SLS_RECEIVER_UDP_FUNCTIONS - else if (mySock->differentClients && lockStatus) - receiverlocked(); - else if ((receiverBase) && (receiverBase->getStatus() != IDLE)) - receiverNotIdle(); - else { - switch(dr) { - case GOTTHARD: - case PROPIX: - case MOENCH: - case EIGER: - case JUNGFRAUCTB: - case JUNGFRAU: - break; - default: - ret = FAIL; - sprintf(mess,"Unknown detector type: %d\n", dr); - FILE_LOG(logERROR) << mess; - break; - } - if(ret == OK) { - if(receiverBase == NULL){ - receiverBase = UDPInterface::create(); - if(startAcquisitionCallBack) - receiverBase->registerCallBackStartAcquisition(startAcquisitionCallBack,pStartAcquisition); - if(acquisitionFinishedCallBack) - receiverBase->registerCallBackAcquisitionFinished(acquisitionFinishedCallBack,pAcquisitionFinished); - if(rawDataReadyCallBack) - receiverBase->registerCallBackRawDataReady(rawDataReadyCallBack,pRawDataReady); - if(rawDataModifyReadyCallBack) - receiverBase->registerCallBackRawDataModifyReady(rawDataModifyReadyCallBack,pRawDataReady); - } - myDetectorType = dr; - ret = receiverBase->setDetectorType(myDetectorType); - retval = myDetectorType; - } - } -#endif - // client has started updating receiver, update ip - if (!lockStatus) - strcpy(mySock->lastClientIP,mySock->thisClientIP); - - - if (ret == OK && mySock->differentClients) - ret = FORCE_UPDATE; - - // send answer - mySock->SendDataOnly(&ret,sizeof(ret)); - if (ret == FAIL) - mySock->SendDataOnly(mess,sizeof(mess)); - mySock->SendDataOnly(&retval,sizeof(retval)); - - // return ok/fail - return ret; -} - - - -int slsReceiverTCPIPInterface::set_detector_hostname() { - ret = OK; - memset(mess, 0, sizeof(mess)); - char hostname[MAX_STR_LENGTH]; - memset(hostname, 0, sizeof(hostname)); - char* retval = NULL; - char defaultVal[MAX_STR_LENGTH]; - memset(defaultVal, 0, sizeof(defaultVal)); - - - // receive arguments - if (mySock->ReceiveDataOnly(hostname,MAX_STR_LENGTH) < 0 ) - return printSocketReadError(); - - // execute action - // only a set, not a get -#ifdef SLS_RECEIVER_UDP_FUNCTIONS - if (mySock->differentClients && lockStatus) - receiverlocked(); - else if (receiverBase == NULL) - invalidReceiverObject(); - else if (receiverBase->getStatus() != IDLE) - receiverNotIdle(); - else { - receiverBase->initialize(hostname); - retval = receiverBase->getDetectorHostname(); - if(retval == NULL) - ret = FAIL; - } -#endif - - if (ret == OK && mySock->differentClients) - ret = FORCE_UPDATE; - - // send answer - mySock->SendDataOnly(&ret,sizeof(ret)); - if (ret == FAIL) - mySock->SendDataOnly(mess,sizeof(mess)); - if(retval == NULL) - mySock->SendDataOnly(defaultVal,MAX_STR_LENGTH); - else { - mySock->SendDataOnly(retval,MAX_STR_LENGTH); - delete[] retval; - } - - // return ok/fail - return ret; -} - - - -int slsReceiverTCPIPInterface::set_roi() { - ret = OK; - memset(mess, 0, sizeof(mess)); - int nroi = 0; - - // receive arguments - if (mySock->ReceiveDataOnly(&nroi,sizeof(nroi)) < 0 ) - return printSocketReadError(); - - std::vector roiLimits; - int iloop = 0; - for (iloop = 0; iloop < nroi; iloop++) { - ROI temp; - if ( mySock->ReceiveDataOnly(&temp,sizeof(ROI)) < 0 ) - return printSocketReadError(); - roiLimits.push_back(temp); - } - - //does not exist - if (myDetectorType != GOTTHARD) - functionNotImplemented(); - - // execute action - // only a set, not a get - else { -#ifdef SLS_RECEIVER_UDP_FUNCTIONS - if (mySock->differentClients && lockStatus) - receiverlocked(); - else if (receiverBase == NULL) - invalidReceiverObject(); - else if (receiverBase->getStatus() != IDLE) - receiverNotIdle(); - else { - ret = receiverBase->setROI(roiLimits); - //retval = receiverBase->getROI(); - } -#endif - } - if (ret == OK && mySock->differentClients) - ret = FORCE_UPDATE; - - // send answer - mySock->SendDataOnly(&ret,sizeof(ret)); - if (ret == FAIL) - mySock->SendDataOnly(mess,sizeof(mess)); - - roiLimits.clear(); - - // return ok/fail - return ret; -} - - - -int slsReceiverTCPIPInterface::setup_udp(){ - ret = OK; - char args[3][MAX_STR_LENGTH]; - memset(args,0,sizeof(args)); - char retval[MAX_STR_LENGTH]; - memset(retval,0,sizeof(retval)); - - - // receive arguments - if (mySock->ReceiveDataOnly(args,sizeof(args)) < 0 ) - return printSocketReadError(); - - // execute action - // only a set, not a get -#ifdef SLS_RECEIVER_UDP_FUNCTIONS - if (mySock->differentClients && lockStatus) - receiverlocked(); - else if (receiverBase == NULL) - invalidReceiverObject(); - else if (receiverBase->getStatus() != IDLE) - receiverNotIdle(); - else { - //set up udp port - int udpport=-1,udpport2=-1; - sscanf(args[1],"%d",&udpport); - sscanf(args[2],"%d",&udpport2); - receiverBase->setUDPPortNumber(udpport); - if (myDetectorType == EIGER) - receiverBase->setUDPPortNumber2(udpport2); - - //setup udpip - //get ethernet interface or IP to listen to - FILE_LOG(logINFO) << "Receiver UDP IP: " << args[0]; - std::string temp = genericSocket::ipToName(args[0]); - if (temp == "none"){ - ret = FAIL; - strcpy(mess, "Failed to get ethernet interface or IP\n"); - FILE_LOG(logERROR) << mess; - } - else { - char eth[MAX_STR_LENGTH]; - memset(eth,0,sizeof(eth)); - strcpy(eth,temp.c_str()); - if (strchr(eth,'.') != NULL) { - strcpy(eth,""); - ret = FAIL; - strcpy(mess, "Failed to get ethernet interface\n"); - FILE_LOG(logERROR) << mess; - } - receiverBase->setEthernetInterface(eth); - - //get mac address from ethernet interface - if (ret != FAIL) - temp = genericSocket::nameToMac(eth); - - if ((temp=="00:00:00:00:00:00") || (ret == FAIL)){ - ret = FAIL; - strcpy(mess,"failed to get mac adddress to listen to\n"); - FILE_LOG(logERROR) << mess; - } - else { - strcpy(retval,temp.c_str()); - FILE_LOG(logINFO) << "Reciever MAC Address: " << retval; - } - } - } -#endif - - if (ret == OK && mySock->differentClients) - ret = FORCE_UPDATE; - - // send answer - mySock->SendDataOnly(&ret,sizeof(ret)); - if (ret == FAIL) - mySock->SendDataOnly(mess,sizeof(mess)); - mySock->SendDataOnly(retval,MAX_STR_LENGTH); - - // return ok/fail - return ret; -} - - - -int slsReceiverTCPIPInterface::set_timer() { - ret = OK; - memset(mess, 0, sizeof(mess)); - int64_t index[2] = {-1, -1}; - int64_t retval = -1; - - // receive arguments - if (mySock->ReceiveDataOnly(index,sizeof(index)) < 0 ) - return printSocketReadError(); - - // execute action -#ifdef SLS_RECEIVER_UDP_FUNCTIONS - if (receiverBase == NULL) - invalidReceiverObject(); - else { - // set - if (index[1] >= 0) { - if (mySock->differentClients && lockStatus) - receiverlocked(); - // else if (receiverBase->getStatus() != IDLE) - // receiverNotIdle(); - else { - switch (index[0]) { - case ACQUISITION_TIME: - ret = receiverBase->setAcquisitionTime(index[1]); - break; - case FRAME_PERIOD: - ret = receiverBase->setAcquisitionPeriod(index[1]); - break; - case FRAME_NUMBER: - case CYCLES_NUMBER: - case STORAGE_CELL_NUMBER: - receiverBase->setNumberOfFrames(index[1]); - break; - case SUBFRAME_ACQUISITION_TIME: - receiverBase->setSubExpTime(index[1]); - break; - case SUBFRAME_DEADTIME: - receiverBase->setSubPeriod(index[1] + receiverBase->getSubExpTime()); - break; - case SAMPLES_JCTB: - if (myDetectorType != JUNGFRAUCTB) { - ret = FAIL; - sprintf(mess,"This timer mode (%lld) does not exist for this receiver type\n", (long long int)index[0]); - FILE_LOG(logERROR) << "Warning: " << mess; - break; - } - receiverBase->setNumberofSamples(index[1]); - break; - default: - ret = FAIL; - sprintf(mess,"This timer mode (%lld) does not exist for receiver\n", (long long int)index[0]); - FILE_LOG(logERROR) << mess; - } - } - } - // get - switch (index[0]) { - case ACQUISITION_TIME: - retval=receiverBase->getAcquisitionTime(); - break; - case FRAME_PERIOD: - retval=receiverBase->getAcquisitionPeriod(); - break; - case FRAME_NUMBER: - case CYCLES_NUMBER: - case STORAGE_CELL_NUMBER: - retval=receiverBase->getNumberOfFrames(); - break; - case SUBFRAME_ACQUISITION_TIME: - retval=receiverBase->getSubExpTime(); - break; - case SUBFRAME_DEADTIME: - retval=(receiverBase->getSubPeriod() - receiverBase->getSubExpTime()); - break; - case SAMPLES_JCTB: - if (myDetectorType != JUNGFRAUCTB) { - ret = FAIL; - sprintf(mess,"This timer mode (%lld) does not exist for this receiver type\n", (long long int)index[0]); - FILE_LOG(logERROR) << "Warning: " << mess; - break; - } - retval=receiverBase->getNumberofSamples(); - break; - default: - ret = FAIL; - sprintf(mess,"This timer mode (%lld) does not exist for receiver\n", (long long int)index[0]); - FILE_LOG(logERROR) << mess; - } - - // check - if (ret == OK && index[1] >= 0 && retval != index[1]) { - ret = FAIL; - strcpy(mess,"Could not set timer\n"); - FILE_LOG(logERROR) << mess; - } - } -#endif -#ifdef VERYVERBOSE - FILE_LOG(logDEBUG1) << getTimerType(index[0]) << ":" << retval; -#endif - - if (ret == OK && mySock->differentClients) - ret = FORCE_UPDATE; - - // send answer - mySock->SendDataOnly(&ret,sizeof(ret)); - if (ret == FAIL) - mySock->SendDataOnly(mess,sizeof(mess)); - mySock->SendDataOnly(&retval,sizeof(retval)); - - // return ok/fail - return ret; -} - - - -int slsReceiverTCPIPInterface::set_dynamic_range() { - ret = OK; - memset(mess, 0, sizeof(mess)); - int dr = -1; - int retval = -1; - - // receive arguments - if (mySock->ReceiveDataOnly(&dr,sizeof(dr)) < 0 ) - return printSocketReadError(); - - // execute action - bool exists = false; - switch (dr) { - case -1: - case 16: - exists = true; - break; - case 4: - case 8: - case 32: - if (myDetectorType == EIGER) - exists = true; - break; - default: - break; - } - if (!exists) { - ret = FAIL; - sprintf(mess,"This dynamic range %d does not exist for this detector\n",dr); - FILE_LOG(logERROR) << mess; - } - -#ifdef SLS_RECEIVER_UDP_FUNCTIONS - if (ret == OK){ - if (receiverBase == NULL) - invalidReceiverObject(); - else { - // set - if (dr > 0) { - if (mySock->differentClients && lockStatus) - receiverlocked(); - else if (receiverBase->getStatus() != IDLE) - receiverNotIdle(); - else { - ret = receiverBase->setDynamicRange(dr); - if(ret == FAIL) { - strcpy(mess, "Could not allocate memory for fifo or could not start listening/writing threads\n"); - FILE_LOG(logERROR) << mess; - } - } - } - //get - retval = receiverBase->getDynamicRange(); - if(dr > 0 && retval != dr) { - ret = FAIL; - strcpy(mess, "Could not set dynamic range\n"); - FILE_LOG(logERROR) << mess; - } - } - } -#ifdef VERYVERBOSE - FILE_LOG(logDEBUG1) << "dynamic range: " << retval; -#endif -#endif - - if (ret == OK && mySock->differentClients) - ret = FORCE_UPDATE; - - // send answer - mySock->SendDataOnly(&ret,sizeof(ret)); - if (ret == FAIL) - mySock->SendDataOnly(mess,sizeof(mess)); - mySock->SendDataOnly(&retval,sizeof(retval)); - - // return ok/fail - return ret; -} - - - -int slsReceiverTCPIPInterface::set_read_frequency(){ - ret = OK; - memset(mess, 0, sizeof(mess)); - int index = -1; - int retval = -1; - - // receive arguments - if (mySock->ReceiveDataOnly(&index,sizeof(index)) < 0 ) - return printSocketReadError(); - - // execute action -#ifdef SLS_RECEIVER_UDP_FUNCTIONS - if (receiverBase == NULL) - invalidReceiverObject(); - else { - // set - if (index >= 0) { - if (mySock->differentClients && lockStatus) - receiverlocked(); - else if (receiverBase->getStatus() != IDLE) - receiverNotIdle(); - else { - ret = receiverBase->setFrameToGuiFrequency(index); - if(ret == FAIL) { - strcpy(mess, "Could not allocate memory for listening fifo\n"); - FILE_LOG(logERROR) << mess; - } - } - } - //get - retval=receiverBase->getFrameToGuiFrequency(); - if(index >= 0 && retval != index){ - ret = FAIL; - strcpy(mess,"Could not set frame to gui frequency"); - FILE_LOG(logERROR) << mess; - } - } -#endif - - if (ret == OK && mySock->differentClients) - ret = FORCE_UPDATE; - - // send answer - mySock->SendDataOnly(&ret,sizeof(ret)); - if (ret == FAIL) - mySock->SendDataOnly(mess,sizeof(mess)); - mySock->SendDataOnly(&retval,sizeof(retval)); - - // return ok/fail - return ret; -} - - - -int slsReceiverTCPIPInterface::get_status(){ - ret = OK; - enum runStatus retval = ERROR; - - // execute action -#ifdef SLS_RECEIVER_UDP_FUNCTIONS - if (receiverBase == NULL) - invalidReceiverObject(); - else retval = receiverBase->getStatus(); -#endif - - if (ret == OK && mySock->differentClients) - ret = FORCE_UPDATE; - - // send answer - mySock->SendDataOnly(&ret,sizeof(ret)); - mySock->SendDataOnly(&retval,sizeof(retval)); - - // return ok/fail - return ret; -} - - - -int slsReceiverTCPIPInterface::start_receiver(){ - ret = OK; - memset(mess, 0, sizeof(mess)); - - // execute action - // only a set, not a get -#ifdef SLS_RECEIVER_UDP_FUNCTIONS - if (receiverBase == NULL) - invalidReceiverObject(); - else if (mySock->differentClients && lockStatus) - receiverlocked(); - /* - else if(!strlen(receiverBase->getFilePath())){ - strcpy(mess,SET_RECEIVER_ERR_MESSAGE"); - ret = FAIL; - } - */ - else { - enum runStatus s = receiverBase->getStatus(); - if (s != IDLE) { - ret=FAIL; - sprintf(mess,"Cannot start Receiver as it is in %s state\n",runStatusType(s).c_str()); - FILE_LOG(logERROR) << mess; - } - else { - ret=receiverBase->startReceiver(mess); - if (ret == FAIL) { - FILE_LOG(logERROR) << mess; - } - } - } -#endif - - if (ret == OK && mySock->differentClients) - ret = FORCE_UPDATE; - - // send answer - mySock->SendDataOnly(&ret,sizeof(ret)); - if (ret == FAIL) - mySock->SendDataOnly(mess,sizeof(mess)); - - // return ok/fail - return ret; - - -} - - - -int slsReceiverTCPIPInterface::stop_receiver(){ - ret = OK; - memset(mess, 0, sizeof(mess)); - enum runStatus s = ERROR; - - // execute action - // only a set, not a get -#ifdef SLS_RECEIVER_UDP_FUNCTIONS - if (receiverBase == NULL) - invalidReceiverObject(); - else if (mySock->differentClients && lockStatus) - receiverlocked(); - else { - if(receiverBase->getStatus() != IDLE) - receiverBase->stopReceiver(); - s = receiverBase->getStatus(); - if (s == IDLE) - ret = OK; - else { - ret = FAIL; - sprintf(mess,"Could not stop receiver. It is in %s state\n",runStatusType(s).c_str()); - FILE_LOG(logERROR) << mess; - } - } -#endif - - if (ret == OK && mySock->differentClients) - ret = FORCE_UPDATE; - - // send answer - mySock->SendDataOnly(&ret,sizeof(ret)); - if (ret == FAIL) - mySock->SendDataOnly(mess,sizeof(mess)); - - // return ok/fail - return ret; -} - - - -int slsReceiverTCPIPInterface::start_readout(){ - ret = OK; - memset(mess, 0, sizeof(mess)); - enum runStatus retval; - - // execute action - // only a set, not a get - -#ifdef SLS_RECEIVER_UDP_FUNCTIONS - if (receiverBase == NULL) - invalidReceiverObject(); - else if (mySock->differentClients && lockStatus) - receiverlocked(); - /*else if(receiverBase->getStatus() != IDLE){ - strcpy(mess,"Can not start receiver readout while receiver not idle\n"); - ret = FAIL; - }*/ - else { - receiverBase->startReadout(); - retval = receiverBase->getStatus(); - if ((retval == TRANSMITTING) || (retval == RUN_FINISHED) || (retval == IDLE)) - ret = OK; - else { - ret = FAIL; - strcpy(mess,"Could not start readout"); - FILE_LOG(logERROR) << mess; - } - } -#endif - - if (ret == OK && mySock->differentClients) - ret = FORCE_UPDATE; - - // send answer - mySock->SendDataOnly(&ret,sizeof(ret)); - if (ret == FAIL) - mySock->SendDataOnly(mess,sizeof(mess)); - mySock->SendDataOnly(&retval,sizeof(retval)); - - // return ok/fail - return ret; -} - - - - - -int slsReceiverTCPIPInterface::set_file_dir() { - ret = OK; - memset(mess, 0, sizeof(mess)); - char fPath[MAX_STR_LENGTH]; - memset(fPath, 0, sizeof(fPath)); - char* retval=NULL; - char defaultVal[MAX_STR_LENGTH]; - memset(defaultVal, 0, sizeof(defaultVal)); - - // receive arguments - if (mySock->ReceiveDataOnly(fPath,MAX_STR_LENGTH) < 0 ) - return printSocketReadError(); - - // execute action -#ifdef SLS_RECEIVER_UDP_FUNCTIONS - if (receiverBase == NULL) - invalidReceiverObject(); - else { - // set - if (strlen(fPath)) { - if (mySock->differentClients && lockStatus) - receiverlocked(); - else if (receiverBase->getStatus() != IDLE) - receiverNotIdle(); - else { - receiverBase->setFilePath(fPath); - } - } - //get - retval = receiverBase->getFilePath(); - if (retval == NULL || (strlen(fPath) && strcasecmp(fPath, retval))) { - ret = FAIL; - strcpy(mess,"receiver file path does not exist\n"); - FILE_LOG(logERROR) << mess; - } - } -#endif -#ifdef VERYVERBOSE - if (retval != NULL) - FILE_LOG(logDEBUG1) << "file path:" << retval; -#endif - - if (ret == OK && mySock->differentClients) - ret = FORCE_UPDATE; - - // send answer - mySock->SendDataOnly(&ret,sizeof(ret)); - if (ret == FAIL) - mySock->SendDataOnly(mess,sizeof(mess)); - if(retval == NULL) - mySock->SendDataOnly(defaultVal,MAX_STR_LENGTH); - else{ - mySock->SendDataOnly(retval,MAX_STR_LENGTH); - delete[] retval; - } - - // return ok/fail - return ret; -} - - - -int slsReceiverTCPIPInterface::set_file_name() { - ret = OK; - memset(mess, 0, sizeof(mess)); - char fName[MAX_STR_LENGTH]; - memset(fName, 0, sizeof(fName)); - char* retval = NULL; - char defaultVal[MAX_STR_LENGTH]; - memset(defaultVal, 0, sizeof(defaultVal)); - - // receive arguments - if (mySock->ReceiveDataOnly(fName,MAX_STR_LENGTH) < 0 ) - return printSocketReadError(); - - // execute action -#ifdef SLS_RECEIVER_UDP_FUNCTIONS - if (receiverBase == NULL) - invalidReceiverObject(); - else { - // set - if (strlen(fName)) { - if (mySock->differentClients && lockStatus) - receiverlocked(); - else if (receiverBase->getStatus() != IDLE) - receiverNotIdle(); - else { - receiverBase->setFileName(fName); - } - } - //get - retval = receiverBase->getFileName(); - if(retval == NULL) { - ret = FAIL; - strcpy(mess, "file name is empty\n"); - FILE_LOG(logERROR) << mess; - } - } -#endif -#ifdef VERYVERBOSE - FILE_LOG(logDEBUG1) << "file name:" << retval; -#endif - - if (ret == OK && mySock->differentClients) - ret = FORCE_UPDATE; - - // send answer - mySock->SendDataOnly(&ret,sizeof(ret)); - if (ret == FAIL) - mySock->SendDataOnly(mess,sizeof(mess)); - if(retval == NULL) - mySock->SendDataOnly(defaultVal,MAX_STR_LENGTH); - else{ - mySock->SendDataOnly(retval,MAX_STR_LENGTH); - delete[] retval; - } - - // return ok/fail - return ret; -} - - - -int slsReceiverTCPIPInterface::set_file_index() { - ret = OK; - memset(mess, 0, sizeof(mess)); - int index = -1; - int retval = -1; - - // receive arguments - if (mySock->ReceiveDataOnly(&index,sizeof(index)) < 0 ) - return printSocketReadError(); - - // execute action -#ifdef SLS_RECEIVER_UDP_FUNCTIONS - if (receiverBase == NULL) - invalidReceiverObject(); - else { - // set - if(index >= 0) { - if (mySock->differentClients && lockStatus) - receiverlocked(); - else if (receiverBase->getStatus() != IDLE) - receiverNotIdle(); - else { - receiverBase->setFileIndex(index); - } - } - //get - retval=receiverBase->getFileIndex(); - if(index >= 0 && retval != index) { - ret = FAIL; - strcpy(mess, "Could not set file index\n"); - FILE_LOG(logERROR) << mess; - } - } -#endif -#ifdef VERYVERBOSE - FILE_LOG(logDEBUG1) << "file index:" << retval; -#endif - - if (ret == OK && mySock->differentClients) - ret = FORCE_UPDATE; - - // send answer - mySock->SendDataOnly(&ret,sizeof(ret)); - if (ret == FAIL) - mySock->SendDataOnly(mess,sizeof(mess)); - mySock->SendDataOnly(&retval,sizeof(retval)); - - // return ok/fail - return ret; -} - - - - - - -int slsReceiverTCPIPInterface::get_frame_index(){ - ret = OK; - int retval = -1; - - // execute action -#ifdef SLS_RECEIVER_UDP_FUNCTIONS - if (receiverBase == NULL) - invalidReceiverObject(); - else - retval=receiverBase->getAcquisitionIndex(); -#endif - - if (mySock->differentClients) - ret = FORCE_UPDATE; - - // send answer - mySock->SendDataOnly(&ret,sizeof(ret)); - mySock->SendDataOnly(&retval,sizeof(retval)); - - // return ok/fail - return ret; -} - - - -int slsReceiverTCPIPInterface::get_frames_caught(){ - ret = OK; - int retval = -1; - - // execute action -#ifdef SLS_RECEIVER_UDP_FUNCTIONS - if (receiverBase == NULL) - invalidReceiverObject(); - else retval=receiverBase->getTotalFramesCaught(); -#endif - - if (mySock->differentClients) - ret = FORCE_UPDATE; - - // send answer - mySock->SendDataOnly(&ret,sizeof(ret)); - mySock->SendDataOnly(&retval,sizeof(retval)); - - // return ok/fail - return ret; -} - - - -int slsReceiverTCPIPInterface::reset_frames_caught(){ - ret = OK; - memset(mess, 0, sizeof(mess)); - - // execute action - // only a set, not a get -#ifdef SLS_RECEIVER_UDP_FUNCTIONS - if (receiverBase == NULL) - invalidReceiverObject(); - else if (mySock->differentClients && lockStatus) - receiverlocked(); - else if (receiverBase->getStatus() != IDLE) - receiverNotIdle(); - else - receiverBase->resetAcquisitionCount(); -#endif - - if (ret == OK && mySock->differentClients) - ret = FORCE_UPDATE; - - // send answer - mySock->SendDataOnly(&ret,sizeof(ret)); - if (ret == FAIL) - mySock->SendDataOnly(mess,sizeof(mess)); - - // return ok/fail - return ret; -} - - - -int slsReceiverTCPIPInterface::enable_file_write(){ - ret = OK; - memset(mess, 0, sizeof(mess)); - int enable = -1; - int retval = -1; - - // receive arguments - if (mySock->ReceiveDataOnly(&enable,sizeof(enable)) < 0 ) - return printSocketReadError(); - - // execute action -#ifdef SLS_RECEIVER_UDP_FUNCTIONS - if (receiverBase == NULL) - invalidReceiverObject(); - else { - // set - if (enable >= 0) { - if (mySock->differentClients && lockStatus) - receiverlocked(); - else if (receiverBase->getStatus() != IDLE) - receiverNotIdle(); - else { - receiverBase->setFileWriteEnable(enable); - } - } - //get - retval=receiverBase->getFileWriteEnable(); - if(enable >= 0 && enable != retval) { - ret=FAIL; - strcpy(mess,"Could not set file write enable"); - FILE_LOG(logERROR) << mess; - } - } -#endif -#ifdef VERYVERBOSE - FILE_LOG(logDEBUG1) << "file write enable:" << retval; -#endif - - if (ret == OK && mySock->differentClients) - ret = FORCE_UPDATE; - - // send answer - mySock->SendDataOnly(&ret,sizeof(ret)); - if (ret == FAIL) - mySock->SendDataOnly(mess,sizeof(mess)); - mySock->SendDataOnly(&retval,sizeof(retval)); - - // return ok/fail - return ret; -} - - - - - -int slsReceiverTCPIPInterface::enable_compression() { - ret = OK; - memset(mess, 0, sizeof(mess)); - int enable = -1; - - // receive arguments - if(mySock->ReceiveDataOnly(&enable,sizeof(enable)) < 0 ) - return printSocketReadError(); - - ret = FAIL; - sprintf(mess, "This function (%s) is not implemented yet\n", getFunctionName((enum recFuncs)fnum)); - FILE_LOG(logERROR) << mess; - - // send answer - mySock->SendDataOnly(&ret,sizeof(ret)); - mySock->SendDataOnly(mess,sizeof(mess)); - - // return ok/fail - return ret; -} - - - -int slsReceiverTCPIPInterface::enable_overwrite() { - ret = OK; - memset(mess, 0, sizeof(mess)); - int index = -1; - int retval = -1; - - // receive arguments - if (mySock->ReceiveDataOnly(&index,sizeof(index)) < 0 ) - return printSocketReadError(); - - // execute action -#ifdef SLS_RECEIVER_UDP_FUNCTIONS - if (receiverBase == NULL) - invalidReceiverObject(); - else { - // set - if(index >= 0) { - if (mySock->differentClients && lockStatus) - receiverlocked(); - else if (receiverBase->getStatus() != IDLE) - receiverNotIdle(); - else { - receiverBase->setOverwriteEnable(index); - } - } - //get - retval=receiverBase->getOverwriteEnable(); - if(index >=0 && retval != index) { - ret = FAIL; - strcpy(mess,"Could not set file over write enable\n"); - FILE_LOG(logERROR) << mess; - } - } -#endif -#ifdef VERYVERBOSE - FILE_LOG(logDEBUG1) << "file overwrite enable:" << retval; -#endif - - if (ret == OK && mySock->differentClients) - ret = FORCE_UPDATE; - - // send answer - mySock->SendDataOnly(&ret,sizeof(ret)); - if (ret == FAIL) - mySock->SendDataOnly(mess,sizeof(mess)); - mySock->SendDataOnly(&retval,sizeof(retval)); - - // return ok/fail - return ret; -} - - - -int slsReceiverTCPIPInterface::enable_tengiga() { - ret = OK; - memset(mess, 0, sizeof(mess)); - int val = -1; - int retval = -1; - - // receive arguments - if (mySock->ReceiveDataOnly(&val,sizeof(val)) < 0 ) - return printSocketReadError(); - - if (myDetectorType != EIGER) - functionNotImplemented(); - - // execute action - - -#ifdef SLS_RECEIVER_UDP_FUNCTIONS - else { - if (receiverBase == NULL) - invalidReceiverObject(); - else { - // set - if (val >= 0) { - if (mySock->differentClients && lockStatus) - receiverlocked(); - else if (receiverBase->getStatus() != IDLE) - receiverNotIdle(); - else { - ret = receiverBase->setTenGigaEnable(val); - } - } - //get - retval=receiverBase->getTenGigaEnable(); - if((val >= 0) && (val != retval)) { - ret = FAIL; - strcpy(mess,"Could not set ten giga enable"); - FILE_LOG(logERROR) << mess; - } - } - } -#endif -#ifdef VERYVERBOSE - FILE_LOG(logDEBUG1) << "10Gbe:" << retval; -#endif - - if (ret == OK && mySock->differentClients) - ret = FORCE_UPDATE; - - // send answer - mySock->SendDataOnly(&ret,sizeof(ret)); - if (ret == FAIL) - mySock->SendDataOnly(mess,sizeof(mess)); - mySock->SendDataOnly(&retval,sizeof(retval)); - - // return ok/fail - return ret; -} - - - - -int slsReceiverTCPIPInterface::set_fifo_depth() { - ret = OK; - memset(mess, 0, sizeof(mess)); - int value = -1; - int retval = -1; - - // receive arguments - if (mySock->ReceiveDataOnly(&value,sizeof(value)) < 0 ) - return printSocketReadError(); - - // execute action -#ifdef SLS_RECEIVER_UDP_FUNCTIONS - if (receiverBase == NULL) - invalidReceiverObject(); - else { - // set - if(value >= 0) { - if (mySock->differentClients && lockStatus) - receiverlocked(); - else if (receiverBase->getStatus() != IDLE) - receiverNotIdle(); - else { - ret = receiverBase->setFifoDepth(value); - if (ret == FAIL) { - strcpy(mess,"Could not set fifo depth"); - FILE_LOG(logERROR) << mess; - } - } - } - //get - retval = receiverBase->getFifoDepth(); - if(value >= 0 && retval != value) { - ret = FAIL; - strcpy(mess, "Could not set fifo depth\n"); - FILE_LOG(logERROR) << mess; - } - } -#endif -#ifdef VERYVERBOSE - FILE_LOG(logDEBUG1) << "fifo depth:" << retval; -#endif - - if (ret == OK && mySock->differentClients) - ret = FORCE_UPDATE; - - // send answer - mySock->SendDataOnly(&ret,sizeof(ret)); - if (ret == FAIL) - mySock->SendDataOnly(mess,sizeof(mess)); - mySock->SendDataOnly(&retval,sizeof(retval)); - - // return ok/fail - return ret; -} - - - -int slsReceiverTCPIPInterface::set_activate() { - ret = OK; - memset(mess, 0, sizeof(mess)); - int enable = -1; - int retval = -1; - - // receive arguments - if (mySock->ReceiveDataOnly(&enable,sizeof(enable)) < 0 ) - return printSocketReadError(); - - if (myDetectorType != EIGER) - functionNotImplemented(); - - // execute action -#ifdef SLS_RECEIVER_UDP_FUNCTIONS - else { - if (receiverBase == NULL) - invalidReceiverObject(); - else { - // set - if(enable >= 0) { - if (mySock->differentClients && lockStatus) - receiverlocked(); - else if (receiverBase->getStatus() != IDLE) - receiverNotIdle(); - else { - receiverBase->setActivate(enable > 0 ? true : false); - } - } - //get - retval = (int)receiverBase->getActivate(); - if(enable >= 0 && retval != enable){ - ret = FAIL; - sprintf(mess,"Could not set activate to %d, returned %d\n",enable,retval); - FILE_LOG(logERROR) << mess; - } - } - } -#endif -#ifdef VERYVERBOSE - FILE_LOG(logDEBUG1) << "Activate: " << retval; -#endif - - if (ret == OK && mySock->differentClients) - ret = FORCE_UPDATE; - - // send answer - mySock->SendDataOnly(&ret,sizeof(ret)); - if (ret == FAIL) - mySock->SendDataOnly(mess,sizeof(mess)); - mySock->SendDataOnly(&retval,sizeof(retval)); - - // return ok/fail - return ret; -} - - - -int slsReceiverTCPIPInterface::set_data_stream_enable(){ - ret = OK; - memset(mess, 0, sizeof(mess)); - int index = -1; - int retval = -1; - - // receive arguments - if (mySock->ReceiveDataOnly(&index,sizeof(index)) < 0 ) - return printSocketReadError(); - - // execute action -#ifdef SLS_RECEIVER_UDP_FUNCTIONS - if (receiverBase == NULL) - invalidReceiverObject(); - else { - // set - if(index >= 0) { - if (mySock->differentClients && lockStatus) - receiverlocked(); - else if (receiverBase->getStatus() != IDLE) - receiverNotIdle(); - else { - ret = receiverBase->setDataStreamEnable(index); - } - } - //get - retval = receiverBase->getDataStreamEnable(); - if(index >= 0 && retval != index){ - ret = FAIL; - strcpy(mess,"Could not set data stream enable"); - FILE_LOG(logERROR) << mess; - } - } -#endif -#ifdef VERYVERBOSE - FILE_LOG(logDEBUG1) << "data streaming enable:" << retval; -#endif - - if (ret == OK && mySock->differentClients) - ret = FORCE_UPDATE; - - // send answer - mySock->SendDataOnly(&ret,sizeof(ret)); - if (ret == FAIL) - mySock->SendDataOnly(mess,sizeof(mess)); - mySock->SendDataOnly(&retval,sizeof(retval)); - - // return ok/fail - return ret; -} - - - -int slsReceiverTCPIPInterface::set_read_receiver_timer(){ - ret = OK; - memset(mess, 0, sizeof(mess)); - int index = -1; - int retval = -1; - - // receive arguments - if(mySock->ReceiveDataOnly(&index,sizeof(index)) < 0 ) - return printSocketReadError(); - - // execute action -#ifdef SLS_RECEIVER_UDP_FUNCTIONS - if (receiverBase == NULL) - invalidReceiverObject(); - else { - // set - if(index >= 0) { - if (mySock->differentClients && lockStatus) - receiverlocked(); - else if (receiverBase->getStatus() != IDLE) - receiverNotIdle(); - else { - receiverBase->setFrameToGuiTimer(index); - } - } - //get - retval=receiverBase->getFrameToGuiTimer(); - if(index >= 0 && retval != index){ - ret = FAIL; - strcpy(mess,"Could not set datastream timer"); - FILE_LOG(logERROR) << mess; - } - } -#endif -#ifdef VERYVERBOSE - FILE_LOG(logDEBUG1) << "receiver read timer:" << retval; -#endif - - if (ret == OK && mySock->differentClients) - ret = FORCE_UPDATE; - - // send answer - mySock->SendDataOnly(&ret,sizeof(ret)); - if (ret == FAIL) - mySock->SendDataOnly(mess,sizeof(mess)); - mySock->SendDataOnly(&retval,sizeof(retval)); - - // return ok/fail - return ret; -} - - - -int slsReceiverTCPIPInterface::set_flipped_data(){ - ret = OK; - memset(mess, 0, sizeof(mess)); - int args[2] = {0,-1}; - int retval = -1; - - // receive arguments - if (mySock->ReceiveDataOnly(args,sizeof(args)) < 0 ) - return printSocketReadError(); - - if (myDetectorType != EIGER) - functionNotImplemented(); - - // execute action -#ifdef SLS_RECEIVER_UDP_FUNCTIONS - else { - if (receiverBase == NULL) - invalidReceiverObject(); - else { - // set - if(args[1] >= 0) { - if (mySock->differentClients && lockStatus) - receiverlocked(); - else if (receiverBase->getStatus() != IDLE) - receiverNotIdle(); - else { - receiverBase->setFlippedData(args[0],args[1]); - } - } - //get - retval=receiverBase->getFlippedData(args[0]); - if (args[1] > -1 && retval != args[1]) { - ret = FAIL; - strcpy(mess, "Could not set flipped data\n"); - FILE_LOG(logERROR) << mess; - } - } - } -#endif -#ifdef VERYVERBOSE - FILE_LOG(logDEBUG1) << "Flipped Data:" << retval; -#endif - - if (ret == OK && mySock->differentClients) - ret = FORCE_UPDATE; - - // send answer - mySock->SendDataOnly(&ret,sizeof(ret)); - if (ret == FAIL) - mySock->SendDataOnly(mess,sizeof(mess)); - mySock->SendDataOnly(&retval,sizeof(retval)); - - // return ok/fail - return ret; -} - - - - -int slsReceiverTCPIPInterface::set_file_format() { - ret = OK; - memset(mess, 0, sizeof(mess)); - fileFormat retval = GET_FILE_FORMAT; - fileFormat f = GET_FILE_FORMAT; - - // receive arguments - if (mySock->ReceiveDataOnly(&f,sizeof(f)) < 0 ) - return printSocketReadError(); - - // execute action -#ifdef SLS_RECEIVER_UDP_FUNCTIONS - if (receiverBase == NULL) - invalidReceiverObject(); - else { - // set - if(f >= 0) { - if (mySock->differentClients && lockStatus) - receiverlocked(); - else if (receiverBase->getStatus() != IDLE) - receiverNotIdle(); - else { - receiverBase->setFileFormat(f); - } - } - //get - retval = receiverBase->getFileFormat(); - if(f >= 0 && retval != f){ - ret = FAIL; - sprintf(mess,"Could not set file format to %s, returned %s\n",getFileFormatType(f).c_str(),getFileFormatType(retval).c_str()); - FILE_LOG(logERROR) << mess; - } - } -#endif -#ifdef VERYVERBOSE - FILE_LOG(logDEBUG1) << "File Format: " << retval; -#endif - - if (ret == OK && mySock->differentClients) - ret = FORCE_UPDATE; - - // send answer - mySock->SendDataOnly(&ret,sizeof(ret)); - if (ret == FAIL) - mySock->SendDataOnly(mess,sizeof(mess)); - mySock->SendDataOnly(&retval,sizeof(retval)); - - // return ok/fail - return ret; -} - - - -int slsReceiverTCPIPInterface::set_detector_posid() { - ret = OK; - memset(mess, 0, sizeof(mess)); - int arg = -1; - int retval = -1; - - // receive arguments - if (mySock->ReceiveDataOnly(&arg,sizeof(arg)) < 0 ) - return printSocketReadError(); - - // execute action -#ifdef SLS_RECEIVER_UDP_FUNCTIONS - if (receiverBase == NULL) - invalidReceiverObject(); - else { - // set - if(arg >= 0) { - if (mySock->differentClients && lockStatus) - receiverlocked(); - else if (receiverBase->getStatus() != IDLE) - receiverNotIdle(); - else { - receiverBase->setDetectorPositionId(arg); - } - } - //get - retval=receiverBase->getDetectorPositionId(); - if (arg >= 0 && retval != arg) { - ret = FAIL; - strcpy(mess,"Could not set detector position id"); - FILE_LOG(logERROR) << mess; - } - } -#endif -#ifdef VERYVERBOSE - FILE_LOG(logDEBUG1) << "Position Id:" << retval; -#endif - - if (ret == OK && mySock->differentClients) - ret = FORCE_UPDATE; - - // send answer - mySock->SendDataOnly(&ret,sizeof(ret)); - if (ret == FAIL) - mySock->SendDataOnly(mess,sizeof(mess)); - mySock->SendDataOnly(&retval,sizeof(retval)); - - // return ok/fail - return ret; -} - - - - - - -int slsReceiverTCPIPInterface::set_multi_detector_size() { - ret = OK; - memset(mess, 0, sizeof(mess)); - int arg[2] = {-1, -1}; - int retval = -1; - - // receive arguments - if (mySock->ReceiveDataOnly(arg,sizeof(arg)) < 0 ) - return printSocketReadError(); - - // execute action -#ifdef SLS_RECEIVER_UDP_FUNCTIONS - if (receiverBase == NULL) - invalidReceiverObject(); - else { - // set - if((arg[0] > 0) && (arg[1] > 0)) { - if (mySock->differentClients && lockStatus) - receiverlocked(); - else if (receiverBase->getStatus() != IDLE) - receiverNotIdle(); - else { - receiverBase->setMultiDetectorSize(arg); - } - } - //get - int* temp = receiverBase->getMultiDetectorSize(); - for (int i = 0; i < MAX_DIMENSIONS; ++i) { - if (!i) - retval = temp[i]; - else - retval *= temp[i]; - } - } -#endif -#ifdef VERYVERBOSE - FILE_LOG(logDEBUG1) << "Multi Detector Size:" << retval; -#endif - - if (ret == OK && mySock->differentClients) - ret = FORCE_UPDATE; - - // send answer - mySock->SendDataOnly(&ret,sizeof(ret)); - if (ret == FAIL) - mySock->SendDataOnly(mess,sizeof(mess)); - mySock->SendDataOnly(&retval,sizeof(retval)); - - // return ok/fail - return ret; -} - - - - -int slsReceiverTCPIPInterface::set_streaming_port() { - ret = OK; - memset(mess, 0, sizeof(mess)); - int port = -1; - int retval = -1; - - // receive arguments - if (mySock->ReceiveDataOnly(&port,sizeof(port)) < 0 ) - return printSocketReadError(); - - // execute action -#ifdef SLS_RECEIVER_UDP_FUNCTIONS - if (receiverBase == NULL) - invalidReceiverObject(); - else { - // set - if(port >= 0) { - if (mySock->differentClients && lockStatus) - receiverlocked(); - else if (receiverBase->getStatus() != IDLE) - receiverNotIdle(); - else { - receiverBase->setStreamingPort(port); - } - } - //get - retval=receiverBase->getStreamingPort(); - } -#endif -#ifdef VERYVERBOSE - FILE_LOG(logDEBUG1) << "streaming port:" << retval; -#endif - - if (ret == OK && mySock->differentClients) - ret = FORCE_UPDATE; - - // send answer - mySock->SendDataOnly(&ret,sizeof(ret)); - if (ret == FAIL) - mySock->SendDataOnly(mess,sizeof(mess)); - mySock->SendDataOnly(&retval,sizeof(retval)); - - // return ok/fail - return ret; -} - - - - - -int slsReceiverTCPIPInterface::set_streaming_source_ip() { - ret = OK; - memset(mess, 0, sizeof(mess)); - char arg[MAX_STR_LENGTH]; - memset(arg, 0, sizeof(arg)); - char* retval=NULL; - - // receive arguments - if (mySock->ReceiveDataOnly(arg,MAX_STR_LENGTH) < 0 ) - return printSocketReadError(); - - // execute action -#ifdef SLS_RECEIVER_UDP_FUNCTIONS - if (receiverBase == NULL) - invalidReceiverObject(); - else { - // set - if (mySock->differentClients && lockStatus) - receiverlocked(); - else if (receiverBase->getStatus() != IDLE) - receiverNotIdle(); - else { - receiverBase->setStreamingSourceIP(arg); - } - - //get - retval = receiverBase->getStreamingSourceIP(); - } -#endif -#ifdef VERYVERBOSE - FILE_LOG(logDEBUG1) << "streaming source ip:" << retval; -#endif - - if (ret == OK && mySock->differentClients) - ret = FORCE_UPDATE; - - // send answer - mySock->SendDataOnly(&ret,sizeof(ret)); - if (ret == FAIL) - mySock->SendDataOnly(mess,sizeof(mess)); - mySock->SendDataOnly(retval,MAX_STR_LENGTH); - delete[] retval; - - // return ok/fail - return ret; -} - - - - - - - -int slsReceiverTCPIPInterface::set_silent_mode() { - ret = OK; - memset(mess, 0, sizeof(mess)); - int value = -1; - int retval = -1; - - // receive arguments - if (mySock->ReceiveDataOnly(&value,sizeof(value)) < 0 ) - return printSocketReadError(); - - // execute action -#ifdef SLS_RECEIVER_UDP_FUNCTIONS - if (receiverBase == NULL) - invalidReceiverObject(); - else { - // set - if(value >= 0) { - if (mySock->differentClients && lockStatus) - receiverlocked(); - else if (receiverBase->getStatus() != IDLE) - receiverNotIdle(); - else { - receiverBase->setSilentMode(value); // no check required - } - } - //get - retval = (int)receiverBase->getSilentMode(); // no check required - } -#endif -#ifdef VERYVERBOSE - FILE_LOG(logDEBUG1) << "silent mode:" << retval; -#endif - - if (ret == OK && mySock->differentClients) - ret = FORCE_UPDATE; - - // send answer - mySock->SendDataOnly(&ret,sizeof(ret)); - if (ret == FAIL) - mySock->SendDataOnly(mess,sizeof(mess)); - mySock->SendDataOnly(&retval,sizeof(retval)); - - // return ok/fail - return ret; -} - - - - - - -int slsReceiverTCPIPInterface::enable_gap_pixels() { - ret = OK; - memset(mess, 0, sizeof(mess)); - int enable = -1; - int retval = -1; - - // receive arguments - if (mySock->ReceiveDataOnly(&enable,sizeof(enable)) < 0 ) - return printSocketReadError(); - - - // execute action -#ifdef SLS_RECEIVER_UDP_FUNCTIONS - if (receiverBase == NULL) - invalidReceiverObject(); - else { - // set - if(enable >= 0) { - if (mySock->differentClients && lockStatus) - receiverlocked(); - else if (receiverBase->getStatus() != IDLE) - receiverNotIdle(); - else { - if ((myDetectorType != EIGER) && (enable > 0)) - functionNotImplemented(); - else - receiverBase->setGapPixelsEnable(enable); - } - } - //get - retval = receiverBase->getGapPixelsEnable(); - if(enable >= 0 && retval != enable){ - ret = FAIL; - sprintf(mess,"Could not set gap pixels to %d, returned %d\n",enable,retval); - FILE_LOG(logERROR) << "Warning: " << mess; - } - } -#endif -#ifdef VERYVERBOSE - FILE_LOG(logDEBUG1) << "Gap Pixels Enable: " << retval; -#endif - - if (ret == OK && mySock->differentClients) - ret = FORCE_UPDATE; - - // send answer - mySock->SendDataOnly(&ret,sizeof(ret)); - if (ret == FAIL) - mySock->SendDataOnly(mess,sizeof(mess)); - mySock->SendDataOnly(&retval,sizeof(retval)); - - // return ok/fail - return ret; -} - - - - -int slsReceiverTCPIPInterface::restream_stop(){ - ret = OK; - memset(mess, 0, sizeof(mess)); - - // execute action - // only a set, not a get -#ifdef SLS_RECEIVER_UDP_FUNCTIONS - if (receiverBase == NULL) - invalidReceiverObject(); - else if (mySock->differentClients && lockStatus) - receiverlocked(); - else if (receiverBase->getStatus() != IDLE) - receiverNotIdle(); - else if (receiverBase->getDataStreamEnable() == false) { - ret = FAIL; - sprintf(mess,"Could not restream stop packet as data Streaming is disabled.\n"); - FILE_LOG(logERROR) << mess; - } else { - ret = receiverBase->restreamStop(); - if (ret == FAIL) { - sprintf(mess,"Could not restream stop packet.\n"); - FILE_LOG(logERROR) << mess; - } - } -#endif - - if (ret == OK && mySock->differentClients) - ret = FORCE_UPDATE; - - // send answer - mySock->SendDataOnly(&ret,sizeof(ret)); - if (ret == FAIL) - mySock->SendDataOnly(mess,sizeof(mess)); - - // return ok/fail - return ret; -} - - - -int slsReceiverTCPIPInterface::set_additional_json_header() { - ret = OK; - memset(mess, 0, sizeof(mess)); - char arg[MAX_STR_LENGTH]; - memset(arg, 0, sizeof(arg)); - char* retval=NULL; - - // receive arguments - if (mySock->ReceiveDataOnly(arg,MAX_STR_LENGTH) < 0 ) - return printSocketReadError(); - - // execute action -#ifdef SLS_RECEIVER_UDP_FUNCTIONS - if (receiverBase == NULL) - invalidReceiverObject(); - else { - // set - if (mySock->differentClients && lockStatus) - receiverlocked(); - else if (receiverBase->getStatus() != IDLE) - receiverNotIdle(); - else { - receiverBase->setAdditionalJsonHeader(arg); - } - - //get - retval = receiverBase->getAdditionalJsonHeader(); - } -#endif -#ifdef VERYVERBOSE - FILE_LOG(logDEBUG1) << "additional json header:" << retval; -#endif - - if (ret == OK && mySock->differentClients) - ret = FORCE_UPDATE; - - // send answer - mySock->SendDataOnly(&ret,sizeof(ret)); - if (ret == FAIL) - mySock->SendDataOnly(mess,sizeof(mess)); - mySock->SendDataOnly(retval,MAX_STR_LENGTH); - delete[] retval; - - // return ok/fail - return ret; -} - - - -int slsReceiverTCPIPInterface::set_udp_socket_buffer_size() { - ret = OK; - memset(mess, 0, sizeof(mess)); - int index = -1; - int retval = -1; - - // receive arguments - if (mySock->ReceiveDataOnly(&index,sizeof(index)) < 0 ) - return printSocketReadError(); - - // execute action -#ifdef SLS_RECEIVER_UDP_FUNCTIONS - if (receiverBase == NULL) - invalidReceiverObject(); - else { - // set - if(index >= 0) { - if (mySock->differentClients && lockStatus) - receiverlocked(); - else if (receiverBase->getStatus() != IDLE) - receiverNotIdle(); - else { - if (receiverBase->setUDPSocketBufferSize(index) == FAIL) { - ret = FAIL; - strcpy(mess, "Could not create dummy UDP Socket to test buffer size\n"); - FILE_LOG(logERROR) << mess; - } - } - } - //get - retval=receiverBase->getUDPSocketBufferSize(); - if(index >= 0 && ((retval != index) || ((int)receiverBase->getActualUDPSocketBufferSize() != (index*2)))) { - ret = FAIL; - strcpy(mess, "Could not set UDP Socket buffer size (No CAP_NET_ADMIN privileges?)\n"); - FILE_LOG(logERROR) << mess; - } - } -#endif -#ifdef VERYVERBOSE - FILE_LOG(logDEBUG1) << "UDP Socket Buffer Size:" << retval; -#endif - - if (ret == OK && mySock->differentClients) - ret = FORCE_UPDATE; - - // send answer - mySock->SendDataOnly(&ret,sizeof(ret)); - if (ret == FAIL) - mySock->SendDataOnly(mess,sizeof(mess)); - mySock->SendDataOnly(&retval,sizeof(retval)); - - // return ok/fail - return ret; -} - - - -int slsReceiverTCPIPInterface::get_real_udp_socket_buffer_size(){ - ret = OK; - int retval = -1; - - // execute action -#ifdef SLS_RECEIVER_UDP_FUNCTIONS - if (receiverBase == NULL) - invalidReceiverObject(); - else retval = receiverBase->getActualUDPSocketBufferSize(); -#endif - - if (ret == OK && mySock->differentClients) - ret = FORCE_UPDATE; - - // send answer - mySock->SendDataOnly(&ret,sizeof(ret)); - mySock->SendDataOnly(&retval,sizeof(retval)); - - // return ok/fail - return ret; -} - - - -int slsReceiverTCPIPInterface::set_frames_per_file() { - ret = OK; - memset(mess, 0, sizeof(mess)); - int index = -1; - int retval = -1; - - // receive arguments - if (mySock->ReceiveDataOnly(&index,sizeof(index)) < 0 ) - return printSocketReadError(); - - // execute action -#ifdef SLS_RECEIVER_UDP_FUNCTIONS - if (receiverBase == NULL) - invalidReceiverObject(); - else { - // set - if(index >= 0) { - if (mySock->differentClients && lockStatus) - receiverlocked(); - else if (receiverBase->getStatus() != IDLE) - receiverNotIdle(); - else { - receiverBase->setFramesPerFile(index); - } - } - //get - retval=receiverBase->getFramesPerFile(); - if(index >= 0 && retval != index) { - ret = FAIL; - strcpy(mess, "Could not set frames per file\n"); - FILE_LOG(logERROR) << mess; - } - } -#endif -#ifdef VERYVERBOSE - FILE_LOG(logDEBUG1) << "frames per file:" << retval; -#endif - - if (ret == OK && mySock->differentClients) - ret = FORCE_UPDATE; - - // send answer - mySock->SendDataOnly(&ret,sizeof(ret)); - if (ret == FAIL) - mySock->SendDataOnly(mess,sizeof(mess)); - mySock->SendDataOnly(&retval,sizeof(retval)); - - // return ok/fail - return ret; -} - - - - - - -int slsReceiverTCPIPInterface::check_version_compatibility() { - ret = OK; - memset(mess, 0, sizeof(mess)); - int64_t arg = -1; - int64_t retval = -1; - - // receive arguments - if (mySock->ReceiveDataOnly(&arg,sizeof(arg)) < 0 ) - return printSocketReadError(); - - - // execute action - FILE_LOG(logDEBUG1) << "Checking versioning compatibility with value " << arg; - - int64_t client_requiredVersion = arg; - int64_t rx_apiVersion = APIRECEIVER; - int64_t rx_version = getReceiverVersion(); - - // old client - if (rx_apiVersion > client_requiredVersion) { - ret = FAIL; - sprintf(mess,"This client is incompatible.\n" - "Client's receiver API Version: (0x%llx). Receiver API Version: (0x%llx).\n" - "Incompatible, update client!\n", - (long long unsigned int)client_requiredVersion, - (long long unsigned int)rx_apiVersion); - FILE_LOG(logERROR) << mess; - } - - // old software - else if (client_requiredVersion > rx_version) { - ret = FAIL; - sprintf(mess,"This receiver is incompatible.\n" - "Receiver Version: (0x%llx). Client's receiver API Version: (0x%llx).\n" - "Incompatible, update receiver!\n", - (long long unsigned int)rx_version, - (long long unsigned int)client_requiredVersion); - FILE_LOG(logERROR) << mess; - } - else FILE_LOG(logINFO) << "Compatibility with Client: Successful"; - - if (ret == OK && mySock->differentClients) - ret = FORCE_UPDATE; - - // send answer - mySock->SendDataOnly(&ret,sizeof(ret)); - if (ret == FAIL) - mySock->SendDataOnly(mess,sizeof(mess)); - mySock->SendDataOnly(&retval,sizeof(retval)); // sending crap (because of thisReceiver interface) - - // return ok/fail - return ret; -} - - - - -int slsReceiverTCPIPInterface::set_discard_policy() { - ret = OK; - memset(mess, 0, sizeof(mess)); - int index = -1; - int retval = -1; - - // receive arguments - if (mySock->ReceiveDataOnly(&index,sizeof(index)) < 0 ) - return printSocketReadError(); - - // execute action -#ifdef SLS_RECEIVER_UDP_FUNCTIONS - if (receiverBase == NULL) - invalidReceiverObject(); - else { - // set - if(index >= 0) { - if (mySock->differentClients && lockStatus) - receiverlocked(); - else if (receiverBase->getStatus() != IDLE) - receiverNotIdle(); - else { - receiverBase->setFrameDiscardPolicy((frameDiscardPolicy)index); - } - } - //get - retval=receiverBase->getFrameDiscardPolicy(); - if(index >= 0 && retval != index) { - ret = FAIL; - strcpy(mess, "Could not set frame discard policy\n"); - FILE_LOG(logERROR) << mess; - } - } -#endif -#ifdef VERYVERBOSE - FILE_LOG(logDEBUG1) << "frame discard policy:" << retval; -#endif - - if (ret == OK && mySock->differentClients) - ret = FORCE_UPDATE; - - // send answer - mySock->SendDataOnly(&ret,sizeof(ret)); - if (ret == FAIL) - mySock->SendDataOnly(mess,sizeof(mess)); - mySock->SendDataOnly(&retval,sizeof(retval)); - - // return ok/fail - return ret; -} - - - - -int slsReceiverTCPIPInterface::set_padding_enable() { - ret = OK; - memset(mess, 0, sizeof(mess)); - int index = -1; - int retval = -1; - - // receive arguments - if (mySock->ReceiveDataOnly(&index,sizeof(index)) < 0 ) - return printSocketReadError(); - - // execute action -#ifdef SLS_RECEIVER_UDP_FUNCTIONS - if (receiverBase == NULL) - invalidReceiverObject(); - else { - // set - if(index >= 0) { - if (mySock->differentClients && lockStatus) - receiverlocked(); - else if (receiverBase->getStatus() != IDLE) - receiverNotIdle(); - else { - index = (index == 0) ? 0 : 1; - receiverBase->setFramePaddingEnable(index); - } - } - //get - retval=(int)receiverBase->getFramePaddingEnable(); - if(index >= 0 && retval != index) { - ret = FAIL; - strcpy(mess, "Could not set frame padding enable\n"); - FILE_LOG(logERROR) << mess; - } - } -#endif -#ifdef VERYVERBOSE - FILE_LOG(logDEBUG1) << "Frame Padding Enable:" << retval; -#endif - - if (ret == OK && mySock->differentClients) - ret = FORCE_UPDATE; - - // send answer - mySock->SendDataOnly(&ret,sizeof(ret)); - if (ret == FAIL) - mySock->SendDataOnly(mess,sizeof(mess)); - mySock->SendDataOnly(&retval,sizeof(retval)); - - // return ok/fail - return ret; -} - - - - -int slsReceiverTCPIPInterface::set_deactivated_receiver_padding_enable() { - ret = OK; - memset(mess, 0, sizeof(mess)); - int enable = -1; - int retval = -1; - - // receive arguments - if (mySock->ReceiveDataOnly(&enable,sizeof(enable)) < 0 ) - return printSocketReadError(); - - if (myDetectorType != EIGER) - functionNotImplemented(); - - // execute action -#ifdef SLS_RECEIVER_UDP_FUNCTIONS - else { - if (receiverBase == NULL) - invalidReceiverObject(); - else { - // set - if(enable >= 0) { - if (mySock->differentClients && lockStatus) - receiverlocked(); - else if (receiverBase->getStatus() != IDLE) - receiverNotIdle(); - else { - receiverBase->setDeactivatedPadding(enable > 0 ? true : false); - } - } - //get - retval = (int)receiverBase->getDeactivatedPadding(); - if(enable >= 0 && retval != enable){ - ret = FAIL; - sprintf(mess,"Could not set deactivated padding enable to %d, returned %d\n",enable,retval); - FILE_LOG(logERROR) << mess; - } - } - } -#endif -#ifdef VERYVERBOSE - FILE_LOG(logDEBUG1) << "Deactivated Padding Enable: " << retval; -#endif - - if (ret == OK && mySock->differentClients) - ret = FORCE_UPDATE; - - // send answer - mySock->SendDataOnly(&ret,sizeof(ret)); - if (ret == FAIL) - mySock->SendDataOnly(mess,sizeof(mess)); - mySock->SendDataOnly(&retval,sizeof(retval)); - - // return ok/fail - return ret; -} diff --git a/slsReceiverSoftware/src/slsReceiverUsers.cpp b/slsReceiverSoftware/src/slsReceiverUsers.cpp deleted file mode 100644 index f65751dbb..000000000 --- a/slsReceiverSoftware/src/slsReceiverUsers.cpp +++ /dev/null @@ -1,47 +0,0 @@ -#include "slsReceiverUsers.h" -#include "slsReceiver.h" - -slsReceiverUsers::slsReceiverUsers(int argc, char *argv[], int &success) { - // catch the exception here to limit it to within the library (for current version) - try { - slsReceiver* r = new slsReceiver(argc, argv); - receiver = r; - success = slsReceiverDefs::OK; - } catch (...) { - success = slsReceiverDefs::FAIL; - } -} - -slsReceiverUsers::~slsReceiverUsers() { - delete receiver; -} - -int slsReceiverUsers::start() { - return receiver->start(); -} - -void slsReceiverUsers::stop() { - receiver->stop(); -} - -int64_t slsReceiverUsers::getReceiverVersion(){ - return receiver->getReceiverVersion(); -} - -void slsReceiverUsers::registerCallBackStartAcquisition(int (*func)(char*, char*, uint64_t, uint32_t, void*),void *arg){ - receiver->registerCallBackStartAcquisition(func,arg); -} - -void slsReceiverUsers::registerCallBackAcquisitionFinished(void (*func)(uint64_t, void*),void *arg){ - receiver->registerCallBackAcquisitionFinished(func,arg); -} - -void slsReceiverUsers::registerCallBackRawDataReady(void (*func)(char* header, - char* datapointer, uint32_t datasize, void*), void *arg){ - receiver->registerCallBackRawDataReady(func,arg); -} - -void slsReceiverUsers::registerCallBackRawDataModifyReady(void (*func)(char* header, - char* datapointer, uint32_t& revDatasize, void*), void *arg){ - receiver->registerCallBackRawDataModifyReady(func,arg); -} diff --git a/slsReceiverSoftware/src/utilities.cpp b/slsReceiverSoftware/src/utilities.cpp deleted file mode 100644 index 60215c96b..000000000 --- a/slsReceiverSoftware/src/utilities.cpp +++ /dev/null @@ -1,80 +0,0 @@ -#include -#include -#include -#include -#include -#include - -#include - -#include "utilities.h" -#include "logger.h" - - - - -int read_config_file(std::string fname, int *tcpip_port_no, std::map * configuration_map ){ - - std::ifstream infile; - std::string sLine,sargname, sargvalue; - int iline = 0; - int success = slsReceiverDefs::OK; - - - FILE_LOG(logINFO) << "config file name " << fname; - try { - infile.open(fname.c_str(), std::ios_base::in); - } catch(...) { - FILE_LOG(logERROR) << "Could not open configuration file " << fname ; - success = slsReceiverDefs::FAIL; - } - - if (success == slsReceiverDefs::OK && infile.is_open()) { - while(infile.good()){ - getline(infile,sLine); - iline++; - - //VERBOSE_PRINT(sLine); - - if(sLine.find('#') != std::string::npos) - continue; - - else if(sLine.length()<2) - continue; - - else{ - std::istringstream sstr(sLine); - - //parameter name - if(sstr.good()){ - sstr >> sargname; - - if (! sstr.good()) - continue; - - sstr >> sargvalue; - (*configuration_map)[sargname] = sargvalue; - } - //tcp port - if(sargname=="rx_tcpport"){ - if(sstr.good()) { - sstr >> sargname; - if(sscanf(sargname.c_str(),"%d",tcpip_port_no)) - cprintf(RESET, "dataport: %d\n" , *tcpip_port_no); - else{ - cprintf(RED, "could not decode port in config file. Exiting.\n"); - success = slsReceiverDefs::FAIL; - } - } - } - } - } - infile.close(); - } - - return success; -} - - - - diff --git a/slsReceiverSoftware/updateAPIVersion.sh b/slsReceiverSoftware/updateAPIVersion.sh deleted file mode 100755 index 389b2929e..000000000 --- a/slsReceiverSoftware/updateAPIVersion.sh +++ /dev/null @@ -1,7 +0,0 @@ -SRCFILE=include/gitInfoReceiver.h -DSTFILE=include/versionAPI.h - -SRCPATTERN=GITDATE -DSTPATTERN=APIRECEIVER - -awk -v a="$SRCFILE" -v b="$DSTFILE" -v c="$SRCPATTERN" -v d="$DSTPATTERN" 'FNR==NR&&$2==c{x=$3} NR!=FNR{if($2==d){$3="0x"substr(x,5)}print > b}' $SRCFILE $DSTFILE \ No newline at end of file diff --git a/slsReceiverSoftware/updateGitVersion.sh b/slsReceiverSoftware/updateGitVersion.sh deleted file mode 100755 index 83b9a65bb..000000000 --- a/slsReceiverSoftware/updateGitVersion.sh +++ /dev/null @@ -1,28 +0,0 @@ -MAINDIR=slsDetectorsPackage -SPECDIR=slsReceiverSoftware -TMPFILE=include/gitInfoReceiverTmp.h -INCLFILE=include/gitInfoReceiver.h -WD=$PWD - -#evaluate the variables -EVALFILE=../evalVersionVariables.sh -source $EVALFILE - -#get modified date -#RDATE1='git log --pretty=format:"%ci" -1' -RDATE1="find . -type f -exec stat --format '%Y :%y %n' '{}' \; | sort -nr | cut -d: -f2- | egrep -v 'gitInfo|build|.git|updateGitVersion' | head -n 1" -RDATE=`eval $RDATE1` -NEWDATE=$(sed "s/-//g" <<< $RDATE | awk '{print $1;}') -NEWDATE=${NEWDATE/#/0x} - -#get old date from INCLFILE -OLDDATE=$(more $INCLFILE | grep '#define GITDATE' | awk '{print $3}') - -#update INCLFILE if changes -if [ "$OLDDATE" != "$NEWDATE" ]; then - echo Path: ${MAINDIR}/${SPECDIR} $'\n'URL: ${GITREPO} $'\n'Repository Root: ${GITREPO} $'\n'Repsitory UUID: ${REPUID} $'\n'Revision: ${FOLDERREV} $'\n'Branch: ${BRANCH} $'\n'Last Changed Author: ${AUTH1}_${AUTH2} $'\n'Last Changed Rev: ${REV} $'\n'Last Changed Date: ${RDATE} > gitInfo.txt - cd .. - ./genVersionHeader.sh $SPECDIR/gitInfo.txt $SPECDIR/$TMPFILE $SPECDIR/$INCLFILE - cd $WD -fi -